@ipld/dag-json
Advanced tools
Comparing version 3.0.11 to 3.0.12
11
index.js
import json from 'fast-json-stable-stringify' | ||
import isCircular from 'is-circular' | ||
import isCircular from '@ipld/is-circular' | ||
import transform from 'lodash.transform' | ||
@@ -8,4 +8,5 @@ | ||
const _encode = obj => transform(obj, (result, value, key) => { | ||
if (CID.isCID(value)) { | ||
result[key] = { '/': value.toString() } | ||
const cid = CID.asCID(value) | ||
if (cid) { | ||
result[key] = { '/': cid.toString() } | ||
} else if (bytes.isBinary(value)) { | ||
@@ -22,4 +23,4 @@ value = bytes.coerce(value) | ||
const encode = obj => { | ||
if (typeof obj === 'object' && !bytes.isBinary(obj) && !CID.isCID(obj) && obj) { | ||
if (isCircular(obj)) throw new Error('Object contains circular references.') | ||
if (typeof obj === 'object' && !bytes.isBinary(obj) && !CID.asCID(obj) && obj) { | ||
if (isCircular(CID, obj)) throw new Error('Object contains circular references.') | ||
obj = _encode(obj) | ||
@@ -26,0 +27,0 @@ } |
{ | ||
"name": "@ipld/dag-json", | ||
"version": "3.0.11", | ||
"version": "3.0.12", | ||
"description": "JSON Directed Acrylic Graph for IPLD", | ||
@@ -38,12 +38,12 @@ "main": "index.js", | ||
"mocha": "^8.0.1", | ||
"multiformats": "1.1.11", | ||
"multiformats": "2.0.1", | ||
"polendina": "^1.0.0", | ||
"rollup": "^2.18.0", | ||
"rollup": "^2.22.1", | ||
"standard": "^14.3.4" | ||
}, | ||
"dependencies": { | ||
"@ipld/is-circular": "^1.0.3", | ||
"fast-json-stable-stringify": "^2.1.0", | ||
"is-circular": "^1.0.2", | ||
"lodash.transform": "^4.6.0" | ||
} | ||
} |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
764855
190
+ Added@ipld/is-circular@^1.0.3
+ Added@ipld/is-circular@1.0.3(transitive)
- Removedis-circular@^1.0.2
- Removedis-circular@1.0.2(transitive)