@fireproof/vendor 1.0.0 → 1.0.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.
- package/package.json +12 -8
- package/src/@ipld/car/README.md +229 -175
- package/src/@ipld/car/dist/src/reader.d.ts.map +1 -1
- package/src/@ipld/car/src/reader.js +19 -2
- package/src/cborg/.github/dependabot.yml +16 -0
- package/src/cborg/.github/workflows/test-and-release.yml +52 -0
- package/src/cborg/{lib → cborg}/bin.js +2 -2
- package/src/cborg/cborg/common.js +28 -0
- package/src/cborg/{lib → cborg}/decode.js +24 -22
- package/src/cborg/{lib → cborg}/diagnostic.js +6 -4
- package/src/cborg/{lib → cborg}/diagnostic_test.js +1 -1
- package/src/cborg/{lib → cborg}/encode.js +23 -21
- package/src/cborg/{cborg.js → cborg/index.js} +12 -10
- package/src/cborg/{lib → cborg}/length.js +3 -2
- package/src/cborg/interface.ts +7 -4
- package/src/cborg/{lib/json → json}/decode.js +25 -25
- package/src/cborg/{lib/json → json}/encode.js +19 -16
- package/src/cborg/package.json +15 -11
- package/src/cborg/taglib.js +3 -1
- package/src/cborg/test/common.js +1 -1
- package/src/cborg/test/noop-bin-test.js +1 -1
- package/src/cborg/test/test-0uint.js +2 -2
- package/src/cborg/test/test-1negint.js +2 -2
- package/src/cborg/test/test-2bytes.js +2 -2
- package/src/cborg/test/test-3string.js +2 -2
- package/src/cborg/test/test-4array.js +2 -2
- package/src/cborg/test/test-5map.js +2 -2
- package/src/cborg/test/test-6tag.js +2 -3
- package/src/cborg/test/test-7float.js +2 -2
- package/src/cborg/test/test-bl.js +1 -1
- package/src/cborg/test/test-cbor-vectors.js +2 -2
- package/src/cborg/test/test-decode-errors.js +2 -2
- package/src/cborg/test/test-fuzz.js +1 -1
- package/src/cborg/test/test-json.js +25 -25
- package/src/cborg/test/test-length.js +3 -3
- package/src/cborg/test/test-partial.js +2 -2
- package/src/cborg/tsconfig.json +5 -2
- package/src/cborg/types/{lib → cborg}/decode.d.ts +5 -3
- package/src/cborg/types/cborg/decode.d.ts.map +1 -0
- package/src/cborg/types/{lib → cborg}/encode.d.ts +4 -3
- package/src/cborg/types/cborg/encode.d.ts.map +1 -0
- package/src/cborg/types/cborg/index.d.ts +26 -0
- package/src/cborg/types/cborg/index.d.ts.map +1 -0
- package/src/cborg/types/cborg/is.d.ts.map +1 -0
- package/src/cborg/types/interface.d.ts +6 -4
- package/src/cborg/types/interface.d.ts.map +1 -1
- package/src/cborg/types/{lib/json → json}/decode.d.ts +7 -7
- package/src/cborg/types/json/decode.d.ts.map +1 -0
- package/src/cborg/types/json/encode.d.ts +11 -0
- package/src/cborg/types/json/encode.d.ts.map +1 -0
- package/src/cborg/types/json/json.d.ts.map +1 -0
- package/src/cborg/types/taglib.d.ts +1 -1
- package/src/cborg/types/taglib.d.ts.map +1 -1
- package/src/cborg/types/tsconfig.tsbuildinfo +1 -1
- package/src/cborg/types/{lib → utils}/0uint.d.ts +6 -4
- package/src/cborg/types/utils/0uint.d.ts.map +1 -0
- package/src/cborg/types/{lib → utils}/1negint.d.ts +4 -3
- package/src/cborg/types/utils/1negint.d.ts.map +1 -0
- package/src/cborg/types/{lib → utils}/2bytes.d.ts +5 -4
- package/src/cborg/types/utils/2bytes.d.ts.map +1 -0
- package/src/cborg/types/{lib → utils}/3string.d.ts +1 -1
- package/src/cborg/types/utils/3string.d.ts.map +1 -0
- package/src/cborg/types/{lib → utils}/4array.d.ts +3 -2
- package/src/cborg/types/utils/4array.d.ts.map +1 -0
- package/src/cborg/types/{lib → utils}/5map.d.ts +3 -2
- package/src/cborg/types/utils/5map.d.ts.map +1 -0
- package/src/cborg/types/{lib → utils}/6tag.d.ts +4 -3
- package/src/cborg/types/utils/6tag.d.ts.map +1 -0
- package/src/cborg/types/{lib → utils}/7float.d.ts +2 -2
- package/src/cborg/types/utils/7float.d.ts.map +1 -0
- package/src/cborg/types/utils/bl.d.ts.map +1 -0
- package/src/cborg/types/utils/byte-utils.d.ts.map +1 -0
- package/src/cborg/types/utils/common.d.ts +8 -0
- package/src/cborg/types/utils/common.d.ts.map +1 -0
- package/src/cborg/types/utils/index.d.ts +13 -0
- package/src/cborg/types/utils/index.d.ts.map +1 -0
- package/src/cborg/types/utils/jump.d.ts +16 -0
- package/src/cborg/types/utils/jump.d.ts.map +1 -0
- package/src/cborg/types/utils/token.d.ts.map +1 -0
- package/src/cborg/{lib → utils}/0uint.js +16 -14
- package/src/cborg/{lib → utils}/1negint.js +5 -5
- package/src/cborg/{lib → utils}/2bytes.js +16 -14
- package/src/cborg/{lib → utils}/3string.js +4 -4
- package/src/cborg/{lib → utils}/4array.js +7 -6
- package/src/cborg/{lib → utils}/5map.js +6 -6
- package/src/cborg/{lib → utils}/6tag.js +4 -3
- package/src/cborg/{lib → utils}/7float.js +23 -21
- package/src/cborg/{lib → utils}/bl.js +1 -1
- package/src/cborg/utils/common.js +11 -0
- package/src/cborg/utils/index.js +12 -0
- package/src/cborg/utils/jump.js +222 -0
- package/src/cborg/lib/common.js +0 -27
- package/src/cborg/lib/jump.js +0 -209
- package/src/cborg/types/cborg.d.ts +0 -28
- package/src/cborg/types/cborg.d.ts.map +0 -1
- package/src/cborg/types/lib/0uint.d.ts.map +0 -1
- package/src/cborg/types/lib/1negint.d.ts.map +0 -1
- package/src/cborg/types/lib/2bytes.d.ts.map +0 -1
- package/src/cborg/types/lib/3string.d.ts.map +0 -1
- package/src/cborg/types/lib/4array.d.ts.map +0 -1
- package/src/cborg/types/lib/5map.d.ts.map +0 -1
- package/src/cborg/types/lib/6tag.d.ts.map +0 -1
- package/src/cborg/types/lib/7float.d.ts.map +0 -1
- package/src/cborg/types/lib/bin.d.ts +0 -4
- package/src/cborg/types/lib/bin.d.ts.map +0 -1
- package/src/cborg/types/lib/bl.d.ts.map +0 -1
- package/src/cborg/types/lib/byte-utils.d.ts.map +0 -1
- package/src/cborg/types/lib/common.d.ts +0 -10
- package/src/cborg/types/lib/common.d.ts.map +0 -1
- package/src/cborg/types/lib/decode.d.ts.map +0 -1
- package/src/cborg/types/lib/diagnostic.d.ts +0 -12
- package/src/cborg/types/lib/diagnostic.d.ts.map +0 -1
- package/src/cborg/types/lib/diagnostic_test.d.ts +0 -2
- package/src/cborg/types/lib/diagnostic_test.d.ts.map +0 -1
- package/src/cborg/types/lib/encode.d.ts.map +0 -1
- package/src/cborg/types/lib/is.d.ts.map +0 -1
- package/src/cborg/types/lib/json/decode.d.ts.map +0 -1
- package/src/cborg/types/lib/json/encode.d.ts +0 -11
- package/src/cborg/types/lib/json/encode.d.ts.map +0 -1
- package/src/cborg/types/lib/json/forward-cborg.d.ts +0 -6
- package/src/cborg/types/lib/json/forward-cborg.d.ts.map +0 -1
- package/src/cborg/types/lib/json/json.d.ts.map +0 -1
- package/src/cborg/types/lib/jump.d.ts +0 -12
- package/src/cborg/types/lib/jump.d.ts.map +0 -1
- package/src/cborg/types/lib/length.d.ts +0 -27
- package/src/cborg/types/lib/length.d.ts.map +0 -1
- package/src/cborg/types/lib/token.d.ts.map +0 -1
- /package/src/cborg/{lib → cborg}/is.js +0 -0
- /package/src/cborg/{lib/json → json}/json.js +0 -0
- /package/src/cborg/types/{lib → cborg}/is.d.ts +0 -0
- /package/src/cborg/types/{lib/json → json}/json.d.ts +0 -0
- /package/src/cborg/types/{lib → utils}/bl.d.ts +0 -0
- /package/src/cborg/types/{lib → utils}/byte-utils.d.ts +0 -0
- /package/src/cborg/types/{lib → utils}/token.d.ts +0 -0
- /package/src/cborg/{lib → utils}/byte-utils.js +0 -0
- /package/src/cborg/{lib → utils}/token.js +0 -0
|
@@ -0,0 +1,222 @@
|
|
|
1
|
+
import { Token, Type } from './token.js'
|
|
2
|
+
import * as uint from './0uint.js'
|
|
3
|
+
import * as negint from './1negint.js'
|
|
4
|
+
import * as bytes from './2bytes.js'
|
|
5
|
+
import * as string from './3string.js'
|
|
6
|
+
import * as array from './4array.js'
|
|
7
|
+
import * as map from './5map.js'
|
|
8
|
+
import * as tag from './6tag.js'
|
|
9
|
+
import * as float from './7float.js'
|
|
10
|
+
import { fromArray } from './byte-utils.js'
|
|
11
|
+
|
|
12
|
+
/**
|
|
13
|
+
* @typedef {import('../interface.js').DecodeOptions} DecodeOptions
|
|
14
|
+
* @typedef {import('../interface.js').DecodeFunction} DecodeFunction
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* @param {string} decodeErrPrefix
|
|
19
|
+
* @returns {DecodeFunction}
|
|
20
|
+
*/
|
|
21
|
+
function invalidMinorWithPrefix (decodeErrPrefix) {
|
|
22
|
+
/**
|
|
23
|
+
* @param {Uint8Array} data
|
|
24
|
+
* @param {number} pos
|
|
25
|
+
* @param {number} minor
|
|
26
|
+
*/
|
|
27
|
+
return (data, pos, minor) => {
|
|
28
|
+
throw new Error(`${decodeErrPrefix} encountered invalid minor (${minor}) for major ${data[pos] >>> 5}`)
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* @param {string} msg
|
|
34
|
+
* @param {string} decodeErrPrefix
|
|
35
|
+
* @returns {()=>any}
|
|
36
|
+
*/
|
|
37
|
+
function errorer (msg, decodeErrPrefix) {
|
|
38
|
+
return () => { throw new Error(`${decodeErrPrefix} ${msg}`) }
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
/**
|
|
42
|
+
* @param {string} decodeErrPrefix
|
|
43
|
+
* @return {DecodeFunction[]}
|
|
44
|
+
*/
|
|
45
|
+
export function jump (decodeErrPrefix) {
|
|
46
|
+
const invalidMinor = invalidMinorWithPrefix(decodeErrPrefix)
|
|
47
|
+
const jump = Array(256).fill(invalidMinor)
|
|
48
|
+
// unsigned integer, 0x00..0x17 (0..23)
|
|
49
|
+
// for (let i = 0; i <= 0x17; i++) {
|
|
50
|
+
// jump[i] = invalidMinor // uint.decodeUintCompact, handled by quick[]
|
|
51
|
+
// }
|
|
52
|
+
jump[0x18] = uint.decodeUint8 // unsigned integer, one-byte uint8_t follows
|
|
53
|
+
jump[0x19] = uint.decodeUint16 // unsigned integer, two-byte uint16_t follows
|
|
54
|
+
jump[0x1a] = uint.decodeUint32 // unsigned integer, four-byte uint32_t follows
|
|
55
|
+
jump[0x1b] = uint.decodeUint64 // unsigned integer, eight-byte uint64_t follows
|
|
56
|
+
// jump[0x1c] = invalidMinor
|
|
57
|
+
// jump[0x1d] = invalidMinor
|
|
58
|
+
// jump[0x1e] = invalidMinor
|
|
59
|
+
// jump[0x1f] = invalidMinor
|
|
60
|
+
// negative integer, -1-0x00..-1-0x17 (-1..-24)
|
|
61
|
+
// for (let i = 0x20; i <= 0x37; i++) {
|
|
62
|
+
// jump[i] = invalidMinor // negintDecode, handled by quick[]
|
|
63
|
+
// }
|
|
64
|
+
jump[0x38] = negint.decodeNegint8 // negative integer, -1-n one-byte uint8_t for n follows
|
|
65
|
+
jump[0x39] = negint.decodeNegint16 // negative integer, -1-n two-byte uint16_t for n follows
|
|
66
|
+
jump[0x3a] = negint.decodeNegint32 // negative integer, -1-n four-byte uint32_t for follows
|
|
67
|
+
jump[0x3b] = negint.decodeNegint64 // negative integer, -1-n eight-byte uint64_t for follows
|
|
68
|
+
// jump[0x3c] = invalidMinor
|
|
69
|
+
// jump[0x3d] = invalidMinor
|
|
70
|
+
// jump[0x3e] = invalidMinor
|
|
71
|
+
// jump[0x3f] = invalidMinor
|
|
72
|
+
// byte string, 0x00..0x17 bytes follow
|
|
73
|
+
for (let i = 0x40; i <= 0x57; i++) {
|
|
74
|
+
jump[i] = bytes.decodeBytesCompact
|
|
75
|
+
}
|
|
76
|
+
jump[0x58] = bytes.decodeBytes8 // byte string, one-byte uint8_t for n, and then n bytes follow
|
|
77
|
+
jump[0x59] = bytes.decodeBytes16 // byte string, two-byte uint16_t for n, and then n bytes follow
|
|
78
|
+
jump[0x5a] = bytes.decodeBytes32 // byte string, four-byte uint32_t for n, and then n bytes follow
|
|
79
|
+
jump[0x5b] = bytes.decodeBytes64 // byte string, eight-byte uint64_t for n, and then n bytes follow
|
|
80
|
+
// jump[0x5c] = invalidMinor
|
|
81
|
+
// jump[0x5d] = invalidMinor
|
|
82
|
+
// jump[0x5e] = invalidMinor
|
|
83
|
+
jump[0x5f] = errorer('indefinite length bytes/strings are not supported', decodeErrPrefix) // byte string, byte strings follow, terminated by "break"
|
|
84
|
+
// UTF-8 string 0x00..0x17 bytes follow
|
|
85
|
+
for (let i = 0x60; i <= 0x77; i++) {
|
|
86
|
+
jump[i] = string.decodeStringCompact
|
|
87
|
+
}
|
|
88
|
+
jump[0x78] = string.decodeString8 // UTF-8 string, one-byte uint8_t for n, and then n bytes follow
|
|
89
|
+
jump[0x79] = string.decodeString16 // UTF-8 string, two-byte uint16_t for n, and then n bytes follow
|
|
90
|
+
jump[0x7a] = string.decodeString32 // UTF-8 string, four-byte uint32_t for n, and then n bytes follow
|
|
91
|
+
jump[0x7b] = string.decodeString64 // UTF-8 string, eight-byte uint64_t for n, and then n bytes follow
|
|
92
|
+
// jump[0x7c] = invalidMinor
|
|
93
|
+
// jump[0x7d] = invalidMinor
|
|
94
|
+
// jump[0x7e] = invalidMinor
|
|
95
|
+
jump[0x7f] = errorer('indefinite length bytes/strings are not supported', decodeErrPrefix) // UTF-8 strings follow, terminated by "break"
|
|
96
|
+
// array, 0x00..0x17 data items follow
|
|
97
|
+
for (let i = 0x80; i <= 0x97; i++) {
|
|
98
|
+
jump[i] = array.decodeArrayCompact
|
|
99
|
+
}
|
|
100
|
+
jump[0x98] = array.decodeArray8 // array, one-byte uint8_t for n, and then n data items follow
|
|
101
|
+
jump[0x99] = array.decodeArray16 // array, two-byte uint16_t for n, and then n data items follow
|
|
102
|
+
jump[0x9a] = array.decodeArray32 // array, four-byte uint32_t for n, and then n data items follow
|
|
103
|
+
jump[0x9b] = array.decodeArray64 // array, eight-byte uint64_t for n, and then n data items follow
|
|
104
|
+
// jump[0x9c] = invalidMinor
|
|
105
|
+
// jump[0x9d] = invalidMinor
|
|
106
|
+
// jump[0x9e] = invalidMinor
|
|
107
|
+
jump[0x9f] = array.decodeArrayIndefinite // array, data items follow, terminated by "break"
|
|
108
|
+
// map, 0x00..0x17 pairs of data items follow
|
|
109
|
+
for (let i = 0xa0; i <= 0xb7; i++) {
|
|
110
|
+
jump[i] = map.decodeMapCompact
|
|
111
|
+
}
|
|
112
|
+
jump[0xb8] = map.decodeMap8 // map, one-byte uint8_t for n, and then n pairs of data items follow
|
|
113
|
+
jump[0xb9] = map.decodeMap16 // map, two-byte uint16_t for n, and then n pairs of data items follow
|
|
114
|
+
jump[0xba] = map.decodeMap32 // map, four-byte uint32_t for n, and then n pairs of data items follow
|
|
115
|
+
jump[0xbb] = map.decodeMap64 // map, eight-byte uint64_t for n, and then n pairs of data items follow
|
|
116
|
+
// jump[0xbc] = invalidMinor
|
|
117
|
+
// jump[0xbd] = invalidMinor
|
|
118
|
+
// jump[0xbe] = invalidMinor
|
|
119
|
+
jump[0xbf] = map.decodeMapIndefinite // map, pairs of data items follow, terminated by "break"
|
|
120
|
+
// tags
|
|
121
|
+
for (let i = 0xc0; i <= 0xd7; i++) {
|
|
122
|
+
jump[i] = tag.decodeTagCompact
|
|
123
|
+
}
|
|
124
|
+
jump[0xd8] = tag.decodeTag8
|
|
125
|
+
jump[0xd9] = tag.decodeTag16
|
|
126
|
+
jump[0xda] = tag.decodeTag32
|
|
127
|
+
jump[0xdb] = tag.decodeTag64
|
|
128
|
+
// jump[0xdc] = invalidMinor
|
|
129
|
+
// jump[0xdd] = invalidMinor
|
|
130
|
+
// jump[0xde] = invalidMinor
|
|
131
|
+
// jump[0xdf] = invalidMinor
|
|
132
|
+
// 0xe0..0xf3 simple values, unsupported
|
|
133
|
+
for (let i = 0xe0; i <= 0xf3; i++) {
|
|
134
|
+
jump[i] = errorer('simple values are not supported', decodeErrPrefix)
|
|
135
|
+
}
|
|
136
|
+
// jump[0xf4] = invalidMinor // false, handled by quick[]
|
|
137
|
+
// jump[0xf5] = invalidMinor // true, handled by quick[]
|
|
138
|
+
// jump[0xf6] = invalidMinor // null, handled by quick[]
|
|
139
|
+
jump[0xf7] = float.decodeUndefined // undefined
|
|
140
|
+
jump[0xf8] = errorer('simple values are not supported', decodeErrPrefix) // simple value, one byte follows, unsupported
|
|
141
|
+
jump[0xf9] = float.decodeFloat16 // half-precision float (two-byte IEEE 754)
|
|
142
|
+
jump[0xfa] = float.decodeFloat32 // single-precision float (four-byte IEEE 754)
|
|
143
|
+
jump[0xfb] = float.decodeFloat64 // double-precision float (eight-byte IEEE 754)
|
|
144
|
+
// jump[0xfc] = invalidMinor
|
|
145
|
+
// jump[0xfd] = invalidMinor
|
|
146
|
+
// jump[0xfe] = invalidMinor
|
|
147
|
+
jump[0xff] = float.decodeBreak // "break" stop code
|
|
148
|
+
return jump
|
|
149
|
+
}
|
|
150
|
+
|
|
151
|
+
/** @type {Token[]} */
|
|
152
|
+
export const quick = []
|
|
153
|
+
// ints <24
|
|
154
|
+
for (let i = 0; i < 24; i++) {
|
|
155
|
+
quick[i] = new Token(Type.uint, i, 1)
|
|
156
|
+
}
|
|
157
|
+
// negints >= -24
|
|
158
|
+
for (let i = -1; i >= -24; i--) {
|
|
159
|
+
quick[31 - i] = new Token(Type.negint, i, 1)
|
|
160
|
+
}
|
|
161
|
+
// empty bytes
|
|
162
|
+
quick[0x40] = new Token(Type.bytes, new Uint8Array(0), 1)
|
|
163
|
+
// empty string
|
|
164
|
+
quick[0x60] = new Token(Type.string, '', 1)
|
|
165
|
+
// empty list
|
|
166
|
+
quick[0x80] = new Token(Type.array, 0, 1)
|
|
167
|
+
// empty map
|
|
168
|
+
quick[0xa0] = new Token(Type.map, 0, 1)
|
|
169
|
+
// false
|
|
170
|
+
quick[0xf4] = new Token(Type.false, false, 1)
|
|
171
|
+
// true
|
|
172
|
+
quick[0xf5] = new Token(Type.true, true, 1)
|
|
173
|
+
// null
|
|
174
|
+
quick[0xf6] = new Token(Type.null, null, 1)
|
|
175
|
+
|
|
176
|
+
/**
|
|
177
|
+
* @param {Token} token
|
|
178
|
+
* @returns {Uint8Array|undefined}
|
|
179
|
+
*/
|
|
180
|
+
export function quickEncodeToken (token) {
|
|
181
|
+
switch (token.type) {
|
|
182
|
+
case Type.false:
|
|
183
|
+
return fromArray([0xf4])
|
|
184
|
+
case Type.true:
|
|
185
|
+
return fromArray([0xf5])
|
|
186
|
+
case Type.null:
|
|
187
|
+
return fromArray([0xf6])
|
|
188
|
+
case Type.bytes:
|
|
189
|
+
if (!token.value.length) {
|
|
190
|
+
return fromArray([0x40])
|
|
191
|
+
}
|
|
192
|
+
return
|
|
193
|
+
case Type.string:
|
|
194
|
+
if (token.value === '') {
|
|
195
|
+
return fromArray([0x60])
|
|
196
|
+
}
|
|
197
|
+
return
|
|
198
|
+
case Type.array:
|
|
199
|
+
if (token.value === 0) {
|
|
200
|
+
return fromArray([0x80])
|
|
201
|
+
}
|
|
202
|
+
/* c8 ignore next 2 */
|
|
203
|
+
// shouldn't be possible if this were called when there was only one token
|
|
204
|
+
return
|
|
205
|
+
case Type.map:
|
|
206
|
+
if (token.value === 0) {
|
|
207
|
+
return fromArray([0xa0])
|
|
208
|
+
}
|
|
209
|
+
/* c8 ignore next 2 */
|
|
210
|
+
// shouldn't be possible if this were called when there was only one token
|
|
211
|
+
return
|
|
212
|
+
case Type.uint:
|
|
213
|
+
if (token.value < 24) {
|
|
214
|
+
return fromArray([Number(token.value)])
|
|
215
|
+
}
|
|
216
|
+
return
|
|
217
|
+
case Type.negint:
|
|
218
|
+
if (token.value >= -24) {
|
|
219
|
+
return fromArray([31 - Number(token.value)])
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
}
|
package/src/cborg/lib/common.js
DELETED
|
@@ -1,27 +0,0 @@
|
|
|
1
|
-
const decodeErrPrefix = 'CBOR decode error:'
|
|
2
|
-
const encodeErrPrefix = 'CBOR encode error:'
|
|
3
|
-
|
|
4
|
-
const uintMinorPrefixBytes = []
|
|
5
|
-
uintMinorPrefixBytes[23] = 1
|
|
6
|
-
uintMinorPrefixBytes[24] = 2
|
|
7
|
-
uintMinorPrefixBytes[25] = 3
|
|
8
|
-
uintMinorPrefixBytes[26] = 5
|
|
9
|
-
uintMinorPrefixBytes[27] = 9
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* @param {Uint8Array} data
|
|
13
|
-
* @param {number} pos
|
|
14
|
-
* @param {number} need
|
|
15
|
-
*/
|
|
16
|
-
function assertEnoughData (data, pos, need) {
|
|
17
|
-
if (data.length - pos < need) {
|
|
18
|
-
throw new Error(`${decodeErrPrefix} not enough data for type`)
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
export {
|
|
23
|
-
decodeErrPrefix,
|
|
24
|
-
encodeErrPrefix,
|
|
25
|
-
uintMinorPrefixBytes,
|
|
26
|
-
assertEnoughData
|
|
27
|
-
}
|
package/src/cborg/lib/jump.js
DELETED
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
import { Token, Type } from './token.js'
|
|
2
|
-
import * as uint from './0uint.js'
|
|
3
|
-
import * as negint from './1negint.js'
|
|
4
|
-
import * as bytes from './2bytes.js'
|
|
5
|
-
import * as string from './3string.js'
|
|
6
|
-
import * as array from './4array.js'
|
|
7
|
-
import * as map from './5map.js'
|
|
8
|
-
import * as tag from './6tag.js'
|
|
9
|
-
import * as float from './7float.js'
|
|
10
|
-
import { decodeErrPrefix } from './common.js'
|
|
11
|
-
import { fromArray } from './byte-utils.js'
|
|
12
|
-
|
|
13
|
-
/**
|
|
14
|
-
* @typedef {import('../interface').DecodeOptions} DecodeOptions
|
|
15
|
-
*/
|
|
16
|
-
|
|
17
|
-
/**
|
|
18
|
-
* @param {Uint8Array} data
|
|
19
|
-
* @param {number} pos
|
|
20
|
-
* @param {number} minor
|
|
21
|
-
*/
|
|
22
|
-
function invalidMinor (data, pos, minor) {
|
|
23
|
-
throw new Error(`${decodeErrPrefix} encountered invalid minor (${minor}) for major ${data[pos] >>> 5}`)
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* @param {string} msg
|
|
28
|
-
* @returns {()=>any}
|
|
29
|
-
*/
|
|
30
|
-
function errorer (msg) {
|
|
31
|
-
return () => { throw new Error(`${decodeErrPrefix} ${msg}`) }
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
/** @type {((data:Uint8Array, pos:number, minor:number, options?:DecodeOptions) => any)[]} */
|
|
35
|
-
export const jump = []
|
|
36
|
-
|
|
37
|
-
// unsigned integer, 0x00..0x17 (0..23)
|
|
38
|
-
for (let i = 0; i <= 0x17; i++) {
|
|
39
|
-
jump[i] = invalidMinor // uint.decodeUintCompact, handled by quick[]
|
|
40
|
-
}
|
|
41
|
-
jump[0x18] = uint.decodeUint8 // unsigned integer, one-byte uint8_t follows
|
|
42
|
-
jump[0x19] = uint.decodeUint16 // unsigned integer, two-byte uint16_t follows
|
|
43
|
-
jump[0x1a] = uint.decodeUint32 // unsigned integer, four-byte uint32_t follows
|
|
44
|
-
jump[0x1b] = uint.decodeUint64 // unsigned integer, eight-byte uint64_t follows
|
|
45
|
-
jump[0x1c] = invalidMinor
|
|
46
|
-
jump[0x1d] = invalidMinor
|
|
47
|
-
jump[0x1e] = invalidMinor
|
|
48
|
-
jump[0x1f] = invalidMinor
|
|
49
|
-
// negative integer, -1-0x00..-1-0x17 (-1..-24)
|
|
50
|
-
for (let i = 0x20; i <= 0x37; i++) {
|
|
51
|
-
jump[i] = invalidMinor // negintDecode, handled by quick[]
|
|
52
|
-
}
|
|
53
|
-
jump[0x38] = negint.decodeNegint8 // negative integer, -1-n one-byte uint8_t for n follows
|
|
54
|
-
jump[0x39] = negint.decodeNegint16 // negative integer, -1-n two-byte uint16_t for n follows
|
|
55
|
-
jump[0x3a] = negint.decodeNegint32 // negative integer, -1-n four-byte uint32_t for follows
|
|
56
|
-
jump[0x3b] = negint.decodeNegint64 // negative integer, -1-n eight-byte uint64_t for follows
|
|
57
|
-
jump[0x3c] = invalidMinor
|
|
58
|
-
jump[0x3d] = invalidMinor
|
|
59
|
-
jump[0x3e] = invalidMinor
|
|
60
|
-
jump[0x3f] = invalidMinor
|
|
61
|
-
// byte string, 0x00..0x17 bytes follow
|
|
62
|
-
for (let i = 0x40; i <= 0x57; i++) {
|
|
63
|
-
jump[i] = bytes.decodeBytesCompact
|
|
64
|
-
}
|
|
65
|
-
jump[0x58] = bytes.decodeBytes8 // byte string, one-byte uint8_t for n, and then n bytes follow
|
|
66
|
-
jump[0x59] = bytes.decodeBytes16 // byte string, two-byte uint16_t for n, and then n bytes follow
|
|
67
|
-
jump[0x5a] = bytes.decodeBytes32 // byte string, four-byte uint32_t for n, and then n bytes follow
|
|
68
|
-
jump[0x5b] = bytes.decodeBytes64 // byte string, eight-byte uint64_t for n, and then n bytes follow
|
|
69
|
-
jump[0x5c] = invalidMinor
|
|
70
|
-
jump[0x5d] = invalidMinor
|
|
71
|
-
jump[0x5e] = invalidMinor
|
|
72
|
-
jump[0x5f] = errorer('indefinite length bytes/strings are not supported') // byte string, byte strings follow, terminated by "break"
|
|
73
|
-
// UTF-8 string 0x00..0x17 bytes follow
|
|
74
|
-
for (let i = 0x60; i <= 0x77; i++) {
|
|
75
|
-
jump[i] = string.decodeStringCompact
|
|
76
|
-
}
|
|
77
|
-
jump[0x78] = string.decodeString8 // UTF-8 string, one-byte uint8_t for n, and then n bytes follow
|
|
78
|
-
jump[0x79] = string.decodeString16 // UTF-8 string, two-byte uint16_t for n, and then n bytes follow
|
|
79
|
-
jump[0x7a] = string.decodeString32 // UTF-8 string, four-byte uint32_t for n, and then n bytes follow
|
|
80
|
-
jump[0x7b] = string.decodeString64 // UTF-8 string, eight-byte uint64_t for n, and then n bytes follow
|
|
81
|
-
jump[0x7c] = invalidMinor
|
|
82
|
-
jump[0x7d] = invalidMinor
|
|
83
|
-
jump[0x7e] = invalidMinor
|
|
84
|
-
jump[0x7f] = errorer('indefinite length bytes/strings are not supported') // UTF-8 strings follow, terminated by "break"
|
|
85
|
-
// array, 0x00..0x17 data items follow
|
|
86
|
-
for (let i = 0x80; i <= 0x97; i++) {
|
|
87
|
-
jump[i] = array.decodeArrayCompact
|
|
88
|
-
}
|
|
89
|
-
jump[0x98] = array.decodeArray8 // array, one-byte uint8_t for n, and then n data items follow
|
|
90
|
-
jump[0x99] = array.decodeArray16 // array, two-byte uint16_t for n, and then n data items follow
|
|
91
|
-
jump[0x9a] = array.decodeArray32 // array, four-byte uint32_t for n, and then n data items follow
|
|
92
|
-
jump[0x9b] = array.decodeArray64 // array, eight-byte uint64_t for n, and then n data items follow
|
|
93
|
-
jump[0x9c] = invalidMinor
|
|
94
|
-
jump[0x9d] = invalidMinor
|
|
95
|
-
jump[0x9e] = invalidMinor
|
|
96
|
-
jump[0x9f] = array.decodeArrayIndefinite // array, data items follow, terminated by "break"
|
|
97
|
-
// map, 0x00..0x17 pairs of data items follow
|
|
98
|
-
for (let i = 0xa0; i <= 0xb7; i++) {
|
|
99
|
-
jump[i] = map.decodeMapCompact
|
|
100
|
-
}
|
|
101
|
-
jump[0xb8] = map.decodeMap8 // map, one-byte uint8_t for n, and then n pairs of data items follow
|
|
102
|
-
jump[0xb9] = map.decodeMap16 // map, two-byte uint16_t for n, and then n pairs of data items follow
|
|
103
|
-
jump[0xba] = map.decodeMap32 // map, four-byte uint32_t for n, and then n pairs of data items follow
|
|
104
|
-
jump[0xbb] = map.decodeMap64 // map, eight-byte uint64_t for n, and then n pairs of data items follow
|
|
105
|
-
jump[0xbc] = invalidMinor
|
|
106
|
-
jump[0xbd] = invalidMinor
|
|
107
|
-
jump[0xbe] = invalidMinor
|
|
108
|
-
jump[0xbf] = map.decodeMapIndefinite // map, pairs of data items follow, terminated by "break"
|
|
109
|
-
// tags
|
|
110
|
-
for (let i = 0xc0; i <= 0xd7; i++) {
|
|
111
|
-
jump[i] = tag.decodeTagCompact
|
|
112
|
-
}
|
|
113
|
-
jump[0xd8] = tag.decodeTag8
|
|
114
|
-
jump[0xd9] = tag.decodeTag16
|
|
115
|
-
jump[0xda] = tag.decodeTag32
|
|
116
|
-
jump[0xdb] = tag.decodeTag64
|
|
117
|
-
jump[0xdc] = invalidMinor
|
|
118
|
-
jump[0xdd] = invalidMinor
|
|
119
|
-
jump[0xde] = invalidMinor
|
|
120
|
-
jump[0xdf] = invalidMinor
|
|
121
|
-
// 0xe0..0xf3 simple values, unsupported
|
|
122
|
-
for (let i = 0xe0; i <= 0xf3; i++) {
|
|
123
|
-
jump[i] = errorer('simple values are not supported')
|
|
124
|
-
}
|
|
125
|
-
jump[0xf4] = invalidMinor // false, handled by quick[]
|
|
126
|
-
jump[0xf5] = invalidMinor // true, handled by quick[]
|
|
127
|
-
jump[0xf6] = invalidMinor // null, handled by quick[]
|
|
128
|
-
jump[0xf7] = float.decodeUndefined // undefined
|
|
129
|
-
jump[0xf8] = errorer('simple values are not supported') // simple value, one byte follows, unsupported
|
|
130
|
-
jump[0xf9] = float.decodeFloat16 // half-precision float (two-byte IEEE 754)
|
|
131
|
-
jump[0xfa] = float.decodeFloat32 // single-precision float (four-byte IEEE 754)
|
|
132
|
-
jump[0xfb] = float.decodeFloat64 // double-precision float (eight-byte IEEE 754)
|
|
133
|
-
jump[0xfc] = invalidMinor
|
|
134
|
-
jump[0xfd] = invalidMinor
|
|
135
|
-
jump[0xfe] = invalidMinor
|
|
136
|
-
jump[0xff] = float.decodeBreak // "break" stop code
|
|
137
|
-
|
|
138
|
-
/** @type {Token[]} */
|
|
139
|
-
export const quick = []
|
|
140
|
-
// ints <24
|
|
141
|
-
for (let i = 0; i < 24; i++) {
|
|
142
|
-
quick[i] = new Token(Type.uint, i, 1)
|
|
143
|
-
}
|
|
144
|
-
// negints >= -24
|
|
145
|
-
for (let i = -1; i >= -24; i--) {
|
|
146
|
-
quick[31 - i] = new Token(Type.negint, i, 1)
|
|
147
|
-
}
|
|
148
|
-
// empty bytes
|
|
149
|
-
quick[0x40] = new Token(Type.bytes, new Uint8Array(0), 1)
|
|
150
|
-
// empty string
|
|
151
|
-
quick[0x60] = new Token(Type.string, '', 1)
|
|
152
|
-
// empty list
|
|
153
|
-
quick[0x80] = new Token(Type.array, 0, 1)
|
|
154
|
-
// empty map
|
|
155
|
-
quick[0xa0] = new Token(Type.map, 0, 1)
|
|
156
|
-
// false
|
|
157
|
-
quick[0xf4] = new Token(Type.false, false, 1)
|
|
158
|
-
// true
|
|
159
|
-
quick[0xf5] = new Token(Type.true, true, 1)
|
|
160
|
-
// null
|
|
161
|
-
quick[0xf6] = new Token(Type.null, null, 1)
|
|
162
|
-
|
|
163
|
-
/**
|
|
164
|
-
* @param {Token} token
|
|
165
|
-
* @returns {Uint8Array|undefined}
|
|
166
|
-
*/
|
|
167
|
-
export function quickEncodeToken (token) {
|
|
168
|
-
switch (token.type) {
|
|
169
|
-
case Type.false:
|
|
170
|
-
return fromArray([0xf4])
|
|
171
|
-
case Type.true:
|
|
172
|
-
return fromArray([0xf5])
|
|
173
|
-
case Type.null:
|
|
174
|
-
return fromArray([0xf6])
|
|
175
|
-
case Type.bytes:
|
|
176
|
-
if (!token.value.length) {
|
|
177
|
-
return fromArray([0x40])
|
|
178
|
-
}
|
|
179
|
-
return
|
|
180
|
-
case Type.string:
|
|
181
|
-
if (token.value === '') {
|
|
182
|
-
return fromArray([0x60])
|
|
183
|
-
}
|
|
184
|
-
return
|
|
185
|
-
case Type.array:
|
|
186
|
-
if (token.value === 0) {
|
|
187
|
-
return fromArray([0x80])
|
|
188
|
-
}
|
|
189
|
-
/* c8 ignore next 2 */
|
|
190
|
-
// shouldn't be possible if this were called when there was only one token
|
|
191
|
-
return
|
|
192
|
-
case Type.map:
|
|
193
|
-
if (token.value === 0) {
|
|
194
|
-
return fromArray([0xa0])
|
|
195
|
-
}
|
|
196
|
-
/* c8 ignore next 2 */
|
|
197
|
-
// shouldn't be possible if this were called when there was only one token
|
|
198
|
-
return
|
|
199
|
-
case Type.uint:
|
|
200
|
-
if (token.value < 24) {
|
|
201
|
-
return fromArray([Number(token.value)])
|
|
202
|
-
}
|
|
203
|
-
return
|
|
204
|
-
case Type.negint:
|
|
205
|
-
if (token.value >= -24) {
|
|
206
|
-
return fromArray([31 - Number(token.value)])
|
|
207
|
-
}
|
|
208
|
-
}
|
|
209
|
-
}
|
|
@@ -1,28 +0,0 @@
|
|
|
1
|
-
export { encodeCustom } from "./lib/encode.js";
|
|
2
|
-
/**
|
|
3
|
-
* There was originally just `TypeEncoder` so don't break types by renaming or not exporting
|
|
4
|
-
*/
|
|
5
|
-
export type TagDecoder = import("./interface").TagDecoder;
|
|
6
|
-
/**
|
|
7
|
-
* Export the types that were present in the original manual cborg.d.ts
|
|
8
|
-
*/
|
|
9
|
-
export type TypeEncoder = import("./interface").OptionalTypeEncoder;
|
|
10
|
-
/**
|
|
11
|
-
* Export the types that were present in the original manual cborg.d.ts
|
|
12
|
-
*/
|
|
13
|
-
export type DecodeOptions = import("./interface").DecodeOptions;
|
|
14
|
-
/**
|
|
15
|
-
* Export the types that were present in the original manual cborg.d.ts
|
|
16
|
-
*/
|
|
17
|
-
export type EncodeOptions = import("./interface").EncodeOptions;
|
|
18
|
-
import { decode } from './lib/decode.js';
|
|
19
|
-
import { decodeFirst } from './lib/decode.js';
|
|
20
|
-
import { Tokeniser } from './lib/decode.js';
|
|
21
|
-
import { tokensToObject } from './lib/decode.js';
|
|
22
|
-
import { encode } from './lib/encode.js';
|
|
23
|
-
import { Token } from './lib/token.js';
|
|
24
|
-
import { Type } from './lib/token.js';
|
|
25
|
-
export { decode, decodeFirst, Tokeniser as Tokenizer, tokensToObject, encode, Token, Type };
|
|
26
|
-
export { encodeErrPrefix, decodeErrPrefix } from "./lib/common.js";
|
|
27
|
-
export { asU8A, fromString, decodeCodePointsArray } from "./lib/byte-utils.js";
|
|
28
|
-
//# sourceMappingURL=cborg.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"cborg.d.ts","sourceRoot":"","sources":["../cborg.js"],"names":[],"mappings":";;;;yBAWa,OAAO,aAAa,EAAE,UAAU;;;;0BAEhC,OAAO,aAAa,EAAE,mBAAmB;;;;4BACzC,OAAO,aAAa,EAAE,aAAa;;;;4BACnC,OAAO,aAAa,EAAE,aAAa;uBAde,iBAAiB;4BAAjB,iBAAiB;0BAAjB,iBAAiB;+BAAjB,iBAAiB;uBADzD,iBAAiB;sBAEZ,gBAAgB;qBAAhB,gBAAgB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"0uint.d.ts","sourceRoot":"","sources":["../../lib/0uint.js"],"names":[],"mappings":"AAOA;;;GAGG;AAEH;;;;;GAKG;AACH,gCALW,UAAU,UACV,MAAM,WACN,aAAa,GACX,MAAM,CASlB;AAED;;;;;GAKG;AACH,iCALW,UAAU,UACV,MAAM,WACN,aAAa,GACX,MAAM,CASlB;AAED;;;;;GAKG;AACH,iCALW,UAAU,UACV,MAAM,WACN,aAAa,GACX,MAAM,CASlB;AAED;;;;;GAKG;AACH,iCALW,UAAU,UACV,MAAM,WACN,aAAa,GACX,MAAM,GAAC,MAAM,CAkBzB;AASD;;;;;;GAMG;AACH,kCANW,UAAU,OACV,MAAM,UACN,MAAM,WACN,aAAa,GACX,KAAK,CAIjB;AAED;;;;;;GAMG;AACH,mCANW,UAAU,OACV,MAAM,UACN,MAAM,WACN,aAAa,GACX,KAAK,CAIjB;AAED;;;;;;GAMG;AACH,mCANW,UAAU,OACV,MAAM,UACN,MAAM,WACN,aAAa,GACX,KAAK,CAIjB;AAED;;;;;;GAMG;AACH,mCANW,UAAU,OACV,MAAM,UACN,MAAM,WACN,aAAa,GACX,KAAK,CAIjB;AAED;;;GAGG;AACH,gCAHW,EAAE,SACF,KAAK,QAIf;;IAqDD;;;OAGG;IACH,4BAHW,KAAK,GACH,MAAM,CAIlB;IAsBD;;;;OAIG;IACH,6BAJW,KAAK,QACL,KAAK,GACH,MAAM,CAIlB;;AAtFD;;;;GAIG;AACH,qCAJW,EAAE,SACF,MAAM,QACN,MAAM,GAAC,MAAM,QA8CvB;;IAUD;;;OAGG;IACH,2BAHW,MAAM,GACJ,MAAM,CAgBlB;;AApND,iDAA0F;iBAG7E,OAAO,SAAS,EAAE,EAAE;4BACpB,OAAO,cAAc,EAAE,aAAa;sBAPrB,YAAY"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"1negint.d.ts","sourceRoot":"","sources":["../../lib/1negint.js"],"names":[],"mappings":"AAMA;;;GAGG;AAEH;;;;;;GAMG;AACH,oCANW,UAAU,OACV,MAAM,UACN,MAAM,WACN,aAAa,GACX,KAAK,CAIjB;AAED;;;;;;GAMG;AACH,qCANW,UAAU,OACV,MAAM,UACN,MAAM,WACN,aAAa,GACX,KAAK,CAIjB;AAED;;;;;;GAMG;AACH,qCANW,UAAU,OACV,MAAM,UACN,MAAM,WACN,aAAa,GACX,KAAK,CAIjB;AAKD;;;;;;GAMG;AACH,qCANW,UAAU,OACV,MAAM,UACN,MAAM,WACN,aAAa,GACX,KAAK,CAcjB;AAED;;;GAGG;AACH,kCAHW,EAAE,SACF,KAAK,QAMf;;IAED;;;OAGG;IACH,4BAHW,KAAK,GACH,MAAM,CAoBlB;IAED;;;;OAIG;IACH,6BAJW,KAAK,QACL,KAAK,GACH,MAAM,CAKlB;;iBAvGY,OAAO,SAAS,EAAE,EAAE;4BACpB,OAAO,cAAc,EAAE,aAAa;sBANrB,YAAY"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"2bytes.d.ts","sourceRoot":"","sources":["../../lib/2bytes.js"],"names":[],"mappings":"AAuBA;;;;;;GAMG;AACH,yCANW,UAAU,OACV,MAAM,SACN,MAAM,YACN,aAAa,GACX,KAAK,CAIjB;AAED;;;;;;GAMG;AACH,mCANW,UAAU,OACV,MAAM,UACN,MAAM,WACN,aAAa,GACX,KAAK,CAIjB;AAED;;;;;;GAMG;AACH,oCANW,UAAU,OACV,MAAM,UACN,MAAM,WACN,aAAa,GACX,KAAK,CAIjB;AAED;;;;;;GAMG;AACH,oCANW,UAAU,OACV,MAAM,UACN,MAAM,WACN,aAAa,GACX,KAAK,CAIjB;AAGD;;;;;;GAMG;AACH,oCANW,UAAU,OACV,MAAM,UACN,MAAM,WACN,aAAa,GACX,KAAK,CAQjB;AAgBD;;;GAGG;AACH,iCAHW,EAAE,SACF,KAAK,QAMf;;IAED;;;OAGG;IACH,4BAHW,KAAK,GACH,MAAM,CAKlB;IAED;;;;OAIG;IACH,6BAJW,KAAK,QACL,KAAK,GACH,MAAM,CAIlB;;AAED;;;;GAIG;AACH,iCAJW,UAAU,MACV,UAAU,GACR,MAAM,CAIlB;iBA9HY,OAAO,SAAS,EAAE,EAAE;4BACpB,OAAO,cAAc,EAAE,aAAa;sBAPrB,YAAY"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"3string.d.ts","sourceRoot":"","sources":["../../lib/3string.js"],"names":[],"mappings":"AA6BA;;;;;;GAMG;AACH,0CANW,UAAU,OACV,MAAM,SACN,MAAM,WACN,aAAa,GACX,KAAK,CAIjB;AAED;;;;;;GAMG;AACH,oCANW,UAAU,OACV,MAAM,UACN,MAAM,WACN,aAAa,GACX,KAAK,CAIjB;AAED;;;;;;GAMG;AACH,qCANW,UAAU,OACV,MAAM,UACN,MAAM,WACN,aAAa,GACX,KAAK,CAIjB;AAED;;;;;;GAMG;AACH,qCANW,UAAU,OACV,MAAM,UACN,MAAM,WACN,aAAa,GACX,KAAK,CAIjB;AAGD;;;;;;GAMG;AACH,qCANW,UAAU,OACV,MAAM,UACN,MAAM,WACN,aAAa,GACX,KAAK,CAQjB;AAED,8CAAuC;iBAlF1B,OAAO,SAAS,EAAE,EAAE;4BACpB,OAAO,cAAc,EAAE,aAAa;sBARrB,YAAY;4BAGZ,aAAa"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"4array.d.ts","sourceRoot":"","sources":["../../lib/4array.js"],"names":[],"mappings":"AAoBA;;;;;;GAMG;AACH,yCANW,UAAU,OACV,MAAM,SACN,MAAM,YACN,aAAa,GACX,KAAK,CAIjB;AAED;;;;;;GAMG;AACH,mCANW,UAAU,OACV,MAAM,UACN,MAAM,WACN,aAAa,GACX,KAAK,CAIjB;AAED;;;;;;GAMG;AACH,oCANW,UAAU,OACV,MAAM,UACN,MAAM,WACN,aAAa,GACX,KAAK,CAIjB;AAED;;;;;;GAMG;AACH,oCANW,UAAU,OACV,MAAM,UACN,MAAM,WACN,aAAa,GACX,KAAK,CAIjB;AAGD;;;;;;GAMG;AACH,oCANW,UAAU,OACV,MAAM,UACN,MAAM,WACN,aAAa,GACX,KAAK,CAQjB;AAED;;;;;;GAMG;AACH,4CANW,UAAU,OACV,MAAM,UACN,MAAM,WACN,aAAa,GACX,KAAK,CAOjB;AAED;;;GAGG;AACH,iCAHW,EAAE,SACF,KAAK,QAIf;;;IAMD;;;OAGG;IACH,4BAHW,KAAK,GACH,MAAM,CAIlB;;iBA3GY,OAAO,SAAS,EAAE,EAAE;4BACpB,OAAO,cAAc,EAAE,aAAa;sBANrB,YAAY"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"5map.d.ts","sourceRoot":"","sources":["../../lib/5map.js"],"names":[],"mappings":"AAoBA;;;;;;GAMG;AACH,uCANW,UAAU,OACV,MAAM,SACN,MAAM,YACN,aAAa,GACX,KAAK,CAIjB;AAED;;;;;;GAMG;AACH,iCANW,UAAU,OACV,MAAM,UACN,MAAM,WACN,aAAa,GACX,KAAK,CAIjB;AAED;;;;;;GAMG;AACH,kCANW,UAAU,OACV,MAAM,UACN,MAAM,WACN,aAAa,GACX,KAAK,CAIjB;AAED;;;;;;GAMG;AACH,kCANW,UAAU,OACV,MAAM,UACN,MAAM,WACN,aAAa,GACX,KAAK,CAIjB;AAGD;;;;;;GAMG;AACH,kCANW,UAAU,OACV,MAAM,UACN,MAAM,WACN,aAAa,GACX,KAAK,CAQjB;AAED;;;;;;GAMG;AACH,0CANW,UAAU,OACV,MAAM,UACN,MAAM,WACN,aAAa,GACX,KAAK,CAOjB;AAED;;;GAGG;AACH,+BAHW,EAAE,SACF,KAAK,QAIf;;;IAMD;;;OAGG;IACH,4BAHW,KAAK,GACH,MAAM,CAIlB;;iBA3GY,OAAO,SAAS,EAAE,EAAE;4BACpB,OAAO,cAAc,EAAE,aAAa;sBANrB,YAAY"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"6tag.d.ts","sourceRoot":"","sources":["../../lib/6tag.js"],"names":[],"mappings":"AAGA;;;GAGG;AAEH;;;;;;GAMG;AACH,wCANW,UAAU,QACV,MAAM,SACN,MAAM,YACN,aAAa,GACX,KAAK,CAIjB;AAED;;;;;;GAMG;AACH,iCANW,UAAU,OACV,MAAM,UACN,MAAM,WACN,aAAa,GACX,KAAK,CAIjB;AAED;;;;;;GAMG;AACH,kCANW,UAAU,OACV,MAAM,UACN,MAAM,WACN,aAAa,GACX,KAAK,CAIjB;AAED;;;;;;GAMG;AACH,kCANW,UAAU,OACV,MAAM,UACN,MAAM,WACN,aAAa,GACX,KAAK,CAIjB;AAED;;;;;;GAMG;AACH,kCANW,UAAU,OACV,MAAM,UACN,MAAM,WACN,aAAa,GACX,KAAK,CAIjB;AAED;;;GAGG;AACH,+BAHW,EAAE,SACF,KAAK,QAIf;;;IAID;;;OAGG;IACH,4BAHW,KAAK,GACH,MAAM,CAIlB;;iBA3EY,OAAO,SAAS,EAAE,EAAE;4BACpB,OAAO,cAAc,EAAE,aAAa;sBALrB,YAAY"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"7float.d.ts","sourceRoot":"","sources":["../../lib/7float.js"],"names":[],"mappings":"AAkBA;;;;;;GAMG;AACH,uCANW,UAAU,QACV,MAAM,UACN,MAAM,WACN,aAAa,GACX,KAAK,CASjB;AAED;;;;;;GAMG;AACH,mCANW,UAAU,QACV,MAAM,UACN,MAAM,WACN,aAAa,GACX,KAAK,CAOjB;AAoBD;;;;;;GAMG;AACH,oCANW,UAAU,OACV,MAAM,UACN,MAAM,WACN,aAAa,GACX,KAAK,CAIjB;AAED;;;;;;GAMG;AACH,oCANW,UAAU,OACV,MAAM,UACN,MAAM,WACN,aAAa,GACX,KAAK,CAIjB;AAED;;;;;;GAMG;AACH,oCANW,UAAU,OACV,MAAM,UACN,MAAM,WACN,aAAa,GACX,KAAK,CAIjB;AAED;;;;GAIG;AACH,iCAJW,EAAE,SACF,KAAK,WACL,aAAa,QAwCvB;;IAED;;;;OAIG;IACH,4BAJW,KAAK,WACL,aAAa,GACX,MAAM,CAsBlB;;;iBAjKY,OAAO,SAAS,EAAE,EAAE;4BACpB,OAAO,cAAc,EAAE,aAAa;4BACpC,OAAO,cAAc,EAAE,aAAa;sBAPrB,YAAY"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"bin.d.ts","sourceRoot":"","sources":["../../lib/bin.js"],"names":[],"mappings":";wBA4Le,IAAI"}
|
|
@@ -1 +0,0 @@
|
|
|
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,CAwBtB;CACF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"byte-utils.d.ts","sourceRoot":"","sources":["../../lib/byte-utils.js"],"names":[],"mappings":"AAwBA;;;GAGG;AACH,2BAHW,UAAU,GAAC,MAAM,EAAE,GACjB,UAAU,CAQtB;AA8ND;;;;GAIG;AACH,4BAJW,UAAU,MACV,UAAU,GACR,MAAM,CAgBlB;AAyHD;;;GAGG;AACH,kDAHW,MAAM,EAAE,GACN,MAAM,CAkBlB;AA5ZD,gCAMkD;AA4B9C;;;;GAIG;AACH,gCAJW,UAAU,SACV,MAAM,OACN,MAAM,UAQhB;AAcL,mCAGe,MAAM,iDAYN,MAAM,6CAIhB;AAOE,+BAHI,MAAM,EAAE,GACN,UAAU,CAItB;AAIG;;;;GAIG;AACH,6BAJW,UAAU,SACV,MAAM,OACN,MAAM,2BAOhB;AAcD;;;;GAIG;AACH,+BAJW,UAAU,EAAE,UACZ,MAAM,GACJ,UAAU,CActB;AAwBD;;;GAGG;AACH,4BAHW,MAAM,GACJ,UAAU,CAMtB;AAaD;;;GAGG;AACH,yBAHW,UAAU,GACR,MAAM,CAQlB;AAiBH;;;GAGG;AACD,6BAHS,MAAM,GAAC,UAAU,GACf,UAAU,CAQpB"}
|
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
export const decodeErrPrefix: "CBOR decode error:";
|
|
2
|
-
export const encodeErrPrefix: "CBOR encode error:";
|
|
3
|
-
export const uintMinorPrefixBytes: any[];
|
|
4
|
-
/**
|
|
5
|
-
* @param {Uint8Array} data
|
|
6
|
-
* @param {number} pos
|
|
7
|
-
* @param {number} need
|
|
8
|
-
*/
|
|
9
|
-
export function assertEnoughData(data: Uint8Array, pos: number, need: number): void;
|
|
10
|
-
//# sourceMappingURL=common.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../lib/common.js"],"names":[],"mappings":"AAAA,8BAAwB,oBAAoB,CAAA;AAC5C,8BAAwB,oBAAoB,CAAA;AAE5C,yCAA+B;AAO/B;;;;GAIG;AACH,uCAJW,UAAU,OACV,MAAM,QACN,MAAM,QAMhB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"decode.d.ts","sourceRoot":"","sources":["../../lib/decode.js"],"names":[],"mappings":"oBAKa,OAAO,YAAY,EAAE,KAAK;4BAC1B,OAAO,cAAc,EAAE,aAAa;8BACpC,OAAO,cAAc,EAAE,eAAe;AAUnD;;GAEG;AACH,kCAFgB,eAAe;IAG7B;;;OAGG;IACH,kBAHW,UAAU,YACV,aAAa,EAMvB;IAHC,aAAa;IACb,kCAAgB;IAChB,8CAAsB;IAGxB,cAEC;IAED,gBAEC;IAED,mCAgBC;CACF;AA6ED;;;;GAIG;AACH,0CAJW,eAAe,WACf,aAAa,GACX,GAAG,6BAAW,CAoC1B;AAuBD;;;;GAIG;AACH,6BAJW,UAAU,YACV,aAAa,GACX,GAAG,CAQf;AAhCD;;;;GAIG;AACH,kCAJW,UAAU,YACV,aAAa,GACX,CAAC,GAAG,EAAE,UAAU,CAAC,CAgB7B;AAtID,mCAAiC;AADjC,kCAA+B"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @param {Uint8Array} inp
|
|
3
|
-
* @param {number} [width]
|
|
4
|
-
*/
|
|
5
|
-
export function tokensToDiagnostic(inp: Uint8Array, width?: number): Generator<string, void, unknown>;
|
|
6
|
-
/**
|
|
7
|
-
* Convert an input string formatted as CBOR diagnostic output into binary CBOR form.
|
|
8
|
-
* @param {string} input
|
|
9
|
-
* @returns {Uint8Array}
|
|
10
|
-
*/
|
|
11
|
-
export function fromDiag(input: string): Uint8Array;
|
|
12
|
-
//# sourceMappingURL=diagnostic.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"diagnostic.d.ts","sourceRoot":"","sources":["../../lib/diagnostic.js"],"names":[],"mappings":"AAQA;;;GAGG;AACH,wCAHW,UAAU,UACV,MAAM,oCA6HhB;AAED;;;;GAIG;AACH,gCAHW,MAAM,GACJ,UAAU,CAatB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"diagnostic_test.d.ts","sourceRoot":"","sources":["../../lib/diagnostic_test.js"],"names":[],"mappings":""}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"encode.d.ts","sourceRoot":"","sources":["../../lib/encode.js"],"names":[],"mappings":"AAgCA,oCAAoC;AACpC,oCADc,gBAAgB,EAAE,CAY/B;4BA3BY,OAAO,cAAc,EAAE,aAAa;kCACpC,OAAO,cAAc,EAAE,mBAAmB;wBAC1C,OAAO,cAAc,EAAE,SAAS;gCAChC,OAAO,cAAc,EAAE,iBAAiB;+BACxC,OAAO,cAAc,EAAE,gBAAgB;kCACvC,OAAO,cAAc,EAAE,mBAAmB;AAgQvD;;;;;GAKG;AACH,oCALW,GAAG,YACH,aAAa,aACb,SAAS,GACP,mBAAmB,CAgB/B;AA2JD;;;;GAIG;AACH,6BAJW,GAAG,YACH,aAAa,GACX,UAAU,CAKtB;AAvCD;;;;;GAKG;AACH,mCALW,GAAG,YACH,gBAAgB,EAAE,WAClB,aAAa,GACX,UAAU,CAyBtB;AAjZD,8BAA8B;AAC9B,4BADiB,SAAS;IA0BxB;;;;OAIG;IACH,0BAJW,SAAS,GAAC,SAAS,OACnB,MAAM,GAAC,GAAG,EAAE,GACV,SAAS,CAOrB;IAlCD;;;OAGG;IACH,iBAHW,MAAM,GAAC,GAAG,EAAE,UACZ,SAAS,GAAC,SAAS,EAK7B;IAFC,oBAAc;IACd,qDAAoB;IAGtB;;;OAGG;IACH,cAHW,MAAM,GAAC,GAAG,EAAE,GACV,OAAO,CAWnB;CAaF"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"is.d.ts","sourceRoot":"","sources":["../../lib/is.js"],"names":[],"mappings":"AAiDA;;;GAGG;AACH,0BAHW,GAAG,GACD,MAAM,CAiClB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"decode.d.ts","sourceRoot":"","sources":["../../../lib/json/decode.js"],"names":[],"mappings":"4BAQa,OAAO,iBAAiB,EAAE,aAAa;8BACvC,OAAO,iBAAiB,EAAE,eAAe;AAgbtD;;;;GAIG;AACH,6BAJW,UAAU,YACV,aAAa,GACX,GAAG,CAKf;AAED;;;;GAIG;AACH,kCAJW,UAAU,YACV,aAAa,GACX,CAAC,GAAG,EAAE,UAAU,CAAC,CAK7B;AApcD;;;GAGG;AAEH;;GAEG;AACH,kCAFgB,eAAe;IAG7B;;;OAGG;IACH,kBAHW,UAAU,YACV,aAAa,EASvB;IANC,aAAa;IACb,kCAAgB;IAChB,iDAAsB;IACtB,uBAAuB;IACvB,WADW,MAAM,EAAE,CACO;IAC1B,kBAAmB;IAGrB,cAEC;IAED;;OAEG;IACH,QAFa,OAAO,CAInB;IAED;;OAEG;IACH,MAFa,MAAM,CAIlB;IAED;;OAEG;IACH,eAFa,MAAM,CAIlB;IAED,uBAMC;IAED;;OAEG;IACH,YAFW,MAAM,EAAE,QAWlB;IAED,qBA+DC;IAED;;OAEG;IACH,eAFa,KAAK,CAkLjB;IAED;;OAEG;IACH,cAFa,KAAK,CAuCjB;IAED;;OAEG;IACH,QAFa,KAAK,CAyEjB;CACF;sBApb2B,OAAO"}
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
export type EncodeOptions = import("../../interface").EncodeOptions;
|
|
2
|
-
export type TokenTypeEncoder = import("../../interface").TokenTypeEncoder;
|
|
3
|
-
export type Token = import("../token").Token;
|
|
4
|
-
export type Bl = import("../bl").Bl;
|
|
5
|
-
/**
|
|
6
|
-
* @param {any} data
|
|
7
|
-
* @param {EncodeOptions} [options]
|
|
8
|
-
* @returns {Uint8Array}
|
|
9
|
-
*/
|
|
10
|
-
export function encode(data: any, options?: EncodeOptions): Uint8Array;
|
|
11
|
-
//# sourceMappingURL=encode.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"encode.d.ts","sourceRoot":"","sources":["../../../lib/json/encode.js"],"names":[],"mappings":"4BAQa,OAAO,iBAAiB,EAAE,aAAa;+BACvC,OAAO,iBAAiB,EAAE,gBAAgB;oBAC1C,OAAO,UAAU,EAAE,KAAK;iBACxB,OAAO,OAAO,EAAE,EAAE;AAqR/B;;;;GAIG;AACH,6BAJW,GAAG,YACH,aAAa,GACX,UAAU,CAKtB"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"forward-cborg.d.ts","sourceRoot":"","sources":["../../../lib/json/forward-cborg.js"],"names":[],"mappings":";;;;qBAAqB,OAAO"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"json.d.ts","sourceRoot":"","sources":["../../../lib/json/json.js"],"names":[],"mappings":"uBAAuB,aAAa;uBACW,aAAa;4BAAb,aAAa;0BAAb,aAAa"}
|
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* @param {Token} token
|
|
3
|
-
* @returns {Uint8Array|undefined}
|
|
4
|
-
*/
|
|
5
|
-
export function quickEncodeToken(token: Token): Uint8Array | undefined;
|
|
6
|
-
/** @type {((data:Uint8Array, pos:number, minor:number, options?:DecodeOptions) => any)[]} */
|
|
7
|
-
export const jump: ((data: Uint8Array, pos: number, minor: number, options?: DecodeOptions) => any)[];
|
|
8
|
-
/** @type {Token[]} */
|
|
9
|
-
export const quick: Token[];
|
|
10
|
-
export type DecodeOptions = import("../interface").DecodeOptions;
|
|
11
|
-
import { Token } from './token.js';
|
|
12
|
-
//# sourceMappingURL=jump.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"jump.d.ts","sourceRoot":"","sources":["../../lib/jump.js"],"names":[],"mappings":"AAkKA;;;GAGG;AACH,wCAHW,KAAK,GACH,UAAU,GAAC,SAAS,CA4ChC;AA/KD,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,cAAc,EAAE,aAAa;sBAbrB,YAAY"}
|