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

@turf/combine

Package Overview
Dependencies
Maintainers
6
Versions
60
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@turf/combine - npm Package Compare versions

Comparing version 6.3.0 to 6.4.0

66

dist/es/index.js

@@ -1,2 +0,2 @@

import { feature, featureCollection } from "@turf/helpers";
import { feature, featureCollection, } from "@turf/helpers";
import { featureEach } from "@turf/meta";

@@ -23,28 +23,46 @@ /**

var groups = {
MultiPoint: { coordinates: [], properties: [] },
MultiLineString: { coordinates: [], properties: [] },
MultiPolygon: { coordinates: [], properties: [] },
MultiPoint: {
coordinates: [],
properties: [],
},
MultiLineString: {
coordinates: [],
properties: [],
},
MultiPolygon: {
coordinates: [],
properties: [],
},
};
var multiMapping = Object.keys(groups).reduce(function (memo, item) {
memo[item.replace("Multi", "")] = item;
return memo;
}, {});
function addToGroup(feature, key, multi) {
if (!multi) {
groups[key].coordinates.push(feature.geometry.coordinates);
}
else {
groups[key].coordinates = groups[key].coordinates.concat(feature.geometry.coordinates);
}
groups[key].properties.push(feature.properties);
}
featureEach(fc, function (feature) {
if (!feature.geometry)
return;
if (groups[feature.geometry.type]) {
addToGroup(feature, feature.geometry.type, true);
var _a, _b, _c;
var _d;
switch ((_d = feature.geometry) === null || _d === void 0 ? void 0 : _d.type) {
case "Point":
groups.MultiPoint.coordinates.push(feature.geometry.coordinates);
groups.MultiPoint.properties.push(feature.properties);
break;
case "MultiPoint":
(_a = groups.MultiPoint.coordinates).push.apply(_a, feature.geometry.coordinates);
groups.MultiPoint.properties.push(feature.properties);
break;
case "LineString":
groups.MultiLineString.coordinates.push(feature.geometry.coordinates);
groups.MultiLineString.properties.push(feature.properties);
break;
case "MultiLineString":
(_b = groups.MultiLineString.coordinates).push.apply(_b, feature.geometry.coordinates);
groups.MultiLineString.properties.push(feature.properties);
break;
case "Polygon":
groups.MultiPolygon.coordinates.push(feature.geometry.coordinates);
groups.MultiPolygon.properties.push(feature.properties);
break;
case "MultiPolygon":
(_c = groups.MultiPolygon.coordinates).push.apply(_c, feature.geometry.coordinates);
groups.MultiPolygon.properties.push(feature.properties);
break;
default:
break;
}
else if (multiMapping[feature.geometry.type]) {
addToGroup(feature, multiMapping[feature.geometry.type], false);
}
});

@@ -51,0 +69,0 @@ return featureCollection(Object.keys(groups)

@@ -0,1 +1,2 @@

import { MultiLineString, MultiPoint, MultiPolygon } from "@turf/helpers";
import { Point, LineString, Polygon, FeatureCollection } from "@turf/helpers";

@@ -20,8 +21,10 @@ /**

*/
declare function combine(fc: FeatureCollection<Point | LineString | Polygon>): FeatureCollection<{
type: string;
coordinates: any;
declare function combine(fc: FeatureCollection<Point | MultiPoint | LineString | MultiLineString | Polygon | MultiPolygon>): FeatureCollection<{
type: "MultiPoint" | "MultiLineString" | "MultiPolygon";
coordinates: number[][] | number[][][] | number[][][][];
}, {
collectedProperties: any;
collectedProperties: {
[name: string]: any;
}[];
}>;
export default combine;

@@ -25,28 +25,46 @@ "use strict";

var groups = {
MultiPoint: { coordinates: [], properties: [] },
MultiLineString: { coordinates: [], properties: [] },
MultiPolygon: { coordinates: [], properties: [] },
MultiPoint: {
coordinates: [],
properties: [],
},
MultiLineString: {
coordinates: [],
properties: [],
},
MultiPolygon: {
coordinates: [],
properties: [],
},
};
var multiMapping = Object.keys(groups).reduce(function (memo, item) {
memo[item.replace("Multi", "")] = item;
return memo;
}, {});
function addToGroup(feature, key, multi) {
if (!multi) {
groups[key].coordinates.push(feature.geometry.coordinates);
}
else {
groups[key].coordinates = groups[key].coordinates.concat(feature.geometry.coordinates);
}
groups[key].properties.push(feature.properties);
}
meta_1.featureEach(fc, function (feature) {
if (!feature.geometry)
return;
if (groups[feature.geometry.type]) {
addToGroup(feature, feature.geometry.type, true);
var _a, _b, _c;
var _d;
switch ((_d = feature.geometry) === null || _d === void 0 ? void 0 : _d.type) {
case "Point":
groups.MultiPoint.coordinates.push(feature.geometry.coordinates);
groups.MultiPoint.properties.push(feature.properties);
break;
case "MultiPoint":
(_a = groups.MultiPoint.coordinates).push.apply(_a, feature.geometry.coordinates);
groups.MultiPoint.properties.push(feature.properties);
break;
case "LineString":
groups.MultiLineString.coordinates.push(feature.geometry.coordinates);
groups.MultiLineString.properties.push(feature.properties);
break;
case "MultiLineString":
(_b = groups.MultiLineString.coordinates).push.apply(_b, feature.geometry.coordinates);
groups.MultiLineString.properties.push(feature.properties);
break;
case "Polygon":
groups.MultiPolygon.coordinates.push(feature.geometry.coordinates);
groups.MultiPolygon.properties.push(feature.properties);
break;
case "MultiPolygon":
(_c = groups.MultiPolygon.coordinates).push.apply(_c, feature.geometry.coordinates);
groups.MultiPolygon.properties.push(feature.properties);
break;
default:
break;
}
else if (multiMapping[feature.geometry.type]) {
addToGroup(feature, multiMapping[feature.geometry.type], false);
}
});

@@ -53,0 +71,0 @@ return helpers_1.featureCollection(Object.keys(groups)

{
"name": "@turf/combine",
"version": "6.3.0",
"version": "6.4.0",
"description": "turf combine module",

@@ -58,6 +58,6 @@ "author": "Turf Authors",

"dependencies": {
"@turf/helpers": "^6.3.0",
"@turf/meta": "^6.3.0"
"@turf/helpers": "^6.4.0",
"@turf/meta": "^6.4.0"
},
"gitHead": "57c8877e1e2d67effc2cdd23385c02b2a6615a49"
"gitHead": "1e62773cfc88c627cca8effcb5c14cfb65a905ac"
}
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