Open noerw opened 5 years ago
I have an implementation ready, und would provide a pull to turf.
Would this be best added to helpers
or invariant
?
Thanks for the proposal @noerw. I do not think this should be added. Most Turf modules target a specific, substantial geospatial operation. This seems like a useful utility, but would probably be better as a helper function in a downstream application's codebase. I generally avoid features that the language already supports, such as array manipulation. In this case, and if/else would be sufficient for normalizing to a feature collection type.
Maybe I overlooked something, but I'm missing functions for ensuring a specific GeoJSON type. This would make writing processing logic for generic input data much simpler.
Considering that coercing between geometry types is ambiguous or impossible, it might be easier to only implement
T: 'Feature' | 'FeatureCollection'
.