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.2 to 5.0.4

20

index.d.ts

@@ -41,3 +41,3 @@ import {

export function propEach<Props extends Properties>(
geojson: Feature<any> | FeatureCollection<any>,
geojson: Feature<any> | FeatureCollection<any> | FeatureGeometryCollection,
callback: (currentProperties: Props, featureIndex: number) => void

@@ -50,3 +50,3 @@ ): void;

export function propReduce<Reducer extends any, Props extends Properties>(
geojson: Feature<any> | FeatureCollection<any>,
geojson: Feature<any> | FeatureCollection<any> | FeatureGeometryCollection,
callback: (previousValue: Reducer, currentProperties: Props, featureIndex: number) => Reducer,

@@ -141,4 +141,4 @@ initialValue?: Reducer

*/
export function lineReduce<Reducer extends any, Geom extends LineString | MultiLineString | Polygon | MultiPolygon>(
geojson: Feature<Geom> | Geom,
export function lineReduce<Reducer extends any>(
geojson: AllGeoJSON,
callback: (previousValue?: Reducer, currentLine?: Feature<LineString>, featureIndex?: number, featureSubIndex?: number, lineIndex?: number) => Reducer,

@@ -151,5 +151,13 @@ initialValue?: Reducer

*/
export function lineEach<Geom extends LineString | MultiLineString | Polygon | MultiPolygon>(
geojson: Feature<Geom> | Geom,
export function lineEach<T extends LineString | MultiLineString | Polygon | MultiPolygon>(
geojson: Feature<T> | T,
callback: (currentLine?: Feature<LineString>, featureIndex?: number, featureSubIndex?: number, lineIndex?: number) => void
): void;
export function lineEach<Feat extends Feature<LineString>>(
geojson: Feat | ExtendedFeatureCollection<Feat>,
callback: (currentLine?: Feat, featureIndex?: number, featureSubIndex?: number, lineIndex?: number) => void
): void;
export function lineEach<Feat extends Feature<MultiLineString | Polygon | MultiPolygon>>(
geojson: Feat | ExtendedFeatureCollection<Feat>,
callback: (currentLine?: Feature<LineString>, featureIndex?: number, featureSubIndex?: number, lineIndex?: number) => void
): void;

@@ -401,3 +401,3 @@ 'use strict';

* array. Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
* @param {object} featureProperties The current feature properties being processed.
* @param {Object} featureProperties The current feature properties being processed.
* @param {Array<number>} featureBBox The current feature BBox being processed.

@@ -879,7 +879,8 @@ * @param {number|string} featureId The current feature Id being processed.

*
* turf.lineReduce(mtp, function (previousValue, currentLine, lineIndex, lineSubIndex) {
* turf.lineReduce(mtp, function (previousValue, currentLine, featureIndex, featureSubIndex, lineIndex) {
* //=previousValue
* //=currentLine
* //=featureIndex
* //=featureSubIndex
* //=lineIndex
* //=lineSubIndex
* return currentLine

@@ -890,5 +891,5 @@ * }, 2);

var previousValue = initialValue;
lineEach(geojson, function (currentLine, lineIndex, lineSubIndex) {
if (lineIndex === 0 && initialValue === undefined) previousValue = currentLine;
else previousValue = callback(previousValue, currentLine, lineIndex, lineSubIndex);
lineEach(geojson, function (currentLine, featureIndex, featureSubIndex, lineIndex) {
if (featureIndex === 0 && initialValue === undefined) previousValue = currentLine;
else previousValue = callback(previousValue, currentLine, featureIndex, featureSubIndex, lineIndex);
});

@@ -895,0 +896,0 @@ return previousValue;

{
"name": "@turf/meta",
"version": "5.0.2",
"version": "5.0.4",
"description": "turf meta module",

@@ -15,4 +15,4 @@ "main": "main",

"scripts": {
"pretest": "rollup -c ../../rollup.config.js",
"test": "node -r @std/esm test.js",
"posttest": "rollup -c ../../rollup.config.js",
"bench": "node -r @std/esm bench.js"

@@ -58,10 +58,10 @@ },

"devDependencies": {
"@turf/random": "*",
"@std/esm": "*",
"@turf/random": "^5.0.4",
"benchmark": "*",
"rollup": "*",
"tape": "*",
"@std/esm": "*"
"tape": "*"
},
"dependencies": {
"@turf/helpers": "^5.0.0"
"@turf/helpers": "^5.0.4"
},

@@ -68,0 +68,0 @@ "@std/esm": {

@@ -140,29 +140,2 @@ # @turf/meta

## 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

@@ -198,6 +171,19 @@

## featureEachCallback
## propReduceCallback
Callback for featureEach
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)

@@ -207,3 +193,5 @@

- `currentFeature` **[Feature](http://geojson.org/geojson-spec.html#feature-objects)&lt;any>** The current feature being processed.
- `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

@@ -236,2 +224,14 @@ array.Starts at index 0, if an initialValue is provided, and at index 1 otherwise.

## featureEachCallback
Callback for featureEach
Type: [Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)
**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.
## featureReduceCallback

@@ -323,5 +323,7 @@

- `currentGeometry` **[Geometry](http://geojson.org/geojson-spec.html#geometry)** The current geometry being processed.
- `currentIndex` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** The index of the current element being processed in the
- `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.
- `currentProperties` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** The current feature properties being processed.
- `featureProperties` **[Object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object)** The current feature properties being processed.
- `featureBBox` **[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 feature BBox being processed.
- `featureId` **([number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number) \| [string](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String))** The current feature Id being processed.

@@ -626,4 +628,5 @@ ## geomEach

- `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.
- `lineIndex` **[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.
- `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
- `featureIndex` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** The feature index of the current element being processed in the array, starts at index 0.
- `featureSubIndex` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** The feature sub-index of the current line being processed at index 0
- `lineIndex` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** The current line being processed at index 0

@@ -638,3 +641,3 @@ ## lineEach

- `geojson` **([Geometry](http://geojson.org/geojson-spec.html#geometry) \| [Feature](http://geojson.org/geojson-spec.html#feature-objects)&lt;([LineString](http://geojson.org/geojson-spec.html#linestring) \| [Polygon](http://geojson.org/geojson-spec.html#polygon) \| [MultiLineString](http://geojson.org/geojson-spec.html#multilinestring) \| [MultiPolygon](http://geojson.org/geojson-spec.html#multipolygon))>)** object
- `callback` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** a method that takes (currentLine, lineIndex, lineSubIndex)
- `callback` **[Function](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function)** a method that takes (currentLine, featureIndex, featureSubIndex, lineIndex)

@@ -644,9 +647,11 @@ **Examples**

```javascript
var mtLn = turf.multiLineString([
turf.lineString([[26, 37], [35, 45]]),
turf.lineString([[36, 53], [38, 50], [41, 55]])
var multiLine = turf.multiLineString([
[[26, 37], [35, 45]],
[[36, 53], [38, 50], [41, 55]]
]);
turf.lineEach(mtLn, function (currentLine, lineIndex) {
turf.lineEach(multiLine, function (currentLine, featureIndex, featureSubIndex, lineIndex) {
//=currentLine
//=featureIndex
//=featureSubIndex
//=lineIndex

@@ -680,5 +685,5 @@ });

- `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.
- `lineIndex` **[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.
- `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
- `featureIndex` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** The feature index of the current element being processed in the array, starts at index 0.
- `featureSubIndex` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** The feature sub-index of the current line being processed at index 0
- `lineIndex` **[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)** The current line being processed at index 0

@@ -703,7 +708,8 @@ ## lineReduce

turf.lineReduce(mtp, function (previousValue, currentLine, lineIndex, lineSubIndex) {
turf.lineReduce(mtp, function (previousValue, currentLine, featureIndex, featureSubIndex, lineIndex) {
//=previousValue
//=currentLine
//=featureIndex
//=featureSubIndex
//=lineIndex
//=lineSubIndex
return currentLine

@@ -710,0 +716,0 @@ }, 2);

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