Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

clone-total

steveswork14MIT1.0.0TypeScript support: included

DX Friendly wrapper for @webkrafters/clone-total package.

clone, clone deep, clone-deep, clone_deep, cloneDeep, clonedeep, clone node, clone-node, clone_node, cloneNode, clonenode, cloneable, clonable, deep copy, deep-copy, deep_copy, deepCopy, deepcopy

readme

Clone Total

Regular clonedeep including all instances implementing the clone and the cloneNode methods.

This is an unscoped version of the @webkrafters/clone-total package.

Install:\ npm i -S clone-total\ Alternate: npm i -S @webkrafters/clone-total

Regarding Class Instances Values

All cloned properties and values which are Instances of non-native classes not implementing either the clone or the cloneNode methods may not be cloneable. Such instances are retured uncloned. To clone these, a customizer argument function may be supplied. Please see Extended example below.

Example

import clone from 'clone-total'; 

clone( object ); // returns cloned object

Example (Extended)


function customizer(
    value : unknown,
    key? : number | string,
    object? : T,
    stack? : unknown
) {
    if( /* <your fallback condition> */ ) {
        return yourCloneAlgorithm( value, key, object, stack );
    }
    // or allow the normal course to continue.
};

clone( object, customizer );

License

MIT