Skip to content
This repository has been archived by the owner on May 17, 2024. It is now read-only.

Like is-circular, but returns the path to the first circular reference found.

Notifications You must be signed in to change notification settings

cypress-io/what-is-circular

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

what-is-circular Build Status

Like is-circular, but returns the path to the first circular reference found.

Installation

npm install @cypress/what-is-circular

Usage

whatIsCircular(obj)

Returns an array that contains the path to the first circular reference found, or undefined if no circular reference is found.

Example

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

License

MIT

Thanks

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.

About

Like is-circular, but returns the path to the first circular reference found.

Resources

Code of conduct

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • JavaScript 100.0%