Comments (3)
Makes sense. I will code up a proposal and let you know.
from deep-copy.
It's not just Map
and Set
, there are other object "types" that are being removed or mangled on the copy. These are the ones I have tested and found the results incorrect:
- RegExp (becomes empty {})
- Int8Array (becomes Object)
- Uint8Array (becomes Object)
- Uint8ClampedArray (becomes Object)
- Int16Array (becomes Object)
- Uint16Array (becomes Object)
- Int32Array (becomes Object)
- Uint32Array (becomes Object)
- Float32Array (becomes Object)
- Float64Array (becomes Object)
- BigInt64Array (becomes Object)
- BigUint64Array (becomes Object)
Example from my RegExp
test:
let src = [1, 2, /abc/, "foo"];
let dest = deepCopy(src);
dest10[3] = "BAR";
console.log(src); // [ 1, 2, /abc/, 'foo' ]
console.log(dest); // [ 1, 2, {}, 'BAR' ]
Also, it's not preserving non-enumerable properties on the copy. I suggest this could be a configurable option—that seems to be the common way to handle those in other modules.
I started a new module named deep-copy-all that handles these new object types. It includes a test suite to validate the handling of the new objects.
from deep-copy.
I'm not sure how similar cloning implementation for Map and Set would look like. Probably a separate module would be better, though I would be interested to see how it look like when ready.
from deep-copy.
Related Issues (1)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from deep-copy.