@f/clone-shallow

Create a shallow clone of an object or array

Stats

StarsIssuesVersionUpdatedCreatedSize
@f/clone-shallow
001.1.45 years ago6 years agoMinified + gzip package size for @f/clone-shallow in KB

Readme

clone-shallow

Build status Git tag NPM version Code style

Create a shallow clone of an object or array

Installation

$ npm install @f/clone-shallow

Usage

var clone = require('@f/clone-shallow')

var arr = [1, 2, 3, 4]
var newArr = clone(arr)

deepEqual(arr, newArr)
arr !== newArr

var obj = {a: 1, b: 2, c: 3}
var newObj = clone(obj)

deepEqual(obj, newObj)
obj !== newObj

API

cloneShallow(a)

  • a - The object or array to be cloned

Returns: A new object or array with identical contents to a.

License

MIT

If you find any bugs or have a feature request, please open an issue on github!

The npm package download data comes from npm's download counts api and package details come from npms.io.