index.js 714 B

12345678910111213141516171819202122232425
  1. // index.ts
  2. import { coordEach } from "@turf/meta";
  3. import { isObject } from "@turf/helpers";
  4. import { clone } from "@turf/clone";
  5. function flip(geojson, options) {
  6. var _a;
  7. options = options || {};
  8. if (!isObject(options)) throw new Error("options is invalid");
  9. const mutate = (_a = options.mutate) != null ? _a : false;
  10. if (!geojson) throw new Error("geojson is required");
  11. if (mutate === false || mutate === void 0) geojson = clone(geojson);
  12. coordEach(geojson, function(coord) {
  13. var x = coord[0];
  14. var y = coord[1];
  15. coord[0] = y;
  16. coord[1] = x;
  17. });
  18. return geojson;
  19. }
  20. var turf_flip_default = flip;
  21. export {
  22. turf_flip_default as default,
  23. flip
  24. };
  25. //# sourceMappingURL=index.js.map