@fedify/vocab-runtime 2.0.0-dev.1908 → 2.0.0-dev.206

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.
Files changed (46) hide show
  1. package/LICENSE +1 -1
  2. package/README.md +2 -1
  3. package/deno.json +7 -1
  4. package/dist/chunk-DWy1uDak.cjs +39 -0
  5. package/dist/docloader.test.cjs +5851 -0
  6. package/dist/docloader.test.d.cts +1 -0
  7. package/dist/docloader.test.d.ts +1 -0
  8. package/dist/docloader.test.js +5877 -0
  9. package/dist/key.test.cjs +272 -0
  10. package/dist/key.test.d.cts +1 -0
  11. package/dist/key.test.d.ts +1 -0
  12. package/dist/key.test.js +271 -0
  13. package/dist/langstr.test.cjs +51 -0
  14. package/dist/langstr.test.d.cts +1 -0
  15. package/dist/langstr.test.d.ts +1 -0
  16. package/dist/langstr.test.js +50 -0
  17. package/dist/link-CdFPEo9O.cjs +189 -0
  18. package/dist/link-Ck2yj4dH.js +183 -0
  19. package/dist/link.test.cjs +56 -0
  20. package/dist/link.test.d.cts +1 -0
  21. package/dist/link.test.d.ts +1 -0
  22. package/dist/link.test.js +55 -0
  23. package/dist/mod.cjs +102 -63
  24. package/dist/mod.js +102 -63
  25. package/dist/multibase/multibase.test.cjs +346 -0
  26. package/dist/multibase/multibase.test.d.cts +1 -0
  27. package/dist/multibase/multibase.test.d.ts +1 -0
  28. package/dist/multibase/multibase.test.js +345 -0
  29. package/dist/multibase-BFbBiaPE.cjs +347 -0
  30. package/dist/multibase-DStmqni9.js +311 -0
  31. package/dist/request-CHSKwWMf.cjs +138 -0
  32. package/dist/request-CXamqU2m.js +108 -0
  33. package/dist/request.test.cjs +44 -0
  34. package/dist/request.test.d.cts +1 -0
  35. package/dist/request.test.d.ts +1 -0
  36. package/dist/request.test.js +43 -0
  37. package/dist/url-C5Vs9nYh.cjs +93 -0
  38. package/dist/url-fW_DHbih.js +63 -0
  39. package/dist/url.test.cjs +37 -0
  40. package/dist/url.test.d.cts +1 -0
  41. package/dist/url.test.d.ts +1 -0
  42. package/dist/url.test.js +36 -0
  43. package/package.json +4 -3
  44. package/src/docloader.test.ts +29 -1
  45. package/src/docloader.ts +101 -45
  46. package/tsdown.config.ts +18 -7
@@ -0,0 +1,347 @@
1
+ const require_chunk = require('./chunk-DWy1uDak.cjs');
2
+ const __multiformats_base_x = require_chunk.__toESM(require("@multiformats/base-x"));
3
+
4
+ //#region src/multibase/util.ts
5
+ const textDecoder = new TextDecoder();
6
+ const decodeText = (bytes) => textDecoder.decode(bytes);
7
+ const textEncoder = new TextEncoder();
8
+ const encodeText = (text) => textEncoder.encode(text);
9
+ function concat(arrs, length) {
10
+ const output = new Uint8Array(length);
11
+ let offset = 0;
12
+ for (const arr of arrs) {
13
+ output.set(arr, offset);
14
+ offset += arr.length;
15
+ }
16
+ return output;
17
+ }
18
+
19
+ //#endregion
20
+ //#region src/multibase/base.ts
21
+ /**
22
+ * Class to encode/decode in the supported Bases
23
+ */
24
+ var Base = class {
25
+ codeBuf;
26
+ codec;
27
+ constructor(name, code, factory, alphabet) {
28
+ this.name = name;
29
+ this.code = code;
30
+ this.alphabet = alphabet;
31
+ this.codeBuf = encodeText(this.code);
32
+ this.alphabet = alphabet;
33
+ this.codec = factory(alphabet);
34
+ }
35
+ encode(buf) {
36
+ return this.codec.encode(buf);
37
+ }
38
+ decode(string) {
39
+ for (const char of string) if (this.alphabet && this.alphabet.indexOf(char) < 0) throw new Error(`invalid character '${char}' in '${string}'`);
40
+ return this.codec.decode(string);
41
+ }
42
+ };
43
+
44
+ //#endregion
45
+ //#region src/multibase/rfc4648.ts
46
+ const decode = (string, alphabet, bitsPerChar) => {
47
+ const codes$1 = {};
48
+ for (let i = 0; i < alphabet.length; ++i) codes$1[alphabet[i]] = i;
49
+ let end = string.length;
50
+ while (string[end - 1] === "=") --end;
51
+ const out = new Uint8Array(end * bitsPerChar / 8 | 0);
52
+ let bits = 0;
53
+ let buffer = 0;
54
+ let written = 0;
55
+ for (let i = 0; i < end; ++i) {
56
+ const value = codes$1[string[i]];
57
+ if (value === void 0) throw new SyntaxError("Invalid character " + string[i]);
58
+ buffer = buffer << bitsPerChar | value;
59
+ bits += bitsPerChar;
60
+ if (bits >= 8) {
61
+ bits -= 8;
62
+ out[written++] = 255 & buffer >> bits;
63
+ }
64
+ }
65
+ if (bits >= bitsPerChar || 255 & buffer << 8 - bits) throw new SyntaxError("Unexpected end of data");
66
+ return out;
67
+ };
68
+ const encode = (data, alphabet, bitsPerChar) => {
69
+ const pad = alphabet[alphabet.length - 1] === "=";
70
+ const mask = (1 << bitsPerChar) - 1;
71
+ let out = "";
72
+ let bits = 0;
73
+ let buffer = 0;
74
+ for (let i = 0; i < data.length; ++i) {
75
+ buffer = buffer << 8 | data[i];
76
+ bits += 8;
77
+ while (bits > bitsPerChar) {
78
+ bits -= bitsPerChar;
79
+ out += alphabet[mask & buffer >> bits];
80
+ }
81
+ }
82
+ if (bits) out += alphabet[mask & buffer << bitsPerChar - bits];
83
+ if (pad) while (out.length * bitsPerChar & 7) out += "=";
84
+ return out;
85
+ };
86
+ /**
87
+ * RFC4648 Factory
88
+ */
89
+ const rfc4648 = (bitsPerChar) => (alphabet) => {
90
+ return {
91
+ encode(input) {
92
+ return encode(input, alphabet, bitsPerChar);
93
+ },
94
+ decode(input) {
95
+ return decode(input, alphabet, bitsPerChar);
96
+ }
97
+ };
98
+ };
99
+
100
+ //#endregion
101
+ //#region src/multibase/constants.ts
102
+ const identity = () => {
103
+ return {
104
+ encode: decodeText,
105
+ decode: encodeText
106
+ };
107
+ };
108
+ /**
109
+ * name, code, implementation, alphabet
110
+ *
111
+ * @type {Array<[BaseName, BaseCode, CodecFactory, string]>}
112
+ */
113
+ const constants = [
114
+ [
115
+ "identity",
116
+ "\0",
117
+ identity,
118
+ ""
119
+ ],
120
+ [
121
+ "base2",
122
+ "0",
123
+ rfc4648(1),
124
+ "01"
125
+ ],
126
+ [
127
+ "base8",
128
+ "7",
129
+ rfc4648(3),
130
+ "01234567"
131
+ ],
132
+ [
133
+ "base10",
134
+ "9",
135
+ __multiformats_base_x.default,
136
+ "0123456789"
137
+ ],
138
+ [
139
+ "base16",
140
+ "f",
141
+ rfc4648(4),
142
+ "0123456789abcdef"
143
+ ],
144
+ [
145
+ "base16upper",
146
+ "F",
147
+ rfc4648(4),
148
+ "0123456789ABCDEF"
149
+ ],
150
+ [
151
+ "base32hex",
152
+ "v",
153
+ rfc4648(5),
154
+ "0123456789abcdefghijklmnopqrstuv"
155
+ ],
156
+ [
157
+ "base32hexupper",
158
+ "V",
159
+ rfc4648(5),
160
+ "0123456789ABCDEFGHIJKLMNOPQRSTUV"
161
+ ],
162
+ [
163
+ "base32hexpad",
164
+ "t",
165
+ rfc4648(5),
166
+ "0123456789abcdefghijklmnopqrstuv="
167
+ ],
168
+ [
169
+ "base32hexpadupper",
170
+ "T",
171
+ rfc4648(5),
172
+ "0123456789ABCDEFGHIJKLMNOPQRSTUV="
173
+ ],
174
+ [
175
+ "base32",
176
+ "b",
177
+ rfc4648(5),
178
+ "abcdefghijklmnopqrstuvwxyz234567"
179
+ ],
180
+ [
181
+ "base32upper",
182
+ "B",
183
+ rfc4648(5),
184
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"
185
+ ],
186
+ [
187
+ "base32pad",
188
+ "c",
189
+ rfc4648(5),
190
+ "abcdefghijklmnopqrstuvwxyz234567="
191
+ ],
192
+ [
193
+ "base32padupper",
194
+ "C",
195
+ rfc4648(5),
196
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567="
197
+ ],
198
+ [
199
+ "base32z",
200
+ "h",
201
+ rfc4648(5),
202
+ "ybndrfg8ejkmcpqxot1uwisza345h769"
203
+ ],
204
+ [
205
+ "base36",
206
+ "k",
207
+ __multiformats_base_x.default,
208
+ "0123456789abcdefghijklmnopqrstuvwxyz"
209
+ ],
210
+ [
211
+ "base36upper",
212
+ "K",
213
+ __multiformats_base_x.default,
214
+ "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
215
+ ],
216
+ [
217
+ "base58btc",
218
+ "z",
219
+ __multiformats_base_x.default,
220
+ "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
221
+ ],
222
+ [
223
+ "base58flickr",
224
+ "Z",
225
+ __multiformats_base_x.default,
226
+ "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"
227
+ ],
228
+ [
229
+ "base64",
230
+ "m",
231
+ rfc4648(6),
232
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
233
+ ],
234
+ [
235
+ "base64pad",
236
+ "M",
237
+ rfc4648(6),
238
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
239
+ ],
240
+ [
241
+ "base64url",
242
+ "u",
243
+ rfc4648(6),
244
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"
245
+ ],
246
+ [
247
+ "base64urlpad",
248
+ "U",
249
+ rfc4648(6),
250
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_="
251
+ ]
252
+ ];
253
+ const names = constants.reduce((prev, tupple) => {
254
+ prev[tupple[0]] = new Base(tupple[0], tupple[1], tupple[2], tupple[3]);
255
+ return prev;
256
+ }, {});
257
+ const codes = constants.reduce((prev, tupple) => {
258
+ prev[tupple[1]] = names[tupple[0]];
259
+ return prev;
260
+ }, {});
261
+
262
+ //#endregion
263
+ //#region src/multibase/mod.ts
264
+ /**
265
+ * Encode data with the specified base and add the multibase prefix.
266
+ *
267
+ * @throws {Error} Will throw if the encoding is not supported
268
+ */
269
+ function encodeMultibase(nameOrCode, buf) {
270
+ const enc = encoding(nameOrCode);
271
+ const data = encodeText(enc.encode(buf));
272
+ return concat([enc.codeBuf, data], enc.codeBuf.length + data.length);
273
+ }
274
+ /**
275
+ * Takes a Uint8Array or string encoded with multibase header, decodes it and
276
+ * returns the decoded buffer
277
+ *
278
+ * @throws {Error} Will throw if the encoding is not supported
279
+ */
280
+ function decodeMultibase(data) {
281
+ if (data instanceof Uint8Array) data = decodeText(data);
282
+ const prefix = data[0];
283
+ if ([
284
+ "f",
285
+ "F",
286
+ "v",
287
+ "V",
288
+ "t",
289
+ "T",
290
+ "b",
291
+ "B",
292
+ "c",
293
+ "C",
294
+ "h",
295
+ "k",
296
+ "K"
297
+ ].includes(prefix)) data = data.toLowerCase();
298
+ const enc = encoding(data[0]);
299
+ return enc.decode(data.substring(1));
300
+ }
301
+ /**
302
+ * Get the encoding by name or code
303
+ * @throws {Error} Will throw if the encoding is not supported
304
+ */
305
+ function encoding(nameOrCode) {
306
+ if (Object.prototype.hasOwnProperty.call(names, nameOrCode)) return names[nameOrCode];
307
+ else if (Object.prototype.hasOwnProperty.call(codes, nameOrCode)) return codes[nameOrCode];
308
+ else throw new Error(`Unsupported encoding: ${nameOrCode}`);
309
+ }
310
+
311
+ //#endregion
312
+ Object.defineProperty(exports, 'codes', {
313
+ enumerable: true,
314
+ get: function () {
315
+ return codes;
316
+ }
317
+ });
318
+ Object.defineProperty(exports, 'decodeMultibase', {
319
+ enumerable: true,
320
+ get: function () {
321
+ return decodeMultibase;
322
+ }
323
+ });
324
+ Object.defineProperty(exports, 'decodeText', {
325
+ enumerable: true,
326
+ get: function () {
327
+ return decodeText;
328
+ }
329
+ });
330
+ Object.defineProperty(exports, 'encodeMultibase', {
331
+ enumerable: true,
332
+ get: function () {
333
+ return encodeMultibase;
334
+ }
335
+ });
336
+ Object.defineProperty(exports, 'encodeText', {
337
+ enumerable: true,
338
+ get: function () {
339
+ return encodeText;
340
+ }
341
+ });
342
+ Object.defineProperty(exports, 'names', {
343
+ enumerable: true,
344
+ get: function () {
345
+ return names;
346
+ }
347
+ });
@@ -0,0 +1,311 @@
1
+ import baseX from "@multiformats/base-x";
2
+
3
+ //#region src/multibase/util.ts
4
+ const textDecoder = new TextDecoder();
5
+ const decodeText = (bytes) => textDecoder.decode(bytes);
6
+ const textEncoder = new TextEncoder();
7
+ const encodeText = (text) => textEncoder.encode(text);
8
+ function concat(arrs, length) {
9
+ const output = new Uint8Array(length);
10
+ let offset = 0;
11
+ for (const arr of arrs) {
12
+ output.set(arr, offset);
13
+ offset += arr.length;
14
+ }
15
+ return output;
16
+ }
17
+
18
+ //#endregion
19
+ //#region src/multibase/base.ts
20
+ /**
21
+ * Class to encode/decode in the supported Bases
22
+ */
23
+ var Base = class {
24
+ codeBuf;
25
+ codec;
26
+ constructor(name, code, factory, alphabet) {
27
+ this.name = name;
28
+ this.code = code;
29
+ this.alphabet = alphabet;
30
+ this.codeBuf = encodeText(this.code);
31
+ this.alphabet = alphabet;
32
+ this.codec = factory(alphabet);
33
+ }
34
+ encode(buf) {
35
+ return this.codec.encode(buf);
36
+ }
37
+ decode(string) {
38
+ for (const char of string) if (this.alphabet && this.alphabet.indexOf(char) < 0) throw new Error(`invalid character '${char}' in '${string}'`);
39
+ return this.codec.decode(string);
40
+ }
41
+ };
42
+
43
+ //#endregion
44
+ //#region src/multibase/rfc4648.ts
45
+ const decode = (string, alphabet, bitsPerChar) => {
46
+ const codes$1 = {};
47
+ for (let i = 0; i < alphabet.length; ++i) codes$1[alphabet[i]] = i;
48
+ let end = string.length;
49
+ while (string[end - 1] === "=") --end;
50
+ const out = new Uint8Array(end * bitsPerChar / 8 | 0);
51
+ let bits = 0;
52
+ let buffer = 0;
53
+ let written = 0;
54
+ for (let i = 0; i < end; ++i) {
55
+ const value = codes$1[string[i]];
56
+ if (value === void 0) throw new SyntaxError("Invalid character " + string[i]);
57
+ buffer = buffer << bitsPerChar | value;
58
+ bits += bitsPerChar;
59
+ if (bits >= 8) {
60
+ bits -= 8;
61
+ out[written++] = 255 & buffer >> bits;
62
+ }
63
+ }
64
+ if (bits >= bitsPerChar || 255 & buffer << 8 - bits) throw new SyntaxError("Unexpected end of data");
65
+ return out;
66
+ };
67
+ const encode = (data, alphabet, bitsPerChar) => {
68
+ const pad = alphabet[alphabet.length - 1] === "=";
69
+ const mask = (1 << bitsPerChar) - 1;
70
+ let out = "";
71
+ let bits = 0;
72
+ let buffer = 0;
73
+ for (let i = 0; i < data.length; ++i) {
74
+ buffer = buffer << 8 | data[i];
75
+ bits += 8;
76
+ while (bits > bitsPerChar) {
77
+ bits -= bitsPerChar;
78
+ out += alphabet[mask & buffer >> bits];
79
+ }
80
+ }
81
+ if (bits) out += alphabet[mask & buffer << bitsPerChar - bits];
82
+ if (pad) while (out.length * bitsPerChar & 7) out += "=";
83
+ return out;
84
+ };
85
+ /**
86
+ * RFC4648 Factory
87
+ */
88
+ const rfc4648 = (bitsPerChar) => (alphabet) => {
89
+ return {
90
+ encode(input) {
91
+ return encode(input, alphabet, bitsPerChar);
92
+ },
93
+ decode(input) {
94
+ return decode(input, alphabet, bitsPerChar);
95
+ }
96
+ };
97
+ };
98
+
99
+ //#endregion
100
+ //#region src/multibase/constants.ts
101
+ const identity = () => {
102
+ return {
103
+ encode: decodeText,
104
+ decode: encodeText
105
+ };
106
+ };
107
+ /**
108
+ * name, code, implementation, alphabet
109
+ *
110
+ * @type {Array<[BaseName, BaseCode, CodecFactory, string]>}
111
+ */
112
+ const constants = [
113
+ [
114
+ "identity",
115
+ "\0",
116
+ identity,
117
+ ""
118
+ ],
119
+ [
120
+ "base2",
121
+ "0",
122
+ rfc4648(1),
123
+ "01"
124
+ ],
125
+ [
126
+ "base8",
127
+ "7",
128
+ rfc4648(3),
129
+ "01234567"
130
+ ],
131
+ [
132
+ "base10",
133
+ "9",
134
+ baseX,
135
+ "0123456789"
136
+ ],
137
+ [
138
+ "base16",
139
+ "f",
140
+ rfc4648(4),
141
+ "0123456789abcdef"
142
+ ],
143
+ [
144
+ "base16upper",
145
+ "F",
146
+ rfc4648(4),
147
+ "0123456789ABCDEF"
148
+ ],
149
+ [
150
+ "base32hex",
151
+ "v",
152
+ rfc4648(5),
153
+ "0123456789abcdefghijklmnopqrstuv"
154
+ ],
155
+ [
156
+ "base32hexupper",
157
+ "V",
158
+ rfc4648(5),
159
+ "0123456789ABCDEFGHIJKLMNOPQRSTUV"
160
+ ],
161
+ [
162
+ "base32hexpad",
163
+ "t",
164
+ rfc4648(5),
165
+ "0123456789abcdefghijklmnopqrstuv="
166
+ ],
167
+ [
168
+ "base32hexpadupper",
169
+ "T",
170
+ rfc4648(5),
171
+ "0123456789ABCDEFGHIJKLMNOPQRSTUV="
172
+ ],
173
+ [
174
+ "base32",
175
+ "b",
176
+ rfc4648(5),
177
+ "abcdefghijklmnopqrstuvwxyz234567"
178
+ ],
179
+ [
180
+ "base32upper",
181
+ "B",
182
+ rfc4648(5),
183
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567"
184
+ ],
185
+ [
186
+ "base32pad",
187
+ "c",
188
+ rfc4648(5),
189
+ "abcdefghijklmnopqrstuvwxyz234567="
190
+ ],
191
+ [
192
+ "base32padupper",
193
+ "C",
194
+ rfc4648(5),
195
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567="
196
+ ],
197
+ [
198
+ "base32z",
199
+ "h",
200
+ rfc4648(5),
201
+ "ybndrfg8ejkmcpqxot1uwisza345h769"
202
+ ],
203
+ [
204
+ "base36",
205
+ "k",
206
+ baseX,
207
+ "0123456789abcdefghijklmnopqrstuvwxyz"
208
+ ],
209
+ [
210
+ "base36upper",
211
+ "K",
212
+ baseX,
213
+ "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ"
214
+ ],
215
+ [
216
+ "base58btc",
217
+ "z",
218
+ baseX,
219
+ "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz"
220
+ ],
221
+ [
222
+ "base58flickr",
223
+ "Z",
224
+ baseX,
225
+ "123456789abcdefghijkmnopqrstuvwxyzABCDEFGHJKLMNPQRSTUVWXYZ"
226
+ ],
227
+ [
228
+ "base64",
229
+ "m",
230
+ rfc4648(6),
231
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"
232
+ ],
233
+ [
234
+ "base64pad",
235
+ "M",
236
+ rfc4648(6),
237
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/="
238
+ ],
239
+ [
240
+ "base64url",
241
+ "u",
242
+ rfc4648(6),
243
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_"
244
+ ],
245
+ [
246
+ "base64urlpad",
247
+ "U",
248
+ rfc4648(6),
249
+ "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_="
250
+ ]
251
+ ];
252
+ const names = constants.reduce((prev, tupple) => {
253
+ prev[tupple[0]] = new Base(tupple[0], tupple[1], tupple[2], tupple[3]);
254
+ return prev;
255
+ }, {});
256
+ const codes = constants.reduce((prev, tupple) => {
257
+ prev[tupple[1]] = names[tupple[0]];
258
+ return prev;
259
+ }, {});
260
+
261
+ //#endregion
262
+ //#region src/multibase/mod.ts
263
+ /**
264
+ * Encode data with the specified base and add the multibase prefix.
265
+ *
266
+ * @throws {Error} Will throw if the encoding is not supported
267
+ */
268
+ function encodeMultibase(nameOrCode, buf) {
269
+ const enc = encoding(nameOrCode);
270
+ const data = encodeText(enc.encode(buf));
271
+ return concat([enc.codeBuf, data], enc.codeBuf.length + data.length);
272
+ }
273
+ /**
274
+ * Takes a Uint8Array or string encoded with multibase header, decodes it and
275
+ * returns the decoded buffer
276
+ *
277
+ * @throws {Error} Will throw if the encoding is not supported
278
+ */
279
+ function decodeMultibase(data) {
280
+ if (data instanceof Uint8Array) data = decodeText(data);
281
+ const prefix = data[0];
282
+ if ([
283
+ "f",
284
+ "F",
285
+ "v",
286
+ "V",
287
+ "t",
288
+ "T",
289
+ "b",
290
+ "B",
291
+ "c",
292
+ "C",
293
+ "h",
294
+ "k",
295
+ "K"
296
+ ].includes(prefix)) data = data.toLowerCase();
297
+ const enc = encoding(data[0]);
298
+ return enc.decode(data.substring(1));
299
+ }
300
+ /**
301
+ * Get the encoding by name or code
302
+ * @throws {Error} Will throw if the encoding is not supported
303
+ */
304
+ function encoding(nameOrCode) {
305
+ if (Object.prototype.hasOwnProperty.call(names, nameOrCode)) return names[nameOrCode];
306
+ else if (Object.prototype.hasOwnProperty.call(codes, nameOrCode)) return codes[nameOrCode];
307
+ else throw new Error(`Unsupported encoding: ${nameOrCode}`);
308
+ }
309
+
310
+ //#endregion
311
+ export { codes, decodeMultibase, decodeText, encodeMultibase, encodeText, names };