diff --git a/packages/turf-flip/index.ts b/packages/turf-flip/index.ts index 1a93455384..0a9a085243 100644 --- a/packages/turf-flip/index.ts +++ b/packages/turf-flip/index.ts @@ -27,8 +27,7 @@ function flip( // Optional parameters options = options || {}; if (!isObject(options)) throw new Error("options is invalid"); - options.mutate = options.mutate || false; - const { mutate } = options; + const mutate = options.mutate || false; if (!geojson) throw new Error("geojson is required"); // ensure that we don't modify features in-place and changes to the diff --git a/packages/turf-polygon-smooth/index.d.ts b/packages/turf-polygon-smooth/index.d.ts deleted file mode 100644 index f688901da4..0000000000 --- a/packages/turf-polygon-smooth/index.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { Feature, FeatureCollection, Polygon, MultiPolygon } from "geojson"; - -/** - * http://turfjs.org/docs/#polygonSmooth - */ -export default function ( - polygon: FeatureCollection | Feature | T, - options?: { - iterations?: number; - } -): FeatureCollection; diff --git a/packages/turf-rewind/index.d.ts b/packages/turf-rewind/index.d.ts deleted file mode 100644 index 8b97e9c858..0000000000 --- a/packages/turf-rewind/index.d.ts +++ /dev/null @@ -1,12 +0,0 @@ -import { AllGeoJSON } from "@turf/helpers"; - -/** - * http://turfjs.org/docs/#rewind - */ -export default function rewind( - geojson: T, - options?: { - reverse?: boolean; - mutate?: boolean; - } -): T; diff --git a/packages/turf-rewind/index.ts b/packages/turf-rewind/index.ts index 76100caf62..f94a745c37 100644 --- a/packages/turf-rewind/index.ts +++ b/packages/turf-rewind/index.ts @@ -35,18 +35,16 @@ import type { AllGeoJSON } from "@turf/helpers"; */ function rewind( geojson: T, - options?: { + options: { reverse?: boolean; mutate?: boolean; - } + } = {} ): Geometry | Feature | FeatureCollection { // Optional parameters options = options || {}; if (!isObject(options)) throw new Error("options is invalid"); - options.mutate = options.mutate || false; - options.reverse = options.reverse || false; - - const { reverse, mutate } = options; + const mutate = options.mutate || false; + const reverse = options.reverse || false; // Prevent input mutation if requested. if (!mutate) geojson = clone(geojson); diff --git a/packages/turf-sector/index.ts b/packages/turf-sector/index.ts index 6ba4dc46aa..817f0685e6 100644 --- a/packages/turf-sector/index.ts +++ b/packages/turf-sector/index.ts @@ -35,19 +35,17 @@ function sector( radius: number, bearing1: number, bearing2: number, - options?: { + options: { steps?: number; units?: Units; properties?: GeoJsonProperties; - } + } = {} ): Feature { // Optional parameters options = options || {}; if (!isObject(options)) throw new Error("options is invalid"); - options.steps = options.steps || 64; - options.units = options.units || "kilometers"; // Most options only for passing through to circle() - const { properties } = options; + const properties = options.properties; // validation if (!center) throw new Error("center is required"); diff --git a/packages/turf-shortest-path/index.ts b/packages/turf-shortest-path/index.ts index 0a0bb0fb66..65ba0887d5 100644 --- a/packages/turf-shortest-path/index.ts +++ b/packages/turf-shortest-path/index.ts @@ -34,7 +34,6 @@ import { Graph, GridNode, astar } from "./lib/javascript-astar"; * @param {Coord} end point * @param {Object} [options={}] optional parameters * @param {Geometry|Feature|FeatureCollection} [options.obstacles] areas which path cannot travel - * @param {number} [options.minDistance] minimum distance between shortest path and obstacles * @param {string} [options.units='kilometers'] unit in which resolution & minimum distance will be expressed in; it can be degrees, radians, miles, kilometers, ... * @param {number} [options.resolution=100] distance between matrix points on which the path will be calculated * @returns {Feature} shortest path between start and end @@ -53,29 +52,23 @@ import { Graph, GridNode, astar } from "./lib/javascript-astar"; function shortestPath( start: Coord, end: Coord, - options?: { + options: { obstacles?: Polygon | Feature | FeatureCollection; - minDistance?: number; units?: Units; resolution?: number; - } + } = {} ): Feature { // Optional parameters options = options || {}; if (!isObject(options)) throw new Error("options is invalid"); - options.obstacles = options.obstacles || featureCollection([]); - options.units = options.units || "kilometers"; - options.resolution = options.resolution || 100; - const { minDistance } = options; - let { obstacles, resolution } = options; + let obstacles = options.obstacles || featureCollection([]); + let resolution = options.resolution || 100; // validation if (!start) throw new Error("start is required"); if (!end) throw new Error("end is required"); if (resolution && (!isNumber(resolution) || resolution <= 0)) throw new Error("options.resolution must be a number, greater than 0"); - if (minDistance) - throw new Error("options.minDistance is not yet implemented"); // Normalize Inputs const startCoord = getCoord(start); diff --git a/packages/turf-simplify/index.ts b/packages/turf-simplify/index.ts index 9074e50829..a0ae248552 100644 --- a/packages/turf-simplify/index.ts +++ b/packages/turf-simplify/index.ts @@ -47,20 +47,18 @@ import simplifyJS from "./lib/simplify"; */ function simplify( geojson: T, - options?: { + options: { tolerance?: number; highQuality?: boolean; mutate?: boolean; - } + } = {} ): T { // Optional parameters options = options || {}; if (!isObject(options)) throw new Error("options is invalid"); - options.tolerance = options.tolerance !== undefined ? options.tolerance : 1; - options.highQuality = options.highQuality || false; - options.mutate = options.mutate || false; - - const { tolerance, highQuality, mutate } = options; + const tolerance = options.tolerance !== undefined ? options.tolerance : 1; + const highQuality = options.highQuality || false; + const mutate = options.mutate || false; if (!geojson) throw new Error("geojson is required"); if (tolerance && tolerance < 0) throw new Error("invalid tolerance");