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
| 名称 | 类型 | 描述 |
|---|---|---|
| geojson | GeoJSON | GeoJSON 对象 |
返回
🌐 Returns
GeoJSON 克隆的 GeoJSON 对象
示例
🌐 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(...);