microcbor 0.1.0 → 0.2.1

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.
@@ -0,0 +1,205 @@
1
+ var _a;
2
+ import { getFloat16 } from "fp16";
3
+ import { UnsafeIntegerError, maxSafeInteger, minSafeInteger } from "./utils.js";
4
+ class DecoderStream {
5
+ constructor(source) {
6
+ this.offset = 0;
7
+ this.byteLength = 0;
8
+ this.chunks = [];
9
+ this.constantBuffer = new ArrayBuffer(8);
10
+ this.constantView = new DataView(this.constantBuffer);
11
+ this[_a] = () => this;
12
+ this.constant = (size, f) => {
13
+ return async () => {
14
+ await this.allocate(size);
15
+ const array = new Uint8Array(this.constantBuffer, 0, size);
16
+ this.fill(array);
17
+ return f(this.constantView);
18
+ };
19
+ };
20
+ this.float16 = this.constant(2, (view) => getFloat16(view, 0));
21
+ this.float32 = this.constant(4, (view) => view.getFloat32(0));
22
+ this.float64 = this.constant(8, (view) => view.getFloat64(0));
23
+ this.uint8 = this.constant(1, (view) => view.getUint8(0));
24
+ this.uint16 = this.constant(2, (view) => view.getUint16(0));
25
+ this.uint32 = this.constant(4, (view) => view.getUint32(0));
26
+ this.uint64 = this.constant(8, (view) => view.getBigUint64(0));
27
+ this.iter = source[Symbol.asyncIterator]();
28
+ }
29
+ async allocate(size) {
30
+ while (this.byteLength < size) {
31
+ const { done, value } = await this.iter.next();
32
+ if (done) {
33
+ throw new Error("stream ended prematurely");
34
+ }
35
+ else {
36
+ this.chunks.push(value);
37
+ this.byteLength += value.byteLength;
38
+ }
39
+ }
40
+ }
41
+ fill(target) {
42
+ if (this.byteLength < target.byteLength) {
43
+ throw new Error("internal error - please file a bug report!");
44
+ }
45
+ let byteLength = 0;
46
+ let deleteCount = 0;
47
+ for (let i = 0; byteLength < target.byteLength; i++) {
48
+ const chunk = this.chunks[i];
49
+ const capacity = target.byteLength - byteLength;
50
+ const length = chunk.byteLength - this.offset;
51
+ if (length <= capacity) {
52
+ // copy the entire remainder of the chunk
53
+ target.set(chunk.subarray(this.offset), byteLength);
54
+ byteLength += length;
55
+ deleteCount += 1;
56
+ this.offset = 0;
57
+ this.byteLength -= length;
58
+ }
59
+ else {
60
+ // fill the remainder of the target
61
+ target.set(chunk.subarray(this.offset, this.offset + capacity), byteLength);
62
+ byteLength += capacity; // equivalent to break
63
+ this.offset += capacity;
64
+ this.byteLength -= capacity;
65
+ }
66
+ }
67
+ this.chunks.splice(0, deleteCount);
68
+ }
69
+ async decodeBytes(length) {
70
+ await this.allocate(length);
71
+ const array = new Uint8Array(length);
72
+ this.fill(array);
73
+ return array;
74
+ }
75
+ async decodeString(length) {
76
+ await this.allocate(length);
77
+ const data = new Uint8Array(length);
78
+ this.fill(data);
79
+ return new TextDecoder().decode(data);
80
+ }
81
+ async getArgument(additionalInformation) {
82
+ if (additionalInformation < 24) {
83
+ return { value: additionalInformation };
84
+ }
85
+ else if (additionalInformation === 24) {
86
+ return { value: await this.uint8() };
87
+ }
88
+ else if (additionalInformation === 25) {
89
+ return { value: await this.uint16() };
90
+ }
91
+ else if (additionalInformation === 26) {
92
+ return { value: await this.uint32() };
93
+ }
94
+ else if (additionalInformation === 27) {
95
+ const uint64 = await this.uint64();
96
+ const value = maxSafeInteger < uint64 ? Infinity : Number(uint64);
97
+ return { value, uint64 };
98
+ }
99
+ else if (additionalInformation === 31) {
100
+ throw new Error("microcbor does not support decoding indefinite-length items");
101
+ }
102
+ else {
103
+ throw new Error("invalid argument encoding");
104
+ }
105
+ }
106
+ async next() {
107
+ while (this.byteLength === 0) {
108
+ const { done, value } = await this.iter.next();
109
+ if (done) {
110
+ return { done: true, value: undefined };
111
+ }
112
+ else if (value.byteLength > 0) {
113
+ this.chunks.push(value);
114
+ this.byteLength += value.byteLength;
115
+ }
116
+ }
117
+ const value = await this.decodeValue();
118
+ return { done: false, value };
119
+ }
120
+ async decodeValue() {
121
+ const initialByte = await this.uint8();
122
+ const majorType = initialByte >> 5;
123
+ const additionalInformation = initialByte & 0x1f;
124
+ if (majorType === 0) {
125
+ const { value, uint64 } = await this.getArgument(additionalInformation);
126
+ if (uint64 !== undefined && maxSafeInteger < uint64) {
127
+ throw new UnsafeIntegerError("cannot decode integers greater than 2^53-1", uint64);
128
+ }
129
+ else {
130
+ return value;
131
+ }
132
+ }
133
+ else if (majorType === 1) {
134
+ const { value, uint64 } = await this.getArgument(additionalInformation);
135
+ if (uint64 !== undefined && -1n - uint64 < minSafeInteger) {
136
+ throw new UnsafeIntegerError("cannot decode integers less than -2^53+1", -1n - uint64);
137
+ }
138
+ else {
139
+ return -1 - value;
140
+ }
141
+ }
142
+ else if (majorType === 2) {
143
+ const { value: length } = await this.getArgument(additionalInformation);
144
+ return await this.decodeBytes(length);
145
+ }
146
+ else if (majorType === 3) {
147
+ const { value: length } = await this.getArgument(additionalInformation);
148
+ return await this.decodeString(length);
149
+ }
150
+ else if (majorType === 4) {
151
+ const { value: length } = await this.getArgument(additionalInformation);
152
+ const value = new Array(length);
153
+ for (let i = 0; i < length; i++) {
154
+ value[i] = await this.decodeValue();
155
+ }
156
+ return value;
157
+ }
158
+ else if (majorType === 5) {
159
+ const { value: length } = await this.getArgument(additionalInformation);
160
+ const value = {};
161
+ for (let i = 0; i < length; i++) {
162
+ const key = await this.decodeValue();
163
+ if (typeof key !== "string") {
164
+ throw new Error("microcbor only supports string keys in objects");
165
+ }
166
+ value[key] = await this.decodeValue();
167
+ }
168
+ return value;
169
+ }
170
+ else if (majorType === 6) {
171
+ throw new Error("microcbor does not support tagged data items");
172
+ }
173
+ else if (majorType === 7) {
174
+ switch (additionalInformation) {
175
+ case 20:
176
+ return false;
177
+ case 21:
178
+ return true;
179
+ case 22:
180
+ return null;
181
+ case 23:
182
+ return undefined;
183
+ case 24:
184
+ throw new Error("microcbor does not support decoding unassigned simple values");
185
+ case 25:
186
+ return await this.float16();
187
+ case 26:
188
+ return await this.float32();
189
+ case 27:
190
+ return await this.float64();
191
+ case 31:
192
+ throw new Error("microcbor does not support decoding indefinite-length items");
193
+ default:
194
+ throw new Error("invalid simple value");
195
+ }
196
+ }
197
+ else {
198
+ throw new Error("invalid major type");
199
+ }
200
+ }
201
+ }
202
+ _a = Symbol.asyncIterator;
203
+ export async function* decodeStream(source) {
204
+ yield* new DecoderStream(source);
205
+ }
package/lib/encode.d.ts CHANGED
@@ -1,5 +1,35 @@
1
- export interface EncodeOptions {
2
- strictJSON?: boolean;
3
- chunkSize?: number;
1
+ import type { CBORValue } from "./types.js";
2
+ export declare class Encoder {
3
+ static defaultChunkSize: number;
4
+ closed: boolean;
5
+ private buffer;
6
+ private view;
7
+ private offset;
8
+ private readonly encoder;
9
+ private readonly chunkSize;
10
+ constructor(options?: {
11
+ chunkSize?: number;
12
+ noCopy?: boolean;
13
+ });
14
+ private allocate;
15
+ private float16;
16
+ private float32;
17
+ private float64;
18
+ private uint8;
19
+ private uint16;
20
+ private uint32;
21
+ private uint64;
22
+ private encodeTypeAndArgument;
23
+ private encodeNumber;
24
+ private encodeInteger;
25
+ private encodeFloat;
26
+ private encodeString;
27
+ private encodeBytes;
28
+ encodeValue(value: CBORValue): Iterable<Uint8Array>;
29
+ flush(): Iterable<Uint8Array>;
30
+ private static compareKeys;
31
+ private static getAdditionalInformation;
4
32
  }
5
- export declare function encode(value: any, options?: EncodeOptions): Uint8Array;
33
+ export declare function encode(value: CBORValue, options?: {
34
+ chunkSize?: number;
35
+ }): Uint8Array;
package/lib/encode.js CHANGED
@@ -1,193 +1,222 @@
1
- import { getFloat16Precision, getFloat32Precision, setFloat16 } from "fp16";
2
- const defaultChunkSize = 512;
3
- function* allocate(state, size) {
4
- if (state.buffer.byteLength < state.offset + size) {
5
- yield new Uint8Array(state.buffer, 0, state.offset);
6
- const byteLength = Math.max(size, state.options.chunkSize || defaultChunkSize);
7
- state.buffer = new ArrayBuffer(byteLength);
8
- state.view = new DataView(state.buffer);
9
- state.offset = 0;
10
- }
11
- }
12
- const c = (size, f) => function* (state, value) {
13
- yield* allocate(state, size);
14
- f(state, value);
15
- state.offset += size;
16
- };
17
- const constants = {
18
- float16: c(2, (state, value) => setFloat16(state.view, state.offset, value)),
19
- float32: c(4, (state, value) => state.view.setFloat32(state.offset, value)),
20
- float64: c(8, (state, value) => state.view.setFloat64(state.offset, value)),
21
- uint8: c(1, (state, value) => state.view.setUint8(state.offset, value)),
22
- uint16: c(2, (state, value) => state.view.setUint16(state.offset, value)),
23
- uint32: c(4, (state, value) => state.view.setUint32(state.offset, value)),
24
- uint64: c(8, (state, value) => state.view.setBigUint64(state.offset, BigInt(value))),
25
- };
26
- function* encodeTypeAndArgument(state, type, argument) {
27
- const additionalInformation = getAdditionalInformation(argument);
28
- yield* constants.uint8(state, (type << 5) | additionalInformation);
29
- switch (additionalInformation) {
30
- case 24:
31
- return yield* constants.uint8(state, argument);
32
- case 25:
33
- return yield* constants.uint16(state, argument);
34
- case 26:
35
- return yield* constants.uint32(state, argument);
36
- case 27:
37
- return yield* constants.uint64(state, argument);
38
- }
39
- }
40
- function* encodeNumber(state, value) {
41
- if (Object.is(value, 0)) {
42
- yield* encodeInteger(state, value);
43
- }
44
- else if (Object.is(value, -0)) {
45
- yield* encodeFloat(state, value);
46
- }
47
- else if (Math.floor(value) === value &&
48
- Number.MIN_SAFE_INTEGER <= value &&
49
- value <= Number.MAX_SAFE_INTEGER) {
50
- yield* encodeInteger(state, value);
51
- }
52
- else {
53
- if (state.options.strictJSON === true) {
54
- if (isNaN(value)) {
55
- throw new Error("cannot encode NaN when strict mode is enabled");
56
- }
57
- else if (value === Infinity || value === -Infinity) {
58
- throw new Error("cannot encode +/- Infinity when strict mode is enabled");
59
- }
1
+ import { getFloat16Precision, getFloat32Precision, setFloat16, Precision, } from "fp16";
2
+ export class Encoder {
3
+ constructor(options = {}) {
4
+ this.encoder = new TextEncoder();
5
+ this.chunkSize = options.chunkSize || Encoder.defaultChunkSize;
6
+ this.buffer = new ArrayBuffer(this.chunkSize);
7
+ this.view = new DataView(this.buffer);
8
+ this.offset = 0;
9
+ this.closed = false;
10
+ }
11
+ *allocate(size) {
12
+ if (this.buffer.byteLength < this.offset + size) {
13
+ yield new Uint8Array(this.buffer, 0, this.offset);
14
+ const byteLength = Math.max(size, this.chunkSize);
15
+ this.buffer = new ArrayBuffer(byteLength);
16
+ this.view = new DataView(this.buffer);
17
+ this.offset = 0;
60
18
  }
61
- yield* encodeFloat(state, value);
62
19
  }
63
- }
64
- function* encodeInteger(state, value) {
65
- if (value < 0) {
66
- yield* encodeTypeAndArgument(state, 1, -value - 1);
67
- }
68
- else {
69
- yield* encodeTypeAndArgument(state, 0, value);
70
- }
71
- }
72
- function* encodeFloat(state, value) {
73
- if (getFloat16Precision(value) === "exact") {
74
- yield* constants.uint8(state, 0xe0 | 25);
75
- return yield* constants.float16(state, value);
76
- }
77
- else if (getFloat32Precision(value) === "exact") {
78
- yield* constants.uint8(state, 0xe0 | 26);
79
- return yield* constants.float32(state, value);
20
+ *float16(value) {
21
+ yield* this.allocate(2);
22
+ setFloat16(this.view, this.offset, value);
23
+ this.offset += 2;
24
+ }
25
+ *float32(value) {
26
+ yield* this.allocate(4);
27
+ this.view.setFloat32(this.offset, value);
28
+ this.offset += 4;
29
+ }
30
+ *float64(value) {
31
+ yield* this.allocate(8);
32
+ this.view.setFloat64(this.offset, value);
33
+ this.offset += 8;
34
+ }
35
+ *uint8(value) {
36
+ yield* this.allocate(1);
37
+ this.view.setUint8(this.offset, value);
38
+ this.offset += 1;
39
+ }
40
+ *uint16(value) {
41
+ yield* this.allocate(2);
42
+ this.view.setUint16(this.offset, value);
43
+ this.offset += 2;
44
+ }
45
+ *uint32(value) {
46
+ yield* this.allocate(4);
47
+ this.view.setUint32(this.offset, value);
48
+ this.offset += 4;
49
+ }
50
+ *uint64(value) {
51
+ yield* this.allocate(8);
52
+ this.view.setBigUint64(this.offset, BigInt(value));
53
+ this.offset += 8;
54
+ }
55
+ *encodeTypeAndArgument(type, argument) {
56
+ const additionalInformation = Encoder.getAdditionalInformation(argument);
57
+ yield* this.uint8((type << 5) | additionalInformation);
58
+ switch (additionalInformation) {
59
+ case 24:
60
+ return yield* this.uint8(argument);
61
+ case 25:
62
+ return yield* this.uint16(argument);
63
+ case 26:
64
+ return yield* this.uint32(argument);
65
+ case 27:
66
+ return yield* this.uint64(argument);
67
+ }
80
68
  }
81
- else {
82
- yield* constants.uint8(state, 0xe0 | 27);
83
- return yield* constants.float64(state, value);
69
+ *encodeNumber(value) {
70
+ if (Object.is(value, 0)) {
71
+ yield* this.encodeInteger(value);
72
+ }
73
+ else if (Object.is(value, -0)) {
74
+ yield* this.encodeFloat(value);
75
+ }
76
+ else if (Math.floor(value) === value &&
77
+ Number.MIN_SAFE_INTEGER <= value &&
78
+ value <= Number.MAX_SAFE_INTEGER) {
79
+ yield* this.encodeInteger(value);
80
+ }
81
+ else {
82
+ yield* this.encodeFloat(value);
83
+ }
84
84
  }
85
- }
86
- function* encodeString(state, value) {
87
- const data = new TextEncoder().encode(value);
88
- yield* encodeTypeAndArgument(state, 3, data.byteLength);
89
- yield* allocate(state, data.byteLength);
90
- new Uint8Array(state.buffer, state.offset).set(data);
91
- state.offset += data.byteLength;
92
- }
93
- function getAdditionalInformation(argument) {
94
- if (argument < 24) {
95
- return argument;
85
+ *encodeInteger(value) {
86
+ if (value < 0) {
87
+ yield* this.encodeTypeAndArgument(1, -value - 1);
88
+ }
89
+ else {
90
+ yield* this.encodeTypeAndArgument(0, value);
91
+ }
96
92
  }
97
- else if (argument < 0x100) {
98
- return 24;
93
+ *encodeFloat(value) {
94
+ if (getFloat16Precision(value) === Precision.Exact) {
95
+ yield* this.uint8(0xe0 | 25);
96
+ yield* this.float16(value);
97
+ }
98
+ else if (getFloat32Precision(value) === Precision.Exact) {
99
+ yield* this.uint8(0xe0 | 26);
100
+ yield* this.float32(value);
101
+ }
102
+ else {
103
+ yield* this.uint8(0xe0 | 27);
104
+ yield* this.float64(value);
105
+ }
99
106
  }
100
- else if (argument < 0x10000) {
101
- return 25;
107
+ *encodeString(value) {
108
+ const data = this.encoder.encode(value);
109
+ yield* this.encodeTypeAndArgument(3, data.byteLength);
110
+ yield* this.allocate(data.byteLength);
111
+ new Uint8Array(this.buffer, this.offset).set(data);
112
+ this.offset += data.byteLength;
113
+ }
114
+ *encodeBytes(value) {
115
+ yield* this.encodeTypeAndArgument(2, value.byteLength);
116
+ yield* this.allocate(value.byteLength);
117
+ new Uint8Array(this.buffer, this.offset, value.byteLength).set(value);
118
+ this.offset += value.byteLength;
119
+ }
120
+ *encodeValue(value) {
121
+ if (this.closed) {
122
+ return;
123
+ }
124
+ if (value === false) {
125
+ yield* this.uint8(0xf4);
126
+ }
127
+ else if (value === true) {
128
+ yield* this.uint8(0xf5);
129
+ }
130
+ else if (value === null) {
131
+ yield* this.uint8(0xf6);
132
+ }
133
+ else if (value === undefined) {
134
+ yield* this.uint8(0xf7);
135
+ }
136
+ else if (typeof value === "number") {
137
+ yield* this.encodeNumber(value);
138
+ }
139
+ else if (typeof value === "string") {
140
+ yield* this.encodeString(value);
141
+ }
142
+ else if (value instanceof Uint8Array) {
143
+ yield* this.encodeBytes(value);
144
+ }
145
+ else if (Array.isArray(value)) {
146
+ yield* this.encodeTypeAndArgument(4, value.length);
147
+ for (const element of value) {
148
+ yield* this.encodeValue(element);
149
+ }
150
+ }
151
+ else {
152
+ const keys = Object.keys(value).sort(Encoder.compareKeys);
153
+ yield* this.encodeTypeAndArgument(5, keys.length);
154
+ for (const key of keys) {
155
+ yield* this.encodeString(key);
156
+ yield* this.encodeValue(value[key]);
157
+ }
158
+ }
102
159
  }
103
- else if (argument < 0x100000000) {
104
- return 26;
160
+ *flush() {
161
+ if (this.closed) {
162
+ return;
163
+ }
164
+ this.closed = true;
165
+ if (this.offset > 0) {
166
+ yield new Uint8Array(this.buffer, 0, this.offset);
167
+ }
105
168
  }
106
- else {
107
- return 27;
169
+ // Per the deterministic CBOR spec, we're supposed to sort keys
170
+ // the byte-wise lexicographic order of the key's CBOR encoding
171
+ // - ie lower major types come before higher major types!
172
+ // However, microcbor only supports string keys, which means we
173
+ // can get away with sorting them without actually encoding them
174
+ // first. One thing we know for sure about strings is that a
175
+ // string with a smaller length will sort byte-wise before a string
176
+ // with a longer length, since strings are encoded with a length
177
+ // prefix (either in the additionalInformation bits, if < 24, or
178
+ // in the next serveral bytes, but in all cases the order holds).
179
+ static compareKeys(a, b) {
180
+ if (a.length < b.length) {
181
+ return -1;
182
+ }
183
+ else if (b.length < a.length) {
184
+ return 1;
185
+ }
186
+ else {
187
+ return a < b ? -1 : 1;
188
+ }
108
189
  }
109
- }
110
- function* encodeValue(state, value) {
111
- if (value === false) {
112
- return yield* constants.uint8(state, 0xf4);
113
- }
114
- else if (value === true) {
115
- return yield* constants.uint8(state, 0xf5);
116
- }
117
- else if (value === null) {
118
- return yield* constants.uint8(state, 0xf6);
119
- }
120
- else if (value === undefined) {
121
- throw new Error("microcbor does not support encoding the undefined value");
122
- }
123
- else if (typeof value === "number") {
124
- return yield* encodeNumber(state, value);
125
- }
126
- else if (typeof value === "string") {
127
- return yield* encodeString(state, value);
128
- }
129
- else if (Array.isArray(value)) {
130
- yield* encodeTypeAndArgument(state, 4, value.length);
131
- for (const element of value) {
132
- yield* encodeValue(state, element);
133
- }
134
- return;
135
- }
136
- else if (typeof value !== "object") {
137
- throw new Error("invalid value");
138
- }
139
- else {
140
- // Note: this can't be a normal sort, because 'b' needs to sort before
141
- // 'aa'
142
- // Per the deterministic CBOR spec, we're supposed to sort keys
143
- // the byte-wise lexicographic order of the key's CBOR encoding
144
- // - ie lower major types come before higher major types!
145
- // However, microcbor only supports string keys, which means we
146
- // can get away with sorting them without actually encoding them
147
- // first. One thing we know for sure about strings is that a
148
- // string with a smaller length will sort byte-wise before a string
149
- // with a longer length, since strings are encoded with a lengt
150
- // prefix (either in the additionalInformation bits, if < 24, or
151
- // in the next serveral bytes, but in all cases the order holds).
152
- const keys = Object.keys(value).sort((a, b) => {
153
- if (a.length < b.length) {
154
- return -1;
155
- }
156
- else if (b.length < a.length) {
157
- return 1;
158
- }
159
- else {
160
- return a < b ? -1 : 1;
161
- }
162
- });
163
- yield* encodeTypeAndArgument(state, 5, keys.length);
164
- for (const key of keys) {
165
- if (typeof key === "string") {
166
- yield* encodeString(state, key);
167
- yield* encodeValue(state, value[key]);
168
- }
169
- else {
170
- throw new Error("object keys must be strings");
171
- }
190
+ static getAdditionalInformation(argument) {
191
+ if (argument < 24) {
192
+ return argument;
193
+ }
194
+ else if (argument < 0x100) {
195
+ return 24;
196
+ }
197
+ else if (argument < 0x10000) {
198
+ return 25;
199
+ }
200
+ else if (argument < 0x100000000) {
201
+ return 26;
202
+ }
203
+ else {
204
+ return 27;
172
205
  }
173
- return;
174
206
  }
175
207
  }
208
+ Encoder.defaultChunkSize = 512;
176
209
  export function encode(value, options = {}) {
177
- const buffer = new ArrayBuffer(options.chunkSize || defaultChunkSize);
178
- const state = {
179
- options: options,
180
- buffer: buffer,
181
- view: new DataView(buffer),
182
- offset: 0,
183
- };
184
- const chunks = Array.from(encodeValue(state, value));
185
- if (state.offset > 0) {
186
- chunks.push(new Uint8Array(state.buffer, 0, state.offset));
187
- }
210
+ const encoder = new Encoder(options);
188
211
  let byteLength = 0;
189
- for (const chunk of chunks) {
190
- byteLength += chunk.length;
212
+ const chunks = [];
213
+ for (const chunk of encoder.encodeValue(value)) {
214
+ chunks.push(chunk);
215
+ byteLength += chunk.byteLength;
216
+ }
217
+ for (const chunk of encoder.flush()) {
218
+ chunks.push(chunk);
219
+ byteLength += chunk.byteLength;
191
220
  }
192
221
  const data = new Uint8Array(byteLength);
193
222
  let offset = 0;
@@ -0,0 +1,4 @@
1
+ import type { CBORValue } from "./types.js";
2
+ export declare function encodeStream(source: AsyncIterable<CBORValue>, options?: {
3
+ chunkSize?: number;
4
+ }): AsyncIterable<Uint8Array>;
@@ -0,0 +1,8 @@
1
+ import { Encoder } from "./encode.js";
2
+ export async function* encodeStream(source, options = {}) {
3
+ const encoder = new Encoder(options);
4
+ for await (const value of source) {
5
+ yield* encoder.encodeValue(value);
6
+ }
7
+ yield* encoder.flush();
8
+ }
@@ -0,0 +1,2 @@
1
+ import type { CBORValue } from "./types.js";
2
+ export declare function encodingLength(value: CBORValue): number;