Socket
Socket
Sign inDemoInstall

@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.2.0 to 6.0.0-beta.2

index.mjs

108

index.js

@@ -1,3 +0,7 @@

import { feature, point, lineString, isObject } from '@turf/helpers';
'use strict';
Object.defineProperty(exports, '__esModule', { value: true });
var helpers = require('@turf/helpers');
/**

@@ -36,3 +40,3 @@ * Callback for coordEach

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

@@ -184,3 +188,3 @@ if (geojson === null) return;

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

@@ -220,3 +224,3 @@ coordEach(geojson, function (currentCoord, coordIndex, featureIndex, multiFeatureIndex, geometryIndex) {

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

@@ -280,3 +284,3 @@ switch (geojson.type) {

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

@@ -317,3 +321,3 @@ propEach(geojson, function (currentProperties, featureIndex) {

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

@@ -370,3 +374,3 @@ callback(geojson, 0);

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

@@ -395,3 +399,3 @@ featureEach(geojson, function (currentFeature, featureIndex) {

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

@@ -436,3 +440,3 @@ coordEach(geojson, function (coord) {

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

@@ -556,3 +560,3 @@ geometryMaybeCollection,

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

@@ -594,3 +598,3 @@ geomEach(geojson, function (currentGeometry, featureIndex, featureProperties, featureBBox, featureId) {

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

@@ -604,3 +608,3 @@ // Callback for single geometry

case 'Polygon':
if (callback(feature(geometry, properties, {bbox: bbox, id: id}), featureIndex, 0) === false) return false;
if (callback(helpers.feature(geometry, properties, {bbox: bbox, id: id}), featureIndex, 0) === false) return false;
return;

@@ -630,3 +634,3 @@ }

};
if (callback(feature(geom, properties), featureIndex, multiFeatureIndex) === false) return false;
if (callback(helpers.feature(geom, properties), featureIndex, multiFeatureIndex) === false) return false;
}

@@ -680,3 +684,3 @@ });

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

@@ -727,10 +731,10 @@ flattenEach(geojson, function (currentFeature, featureIndex, multiFeatureIndex) {

*/
export function segmentEach(geojson, callback) {
flattenEach(geojson, function (feature, featureIndex, multiFeatureIndex) {
function segmentEach(geojson, callback) {
flattenEach(geojson, function (feature$$1, featureIndex, multiFeatureIndex) {
var segmentIndex = 0;
// Exclude null Geometries
if (!feature.geometry) return;
if (!feature$$1.geometry) return;
// (Multi)Point geometries do not contain segments therefore they are ignored during this operation.
var type = feature.geometry.type;
var type = feature$$1.geometry.type;
if (type === 'Point' || type === 'MultiPoint') return;

@@ -740,3 +744,3 @@

var previousCoords;
if (coordEach(feature, function (currentCoord, coordIndex, featureIndexCoord, mutliPartIndexCoord, geometryIndex) {
if (coordEach(feature$$1, function (currentCoord, coordIndex, featureIndexCoord, mutliPartIndexCoord, geometryIndex) {
// Simulating a meta.coordReduce() since `reduce` operations cannot be stopped by returning `false`

@@ -747,3 +751,3 @@ if (previousCoords === undefined) {

}
var currentSegment = lineString([previousCoords, currentCoord], feature.properties);
var currentSegment = helpers.lineString([previousCoords, currentCoord], feature$$1.properties);
if (callback(currentSegment, featureIndex, multiFeatureIndex, geometryIndex, segmentIndex) === false) return false;

@@ -809,3 +813,3 @@ segmentIndex++;

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

@@ -851,17 +855,17 @@ var started = false;

*/
export function lineEach(geojson, callback) {
function lineEach(geojson, callback) {
// validation
if (!geojson) throw new Error('geojson is required');
flattenEach(geojson, function (feature, featureIndex, multiFeatureIndex) {
if (feature.geometry === null) return;
var type = feature.geometry.type;
var coords = feature.geometry.coordinates;
flattenEach(geojson, function (feature$$1, featureIndex, multiFeatureIndex) {
if (feature$$1.geometry === null) return;
var type = feature$$1.geometry.type;
var coords = feature$$1.geometry.coordinates;
switch (type) {
case 'LineString':
if (callback(feature, featureIndex, multiFeatureIndex, 0, 0) === false) return false;
if (callback(feature$$1, featureIndex, multiFeatureIndex, 0, 0) === false) return false;
break;
case 'Polygon':
for (var geometryIndex = 0; geometryIndex < coords.length; geometryIndex++) {
if (callback(lineString(coords[geometryIndex], feature.properties), featureIndex, multiFeatureIndex, geometryIndex) === false) return false;
if (callback(helpers.lineString(coords[geometryIndex], feature$$1.properties), featureIndex, multiFeatureIndex, geometryIndex) === false) return false;
}

@@ -919,3 +923,3 @@ break;

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

@@ -963,6 +967,6 @@ lineEach(geojson, function (currentLine, featureIndex, multiFeatureIndex, geometryIndex) {

*/
export function findSegment(geojson, options) {
function findSegment(geojson, options) {
// Optional Parameters
options = options || {};
if (!isObject(options)) throw new Error('options is invalid');
if (!helpers.isObject(options)) throw new Error('options is invalid');
var featureIndex = options.featureIndex || 0;

@@ -1009,11 +1013,11 @@ var multiFeatureIndex = options.multiFeatureIndex || 0;

if (segmentIndex < 0) segmentIndex = coords.length + segmentIndex - 1;
return lineString([coords[segmentIndex], coords[segmentIndex + 1]], properties, options);
return helpers.lineString([coords[segmentIndex], coords[segmentIndex + 1]], properties, options);
case 'Polygon':
if (geometryIndex < 0) geometryIndex = coords.length + geometryIndex;
if (segmentIndex < 0) segmentIndex = coords[geometryIndex].length + segmentIndex - 1;
return lineString([coords[geometryIndex][segmentIndex], coords[geometryIndex][segmentIndex + 1]], properties, options);
return helpers.lineString([coords[geometryIndex][segmentIndex], coords[geometryIndex][segmentIndex + 1]], properties, options);
case 'MultiLineString':
if (multiFeatureIndex < 0) multiFeatureIndex = coords.length + multiFeatureIndex;
if (segmentIndex < 0) segmentIndex = coords[multiFeatureIndex].length + segmentIndex - 1;
return lineString([coords[multiFeatureIndex][segmentIndex], coords[multiFeatureIndex][segmentIndex + 1]], properties, options);
return helpers.lineString([coords[multiFeatureIndex][segmentIndex], coords[multiFeatureIndex][segmentIndex + 1]], properties, options);
case 'MultiPolygon':

@@ -1023,3 +1027,3 @@ if (multiFeatureIndex < 0) multiFeatureIndex = coords.length + multiFeatureIndex;

if (segmentIndex < 0) segmentIndex = coords[multiFeatureIndex][geometryIndex].length - segmentIndex - 1;
return lineString([coords[multiFeatureIndex][geometryIndex][segmentIndex], coords[multiFeatureIndex][geometryIndex][segmentIndex + 1]], properties, options);
return helpers.lineString([coords[multiFeatureIndex][geometryIndex][segmentIndex], coords[multiFeatureIndex][geometryIndex][segmentIndex + 1]], properties, options);
}

@@ -1062,6 +1066,6 @@ throw new Error('geojson is invalid');

*/
export function findPoint(geojson, options) {
function findPoint(geojson, options) {
// Optional Parameters
options = options || {};
if (!isObject(options)) throw new Error('options is invalid');
if (!helpers.isObject(options)) throw new Error('options is invalid');
var featureIndex = options.featureIndex || 0;

@@ -1104,17 +1108,17 @@ var multiFeatureIndex = options.multiFeatureIndex || 0;

case 'Point':
return point(coords, properties, options);
return helpers.point(coords, properties, options);
case 'MultiPoint':
if (multiFeatureIndex < 0) multiFeatureIndex = coords.length + multiFeatureIndex;
return point(coords[multiFeatureIndex], properties, options);
return helpers.point(coords[multiFeatureIndex], properties, options);
case 'LineString':
if (coordIndex < 0) coordIndex = coords.length + coordIndex;
return point(coords[coordIndex], properties, options);
return helpers.point(coords[coordIndex], properties, options);
case 'Polygon':
if (geometryIndex < 0) geometryIndex = coords.length + geometryIndex;
if (coordIndex < 0) coordIndex = coords[geometryIndex].length + coordIndex;
return point(coords[geometryIndex][coordIndex], properties, options);
return helpers.point(coords[geometryIndex][coordIndex], properties, options);
case 'MultiLineString':
if (multiFeatureIndex < 0) multiFeatureIndex = coords.length + multiFeatureIndex;
if (coordIndex < 0) coordIndex = coords[multiFeatureIndex].length + coordIndex;
return point(coords[multiFeatureIndex][coordIndex], properties, options);
return helpers.point(coords[multiFeatureIndex][coordIndex], properties, options);
case 'MultiPolygon':

@@ -1124,5 +1128,23 @@ if (multiFeatureIndex < 0) multiFeatureIndex = coords.length + multiFeatureIndex;

if (coordIndex < 0) coordIndex = coords[multiFeatureIndex][geometryIndex].length - coordIndex;
return point(coords[multiFeatureIndex][geometryIndex][coordIndex], properties, options);
return helpers.point(coords[multiFeatureIndex][geometryIndex][coordIndex], properties, options);
}
throw new Error('geojson is invalid');
}
exports.coordEach = coordEach;
exports.coordReduce = coordReduce;
exports.propEach = propEach;
exports.propReduce = propReduce;
exports.featureEach = featureEach;
exports.featureReduce = featureReduce;
exports.coordAll = coordAll;
exports.geomEach = geomEach;
exports.geomReduce = geomReduce;
exports.flattenEach = flattenEach;
exports.flattenReduce = flattenReduce;
exports.segmentEach = segmentEach;
exports.segmentReduce = segmentReduce;
exports.lineEach = lineEach;
exports.lineReduce = lineReduce;
exports.findSegment = findSegment;
exports.findPoint = findPoint;
{
"name": "@turf/meta",
"version": "5.2.0",
"version": "6.0.0-beta.2",
"description": "turf meta module",
"main": "main.js",
"module": "main.es.js",
"main": "index",
"types": "index.d.ts",
"files": [
"index.js",
"index.d.ts",
"main.js",
"main.es.js"
"index.mjs",
"index.d.ts"
],
"scripts": {
"pretest": "rollup -c ../../rollup.config.js",
"test": "node -r @std/esm test.js",
"posttest": "node -r @std/esm ../../scripts/validate-es5-dependencies.js",
"bench": "node -r @std/esm bench.js",
"pretest": "rollup -f cjs -i index.mjs -o index.js",
"test": "node test.js",
"posttest": "node ../../scripts/validate-es5-dependencies.js",
"bench": "node bench.js",
"docs": "node ../../scripts/generate-readmes"

@@ -66,3 +64,3 @@ },

"dependencies": {
"@turf/helpers": "^5.1.5"
"@turf/helpers": "6.0.0-beta.2"
},

@@ -69,0 +67,0 @@ "@std/esm": {

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