Skip to content

Utility for generic shallow copies and instances creation.

License

Notifications You must be signed in to change notification settings

WebReflection/newtility

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

newtility build status

Utility for generic shallow copies and instances creation.

Available in npm through npm install newtility.

node example

var New = require('newtility');

var object = New(Constructor[, args])

Create an instance of Constructor using the optional Array object args as list of arguments.

// simulating new Array(1, 2, 3)
var ott = New(Array, [1, 2, 3]);

// simulating new Uint32Array([4, 5, 6]);
var ui32 = New(Uint32Array, [ [4, 5, 6] ]);

var copy = New(object);

Create a shallow copy of a generic object.

var a = [1, 2, 3];
var b = New(a);

a !== b;                // true
a.join() === b.join();  // true

About

Utility for generic shallow copies and instances creation.

Resources

License

Stars

Watchers

Forks

Packages

No packages published