Mangler.getCloner() - DarthJDG/Mangler.js GitHub Wiki
Returns the cloning function for an object.
Mangler.getCloner(object)| Parameter | Type | Default | Description |
|---|---|---|---|
| object | Instance | An object instance or its constructor to get the cloning function for. |
Returns a cloning function in the form of function(object), or null if object is not clonable.
Gets a cloning function for any object that's supported by Mangler.js:
a = Mangler([1, 2, 3]);
func = Mangler.getCloner(a);
cloned_a = func ? func(a) : a;The above example is identical to:
a = Mangler([1, 2, 3]);
cloned_a = Mangler.clone(a);To check whether an object type is clonable:
isClonable = !!Mangler.getCloner(Date); // trueFor supported object types and to add support for other objects, see Mangler.registerType().