@bemoje/clone v1.0.1
@bemoje/clone
Deep and shallow clone.
Version
Travis CI
Dependencies
Stats
Donate
Installation
npm install @bemoje/clone
npm install --save @bemoje/clone
npm install --save-dev @bemoje/cloneUsage
import clone from '@bemoje/clone'
clone({ a: 2 })
//=> {a: 2}
clone.deep({ a: 2, b: [25, 2] })
//=> {a: 2, b: [25,2]}Tests
Uses Jest to test module functionality. Run tests to get coverage details.
npm run testAPI
Table of Contents
clone
Deep and shallow clone.
Merged forks of https://github.com/jonschlinkert/shallow-clone and https://github.com/jonschlinkert/clone-deep.
Parameters
- valueany The value to clone
- deepboolean Whether or not to do a deep clone (optional, default- false)
- instanceCloneboolean Whether or not to deep clone custom objects. (optional, default- true)
Array
Shallow clone an array.
Parameters
- arrArray
Returns Array
Object
Shallow clone an object.
Parameters
- objobject
Returns object
Date
Shallow clone a Date-object.
Parameters
- dateDate
Returns Date
Map
Shallow clone a Map object.
Parameters
- mapMap
Returns Map
Set
Shallow clone a Set.
Parameters
- setSet
Returns Set
Error
Shallow clone an Error object.
Parameters
- errError
Returns Error
RegExp
Shallow clone an RegExp object.
Parameters
- regexRegExp
Returns RegExp
ArrayBuffer
Shallow clone an ArrayBuffer.
Parameters
- arrBufArrayBuffer
Returns ArrayBuffer
TypedArray
Shallow clone a TypedArray
Parameters
- arrTypedTypedArray
Returns TypedArray
Buffer
Shallow clone a Buffer.
Parameters
- bufBuffer
Returns Buffer
Symbol
Shallow clone a Symbol.
Parameters
- symSymbol
Returns Symbol
deep
Deep clone a value
Parameters
- valueany The value to clone.
- instanceCloneboolean Whether or not to deep clone custom objects. (optional, default- true)
Returns any
6 years ago