Yes, you could write code to do that. Or use the utilities provided in the TopoJSON GitHub and let them do it for you: convert to TopoJSON, simplify, convert back to GeoJSON. They have already written all the code for you.
Yeah, or you could use Geojson and use https://mapshaper.org/
Yeah, or you could use Geojson and use https://mapshaper.org/