@turf/sector 7.2.0 → 7.3.1

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
@@ -15,7 +15,7 @@ between (clockwise) bearing1 and bearing2; 0 bearing is North of center point, p
15
15
  * `bearing2` **[number][3]** angle, in decimal degrees, of the second radius of the sector
16
16
  * `options` **[Object][4]** Optional parameters (optional, default `{}`)
17
17
 
18
- * `options.units` **[string][5]** miles, kilometers, degrees, or radians (optional, default `'kilometers'`)
18
+ * `options.units` **Units** Supports all valid Turf [Units][5] (optional, default `'kilometers'`)
19
19
  * `options.steps` **[number][3]** number of steps (optional, default `64`)
20
20
  * `options.properties` **Properties** Translate properties to Feature Polygon (optional, default `{}`)
21
21
 
@@ -43,7 +43,7 @@ Returns **[Feature][6]<[Polygon][7]>** sector polygon
43
43
 
44
44
  [4]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/Object
45
45
 
46
- [5]: https://developer.mozilla.org/docs/Web/JavaScript/Reference/Global_Objects/String
46
+ [5]: https://turfjs.org/docs/api/types/Units
47
47
 
48
48
  [6]: https://tools.ietf.org/html/rfc7946#section-3.2
49
49
 
@@ -34,9 +34,9 @@ function convertAngleTo360(alpha) {
34
34
  }
35
35
  return beta;
36
36
  }
37
- var turf_sector_default = sector;
37
+ var index_default = sector;
38
38
 
39
39
 
40
40
 
41
- exports.default = turf_sector_default; exports.sector = sector;
41
+ exports.default = index_default; exports.sector = sector;
42
42
  //# sourceMappingURL=index.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/home/runner/work/turf/turf/packages/turf-sector/dist/cjs/index.cjs","../../index.ts"],"names":[],"mappings":"AAAA;ACCA,sCAAuB;AACvB,yCAAwB;AACxB,kCAA0B;AAC1B,wCAAgD;AAChD,4CAA0B;AA2B1B,SAAS,MAAA,CACP,MAAA,EACA,MAAA,EACA,QAAA,EACA,QAAA,EACA,QAAA,EAII,CAAC,CAAA,EACa;AA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A,WAAA,CAAY,CAAC,CAAA,CAAE,IAAA,CAAK,MAAM,CAAA;AAE1B,EAAA,OAAO,8BAAA,WAAQ,EAAa,UAAU,CAAA;AACxC;AAUA,SAAS,iBAAA,CAAkB,KAAA,EAAe;AACxC,EAAA,IAAI,KAAA,EAAO,MAAA,EAAQ,GAAA;AACnB,EAAA,GAAA,CAAI,KAAA,EAAO,CAAA,EAAG;AACZ,IAAA,KAAA,GAAQ,GAAA;AAAA,EACV;AACA,EAAA,OAAO,IAAA;AACT;AAGA,IAAO,oBAAA,EAAQ,MAAA;ADpDf;AACE;AACA;AACF,+DAAC","file":"/home/runner/work/turf/turf/packages/turf-sector/dist/cjs/index.cjs","sourcesContent":[null,"import { Feature, Polygon, GeoJsonProperties } from \"geojson\";\nimport { circle } from \"@turf/circle\";\nimport { lineArc } from \"@turf/line-arc\";\nimport { coordEach } from \"@turf/meta\";\nimport { Units, Coord, isObject, polygon } from \"@turf/helpers\";\nimport { getCoords } from \"@turf/invariant\";\n\n/**\n * Creates a circular sector of a circle of given radius and center {@link Point},\n * between (clockwise) bearing1 and bearing2; 0 bearing is North of center point, positive clockwise.\n *\n * @function\n * @param {Coord} center center point\n * @param {number} radius radius of the circle\n * @param {number} bearing1 angle, in decimal degrees, of the first radius of the sector\n * @param {number} bearing2 angle, in decimal degrees, of the second radius of the sector\n * @param {Object} [options={}] Optional parameters\n * @param {string} [options.units='kilometers'] miles, kilometers, degrees, or radians\n * @param {number} [options.steps=64] number of steps\n * @param {Properties} [options.properties={}] Translate properties to Feature Polygon\n * @returns {Feature<Polygon>} sector polygon\n * @example\n * var center = turf.point([-75, 40]);\n * var radius = 5;\n * var bearing1 = 25;\n * var bearing2 = 45;\n *\n * var sector = turf.sector(center, radius, bearing1, bearing2);\n *\n * //addToMap\n * var addToMap = [center, sector];\n */\nfunction sector(\n center: Coord,\n radius: number,\n bearing1: number,\n bearing2: number,\n options: {\n steps?: number;\n units?: Units;\n properties?: GeoJsonProperties;\n } = {}\n): Feature<Polygon> {\n // Optional parameters\n options = options || {};\n if (!isObject(options)) throw new Error(\"options is invalid\");\n // Most options only for passing through to circle()\n const properties = options.properties;\n\n // validation\n if (!center) throw new Error(\"center is required\");\n if (bearing1 === undefined || bearing1 === null)\n throw new Error(\"bearing1 is required\");\n if (bearing2 === undefined || bearing2 === null)\n throw new Error(\"bearing2 is required\");\n if (!radius) throw new Error(\"radius is required\");\n if (typeof options !== \"object\") throw new Error(\"options must be an object\");\n\n if (convertAngleTo360(bearing1) === convertAngleTo360(bearing2)) {\n return circle(center, radius, options);\n }\n const coords = getCoords(center);\n const arc = lineArc(center, radius, bearing1, bearing2, options);\n const sliceCoords = [[coords]];\n coordEach(arc, function (currentCoords) {\n sliceCoords[0].push(currentCoords);\n });\n sliceCoords[0].push(coords);\n\n return polygon(sliceCoords, properties);\n}\n\n/**\n * Takes any angle in degrees\n * and returns a valid angle between 0-360 degrees\n *\n * @private\n * @param {number} alpha angle between -180-180 degrees\n * @returns {number} angle between 0-360 degrees\n */\nfunction convertAngleTo360(alpha: number) {\n let beta = alpha % 360;\n if (beta < 0) {\n beta += 360;\n }\n return beta;\n}\n\nexport { sector };\nexport default sector;\n"]}
1
+ {"version":3,"sources":["/home/runner/work/turf/turf/packages/turf-sector/dist/cjs/index.cjs","../../index.ts"],"names":[],"mappings":"AAAA;ACCA,sCAAuB;AACvB,yCAAwB;AACxB,kCAA0B;AAC1B,wCAAgD;AAChD,4CAA0B;AA2B1B,SAAS,MAAA,CACP,MAAA,EACA,MAAA,EACA,QAAA,EACA,QAAA,EACA,QAAA,EAII,CAAC,CAAA,EACa;AAElB,EAAA,QAAA,EAAU,QAAA,GAAW,CAAC,CAAA;AACtB,EAAA,GAAA,CAAI,CAAC,+BAAA,OAAgB,CAAA,EAAG,MAAM,IAAI,KAAA,CAAM,oBAAoB,CAAA;AAE5D,EAAA,MAAM,WAAA,EAAa,OAAA,CAAQ,UAAA;AAG3B,EAAA,GAAA,CAAI,CAAC,MAAA,EAAQ,M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,CAAA,EAAG;AACZ,IAAA,KAAA,GAAQ,GAAA;AAAA,EACV;AACA,EAAA,OAAO,IAAA;AACT;AAGA,IAAO,cAAA,EAAQ,MAAA;ADpDf;AACE;AACA;AACF,yDAAC","file":"/home/runner/work/turf/turf/packages/turf-sector/dist/cjs/index.cjs","sourcesContent":[null,"import { Feature, Polygon, GeoJsonProperties } from \"geojson\";\nimport { circle } from \"@turf/circle\";\nimport { lineArc } from \"@turf/line-arc\";\nimport { coordEach } from \"@turf/meta\";\nimport { Units, Coord, isObject, polygon } from \"@turf/helpers\";\nimport { getCoords } from \"@turf/invariant\";\n\n/**\n * Creates a circular sector of a circle of given radius and center {@link Point},\n * between (clockwise) bearing1 and bearing2; 0 bearing is North of center point, positive clockwise.\n *\n * @function\n * @param {Coord} center center point\n * @param {number} radius radius of the circle\n * @param {number} bearing1 angle, in decimal degrees, of the first radius of the sector\n * @param {number} bearing2 angle, in decimal degrees, of the second radius of the sector\n * @param {Object} [options={}] Optional parameters\n * @param {Units} [options.units='kilometers'] Supports all valid Turf {@link https://turfjs.org/docs/api/types/Units Units}\n * @param {number} [options.steps=64] number of steps\n * @param {Properties} [options.properties={}] Translate properties to Feature Polygon\n * @returns {Feature<Polygon>} sector polygon\n * @example\n * var center = turf.point([-75, 40]);\n * var radius = 5;\n * var bearing1 = 25;\n * var bearing2 = 45;\n *\n * var sector = turf.sector(center, radius, bearing1, bearing2);\n *\n * //addToMap\n * var addToMap = [center, sector];\n */\nfunction sector(\n center: Coord,\n radius: number,\n bearing1: number,\n bearing2: number,\n options: {\n steps?: number;\n units?: Units;\n properties?: GeoJsonProperties;\n } = {}\n): Feature<Polygon> {\n // Optional parameters\n options = options || {};\n if (!isObject(options)) throw new Error(\"options is invalid\");\n // Most options only for passing through to circle()\n const properties = options.properties;\n\n // validation\n if (!center) throw new Error(\"center is required\");\n if (bearing1 === undefined || bearing1 === null)\n throw new Error(\"bearing1 is required\");\n if (bearing2 === undefined || bearing2 === null)\n throw new Error(\"bearing2 is required\");\n if (!radius) throw new Error(\"radius is required\");\n if (typeof options !== \"object\") throw new Error(\"options must be an object\");\n\n if (convertAngleTo360(bearing1) === convertAngleTo360(bearing2)) {\n return circle(center, radius, options);\n }\n const coords = getCoords(center);\n const arc = lineArc(center, radius, bearing1, bearing2, options);\n const sliceCoords = [[coords]];\n coordEach(arc, function (currentCoords) {\n sliceCoords[0].push(currentCoords);\n });\n sliceCoords[0].push(coords);\n\n return polygon(sliceCoords, properties);\n}\n\n/**\n * Takes any angle in degrees\n * and returns a valid angle between 0-360 degrees\n *\n * @private\n * @param {number} alpha angle between -180-180 degrees\n * @returns {number} angle between 0-360 degrees\n */\nfunction convertAngleTo360(alpha: number) {\n let beta = alpha % 360;\n if (beta < 0) {\n beta += 360;\n }\n return beta;\n}\n\nexport { sector };\nexport default sector;\n"]}
@@ -11,7 +11,7 @@ import { Coord, Units } from '@turf/helpers';
11
11
  * @param {number} bearing1 angle, in decimal degrees, of the first radius of the sector
12
12
  * @param {number} bearing2 angle, in decimal degrees, of the second radius of the sector
13
13
  * @param {Object} [options={}] Optional parameters
14
- * @param {string} [options.units='kilometers'] miles, kilometers, degrees, or radians
14
+ * @param {Units} [options.units='kilometers'] Supports all valid Turf {@link https://turfjs.org/docs/api/types/Units Units}
15
15
  * @param {number} [options.steps=64] number of steps
16
16
  * @param {Properties} [options.properties={}] Translate properties to Feature Polygon
17
17
  * @returns {Feature<Polygon>} sector polygon
@@ -11,7 +11,7 @@ import { Coord, Units } from '@turf/helpers';
11
11
  * @param {number} bearing1 angle, in decimal degrees, of the first radius of the sector
12
12
  * @param {number} bearing2 angle, in decimal degrees, of the second radius of the sector
13
13
  * @param {Object} [options={}] Optional parameters
14
- * @param {string} [options.units='kilometers'] miles, kilometers, degrees, or radians
14
+ * @param {Units} [options.units='kilometers'] Supports all valid Turf {@link https://turfjs.org/docs/api/types/Units Units}
15
15
  * @param {number} [options.steps=64] number of steps
16
16
  * @param {Properties} [options.properties={}] Translate properties to Feature Polygon
17
17
  * @returns {Feature<Polygon>} sector polygon
package/dist/esm/index.js CHANGED
@@ -34,9 +34,9 @@ function convertAngleTo360(alpha) {
34
34
  }
35
35
  return beta;
36
36
  }
37
- var turf_sector_default = sector;
37
+ var index_default = sector;
38
38
  export {
39
- turf_sector_default as default,
39
+ index_default as default,
40
40
  sector
41
41
  };
42
42
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"sources":["../../index.ts"],"sourcesContent":["import { Feature, Polygon, GeoJsonProperties } from \"geojson\";\nimport { circle } from \"@turf/circle\";\nimport { lineArc } from \"@turf/line-arc\";\nimport { coordEach } from \"@turf/meta\";\nimport { Units, Coord, isObject, polygon } from \"@turf/helpers\";\nimport { getCoords } from \"@turf/invariant\";\n\n/**\n * Creates a circular sector of a circle of given radius and center {@link Point},\n * between (clockwise) bearing1 and bearing2; 0 bearing is North of center point, positive clockwise.\n *\n * @function\n * @param {Coord} center center point\n * @param {number} radius radius of the circle\n * @param {number} bearing1 angle, in decimal degrees, of the first radius of the sector\n * @param {number} bearing2 angle, in decimal degrees, of the second radius of the sector\n * @param {Object} [options={}] Optional parameters\n * @param {string} [options.units='kilometers'] miles, kilometers, degrees, or radians\n * @param {number} [options.steps=64] number of steps\n * @param {Properties} [options.properties={}] Translate properties to Feature Polygon\n * @returns {Feature<Polygon>} sector polygon\n * @example\n * var center = turf.point([-75, 40]);\n * var radius = 5;\n * var bearing1 = 25;\n * var bearing2 = 45;\n *\n * var sector = turf.sector(center, radius, bearing1, bearing2);\n *\n * //addToMap\n * var addToMap = [center, sector];\n */\nfunction sector(\n center: Coord,\n radius: number,\n bearing1: number,\n bearing2: number,\n options: {\n steps?: number;\n units?: Units;\n properties?: GeoJsonProperties;\n } = {}\n): Feature<Polygon> {\n // Optional parameters\n options = options || {};\n if (!isObject(options)) throw new Error(\"options is invalid\");\n // Most options only for passing through to circle()\n const properties = options.properties;\n\n // validation\n if (!center) throw new Error(\"center is required\");\n if (bearing1 === undefined || bearing1 === null)\n throw new Error(\"bearing1 is required\");\n if (bearing2 === undefined || bearing2 === null)\n throw new Error(\"bearing2 is required\");\n if (!radius) throw new Error(\"radius is required\");\n if (typeof options !== \"object\") throw new Error(\"options must be an object\");\n\n if (convertAngleTo360(bearing1) === convertAngleTo360(bearing2)) {\n return circle(center, radius, options);\n }\n const coords = getCoords(center);\n const arc = lineArc(center, radius, bearing1, bearing2, options);\n const sliceCoords = [[coords]];\n coordEach(arc, function (currentCoords) {\n sliceCoords[0].push(currentCoords);\n });\n sliceCoords[0].push(coords);\n\n return polygon(sliceCoords, properties);\n}\n\n/**\n * Takes any angle in degrees\n * and returns a valid angle between 0-360 degrees\n *\n * @private\n * @param {number} alpha angle between -180-180 degrees\n * @returns {number} angle between 0-360 degrees\n */\nfunction convertAngleTo360(alpha: number) {\n let beta = alpha % 360;\n if (beta < 0) {\n beta += 360;\n }\n return beta;\n}\n\nexport { sector };\nexport default sector;\n"],"mappings":";AACA,SAAS,cAAc;AACvB,SAAS,eAAe;AACxB,SAAS,iBAAiB;AAC1B,SAAuB,UAAU,eAAe;AAChD,SAAS,iBAAiB;AA2B1B,SAAS,OACP,QACA,QACA,UACA,UACA,UAII,CAAC,GACa;AAElB,YAAU,WAAW,CAAC;AACtB,MAAI,CAAC,SAAS,OAAO,EAAG,OAAM,IAAI,MAAM,oBAAoB;AAE5D,QAAM,aAAa,QAAQ;AAG3B,MAAI,CAAC,OAAQ,OAAM,IAAI,MAAM,oBAAoB;AACjD,MAAI,aAAa,UAAa,aAAa;AACzC,UAAM,IAAI,MAAM,sBAAsB;AACxC,MAAI,aAAa,UAAa,aAAa;AACzC,UAAM,IAAI,MAAM,sBAAsB;AACxC,MAAI,CAAC,OAAQ,OAAM,IAAI,MAAM,oBAAoB;AACjD,MAAI,OAAO,YAAY,SAAU,OAAM,IAAI,MAAM,2BAA2B;AAE5E,MAAI,kBAAkB,QAAQ,MAAM,kBAAkB,QAAQ,GAAG;AAC/D,WAAO,OAAO,QAAQ,QAAQ,OAAO;AAAA,EACvC;AACA,QAAM,SAAS,UAAU,MAAM;AAC/B,QAAM,MAAM,QAAQ,QAAQ,QAAQ,UAAU,UAAU,OAAO;AAC/D,QAAM,cAAc,CAAC,CAAC,MAAM,CAAC;AAC7B,YAAU,KAAK,SAAU,eAAe;AACtC,gBAAY,CAAC,EAAE,KAAK,aAAa;AAAA,EACnC,CAAC;AACD,cAAY,CAAC,EAAE,KAAK,MAAM;AAE1B,SAAO,QAAQ,aAAa,UAAU;AACxC;AAUA,SAAS,kBAAkB,OAAe;AACxC,MAAI,OAAO,QAAQ;AACnB,MAAI,OAAO,GAAG;AACZ,YAAQ;AAAA,EACV;AACA,SAAO;AACT;AAGA,IAAO,sBAAQ;","names":[]}
1
+ {"version":3,"sources":["../../index.ts"],"sourcesContent":["import { Feature, Polygon, GeoJsonProperties } from \"geojson\";\nimport { circle } from \"@turf/circle\";\nimport { lineArc } from \"@turf/line-arc\";\nimport { coordEach } from \"@turf/meta\";\nimport { Units, Coord, isObject, polygon } from \"@turf/helpers\";\nimport { getCoords } from \"@turf/invariant\";\n\n/**\n * Creates a circular sector of a circle of given radius and center {@link Point},\n * between (clockwise) bearing1 and bearing2; 0 bearing is North of center point, positive clockwise.\n *\n * @function\n * @param {Coord} center center point\n * @param {number} radius radius of the circle\n * @param {number} bearing1 angle, in decimal degrees, of the first radius of the sector\n * @param {number} bearing2 angle, in decimal degrees, of the second radius of the sector\n * @param {Object} [options={}] Optional parameters\n * @param {Units} [options.units='kilometers'] Supports all valid Turf {@link https://turfjs.org/docs/api/types/Units Units}\n * @param {number} [options.steps=64] number of steps\n * @param {Properties} [options.properties={}] Translate properties to Feature Polygon\n * @returns {Feature<Polygon>} sector polygon\n * @example\n * var center = turf.point([-75, 40]);\n * var radius = 5;\n * var bearing1 = 25;\n * var bearing2 = 45;\n *\n * var sector = turf.sector(center, radius, bearing1, bearing2);\n *\n * //addToMap\n * var addToMap = [center, sector];\n */\nfunction sector(\n center: Coord,\n radius: number,\n bearing1: number,\n bearing2: number,\n options: {\n steps?: number;\n units?: Units;\n properties?: GeoJsonProperties;\n } = {}\n): Feature<Polygon> {\n // Optional parameters\n options = options || {};\n if (!isObject(options)) throw new Error(\"options is invalid\");\n // Most options only for passing through to circle()\n const properties = options.properties;\n\n // validation\n if (!center) throw new Error(\"center is required\");\n if (bearing1 === undefined || bearing1 === null)\n throw new Error(\"bearing1 is required\");\n if (bearing2 === undefined || bearing2 === null)\n throw new Error(\"bearing2 is required\");\n if (!radius) throw new Error(\"radius is required\");\n if (typeof options !== \"object\") throw new Error(\"options must be an object\");\n\n if (convertAngleTo360(bearing1) === convertAngleTo360(bearing2)) {\n return circle(center, radius, options);\n }\n const coords = getCoords(center);\n const arc = lineArc(center, radius, bearing1, bearing2, options);\n const sliceCoords = [[coords]];\n coordEach(arc, function (currentCoords) {\n sliceCoords[0].push(currentCoords);\n });\n sliceCoords[0].push(coords);\n\n return polygon(sliceCoords, properties);\n}\n\n/**\n * Takes any angle in degrees\n * and returns a valid angle between 0-360 degrees\n *\n * @private\n * @param {number} alpha angle between -180-180 degrees\n * @returns {number} angle between 0-360 degrees\n */\nfunction convertAngleTo360(alpha: number) {\n let beta = alpha % 360;\n if (beta < 0) {\n beta += 360;\n }\n return beta;\n}\n\nexport { sector };\nexport default sector;\n"],"mappings":";AACA,SAAS,cAAc;AACvB,SAAS,eAAe;AACxB,SAAS,iBAAiB;AAC1B,SAAuB,UAAU,eAAe;AAChD,SAAS,iBAAiB;AA2B1B,SAAS,OACP,QACA,QACA,UACA,UACA,UAII,CAAC,GACa;AAElB,YAAU,WAAW,CAAC;AACtB,MAAI,CAAC,SAAS,OAAO,EAAG,OAAM,IAAI,MAAM,oBAAoB;AAE5D,QAAM,aAAa,QAAQ;AAG3B,MAAI,CAAC,OAAQ,OAAM,IAAI,MAAM,oBAAoB;AACjD,MAAI,aAAa,UAAa,aAAa;AACzC,UAAM,IAAI,MAAM,sBAAsB;AACxC,MAAI,aAAa,UAAa,aAAa;AACzC,UAAM,IAAI,MAAM,sBAAsB;AACxC,MAAI,CAAC,OAAQ,OAAM,IAAI,MAAM,oBAAoB;AACjD,MAAI,OAAO,YAAY,SAAU,OAAM,IAAI,MAAM,2BAA2B;AAE5E,MAAI,kBAAkB,QAAQ,MAAM,kBAAkB,QAAQ,GAAG;AAC/D,WAAO,OAAO,QAAQ,QAAQ,OAAO;AAAA,EACvC;AACA,QAAM,SAAS,UAAU,MAAM;AAC/B,QAAM,MAAM,QAAQ,QAAQ,QAAQ,UAAU,UAAU,OAAO;AAC/D,QAAM,cAAc,CAAC,CAAC,MAAM,CAAC;AAC7B,YAAU,KAAK,SAAU,eAAe;AACtC,gBAAY,CAAC,EAAE,KAAK,aAAa;AAAA,EACnC,CAAC;AACD,cAAY,CAAC,EAAE,KAAK,MAAM;AAE1B,SAAO,QAAQ,aAAa,UAAU;AACxC;AAUA,SAAS,kBAAkB,OAAe;AACxC,MAAI,OAAO,QAAQ;AACnB,MAAI,OAAO,GAAG;AACZ,YAAQ;AAAA,EACV;AACA,SAAO;AACT;AAGA,IAAO,gBAAQ;","names":[]}
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@turf/sector",
3
- "version": "7.2.0",
4
- "description": "turf sector module",
3
+ "version": "7.3.1",
4
+ "description": "Creates a circular sector of a circle.",
5
5
  "author": "Turf Authors",
6
6
  "license": "MIT",
7
7
  "bugs": {
@@ -45,31 +45,30 @@
45
45
  "bench": "tsx bench.ts",
46
46
  "build": "tsup --config ../../tsup.config.ts",
47
47
  "docs": "tsx ../../scripts/generate-readmes.ts",
48
- "test": "npm-run-all --npm-path npm test:*",
48
+ "test": "pnpm run /test:.*/",
49
49
  "test:tape": "tsx test.ts",
50
50
  "test:types": "tsc --esModuleInterop --module node16 --moduleResolution node16 --noEmit --strict types.ts"
51
51
  },
52
52
  "devDependencies": {
53
- "@turf/truncate": "^7.2.0",
53
+ "@turf/truncate": "7.3.1",
54
54
  "@types/benchmark": "^2.1.5",
55
- "@types/tape": "^4.13.4",
55
+ "@types/tape": "^5.8.1",
56
56
  "benchmark": "^2.1.4",
57
57
  "load-json-file": "^7.0.1",
58
- "npm-run-all": "^4.1.5",
59
58
  "tape": "^5.9.0",
60
- "tsup": "^8.3.5",
61
- "tsx": "^4.19.2",
62
- "typescript": "^5.5.4",
63
- "write-json-file": "^5.0.0"
59
+ "tsup": "^8.4.0",
60
+ "tsx": "^4.19.4",
61
+ "typescript": "^5.8.3",
62
+ "write-json-file": "^6.0.0"
64
63
  },
65
64
  "dependencies": {
66
- "@turf/circle": "^7.2.0",
67
- "@turf/helpers": "^7.2.0",
68
- "@turf/invariant": "^7.2.0",
69
- "@turf/line-arc": "^7.2.0",
70
- "@turf/meta": "^7.2.0",
65
+ "@turf/circle": "7.3.1",
66
+ "@turf/helpers": "7.3.1",
67
+ "@turf/invariant": "7.3.1",
68
+ "@turf/line-arc": "7.3.1",
69
+ "@turf/meta": "7.3.1",
71
70
  "@types/geojson": "^7946.0.10",
72
71
  "tslib": "^2.8.1"
73
72
  },
74
- "gitHead": "7b0f0374c4668cd569f8904c71e2ae7d941be867"
73
+ "gitHead": "b7f1b4eafb760431e03955499d8eac9489438219"
75
74
  }