Skip to content

Commit

Permalink
Merge ec87f8b into 593c551
Browse files Browse the repository at this point in the history
  • Loading branch information
hildjj committed Jul 21, 2023
2 parents 593c551 + ec87f8b commit fe878c6
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 1 deletion.
2 changes: 1 addition & 1 deletion packages/cbor-web/dist/cbor.js

Large diffs are not rendered by default.

3 changes: 3 additions & 0 deletions packages/cbor/lib/tagged.js
Expand Up @@ -332,6 +332,9 @@ class Tagged {
*/
convert(converters) {
let f = (converters == null) ? undefined : converters[this.tag]
if (f === null) { // === is intentional. null has semantic meaning as above
return this
}
if (typeof f !== 'function') {
f = Tagged.TAGS[this.tag]
if (typeof f !== 'function') {
Expand Down
6 changes: 6 additions & 0 deletions packages/cbor/test/tagged.ava.js
Expand Up @@ -138,3 +138,9 @@ test('Typed Arrays', t => {
tag = new cbor.Tagged(73, Buffer.from('000100020003', 'hex'))
t.deepEqual(_toTypedArray(tag.value, tag), new Int16Array([1, 2, 3]))
})

test('null converter', t => {
const buf = Buffer.from('c100', 'hex');
t.deepEqual(cbor.decode(buf), new Date(0));
t.deepEqual(cbor.decode(buf, {tags: {1: null}}), new cbor.Tagged(1, 0));
})

0 comments on commit fe878c6

Please sign in to comment.