@turf/flip 7.0.0-alpha.2 → 7.1.0-alpha.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -32,26 +32,21 @@ Returns **[GeoJSON][1]** a feature or set of features of the same type as `input
32
32
 
33
33
  [3]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Boolean
34
34
 
35
- <!-- This file is automatically generated. Please don't edit it directly:
36
- if you find an error, edit the source file (likely index.js), and re-run
37
- ./scripts/generate-readmes in the turf project. -->
35
+ <!-- This file is automatically generated. Please don't edit it directly. If you find an error, edit the source file of the module in question (likely index.js or index.ts), and re-run "yarn docs" from the root of the turf project. -->
38
36
 
39
37
  ---
40
38
 
41
- This module is part of the [Turfjs project](http://turfjs.org/), an open source
42
- module collection dedicated to geographic algorithms. It is maintained in the
43
- [Turfjs/turf](https://github.com/Turfjs/turf) repository, where you can create
44
- PRs and issues.
39
+ This module is part of the [Turfjs project](https://turfjs.org/), an open source module collection dedicated to geographic algorithms. It is maintained in the [Turfjs/turf](https://github.com/Turfjs/turf) repository, where you can create PRs and issues.
45
40
 
46
41
  ### Installation
47
42
 
48
- Install this module individually:
43
+ Install this single module individually:
49
44
 
50
45
  ```sh
51
46
  $ npm install @turf/flip
52
47
  ```
53
48
 
54
- Or install the Turf module that includes it as a function:
49
+ Or install the all-encompassing @turf/turf module that includes all modules as functions:
55
50
 
56
51
  ```sh
57
52
  $ npm install @turf/turf
@@ -0,0 +1,28 @@
1
+ "use strict";Object.defineProperty(exports, "__esModule", {value: true});// index.ts
2
+ var _meta = require('@turf/meta');
3
+ var _helpers = require('@turf/helpers');
4
+ var _clone = require('@turf/clone');
5
+ function flip(geojson, options) {
6
+ var _a;
7
+ options = options || {};
8
+ if (!_helpers.isObject.call(void 0, options))
9
+ throw new Error("options is invalid");
10
+ const mutate = (_a = options.mutate) != null ? _a : false;
11
+ if (!geojson)
12
+ throw new Error("geojson is required");
13
+ if (mutate === false || mutate === void 0)
14
+ geojson = _clone.clone.call(void 0, geojson);
15
+ _meta.coordEach.call(void 0, geojson, function(coord) {
16
+ var x = coord[0];
17
+ var y = coord[1];
18
+ coord[0] = y;
19
+ coord[1] = x;
20
+ });
21
+ return geojson;
22
+ }
23
+ var turf_flip_default = flip;
24
+
25
+
26
+
27
+ exports.default = turf_flip_default; exports.flip = flip;
28
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../index.ts"],"names":[],"mappings":";AAAA,SAAS,iBAAiB;AAC1B,SAAS,gBAA4B;AACrC,SAAS,aAAa;AAkBtB,SAAS,KACP,SACA,SAGG;AAzBL;AA2BE,YAAU,WAAW,CAAC;AACtB,MAAI,CAAC,SAAS,OAAO;AAAG,UAAM,IAAI,MAAM,oBAAoB;AAC5D,QAAM,UAAS,aAAQ,WAAR,YAAkB;AAEjC,MAAI,CAAC;AAAS,UAAM,IAAI,MAAM,qBAAqB;AAInD,MAAI,WAAW,SAAS,WAAW;AAAW,cAAU,MAAM,OAAO;AAErE,YAAU,SAAS,SAAU,OAAO;AAClC,QAAI,IAAI,MAAM,CAAC;AACf,QAAI,IAAI,MAAM,CAAC;AACf,UAAM,CAAC,IAAI;AACX,UAAM,CAAC,IAAI;AAAA,EACb,CAAC;AACD,SAAO;AACT;AAGA,IAAO,oBAAQ","sourcesContent":["import { coordEach } from \"@turf/meta\";\nimport { isObject, AllGeoJSON } from \"@turf/helpers\";\nimport { clone } from \"@turf/clone\";\n\n/**\n * Takes input features and flips all of their coordinates from `[x, y]` to `[y, x]`.\n *\n * @name flip\n * @param {GeoJSON} geojson input features\n * @param {Object} [options={}] Optional parameters\n * @param {boolean} [options.mutate=false] allows GeoJSON input to be mutated (significant performance increase if true)\n * @returns {GeoJSON} a feature or set of features of the same type as `input` with flipped coordinates\n * @example\n * var serbia = turf.point([20.566406, 43.421008]);\n *\n * var saudiArabia = turf.flip(serbia);\n *\n * //addToMap\n * var addToMap = [serbia, saudiArabia];\n */\nfunction flip<T extends AllGeoJSON>(\n geojson: T,\n options?: {\n mutate?: boolean;\n }\n): T {\n // Optional parameters\n options = options || {};\n if (!isObject(options)) throw new Error(\"options is invalid\");\n const mutate = options.mutate ?? false;\n\n if (!geojson) throw new Error(\"geojson is required\");\n // ensure that we don't modify features in-place and changes to the\n // output do not change the previous feature, including changes to nested\n // properties.\n if (mutate === false || mutate === undefined) geojson = clone(geojson);\n\n coordEach(geojson, function (coord) {\n var x = coord[0];\n var y = coord[1];\n coord[0] = y;\n coord[1] = x;\n });\n return geojson;\n}\n\nexport { flip };\nexport default flip;\n"]}
@@ -0,0 +1,23 @@
1
+ import { AllGeoJSON } from '@turf/helpers';
2
+
3
+ /**
4
+ * Takes input features and flips all of their coordinates from `[x, y]` to `[y, x]`.
5
+ *
6
+ * @name flip
7
+ * @param {GeoJSON} geojson input features
8
+ * @param {Object} [options={}] Optional parameters
9
+ * @param {boolean} [options.mutate=false] allows GeoJSON input to be mutated (significant performance increase if true)
10
+ * @returns {GeoJSON} a feature or set of features of the same type as `input` with flipped coordinates
11
+ * @example
12
+ * var serbia = turf.point([20.566406, 43.421008]);
13
+ *
14
+ * var saudiArabia = turf.flip(serbia);
15
+ *
16
+ * //addToMap
17
+ * var addToMap = [serbia, saudiArabia];
18
+ */
19
+ declare function flip<T extends AllGeoJSON>(geojson: T, options?: {
20
+ mutate?: boolean;
21
+ }): T;
22
+
23
+ export { flip as default, flip };
@@ -0,0 +1,23 @@
1
+ import { AllGeoJSON } from '@turf/helpers';
2
+
3
+ /**
4
+ * Takes input features and flips all of their coordinates from `[x, y]` to `[y, x]`.
5
+ *
6
+ * @name flip
7
+ * @param {GeoJSON} geojson input features
8
+ * @param {Object} [options={}] Optional parameters
9
+ * @param {boolean} [options.mutate=false] allows GeoJSON input to be mutated (significant performance increase if true)
10
+ * @returns {GeoJSON} a feature or set of features of the same type as `input` with flipped coordinates
11
+ * @example
12
+ * var serbia = turf.point([20.566406, 43.421008]);
13
+ *
14
+ * var saudiArabia = turf.flip(serbia);
15
+ *
16
+ * //addToMap
17
+ * var addToMap = [serbia, saudiArabia];
18
+ */
19
+ declare function flip<T extends AllGeoJSON>(geojson: T, options?: {
20
+ mutate?: boolean;
21
+ }): T;
22
+
23
+ export { flip as default, flip };
@@ -0,0 +1,28 @@
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))
9
+ throw new Error("options is invalid");
10
+ const mutate = (_a = options.mutate) != null ? _a : false;
11
+ if (!geojson)
12
+ throw new Error("geojson is required");
13
+ if (mutate === false || mutate === void 0)
14
+ geojson = clone(geojson);
15
+ coordEach(geojson, function(coord) {
16
+ var x = coord[0];
17
+ var y = coord[1];
18
+ coord[0] = y;
19
+ coord[1] = x;
20
+ });
21
+ return geojson;
22
+ }
23
+ var turf_flip_default = flip;
24
+ export {
25
+ turf_flip_default as default,
26
+ flip
27
+ };
28
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../../index.ts"],"sourcesContent":["import { coordEach } from \"@turf/meta\";\nimport { isObject, AllGeoJSON } from \"@turf/helpers\";\nimport { clone } from \"@turf/clone\";\n\n/**\n * Takes input features and flips all of their coordinates from `[x, y]` to `[y, x]`.\n *\n * @name flip\n * @param {GeoJSON} geojson input features\n * @param {Object} [options={}] Optional parameters\n * @param {boolean} [options.mutate=false] allows GeoJSON input to be mutated (significant performance increase if true)\n * @returns {GeoJSON} a feature or set of features of the same type as `input` with flipped coordinates\n * @example\n * var serbia = turf.point([20.566406, 43.421008]);\n *\n * var saudiArabia = turf.flip(serbia);\n *\n * //addToMap\n * var addToMap = [serbia, saudiArabia];\n */\nfunction flip<T extends AllGeoJSON>(\n geojson: T,\n options?: {\n mutate?: boolean;\n }\n): T {\n // Optional parameters\n options = options || {};\n if (!isObject(options)) throw new Error(\"options is invalid\");\n const mutate = options.mutate ?? false;\n\n if (!geojson) throw new Error(\"geojson is required\");\n // ensure that we don't modify features in-place and changes to the\n // output do not change the previous feature, including changes to nested\n // properties.\n if (mutate === false || mutate === undefined) geojson = clone(geojson);\n\n coordEach(geojson, function (coord) {\n var x = coord[0];\n var y = coord[1];\n coord[0] = y;\n coord[1] = x;\n });\n return geojson;\n}\n\nexport { flip };\nexport default flip;\n"],"mappings":";AAAA,SAAS,iBAAiB;AAC1B,SAAS,gBAA4B;AACrC,SAAS,aAAa;AAkBtB,SAAS,KACP,SACA,SAGG;AAzBL;AA2BE,YAAU,WAAW,CAAC;AACtB,MAAI,CAAC,SAAS,OAAO;AAAG,UAAM,IAAI,MAAM,oBAAoB;AAC5D,QAAM,UAAS,aAAQ,WAAR,YAAkB;AAEjC,MAAI,CAAC;AAAS,UAAM,IAAI,MAAM,qBAAqB;AAInD,MAAI,WAAW,SAAS,WAAW;AAAW,cAAU,MAAM,OAAO;AAErE,YAAU,SAAS,SAAU,OAAO;AAClC,QAAI,IAAI,MAAM,CAAC;AACf,QAAI,IAAI,MAAM,CAAC;AACf,UAAM,CAAC,IAAI;AACX,UAAM,CAAC,IAAI;AAAA,EACb,CAAC;AACD,SAAO;AACT;AAGA,IAAO,oBAAQ;","names":[]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@turf/flip",
3
- "version": "7.0.0-alpha.2",
3
+ "version": "7.1.0-alpha.7+0ce6ecca0",
4
4
  "description": "turf flip module",
5
5
  "author": "Turf Authors",
6
6
  "license": "MIT",
@@ -22,43 +22,52 @@
22
22
  "coordinate",
23
23
  "flip"
24
24
  ],
25
- "main": "dist/js/index.js",
26
- "module": "dist/es/index.js",
25
+ "type": "module",
26
+ "main": "dist/cjs/index.cjs",
27
+ "module": "dist/esm/index.js",
28
+ "types": "dist/esm/index.d.ts",
27
29
  "exports": {
28
30
  "./package.json": "./package.json",
29
31
  ".": {
30
- "types": "./index.d.ts",
31
- "import": "./dist/es/index.js",
32
- "require": "./dist/js/index.js"
32
+ "import": {
33
+ "types": "./dist/esm/index.d.ts",
34
+ "default": "./dist/esm/index.js"
35
+ },
36
+ "require": {
37
+ "types": "./dist/cjs/index.d.cts",
38
+ "default": "./dist/cjs/index.cjs"
39
+ }
33
40
  }
34
41
  },
35
- "types": "index.d.ts",
36
42
  "sideEffects": false,
37
43
  "files": [
38
- "dist",
39
- "index.d.ts"
44
+ "dist"
40
45
  ],
41
46
  "scripts": {
42
- "bench": "tsx bench.js",
43
- "build": "rollup -c ../../rollup.config.js && echo '{\"type\":\"module\"}' > dist/es/package.json",
44
- "docs": "tsx ../../scripts/generate-readmes",
45
- "test": "npm-run-all test:*",
46
- "test:tape": "tsx test.js",
47
- "test:types": "tsc --esModuleInterop --noEmit --strict types.ts"
47
+ "bench": "tsx bench.ts",
48
+ "build": "tsup --config ../../tsup.config.ts",
49
+ "docs": "tsx ../../scripts/generate-readmes.ts",
50
+ "test": "npm-run-all --npm-path npm test:*",
51
+ "test:tape": "tsx test.ts",
52
+ "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts"
48
53
  },
49
54
  "devDependencies": {
50
- "benchmark": "*",
51
- "load-json-file": "*",
52
- "npm-run-all": "*",
53
- "rollup": "*",
54
- "tape": "*",
55
- "tsx": "*",
56
- "write-json-file": "*"
55
+ "@types/benchmark": "^2.1.5",
56
+ "@types/tape": "^4.2.32",
57
+ "benchmark": "^2.1.4",
58
+ "load-json-file": "^7.0.1",
59
+ "npm-run-all": "^4.1.5",
60
+ "tape": "^5.7.2",
61
+ "tsup": "^8.0.1",
62
+ "tsx": "^4.6.2",
63
+ "typescript": "^5.2.2",
64
+ "write-json-file": "^5.0.0"
57
65
  },
58
66
  "dependencies": {
59
- "@turf/clone": "^7.0.0-alpha.2",
60
- "@turf/helpers": "^7.0.0-alpha.2",
61
- "@turf/meta": "^7.0.0-alpha.2"
67
+ "@turf/clone": "^7.1.0-alpha.7+0ce6ecca0",
68
+ "@turf/helpers": "^7.1.0-alpha.7+0ce6ecca0",
69
+ "@turf/meta": "^7.1.0-alpha.7+0ce6ecca0",
70
+ "tslib": "^2.6.2"
62
71
  },
63
- "gitHead": "dd35b52725945b4fa29a98d9a550733e06cc222e"
72
+ "gitHead": "0ce6ecca05829690270fec6d6bed2003495fe0ea"
64
73
  }
package/dist/es/index.js DELETED
@@ -1,42 +0,0 @@
1
- import { coordEach } from '@turf/meta';
2
- import { isObject } from '@turf/helpers';
3
- import clone from '@turf/clone';
4
-
5
- /**
6
- * Takes input features and flips all of their coordinates from `[x, y]` to `[y, x]`.
7
- *
8
- * @name flip
9
- * @param {GeoJSON} geojson input features
10
- * @param {Object} [options={}] Optional parameters
11
- * @param {boolean} [options.mutate=false] allows GeoJSON input to be mutated (significant performance increase if true)
12
- * @returns {GeoJSON} a feature or set of features of the same type as `input` with flipped coordinates
13
- * @example
14
- * var serbia = turf.point([20.566406, 43.421008]);
15
- *
16
- * var saudiArabia = turf.flip(serbia);
17
- *
18
- * //addToMap
19
- * var addToMap = [serbia, saudiArabia];
20
- */
21
- function flip(geojson, options) {
22
- // Optional parameters
23
- options = options || {};
24
- if (!isObject(options)) throw new Error("options is invalid");
25
- var mutate = options.mutate;
26
-
27
- if (!geojson) throw new Error("geojson is required");
28
- // ensure that we don't modify features in-place and changes to the
29
- // output do not change the previous feature, including changes to nested
30
- // properties.
31
- if (mutate === false || mutate === undefined) geojson = clone(geojson);
32
-
33
- coordEach(geojson, function (coord) {
34
- var x = coord[0];
35
- var y = coord[1];
36
- coord[0] = y;
37
- coord[1] = x;
38
- });
39
- return geojson;
40
- }
41
-
42
- export default flip;
@@ -1 +0,0 @@
1
- {"type":"module"}
package/dist/js/index.js DELETED
@@ -1,49 +0,0 @@
1
- 'use strict';
2
-
3
- var meta = require('@turf/meta');
4
- var helpers = require('@turf/helpers');
5
- var clone = require('@turf/clone');
6
-
7
- function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'default' in e ? e : { 'default': e }; }
8
-
9
- var clone__default = /*#__PURE__*/_interopDefaultLegacy(clone);
10
-
11
- /**
12
- * Takes input features and flips all of their coordinates from `[x, y]` to `[y, x]`.
13
- *
14
- * @name flip
15
- * @param {GeoJSON} geojson input features
16
- * @param {Object} [options={}] Optional parameters
17
- * @param {boolean} [options.mutate=false] allows GeoJSON input to be mutated (significant performance increase if true)
18
- * @returns {GeoJSON} a feature or set of features of the same type as `input` with flipped coordinates
19
- * @example
20
- * var serbia = turf.point([20.566406, 43.421008]);
21
- *
22
- * var saudiArabia = turf.flip(serbia);
23
- *
24
- * //addToMap
25
- * var addToMap = [serbia, saudiArabia];
26
- */
27
- function flip(geojson, options) {
28
- // Optional parameters
29
- options = options || {};
30
- if (!helpers.isObject(options)) throw new Error("options is invalid");
31
- var mutate = options.mutate;
32
-
33
- if (!geojson) throw new Error("geojson is required");
34
- // ensure that we don't modify features in-place and changes to the
35
- // output do not change the previous feature, including changes to nested
36
- // properties.
37
- if (mutate === false || mutate === undefined) geojson = clone__default['default'](geojson);
38
-
39
- meta.coordEach(geojson, function (coord) {
40
- var x = coord[0];
41
- var y = coord[1];
42
- coord[0] = y;
43
- coord[1] = x;
44
- });
45
- return geojson;
46
- }
47
-
48
- module.exports = flip;
49
- module.exports.default = flip;
package/index.d.ts DELETED
@@ -1,8 +0,0 @@
1
- import { AllGeoJSON } from "@turf/helpers";
2
-
3
- export default function flip<T extends AllGeoJSON>(
4
- geojson: T,
5
- options?: {
6
- mutate?: boolean;
7
- }
8
- ): T;