@ipld/dag-cbor
Advanced tools
Comparing version 6.0.15 to 7.0.0
@@ -74,6 +74,2 @@ 'use strict'; | ||
}); | ||
test('error on decoding undefined', () => { | ||
assert.throws(() => decode(multiformats.bytes.fromHex('f7')), /\Wundefined\W.*not supported/); | ||
assert.throws(() => decode(multiformats.bytes.fromHex('a2616161616162f7')), /\Wundefined\W.*not supported/); | ||
}); | ||
test('error on encoding IEEE 754 specials', () => { | ||
@@ -208,2 +204,13 @@ for (const special of [ | ||
}); | ||
test('sloppy decode: coerce undefined', () => { | ||
let encoded = multiformats.bytes.fromHex('f7'); | ||
let decoded = decode(encoded); | ||
same(null, decoded); | ||
encoded = multiformats.bytes.fromHex('a26362617af763666f6f63626172'); | ||
decoded = decode(encoded); | ||
same({ | ||
foo: 'bar', | ||
baz: null | ||
}, decoded); | ||
}); | ||
}); |
@@ -72,3 +72,3 @@ 'use strict'; | ||
allowIndefinite: false, | ||
allowUndefined: false, | ||
coerceUndefinedToNull: true, | ||
allowNaN: false, | ||
@@ -75,0 +75,0 @@ allowInfinity: false, |
@@ -74,6 +74,2 @@ 'use strict'; | ||
}); | ||
test('error on decoding undefined', () => { | ||
assert.throws(() => decode(multiformats.bytes.fromHex('f7')), /\Wundefined\W.*not supported/); | ||
assert.throws(() => decode(multiformats.bytes.fromHex('a2616161616162f7')), /\Wundefined\W.*not supported/); | ||
}); | ||
test('error on encoding IEEE 754 specials', () => { | ||
@@ -208,2 +204,13 @@ for (const special of [ | ||
}); | ||
test('sloppy decode: coerce undefined', () => { | ||
let encoded = multiformats.bytes.fromHex('f7'); | ||
let decoded = decode(encoded); | ||
same(null, decoded); | ||
encoded = multiformats.bytes.fromHex('a26362617af763666f6f63626172'); | ||
decoded = decode(encoded); | ||
same({ | ||
foo: 'bar', | ||
baz: null | ||
}, decoded); | ||
}); | ||
}); |
@@ -70,6 +70,2 @@ import { Buffer } from 'buffer'; | ||
}); | ||
test('error on decoding undefined', () => { | ||
assert.throws(() => decode(bytes.fromHex('f7')), /\Wundefined\W.*not supported/); | ||
assert.throws(() => decode(bytes.fromHex('a2616161616162f7')), /\Wundefined\W.*not supported/); | ||
}); | ||
test('error on encoding IEEE 754 specials', () => { | ||
@@ -204,2 +200,13 @@ for (const special of [ | ||
}); | ||
test('sloppy decode: coerce undefined', () => { | ||
let encoded = bytes.fromHex('f7'); | ||
let decoded = decode(encoded); | ||
same(null, decoded); | ||
encoded = bytes.fromHex('a26362617af763666f6f63626172'); | ||
decoded = decode(encoded); | ||
same({ | ||
foo: 'bar', | ||
baz: null | ||
}, decoded); | ||
}); | ||
}); |
@@ -47,3 +47,3 @@ import * as cborg from 'cborg'; | ||
allowIndefinite: false, | ||
allowUndefined: false, | ||
coerceUndefinedToNull: true, | ||
allowNaN: false, | ||
@@ -50,0 +50,0 @@ allowInfinity: false, |
@@ -70,6 +70,2 @@ import { Buffer } from 'buffer'; | ||
}); | ||
test('error on decoding undefined', () => { | ||
assert.throws(() => decode(bytes.fromHex('f7')), /\Wundefined\W.*not supported/); | ||
assert.throws(() => decode(bytes.fromHex('a2616161616162f7')), /\Wundefined\W.*not supported/); | ||
}); | ||
test('error on encoding IEEE 754 specials', () => { | ||
@@ -204,2 +200,13 @@ for (const special of [ | ||
}); | ||
test('sloppy decode: coerce undefined', () => { | ||
let encoded = bytes.fromHex('f7'); | ||
let decoded = decode(encoded); | ||
same(null, decoded); | ||
encoded = bytes.fromHex('a26362617af763666f6f63626172'); | ||
decoded = decode(encoded); | ||
same({ | ||
foo: 'bar', | ||
baz: null | ||
}, decoded); | ||
}); | ||
}); |
@@ -88,3 +88,3 @@ import * as cborg from 'cborg' | ||
allowIndefinite: false, | ||
allowUndefined: false, | ||
coerceUndefinedToNull: true, | ||
allowNaN: false, | ||
@@ -91,0 +91,0 @@ allowInfinity: false, |
{ | ||
"name": "@ipld/dag-cbor", | ||
"version": "6.0.15", | ||
"version": "7.0.0", | ||
"description": "JS implementation of DAG-CBOR", | ||
@@ -36,3 +36,3 @@ "main": "./cjs/index.js", | ||
"dependencies": { | ||
"cborg": "^1.5.4", | ||
"cborg": "^1.6.0", | ||
"multiformats": "^9.5.4" | ||
@@ -39,0 +39,0 @@ }, |
@@ -83,8 +83,2 @@ /* eslint-env mocha */ | ||
test('error on decoding undefined', () => { | ||
// encoded forms from the encode() test above | ||
assert.throws(() => decode(bytes.fromHex('f7')), /\Wundefined\W.*not supported/) | ||
assert.throws(() => decode(bytes.fromHex('a2616161616162f7')), /\Wundefined\W.*not supported/) | ||
}) | ||
test('error on encoding IEEE 754 specials', () => { | ||
@@ -176,2 +170,13 @@ for (const special of [NaN, Infinity, -Infinity]) { | ||
}) | ||
test('sloppy decode: coerce undefined', () => { | ||
// See https://github.com/ipld/js-dag-cbor/issues/44 for context on this | ||
let encoded = bytes.fromHex('f7') | ||
let decoded = decode(encoded) | ||
same(null, decoded) | ||
encoded = bytes.fromHex('a26362617af763666f6f63626172') | ||
decoded = decode(encoded) | ||
same({ foo: 'bar', baz: null }, decoded) | ||
}) | ||
}) |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
48090
1280
0
Updatedcborg@^1.6.0