Skip to main content
Version: 7.2.0

clone

描述

¥Description

返回所传递 GeoJSON 对象的克隆副本,包括可能的 '外来成员'。比常见的 JSON.parse + JSON.stringify 组合方法快 3-5 倍。

¥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

名称类型描述
geojsonGeoJSONGeoJSON 对象

返回

¥Returns

GeoJSON 克隆的 GeoJSON 对象

¥GeoJSON cloned GeoJSON Object

示例

¥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(...);