Socket
Socket
Sign inDemoInstall

graph-clone

Package Overview
Dependencies
1
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    graph-clone

This module offers a traversal mechanic for circular data JSON structures that allows you to clone or skip cloning on nodes and also apply optional transforms to encountered nodes.


Version published
Weekly downloads
6
increased by200%
Maintainers
1
Install size
7.26 kB
Created
Weekly downloads
 

Readme

Source

Graph Clone

This module offers a traversal mechanic for circular data JSON structures that allows you to clone or skip cloning on nodes and also apply optional transforms to encountered nodes.

Example usage

See test.js for best illustrating example. Below is a dead simple version but the test is more exhaustive

var w = require('graph-clone')
var stringify = require('json-stringify-safe')
var obj = {
  foo: {
    name: 'boris',
    bar: null 
  }
}
obj.foo.bar = obj

var copy = w(obj, () => true, (obj, key, val) => key === 'name' ? val + '!!!' : val)

console.log(stringify(copy))

// copy = {
//   foo: {
//      name: 'boris!!!',
//      bar: [ circular ]
//   }
// }

Keywords

FAQs

Last updated on 29 Aug 2016

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc