2.2.0 • Published 2 years ago
just-is-circular v2.2.0
just-is-circular
Part of a library of zero-dependency npm modules that do just do one thing. Guilt-free utilities for every occasion.
npm install just-is-circular
yarn add just-is-circular
Return true if object has a circular reference NOTE: not supported in IE or microsoft edge
import isCircular from 'just-is-circular';
const a = {};
a.b = a;
isCircular(a); // true
const a = {};
a.b = {
c: a
};
isCircular(a); // true
const a = {};
a.b = {
c: 4
};
isCircular(a); // false
const a = [];
a.push(a);
isCircular(a); // true
isCircular({}); // false
isCircular('hi'); // false
isCircular(undefined); // false