@ipld/dag-cbor
Advanced tools
Comparing version 0.0.0 to 1.0.0
35
index.js
@@ -1,3 +0,3 @@ | ||
const cbor = require('borc') | ||
const isCircular = require('is-circular') | ||
import cbor from 'borc' | ||
import isCircular from 'is-circular' | ||
@@ -7,12 +7,9 @@ // https://github.com/ipfs/go-ipfs/issues/3570#issuecomment-273931692 | ||
module.exports = multiformats => { | ||
const code = 0x71 | ||
const name = 'dag-cbor' | ||
const create = multiformats => { | ||
const { CID, bytes, varint } = multiformats | ||
function tagCID (cid) { | ||
if (typeof cid === 'string') { | ||
cid = new CID(cid).buffer | ||
} else if (CID.isCID(cid)) { | ||
cid = cid.buffer | ||
} | ||
const buffer = Uint8Array.from([...bytes.fromHex('00'), ...cid]) | ||
const buffer = Uint8Array.from([...bytes.fromHex('00'), ...cid.buffer]) | ||
return new cbor.Tagged(CID_CBOR_TAG, buffer) | ||
@@ -22,9 +19,3 @@ } | ||
function replaceCIDbyTAG (dagNode) { | ||
let circular | ||
try { | ||
circular = isCircular(dagNode) | ||
} catch (e) { | ||
circular = false | ||
} | ||
if (circular) { | ||
if (isCircular(dagNode)) { | ||
throw new Error('The object passed has circular references') | ||
@@ -95,3 +86,3 @@ } | ||
const configureDecoder = (options) => { | ||
let tags = defaultTags | ||
const tags = defaultTags | ||
@@ -105,5 +96,2 @@ if (options) { | ||
} | ||
if (options.tags) { | ||
tags = Object.assign({}, defaultTags, options && options.tags) | ||
} | ||
} else { | ||
@@ -125,3 +113,3 @@ // no options, reset to defaults | ||
configureDecoder() | ||
module.exports.configureDecoder = configureDecoder // for testing | ||
create.configureDecoder = configureDecoder // for testing | ||
@@ -147,5 +135,4 @@ const encode = (node) => { | ||
const code = 0x71 | ||
const name = 'dag-cbor' | ||
return { encode, decode, code, name } | ||
} | ||
export default create |
{ | ||
"name": "@ipld/dag-cbor", | ||
"version": "0.0.0", | ||
"version": "1.0.0", | ||
"description": "JS implementation of dag-cbor", | ||
"main": "src/index.js", | ||
"type": "module", | ||
"scripts": { | ||
@@ -30,5 +31,5 @@ "test": "hundreds mocha test/test-*.js && npm run test:browser", | ||
"garbage": "0.0.0", | ||
"hundreds": "0.0.2", | ||
"mocha": "^7.1.2", | ||
"multiformats": "0.0.1", | ||
"hundreds": "0.0.4", | ||
"mocha": "^8.0.1", | ||
"multiformats": "1.0.7", | ||
"polendina": "^1.0.0", | ||
@@ -35,0 +36,0 @@ "standard": "^14.3.4" |
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
No v1
QualityPackage is not semver >=1. This means it is not stable and does not support ^ ranges.
Found 1 instance in 1 package
0
Yes
18071
6
112