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 4.7.3 to 4.7.4

index.es5.js

77

index.d.ts

@@ -9,3 +9,3 @@ /// <reference types="geojson" />

export type MultiPolygon = GeoJSON.MultiPolygon;
export type Features<Geom extends GeometryObject> = GeoJSON.FeatureCollection<Geom>;
export type FeatureCollection<Geom extends GeometryObject> = GeoJSON.FeatureCollection<Geom>;
export type Feature<Geom extends GeometryObject> = GeoJSON.Feature<Geom>;

@@ -16,3 +16,6 @@ export type GeometryObject = GeoJSON.GeometryObject;

export type Lines = LineString | Polygon | MultiLineString | MultiPolygon;
export type AllGeoJSON = Feature<any> | Features<any> | GeometryObject | GeometryCollection;
export type AllGeoJSON = Feature<any> | FeatureCollection<any> | GeometryObject | GeometryCollection;
export interface FeatureGeometryCollection extends GeoJSON.Feature<any> {
geometry: GeometryCollection;
}

@@ -23,5 +26,5 @@ /**

export function coordReduce<Reducer extends any>(
geojson: AllGeoJSON,
callback: (previousValue: Reducer, currentCoord: number[], coordIndex: number, featureIndex: number, featureSubIndex: number) => Reducer,
initialValue?: Reducer
geojson: AllGeoJSON,
callback: (previousValue: Reducer, currentCoord: number[], coordIndex: number, featureIndex: number, featureSubIndex: number) => Reducer,
initialValue?: Reducer
): Reducer;

@@ -33,4 +36,4 @@

export function coordEach(
geojson: AllGeoJSON,
callback: (currentCoord: number[], coordIndex: number, featureIndex: number, featureSubIndex: number) => void
geojson: AllGeoJSON,
callback: (currentCoord: number[], coordIndex: number, featureIndex: number, featureSubIndex: number) => void
): void;

@@ -42,4 +45,4 @@

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

@@ -51,5 +54,5 @@

export function propReduce<Reducer extends any, Props extends any>(
geojson: Feature<any> | Features<any>,
callback: (previousValue: Reducer, currentProperties: Props, featureIndex: number) => Reducer,
initialValue?: Reducer
geojson: Feature<any> | FeatureCollection<any>,
callback: (previousValue: Reducer, currentProperties: Props, featureIndex: number) => Reducer,
initialValue?: Reducer
): Reducer;

@@ -61,5 +64,5 @@

export function featureReduce<Reducer extends any, Geom extends GeometryObject>(
geojson: Feature<Geom> | Features<Geom>,
callback: (previousValue: Reducer, currentFeature: Feature<Geom>, featureIndex: number) => Reducer,
initialValue?: Reducer
geojson: Feature<Geom> | FeatureCollection<Geom> | FeatureGeometryCollection,
callback: (previousValue: Reducer, currentFeature: Feature<Geom>, featureIndex: number) => Reducer,
initialValue?: Reducer
): Reducer;

@@ -71,4 +74,4 @@

export function featureEach<Geom extends GeometryObject>(
geojson: Feature<Geom> | Features<Geom>,
callback: (currentFeature: Feature<Geom>, featureIndex: number) => void
geojson: Feature<Geom> | FeatureCollection<Geom> | FeatureGeometryCollection,
callback: (currentFeature: Feature<Geom>, featureIndex: number) => void
): void;

@@ -85,5 +88,5 @@

export function geomReduce<Reducer extends any, Geom extends GeometryObject>(
geojson: Feature<Geom> | Features<Geom> | Geom | GeometryCollection,
callback: (previousValue: Reducer, currentGeometry: Geom, featureIndex: number, currentProperties: any) => Reducer,
initialValue?: Reducer
geojson: Feature<Geom> | FeatureCollection<Geom> | Geom | GeometryCollection | FeatureGeometryCollection,
callback: (previousValue: Reducer, currentGeometry: Geom, featureIndex: number, currentProperties: any) => Reducer,
initialValue?: Reducer
): Reducer;

@@ -95,4 +98,4 @@

export function geomEach<Geom extends GeometryObject>(
geojson: Feature<Geom> | Features<Geom> | Geom | GeometryCollection,
callback: (currentGeometry: Geom, featureIndex: number, currentProperties: any) => void
geojson: Feature<Geom> | FeatureCollection<Geom> | Geom | GeometryCollection | FeatureGeometryCollection,
callback: (currentGeometry: Geom, featureIndex: number, currentProperties: any) => void
): void;

@@ -104,5 +107,5 @@

export function flattenReduce<Reducer extends any, Geom extends GeometryObject>(
geojson: Feature<Geom> | Features<Geom> | Geom | GeometryCollection,
callback: (previousValue: Reducer, currentFeature: Feature<Geom>, featureIndex: number, featureSubIndex: number) => Reducer,
initialValue?: Reducer
geojson: Feature<Geom> | FeatureCollection<Geom> | Geom | GeometryCollection | FeatureGeometryCollection,
callback: (previousValue: Reducer, currentFeature: Feature<Geom>, featureIndex: number, featureSubIndex: number) => Reducer,
initialValue?: Reducer
): Reducer;

@@ -114,4 +117,4 @@

export function flattenEach<Geom extends GeometryObject>(
geojson: Feature<Geom> | Features<Geom> | Geom | GeometryCollection,
callback: (currentFeature: Feature<Geom>, featureIndex: number, featureSubIndex: number) => void
geojson: Feature<Geom> | FeatureCollection<Geom> | Geom | GeometryCollection | FeatureGeometryCollection,
callback: (currentFeature: Feature<Geom>, featureIndex: number, featureSubIndex: number) => void
): void;

@@ -123,5 +126,5 @@

export function segmentReduce<Reducer extends any>(
geojson: Feature<any> | Features<any> | GeometryObject | GeometryCollection,
callback: (previousValue?: Reducer, currentSegment?: Feature<LineString>, featureIndex?: number, featureSubIndex?: number) => Reducer,
initialValue?: Reducer
geojson: Feature<any> | FeatureCollection<any> | GeometryObject | GeometryCollection | FeatureGeometryCollection,
callback: (previousValue?: Reducer, currentSegment?: Feature<LineString>, featureIndex?: number, featureSubIndex?: number, segmentIndex?: number) => Reducer,
initialValue?: Reducer
): Reducer;

@@ -133,4 +136,4 @@

export function segmentEach(
geojson: Feature<any> | Features<any> | GeometryObject | GeometryCollection,
allback: (currentSegment?: Feature<LineString>, featureIndex?: number, featureSubIndex?: number) => void
geojson: Feature<any> | FeatureCollection<any> | GeometryObject | GeometryCollection | FeatureGeometryCollection,
callback: (currentSegment?: Feature<LineString>, featureIndex?: number, featureSubIndex?: number, segmentIndex?: number) => void
): void;

@@ -142,5 +145,5 @@

export function lineReduce<Reducer extends any>(
geojson: Feature<Lines> | Lines,
callback: (previousValue?: Reducer, currentLine?: Feature<LineString>, featureIndex?: number, featureSubIndex?: number) => Reducer,
initialValue?: Reducer
geojson: Feature<Lines> | Lines,
callback: (previousValue?: Reducer, currentLine?: Feature<LineString>, featureIndex?: number, featureSubIndex?: number) => Reducer,
initialValue?: Reducer
): Reducer;

@@ -152,4 +155,4 @@

export function lineEach(
geojson: Feature<Lines> | Lines,
callback: (currentLine?: Feature<LineString>, featureIndex?: number, featureSubIndex?: number) => void
geojson: Feature<Lines> | Lines,
callback: (currentLine?: Feature<LineString>, featureIndex?: number, featureSubIndex?: number) => void
): void;

@@ -78,3 +78,3 @@ /**

*/
function coordEach(geojson, callback, excludeWrapCoord) {
export function coordEach(geojson, callback, excludeWrapCoord) {
// Handles null Geometry -- Skips this GeoJSON

@@ -105,4 +105,2 @@ if (geojson === null) return;

for (featureIndex = 0; featureIndex < stop; featureIndex++) {
var featureSubIndex = 0;
geometryMaybeCollection = (isFeatureCollection ? geojson.features[featureIndex].geometry :

@@ -114,2 +112,3 @@ (isFeature ? geojson.geometry : geojson));

for (geometryIndex = 0; geometryIndex < stopG; geometryIndex++) {
var featureSubIndex = 0;
geometry = isGeometryCollection ?

@@ -138,16 +137,19 @@ geometryMaybeCollection.geometries[geometryIndex] : geometryMaybeCollection;

coordIndex++;
featureSubIndex++;
if (geomType === 'MultiPoint') featureSubIndex++;
}
if (geomType === 'LineString') featureSubIndex++;
break;
case 'Polygon':
case 'MultiLineString':
for (j = 0; j < coords.length; j++)
for (j = 0; j < coords.length; j++) {
for (k = 0; k < coords[j].length - wrapShrink; k++) {
callback(coords[j][k], coordIndex, featureIndex, featureSubIndex);
coordIndex++;
featureSubIndex++;
}
if (geomType === 'MultiLineString') featureSubIndex++;
}
if (geomType === 'Polygon') featureSubIndex++;
break;
case 'MultiPolygon':
for (j = 0; j < coords.length; j++)
for (j = 0; j < coords.length; j++) {
for (k = 0; k < coords[j].length; k++)

@@ -157,4 +159,5 @@ for (l = 0; l < coords[j][k].length - wrapShrink; l++) {

coordIndex++;
featureSubIndex++;
}
featureSubIndex++;
}
break;

@@ -220,3 +223,3 @@ case 'GeometryCollection':

*/
function coordReduce(geojson, callback, initialValue, excludeWrapCoord) {
export function coordReduce(geojson, callback, initialValue, excludeWrapCoord) {
var previousValue = initialValue;

@@ -256,3 +259,3 @@ coordEach(geojson, function (currentCoord, coordIndex, featureIndex, featureSubIndex) {

*/
function propEach(geojson, callback) {
export function propEach(geojson, callback) {
var i;

@@ -317,3 +320,3 @@ switch (geojson.type) {

*/
function propReduce(geojson, callback, initialValue) {
export function propReduce(geojson, callback, initialValue) {
var previousValue = initialValue;

@@ -354,3 +357,3 @@ propEach(geojson, function (currentProperties, featureIndex) {

*/
function featureEach(geojson, callback) {
export function featureEach(geojson, callback) {
if (geojson.type === 'Feature') {

@@ -408,3 +411,3 @@ callback(geojson, 0);

*/
function featureReduce(geojson, callback, initialValue) {
export function featureReduce(geojson, callback, initialValue) {
var previousValue = initialValue;

@@ -433,3 +436,3 @@ featureEach(geojson, function (currentFeature, featureIndex) {

*/
function coordAll(geojson) {
export function coordAll(geojson) {
var coords = [];

@@ -470,3 +473,3 @@ coordEach(geojson, function (coord) {

*/
function geomEach(geojson, callback) {
export function geomEach(geojson, callback) {
var i, j, g, geometry, stopG,

@@ -509,3 +512,2 @@ geometryMaybeCollection,

callback(null, featureIndex, geometryProperties);
featureIndex++;
continue;

@@ -521,3 +523,2 @@ }

callback(geometry, featureIndex, geometryProperties);
featureIndex++;
break;

@@ -528,3 +529,2 @@ }

callback(geometry.geometries[j], featureIndex, geometryProperties);
featureIndex++;
}

@@ -537,2 +537,4 @@ break;

}
// Only increase `featureIndex` per each feature
featureIndex++;
}

@@ -586,3 +588,3 @@ }

*/
function geomReduce(geojson, callback, initialValue) {
export function geomReduce(geojson, callback, initialValue) {
var previousValue = initialValue;

@@ -626,3 +628,3 @@ geomEach(geojson, function (currentGeometry, currentIndex, currentProperties) {

*/
function flattenEach(geojson, callback) {
export function flattenEach(geojson, callback) {
geomEach(geojson, function (geometry, featureIndex, properties) {

@@ -712,3 +714,3 @@ // Callback for single geometry

*/
function flattenReduce(geojson, callback, initialValue) {
export function flattenReduce(geojson, callback, initialValue) {
var previousValue = initialValue;

@@ -727,5 +729,5 @@ flattenEach(geojson, function (currentFeature, featureIndex, featureSubIndex) {

* @param {Feature<LineString>} currentSegment The current segment being processed.
* @param {number} featureIndex The index of the current element being processed in the array, starts at index 0.
* @param {number} featureSubIndex The subindex of the current element being processed in the
* array. Starts at index 0 and increases for each iterating line segment.
* @param {number} featureIndex The featureIndex currently being processed, starts at index 0.
* @param {number} featureSubIndex The featureSubIndex currently being processed, starts at index 0.
* @param {number} segmentIndex The segmentIndex currently being processed, starts at index 0.
* @returns {void}

@@ -745,6 +747,7 @@ */

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

@@ -758,5 +761,6 @@ *

*/
function segmentEach(geojson, callback) {
flattenEach(geojson, function (feature, featureIndex) {
var featureSubIndex = 0;
export function segmentEach(geojson, callback) {
flattenEach(geojson, function (feature, featureIndex, featureSubIndex) {
var segmentIndex = 0;
// Exclude null Geometries

@@ -771,4 +775,4 @@ if (!feature.geometry) return;

var currentSegment = lineString([previousCoords, currentCoord], feature.properties);
callback(currentSegment, featureIndex, featureSubIndex);
featureSubIndex++;
callback(currentSegment, featureIndex, featureSubIndex, segmentIndex);
segmentIndex++;
return currentCoord;

@@ -797,6 +801,5 @@ });

* @param {Feature<LineString>} [currentSegment] The current segment being processed.
* @param {number} [currentIndex] 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.
* @param {number} [currentSubIndex] The subindex of the current element being processed in the
* array. Starts at index 0 and increases for each iterating line segment.
* @param {number} featureIndex The featureIndex currently being processed, starts at index 0.
* @param {number} featureSubIndex The featureSubIndex currently being processed, starts at index 0.
* @param {number} segmentIndex The segmentIndex currently being processed, starts at index 0.
*/

@@ -816,7 +819,8 @@

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

@@ -832,7 +836,9 @@ * });

*/
function segmentReduce(geojson, callback, initialValue) {
export function segmentReduce(geojson, callback, initialValue) {
var previousValue = initialValue;
segmentEach(geojson, function (currentSegment, currentIndex, currentSubIndex) {
if (currentIndex === 0 && initialValue === undefined) previousValue = currentSegment;
else previousValue = callback(previousValue, currentSegment, currentIndex, currentSubIndex);
var started = false;
segmentEach(geojson, function (currentSegment, featureIndex, featureSubIndex, segmentIndex) {
if (started === false && initialValue === undefined) previousValue = currentSegment;
else previousValue = callback(previousValue, currentSegment, featureIndex, featureSubIndex, segmentIndex);
started = true;
});

@@ -850,3 +856,3 @@ return previousValue;

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

@@ -869,3 +875,3 @@

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

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

*/
function lineEach(geojson, callback) {
export function lineEach(geojson, callback) {
// validation

@@ -992,3 +998,3 @@ if (!geojson) throw new Error('geojson is required');

*/
function lineReduce(geojson, callback, initialValue) {
export function lineReduce(geojson, callback, initialValue) {
var previousValue = initialValue;

@@ -1001,19 +1007,1 @@ lineEach(geojson, function (currentLine, lineIndex, lineSubIndex) {

}
module.exports = {
coordEach: coordEach,
coordReduce: coordReduce,
propEach: propEach,
propReduce: propReduce,
featureEach: featureEach,
featureReduce: featureReduce,
coordAll: coordAll,
geomEach: geomEach,
geomReduce: geomReduce,
flattenEach: flattenEach,
flattenReduce: flattenReduce,
segmentEach: segmentEach,
segmentReduce: segmentReduce,
lineEach: lineEach,
lineReduce: lineReduce
};
{
"name": "@turf/meta",
"version": "4.7.3",
"version": "4.7.4",
"description": "turf meta module",
"main": "index.js",
"main": "index.es5.js",
"module": "index.js",
"jsnext:main": "index.js",
"types": "index.d.ts",
"files": [
"index.js",
"index.d.ts"
"index.d.ts",
"index.es5.js"
],
"scripts": {
"test": "node test.js",
"pretest": "rollup -c ../../rollup.config.js",
"test": "node test.es5.js",
"bench": "node bench.js"
},
"repository": {
"type": "git",
"url": "git://github.com/Turfjs/turf.git"
},
"keywords": [

@@ -42,16 +50,14 @@ "functional",

"license": "MIT",
"repository": {
"type": "git",
"url": "git://github.com/Turfjs/turf.git"
},
"homepage": "https://github.com/Turfjs/turf",
"bugs": {
"url": "https://github.com/Turfjs/turf/issues"
},
"homepage": "https://github.com/Turfjs/turf",
"devDependencies": {
"@turf/helpers": "^4.7.3",
"@turf/random": "^4.7.3",
"benchmark": "2.1.4",
"tape": "4.8.0"
}
"@turf/helpers": "*",
"@turf/random": "*",
"benchmark": "*",
"rollup": "*",
"tape": "*"
},
"dependencies": {}
}

@@ -513,5 +513,5 @@ # @turf/meta

- `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 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 subindex of the current element being processed in the
array. Starts at index 0 and increases for each iterating line segment.
- `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`

@@ -540,2 +540,3 @@ - `callback`

//= currentSegment
//= segmentIndex
//= featureIndex

@@ -576,6 +577,5 @@ //= featureSubIndex

- `currentSegment` **\[[Feature](http://geojson.org/geojson-spec.html#feature-objects)&lt;[LineString](http://geojson.org/geojson-spec.html#linestring)>]** The current segment 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
array. Starts at index 0, if an initialValue is provided, and at index 1 otherwise.
- `currentSubIndex` **\[[number](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Number)]** The subindex of the current element being processed in the
array. Starts at index 0 and increases for each iterating line segment.
- `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`

@@ -602,7 +602,8 @@ - `callback`

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

@@ -609,0 +610,0 @@ });

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