cborg 1.5.0 → 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.
@@ -13,14 +13,14 @@ var chai__default = /*#__PURE__*/_interopDefaultLegacy(chai);
13
13
  var process__default = /*#__PURE__*/_interopDefaultLegacy(process);
14
14
  var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
15
15
 
16
- const {assert} = chai__default['default'];
17
- const binPath = path__default['default'].join(path__default['default'].dirname(url.fileURLToPath((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('browser-test/node-test-bin.js', document.baseURI).href)))), '../lib/bin.js');
16
+ const {assert} = chai__default["default"];
17
+ const binPath = path__default["default"].join(path__default["default"].dirname(url.fileURLToPath((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('browser-test/node-test-bin.js', document.baseURI).href)))), '../lib/bin.js');
18
18
  function fromHex(hex) {
19
19
  return new Uint8Array(hex.split('').map((c, i, d) => i % 2 === 0 ? `0x${ c }${ d[i + 1] }` : '').filter(Boolean).map(e => parseInt(e, 16)));
20
20
  }
21
21
  async function execBin(cmd, stdin) {
22
22
  return new Promise((resolve, reject) => {
23
- const cp = child_process.exec(`"${ process__default['default'].execPath }" "${ binPath }" ${ cmd }`, (err, stdout, stderr) => {
23
+ const cp = child_process.exec(`"${ process__default["default"].execPath }" "${ binPath }" ${ cmd }`, (err, stdout, stderr) => {
24
24
  if (err) {
25
25
  err.stdout = stdout;
26
26
  err.stderr = stderr;
@@ -10,7 +10,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
10
10
 
11
11
  var chai__default = /*#__PURE__*/_interopDefaultLegacy(chai);
12
12
 
13
- const {assert} = chai__default['default'];
13
+ const {assert} = chai__default["default"];
14
14
  const fixtures = [
15
15
  {
16
16
  data: '00',
@@ -10,7 +10,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
10
10
 
11
11
  var chai__default = /*#__PURE__*/_interopDefaultLegacy(chai);
12
12
 
13
- const {assert} = chai__default['default'];
13
+ const {assert} = chai__default["default"];
14
14
  const fixtures = [
15
15
  {
16
16
  data: '20',
@@ -10,7 +10,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
10
10
 
11
11
  var chai__default = /*#__PURE__*/_interopDefaultLegacy(chai);
12
12
 
13
- const {assert} = chai__default['default'];
13
+ const {assert} = chai__default["default"];
14
14
  const fixtures = [
15
15
  {
16
16
  data: '40',
@@ -10,7 +10,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
10
10
 
11
11
  var chai__default = /*#__PURE__*/_interopDefaultLegacy(chai);
12
12
 
13
- const {assert} = chai__default['default'];
13
+ const {assert} = chai__default["default"];
14
14
  const fixtures = [
15
15
  {
16
16
  data: '60',
@@ -10,7 +10,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
10
10
 
11
11
  var chai__default = /*#__PURE__*/_interopDefaultLegacy(chai);
12
12
 
13
- const {assert} = chai__default['default'];
13
+ const {assert} = chai__default["default"];
14
14
  const fixtures = [
15
15
  {
16
16
  data: '80',
@@ -10,7 +10,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
10
10
 
11
11
  var chai__default = /*#__PURE__*/_interopDefaultLegacy(chai);
12
12
 
13
- const {assert} = chai__default['default'];
13
+ const {assert} = chai__default["default"];
14
14
  const fixtures = [
15
15
  {
16
16
  data: 'a0',
@@ -11,7 +11,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
11
11
 
12
12
  var chai__default = /*#__PURE__*/_interopDefaultLegacy(chai);
13
13
 
14
- const {assert} = chai__default['default'];
14
+ const {assert} = chai__default["default"];
15
15
  function dateDecoder(obj) {
16
16
  if (typeof obj !== 'string') {
17
17
  throw new Error('expected string for tag 1');
@@ -10,7 +10,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
10
10
 
11
11
  var chai__default = /*#__PURE__*/_interopDefaultLegacy(chai);
12
12
 
13
- const {assert} = chai__default['default'];
13
+ const {assert} = chai__default["default"];
14
14
  const fixtures = [
15
15
  {
16
16
  data: '8601f5f4f6f720',
@@ -7,7 +7,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
7
7
 
8
8
  var chai__default = /*#__PURE__*/_interopDefaultLegacy(chai);
9
9
 
10
- const {assert} = chai__default['default'];
10
+ const {assert} = chai__default["default"];
11
11
  describe('Internal bytes list', () => {
12
12
  describe('push', () => {
13
13
  it('push bits', () => {
@@ -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');
@@ -13,7 +12,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
13
12
 
14
13
  var chai__default = /*#__PURE__*/_interopDefaultLegacy(chai);
15
14
 
16
- const {assert} = chai__default['default'];
15
+ const {assert} = chai__default["default"];
17
16
  const tags = [];
18
17
  const typeEncoders = {};
19
18
  tags[0] = function (obj) {
@@ -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
+ }
@@ -9,7 +9,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
9
9
 
10
10
  var chai__default = /*#__PURE__*/_interopDefaultLegacy(chai);
11
11
 
12
- const {assert} = chai__default['default'];
12
+ const {assert} = chai__default["default"];
13
13
  describe('decode errors', () => {
14
14
  it('not Uint8Array', () => {
15
15
  for (const arg of [
@@ -10,7 +10,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
10
10
 
11
11
  var chai__default = /*#__PURE__*/_interopDefaultLegacy(chai);
12
12
 
13
- const {assert} = chai__default['default'];
13
+ const {assert} = chai__default["default"];
14
14
  describe('Fuzz round-trip', () => {
15
15
  it('random objects', function () {
16
16
  this.timeout(5000);
package/cjs/lib/bin.js CHANGED
@@ -24,11 +24,11 @@ function usage(code) {
24
24
  console.error('\tjson2diag \'[json input]\'');
25
25
  console.error('\tjson2bin \'[json input]\'');
26
26
  console.error('Input may either be supplied as an argument or piped via stdin');
27
- process__default['default'].exit(code || 0);
27
+ process__default["default"].exit(code || 0);
28
28
  }
29
29
  async function fromStdin() {
30
30
  const chunks = [];
31
- for await (const chunk of process__default['default'].stdin) {
31
+ for await (const chunk of process__default["default"].stdin) {
32
32
  chunks.push(chunk);
33
33
  }
34
34
  return Buffer.concat(chunks);
@@ -41,15 +41,15 @@ function fromHex(str) {
41
41
  return byteUtils.fromHex(str);
42
42
  }
43
43
  function argvPretty() {
44
- const argv = process__default['default'].argv.filter(s => s !== '--pretty');
45
- const pretty = argv.length !== process__default['default'].argv.length;
44
+ const argv = process__default["default"].argv.filter(s => s !== '--pretty');
45
+ const pretty = argv.length !== process__default["default"].argv.length;
46
46
  return {
47
47
  argv,
48
48
  pretty
49
49
  };
50
50
  }
51
51
  async function run() {
52
- const cmd = process__default['default'].argv[2];
52
+ const cmd = process__default["default"].argv[2];
53
53
  switch (cmd) {
54
54
  case 'help': {
55
55
  return usage(0);
@@ -60,18 +60,18 @@ async function run() {
60
60
  return console.log(JSON.stringify(decode.decode(bin), undefined, pretty ? 2 : undefined));
61
61
  }
62
62
  case 'hex2diag': {
63
- const bin = fromHex(process__default['default'].argv.length < 4 ? (await fromStdin()).toString() : process__default['default'].argv[3]);
63
+ const bin = fromHex(process__default["default"].argv.length < 4 ? (await fromStdin()).toString() : process__default["default"].argv[3]);
64
64
  for (const line of diagnostic.tokensToDiagnostic(bin)) {
65
65
  console.log(line);
66
66
  }
67
67
  return;
68
68
  }
69
69
  case 'hex2bin': {
70
- const bin = fromHex(process__default['default'].argv.length < 4 ? (await fromStdin()).toString() : process__default['default'].argv[3]);
71
- return process__default['default'].stdout.write(bin);
70
+ const bin = fromHex(process__default["default"].argv.length < 4 ? (await fromStdin()).toString() : process__default["default"].argv[3]);
71
+ return process__default["default"].stdout.write(bin);
72
72
  }
73
73
  case 'bin2hex': {
74
- const bin = process__default['default'].argv.length < 4 ? await fromStdin() : new TextEncoder().encode(process__default['default'].argv[3]);
74
+ const bin = process__default["default"].argv.length < 4 ? await fromStdin() : new TextEncoder().encode(process__default["default"].argv[3]);
75
75
  return console.log(byteUtils.toHex(bin));
76
76
  }
77
77
  case 'bin2json': {
@@ -80,19 +80,19 @@ async function run() {
80
80
  return console.log(JSON.stringify(decode.decode(bin), undefined, pretty ? 2 : undefined));
81
81
  }
82
82
  case 'bin2diag': {
83
- const bin = process__default['default'].argv.length < 4 ? await fromStdin() : new TextEncoder().encode(process__default['default'].argv[3]);
83
+ const bin = process__default["default"].argv.length < 4 ? await fromStdin() : new TextEncoder().encode(process__default["default"].argv[3]);
84
84
  for (const line of diagnostic.tokensToDiagnostic(bin)) {
85
85
  console.log(line);
86
86
  }
87
87
  return;
88
88
  }
89
89
  case 'json2hex': {
90
- const inp = process__default['default'].argv.length < 4 ? (await fromStdin()).toString() : process__default['default'].argv[3];
90
+ const inp = process__default["default"].argv.length < 4 ? (await fromStdin()).toString() : process__default["default"].argv[3];
91
91
  const obj = JSON.parse(inp);
92
92
  return console.log(byteUtils.toHex(encode.encode(obj)));
93
93
  }
94
94
  case 'json2diag': {
95
- const inp = process__default['default'].argv.length < 4 ? (await fromStdin()).toString() : process__default['default'].argv[3];
95
+ const inp = process__default["default"].argv.length < 4 ? (await fromStdin()).toString() : process__default["default"].argv[3];
96
96
  const obj = JSON.parse(inp);
97
97
  for (const line of diagnostic.tokensToDiagnostic(encode.encode(obj))) {
98
98
  console.log(line);
@@ -100,12 +100,12 @@ async function run() {
100
100
  return;
101
101
  }
102
102
  case 'json2bin': {
103
- const inp = process__default['default'].argv.length < 4 ? (await fromStdin()).toString() : process__default['default'].argv[3];
103
+ const inp = process__default["default"].argv.length < 4 ? (await fromStdin()).toString() : process__default["default"].argv[3];
104
104
  const obj = JSON.parse(inp);
105
- return process__default['default'].stdout.write(encode.encode(obj));
105
+ return process__default["default"].stdout.write(encode.encode(obj));
106
106
  }
107
107
  default: {
108
- if (process__default['default'].argv.findIndex(a => a.endsWith('mocha')) === -1) {
108
+ if (process__default["default"].argv.findIndex(a => a.endsWith('mocha')) === -1) {
109
109
  if (cmd) {
110
110
  console.error(`Unknown command: '${ cmd }'`);
111
111
  }
@@ -116,7 +116,7 @@ async function run() {
116
116
  }
117
117
  run().catch(err => {
118
118
  console.error(err);
119
- process__default['default'].exit(1);
119
+ process__default["default"].exit(1);
120
120
  });
121
121
  var bin = true;
122
122
 
@@ -13,14 +13,14 @@ var chai__default = /*#__PURE__*/_interopDefaultLegacy(chai);
13
13
  var process__default = /*#__PURE__*/_interopDefaultLegacy(process);
14
14
  var path__default = /*#__PURE__*/_interopDefaultLegacy(path);
15
15
 
16
- const {assert} = chai__default['default'];
17
- const binPath = path__default['default'].join(path__default['default'].dirname(url.fileURLToPath((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('node-test/node-test-bin.js', document.baseURI).href)))), '../lib/bin.js');
16
+ const {assert} = chai__default["default"];
17
+ const binPath = path__default["default"].join(path__default["default"].dirname(url.fileURLToPath((typeof document === 'undefined' ? new (require('u' + 'rl').URL)('file:' + __filename).href : (document.currentScript && document.currentScript.src || new URL('node-test/node-test-bin.js', document.baseURI).href)))), '../lib/bin.js');
18
18
  function fromHex(hex) {
19
19
  return new Uint8Array(hex.split('').map((c, i, d) => i % 2 === 0 ? `0x${ c }${ d[i + 1] }` : '').filter(Boolean).map(e => parseInt(e, 16)));
20
20
  }
21
21
  async function execBin(cmd, stdin) {
22
22
  return new Promise((resolve, reject) => {
23
- const cp = child_process.exec(`"${ process__default['default'].execPath }" "${ binPath }" ${ cmd }`, (err, stdout, stderr) => {
23
+ const cp = child_process.exec(`"${ process__default["default"].execPath }" "${ binPath }" ${ cmd }`, (err, stdout, stderr) => {
24
24
  if (err) {
25
25
  err.stdout = stdout;
26
26
  err.stderr = stderr;
@@ -10,7 +10,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
10
10
 
11
11
  var chai__default = /*#__PURE__*/_interopDefaultLegacy(chai);
12
12
 
13
- const {assert} = chai__default['default'];
13
+ const {assert} = chai__default["default"];
14
14
  const fixtures = [
15
15
  {
16
16
  data: '00',
@@ -10,7 +10,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
10
10
 
11
11
  var chai__default = /*#__PURE__*/_interopDefaultLegacy(chai);
12
12
 
13
- const {assert} = chai__default['default'];
13
+ const {assert} = chai__default["default"];
14
14
  const fixtures = [
15
15
  {
16
16
  data: '20',
@@ -10,7 +10,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
10
10
 
11
11
  var chai__default = /*#__PURE__*/_interopDefaultLegacy(chai);
12
12
 
13
- const {assert} = chai__default['default'];
13
+ const {assert} = chai__default["default"];
14
14
  const fixtures = [
15
15
  {
16
16
  data: '40',
@@ -10,7 +10,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
10
10
 
11
11
  var chai__default = /*#__PURE__*/_interopDefaultLegacy(chai);
12
12
 
13
- const {assert} = chai__default['default'];
13
+ const {assert} = chai__default["default"];
14
14
  const fixtures = [
15
15
  {
16
16
  data: '60',
@@ -10,7 +10,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
10
10
 
11
11
  var chai__default = /*#__PURE__*/_interopDefaultLegacy(chai);
12
12
 
13
- const {assert} = chai__default['default'];
13
+ const {assert} = chai__default["default"];
14
14
  const fixtures = [
15
15
  {
16
16
  data: '80',
@@ -10,7 +10,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
10
10
 
11
11
  var chai__default = /*#__PURE__*/_interopDefaultLegacy(chai);
12
12
 
13
- const {assert} = chai__default['default'];
13
+ const {assert} = chai__default["default"];
14
14
  const fixtures = [
15
15
  {
16
16
  data: 'a0',
@@ -11,7 +11,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
11
11
 
12
12
  var chai__default = /*#__PURE__*/_interopDefaultLegacy(chai);
13
13
 
14
- const {assert} = chai__default['default'];
14
+ const {assert} = chai__default["default"];
15
15
  function dateDecoder(obj) {
16
16
  if (typeof obj !== 'string') {
17
17
  throw new Error('expected string for tag 1');
@@ -10,7 +10,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
10
10
 
11
11
  var chai__default = /*#__PURE__*/_interopDefaultLegacy(chai);
12
12
 
13
- const {assert} = chai__default['default'];
13
+ const {assert} = chai__default["default"];
14
14
  const fixtures = [
15
15
  {
16
16
  data: '8601f5f4f6f720',
@@ -7,7 +7,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
7
7
 
8
8
  var chai__default = /*#__PURE__*/_interopDefaultLegacy(chai);
9
9
 
10
- const {assert} = chai__default['default'];
10
+ const {assert} = chai__default["default"];
11
11
  describe('Internal bytes list', () => {
12
12
  describe('push', () => {
13
13
  it('push bits', () => {
@@ -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');
@@ -13,7 +12,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
13
12
 
14
13
  var chai__default = /*#__PURE__*/_interopDefaultLegacy(chai);
15
14
 
16
- const {assert} = chai__default['default'];
15
+ const {assert} = chai__default["default"];
17
16
  const tags = [];
18
17
  const typeEncoders = {};
19
18
  tags[0] = function (obj) {
@@ -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
+ }
@@ -9,7 +9,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
9
9
 
10
10
  var chai__default = /*#__PURE__*/_interopDefaultLegacy(chai);
11
11
 
12
- const {assert} = chai__default['default'];
12
+ const {assert} = chai__default["default"];
13
13
  describe('decode errors', () => {
14
14
  it('not Uint8Array', () => {
15
15
  for (const arg of [
@@ -10,7 +10,7 @@ function _interopDefaultLegacy (e) { return e && typeof e === 'object' && 'defau
10
10
 
11
11
  var chai__default = /*#__PURE__*/_interopDefaultLegacy(chai);
12
12
 
13
- const {assert} = chai__default['default'];
13
+ const {assert} = chai__default["default"];
14
14
  describe('Fuzz round-trip', () => {
15
15
  it('random objects', function () {
16
16
  this.timeout(5000);
@@ -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.0",
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
+ }
@@ -1,6 +1,6 @@
1
1
  export const decodeErrPrefix: "CBOR decode error:";
2
2
  export const encodeErrPrefix: "CBOR encode error:";
3
- export let uintMinorPrefixBytes: any[];
3
+ export const uintMinorPrefixBytes: any[];
4
4
  /**
5
5
  * @param {Uint8Array} data
6
6
  * @param {number} pos
@@ -1 +1 @@
1
- {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../lib/common.js"],"names":[],"mappings":"AAAA,mDAA4C;AAC5C,mDAA4C;AAE5C,uCAA+B;AAO/B;;;;GAIG;AACH,uCAJW,UAAU,OACV,MAAM,QACN,MAAM,QAMhB"}
1
+ {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../lib/common.js"],"names":[],"mappings":"AAAA,mDAA4C;AAC5C,mDAA4C;AAE5C,yCAA+B;AAO/B;;;;GAIG;AACH,uCAJW,UAAU,OACV,MAAM,QACN,MAAM,QAMhB"}