Like is-circular, but returns the path to the first circular reference found.
npm install @cypress/what-is-circularLike is-circular, but returns the path to the first circular reference found.
npm install @cypress/what-is-circular
whatIsCircular(obj)Returns an array that contains the path to the first circular reference found, or undefined if no circular reference is found.
``js
var whatIsCircular = require('@cypress/what-is-circular')
var circularObj = {
foo: 1,
bar: 2
}
// qux.baz is the circular reference
circularObj.qux = {
baz: circularObj
}
whatIsCircular(circularObj) // ['qux', 'baz']
var obj = {
foo: 1,
bar: 2,
qux: 3
}
whatIsCircular(obj) // undefined
`
Thanks to @tjmehta's is-circular for providing the tests and README for this project.
Thanks to @angus-c's just-is-circular` for contributing additional tests.