newtility

Utility for generic shallow copies and instances creation.

Usage no npm install needed!

<script type="module">
  import newtility from 'https://cdn.skypack.dev/newtility';
</script>

README

newtility

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.

var ott = New(Array, [1, 2, 3]);
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