@turf/flip
Advanced tools
Comparing version 6.2.0-alpha.2 to 6.2.0-alpha.3
@@ -22,22 +22,22 @@ import { coordEach } from '@turf/meta'; | ||
function flip(geojson, options) { | ||
// Optional parameters | ||
options = options || {}; | ||
if (!isObject(options)) throw new Error('options is invalid'); | ||
var mutate = options.mutate; | ||
// Optional parameters | ||
options = options || {}; | ||
if (!isObject(options)) throw new Error("options is invalid"); | ||
var mutate = options.mutate; | ||
if (!geojson) throw new Error('geojson is required'); | ||
// ensure that we don't modify features in-place and changes to the | ||
// output do not change the previous feature, including changes to nested | ||
// properties. | ||
if (mutate === false || mutate === undefined) geojson = clone(geojson); | ||
if (!geojson) throw new Error("geojson is required"); | ||
// ensure that we don't modify features in-place and changes to the | ||
// output do not change the previous feature, including changes to nested | ||
// properties. | ||
if (mutate === false || mutate === undefined) geojson = clone(geojson); | ||
coordEach(geojson, function (coord) { | ||
var x = coord[0]; | ||
var y = coord[1]; | ||
coord[0] = y; | ||
coord[1] = x; | ||
}); | ||
return geojson; | ||
coordEach(geojson, function (coord) { | ||
var x = coord[0]; | ||
var y = coord[1]; | ||
coord[0] = y; | ||
coord[1] = x; | ||
}); | ||
return geojson; | ||
} | ||
export default flip; |
@@ -26,23 +26,22 @@ 'use strict'; | ||
function flip(geojson, options) { | ||
// Optional parameters | ||
options = options || {}; | ||
if (!helpers.isObject(options)) throw new Error('options is invalid'); | ||
var mutate = options.mutate; | ||
// Optional parameters | ||
options = options || {}; | ||
if (!helpers.isObject(options)) throw new Error("options is invalid"); | ||
var mutate = options.mutate; | ||
if (!geojson) throw new Error('geojson is required'); | ||
// ensure that we don't modify features in-place and changes to the | ||
// output do not change the previous feature, including changes to nested | ||
// properties. | ||
if (mutate === false || mutate === undefined) geojson = clone(geojson); | ||
if (!geojson) throw new Error("geojson is required"); | ||
// ensure that we don't modify features in-place and changes to the | ||
// output do not change the previous feature, including changes to nested | ||
// properties. | ||
if (mutate === false || mutate === undefined) geojson = clone(geojson); | ||
meta.coordEach(geojson, function (coord) { | ||
var x = coord[0]; | ||
var y = coord[1]; | ||
coord[0] = y; | ||
coord[1] = x; | ||
}); | ||
return geojson; | ||
meta.coordEach(geojson, function (coord) { | ||
var x = coord[0]; | ||
var y = coord[1]; | ||
coord[0] = y; | ||
coord[1] = x; | ||
}); | ||
return geojson; | ||
} | ||
module.exports = flip; | ||
module.exports.default = flip; |
@@ -1,8 +0,8 @@ | ||
import { AllGeoJSON } from '@turf/helpers' | ||
import { AllGeoJSON } from "@turf/helpers"; | ||
export default function flip<T extends AllGeoJSON>( | ||
geojson: T, | ||
options?: { | ||
mutate?: boolean | ||
} | ||
): T | ||
geojson: T, | ||
options?: { | ||
mutate?: boolean; | ||
} | ||
): T; |
{ | ||
"name": "@turf/flip", | ||
"version": "6.2.0-alpha.2", | ||
"version": "6.2.0-alpha.3", | ||
"description": "turf flip module", | ||
@@ -26,2 +26,6 @@ "author": "Turf Authors", | ||
"module": "dist/es/index.js", | ||
"exports": { | ||
"import": "./dist/es/index.js", | ||
"require": "./dist/js/index.js" | ||
}, | ||
"types": "index.d.ts", | ||
@@ -34,10 +38,9 @@ "sideEffects": false, | ||
"scripts": { | ||
"bench": "npm-run-all prepare bench:run", | ||
"bench:run": "node bench.js", | ||
"bench": "node -r esm bench.js", | ||
"build": "rollup -c ../../rollup.config.js && echo '{\"type\":\"module\"}' > dist/es/package.json", | ||
"docs": "node ../../scripts/generate-readmes", | ||
"posttest": "node -r esm ../../scripts/validate-es5-dependencies.js", | ||
"prepare": "rollup -c ../../rollup.config.js", | ||
"test": "npm-run-all prepare test:*", | ||
"test": "npm-run-all test:*", | ||
"test:tape": "node -r esm test.js", | ||
"test:types": "tsc --noEmit types.ts" | ||
"test:types": "tsc --esModuleInterop --noEmit types.ts" | ||
}, | ||
@@ -53,7 +56,7 @@ "devDependencies": { | ||
"dependencies": { | ||
"@turf/clone": "^6.2.0-alpha.2", | ||
"@turf/helpers": "^6.2.0-alpha.2", | ||
"@turf/meta": "^6.2.0-alpha.2" | ||
"@turf/clone": "^6.2.0-alpha.3", | ||
"@turf/helpers": "^6.2.0-alpha.3", | ||
"@turf/meta": "^6.2.0-alpha.3" | ||
}, | ||
"gitHead": "23d5cb91d77e0c1e2e903a2252f525797f1d0d09" | ||
"gitHead": "dce9edfc705352e8cb9e0083c9330ba0e8d77409" | ||
} |
8655
8
123
Updated@turf/clone@^6.2.0-alpha.3
Updated@turf/helpers@^6.2.0-alpha.3
Updated@turf/meta@^6.2.0-alpha.3