Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@ipld/is-circular

Package Overview
Dependencies
Maintainers
3
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@ipld/is-circular - npm Package Compare versions

Comparing version 1.0.3 to 2.0.0

.github/workflows/mikeals-workflow.yml

21

index.js

@@ -7,10 +7,11 @@ var Node = require('./lib/node')

* checks whether the object is circular
* @param {object} obj - object to check circularity for
* @param {object} obj - object to check circularity for
* @param {Object<string, true>} ignore - dictionary who's keys will be ignored
* @return {Boolean} true if obj is circular, false if it is not
*/
function isCircular (CID, obj) {
function isCircular (obj, ignore={}) {
if (!(obj instanceof Object)) {
throw new TypeError('"obj" must be an object (or inherit from it)')
}
return _isCircular(CID, obj)
return _isCircular(obj, ignore)
}

@@ -21,7 +22,8 @@

* checks whether the object is circular
* @param {object} obj - object to check circularity for
* @param {Node} parentList - linked-list that contains all the object's parents
* @param {object} obj - object to check circularity for
* @param {Object<string, true>} ignore - dictionary who's keys will be ignored
* @param {Node} parentList - linked-list that contains all the object's parents
* @return {Boolean} true if obj is circular, false if it is not
*/
function _isCircular (CID, obj, parentList) {
function _isCircular (obj, ignore, parentList) {
parentList = new Node(obj, parentList)

@@ -31,6 +33,9 @@

for (var key in obj) {
if (ignore[key]) {
continue
}
var val = obj[key]
if (CID.asCID(val)) continue
if (val instanceof Object) {
if (parentList.contains(val) || _isCircular(CID, val, parentList)) {
if (parentList.contains(val) || _isCircular(val, ignore, parentList)) {
return true

@@ -37,0 +42,0 @@ }

{
"name": "@ipld/is-circular",
"version": "1.0.3",
"version": "2.0.0",
"description": "high-performance, zero-dependency circular reference check for objects (or arrays)",

@@ -11,6 +11,5 @@ "main": "index.js",

"is-circular": "github:tjmehta/is-circular#v1.0.1",
"jest": "^26.1.0",
"jest": "^23.2.0",
"matcha": "^0.7.0",
"multiformats": "^2.0.1",
"standard": "^14.3.4"
"standard": "^11.0.1"
},

@@ -17,0 +16,0 @@ "scripts": {

/* eslint-env jest */
const { CID } = require('multiformats').create()
const _isCircular = require('../')
const isCircular = (...args) => _isCircular(CID, ...args)
var isCircular = require('../')

@@ -7,0 +5,0 @@ describe('is-circular', function () {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc