Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

lutils-clone

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lutils-clone

Reliably and recursively clone javascript objects

  • 0.1.3
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
28
increased by211.11%
Maintainers
1
Weekly downloads
 
Created
Source

clone lutils-clone

Reliably and recursively clone javascript objects

API

clone([mixed], [[options]])

Clones an object, recursively.

import clone from 'lutils-clone'

var test = new class Test {}

var obj = {
    a: { b: 2 },
    test,
    fn: function() {}
}

var newObj = clone(obj)

newObj.a.b = 5 // 5
obj.a.b // 2
newObj.a === obj.a // false
newObj.test === test // false
newObj.test.__proto__ === test.__proto__ // true
newObj.fn === obj.fn // true

Advanced usage

Options

{
    // Decremented with each recursion for each nested object, halting the clone at 0
    // A halted clone will preserve references to any remaining values
    depth: 8,

    // Determines whether recursing will occur. When this type matches, it will be iterated over.
    types: { object: true, array: true }
    types: [ "object", "array" ] // Can also be an array of type strings
}

FAQs

Package last updated on 01 Jul 2016

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc