Latest Threat Research:Malicious dYdX Packages Published to npm and PyPI After Maintainer Compromise.Details
Socket
Book a DemoInstallSign in
Socket

clone-shallow

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

clone-shallow

Shallow clone objects and arrays, or return primitive values directly.

Source
npmnpm
Version
0.1.0
Version published
Weekly downloads
116
-49.78%
Maintainers
1
Weekly downloads
 
Created
Source

clone-shallow NPM version

Shallow clone objects and arrays, or return primitive values directly.

Install

Install with npm:

npm i clone-shallow --save-dev

Usage

clone(value);
  • value {*} The value to clone.
  • return {*} The cloned value.

Example

Arrays:

var a = ['a', 'b', 'c'];
var b = clone(a);
a = a.concat('new');

console.log('a:', a);
//=> a: [ 'a', 'b', 'c', 'new' ]

console.log('b:', b);
//=> b: [ 'a', 'b', 'c' ]

Objects:

var extend = require('xtend');
var a = {foo: 'alpha', bar: 'beta', baz: 'gamma'};
var b = cloneObject(a);
a = extend(a, {quux: 'delta'});

console.log('a:', a);
//=> a: { foo: 'alpha', bar: 'beta', baz: 'gamma', quux: 'delta' }
console.log('b:', b);
//=> b: { foo: 'alpha', bar: 'beta', baz: 'gamma' }

Also see:

Author

Jon Schlinkert

License

Copyright (c) 2014 Jon Schlinkert, contributors.
Released under the MIT license

This file was generated by verb-cli on June 30, 2014.

Keywords

clone

FAQs

Package last updated on 30 Jun 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts