From d83e5801ac9d8bba237501668fa1a86a15a377bd Mon Sep 17 00:00:00 2001 From: James Beard Date: Tue, 5 Dec 2023 19:04:54 +1100 Subject: [PATCH] Convert tests to Typescript, change require to import, and add named exports to modules (#2550) * Converting bench.js and test.js to Typescript. Adding along as a named export as well as the default. * Converting bench.js and test.js to Typescript and ESM import. Adding angle as a named export as well as the default. * Converting bench.js and test.js to Typescript and ESM import. Adding area as a named export as well as the default. * Making turf last-checks a bit more flexible as we will have a mix of JS and TS test files for a while. * Converting bench.js and test.js to Typescript and ESM import, and adding named exports as well as the default export for modules: bbox bboxCliip bboxPolygon bearing bezierSpline booleanClockwise booleanConcave booleanContains booleanCrosses booleanDisjoint booleanEqual booleanIntersect booleanOverlap booleanParallel booleanPointInPolygon booleanPointOnLine booleanTouches booleanValid booleanWithin * Converting bench.js and test.js to Typescript and ESM import for remaining Typescript modules. Also adding named exports in addition to the default export for those same modules. * Proceeding with migrating remaining tests to Typescript. Still a few to do - waiting for PR #2543 to merge first to avoid conflicts. * Converting bench.js and test.js to Typescript and ESM import for some more Typescript modules (postponed until recent PRs merged). Also adding named exports in addition to the default export for those same modules. * Banishing a couple more require() calls from module code. * Retiring custom rollup typescript plugin. Problem it was designed to address probably fixed by a previous typescript upgrade. Removing redundant es5 checking script that hasn't been used for a while as well. --- .monorepolint.config.ts | 30 ++--------- packages/turf-along/{bench.js => bench.ts} | 21 ++++---- packages/turf-along/index.ts | 5 +- packages/turf-along/package.json | 5 +- packages/turf-along/{test.js => test.ts} | 15 +++--- packages/turf-angle/{bench.js => bench.ts} | 6 +-- packages/turf-angle/index.ts | 1 + packages/turf-angle/package.json | 5 +- packages/turf-angle/{test.js => test.ts} | 27 ++++------ packages/turf-area/{bench.js => bench.ts} | 10 ++-- packages/turf-area/index.ts | 7 +-- packages/turf-area/package.json | 5 +- packages/turf-area/{test.js => test.ts} | 12 ++--- .../turf-bbox-clip/{bench.js => bench.ts} | 12 ++--- packages/turf-bbox-clip/index.ts | 5 +- packages/turf-bbox-clip/package.json | 5 +- packages/turf-bbox-clip/{test.js => test.ts} | 16 +++--- .../turf-bbox-polygon/{bench.js => bench.ts} | 6 +-- packages/turf-bbox-polygon/index.ts | 7 +-- packages/turf-bbox-polygon/package.json | 5 +- .../turf-bbox-polygon/{test.js => test.ts} | 4 +- packages/turf-bbox/{bench.js => bench.ts} | 6 +-- packages/turf-bbox/index.ts | 2 +- packages/turf-bbox/package.json | 5 +- packages/turf-bbox/{test.js => test.ts} | 8 +-- packages/turf-bearing/{bench.js => bench.ts} | 4 +- packages/turf-bearing/index.ts | 5 +- packages/turf-bearing/package.json | 5 +- packages/turf-bearing/{test.js => test.ts} | 12 ++--- .../turf-bezier-spline/{bench.js => bench.ts} | 10 ++-- packages/turf-bezier-spline/index.ts | 1 + packages/turf-bezier-spline/package.json | 5 +- .../turf-bezier-spline/{test.js => test.ts} | 14 ++--- .../{bench.js => bench.ts} | 10 ++-- packages/turf-boolean-clockwise/index.ts | 5 +- packages/turf-boolean-clockwise/package.json | 5 +- .../{test.js => test.ts} | 12 ++--- .../{bench.js => bench.ts} | 10 ++-- packages/turf-boolean-concave/index.ts | 5 +- packages/turf-boolean-concave/package.json | 5 +- .../turf-boolean-concave/{test.js => test.ts} | 12 ++--- .../{bench.js => bench.ts} | 12 ++--- packages/turf-boolean-contains/index.ts | 47 +++++++++------- packages/turf-boolean-contains/package.json | 5 +- .../{test.js => test.ts} | 16 +++--- .../{bench.js => bench.ts} | 10 ++-- packages/turf-boolean-crosses/index.ts | 1 + packages/turf-boolean-crosses/package.json | 5 +- .../turf-boolean-crosses/{test.js => test.ts} | 12 ++--- .../{bench.js => bench.ts} | 10 ++-- packages/turf-boolean-disjoint/index.ts | 1 + packages/turf-boolean-disjoint/package.json | 5 +- .../{test.js => test.ts} | 12 ++--- .../turf-boolean-equal/{bench.js => bench.ts} | 10 ++-- packages/turf-boolean-equal/index.ts | 1 + packages/turf-boolean-equal/package.json | 5 +- .../turf-boolean-equal/{test.js => test.ts} | 14 ++--- .../{bench.js => bench.ts} | 10 ++-- packages/turf-boolean-intersects/index.ts | 5 +- packages/turf-boolean-intersects/package.json | 5 +- .../{test.js => test.ts} | 12 ++--- .../{bench.js => bench.ts} | 10 ++-- packages/turf-boolean-overlap/index.ts | 5 +- packages/turf-boolean-overlap/package.json | 5 +- .../turf-boolean-overlap/{test.js => test.ts} | 16 +++--- .../{bench.js => bench.ts} | 10 ++-- packages/turf-boolean-parallel/index.ts | 1 + packages/turf-boolean-parallel/package.json | 5 +- .../{test.js => test.ts} | 12 ++--- .../{bench.js => bench.ts} | 8 +-- .../turf-boolean-point-in-polygon/index.ts | 5 +- .../package.json | 5 +- .../{test.js => test.ts} | 10 ++-- .../{bench.js => bench.ts} | 10 ++-- packages/turf-boolean-point-on-line/index.ts | 1 + .../turf-boolean-point-on-line/package.json | 5 +- .../{test.js => test.ts} | 10 ++-- .../{bench.js => bench.ts} | 10 ++-- packages/turf-boolean-touches/index.ts | 1 + packages/turf-boolean-touches/package.json | 5 +- .../turf-boolean-touches/{test.js => test.ts} | 14 ++--- .../turf-boolean-valid/{bench.js => bench.ts} | 12 ++--- packages/turf-boolean-valid/index.ts | 5 +- packages/turf-boolean-valid/package.json | 5 +- .../turf-boolean-valid/{test.js => test.ts} | 11 ++-- .../{bench.js => bench.ts} | 10 ++-- packages/turf-boolean-within/index.ts | 7 +-- packages/turf-boolean-within/package.json | 5 +- .../turf-boolean-within/{test.js => test.ts} | 14 ++--- packages/turf-buffer/{bench.js => bench.ts} | 2 +- packages/turf-buffer/index.d.ts | 1 + packages/turf-buffer/index.js | 1 + packages/turf-buffer/package.json | 4 +- packages/turf-buffer/{test.js => test.ts} | 2 +- .../turf-center-mean/{bench.js => bench.ts} | 10 ++-- packages/turf-center-mean/index.ts | 1 + packages/turf-center-mean/package.json | 5 +- .../turf-center-mean/{test.js => test.ts} | 20 +++---- .../turf-center-median/{bench.js => bench.ts} | 6 +-- packages/turf-center-median/index.ts | 1 + packages/turf-center-median/package.json | 5 +- .../turf-center-median/{test.js => test.ts} | 22 ++++---- .../{bench.js => bench.ts} | 2 +- packages/turf-center-of-mass/index.ts | 1 + packages/turf-center-of-mass/package.json | 5 +- .../turf-center-of-mass/{test.js => test.ts} | 21 +++----- packages/turf-center/{bench.js => bench.ts} | 10 ++-- packages/turf-center/index.ts | 1 + packages/turf-center/package.json | 5 +- packages/turf-center/{test.js => test.ts} | 20 +++---- packages/turf-centroid/{bench.js => bench.ts} | 10 ++-- packages/turf-centroid/index.ts | 1 + packages/turf-centroid/package.json | 5 +- packages/turf-centroid/{test.js => test.ts} | 16 +++--- packages/turf-circle/{bench.js => bench.ts} | 4 +- packages/turf-circle/index.ts | 1 + packages/turf-circle/package.json | 5 +- packages/turf-circle/{test.js => test.ts} | 18 +++---- .../turf-clean-coords/{bench.js => bench.ts} | 10 ++-- packages/turf-clean-coords/index.ts | 1 + packages/turf-clean-coords/package.json | 5 +- .../turf-clean-coords/{test.js => test.ts} | 18 +++---- packages/turf-clone/{bench.js => bench.ts} | 11 ++-- packages/turf-clone/index.ts | 1 + packages/turf-clone/package.json | 5 +- packages/turf-clone/{test.js => test.ts} | 10 ++-- .../{bench.js => bench.ts} | 10 ++-- packages/turf-clusters-dbscan/index.ts | 5 +- packages/turf-clusters-dbscan/package.json | 5 +- .../turf-clusters-dbscan/{test.js => test.ts} | 24 ++++----- .../{bench.js => bench.ts} | 10 ++-- packages/turf-clusters-kmeans/index.ts | 3 +- packages/turf-clusters-kmeans/package.json | 5 +- .../turf-clusters-kmeans/{test.js => test.ts} | 24 ++++----- packages/turf-clusters/{bench.js => bench.ts} | 8 +-- packages/turf-clusters/index.ts | 28 ++++++---- packages/turf-clusters/package.json | 5 +- packages/turf-clusters/{test.js => test.ts} | 8 +-- packages/turf-collect/{bench.js => bench.ts} | 6 +-- packages/turf-collect/index.ts | 1 + packages/turf-collect/package.json | 5 +- packages/turf-collect/{test.js => test.ts} | 6 +-- packages/turf-combine/{bench.js => bench.ts} | 11 ++-- packages/turf-combine/index.ts | 1 + packages/turf-combine/package.json | 5 +- packages/turf-combine/{test.js => test.ts} | 8 +-- packages/turf-concave/{bench.js => bench.ts} | 10 ++-- packages/turf-concave/index.ts | 1 + packages/turf-concave/package.json | 5 +- packages/turf-concave/{test.js => test.ts} | 16 +++--- packages/turf-convex/{bench.js => bench.ts} | 10 ++-- packages/turf-convex/index.ts | 5 +- packages/turf-convex/package.json | 5 +- packages/turf-convex/{test.js => test.ts} | 14 ++--- .../turf-destination/{bench.js => bench.ts} | 4 +- packages/turf-destination/index.ts | 7 +-- packages/turf-destination/package.json | 5 +- .../turf-destination/{test.js => test.ts} | 18 +++---- .../turf-difference/{bench.js => bench.ts} | 10 ++-- packages/turf-difference/index.ts | 1 + packages/turf-difference/package.json | 5 +- packages/turf-difference/{test.js => test.ts} | 14 ++--- .../{bench.js => bench.ts} | 10 ++-- packages/turf-directional-mean/index.ts | 7 ++- packages/turf-directional-mean/package.json | 5 +- .../{test.js => test.ts} | 10 ++-- packages/turf-dissolve/{bench.js => bench.ts} | 2 +- packages/turf-dissolve/index.ts | 3 +- packages/turf-dissolve/package.json | 5 +- packages/turf-dissolve/{test.js => test.ts} | 0 .../{bench.js => bench.ts} | 8 +-- packages/turf-distance-weight/index.ts | 7 ++- packages/turf-distance-weight/package.json | 5 +- .../turf-distance-weight/{test.js => test.ts} | 12 ++--- packages/turf-distance/{bench.js => bench.ts} | 4 +- packages/turf-distance/index.ts | 1 + packages/turf-distance/package.json | 5 +- packages/turf-distance/{test.js => test.ts} | 14 ++--- packages/turf-ellipse/{bench.js => bench.ts} | 2 +- packages/turf-ellipse/index.ts | 1 + packages/turf-ellipse/package.json | 5 +- packages/turf-ellipse/{test.js => test.ts} | 10 ++-- packages/turf-envelope/{bench.js => bench.ts} | 2 +- packages/turf-envelope/index.ts | 5 +- packages/turf-envelope/package.json | 5 +- packages/turf-envelope/{test.js => test.ts} | 2 +- packages/turf-explode/{bench.js => bench.ts} | 2 +- packages/turf-explode/index.ts | 1 + packages/turf-explode/package.json | 5 +- packages/turf-explode/{test.js => test.ts} | 2 +- packages/turf-flatten/{bench.js => bench.ts} | 2 +- packages/turf-flatten/index.ts | 1 + packages/turf-flatten/package.json | 5 +- packages/turf-flatten/{test.js => test.ts} | 2 +- packages/turf-flip/{bench.js => bench.ts} | 2 +- packages/turf-flip/index.ts | 1 + packages/turf-flip/package.json | 5 +- packages/turf-flip/{test.js => test.ts} | 2 +- .../turf-geojson-rbush/{bench.js => bench.ts} | 6 +-- packages/turf-geojson-rbush/index.d.ts | 5 +- packages/turf-geojson-rbush/index.js | 3 +- packages/turf-geojson-rbush/package.json | 4 +- .../turf-geojson-rbush/{test.js => test.ts} | 16 +++--- packages/turf-geojson-rbush/types.ts | 2 +- .../turf-great-circle/{bench.js => bench.ts} | 2 +- packages/turf-great-circle/index.d.ts | 5 +- packages/turf-great-circle/index.js | 1 + packages/turf-great-circle/package.json | 4 +- .../turf-great-circle/{test.js => test.ts} | 4 +- packages/turf-helpers/{bench.js => bench.ts} | 6 +-- packages/turf-helpers/package.json | 5 +- packages/turf-helpers/{test.js => test.ts} | 8 +-- packages/turf-hex-grid/{bench.js => bench.ts} | 4 +- packages/turf-hex-grid/index.ts | 1 + packages/turf-hex-grid/package.json | 5 +- packages/turf-hex-grid/{test.js => test.ts} | 16 +++--- .../turf-interpolate/{bench.js => bench.ts} | 2 +- packages/turf-interpolate/index.d.ts | 7 ++- packages/turf-interpolate/index.js | 1 + packages/turf-interpolate/package.json | 4 +- .../turf-interpolate/{test.js => test.ts} | 4 +- .../turf-intersect/{bench.js => bench.ts} | 8 +-- packages/turf-intersect/index.ts | 7 +-- packages/turf-intersect/package.json | 5 +- packages/turf-intersect/{test.js => test.ts} | 14 ++--- .../turf-invariant/{bench.js => bench.ts} | 6 +-- packages/turf-invariant/index.ts | 32 ++++++----- packages/turf-invariant/package.json | 5 +- packages/turf-invariant/{test.js => test.ts} | 8 +-- packages/turf-isobands/{bench.js => bench.ts} | 2 +- packages/turf-isobands/index.ts | 4 +- packages/turf-isobands/package.json | 5 +- packages/turf-isobands/{test.js => test.ts} | 6 +-- packages/turf-isolines/{bench.js => bench.ts} | 2 +- packages/turf-isolines/index.ts | 4 +- packages/turf-isolines/package.json | 5 +- packages/turf-isolines/{test.js => test.ts} | 6 +-- packages/turf-kinks/{bench.js => bench.ts} | 10 ++-- packages/turf-kinks/index.ts | 9 ++-- packages/turf-kinks/package.json | 5 +- packages/turf-kinks/{test.js => test.ts} | 14 ++--- packages/turf-length/{bench.js => bench.ts} | 10 ++-- packages/turf-length/index.ts | 5 +- packages/turf-length/package.json | 5 +- packages/turf-length/{test.js => test.ts} | 12 ++--- packages/turf-line-arc/{bench.js => bench.ts} | 10 ++-- packages/turf-line-arc/index.ts | 5 +- packages/turf-line-arc/package.json | 5 +- packages/turf-line-arc/{test.js => test.ts} | 16 +++--- .../turf-line-chunk/{bench.js => bench.ts} | 2 +- packages/turf-line-chunk/index.d.ts | 5 +- packages/turf-line-chunk/index.js | 1 + packages/turf-line-chunk/package.json | 4 +- packages/turf-line-chunk/{test.js => test.ts} | 2 +- .../{bench.js => bench.ts} | 10 ++-- packages/turf-line-intersect/index.ts | 1 + packages/turf-line-intersect/package.json | 5 +- .../turf-line-intersect/{test.js => test.ts} | 18 +++---- .../turf-line-offset/{bench.js => bench.ts} | 2 +- packages/turf-line-offset/index.d.ts | 5 +- packages/turf-line-offset/index.js | 1 + packages/turf-line-offset/package.json | 4 +- .../turf-line-offset/{test.js => test.ts} | 4 +- .../turf-line-overlap/{bench.js => bench.ts} | 10 ++-- packages/turf-line-overlap/index.ts | 1 + packages/turf-line-overlap/package.json | 5 +- .../turf-line-overlap/{test.js => test.ts} | 16 +++--- .../turf-line-segment/{bench.js => bench.ts} | 10 ++-- packages/turf-line-segment/index.ts | 1 + packages/turf-line-segment/package.json | 5 +- .../turf-line-segment/{test.js => test.ts} | 16 +++--- .../{bench.js => bench.ts} | 2 +- packages/turf-line-slice-along/index.d.ts | 5 +- packages/turf-line-slice-along/index.js | 1 + packages/turf-line-slice-along/package.json | 4 +- .../{test.js => test.ts} | 6 +-- .../turf-line-slice/{bench.js => bench.ts} | 2 +- packages/turf-line-slice/index.d.ts | 5 +- packages/turf-line-slice/index.js | 1 + packages/turf-line-slice/package.json | 4 +- packages/turf-line-slice/{test.js => test.ts} | 2 +- .../turf-line-split/{bench.js => bench.ts} | 2 +- packages/turf-line-split/index.d.ts | 7 ++- packages/turf-line-split/index.js | 1 + packages/turf-line-split/package.json | 4 +- packages/turf-line-split/{test.js => test.ts} | 2 +- .../{bench.js => bench.ts} | 10 ++-- packages/turf-line-to-polygon/index.ts | 1 + packages/turf-line-to-polygon/package.json | 5 +- .../turf-line-to-polygon/{test.js => test.ts} | 16 +++--- packages/turf-mask/{bench.js => bench.ts} | 2 +- packages/turf-mask/index.d.ts | 5 +- packages/turf-mask/index.js | 1 + packages/turf-mask/package.json | 4 +- packages/turf-mask/{test.js => test.ts} | 2 +- packages/turf-meta/{bench.js => bench.ts} | 6 +-- packages/turf-meta/index.d.ts | 54 +++++++++++++------ packages/turf-meta/index.js | 54 +++++++++++++------ packages/turf-meta/package.json | 4 +- packages/turf-meta/{test.js => test.ts} | 8 +-- packages/turf-midpoint/{bench.js => bench.ts} | 2 +- packages/turf-midpoint/index.d.ts | 5 +- packages/turf-midpoint/index.js | 7 +-- packages/turf-midpoint/package.json | 4 +- packages/turf-midpoint/{test.js => test.ts} | 4 +- .../turf-moran-index/{bench.js => bench.ts} | 8 +-- packages/turf-moran-index/index.ts | 5 +- packages/turf-moran-index/package.json | 5 +- .../turf-moran-index/{test.js => test.ts} | 8 +-- .../{bench.js => bench.ts} | 10 ++-- .../turf-nearest-neighbor-analysis/index.ts | 9 +++- .../package.json | 5 +- .../{test.js => test.ts} | 20 +++---- .../{bench.js => bench.ts} | 10 ++-- packages/turf-nearest-point-on-line/index.ts | 1 + .../turf-nearest-point-on-line/package.json | 5 +- .../{test.js => test.ts} | 24 ++++----- .../{bench.js => bench.ts} | 10 ++-- packages/turf-nearest-point-to-line/index.ts | 1 + .../turf-nearest-point-to-line/package.json | 5 +- .../{test.js => test.ts} | 20 +++---- .../turf-nearest-point/{bench.js => bench.ts} | 8 +-- packages/turf-nearest-point/index.ts | 7 +-- packages/turf-nearest-point/package.json | 5 +- .../turf-nearest-point/{test.js => test.ts} | 14 ++--- .../turf-planepoint/{bench.js => bench.ts} | 2 +- packages/turf-planepoint/index.d.ts | 5 +- packages/turf-planepoint/index.js | 1 + packages/turf-planepoint/package.json | 4 +- packages/turf-planepoint/{test.js => test.ts} | 2 +- .../turf-point-grid/{bench.js => bench.ts} | 6 +-- packages/turf-point-grid/index.ts | 5 +- packages/turf-point-grid/package.json | 5 +- packages/turf-point-grid/{test.js => test.ts} | 16 +++--- .../{bench.js => bench.ts} | 2 +- packages/turf-point-on-feature/index.ts | 1 + packages/turf-point-on-feature/package.json | 5 +- .../{test.js => test.ts} | 4 +- .../{bench.js => bench.ts} | 10 ++-- packages/turf-point-to-line-distance/index.ts | 1 + .../turf-point-to-line-distance/package.json | 5 +- .../{test.js => test.ts} | 16 +++--- .../{bench.js => bench.ts} | 2 +- packages/turf-points-within-polygon/index.ts | 1 + .../turf-points-within-polygon/package.json | 5 +- .../{test.js => test.ts} | 2 +- .../{bench.js => bench.ts} | 2 +- packages/turf-polygon-smooth/index.ts | 1 + packages/turf-polygon-smooth/package.json | 5 +- .../turf-polygon-smooth/{test.js => test.ts} | 2 +- .../{bench.js => bench.ts} | 2 +- packages/turf-polygon-tangents/index.ts | 1 + packages/turf-polygon-tangents/package.json | 5 +- .../{test.js => test.ts} | 2 +- .../{bench.js => bench.ts} | 10 ++-- packages/turf-polygon-to-line/index.ts | 13 +++-- packages/turf-polygon-to-line/package.json | 5 +- .../turf-polygon-to-line/{test.js => test.ts} | 16 +++--- .../turf-polygonize/{bench.js => bench.ts} | 10 ++-- packages/turf-polygonize/index.ts | 5 +- packages/turf-polygonize/package.json | 5 +- packages/turf-polygonize/{test.js => test.ts} | 16 +++--- .../turf-projection/{bench.js => bench.ts} | 10 ++-- packages/turf-projection/index.ts | 6 ++- packages/turf-projection/package.json | 5 +- packages/turf-projection/{test.js => test.ts} | 22 ++++---- .../{bench.js => bench.ts} | 9 ++-- packages/turf-quadrat-analysis/index.ts | 7 ++- packages/turf-quadrat-analysis/package.json | 5 +- .../{test.js => test.ts} | 24 ++++----- packages/turf-random/{bench.js => bench.ts} | 7 ++- packages/turf-random/index.ts | 10 ++-- packages/turf-random/package.json | 5 +- packages/turf-random/{test.js => test.ts} | 6 +-- .../{bench.js => bench.ts} | 4 +- packages/turf-rectangle-grid/index.ts | 3 +- packages/turf-rectangle-grid/package.json | 5 +- .../turf-rectangle-grid/{test.js => test.ts} | 16 +++--- packages/turf-rewind/{bench.js => bench.ts} | 2 +- packages/turf-rewind/index.ts | 1 + packages/turf-rewind/package.json | 5 +- packages/turf-rewind/{test.js => test.ts} | 2 +- .../turf-rhumb-bearing/{bench.js => bench.ts} | 6 +-- packages/turf-rhumb-bearing/index.ts | 1 + packages/turf-rhumb-bearing/package.json | 5 +- .../turf-rhumb-bearing/{test.js => test.ts} | 14 ++--- .../{bench.js => bench.ts} | 6 +-- packages/turf-rhumb-destination/index.ts | 1 + packages/turf-rhumb-destination/package.json | 5 +- .../{test.js => test.ts} | 18 +++---- .../{bench.js => bench.ts} | 6 +-- packages/turf-rhumb-distance/index.ts | 1 + packages/turf-rhumb-distance/package.json | 5 +- .../turf-rhumb-distance/{test.js => test.ts} | 16 +++--- packages/turf-sample/{bench.js => bench.ts} | 2 +- packages/turf-sample/index.ts | 1 + packages/turf-sample/package.json | 5 +- packages/turf-sample/{test.js => test.ts} | 2 +- packages/turf-sector/{bench.js => bench.ts} | 2 +- packages/turf-sector/index.ts | 1 + packages/turf-sector/package.json | 5 +- packages/turf-sector/{test.js => test.ts} | 2 +- .../turf-shortest-path/{bench.js => bench.ts} | 2 +- packages/turf-shortest-path/index.ts | 1 + packages/turf-shortest-path/package.json | 5 +- .../turf-shortest-path/{test.js => test.ts} | 4 +- packages/turf-simplify/{bench.js => bench.ts} | 2 +- packages/turf-simplify/index.ts | 1 + packages/turf-simplify/package.json | 5 +- packages/turf-simplify/{test.js => test.ts} | 4 +- .../turf-square-grid/{bench.js => bench.ts} | 4 +- packages/turf-square-grid/index.ts | 10 ++-- packages/turf-square-grid/package.json | 5 +- .../turf-square-grid/{test.js => test.ts} | 16 +++--- packages/turf-square/{bench.js => bench.ts} | 2 +- packages/turf-square/index.d.ts | 5 +- packages/turf-square/index.js | 3 +- packages/turf-square/package.json | 4 +- packages/turf-square/{test.js => test.ts} | 2 +- .../{bench.js => bench.ts} | 2 +- .../index.d.ts | 9 ++-- .../index.js | 1 + .../package.json | 4 +- .../{test.js => test.ts} | 2 +- packages/turf-tag/{bench.js => bench.ts} | 2 +- packages/turf-tag/index.ts | 1 + packages/turf-tag/package.json | 5 +- packages/turf-tag/{test.js => test.ts} | 2 +- .../turf-tesselate/{bench.js => bench.ts} | 2 +- packages/turf-tesselate/index.d.ts | 7 ++- packages/turf-tesselate/index.js | 1 + packages/turf-tesselate/package.json | 4 +- packages/turf-tesselate/{test.js => test.ts} | 2 +- packages/turf-tin/{bench.js => bench.ts} | 8 +-- packages/turf-tin/index.ts | 9 ++-- packages/turf-tin/package.json | 5 +- packages/turf-tin/{test.js => test.ts} | 8 +-- .../{bench.js => bench.ts} | 2 +- packages/turf-transform-rotate/index.d.ts | 5 +- packages/turf-transform-rotate/index.js | 1 + packages/turf-transform-rotate/package.json | 4 +- .../{test.js => test.ts} | 6 +-- .../{bench.js => bench.ts} | 2 +- packages/turf-transform-scale/index.d.ts | 5 +- packages/turf-transform-scale/index.js | 1 + packages/turf-transform-scale/package.json | 4 +- .../turf-transform-scale/{test.js => test.ts} | 14 ++--- .../{bench.js => bench.ts} | 2 +- packages/turf-transform-translate/index.d.ts | 5 +- packages/turf-transform-translate/index.js | 5 +- .../turf-transform-translate/package.json | 4 +- .../{test.js => test.ts} | 4 +- .../turf-triangle-grid/{bench.js => bench.ts} | 2 +- packages/turf-triangle-grid/index.ts | 1 + packages/turf-triangle-grid/package.json | 5 +- .../turf-triangle-grid/{test.js => test.ts} | 16 +++--- packages/turf-truncate/{bench.js => bench.ts} | 10 ++-- packages/turf-truncate/index.ts | 1 + packages/turf-truncate/package.json | 5 +- packages/turf-truncate/{test.js => test.ts} | 14 ++--- packages/turf-union/{bench.js => bench.ts} | 12 ++--- packages/turf-union/index.ts | 1 + packages/turf-union/package.json | 5 +- packages/turf-union/{test.js => test.ts} | 12 ++--- .../{bench.js => bench.ts} | 2 +- packages/turf-unkink-polygon/index.d.ts | 5 +- packages/turf-unkink-polygon/index.js | 1 + packages/turf-unkink-polygon/package.json | 4 +- .../turf-unkink-polygon/{test.js => test.ts} | 4 +- packages/turf-voronoi/{bench.js => bench.ts} | 2 +- packages/turf-voronoi/index.d.ts | 5 +- packages/turf-voronoi/index.js | 1 + packages/turf-voronoi/package.json | 4 +- packages/turf-voronoi/{test.js => test.ts} | 2 +- packages/turf/package.json | 2 +- packages/turf/{test.js => test.ts} | 19 ++++--- rollup-plugins/typescript-export.js | 12 ----- rollup-plugins/valid-es5.js | 26 --------- rollup.config.js | 5 +- yarn.lock | 5 ++ 480 files changed, 1772 insertions(+), 1471 deletions(-) rename packages/turf-along/{bench.js => bench.ts} (64%) rename packages/turf-along/{test.js => test.ts} (71%) rename packages/turf-angle/{bench.js => bench.ts} (75%) rename packages/turf-angle/{test.js => test.ts} (85%) rename packages/turf-area/{bench.js => bench.ts} (74%) rename packages/turf-area/{test.js => test.ts} (74%) rename packages/turf-bbox-clip/{bench.js => bench.ts} (80%) rename packages/turf-bbox-clip/{test.js => test.ts} (81%) rename packages/turf-bbox-polygon/{bench.js => bench.ts} (57%) rename packages/turf-bbox-polygon/{test.js => test.ts} (96%) rename packages/turf-bbox/{bench.js => bench.ts} (64%) rename packages/turf-bbox/{test.js => test.ts} (95%) rename packages/turf-bearing/{bench.js => bench.ts} (77%) rename packages/turf-bearing/{test.js => test.ts} (79%) rename packages/turf-bezier-spline/{bench.js => bench.ts} (75%) rename packages/turf-bezier-spline/{test.js => test.ts} (77%) rename packages/turf-boolean-clockwise/{bench.js => bench.ts} (73%) rename packages/turf-boolean-clockwise/{test.js => test.ts} (85%) rename packages/turf-boolean-concave/{bench.js => bench.ts} (77%) rename packages/turf-boolean-concave/{test.js => test.ts} (79%) rename packages/turf-boolean-contains/{bench.js => bench.ts} (94%) rename packages/turf-boolean-contains/{test.js => test.ts} (83%) rename packages/turf-boolean-crosses/{bench.js => bench.ts} (87%) rename packages/turf-boolean-crosses/{test.js => test.ts} (82%) rename packages/turf-boolean-disjoint/{bench.js => bench.ts} (93%) rename packages/turf-boolean-disjoint/{test.js => test.ts} (83%) rename packages/turf-boolean-equal/{bench.js => bench.ts} (87%) rename packages/turf-boolean-equal/{test.js => test.ts} (90%) rename packages/turf-boolean-intersects/{bench.js => bench.ts} (93%) rename packages/turf-boolean-intersects/{test.js => test.ts} (83%) rename packages/turf-boolean-overlap/{bench.js => bench.ts} (90%) rename packages/turf-boolean-overlap/{test.js => test.ts} (91%) rename packages/turf-boolean-parallel/{bench.js => bench.ts} (87%) rename packages/turf-boolean-parallel/{test.js => test.ts} (82%) rename packages/turf-boolean-point-in-polygon/{bench.js => bench.ts} (84%) rename packages/turf-boolean-point-in-polygon/{test.js => test.ts} (96%) rename packages/turf-boolean-point-on-line/{bench.js => bench.ts} (86%) rename packages/turf-boolean-point-on-line/{test.js => test.ts} (83%) rename packages/turf-boolean-touches/{bench.js => bench.ts} (91%) rename packages/turf-boolean-touches/{test.js => test.ts} (84%) rename packages/turf-boolean-valid/{bench.js => bench.ts} (68%) rename packages/turf-boolean-valid/{test.js => test.ts} (83%) rename packages/turf-boolean-within/{bench.js => bench.ts} (92%) rename packages/turf-boolean-within/{test.js => test.ts} (84%) rename packages/turf-buffer/{bench.js => bench.ts} (98%) rename packages/turf-buffer/{test.js => test.ts} (99%) rename packages/turf-center-mean/{bench.js => bench.ts} (83%) rename packages/turf-center-mean/{test.js => test.ts} (76%) rename packages/turf-center-median/{bench.js => bench.ts} (82%) rename packages/turf-center-median/{test.js => test.ts} (72%) rename packages/turf-center-of-mass/{bench.js => bench.ts} (96%) rename packages/turf-center-of-mass/{test.js => test.ts} (84%) rename packages/turf-center/{bench.js => bench.ts} (83%) rename packages/turf-center/{test.js => test.ts} (74%) rename packages/turf-centroid/{bench.js => bench.ts} (83%) rename packages/turf-centroid/{test.js => test.ts} (75%) rename packages/turf-circle/{bench.js => bench.ts} (88%) rename packages/turf-circle/{test.js => test.ts} (74%) rename packages/turf-clean-coords/{bench.js => bench.ts} (93%) rename packages/turf-clean-coords/{test.js => test.ts} (89%) rename packages/turf-clone/{bench.js => bench.ts} (90%) rename packages/turf-clone/{test.js => test.ts} (97%) rename packages/turf-clusters-dbscan/{bench.js => bench.ts} (85%) rename packages/turf-clusters-dbscan/{test.js => test.ts} (87%) rename packages/turf-clusters-kmeans/{bench.js => bench.ts} (84%) rename packages/turf-clusters-kmeans/{test.js => test.ts} (83%) rename packages/turf-clusters/{bench.js => bench.ts} (93%) rename packages/turf-clusters/{test.js => test.ts} (95%) rename packages/turf-collect/{bench.js => bench.ts} (83%) rename packages/turf-collect/{test.js => test.ts} (89%) rename packages/turf-combine/{bench.js => bench.ts} (83%) rename packages/turf-combine/{test.js => test.ts} (98%) rename packages/turf-concave/{bench.js => bench.ts} (86%) rename packages/turf-concave/{test.js => test.ts} (80%) rename packages/turf-convex/{bench.js => bench.ts} (76%) rename packages/turf-convex/{test.js => test.ts} (69%) rename packages/turf-destination/{bench.js => bench.ts} (71%) rename packages/turf-destination/{test.js => test.ts} (72%) rename packages/turf-difference/{bench.js => bench.ts} (84%) rename packages/turf-difference/{test.js => test.ts} (88%) rename packages/turf-directional-mean/{bench.js => bench.ts} (89%) rename packages/turf-directional-mean/{test.js => test.ts} (88%) rename packages/turf-dissolve/{bench.js => bench.ts} (95%) rename packages/turf-dissolve/{test.js => test.ts} (100%) rename packages/turf-distance-weight/{bench.js => bench.ts} (73%) rename packages/turf-distance-weight/{test.js => test.ts} (86%) rename packages/turf-distance/{bench.js => bench.ts} (72%) rename packages/turf-distance/{test.js => test.ts} (83%) rename packages/turf-ellipse/{bench.js => bench.ts} (95%) rename packages/turf-ellipse/{test.js => test.ts} (94%) rename packages/turf-envelope/{bench.js => bench.ts} (92%) rename packages/turf-envelope/{test.js => test.ts} (94%) rename packages/turf-explode/{bench.js => bench.ts} (91%) rename packages/turf-explode/{test.js => test.ts} (97%) rename packages/turf-flatten/{bench.js => bench.ts} (96%) rename packages/turf-flatten/{test.js => test.ts} (97%) rename packages/turf-flip/{bench.js => bench.ts} (96%) rename packages/turf-flip/{test.js => test.ts} (97%) rename packages/turf-geojson-rbush/{bench.js => bench.ts} (87%) rename packages/turf-geojson-rbush/{test.js => test.ts} (88%) rename packages/turf-great-circle/{bench.js => bench.ts} (89%) rename packages/turf-great-circle/{test.js => test.ts} (93%) rename packages/turf-helpers/{bench.js => bench.ts} (96%) rename packages/turf-helpers/{test.js => test.ts} (99%) rename packages/turf-hex-grid/{bench.js => bench.ts} (92%) rename packages/turf-hex-grid/{test.js => test.ts} (87%) rename packages/turf-interpolate/{bench.js => bench.ts} (97%) rename packages/turf-interpolate/{test.js => test.ts} (97%) rename packages/turf-intersect/{bench.js => bench.ts} (77%) rename packages/turf-intersect/{test.js => test.ts} (78%) rename packages/turf-invariant/{bench.js => bench.ts} (89%) rename packages/turf-invariant/{test.js => test.ts} (98%) rename packages/turf-isobands/{bench.js => bench.ts} (98%) rename packages/turf-isobands/{test.js => test.ts} (94%) rename packages/turf-isolines/{bench.js => bench.ts} (97%) rename packages/turf-isolines/{test.js => test.ts} (96%) rename packages/turf-kinks/{bench.js => bench.ts} (73%) rename packages/turf-kinks/{test.js => test.ts} (71%) rename packages/turf-length/{bench.js => bench.ts} (81%) rename packages/turf-length/{test.js => test.ts} (73%) rename packages/turf-line-arc/{bench.js => bench.ts} (84%) rename packages/turf-line-arc/{test.js => test.ts} (85%) rename packages/turf-line-chunk/{bench.js => bench.ts} (96%) rename packages/turf-line-chunk/{test.js => test.ts} (98%) rename packages/turf-line-intersect/{bench.js => bench.ts} (81%) rename packages/turf-line-intersect/{test.js => test.ts} (89%) rename packages/turf-line-offset/{bench.js => bench.ts} (96%) rename packages/turf-line-offset/{test.js => test.ts} (96%) rename packages/turf-line-overlap/{bench.js => bench.ts} (79%) rename packages/turf-line-overlap/{test.js => test.ts} (85%) rename packages/turf-line-segment/{bench.js => bench.ts} (82%) rename packages/turf-line-segment/{test.js => test.ts} (81%) rename packages/turf-line-slice-along/{bench.js => bench.ts} (97%) rename packages/turf-line-slice-along/{test.js => test.ts} (96%) rename packages/turf-line-slice/{bench.js => bench.ts} (96%) rename packages/turf-line-slice/{test.js => test.ts} (96%) rename packages/turf-line-split/{bench.js => bench.ts} (97%) rename packages/turf-line-split/{test.js => test.ts} (99%) rename packages/turf-line-to-polygon/{bench.js => bench.ts} (85%) rename packages/turf-line-to-polygon/{test.js => test.ts} (80%) rename packages/turf-mask/{bench.js => bench.ts} (95%) rename packages/turf-mask/{test.js => test.ts} (96%) rename packages/turf-meta/{bench.js => bench.ts} (98%) rename packages/turf-meta/{test.js => test.ts} (99%) rename packages/turf-midpoint/{bench.js => bench.ts} (89%) rename packages/turf-midpoint/{test.js => test.ts} (95%) rename packages/turf-moran-index/{bench.js => bench.ts} (75%) rename packages/turf-moran-index/{test.js => test.ts} (84%) rename packages/turf-nearest-neighbor-analysis/{bench.js => bench.ts} (76%) rename packages/turf-nearest-neighbor-analysis/{test.js => test.ts} (72%) rename packages/turf-nearest-point-on-line/{bench.js => bench.ts} (81%) rename packages/turf-nearest-point-on-line/{test.js => test.ts} (95%) rename packages/turf-nearest-point-to-line/{bench.js => bench.ts} (80%) rename packages/turf-nearest-point-to-line/{test.js => test.ts} (88%) rename packages/turf-nearest-point/{bench.js => bench.ts} (69%) rename packages/turf-nearest-point/{test.js => test.ts} (88%) rename packages/turf-planepoint/{bench.js => bench.ts} (93%) rename packages/turf-planepoint/{test.js => test.ts} (94%) rename packages/turf-point-grid/{bench.js => bench.ts} (90%) rename packages/turf-point-grid/{test.js => test.ts} (80%) rename packages/turf-point-on-feature/{bench.js => bench.ts} (95%) rename packages/turf-point-on-feature/{test.js => test.ts} (93%) rename packages/turf-point-to-line-distance/{bench.js => bench.ts} (92%) rename packages/turf-point-to-line-distance/{test.js => test.ts} (88%) rename packages/turf-points-within-polygon/{bench.js => bench.ts} (94%) rename packages/turf-points-within-polygon/{test.js => test.ts} (99%) rename packages/turf-polygon-smooth/{bench.js => bench.ts} (95%) rename packages/turf-polygon-smooth/{test.js => test.ts} (96%) rename packages/turf-polygon-tangents/{bench.js => bench.ts} (95%) rename packages/turf-polygon-tangents/{test.js => test.ts} (98%) rename packages/turf-polygon-to-line/{bench.js => bench.ts} (81%) rename packages/turf-polygon-to-line/{test.js => test.ts} (71%) rename packages/turf-polygonize/{bench.js => bench.ts} (82%) rename packages/turf-polygonize/{test.js => test.ts} (83%) rename packages/turf-projection/{bench.js => bench.ts} (91%) rename packages/turf-projection/{test.js => test.ts} (87%) rename packages/turf-quadrat-analysis/{bench.js => bench.ts} (78%) rename packages/turf-quadrat-analysis/{test.js => test.ts} (88%) rename packages/turf-random/{bench.js => bench.ts} (51%) rename packages/turf-random/{test.js => test.ts} (97%) rename packages/turf-rectangle-grid/{bench.js => bench.ts} (90%) rename packages/turf-rectangle-grid/{test.js => test.ts} (78%) rename packages/turf-rewind/{bench.js => bench.ts} (97%) rename packages/turf-rewind/{test.js => test.ts} (98%) rename packages/turf-rhumb-bearing/{bench.js => bench.ts} (78%) rename packages/turf-rhumb-bearing/{test.js => test.ts} (78%) rename packages/turf-rhumb-destination/{bench.js => bench.ts} (75%) rename packages/turf-rhumb-destination/{test.js => test.ts} (84%) rename packages/turf-rhumb-distance/{bench.js => bench.ts} (73%) rename packages/turf-rhumb-distance/{test.js => test.ts} (83%) rename packages/turf-sample/{bench.js => bench.ts} (94%) rename packages/turf-sample/{test.js => test.ts} (94%) rename packages/turf-sector/{bench.js => bench.ts} (97%) rename packages/turf-sector/{test.js => test.ts} (97%) rename packages/turf-shortest-path/{bench.js => bench.ts} (96%) rename packages/turf-shortest-path/{test.js => test.ts} (95%) rename packages/turf-simplify/{bench.js => bench.ts} (98%) rename packages/turf-simplify/{test.js => test.ts} (98%) rename packages/turf-square-grid/{bench.js => bench.ts} (91%) rename packages/turf-square-grid/{test.js => test.ts} (77%) rename packages/turf-square/{bench.js => bench.ts} (88%) rename packages/turf-square/{test.js => test.ts} (88%) rename packages/turf-standard-deviational-ellipse/{bench.js => bench.ts} (94%) rename packages/turf-standard-deviational-ellipse/{test.js => test.ts} (95%) rename packages/turf-tag/{bench.js => bench.ts} (93%) rename packages/turf-tag/{test.js => test.ts} (98%) rename packages/turf-tesselate/{bench.js => bench.ts} (91%) rename packages/turf-tesselate/{test.js => test.ts} (99%) rename packages/turf-tin/{bench.js => bench.ts} (66%) rename packages/turf-tin/{test.js => test.ts} (88%) rename packages/turf-transform-rotate/{bench.js => bench.ts} (96%) rename packages/turf-transform-rotate/{test.js => test.ts} (96%) rename packages/turf-transform-scale/{bench.js => bench.ts} (97%) rename packages/turf-transform-scale/{test.js => test.ts} (96%) rename packages/turf-transform-translate/{bench.js => bench.ts} (96%) rename packages/turf-transform-translate/{test.js => test.ts} (97%) rename packages/turf-triangle-grid/{bench.js => bench.ts} (94%) rename packages/turf-triangle-grid/{test.js => test.ts} (76%) rename packages/turf-truncate/{bench.js => bench.ts} (87%) rename packages/turf-truncate/{test.js => test.ts} (86%) rename packages/turf-union/{bench.js => bench.ts} (69%) rename packages/turf-union/{test.js => test.ts} (72%) rename packages/turf-unkink-polygon/{bench.js => bench.ts} (92%) rename packages/turf-unkink-polygon/{test.js => test.ts} (96%) rename packages/turf-voronoi/{bench.js => bench.ts} (95%) rename packages/turf-voronoi/{test.js => test.ts} (95%) rename packages/turf/{test.js => test.ts} (96%) delete mode 100644 rollup-plugins/typescript-export.js delete mode 100644 rollup-plugins/valid-es5.js diff --git a/.monorepolint.config.ts b/.monorepolint.config.ts index 4f85e3074..8ba6bec73 100644 --- a/.monorepolint.config.ts +++ b/.monorepolint.config.ts @@ -202,34 +202,11 @@ module.exports = { { options: { scripts: { - "test:tape": "tsx test.js", + bench: "tsx bench.ts", + "test:tape": "tsx test.ts", }, }, - includePackages: JS_TAPE_PACKAGES, - }, - { - options: { - scripts: { - "test:tape": "tsx test.js", - }, - }, - includePackages: TS_TAPE_PACKAGES, - }, - { - options: { - scripts: { - bench: "tsx bench.js", - }, - }, - includePackages: JS_TAPE_PACKAGES, - }, - { - options: { - scripts: { - bench: "tsx bench.js", - }, - }, - includePackages: TS_TAPE_PACKAGES, + includePackages: [...TS_TAPE_PACKAGES, ...JS_TAPE_PACKAGES], }, { options: { @@ -263,6 +240,7 @@ module.exports = { tslib: "^2.6.2", }, devDependencies: { + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", typescript: "^5.2.2", }, diff --git a/packages/turf-along/bench.js b/packages/turf-along/bench.ts similarity index 64% rename from packages/turf-along/bench.js rename to packages/turf-along/bench.ts index 4e130b2df..a4d54351d 100644 --- a/packages/turf-along/bench.js +++ b/packages/turf-along/bench.ts @@ -1,8 +1,9 @@ -const fs = require("fs"); -const Benchmark = require("benchmark"); -const along = require("./index").default; +import fs from "fs"; +import Benchmark from "benchmark"; +import { along } from "./index"; +import { Feature, LineString } from "geojson"; -const line = { +const line: Feature = { type: "Feature", properties: {}, geometry: { @@ -19,25 +20,25 @@ const line = { }; const route = JSON.parse( - fs.readFileSync(__dirname + "/test/fixtures/route.geojson") + fs.readFileSync(__dirname + "/test/fixtures/route.geojson").toString() ); const suite = new Benchmark.Suite("turf-along"); suite .add("turf-along", function () { - along(line, 1, "miles"); + along(line, 1, { units: "miles" }); }) .add("turf-along#route 1 mile", function () { - along(route, 1, "miles"); + along(route, 1, { units: "miles" }); }) .add("turf-along#route 10 miles", function () { - along(route, 10, "miles"); + along(route, 10, { units: "miles" }); }) .add("turf-along#route 50 miles", function () { - along(route, 50, "miles"); + along(route, 50, { units: "miles" }); }) .add("turf-along#route 100 miles", function () { - along(route, 100, "miles"); + along(route, 100, { units: "miles" }); }) .on("cycle", function (event) { console.log(String(event.target)); diff --git a/packages/turf-along/index.ts b/packages/turf-along/index.ts index 160dffa43..20c11fda0 100644 --- a/packages/turf-along/index.ts +++ b/packages/turf-along/index.ts @@ -23,7 +23,7 @@ import { getGeom } from "@turf/invariant"; * //addToMap * var addToMap = [along, line] */ -export default function along( +function along( line: Feature | LineString, distance: number, options: { units?: Units } = {} @@ -55,3 +55,6 @@ export default function along( } return point(coords[coords.length - 1]); } + +export { along }; +export default along; diff --git a/packages/turf-along/package.json b/packages/turf-along/package.json index 795407a11..8793e942b 100644 --- a/packages/turf-along/package.json +++ b/packages/turf-along/package.json @@ -39,15 +39,16 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js" + "test:tape": "tsx test.ts" }, "devDependencies": { + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "load-json-file": "^7.0.1", diff --git a/packages/turf-along/test.js b/packages/turf-along/test.ts similarity index 71% rename from packages/turf-along/test.js rename to packages/turf-along/test.ts index c3514c4a7..2fa6e5c18 100644 --- a/packages/turf-along/test.js +++ b/packages/turf-along/test.ts @@ -1,15 +1,16 @@ -const path = require("path"); -const test = require("tape"); -const { loadJsonFileSync } = require("load-json-file"); -const { featureCollection } = require("@turf/helpers"); -const along = require("./index").default; +import path from "path"; +import test from "tape"; +import { loadJsonFileSync } from "load-json-file"; +import { Units, featureCollection } from "@turf/helpers"; +import { along } from "./index"; +import { Feature, LineString } from "geojson"; -const line = loadJsonFileSync( +const line: Feature = loadJsonFileSync( path.join(__dirname, "test", "fixtures", "dc-line.geojson") ); test("turf-along", (t) => { - const options = { units: "miles" }; + const options: { units: Units } = { units: "miles" }; const pt1 = along(line, 1, options); const pt2 = along(line.geometry, 1.2, options); const pt3 = along(line, 1.4, options); diff --git a/packages/turf-angle/bench.js b/packages/turf-angle/bench.ts similarity index 75% rename from packages/turf-angle/bench.js rename to packages/turf-angle/bench.ts index dfadcbd26..9b36fb710 100644 --- a/packages/turf-angle/bench.js +++ b/packages/turf-angle/bench.ts @@ -1,5 +1,5 @@ -const Benchmark = require("benchmark"); -const angle = require("./index").default; +import Benchmark from "benchmark"; +import { angle } from "./index"; /** * Benchmark Results @@ -9,7 +9,7 @@ const angle = require("./index").default; */ new Benchmark.Suite("turf-angle") .add("angle", () => angle([5, 5], [5, 6], [3, 4])) - .add("angle -- meractor", () => + .add("angle -- mercator", () => angle([5, 5], [5, 6], [3, 4], { mercator: true }) ) .on("cycle", (e) => console.log(String(e.target))) diff --git a/packages/turf-angle/index.ts b/packages/turf-angle/index.ts index 72b173f84..cf8860df9 100644 --- a/packages/turf-angle/index.ts +++ b/packages/turf-angle/index.ts @@ -64,4 +64,5 @@ function angle( return angleAO; } +export { angle }; export default angle; diff --git a/packages/turf-angle/package.json b/packages/turf-angle/package.json index 58306f982..03d3756b8 100644 --- a/packages/turf-angle/package.json +++ b/packages/turf-angle/package.json @@ -39,18 +39,19 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js" + "test:tape": "tsx test.ts" }, "devDependencies": { "@turf/distance": "^7.0.0-alpha.2", "@turf/sector": "^7.0.0-alpha.2", "@turf/truncate": "^7.0.0-alpha.2", + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "glob": "^10.3.10", diff --git a/packages/turf-angle/test.js b/packages/turf-angle/test.ts similarity index 85% rename from packages/turf-angle/test.js rename to packages/turf-angle/test.ts index af21dc115..fadfb43a2 100644 --- a/packages/turf-angle/test.js +++ b/packages/turf-angle/test.ts @@ -1,19 +1,14 @@ -const test = require("tape"); -const path = require("path"); -const { glob } = require("glob"); -const { loadJsonFileSync } = require("load-json-file"); -const { writeJsonFileSync } = require("write-json-file"); -const sector = require("@turf/sector").default; -const bearing = require("@turf/bearing").default; -const truncate = require("@turf/truncate").default; -const distance = require("@turf/distance").default; -const { - point, - round, - lineString, - featureCollection, -} = require("@turf/helpers"); -const angle = require("./index").default; +import test from "tape"; +import path from "path"; +import { glob } from "glob"; +import { loadJsonFileSync } from "load-json-file"; +import { writeJsonFileSync } from "write-json-file"; +import sector from "@turf/sector"; +import { bearing } from "@turf/bearing"; +import { truncate } from "@turf/truncate"; +import { distance } from "@turf/distance"; +import { point, round, lineString, featureCollection } from "@turf/helpers"; +import { angle } from "./index"; test("turf-angle", (t) => { glob diff --git a/packages/turf-area/bench.js b/packages/turf-area/bench.ts similarity index 74% rename from packages/turf-area/bench.js rename to packages/turf-area/bench.ts index 5daa8ac15..6a95534e5 100644 --- a/packages/turf-area/bench.js +++ b/packages/turf-area/bench.ts @@ -1,8 +1,8 @@ -const fs = require("fs"); -const path = require("path"); -const { loadJsonFileSync } = require("load-json-file"); -const Benchmark = require("benchmark"); -const area = require("./index").default; +import fs from "fs"; +import path from "path"; +import { loadJsonFileSync } from "load-json-file"; +import Benchmark from "benchmark"; +import { area } from "./index"; // Define fixtures const directory = path.join(__dirname, "test", "in") + path.sep; diff --git a/packages/turf-area/index.ts b/packages/turf-area/index.ts index d6bbfd125..bd98de7ad 100644 --- a/packages/turf-area/index.ts +++ b/packages/turf-area/index.ts @@ -17,9 +17,7 @@ import { geomReduce } from "@turf/meta"; * var addToMap = [polygon] * polygon.properties.area = area */ -export default function area( - geojson: Feature | FeatureCollection | Geometry -) { +function area(geojson: Feature | FeatureCollection | Geometry) { return geomReduce( geojson, (value, geom) => { @@ -122,3 +120,6 @@ function ringArea(coords: number[][]): number { return total * FACTOR; } + +export { area }; +export default area; diff --git a/packages/turf-area/package.json b/packages/turf-area/package.json index 4cce9fd5e..956ece1a2 100644 --- a/packages/turf-area/package.json +++ b/packages/turf-area/package.json @@ -38,15 +38,16 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js" + "test:tape": "tsx test.ts" }, "devDependencies": { + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "load-json-file": "^7.0.1", diff --git a/packages/turf-area/test.js b/packages/turf-area/test.ts similarity index 74% rename from packages/turf-area/test.js rename to packages/turf-area/test.ts index abb51379d..ace5f74b8 100644 --- a/packages/turf-area/test.js +++ b/packages/turf-area/test.ts @@ -1,9 +1,9 @@ -const fs = require("fs"); -const test = require("tape"); -const path = require("path"); -const { loadJsonFileSync } = require("load-json-file"); -const { writeJsonFileSync } = require("write-json-file"); -const area = require("./index").default; +import fs from "fs"; +import test from "tape"; +import path from "path"; +import { loadJsonFileSync } from "load-json-file"; +import { writeJsonFileSync } from "write-json-file"; +import { area } from "./index"; const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-bbox-clip/bench.js b/packages/turf-bbox-clip/bench.ts similarity index 80% rename from packages/turf-bbox-clip/bench.js rename to packages/turf-bbox-clip/bench.ts index 2956fc405..ef947eaf8 100644 --- a/packages/turf-bbox-clip/bench.js +++ b/packages/turf-bbox-clip/bench.ts @@ -1,9 +1,9 @@ -const fs = require("fs"); -const path = require("path"); -const { loadJsonFileSync } = require("load-json-file"); -const Benchmark = require("benchmark"); -const bbox = require("@turf/bbox").default; -const bboxClip = require("./index").default; +import fs from "fs"; +import path from "path"; +import { loadJsonFileSync } from "load-json-file"; +import Benchmark from "benchmark"; +import { bbox } from "@turf/bbox"; +import { bboxClip } from "./index"; const directory = path.join(__dirname, "test", "in") + path.sep; const fixtures = fs.readdirSync(directory).map((filename) => { diff --git a/packages/turf-bbox-clip/index.ts b/packages/turf-bbox-clip/index.ts index 78607dd66..1497748e4 100644 --- a/packages/turf-bbox-clip/index.ts +++ b/packages/turf-bbox-clip/index.ts @@ -35,7 +35,7 @@ import { lineclip, polygonclip } from "./lib/lineclip"; * //addToMap * var addToMap = [bbox, poly, clipped] */ -export default function bboxClip< +function bboxClip< G extends Polygon | MultiPolygon | LineString | MultiLineString, P extends GeoJsonProperties = GeoJsonProperties, >(feature: Feature | G, bbox: BBox) { @@ -91,3 +91,6 @@ function clipPolygon(rings: number[][][], bbox: BBox) { } return outRings; } + +export { bboxClip }; +export default bboxClip; diff --git a/packages/turf-bbox-clip/package.json b/packages/turf-bbox-clip/package.json index a0c353c31..f34b11603 100644 --- a/packages/turf-bbox-clip/package.json +++ b/packages/turf-bbox-clip/package.json @@ -44,16 +44,17 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js" + "test:tape": "tsx test.ts" }, "devDependencies": { "@turf/bbox": "^7.0.0-alpha.2", + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "load-json-file": "^7.0.1", diff --git a/packages/turf-bbox-clip/test.js b/packages/turf-bbox-clip/test.ts similarity index 81% rename from packages/turf-bbox-clip/test.js rename to packages/turf-bbox-clip/test.ts index 96cd393e4..8e8f10e13 100644 --- a/packages/turf-bbox-clip/test.js +++ b/packages/turf-bbox-clip/test.ts @@ -1,11 +1,11 @@ -const fs = require("fs"); -const test = require("tape"); -const path = require("path"); -const { loadJsonFileSync } = require("load-json-file"); -const { writeJsonFileSync } = require("write-json-file"); -const { point, feature, featureCollection } = require("@turf/helpers"); -const turfBBox = require("@turf/bbox").default; -const bboxClip = require("./index").default; +import fs from "fs"; +import test from "tape"; +import path from "path"; +import { loadJsonFileSync } from "load-json-file"; +import { writeJsonFileSync } from "write-json-file"; +import { point, feature, featureCollection } from "@turf/helpers"; +import { bbox as turfBBox } from "@turf/bbox"; +import { bboxClip } from "./index"; const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-bbox-polygon/bench.js b/packages/turf-bbox-polygon/bench.ts similarity index 57% rename from packages/turf-bbox-polygon/bench.js rename to packages/turf-bbox-polygon/bench.ts index ce514e0ab..554b17112 100644 --- a/packages/turf-bbox-polygon/bench.js +++ b/packages/turf-bbox-polygon/bench.ts @@ -1,5 +1,5 @@ -const Benchmark = require("benchmark"); -const bboxpolygon = require("./index").default; +import Benchmark from "benchmark"; +import { bboxPolygon } from "./index"; /** * Benchmark Results @@ -7,6 +7,6 @@ const bboxpolygon = require("./index").default; * turf-bbox-polygon x 3,885,828 ops/sec ±1.20% (86 runs sampled) */ new Benchmark.Suite("turf-bbox-polygon") - .add("turf-bbox-polygon", () => bboxpolygon([0, 0, 10, 10])) + .add("turf-bbox-polygon", () => bboxPolygon([0, 0, 10, 10])) .on("cycle", (e) => console.log(String(e.target))) .run(); diff --git a/packages/turf-bbox-polygon/index.ts b/packages/turf-bbox-polygon/index.ts index 0dabe181c..7da8fd1ee 100644 --- a/packages/turf-bbox-polygon/index.ts +++ b/packages/turf-bbox-polygon/index.ts @@ -18,9 +18,7 @@ import { polygon, Id } from "@turf/helpers"; * //addToMap * var addToMap = [poly] */ -export default function bboxPolygon< - P extends GeoJsonProperties = GeoJsonProperties, ->( +function bboxPolygon

( bbox: BBox, options: { properties?: P; @@ -52,3 +50,6 @@ export default function bboxPolygon< { bbox, id: options.id } ); } + +export { bboxPolygon }; +export default bboxPolygon; diff --git a/packages/turf-bbox-polygon/package.json b/packages/turf-bbox-polygon/package.json index 9fab0db8a..1b7e9490b 100644 --- a/packages/turf-bbox-polygon/package.json +++ b/packages/turf-bbox-polygon/package.json @@ -39,15 +39,16 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js" + "test:tape": "tsx test.ts" }, "devDependencies": { + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "npm-run-all": "^4.1.5", diff --git a/packages/turf-bbox-polygon/test.js b/packages/turf-bbox-polygon/test.ts similarity index 96% rename from packages/turf-bbox-polygon/test.js rename to packages/turf-bbox-polygon/test.ts index 8643ddecf..f06bbb8a4 100644 --- a/packages/turf-bbox-polygon/test.js +++ b/packages/turf-bbox-polygon/test.ts @@ -1,5 +1,5 @@ -const test = require("tape"); -const bboxPolygon = require("./index").default; +import test from "tape"; +import { bboxPolygon } from "./index"; test("bbox-polygon", (t) => { const poly = bboxPolygon([0, 0, 10, 10]); diff --git a/packages/turf-bbox/bench.js b/packages/turf-bbox/bench.ts similarity index 64% rename from packages/turf-bbox/bench.js rename to packages/turf-bbox/bench.ts index ed4a132b0..ec5289355 100644 --- a/packages/turf-bbox/bench.js +++ b/packages/turf-bbox/bench.ts @@ -1,6 +1,6 @@ -const Benchmark = require("benchmark"); -const { lineString } = require("@turf/helpers"); -const bbox = require("./index").default; +import Benchmark from "benchmark"; +import { lineString } from "@turf/helpers"; +import bbox from "./index"; const line = lineString([ [-74, 40], diff --git a/packages/turf-bbox/index.ts b/packages/turf-bbox/index.ts index dbb510ff8..f3a414368 100644 --- a/packages/turf-bbox/index.ts +++ b/packages/turf-bbox/index.ts @@ -46,5 +46,5 @@ function bbox( return result; } -bbox["default"] = bbox; +export { bbox }; export default bbox; diff --git a/packages/turf-bbox/package.json b/packages/turf-bbox/package.json index 0f6a2c376..82efb1c23 100644 --- a/packages/turf-bbox/package.json +++ b/packages/turf-bbox/package.json @@ -40,15 +40,16 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js" + "test:tape": "tsx test.ts" }, "devDependencies": { + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "npm-run-all": "^4.1.5", diff --git a/packages/turf-bbox/test.js b/packages/turf-bbox/test.ts similarity index 95% rename from packages/turf-bbox/test.js rename to packages/turf-bbox/test.ts index 5b8e5ce30..8ec8408f8 100644 --- a/packages/turf-bbox/test.js +++ b/packages/turf-bbox/test.ts @@ -1,5 +1,5 @@ -const test = require("tape"); -const { +import test from "tape"; +import { point, polygon, feature, @@ -7,8 +7,8 @@ const { multiPolygon, multiLineString, featureCollection, -} = require("@turf/helpers"); -const bbox = require("./index").default; +} from "@turf/helpers"; +import { bbox } from "./index"; // Fixtures const pt = point([102.0, 0.5]); diff --git a/packages/turf-bearing/bench.js b/packages/turf-bearing/bench.ts similarity index 77% rename from packages/turf-bearing/bench.js rename to packages/turf-bearing/bench.ts index 29da40524..a73201da2 100644 --- a/packages/turf-bearing/bench.js +++ b/packages/turf-bearing/bench.ts @@ -1,5 +1,5 @@ -const Benchmark = require("benchmark"); -const bearing = require("./index").default; +import Benchmark from "benchmark"; +import { bearing } from "./index"; var start = [-75.4, 39.4]; var end = [-75.534, 39.123]; diff --git a/packages/turf-bearing/index.ts b/packages/turf-bearing/index.ts index 41468f064..dbe25c28c 100644 --- a/packages/turf-bearing/index.ts +++ b/packages/turf-bearing/index.ts @@ -26,7 +26,7 @@ import { getCoord } from "@turf/invariant"; * point2.properties['marker-color'] = '#0f0' * point1.properties.bearing = bearing */ -export default function bearing( +function bearing( start: Coord, end: Coord, options: { @@ -67,3 +67,6 @@ function calculateFinalBearing(start: Coord, end: Coord) { bear = (bear + 180) % 360; return bear; } + +export { bearing }; +export default bearing; diff --git a/packages/turf-bearing/package.json b/packages/turf-bearing/package.json index 1d17af7ed..b1f53dc5e 100644 --- a/packages/turf-bearing/package.json +++ b/packages/turf-bearing/package.json @@ -36,16 +36,17 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js" + "test:tape": "tsx test.ts" }, "devDependencies": { "@turf/destination": "^7.0.0-alpha.2", + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "npm-run-all": "^4.1.5", diff --git a/packages/turf-bearing/test.js b/packages/turf-bearing/test.ts similarity index 79% rename from packages/turf-bearing/test.js rename to packages/turf-bearing/test.ts index f960d0f2f..2f9221aec 100644 --- a/packages/turf-bearing/test.js +++ b/packages/turf-bearing/test.ts @@ -1,9 +1,9 @@ -const path = require("path"); -const test = require("tape"); -const { writeJsonFileSync } = require("write-json-file"); -const destination = require("@turf/destination").default; -const { point, lineString, featureCollection } = require("@turf/helpers"); -const bearing = require("./index").default; +import path from "path"; +import test from "tape"; +import { writeJsonFileSync } from "write-json-file"; +import { destination } from "@turf/destination"; +import { point, lineString, featureCollection } from "@turf/helpers"; +import { bearing } from "./index"; const out = path.join(__dirname, "test", "out") + path.sep; diff --git a/packages/turf-bezier-spline/bench.js b/packages/turf-bezier-spline/bench.ts similarity index 75% rename from packages/turf-bezier-spline/bench.js rename to packages/turf-bezier-spline/bench.ts index 969d1ac4b..315223556 100644 --- a/packages/turf-bezier-spline/bench.js +++ b/packages/turf-bezier-spline/bench.ts @@ -1,8 +1,8 @@ -const fs = require("fs"); -const path = require("path"); -const { loadJsonFileSync } = require("load-json-file"); -const Benchmark = require("benchmark"); -const bezierSpline = require("./index").default; +import fs from "fs"; +import path from "path"; +import { loadJsonFileSync } from "load-json-file"; +import Benchmark from "benchmark"; +import { bezier as bezierSpline } from "./index"; const directory = path.join(__dirname, "test", "in") + path.sep; const fixtures = fs.readdirSync(directory).map((filename) => { diff --git a/packages/turf-bezier-spline/index.ts b/packages/turf-bezier-spline/index.ts index 86d0f4fbe..3d315501c 100644 --- a/packages/turf-bezier-spline/index.ts +++ b/packages/turf-bezier-spline/index.ts @@ -70,4 +70,5 @@ function bezier

( return lineString(coords, options.properties); } +export { bezier }; export default bezier; diff --git a/packages/turf-bezier-spline/package.json b/packages/turf-bezier-spline/package.json index 9f5e70787..65f821f34 100644 --- a/packages/turf-bezier-spline/package.json +++ b/packages/turf-bezier-spline/package.json @@ -39,15 +39,16 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js" + "test:tape": "tsx test.ts" }, "devDependencies": { + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "load-json-file": "^7.0.1", diff --git a/packages/turf-bezier-spline/test.js b/packages/turf-bezier-spline/test.ts similarity index 77% rename from packages/turf-bezier-spline/test.js rename to packages/turf-bezier-spline/test.ts index 81c6dd406..dcb6fdc49 100644 --- a/packages/turf-bezier-spline/test.js +++ b/packages/turf-bezier-spline/test.ts @@ -1,10 +1,10 @@ -const fs = require("fs"); -const test = require("tape"); -const path = require("path"); -const { loadJsonFileSync } = require("load-json-file"); -const { writeJsonFileSync } = require("write-json-file"); -const { featureCollection } = require("@turf/helpers"); -const bezierSpline = require("./index").default; +import fs from "fs"; +import test from "tape"; +import path from "path"; +import { loadJsonFileSync } from "load-json-file"; +import { writeJsonFileSync } from "write-json-file"; +import { featureCollection } from "@turf/helpers"; +import { bezier as bezierSpline } from "./index"; const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-boolean-clockwise/bench.js b/packages/turf-boolean-clockwise/bench.ts similarity index 73% rename from packages/turf-boolean-clockwise/bench.js rename to packages/turf-boolean-clockwise/bench.ts index 6c10a6293..b87d3655e 100755 --- a/packages/turf-boolean-clockwise/bench.js +++ b/packages/turf-boolean-clockwise/bench.ts @@ -1,8 +1,8 @@ -const path = require("path"); -const { glob } = require("glob"); -const Benchmark = require("benchmark"); -const { loadJsonFileSync } = require("load-json-file"); -const isClockwise = require("./index").default; +import path from "path"; +import { glob } from "glob"; +import Benchmark from "benchmark"; +import { loadJsonFileSync } from "load-json-file"; +import { booleanClockwise as isClockwise } from "./index"; /** * Benchmark Results diff --git a/packages/turf-boolean-clockwise/index.ts b/packages/turf-boolean-clockwise/index.ts index c147f3fd8..a0579731e 100644 --- a/packages/turf-boolean-clockwise/index.ts +++ b/packages/turf-boolean-clockwise/index.ts @@ -16,7 +16,7 @@ import { getCoords } from "@turf/invariant"; * turf.booleanClockwise(counterClockwiseRing) * //=false */ -export default function booleanClockwise( +function booleanClockwise( line: Feature | LineString | Position[] ): boolean { const ring = getCoords(line); @@ -33,3 +33,6 @@ export default function booleanClockwise( } return sum > 0; } + +export { booleanClockwise }; +export default booleanClockwise; diff --git a/packages/turf-boolean-clockwise/package.json b/packages/turf-boolean-clockwise/package.json index fca5a0e7d..fec81de1f 100755 --- a/packages/turf-boolean-clockwise/package.json +++ b/packages/turf-boolean-clockwise/package.json @@ -43,15 +43,16 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js" + "test:tape": "tsx test.ts" }, "devDependencies": { + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "glob": "^10.3.10", diff --git a/packages/turf-boolean-clockwise/test.js b/packages/turf-boolean-clockwise/test.ts similarity index 85% rename from packages/turf-boolean-clockwise/test.js rename to packages/turf-boolean-clockwise/test.ts index 62f0bf58a..30de5d4fd 100644 --- a/packages/turf-boolean-clockwise/test.js +++ b/packages/turf-boolean-clockwise/test.ts @@ -1,9 +1,9 @@ -const { glob } = require("glob"); -const path = require("path"); -const test = require("tape"); -const { loadJsonFileSync } = require("load-json-file"); -const { lineString } = require("@turf/helpers"); -const isClockwise = require("./dist/js/index.js").default; +import { glob } from "glob"; +import path from "path"; +import test from "tape"; +import { loadJsonFileSync } from "load-json-file"; +import { lineString } from "@turf/helpers"; +import { booleanClockwise as isClockwise } from "./index"; test("isClockwise#fixtures", (t) => { // True Fixtures diff --git a/packages/turf-boolean-concave/bench.js b/packages/turf-boolean-concave/bench.ts similarity index 77% rename from packages/turf-boolean-concave/bench.js rename to packages/turf-boolean-concave/bench.ts index 06068805c..a40b814ff 100644 --- a/packages/turf-boolean-concave/bench.js +++ b/packages/turf-boolean-concave/bench.ts @@ -1,8 +1,8 @@ -const path = require("path"); -const { glob } = require("glob"); -const Benchmark = require("benchmark"); -const { loadJsonFileSync } = require("load-json-file"); -const concave = require("./index").default; +import path from "path"; +import { glob } from "glob"; +import Benchmark from "benchmark"; +import { loadJsonFileSync } from "load-json-file"; +import { booleanConcave as concave } from "./index"; /** * Benchmark Results diff --git a/packages/turf-boolean-concave/index.ts b/packages/turf-boolean-concave/index.ts index b3bb4b13c..25d97e95c 100644 --- a/packages/turf-boolean-concave/index.ts +++ b/packages/turf-boolean-concave/index.ts @@ -13,7 +13,7 @@ import { getGeom } from "@turf/invariant"; * turf.booleanConcave(convexPolygon) * //=false */ -export default function booleanConcave(polygon: Feature | Polygon) { +function booleanConcave(polygon: Feature | Polygon) { // Taken from https://stackoverflow.com/a/1881201 & https://stackoverflow.com/a/25304159 const coords = getGeom(polygon).coordinates; if (coords[0].length <= 4) { @@ -36,3 +36,6 @@ export default function booleanConcave(polygon: Feature | Polygon) { } return false; } + +export { booleanConcave }; +export default booleanConcave; diff --git a/packages/turf-boolean-concave/package.json b/packages/turf-boolean-concave/package.json index 523ce48c3..dccc30a53 100644 --- a/packages/turf-boolean-concave/package.json +++ b/packages/turf-boolean-concave/package.json @@ -42,15 +42,16 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js" + "test:tape": "tsx test.ts" }, "devDependencies": { + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "glob": "^10.3.10", diff --git a/packages/turf-boolean-concave/test.js b/packages/turf-boolean-concave/test.ts similarity index 79% rename from packages/turf-boolean-concave/test.js rename to packages/turf-boolean-concave/test.ts index 8224328cb..8829a087a 100644 --- a/packages/turf-boolean-concave/test.js +++ b/packages/turf-boolean-concave/test.ts @@ -1,9 +1,9 @@ -const { glob } = require("glob"); -const path = require("path"); -const test = require("tape"); -const { loadJsonFileSync } = require("load-json-file"); -const { polygon } = require("@turf/helpers"); -const isConcave = require("./dist/js/index.js").default; +import { glob } from "glob"; +import path from "path"; +import test from "tape"; +import { loadJsonFileSync } from "load-json-file"; +import { polygon } from "@turf/helpers"; +import { booleanConcave as isConcave } from "./index.js"; test("isConcave#fixtures", (t) => { // True Fixtures diff --git a/packages/turf-boolean-contains/bench.js b/packages/turf-boolean-contains/bench.ts similarity index 94% rename from packages/turf-boolean-contains/bench.js rename to packages/turf-boolean-contains/bench.ts index 4678000f8..ec8b6bece 100644 --- a/packages/turf-boolean-contains/bench.js +++ b/packages/turf-boolean-contains/bench.ts @@ -1,9 +1,9 @@ -const path = require("path"); -const { glob } = require("glob"); -const Benchmark = require("benchmark"); -const { loadJsonFileSync } = require("load-json-file"); -const bbox = require("@turf/bbox").default; -const contains = require("./index").default; +import path from "path"; +import { glob } from "glob"; +import Benchmark from "benchmark"; +import { loadJsonFileSync } from "load-json-file"; +import { bbox } from "@turf/bbox"; +import { booleanContains as contains } from "./index"; /** * Benchmark Results diff --git a/packages/turf-boolean-contains/index.ts b/packages/turf-boolean-contains/index.ts index c49a0f1fd..70cfe1cc0 100644 --- a/packages/turf-boolean-contains/index.ts +++ b/packages/turf-boolean-contains/index.ts @@ -30,7 +30,7 @@ import { getGeom } from "@turf/invariant"; * turf.booleanContains(line, point); * //=true */ -export default function booleanContains( +function booleanContains( feature1: Feature | Geometry, feature2: Feature | Geometry ) { @@ -94,16 +94,13 @@ export default function booleanContains( } } -export function isPolygonInMultiPolygon( - multiPolygon: MultiPolygon, - polygon: Polygon -) { +function isPolygonInMultiPolygon(multiPolygon: MultiPolygon, polygon: Polygon) { return multiPolygon.coordinates.some((coords) => isPolyInPoly({ type: "Polygon", coordinates: coords }, polygon) ); } -export function isPointInMultiPoint(multiPoint: MultiPoint, pt: Point) { +function isPointInMultiPoint(multiPoint: MultiPoint, pt: Point) { let i; let output = false; for (i = 0; i < multiPoint.coordinates.length; i++) { @@ -115,7 +112,7 @@ export function isPointInMultiPoint(multiPoint: MultiPoint, pt: Point) { return output; } -export function isMultiPointInMultiPoint( +function isMultiPointInMultiPoint( multiPoint1: MultiPoint, multiPoint2: MultiPoint ) { @@ -134,10 +131,7 @@ export function isMultiPointInMultiPoint( return true; } -export function isMultiPointOnLine( - lineString: LineString, - multiPoint: MultiPoint -) { +function isMultiPointOnLine(lineString: LineString, multiPoint: MultiPoint) { let haveFoundInteriorPoint = false; for (const coord of multiPoint.coordinates) { if (isPointOnLine(coord, lineString, { ignoreEndVertices: true })) { @@ -153,7 +147,7 @@ export function isMultiPointOnLine( return false; } -export function isMultiPointInPoly(polygon: Polygon, multiPoint: MultiPoint) { +function isMultiPointInPoly(polygon: Polygon, multiPoint: MultiPoint) { for (const coord of multiPoint.coordinates) { if (!booleanPointInPolygon(coord, polygon, { ignoreBoundary: true })) { return false; @@ -162,7 +156,7 @@ export function isMultiPointInPoly(polygon: Polygon, multiPoint: MultiPoint) { return true; } -export function isLineOnLine(lineString1: LineString, lineString2: LineString) { +function isLineOnLine(lineString1: LineString, lineString2: LineString) { let haveFoundInteriorPoint = false; for (const coords of lineString2.coordinates) { if ( @@ -183,7 +177,7 @@ export function isLineOnLine(lineString1: LineString, lineString2: LineString) { return haveFoundInteriorPoint; } -export function isLineInPoly(polygon: Polygon, linestring: LineString) { +function isLineInPoly(polygon: Polygon, linestring: LineString) { let output = false; let i = 0; @@ -218,7 +212,7 @@ export function isLineInPoly(polygon: Polygon, linestring: LineString) { * @param {Geometry|Feature} feature2 Polygon2 * @returns {boolean} true/false */ -export function isPolyInPoly( +function isPolyInPoly( feature1: Feature | Polygon, feature2: Feature | Polygon ) { @@ -247,7 +241,7 @@ export function isPolyInPoly( return true; } -export function doBBoxOverlap(bbox1: BBox, bbox2: BBox) { +function doBBoxOverlap(bbox1: BBox, bbox2: BBox) { if (bbox1[0] > bbox2[0]) { return false; } @@ -271,10 +265,27 @@ export function doBBoxOverlap(bbox1: BBox, bbox2: BBox) { * @param {Position} pair2 point [x,y] * @returns {boolean} true/false if coord pairs match */ -export function compareCoords(pair1: number[], pair2: number[]) { +function compareCoords(pair1: number[], pair2: number[]) { return pair1[0] === pair2[0] && pair1[1] === pair2[1]; } -export function getMidpoint(pair1: number[], pair2: number[]) { +function getMidpoint(pair1: number[], pair2: number[]) { return [(pair1[0] + pair2[0]) / 2, (pair1[1] + pair2[1]) / 2]; } + +export { + booleanContains, + isPolygonInMultiPolygon, + isPointInMultiPoint, + isMultiPointInMultiPoint, + isMultiPointOnLine, + isMultiPointInPoly, + isLineOnLine, + isLineInPoly, + isPolyInPoly, + doBBoxOverlap, + compareCoords, + getMidpoint, +}; + +export default booleanContains; diff --git a/packages/turf-boolean-contains/package.json b/packages/turf-boolean-contains/package.json index ee547c9df..8d7770705 100644 --- a/packages/turf-boolean-contains/package.json +++ b/packages/turf-boolean-contains/package.json @@ -42,15 +42,16 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js" + "test:tape": "tsx test.ts" }, "devDependencies": { + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "boolean-jsts": "*", diff --git a/packages/turf-boolean-contains/test.js b/packages/turf-boolean-contains/test.ts similarity index 83% rename from packages/turf-boolean-contains/test.js rename to packages/turf-boolean-contains/test.ts index 2ead3a81e..8fc8de0bd 100644 --- a/packages/turf-boolean-contains/test.js +++ b/packages/turf-boolean-contains/test.ts @@ -1,11 +1,11 @@ -const { glob } = require("glob"); -const path = require("path"); -const test = require("tape"); -const { loadJsonFileSync } = require("load-json-file"); -const { point } = require("@turf/helpers"); -const booleanJSTS = require("boolean-jsts"); -const shapely = require("boolean-shapely"); -const contains = require("./index").default; +import { glob } from "glob"; +import path from "path"; +import test from "tape"; +import { loadJsonFileSync } from "load-json-file"; +import { point } from "@turf/helpers"; +import booleanJSTS from "boolean-jsts"; +import shapely from "boolean-shapely"; +import { booleanContains as contains } from "./index"; test("turf-boolean-contains", (t) => { // True Fixtures diff --git a/packages/turf-boolean-crosses/bench.js b/packages/turf-boolean-crosses/bench.ts similarity index 87% rename from packages/turf-boolean-crosses/bench.js rename to packages/turf-boolean-crosses/bench.ts index 74d3c6c93..5560880dd 100644 --- a/packages/turf-boolean-crosses/bench.js +++ b/packages/turf-boolean-crosses/bench.ts @@ -1,8 +1,8 @@ -const path = require("path"); -const { glob } = require("glob"); -const Benchmark = require("benchmark"); -const { loadJsonFileSync } = require("load-json-file"); -const crosses = require("./index").default; +import path from "path"; +import { glob } from "glob"; +import Benchmark from "benchmark"; +import { loadJsonFileSync } from "load-json-file"; +import { booleanCrosses as crosses } from "./index"; /** * Benchmark Results diff --git a/packages/turf-boolean-crosses/index.ts b/packages/turf-boolean-crosses/index.ts index f84d5d9ff..588d6685c 100644 --- a/packages/turf-boolean-crosses/index.ts +++ b/packages/turf-boolean-crosses/index.ts @@ -196,4 +196,5 @@ function isPointOnLineSegment( } } +export { booleanCrosses }; export default booleanCrosses; diff --git a/packages/turf-boolean-crosses/package.json b/packages/turf-boolean-crosses/package.json index 458bc8b0d..a73440e34 100644 --- a/packages/turf-boolean-crosses/package.json +++ b/packages/turf-boolean-crosses/package.json @@ -42,15 +42,16 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js" + "test:tape": "tsx test.ts" }, "devDependencies": { + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "boolean-shapely": "*", diff --git a/packages/turf-boolean-crosses/test.js b/packages/turf-boolean-crosses/test.ts similarity index 82% rename from packages/turf-boolean-crosses/test.js rename to packages/turf-boolean-crosses/test.ts index 311ffdd91..df685bcfb 100644 --- a/packages/turf-boolean-crosses/test.js +++ b/packages/turf-boolean-crosses/test.ts @@ -1,9 +1,9 @@ -const test = require("tape"); -const { glob } = require("glob"); -const path = require("path"); -const { loadJsonFileSync } = require("load-json-file"); -const shapely = require("boolean-shapely"); -const crosses = require("./index").default; +import test from "tape"; +import { glob } from "glob"; +import path from "path"; +import { loadJsonFileSync } from "load-json-file"; +import shapely from "boolean-shapely"; +import { booleanCrosses as crosses } from "./index"; test("turf-boolean-crosses", (t) => { // True Fixtures diff --git a/packages/turf-boolean-disjoint/bench.js b/packages/turf-boolean-disjoint/bench.ts similarity index 93% rename from packages/turf-boolean-disjoint/bench.js rename to packages/turf-boolean-disjoint/bench.ts index fdc470743..10bb47ed1 100644 --- a/packages/turf-boolean-disjoint/bench.js +++ b/packages/turf-boolean-disjoint/bench.ts @@ -1,8 +1,8 @@ -const path = require("path"); -const { glob } = require("glob"); -const { loadJsonFileSync } = require("load-json-file"); -const Benchmark = require("benchmark"); -const disjoint = require("./index").default; +import path from "path"; +import { glob } from "glob"; +import { loadJsonFileSync } from "load-json-file"; +import Benchmark from "benchmark"; +import { booleanDisjoint as disjoint } from "./index"; /** * Benchmark Results diff --git a/packages/turf-boolean-disjoint/index.ts b/packages/turf-boolean-disjoint/index.ts index 8a62b5d50..ea222ed69 100644 --- a/packages/turf-boolean-disjoint/index.ts +++ b/packages/turf-boolean-disjoint/index.ts @@ -185,4 +185,5 @@ function compareCoords(pair1: number[], pair2: number[]) { return pair1[0] === pair2[0] && pair1[1] === pair2[1]; } +export { booleanDisjoint }; export default booleanDisjoint; diff --git a/packages/turf-boolean-disjoint/package.json b/packages/turf-boolean-disjoint/package.json index f633dc499..78fcf88e5 100644 --- a/packages/turf-boolean-disjoint/package.json +++ b/packages/turf-boolean-disjoint/package.json @@ -42,15 +42,16 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js" + "test:tape": "tsx test.ts" }, "devDependencies": { + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "boolean-shapely": "*", diff --git a/packages/turf-boolean-disjoint/test.js b/packages/turf-boolean-disjoint/test.ts similarity index 83% rename from packages/turf-boolean-disjoint/test.js rename to packages/turf-boolean-disjoint/test.ts index 8eb6604a9..b0c12070d 100644 --- a/packages/turf-boolean-disjoint/test.js +++ b/packages/turf-boolean-disjoint/test.ts @@ -1,9 +1,9 @@ -const { glob } = require("glob"); -const path = require("path"); -const test = require("tape"); -const { loadJsonFileSync } = require("load-json-file"); -const shapely = require("boolean-shapely"); -const disjoint = require("./index").default; +import { glob } from "glob"; +import path from "path"; +import test from "tape"; +import { loadJsonFileSync } from "load-json-file"; +import shapely from "boolean-shapely"; +import { booleanDisjoint as disjoint } from "./index"; test("turf-boolean-disjoint", (t) => { // True Fixtures diff --git a/packages/turf-boolean-equal/bench.js b/packages/turf-boolean-equal/bench.ts similarity index 87% rename from packages/turf-boolean-equal/bench.js rename to packages/turf-boolean-equal/bench.ts index 7203d45d1..9de3b7cb3 100644 --- a/packages/turf-boolean-equal/bench.js +++ b/packages/turf-boolean-equal/bench.ts @@ -1,8 +1,8 @@ -const path = require("path"); -const { glob } = require("glob"); -const { loadJsonFileSync } = require("load-json-file"); -const Benchmark = require("benchmark"); -const equal = require("./index").default; +import path from "path"; +import { glob } from "glob"; +import { loadJsonFileSync } from "load-json-file"; +import Benchmark from "benchmark"; +import { booleanEqual as equal } from "./index"; /** * Benchmark Results diff --git a/packages/turf-boolean-equal/index.ts b/packages/turf-boolean-equal/index.ts index a9d123106..c7eb812b2 100644 --- a/packages/turf-boolean-equal/index.ts +++ b/packages/turf-boolean-equal/index.ts @@ -49,4 +49,5 @@ function booleanEqual( return equality.compare(cleanCoords(feature1), cleanCoords(feature2)); } +export { booleanEqual }; export default booleanEqual; diff --git a/packages/turf-boolean-equal/package.json b/packages/turf-boolean-equal/package.json index 97cc9335e..eacfab54e 100644 --- a/packages/turf-boolean-equal/package.json +++ b/packages/turf-boolean-equal/package.json @@ -45,15 +45,16 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js" + "test:tape": "tsx test.ts" }, "devDependencies": { + "@types/benchmark": "^2.1.5", "@types/geojson-equality": "^0.2.2", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", diff --git a/packages/turf-boolean-equal/test.js b/packages/turf-boolean-equal/test.ts similarity index 90% rename from packages/turf-boolean-equal/test.js rename to packages/turf-boolean-equal/test.ts index da3675e33..c0346666f 100644 --- a/packages/turf-boolean-equal/test.js +++ b/packages/turf-boolean-equal/test.ts @@ -1,10 +1,10 @@ -const { glob } = require("glob"); -const path = require("path"); -const test = require("tape"); -const { loadJsonFileSync } = require("load-json-file"); -const shapely = require("boolean-shapely"); -const { point, lineString, polygon } = require("@turf/helpers"); -const equal = require("./index").default; +import { glob } from "glob"; +import path from "path"; +import test from "tape"; +import { loadJsonFileSync } from "load-json-file"; +import shapely from "boolean-shapely"; +import { point, lineString, polygon } from "@turf/helpers"; +import { booleanEqual as equal } from "./index"; test("turf-boolean-equal", (t) => { // True Fixtures diff --git a/packages/turf-boolean-intersects/bench.js b/packages/turf-boolean-intersects/bench.ts similarity index 93% rename from packages/turf-boolean-intersects/bench.js rename to packages/turf-boolean-intersects/bench.ts index 11aae4cf7..2db4d67b2 100644 --- a/packages/turf-boolean-intersects/bench.js +++ b/packages/turf-boolean-intersects/bench.ts @@ -1,8 +1,8 @@ -const path = require("path"); -const { glob } = require("glob"); -const { loadJsonFileSync } = require("load-json-file"); -const Benchmark = require("benchmark"); -const intersects = require("./index").default; +import path from "path"; +import { glob } from "glob"; +import { loadJsonFileSync } from "load-json-file"; +import Benchmark from "benchmark"; +import { booleanIntersects as intersects } from "./index"; /** * Benchmark Results diff --git a/packages/turf-boolean-intersects/index.ts b/packages/turf-boolean-intersects/index.ts index 49b6fe223..807f8dd7c 100644 --- a/packages/turf-boolean-intersects/index.ts +++ b/packages/turf-boolean-intersects/index.ts @@ -16,7 +16,7 @@ import { flattenEach } from "@turf/meta"; * turf.booleanIntersects(line, point); * //=true */ -export default function booleanIntersects( +function booleanIntersects( feature1: Feature | Geometry, feature2: Feature | Geometry ) { @@ -31,3 +31,6 @@ export default function booleanIntersects( }); return bool; } + +export { booleanIntersects }; +export default booleanIntersects; diff --git a/packages/turf-boolean-intersects/package.json b/packages/turf-boolean-intersects/package.json index 9eb6f5929..e81f1bec1 100644 --- a/packages/turf-boolean-intersects/package.json +++ b/packages/turf-boolean-intersects/package.json @@ -42,15 +42,16 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js" + "test:tape": "tsx test.ts" }, "devDependencies": { + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "boolean-shapely": "*", diff --git a/packages/turf-boolean-intersects/test.js b/packages/turf-boolean-intersects/test.ts similarity index 83% rename from packages/turf-boolean-intersects/test.js rename to packages/turf-boolean-intersects/test.ts index f0cf85a64..e79d797a3 100644 --- a/packages/turf-boolean-intersects/test.js +++ b/packages/turf-boolean-intersects/test.ts @@ -1,9 +1,9 @@ -const { glob } = require("glob"); -const path = require("path"); -const test = require("tape"); -const { loadJsonFileSync } = require("load-json-file"); -const shapely = require("boolean-shapely"); -const intersects = require("./index").default; +import { glob } from "glob"; +import path from "path"; +import test from "tape"; +import { loadJsonFileSync } from "load-json-file"; +import shapely from "boolean-shapely"; +import { booleanIntersects as intersects } from "./index"; test("turf-boolean-intersects", (t) => { // True Fixtures diff --git a/packages/turf-boolean-overlap/bench.js b/packages/turf-boolean-overlap/bench.ts similarity index 90% rename from packages/turf-boolean-overlap/bench.js rename to packages/turf-boolean-overlap/bench.ts index c8691c762..ca5f9b93d 100755 --- a/packages/turf-boolean-overlap/bench.js +++ b/packages/turf-boolean-overlap/bench.ts @@ -1,8 +1,8 @@ -const path = require("path"); -const { glob } = require("glob"); -const { loadJsonFileSync } = require("load-json-file"); -const Benchmark = require("benchmark"); -const overlap = require("./index").default; +import path from "path"; +import { glob } from "glob"; +import { loadJsonFileSync } from "load-json-file"; +import Benchmark from "benchmark"; +import { booleanOverlap as overlap } from "./index"; /** * Benchmark Results diff --git a/packages/turf-boolean-overlap/index.ts b/packages/turf-boolean-overlap/index.ts index 5526799e8..3928a53d4 100644 --- a/packages/turf-boolean-overlap/index.ts +++ b/packages/turf-boolean-overlap/index.ts @@ -26,7 +26,7 @@ import GeojsonEquality from "geojson-equality"; * turf.booleanOverlap(poly2, poly3) * //=false */ -export default function booleanOverlap( +function booleanOverlap( feature1: Feature | Geometry, feature2: Feature | Geometry ): boolean { @@ -88,3 +88,6 @@ export default function booleanOverlap( return overlap > 0; } + +export { booleanOverlap }; +export default booleanOverlap; diff --git a/packages/turf-boolean-overlap/package.json b/packages/turf-boolean-overlap/package.json index 0d6441f22..1951217be 100755 --- a/packages/turf-boolean-overlap/package.json +++ b/packages/turf-boolean-overlap/package.json @@ -44,15 +44,16 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js" + "test:tape": "tsx test.ts" }, "devDependencies": { + "@types/benchmark": "^2.1.5", "@types/geojson-equality": "^0.2.2", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", diff --git a/packages/turf-boolean-overlap/test.js b/packages/turf-boolean-overlap/test.ts similarity index 91% rename from packages/turf-boolean-overlap/test.js rename to packages/turf-boolean-overlap/test.ts index c82a392ed..c9a945bb4 100644 --- a/packages/turf-boolean-overlap/test.js +++ b/packages/turf-boolean-overlap/test.ts @@ -1,16 +1,16 @@ -const { glob } = require("glob"); -const path = require("path"); -const test = require("tape"); -const { loadJsonFileSync } = require("load-json-file"); -const shapely = require("boolean-shapely"); -const { +import { glob } from "glob"; +import path from "path"; +import test from "tape"; +import { loadJsonFileSync } from "load-json-file"; +import shapely from "boolean-shapely"; +import { point, lineString, polygon, multiLineString, multiPolygon, -} = require("@turf/helpers"); -const overlap = require("./index").default; +} from "@turf/helpers"; +import { booleanOverlap as overlap } from "./index"; test("turf-boolean-overlap", (t) => { // True Fixtures diff --git a/packages/turf-boolean-parallel/bench.js b/packages/turf-boolean-parallel/bench.ts similarity index 87% rename from packages/turf-boolean-parallel/bench.js rename to packages/turf-boolean-parallel/bench.ts index 02a908c39..5cd24ea4d 100644 --- a/packages/turf-boolean-parallel/bench.js +++ b/packages/turf-boolean-parallel/bench.ts @@ -1,8 +1,8 @@ -const path = require("path"); -const { glob } = require("glob"); -const { loadJsonFileSync } = require("load-json-file"); -const Benchmark = require("benchmark"); -const booleanParallel = require("./index").default; +import path from "path"; +import { glob } from "glob"; +import { loadJsonFileSync } from "load-json-file"; +import Benchmark from "benchmark"; +import { booleanParallel } from "./index"; /** * Benchmark Results diff --git a/packages/turf-boolean-parallel/index.ts b/packages/turf-boolean-parallel/index.ts index 5b055138d..fccf6e333 100644 --- a/packages/turf-boolean-parallel/index.ts +++ b/packages/turf-boolean-parallel/index.ts @@ -71,4 +71,5 @@ function getType(geojson: Geometry | Feature, name: string) { throw new Error("Invalid GeoJSON object for " + name); } +export { booleanParallel }; export default booleanParallel; diff --git a/packages/turf-boolean-parallel/package.json b/packages/turf-boolean-parallel/package.json index 5b247901b..37f89193e 100644 --- a/packages/turf-boolean-parallel/package.json +++ b/packages/turf-boolean-parallel/package.json @@ -41,15 +41,16 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js" + "test:tape": "tsx test.ts" }, "devDependencies": { + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "load-json-file": "^7.0.1", diff --git a/packages/turf-boolean-parallel/test.js b/packages/turf-boolean-parallel/test.ts similarity index 82% rename from packages/turf-boolean-parallel/test.js rename to packages/turf-boolean-parallel/test.ts index e438a6088..5cbe9979b 100644 --- a/packages/turf-boolean-parallel/test.js +++ b/packages/turf-boolean-parallel/test.ts @@ -1,9 +1,9 @@ -const { glob } = require("glob"); -const path = require("path"); -const test = require("tape"); -const { loadJsonFileSync } = require("load-json-file"); -const { lineString } = require("@turf/helpers"); -const booleanParallel = require("./dist/js/index.js").default; +import { glob } from "glob"; +import path from "path"; +import test from "tape"; +import { loadJsonFileSync } from "load-json-file"; +import { lineString } from "@turf/helpers"; +import { booleanParallel } from "./index"; test("turf-boolean-parallel", (t) => { // True Fixtures diff --git a/packages/turf-boolean-point-in-polygon/bench.js b/packages/turf-boolean-point-in-polygon/bench.ts similarity index 84% rename from packages/turf-boolean-point-in-polygon/bench.js rename to packages/turf-boolean-point-in-polygon/bench.ts index c70091220..0e1032f5f 100644 --- a/packages/turf-boolean-point-in-polygon/bench.js +++ b/packages/turf-boolean-point-in-polygon/bench.ts @@ -1,7 +1,7 @@ -const fs = require("fs"); -const Benchmark = require("benchmark"); -const { point, polygon } = require("@turf/helpers"); -const booleanPointInPolygon = require("./index").default; +import fs from "fs"; +import Benchmark from "benchmark"; +import { point, polygon } from "@turf/helpers"; +import { booleanPointInPolygon } from "./index"; var poly = polygon([ [ diff --git a/packages/turf-boolean-point-in-polygon/index.ts b/packages/turf-boolean-point-in-polygon/index.ts index f51168983..b114d927c 100644 --- a/packages/turf-boolean-point-in-polygon/index.ts +++ b/packages/turf-boolean-point-in-polygon/index.ts @@ -36,7 +36,7 @@ import { getCoord, getGeom } from "@turf/invariant"; * turf.booleanPointInPolygon(pt, poly); * //= true */ -export default function booleanPointInPolygon< +function booleanPointInPolygon< G extends Polygon | MultiPolygon, P extends GeoJsonProperties = GeoJsonProperties, >( @@ -91,3 +91,6 @@ function inBBox(pt: number[], bbox: BBox) { bbox[0] <= pt[0] && bbox[1] <= pt[1] && bbox[2] >= pt[0] && bbox[3] >= pt[1] ); } + +export { booleanPointInPolygon }; +export default booleanPointInPolygon; diff --git a/packages/turf-boolean-point-in-polygon/package.json b/packages/turf-boolean-point-in-polygon/package.json index 83bd013a6..0dcdefe75 100644 --- a/packages/turf-boolean-point-in-polygon/package.json +++ b/packages/turf-boolean-point-in-polygon/package.json @@ -40,15 +40,16 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js" + "test:tape": "tsx test.ts" }, "devDependencies": { + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "npm-run-all": "^4.1.5", diff --git a/packages/turf-boolean-point-in-polygon/test.js b/packages/turf-boolean-point-in-polygon/test.ts similarity index 96% rename from packages/turf-boolean-point-in-polygon/test.js rename to packages/turf-boolean-point-in-polygon/test.ts index aaac1ecb0..15eea40ad 100644 --- a/packages/turf-boolean-point-in-polygon/test.js +++ b/packages/turf-boolean-point-in-polygon/test.ts @@ -1,8 +1,8 @@ -const fs = require("fs"); -const test = require("tape"); -const { point } = require("@turf/helpers"); -const { polygon } = require("@turf/helpers"); -const booleanPointInPolygon = require("./index").default; +import fs from "fs"; +import test from "tape"; +import { point } from "@turf/helpers"; +import { polygon } from "@turf/helpers"; +import { booleanPointInPolygon } from "./index"; test("boolean-point-in-polygon -- featureCollection", function (t) { // test for a simple polygon diff --git a/packages/turf-boolean-point-on-line/bench.js b/packages/turf-boolean-point-on-line/bench.ts similarity index 86% rename from packages/turf-boolean-point-on-line/bench.js rename to packages/turf-boolean-point-on-line/bench.ts index 2ccc2d2f5..607ac5c41 100644 --- a/packages/turf-boolean-point-on-line/bench.js +++ b/packages/turf-boolean-point-on-line/bench.ts @@ -1,8 +1,8 @@ -const path = require("path"); -const { glob } = require("glob"); -const { loadJsonFileSync } = require("load-json-file"); -const Benchmark = require("benchmark"); -const booleanPointOnLine = require("./index").default; +import path from "path"; +import { glob } from "glob"; +import { loadJsonFileSync } from "load-json-file"; +import Benchmark from "benchmark"; +import { booleanPointOnLine } from "./index"; /** * Benchmark Results diff --git a/packages/turf-boolean-point-on-line/index.ts b/packages/turf-boolean-point-on-line/index.ts index 46debb799..3d36c316b 100644 --- a/packages/turf-boolean-point-on-line/index.ts +++ b/packages/turf-boolean-point-on-line/index.ts @@ -121,4 +121,5 @@ function isPointOnLineSegment( return false; } +export { booleanPointOnLine }; export default booleanPointOnLine; diff --git a/packages/turf-boolean-point-on-line/package.json b/packages/turf-boolean-point-on-line/package.json index f20ab6442..fcdf427e7 100644 --- a/packages/turf-boolean-point-on-line/package.json +++ b/packages/turf-boolean-point-on-line/package.json @@ -39,15 +39,16 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js" + "test:tape": "tsx test.ts" }, "devDependencies": { + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "glob": "^10.3.10", diff --git a/packages/turf-boolean-point-on-line/test.js b/packages/turf-boolean-point-on-line/test.ts similarity index 83% rename from packages/turf-boolean-point-on-line/test.js rename to packages/turf-boolean-point-on-line/test.ts index 2d46d9c78..2da0a3447 100644 --- a/packages/turf-boolean-point-on-line/test.js +++ b/packages/turf-boolean-point-on-line/test.ts @@ -1,8 +1,8 @@ -const { glob } = require("glob"); -const path = require("path"); -const test = require("tape"); -const { loadJsonFileSync } = require("load-json-file"); -const pointOnLine = require("./index").default; +import { glob } from "glob"; +import path from "path"; +import test from "tape"; +import { loadJsonFileSync } from "load-json-file"; +import { booleanPointOnLine as pointOnLine } from "./index"; test("turf-boolean-point-on-line", (t) => { // True Fixtures diff --git a/packages/turf-boolean-touches/bench.js b/packages/turf-boolean-touches/bench.ts similarity index 91% rename from packages/turf-boolean-touches/bench.js rename to packages/turf-boolean-touches/bench.ts index fa0afaf12..7e40534fe 100644 --- a/packages/turf-boolean-touches/bench.js +++ b/packages/turf-boolean-touches/bench.ts @@ -1,8 +1,8 @@ -const path = require("path"); -const { glob } = require("glob"); -const { loadJsonFileSync } = require("load-json-file"); -const Benchmark = require("benchmark"); -const touches = require("./index").default; +import path from "path"; +import { glob } from "glob"; +import { loadJsonFileSync } from "load-json-file"; +import Benchmark from "benchmark"; +import { booleanTouches as touches } from "./index"; /** * Benchmark Results diff --git a/packages/turf-boolean-touches/index.ts b/packages/turf-boolean-touches/index.ts index 9f588bb1e..3077ce94f 100644 --- a/packages/turf-boolean-touches/index.ts +++ b/packages/turf-boolean-touches/index.ts @@ -790,4 +790,5 @@ function compareCoords(pair1: number[], pair2: number[]) { return pair1[0] === pair2[0] && pair1[1] === pair2[1]; } +export { booleanTouches }; export default booleanTouches; diff --git a/packages/turf-boolean-touches/package.json b/packages/turf-boolean-touches/package.json index eee4db0a5..f74fa67b4 100644 --- a/packages/turf-boolean-touches/package.json +++ b/packages/turf-boolean-touches/package.json @@ -43,16 +43,17 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js", + "test:tape": "tsx test.ts", "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" }, "devDependencies": { + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "boolean-jsts": "*", diff --git a/packages/turf-boolean-touches/test.js b/packages/turf-boolean-touches/test.ts similarity index 84% rename from packages/turf-boolean-touches/test.js rename to packages/turf-boolean-touches/test.ts index 9b1b7a10c..62f0d357d 100644 --- a/packages/turf-boolean-touches/test.js +++ b/packages/turf-boolean-touches/test.ts @@ -1,10 +1,10 @@ -const { glob } = require("glob"); -const path = require("path"); -const test = require("tape"); -const { loadJsonFileSync } = require("load-json-file"); -const shapely = require("boolean-shapely"); -const booleanJSTS = require("boolean-jsts"); -const touches = require("./index").default; +import { glob } from "glob"; +import path from "path"; +import test from "tape"; +import { loadJsonFileSync } from "load-json-file"; +import shapely from "boolean-shapely"; +import booleanJSTS from "boolean-jsts"; +import { booleanTouches as touches } from "./index"; test("turf-boolean-touches", (t) => { // True Fixtures diff --git a/packages/turf-boolean-valid/bench.js b/packages/turf-boolean-valid/bench.ts similarity index 68% rename from packages/turf-boolean-valid/bench.js rename to packages/turf-boolean-valid/bench.ts index 219e9865d..6e20a4f76 100644 --- a/packages/turf-boolean-valid/bench.js +++ b/packages/turf-boolean-valid/bench.ts @@ -1,9 +1,9 @@ -const path = require("path"); -const { glob } = require("glob"); -const Benchmark = require("benchmark"); -const { loadJsonFileSync } = require("load-json-file"); -const bbox = require("@turf/bbox").default; -const isValid = require("./index").default; +import path from "path"; +import { glob } from "glob"; +import Benchmark from "benchmark"; +import { loadJsonFileSync } from "load-json-file"; +import { bbox } from "@turf/bbox"; +import { booleanValid as isValid } from "./index"; /** * Benchmark Results diff --git a/packages/turf-boolean-valid/index.ts b/packages/turf-boolean-valid/index.ts index 1f811a58d..8a5678dd8 100644 --- a/packages/turf-boolean-valid/index.ts +++ b/packages/turf-boolean-valid/index.ts @@ -18,7 +18,7 @@ import isPointOnLine from "@turf/boolean-point-on-line"; * turf.booleanValid(line); // => true * turf.booleanValid({foo: "bar"}); // => false */ -export default function booleanValid(feature: Feature | Geometry) { +function booleanValid(feature: Feature | Geometry) { // Automatic False if (!feature.type) return false; @@ -119,3 +119,6 @@ function checkPolygonAgainstOthers( } return true; } + +export { booleanValid }; +export default booleanValid; diff --git a/packages/turf-boolean-valid/package.json b/packages/turf-boolean-valid/package.json index 487f961e7..294822d6f 100644 --- a/packages/turf-boolean-valid/package.json +++ b/packages/turf-boolean-valid/package.json @@ -42,15 +42,16 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js" + "test:tape": "tsx test.ts" }, "devDependencies": { + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "boolean-jsts": "*", diff --git a/packages/turf-boolean-valid/test.js b/packages/turf-boolean-valid/test.ts similarity index 83% rename from packages/turf-boolean-valid/test.js rename to packages/turf-boolean-valid/test.ts index c89e91f82..813c92235 100644 --- a/packages/turf-boolean-valid/test.js +++ b/packages/turf-boolean-valid/test.ts @@ -1,9 +1,8 @@ -const { glob } = require("glob"); -const path = require("path"); -const test = require("tape"); -const { loadJsonFileSync } = require("load-json-file"); -// const shapely = require('boolean-shapely'); -const isValid = require("./index").default; +import { glob } from "glob"; +import path from "path"; +import test from "tape"; +import { loadJsonFileSync } from "load-json-file"; +import { booleanValid as isValid } from "./index"; test("turf-boolean-valid", (t) => { // True Fixtures diff --git a/packages/turf-boolean-within/bench.js b/packages/turf-boolean-within/bench.ts similarity index 92% rename from packages/turf-boolean-within/bench.js rename to packages/turf-boolean-within/bench.ts index dab044f10..7e9619bdf 100644 --- a/packages/turf-boolean-within/bench.js +++ b/packages/turf-boolean-within/bench.ts @@ -1,8 +1,8 @@ -const path = require("path"); -const { glob } = require("glob"); -const { loadJsonFileSync } = require("load-json-file"); -const Benchmark = require("benchmark"); -const within = require("./index").default; +import path from "path"; +import { glob } from "glob"; +import { loadJsonFileSync } from "load-json-file"; +import Benchmark from "benchmark"; +import { booleanWithin as within } from "./index"; /** * Benchmark Results diff --git a/packages/turf-boolean-within/index.ts b/packages/turf-boolean-within/index.ts index d314c2d9c..4f900300b 100644 --- a/packages/turf-boolean-within/index.ts +++ b/packages/turf-boolean-within/index.ts @@ -8,9 +8,9 @@ import { Point, Polygon, } from "geojson"; -import calcBbox from "@turf/bbox"; -import booleanPointOnLine from "@turf/boolean-point-on-line"; -import booleanPointInPolygon from "@turf/boolean-point-in-polygon"; +import { bbox as calcBbox } from "@turf/bbox"; +import { booleanPointOnLine } from "@turf/boolean-point-on-line"; +import { booleanPointInPolygon } from "@turf/boolean-point-in-polygon"; import { getGeom } from "@turf/invariant"; /** @@ -252,4 +252,5 @@ function getMidpoint(pair1: number[], pair2: number[]) { return [(pair1[0] + pair2[0]) / 2, (pair1[1] + pair2[1]) / 2]; } +export { booleanWithin }; export default booleanWithin; diff --git a/packages/turf-boolean-within/package.json b/packages/turf-boolean-within/package.json index 3ea12b4d4..3a72cf94f 100644 --- a/packages/turf-boolean-within/package.json +++ b/packages/turf-boolean-within/package.json @@ -43,16 +43,17 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js", + "test:tape": "tsx test.ts", "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" }, "devDependencies": { + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "boolean-jsts": "*", diff --git a/packages/turf-boolean-within/test.js b/packages/turf-boolean-within/test.ts similarity index 84% rename from packages/turf-boolean-within/test.js rename to packages/turf-boolean-within/test.ts index a13afc9f3..a2382300c 100644 --- a/packages/turf-boolean-within/test.js +++ b/packages/turf-boolean-within/test.ts @@ -1,10 +1,10 @@ -const { glob } = require("glob"); -const path = require("path"); -const test = require("tape"); -const { loadJsonFileSync } = require("load-json-file"); -const shapely = require("boolean-shapely"); -const booleanJSTS = require("boolean-jsts"); -const within = require("./index").default; +import { glob } from "glob"; +import path from "path"; +import test from "tape"; +import { loadJsonFileSync } from "load-json-file"; +import shapely from "boolean-shapely"; +import booleanJSTS from "boolean-jsts"; +import { booleanWithin as within } from "./index"; test("turf-boolean-within", (t) => { // True Fixtures diff --git a/packages/turf-buffer/bench.js b/packages/turf-buffer/bench.ts similarity index 98% rename from packages/turf-buffer/bench.js rename to packages/turf-buffer/bench.ts index 2d32f250c..481ab065f 100644 --- a/packages/turf-buffer/bench.js +++ b/packages/turf-buffer/bench.ts @@ -2,7 +2,7 @@ import fs from "fs"; import path from "path"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import buffer from "./index"; +import { buffer } from "./index"; const directory = path.join(__dirname, "test", "in") + path.sep; const fixtures = fs.readdirSync(directory).map((filename) => { diff --git a/packages/turf-buffer/index.d.ts b/packages/turf-buffer/index.d.ts index 69abc783d..2dd6de202 100644 --- a/packages/turf-buffer/index.d.ts +++ b/packages/turf-buffer/index.d.ts @@ -38,4 +38,5 @@ declare function buffer( options?: Options ): FeatureCollection; +export { buffer }; export default buffer; diff --git a/packages/turf-buffer/index.js b/packages/turf-buffer/index.js index 8c51ff419..9197738d1 100644 --- a/packages/turf-buffer/index.js +++ b/packages/turf-buffer/index.js @@ -180,4 +180,5 @@ function defineProjection(geojson) { return geoAzimuthalEquidistant().rotate(rotation).scale(earthRadius); } +export { buffer }; export default buffer; diff --git a/packages/turf-buffer/package.json b/packages/turf-buffer/package.json index fbfea0302..3260e586f 100644 --- a/packages/turf-buffer/package.json +++ b/packages/turf-buffer/package.json @@ -47,11 +47,11 @@ "index.d.ts" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "rollup -c ../../rollup.config.js && echo '{\"type\":\"module\"}' > dist/es/package.json", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js", + "test:tape": "tsx test.ts", "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" }, "devDependencies": { diff --git a/packages/turf-buffer/test.js b/packages/turf-buffer/test.ts similarity index 99% rename from packages/turf-buffer/test.js rename to packages/turf-buffer/test.ts index d6693e140..f36d819c2 100644 --- a/packages/turf-buffer/test.js +++ b/packages/turf-buffer/test.ts @@ -11,7 +11,7 @@ import { polygon, geometryCollection, } from "@turf/helpers"; -import buffer from "./index"; +import { buffer } from "./index"; const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-center-mean/bench.js b/packages/turf-center-mean/bench.ts similarity index 83% rename from packages/turf-center-mean/bench.js rename to packages/turf-center-mean/bench.ts index cdec2920a..3bb1fff22 100644 --- a/packages/turf-center-mean/bench.js +++ b/packages/turf-center-mean/bench.ts @@ -1,8 +1,8 @@ -const path = require("path"); -const { glob } = require("glob"); -const { loadJsonFileSync } = require("load-json-file"); -const Benchmark = require("benchmark"); -const centerMean = require("./index").default; +import path from "path"; +import { glob } from "glob"; +import { loadJsonFileSync } from "load-json-file"; +import Benchmark from "benchmark"; +import { centerMean } from "./index"; const fixtures = glob .sync(path.join(__dirname, "test", "in", "*.geojson")) diff --git a/packages/turf-center-mean/index.ts b/packages/turf-center-mean/index.ts index 17cea0f78..c94733c79 100644 --- a/packages/turf-center-mean/index.ts +++ b/packages/turf-center-mean/index.ts @@ -54,4 +54,5 @@ function centerMean

( return point([sumXs / sumNs, sumYs / sumNs], options.properties, options); } +export { centerMean }; export default centerMean; diff --git a/packages/turf-center-mean/package.json b/packages/turf-center-mean/package.json index 7d77ee883..f9ab1b08a 100644 --- a/packages/turf-center-mean/package.json +++ b/packages/turf-center-mean/package.json @@ -44,18 +44,19 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js", + "test:tape": "tsx test.ts", "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" }, "devDependencies": { "@turf/center": "^7.0.0-alpha.2", "@turf/truncate": "^7.0.0-alpha.2", + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "glob": "^10.3.10", diff --git a/packages/turf-center-mean/test.js b/packages/turf-center-mean/test.ts similarity index 76% rename from packages/turf-center-mean/test.js rename to packages/turf-center-mean/test.ts index 33e221432..61dfddd73 100644 --- a/packages/turf-center-mean/test.js +++ b/packages/turf-center-mean/test.ts @@ -1,13 +1,13 @@ -const test = require("tape"); -const { glob } = require("glob"); -const path = require("path"); -const { loadJsonFileSync } = require("load-json-file"); -const { writeJsonFileSync } = require("write-json-file"); -const truncate = require("@turf/truncate").default; -const { featureEach, coordEach } = require("@turf/meta"); -const { lineString, featureCollection } = require("@turf/helpers"); -const center = require("@turf/center").default; -const centerMean = require("./index").default; +import test from "tape"; +import { glob } from "glob"; +import path from "path"; +import { loadJsonFileSync } from "load-json-file"; +import { writeJsonFileSync } from "write-json-file"; +import { truncate } from "@turf/truncate"; +import { featureEach, coordEach } from "@turf/meta"; +import { lineString, featureCollection } from "@turf/helpers"; +import { center } from "@turf/center"; +import { centerMean } from "./index"; test("turf-center-mean", (t) => { glob diff --git a/packages/turf-center-median/bench.js b/packages/turf-center-median/bench.ts similarity index 82% rename from packages/turf-center-median/bench.js rename to packages/turf-center-median/bench.ts index d028974a5..d97ffa3ba 100644 --- a/packages/turf-center-median/bench.js +++ b/packages/turf-center-median/bench.ts @@ -1,6 +1,6 @@ -const Benchmark = require("benchmark"); -const { randomPoint } = require("@turf/random"); -const centerMedian = require("./index").default; +import Benchmark from "benchmark"; +import { randomPoint } from "@turf/random"; +import { centerMedian } from "./index"; /** * Benchmark Results diff --git a/packages/turf-center-median/index.ts b/packages/turf-center-median/index.ts index e95fb2ef8..a8bfefe85 100644 --- a/packages/turf-center-median/index.ts +++ b/packages/turf-center-median/index.ts @@ -175,4 +175,5 @@ function findMedian( } } +export { centerMedian }; export default centerMedian; diff --git a/packages/turf-center-median/package.json b/packages/turf-center-median/package.json index ddbaf5bf6..7cdb08522 100644 --- a/packages/turf-center-median/package.json +++ b/packages/turf-center-median/package.json @@ -39,19 +39,20 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js" + "test:tape": "tsx test.ts" }, "devDependencies": { "@turf/center": "^7.0.0-alpha.2", "@turf/center-of-mass": "^7.0.0-alpha.2", "@turf/random": "^7.0.0-alpha.2", "@turf/truncate": "^7.0.0-alpha.2", + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "load-json-file": "^7.0.1", diff --git a/packages/turf-center-median/test.js b/packages/turf-center-median/test.ts similarity index 72% rename from packages/turf-center-median/test.js rename to packages/turf-center-median/test.ts index b34145a02..6c41cdf6e 100644 --- a/packages/turf-center-median/test.js +++ b/packages/turf-center-median/test.ts @@ -1,14 +1,14 @@ -const test = require("tape"); -const { glob } = require("glob"); -const path = require("path"); -const { loadJsonFileSync } = require("load-json-file"); -const { writeJsonFileSync } = require("write-json-file"); -const center = require("@turf/center").default; -const truncate = require("@turf/truncate").default; -const centerMean = require("@turf/center-mean").default; -const centerOfMass = require("@turf/center-of-mass").default; -const { featureCollection, round } = require("@turf/helpers"); -const centerMedian = require("./index").default; +import test from "tape"; +import { glob } from "glob"; +import path from "path"; +import { loadJsonFileSync } from "load-json-file"; +import { writeJsonFileSync } from "write-json-file"; +import { center } from "@turf/center"; +import truncate from "@turf/truncate"; +import { centerMean } from "@turf/center-mean"; +import { centerOfMass } from "@turf/center-of-mass"; +import { featureCollection, round } from "@turf/helpers"; +import { centerMedian } from "./index"; test("turf-center-median", (t) => { glob diff --git a/packages/turf-center-of-mass/bench.js b/packages/turf-center-of-mass/bench.ts similarity index 96% rename from packages/turf-center-of-mass/bench.js rename to packages/turf-center-of-mass/bench.ts index cf2bc12b7..4701b5337 100644 --- a/packages/turf-center-of-mass/bench.js +++ b/packages/turf-center-of-mass/bench.ts @@ -2,7 +2,7 @@ import path from "path"; import { glob } from "glob"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import centerOfMass from "./dist/js/index.js"; +import { centerOfMass } from "./index.js"; const fixtures = glob .sync(path.join(__dirname, "test", "in", "*.geojson")) diff --git a/packages/turf-center-of-mass/index.ts b/packages/turf-center-of-mass/index.ts index f010aa5ad..5c79dae23 100644 --- a/packages/turf-center-of-mass/index.ts +++ b/packages/turf-center-of-mass/index.ts @@ -95,4 +95,5 @@ function centerOfMass

( } } +export { centerOfMass }; export default centerOfMass; diff --git a/packages/turf-center-of-mass/package.json b/packages/turf-center-of-mass/package.json index a8f630a5c..d8934708f 100644 --- a/packages/turf-center-of-mass/package.json +++ b/packages/turf-center-of-mass/package.json @@ -36,16 +36,17 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js", + "test:tape": "tsx test.ts", "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" }, "devDependencies": { + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "glob": "^10.3.10", diff --git a/packages/turf-center-of-mass/test.js b/packages/turf-center-of-mass/test.ts similarity index 84% rename from packages/turf-center-of-mass/test.js rename to packages/turf-center-of-mass/test.ts index 1a11532dd..9c81be249 100644 --- a/packages/turf-center-of-mass/test.js +++ b/packages/turf-center-of-mass/test.ts @@ -1,16 +1,11 @@ -const path = require("path"); -const test = require("tape"); -const { glob } = require("glob"); -const { loadJsonFileSync } = require("load-json-file"); -const { writeJsonFileSync } = require("write-json-file"); -const { featureEach } = require("@turf/meta"); -const { - point, - lineString, - polygon, - featureCollection, -} = require("@turf/helpers"); -const centerOfMass = require("./index").default; +import path from "path"; +import test from "tape"; +import { glob } from "glob"; +import { loadJsonFileSync } from "load-json-file"; +import { writeJsonFileSync } from "write-json-file"; +import { featureEach } from "@turf/meta"; +import { point, lineString, polygon, featureCollection } from "@turf/helpers"; +import { centerOfMass } from "./index"; const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-center/bench.js b/packages/turf-center/bench.ts similarity index 83% rename from packages/turf-center/bench.js rename to packages/turf-center/bench.ts index 138903b62..1ab5c5a23 100644 --- a/packages/turf-center/bench.js +++ b/packages/turf-center/bench.ts @@ -1,8 +1,8 @@ -const path = require("path"); -const { glob } = require("glob"); -const { loadJsonFileSync } = require("load-json-file"); -const Benchmark = require("benchmark"); -const center = require("./index").default; +import path from "path"; +import { glob } from "glob"; +import { loadJsonFileSync } from "load-json-file"; +import Benchmark from "benchmark"; +import { center } from "./index"; const fixtures = glob .sync(path.join(__dirname, "test", "in", "*.geojson")) diff --git a/packages/turf-center/index.ts b/packages/turf-center/index.ts index 268513c5f..fbc3066f2 100644 --- a/packages/turf-center/index.ts +++ b/packages/turf-center/index.ts @@ -36,4 +36,5 @@ function center

( return point([x, y], options.properties, options); } +export { center }; export default center; diff --git a/packages/turf-center/package.json b/packages/turf-center/package.json index 6fe977e01..8d5acdf8a 100644 --- a/packages/turf-center/package.json +++ b/packages/turf-center/package.json @@ -40,18 +40,19 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js", + "test:tape": "tsx test.ts", "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" }, "devDependencies": { "@turf/bbox-polygon": "^7.0.0-alpha.2", "@turf/meta": "^7.0.0-alpha.2", + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "glob": "^10.3.10", diff --git a/packages/turf-center/test.js b/packages/turf-center/test.ts similarity index 74% rename from packages/turf-center/test.js rename to packages/turf-center/test.ts index c58f37c86..b6dec98ca 100644 --- a/packages/turf-center/test.js +++ b/packages/turf-center/test.ts @@ -1,13 +1,13 @@ -const test = require("tape"); -const { glob } = require("glob"); -const path = require("path"); -const { loadJsonFileSync } = require("load-json-file"); -const { writeJsonFileSync } = require("write-json-file"); -const bboxPolygon = require("@turf/bbox-polygon").default; -const bbox = require("@turf/bbox").default; -const { featureEach, coordEach } = require("@turf/meta"); -const { lineString, featureCollection } = require("@turf/helpers"); -const center = require("./index").default; +import test from "tape"; +import { glob } from "glob"; +import path from "path"; +import { loadJsonFileSync } from "load-json-file"; +import { writeJsonFileSync } from "write-json-file"; +import { bboxPolygon } from "@turf/bbox-polygon"; +import { bbox } from "@turf/bbox"; +import { featureEach, coordEach } from "@turf/meta"; +import { lineString, featureCollection } from "@turf/helpers"; +import { center } from "./index"; test("turf-center", (t) => { glob diff --git a/packages/turf-centroid/bench.js b/packages/turf-centroid/bench.ts similarity index 83% rename from packages/turf-centroid/bench.js rename to packages/turf-centroid/bench.ts index 85678047d..a6bfba287 100644 --- a/packages/turf-centroid/bench.js +++ b/packages/turf-centroid/bench.ts @@ -1,8 +1,8 @@ -const path = require("path"); -const { glob } = require("glob"); -const { loadJsonFileSync } = require("load-json-file"); -const Benchmark = require("benchmark"); -const centroid = require("./index").default; +import path from "path"; +import { glob } from "glob"; +import { loadJsonFileSync } from "load-json-file"; +import Benchmark from "benchmark"; +import { centroid } from "./index"; const fixtures = glob .sync(path.join(__dirname, "test", "in", "*.geojson")) diff --git a/packages/turf-centroid/index.ts b/packages/turf-centroid/index.ts index 7f30d53e7..7a6ac39cf 100644 --- a/packages/turf-centroid/index.ts +++ b/packages/turf-centroid/index.ts @@ -39,4 +39,5 @@ function centroid

( return point([xSum / len, ySum / len], options.properties); } +export { centroid }; export default centroid; diff --git a/packages/turf-centroid/package.json b/packages/turf-centroid/package.json index 6d535ce7d..3ab00a7f2 100644 --- a/packages/turf-centroid/package.json +++ b/packages/turf-centroid/package.json @@ -38,16 +38,17 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js", + "test:tape": "tsx test.ts", "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" }, "devDependencies": { + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "geojson-fixtures": "*", diff --git a/packages/turf-centroid/test.js b/packages/turf-centroid/test.ts similarity index 75% rename from packages/turf-centroid/test.js rename to packages/turf-centroid/test.ts index e75c65692..253904959 100644 --- a/packages/turf-centroid/test.js +++ b/packages/turf-centroid/test.ts @@ -1,11 +1,11 @@ -const path = require("path"); -const test = require("tape"); -const { glob } = require("glob"); -const { loadJsonFileSync } = require("load-json-file"); -const { writeJsonFileSync } = require("write-json-file"); -const { featureEach } = require("@turf/meta"); -const { featureCollection, lineString } = require("@turf/helpers"); -const centroid = require("./index").default; +import path from "path"; +import test from "tape"; +import { glob } from "glob"; +import { loadJsonFileSync } from "load-json-file"; +import { writeJsonFileSync } from "write-json-file"; +import { featureEach } from "@turf/meta"; +import { featureCollection, lineString } from "@turf/helpers"; +import { centroid } from "./index"; const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-circle/bench.js b/packages/turf-circle/bench.ts similarity index 88% rename from packages/turf-circle/bench.js rename to packages/turf-circle/bench.ts index d098b60b4..9279af0d8 100644 --- a/packages/turf-circle/bench.js +++ b/packages/turf-circle/bench.ts @@ -1,5 +1,5 @@ -const Benchmark = require("benchmark"); -const circle = require("./index").default; +import Benchmark from "benchmark"; +import { circle } from "./index"; const center = [-75.0, 39.0]; const radius = 5; diff --git a/packages/turf-circle/index.ts b/packages/turf-circle/index.ts index a38672896..e8b856c3c 100644 --- a/packages/turf-circle/index.ts +++ b/packages/turf-circle/index.ts @@ -52,4 +52,5 @@ function circle

( return polygon([coordinates], properties); } +export { circle }; export default circle; diff --git a/packages/turf-circle/package.json b/packages/turf-circle/package.json index 77ba3614a..6c190d29a 100644 --- a/packages/turf-circle/package.json +++ b/packages/turf-circle/package.json @@ -40,18 +40,19 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js", + "test:tape": "tsx test.ts", "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" }, "devDependencies": { "@mapbox/geojsonhint": "^3.2.0", "@turf/truncate": "^7.0.0-alpha.2", + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "load-json-file": "^7.0.1", diff --git a/packages/turf-circle/test.js b/packages/turf-circle/test.ts similarity index 74% rename from packages/turf-circle/test.js rename to packages/turf-circle/test.ts index 44ed3784a..da91982db 100644 --- a/packages/turf-circle/test.js +++ b/packages/turf-circle/test.ts @@ -1,12 +1,12 @@ -const fs = require("fs"); -const test = require("tape"); -const path = require("path"); -const { loadJsonFileSync } = require("load-json-file"); -const { writeJsonFileSync } = require("write-json-file"); -const truncate = require("@turf/truncate").default; -const { featureCollection } = require("@turf/helpers"); -const geojsonhint = require("@mapbox/geojsonhint"); -const circle = require("./index").default; +import fs from "fs"; +import test from "tape"; +import path from "path"; +import { loadJsonFileSync } from "load-json-file"; +import { writeJsonFileSync } from "write-json-file"; +import { truncate } from "@turf/truncate"; +import { featureCollection } from "@turf/helpers"; +import geojsonhint from "@mapbox/geojsonhint"; +import { circle } from "./index"; const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-clean-coords/bench.js b/packages/turf-clean-coords/bench.ts similarity index 93% rename from packages/turf-clean-coords/bench.js rename to packages/turf-clean-coords/bench.ts index 36c932d09..5dfbeb3d1 100644 --- a/packages/turf-clean-coords/bench.js +++ b/packages/turf-clean-coords/bench.ts @@ -1,8 +1,8 @@ -const path = require("path"); -const { glob } = require("glob"); -const { loadJsonFileSync } = require("load-json-file"); -const Benchmark = require("benchmark"); -const cleanCoords = require("./index").default; +import path from "path"; +import { glob } from "glob"; +import { loadJsonFileSync } from "load-json-file"; +import Benchmark from "benchmark"; +import { cleanCoords } from "./index"; /** * Benchmark Results diff --git a/packages/turf-clean-coords/index.ts b/packages/turf-clean-coords/index.ts index 6fb27e100..a1ff53c02 100644 --- a/packages/turf-clean-coords/index.ts +++ b/packages/turf-clean-coords/index.ts @@ -200,4 +200,5 @@ function isPointOnLineSegment(start: Position, end: Position, point: Position) { else return dyl > 0 ? startY <= y && y <= endY : endY <= y && y <= startY; } +export { cleanCoords }; export default cleanCoords; diff --git a/packages/turf-clean-coords/package.json b/packages/turf-clean-coords/package.json index fc03043ee..1d335a598 100644 --- a/packages/turf-clean-coords/package.json +++ b/packages/turf-clean-coords/package.json @@ -40,17 +40,18 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js", + "test:tape": "tsx test.ts", "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" }, "devDependencies": { "@turf/truncate": "^7.0.0-alpha.2", + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "load-json-file": "^7.0.1", diff --git a/packages/turf-clean-coords/test.js b/packages/turf-clean-coords/test.ts similarity index 89% rename from packages/turf-clean-coords/test.js rename to packages/turf-clean-coords/test.ts index ed7a652ee..762faf6c3 100644 --- a/packages/turf-clean-coords/test.js +++ b/packages/turf-clean-coords/test.ts @@ -1,17 +1,17 @@ -const fs = require("fs"); -const test = require("tape"); -const path = require("path"); -const { loadJsonFileSync } = require("load-json-file"); -const truncate = require("@turf/truncate").default; -const { +import fs from "fs"; +import test from "tape"; +import path from "path"; +import { loadJsonFileSync } from "load-json-file"; +import { truncate } from "@turf/truncate"; +import { point, multiPoint, lineString, multiPolygon, polygon, -} = require("@turf/helpers"); -const { writeJsonFileSync } = require("write-json-file"); -const cleanCoords = require("./index").default; +} from "@turf/helpers"; +import { writeJsonFileSync } from "write-json-file"; +import { cleanCoords } from "./index"; const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-clone/bench.js b/packages/turf-clone/bench.ts similarity index 90% rename from packages/turf-clone/bench.js rename to packages/turf-clone/bench.ts index 9579e4472..373eb713f 100644 --- a/packages/turf-clone/bench.js +++ b/packages/turf-clone/bench.ts @@ -1,11 +1,6 @@ -const Benchmark = require("benchmark"); -const { - point, - lineString, - polygon, - featureCollection, -} = require("@turf/helpers"); -const clone = require("./index").default; +import Benchmark from "benchmark"; +import { point, lineString, polygon, featureCollection } from "@turf/helpers"; +import { clone } from "./index"; const fixtures = [ point([0, 20]), diff --git a/packages/turf-clone/index.ts b/packages/turf-clone/index.ts index 2f23643f0..cf008eb0e 100644 --- a/packages/turf-clone/index.ts +++ b/packages/turf-clone/index.ts @@ -167,4 +167,5 @@ function deepSlice(coords: C): C { }); } +export { clone }; export default clone; diff --git a/packages/turf-clone/package.json b/packages/turf-clone/package.json index 2b850fa8b..6eb24af71 100644 --- a/packages/turf-clone/package.json +++ b/packages/turf-clone/package.json @@ -39,17 +39,18 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js", + "test:tape": "tsx test.ts", "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" }, "devDependencies": { "@turf/meta": "^7.0.0-alpha.2", + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "npm-run-all": "^4.1.5", diff --git a/packages/turf-clone/test.js b/packages/turf-clone/test.ts similarity index 97% rename from packages/turf-clone/test.js rename to packages/turf-clone/test.ts index 3ab8f54a1..563d184e0 100644 --- a/packages/turf-clone/test.js +++ b/packages/turf-clone/test.ts @@ -1,13 +1,13 @@ -const test = require("tape"); -const { +import test from "tape"; +import { point, lineString, polygon, featureCollection, geometryCollection, -} = require("@turf/helpers"); -const { coordEach } = require("@turf/meta"); -const clone = require("./index").default; +} from "@turf/helpers"; +import { coordEach } from "@turf/meta"; +import { clone } from "./index"; test("turf-clone", (t) => { // Define Features diff --git a/packages/turf-clusters-dbscan/bench.js b/packages/turf-clusters-dbscan/bench.ts similarity index 85% rename from packages/turf-clusters-dbscan/bench.js rename to packages/turf-clusters-dbscan/bench.ts index 9d332f315..167b69ded 100644 --- a/packages/turf-clusters-dbscan/bench.js +++ b/packages/turf-clusters-dbscan/bench.ts @@ -1,8 +1,8 @@ -const fs = require("fs"); -const path = require("path"); -const { loadJsonFileSync } = require("load-json-file"); -const Benchmark = require("benchmark"); -const clustersDbscan = require("./index").default; +import fs from "fs"; +import path from "path"; +import { loadJsonFileSync } from "load-json-file"; +import Benchmark from "benchmark"; +import { clustersDbscan } from "./index"; // Define Fixtures const directory = path.join(__dirname, "test", "in") + path.sep; diff --git a/packages/turf-clusters-dbscan/index.ts b/packages/turf-clusters-dbscan/index.ts index aec8c0bff..f20908e27 100644 --- a/packages/turf-clusters-dbscan/index.ts +++ b/packages/turf-clusters-dbscan/index.ts @@ -4,8 +4,8 @@ import distance from "@turf/distance"; import { degreesToRadians, lengthToDegrees, Units } from "@turf/helpers"; import RBush from "rbush"; -export type Dbscan = "core" | "edge" | "noise"; -export type DbscanProps = GeoJsonProperties & { +type Dbscan = "core" | "edge" | "noise"; +type DbscanProps = GeoJsonProperties & { dbscan?: Dbscan; cluster?: number; }; @@ -182,4 +182,5 @@ function clustersDbscan( return points as FeatureCollection; } +export { Dbscan, DbscanProps, clustersDbscan }; export default clustersDbscan; diff --git a/packages/turf-clusters-dbscan/package.json b/packages/turf-clusters-dbscan/package.json index dd47b96bb..cc35a0547 100644 --- a/packages/turf-clusters-dbscan/package.json +++ b/packages/turf-clusters-dbscan/package.json @@ -46,18 +46,19 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js", + "test:tape": "tsx test.ts", "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" }, "devDependencies": { "@turf/centroid": "^7.0.0-alpha.2", "@turf/clusters": "^7.0.0-alpha.2", + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "chromatism": "^3.0.0", diff --git a/packages/turf-clusters-dbscan/test.js b/packages/turf-clusters-dbscan/test.ts similarity index 87% rename from packages/turf-clusters-dbscan/test.js rename to packages/turf-clusters-dbscan/test.ts index b318e9f0d..7a20ba3d4 100644 --- a/packages/turf-clusters-dbscan/test.js +++ b/packages/turf-clusters-dbscan/test.ts @@ -1,15 +1,15 @@ -const fs = require("fs"); -const test = require("tape"); -const path = require("path"); -const { loadJsonFileSync } = require("load-json-file"); -const { writeJsonFileSync } = require("write-json-file"); -const centroid = require("@turf/centroid").default; -const chromatism = require("chromatism"); -const concaveman = require("concaveman"); -const { point, polygon, featureCollection } = require("@turf/helpers"); -const { clusterReduce, clusterEach } = require("@turf/clusters"); -const { coordAll, featureEach } = require("@turf/meta"); -const clustersDbscan = require("./index").default; +import fs from "fs"; +import test from "tape"; +import path from "path"; +import { loadJsonFileSync } from "load-json-file"; +import { writeJsonFileSync } from "write-json-file"; +import { centroid } from "@turf/centroid"; +import * as chromatism from "chromatism"; +import concaveman from "concaveman"; +import { point, polygon, featureCollection } from "@turf/helpers"; +import { clusterReduce, clusterEach } from "@turf/clusters"; +import { coordAll, featureEach } from "@turf/meta"; +import { clustersDbscan } from "./index"; const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-clusters-kmeans/bench.js b/packages/turf-clusters-kmeans/bench.ts similarity index 84% rename from packages/turf-clusters-kmeans/bench.js rename to packages/turf-clusters-kmeans/bench.ts index 42c9624d2..5f0f51569 100644 --- a/packages/turf-clusters-kmeans/bench.js +++ b/packages/turf-clusters-kmeans/bench.ts @@ -1,8 +1,8 @@ -const fs = require("fs"); -const path = require("path"); -const { loadJsonFileSync } = require("load-json-file"); -const Benchmark = require("benchmark"); -const clustersKmeans = require("./index").default; +import fs from "fs"; +import path from "path"; +import { loadJsonFileSync } from "load-json-file"; +import Benchmark from "benchmark"; +import { clustersKmeans } from "./index"; // Define Fixtures const directory = path.join(__dirname, "test", "in") + path.sep; diff --git a/packages/turf-clusters-kmeans/index.ts b/packages/turf-clusters-kmeans/index.ts index 91ddb303b..19e0efe43 100644 --- a/packages/turf-clusters-kmeans/index.ts +++ b/packages/turf-clusters-kmeans/index.ts @@ -3,7 +3,7 @@ import clone from "@turf/clone"; import { coordAll, featureEach } from "@turf/meta"; import skmeans from "skmeans"; -export type KmeansProps = GeoJsonProperties & { +type KmeansProps = GeoJsonProperties & { cluster?: number; centroid?: [number, number]; }; @@ -76,4 +76,5 @@ function clustersKmeans( return points as FeatureCollection; } +export { clustersKmeans, KmeansProps }; export default clustersKmeans; diff --git a/packages/turf-clusters-kmeans/package.json b/packages/turf-clusters-kmeans/package.json index 4fa310d53..b1d409690 100644 --- a/packages/turf-clusters-kmeans/package.json +++ b/packages/turf-clusters-kmeans/package.json @@ -45,19 +45,20 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js", + "test:tape": "tsx test.ts", "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" }, "devDependencies": { "@turf/centroid": "^7.0.0-alpha.2", "@turf/clusters": "^7.0.0-alpha.2", "@turf/random": "^7.0.0-alpha.2", + "@types/benchmark": "^2.1.5", "@types/skmeans": "^0.11.7", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", diff --git a/packages/turf-clusters-kmeans/test.js b/packages/turf-clusters-kmeans/test.ts similarity index 83% rename from packages/turf-clusters-kmeans/test.js rename to packages/turf-clusters-kmeans/test.ts index 61f35bc76..757023340 100644 --- a/packages/turf-clusters-kmeans/test.js +++ b/packages/turf-clusters-kmeans/test.ts @@ -1,15 +1,15 @@ -const fs = require("fs"); -const test = require("tape"); -const path = require("path"); -const { loadJsonFileSync } = require("load-json-file"); -const { writeJsonFileSync } = require("write-json-file"); -const centroid = require("@turf/centroid").default; -const chromatism = require("chromatism"); -const concaveman = require("concaveman"); -const { point, polygon, featureCollection } = require("@turf/helpers"); -const { clusterReduce, clusterEach } = require("@turf/clusters"); -const { coordAll, featureEach } = require("@turf/meta"); -const clustersKmeans = require("./index").default; +import fs from "fs"; +import test from "tape"; +import path from "path"; +import { loadJsonFileSync } from "load-json-file"; +import { writeJsonFileSync } from "write-json-file"; +import { centroid } from "@turf/centroid"; +import * as chromatism from "chromatism"; +import concaveman from "concaveman"; +import { point, polygon, featureCollection } from "@turf/helpers"; +import { clusterReduce, clusterEach } from "@turf/clusters"; +import { coordAll, featureEach } from "@turf/meta"; +import { clustersKmeans } from "./index"; const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-clusters/bench.js b/packages/turf-clusters/bench.ts similarity index 93% rename from packages/turf-clusters/bench.js rename to packages/turf-clusters/bench.ts index 7d42452fa..bf3c384ed 100644 --- a/packages/turf-clusters/bench.js +++ b/packages/turf-clusters/bench.ts @@ -1,6 +1,6 @@ -const Benchmark = require("benchmark"); -const { featureCollection, point } = require("@turf/helpers"); -const { +import Benchmark from "benchmark"; +import { featureCollection, point } from "@turf/helpers"; +import { getCluster, clusterEach, clusterReduce, @@ -8,7 +8,7 @@ const { filterProperties, applyFilter, createBins, -} = require("./index"); +} from "./index"; const geojson = featureCollection([ point([0, 0], { cluster: 0 }), diff --git a/packages/turf-clusters/index.ts b/packages/turf-clusters/index.ts index 78ecc5649..0d72b2abc 100644 --- a/packages/turf-clusters/index.ts +++ b/packages/turf-clusters/index.ts @@ -36,7 +36,7 @@ import { featureCollection } from "@turf/helpers"; * turf.getCluster(clustered, {'marker-symbol': 'square'}).length; * //= 1 */ -export function getCluster< +function getCluster< G extends GeometryObject, P extends GeoJsonProperties = GeoJsonProperties, >(geojson: FeatureCollection, filter: any): FeatureCollection { @@ -104,7 +104,7 @@ export function getCluster< * values.push(clusterValue); * }); */ -export function clusterEach< +function clusterEach< G extends GeometryObject, P extends GeoJsonProperties = GeoJsonProperties, >( @@ -201,7 +201,7 @@ export function clusterEach< * return previousValue.concat(clusterValue); * }, []); */ -export function clusterReduce< +function clusterReduce< G extends GeometryObject, P extends GeoJsonProperties = GeoJsonProperties, >( @@ -251,7 +251,7 @@ export function clusterReduce< * createBins(geojson, 'cluster'); * //= { '0': [ 0 ], '1': [ 1, 3 ] } */ -export function createBins( +function createBins( geojson: FeatureCollection, property: string | number ) { @@ -277,7 +277,7 @@ export function createBins( * @param {*} filter Filter * @returns {boolean} applied Filter to properties */ -export function applyFilter(properties: any, filter: any) { +function applyFilter(properties: any, filter: any) { if (properties === undefined) return false; var filterType = typeof filter; @@ -309,10 +309,7 @@ export function applyFilter(properties: any, filter: any) { * propertiesContainsFilter({foo: 'bar', cluster: 0}, {cluster: 1}) * //= false */ -export function propertiesContainsFilter( - properties: any, - filter: any -): boolean { +function propertiesContainsFilter(properties: any, filter: any): boolean { var keys = Object.keys(filter); for (var i = 0; i < keys.length; i++) { var key = keys[i]; @@ -332,7 +329,7 @@ export function propertiesContainsFilter( * filterProperties({foo: 'bar', cluster: 0}, ['cluster']) * //= {cluster: 0} */ -export function filterProperties( +function filterProperties( properties: Record, keys: string[] ): any { @@ -347,3 +344,14 @@ export function filterProperties( } return newProperties; } + +export { + getCluster, + clusterEach, + clusterReduce, + createBins, + applyFilter, + propertiesContainsFilter, + filterProperties, +}; +// No default export! diff --git a/packages/turf-clusters/package.json b/packages/turf-clusters/package.json index 6e1a90110..6841def29 100644 --- a/packages/turf-clusters/package.json +++ b/packages/turf-clusters/package.json @@ -42,16 +42,17 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js", + "test:tape": "tsx test.ts", "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" }, "devDependencies": { + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "npm-run-all": "^4.1.5", diff --git a/packages/turf-clusters/test.js b/packages/turf-clusters/test.ts similarity index 95% rename from packages/turf-clusters/test.js rename to packages/turf-clusters/test.ts index 2a4a04630..68625bead 100644 --- a/packages/turf-clusters/test.js +++ b/packages/turf-clusters/test.ts @@ -1,6 +1,6 @@ -const test = require("tape"); -const { point, featureCollection } = require("@turf/helpers"); -const { +import test from "tape"; +import { point, featureCollection } from "@turf/helpers"; +import { getCluster, clusterEach, clusterReduce, @@ -9,7 +9,7 @@ const { applyFilter, filterProperties, propertiesContainsFilter, -} = require("./index"); +} from "./index"; const properties = { foo: "bar", cluster: 0 }; const geojson = featureCollection([ diff --git a/packages/turf-collect/bench.js b/packages/turf-collect/bench.ts similarity index 83% rename from packages/turf-collect/bench.js rename to packages/turf-collect/bench.ts index 62c39600a..b2b84b96c 100644 --- a/packages/turf-collect/bench.js +++ b/packages/turf-collect/bench.ts @@ -1,6 +1,6 @@ -const Benchmark = require("benchmark"); -const { polygon, featureCollection, point } = require("@turf/helpers"); -const collect = require("./index").default; +import Benchmark from "benchmark"; +import { polygon, featureCollection, point } from "@turf/helpers"; +import { collect } from "./index"; var poly1 = polygon([ [ diff --git a/packages/turf-collect/index.ts b/packages/turf-collect/index.ts index 62fde63dd..eecdf9539 100644 --- a/packages/turf-collect/index.ts +++ b/packages/turf-collect/index.ts @@ -84,4 +84,5 @@ function collect( return polygons; } +export { collect }; export default collect; diff --git a/packages/turf-collect/package.json b/packages/turf-collect/package.json index 6b096acd3..e936b3699 100644 --- a/packages/turf-collect/package.json +++ b/packages/turf-collect/package.json @@ -43,15 +43,16 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js" + "test:tape": "tsx test.ts" }, "devDependencies": { + "@types/benchmark": "^2.1.5", "@types/rbush": "^3.0.2", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", diff --git a/packages/turf-collect/test.js b/packages/turf-collect/test.ts similarity index 89% rename from packages/turf-collect/test.js rename to packages/turf-collect/test.ts index b12381a99..e055f9aa6 100644 --- a/packages/turf-collect/test.js +++ b/packages/turf-collect/test.ts @@ -1,6 +1,6 @@ -const test = require("tape"); -const { featureCollection, point, polygon } = require("@turf/helpers"); -const collect = require("./index").default; +import test from "tape"; +import { featureCollection, point, polygon } from "@turf/helpers"; +import { collect } from "./index"; test("turf collect module", (t) => { const poly1 = polygon([ diff --git a/packages/turf-combine/bench.js b/packages/turf-combine/bench.ts similarity index 83% rename from packages/turf-combine/bench.js rename to packages/turf-combine/bench.ts index 74a5af95a..5e5cabb59 100644 --- a/packages/turf-combine/bench.js +++ b/packages/turf-combine/bench.ts @@ -1,11 +1,6 @@ -const Benchmark = require("benchmark"); -const { - point, - polygon, - lineString, - featureCollection, -} = require("@turf/helpers"); -const combine = require("./index").default; +import Benchmark from "benchmark"; +import { point, polygon, lineString, featureCollection } from "@turf/helpers"; +import { combine } from "./index"; // MultiPoint var pt1 = point(50, 51); diff --git a/packages/turf-combine/index.ts b/packages/turf-combine/index.ts index 155d5c973..e3e72a4a4 100644 --- a/packages/turf-combine/index.ts +++ b/packages/turf-combine/index.ts @@ -99,4 +99,5 @@ function combine( ); } +export { combine }; export default combine; diff --git a/packages/turf-combine/package.json b/packages/turf-combine/package.json index 8cfc019b4..26458eb0d 100644 --- a/packages/turf-combine/package.json +++ b/packages/turf-combine/package.json @@ -39,15 +39,16 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js" + "test:tape": "tsx test.ts" }, "devDependencies": { + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "npm-run-all": "^4.1.5", diff --git a/packages/turf-combine/test.js b/packages/turf-combine/test.ts similarity index 98% rename from packages/turf-combine/test.js rename to packages/turf-combine/test.ts index 6c889224e..6e3eac52f 100644 --- a/packages/turf-combine/test.js +++ b/packages/turf-combine/test.ts @@ -1,5 +1,5 @@ -const test = require("tape"); -const { +import test from "tape"; +import { point, multiPoint, polygon, @@ -7,8 +7,8 @@ const { lineString, multiLineString, featureCollection, -} = require("@turf/helpers"); -const combine = require("./index").default; +} from "@turf/helpers"; +import { combine } from "./index"; test("combine -- points", (t) => { // MultiPoint diff --git a/packages/turf-concave/bench.js b/packages/turf-concave/bench.ts similarity index 86% rename from packages/turf-concave/bench.js rename to packages/turf-concave/bench.ts index 8f81e261c..aeb64a6ba 100644 --- a/packages/turf-concave/bench.js +++ b/packages/turf-concave/bench.ts @@ -1,8 +1,8 @@ -const fs = require("fs"); -const path = require("path"); -const { loadJsonFileSync } = require("load-json-file"); -const Benchmark = require("benchmark"); -const concave = require("./index").default; +import fs from "fs"; +import path from "path"; +import { loadJsonFileSync } from "load-json-file"; +import Benchmark from "benchmark"; +import { concave } from "./index"; const directory = path.join(__dirname, "test", "in") + path.sep; const fixtures = fs.readdirSync(directory).map((filename) => { diff --git a/packages/turf-concave/index.ts b/packages/turf-concave/index.ts index 2562860fa..a87d092bf 100644 --- a/packages/turf-concave/index.ts +++ b/packages/turf-concave/index.ts @@ -101,4 +101,5 @@ function removeDuplicates( return featureCollection(cleaned); } +export { concave }; export default concave; diff --git a/packages/turf-concave/package.json b/packages/turf-concave/package.json index 6c59c65ed..7d20a7936 100644 --- a/packages/turf-concave/package.json +++ b/packages/turf-concave/package.json @@ -49,15 +49,16 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js" + "test:tape": "tsx test.ts" }, "devDependencies": { + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "@types/topojson-client": "3.1.3", "@types/topojson-server": "3.0.3", diff --git a/packages/turf-concave/test.js b/packages/turf-concave/test.ts similarity index 80% rename from packages/turf-concave/test.js rename to packages/turf-concave/test.ts index 9cfd799fb..94555c4a5 100644 --- a/packages/turf-concave/test.js +++ b/packages/turf-concave/test.ts @@ -1,11 +1,11 @@ -const fs = require("fs"); -const test = require("tape"); -const path = require("path"); -const { loadJsonFileSync } = require("load-json-file"); -const { writeJsonFileSync } = require("write-json-file"); -const { point, featureCollection } = require("@turf/helpers"); -const { featureEach } = require("@turf/meta"); -const concave = require("./index").default; +import fs from "fs"; +import test from "tape"; +import path from "path"; +import { loadJsonFileSync } from "load-json-file"; +import { writeJsonFileSync } from "write-json-file"; +import { point, featureCollection } from "@turf/helpers"; +import { featureEach } from "@turf/meta"; +import { concave } from "./index"; const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-convex/bench.js b/packages/turf-convex/bench.ts similarity index 76% rename from packages/turf-convex/bench.js rename to packages/turf-convex/bench.ts index a455c9b51..3d404d92a 100644 --- a/packages/turf-convex/bench.js +++ b/packages/turf-convex/bench.ts @@ -1,8 +1,8 @@ -const { glob } = require("glob"); -const path = require("path"); -const { loadJsonFileSync } = require("load-json-file"); -const Benchmark = require("benchmark"); -const convex = require("./index").default; +import { glob } from "glob"; +import path from "path"; +import { loadJsonFileSync } from "load-json-file"; +import Benchmark from "benchmark"; +import { convex } from "./index"; const suite = new Benchmark.Suite("turf-convex"); diff --git a/packages/turf-convex/index.ts b/packages/turf-convex/index.ts index 18663bd64..d89cc7c4d 100644 --- a/packages/turf-convex/index.ts +++ b/packages/turf-convex/index.ts @@ -31,7 +31,7 @@ import concaveman from "concaveman"; * //addToMap * var addToMap = [points, hull] */ -export default function convex

( +function convex

( geojson: AllGeoJSON, options: { concavity?: number; @@ -60,3 +60,6 @@ export default function convex

( } return null; } + +export { convex }; +export default convex; diff --git a/packages/turf-convex/package.json b/packages/turf-convex/package.json index 886082b18..fbe43ffee 100644 --- a/packages/turf-convex/package.json +++ b/packages/turf-convex/package.json @@ -36,15 +36,16 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js" + "test:tape": "tsx test.ts" }, "devDependencies": { + "@types/benchmark": "^2.1.5", "@types/concaveman": "^1.1.6", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", diff --git a/packages/turf-convex/test.js b/packages/turf-convex/test.ts similarity index 69% rename from packages/turf-convex/test.js rename to packages/turf-convex/test.ts index 868e1a5dd..cef321ac6 100644 --- a/packages/turf-convex/test.js +++ b/packages/turf-convex/test.ts @@ -1,10 +1,10 @@ -const test = require("tape"); -const { glob } = require("glob"); -const path = require("path"); -const { writeJsonFileSync } = require("write-json-file"); -const { loadJsonFileSync } = require("load-json-file"); -const { featureCollection } = require("@turf/helpers"); -const convex = require("./index").default; +import test from "tape"; +import { glob } from "glob"; +import path from "path"; +import { writeJsonFileSync } from "write-json-file"; +import { loadJsonFileSync } from "load-json-file"; +import { featureCollection } from "@turf/helpers"; +import { convex } from "./index"; const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-destination/bench.js b/packages/turf-destination/bench.ts similarity index 71% rename from packages/turf-destination/bench.js rename to packages/turf-destination/bench.ts index 3ef0dae53..51551b980 100644 --- a/packages/turf-destination/bench.js +++ b/packages/turf-destination/bench.ts @@ -1,5 +1,5 @@ -const Benchmark = require("benchmark"); -const destination = require("./index").default; +import Benchmark from "benchmark"; +import { destination } from "./index"; var pt1 = [-75.0, 39.0]; var dist = 100; diff --git a/packages/turf-destination/index.ts b/packages/turf-destination/index.ts index 72f012373..ab6d110e1 100644 --- a/packages/turf-destination/index.ts +++ b/packages/turf-destination/index.ts @@ -37,9 +37,7 @@ import { getCoord } from "@turf/invariant"; * destination.properties['marker-color'] = '#f00'; * point.properties['marker-color'] = '#0f0'; */ -export default function destination< - P extends GeoJsonProperties = GeoJsonProperties, ->( +function destination

( origin: Coord, distance: number, bearing: number, @@ -71,3 +69,6 @@ export default function destination< return point([lng, lat], options.properties); } + +export { destination }; +export default destination; diff --git a/packages/turf-destination/package.json b/packages/turf-destination/package.json index a7de04689..b6a94a0de 100644 --- a/packages/turf-destination/package.json +++ b/packages/turf-destination/package.json @@ -40,16 +40,17 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js" + "test:tape": "tsx test.ts" }, "devDependencies": { "@turf/truncate": "^7.0.0-alpha.2", + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "glob": "^10.3.10", diff --git a/packages/turf-destination/test.js b/packages/turf-destination/test.ts similarity index 72% rename from packages/turf-destination/test.js rename to packages/turf-destination/test.ts index 5e8360409..ed25493b0 100644 --- a/packages/turf-destination/test.js +++ b/packages/turf-destination/test.ts @@ -1,12 +1,12 @@ -const path = require("path"); -const test = require("tape"); -const { glob } = require("glob"); -const { loadJsonFileSync } = require("load-json-file"); -const { writeJsonFileSync } = require("write-json-file"); -const { getCoords } = require("@turf/invariant"); -const { lineString, featureCollection } = require("@turf/helpers"); -const truncate = require("@turf/truncate").default; -const destination = require("./index").default; +import path from "path"; +import test from "tape"; +import { glob } from "glob"; +import { loadJsonFileSync } from "load-json-file"; +import { writeJsonFileSync } from "write-json-file"; +import { getCoords } from "@turf/invariant"; +import { lineString, featureCollection } from "@turf/helpers"; +import { truncate } from "@turf/truncate"; +import { destination } from "./index"; const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-difference/bench.js b/packages/turf-difference/bench.ts similarity index 84% rename from packages/turf-difference/bench.js rename to packages/turf-difference/bench.ts index 1f0cd22bf..08bb38e24 100644 --- a/packages/turf-difference/bench.js +++ b/packages/turf-difference/bench.ts @@ -1,8 +1,8 @@ -const fs = require("fs"); -const path = require("path"); -const { loadJsonFileSync } = require("load-json-file"); -const Benchmark = require("benchmark"); -const difference = require("./index").default; +import fs from "fs"; +import path from "path"; +import { loadJsonFileSync } from "load-json-file"; +import Benchmark from "benchmark"; +import { difference } from "./index"; const directory = path.join(__dirname, "test", "in") + path.sep; let fixtures = fs.readdirSync(directory).map((filename) => { diff --git a/packages/turf-difference/index.ts b/packages/turf-difference/index.ts index e3df2ffe7..8629db4b0 100644 --- a/packages/turf-difference/index.ts +++ b/packages/turf-difference/index.ts @@ -57,4 +57,5 @@ function difference( return multiPolygon(differenced, properties); } +export { difference }; export default difference; diff --git a/packages/turf-difference/package.json b/packages/turf-difference/package.json index 30c31bbb5..cbce8ef5d 100644 --- a/packages/turf-difference/package.json +++ b/packages/turf-difference/package.json @@ -36,15 +36,16 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js" + "test:tape": "tsx test.ts" }, "devDependencies": { + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "glob": "^10.3.10", diff --git a/packages/turf-difference/test.js b/packages/turf-difference/test.ts similarity index 88% rename from packages/turf-difference/test.js rename to packages/turf-difference/test.ts index cb0e0ab8b..91ed5b2a3 100644 --- a/packages/turf-difference/test.js +++ b/packages/turf-difference/test.ts @@ -1,10 +1,10 @@ -const path = require("path"); -const test = require("tape"); -const { glob } = require("glob"); -const { loadJsonFileSync } = require("load-json-file"); -const { writeJsonFileSync } = require("write-json-file"); -const { featureCollection, polygon } = require("@turf/helpers"); -const difference = require("./index").default; +import path from "path"; +import test from "tape"; +import { glob } from "glob"; +import { loadJsonFileSync } from "load-json-file"; +import { writeJsonFileSync } from "write-json-file"; +import { featureCollection, polygon } from "@turf/helpers"; +import { difference } from "./index"; const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-directional-mean/bench.js b/packages/turf-directional-mean/bench.ts similarity index 89% rename from packages/turf-directional-mean/bench.js rename to packages/turf-directional-mean/bench.ts index bc7b89be7..17598e670 100644 --- a/packages/turf-directional-mean/bench.js +++ b/packages/turf-directional-mean/bench.ts @@ -1,8 +1,8 @@ -const Benchmark = require("benchmark"); -const directionalMean = require("./index").default; -const { glob } = require("glob"); -const path = require("path"); -const { loadJsonFileSync } = require("load-json-file"); +import Benchmark from "benchmark"; +import { directionalMean } from "./index"; +import { glob } from "glob"; +import path from "path"; +import { loadJsonFileSync } from "load-json-file"; /** * Benchmark Results diff --git a/packages/turf-directional-mean/index.ts b/packages/turf-directional-mean/index.ts index d077cfecc..68bfedb03 100644 --- a/packages/turf-directional-mean/index.ts +++ b/packages/turf-directional-mean/index.ts @@ -7,7 +7,7 @@ import { getCoord } from "@turf/invariant"; import length from "@turf/length"; import { featureEach, segmentEach, segmentReduce } from "@turf/meta"; -export interface DirectionalMeanLine extends Feature { +interface DirectionalMeanLine extends Feature { properties: { cartesianAngle: number; bearingAngle: number; @@ -51,7 +51,7 @@ export interface DirectionalMeanLine extends Feature { * var directionalMeanLine = turf.directionalMean(lines); * // => directionalMeanLine */ -export default function directionalMean( +function directionalMean( lines: FeatureCollection, options: { planar?: boolean; @@ -289,3 +289,6 @@ function getMeanLineString( return [getCoord(begin), getCoord(end)]; } } + +export { directionalMean, DirectionalMeanLine }; +export default directionalMean; diff --git a/packages/turf-directional-mean/package.json b/packages/turf-directional-mean/package.json index 3ab3bf7be..53e191a12 100644 --- a/packages/turf-directional-mean/package.json +++ b/packages/turf-directional-mean/package.json @@ -39,15 +39,16 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js" + "test:tape": "tsx test.ts" }, "devDependencies": { + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "load-json-file": "^7.0.1", diff --git a/packages/turf-directional-mean/test.js b/packages/turf-directional-mean/test.ts similarity index 88% rename from packages/turf-directional-mean/test.js rename to packages/turf-directional-mean/test.ts index 35ae711c8..50f652415 100644 --- a/packages/turf-directional-mean/test.js +++ b/packages/turf-directional-mean/test.ts @@ -1,8 +1,8 @@ -const test = require("tape"); -const path = require("path"); -const { loadJsonFileSync } = require("load-json-file"); -const { writeJsonFileSync } = require("write-json-file"); -const directionalMean = require("./index").default; +import test from "tape"; +import path from "path"; +import { loadJsonFileSync } from "load-json-file"; +import { writeJsonFileSync } from "write-json-file"; +import { directionalMean } from "./index"; test("turf-directional-mean", (t) => { const outGpsJsonPath1 = path.join( diff --git a/packages/turf-dissolve/bench.js b/packages/turf-dissolve/bench.ts similarity index 95% rename from packages/turf-dissolve/bench.js rename to packages/turf-dissolve/bench.ts index 3af201203..a1a9c18a3 100644 --- a/packages/turf-dissolve/bench.js +++ b/packages/turf-dissolve/bench.ts @@ -2,7 +2,7 @@ import fs from "fs"; import path from "path"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import dissolve from "./index"; +import { dissolve } from "./index"; const directory = path.join(__dirname, "test", "in") + path.sep; const fixtures = fs.readdirSync(directory).map((filename) => { diff --git a/packages/turf-dissolve/index.ts b/packages/turf-dissolve/index.ts index f8f1465fc..fd5a5eb2d 100644 --- a/packages/turf-dissolve/index.ts +++ b/packages/turf-dissolve/index.ts @@ -2,7 +2,7 @@ import { Feature, FeatureCollection, Polygon } from "geojson"; import { featureCollection, isObject, multiPolygon } from "@turf/helpers"; import { collectionOf } from "@turf/invariant"; import { featureEach } from "@turf/meta"; -import flatten from "@turf/flatten"; +import { flatten } from "@turf/flatten"; import polygonClipping, { Geom } from "polygon-clipping"; /** @@ -94,4 +94,5 @@ function dissolve( return flatten(featureCollection(outFeatures)); } +export { dissolve }; export default dissolve; diff --git a/packages/turf-dissolve/package.json b/packages/turf-dissolve/package.json index 44c33e8ec..9856093c6 100644 --- a/packages/turf-dissolve/package.json +++ b/packages/turf-dissolve/package.json @@ -39,15 +39,16 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js" + "test:tape": "tsx test.ts" }, "devDependencies": { + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "load-json-file": "^7.0.1", diff --git a/packages/turf-dissolve/test.js b/packages/turf-dissolve/test.ts similarity index 100% rename from packages/turf-dissolve/test.js rename to packages/turf-dissolve/test.ts diff --git a/packages/turf-distance-weight/bench.js b/packages/turf-distance-weight/bench.ts similarity index 73% rename from packages/turf-distance-weight/bench.js rename to packages/turf-distance-weight/bench.ts index ffccc16dd..fd4d68227 100644 --- a/packages/turf-distance-weight/bench.js +++ b/packages/turf-distance-weight/bench.ts @@ -1,7 +1,7 @@ -const Benchmark = require("benchmark"); -const distanceWeight = require("./dist/js/index.js").default; -const path = require("path"); -const { loadJsonFileSync } = require("load-json-file"); +import Benchmark from "benchmark"; +import { distanceWeight } from "./index"; +import path from "path"; +import { loadJsonFileSync } from "load-json-file"; /** * Benchmark Results diff --git a/packages/turf-distance-weight/index.ts b/packages/turf-distance-weight/index.ts index 125e75aa2..16ce731cc 100644 --- a/packages/turf-distance-weight/index.ts +++ b/packages/turf-distance-weight/index.ts @@ -9,7 +9,7 @@ import { featureEach } from "@turf/meta"; * @param feature2 point feature * @param p p-norm 1=, feature2: Feature, p = 2 @@ -46,7 +46,7 @@ export function pNormDistance( * var dataset = turf.randomPoint(100, { bbox: bbox }); * var result = turf.distanceWeight(dataset); */ -export default function distanceWeight( +function distanceWeight( fc: FeatureCollection, options?: { threshold?: number; @@ -121,3 +121,6 @@ export default function distanceWeight( return weights; } + +export { pNormDistance, distanceWeight }; +export default distanceWeight; diff --git a/packages/turf-distance-weight/package.json b/packages/turf-distance-weight/package.json index 4237d2fd0..1efd99ed1 100644 --- a/packages/turf-distance-weight/package.json +++ b/packages/turf-distance-weight/package.json @@ -39,15 +39,16 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js" + "test:tape": "tsx test.ts" }, "devDependencies": { + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "load-json-file": "^7.0.1", diff --git a/packages/turf-distance-weight/test.js b/packages/turf-distance-weight/test.ts similarity index 86% rename from packages/turf-distance-weight/test.js rename to packages/turf-distance-weight/test.ts index 99c216453..83059f4fe 100644 --- a/packages/turf-distance-weight/test.js +++ b/packages/turf-distance-weight/test.ts @@ -1,10 +1,10 @@ -const { point } = require("@turf/helpers"); +import { point } from "@turf/helpers"; -const test = require("tape"); -const path = require("path"); -const { loadJsonFileSync } = require("load-json-file"); -const distanceWeight = require("./dist/js/index.js").default; -const { pNormDistance } = require("./dist/js/index.js"); +import test from "tape"; +import path from "path"; +import { loadJsonFileSync } from "load-json-file"; +import { distanceWeight } from "./index"; +import { pNormDistance } from "./dist/js/index.js"; test("pNormDistance function", (t) => { t.equal(pNormDistance(point([2, 0]), point([0, 0]), 2), 2, "2-norm is ok"); diff --git a/packages/turf-distance/bench.js b/packages/turf-distance/bench.ts similarity index 72% rename from packages/turf-distance/bench.js rename to packages/turf-distance/bench.ts index a0bcb8eb9..4b33b7400 100644 --- a/packages/turf-distance/bench.js +++ b/packages/turf-distance/bench.ts @@ -1,5 +1,5 @@ -const Benchmark = require("benchmark"); -const distance = require("./index").default; +import Benchmark from "benchmark"; +import { distance } from "./index"; var pt1 = [-75.4, 39.4]; var pt2 = [-75.534, 39.123]; diff --git a/packages/turf-distance/index.ts b/packages/turf-distance/index.ts index 7f8176578..f6b05a8c6 100644 --- a/packages/turf-distance/index.ts +++ b/packages/turf-distance/index.ts @@ -51,4 +51,5 @@ function distance( ); } +export { distance }; export default distance; diff --git a/packages/turf-distance/package.json b/packages/turf-distance/package.json index afeb9d10c..767df17e4 100644 --- a/packages/turf-distance/package.json +++ b/packages/turf-distance/package.json @@ -38,15 +38,16 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js" + "test:tape": "tsx test.ts" }, "devDependencies": { + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "load-json-file": "^7.0.1", diff --git a/packages/turf-distance/test.js b/packages/turf-distance/test.ts similarity index 83% rename from packages/turf-distance/test.js rename to packages/turf-distance/test.ts index ca8e4e42e..88d2970a2 100644 --- a/packages/turf-distance/test.js +++ b/packages/turf-distance/test.ts @@ -1,10 +1,10 @@ -const fs = require("fs"); -const path = require("path"); -const test = require("tape"); -const { loadJsonFileSync } = require("load-json-file"); -const { writeJsonFileSync } = require("write-json-file"); -const { point } = require("@turf/helpers"); -const distance = require("./index").default; +import fs from "fs"; +import path from "path"; +import test from "tape"; +import { loadJsonFileSync } from "load-json-file"; +import { writeJsonFileSync } from "write-json-file"; +import { point } from "@turf/helpers"; +import { distance } from "./index"; const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-ellipse/bench.js b/packages/turf-ellipse/bench.ts similarity index 95% rename from packages/turf-ellipse/bench.js rename to packages/turf-ellipse/bench.ts index 31891de54..6dfb72780 100644 --- a/packages/turf-ellipse/bench.js +++ b/packages/turf-ellipse/bench.ts @@ -1,5 +1,5 @@ import Benchmark from "benchmark"; -import ellipse from "./index"; +import { ellipse } from "./index"; /** * Benchmark Results diff --git a/packages/turf-ellipse/index.ts b/packages/turf-ellipse/index.ts index 487edb711..19aacb0be 100644 --- a/packages/turf-ellipse/index.ts +++ b/packages/turf-ellipse/index.ts @@ -119,4 +119,5 @@ function getTanDeg(deg: number) { return Math.tan(rad); } +export { ellipse }; export default ellipse; diff --git a/packages/turf-ellipse/package.json b/packages/turf-ellipse/package.json index d05e04e40..4f448e819 100644 --- a/packages/turf-ellipse/package.json +++ b/packages/turf-ellipse/package.json @@ -39,13 +39,13 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js" + "test:tape": "tsx test.ts" }, "devDependencies": { "@mapbox/geojsonhint": "^3.2.0", @@ -53,6 +53,7 @@ "@turf/circle": "^7.0.0-alpha.2", "@turf/destination": "^7.0.0-alpha.2", "@turf/truncate": "^7.0.0-alpha.2", + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "glob": "^10.3.10", diff --git a/packages/turf-ellipse/test.js b/packages/turf-ellipse/test.ts similarity index 94% rename from packages/turf-ellipse/test.js rename to packages/turf-ellipse/test.ts index 00f7bc080..cbc499004 100644 --- a/packages/turf-ellipse/test.js +++ b/packages/turf-ellipse/test.ts @@ -3,14 +3,14 @@ import { glob } from "glob"; import path from "path"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; -import circle from "@turf/circle"; -import truncate from "@turf/truncate"; +import { circle } from "@turf/circle"; +import { truncate } from "@turf/truncate"; import geojsonhint from "@mapbox/geojsonhint"; -import bboxPolygon from "@turf/bbox-polygon"; -import rhumbDestination from "@turf/rhumb-destination"; +import { bboxPolygon } from "@turf/bbox-polygon"; +import { rhumbDestination } from "@turf/rhumb-destination"; // import destination from '@turf/destination'; import { featureCollection } from "@turf/helpers"; -import ellipse from "./index"; +import { ellipse } from "./index"; test("turf-ellipse", (t) => { glob diff --git a/packages/turf-envelope/bench.js b/packages/turf-envelope/bench.ts similarity index 92% rename from packages/turf-envelope/bench.js rename to packages/turf-envelope/bench.ts index 4f0f83fce..0442bcc0d 100644 --- a/packages/turf-envelope/bench.js +++ b/packages/turf-envelope/bench.ts @@ -1,7 +1,7 @@ import path from "path"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import envelope from "./index"; +import { envelope } from "./index"; const fixture = loadJsonFileSync( path.join(__dirname, "test", "in", "feature-collection.geojson") diff --git a/packages/turf-envelope/index.ts b/packages/turf-envelope/index.ts index 25c59c5bc..1db373e12 100644 --- a/packages/turf-envelope/index.ts +++ b/packages/turf-envelope/index.ts @@ -1,7 +1,7 @@ import type { Feature, Polygon } from "geojson"; import type { AllGeoJSON } from "@turf/helpers"; -import bbox from "@turf/bbox"; -import bboxPolygon from "@turf/bbox-polygon"; +import { bbox } from "@turf/bbox"; +import { bboxPolygon } from "@turf/bbox-polygon"; /** * Takes any number of features and returns a rectangular {@link Polygon} that encompasses all vertices. @@ -25,4 +25,5 @@ function envelope(geojson: AllGeoJSON): Feature { return bboxPolygon(bbox(geojson)); } +export { envelope }; export default envelope; diff --git a/packages/turf-envelope/package.json b/packages/turf-envelope/package.json index 5bc86e7a4..df4d03f31 100644 --- a/packages/turf-envelope/package.json +++ b/packages/turf-envelope/package.json @@ -39,15 +39,16 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js" + "test:tape": "tsx test.ts" }, "devDependencies": { + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "load-json-file": "^7.0.1", diff --git a/packages/turf-envelope/test.js b/packages/turf-envelope/test.ts similarity index 94% rename from packages/turf-envelope/test.js rename to packages/turf-envelope/test.ts index a3ce897dd..97280e563 100644 --- a/packages/turf-envelope/test.js +++ b/packages/turf-envelope/test.ts @@ -1,7 +1,7 @@ import path from "path"; import test from "tape"; import { loadJsonFileSync } from "load-json-file"; -import envelope from "./index"; +import { envelope } from "./index"; // Fixtures const fc = loadJsonFileSync( diff --git a/packages/turf-explode/bench.js b/packages/turf-explode/bench.ts similarity index 91% rename from packages/turf-explode/bench.js rename to packages/turf-explode/bench.ts index 448a9aec3..5c98b93fa 100644 --- a/packages/turf-explode/bench.js +++ b/packages/turf-explode/bench.ts @@ -1,6 +1,6 @@ import Benchmark from "benchmark"; import { polygon } from "@turf/helpers"; -import explode from "./index"; +import { explode } from "./index"; var poly = polygon([ [ diff --git a/packages/turf-explode/index.ts b/packages/turf-explode/index.ts index 35c49bba1..2ca866bb6 100644 --- a/packages/turf-explode/index.ts +++ b/packages/turf-explode/index.ts @@ -40,4 +40,5 @@ function explode(geojson: AllGeoJSON): FeatureCollection { return featureCollection(points); } +export { explode }; export default explode; diff --git a/packages/turf-explode/package.json b/packages/turf-explode/package.json index b5d2fe690..d0c25c108 100644 --- a/packages/turf-explode/package.json +++ b/packages/turf-explode/package.json @@ -38,15 +38,16 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js" + "test:tape": "tsx test.ts" }, "devDependencies": { + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "geojson-fixtures": "*", diff --git a/packages/turf-explode/test.js b/packages/turf-explode/test.ts similarity index 97% rename from packages/turf-explode/test.js rename to packages/turf-explode/test.ts index be18837ca..38aecea74 100644 --- a/packages/turf-explode/test.js +++ b/packages/turf-explode/test.ts @@ -4,7 +4,7 @@ import tape from "tape"; import { all as fixtures } from "geojson-fixtures"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; -import explode from "./index"; +import { explode } from "./index"; const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-flatten/bench.js b/packages/turf-flatten/bench.ts similarity index 96% rename from packages/turf-flatten/bench.js rename to packages/turf-flatten/bench.ts index 428c79b80..961eca9f4 100644 --- a/packages/turf-flatten/bench.js +++ b/packages/turf-flatten/bench.ts @@ -2,7 +2,7 @@ import fs from "fs"; import path from "path"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import flatten from "./index"; +import { flatten } from "./index"; // Define fixtures const directory = path.join(__dirname, "test", "in") + path.sep; diff --git a/packages/turf-flatten/index.ts b/packages/turf-flatten/index.ts index cde14a466..3ed12e7aa 100644 --- a/packages/turf-flatten/index.ts +++ b/packages/turf-flatten/index.ts @@ -54,4 +54,5 @@ function flatten(geojson: AllGeoJSON): FeatureCollection { return featureCollection(results); } +export { flatten }; export default flatten; diff --git a/packages/turf-flatten/package.json b/packages/turf-flatten/package.json index 79a894298..4b2be5d01 100644 --- a/packages/turf-flatten/package.json +++ b/packages/turf-flatten/package.json @@ -43,16 +43,17 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js", + "test:tape": "tsx test.ts", "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" }, "devDependencies": { + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "load-json-file": "^7.0.1", diff --git a/packages/turf-flatten/test.js b/packages/turf-flatten/test.ts similarity index 97% rename from packages/turf-flatten/test.js rename to packages/turf-flatten/test.ts index 64ca5fddd..47933ee93 100644 --- a/packages/turf-flatten/test.js +++ b/packages/turf-flatten/test.ts @@ -3,7 +3,7 @@ import test from "tape"; import path from "path"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; -import flatten from "./index"; +import { flatten } from "./index"; const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-flip/bench.js b/packages/turf-flip/bench.ts similarity index 96% rename from packages/turf-flip/bench.js rename to packages/turf-flip/bench.ts index 625249caa..d1f77864d 100644 --- a/packages/turf-flip/bench.js +++ b/packages/turf-flip/bench.ts @@ -2,7 +2,7 @@ import fs from "fs"; import path from "path"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import flip from "./index"; +import { flip } from "./index"; const directory = path.join(__dirname, "test", "in") + path.sep; const fixtures = fs.readdirSync(directory).map((filename) => { diff --git a/packages/turf-flip/index.ts b/packages/turf-flip/index.ts index f880c772f..d482b53ab 100644 --- a/packages/turf-flip/index.ts +++ b/packages/turf-flip/index.ts @@ -44,4 +44,5 @@ function flip( return geojson; } +export { flip }; export default flip; diff --git a/packages/turf-flip/package.json b/packages/turf-flip/package.json index aa516b275..ecfddbd4e 100644 --- a/packages/turf-flip/package.json +++ b/packages/turf-flip/package.json @@ -38,16 +38,17 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js", + "test:tape": "tsx test.ts", "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" }, "devDependencies": { + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "load-json-file": "^7.0.1", diff --git a/packages/turf-flip/test.js b/packages/turf-flip/test.ts similarity index 97% rename from packages/turf-flip/test.js rename to packages/turf-flip/test.ts index 04350a97e..d4d4f2d45 100644 --- a/packages/turf-flip/test.js +++ b/packages/turf-flip/test.ts @@ -4,7 +4,7 @@ import path from "path"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; import { point } from "@turf/helpers"; -import flip from "./index"; +import { flip } from "./index"; const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-geojson-rbush/bench.js b/packages/turf-geojson-rbush/bench.ts similarity index 87% rename from packages/turf-geojson-rbush/bench.js rename to packages/turf-geojson-rbush/bench.ts index 51d932f1a..ce0893c4f 100644 --- a/packages/turf-geojson-rbush/bench.js +++ b/packages/turf-geojson-rbush/bench.ts @@ -1,6 +1,6 @@ -const Benchmark = require("benchmark"); -const { randomPoint, randomPolygon } = require("@turf/random"); -const geojsonRbush = require("./").default; +import Benchmark from "benchmark"; +import { randomPoint, randomPolygon } from "@turf/random"; +import { rbush as geojsonRbush } from "./index"; // Fixtures const points = randomPoint(3); diff --git a/packages/turf-geojson-rbush/index.d.ts b/packages/turf-geojson-rbush/index.d.ts index 42fc43a07..ed3c09a94 100644 --- a/packages/turf-geojson-rbush/index.d.ts +++ b/packages/turf-geojson-rbush/index.d.ts @@ -24,7 +24,10 @@ declare class RBush { /** * https://github.com/mourner/rbush */ -export default function rbush< +declare function geojsonRbush< G extends Geometry = Geometry, P extends GeoJsonProperties = GeoJsonProperties, >(maxEntries?: number): RBush; + +export { geojsonRbush }; +export default geojsonRbush; diff --git a/packages/turf-geojson-rbush/index.js b/packages/turf-geojson-rbush/index.js index 359f397b6..55945bbf2 100644 --- a/packages/turf-geojson-rbush/index.js +++ b/packages/turf-geojson-rbush/index.js @@ -1,7 +1,7 @@ import rbush from "rbush"; import { featureCollection } from "@turf/helpers"; import { featureEach } from "@turf/meta"; -import turfBBox from "@turf/bbox"; +import { bbox as turfBBox } from "@turf/bbox"; /** * @module rbush @@ -216,4 +216,5 @@ function geojsonRbush(maxEntries) { return tree; } +export { geojsonRbush }; export default geojsonRbush; diff --git a/packages/turf-geojson-rbush/package.json b/packages/turf-geojson-rbush/package.json index a59bbd7fd..c12beee42 100644 --- a/packages/turf-geojson-rbush/package.json +++ b/packages/turf-geojson-rbush/package.json @@ -45,11 +45,11 @@ "index.d.ts" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "rollup -c ../../rollup.config.js && echo '{\"type\":\"module\"}' > dist/es/package.json", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js", + "test:tape": "tsx test.ts", "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" }, "devDependencies": { diff --git a/packages/turf-geojson-rbush/test.js b/packages/turf-geojson-rbush/test.ts similarity index 88% rename from packages/turf-geojson-rbush/test.js rename to packages/turf-geojson-rbush/test.ts index a65dbae3c..f1a2298b1 100644 --- a/packages/turf-geojson-rbush/test.js +++ b/packages/turf-geojson-rbush/test.ts @@ -1,11 +1,11 @@ -const fs = require("fs"); -const test = require("tape"); -const path = require("path"); -const { loadJsonFileSync } = require("load-json-file"); -const { writeJsonFileSync } = require("write-json-file"); -const bboxPolygon = require("@turf/bbox-polygon").default; -const { featureCollection, polygons } = require("@turf/helpers"); -const geojsonRbush = require("./").default; +import fs from "fs"; +import test from "tape"; +import path from "path"; +import { loadJsonFileSync } from "load-json-file"; +import { writeJsonFileSync } from "write-json-file"; +import { bboxPolygon } from "@turf/bbox-polygon"; +import { featureCollection, polygons } from "@turf/helpers"; +import { geojsonRbush } from "./index"; const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-geojson-rbush/types.ts b/packages/turf-geojson-rbush/types.ts index adf299ec0..cc10b4636 100644 --- a/packages/turf-geojson-rbush/types.ts +++ b/packages/turf-geojson-rbush/types.ts @@ -1,6 +1,6 @@ import { point, polygon, featureCollection } from "@turf/helpers"; import { BBox, Point, Polygon } from "geojson"; -import rbush from "./"; +import { geojsonRbush as rbush } from "./"; // Fixtures const bbox: BBox = [-180, -90, 180, 90]; diff --git a/packages/turf-great-circle/bench.js b/packages/turf-great-circle/bench.ts similarity index 89% rename from packages/turf-great-circle/bench.js rename to packages/turf-great-circle/bench.ts index 6ec6c25be..19621bc7a 100644 --- a/packages/turf-great-circle/bench.js +++ b/packages/turf-great-circle/bench.ts @@ -1,6 +1,6 @@ import Benchmark from "benchmark"; import { point } from "@turf/helpers"; -import greatCircle from "./index"; +import { greatCircle } from "./index"; const point1 = point([-75, 45]); const point2 = point([30, 45]); diff --git a/packages/turf-great-circle/index.d.ts b/packages/turf-great-circle/index.d.ts index 81d66466f..eae84e0d0 100644 --- a/packages/turf-great-circle/index.d.ts +++ b/packages/turf-great-circle/index.d.ts @@ -9,7 +9,7 @@ import { Coord } from "@turf/helpers"; /** * http://turfjs.org/docs/#greatcircle */ -export default function greatCircle( +declare function greatCircle( start: Coord, end: Coord, options?: { @@ -18,3 +18,6 @@ export default function greatCircle( offset?: number; } ): Feature; + +export { greatCircle }; +export default greatCircle; diff --git a/packages/turf-great-circle/index.js b/packages/turf-great-circle/index.js index c25886c1e..c8f53117d 100644 --- a/packages/turf-great-circle/index.js +++ b/packages/turf-great-circle/index.js @@ -49,4 +49,5 @@ function greatCircle(start, end, options) { return line.json(); } +export { greatCircle }; export default greatCircle; diff --git a/packages/turf-great-circle/package.json b/packages/turf-great-circle/package.json index a70386ee2..eb7e5f140 100644 --- a/packages/turf-great-circle/package.json +++ b/packages/turf-great-circle/package.json @@ -45,11 +45,11 @@ "index.d.ts" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "rollup -c ../../rollup.config.js && echo '{\"type\":\"module\"}' > dist/es/package.json", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js", + "test:tape": "tsx test.ts", "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" }, "devDependencies": { diff --git a/packages/turf-great-circle/test.js b/packages/turf-great-circle/test.ts similarity index 93% rename from packages/turf-great-circle/test.js rename to packages/turf-great-circle/test.ts index aed46cd12..ba94acb9b 100644 --- a/packages/turf-great-circle/test.js +++ b/packages/turf-great-circle/test.ts @@ -3,9 +3,9 @@ import test from "tape"; import path from "path"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; -import truncate from "@turf/truncate"; +import { truncate } from "@turf/truncate"; import { featureCollection } from "@turf/helpers"; -import greatCircle from "./index"; +import { greatCircle } from "./index"; const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-helpers/bench.js b/packages/turf-helpers/bench.ts similarity index 96% rename from packages/turf-helpers/bench.js rename to packages/turf-helpers/bench.ts index 445106b39..3ef97544f 100644 --- a/packages/turf-helpers/bench.js +++ b/packages/turf-helpers/bench.ts @@ -1,5 +1,5 @@ -const Benchmark = require("benchmark"); -const { +import Benchmark from "benchmark"; +import { point, lineString, polygon, @@ -9,7 +9,7 @@ const { featureCollection, geometryCollection, round, -} = require("./index"); +} from "./index"; /** * Benchmark Results diff --git a/packages/turf-helpers/package.json b/packages/turf-helpers/package.json index e66a0783c..ae499ad11 100644 --- a/packages/turf-helpers/package.json +++ b/packages/turf-helpers/package.json @@ -44,16 +44,17 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js", + "test:tape": "tsx test.ts", "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" }, "devDependencies": { + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "npm-run-all": "^4.1.5", diff --git a/packages/turf-helpers/test.js b/packages/turf-helpers/test.ts similarity index 99% rename from packages/turf-helpers/test.js rename to packages/turf-helpers/test.ts index a29258bf8..a2a8ac760 100644 --- a/packages/turf-helpers/test.js +++ b/packages/turf-helpers/test.ts @@ -1,5 +1,5 @@ -const test = require("tape"); -const { +import test from "tape"; +import { point, polygon, lineString, @@ -21,8 +21,8 @@ const { isObject, isNumber, earthRadius, -} = require("./index"); -const turf = require("./index"); +} from "./index"; +import * as turf from "./index"; test("point", (t) => { const ptArray = point([5, 10], { name: "test point" }); diff --git a/packages/turf-hex-grid/bench.js b/packages/turf-hex-grid/bench.ts similarity index 92% rename from packages/turf-hex-grid/bench.js rename to packages/turf-hex-grid/bench.ts index 5e54c4eb6..8ac452cba 100644 --- a/packages/turf-hex-grid/bench.js +++ b/packages/turf-hex-grid/bench.ts @@ -1,5 +1,5 @@ -const Benchmark = require("benchmark"); -const grid = require("./index").default; +import Benchmark from "benchmark"; +import { hexGrid as grid } from "./index"; // prettier-ignore var bbox = [ diff --git a/packages/turf-hex-grid/index.ts b/packages/turf-hex-grid/index.ts index f542b4982..69fd5d955 100644 --- a/packages/turf-hex-grid/index.ts +++ b/packages/turf-hex-grid/index.ts @@ -215,4 +215,5 @@ function hexTriangles( return triangles; } +export { hexGrid }; export default hexGrid; diff --git a/packages/turf-hex-grid/package.json b/packages/turf-hex-grid/package.json index 099743d22..cb4a7ae13 100644 --- a/packages/turf-hex-grid/package.json +++ b/packages/turf-hex-grid/package.json @@ -48,18 +48,19 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js", + "test:tape": "tsx test.ts", "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" }, "devDependencies": { "@turf/bbox-polygon": "^7.0.0-alpha.2", "@turf/truncate": "^7.0.0-alpha.2", + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "load-json-file": "^7.0.1", diff --git a/packages/turf-hex-grid/test.js b/packages/turf-hex-grid/test.ts similarity index 87% rename from packages/turf-hex-grid/test.js rename to packages/turf-hex-grid/test.ts index a74284751..245b4033d 100644 --- a/packages/turf-hex-grid/test.js +++ b/packages/turf-hex-grid/test.ts @@ -1,11 +1,11 @@ -const fs = require("fs"); -const test = require("tape"); -const path = require("path"); -const { loadJsonFileSync } = require("load-json-file"); -const { writeJsonFileSync } = require("write-json-file"); -const truncate = require("@turf/truncate").default; -const bboxPoly = require("@turf/bbox-polygon").default; -const hexGrid = require("./index").default; +import fs from "fs"; +import test from "tape"; +import path from "path"; +import { loadJsonFileSync } from "load-json-file"; +import { writeJsonFileSync } from "write-json-file"; +import { truncate } from "@turf/truncate"; +import { bboxPolygon as bboxPoly } from "@turf/bbox-polygon"; +import { hexGrid } from "./index"; const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-interpolate/bench.js b/packages/turf-interpolate/bench.ts similarity index 97% rename from packages/turf-interpolate/bench.js rename to packages/turf-interpolate/bench.ts index f7e6d59b5..85ce7f647 100644 --- a/packages/turf-interpolate/bench.js +++ b/packages/turf-interpolate/bench.ts @@ -2,7 +2,7 @@ import fs from "fs"; import path from "path"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import interpolate from "./index"; +import { interpolate } from "./index"; // Define Fixtures const directory = path.join(__dirname, "test", "in") + path.sep; diff --git a/packages/turf-interpolate/index.d.ts b/packages/turf-interpolate/index.d.ts index 2ae2f6c70..6e5639a85 100644 --- a/packages/turf-interpolate/index.d.ts +++ b/packages/turf-interpolate/index.d.ts @@ -4,7 +4,7 @@ import { Units, Grid } from "@turf/helpers"; /** * http://turfjs.org/docs/#interpolate */ -export default function interpolate( +declare function interpolate( points: FeatureCollection, cellSize: number, options?: { @@ -14,7 +14,7 @@ export default function interpolate( weight?: number; } ): FeatureCollection; -export default function interpolate( +declare function interpolate( points: FeatureCollection, cellSize: number, options?: { @@ -24,3 +24,6 @@ export default function interpolate( weight?: number; } ): FeatureCollection; + +export { interpolate }; +export default interpolate; diff --git a/packages/turf-interpolate/index.js b/packages/turf-interpolate/index.js index 87b4f8a03..263ce6d0c 100644 --- a/packages/turf-interpolate/index.js +++ b/packages/turf-interpolate/index.js @@ -104,4 +104,5 @@ function interpolate(points, cellSize, options) { return featureCollection(results); } +export { interpolate }; export default interpolate; diff --git a/packages/turf-interpolate/package.json b/packages/turf-interpolate/package.json index bba596a2c..f71e10f62 100644 --- a/packages/turf-interpolate/package.json +++ b/packages/turf-interpolate/package.json @@ -41,11 +41,11 @@ "index.d.ts" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "rollup -c ../../rollup.config.js && echo '{\"type\":\"module\"}' > dist/es/package.json", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js", + "test:tape": "tsx test.ts", "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" }, "devDependencies": { diff --git a/packages/turf-interpolate/test.js b/packages/turf-interpolate/test.ts similarity index 97% rename from packages/turf-interpolate/test.js rename to packages/turf-interpolate/test.ts index f35a5a628..33ef0f28c 100644 --- a/packages/turf-interpolate/test.js +++ b/packages/turf-interpolate/test.ts @@ -3,11 +3,11 @@ import test from "tape"; import path from "path"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; -import truncate from "@turf/truncate"; +import { truncate } from "@turf/truncate"; import { brightness } from "chromatism"; import { round, featureCollection, point } from "@turf/helpers"; import { featureEach, propEach } from "@turf/meta"; -import interpolate from "./index"; +import { interpolate } from "./index"; const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-intersect/bench.js b/packages/turf-intersect/bench.ts similarity index 77% rename from packages/turf-intersect/bench.js rename to packages/turf-intersect/bench.ts index 0cf12debc..300546277 100644 --- a/packages/turf-intersect/bench.js +++ b/packages/turf-intersect/bench.ts @@ -1,7 +1,7 @@ -const path = require("path"); -const { loadJsonFileSync } = require("load-json-file"); -const Benchmark = require("benchmark"); -const intersect = require("./index").default; +import path from "path"; +import { loadJsonFileSync } from "load-json-file"; +import Benchmark from "benchmark"; +import { intersect } from "./index"; // Fixtures const armenia = loadJsonFileSync( diff --git a/packages/turf-intersect/index.ts b/packages/turf-intersect/index.ts index 3ed07bf21..f8f3e8050 100644 --- a/packages/turf-intersect/index.ts +++ b/packages/turf-intersect/index.ts @@ -44,9 +44,7 @@ import polygonClipping from "polygon-clipping"; * //addToMap * var addToMap = [poly1, poly2, intersection]; */ -export default function intersect< - P extends GeoJsonProperties = GeoJsonProperties, ->( +function intersect

( features: FeatureCollection, options: { properties?: P; @@ -70,3 +68,6 @@ export default function intersect< return polygon(intersection[0], options.properties); return multiPolygon(intersection, options.properties); } + +export { intersect }; +export default intersect; diff --git a/packages/turf-intersect/package.json b/packages/turf-intersect/package.json index dd90a9db2..f5ddfbbe9 100644 --- a/packages/turf-intersect/package.json +++ b/packages/turf-intersect/package.json @@ -37,16 +37,17 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js", + "test:tape": "tsx test.ts", "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" }, "devDependencies": { + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "glob": "^10.3.10", diff --git a/packages/turf-intersect/test.js b/packages/turf-intersect/test.ts similarity index 78% rename from packages/turf-intersect/test.js rename to packages/turf-intersect/test.ts index 43eade7e5..c283f32fe 100644 --- a/packages/turf-intersect/test.js +++ b/packages/turf-intersect/test.ts @@ -1,10 +1,10 @@ -const path = require("path"); -const { glob } = require("glob"); -const test = require("tape"); -const { loadJsonFileSync } = require("load-json-file"); -const { writeJsonFileSync } = require("write-json-file"); -const { featureCollection } = require("@turf/helpers"); -const intersect = require("./index").default; +import path from "path"; +import { glob } from "glob"; +import test from "tape"; +import { loadJsonFileSync } from "load-json-file"; +import { writeJsonFileSync } from "write-json-file"; +import { featureCollection } from "@turf/helpers"; +import { intersect } from "./index"; const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-invariant/bench.js b/packages/turf-invariant/bench.ts similarity index 89% rename from packages/turf-invariant/bench.js rename to packages/turf-invariant/bench.ts index 345df2aeb..15c2ab712 100644 --- a/packages/turf-invariant/bench.js +++ b/packages/turf-invariant/bench.ts @@ -1,6 +1,6 @@ -const Benchmark = require("benchmark"); -const helpers = require("@turf/helpers"); -const invariant = require("./index"); +import Benchmark from "benchmark"; +import helpers from "@turf/helpers"; +import * as invariant from "./index"; const pt = helpers.point([-75, 40]); const line = helpers.lineString([ diff --git a/packages/turf-invariant/index.ts b/packages/turf-invariant/index.ts index 078937d1f..c544d3c75 100644 --- a/packages/turf-invariant/index.ts +++ b/packages/turf-invariant/index.ts @@ -23,7 +23,7 @@ import { isNumber } from "@turf/helpers"; * var coord = turf.getCoord(pt); * //= [10, 10] */ -export function getCoord(coord: Feature | Point | number[]): number[] { +function getCoord(coord: Feature | Point | number[]): number[] { if (!coord) { throw new Error("coord is required"); } @@ -64,7 +64,7 @@ export function getCoord(coord: Feature | Point | number[]): number[] { * var coords = turf.getCoords(poly); * //= [[[119.32, -8.7], [119.55, -8.69], [119.51, -8.54], [119.32, -8.7]]] */ -export function getCoords< +function getCoords< G extends | Point | LineString @@ -101,7 +101,7 @@ export function getCoords< * @param {Array} coordinates GeoJSON Coordinates * @returns {boolean} true if Array contains a number */ -export function containsNumber(coordinates: any[]): boolean { +function containsNumber(coordinates: any[]): boolean { if ( coordinates.length > 1 && isNumber(coordinates[0]) && @@ -125,7 +125,7 @@ export function containsNumber(coordinates: any[]): boolean { * @param {string} name name of calling function * @throws {Error} if value is not the expected type. */ -export function geojsonType(value: any, type: string, name: string): void { +function geojsonType(value: any, type: string, name: string): void { if (!type || !name) { throw new Error("type and name required"); } @@ -152,11 +152,7 @@ export function geojsonType(value: any, type: string, name: string): void { * @param {string} name name of calling function * @throws {Error} error if value is not the expected type. */ -export function featureOf( - feature: Feature, - type: string, - name: string -): void { +function featureOf(feature: Feature, type: string, name: string): void { if (!feature) { throw new Error("No feature passed"); } @@ -190,7 +186,7 @@ export function featureOf( * @param {string} name name of calling function * @throws {Error} if value is not the expected type. */ -export function collectionOf( +function collectionOf( featureCollection: FeatureCollection, type: string, name: string @@ -243,7 +239,7 @@ export function collectionOf( * var geom = turf.getGeom(point) * //={"type": "Point", "coordinates": [110, 40]} */ -export function getGeom(geojson: Feature | G): G { +function getGeom(geojson: Feature | G): G { if (geojson.type === "Feature") { return geojson.geometry; } @@ -268,7 +264,7 @@ export function getGeom(geojson: Feature | G): G { * var geom = turf.getType(point) * //="Point" */ -export function getType( +function getType( geojson: Feature | FeatureCollection | Geometry, _name?: string ): string { @@ -283,3 +279,15 @@ export function getType( } return geojson.type; } + +export { + getCoord, + getCoords, + containsNumber, + geojsonType, + featureOf, + collectionOf, + getGeom, + getType, +}; +// No default export! diff --git a/packages/turf-invariant/package.json b/packages/turf-invariant/package.json index 2a4b699f2..079ce96dc 100644 --- a/packages/turf-invariant/package.json +++ b/packages/turf-invariant/package.json @@ -41,16 +41,17 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js", + "test:tape": "tsx test.ts", "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" }, "devDependencies": { + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "npm-run-all": "^4.1.5", diff --git a/packages/turf-invariant/test.js b/packages/turf-invariant/test.ts similarity index 98% rename from packages/turf-invariant/test.js rename to packages/turf-invariant/test.ts index 5457e8504..ff5c8cd9f 100644 --- a/packages/turf-invariant/test.js +++ b/packages/turf-invariant/test.ts @@ -1,12 +1,12 @@ -const test = require("tape"); -const { +import test from "tape"; +import { point, lineString, polygon, featureCollection, geometryCollection, -} = require("@turf/helpers"); -const invariant = require("./index"); +} from "@turf/helpers"; +import * as invariant from "./index"; test("invariant -- containsNumber", (t) => { t.equals(invariant.containsNumber([1, 1]), true); diff --git a/packages/turf-isobands/bench.js b/packages/turf-isobands/bench.ts similarity index 98% rename from packages/turf-isobands/bench.js rename to packages/turf-isobands/bench.ts index 5c3573b8c..bd4bdca46 100644 --- a/packages/turf-isobands/bench.js +++ b/packages/turf-isobands/bench.ts @@ -3,7 +3,7 @@ import path from "path"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; import matrixToGrid from "./lib/matrix-to-grid"; -import isobands from "./index"; +import { isobands } from "./index"; // Define Fixtures const directory = path.join(__dirname, "test", "in") + path.sep; diff --git a/packages/turf-isobands/index.ts b/packages/turf-isobands/index.ts index 3f3f28227..023045fee 100644 --- a/packages/turf-isobands/index.ts +++ b/packages/turf-isobands/index.ts @@ -21,7 +21,8 @@ import { } from "geojson"; import gridToMatrix from "./lib/grid-to-matrix"; -const { isoBands } = require("marchingsquares"); +// @ts-expect-error Legacy JS library with no types defined +import { isoBands } from "marchingsquares"; type GroupRingProps = { [prop: string]: string }; type GroupedRings = @@ -281,4 +282,5 @@ function allGrouped( return true; } +export { isobands }; export default isobands; diff --git a/packages/turf-isobands/package.json b/packages/turf-isobands/package.json index 7edc30aad..fe8258171 100644 --- a/packages/turf-isobands/package.json +++ b/packages/turf-isobands/package.json @@ -44,13 +44,13 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js" + "test:tape": "tsx test.ts" }, "devDependencies": { "@turf/envelope": "^7.0.0-alpha.2", @@ -58,6 +58,7 @@ "@turf/random": "^7.0.0-alpha.2", "@turf/rhumb-destination": "^7.0.0-alpha.2", "@turf/truncate": "^7.0.0-alpha.2", + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "load-json-file": "^7.0.1", diff --git a/packages/turf-isobands/test.js b/packages/turf-isobands/test.ts similarity index 94% rename from packages/turf-isobands/test.js rename to packages/turf-isobands/test.ts index 4c8ee6ff8..ff64e3c80 100644 --- a/packages/turf-isobands/test.js +++ b/packages/turf-isobands/test.ts @@ -4,13 +4,13 @@ import path from "path"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; import envelope from "@turf/envelope"; -import pointGrid from "@turf/point-grid"; -import truncate from "@turf/truncate"; +import { pointGrid } from "@turf/point-grid"; +import { truncate } from "@turf/truncate"; import { getCoords } from "@turf/invariant"; import { lineString } from "@turf/helpers"; import { randomPolygon } from "@turf/random"; import matrixToGrid from "./lib/matrix-to-grid"; -import isobands from "./index"; +import { isobands } from "./index"; const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-isolines/bench.js b/packages/turf-isolines/bench.ts similarity index 97% rename from packages/turf-isolines/bench.js rename to packages/turf-isolines/bench.ts index 9295a3a68..e66f92c1e 100644 --- a/packages/turf-isolines/bench.js +++ b/packages/turf-isolines/bench.ts @@ -3,7 +3,7 @@ import path from "path"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; import matrixToGrid from "./lib/matrix-to-grid"; -import isolines from "./index"; +import { isolines } from "./index"; // Define Fixtures const directory = path.join(__dirname, "test", "in") + path.sep; diff --git a/packages/turf-isolines/index.ts b/packages/turf-isolines/index.ts index 53098de9a..298a55504 100644 --- a/packages/turf-isolines/index.ts +++ b/packages/turf-isolines/index.ts @@ -2,7 +2,8 @@ import bbox from "@turf/bbox"; import { coordEach } from "@turf/meta"; import { collectionOf } from "@turf/invariant"; import { multiLineString, featureCollection, isObject } from "@turf/helpers"; -const { isoContours } = require("marchingsquares"); +// @ts-expect-error Legacy JS library with no types defined +import { isoContours } from "marchingsquares"; import gridToMatrix from "./lib/grid-to-matrix"; import { FeatureCollection, @@ -163,4 +164,5 @@ function rescaleIsolines( return createdIsoLines; } +export { isolines }; export default isolines; diff --git a/packages/turf-isolines/package.json b/packages/turf-isolines/package.json index f2d5dbda2..815b40243 100644 --- a/packages/turf-isolines/package.json +++ b/packages/turf-isolines/package.json @@ -43,13 +43,13 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js", + "test:tape": "tsx test.ts", "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" }, "devDependencies": { @@ -58,6 +58,7 @@ "@turf/random": "^7.0.0-alpha.2", "@turf/rhumb-destination": "^7.0.0-alpha.2", "@turf/truncate": "^7.0.0-alpha.2", + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "load-json-file": "^7.0.1", diff --git a/packages/turf-isolines/test.js b/packages/turf-isolines/test.ts similarity index 96% rename from packages/turf-isolines/test.js rename to packages/turf-isolines/test.ts index 20d139d18..ad6e8df36 100644 --- a/packages/turf-isolines/test.js +++ b/packages/turf-isolines/test.ts @@ -4,13 +4,13 @@ import path from "path"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; import envelope from "@turf/envelope"; -import truncate from "@turf/truncate"; -import pointGrid from "@turf/point-grid"; +import { truncate } from "@turf/truncate"; +import { pointGrid } from "@turf/point-grid"; import { getCoords } from "@turf/invariant"; import { randomPolygon } from "@turf/random"; import { lineString } from "@turf/helpers"; import matrixToGrid from "./lib/matrix-to-grid"; -import isolines from "./index"; +import { isolines } from "./index"; const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-kinks/bench.js b/packages/turf-kinks/bench.ts similarity index 73% rename from packages/turf-kinks/bench.js rename to packages/turf-kinks/bench.ts index 58ef55671..2a5df0951 100644 --- a/packages/turf-kinks/bench.js +++ b/packages/turf-kinks/bench.ts @@ -1,8 +1,8 @@ -const fs = require("fs"); -const path = require("path"); -const { loadJsonFileSync } = require("load-json-file"); -const Benchmark = require("benchmark"); -const kinks = require("./index").default; +import fs from "fs"; +import path from "path"; +import { loadJsonFileSync } from "load-json-file"; +import Benchmark from "benchmark"; +import { kinks } from "./index"; const suite = new Benchmark.Suite("turf-kinks"); diff --git a/packages/turf-kinks/index.ts b/packages/turf-kinks/index.ts index 9221e82c4..9d6babbf4 100644 --- a/packages/turf-kinks/index.ts +++ b/packages/turf-kinks/index.ts @@ -32,9 +32,9 @@ import { point } from "@turf/helpers"; * //addToMap * var addToMap = [poly, kinks] */ -export default function kinks< - T extends LineString | MultiLineString | Polygon | MultiPolygon, ->(featureIn: Feature): FeatureCollection { +function kinks( + featureIn: Feature +): FeatureCollection { const results: FeatureCollection = { type: "FeatureCollection", features: [], @@ -56,3 +56,6 @@ export default function kinks< } return results; } + +export { kinks }; +export default kinks; diff --git a/packages/turf-kinks/package.json b/packages/turf-kinks/package.json index d2fc4237a..6aeaa6570 100644 --- a/packages/turf-kinks/package.json +++ b/packages/turf-kinks/package.json @@ -37,17 +37,18 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js", + "test:tape": "tsx test.ts", "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" }, "devDependencies": { "@turf/meta": "^7.0.0-alpha.2", + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "load-json-file": "^7.0.1", diff --git a/packages/turf-kinks/test.js b/packages/turf-kinks/test.ts similarity index 71% rename from packages/turf-kinks/test.js rename to packages/turf-kinks/test.ts index 7368eddd2..12b44c164 100644 --- a/packages/turf-kinks/test.js +++ b/packages/turf-kinks/test.ts @@ -1,10 +1,10 @@ -const test = require("tape"); -const fs = require("fs"); -const path = require("path"); -const { loadJsonFileSync } = require("load-json-file"); -const { writeJsonFileSync } = require("write-json-file"); -const { featureEach } = require("@turf/meta"); -const kinks = require("./index").default; +import test from "tape"; +import fs from "fs"; +import path from "path"; +import { loadJsonFileSync } from "load-json-file"; +import { writeJsonFileSync } from "write-json-file"; +import { featureEach } from "@turf/meta"; +import { kinks } from "./index"; const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-length/bench.js b/packages/turf-length/bench.ts similarity index 81% rename from packages/turf-length/bench.js rename to packages/turf-length/bench.ts index 2bf7b4ebc..c2fef085f 100644 --- a/packages/turf-length/bench.js +++ b/packages/turf-length/bench.ts @@ -1,8 +1,8 @@ -const fs = require("fs"); -const path = require("path"); -const { loadJsonFileSync } = require("load-json-file"); -const Benchmark = require("benchmark"); -const length = require("./index").default; +import fs from "fs"; +import path from "path"; +import { loadJsonFileSync } from "load-json-file"; +import Benchmark from "benchmark"; +import { length } from "./index"; // Define fixtures const directory = path.join(__dirname, "test", "in") + path.sep; diff --git a/packages/turf-length/index.ts b/packages/turf-length/index.ts index c95652192..71fa1af71 100644 --- a/packages/turf-length/index.ts +++ b/packages/turf-length/index.ts @@ -19,7 +19,7 @@ import { segmentReduce } from "@turf/meta"; * var addToMap = [line]; * line.properties.distance = length; */ -export default function length( +function length( geojson: Feature | FeatureCollection | GeometryCollection, options: { units?: Units; @@ -35,3 +35,6 @@ export default function length( 0 ); } + +export { length }; +export default length; diff --git a/packages/turf-length/package.json b/packages/turf-length/package.json index 643d47eca..3f3776433 100644 --- a/packages/turf-length/package.json +++ b/packages/turf-length/package.json @@ -44,15 +44,16 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js" + "test:tape": "tsx test.ts" }, "devDependencies": { + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "load-json-file": "^7.0.1", diff --git a/packages/turf-length/test.js b/packages/turf-length/test.ts similarity index 73% rename from packages/turf-length/test.js rename to packages/turf-length/test.ts index bcc1d367e..e5208b144 100644 --- a/packages/turf-length/test.js +++ b/packages/turf-length/test.ts @@ -1,9 +1,9 @@ -const fs = require("fs"); -const test = require("tape"); -const path = require("path"); -const { loadJsonFileSync } = require("load-json-file"); -const { writeJsonFileSync } = require("write-json-file"); -const length = require("./index").default; +import fs from "fs"; +import test from "tape"; +import path from "path"; +import { loadJsonFileSync } from "load-json-file"; +import { writeJsonFileSync } from "write-json-file"; +import { length } from "./index"; const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-line-arc/bench.js b/packages/turf-line-arc/bench.ts similarity index 84% rename from packages/turf-line-arc/bench.js rename to packages/turf-line-arc/bench.ts index d14566778..f64d18da5 100644 --- a/packages/turf-line-arc/bench.js +++ b/packages/turf-line-arc/bench.ts @@ -1,8 +1,8 @@ -const fs = require("fs"); -const path = require("path"); -const { loadJsonFileSync } = require("load-json-file"); -const Benchmark = require("benchmark"); -const lineArc = require("./index").default; +import fs from "fs"; +import path from "path"; +import { loadJsonFileSync } from "load-json-file"; +import Benchmark from "benchmark"; +import { lineArc } from "./index"; const directory = path.join(__dirname, "test", "in") + path.sep; const fixtures = fs.readdirSync(directory).map((filename) => { diff --git a/packages/turf-line-arc/index.ts b/packages/turf-line-arc/index.ts index 1cb9d9e82..5648159b6 100644 --- a/packages/turf-line-arc/index.ts +++ b/packages/turf-line-arc/index.ts @@ -27,7 +27,7 @@ import { Coord, lineString, Units } from "@turf/helpers"; * //addToMap * var addToMap = [center, arc] */ -export default function lineArc( +function lineArc( center: Coord, radius: number, bearing1: number, @@ -89,3 +89,6 @@ function convertAngleTo360(alpha: number) { } return beta; } + +export { lineArc }; +export default lineArc; diff --git a/packages/turf-line-arc/package.json b/packages/turf-line-arc/package.json index adbfd420c..1174ac7cc 100644 --- a/packages/turf-line-arc/package.json +++ b/packages/turf-line-arc/package.json @@ -36,17 +36,18 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js", + "test:tape": "tsx test.ts", "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" }, "devDependencies": { "@turf/truncate": "^7.0.0-alpha.2", + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "load-json-file": "^7.0.1", diff --git a/packages/turf-line-arc/test.js b/packages/turf-line-arc/test.ts similarity index 85% rename from packages/turf-line-arc/test.js rename to packages/turf-line-arc/test.ts index 5f362780a..68e5e1a52 100644 --- a/packages/turf-line-arc/test.js +++ b/packages/turf-line-arc/test.ts @@ -1,11 +1,11 @@ -const fs = require("fs"); -const test = require("tape"); -const path = require("path"); -const { loadJsonFileSync } = require("load-json-file"); -const { writeJsonFileSync } = require("write-json-file"); -const truncate = require("@turf/truncate").default; -const { featureCollection, point } = require("@turf/helpers"); -const lineArc = require("./index").default; +import fs from "fs"; +import test from "tape"; +import path from "path"; +import { loadJsonFileSync } from "load-json-file"; +import { writeJsonFileSync } from "write-json-file"; +import { truncate } from "@turf/truncate"; +import { featureCollection, point } from "@turf/helpers"; +import { lineArc } from "./index"; const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-line-chunk/bench.js b/packages/turf-line-chunk/bench.ts similarity index 96% rename from packages/turf-line-chunk/bench.js rename to packages/turf-line-chunk/bench.ts index aa84c3095..4f014f16e 100644 --- a/packages/turf-line-chunk/bench.js +++ b/packages/turf-line-chunk/bench.ts @@ -2,7 +2,7 @@ import fs from "fs"; import path from "path"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import lineChunk from "./index"; +import { lineChunk } from "./index"; const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-line-chunk/index.d.ts b/packages/turf-line-chunk/index.d.ts index 6773b9400..b0ee9595a 100644 --- a/packages/turf-line-chunk/index.d.ts +++ b/packages/turf-line-chunk/index.d.ts @@ -10,7 +10,7 @@ import { Units } from "@turf/helpers"; /** * http://turfjs.org/docs/#lineChunk */ -export default function lineChunk( +declare function lineChunk( geojson: | Feature | FeatureCollection @@ -23,3 +23,6 @@ export default function lineChunk( reverse?: boolean; } ): FeatureCollection; + +export { lineChunk }; +export default lineChunk; diff --git a/packages/turf-line-chunk/index.js b/packages/turf-line-chunk/index.js index fe7f8f50c..99d87357b 100644 --- a/packages/turf-line-chunk/index.js +++ b/packages/turf-line-chunk/index.js @@ -84,4 +84,5 @@ function sliceLineSegments(line, segmentLength, units, callback) { } } +export { lineChunk }; export default lineChunk; diff --git a/packages/turf-line-chunk/package.json b/packages/turf-line-chunk/package.json index 3182e3d00..0743361f1 100644 --- a/packages/turf-line-chunk/package.json +++ b/packages/turf-line-chunk/package.json @@ -46,11 +46,11 @@ "index.d.ts" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "rollup -c ../../rollup.config.js && echo '{\"type\":\"module\"}' > dist/es/package.json", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js", + "test:tape": "tsx test.ts", "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" }, "devDependencies": { diff --git a/packages/turf-line-chunk/test.js b/packages/turf-line-chunk/test.ts similarity index 98% rename from packages/turf-line-chunk/test.js rename to packages/turf-line-chunk/test.ts index f312e2f3f..a899450c4 100644 --- a/packages/turf-line-chunk/test.js +++ b/packages/turf-line-chunk/test.ts @@ -6,7 +6,7 @@ import { writeJsonFileSync } from "write-json-file"; import truncate from "@turf/truncate"; import { featureEach } from "@turf/meta"; import { lineString, featureCollection } from "@turf/helpers"; -import lineChunk from "./index"; +import { lineChunk } from "./index"; const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-line-intersect/bench.js b/packages/turf-line-intersect/bench.ts similarity index 81% rename from packages/turf-line-intersect/bench.js rename to packages/turf-line-intersect/bench.ts index 0ce0f241e..071055a6b 100644 --- a/packages/turf-line-intersect/bench.js +++ b/packages/turf-line-intersect/bench.ts @@ -1,8 +1,8 @@ -const fs = require("fs"); -const path = require("path"); -const { loadJsonFileSync } = require("load-json-file"); -const Benchmark = require("benchmark"); -const lineIntersect = require("./index").default; +import fs from "fs"; +import path from "path"; +import { loadJsonFileSync } from "load-json-file"; +import Benchmark from "benchmark"; +import { lineIntersect } from "./index"; const directory = path.join(__dirname, "test", "in") + path.sep; const fixtures = fs.readdirSync(directory).map((filename) => { diff --git a/packages/turf-line-intersect/index.ts b/packages/turf-line-intersect/index.ts index fdffb1980..351a9fb6d 100644 --- a/packages/turf-line-intersect/index.ts +++ b/packages/turf-line-intersect/index.ts @@ -86,4 +86,5 @@ function lineIntersect< return featureCollection(results.map((r) => point(r))); } +export { lineIntersect }; export default lineIntersect; diff --git a/packages/turf-line-intersect/package.json b/packages/turf-line-intersect/package.json index 3f7d79bd1..80c12c08b 100644 --- a/packages/turf-line-intersect/package.json +++ b/packages/turf-line-intersect/package.json @@ -43,16 +43,17 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js" + "test:tape": "tsx test.ts" }, "devDependencies": { "@turf/truncate": "^7.0.0-alpha.2", + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "load-json-file": "^7.0.1", diff --git a/packages/turf-line-intersect/test.js b/packages/turf-line-intersect/test.ts similarity index 89% rename from packages/turf-line-intersect/test.js rename to packages/turf-line-intersect/test.ts index 1b13f1598..c04d0d2c5 100644 --- a/packages/turf-line-intersect/test.js +++ b/packages/turf-line-intersect/test.ts @@ -1,16 +1,16 @@ -const fs = require("fs"); -const test = require("tape"); -const path = require("path"); -const { loadJsonFileSync } = require("load-json-file"); -const { writeJsonFileSync } = require("write-json-file"); -const truncate = require("@turf/truncate").default; -const { +import fs from "fs"; +import test from "tape"; +import path from "path"; +import { loadJsonFileSync } from "load-json-file"; +import { writeJsonFileSync } from "write-json-file"; +import { truncate } from "@turf/truncate"; +import { featureCollection, // geometryCollection, lineString, polygon, -} = require("@turf/helpers"); -const lineIntersect = require("./index").default; +} from "@turf/helpers"; +import { lineIntersect } from "./index"; const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-line-offset/bench.js b/packages/turf-line-offset/bench.ts similarity index 96% rename from packages/turf-line-offset/bench.js rename to packages/turf-line-offset/bench.ts index 85b1c07f3..5a5efabf4 100644 --- a/packages/turf-line-offset/bench.js +++ b/packages/turf-line-offset/bench.ts @@ -2,7 +2,7 @@ import fs from "fs"; import path from "path"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import lineOffset from "./index"; +import { lineOffset } from "./index"; const directory = path.join(__dirname, "test", "in") + path.sep; let fixtures = fs.readdirSync(directory).map((filename) => { diff --git a/packages/turf-line-offset/index.d.ts b/packages/turf-line-offset/index.d.ts index 8a13be840..7ea33fe2a 100644 --- a/packages/turf-line-offset/index.d.ts +++ b/packages/turf-line-offset/index.d.ts @@ -4,10 +4,13 @@ import { Units } from "@turf/helpers"; /** * http://turfjs.org/docs/#lineoffset */ -export default function lineOffset( +declare function lineOffset( line: Feature | T, distance: number, options?: { units?: Units; } ): Feature; + +export { lineOffset }; +export default lineOffset; diff --git a/packages/turf-line-offset/index.js b/packages/turf-line-offset/index.js index 2541e42f4..651d24adf 100644 --- a/packages/turf-line-offset/index.js +++ b/packages/turf-line-offset/index.js @@ -130,4 +130,5 @@ function processSegment(point1, point2, offset) { ]; } +export { lineOffset }; export default lineOffset; diff --git a/packages/turf-line-offset/package.json b/packages/turf-line-offset/package.json index 5e960886e..2c1148e18 100644 --- a/packages/turf-line-offset/package.json +++ b/packages/turf-line-offset/package.json @@ -44,11 +44,11 @@ "index.d.ts" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "rollup -c ../../rollup.config.js && echo '{\"type\":\"module\"}' > dist/es/package.json", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js", + "test:tape": "tsx test.ts", "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" }, "devDependencies": { diff --git a/packages/turf-line-offset/test.js b/packages/turf-line-offset/test.ts similarity index 96% rename from packages/turf-line-offset/test.js rename to packages/turf-line-offset/test.ts index bd6e3de6d..d13755d16 100644 --- a/packages/turf-line-offset/test.js +++ b/packages/turf-line-offset/test.ts @@ -3,9 +3,9 @@ import test from "tape"; import path from "path"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; -import truncate from "@turf/truncate"; +import { truncate } from "@turf/truncate"; import { featureCollection, lineString } from "@turf/helpers"; -import lineOffset from "./index"; +import { lineOffset } from "./index"; const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-line-overlap/bench.js b/packages/turf-line-overlap/bench.ts similarity index 79% rename from packages/turf-line-overlap/bench.js rename to packages/turf-line-overlap/bench.ts index 6e79f8f5c..378b5a1b1 100644 --- a/packages/turf-line-overlap/bench.js +++ b/packages/turf-line-overlap/bench.ts @@ -1,8 +1,8 @@ -const fs = require("fs"); -const path = require("path"); -const { loadJsonFileSync } = require("load-json-file"); -const Benchmark = require("benchmark"); -const lineOverlap = require("./index").default; +import fs from "fs"; +import path from "path"; +import { loadJsonFileSync } from "load-json-file"; +import Benchmark from "benchmark"; +import { lineOverlap } from "./index"; const directory = path.join(__dirname, "test", "in") + path.sep; const fixtures = fs.readdirSync(directory).map((filename) => { diff --git a/packages/turf-line-overlap/index.ts b/packages/turf-line-overlap/index.ts index d9f07594a..f5d0f8c7b 100644 --- a/packages/turf-line-overlap/index.ts +++ b/packages/turf-line-overlap/index.ts @@ -165,4 +165,5 @@ function concatSegment( return line; } +export { lineOverlap }; export default lineOverlap; diff --git a/packages/turf-line-overlap/package.json b/packages/turf-line-overlap/package.json index 60c95ab93..983db4626 100644 --- a/packages/turf-line-overlap/package.json +++ b/packages/turf-line-overlap/package.json @@ -42,16 +42,17 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js", + "test:tape": "tsx test.ts", "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" }, "devDependencies": { + "@types/benchmark": "^2.1.5", "@types/deep-equal": "^1.0.4", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", diff --git a/packages/turf-line-overlap/test.js b/packages/turf-line-overlap/test.ts similarity index 85% rename from packages/turf-line-overlap/test.js rename to packages/turf-line-overlap/test.ts index b7ba816f7..c120a83a6 100644 --- a/packages/turf-line-overlap/test.js +++ b/packages/turf-line-overlap/test.ts @@ -1,11 +1,11 @@ -const fs = require("fs"); -const test = require("tape"); -const path = require("path"); -const { loadJsonFileSync } = require("load-json-file"); -const { writeJsonFileSync } = require("write-json-file"); -const { featureEach } = require("@turf/meta"); -const { featureCollection, lineString } = require("@turf/helpers"); -const lineOverlap = require("./index").default; +import fs from "fs"; +import test from "tape"; +import path from "path"; +import { loadJsonFileSync } from "load-json-file"; +import { writeJsonFileSync } from "write-json-file"; +import { featureEach } from "@turf/meta"; +import { featureCollection, lineString } from "@turf/helpers"; +import { lineOverlap } from "./index"; const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-line-segment/bench.js b/packages/turf-line-segment/bench.ts similarity index 82% rename from packages/turf-line-segment/bench.js rename to packages/turf-line-segment/bench.ts index dd6bf00d9..a2f0dbec3 100644 --- a/packages/turf-line-segment/bench.js +++ b/packages/turf-line-segment/bench.ts @@ -1,8 +1,8 @@ -const fs = require("fs"); -const path = require("path"); -const { loadJsonFileSync } = require("load-json-file"); -const Benchmark = require("benchmark"); -const lineSegment = require("./index").default; +import fs from "fs"; +import path from "path"; +import { loadJsonFileSync } from "load-json-file"; +import Benchmark from "benchmark"; +import { lineSegment } from "./index"; // Fixtures const directory = path.join(__dirname, "test", "in") + path.sep; diff --git a/packages/turf-line-segment/index.ts b/packages/turf-line-segment/index.ts index 4d40d29c1..5c518277f 100644 --- a/packages/turf-line-segment/index.ts +++ b/packages/turf-line-segment/index.ts @@ -112,4 +112,5 @@ function bbox(coords1: number[], coords2: number[]): BBox { return [west, south, east, north]; } +export { lineSegment }; export default lineSegment; diff --git a/packages/turf-line-segment/package.json b/packages/turf-line-segment/package.json index 6d635ddf0..67ef323e3 100644 --- a/packages/turf-line-segment/package.json +++ b/packages/turf-line-segment/package.json @@ -37,15 +37,16 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js" + "test:tape": "tsx test.ts" }, "devDependencies": { + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "load-json-file": "^7.0.1", diff --git a/packages/turf-line-segment/test.js b/packages/turf-line-segment/test.ts similarity index 81% rename from packages/turf-line-segment/test.js rename to packages/turf-line-segment/test.ts index 32c1d7271..1da32aa0e 100644 --- a/packages/turf-line-segment/test.js +++ b/packages/turf-line-segment/test.ts @@ -1,11 +1,11 @@ -const fs = require("fs"); -const test = require("tape"); -const path = require("path"); -const { loadJsonFileSync } = require("load-json-file"); -const { writeJsonFileSync } = require("write-json-file"); -const { featureEach } = require("@turf/meta"); -const { featureCollection, lineString } = require("@turf/helpers"); -const lineSegment = require("./index").default; +import fs from "fs"; +import test from "tape"; +import path from "path"; +import { loadJsonFileSync } from "load-json-file"; +import { writeJsonFileSync } from "write-json-file"; +import { featureEach } from "@turf/meta"; +import { featureCollection, lineString } from "@turf/helpers"; +import { lineSegment } from "./index"; const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-line-slice-along/bench.js b/packages/turf-line-slice-along/bench.ts similarity index 97% rename from packages/turf-line-slice-along/bench.js rename to packages/turf-line-slice-along/bench.ts index 2e2fee80f..0e4244981 100644 --- a/packages/turf-line-slice-along/bench.js +++ b/packages/turf-line-slice-along/bench.ts @@ -1,6 +1,6 @@ import fs from "fs"; import Benchmark from "benchmark"; -import lineSliceAlong from "./index"; +import { lineSliceAlong } from "./index"; var line1 = JSON.parse( fs.readFileSync(__dirname + "/test/fixtures/line1.geojson") diff --git a/packages/turf-line-slice-along/index.d.ts b/packages/turf-line-slice-along/index.d.ts index 77afe3406..5ced1a8b6 100644 --- a/packages/turf-line-slice-along/index.d.ts +++ b/packages/turf-line-slice-along/index.d.ts @@ -4,7 +4,7 @@ import { Units } from "@turf/helpers"; /** * http://turfjs.org/docs/ */ -export default function lineSliceAlong( +declare function lineSliceAlong( line: Feature | LineString, startDist: number, stopDist: number, @@ -12,3 +12,6 @@ export default function lineSliceAlong( units?: Units; } ): Feature; + +export { lineSliceAlong }; +export default lineSliceAlong; diff --git a/packages/turf-line-slice-along/index.js b/packages/turf-line-slice-along/index.js index d01319642..1b68f5e1c 100644 --- a/packages/turf-line-slice-along/index.js +++ b/packages/turf-line-slice-along/index.js @@ -84,4 +84,5 @@ function lineSliceAlong(line, startDist, stopDist, options) { return lineString([last, last]); } +export { lineSliceAlong }; export default lineSliceAlong; diff --git a/packages/turf-line-slice-along/package.json b/packages/turf-line-slice-along/package.json index 88c7705da..9ac532a76 100644 --- a/packages/turf-line-slice-along/package.json +++ b/packages/turf-line-slice-along/package.json @@ -38,11 +38,11 @@ "index.d.ts" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "rollup -c ../../rollup.config.js && echo '{\"type\":\"module\"}' > dist/es/package.json", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js" + "test:tape": "tsx test.ts" }, "devDependencies": { "@turf/along": "^7.0.0-alpha.2", diff --git a/packages/turf-line-slice-along/test.js b/packages/turf-line-slice-along/test.ts similarity index 96% rename from packages/turf-line-slice-along/test.js rename to packages/turf-line-slice-along/test.ts index 751549c27..a5c7db204 100644 --- a/packages/turf-line-slice-along/test.js +++ b/packages/turf-line-slice-along/test.ts @@ -1,9 +1,9 @@ import test from "tape"; import path from "path"; import { loadJsonFileSync } from "load-json-file"; -import along from "@turf/along"; -import length from "@turf/length"; -import lineSliceAlong from "./index"; +import { along } from "@turf/along"; +import { length } from "@turf/length"; +import { lineSliceAlong } from "./index"; var line1 = loadJsonFileSync( path.join(__dirname, "test", "fixtures", "line1.geojson") diff --git a/packages/turf-line-slice/bench.js b/packages/turf-line-slice/bench.ts similarity index 96% rename from packages/turf-line-slice/bench.js rename to packages/turf-line-slice/bench.ts index c0e0c07ed..629eb3a43 100644 --- a/packages/turf-line-slice/bench.js +++ b/packages/turf-line-slice/bench.ts @@ -1,7 +1,7 @@ import fs from "fs"; import Benchmark from "benchmark"; import { point } from "@turf/helpers"; -import lineSlice from "./index"; +import { lineSlice } from "./index"; var route1 = JSON.parse(fs.readFileSync(__dirname + "/test/in/route1.geojson")); var route2 = JSON.parse(fs.readFileSync(__dirname + "/test/in/route2.geojson")); diff --git a/packages/turf-line-slice/index.d.ts b/packages/turf-line-slice/index.d.ts index 9f3e23069..f01ebd861 100644 --- a/packages/turf-line-slice/index.d.ts +++ b/packages/turf-line-slice/index.d.ts @@ -4,8 +4,11 @@ import { Coord } from "@turf/helpers"; /** * http://turfjs.org/docs/#lineslice */ -export default function lineSlice( +declare function lineSlice( startPt: Coord, stopPt: Coord, line: Feature | LineString ): Feature; + +export { lineSlice }; +export default lineSlice; diff --git a/packages/turf-line-slice/index.js b/packages/turf-line-slice/index.js index 5f6e6966f..926fb28a7 100644 --- a/packages/turf-line-slice/index.js +++ b/packages/turf-line-slice/index.js @@ -57,4 +57,5 @@ function lineSlice(startPt, stopPt, line) { return linestring(clipCoords, line.properties); } +export { lineSlice }; export default lineSlice; diff --git a/packages/turf-line-slice/package.json b/packages/turf-line-slice/package.json index 7a1bb71ee..849e29628 100644 --- a/packages/turf-line-slice/package.json +++ b/packages/turf-line-slice/package.json @@ -42,11 +42,11 @@ "index.d.ts" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "rollup -c ../../rollup.config.js && echo '{\"type\":\"module\"}' > dist/es/package.json", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js" + "test:tape": "tsx test.ts" }, "devDependencies": { "@turf/truncate": "^7.0.0-alpha.2", diff --git a/packages/turf-line-slice/test.js b/packages/turf-line-slice/test.ts similarity index 96% rename from packages/turf-line-slice/test.js rename to packages/turf-line-slice/test.ts index a41e2dc0a..58eeec236 100644 --- a/packages/turf-line-slice/test.js +++ b/packages/turf-line-slice/test.ts @@ -5,7 +5,7 @@ import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; import truncate from "@turf/truncate"; import { featureCollection } from "@turf/helpers"; -import lineSlice from "./index"; +import { lineSlice } from "./index"; const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-line-split/bench.js b/packages/turf-line-split/bench.ts similarity index 97% rename from packages/turf-line-split/bench.js rename to packages/turf-line-split/bench.ts index 330cc3c7a..d6dd4ca85 100644 --- a/packages/turf-line-split/bench.js +++ b/packages/turf-line-split/bench.ts @@ -2,7 +2,7 @@ import fs from "fs"; import path from "path"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import lineSplit from "./index"; +import { lineSplit } from "./index"; const directory = path.join(__dirname, "test", "in") + path.sep; const fixtures = fs.readdirSync(directory).map((filename) => { diff --git a/packages/turf-line-split/index.d.ts b/packages/turf-line-split/index.d.ts index b01b960cd..610dde1c9 100644 --- a/packages/turf-line-split/index.d.ts +++ b/packages/turf-line-split/index.d.ts @@ -9,14 +9,17 @@ import { MultiPolygon, } from "geojson"; -export type Splitter = Feature< +declare type Splitter = Feature< Point | MultiPoint | LineString | MultiLineString | Polygon | MultiPolygon >; /** * http://turfjs.org/docs/#linesplit */ -export default function lineSplit( +declare function lineSplit( line: Feature | T, splitter: Splitter ): FeatureCollection; + +export { Splitter, lineSplit }; +export default lineSplit; diff --git a/packages/turf-line-split/index.js b/packages/turf-line-split/index.js index 70111057d..c3642bfc9 100644 --- a/packages/turf-line-split/index.js +++ b/packages/turf-line-split/index.js @@ -217,4 +217,5 @@ function pointsEquals(pt1, pt2) { return pt1[0] === pt2[0] && pt1[1] === pt2[1]; } +export { lineSplit }; export default lineSplit; diff --git a/packages/turf-line-split/package.json b/packages/turf-line-split/package.json index eefd3ecb6..de0b0c06e 100644 --- a/packages/turf-line-split/package.json +++ b/packages/turf-line-split/package.json @@ -43,11 +43,11 @@ "index.d.ts" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "rollup -c ../../rollup.config.js && echo '{\"type\":\"module\"}' > dist/es/package.json", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js" + "test:tape": "tsx test.ts" }, "devDependencies": { "benchmark": "^2.1.4", diff --git a/packages/turf-line-split/test.js b/packages/turf-line-split/test.ts similarity index 99% rename from packages/turf-line-split/test.js rename to packages/turf-line-split/test.ts index 0da80f928..2191b6326 100644 --- a/packages/turf-line-split/test.js +++ b/packages/turf-line-split/test.ts @@ -12,7 +12,7 @@ import { round, } from "@turf/helpers"; import { getCoords } from "@turf/invariant"; -import lineSplit from "./index"; +import { lineSplit } from "./index"; const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-line-to-polygon/bench.js b/packages/turf-line-to-polygon/bench.ts similarity index 85% rename from packages/turf-line-to-polygon/bench.js rename to packages/turf-line-to-polygon/bench.ts index aea8c0518..ddf596083 100644 --- a/packages/turf-line-to-polygon/bench.js +++ b/packages/turf-line-to-polygon/bench.ts @@ -1,8 +1,8 @@ -const fs = require("fs"); -const path = require("path"); -const { loadJsonFileSync } = require("load-json-file"); -const Benchmark = require("benchmark"); -const lineToPolygon = require("./index").default; +import fs from "fs"; +import path from "path"; +import { loadJsonFileSync } from "load-json-file"; +import Benchmark from "benchmark"; +import { lineToPolygon } from "./index"; const directory = path.join(__dirname, "test", "in") + path.sep; let fixtures = fs.readdirSync(directory).map((filename) => { diff --git a/packages/turf-line-to-polygon/index.ts b/packages/turf-line-to-polygon/index.ts index 97723a487..8eb1bc1f7 100644 --- a/packages/turf-line-to-polygon/index.ts +++ b/packages/turf-line-to-polygon/index.ts @@ -154,4 +154,5 @@ function calculateArea(bbox: BBox) { return Math.abs(west - east) * Math.abs(south - north); } +export { lineToPolygon }; export default lineToPolygon; diff --git a/packages/turf-line-to-polygon/package.json b/packages/turf-line-to-polygon/package.json index 77f31f353..365fa7928 100644 --- a/packages/turf-line-to-polygon/package.json +++ b/packages/turf-line-to-polygon/package.json @@ -42,16 +42,17 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js", + "test:tape": "tsx test.ts", "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" }, "devDependencies": { + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "load-json-file": "^7.0.1", diff --git a/packages/turf-line-to-polygon/test.js b/packages/turf-line-to-polygon/test.ts similarity index 80% rename from packages/turf-line-to-polygon/test.js rename to packages/turf-line-to-polygon/test.ts index ef1fb2272..d69b779a1 100644 --- a/packages/turf-line-to-polygon/test.js +++ b/packages/turf-line-to-polygon/test.ts @@ -1,11 +1,11 @@ -const fs = require("fs"); -const test = require("tape"); -const path = require("path"); -const { loadJsonFileSync } = require("load-json-file"); -const { writeJsonFileSync } = require("write-json-file"); -const { point, lineString } = require("@turf/helpers"); -const clone = require("@turf/clone").default; -const lineToPolygon = require("./index").default; +import fs from "fs"; +import test from "tape"; +import path from "path"; +import { loadJsonFileSync } from "load-json-file"; +import { writeJsonFileSync } from "write-json-file"; +import { point, lineString } from "@turf/helpers"; +import { clone } from "@turf/clone"; +import { lineToPolygon } from "./index"; const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-mask/bench.js b/packages/turf-mask/bench.ts similarity index 95% rename from packages/turf-mask/bench.js rename to packages/turf-mask/bench.ts index db7425901..57fe34426 100644 --- a/packages/turf-mask/bench.js +++ b/packages/turf-mask/bench.ts @@ -2,7 +2,7 @@ import fs from "fs"; import path from "path"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import turfMask from "./index"; +import { mask as turfMask } from "./index"; const suite = new Benchmark.Suite("turf-mask"); diff --git a/packages/turf-mask/index.d.ts b/packages/turf-mask/index.d.ts index d9f99901d..3efb5d86e 100644 --- a/packages/turf-mask/index.d.ts +++ b/packages/turf-mask/index.d.ts @@ -3,7 +3,10 @@ import { Feature, Polygon, MultiPolygon, FeatureCollection } from "geojson"; /** * http://turfjs.org/docs/#mask */ -export default function ( +declare function mask( poly: Feature | FeatureCollection | T, mask?: Feature | Polygon ): Feature; + +export { mask }; +export default mask; diff --git a/packages/turf-mask/index.js b/packages/turf-mask/index.js index 1c8fb89cb..5718c9826 100644 --- a/packages/turf-mask/index.js +++ b/packages/turf-mask/index.js @@ -76,4 +76,5 @@ function createMask(mask) { return createPolygon(coordinates); } +export { mask }; export default mask; diff --git a/packages/turf-mask/package.json b/packages/turf-mask/package.json index bf2b88fc7..dd9817d66 100644 --- a/packages/turf-mask/package.json +++ b/packages/turf-mask/package.json @@ -38,11 +38,11 @@ "index.d.ts" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "rollup -c ../../rollup.config.js && echo '{\"type\":\"module\"}' > dist/es/package.json", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js", + "test:tape": "tsx test.ts", "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" }, "devDependencies": { diff --git a/packages/turf-mask/test.js b/packages/turf-mask/test.ts similarity index 96% rename from packages/turf-mask/test.js rename to packages/turf-mask/test.ts index 74c1a986c..753593e74 100644 --- a/packages/turf-mask/test.js +++ b/packages/turf-mask/test.ts @@ -3,7 +3,7 @@ import test from "tape"; import path from "path"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; -import mask from "./index"; +import { mask } from "./index"; const SKIP = ["multi-polygon.geojson", "overlapping.geojson"]; diff --git a/packages/turf-meta/bench.js b/packages/turf-meta/bench.ts similarity index 98% rename from packages/turf-meta/bench.js rename to packages/turf-meta/bench.ts index 0e7dd4b1d..c1f393cd4 100644 --- a/packages/turf-meta/bench.js +++ b/packages/turf-meta/bench.ts @@ -1,6 +1,6 @@ -const Benchmark = require("benchmark"); -const random = require("@turf/random"); -const meta = require("./index"); +import Benchmark from "benchmark"; +import * as random from "@turf/random"; +import * as meta from "./index"; const fixtures = { point: random.randomPoint(), diff --git a/packages/turf-meta/index.d.ts b/packages/turf-meta/index.d.ts index 163587ea9..4fbab3849 100644 --- a/packages/turf-meta/index.d.ts +++ b/packages/turf-meta/index.d.ts @@ -17,7 +17,7 @@ import { AllGeoJSON, Lines, Id } from "@turf/helpers"; /** * http://turfjs.org/docs/#coordreduce */ -export function coordReduce( +declare function coordReduce( geojson: AllGeoJSON, callback: ( previousValue: Reducer, @@ -33,7 +33,7 @@ export function coordReduce( /** * http://turfjs.org/docs/#coordeach */ -export function coordEach( +declare function coordEach( geojson: AllGeoJSON, callback: ( currentCoord: number[], @@ -48,7 +48,7 @@ export function coordEach( /** * http://turfjs.org/docs/#propeach */ -export function propEach( +declare function propEach( geojson: Feature | FeatureCollection | Feature, callback: (currentProperties: Props, featureIndex: number) => void ): void; @@ -56,7 +56,7 @@ export function propEach( /** * http://turfjs.org/docs/#propreduce */ -export function propReduce< +declare function propReduce< Reducer, P extends GeoJsonProperties = GeoJsonProperties, >( @@ -72,7 +72,7 @@ export function propReduce< /** * http://turfjs.org/docs/#featurereduce */ -export function featureReduce< +declare function featureReduce< Reducer, G extends GeometryObject, P extends GeoJsonProperties = GeoJsonProperties, @@ -92,7 +92,7 @@ export function featureReduce< /** * http://turfjs.org/docs/#featureeach */ -export function featureEach< +declare function featureEach< G extends GeometryObject, P extends GeoJsonProperties = GeoJsonProperties, >( @@ -106,12 +106,12 @@ export function featureEach< /** * http://turfjs.org/docs/#coordall */ -export function coordAll(geojson: AllGeoJSON): number[][]; +declare function coordAll(geojson: AllGeoJSON): number[][]; /** * http://turfjs.org/docs/#geomreduce */ -export function geomReduce< +declare function geomReduce< Reducer, G extends GeometryObject, P extends GeoJsonProperties = GeoJsonProperties, @@ -136,7 +136,7 @@ export function geomReduce< /** * http://turfjs.org/docs/#geomeach */ -export function geomEach< +declare function geomEach< G extends GeometryObject | null, P extends GeoJsonProperties = GeoJsonProperties, >( @@ -158,7 +158,7 @@ export function geomEach< /** * http://turfjs.org/docs/#flattenreduce */ -export function flattenReduce< +declare function flattenReduce< Reducer, G extends GeometryObject, P extends GeoJsonProperties = GeoJsonProperties, @@ -181,7 +181,7 @@ export function flattenReduce< /** * http://turfjs.org/docs/#flatteneach */ -export function flattenEach< +declare function flattenEach< G extends GeometryObject = GeometryObject, P extends GeoJsonProperties = GeoJsonProperties, >( @@ -201,7 +201,7 @@ export function flattenEach< /** * http://turfjs.org/docs/#segmentreduce */ -export function segmentReduce< +declare function segmentReduce< Reducer, P extends GeoJsonProperties = GeoJsonProperties, >( @@ -225,7 +225,7 @@ export function segmentReduce< /** * http://turfjs.org/docs/#segmenteach */ -export function segmentEach

( +declare function segmentEach

( geojson: AllGeoJSON, callback: ( currentSegment?: Feature, @@ -239,7 +239,7 @@ export function segmentEach

( /** * http://turfjs.org/docs/#linereduce */ -export function lineReduce< +declare function lineReduce< Reducer, P extends GeoJsonProperties = GeoJsonProperties, >( @@ -262,7 +262,7 @@ export function lineReduce< /** * http://turfjs.org/docs/#lineeach */ -export function lineEach

( +declare function lineEach

( geojson: | FeatureCollection | Feature @@ -280,7 +280,7 @@ export function lineEach

( /** * http://turfjs.org/docs/#findsegment */ -export function findSegment< +declare function findSegment< G extends LineString | MultiLineString | Polygon | MultiPolygon, P extends GeoJsonProperties = GeoJsonProperties, >( @@ -299,7 +299,7 @@ export function findSegment< /** * http://turfjs.org/docs/#findpoint */ -export function findPoint< +declare function findPoint< G extends GeometryObject, P extends GeoJsonProperties = GeoJsonProperties, >( @@ -314,3 +314,23 @@ export function findPoint< id?: Id; } ): Feature; + +export { + coordReduce, + coordEach, + propEach, + propReduce, + featureReduce, + featureEach, + coordAll, + geomReduce, + geomEach, + flattenReduce, + flattenEach, + segmentReduce, + segmentEach, + lineReduce, + lineEach, + findSegment, + findPoint, +}; diff --git a/packages/turf-meta/index.js b/packages/turf-meta/index.js index fc2ff0d4d..7ffe10c13 100644 --- a/packages/turf-meta/index.js +++ b/packages/turf-meta/index.js @@ -33,7 +33,7 @@ import { feature, point, lineString, isObject } from "@turf/helpers"; * //=geometryIndex * }); */ -export function coordEach(geojson, callback, excludeWrapCoord) { +function coordEach(geojson, callback, excludeWrapCoord) { // Handles null Geometry -- Skips this GeoJSON if (geojson === null) return; var j, @@ -237,7 +237,7 @@ export function coordEach(geojson, callback, excludeWrapCoord) { * return currentCoord; * }); */ -export function coordReduce(geojson, callback, initialValue, excludeWrapCoord) { +function coordReduce(geojson, callback, initialValue, excludeWrapCoord) { var previousValue = initialValue; coordEach( geojson, @@ -291,7 +291,7 @@ export function coordReduce(geojson, callback, initialValue, excludeWrapCoord) { * //=featureIndex * }); */ -export function propEach(geojson, callback) { +function propEach(geojson, callback) { var i; switch (geojson.type) { case "FeatureCollection": @@ -349,7 +349,7 @@ export function propEach(geojson, callback) { * return currentProperties * }); */ -export function propReduce(geojson, callback, initialValue) { +function propReduce(geojson, callback, initialValue) { var previousValue = initialValue; propEach(geojson, function (currentProperties, featureIndex) { if (featureIndex === 0 && initialValue === undefined) @@ -387,7 +387,7 @@ export function propReduce(geojson, callback, initialValue) { * //=featureIndex * }); */ -export function featureEach(geojson, callback) { +function featureEach(geojson, callback) { if (geojson.type === "Feature") { callback(geojson, 0); } else if (geojson.type === "FeatureCollection") { @@ -439,7 +439,7 @@ export function featureEach(geojson, callback) { * return currentFeature * }); */ -export function featureReduce(geojson, callback, initialValue) { +function featureReduce(geojson, callback, initialValue) { var previousValue = initialValue; featureEach(geojson, function (currentFeature, featureIndex) { if (featureIndex === 0 && initialValue === undefined) @@ -464,7 +464,7 @@ export function featureReduce(geojson, callback, initialValue) { * var coords = turf.coordAll(features); * //= [[26, 37], [36, 53]] */ -export function coordAll(geojson) { +function coordAll(geojson) { var coords = []; coordEach(geojson, function (coord) { coords.push(coord); @@ -504,7 +504,7 @@ export function coordAll(geojson) { * //=featureId * }); */ -export function geomEach(geojson, callback) { +function geomEach(geojson, callback) { var i, j, g, @@ -670,7 +670,7 @@ export function geomEach(geojson, callback) { * return currentGeometry * }); */ -export function geomReduce(geojson, callback, initialValue) { +function geomReduce(geojson, callback, initialValue) { var previousValue = initialValue; geomEach( geojson, @@ -725,7 +725,7 @@ export function geomReduce(geojson, callback, initialValue) { * //=multiFeatureIndex * }); */ -export function flattenEach(geojson, callback) { +function flattenEach(geojson, callback) { geomEach(geojson, function (geometry, featureIndex, properties, bbox, id) { // Callback for single geometry var type = geometry === null ? null : geometry.type; @@ -823,7 +823,7 @@ export function flattenEach(geojson, callback) { * return currentFeature * }); */ -export function flattenReduce(geojson, callback, initialValue) { +function flattenReduce(geojson, callback, initialValue) { var previousValue = initialValue; flattenEach( geojson, @@ -883,7 +883,7 @@ export function flattenReduce(geojson, callback, initialValue) { * total++; * }); */ -export function segmentEach(geojson, callback) { +function segmentEach(geojson, callback) { flattenEach(geojson, function (feature, featureIndex, multiFeatureIndex) { var segmentIndex = 0; @@ -998,7 +998,7 @@ export function segmentEach(geojson, callback) { * return previousValue; * }, initialValue); */ -export function segmentReduce(geojson, callback, initialValue) { +function segmentReduce(geojson, callback, initialValue) { var previousValue = initialValue; var started = false; segmentEach( @@ -1057,7 +1057,7 @@ export function segmentReduce(geojson, callback, initialValue) { * //=geometryIndex * }); */ -export function lineEach(geojson, callback) { +function lineEach(geojson, callback) { // validation if (!geojson) throw new Error("geojson is required"); @@ -1137,7 +1137,7 @@ export function lineEach(geojson, callback) { * return currentLine * }); */ -export function lineReduce(geojson, callback, initialValue) { +function lineReduce(geojson, callback, initialValue) { var previousValue = initialValue; lineEach( geojson, @@ -1191,7 +1191,7 @@ export function lineReduce(geojson, callback, initialValue) { * turf.findSegment(multiLine, {multiFeatureIndex: -1, segmentIndex: -1}); * // => Feature> */ -export function findSegment(geojson, options) { +function findSegment(geojson, options) { // Optional Parameters options = options || {}; if (!isObject(options)) throw new Error("options is invalid"); @@ -1320,7 +1320,7 @@ export function findSegment(geojson, options) { * turf.findPoint(multiLine, {multiFeatureIndex: -1, coordIndex: -1}); * // => Feature> */ -export function findPoint(geojson, options) { +function findPoint(geojson, options) { // Optional Parameters options = options || {}; if (!isObject(options)) throw new Error("options is invalid"); @@ -1397,3 +1397,23 @@ export function findPoint(geojson, options) { } throw new Error("geojson is invalid"); } + +export { + coordReduce, + coordEach, + propEach, + propReduce, + featureReduce, + featureEach, + coordAll, + geomReduce, + geomEach, + flattenReduce, + flattenEach, + segmentReduce, + segmentEach, + lineReduce, + lineEach, + findSegment, + findPoint, +}; diff --git a/packages/turf-meta/package.json b/packages/turf-meta/package.json index 5d4653cf1..e5fb0b93b 100644 --- a/packages/turf-meta/package.json +++ b/packages/turf-meta/package.json @@ -60,11 +60,11 @@ "index.d.ts" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "rollup -c ../../rollup.config.js && echo '{\"type\":\"module\"}' > dist/es/package.json", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js", + "test:tape": "tsx test.ts", "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" }, "devDependencies": { diff --git a/packages/turf-meta/test.js b/packages/turf-meta/test.ts similarity index 99% rename from packages/turf-meta/test.js rename to packages/turf-meta/test.ts index 32c132889..a5c8e2767 100644 --- a/packages/turf-meta/test.js +++ b/packages/turf-meta/test.ts @@ -1,5 +1,5 @@ -const test = require("tape"); -const { +import test from "tape"; +import { point, lineString, feature, @@ -10,8 +10,8 @@ const { geometryCollection, featureCollection, lineStrings, -} = require("@turf/helpers"); -const meta = require("./index"); +} from "@turf/helpers"; +import * as meta from "./index"; const pt = point([0, 0], { a: 1 }); const pt2 = point([1, 1]); diff --git a/packages/turf-midpoint/bench.js b/packages/turf-midpoint/bench.ts similarity index 89% rename from packages/turf-midpoint/bench.js rename to packages/turf-midpoint/bench.ts index 87c7e4acc..1a854af22 100644 --- a/packages/turf-midpoint/bench.js +++ b/packages/turf-midpoint/bench.ts @@ -1,6 +1,6 @@ import Benchmark from "benchmark"; import { point } from "@turf/helpers"; -import midpoint from "./index"; +import { midpoint } from "./index"; var pt1 = point([0, 0]); var pt2 = point([10, 0]); diff --git a/packages/turf-midpoint/index.d.ts b/packages/turf-midpoint/index.d.ts index b3612cea4..5e4fc13ea 100644 --- a/packages/turf-midpoint/index.d.ts +++ b/packages/turf-midpoint/index.d.ts @@ -4,4 +4,7 @@ import { Coord } from "@turf/helpers"; /** * http://turfjs.org/docs/#midpoint */ -export default function midpoint(point1: Coord, point2: Coord): Feature; +declare function midpoint(point1: Coord, point2: Coord): Feature; + +export { midpoint }; +export default midpoint; diff --git a/packages/turf-midpoint/index.js b/packages/turf-midpoint/index.js index 93738d06d..8c7dd5ed8 100644 --- a/packages/turf-midpoint/index.js +++ b/packages/turf-midpoint/index.js @@ -1,6 +1,6 @@ -import bearing from "@turf/bearing"; -import destination from "@turf/destination"; -import distance from "@turf/distance"; +import { bearing } from "@turf/bearing"; +import { destination } from "@turf/destination"; +import { distance } from "@turf/distance"; /** * Takes two {@link Point|points} and returns a point midway between them. @@ -28,4 +28,5 @@ function midpoint(point1, point2) { return midpoint; } +export { midpoint }; export default midpoint; diff --git a/packages/turf-midpoint/package.json b/packages/turf-midpoint/package.json index 6e1f204a5..44e398b92 100644 --- a/packages/turf-midpoint/package.json +++ b/packages/turf-midpoint/package.json @@ -40,11 +40,11 @@ "index.d.ts" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "rollup -c ../../rollup.config.js && echo '{\"type\":\"module\"}' > dist/es/package.json", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js" + "test:tape": "tsx test.ts" }, "devDependencies": { "benchmark": "^2.1.4", diff --git a/packages/turf-midpoint/test.js b/packages/turf-midpoint/test.ts similarity index 95% rename from packages/turf-midpoint/test.js rename to packages/turf-midpoint/test.ts index a1b228c24..ac79e4eb6 100644 --- a/packages/turf-midpoint/test.js +++ b/packages/turf-midpoint/test.ts @@ -1,6 +1,6 @@ import test from "tape"; -import midpoint from "./index"; -import distance from "@turf/distance"; +import { midpoint } from "./index"; +import { distance } from "@turf/distance"; import { point } from "@turf/helpers"; test("midpoint -- horizontal equator", function (t) { diff --git a/packages/turf-moran-index/bench.js b/packages/turf-moran-index/bench.ts similarity index 75% rename from packages/turf-moran-index/bench.js rename to packages/turf-moran-index/bench.ts index d6c01b815..9fe3949f9 100644 --- a/packages/turf-moran-index/bench.js +++ b/packages/turf-moran-index/bench.ts @@ -1,7 +1,7 @@ -const Benchmark = require("benchmark"); -const moranIndex = require("./dist/js/index.js").default; -const path = require("path"); -const { loadJsonFileSync } = require("load-json-file"); +import Benchmark from "benchmark"; +import { moranIndex } from "./index"; +import path from "path"; +import { loadJsonFileSync } from "load-json-file"; /** * Benchmark Results diff --git a/packages/turf-moran-index/index.ts b/packages/turf-moran-index/index.ts index 19c206c3c..4a7aee03e 100644 --- a/packages/turf-moran-index/index.ts +++ b/packages/turf-moran-index/index.ts @@ -45,7 +45,7 @@ import { featureEach } from "@turf/meta"; * }); */ -export default function ( +function moranIndex( fc: FeatureCollection, options: { inputField: string; @@ -154,3 +154,6 @@ function variance(y: number[]): number { * @property {number} stdNorm the standard devitaion of the random distribution * @property {number} zNorm the z-score of the observe samples with regard to the random distribution */ + +export { moranIndex }; +export default moranIndex; diff --git a/packages/turf-moran-index/package.json b/packages/turf-moran-index/package.json index 3d0c8d824..121c9cff1 100644 --- a/packages/turf-moran-index/package.json +++ b/packages/turf-moran-index/package.json @@ -39,15 +39,16 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js" + "test:tape": "tsx test.ts" }, "devDependencies": { + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "load-json-file": "^7.0.1", diff --git a/packages/turf-moran-index/test.js b/packages/turf-moran-index/test.ts similarity index 84% rename from packages/turf-moran-index/test.js rename to packages/turf-moran-index/test.ts index 91ebd99f7..74b64a78b 100644 --- a/packages/turf-moran-index/test.js +++ b/packages/turf-moran-index/test.ts @@ -1,7 +1,7 @@ -const test = require("tape"); -const path = require("path"); -const { loadJsonFileSync } = require("load-json-file"); -const moranIndex = require("./dist/js/index.js").default; +import test from "tape"; +import path from "path"; +import { loadJsonFileSync } from "load-json-file"; +import { moranIndex } from "./index"; test("turf-moran-index", (t) => { const pointPath = path.join(__dirname, "test", "in", "point.json"); diff --git a/packages/turf-nearest-neighbor-analysis/bench.js b/packages/turf-nearest-neighbor-analysis/bench.ts similarity index 76% rename from packages/turf-nearest-neighbor-analysis/bench.js rename to packages/turf-nearest-neighbor-analysis/bench.ts index 68ee8ee37..596d3fba5 100644 --- a/packages/turf-nearest-neighbor-analysis/bench.js +++ b/packages/turf-nearest-neighbor-analysis/bench.ts @@ -1,8 +1,8 @@ -const Benchmark = require("benchmark"); -const { glob } = require("glob"); -const path = require("path"); -const { loadJsonFileSync } = require("load-json-file"); -const nearestNeighborAnalysis = require("./index").default; +import Benchmark from "benchmark"; +import { glob } from "glob"; +import path from "path"; +import { loadJsonFileSync } from "load-json-file"; +import { nearestNeighborAnalysis } from "./index"; /** * Benchmark Results diff --git a/packages/turf-nearest-neighbor-analysis/index.ts b/packages/turf-nearest-neighbor-analysis/index.ts index f22b8e9b8..2aa1227db 100644 --- a/packages/turf-nearest-neighbor-analysis/index.ts +++ b/packages/turf-nearest-neighbor-analysis/index.ts @@ -19,7 +19,7 @@ import { AreaUnits, } from "@turf/helpers"; -export interface NearestNeighborStatistics { +interface NearestNeighborStatistics { units: Units & AreaUnits; arealUnits: string; observedMeanDistance: number; @@ -28,7 +28,7 @@ export interface NearestNeighborStatistics { zScore: number; } -export interface NearestNeighborStudyArea extends Feature { +interface NearestNeighborStudyArea extends Feature { properties: { nearestNeighborAnalysis: NearestNeighborStatistics; [key: string]: any; @@ -142,4 +142,9 @@ function nearestNeighborAnalysis( return studyArea as NearestNeighborStudyArea; } +export { + nearestNeighborAnalysis, + NearestNeighborStatistics, + NearestNeighborStudyArea, +}; export default nearestNeighborAnalysis; diff --git a/packages/turf-nearest-neighbor-analysis/package.json b/packages/turf-nearest-neighbor-analysis/package.json index 8b503ec5d..bfac46aaa 100644 --- a/packages/turf-nearest-neighbor-analysis/package.json +++ b/packages/turf-nearest-neighbor-analysis/package.json @@ -39,16 +39,17 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js" + "test:tape": "tsx test.ts" }, "devDependencies": { "@turf/truncate": "^7.0.0-alpha.2", + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "load-json-file": "^7.0.1", diff --git a/packages/turf-nearest-neighbor-analysis/test.js b/packages/turf-nearest-neighbor-analysis/test.ts similarity index 72% rename from packages/turf-nearest-neighbor-analysis/test.js rename to packages/turf-nearest-neighbor-analysis/test.ts index 2388555ce..115335e3c 100644 --- a/packages/turf-nearest-neighbor-analysis/test.js +++ b/packages/turf-nearest-neighbor-analysis/test.ts @@ -1,13 +1,13 @@ -const fs = require("fs"); -const test = require("tape"); -const path = require("path"); -const { loadJsonFileSync } = require("load-json-file"); -const { writeJsonFileSync } = require("write-json-file"); -const truncate = require("@turf/truncate").default; -const centroid = require("@turf/centroid").default; -const { featureEach } = require("@turf/meta"); -const { featureCollection } = require("@turf/helpers"); -const nearestNeighborAnalysis = require("./index").default; +import fs from "fs"; +import test from "tape"; +import path from "path"; +import { loadJsonFileSync } from "load-json-file"; +import { writeJsonFileSync } from "write-json-file"; +import { truncate } from "@turf/truncate"; +import { centroid } from "@turf/centroid"; +import { featureEach } from "@turf/meta"; +import { featureCollection } from "@turf/helpers"; +import { nearestNeighborAnalysis } from "./index"; const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-nearest-point-on-line/bench.js b/packages/turf-nearest-point-on-line/bench.ts similarity index 81% rename from packages/turf-nearest-point-on-line/bench.js rename to packages/turf-nearest-point-on-line/bench.ts index e1e7da797..54b5a757a 100644 --- a/packages/turf-nearest-point-on-line/bench.js +++ b/packages/turf-nearest-point-on-line/bench.ts @@ -1,8 +1,8 @@ -const fs = require("fs"); -const path = require("path"); -const { loadJsonFileSync } = require("load-json-file"); -const Benchmark = require("benchmark"); -const nearestPointOnLine = require("./index").default; +import fs from "fs"; +import path from "path"; +import { loadJsonFileSync } from "load-json-file"; +import Benchmark from "benchmark"; +import { nearestPointOnLine } from "./index"; const directory = path.join(__dirname, "test", "in") + path.sep; const fixtures = fs.readdirSync(directory).map((filename) => { diff --git a/packages/turf-nearest-point-on-line/index.ts b/packages/turf-nearest-point-on-line/index.ts index 460b0db35..c4717bc8d 100644 --- a/packages/turf-nearest-point-on-line/index.ts +++ b/packages/turf-nearest-point-on-line/index.ts @@ -146,4 +146,5 @@ function nearestPointOnLine( return closestPt; } +export { nearestPointOnLine }; export default nearestPointOnLine; diff --git a/packages/turf-nearest-point-on-line/package.json b/packages/turf-nearest-point-on-line/package.json index 914701a31..429b33447 100644 --- a/packages/turf-nearest-point-on-line/package.json +++ b/packages/turf-nearest-point-on-line/package.json @@ -32,19 +32,20 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js", + "test:tape": "tsx test.ts", "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" }, "devDependencies": { "@turf/along": "^7.0.0-alpha.2", "@turf/length": "^7.0.0-alpha.2", "@turf/truncate": "^7.0.0-alpha.2", + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "load-json-file": "^7.0.1", diff --git a/packages/turf-nearest-point-on-line/test.js b/packages/turf-nearest-point-on-line/test.ts similarity index 95% rename from packages/turf-nearest-point-on-line/test.js rename to packages/turf-nearest-point-on-line/test.ts index 6a8d0f6b1..127013838 100644 --- a/packages/turf-nearest-point-on-line/test.js +++ b/packages/turf-nearest-point-on-line/test.ts @@ -1,20 +1,20 @@ -const fs = require("fs"); -const test = require("tape"); -const path = require("path"); -const { loadJsonFileSync } = require("load-json-file"); -const { writeJsonFileSync } = require("write-json-file"); -const along = require("@turf/along").default; -const distance = require("@turf/distance").default; -const truncate = require("@turf/truncate").default; -const length = require("@turf/length").default; -const { +import fs from "fs"; +import test from "tape"; +import path from "path"; +import { loadJsonFileSync } from "load-json-file"; +import { writeJsonFileSync } from "write-json-file"; +import { along } from "@turf/along"; +import { distance } from "@turf/distance"; +import { truncate } from "@turf/truncate"; +import { length } from "@turf/length"; +import { lineString, multiLineString, point, featureCollection, round, -} = require("@turf/helpers"); -const nearestPointOnLine = require("./index").default; +} from "@turf/helpers"; +import { nearestPointOnLine } from "./index"; const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-nearest-point-to-line/bench.js b/packages/turf-nearest-point-to-line/bench.ts similarity index 80% rename from packages/turf-nearest-point-to-line/bench.js rename to packages/turf-nearest-point-to-line/bench.ts index 54d8a9e18..9b898687e 100644 --- a/packages/turf-nearest-point-to-line/bench.js +++ b/packages/turf-nearest-point-to-line/bench.ts @@ -1,8 +1,8 @@ -const path = require("path"); -const { glob } = require("glob"); -const { loadJsonFileSync } = require("load-json-file"); -const Benchmark = require("benchmark"); -const nearestPointToLine = require("./index").default; +import path from "path"; +import { glob } from "glob"; +import { loadJsonFileSync } from "load-json-file"; +import Benchmark from "benchmark"; +import { nearestPointToLine } from "./index"; /** * Benchmark Results diff --git a/packages/turf-nearest-point-to-line/index.ts b/packages/turf-nearest-point-to-line/index.ts index 777b628dc..f31a08cae 100644 --- a/packages/turf-nearest-point-to-line/index.ts +++ b/packages/turf-nearest-point-to-line/index.ts @@ -111,4 +111,5 @@ function normalize(points: any): FeatureCollection { } } +export { nearestPointToLine }; export default nearestPointToLine; diff --git a/packages/turf-nearest-point-to-line/package.json b/packages/turf-nearest-point-to-line/package.json index 44b89b0ce..012735a48 100644 --- a/packages/turf-nearest-point-to-line/package.json +++ b/packages/turf-nearest-point-to-line/package.json @@ -42,18 +42,19 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js", + "test:tape": "tsx test.ts", "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" }, "devDependencies": { "@turf/circle": "^7.0.0-alpha.2", "@turf/truncate": "^7.0.0-alpha.2", + "@types/benchmark": "^2.1.5", "@types/object-assign": "^4.0.33", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", diff --git a/packages/turf-nearest-point-to-line/test.js b/packages/turf-nearest-point-to-line/test.ts similarity index 88% rename from packages/turf-nearest-point-to-line/test.js rename to packages/turf-nearest-point-to-line/test.ts index 2a1760e60..f7f2185e8 100644 --- a/packages/turf-nearest-point-to-line/test.js +++ b/packages/turf-nearest-point-to-line/test.ts @@ -1,18 +1,18 @@ -const fs = require("fs"); -const test = require("tape"); -const path = require("path"); -const { loadJsonFileSync } = require("load-json-file"); -const { writeJsonFileSync } = require("write-json-file"); -const circle = require("@turf/circle").default; -const truncate = require("@turf/truncate").default; -const { +import fs from "fs"; +import test from "tape"; +import path from "path"; +import { loadJsonFileSync } from "load-json-file"; +import { writeJsonFileSync } from "write-json-file"; +import { circle } from "@turf/circle"; +import { truncate } from "@turf/truncate"; +import { geometryCollection, featureCollection, point, lineString, round, -} = require("@turf/helpers"); -const nearestPointToLine = require("./index").default; +} from "@turf/helpers"; +import { nearestPointToLine } from "./index"; const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-nearest-point/bench.js b/packages/turf-nearest-point/bench.ts similarity index 69% rename from packages/turf-nearest-point/bench.js rename to packages/turf-nearest-point/bench.ts index 35a471592..7b4d3b41b 100644 --- a/packages/turf-nearest-point/bench.js +++ b/packages/turf-nearest-point/bench.ts @@ -1,7 +1,7 @@ -const path = require("path"); -const Benchmark = require("benchmark"); -const { loadJsonFileSync } = require("load-json-file"); -const nearestPoint = require("./index").default; +import path from "path"; +import Benchmark from "benchmark"; +import { loadJsonFileSync } from "load-json-file"; +import { nearestPoint } from "./index"; const pts = loadJsonFileSync(path.join(__dirname, "test", "in", "points.json")); diff --git a/packages/turf-nearest-point/index.ts b/packages/turf-nearest-point/index.ts index 630964a21..d53b5a8c9 100644 --- a/packages/turf-nearest-point/index.ts +++ b/packages/turf-nearest-point/index.ts @@ -1,10 +1,10 @@ import { Feature, FeatureCollection, Point } from "geojson"; import { Coord, Units } from "@turf/helpers"; -import clone from "@turf/clone"; -import distance from "@turf/distance"; +import { clone } from "@turf/clone"; +import { distance } from "@turf/distance"; import { featureEach } from "@turf/meta"; -export interface NearestPoint extends Feature { +interface NearestPoint extends Feature { properties: { featureIndex: number; distanceToPoint: number; @@ -70,4 +70,5 @@ function nearestPoint( }; } +export { nearestPoint, NearestPoint }; export default nearestPoint; diff --git a/packages/turf-nearest-point/package.json b/packages/turf-nearest-point/package.json index 7879f0e77..04befdcb5 100644 --- a/packages/turf-nearest-point/package.json +++ b/packages/turf-nearest-point/package.json @@ -40,16 +40,17 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js", + "test:tape": "tsx test.ts", "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" }, "devDependencies": { + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "npm-run-all": "^4.1.5", diff --git a/packages/turf-nearest-point/test.js b/packages/turf-nearest-point/test.ts similarity index 88% rename from packages/turf-nearest-point/test.js rename to packages/turf-nearest-point/test.ts index bf4867472..821e3c490 100644 --- a/packages/turf-nearest-point/test.js +++ b/packages/turf-nearest-point/test.ts @@ -1,10 +1,10 @@ -const fs = require("fs"); -const test = require("tape"); -const path = require("path"); -const { loadJsonFileSync } = require("load-json-file"); -const { writeJsonFileSync } = require("write-json-file"); -const { featureCollection, point } = require("@turf/helpers"); -const nearestPoint = require("./index").default; +import fs from "fs"; +import test from "tape"; +import path from "path"; +import { loadJsonFileSync } from "load-json-file"; +import { writeJsonFileSync } from "write-json-file"; +import { featureCollection, point } from "@turf/helpers"; +import { nearestPoint } from "./index"; const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-planepoint/bench.js b/packages/turf-planepoint/bench.ts similarity index 93% rename from packages/turf-planepoint/bench.js rename to packages/turf-planepoint/bench.ts index e6baa5a46..4c47aba84 100644 --- a/packages/turf-planepoint/bench.js +++ b/packages/turf-planepoint/bench.ts @@ -1,6 +1,6 @@ import Benchmark from "benchmark"; import { polygon } from "@turf/helpers"; -import planepoint from "./index"; +import { planepoint } from "./index"; const point = [1, 1]; const triangle = polygon( diff --git a/packages/turf-planepoint/index.d.ts b/packages/turf-planepoint/index.d.ts index 5d8f0f571..bbb3e5897 100644 --- a/packages/turf-planepoint/index.d.ts +++ b/packages/turf-planepoint/index.d.ts @@ -4,7 +4,10 @@ import { Coord } from "@turf/helpers"; /** * http://turfjs.org/docs/#planepoint */ -export default function planepoint( +declare function planepoint( point: Coord, triangle: Feature | Polygon ): number; + +export { planepoint }; +export default planepoint; diff --git a/packages/turf-planepoint/index.js b/packages/turf-planepoint/index.js index f3ecaa68f..0b6823b39 100644 --- a/packages/turf-planepoint/index.js +++ b/packages/turf-planepoint/index.js @@ -74,4 +74,5 @@ function planepoint(point, triangle) { return z; } +export { planepoint }; export default planepoint; diff --git a/packages/turf-planepoint/package.json b/packages/turf-planepoint/package.json index a051c0833..2199e06f2 100644 --- a/packages/turf-planepoint/package.json +++ b/packages/turf-planepoint/package.json @@ -40,11 +40,11 @@ "index.d.ts" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "rollup -c ../../rollup.config.js && echo '{\"type\":\"module\"}' > dist/es/package.json", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js", + "test:tape": "tsx test.ts", "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" }, "devDependencies": { diff --git a/packages/turf-planepoint/test.js b/packages/turf-planepoint/test.ts similarity index 94% rename from packages/turf-planepoint/test.js rename to packages/turf-planepoint/test.ts index 818521bc8..daeb2fdcb 100644 --- a/packages/turf-planepoint/test.js +++ b/packages/turf-planepoint/test.ts @@ -3,7 +3,7 @@ import test from "tape"; import { polygon } from "@turf/helpers"; -import planepoint from "./index"; +import { planepoint } from "./index"; test("turf-planepoint", (t) => { const point = [1, 1]; diff --git a/packages/turf-point-grid/bench.js b/packages/turf-point-grid/bench.ts similarity index 90% rename from packages/turf-point-grid/bench.js rename to packages/turf-point-grid/bench.ts index 900aad169..bd6f0eaa6 100644 --- a/packages/turf-point-grid/bench.js +++ b/packages/turf-point-grid/bench.ts @@ -1,6 +1,6 @@ -const Benchmark = require("benchmark"); -const { polygon } = require("@turf/helpers"); -const grid = require("./index").default; +import Benchmark from "benchmark"; +import { polygon } from "@turf/helpers"; +import { pointGrid as grid } from "./index"; var bbox = [-95, 30, -85, 40]; var mask = polygon([ diff --git a/packages/turf-point-grid/index.ts b/packages/turf-point-grid/index.ts index 03bd32552..05e8d716e 100644 --- a/packages/turf-point-grid/index.ts +++ b/packages/turf-point-grid/index.ts @@ -7,8 +7,8 @@ import { Point, GeoJsonProperties, } from "geojson"; -import within from "@turf/boolean-within"; -import distance from "@turf/distance"; +import { booleanWithin as within } from "@turf/boolean-within"; +import { distance } from "@turf/distance"; import { point, featureCollection, Units } from "@turf/helpers"; /** @@ -92,4 +92,5 @@ function pointGrid

( return featureCollection(results); } +export { pointGrid }; export default pointGrid; diff --git a/packages/turf-point-grid/package.json b/packages/turf-point-grid/package.json index abfccf1f6..8cc040092 100644 --- a/packages/turf-point-grid/package.json +++ b/packages/turf-point-grid/package.json @@ -42,18 +42,19 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js", + "test:tape": "tsx test.ts", "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" }, "devDependencies": { "@turf/bbox-polygon": "^7.0.0-alpha.2", "@turf/truncate": "^7.0.0-alpha.2", + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "load-json-file": "^7.0.1", diff --git a/packages/turf-point-grid/test.js b/packages/turf-point-grid/test.ts similarity index 80% rename from packages/turf-point-grid/test.js rename to packages/turf-point-grid/test.ts index 5a21e7d6a..3e54ac7fe 100644 --- a/packages/turf-point-grid/test.js +++ b/packages/turf-point-grid/test.ts @@ -1,11 +1,11 @@ -const fs = require("fs"); -const test = require("tape"); -const path = require("path"); -const { loadJsonFileSync } = require("load-json-file"); -const { writeJsonFileSync } = require("write-json-file"); -const bboxPoly = require("@turf/bbox-polygon").default; -const truncate = require("@turf/truncate").default; -const pointGrid = require("./dist/js/index.js").default; +import fs from "fs"; +import test from "tape"; +import path from "path"; +import { loadJsonFileSync } from "load-json-file"; +import { writeJsonFileSync } from "write-json-file"; +import { bboxPolygon as bboxPoly } from "@turf/bbox-polygon"; +import { truncate } from "@turf/truncate"; +import { pointGrid } from "./index"; const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-point-on-feature/bench.js b/packages/turf-point-on-feature/bench.ts similarity index 95% rename from packages/turf-point-on-feature/bench.js rename to packages/turf-point-on-feature/bench.ts index 6dce0863b..c3255b4cb 100644 --- a/packages/turf-point-on-feature/bench.js +++ b/packages/turf-point-on-feature/bench.ts @@ -2,7 +2,7 @@ import path from "path"; import { glob } from "glob"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import pointOnFeature from "./index"; +import { pointOnFeature } from "./index"; /** * Benchmark Results diff --git a/packages/turf-point-on-feature/index.ts b/packages/turf-point-on-feature/index.ts index f2150bfea..66edabd01 100644 --- a/packages/turf-point-on-feature/index.ts +++ b/packages/turf-point-on-feature/index.ts @@ -155,4 +155,5 @@ function pointOnSegment( return ab === ap + pb; } +export { pointOnFeature }; export default pointOnFeature; diff --git a/packages/turf-point-on-feature/package.json b/packages/turf-point-on-feature/package.json index fecaf7491..f3b260ab7 100644 --- a/packages/turf-point-on-feature/package.json +++ b/packages/turf-point-on-feature/package.json @@ -40,17 +40,18 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js" + "test:tape": "tsx test.ts" }, "devDependencies": { "@turf/meta": "^7.0.0-alpha.2", "@turf/truncate": "^7.0.0-alpha.2", + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "npm-run-all": "^4.1.5", diff --git a/packages/turf-point-on-feature/test.js b/packages/turf-point-on-feature/test.ts similarity index 93% rename from packages/turf-point-on-feature/test.js rename to packages/turf-point-on-feature/test.ts index f38096034..f54ab546d 100644 --- a/packages/turf-point-on-feature/test.js +++ b/packages/turf-point-on-feature/test.ts @@ -3,10 +3,10 @@ import { glob } from "glob"; import path from "path"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; -import truncate from "@turf/truncate"; +import { truncate } from "@turf/truncate"; import { featureEach } from "@turf/meta"; import { featureCollection } from "@turf/helpers"; -import pointOnFeature from "./index"; +import { pointOnFeature } from "./index"; test("turf-point-on-feature", (t) => { glob diff --git a/packages/turf-point-to-line-distance/bench.js b/packages/turf-point-to-line-distance/bench.ts similarity index 92% rename from packages/turf-point-to-line-distance/bench.js rename to packages/turf-point-to-line-distance/bench.ts index 179c5a6b2..cc16fa1fe 100644 --- a/packages/turf-point-to-line-distance/bench.js +++ b/packages/turf-point-to-line-distance/bench.ts @@ -1,8 +1,8 @@ -const fs = require("fs"); -const path = require("path"); -const { loadJsonFileSync } = require("load-json-file"); -const Benchmark = require("benchmark"); -const pointToLineDistance = require("./index").default; +import fs from "fs"; +import path from "path"; +import { loadJsonFileSync } from "load-json-file"; +import Benchmark from "benchmark"; +import { pointToLineDistance } from "./index"; const directory = path.join(__dirname, "test", "in") + path.sep; const fixtures = fs.readdirSync(directory).map((filename) => { diff --git a/packages/turf-point-to-line-distance/index.ts b/packages/turf-point-to-line-distance/index.ts index 3bcb351ac..d84ddd09e 100644 --- a/packages/turf-point-to-line-distance/index.ts +++ b/packages/turf-point-to-line-distance/index.ts @@ -127,4 +127,5 @@ function calcDistance(a: number[], b: number[], options: any) { : getDistance(a, b, options); } +export { pointToLineDistance }; export default pointToLineDistance; diff --git a/packages/turf-point-to-line-distance/package.json b/packages/turf-point-to-line-distance/package.json index 241514545..664783499 100644 --- a/packages/turf-point-to-line-distance/package.json +++ b/packages/turf-point-to-line-distance/package.json @@ -40,17 +40,18 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js", + "test:tape": "tsx test.ts", "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" }, "devDependencies": { "@turf/circle": "^7.0.0-alpha.2", + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "load-json-file": "^7.0.1", diff --git a/packages/turf-point-to-line-distance/test.js b/packages/turf-point-to-line-distance/test.ts similarity index 88% rename from packages/turf-point-to-line-distance/test.js rename to packages/turf-point-to-line-distance/test.ts index 232f2ca24..7ac0baa61 100644 --- a/packages/turf-point-to-line-distance/test.js +++ b/packages/turf-point-to-line-distance/test.ts @@ -1,11 +1,11 @@ -const fs = require("fs"); -const test = require("tape"); -const path = require("path"); -const { loadJsonFileSync } = require("load-json-file"); -const { writeJsonFileSync } = require("write-json-file"); -const circle = require("@turf/circle").default; -const { point, lineString, round } = require("@turf/helpers"); -const pointToLineDistance = require("./index").default; +import fs from "fs"; +import test from "tape"; +import path from "path"; +import { loadJsonFileSync } from "load-json-file"; +import { writeJsonFileSync } from "write-json-file"; +import { circle } from "@turf/circle"; +import { point, lineString, round } from "@turf/helpers"; +import { pointToLineDistance } from "./index"; const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-points-within-polygon/bench.js b/packages/turf-points-within-polygon/bench.ts similarity index 94% rename from packages/turf-points-within-polygon/bench.js rename to packages/turf-points-within-polygon/bench.ts index 32b6e43b9..8b20e65b0 100644 --- a/packages/turf-points-within-polygon/bench.js +++ b/packages/turf-points-within-polygon/bench.ts @@ -1,6 +1,6 @@ import Benchmark from "benchmark"; import { featureCollection, point, polygon } from "@turf/helpers"; -import pointsWithinPolygon from "./index"; +import { pointsWithinPolygon } from "./index"; var poly1 = polygon([ [ diff --git a/packages/turf-points-within-polygon/index.ts b/packages/turf-points-within-polygon/index.ts index 8c79e5994..596bfc53f 100644 --- a/packages/turf-points-within-polygon/index.ts +++ b/packages/turf-points-within-polygon/index.ts @@ -90,4 +90,5 @@ function pointsWithinPolygon< return featureCollection(results); } +export { pointsWithinPolygon }; export default pointsWithinPolygon; diff --git a/packages/turf-points-within-polygon/package.json b/packages/turf-points-within-polygon/package.json index b3c02293f..afd75dfb6 100644 --- a/packages/turf-points-within-polygon/package.json +++ b/packages/turf-points-within-polygon/package.json @@ -39,16 +39,17 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js", + "test:tape": "tsx test.ts", "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" }, "devDependencies": { + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "npm-run-all": "^4.1.5", diff --git a/packages/turf-points-within-polygon/test.js b/packages/turf-points-within-polygon/test.ts similarity index 99% rename from packages/turf-points-within-polygon/test.js rename to packages/turf-points-within-polygon/test.ts index 8b866b413..95b48d6a2 100644 --- a/packages/turf-points-within-polygon/test.js +++ b/packages/turf-points-within-polygon/test.ts @@ -2,7 +2,7 @@ import test from "tape"; import { multiPoint, point, points } from "@turf/helpers"; import { polygon } from "@turf/helpers"; import { featureCollection } from "@turf/helpers"; -import pointsWithinPolygon from "./index"; +import { pointsWithinPolygon } from "./index"; test("turf-points-within-polygon -- point", (t) => { t.plan(4); diff --git a/packages/turf-polygon-smooth/bench.js b/packages/turf-polygon-smooth/bench.ts similarity index 95% rename from packages/turf-polygon-smooth/bench.js rename to packages/turf-polygon-smooth/bench.ts index ad1af2325..d52ad499a 100644 --- a/packages/turf-polygon-smooth/bench.js +++ b/packages/turf-polygon-smooth/bench.ts @@ -2,7 +2,7 @@ import fs from "fs"; import path from "path"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import polygonSmooth from "./index"; +import { polygonSmooth } from "./index"; const directory = path.join(__dirname, "test", "in") + path.sep; let fixtures = fs.readdirSync(directory).map((filename) => { diff --git a/packages/turf-polygon-smooth/index.ts b/packages/turf-polygon-smooth/index.ts index d27ddfcb5..9f8003e84 100644 --- a/packages/turf-polygon-smooth/index.ts +++ b/packages/turf-polygon-smooth/index.ts @@ -171,4 +171,5 @@ function processMultiPolygon(poly: MultiPolygon, tempOutput: Position[][][]) { }); } +export { polygonSmooth }; export default polygonSmooth; diff --git a/packages/turf-polygon-smooth/package.json b/packages/turf-polygon-smooth/package.json index 1ce571d9e..48fa27fec 100644 --- a/packages/turf-polygon-smooth/package.json +++ b/packages/turf-polygon-smooth/package.json @@ -40,16 +40,17 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js", + "test:tape": "tsx test.ts", "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" }, "devDependencies": { + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "glob": "^10.3.10", diff --git a/packages/turf-polygon-smooth/test.js b/packages/turf-polygon-smooth/test.ts similarity index 96% rename from packages/turf-polygon-smooth/test.js rename to packages/turf-polygon-smooth/test.ts index 980bfa23b..3a68a61fb 100644 --- a/packages/turf-polygon-smooth/test.js +++ b/packages/turf-polygon-smooth/test.ts @@ -4,7 +4,7 @@ import { loadJsonFileSync } from "load-json-file"; import path from "path"; import test from "tape"; import { writeJsonFileSync } from "write-json-file"; -import polygonSmooth from "./index"; +import { polygonSmooth } from "./index"; test("turf-polygon-smooth", (t) => { glob diff --git a/packages/turf-polygon-tangents/bench.js b/packages/turf-polygon-tangents/bench.ts similarity index 95% rename from packages/turf-polygon-tangents/bench.js rename to packages/turf-polygon-tangents/bench.ts index a0cc3e1e8..3485a9ca3 100644 --- a/packages/turf-polygon-tangents/bench.js +++ b/packages/turf-polygon-tangents/bench.ts @@ -2,7 +2,7 @@ import fs from "fs"; import path from "path"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import tangents from "./index"; +import { polygonTangents as tangents } from "./index"; const directory = path.join(__dirname, "test", "in") + path.sep; let fixtures = fs.readdirSync(directory).map((filename) => { diff --git a/packages/turf-polygon-tangents/index.ts b/packages/turf-polygon-tangents/index.ts index 62eb08aef..7c795976c 100644 --- a/packages/turf-polygon-tangents/index.ts +++ b/packages/turf-polygon-tangents/index.ts @@ -151,4 +151,5 @@ function isLeft(point1: Position, point2: Position, point3: Position) { ); } +export { polygonTangents }; export default polygonTangents; diff --git a/packages/turf-polygon-tangents/package.json b/packages/turf-polygon-tangents/package.json index 7fe5f049b..b81ce9c08 100644 --- a/packages/turf-polygon-tangents/package.json +++ b/packages/turf-polygon-tangents/package.json @@ -43,16 +43,17 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js", + "test:tape": "tsx test.ts", "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" }, "devDependencies": { + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "load-json-file": "^7.0.1", diff --git a/packages/turf-polygon-tangents/test.js b/packages/turf-polygon-tangents/test.ts similarity index 98% rename from packages/turf-polygon-tangents/test.js rename to packages/turf-polygon-tangents/test.ts index 231ade470..d350ce961 100644 --- a/packages/turf-polygon-tangents/test.js +++ b/packages/turf-polygon-tangents/test.ts @@ -4,7 +4,7 @@ import path from "path"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; import { polygon, point } from "@turf/helpers"; -import polygonTangents from "./index"; +import { polygonTangents } from "./index"; const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-polygon-to-line/bench.js b/packages/turf-polygon-to-line/bench.ts similarity index 81% rename from packages/turf-polygon-to-line/bench.js rename to packages/turf-polygon-to-line/bench.ts index 76c693d6c..2d18839db 100644 --- a/packages/turf-polygon-to-line/bench.js +++ b/packages/turf-polygon-to-line/bench.ts @@ -1,8 +1,8 @@ -const fs = require("fs"); -const path = require("path"); -const { loadJsonFileSync } = require("load-json-file"); -const Benchmark = require("benchmark"); -const polygonToLine = require("./index"); +import fs from "fs"; +import path from "path"; +import { loadJsonFileSync } from "load-json-file"; +import Benchmark from "benchmark"; +import { polygonToLine } from "./index"; const directory = path.join(__dirname, "test", "in") + path.sep; const fixtures = fs.readdirSync(directory).map((filename) => { diff --git a/packages/turf-polygon-to-line/index.ts b/packages/turf-polygon-to-line/index.ts index d47d69c18..38bd65ba3 100644 --- a/packages/turf-polygon-to-line/index.ts +++ b/packages/turf-polygon-to-line/index.ts @@ -27,7 +27,7 @@ import { getGeom } from "@turf/invariant"; * //addToMap * var addToMap = [line]; */ -export default function < +function polygonToLine< G extends Polygon | MultiPolygon, P extends GeoJsonProperties = GeoJsonProperties, >( @@ -42,7 +42,7 @@ export default function < } switch (geom.type) { case "Polygon": - return polygonToLine(geom, options); + return singlePolygonToLine(geom, options); case "MultiPolygon": return multiPolygonToLine(geom, options); default: @@ -53,7 +53,7 @@ export default function < /** * @private */ -export function polygonToLine< +function singlePolygonToLine< G extends Polygon, P extends GeoJsonProperties = GeoJsonProperties, >( @@ -74,7 +74,7 @@ export function polygonToLine< /** * @private */ -export function multiPolygonToLine< +function multiPolygonToLine< G extends MultiPolygon, P extends GeoJsonProperties = GeoJsonProperties, >( @@ -99,7 +99,7 @@ export function multiPolygonToLine< /** * @private */ -export function coordsToLine

( +function coordsToLine

( coords: number[][][], properties: P ): Feature { @@ -108,3 +108,6 @@ export function coordsToLine

( } return lineString(coords[0], properties); } + +export { polygonToLine, coordsToLine, multiPolygonToLine, singlePolygonToLine }; +export default polygonToLine; diff --git a/packages/turf-polygon-to-line/package.json b/packages/turf-polygon-to-line/package.json index 88f6462ac..3f0850c71 100644 --- a/packages/turf-polygon-to-line/package.json +++ b/packages/turf-polygon-to-line/package.json @@ -39,15 +39,16 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js" + "test:tape": "tsx test.ts" }, "devDependencies": { + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "load-json-file": "^7.0.1", diff --git a/packages/turf-polygon-to-line/test.js b/packages/turf-polygon-to-line/test.ts similarity index 71% rename from packages/turf-polygon-to-line/test.js rename to packages/turf-polygon-to-line/test.ts index a7dbfaffc..360ea326f 100644 --- a/packages/turf-polygon-to-line/test.js +++ b/packages/turf-polygon-to-line/test.ts @@ -1,11 +1,11 @@ -const fs = require("fs"); -const test = require("tape"); -const path = require("path"); -const { loadJsonFileSync } = require("load-json-file"); -const { writeJsonFileSync } = require("write-json-file"); -const { point } = require("@turf/helpers"); -const { polygon } = require("@turf/helpers"); -const polygonToLine = require("./index").default; +import fs from "fs"; +import test from "tape"; +import path from "path"; +import { loadJsonFileSync } from "load-json-file"; +import { writeJsonFileSync } from "write-json-file"; +import { point } from "@turf/helpers"; +import { polygon } from "@turf/helpers"; +import { polygonToLine } from "./index"; const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-polygonize/bench.js b/packages/turf-polygonize/bench.ts similarity index 82% rename from packages/turf-polygonize/bench.js rename to packages/turf-polygonize/bench.ts index 9cf4958ee..059b4e038 100644 --- a/packages/turf-polygonize/bench.js +++ b/packages/turf-polygonize/bench.ts @@ -1,8 +1,8 @@ -const fs = require("fs"); -const path = require("path"); -const { loadJsonFileSync } = require("load-json-file"); -const Benchmark = require("benchmark"); -const polygonize = require("./index").default; +import fs from "fs"; +import path from "path"; +import { loadJsonFileSync } from "load-json-file"; +import Benchmark from "benchmark"; +import { polygonize } from "./index"; const directory = path.join(__dirname, "test", "in") + path.sep; const fixtures = fs.readdirSync(directory).map((filename) => { diff --git a/packages/turf-polygonize/index.ts b/packages/turf-polygonize/index.ts index 17b27e2e9..e1f20c240 100644 --- a/packages/turf-polygonize/index.ts +++ b/packages/turf-polygonize/index.ts @@ -27,7 +27,7 @@ import EdgeRing from "./lib/EdgeRing"; * @returns {FeatureCollection} Polygons created * @throws {Error} if geoJson is invalid. */ -export default function polygonize( +function polygonize( geoJson: Feature | FeatureCollection | T ): FeatureCollection { const graph = Graph.fromGeoJson(geoJson); @@ -58,3 +58,6 @@ export default function polygonize( // 5. EdgeRings to Polygons return featureCollection(shells.map((shell) => shell.toPolygon())); } + +export { polygonize }; +export default polygonize; diff --git a/packages/turf-polygonize/package.json b/packages/turf-polygonize/package.json index 43b12886a..eeaadbea3 100644 --- a/packages/turf-polygonize/package.json +++ b/packages/turf-polygonize/package.json @@ -42,16 +42,17 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js", + "test:tape": "tsx test.ts", "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" }, "devDependencies": { + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "load-json-file": "^7.0.1", diff --git a/packages/turf-polygonize/test.js b/packages/turf-polygonize/test.ts similarity index 83% rename from packages/turf-polygonize/test.js rename to packages/turf-polygonize/test.ts index 156b1a32a..14ee09741 100644 --- a/packages/turf-polygonize/test.js +++ b/packages/turf-polygonize/test.ts @@ -1,11 +1,11 @@ -const fs = require("fs"); -const test = require("tape"); -const path = require("path"); -const { loadJsonFileSync } = require("load-json-file"); -const { writeJsonFileSync } = require("write-json-file"); -const { featureEach } = require("@turf/meta"); -const { featureCollection, lineString } = require("@turf/helpers"); -const polygonize = require("./index").default; +import fs from "fs"; +import test from "tape"; +import path from "path"; +import { loadJsonFileSync } from "load-json-file"; +import { writeJsonFileSync } from "write-json-file"; +import { featureEach } from "@turf/meta"; +import { featureCollection, lineString } from "@turf/helpers"; +import { polygonize } from "./index"; const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-projection/bench.js b/packages/turf-projection/bench.ts similarity index 91% rename from packages/turf-projection/bench.js rename to packages/turf-projection/bench.ts index dc966cbf6..655355a95 100644 --- a/packages/turf-projection/bench.js +++ b/packages/turf-projection/bench.ts @@ -1,8 +1,8 @@ -const path = require("path"); -const { glob } = require("glob"); -const { loadJsonFileSync } = require("load-json-file"); -const Benchmark = require("benchmark"); -const { toMercator, toWgs84 } = require("./index"); +import path from "path"; +import { glob } from "glob"; +import { loadJsonFileSync } from "load-json-file"; +import Benchmark from "benchmark"; +import { toMercator, toWgs84 } from "./index"; const suite = new Benchmark.Suite("turf-projection"); diff --git a/packages/turf-projection/index.ts b/packages/turf-projection/index.ts index e79a9f1f6..c9f9c44ce 100644 --- a/packages/turf-projection/index.ts +++ b/packages/turf-projection/index.ts @@ -18,7 +18,7 @@ import clone from "@turf/clone"; * //addToMap * var addToMap = [pt, converted]; */ -export function toMercator( +function toMercator( geojson: G, options: { mutate?: boolean } = {} ): G { @@ -40,7 +40,7 @@ export function toMercator( * //addToMap * var addToMap = [pt, converted]; */ -export function toWgs84( +function toWgs84( geojson: G, options: { mutate?: boolean } = {} ): G { @@ -153,3 +153,5 @@ function convertToWgs84(xy: number[]) { function sign(x: number) { return x < 0 ? -1 : x > 0 ? 1 : 0; } + +export { toMercator, toWgs84 }; diff --git a/packages/turf-projection/package.json b/packages/turf-projection/package.json index 477061634..fc3729ae2 100644 --- a/packages/turf-projection/package.json +++ b/packages/turf-projection/package.json @@ -50,17 +50,18 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js", + "test:tape": "tsx test.ts", "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" }, "devDependencies": { "@turf/truncate": "^7.0.0-alpha.2", + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "load-json-file": "^7.0.1", diff --git a/packages/turf-projection/test.js b/packages/turf-projection/test.ts similarity index 87% rename from packages/turf-projection/test.js rename to packages/turf-projection/test.ts index f22d0336f..5ab69bf82 100644 --- a/packages/turf-projection/test.js +++ b/packages/turf-projection/test.ts @@ -1,14 +1,14 @@ -const fs = require("fs"); -const test = require("tape"); -const path = require("path"); -const { loadJsonFileSync } = require("load-json-file"); -const proj4 = require("proj4"); -const { writeJsonFileSync } = require("write-json-file"); -const clone = require("@turf/clone").default; -const { point } = require("@turf/helpers"); -const truncate = require("@turf/truncate").default; -const { coordEach } = require("@turf/meta"); -const { toMercator, toWgs84 } = require("./index"); +import fs from "fs"; +import test from "tape"; +import path from "path"; +import { loadJsonFileSync } from "load-json-file"; +import proj4 from "proj4"; +import { writeJsonFileSync } from "write-json-file"; +import { clone } from "@turf/clone"; +import { point } from "@turf/helpers"; +import { truncate } from "@turf/truncate"; +import { coordEach } from "@turf/meta"; +import { toMercator, toWgs84 } from "./index"; const directories = { mercator: path.join(__dirname, "test", "mercator") + path.sep, diff --git a/packages/turf-quadrat-analysis/bench.js b/packages/turf-quadrat-analysis/bench.ts similarity index 78% rename from packages/turf-quadrat-analysis/bench.js rename to packages/turf-quadrat-analysis/bench.ts index 03ea91b8c..867d0ed7b 100644 --- a/packages/turf-quadrat-analysis/bench.js +++ b/packages/turf-quadrat-analysis/bench.ts @@ -1,8 +1,7 @@ -const Benchmark = require("benchmark"); -const { randomPoint } = require("@turf/random"); -const nearestNeighborAnalysis = - require("@turf/nearest-neighbor-analysis").default; -const quadratAnalysis = require("./index").default; +import Benchmark from "benchmark"; +import { randomPoint } from "@turf/random"; +import { nearestNeighborAnalysis } from "@turf/nearest-neighbor-analysis"; +import { quadratAnalysis } from "./index"; /** * Benchmark Results diff --git a/packages/turf-quadrat-analysis/index.ts b/packages/turf-quadrat-analysis/index.ts index 6eefcbe10..73cea7150 100644 --- a/packages/turf-quadrat-analysis/index.ts +++ b/packages/turf-quadrat-analysis/index.ts @@ -5,7 +5,7 @@ import bboxPolygon from "@turf/bbox-polygon"; import { getCoord } from "@turf/invariant"; import squareGrid from "@turf/square-grid"; -export interface QuadratAnalysisResult { +interface QuadratAnalysisResult { criticalValue: number; maxAbsoluteDifference: number; isRandom: boolean; @@ -53,7 +53,7 @@ export interface QuadratAnalysisResult { * var result = turf.quadratAnalysis(dataset); * */ -export default function quadratAnalysis( +function quadratAnalysis( pointFeatureSet: FeatureCollection, options: { studyBbox?: [number, number, number, number]; @@ -220,3 +220,6 @@ function factorial(num: number) { } return inner(num); } + +export { QuadratAnalysisResult, quadratAnalysis }; +export default quadratAnalysis; diff --git a/packages/turf-quadrat-analysis/package.json b/packages/turf-quadrat-analysis/package.json index 79eb835fd..43a191a56 100644 --- a/packages/turf-quadrat-analysis/package.json +++ b/packages/turf-quadrat-analysis/package.json @@ -39,16 +39,17 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js" + "test:tape": "tsx test.ts" }, "devDependencies": { "@turf/nearest-neighbor-analysis": "^7.0.0-alpha.2", + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "load-json-file": "^7.0.1", diff --git a/packages/turf-quadrat-analysis/test.js b/packages/turf-quadrat-analysis/test.ts similarity index 88% rename from packages/turf-quadrat-analysis/test.js rename to packages/turf-quadrat-analysis/test.ts index 6f3191ada..b71356afe 100644 --- a/packages/turf-quadrat-analysis/test.js +++ b/packages/turf-quadrat-analysis/test.ts @@ -1,15 +1,15 @@ -const test = require("tape"); -const path = require("path"); -const { loadJsonFileSync } = require("load-json-file"); -const { writeJsonFileSync } = require("write-json-file"); -const bbox = require("@turf/bbox").default; -const centroid = require("@turf/centroid").default; -const squareGrid = require("@turf/square-grid").default; -const bboxPolygon = require("@turf/bbox-polygon").default; -const { randomPoint } = require("@turf/random"); -const { featureCollection } = require("@turf/helpers"); -const quadratAnalysis = require("./index").default; -const fs = require("fs"); +import test from "tape"; +import path from "path"; +import { loadJsonFileSync } from "load-json-file"; +import { writeJsonFileSync } from "write-json-file"; +import { bbox } from "@turf/bbox"; +import { centroid } from "@turf/centroid"; +import { squareGrid } from "@turf/square-grid"; +import { bboxPolygon } from "@turf/bbox-polygon"; +import { randomPoint } from "@turf/random"; +import { featureCollection } from "@turf/helpers"; +import { quadratAnalysis } from "./index"; +import fs from "fs"; test("turf-quadrat-analysis geojson file", (t) => { const futianBboxPath = path.join(__dirname, "test", "in", "futian_bbox.json"); diff --git a/packages/turf-random/bench.js b/packages/turf-random/bench.ts similarity index 51% rename from packages/turf-random/bench.js rename to packages/turf-random/bench.ts index cbe39f0dd..ffd0844b0 100644 --- a/packages/turf-random/bench.js +++ b/packages/turf-random/bench.ts @@ -1,5 +1,8 @@ -const random = require("./index"); -const Benchmark = require("benchmark"); +// I don't think this bench test does anything? There is no entry point into +// the module called random() that takes a string? + +import random from "./index"; +import Benchmark from "benchmark"; var suite = new Benchmark.Suite("turf-random"); suite diff --git a/packages/turf-random/index.ts b/packages/turf-random/index.ts index 49f1776f1..47aa64db0 100644 --- a/packages/turf-random/index.ts +++ b/packages/turf-random/index.ts @@ -27,7 +27,7 @@ import { * var position = turf.randomPosition([-180, -90, 180, 90]) * // => position */ -export function randomPosition(bbox?: BBox | { bbox: BBox }): Position { +function randomPosition(bbox?: BBox | { bbox: BBox }): Position { checkBBox(bbox); return randomPositionUnchecked(bbox); } @@ -66,7 +66,7 @@ function checkBBox(bbox?: BBox | { bbox: BBox }) { * var points = turf.randomPoint(25, {bbox: [-180, -90, 180, 90]}) * // => points */ -export function randomPoint( +function randomPoint( count?: number, options: { bbox?: BBox; @@ -99,7 +99,7 @@ export function randomPoint( * var polygons = turf.randomPolygon(25, {bbox: [-180, -90, 180, 90]}) * // => polygons */ -export function randomPolygon( +function randomPolygon( count?: number, options: { bbox?: BBox; @@ -170,7 +170,7 @@ export function randomPolygon( * var lineStrings = turf.randomLineString(25, {bbox: [-180, -90, 180, 90]}) * // => lineStrings */ -export function randomLineString( +function randomLineString( count?: number, options: { bbox?: BBox; @@ -255,3 +255,5 @@ function coordInBBox(bbox: BBox) { Math.random() * (bbox[3] - bbox[1]) + bbox[1], ]; } + +export { randomPosition, randomPoint, randomPolygon, randomLineString }; diff --git a/packages/turf-random/package.json b/packages/turf-random/package.json index 4bf952397..58d08287e 100644 --- a/packages/turf-random/package.json +++ b/packages/turf-random/package.json @@ -36,15 +36,16 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js" + "test:tape": "tsx test.ts" }, "devDependencies": { + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "glob": "^10.3.10", diff --git a/packages/turf-random/test.js b/packages/turf-random/test.ts similarity index 97% rename from packages/turf-random/test.js rename to packages/turf-random/test.ts index b26ab74b7..a6f619581 100644 --- a/packages/turf-random/test.js +++ b/packages/turf-random/test.ts @@ -1,10 +1,10 @@ -const test = require("tape"); -const { +import test from "tape"; +import { randomPoint, randomPolygon, randomLineString, randomPosition, -} = require("./index"); +} from "./index"; test("random(points)", (t) => { var points = randomPoint(); diff --git a/packages/turf-rectangle-grid/bench.js b/packages/turf-rectangle-grid/bench.ts similarity index 90% rename from packages/turf-rectangle-grid/bench.js rename to packages/turf-rectangle-grid/bench.ts index 486506ccb..8562eae70 100644 --- a/packages/turf-rectangle-grid/bench.js +++ b/packages/turf-rectangle-grid/bench.ts @@ -1,5 +1,5 @@ -const Benchmark = require("benchmark"); -const rectangleGrid = require("./index").default; +import Benchmark from "benchmark"; +import { rectangleGrid } from "./index"; var bbox = [-95, 30, -85, 40]; diff --git a/packages/turf-rectangle-grid/index.ts b/packages/turf-rectangle-grid/index.ts index 196ff1fe6..68492330a 100644 --- a/packages/turf-rectangle-grid/index.ts +++ b/packages/turf-rectangle-grid/index.ts @@ -1,4 +1,4 @@ -import intersect from "@turf/boolean-intersects"; +import { booleanIntersects as intersect } from "@turf/boolean-intersects"; import { BBox, Feature, @@ -100,4 +100,5 @@ function rectangleGrid

( return featureCollection(results); } +export { rectangleGrid }; export default rectangleGrid; diff --git a/packages/turf-rectangle-grid/package.json b/packages/turf-rectangle-grid/package.json index 8260f7665..9a65cd533 100644 --- a/packages/turf-rectangle-grid/package.json +++ b/packages/turf-rectangle-grid/package.json @@ -42,17 +42,18 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js" + "test:tape": "tsx test.ts" }, "devDependencies": { "@turf/bbox-polygon": "^7.0.0-alpha.2", "@turf/truncate": "^7.0.0-alpha.2", + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "load-json-file": "^7.0.1", diff --git a/packages/turf-rectangle-grid/test.js b/packages/turf-rectangle-grid/test.ts similarity index 78% rename from packages/turf-rectangle-grid/test.js rename to packages/turf-rectangle-grid/test.ts index fa1fc39f6..48a2ec0e4 100644 --- a/packages/turf-rectangle-grid/test.js +++ b/packages/turf-rectangle-grid/test.ts @@ -1,11 +1,11 @@ -const fs = require("fs"); -const test = require("tape"); -const path = require("path"); -const { loadJsonFileSync } = require("load-json-file"); -const { writeJsonFileSync } = require("write-json-file"); -const bboxPoly = require("@turf/bbox-polygon").default; -const truncate = require("@turf/truncate").default; -const rectangleGrid = require("./index").default; +import fs from "fs"; +import test from "tape"; +import path from "path"; +import { loadJsonFileSync } from "load-json-file"; +import { writeJsonFileSync } from "write-json-file"; +import { bboxPolygon as bboxPoly } from "@turf/bbox-polygon"; +import { truncate } from "@turf/truncate"; +import { rectangleGrid } from "./index"; const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-rewind/bench.js b/packages/turf-rewind/bench.ts similarity index 97% rename from packages/turf-rewind/bench.js rename to packages/turf-rewind/bench.ts index ac8edaafb..5e6107bc3 100644 --- a/packages/turf-rewind/bench.js +++ b/packages/turf-rewind/bench.ts @@ -2,7 +2,7 @@ import fs from "fs"; import path from "path"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import rewind from "./index"; +import { rewind } from "./index"; const directory = path.join(__dirname, "test", "in") + path.sep; let fixtures = fs.readdirSync(directory).map((filename) => { diff --git a/packages/turf-rewind/index.ts b/packages/turf-rewind/index.ts index 585a95ffb..c8eca8d97 100644 --- a/packages/turf-rewind/index.ts +++ b/packages/turf-rewind/index.ts @@ -157,4 +157,5 @@ function rewindPolygon(coords: Position[][], reverse: boolean) { } } +export { rewind }; export default rewind; diff --git a/packages/turf-rewind/package.json b/packages/turf-rewind/package.json index bfe7be52a..9e911a78b 100644 --- a/packages/turf-rewind/package.json +++ b/packages/turf-rewind/package.json @@ -44,16 +44,17 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js", + "test:tape": "tsx test.ts", "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" }, "devDependencies": { + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "load-json-file": "^7.0.1", diff --git a/packages/turf-rewind/test.js b/packages/turf-rewind/test.ts similarity index 98% rename from packages/turf-rewind/test.js rename to packages/turf-rewind/test.ts index 7e1fc5947..267644e7f 100644 --- a/packages/turf-rewind/test.js +++ b/packages/turf-rewind/test.ts @@ -9,7 +9,7 @@ import { featureCollection, geometryCollection, } from "@turf/helpers"; -import rewind from "./index"; +import { rewind } from "./index"; const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-rhumb-bearing/bench.js b/packages/turf-rhumb-bearing/bench.ts similarity index 78% rename from packages/turf-rhumb-bearing/bench.js rename to packages/turf-rhumb-bearing/bench.ts index 1b1788af5..a0fba6ea7 100644 --- a/packages/turf-rhumb-bearing/bench.js +++ b/packages/turf-rhumb-bearing/bench.ts @@ -1,6 +1,6 @@ -const { point } = require("@turf/helpers"); -const Benchmark = require("benchmark"); -const rhumbBearing = require("./index").default; +import { point } from "@turf/helpers"; +import Benchmark from "benchmark"; +import { rhumbBearing } from "./index"; var start = point([-75.4, 39.4]); var end = point([-75.534, 39.123]); diff --git a/packages/turf-rhumb-bearing/index.ts b/packages/turf-rhumb-bearing/index.ts index ff14b2c66..16372c398 100644 --- a/packages/turf-rhumb-bearing/index.ts +++ b/packages/turf-rhumb-bearing/index.ts @@ -78,4 +78,5 @@ function calculateRhumbBearing(from: number[], to: number[]) { return (radiansToDegrees(theta) + 360) % 360; } +export { rhumbBearing }; export default rhumbBearing; diff --git a/packages/turf-rhumb-bearing/package.json b/packages/turf-rhumb-bearing/package.json index 941189ebf..0a0cdef5e 100644 --- a/packages/turf-rhumb-bearing/package.json +++ b/packages/turf-rhumb-bearing/package.json @@ -44,16 +44,17 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js" + "test:tape": "tsx test.ts" }, "devDependencies": { "@turf/destination": "^7.0.0-alpha.2", + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "npm-run-all": "^4.1.5", diff --git a/packages/turf-rhumb-bearing/test.js b/packages/turf-rhumb-bearing/test.ts similarity index 78% rename from packages/turf-rhumb-bearing/test.js rename to packages/turf-rhumb-bearing/test.ts index 12348a43c..3648110d8 100644 --- a/packages/turf-rhumb-bearing/test.js +++ b/packages/turf-rhumb-bearing/test.ts @@ -1,10 +1,10 @@ -const fs = require("fs"); -const path = require("path"); -const test = require("tape"); -const { loadJsonFileSync } = require("load-json-file"); -const { writeJsonFileSync } = require("write-json-file"); -const { point } = require("@turf/helpers"); -const rhumbBearing = require("./index").default; +import fs from "fs"; +import path from "path"; +import test from "tape"; +import { loadJsonFileSync } from "load-json-file"; +import { writeJsonFileSync } from "write-json-file"; +import { point } from "@turf/helpers"; +import { rhumbBearing } from "./index"; const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-rhumb-destination/bench.js b/packages/turf-rhumb-destination/bench.ts similarity index 75% rename from packages/turf-rhumb-destination/bench.js rename to packages/turf-rhumb-destination/bench.ts index ba0c67d48..6940e6327 100644 --- a/packages/turf-rhumb-destination/bench.js +++ b/packages/turf-rhumb-destination/bench.ts @@ -1,6 +1,6 @@ -const { point } = require("@turf/helpers"); -const Benchmark = require("benchmark"); -const destination = require("./index").default; +import { point } from "@turf/helpers"; +import Benchmark from "benchmark"; +import { rhumbDestination as destination } from "./index"; const pt1 = point([-75.0, 39.0]); const distance = 100; diff --git a/packages/turf-rhumb-destination/index.ts b/packages/turf-rhumb-destination/index.ts index 9055b3937..6abaa9364 100644 --- a/packages/turf-rhumb-destination/index.ts +++ b/packages/turf-rhumb-destination/index.ts @@ -123,4 +123,5 @@ function calculateRhumbDestination( ]; // normalise to −180..+180° } +export { rhumbDestination }; export default rhumbDestination; diff --git a/packages/turf-rhumb-destination/package.json b/packages/turf-rhumb-destination/package.json index e64a3c5af..26cd665b1 100644 --- a/packages/turf-rhumb-destination/package.json +++ b/packages/turf-rhumb-destination/package.json @@ -48,16 +48,17 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js" + "test:tape": "tsx test.ts" }, "devDependencies": { "@turf/truncate": "^7.0.0-alpha.2", + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "load-json-file": "^7.0.1", diff --git a/packages/turf-rhumb-destination/test.js b/packages/turf-rhumb-destination/test.ts similarity index 84% rename from packages/turf-rhumb-destination/test.js rename to packages/turf-rhumb-destination/test.ts index b552d9ca3..15872c50b 100644 --- a/packages/turf-rhumb-destination/test.js +++ b/packages/turf-rhumb-destination/test.ts @@ -1,12 +1,12 @@ -const fs = require("fs"); -const path = require("path"); -const test = require("tape"); -const { writeJsonFileSync } = require("write-json-file"); -const { loadJsonFileSync } = require("load-json-file"); -const truncate = require("@turf/truncate").default; -const { getCoords } = require("@turf/invariant"); -const { featureCollection, lineString, point } = require("@turf/helpers"); -const rhumbDestination = require("./index").default; +import fs from "fs"; +import path from "path"; +import test from "tape"; +import { writeJsonFileSync } from "write-json-file"; +import { loadJsonFileSync } from "load-json-file"; +import { truncate } from "@turf/truncate"; +import { getCoords } from "@turf/invariant"; +import { featureCollection, lineString, point } from "@turf/helpers"; +import { rhumbDestination } from "./index"; const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-rhumb-distance/bench.js b/packages/turf-rhumb-distance/bench.ts similarity index 73% rename from packages/turf-rhumb-distance/bench.js rename to packages/turf-rhumb-distance/bench.ts index 00eca5d51..e1116bc45 100644 --- a/packages/turf-rhumb-distance/bench.js +++ b/packages/turf-rhumb-distance/bench.ts @@ -1,6 +1,6 @@ -const { point } = require("@turf/helpers"); -const Benchmark = require("benchmark"); -const distance = require("./index").default; +import { point } from "@turf/helpers"; +import Benchmark from "benchmark"; +import { rhumbDistance as distance } from "./index"; const pt1 = point([-75.4, 39.4]); const pt2 = point([-75.534, 39.123]); diff --git a/packages/turf-rhumb-distance/index.ts b/packages/turf-rhumb-distance/index.ts index 622422d09..c681b9781 100644 --- a/packages/turf-rhumb-distance/index.ts +++ b/packages/turf-rhumb-distance/index.ts @@ -103,4 +103,5 @@ function calculateRhumbDistance( return dist; } +export { rhumbDistance }; export default rhumbDistance; diff --git a/packages/turf-rhumb-distance/package.json b/packages/turf-rhumb-distance/package.json index b2a907872..8a67967f3 100644 --- a/packages/turf-rhumb-distance/package.json +++ b/packages/turf-rhumb-distance/package.json @@ -46,16 +46,17 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js" + "test:tape": "tsx test.ts" }, "devDependencies": { "@turf/distance": "^7.0.0-alpha.2", + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "load-json-file": "^7.0.1", diff --git a/packages/turf-rhumb-distance/test.js b/packages/turf-rhumb-distance/test.ts similarity index 83% rename from packages/turf-rhumb-distance/test.js rename to packages/turf-rhumb-distance/test.ts index 90d2596c3..2c7f5dbe7 100644 --- a/packages/turf-rhumb-distance/test.js +++ b/packages/turf-rhumb-distance/test.ts @@ -1,11 +1,11 @@ -const fs = require("fs"); -const path = require("path"); -const test = require("tape"); -const { loadJsonFileSync } = require("load-json-file"); -const { writeJsonFileSync } = require("write-json-file"); -const distance = require("@turf/distance").default; -const { point, round } = require("@turf/helpers"); -const rhumbDistance = require("./index").default; +import fs from "fs"; +import path from "path"; +import test from "tape"; +import { loadJsonFileSync } from "load-json-file"; +import { writeJsonFileSync } from "write-json-file"; +import { distance } from "@turf/distance"; +import { point, round } from "@turf/helpers"; +import { rhumbDistance } from "./index"; const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-sample/bench.js b/packages/turf-sample/bench.ts similarity index 94% rename from packages/turf-sample/bench.js rename to packages/turf-sample/bench.ts index 23d08e26c..ee06de1fd 100644 --- a/packages/turf-sample/bench.js +++ b/packages/turf-sample/bench.ts @@ -1,6 +1,6 @@ import Benchmark from "benchmark"; import { point, featureCollection } from "@turf/helpers"; -import sample from "./index"; +import { sample } from "./index"; var points = featureCollection([ point(1, 2, { team: "Red Sox" }), diff --git a/packages/turf-sample/index.ts b/packages/turf-sample/index.ts index 05e7be0c8..c3b7284ea 100644 --- a/packages/turf-sample/index.ts +++ b/packages/turf-sample/index.ts @@ -50,4 +50,5 @@ function getRandomSubarray( return shuffled.slice(min); } +export { sample }; export default sample; diff --git a/packages/turf-sample/package.json b/packages/turf-sample/package.json index bc004b15f..3b2410d06 100644 --- a/packages/turf-sample/package.json +++ b/packages/turf-sample/package.json @@ -38,15 +38,16 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js" + "test:tape": "tsx test.ts" }, "devDependencies": { + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "npm-run-all": "^4.1.5", diff --git a/packages/turf-sample/test.js b/packages/turf-sample/test.ts similarity index 94% rename from packages/turf-sample/test.js rename to packages/turf-sample/test.ts index 9a6c2d38b..0cab3584a 100644 --- a/packages/turf-sample/test.js +++ b/packages/turf-sample/test.ts @@ -1,7 +1,7 @@ import test from "tape"; import { point } from "@turf/helpers"; import { featureCollection } from "@turf/helpers"; -import sample from "./index"; +import { sample } from "./index"; test("remove", function (t) { var points = featureCollection([ diff --git a/packages/turf-sector/bench.js b/packages/turf-sector/bench.ts similarity index 97% rename from packages/turf-sector/bench.js rename to packages/turf-sector/bench.ts index 6000a80e7..b2d61ae89 100644 --- a/packages/turf-sector/bench.js +++ b/packages/turf-sector/bench.ts @@ -2,7 +2,7 @@ import fs from "fs"; import path from "path"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import sector from "./index"; +import { sector } from "./index"; const directory = path.join(__dirname, "test", "in") + path.sep; const fixtures = fs.readdirSync(directory).map((filename) => { diff --git a/packages/turf-sector/index.ts b/packages/turf-sector/index.ts index 817f0685e..0d87842c9 100644 --- a/packages/turf-sector/index.ts +++ b/packages/turf-sector/index.ts @@ -86,4 +86,5 @@ function convertAngleTo360(alpha: number) { return beta; } +export { sector }; export default sector; diff --git a/packages/turf-sector/package.json b/packages/turf-sector/package.json index 08c4dc380..f53b973ea 100644 --- a/packages/turf-sector/package.json +++ b/packages/turf-sector/package.json @@ -36,17 +36,18 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js", + "test:tape": "tsx test.ts", "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" }, "devDependencies": { "@turf/truncate": "^7.0.0-alpha.2", + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "load-json-file": "^7.0.1", diff --git a/packages/turf-sector/test.js b/packages/turf-sector/test.ts similarity index 97% rename from packages/turf-sector/test.js rename to packages/turf-sector/test.ts index 266aebb38..e739f4d72 100644 --- a/packages/turf-sector/test.js +++ b/packages/turf-sector/test.ts @@ -5,7 +5,7 @@ import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; import truncate from "@turf/truncate"; import { featureCollection } from "@turf/helpers"; -import sector from "./index"; +import { sector } from "./index"; const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-shortest-path/bench.js b/packages/turf-shortest-path/bench.ts similarity index 96% rename from packages/turf-shortest-path/bench.js rename to packages/turf-shortest-path/bench.ts index 10b2f2f00..841d2d874 100644 --- a/packages/turf-shortest-path/bench.js +++ b/packages/turf-shortest-path/bench.ts @@ -2,7 +2,7 @@ import fs from "fs"; import path from "path"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import shortestPath from "./index"; +import { shortestPath } from "./index"; const directory = path.join(__dirname, "test", "in") + path.sep; const fixtures = fs.readdirSync(directory).map((filename) => { diff --git a/packages/turf-shortest-path/index.ts b/packages/turf-shortest-path/index.ts index 65ba0887d..8cd94be5d 100644 --- a/packages/turf-shortest-path/index.ts +++ b/packages/turf-shortest-path/index.ts @@ -206,4 +206,5 @@ function isInside(pt: Feature, polygons: FeatureCollection) { return false; } +export { shortestPath }; export default shortestPath; diff --git a/packages/turf-shortest-path/package.json b/packages/turf-shortest-path/package.json index 04d1719a8..48c8bc20e 100644 --- a/packages/turf-shortest-path/package.json +++ b/packages/turf-shortest-path/package.json @@ -41,17 +41,18 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js", + "test:tape": "tsx test.ts", "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" }, "devDependencies": { "@turf/truncate": "^7.0.0-alpha.2", + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "load-json-file": "^7.0.1", diff --git a/packages/turf-shortest-path/test.js b/packages/turf-shortest-path/test.ts similarity index 95% rename from packages/turf-shortest-path/test.js rename to packages/turf-shortest-path/test.ts index b61d6779a..d40ceb175 100644 --- a/packages/turf-shortest-path/test.js +++ b/packages/turf-shortest-path/test.ts @@ -3,11 +3,11 @@ import test from "tape"; import path from "path"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; -import truncate from "@turf/truncate"; +import { truncate } from "@turf/truncate"; import { featureCollection, point } from "@turf/helpers"; import { getCoord } from "@turf/invariant"; import { featureEach } from "@turf/meta"; -import shortestPath from "./index"; +import { shortestPath } from "./index"; const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-simplify/bench.js b/packages/turf-simplify/bench.ts similarity index 98% rename from packages/turf-simplify/bench.js rename to packages/turf-simplify/bench.ts index aef4ec63b..d03935d96 100644 --- a/packages/turf-simplify/bench.js +++ b/packages/turf-simplify/bench.ts @@ -2,7 +2,7 @@ import fs from "fs"; import path from "path"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import simplify from "./index"; +import { simplify } from "./index"; const directory = path.join(__dirname, "test", "in") + path.sep; const fixtures = fs.readdirSync(directory).map((filename) => { diff --git a/packages/turf-simplify/index.ts b/packages/turf-simplify/index.ts index 56a099ce9..2865ff382 100644 --- a/packages/turf-simplify/index.ts +++ b/packages/turf-simplify/index.ts @@ -218,4 +218,5 @@ function checkValidity(ring: Position[]) { ); } +export { simplify }; export default simplify; diff --git a/packages/turf-simplify/package.json b/packages/turf-simplify/package.json index 8ae54c827..172910e92 100644 --- a/packages/turf-simplify/package.json +++ b/packages/turf-simplify/package.json @@ -44,17 +44,18 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js", + "test:tape": "tsx test.ts", "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" }, "devDependencies": { "@turf/truncate": "^7.0.0-alpha.2", + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "load-json-file": "^7.0.1", diff --git a/packages/turf-simplify/test.js b/packages/turf-simplify/test.ts similarity index 98% rename from packages/turf-simplify/test.js rename to packages/turf-simplify/test.ts index 81c97b71f..762c89cd7 100644 --- a/packages/turf-simplify/test.js +++ b/packages/turf-simplify/test.ts @@ -3,9 +3,9 @@ import test from "tape"; import path from "path"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; -import truncate from "@turf/truncate"; +import { truncate } from "@turf/truncate"; import { polygon, multiPolygon } from "@turf/helpers"; -import simplify from "./index"; +import { simplify } from "./index"; const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-square-grid/bench.js b/packages/turf-square-grid/bench.ts similarity index 91% rename from packages/turf-square-grid/bench.js rename to packages/turf-square-grid/bench.ts index bc2b35124..306fadd97 100644 --- a/packages/turf-square-grid/bench.js +++ b/packages/turf-square-grid/bench.ts @@ -1,5 +1,5 @@ -const Benchmark = require("benchmark"); -const squareGrid = require("./index").default; +import Benchmark from "benchmark"; +import { squareGrid } from "./index"; var bbox = [-95, 30, -85, 40]; diff --git a/packages/turf-square-grid/index.ts b/packages/turf-square-grid/index.ts index e2bd27321..e70a5e953 100644 --- a/packages/turf-square-grid/index.ts +++ b/packages/turf-square-grid/index.ts @@ -7,8 +7,7 @@ import { GeoJsonProperties, } from "geojson"; import { Units } from "@turf/helpers"; - -import rectangleGrid from "@turf/rectangle-grid"; +import { rectangleGrid } from "@turf/rectangle-grid"; /** * Creates a square grid from a bounding box. @@ -34,9 +33,7 @@ import rectangleGrid from "@turf/rectangle-grid"; * var addToMap = [squareGrid] */ -export default function squareGrid< - P extends GeoJsonProperties = GeoJsonProperties, ->( +function squareGrid

( bbox: BBox, cellSide: number, options: { @@ -47,3 +44,6 @@ export default function squareGrid< ): FeatureCollection { return rectangleGrid(bbox, cellSide, cellSide, options); } + +export { squareGrid }; +export default squareGrid; diff --git a/packages/turf-square-grid/package.json b/packages/turf-square-grid/package.json index 3ee31acf5..b3f82d367 100644 --- a/packages/turf-square-grid/package.json +++ b/packages/turf-square-grid/package.json @@ -39,17 +39,18 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js" + "test:tape": "tsx test.ts" }, "devDependencies": { "@turf/bbox-polygon": "^7.0.0-alpha.2", "@turf/truncate": "^7.0.0-alpha.2", + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "npm-run-all": "^4.1.5", diff --git a/packages/turf-square-grid/test.js b/packages/turf-square-grid/test.ts similarity index 77% rename from packages/turf-square-grid/test.js rename to packages/turf-square-grid/test.ts index 8b74acb28..e2d64dd08 100644 --- a/packages/turf-square-grid/test.js +++ b/packages/turf-square-grid/test.ts @@ -1,11 +1,11 @@ -const fs = require("fs"); -const test = require("tape"); -const path = require("path"); -const { loadJsonFileSync } = require("load-json-file"); -const { writeJsonFileSync } = require("write-json-file"); -const bboxPoly = require("@turf/bbox-polygon").default; -const truncate = require("@turf/truncate").default; -const squareGrid = require("./index").default; +import fs from "fs"; +import test from "tape"; +import path from "path"; +import { loadJsonFileSync } from "load-json-file"; +import { writeJsonFileSync } from "write-json-file"; +import { bboxPolygon as bboxPoly } from "@turf/bbox-polygon"; +import { truncate } from "@turf/truncate"; +import { squareGrid } from "./index"; const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-square/bench.js b/packages/turf-square/bench.ts similarity index 88% rename from packages/turf-square/bench.js rename to packages/turf-square/bench.ts index 4914a3ff7..e09d85384 100644 --- a/packages/turf-square/bench.js +++ b/packages/turf-square/bench.ts @@ -1,5 +1,5 @@ import Benchmark from "benchmark"; -import square from "./index"; +import { square } from "./index"; var bbox = [0, 0, 5, 10]; diff --git a/packages/turf-square/index.d.ts b/packages/turf-square/index.d.ts index e5c428f40..d5b331926 100644 --- a/packages/turf-square/index.d.ts +++ b/packages/turf-square/index.d.ts @@ -3,4 +3,7 @@ import { BBox } from "geojson"; /** * http://turfjs.org/docs/#square */ -export default function (bbox: BBox): BBox; +declare function square(bbox: BBox): BBox; + +export { square }; +export default square; diff --git a/packages/turf-square/index.js b/packages/turf-square/index.js index 7ec1f3b71..e102b0c9e 100644 --- a/packages/turf-square/index.js +++ b/packages/turf-square/index.js @@ -1,4 +1,4 @@ -import distance from "@turf/distance"; +import { distance } from "@turf/distance"; /** * Takes a bounding box and calculates the minimum square bounding box that @@ -41,4 +41,5 @@ function square(bbox) { } } +export { square }; export default square; diff --git a/packages/turf-square/package.json b/packages/turf-square/package.json index daaf8c8c1..6623f12b4 100644 --- a/packages/turf-square/package.json +++ b/packages/turf-square/package.json @@ -39,11 +39,11 @@ "index.d.ts" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "rollup -c ../../rollup.config.js && echo '{\"type\":\"module\"}' > dist/es/package.json", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js" + "test:tape": "tsx test.ts" }, "devDependencies": { "benchmark": "^2.1.4", diff --git a/packages/turf-square/test.js b/packages/turf-square/test.ts similarity index 88% rename from packages/turf-square/test.js rename to packages/turf-square/test.ts index 03aa27a4a..018337356 100644 --- a/packages/turf-square/test.js +++ b/packages/turf-square/test.ts @@ -1,5 +1,5 @@ import test from "tape"; -import square from "./index"; +import { square } from "./index"; test("square", function (t) { var bbox1 = [0, 0, 5, 10]; diff --git a/packages/turf-standard-deviational-ellipse/bench.js b/packages/turf-standard-deviational-ellipse/bench.ts similarity index 94% rename from packages/turf-standard-deviational-ellipse/bench.js rename to packages/turf-standard-deviational-ellipse/bench.ts index a0eb267de..37c74c466 100644 --- a/packages/turf-standard-deviational-ellipse/bench.js +++ b/packages/turf-standard-deviational-ellipse/bench.ts @@ -1,5 +1,5 @@ import { randomPoint } from "@turf/random"; -import standardDeviationalEllipse from "./index"; +import { standardDeviationalEllipse } from "./index"; import Benchmark from "benchmark"; /** diff --git a/packages/turf-standard-deviational-ellipse/index.d.ts b/packages/turf-standard-deviational-ellipse/index.d.ts index 301bdaaf4..0f4a02618 100644 --- a/packages/turf-standard-deviational-ellipse/index.d.ts +++ b/packages/turf-standard-deviational-ellipse/index.d.ts @@ -11,7 +11,7 @@ import { * http://turfjs.org/docs/#standarddeviational-ellipse */ -export interface SDEProps { +declare interface SDEProps { meanCenterCoordinates: Position; semiMajorAxis: number; semiMinorAxis: number; @@ -20,14 +20,14 @@ export interface SDEProps { percentageWithinEllipse: number; } -export interface StandardDeviationalEllipse extends Feature { +declare interface StandardDeviationalEllipse extends Feature { properties: { standardDeviationalEllipse: SDEProps; [key: string]: any; }; } -export default function ( +declare function standardDeviationalEllipse( points: FeatureCollection, options?: { properties?: GeoJsonProperties; @@ -35,3 +35,6 @@ export default function ( steps?: number; } ): StandardDeviationalEllipse; + +export { SDEProps, StandardDeviationalEllipse, standardDeviationalEllipse }; +export default standardDeviationalEllipse; diff --git a/packages/turf-standard-deviational-ellipse/index.js b/packages/turf-standard-deviational-ellipse/index.js index 6e0476d84..029ed4080 100644 --- a/packages/turf-standard-deviational-ellipse/index.js +++ b/packages/turf-standard-deviational-ellipse/index.js @@ -149,4 +149,5 @@ function getDeviations(coordinates, center) { }; } +export { standardDeviationalEllipse }; export default standardDeviationalEllipse; diff --git a/packages/turf-standard-deviational-ellipse/package.json b/packages/turf-standard-deviational-ellipse/package.json index adc200b1c..43786fa1a 100644 --- a/packages/turf-standard-deviational-ellipse/package.json +++ b/packages/turf-standard-deviational-ellipse/package.json @@ -42,11 +42,11 @@ "index.d.ts" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "rollup -c ../../rollup.config.js && echo '{\"type\":\"module\"}' > dist/es/package.json", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js", + "test:tape": "tsx test.ts", "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" }, "devDependencies": { diff --git a/packages/turf-standard-deviational-ellipse/test.js b/packages/turf-standard-deviational-ellipse/test.ts similarity index 95% rename from packages/turf-standard-deviational-ellipse/test.js rename to packages/turf-standard-deviational-ellipse/test.ts index eb3bf2bbf..146aaa24f 100644 --- a/packages/turf-standard-deviational-ellipse/test.js +++ b/packages/turf-standard-deviational-ellipse/test.ts @@ -4,7 +4,7 @@ import path from "path"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; import { featureCollection } from "@turf/helpers"; -import standardDeviationalEllipse from "./dist/js/index.js"; +import { standardDeviationalEllipse } from "./index"; test("turf-standard-deviational-ellipse", (t) => { glob diff --git a/packages/turf-tag/bench.js b/packages/turf-tag/bench.ts similarity index 93% rename from packages/turf-tag/bench.js rename to packages/turf-tag/bench.ts index 4ffe66eaf..4b6aa9ed4 100644 --- a/packages/turf-tag/bench.js +++ b/packages/turf-tag/bench.ts @@ -1,6 +1,6 @@ import fs from "fs"; import Benchmark from "benchmark"; -import tag from "./index"; +import { tag } from "./index"; var points = JSON.parse(fs.readFileSync("./test/tagPoints.geojson")); var polygons = JSON.parse(fs.readFileSync("./test/tagPolygons.geojson")); diff --git a/packages/turf-tag/index.ts b/packages/turf-tag/index.ts index e4db9458d..cc372fa28 100644 --- a/packages/turf-tag/index.ts +++ b/packages/turf-tag/index.ts @@ -61,4 +61,5 @@ function tag( return points; } +export { tag }; export default tag; diff --git a/packages/turf-tag/package.json b/packages/turf-tag/package.json index 6cb73e954..8bc03cad3 100644 --- a/packages/turf-tag/package.json +++ b/packages/turf-tag/package.json @@ -42,15 +42,16 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js" + "test:tape": "tsx test.ts" }, "devDependencies": { + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "load-json-file": "^7.0.1", diff --git a/packages/turf-tag/test.js b/packages/turf-tag/test.ts similarity index 98% rename from packages/turf-tag/test.js rename to packages/turf-tag/test.ts index 12b727018..0ef365835 100644 --- a/packages/turf-tag/test.js +++ b/packages/turf-tag/test.ts @@ -1,7 +1,7 @@ import path from "path"; import test from "tape"; import { loadJsonFileSync } from "load-json-file"; -import tag from "./index"; +import { tag } from "./index"; test("tag", (t) => { const points = loadJsonFileSync( diff --git a/packages/turf-tesselate/bench.js b/packages/turf-tesselate/bench.ts similarity index 91% rename from packages/turf-tesselate/bench.js rename to packages/turf-tesselate/bench.ts index 50ab7edc1..874888473 100644 --- a/packages/turf-tesselate/bench.js +++ b/packages/turf-tesselate/bench.ts @@ -1,6 +1,6 @@ import Benchmark from "benchmark"; import { polygon } from "@turf/helpers"; -import tesselate from "./index"; +import { tesselate } from "./index"; var poly = polygon([ [ diff --git a/packages/turf-tesselate/index.d.ts b/packages/turf-tesselate/index.d.ts index 3089e3282..67544306e 100644 --- a/packages/turf-tesselate/index.d.ts +++ b/packages/turf-tesselate/index.d.ts @@ -3,4 +3,9 @@ import { Feature, FeatureCollection, Polygon } from "geojson"; /** * http://turfjs.org/docs/#tesselate */ -export default function (polygon: Feature): FeatureCollection; +declare function tesselate( + polygon: Feature +): FeatureCollection; + +export { tesselate }; +export default tesselate; diff --git a/packages/turf-tesselate/index.js b/packages/turf-tesselate/index.js index f8eb5ac9f..0aef2a7ac 100644 --- a/packages/turf-tesselate/index.js +++ b/packages/turf-tesselate/index.js @@ -76,4 +76,5 @@ function flattenCoords(data) { return result; } +export { tesselate }; export default tesselate; diff --git a/packages/turf-tesselate/package.json b/packages/turf-tesselate/package.json index 931bed640..564e2af74 100644 --- a/packages/turf-tesselate/package.json +++ b/packages/turf-tesselate/package.json @@ -47,11 +47,11 @@ "index.d.ts" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "rollup -c ../../rollup.config.js && echo '{\"type\":\"module\"}' > dist/es/package.json", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js" + "test:tape": "tsx test.ts" }, "devDependencies": { "benchmark": "^2.1.4", diff --git a/packages/turf-tesselate/test.js b/packages/turf-tesselate/test.ts similarity index 99% rename from packages/turf-tesselate/test.js rename to packages/turf-tesselate/test.ts index 267e4fe12..173a9ed1e 100644 --- a/packages/turf-tesselate/test.js +++ b/packages/turf-tesselate/test.ts @@ -1,5 +1,5 @@ import test from "tape"; -import tesselate from "./index"; +import { tesselate } from "./index"; import { featureCollection as featurecollection } from "@turf/helpers"; import { point } from "@turf/helpers"; diff --git a/packages/turf-tin/bench.js b/packages/turf-tin/bench.ts similarity index 66% rename from packages/turf-tin/bench.js rename to packages/turf-tin/bench.ts index 2ca42ee7d..910999051 100644 --- a/packages/turf-tin/bench.js +++ b/packages/turf-tin/bench.ts @@ -1,7 +1,7 @@ -const fs = require("fs"); -const path = require("path"); -const Benchmark = require("benchmark"); -const tin = require("./index").default; +import fs from "fs"; +import path from "path"; +import Benchmark from "benchmark"; +import { tin } from "./index"; const points = JSON.parse( fs.readFileSync(path.join(__dirname, "test", "Points.json")) diff --git a/packages/turf-tin/index.ts b/packages/turf-tin/index.ts index 5b3b7a4bc..1864d9e95 100644 --- a/packages/turf-tin/index.ts +++ b/packages/turf-tin/index.ts @@ -3,13 +3,13 @@ import { FeatureCollection, Point, Polygon } from "geojson"; import { featureCollection, polygon } from "@turf/helpers"; -export interface Pt { +interface Pt { x: number; y: number; z?: number; __sentinel?: boolean; } -export interface Vertice { +interface Vertice { x: number; y: number; } @@ -46,7 +46,7 @@ export interface Vertice { * properties.fill = '#' + properties.a + properties.b + properties.c; * } */ -export default function tin( +function tin( points: FeatureCollection, z?: string ): FeatureCollection { @@ -298,3 +298,6 @@ function triangulate(vertices: Vertice[]) { return closed; } + +export { Pt, Vertice, tin }; +export default tin; diff --git a/packages/turf-tin/package.json b/packages/turf-tin/package.json index 3daf2ab73..62d947732 100644 --- a/packages/turf-tin/package.json +++ b/packages/turf-tin/package.json @@ -37,16 +37,17 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js", + "test:tape": "tsx test.ts", "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" }, "devDependencies": { + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "npm-run-all": "^4.1.5", diff --git a/packages/turf-tin/test.js b/packages/turf-tin/test.ts similarity index 88% rename from packages/turf-tin/test.js rename to packages/turf-tin/test.ts index 85e6d59eb..f061b98ac 100644 --- a/packages/turf-tin/test.js +++ b/packages/turf-tin/test.ts @@ -1,7 +1,7 @@ -const fs = require("fs"); -const path = require("path"); -const test = require("tape"); -const tin = require("./index").default; +import fs from "fs"; +import path from "path"; +import test from "tape"; +import { tin } from "./index"; const points = require(path.join(__dirname, "test", "Points.json")); diff --git a/packages/turf-transform-rotate/bench.js b/packages/turf-transform-rotate/bench.ts similarity index 96% rename from packages/turf-transform-rotate/bench.js rename to packages/turf-transform-rotate/bench.ts index abd7bb82d..56a94e94b 100644 --- a/packages/turf-transform-rotate/bench.js +++ b/packages/turf-transform-rotate/bench.ts @@ -2,7 +2,7 @@ import fs from "fs"; import path from "path"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import rotate from "./index"; +import { transformRotate as rotate } from "./index"; const directory = path.join(__dirname, "test", "in") + path.sep; const fixtures = fs.readdirSync(directory).map((filename) => { diff --git a/packages/turf-transform-rotate/index.d.ts b/packages/turf-transform-rotate/index.d.ts index 999e30e0d..651024d12 100644 --- a/packages/turf-transform-rotate/index.d.ts +++ b/packages/turf-transform-rotate/index.d.ts @@ -3,7 +3,7 @@ import { AllGeoJSON, Coord } from "@turf/helpers"; /** * http://turfjs.org/docs/#transformrotate */ -export default function transformRotate( +declare function transformRotate( geojson: T, angle: number, options?: { @@ -11,3 +11,6 @@ export default function transformRotate( mutate?: boolean; } ): T; + +export { transformRotate }; +export default transformRotate; diff --git a/packages/turf-transform-rotate/index.js b/packages/turf-transform-rotate/index.js index 840cefd76..98105656f 100644 --- a/packages/turf-transform-rotate/index.js +++ b/packages/turf-transform-rotate/index.js @@ -59,4 +59,5 @@ function transformRotate(geojson, angle, options) { return geojson; } +export { transformRotate }; export default transformRotate; diff --git a/packages/turf-transform-rotate/package.json b/packages/turf-transform-rotate/package.json index 87b4c3ecc..82086d368 100644 --- a/packages/turf-transform-rotate/package.json +++ b/packages/turf-transform-rotate/package.json @@ -43,11 +43,11 @@ "index.d.ts" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "rollup -c ../../rollup.config.js && echo '{\"type\":\"module\"}' > dist/es/package.json", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js", + "test:tape": "tsx test.ts", "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" }, "devDependencies": { diff --git a/packages/turf-transform-rotate/test.js b/packages/turf-transform-rotate/test.ts similarity index 96% rename from packages/turf-transform-rotate/test.js rename to packages/turf-transform-rotate/test.ts index d25ffdad3..34d237331 100644 --- a/packages/turf-transform-rotate/test.js +++ b/packages/turf-transform-rotate/test.ts @@ -3,8 +3,8 @@ import test from "tape"; import path from "path"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; -import centroid from "@turf/centroid"; -import truncate from "@turf/truncate"; +import { centroid } from "@turf/centroid"; +import { truncate } from "@turf/truncate"; import { getCoord } from "@turf/invariant"; import { point, @@ -12,7 +12,7 @@ import { featureCollection, geometryCollection, } from "@turf/helpers"; -import rotate from "./index"; +import { transformRotate as rotate } from "./index"; const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-transform-scale/bench.js b/packages/turf-transform-scale/bench.ts similarity index 97% rename from packages/turf-transform-scale/bench.js rename to packages/turf-transform-scale/bench.ts index ae7b0b640..de948532a 100644 --- a/packages/turf-transform-scale/bench.js +++ b/packages/turf-transform-scale/bench.ts @@ -2,7 +2,7 @@ import fs from "fs"; import path from "path"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import scale from "./index"; +import { transformScale as scale } from "./index"; const directory = path.join(__dirname, "test", "in") + path.sep; const fixtures = fs.readdirSync(directory).map((filename) => { diff --git a/packages/turf-transform-scale/index.d.ts b/packages/turf-transform-scale/index.d.ts index 915190b40..371668a7d 100644 --- a/packages/turf-transform-scale/index.d.ts +++ b/packages/turf-transform-scale/index.d.ts @@ -3,7 +3,7 @@ import { Corners, Coord, AllGeoJSON } from "@turf/helpers"; /** * http://turfjs.org/docs/#transformscale */ -export default function transformScale( +declare function transformScale( geojson: T, factor: number, options?: { @@ -11,3 +11,6 @@ export default function transformScale( mutate?: boolean; } ): T; + +export { transformScale }; +export default transformScale; diff --git a/packages/turf-transform-scale/index.js b/packages/turf-transform-scale/index.js index 691ac4613..7a272603f 100644 --- a/packages/turf-transform-scale/index.js +++ b/packages/turf-transform-scale/index.js @@ -145,4 +145,5 @@ function defineOrigin(geojson, origin) { } } +export { transformScale }; export default transformScale; diff --git a/packages/turf-transform-scale/package.json b/packages/turf-transform-scale/package.json index 4cd669f2b..324b4ca8d 100644 --- a/packages/turf-transform-scale/package.json +++ b/packages/turf-transform-scale/package.json @@ -47,11 +47,11 @@ "index.d.ts" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "rollup -c ../../rollup.config.js && echo '{\"type\":\"module\"}' > dist/es/package.json", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js", + "test:tape": "tsx test.ts", "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" }, "devDependencies": { diff --git a/packages/turf-transform-scale/test.js b/packages/turf-transform-scale/test.ts similarity index 96% rename from packages/turf-transform-scale/test.js rename to packages/turf-transform-scale/test.ts index 51fbef8f9..17f66d2ab 100644 --- a/packages/turf-transform-scale/test.js +++ b/packages/turf-transform-scale/test.ts @@ -3,12 +3,12 @@ import test from "tape"; import path from "path"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; -import center from "@turf/center"; -import hexGrid from "@turf/hex-grid"; -import truncate from "@turf/truncate"; -import turfBBox from "@turf/bbox"; -import bboxPolygon from "@turf/bbox-polygon"; -import centroid from "@turf/centroid"; +import { center } from "@turf/center"; +import { hexGrid } from "@turf/hex-grid"; +import { truncate } from "@turf/truncate"; +import { bbox as turfBBox } from "@turf/bbox"; +import { bboxPolygon } from "@turf/bbox-polygon"; +import { centroid } from "@turf/centroid"; import { featureEach } from "@turf/meta"; import { getCoord } from "@turf/invariant"; import { @@ -17,7 +17,7 @@ import { geometryCollection, featureCollection, } from "@turf/helpers"; -import scale from "./index"; +import { transformScale as scale } from "./index"; const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-transform-translate/bench.js b/packages/turf-transform-translate/bench.ts similarity index 96% rename from packages/turf-transform-translate/bench.js rename to packages/turf-transform-translate/bench.ts index 4c1c7a116..059c48eb4 100644 --- a/packages/turf-transform-translate/bench.js +++ b/packages/turf-transform-translate/bench.ts @@ -2,7 +2,7 @@ import fs from "fs"; import path from "path"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import translate from "./index"; +import { transformTranslate as translate } from "./index"; const directory = path.join(__dirname, "test", "in") + path.sep; const fixtures = fs.readdirSync(directory).map((filename) => { diff --git a/packages/turf-transform-translate/index.d.ts b/packages/turf-transform-translate/index.d.ts index 4aebdc391..d67a9c9d1 100644 --- a/packages/turf-transform-translate/index.d.ts +++ b/packages/turf-transform-translate/index.d.ts @@ -3,7 +3,7 @@ import { AllGeoJSON, Units } from "@turf/helpers"; /** * http://turfjs.org/docs/#transform-translate */ -export default function transformTranslate( +declare function transformTranslate( geojson: T, distance: number, direction: number, @@ -13,3 +13,6 @@ export default function transformTranslate( mutate?: boolean; } ): T; + +export { transformTranslate }; +export default transformTranslate; diff --git a/packages/turf-transform-translate/index.js b/packages/turf-transform-translate/index.js index 1b356a6d4..65c554250 100644 --- a/packages/turf-transform-translate/index.js +++ b/packages/turf-transform-translate/index.js @@ -1,8 +1,8 @@ import { coordEach } from "@turf/meta"; import { isObject } from "@turf/helpers"; import { getCoords } from "@turf/invariant"; -import clone from "@turf/clone"; -import rhumbDestination from "@turf/rhumb-destination"; +import { clone } from "@turf/clone"; +import { rhumbDestination } from "@turf/rhumb-destination"; /** * Moves any geojson Feature or Geometry of a specified distance along a Rhumb Line @@ -69,4 +69,5 @@ function transformTranslate(geojson, distance, direction, options) { return geojson; } +export { transformTranslate }; export default transformTranslate; diff --git a/packages/turf-transform-translate/package.json b/packages/turf-transform-translate/package.json index 4b8885235..ddb8cf3f7 100644 --- a/packages/turf-transform-translate/package.json +++ b/packages/turf-transform-translate/package.json @@ -45,11 +45,11 @@ "index.d.ts" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "rollup -c ../../rollup.config.js && echo '{\"type\":\"module\"}' > dist/es/package.json", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js", + "test:tape": "tsx test.ts", "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" }, "devDependencies": { diff --git a/packages/turf-transform-translate/test.js b/packages/turf-transform-translate/test.ts similarity index 97% rename from packages/turf-transform-translate/test.js rename to packages/turf-transform-translate/test.ts index 7583a1031..59c57e5d6 100644 --- a/packages/turf-transform-translate/test.js +++ b/packages/turf-transform-translate/test.ts @@ -3,14 +3,14 @@ import test from "tape"; import path from "path"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; -import truncate from "@turf/truncate"; +import { truncate } from "@turf/truncate"; import { point, lineString, geometryCollection, featureCollection, } from "@turf/helpers"; -import translate from "./index"; +import { transformTranslate as translate } from "./index"; const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-triangle-grid/bench.js b/packages/turf-triangle-grid/bench.ts similarity index 94% rename from packages/turf-triangle-grid/bench.js rename to packages/turf-triangle-grid/bench.ts index 8bccbc387..da656924d 100644 --- a/packages/turf-triangle-grid/bench.js +++ b/packages/turf-triangle-grid/bench.ts @@ -1,5 +1,5 @@ import Benchmark from "benchmark"; -import grid from "./dist/js/index.js"; +import { triangleGrid as grid } from "./index"; // prettier-ignore var bbox1 = [ diff --git a/packages/turf-triangle-grid/index.ts b/packages/turf-triangle-grid/index.ts index 7951b79fa..fbed9524f 100644 --- a/packages/turf-triangle-grid/index.ts +++ b/packages/turf-triangle-grid/index.ts @@ -180,4 +180,5 @@ function triangleGrid

( return featureCollection(results); } +export { triangleGrid }; export default triangleGrid; diff --git a/packages/turf-triangle-grid/package.json b/packages/turf-triangle-grid/package.json index a49cecbc7..7729ecc2c 100644 --- a/packages/turf-triangle-grid/package.json +++ b/packages/turf-triangle-grid/package.json @@ -40,18 +40,19 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js", + "test:tape": "tsx test.ts", "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" }, "devDependencies": { "@turf/bbox-polygon": "^7.0.0-alpha.2", "@turf/truncate": "^7.0.0-alpha.2", + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "load-json-file": "^7.0.1", diff --git a/packages/turf-triangle-grid/test.js b/packages/turf-triangle-grid/test.ts similarity index 76% rename from packages/turf-triangle-grid/test.js rename to packages/turf-triangle-grid/test.ts index dccf65985..05f35ce1b 100644 --- a/packages/turf-triangle-grid/test.js +++ b/packages/turf-triangle-grid/test.ts @@ -1,11 +1,11 @@ -const fs = require("fs"); -const test = require("tape"); -const path = require("path"); -const { loadJsonFileSync } = require("load-json-file"); -const { writeJsonFileSync } = require("write-json-file"); -const bboxPoly = require("@turf/bbox-polygon").default; -const truncate = require("@turf/truncate").default; -const triangleGrid = require("./index").default; +import fs from "fs"; +import test from "tape"; +import path from "path"; +import { loadJsonFileSync } from "load-json-file"; +import { writeJsonFileSync } from "write-json-file"; +import { bboxPolygon as bboxPoly } from "@turf/bbox-polygon"; +import { truncate } from "@turf/truncate"; +import { triangleGrid } from "./index"; const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-truncate/bench.js b/packages/turf-truncate/bench.ts similarity index 87% rename from packages/turf-truncate/bench.js rename to packages/turf-truncate/bench.ts index 671c802ac..31b4145bb 100644 --- a/packages/turf-truncate/bench.js +++ b/packages/turf-truncate/bench.ts @@ -1,8 +1,8 @@ -const fs = require("fs"); -const path = require("path"); -const { loadJsonFileSync } = require("load-json-file"); -const Benchmark = require("benchmark"); -const truncate = require("./index").default; +import fs from "fs"; +import path from "path"; +import { loadJsonFileSync } from "load-json-file"; +import Benchmark from "benchmark"; +import { truncate } from "./index"; const directory = path.join(__dirname, "test", "in") + path.sep; let fixtures = fs.readdirSync(directory).map((filename) => { diff --git a/packages/turf-truncate/index.ts b/packages/turf-truncate/index.ts index 5786663ad..699a3ce69 100644 --- a/packages/turf-truncate/index.ts +++ b/packages/turf-truncate/index.ts @@ -89,4 +89,5 @@ function truncateCoords(coords: number[], factor: number, coordinates: number) { return coords; } +export { truncate }; export default truncate; diff --git a/packages/turf-truncate/package.json b/packages/turf-truncate/package.json index 5cc89ff08..33e853895 100644 --- a/packages/turf-truncate/package.json +++ b/packages/turf-truncate/package.json @@ -41,16 +41,17 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js", + "test:tape": "tsx test.ts", "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" }, "devDependencies": { + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "load-json-file": "^7.0.1", diff --git a/packages/turf-truncate/test.js b/packages/turf-truncate/test.ts similarity index 86% rename from packages/turf-truncate/test.js rename to packages/turf-truncate/test.ts index 7b3a2e3ab..003eab34b 100644 --- a/packages/turf-truncate/test.js +++ b/packages/turf-truncate/test.ts @@ -1,10 +1,10 @@ -const fs = require("fs"); -const test = require("tape"); -const path = require("path"); -const { loadJsonFileSync } = require("load-json-file"); -const { writeJsonFileSync } = require("write-json-file"); -const { point } = require("@turf/helpers"); -const truncate = require("./index").default; +import fs from "fs"; +import test from "tape"; +import path from "path"; +import { loadJsonFileSync } from "load-json-file"; +import { writeJsonFileSync } from "write-json-file"; +import { point } from "@turf/helpers"; +import { truncate } from "./index"; const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-union/bench.js b/packages/turf-union/bench.ts similarity index 69% rename from packages/turf-union/bench.js rename to packages/turf-union/bench.ts index 0763c8081..8000991fd 100644 --- a/packages/turf-union/bench.js +++ b/packages/turf-union/bench.ts @@ -1,9 +1,9 @@ -const fs = require("fs"); -const path = require("path"); -const { loadJsonFileSync } = require("load-json-file"); -const Benchmark = require("benchmark"); -const union = require("./index").default; -const { featureCollection } = require("@turf/helpers"); +import fs from "fs"; +import path from "path"; +import { loadJsonFileSync } from "load-json-file"; +import Benchmark from "benchmark"; +import { union } from "./index"; +import { featureCollection } from "@turf/helpers"; const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-union/index.ts b/packages/turf-union/index.ts index 017c2ba26..9db47ad20 100644 --- a/packages/turf-union/index.ts +++ b/packages/turf-union/index.ts @@ -57,4 +57,5 @@ function union

( else return multiPolygon(unioned, options.properties); } +export { union }; export default union; diff --git a/packages/turf-union/package.json b/packages/turf-union/package.json index 00de56295..0d6a7e246 100644 --- a/packages/turf-union/package.json +++ b/packages/turf-union/package.json @@ -36,16 +36,17 @@ "dist" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "npm-run-all --npm-path npm build:*", "build:es": "tsc --outDir dist/es --module esnext --declaration false && echo '{\"type\":\"module\"}' > dist/es/package.json", "build:js": "tsc", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js", + "test:tape": "tsx test.ts", "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" }, "devDependencies": { + "@types/benchmark": "^2.1.5", "@types/tape": "^4.2.32", "benchmark": "^2.1.4", "glob": "^10.3.10", diff --git a/packages/turf-union/test.js b/packages/turf-union/test.ts similarity index 72% rename from packages/turf-union/test.js rename to packages/turf-union/test.ts index 8d2ed39ec..eb1fed79c 100644 --- a/packages/turf-union/test.js +++ b/packages/turf-union/test.ts @@ -1,9 +1,9 @@ -const fs = require("fs"); -const path = require("path"); -const test = require("tape"); -const { loadJsonFileSync } = require("load-json-file"); -const { writeJsonFileSync } = require("write-json-file"); -const union = require("./index").default; +import fs from "fs"; +import path from "path"; +import test from "tape"; +import { loadJsonFileSync } from "load-json-file"; +import { writeJsonFileSync } from "write-json-file"; +import { union } from "./index"; const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-unkink-polygon/bench.js b/packages/turf-unkink-polygon/bench.ts similarity index 92% rename from packages/turf-unkink-polygon/bench.js rename to packages/turf-unkink-polygon/bench.ts index 45679eaa4..fa32a248e 100644 --- a/packages/turf-unkink-polygon/bench.js +++ b/packages/turf-unkink-polygon/bench.ts @@ -2,7 +2,7 @@ import fs from "fs"; import path from "path"; import { loadJsonFileSync } from "load-json-file"; import Benchmark from "benchmark"; -import unkink from "./index"; +import { unkinkPolygon as unkink } from "./index"; const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-unkink-polygon/index.d.ts b/packages/turf-unkink-polygon/index.d.ts index 4f85e47b8..a603833ae 100644 --- a/packages/turf-unkink-polygon/index.d.ts +++ b/packages/turf-unkink-polygon/index.d.ts @@ -3,6 +3,9 @@ import { Polygon, MultiPolygon, Feature, FeatureCollection } from "geojson"; /** * http://turfjs.org/docs/#unkink-polygon */ -export default function unkinkPolygon( +declare function unkinkPolygon( geojson: Feature | FeatureCollection | T ): FeatureCollection; + +export { unkinkPolygon }; +export default unkinkPolygon; diff --git a/packages/turf-unkink-polygon/index.js b/packages/turf-unkink-polygon/index.js index 979331137..d11ed0168 100644 --- a/packages/turf-unkink-polygon/index.js +++ b/packages/turf-unkink-polygon/index.js @@ -28,4 +28,5 @@ function unkinkPolygon(geojson) { return featureCollection(features); } +export { unkinkPolygon }; export default unkinkPolygon; diff --git a/packages/turf-unkink-polygon/package.json b/packages/turf-unkink-polygon/package.json index 6dfe322b9..a220b5f68 100644 --- a/packages/turf-unkink-polygon/package.json +++ b/packages/turf-unkink-polygon/package.json @@ -40,11 +40,11 @@ "index.d.ts" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "rollup -c ../../rollup.config.js && echo '{\"type\":\"module\"}' > dist/es/package.json", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js", + "test:tape": "tsx test.ts", "test:types": "tsc --esModuleInterop --noEmit --strict types.ts" }, "devDependencies": { diff --git a/packages/turf-unkink-polygon/test.js b/packages/turf-unkink-polygon/test.ts similarity index 96% rename from packages/turf-unkink-polygon/test.js rename to packages/turf-unkink-polygon/test.ts index 9578f7187..c00c1b5ef 100644 --- a/packages/turf-unkink-polygon/test.js +++ b/packages/turf-unkink-polygon/test.ts @@ -5,8 +5,8 @@ import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; import { featureEach } from "@turf/meta"; import { featureCollection } from "@turf/helpers"; -import kinks from "@turf/kinks"; -import unkinkPolygon from "./index"; +import { kinks } from "@turf/kinks"; +import { unkinkPolygon } from "./index"; const directories = { in: path.join(__dirname, "test", "in") + path.sep, diff --git a/packages/turf-voronoi/bench.js b/packages/turf-voronoi/bench.ts similarity index 95% rename from packages/turf-voronoi/bench.js rename to packages/turf-voronoi/bench.ts index 8fae89832..decb658e9 100644 --- a/packages/turf-voronoi/bench.js +++ b/packages/turf-voronoi/bench.ts @@ -2,7 +2,7 @@ import Benchmark from "benchmark"; import path from "path"; import fs from "fs"; import { loadJsonFileSync } from "load-json-file"; -import voronoi from "./index"; +import { voronoi } from "./index"; const directory = path.join(__dirname, "test", "in") + path.sep; const fixtures = fs.readdirSync(directory).map((filename) => { diff --git a/packages/turf-voronoi/index.d.ts b/packages/turf-voronoi/index.d.ts index e86325dab..836a6b770 100644 --- a/packages/turf-voronoi/index.d.ts +++ b/packages/turf-voronoi/index.d.ts @@ -3,7 +3,10 @@ import { FeatureCollection, BBox, Point, Polygon } from "geojson"; /** * http://turfjs.org/docs/#voronoi */ -export default function voronoi( +declare function voronoi( points: FeatureCollection, options?: { bbox: BBox } ): FeatureCollection; + +export { voronoi }; +export default voronoi; diff --git a/packages/turf-voronoi/index.js b/packages/turf-voronoi/index.js index 2844bfcc2..1032d088f 100644 --- a/packages/turf-voronoi/index.js +++ b/packages/turf-voronoi/index.js @@ -69,4 +69,5 @@ function voronoi(points, options) { ); } +export { voronoi }; export default voronoi; diff --git a/packages/turf-voronoi/package.json b/packages/turf-voronoi/package.json index b7ef2ae5f..e17428b75 100644 --- a/packages/turf-voronoi/package.json +++ b/packages/turf-voronoi/package.json @@ -46,11 +46,11 @@ "index.d.ts" ], "scripts": { - "bench": "tsx bench.js", + "bench": "tsx bench.ts", "build": "rollup -c ../../rollup.config.js && echo '{\"type\":\"module\"}' > dist/es/package.json", "docs": "tsx ../../scripts/generate-readmes.ts", "test": "npm-run-all --npm-path npm test:*", - "test:tape": "tsx test.js" + "test:tape": "tsx test.ts" }, "devDependencies": { "benchmark": "^2.1.4", diff --git a/packages/turf-voronoi/test.js b/packages/turf-voronoi/test.ts similarity index 95% rename from packages/turf-voronoi/test.js rename to packages/turf-voronoi/test.ts index 0994d23d4..eab68d1eb 100644 --- a/packages/turf-voronoi/test.js +++ b/packages/turf-voronoi/test.ts @@ -3,7 +3,7 @@ import { glob } from "glob"; import path from "path"; import { loadJsonFileSync } from "load-json-file"; import { writeJsonFileSync } from "write-json-file"; -import voronoi from "./index"; +import { voronoi } from "./index"; test("turf-voronoi", (t) => { glob diff --git a/packages/turf/package.json b/packages/turf/package.json index 505749282..6ab4a496d 100644 --- a/packages/turf/package.json +++ b/packages/turf/package.json @@ -65,7 +65,7 @@ "build": "rollup -c rollup.config.js && echo '{\"type\":\"module\"}' > dist/es/package.json", "last-checks": "npm-run-all last-checks:testjs last-checks:example", "last-checks:example": "tsx test.example.js", - "last-checks:testjs": "tsx test.js", + "last-checks:testjs": "tsx test.ts", "test": "echo '@turf/turf tests run in the last-checks step'" }, "devDependencies": { diff --git a/packages/turf/test.js b/packages/turf/test.ts similarity index 96% rename from packages/turf/test.js rename to packages/turf/test.ts index 2f5d91882..59cb651cd 100644 --- a/packages/turf/test.js +++ b/packages/turf/test.ts @@ -1,10 +1,10 @@ -const fs = require("fs"); -const path = require("path"); -const { glob } = require("glob"); -const test = require("tape"); -const camelCase = require("camelcase").default; -const documentation = require("documentation"); -const turf = require("./dist/js/index.js"); +import fs from "fs"; +import path from "path"; +import { glob } from "glob"; +import test from "tape"; +import camelCase from "camelcase"; +import documentation from "documentation"; +import * as turf from "./dist/js/index.js"; // Helpers const directory = path.join(__dirname, ".."); @@ -22,7 +22,10 @@ for (const name of fs.readdirSync(directory)) { } const index = fs.readFileSync(mainFile, "utf8"); - const test = fs.readFileSync(path.join(directory, name, "test.js"), "utf8"); + // Cater for JS or TS test files. + const test = fs.existsSync(path.join(directory, name, "test.ts")) + ? fs.readFileSync(path.join(directory, name, "test.ts"), "utf8") + : fs.readFileSync(path.join(directory, name, "test.js"), "utf8"); modules.push({ name, diff --git a/rollup-plugins/typescript-export.js b/rollup-plugins/typescript-export.js deleted file mode 100644 index 53a6d1975..000000000 --- a/rollup-plugins/typescript-export.js +++ /dev/null @@ -1,12 +0,0 @@ -// https://github.com/Turfjs/turf/pull/986 -export default function typescriptExport() { - return { - name: "typescript-export", - renderChunk(code) { - code = code.trim(); - const name = code.match(/module.exports = ([\w$]+);/); - if (name) code += `\nmodule.exports.default = ${name[1]};\n`; - return code; - }, - }; -} diff --git a/rollup-plugins/valid-es5.js b/rollup-plugins/valid-es5.js deleted file mode 100644 index b62c156f1..000000000 --- a/rollup-plugins/valid-es5.js +++ /dev/null @@ -1,26 +0,0 @@ -export default function validES5() { - return { - name: "valid-es5", - renderChunk(code) { - removeComments(code) - .match(/[\w\=\>]+/g) - .forEach((word) => { - switch (word) { - case "const": - case "let": - case "=>": - throw new Error(word + " is not valid ES5 syntax"); - } - }); - return code; - }, - }; -} - -function removeComments(code) { - // Remove comments block comments - code = code.replace(/\/\*\*[\w\s*\.@{}|<>,=()[\];\/\-'`":]+\*\//g, ""); - // Remove inline comments - code = code.replace(/\/\/.+\n/g, "\n"); - return code; -} diff --git a/rollup.config.js b/rollup.config.js index ef97d7563..4afebbf21 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -1,10 +1,7 @@ -import typescript from "./rollup-plugins/typescript-export"; - export default { input: "index.js", output: [ - { file: "dist/js/index.js", format: "cjs" }, + { file: "dist/js/index.js", format: "cjs", exports: "named" }, { file: "dist/es/index.js", format: "es" }, ], - plugins: [typescript()], }; diff --git a/yarn.lock b/yarn.lock index ba5706372..1196ea913 100644 --- a/yarn.lock +++ b/yarn.lock @@ -1888,6 +1888,11 @@ "@turf/helpers" "^5.1.5" "@turf/invariant" "^5.1.5" +"@types/benchmark@^2.1.5": + version "2.1.5" + resolved "https://registry.yarnpkg.com/@types/benchmark/-/benchmark-2.1.5.tgz#940c1850c18fdfdaee3fd6ed29cd92ae0d445b45" + integrity sha512-cKio2eFB3v7qmKcvIHLUMw/dIx/8bhWPuzpzRT4unCPRTD8VdA9Zb0afxpcxOqR4PixRS7yT42FqGS8BYL8g1w== + "@types/concaveman@^1.1.6": version "1.1.6" resolved "https://registry.yarnpkg.com/@types/concaveman/-/concaveman-1.1.6.tgz#d82548021d8db80562be70187fa6e07237f60775"