Removes all recursive references in a object
import preventObjectRecursion from '@rxluz/prevent-object-recursion' const a = { hello: 'world' } const b = { hey: 'hey', hello: a } a.newProp = b console.log(preventObjectRecursion(a)) // => { hello: 'world', newProp: { hey: 'hey' }}
const preventObjectRecursion = require('@rxluz/prevent-object-recursion').default; const a = { hello: 'world' } const b = { hey: 'hey', hello: a } a.newProp = b console.log(preventObjectRecursion(a)) // => { hello: 'world', newProp: { hey: 'hey' }}
Works in the browser as well as node.
Returns a new object without the recursive references.
Generated using TypeDoc
Removes all recursive references in a object
Example (es module)
import preventObjectRecursion from '@rxluz/prevent-object-recursion' const a = { hello: 'world' } const b = { hey: 'hey', hello: a } a.newProp = b console.log(preventObjectRecursion(a)) // => { hello: 'world', newProp: { hey: 'hey' }}
Example (commonjs)
const preventObjectRecursion = require('@rxluz/prevent-object-recursion').default; const a = { hello: 'world' } const b = { hey: 'hey', hello: a } a.newProp = b console.log(preventObjectRecursion(a)) // => { hello: 'world', newProp: { hey: 'hey' }}
Works in the browser as well as node.