Skip to content

rxluz/prevent-object-recursion

Folders and files

NameName
Last commit message
Last commit date

Latest commit

48eb4c0 · Feb 19, 2019

History

43 Commits
Feb 10, 2019
Feb 10, 2019
Feb 10, 2019
Feb 12, 2019
Feb 10, 2019
Feb 10, 2019
Feb 10, 2019
Feb 10, 2019
Feb 10, 2019
Feb 10, 2019
Feb 12, 2019
Feb 10, 2019
Feb 19, 2019
Feb 10, 2019
Feb 12, 2019
Feb 12, 2019
Feb 10, 2019
Feb 10, 2019
Feb 10, 2019

Repository files navigation

@rxluz/prevent-object-recursion Tweet

➰ Remove all recursive references from the object

Build Status codecov Commitizen friendly

Usage

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)

var 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' }}

Install

With npm installed, run

$ npm i @rxluz/prevent-object-recursion --save

Acknowledgments

  • This project was inspired by a chat in NodeJS Brasil Telegram Group.
  • rxluz

See Also

License

MIT