@bemoje/clone

    1.0.1 • Public • Published

    @bemoje/clone

    Deep and shallow clone.

    Version

    NPM version

    Travis CI

    dependencies

    Dependencies

    dependencies

    Stats

    NPM downloads Forks

    Donate

    Buy Me A Beer donate button PayPal donate button

    Installation

    npm install @bemoje/clone
    npm install --save @bemoje/clone
    npm install --save-dev @bemoje/clone

    Usage

     
    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 test

    API

    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
    • value any The value to clone

    • deep boolean Whether or not to do a deep clone (optional, default false)

    • instanceClone boolean Whether or not to deep clone custom objects. (optional, default true)

    Array

    Shallow clone an array.

    Parameters

    Returns Array

    Object

    Shallow clone an object.

    Parameters

    Returns object

    Date

    Shallow clone a Date-object.

    Parameters

    Returns Date

    Map

    Shallow clone a Map object.

    Parameters

    Returns Map

    Set

    Shallow clone a Set.

    Parameters

    Returns Set

    Error

    Shallow clone an Error object.

    Parameters

    Returns Error

    RegExp

    Shallow clone an RegExp object.

    Parameters

    Returns RegExp

    ArrayBuffer

    Shallow clone an ArrayBuffer.

    Parameters

    Returns ArrayBuffer

    TypedArray

    Shallow clone a TypedArray

    Parameters

    Returns TypedArray

    Buffer

    Shallow clone a Buffer.

    Parameters

    Returns Buffer

    Symbol

    Shallow clone a Symbol.

    Parameters

    Returns Symbol

    deep

    Deep clone a value

    Parameters
    • value any The value to clone.

    • instanceClone boolean Whether or not to deep clone custom objects. (optional, default true)

    Returns any

    Install

    npm i @bemoje/clone

    DownloadsWeekly Downloads

    1

    Version

    1.0.1

    License

    MIT

    Unpacked Size

    18.6 kB

    Total Files

    5

    Last publish

    Collaborators

    • avatar