[go: nahoru, domu]

@webkrafters/clone-total
TypeScript icon, indicating that this package has built-in type declarations

1.0.1 • Public • Published

Clone Total

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

Built on of the lodash.clondeepwith 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<T>(
    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

Package Sidebar

Install

npm i @webkrafters/clone-total

Weekly Downloads

11

Version

1.0.1

License

MIT

Unpacked Size

8.16 kB

Total Files

7

Last publish

Collaborators

  • webkrafters