Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New module @turf/clone #780

Closed
DenisCarriere opened this issue Jun 6, 2017 · 1 comment
Closed

New module @turf/clone #780

DenisCarriere opened this issue Jun 6, 2017 · 1 comment
Assignees
Milestone

Comments

@DenisCarriere
Copy link
Member

DenisCarriere commented Jun 6, 2017

New module proposal @turf/clone

Noticed when we want to prevent input mutation we typically do the following:

geojson = JSON.parse(JSON.stringify(geojson));

However, most of the times we only need to clone the coordinates since that's the only thing that might be mutated.

Using coordinates.slice() vs. the JSON parse & stringify combo is about 8x times faster which can increase the performance of a "mutating" module/operation from 50,000 ops/sec to 400,000 ops/sec.

Expected Example

var clone = require('@turf/clone');
geojson = clone(geojson);

Ref: https://developers.google.com/web/updates/2017/06/object-rest-spread

@DenisCarriere DenisCarriere added this to the 4.5.0 milestone Jun 6, 2017
@DenisCarriere
Copy link
Member Author

Being implemented via PR #824

@DenisCarriere DenisCarriere self-assigned this Jun 30, 2017
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant