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

@turf/clone

Package Overview
Dependencies
Maintainers
7
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@turf/clone - npm Package Compare versions

Comparing version 6.5.0 to 7.0.0-alpha.0

33

dist/es/index.js

@@ -42,5 +42,5 @@ /**

function cloneFeature(geojson) {
var cloned = { type: "Feature" };
const cloned = { type: "Feature" };
// Preserve Foreign Members
Object.keys(geojson).forEach(function (key) {
Object.keys(geojson).forEach((key) => {
switch (key) {

@@ -57,3 +57,8 @@ case "type":

cloned.properties = cloneProperties(geojson.properties);
cloned.geometry = cloneGeometry(geojson.geometry);
if (geojson.geometry == null) {
cloned.geometry = null;
}
else {
cloned.geometry = cloneGeometry(geojson.geometry);
}
return cloned;

@@ -69,8 +74,8 @@ }

function cloneProperties(properties) {
var cloned = {};
const cloned = {};
if (!properties) {
return cloned;
}
Object.keys(properties).forEach(function (key) {
var value = properties[key];
Object.keys(properties).forEach((key) => {
const value = properties[key];
if (typeof value === "object") {

@@ -83,3 +88,3 @@ if (value === null) {

// handle Array
cloned[key] = value.map(function (item) {
cloned[key] = value.map((item) => {
return item;

@@ -107,5 +112,5 @@ });

function cloneFeatureCollection(geojson) {
var cloned = { type: "FeatureCollection" };
const cloned = { type: "FeatureCollection" };
// Preserve Foreign Members
Object.keys(geojson).forEach(function (key) {
Object.keys(geojson).forEach((key) => {
switch (key) {

@@ -120,3 +125,3 @@ case "type":

// Add features
cloned.features = geojson.features.map(function (feature) {
cloned.features = geojson.features.map((feature) => {
return cloneFeature(feature);

@@ -134,3 +139,3 @@ });

function cloneGeometry(geometry) {
var geom = { type: geometry.type };
const geom = { type: geometry.type };
if (geometry.bbox) {

@@ -140,3 +145,3 @@ geom.bbox = geometry.bbox;

if (geometry.type === "GeometryCollection") {
geom.geometries = geometry.geometries.map(function (g) {
geom.geometries = geometry.geometries.map((g) => {
return cloneGeometry(g);

@@ -157,7 +162,7 @@ });

function deepSlice(coords) {
var cloned = coords;
const cloned = coords;
if (typeof cloned[0] !== "object") {
return cloned.slice();
}
return cloned.map(function (coord) {
return cloned.map((coord) => {
return deepSlice(coord);

@@ -164,0 +169,0 @@ });

@@ -14,3 +14,3 @@ import { AllGeoJSON } from "@turf/helpers";

*/
declare function clone(geojson: AllGeoJSON): any;
declare function clone<T extends AllGeoJSON>(geojson: T): T;
export default clone;

@@ -44,5 +44,5 @@ "use strict";

function cloneFeature(geojson) {
var cloned = { type: "Feature" };
const cloned = { type: "Feature" };
// Preserve Foreign Members
Object.keys(geojson).forEach(function (key) {
Object.keys(geojson).forEach((key) => {
switch (key) {

@@ -59,3 +59,8 @@ case "type":

cloned.properties = cloneProperties(geojson.properties);
cloned.geometry = cloneGeometry(geojson.geometry);
if (geojson.geometry == null) {
cloned.geometry = null;
}
else {
cloned.geometry = cloneGeometry(geojson.geometry);
}
return cloned;

@@ -71,8 +76,8 @@ }

function cloneProperties(properties) {
var cloned = {};
const cloned = {};
if (!properties) {
return cloned;
}
Object.keys(properties).forEach(function (key) {
var value = properties[key];
Object.keys(properties).forEach((key) => {
const value = properties[key];
if (typeof value === "object") {

@@ -85,3 +90,3 @@ if (value === null) {

// handle Array
cloned[key] = value.map(function (item) {
cloned[key] = value.map((item) => {
return item;

@@ -109,5 +114,5 @@ });

function cloneFeatureCollection(geojson) {
var cloned = { type: "FeatureCollection" };
const cloned = { type: "FeatureCollection" };
// Preserve Foreign Members
Object.keys(geojson).forEach(function (key) {
Object.keys(geojson).forEach((key) => {
switch (key) {

@@ -122,3 +127,3 @@ case "type":

// Add features
cloned.features = geojson.features.map(function (feature) {
cloned.features = geojson.features.map((feature) => {
return cloneFeature(feature);

@@ -136,3 +141,3 @@ });

function cloneGeometry(geometry) {
var geom = { type: geometry.type };
const geom = { type: geometry.type };
if (geometry.bbox) {

@@ -142,3 +147,3 @@ geom.bbox = geometry.bbox;

if (geometry.type === "GeometryCollection") {
geom.geometries = geometry.geometries.map(function (g) {
geom.geometries = geometry.geometries.map((g) => {
return cloneGeometry(g);

@@ -159,7 +164,7 @@ });

function deepSlice(coords) {
var cloned = coords;
const cloned = coords;
if (typeof cloned[0] !== "object") {
return cloned.slice();
}
return cloned.map(function (coord) {
return cloned.map((coord) => {
return deepSlice(coord);

@@ -166,0 +171,0 @@ });

{
"name": "@turf/clone",
"version": "6.5.0",
"version": "7.0.0-alpha.0",
"description": "turf clone module",

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

"test:tape": "ts-node -r esm test.js",
"test:types": "tsc --esModuleInterop --noEmit types.ts"
"test:types": "tsc --esModuleInterop --noEmit --strict types.ts"
},
"devDependencies": {
"@turf/meta": "^6.5.0",
"@turf/meta": "^7.0.0-alpha.0",
"@types/tape": "*",

@@ -62,5 +62,6 @@ "benchmark": "*",

"dependencies": {
"@turf/helpers": "^6.5.0"
"@turf/helpers": "^7.0.0-alpha.0",
"tslib": "^2.3.0"
},
"gitHead": "5375941072b90d489389db22b43bfe809d5e451e"
"gitHead": "0edc4c491b999e5ace770a61e1cf549f7c004189"
}

@@ -8,9 +8,9 @@ # @turf/clone

Returns a cloned copy of the passed GeoJSON Object, including possible 'Foreign Members'.
~3-5x faster than the common JSON.parse + JSON.stringify combo method.
\~3-5x faster than the common JSON.parse + JSON.stringify combo method.
**Parameters**
### Parameters
- `geojson` **[GeoJSON][1]** GeoJSON Object
* `geojson` **[GeoJSON][1]** GeoJSON Object
**Examples**
### Examples

@@ -17,0 +17,0 @@ ```javascript

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