cborg 1.5.3 → 1.5.4

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,7 +1,6 @@
1
1
  'use strict';
2
2
 
3
3
  var chai = require('chai');
4
- var util = require('util');
5
4
  require('../cborg.js');
6
5
  var taglib = require('../taglib.js');
7
6
  var byteUtils = require('../lib/byte-utils.js');
@@ -56,7 +55,7 @@ describe('cbor/test-vectors', () => {
56
55
  if (typeof expected === 'string' && expected.startsWith('h\'')) {
57
56
  expected = byteUtils.fromHex(expected.replace(/(^h)'|('$)/g, ''));
58
57
  }
59
- it(`test vector #${ i }: ${ util.inspect(expected).replace(/\n\s*/g, '') }`, () => {
58
+ it(`test vector #${ i }: ${ inspect(expected).replace(/\n\s*/g, '') }`, () => {
60
59
  if (fixture.error) {
61
60
  assert.throws(() => decode.decode(u8a, { tags }), fixture.error);
62
61
  } else {
@@ -65,10 +64,10 @@ describe('cbor/test-vectors', () => {
65
64
  }
66
65
  let actual = decode.decode(u8a, { tags });
67
66
  if (typeof actual === 'bigint') {
68
- actual = util.inspect(actual);
67
+ actual = inspect(actual);
69
68
  }
70
69
  if (typeof expected === 'bigint') {
71
- expected = util.inspect(expected);
70
+ expected = inspect(expected);
72
71
  }
73
72
  assert.deepEqual(actual, expected);
74
73
  if (fixture.roundtrip) {
@@ -85,3 +84,15 @@ describe('cbor/test-vectors', () => {
85
84
  it.skip('encode w/ tags', () => {
86
85
  });
87
86
  });
87
+ function inspect(o) {
88
+ if (typeof o === 'string') {
89
+ return `'${ o }'`;
90
+ }
91
+ if (o instanceof Uint8Array) {
92
+ return `Uint8Array<${ o.join(',') }>`;
93
+ }
94
+ if (o == null || typeof o !== 'object') {
95
+ return String(o);
96
+ }
97
+ return JSON.stringify(o);
98
+ }
@@ -1,7 +1,6 @@
1
1
  'use strict';
2
2
 
3
3
  var chai = require('chai');
4
- var util = require('util');
5
4
  require('../cborg.js');
6
5
  var taglib = require('../taglib.js');
7
6
  var byteUtils = require('../lib/byte-utils.js');
@@ -56,7 +55,7 @@ describe('cbor/test-vectors', () => {
56
55
  if (typeof expected === 'string' && expected.startsWith('h\'')) {
57
56
  expected = byteUtils.fromHex(expected.replace(/(^h)'|('$)/g, ''));
58
57
  }
59
- it(`test vector #${ i }: ${ util.inspect(expected).replace(/\n\s*/g, '') }`, () => {
58
+ it(`test vector #${ i }: ${ inspect(expected).replace(/\n\s*/g, '') }`, () => {
60
59
  if (fixture.error) {
61
60
  assert.throws(() => decode.decode(u8a, { tags }), fixture.error);
62
61
  } else {
@@ -65,10 +64,10 @@ describe('cbor/test-vectors', () => {
65
64
  }
66
65
  let actual = decode.decode(u8a, { tags });
67
66
  if (typeof actual === 'bigint') {
68
- actual = util.inspect(actual);
67
+ actual = inspect(actual);
69
68
  }
70
69
  if (typeof expected === 'bigint') {
71
- expected = util.inspect(expected);
70
+ expected = inspect(expected);
72
71
  }
73
72
  assert.deepEqual(actual, expected);
74
73
  if (fixture.roundtrip) {
@@ -85,3 +84,15 @@ describe('cbor/test-vectors', () => {
85
84
  it.skip('encode w/ tags', () => {
86
85
  });
87
86
  });
87
+ function inspect(o) {
88
+ if (typeof o === 'string') {
89
+ return `'${ o }'`;
90
+ }
91
+ if (o instanceof Uint8Array) {
92
+ return `Uint8Array<${ o.join(',') }>`;
93
+ }
94
+ if (o == null || typeof o !== 'object') {
95
+ return String(o);
96
+ }
97
+ return JSON.stringify(o);
98
+ }
@@ -1,5 +1,4 @@
1
1
  import chai from 'chai';
2
- import { inspect } from 'util';
3
2
  import {
4
3
  decode,
5
4
  encode
@@ -81,4 +80,16 @@ describe('cbor/test-vectors', () => {
81
80
  }
82
81
  it.skip('encode w/ tags', () => {
83
82
  });
84
- });
83
+ });
84
+ function inspect(o) {
85
+ if (typeof o === 'string') {
86
+ return `'${ o }'`;
87
+ }
88
+ if (o instanceof Uint8Array) {
89
+ return `Uint8Array<${ o.join(',') }>`;
90
+ }
91
+ if (o == null || typeof o !== 'object') {
92
+ return String(o);
93
+ }
94
+ return JSON.stringify(o);
95
+ }
@@ -1,5 +1,4 @@
1
1
  import chai from 'chai';
2
- import { inspect } from 'util';
3
2
  import {
4
3
  decode,
5
4
  encode
@@ -81,4 +80,16 @@ describe('cbor/test-vectors', () => {
81
80
  }
82
81
  it.skip('encode w/ tags', () => {
83
82
  });
84
- });
83
+ });
84
+ function inspect(o) {
85
+ if (typeof o === 'string') {
86
+ return `'${ o }'`;
87
+ }
88
+ if (o instanceof Uint8Array) {
89
+ return `Uint8Array<${ o.join(',') }>`;
90
+ }
91
+ if (o == null || typeof o !== 'object') {
92
+ return String(o);
93
+ }
94
+ return JSON.stringify(o);
95
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cborg",
3
- "version": "1.5.3",
3
+ "version": "1.5.4",
4
4
  "description": "Fast CBOR with a focus on strictness",
5
5
  "main": "./cjs/cborg.js",
6
6
  "bin": {
@@ -14,7 +14,9 @@
14
14
  "build:types": "npm run build:copy && cd dist && tsc --build",
15
15
  "test:cjs": "npm run build && mocha dist/cjs/node-test/test-*.js dist/cjs/node-test/node-test-*.js",
16
16
  "test:node": "c8 --check-coverage --branches 100 --functions 100 --lines 100 mocha test/test-*.js test/node-test-*.js",
17
- "test:browser": "polendina --page --worker --serviceworker --cleanup dist/cjs/node-test/test-*.js",
17
+ "test:browser:cjs": "polendina --page --worker --serviceworker --cleanup dist/cjs/node-test/test-*.js",
18
+ "test:browser:esm": "polendina --page --worker --serviceworker --cleanup dist/esm/node-test/test-*.js",
19
+ "test:browser": "npm run test:browser:cjs && npm run test:browser:cjs",
18
20
  "test": "npm run lint && npm run test:node && npm run test:cjs && npm run test:browser",
19
21
  "coverage": "c8 --reporter=html mocha test/test-*.js && npx st -d coverage -p 8080"
20
22
  },
@@ -33,7 +35,7 @@
33
35
  "ipjs": "^5.0.0",
34
36
  "ipld-garbage": "^4.0.1",
35
37
  "mocha": "^9.0.0",
36
- "polendina": "^1.1.0",
38
+ "polendina": "^2.0.0",
37
39
  "standard": "^16.0.3",
38
40
  "typescript": "^4.2.4"
39
41
  },
@@ -1,7 +1,6 @@
1
1
  /* eslint-env mocha,es2020 */
2
2
 
3
3
  import chai from 'chai'
4
- import { inspect } from 'util'
5
4
 
6
5
  import { decode, encode } from '../cborg.js'
7
6
  import * as taglib from 'cborg/taglib'
@@ -93,3 +92,16 @@ describe('cbor/test-vectors', () => {
93
92
  it.skip('encode w/ tags', () => {
94
93
  })
95
94
  })
95
+
96
+ function inspect (o) {
97
+ if (typeof o === 'string') {
98
+ return `'${o}'`
99
+ }
100
+ if (o instanceof Uint8Array) {
101
+ return `Uint8Array<${o.join(',')}>`
102
+ }
103
+ if (o == null || typeof o !== 'object') {
104
+ return String(o)
105
+ }
106
+ return JSON.stringify(o)
107
+ }