Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@turf/meta

Package Overview
Dependencies
Maintainers
4
Versions
70
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@turf/meta - npm Package Compare versions

Comparing version 5.0.0-alpha to 5.0.0

main.js

51

index.js
/**
* GeoJSON BBox
*
* @private
* @typedef {[number, number, number, number]} BBox
*/
/**
* GeoJSON Id
*
* @private
* @typedef {(number|string)} Id
*/
/**
* GeoJSON FeatureCollection
*
* @private
* @typedef {Object} FeatureCollection
* @property {string} type
* @property {?Id} id
* @property {?BBox} bbox
* @property {Feature[]} features
*/
/**
* GeoJSON Feature
*
* @private
* @typedef {Object} Feature
* @property {string} type
* @property {?Id} id
* @property {?BBox} bbox
* @property {*} properties
* @property {Geometry} geometry
*/
/**
* GeoJSON Geometry
*
* @private
* @typedef {Object} Geometry
* @property {string} type
* @property {any[]} coordinates
*/
/**
* Callback for coordEach

@@ -830,3 +784,3 @@ *

*/
export function feature(geometry, properties) {
function feature(geometry, properties) {
if (geometry === undefined) throw new Error('No geometry passed');

@@ -849,3 +803,3 @@

*/
export function lineString(coordinates, properties) {
function lineString(coordinates, properties) {
if (!coordinates) throw new Error('No coordinates passed');

@@ -864,3 +818,2 @@ if (coordinates.length < 2) throw new Error('Coordinates must be an array of two or more positions');

/**

@@ -867,0 +820,0 @@ * Callback for lineEach

{
"name": "@turf/meta",
"version": "5.0.0-alpha",
"version": "5.0.0",
"description": "turf meta module",
"main": "index.es5.js",
"module": "index.js",
"jsnext:main": "index.js",
"main": "main",
"module": "index",
"jsnext:main": "index",
"types": "index.d.ts",

@@ -12,8 +12,9 @@ "files": [

"index.d.ts",
"index.es5.js"
"main.js"
],
"scripts": {
"pretest": "rollup -c ../../rollup.config.js",
"test": "node test.es5.js",
"bench": "node bench.js"
"test": "node -r @std/esm test.js",
"posttest": "uglifyjs main.js -o main.min.js",
"bench": "node -r @std/esm bench.js"
},

@@ -56,9 +57,15 @@ "repository": {

"devDependencies": {
"@turf/helpers": "*",
"@turf/helpers": "5.0.0",
"@turf/random": "*",
"benchmark": "*",
"rollup": "*",
"tape": "*"
"tape": "*",
"@std/esm": "*",
"uglify-js": "*"
},
"dependencies": {}
"dependencies": {},
"@std/esm": {
"esm": "js",
"cjs": true
}
}
# @turf/meta
# coordEachCallback
<!-- Generated by documentation.js. Update this documentation by updating the source code. -->
## coordEachCallback
Callback for coordEach
Type: [Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)
**Parameters**

@@ -14,7 +18,4 @@

- `featureSubIndex` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** The current subIndex of the feature being processed.
- `geojson`
- `callback`
- `excludeWrapCoord`
# coordEach
## coordEach

@@ -27,3 +28,3 @@ Iterate over coordinates in any GeoJSON object, similar to Array.forEach()

- `callback` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** a method that takes (currentCoord, coordIndex, featureIndex, featureSubIndex)
- `excludeWrapCoord` **\[[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)]** whether or not to include the final coordinate of LinearRings that wraps the ring in its iteration. (optional, default `false`)
- `excludeWrapCoord` **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** whether or not to include the final coordinate of LinearRings that wraps the ring in its iteration. (optional, default `false`)

@@ -46,3 +47,3 @@ **Examples**

# coordReduce
## coordReduce

@@ -55,4 +56,4 @@ Reduce coordinates in any GeoJSON object, similar to Array.reduce()

- `callback` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** a method that takes (previousValue, currentCoord, coordIndex)
- `initialValue` **\[Any]** Value to use as the first argument to the first call of the callback.
- `excludeWrapCoord` **\[[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)]** whether or not to include the final coordinate of LinearRings that wraps the ring in its iteration. (optional, default `false`)
- `initialValue` **any?** Value to use as the first argument to the first call of the callback.
- `excludeWrapCoord` **[boolean](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Boolean)** whether or not to include the final coordinate of LinearRings that wraps the ring in its iteration. (optional, default `false`)

@@ -77,5 +78,5 @@ **Examples**

Returns **Any** The value that results from the reduction.
Returns **any** The value that results from the reduction.
# coordReduceCallback
## coordReduceCallback

@@ -97,5 +98,7 @@ Callback for coordReduce

Type: [Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)
**Parameters**
- `previousValue` **Any** The accumulated value previously returned in the last invocation
- `previousValue` **any** The accumulated value previously returned in the last invocation
of the callback, or initialValue, if supplied.

@@ -107,8 +110,4 @@ - `currentCoord` **[Array](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array)&lt;[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)>** The current coordinate being processed.

- `featureSubIndex` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** The current subIndex of the feature being processed.
- `geojson`
- `callback`
- `initialValue`
- `excludeWrapCoord`
# propEach
## propEach

@@ -136,6 +135,8 @@ Iterate over properties in any GeoJSON object, similar to Array.forEach()

# propEachCallback
## propEachCallback
Callback for propEach
Type: [Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)
**Parameters**

@@ -146,7 +147,32 @@

array.Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
- `geojson`
- `callback`
# propReduce
## propReduceCallback
Callback for propReduce
The first time the callback function is called, the values provided as arguments depend
on whether the reduce method has an initialValue argument.
If an initialValue is provided to the reduce method:
- The previousValue argument is initialValue.
- The currentValue argument is the value of the first element present in the array.
If an initialValue is not provided:
- The previousValue argument is the value of the first element present in the array.
- The currentValue argument is the value of the second element present in the array.
Type: [Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)
**Parameters**
- `previousValue` **any** The accumulated value previously returned in the last invocation
of the callback, or initialValue, if supplied.
- `currentProperties` **any** The current properties being processed.
- `featureIndex` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** The index of the current element being processed in the
array.Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
## propReduce
Reduce properties in any GeoJSON object into a single value,

@@ -160,3 +186,3 @@ similar to how Array.reduce works. However, in this case we lazily run

- `callback` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** a method that takes (previousValue, currentProperties, featureIndex)
- `initialValue` **\[Any]** Value to use as the first argument to the first call of the callback.
- `initialValue` **any?** Value to use as the first argument to the first call of the callback.

@@ -179,33 +205,17 @@ **Examples**

Returns **Any** The value that results from the reduction.
Returns **any** The value that results from the reduction.
# propReduceCallback
## featureEachCallback
Callback for propReduce
Callback for featureEach
The first time the callback function is called, the values provided as arguments depend
on whether the reduce method has an initialValue argument.
Type: [Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)
If an initialValue is provided to the reduce method:
- The previousValue argument is initialValue.
- The currentValue argument is the value of the first element present in the array.
If an initialValue is not provided:
- The previousValue argument is the value of the first element present in the array.
- The currentValue argument is the value of the second element present in the array.
**Parameters**
- `previousValue` **Any** The accumulated value previously returned in the last invocation
of the callback, or initialValue, if supplied.
- `currentProperties` **Any** The current properties being processed.
- `currentFeature` **[Feature](http://geojson.org/geojson-spec.html#feature-objects)&lt;any>** The current feature being processed.
- `featureIndex` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** The index of the current element being processed in the
array.Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
- `geojson`
- `callback`
- `initialValue`
# featureEach
## featureEach

@@ -234,16 +244,4 @@ Iterate over features in any GeoJSON object, similar to

# featureEachCallback
## featureReduceCallback
Callback for featureEach
**Parameters**
- `currentFeature` **[Feature](http://geojson.org/geojson-spec.html#feature-objects)&lt;any>** The current feature being processed.
- `featureIndex` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** The index of the current element being processed in the
array.Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
- `geojson`
- `callback`
# featureReduceCallback
Callback for featureReduce

@@ -264,5 +262,7 @@

Type: [Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)
**Parameters**
- `previousValue` **Any** The accumulated value previously returned in the last invocation
- `previousValue` **any** The accumulated value previously returned in the last invocation
of the callback, or initialValue, if supplied.

@@ -272,7 +272,4 @@ - `currentFeature` **[Feature](http://geojson.org/geojson-spec.html#feature-objects)** The current Feature being processed.

array.Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
- `geojson`
- `callback`
- `initialValue`
# featureReduce
## featureReduce

@@ -285,3 +282,3 @@ Reduce features in any GeoJSON object, similar to Array.reduce().

- `callback` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** a method that takes (previousValue, currentFeature, featureIndex)
- `initialValue` **\[Any]** Value to use as the first argument to the first call of the callback.
- `initialValue` **any?** Value to use as the first argument to the first call of the callback.

@@ -304,5 +301,5 @@ **Examples**

Returns **Any** The value that results from the reduction.
Returns **any** The value that results from the reduction.
# coordAll
## coordAll

@@ -329,6 +326,8 @@ Get all coordinates from any GeoJSON object.

# geomEachCallback
## geomEachCallback
Callback for geomEach
Type: [Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)
**Parameters**

@@ -340,6 +339,4 @@

- `currentProperties` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** The current feature properties being processed.
- `geojson`
- `callback`
# geomEach
## geomEach

@@ -368,3 +365,3 @@ Iterate over each geometry in any GeoJSON object, similar to Array.forEach()

# geomReduceCallback
## geomReduceCallback

@@ -386,5 +383,7 @@ Callback for geomReduce

Type: [Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)
**Parameters**
- `previousValue` **Any** The accumulated value previously returned in the last invocation
- `previousValue` **any** The accumulated value previously returned in the last invocation
of the callback, or initialValue, if supplied.

@@ -395,7 +394,4 @@ - `currentGeometry` **[Geometry](http://geojson.org/geojson-spec.html#geometry)** The current Feature being processed.

- `currentProperties` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** The current feature properties being processed.
- `geojson`
- `callback`
- `initialValue`
# geomReduce
## geomReduce

@@ -408,3 +404,3 @@ Reduce geometry in any GeoJSON object, similar to Array.reduce().

- `callback` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** a method that takes (previousValue, currentGeometry, featureIndex, currentProperties)
- `initialValue` **\[Any]** Value to use as the first argument to the first call of the callback.
- `initialValue` **any?** Value to use as the first argument to the first call of the callback.

@@ -428,8 +424,10 @@ **Examples**

Returns **Any** The value that results from the reduction.
Returns **any** The value that results from the reduction.
# flattenEachCallback
## flattenEachCallback
Callback for flattenEach
Type: [Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)
**Parameters**

@@ -442,6 +440,4 @@

array. Starts at index 0 and increases if the flattened feature was a multi-geometry.
- `geojson`
- `callback`
# flattenEach
## flattenEach

@@ -471,3 +467,3 @@ Iterate over flattened features in any GeoJSON object, similar to

# flattenReduceCallback
## flattenReduceCallback

@@ -489,5 +485,7 @@ Callback for flattenReduce

Type: [Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)
**Parameters**
- `previousValue` **Any** The accumulated value previously returned in the last invocation
- `previousValue` **any** The accumulated value previously returned in the last invocation
of the callback, or initialValue, if supplied.

@@ -499,7 +497,4 @@ - `currentFeature` **[Feature](http://geojson.org/geojson-spec.html#feature-objects)** The current Feature being processed.

array. Starts at index 0 and increases if the flattened feature was a multi-geometry.
- `geojson`
- `callback`
- `initialValue`
# flattenReduce
## flattenReduce

@@ -512,3 +507,3 @@ Reduce flattened features in any GeoJSON object, similar to Array.reduce().

- `callback` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** a method that takes (previousValue, currentFeature, featureIndex, featureSubIndex)
- `initialValue` **\[Any]** Value to use as the first argument to the first call of the callback.
- `initialValue` **any?** Value to use as the first argument to the first call of the callback.

@@ -532,20 +527,20 @@ **Examples**

Returns **Any** The value that results from the reduction.
Returns **any** The value that results from the reduction.
# segmentEachCallback
## segmentEachCallback
Callback for segmentEach
Type: [Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)
**Parameters**
- `currentSegment` **[Feature](http://geojson.org/geojson-spec.html#feature-objects)&lt;[LineString](http://geojson.org/geojson-spec.html#linestring)>** The current segment being processed.
- `segmentIndex` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** The segmentIndex currently being processed, starts at index 0.
- `featureIndex` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** The featureIndex currently being processed, starts at index 0.
- `featureSubIndex` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** The featureSubIndex currently being processed, starts at index 0.
- `geojson`
- `callback`
- `segmentIndex` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** The segmentIndex currently being processed, starts at index 0.
Returns **void**
# segmentEach
## segmentEach

@@ -566,7 +561,7 @@ Iterate over 2-vertex line segment in any GeoJSON object, similar to Array.forEach()

// Iterate over GeoJSON by 2-vertex segments
turf.segmentEach(polygon, function (currentSegment, featureIndex, featureSubIndex) {
turf.segmentEach(polygon, function (currentSegment, featureIndex, featureSubIndex, segmentIndex) {
//= currentSegment
//= segmentIndex
//= featureIndex
//= featureSubIndex
//= segmentIndex
});

@@ -583,3 +578,3 @@

# segmentReduceCallback
## segmentReduceCallback

@@ -601,15 +596,14 @@ Callback for segmentReduce

Type: [Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)
**Parameters**
- `previousValue` **\[Any]** The accumulated value previously returned in the last invocation
- `previousValue` **any?** The accumulated value previously returned in the last invocation
of the callback, or initialValue, if supplied.
- `currentSegment` **\[[Feature](http://geojson.org/geojson-spec.html#feature-objects)&lt;[LineString](http://geojson.org/geojson-spec.html#linestring)>]** The current segment being processed.
- `segmentIndex` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** The segmentIndex currently being processed, starts at index 0.
- `currentSegment` **[Feature](http://geojson.org/geojson-spec.html#feature-objects)&lt;[LineString](http://geojson.org/geojson-spec.html#linestring)>?** The current segment being processed.
- `featureIndex` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** The featureIndex currently being processed, starts at index 0.
- `featureSubIndex` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** The featureSubIndex currently being processed, starts at index 0.
- `geojson`
- `callback`
- `initialValue`
- `segmentIndex` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** The segmentIndex currently being processed, starts at index 0.
# segmentReduce
## segmentReduce

@@ -623,3 +617,3 @@ Reduce 2-vertex line segment in any GeoJSON object, similar to Array.reduce()

- `callback` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** a method that takes (previousValue, currentSegment, currentIndex)
- `initialValue` **\[Any]** Value to use as the first argument to the first call of the callback.
- `initialValue` **any?** Value to use as the first argument to the first call of the callback.

@@ -632,8 +626,8 @@ **Examples**

// Iterate over GeoJSON by 2-vertex segments
turf.segmentReduce(polygon, function (previousSegment, currentSegment, segmentIndex, featureIndex, featureSubIndex) {
turf.segmentReduce(polygon, function (previousSegment, currentSegment, featureIndex, featureSubIndex, segmentIndex) {
//= previousSegment
//= currentSegment
//= segmentInex
//= featureIndex
//= featureSubIndex
//= segmentInex
return currentSegment

@@ -652,6 +646,8 @@ });

# lineEachCallback
## lineEachCallback
Callback for lineEach
Type: [Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)
**Parameters**

@@ -662,6 +658,4 @@

- `lineSubIndex` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** The sub-index of the current line being processed at index 0
- `geojson`
- `callback`
# lineEach
## lineEach

@@ -690,3 +684,3 @@ Iterate over line or ring coordinates in LineString, Polygon, MultiLineString, MultiPolygon Features or Geometries,

# lineReduceCallback
## lineReduceCallback

@@ -708,5 +702,7 @@ Callback for lineReduce

Type: [Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)
**Parameters**
- `previousValue` **Any** The accumulated value previously returned in the last invocation
- `previousValue` **any** The accumulated value previously returned in the last invocation
of the callback, or initialValue, if supplied.

@@ -717,7 +713,4 @@ - `currentLine` **[Feature](http://geojson.org/geojson-spec.html#feature-objects)&lt;[LineString](http://geojson.org/geojson-spec.html#linestring)>** The current LineString|LinearRing being processed.

- `lineSubIndex` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** The sub-index of the current line being processed at index 0
- `geojson`
- `callback`
- `initialValue`
# lineReduce
## lineReduce

@@ -730,3 +723,3 @@ Reduce features in any GeoJSON object, similar to Array.reduce().

- `callback` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** a method that takes (previousValue, currentFeature, featureIndex)
- `initialValue` **\[Any]** Value to use as the first argument to the first call of the callback.
- `initialValue` **any?** Value to use as the first argument to the first call of the callback.

@@ -750,3 +743,3 @@ **Examples**

Returns **Any** The value that results from the reduction.
Returns **any** The value that results from the reduction.

@@ -753,0 +746,0 @@ <!-- This file is automatically generated. Please don't edit it directly:

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc