mbostock
This example demonstrates how to use d3.geoIdentity to clip a polygon to an extent while rendering. You can save the resulting clipped polygon using d3.geoProject.
https://d3js.org/d3.v4.min.js
https://d3js.org/topojson.v2.min.js