cborg 5.1.6 → 5.1.7

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.
package/CHANGELOG.md CHANGED
@@ -1,3 +1,5 @@
1
+ ## [5.1.7](https://github.com/rvagg/cborg/compare/v5.1.6...v5.1.7) (2026-07-04)
2
+
1
3
  ## [5.1.6](https://github.com/rvagg/cborg/compare/v5.1.5...v5.1.6) (2026-07-02)
2
4
 
3
5
  ## [5.1.5](https://github.com/rvagg/cborg/compare/v5.1.4...v5.1.5) (2026-06-30)
package/interface.ts CHANGED
@@ -1,5 +1,9 @@
1
1
  import { Token } from './lib/token.js'
2
2
 
3
+ export type ByteView<T extends ArrayBufferLike = ArrayBufferLike> = Uint8Array<T>
4
+
5
+ export type AllocatedByteView = Uint8Array<ArrayBuffer>
6
+
3
7
  export type TokenOrNestedTokens = Token | Token[] | TokenOrNestedTokens[]
4
8
 
5
9
  export interface Reference {
@@ -21,7 +25,7 @@ export type TokenTypeEncoder = {
21
25
 
22
26
  export type MapSorter = (e1: (Token | Token[])[], e2: (Token | Token[])[]) => number
23
27
 
24
- export type QuickEncodeToken = (token: Token) => Uint8Array | undefined
28
+ export type QuickEncodeToken = (token: Token) => AllocatedByteView | undefined
25
29
 
26
30
  export interface DecodeTokenizer {
27
31
  done(): boolean,
@@ -72,8 +76,8 @@ export interface EncodeOptions {
72
76
  }
73
77
 
74
78
  export interface ByteWriter {
75
- chunks: (Uint8Array | number[])[];
79
+ chunks: (ByteView | number[])[];
76
80
  reset(): void;
77
- push(bytes: Uint8Array | number[]): void;
78
- toBytes(reset?: boolean | undefined): Uint8Array;
81
+ push(bytes: ByteView | number[]): void;
82
+ toBytes(reset?: boolean | undefined): ByteView;
79
83
  }
package/lib/bl.js CHANGED
@@ -18,6 +18,11 @@
18
18
  // TODO: ipjs doesn't support this, only for test files: https://github.com/mikeal/ipjs/blob/master/src/package/testFile.js#L39
19
19
  import { alloc, concat, slice } from './byte-utils.js'
20
20
 
21
+ /**
22
+ * @typedef {import('../interface.js').ByteView} ByteView
23
+ * @typedef {import('../interface.js').AllocatedByteView} AllocatedByteView
24
+ */
25
+
21
26
  // the ts-ignores in this file are almost all for the `Uint8Array|number[]` duality that exists
22
27
  // for perf reasons. Consider better approaches to this or removing it entirely, it is quite
23
28
  // risky because of some assumptions about small chunks === number[] and everything else === Uint8Array.
@@ -34,10 +39,10 @@ export class Bl {
34
39
  this.cursor = 0
35
40
  /** @type {number} */
36
41
  this.maxCursor = -1
37
- /** @type {(Uint8Array|number[])[]} */
42
+ /** @type {(ByteView|number[])[]} */
38
43
  this.chunks = []
39
44
  // keep the first chunk around if we can to save allocations for future encodes
40
- /** @type {Uint8Array|number[]|null} */
45
+ /** @type {ByteView|number[]|null} */
41
46
  this._initReuseChunk = null
42
47
  }
43
48
 
@@ -54,7 +59,7 @@ export class Bl {
54
59
  }
55
60
 
56
61
  /**
57
- * @param {Uint8Array|number[]} bytes
62
+ * @param {ByteView|number[]} bytes
58
63
  */
59
64
  push (bytes) {
60
65
  let topChunk = this.chunks[this.chunks.length - 1]
@@ -96,7 +101,7 @@ export class Bl {
96
101
 
97
102
  /**
98
103
  * @param {boolean} [reset]
99
- * @returns {Uint8Array}
104
+ * @returns {AllocatedByteView}
100
105
  */
101
106
  toBytes (reset = false) {
102
107
  let byts
@@ -125,10 +130,11 @@ export class Bl {
125
130
  /**
126
131
  * U8Bl is a buffer list that writes directly to a user-provided Uint8Array.
127
132
  * It provides the same interface as Bl but writes to a fixed destination.
133
+ * @template {ArrayBufferLike} T
128
134
  */
129
135
  export class U8Bl {
130
136
  /**
131
- * @param {Uint8Array} dest
137
+ * @param {Uint8Array<T>} dest
132
138
  */
133
139
  constructor (dest) {
134
140
  this.dest = dest
@@ -136,7 +142,7 @@ export class U8Bl {
136
142
  this.cursor = 0
137
143
  // chunks is for interface compatibility with Bl - encode.js checks chunks.length
138
144
  // as a sanity check for pre-calculated sizes. For U8Bl this is always [dest].
139
- /** @type {Uint8Array[]} */
145
+ /** @type {Array<Uint8Array<T>>} */
140
146
  this.chunks = [dest]
141
147
  }
142
148
 
@@ -145,7 +151,7 @@ export class U8Bl {
145
151
  }
146
152
 
147
153
  /**
148
- * @param {Uint8Array|number[]} bytes
154
+ * @param {ByteView|number[]} bytes
149
155
  */
150
156
  push (bytes) {
151
157
  if (this.cursor + bytes.length > this.dest.length) {
@@ -157,7 +163,7 @@ export class U8Bl {
157
163
 
158
164
  /**
159
165
  * @param {boolean} [reset]
160
- * @returns {Uint8Array}
166
+ * @returns {Uint8Array<T>}
161
167
  */
162
168
  toBytes (reset = false) {
163
169
  const byts = this.dest.subarray(0, this.cursor)
package/lib/byte-utils.js CHANGED
@@ -12,6 +12,11 @@ export const useBuffer = globalThis.process &&
12
12
 
13
13
  const textEncoder = new TextEncoder()
14
14
 
15
+ /**
16
+ * @typedef {import('../interface.js').ByteView} ByteView
17
+ * @typedef {import('../interface.js').AllocatedByteView} AllocatedByteView
18
+ */
19
+
15
20
  /**
16
21
  * @param {Uint8Array} buf
17
22
  * @returns {boolean}
@@ -22,8 +27,8 @@ function isBuffer (buf) {
22
27
  }
23
28
 
24
29
  /**
25
- * @param {Uint8Array|number[]} buf
26
- * @returns {Uint8Array}
30
+ * @param {ByteView|number[]} buf
31
+ * @returns {ByteView}
27
32
  */
28
33
  export function asU8A (buf) {
29
34
  if (!(buf instanceof Uint8Array)) {
@@ -61,7 +66,7 @@ export const fromString = useBuffer
61
66
  /**
62
67
  * Buffer variant not fast enough for what we need
63
68
  * @param {number[]} arr
64
- * @returns {Uint8Array}
69
+ * @returns {AllocatedByteView}
65
70
  */
66
71
  export const fromArray = (arr) => {
67
72
  return Uint8Array.from(arr)
@@ -94,9 +99,9 @@ export const slice = useBuffer
94
99
  export const concat = useBuffer
95
100
  ? // eslint-disable-line operator-linebreak
96
101
  /**
97
- * @param {Uint8Array[]} chunks
102
+ * @param {ByteView[]} chunks
98
103
  * @param {number} length
99
- * @returns {Uint8Array}
104
+ * @returns {AllocatedByteView}
100
105
  */
101
106
  (chunks, length) => {
102
107
  // might get a stray plain Array here
@@ -106,13 +111,13 @@ export const concat = useBuffer
106
111
  // @ts-ignore
107
112
  globalThis.Buffer.from(c))
108
113
  // @ts-ignore
109
- return asU8A(globalThis.Buffer.concat(chunks, length))
114
+ return /** @type {AllocatedByteView} */ (asU8A(globalThis.Buffer.concat(chunks, length)))
110
115
  }
111
116
  : // eslint-disable-line operator-linebreak
112
117
  /**
113
- * @param {Uint8Array[]} chunks
118
+ * @param {ByteView[]} chunks
114
119
  * @param {number} length
115
- * @returns {Uint8Array}
120
+ * @returns {AllocatedByteView}
116
121
  */
117
122
  (chunks, length) => {
118
123
  const out = new Uint8Array(length)
@@ -132,7 +137,7 @@ export const alloc = useBuffer
132
137
  ? // eslint-disable-line operator-linebreak
133
138
  /**
134
139
  * @param {number} size
135
- * @returns {Uint8Array}
140
+ * @returns {AllocatedByteView}
136
141
  */
137
142
  (size) => {
138
143
  // we always write over the contents we expose so this should be safe
@@ -142,7 +147,7 @@ export const alloc = useBuffer
142
147
  : // eslint-disable-line operator-linebreak
143
148
  /**
144
149
  * @param {number} size
145
- * @returns {Uint8Array}
150
+ * @returns {AllocatedByteView}
146
151
  */
147
152
  (size) => {
148
153
  return new Uint8Array(size)
@@ -177,8 +182,8 @@ export const toHex = useBuffer
177
182
  export const fromHex = useBuffer
178
183
  ? // eslint-disable-line operator-linebreak
179
184
  /**
180
- * @param {string|Uint8Array} hex
181
- * @returns {Uint8Array}
185
+ * @param {string|ByteView} hex
186
+ * @returns {ByteView}
182
187
  */
183
188
  (hex) => {
184
189
  if (hex instanceof Uint8Array) {
@@ -189,8 +194,8 @@ export const fromHex = useBuffer
189
194
  }
190
195
  : // eslint-disable-line operator-linebreak
191
196
  /**
192
- * @param {string|Uint8Array} hex
193
- * @returns {Uint8Array}
197
+ * @param {string|ByteView} hex
198
+ * @returns {ByteView}
194
199
  */
195
200
  (hex) => {
196
201
  if (hex instanceof Uint8Array) {
package/lib/encode.js CHANGED
@@ -22,6 +22,8 @@ import { encodeFloat, MINOR_FALSE, MINOR_TRUE, MINOR_NULL, MINOR_UNDEFINED } fro
22
22
  * @typedef {import('../interface.js').TokenTypeEncoder} TokenTypeEncoder
23
23
  * @typedef {import('../interface.js').TokenOrNestedTokens} TokenOrNestedTokens
24
24
  * @typedef {import('../interface.js').ByteWriter} ByteWriter
25
+ * @typedef {import('../interface.js').ByteView} ByteView
26
+ * @typedef {import('../interface.js').AllocatedByteView} AllocatedByteView
25
27
  */
26
28
 
27
29
  /** @type {EncodeOptions} */
@@ -434,7 +436,7 @@ function mapSorter (e1, e2) {
434
436
  }
435
437
 
436
438
  /**
437
- * @typedef {Token & { _keyBytes?: Uint8Array }} TokenEx
439
+ * @typedef {Token & { _keyBytes?: AllocatedByteView }} TokenEx
438
440
  *
439
441
  * @param {(Token|Token[])[]} e1
440
442
  * @param {(Token|Token[])[]} e2
@@ -461,7 +463,7 @@ function rfc8949MapSorter (e1, e2) {
461
463
 
462
464
  /**
463
465
  * @param {any} data
464
- * @returns {Uint8Array}
466
+ * @returns {AllocatedByteView}
465
467
  */
466
468
  function encodeRfc8949 (data) {
467
469
  return encodeCustom(data, cborEncoders, rfc8949EncodeOptions)
@@ -617,11 +619,27 @@ function directEncode (writer, data, options, refStack) {
617
619
  }
618
620
 
619
621
  /**
622
+ * @template {ArrayBufferLike} T
623
+ * @overload
620
624
  * @param {any} data
621
625
  * @param {TokenTypeEncoder[]} encoders
622
626
  * @param {EncodeOptions} options
623
- * @param {Uint8Array} [destination]
624
- * @returns {Uint8Array}
627
+ * @param {Uint8Array<T>} destination
628
+ * @returns {Uint8Array<T>}
629
+ */
630
+ /**
631
+ * @overload
632
+ * @param {any} data
633
+ * @param {TokenTypeEncoder[]} encoders
634
+ * @param {EncodeOptions} options
635
+ * @returns {AllocatedByteView}
636
+ */
637
+ /**
638
+ * @param {any} data
639
+ * @param {TokenTypeEncoder[]} encoders
640
+ * @param {EncodeOptions} options
641
+ * @param {ByteView} [destination]
642
+ * @returns {ByteView}
625
643
  */
626
644
  function encodeCustom (data, encoders, options, destination) {
627
645
  // arg ordering is different to encodeInto for backward compatibility
@@ -661,7 +679,7 @@ function encodeCustom (data, encoders, options, destination) {
661
679
  /**
662
680
  * @param {any} data
663
681
  * @param {EncodeOptions} [options]
664
- * @returns {Uint8Array}
682
+ * @returns {AllocatedByteView}
665
683
  */
666
684
  function encode (data, options) {
667
685
  options = Object.assign({}, defaultEncodeOptions, options)
@@ -677,8 +695,9 @@ function encode (data, options) {
677
695
  }
678
696
 
679
697
  /**
698
+ * @template {ArrayBufferLike} T
680
699
  * @param {any} data
681
- * @param {Uint8Array} destination
700
+ * @param {Uint8Array<T>} destination
682
701
  * @param {EncodeOptions} [options]
683
702
  * @returns {{ written: number }}
684
703
  */
@@ -87,6 +87,7 @@ import {
87
87
  /**
88
88
  * @typedef {import('../../interface.js').EncodeOptions} EncodeOptions
89
89
  * @typedef {import('../../interface.js').DecodeOptions} DecodeOptions
90
+ * @typedef {import('../../interface.js').AllocatedByteView} AllocatedByteView
90
91
  */
91
92
 
92
93
  /**
@@ -156,7 +157,7 @@ const tags = {
156
157
  *
157
158
  * @param {any} obj - Value to encode
158
159
  * @param {EncodeOptions} [options] - Additional options (merged with extended defaults)
159
- * @returns {Uint8Array}
160
+ * @returns {AllocatedByteView}
160
161
  */
161
162
  export function encode (obj, options = {}) {
162
163
  return _encode(obj, {
@@ -6,6 +6,7 @@ import { asU8A, fromString } from '../byte-utils.js'
6
6
  /**
7
7
  * @typedef {import('../../interface.js').EncodeOptions} EncodeOptions
8
8
  * @typedef {import('../../interface.js').ByteWriter} ByteWriter
9
+ * @typedef {import('../../interface.js').AllocatedByteView} AllocatedByteView
9
10
  * @typedef {import('../token.js').Token} Token
10
11
  */
11
12
 
@@ -291,7 +292,7 @@ const defaultEncodeOptions = { addBreakTokens: true, mapSorter }
291
292
  /**
292
293
  * @param {any} data
293
294
  * @param {EncodeOptions} [options]
294
- * @returns {Uint8Array}
295
+ * @returns {AllocatedByteView}
295
296
  */
296
297
  function encode (data, options) {
297
298
  options = Object.assign({}, defaultEncodeOptions, options)
package/lib/jump.js CHANGED
@@ -12,6 +12,7 @@ import { fromArray } from './byte-utils.js'
12
12
 
13
13
  /**
14
14
  * @typedef {import('../interface.js').DecodeOptions} DecodeOptions
15
+ * @typedef {import('../interface.js').AllocatedByteView} AllocatedByteView
15
16
  */
16
17
 
17
18
  /**
@@ -162,7 +163,7 @@ quick[0xf6] = new Token(Type.null, null, 1)
162
163
 
163
164
  /**
164
165
  * @param {Token} token
165
- * @returns {Uint8Array|undefined}
166
+ * @returns {AllocatedByteView|undefined}
166
167
  */
167
168
  export function quickEncodeToken (token) {
168
169
  switch (token.type) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "cborg",
3
- "version": "5.1.6",
3
+ "version": "5.1.7",
4
4
  "description": "Fast CBOR with a focus on strictness",
5
5
  "main": "cborg.js",
6
6
  "type": "module",
@@ -1,4 +1,6 @@
1
1
  import { Token } from './lib/token.js';
2
+ export type ByteView<T extends ArrayBufferLike = ArrayBufferLike> = Uint8Array<T>;
3
+ export type AllocatedByteView = Uint8Array<ArrayBuffer>;
2
4
  export type TokenOrNestedTokens = Token | Token[] | TokenOrNestedTokens[];
3
5
  export interface Reference {
4
6
  parent: Reference | undefined;
@@ -13,7 +15,7 @@ export type TokenTypeEncoder = {
13
15
  encodedSize?(token: Token, options?: EncodeOptions): number;
14
16
  };
15
17
  export type MapSorter = (e1: (Token | Token[])[], e2: (Token | Token[])[]) => number;
16
- export type QuickEncodeToken = (token: Token) => Uint8Array | undefined;
18
+ export type QuickEncodeToken = (token: Token) => AllocatedByteView | undefined;
17
19
  export interface DecodeTokenizer {
18
20
  done(): boolean;
19
21
  next(): Token;
@@ -60,9 +62,9 @@ export interface EncodeOptions {
60
62
  ignoreUndefinedProperties?: boolean;
61
63
  }
62
64
  export interface ByteWriter {
63
- chunks: (Uint8Array | number[])[];
65
+ chunks: (ByteView | number[])[];
64
66
  reset(): void;
65
- push(bytes: Uint8Array | number[]): void;
66
- toBytes(reset?: boolean | undefined): Uint8Array;
67
+ push(bytes: ByteView | number[]): void;
68
+ toBytes(reset?: boolean | undefined): ByteView;
67
69
  }
68
70
  //# sourceMappingURL=interface.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"interface.d.ts","sourceRoot":"","sources":["../interface.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,gBAAgB,CAAA;AAEtC,MAAM,MAAM,mBAAmB,GAAG,KAAK,GAAG,KAAK,EAAE,GAAG,mBAAmB,EAAE,CAAA;AAEzE,MAAM,WAAW,SAAS;IACxB,MAAM,EAAE,SAAS,GAAG,SAAS,CAAA;IAC7B,GAAG,EAAE,MAAM,GAAG,GAAG,EAAE,CAAA;IACnB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,GAAG,EAAE,GAAG,OAAO,CAAA;CACvC;AAED,MAAM,MAAM,mBAAmB,GAAG,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,QAAQ,CAAC,EAAE,SAAS,KAAK,mBAAmB,GAAG,IAAI,CAAA;AAEtI,MAAM,MAAM,iBAAiB,GAAG,CAAC,IAAI,EAAE,GAAG,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,aAAa,EAAE,QAAQ,CAAC,EAAE,SAAS,KAAK,mBAAmB,CAAA;AAE7H,MAAM,MAAM,gBAAgB,GAAG;IAC7B,CAAC,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,IAAI,CAAC;IAClE,aAAa,CAAC,EAAE,EAAE,KAAK,EAAE,EAAE,EAAE,KAAK,GAAG,MAAM,CAAC;IAE5C,WAAW,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG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qB,CAAC,EAAE,OAAO,CAAA;IAC/B,aAAa,CAAC,EAAE,OAAO,CAAA;IACvB,QAAQ,CAAC,EAAE,OAAO,CAAA;IAClB,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,MAAM,CAAC,EAAE,OAAO,CAAA;IAChB,OAAO,CAAC,EAAE,OAAO,CAAA;IACjB,sBAAsB,CAAC,EAAE,OAAO,CAAA;IAChC,iBAAiB,CAAC,EAAE,OAAO,CAAA;IAC3B,IAAI,CAAC,EAAE;QAAE,CAAC,SAAS,EAAE,MAAM,GAAG,UAAU,CAAA;KAAE,CAAC;IAC3C,SAAS,CAAC,EAAE,eAAe,CAAA;CAC5B;AAED,MAAM,WAAW,aAAa;IAC5B,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,cAAc,CAAC,EAAE,OAAO,CAAC;IACzB,SAAS,CAAC,EAAE,SAAS,CAAC;IACtB,gBAAgB,CAAC,EAAE,gBAAgB,CAAC;IACpC,YAAY,CAAC,EAAE;QAAE,CAAC,QAAQ,EAAE,MAAM,GAAG,mBAAmB,CAAA;KAAE,CAAA;IAC1D;;;OAGG;IACH,yBAAyB,CAAC,EAAE,OAAO,CAAC;CACrC;AAED,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,CAAC,QAAQ,GAAG,MAAM,EAAE,CAAC,EAAE,CAAC;IAChC,KAAK,IAAI,IAAI,CAAC;IACd,IAAI,CAAC,KAAK,EAAE,QAAQ,GAAG,MAAM,EAAE,GAAG,IAAI,CAAC;IACvC,OAAO,CAAC,KAAK,CAAC,EAAE,OAAO,GAAG,SAAS,GAAG,QAAQ,CAAC;CAChD"}
package/types/lib/bl.d.ts CHANGED
@@ -8,44 +8,47 @@ export class Bl {
8
8
  cursor: number;
9
9
  /** @type {number} */
10
10
  maxCursor: number;
11
- /** @type {(Uint8Array|number[])[]} */
12
- chunks: (Uint8Array | number[])[];
13
- /** @type {Uint8Array|number[]|null} */
14
- _initReuseChunk: Uint8Array | number[] | null;
11
+ /** @type {(ByteView|number[])[]} */
12
+ chunks: (ByteView | number[])[];
13
+ /** @type {ByteView|number[]|null} */
14
+ _initReuseChunk: ByteView | number[] | null;
15
15
  reset(): void;
16
16
  /**
17
- * @param {Uint8Array|number[]} bytes
17
+ * @param {ByteView|number[]} bytes
18
18
  */
19
- push(bytes: Uint8Array | number[]): void;
19
+ push(bytes: ByteView | number[]): void;
20
20
  /**
21
21
  * @param {boolean} [reset]
22
- * @returns {Uint8Array}
22
+ * @returns {AllocatedByteView}
23
23
  */
24
- toBytes(reset?: boolean): Uint8Array;
24
+ toBytes(reset?: boolean): AllocatedByteView;
25
25
  }
26
26
  /**
27
27
  * U8Bl is a buffer list that writes directly to a user-provided Uint8Array.
28
28
  * It provides the same interface as Bl but writes to a fixed destination.
29
+ * @template {ArrayBufferLike} T
29
30
  */
30
- export class U8Bl {
31
+ export class U8Bl<T extends ArrayBufferLike> {
31
32
  /**
32
- * @param {Uint8Array} dest
33
+ * @param {Uint8Array<T>} dest
33
34
  */
34
- constructor(dest: Uint8Array);
35
- dest: Uint8Array<ArrayBufferLike>;
35
+ constructor(dest: Uint8Array<T>);
36
+ dest: Uint8Array<T>;
36
37
  /** @type {number} */
37
38
  cursor: number;
38
- /** @type {Uint8Array[]} */
39
- chunks: Uint8Array[];
39
+ /** @type {Array<Uint8Array<T>>} */
40
+ chunks: Array<Uint8Array<T>>;
40
41
  reset(): void;
41
42
  /**
42
- * @param {Uint8Array|number[]} bytes
43
+ * @param {ByteView|number[]} bytes
43
44
  */
44
- push(bytes: Uint8Array | number[]): void;
45
+ push(bytes: ByteView | number[]): void;
45
46
  /**
46
47
  * @param {boolean} [reset]
47
- * @returns {Uint8Array}
48
+ * @returns {Uint8Array<T>}
48
49
  */
49
- toBytes(reset?: boolean): Uint8Array;
50
+ toBytes(reset?: boolean): Uint8Array<T>;
50
51
  }
52
+ export type ByteView = import("../interface.js").ByteView;
53
+ export type AllocatedByteView = import("../interface.js").AllocatedByteView;
51
54
  //# sourceMappingURL=bl.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"bl.d.ts","sourceRoot":"","sources":["../../lib/bl.js"],"names":[],"mappings":"AA0BA;IACE;;OAEG;IACH,wBAFW,MAAM,EAahB;IAVC,kBAA0B;IAC1B,qBAAqB;IACrB,QADW,MAAM,CACF;IACf,qBAAqB;IACrB,WADW,MAAM,CACE;IACnB,sCAAsC;IACtC,QADW,CAAC,UAAU,GAAC,MAAM,EAAE,CAAC,EAAE,CAClB;IAEhB,uCAAuC;IACvC,iBADW,UAAU,GAAC,MAAM,EAAE,GAAC,IAAI,CACR;IAG7B,cAUC;IAED;;OAEG;IACH,YAFW,UAAU,GAAC,MAAM,EAAE,QAsC7B;IAED;;;OAGG;IACH,gBAHW,OAAO,GACL,UAAU,CAuBtB;CACF;AAED;;;GAGG;AACH;IACE;;OAEG;IACH,kBAFW,UAAU,EAUpB;IAPC,kCAAgB;IAChB,qBAAqB;IACrB,QADW,MAAM,CACF;IAGf,2BAA2B;IAC3B,QADW,UAAU,EAAE,CACH;IAGtB,cAEC;IAED;;OAEG;IACH,YAFW,UAAU,GAAC,MAAM,EAAE,QAQ7B;IAED;;;OAGG;IACH,gBAHW,OAAO,GACL,UAAU,CAQtB;CACF"}
1
+ {"version":3,"file":"bl.d.ts","sourceRoot":"","sources":["../../lib/bl.js"],"names":[],"mappings":"AA+BA;IACE;;OAEG;IACH,wBAFW,MAAM,EAahB;IAVC,kBAA0B;IAC1B,qBAAqB;IACrB,QADW,MAAM,CACF;IACf,qBAAqB;IACrB,WADW,MAAM,CACE;IACnB,oCAAoC;IACpC,QADW,CAAC,QAAQ,GAAC,MAAM,EAAE,CAAC,EAAE,CAChB;IAEhB,qCAAqC;IACrC,iBADW,QAAQ,GAAC,MAAM,EAAE,GAAC,IAAI,CACN;IAG7B,cAUC;IAED;;OAEG;IACH,YAFW,QAAQ,GAAC,MAAM,EAAE,QAsC3B;IAED;;;OAGG;IACH,gBAHW,OAAO,GACL,iBAAiB,CAuB7B;CACF;AAED;;;;GAIG;AACH,kBAF+B,CAAC,SAAlB,eAAgB;IAG5B;;OAEG;IACH,kBAFW,UAAU,CAAC,CAAC,CAAC,EAUvB;IAPC,oBAAgB;IAChB,qBAAqB;IACrB,QADW,MAAM,CACF;IAGf,mCAAmC;IACnC,QADW,KAAK,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CACX;IAGtB,cAEC;IAED;;OAEG;IACH,YAFW,QAAQ,GAAC,MAAM,EAAE,QAQ3B;IAED;;;OAGG;IACH,gBAHW,OAAO,GACL,UAAU,CAAC,CAAC,CAAC,CAQzB;CACF;uBAzJY,OAAO,iBAAiB,EAAE,QAAQ;gCAClC,OAAO,iBAAiB,EAAE,iBAAiB"}
@@ -1,8 +1,8 @@
1
1
  /**
2
- * @param {Uint8Array|number[]} buf
3
- * @returns {Uint8Array}
2
+ * @param {ByteView|number[]} buf
3
+ * @returns {ByteView}
4
4
  */
5
- export function asU8A(buf: Uint8Array | number[]): Uint8Array;
5
+ export function asU8A(buf: ByteView | number[]): ByteView;
6
6
  /**
7
7
  * @param {Uint8Array} b1
8
8
  * @param {Uint8Array} b2
@@ -19,7 +19,7 @@ export const useBuffer: any;
19
19
  * @param {string} string
20
20
  */
21
21
  export function fromString(string: string): any;
22
- export function fromArray(arr: number[]): Uint8Array;
22
+ export function fromArray(arr: number[]): AllocatedByteView;
23
23
  /**
24
24
  * @param {Uint8Array} bytes
25
25
  * @param {number} start
@@ -27,24 +27,26 @@ export function fromArray(arr: number[]): Uint8Array;
27
27
  */
28
28
  export function slice(bytes: Uint8Array, start: number, end: number): Uint8Array<ArrayBuffer>;
29
29
  /**
30
- * @param {Uint8Array[]} chunks
30
+ * @param {ByteView[]} chunks
31
31
  * @param {number} length
32
- * @returns {Uint8Array}
32
+ * @returns {AllocatedByteView}
33
33
  */
34
- export function concat(chunks: Uint8Array[], length: number): Uint8Array;
34
+ export function concat(chunks: ByteView[], length: number): AllocatedByteView;
35
35
  /**
36
36
  * @param {number} size
37
- * @returns {Uint8Array}
37
+ * @returns {AllocatedByteView}
38
38
  */
39
- export function alloc(size: number): Uint8Array;
39
+ export function alloc(size: number): AllocatedByteView;
40
40
  /**
41
41
  * @param {Uint8Array} d
42
42
  * @returns {string}
43
43
  */
44
44
  export function toHex(d: Uint8Array): string;
45
45
  /**
46
- * @param {string|Uint8Array} hex
47
- * @returns {Uint8Array}
46
+ * @param {string|ByteView} hex
47
+ * @returns {ByteView}
48
48
  */
49
- export function fromHex(hex: string | Uint8Array): Uint8Array;
49
+ export function fromHex(hex: string | ByteView): ByteView;
50
+ export type ByteView = import("../interface.js").ByteView;
51
+ export type AllocatedByteView = import("../interface.js").AllocatedByteView;
50
52
  //# sourceMappingURL=byte-utils.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"byte-utils.d.ts","sourceRoot":"","sources":["../../lib/byte-utils.js"],"names":[],"mappings":"AAuBA;;;GAGG;AACH,2BAHW,UAAU,GAAC,MAAM,EAAE,GACjB,UAAU,CAOtB;AAgMD;;;;GAIG;AACH,4BAJW,UAAU,MACV,UAAU,GACR,MAAM,CAelB;AA6CD;;;GAGG;AACH,kDAHW,MAAM,EAAE,GACN,MAAM,CAiBlB;AA9SD,4BAMkD;AAgC9C;;GAEG;AACH,mCAFW,MAAM,OAQhB;AAcE,+BAHI,MAAM,EAAE,GACN,UAAU,CAItB;AAIG;;;;GAIG;AAEH,6BALW,UAAU,SACV,MAAM,OACN,MAAM,2BAQhB;AAaD;;;;GAIG;AACH,+BAJW,UAAU,EAAE,UACZ,MAAM,GACJ,UAAU,CAWtB;AAuBD;;;GAGG;AACH,4BAHW,MAAM,GACJ,UAAU,CAMtB;AAYD;;;GAGG;AACH,yBAHW,UAAU,GACR,MAAM,CAQlB;AAgBH;;;GAGG;AACD,6BAHS,MAAM,GAAC,UAAU,GACf,UAAU,CAQpB"}
1
+ {"version":3,"file":"byte-utils.d.ts","sourceRoot":"","sources":["../../lib/byte-utils.js"],"names":[],"mappings":"AA4BA;;;GAGG;AACH,2BAHW,QAAQ,GAAC,MAAM,EAAE,GACf,QAAQ,CAOpB;AAgMD;;;;GAIG;AACH,4BAJW,UAAU,MACV,UAAU,GACR,MAAM,CAelB;AA6CD;;;GAGG;AACH,kDAHW,MAAM,EAAE,GACN,MAAM,CAiBlB;AAnTD,4BAMkD;AAqC9C;;GAEG;AACH,mCAFW,MAAM,OAQhB;AAcE,+BAHI,MAAM,EAAE,GACN,iBAAiB,CAI7B;AAIG;;;;GAIG;AAEH,6BALW,UAAU,SACV,MAAM,OACN,MAAM,2BAQhB;AAaD;;;;GAIG;AACH,+BAJW,QAAQ,EAAE,UACV,MAAM,GACJ,iBAAiB,CAW7B;AAuBD;;;GAGG;AACH,4BAHW,MAAM,GACJ,iBAAiB,CAM7B;AAYD;;;GAGG;AACH,yBAHW,UAAU,GACR,MAAM,CAQlB;AAgBH;;;GAGG;AACD,6BAHS,MAAM,GAAC,QAAQ,GACb,QAAQ,CAQlB;uBAlLQ,OAAO,iBAAiB,EAAE,QAAQ;gCAClC,OAAO,iBAAiB,EAAE,iBAAiB"}
@@ -3,7 +3,7 @@ export function makeCborEncoders(): TokenTypeEncoder[];
3
3
  /** @type {EncodeOptions} */
4
4
  export const rfc8949EncodeOptions: EncodeOptions;
5
5
  export type TokenEx = Token & {
6
- _keyBytes?: Uint8Array;
6
+ _keyBytes?: AllocatedByteView;
7
7
  };
8
8
  export type EncodeOptions = import("../interface.js").EncodeOptions;
9
9
  export type OptionalTypeEncoder = import("../interface.js").OptionalTypeEncoder;
@@ -12,6 +12,8 @@ export type StrictTypeEncoder = import("../interface.js").StrictTypeEncoder;
12
12
  export type TokenTypeEncoder = import("../interface.js").TokenTypeEncoder;
13
13
  export type TokenOrNestedTokens = import("../interface.js").TokenOrNestedTokens;
14
14
  export type ByteWriter = import("../interface.js").ByteWriter;
15
+ export type ByteView = import("../interface.js").ByteView;
16
+ export type AllocatedByteView = import("../interface.js").AllocatedByteView;
15
17
  /**
16
18
  * @param {any} obj
17
19
  * @param {EncodeOptions} [options]
@@ -22,24 +24,35 @@ export function objectToTokens(obj: any, options?: EncodeOptions, refStack?: Ref
22
24
  /**
23
25
  * @param {any} data
24
26
  * @param {EncodeOptions} [options]
25
- * @returns {Uint8Array}
27
+ * @returns {AllocatedByteView}
26
28
  */
27
- export function encode(data: any, options?: EncodeOptions): Uint8Array;
29
+ export function encode(data: any, options?: EncodeOptions): AllocatedByteView;
28
30
  /**
31
+ * @template {ArrayBufferLike} T
32
+ * @overload
29
33
  * @param {any} data
30
34
  * @param {TokenTypeEncoder[]} encoders
31
35
  * @param {EncodeOptions} options
32
- * @param {Uint8Array} [destination]
33
- * @returns {Uint8Array}
36
+ * @param {Uint8Array<T>} destination
37
+ * @returns {Uint8Array<T>}
34
38
  */
35
- export function encodeCustom(data: any, encoders: TokenTypeEncoder[], options: EncodeOptions, destination?: Uint8Array): Uint8Array;
39
+ export function encodeCustom<T extends ArrayBufferLike>(data: any, encoders: TokenTypeEncoder[], options: EncodeOptions, destination: Uint8Array<T>): Uint8Array<T>;
36
40
  /**
41
+ * @overload
37
42
  * @param {any} data
38
- * @param {Uint8Array} destination
43
+ * @param {TokenTypeEncoder[]} encoders
44
+ * @param {EncodeOptions} options
45
+ * @returns {AllocatedByteView}
46
+ */
47
+ export function encodeCustom(data: any, encoders: TokenTypeEncoder[], options: EncodeOptions): AllocatedByteView;
48
+ /**
49
+ * @template {ArrayBufferLike} T
50
+ * @param {any} data
51
+ * @param {Uint8Array<T>} destination
39
52
  * @param {EncodeOptions} [options]
40
53
  * @returns {{ written: number }}
41
54
  */
42
- export function encodeInto(data: any, destination: Uint8Array, options?: EncodeOptions): {
55
+ export function encodeInto<T extends ArrayBufferLike>(data: any, destination: Uint8Array<T>, options?: EncodeOptions): {
43
56
  written: number;
44
57
  };
45
58
  /** @implements {Reference} */
@@ -1 +1 @@
1
- {"version":3,"file":"encode.d.ts","sourceRoot":"","sources":["../../lib/encode.js"],"names":[],"mappings":"AAuCA,oCAAoC;AACpC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/F2B,YAAY"}
@@ -11,9 +11,9 @@
11
11
  *
12
12
  * @param {any} obj - Value to encode
13
13
  * @param {EncodeOptions} [options] - Additional options (merged with extended defaults)
14
- * @returns {Uint8Array}
14
+ * @returns {AllocatedByteView}
15
15
  */
16
- export function encode(obj: any, options?: EncodeOptions): Uint8Array;
16
+ export function encode(obj: any, options?: EncodeOptions): AllocatedByteView;
17
17
  /**
18
18
  * Decode CBOR to a value with extended JavaScript type support.
19
19
  *
@@ -24,6 +24,7 @@ export function encode(obj: any, options?: EncodeOptions): Uint8Array;
24
24
  export function decode(data: Uint8Array, options?: DecodeOptions): any;
25
25
  export type EncodeOptions = import("../../interface.js").EncodeOptions;
26
26
  export type DecodeOptions = import("../../interface.js").DecodeOptions;
27
+ export type AllocatedByteView = import("../../interface.js").AllocatedByteView;
27
28
  import { TAG_DATE_EPOCH } from '../taglib.js';
28
29
  import { TAG_BIGINT_POS } from '../taglib.js';
29
30
  import { TAG_BIGINT_NEG } from '../taglib.js';
@@ -1 +1 @@
1
- {"version":3,"file":"extended.d.ts","sourceRoot":"","sources":["../../../lib/extended/extended.js"],"names":[],"mappings":"AAiJA;;;;;;;;;;;;;;GAcG;AACH,4BAJW,GAAG,YACH,aAAa,GACX,UAAU,CAQtB;AAED;;;;;;GAMG;AACH,6BAJW,UAAU,YACV,aAAa,GACX,GAAG,CASf;4BA/FY,OAAO,oBAAoB,EAAE,aAAa;4BAC1C,OAAO,oBAAoB,EAAE,aAAa;+BAJhD,cAAc;+BAAd,cAAc;+BAAd,cAAc;gCAAd,cAAc;wCAAd,cAAc;+BAAd,cAAc;oCAAd,cAAc;oCAAd,cAAc;uCAAd,cAAc;mCAAd,cAAc;mCAAd,cAAc;sCAAd,cAAc;qCAAd,cAAc;qCAAd,cAAc;wBAAd,cAAc;wBAAd,cAAc;2BAAd,cAAc;oCAAd,cAAc;8BAAd,cAAc;iCAAd,cAAc;4BAAd,cAAc;4BAAd,cAAc;8BAAd,cAAc;8BAAd,cAAc;2B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c;oCAAd,cAAc;oCAAd,cAAc;oCAAd,cAAc;sCAAd,cAAc;sCAAd,cAAc;qCAAd,cAAc;qCAAd,cAAc"}
@@ -1,10 +1,11 @@
1
1
  export type EncodeOptions = import("../../interface.js").EncodeOptions;
2
2
  export type ByteWriter = import("../../interface.js").ByteWriter;
3
+ export type AllocatedByteView = import("../../interface.js").AllocatedByteView;
3
4
  export type Token = import("../token.js").Token;
4
5
  /**
5
6
  * @param {any} data
6
7
  * @param {EncodeOptions} [options]
7
- * @returns {Uint8Array}
8
+ * @returns {AllocatedByteView}
8
9
  */
9
- export function encode(data: any, options?: EncodeOptions): Uint8Array;
10
+ export function encode(data: any, options?: EncodeOptions): AllocatedByteView;
10
11
  //# sourceMappingURL=encode.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"encode.d.ts","sourceRoot":"","sources":["../../../lib/json/encode.js"],"names":[],"mappings":"4BAMa,OAAO,oBAAoB,EAAE,aAAa;yBAC1C,OAAO,oBAAoB,EAAE,UAAU;oBACvC,OAAO,aAAa,EAAE,KAAK;AA0RxC;;;;GAIG;AACH,6BAJW,GAAG,YACH,aAAa,GACX,UAAU,CAMtB"}
1
+ {"version":3,"file":"encode.d.ts","sourceRoot":"","sources":["../../../lib/json/encode.js"],"names":[],"mappings":"4BAMa,OAAO,oBAAoB,EAAE,aAAa;yBAC1C,OAAO,oBAAoB,EAAE,UAAU;gCACvC,OAAO,oBAAoB,EAAE,iBAAiB;oBAC9C,OAAO,aAAa,EAAE,KAAK;AA0RxC;;;;GAIG;AACH,6BAJW,GAAG,YACH,aAAa,GACX,iBAAiB,CAM7B"}
@@ -1,12 +1,13 @@
1
1
  /**
2
2
  * @param {Token} token
3
- * @returns {Uint8Array|undefined}
3
+ * @returns {AllocatedByteView|undefined}
4
4
  */
5
- export function quickEncodeToken(token: Token): Uint8Array | undefined;
5
+ export function quickEncodeToken(token: Token): AllocatedByteView | undefined;
6
6
  /** @type {((data:Uint8Array, pos:number, minor:number, options?:DecodeOptions) => any)[]} */
7
7
  export const jump: ((data: Uint8Array, pos: number, minor: number, options?: DecodeOptions) => any)[];
8
8
  /** @type {Token[]} */
9
9
  export const quick: Token[];
10
10
  export type DecodeOptions = import("../interface.js").DecodeOptions;
11
+ export type AllocatedByteView = import("../interface.js").AllocatedByteView;
11
12
  import { Token } from './token.js';
12
13
  //# sourceMappingURL=jump.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"jump.d.ts","sourceRoot":"","sources":["../../lib/jump.js"],"names":[],"mappings":"AAkKA;;;GAGG;AACH,wCAHW,KAAK,GACH,UAAU,GAAC,SAAS,CA0ChC;AA7KD,6FAA6F;AAC7F,mBADW,CAAC,CAAC,IAAI,EAAC,UAAU,EAAE,GAAG,EAAC,MAAM,EAAE,KAAK,EAAC,MAAM,EAAE,OAAO,CAAC,EAAC,aAAa,KAAK,GAAG,CAAC,EAAE,CACnE;AAuGtB,sBAAsB;AACtB,oBADW,KAAK,EAAE,CACK;4BA7HV,OAAO,iBAAiB,EAAE,aAAa;sBAbxB,YAAY"}
1
+ {"version":3,"file":"jump.d.ts","sourceRoot":"","sources":["../../lib/jump.js"],"names":[],"mappings":"AAmKA;;;GAGG;AACH,wCAHW,KAAK,GACH,iBAAiB,GAAC,SAAS,CA0CvC;AA7KD,6FAA6F;AAC7F,mBADW,CAAC,CAAC,IAAI,EAAC,UAAU,EAAE,GAAG,EAAC,MAAM,EAAE,KAAK,EAAC,MAAM,EAAE,OAAO,CAAC,EAAC,aAAa,KAAK,GAAG,CAAC,EAAE,CACnE;AAuGtB,sBAAsB;AACtB,oBADW,KAAK,EAAE,CACK;4BA9HV,OAAO,iBAAiB,EAAE,aAAa;gCACvC,OAAO,iBAAiB,EAAE,iBAAiB;sBAd5B,YAAY"}