You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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.
New module proposal
@turf/clone
Noticed when we want to prevent input mutation we typically do the following:
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
Ref: https://developers.google.com/web/updates/2017/06/object-rest-spread
The text was updated successfully, but these errors were encountered: