shimondoodkin / nodejs-clone-extend Goto Github PK
View Code? Open in Web Editor NEWClone & extend / mixin for node js. It is easy to use and practical. supports circular references
Clone & extend / mixin for node js. It is easy to use and practical. supports circular references
try extend(res.locals, app.locals)
throws [TypeError: undefined is not a function]
https://developer.mozilla.org/en-US/docs/JavaScript/Reference/Global_Objects/Object/constructor
maybe to re review cloned object creation to add constructors
like to create an empty object with prototype in it a constructor from other object
then to fill in data. but there will be a problem of hidden fields
now this thing works only for plain objects. for others it might not work.
hi,
have you considered adding tests to cloneextend?
I'm using it quite extensively and would be happy to contribute.
It should overwrite properties of initial object with new ones, but it doesn't...
I tested clone()
, and it failed to duplicate these Objects:
They were usually converted to vanilla Object, sometimes with no properties.
Here is a sample test using RegExp:
let src10 = [1,2,/abc/,"foo"];
let dest10 = clone(src10, [object Object]);
dest10[3] = "BAR";
// src10: [ 1, 2, /abc/, 'foo' ]
// dest10: [ 1, 2, {}, 'BAR' ]
It also ignores any non-enumerable object properties.
simple tests done!
maybe to write extensive tests
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.