Skip to main content
Version: Next

clone

Description

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.

Parameters

NameTypeDescription
geojsonGeoJSONGeoJSON Object

Returns

Examples

var line = turf.lineString(
[
[-74, 40],
[-78, 42],
[-82, 35],
],
{ color: "red" },
);

var lineCloned = turf.clone(line);

Installation

$ npm install @turf/clone

import { clone } from "@turf/clone";
const result = clone(...);
$ npm install @turf/turf

import * as turf from "@turf/turf";
const result = turf.clone(...);