@ipld/dag-json
Advanced tools
Comparing version 3.0.1 to 3.0.2
@@ -21,8 +21,7 @@ import json from 'fast-json-stable-stringify' | ||
const encode = obj => { | ||
if (typeof obj === 'object' && isCircular(obj)) { | ||
throw new Error('Object contains circular references.') | ||
if (typeof obj === 'object' && !bytes.isBinary(obj) && !CID.isCID(obj) && obj) { | ||
if (isCircular(obj)) throw new Error('Object contains circular references.') | ||
obj = _encode(obj) | ||
} | ||
const data = _encode(obj) | ||
return bytes.fromString(json(data)) | ||
return bytes.fromString(json(obj)) | ||
} | ||
@@ -29,0 +28,0 @@ |
{ | ||
"name": "@ipld/dag-json", | ||
"version": "3.0.1", | ||
"version": "3.0.2", | ||
"description": "JSON Directed Acrylic Graph for IPLD", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
14
test.js
@@ -47,2 +47,16 @@ 'use strict' | ||
}) | ||
test('native types', done => { | ||
const flip = obj => dag.decode(dag.encode(obj)) | ||
same(flip('test'), 'test') | ||
same(flip(null), null) | ||
same(flip(12), 12) | ||
same(flip(-1), -1) | ||
same(flip(1.2), 1.2) | ||
same(flip(true), true) | ||
same(flip(false), false) | ||
same(flip([]), []) | ||
same(flip(['asdf']), ['asdf']) | ||
done() | ||
}) | ||
}) |
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
6476
102