|
@lukeed05 | |||||
|
Introducing `klona` – a tiny (281B) and fast utility to deep clone Arrays, Objects, Dates, RegExps & more~!
It works in Node & all browsers, and so far it's the fastest version I've found.
GitHub: github.com/lukeed/klona
PS: @_developit totally inspired me to do this yesterday pic.twitter.com/IQRLi2D1MZ
|
||||||
|
||||||
|
Luke Edwards
@lukeed05
|
16. sij |
|
I'm _definitely_ going to be adding additional "modes" to `klona`. You may have seen me do this with other modules like `dimport`, `totalist`, `throttles`, etc... IMO this is a perfect fit.
Would love to hear your feedback on what I'm planning so far: github.com/lukeed/klona/i… pic.twitter.com/gvVtq5GNzM
|
||
|
|
||
|
Jose J. Breijo
@josebreijo
|
10. sij |
|
Hey @lukeed05 👋. Great work as always. Just curious: Since the cloning of objects relies on recursion, which depth should be the theorical limit before a stack overflow?
|
||
|
|
||
|
Luke Edwards
@lukeed05
|
10. sij |
|
Thank you, food question! I'll have to check when I'm back to a computer.
I know it depends on the browser/context you're in.
Will circle back
|
||
|
|
||
|
Hovhannes Babayan
@bhovhannes
|
10. sij |
|
Impressed with size!
Cloning Map and Set in this way is not supported in IE11
It creates a map/set but without items instead.
|
||
|
|
||
|
Luke Edwards
@lukeed05
|
10. sij |
|
Dang, TIL. That's a pretty useless Set/Map then. I can think of a few important libs that aren't aware of this either.
Don't usually do this, but think I'm going to play the "dead browser" card.
|
||
|
|
||
|
Paulus Schoutsen
@balloob
|
10. sij |
|
|
||
|
Luke Edwards
@lukeed05
|
10. sij |
|
Oo nice! 🍻 Are you saying you want it added to benchmark? I'm sure it'll be one of the faster items, but it'll definitely fail the validation step, so not sure how you feel about that
|
||
|
|
||
|
Andrea Giammarchi
@WebReflection
|
10. sij |
|
Cloning is a big word ... there are many things here not cloned:
* Symbols
* Accessors
* Not enumerable properties
* Inheritance
The lib looks great for some ad-hoc use case though, but I'd put caveats/limits/non-goals on top of the readme 👋
|
||
|
|
||
|
Luke Edwards
@lukeed05
|
10. sij |
|
For sure 👍 I had all these originally but stripped for common case. I'm planning on adding an opt-in mode/entry for complete support and docs describing the differences
|
||
|
|
||
|
Anton
@cocoanton
|
10. sij |
|
Great name since it means 'to clone' in Swedish 😄
|
||
|
|
||
|
Luke Edwards
@lukeed05
|
10. sij |
|
Haha yeah 😄 and the sheep for Dolly!
|
||
|
|
||