@cbortech/cbor 0.23.1 → 0.25.0

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 (49) hide show
  1. package/README.ja.md +76 -29
  2. package/README.md +76 -29
  3. package/dist/ast/CborArray.d.ts +3 -3
  4. package/dist/ast/CborBignum.d.ts +5 -5
  5. package/dist/ast/CborByteString.d.ts +2 -2
  6. package/dist/ast/CborEllipsis.d.ts +2 -2
  7. package/dist/ast/CborEmbeddedCBOR.d.ts +3 -3
  8. package/dist/ast/CborFloat.d.ts +2 -2
  9. package/dist/ast/CborIndefiniteByteString.d.ts +3 -3
  10. package/dist/ast/CborIndefiniteTextString.d.ts +3 -3
  11. package/dist/ast/CborItem.d.ts +16 -10
  12. package/dist/ast/CborMap.d.ts +3 -3
  13. package/dist/ast/CborNint.d.ts +2 -2
  14. package/dist/ast/CborSimple.d.ts +2 -2
  15. package/dist/ast/CborTag.d.ts +3 -3
  16. package/dist/ast/CborTextString.d.ts +2 -2
  17. package/dist/ast/CborUint.d.ts +2 -2
  18. package/dist/ast/CborUnresolvedAppExt.d.ts +2 -2
  19. package/dist/ast/index.cjs +1 -1
  20. package/dist/ast/index.js +1 -1
  21. package/dist/cbor.d.ts +54 -22
  22. package/dist/cdn/parser.d.ts +7 -0
  23. package/dist/{edn → cdn}/serialize-utils.d.ts +4 -4
  24. package/dist/cdn/serializer.d.ts +7 -0
  25. package/dist/{edn → cdn}/tokenizer.d.ts +3 -3
  26. package/dist/extensions/cri.d.ts +7 -7
  27. package/dist/extensions/dt.d.ts +9 -9
  28. package/dist/extensions/ip.d.ts +8 -8
  29. package/dist/extensions/types.d.ts +4 -4
  30. package/dist/index.cjs +1 -1
  31. package/dist/index.cjs.map +1 -1
  32. package/dist/index.d.ts +1 -1
  33. package/dist/index.js +36 -18
  34. package/dist/index.js.map +1 -1
  35. package/dist/mapEntries-CNxwMt7o.cjs +31 -0
  36. package/dist/mapEntries-CNxwMt7o.cjs.map +1 -0
  37. package/dist/{mapEntries-CSjvgq1X.js → mapEntries-Da-2HMRf.js} +583 -1219
  38. package/dist/mapEntries-Da-2HMRf.js.map +1 -0
  39. package/dist/simple.d.ts +2 -2
  40. package/dist/tag.d.ts +1 -1
  41. package/dist/types.d.ts +51 -25
  42. package/dist/utils/hexfloat.d.ts +2 -2
  43. package/package.json +20 -19
  44. package/dist/edn/parser.d.ts +0 -7
  45. package/dist/edn/serializer.d.ts +0 -7
  46. package/dist/extensions/hash.d.ts +0 -17
  47. package/dist/mapEntries-C73nWM8o.cjs +0 -31
  48. package/dist/mapEntries-C73nWM8o.cjs.map +0 -1
  49. package/dist/mapEntries-CSjvgq1X.js.map +0 -1
package/README.ja.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # @cbortech/cbor
2
2
 
3
- [CBOR](#準拠している仕様)、[CBOR-EDN](#準拠している仕様)、JavaScript 値を相互変換するための TypeScript ライブラリです。
3
+ [CBOR](#準拠している仕様)、[CDN](#準拠している仕様)、JavaScript 値を相互変換するための TypeScript ライブラリです。
4
4
 
5
5
  このパッケージは `CBOR` ファサードに加えて、extension の実装に必要な CBOR AST ノードクラス用の entrypoint を公開します。
6
6
  低レベルのパーサー、エンコーダー内部は、ドキュメント上の公開 API には含めていません。
@@ -52,29 +52,29 @@ console.log(value);
52
52
  // { hello: 'world', n: 42 }
53
53
  ```
54
54
 
55
- ### CBOR バイト列から CBOR-EDN
55
+ ### CBOR バイト列から CDN
56
56
 
57
57
  ```ts
58
58
  import { CBOR } from '@cbortech/cbor';
59
59
 
60
- const text = CBOR.cborToCborEdn(new Uint8Array([0x83, 0x01, 0x02, 0x03]));
60
+ const text = CBOR.fromCBOR(new Uint8Array([0x83, 0x01, 0x02, 0x03])).toCDN();
61
61
 
62
62
  console.log(text);
63
63
  // [1,2,3]
64
64
  ```
65
65
 
66
- ### CBOR-EDN から CBOR バイト列へ
66
+ ### CDN から CBOR バイト列へ
67
67
 
68
68
  ```ts
69
69
  import { CBOR } from '@cbortech/cbor';
70
70
 
71
- const bytes = CBOR.cborEdnToCbor('[1, 2, 3]');
71
+ const bytes = CBOR.fromCDN('[1, 2, 3]').toCBOR();
72
72
 
73
73
  console.log(bytes);
74
74
  // Uint8Array([0x83, 0x01, 0x02, 0x03])
75
75
  ```
76
76
 
77
- ### JavaScript から CBOR-EDN
77
+ ### JavaScript から CDN
78
78
 
79
79
  ```ts
80
80
  import { CBOR } from '@cbortech/cbor';
@@ -85,7 +85,7 @@ console.log(text);
85
85
  // {"a":1,"b":true,"c":null}
86
86
  ```
87
87
 
88
- ### 読みやすい CBOR-EDN を出力する
88
+ ### 読みやすい CDN を出力する
89
89
 
90
90
  ```ts
91
91
  import { CBOR } from '@cbortech/cbor';
@@ -103,7 +103,7 @@ console.log(text);
103
103
  // }
104
104
  ```
105
105
 
106
- ### CBOR-EDN から JavaScript へ
106
+ ### CDN から JavaScript へ
107
107
 
108
108
  ```ts
109
109
  import { CBOR } from '@cbortech/cbor';
@@ -114,7 +114,7 @@ console.log(value);
114
114
  // [1, Uint8Array(...), true, null]
115
115
  ```
116
116
 
117
- ### CBOR-EDN を正規化する
117
+ ### CDN を正規化する
118
118
 
119
119
  ```ts
120
120
  import { CBOR } from '@cbortech/cbor';
@@ -133,7 +133,7 @@ console.log(text);
133
133
 
134
134
  ### テキスト文字列を分割して整形する
135
135
 
136
- `textStringFormat` を使うと、長いテキスト文字列を EDN の文字列連結として分割できます。
136
+ `textStringFormat` を使うと、長いテキスト文字列を CDN の文字列連結として分割できます。
137
137
  このオプションは `indent` を指定したときに適用されます。
138
138
 
139
139
  ```ts
@@ -152,19 +152,19 @@ console.log(text);
152
152
  // }
153
153
  ```
154
154
 
155
- 文字列の中身が CBOR-EDN や JSON 風の内容なら、`cboredn` を使えます。
155
+ 文字列の中身が CDN や JSON 風の内容なら、`cdn` を使えます。
156
156
 
157
157
  ```ts
158
158
  import { CBOR } from '@cbortech/cbor';
159
159
 
160
- const text = CBOR.format('{"edn": "[1,2,3]"}', {
160
+ const text = CBOR.format('{"cdn": "[1,2,3]"}', {
161
161
  indent: 2,
162
- textStringFormat: ['cboredn'],
162
+ textStringFormat: ['cdn'],
163
163
  });
164
164
 
165
165
  console.log(text);
166
166
  // {
167
- // "edn": "[" +
167
+ // "cdn": "[" +
168
168
  // "1," +
169
169
  // "2," +
170
170
  // "3" +
@@ -174,7 +174,7 @@ console.log(text);
174
174
 
175
175
  ## AST を扱う
176
176
 
177
- `CBOR.fromCBOR()`、`CBOR.fromEDN()`、`CBOR.fromJS()` は CBOR item を返します。
177
+ `CBOR.fromCBOR()`、`CBOR.fromCDN()`、`CBOR.fromJS()` は CBOR item を返します。
178
178
  `CborTextString`、`CborByteString`、`CborArray`、`CborTag` などの具体的なノードクラスは、
179
179
  extension 向けに `@cbortech/cbor/ast` から export されています。すべての item は次のメソッドを持ちます。
180
180
 
@@ -182,11 +182,11 @@ extension 向けに `@cbortech/cbor/ast` から export されています。す
182
182
  import { CBOR } from '@cbortech/cbor';
183
183
  import { CborItem } from '@cbortech/cbor/ast';
184
184
 
185
- const item = CBOR.fromEDN('{ "x": 1 }');
185
+ const item = CBOR.fromCDN('{ "x": 1 }');
186
186
  item satisfies CborItem;
187
187
 
188
188
  const bytes = item.toCBOR();
189
- const text = item.toEDN();
189
+ const text = item.toCDN();
190
190
  const value = item.toJS();
191
191
  ```
192
192
 
@@ -195,23 +195,23 @@ const value = item.toJS();
195
195
  ```ts
196
196
  import { CBOR } from '@cbortech/cbor';
197
197
 
198
- const item = CBOR.fromEDN('[_ 1, 2, 3]');
198
+ const item = CBOR.fromCDN('[_ 1, 2, 3]');
199
199
 
200
- console.log(item.toEDN());
200
+ console.log(item.toCDN());
201
201
  // [_ 1,2,3]
202
202
 
203
203
  console.log(item.toCBOR());
204
204
  // Uint8Array(...)
205
205
  ```
206
206
 
207
- ### CBOR を AST としてデコードし、EDN として確認する
207
+ ### CBOR を AST としてデコードし、CDN として確認する
208
208
 
209
209
  ```ts
210
210
  import { CBOR } from '@cbortech/cbor';
211
211
 
212
212
  const item = CBOR.fromCBOR(new Uint8Array([0x83, 0x01, 0x02, 0x03]));
213
213
 
214
- console.log(item.toEDN());
214
+ console.log(item.toCDN());
215
215
  // [1,2,3]
216
216
 
217
217
  console.log(item.toJS());
@@ -299,7 +299,7 @@ console.log(cbor.stringify({ value }));
299
299
 
300
300
  ## 日時
301
301
 
302
- CBOR-EDN の `dt'...'` と `DT'...'` リテラルは、デフォルトでパースできます。
302
+ CDN の `dt'...'` と `DT'...'` リテラルは、デフォルトでパースできます。
303
303
  JavaScript の `Date` オブジェクトとして扱いたい場合は `CBOR.dt_as_Date` を追加します。
304
304
 
305
305
  ```ts
@@ -324,6 +324,41 @@ console.log(text);
324
324
  // DT'2026-05-06T00:00:00Z'
325
325
  ```
326
326
 
327
+ ## オプション extension
328
+
329
+ 追加の application extension は別パッケージとして公開されています。必要なものを
330
+ インストールし、`extensions` オプションに渡して使います。
331
+
332
+ `hash` は CDN の仕様に含まれる application extension ですが、利用には
333
+ 外部パッケージが必要です。そのため、このパッケージ本体には含めず、
334
+ `@cbortech/hash-extension` として提供しています。
335
+
336
+ `uuid` は CDN の仕様には定められていない、このライブラリ独自の
337
+ application extension です。仕様上の標準機能と区別するため、
338
+ `@cbortech/uuid-extension` として別パッケージで提供しています。
339
+
340
+ ```bash
341
+ npm install @cbortech/hash-extension @cbortech/uuid-extension
342
+ ```
343
+
344
+ ```ts
345
+ import { CBOR } from '@cbortech/cbor';
346
+ import hashExtension from '@cbortech/hash-extension';
347
+ import uuidExtension from '@cbortech/uuid-extension';
348
+
349
+ const cbor = new CBOR({
350
+ extensions: [hashExtension, uuidExtension],
351
+ });
352
+
353
+ const digest = cbor.fromCDN("hash'foo'");
354
+ console.log(digest.toCDN());
355
+ // hash'foo'
356
+
357
+ const id = cbor.fromCDN("uuid'550e8400-e29b-41d4-a716-446655440000'");
358
+ console.log(id.toCDN());
359
+ // uuid'550e8400-e29b-41d4-a716-446655440000'
360
+ ```
361
+
327
362
  ## タグ
328
363
 
329
364
  JavaScript 上で CBOR のタグ付き値を扱うには `CBOR.Tag` を使います。
@@ -350,6 +385,18 @@ console.log(CBOR.Tag.getValue(value));
350
385
  // "hello"
351
386
  ```
352
387
 
388
+ タグ情報が不要で、中身だけを通常の JavaScript 値として扱いたい場合は
389
+ `stripTags: true` を指定できます。
390
+
391
+ ```ts
392
+ import { CBOR } from '@cbortech/cbor';
393
+
394
+ const value = CBOR.parse('42("hello")', { stripTags: true });
395
+
396
+ console.log(value);
397
+ // "hello"
398
+ ```
399
+
353
400
  ## Simple 値
354
401
 
355
402
  `false`、`true`、`null`、`undefined` 以外の CBOR simple value には `CBOR.Simple` を使います。
@@ -422,7 +469,7 @@ CBOR item は注釈付き hex dump の生成とパースに対応しています
422
469
  ```ts
423
470
  import { CBOR } from '@cbortech/cbor';
424
471
 
425
- const item = CBOR.fromEDN('[_ 1, [2, 3]]');
472
+ const item = CBOR.fromCDN('[_ 1, [2, 3]]');
426
473
  const dump = item.toHexDump();
427
474
 
428
475
  console.log(dump);
@@ -440,7 +487,7 @@ const item = CBOR.fromHexDump(`
440
487
  03 -- 3
441
488
  `);
442
489
 
443
- console.log(item.toEDN());
490
+ console.log(item.toCDN());
444
491
  // [1,2,3]
445
492
  ```
446
493
 
@@ -463,19 +510,19 @@ console.log(item.toEDN());
463
510
  このライブラリは次の仕様を対象にしています。
464
511
 
465
512
  - [CBOR, RFC 8949](https://www.rfc-editor.org/rfc/rfc8949)
466
- - [CBOR Extended Diagnostic Notation (CBOR-EDN), draft-ietf-cbor-edn-literals-23](https://datatracker.ietf.org/doc/draft-ietf-cbor-edn-literals/23/)
513
+ - [Concise Diagnostic Notation (CDN), draft-ietf-cbor-edn-literals-25](https://datatracker.ietf.org/doc/draft-ietf-cbor-edn-literals/25/)
467
514
 
468
- CBOR-EDN は、CBOR データを人間が読み書きしやすいテキストとして表現するための記法です。
515
+ CDN は、CBOR データを人間が読み書きしやすいテキストとして表現するための記法です。
469
516
  サンプル、テストベクター、デバッグ、fixture、設定ファイルに近い用途など、CBOR のバイト列をそのまま扱うと読みにくい場面で役立ちます。
470
517
 
471
518
  通常の配列、マップ、文字列、数値、真偽値、null は JSON に近い見た目で書けます。
472
519
  一方で、CBOR 固有の byte string、tag、simple value、不定長 item、文字列以外の map key、
473
520
  `dt'2026-05-06T00:00:00Z'` のような application literal も表現できます。
474
521
 
475
- CBOR-EDN は JSON / JSONC の上位互換なので、通常の JSON データやコメント付きの JSON 風データも、
476
- 特別な変換なしに CBOR-EDN としてパース・整形できます。
522
+ CDN は JSON / JSONC の上位互換なので、通常の JSON データやコメント付きの JSON 風データも、
523
+ 特別な変換なしに CDN としてパース・整形できます。
477
524
 
478
- CBOR-EDN はまだ広く普及した RFC ではなく、Internet-Draft として策定中の仕様です。
525
+ CDN はまだ広く普及した RFC ではなく、Internet-Draft として策定中の仕様です。
479
526
 
480
527
  ## ライセンス
481
528
 
package/README.md CHANGED
@@ -1,7 +1,7 @@
1
1
  # @cbortech/cbor
2
2
 
3
3
  TypeScript library for converting between [CBOR](#specifications),
4
- [CBOR-EDN](#specifications), and JavaScript values.
4
+ [CDN](#specifications), and JavaScript values.
5
5
 
6
6
  This package exposes the `CBOR` facade plus a separate AST entrypoint for the
7
7
  CBOR node classes needed by extensions. Lower-level parser and encoder internals
@@ -54,29 +54,29 @@ console.log(value);
54
54
  // { hello: 'world', n: 42 }
55
55
  ```
56
56
 
57
- ### CBOR bytes to CBOR-EDN
57
+ ### CBOR bytes to CDN
58
58
 
59
59
  ```ts
60
60
  import { CBOR } from '@cbortech/cbor';
61
61
 
62
- const text = CBOR.cborToCborEdn(new Uint8Array([0x83, 0x01, 0x02, 0x03]));
62
+ const text = CBOR.fromCBOR(new Uint8Array([0x83, 0x01, 0x02, 0x03])).toCDN();
63
63
 
64
64
  console.log(text);
65
65
  // [1,2,3]
66
66
  ```
67
67
 
68
- ### CBOR-EDN to CBOR bytes
68
+ ### CDN to CBOR bytes
69
69
 
70
70
  ```ts
71
71
  import { CBOR } from '@cbortech/cbor';
72
72
 
73
- const bytes = CBOR.cborEdnToCbor('[1, 2, 3]');
73
+ const bytes = CBOR.fromCDN('[1, 2, 3]').toCBOR();
74
74
 
75
75
  console.log(bytes);
76
76
  // Uint8Array([0x83, 0x01, 0x02, 0x03])
77
77
  ```
78
78
 
79
- ### JavaScript to CBOR-EDN
79
+ ### JavaScript to CDN
80
80
 
81
81
  ```ts
82
82
  import { CBOR } from '@cbortech/cbor';
@@ -87,7 +87,7 @@ console.log(text);
87
87
  // {"a":1,"b":true,"c":null}
88
88
  ```
89
89
 
90
- ### Pretty CBOR-EDN
90
+ ### Pretty CDN
91
91
 
92
92
  ```ts
93
93
  import { CBOR } from '@cbortech/cbor';
@@ -105,7 +105,7 @@ console.log(text);
105
105
  // }
106
106
  ```
107
107
 
108
- ### CBOR-EDN to JavaScript
108
+ ### CDN to JavaScript
109
109
 
110
110
  ```ts
111
111
  import { CBOR } from '@cbortech/cbor';
@@ -116,7 +116,7 @@ console.log(value);
116
116
  // [1, Uint8Array(...), true, null]
117
117
  ```
118
118
 
119
- ### Normalize CBOR-EDN
119
+ ### Normalize CDN
120
120
 
121
121
  ```ts
122
122
  import { CBOR } from '@cbortech/cbor';
@@ -135,7 +135,7 @@ console.log(text);
135
135
 
136
136
  ### Split text strings while formatting
137
137
 
138
- `textStringFormat` can split long text strings with EDN string concatenation.
138
+ `textStringFormat` can split long text strings with CDN string concatenation.
139
139
  It is applied when `indent` is specified.
140
140
 
141
141
  ```ts
@@ -154,19 +154,19 @@ console.log(text);
154
154
  // }
155
155
  ```
156
156
 
157
- For strings that contain CBOR-EDN or JSON-like content, use `cboredn`.
157
+ For strings that contain CDN or JSON-like content, use `cdn`.
158
158
 
159
159
  ```ts
160
160
  import { CBOR } from '@cbortech/cbor';
161
161
 
162
- const text = CBOR.format('{"edn": "[1,2,3]"}', {
162
+ const text = CBOR.format('{"cdn": "[1,2,3]"}', {
163
163
  indent: 2,
164
- textStringFormat: ['cboredn'],
164
+ textStringFormat: ['cdn'],
165
165
  });
166
166
 
167
167
  console.log(text);
168
168
  // {
169
- // "edn": "[" +
169
+ // "cdn": "[" +
170
170
  // "1," +
171
171
  // "2," +
172
172
  // "3" +
@@ -176,7 +176,7 @@ console.log(text);
176
176
 
177
177
  ## Working With The AST
178
178
 
179
- `CBOR.fromCBOR()`, `CBOR.fromEDN()`, and `CBOR.fromJS()` return a CBOR item.
179
+ `CBOR.fromCBOR()`, `CBOR.fromCDN()`, and `CBOR.fromJS()` return a CBOR item.
180
180
  Concrete node classes such as `CborTextString`, `CborByteString`, `CborArray`,
181
181
  and `CborTag` are exported from `@cbortech/cbor/ast` for extensions. Every item
182
182
  supports these methods:
@@ -185,11 +185,11 @@ supports these methods:
185
185
  import { CBOR } from '@cbortech/cbor';
186
186
  import { CborItem } from '@cbortech/cbor/ast';
187
187
 
188
- const item = CBOR.fromEDN('{ "x": 1 }');
188
+ const item = CBOR.fromCDN('{ "x": 1 }');
189
189
  item satisfies CborItem;
190
190
 
191
191
  const bytes = item.toCBOR();
192
- const text = item.toEDN();
192
+ const text = item.toCDN();
193
193
  const value = item.toJS();
194
194
  ```
195
195
 
@@ -198,23 +198,23 @@ const value = item.toJS();
198
198
  ```ts
199
199
  import { CBOR } from '@cbortech/cbor';
200
200
 
201
- const item = CBOR.fromEDN('[_ 1, 2, 3]');
201
+ const item = CBOR.fromCDN('[_ 1, 2, 3]');
202
202
 
203
- console.log(item.toEDN());
203
+ console.log(item.toCDN());
204
204
  // [_ 1,2,3]
205
205
 
206
206
  console.log(item.toCBOR());
207
207
  // Uint8Array(...)
208
208
  ```
209
209
 
210
- ### Decode to AST, then inspect as EDN
210
+ ### Decode to AST, then inspect as CDN
211
211
 
212
212
  ```ts
213
213
  import { CBOR } from '@cbortech/cbor';
214
214
 
215
215
  const item = CBOR.fromCBOR(new Uint8Array([0x83, 0x01, 0x02, 0x03]));
216
216
 
217
- console.log(item.toEDN());
217
+ console.log(item.toCDN());
218
218
  // [1,2,3]
219
219
 
220
220
  console.log(item.toJS());
@@ -303,7 +303,7 @@ console.log(cbor.stringify({ value }));
303
303
 
304
304
  ## Dates
305
305
 
306
- CBOR-EDN `dt'...'` and `DT'...'` literals are parsed by default. Add `CBOR.dt_as_Date`
306
+ CDN `dt'...'` and `DT'...'` literals are parsed by default. Add `CBOR.dt_as_Date`
307
307
  when you want JavaScript `Date` objects.
308
308
 
309
309
  ```ts
@@ -328,6 +328,41 @@ console.log(text);
328
328
  // DT'2026-05-06T00:00:00Z'
329
329
  ```
330
330
 
331
+ ## Optional Extensions
332
+
333
+ Additional application extensions are published as separate packages. Install
334
+ the ones you need and pass them through the `extensions` option.
335
+
336
+ `hash` is an application extension defined by the CDN specification, but
337
+ it requires an external package. For that reason, it is not bundled with this
338
+ package and is provided separately as `@cbortech/hash-extension`.
339
+
340
+ `uuid` is a library-specific application extension that is not defined by the
341
+ CDN specification. To keep it distinct from standard CDN features, it
342
+ is provided separately as `@cbortech/uuid-extension`.
343
+
344
+ ```bash
345
+ npm install @cbortech/hash-extension @cbortech/uuid-extension
346
+ ```
347
+
348
+ ```ts
349
+ import { CBOR } from '@cbortech/cbor';
350
+ import hashExtension from '@cbortech/hash-extension';
351
+ import uuidExtension from '@cbortech/uuid-extension';
352
+
353
+ const cbor = new CBOR({
354
+ extensions: [hashExtension, uuidExtension],
355
+ });
356
+
357
+ const digest = cbor.fromCDN("hash'foo'");
358
+ console.log(digest.toCDN());
359
+ // hash'foo'
360
+
361
+ const id = cbor.fromCDN("uuid'550e8400-e29b-41d4-a716-446655440000'");
362
+ console.log(id.toCDN());
363
+ // uuid'550e8400-e29b-41d4-a716-446655440000'
364
+ ```
365
+
331
366
  ## Tags
332
367
 
333
368
  Use `CBOR.Tag` for CBOR tagged values in JavaScript.
@@ -354,6 +389,18 @@ console.log(CBOR.Tag.getValue(value));
354
389
  // "hello"
355
390
  ```
356
391
 
392
+ Use `stripTags: true` when you only need the tagged content as a plain
393
+ JavaScript value.
394
+
395
+ ```ts
396
+ import { CBOR } from '@cbortech/cbor';
397
+
398
+ const value = CBOR.parse('42("hello")', { stripTags: true });
399
+
400
+ console.log(value);
401
+ // "hello"
402
+ ```
403
+
357
404
  ## Simple Values
358
405
 
359
406
  Use `CBOR.Simple` for CBOR simple values other than `false`, `true`, `null`, and
@@ -428,7 +475,7 @@ CBOR items can produce and parse annotated hex dumps.
428
475
  ```ts
429
476
  import { CBOR } from '@cbortech/cbor';
430
477
 
431
- const item = CBOR.fromEDN('[_ 1, [2, 3]]');
478
+ const item = CBOR.fromCDN('[_ 1, [2, 3]]');
432
479
  const dump = item.toHexDump();
433
480
 
434
481
  console.log(dump);
@@ -446,7 +493,7 @@ const item = CBOR.fromHexDump(`
446
493
  03 -- 3
447
494
  `);
448
495
 
449
- console.log(item.toEDN());
496
+ console.log(item.toCDN());
450
497
  // [1,2,3]
451
498
  ```
452
499
 
@@ -469,9 +516,9 @@ The `CBOR` facade also exposes:
469
516
  This library targets:
470
517
 
471
518
  - [CBOR, RFC 8949](https://www.rfc-editor.org/rfc/rfc8949)
472
- - [CBOR Extended Diagnostic Notation (CBOR-EDN), draft-ietf-cbor-edn-literals-23](https://datatracker.ietf.org/doc/draft-ietf-cbor-edn-literals/23/)
519
+ - [Concise Diagnostic Notation (CDN), draft-ietf-cbor-edn-literals-25](https://datatracker.ietf.org/doc/draft-ietf-cbor-edn-literals/25/)
473
520
 
474
- CBOR-EDN is a human-readable text notation for CBOR data. It is useful for
521
+ CDN is a human-readable text notation for CBOR data. It is useful for
475
522
  examples, test vectors, debugging, fixtures, and configuration-like files where
476
523
  raw CBOR bytes would be hard to read.
477
524
 
@@ -480,11 +527,11 @@ and null values, but it can also represent CBOR-specific features such as byte
480
527
  strings, tags, simple values, indefinite-length items, non-string map keys, and
481
528
  application literals like `dt'2026-05-06T00:00:00Z'`.
482
529
 
483
- CBOR-EDN is a superset of JSON and JSONC, so ordinary JSON data and
484
- commented JSON-style data can be parsed and formatted as CBOR-EDN without
530
+ CDN is a superset of JSON and JSONC, so ordinary JSON data and
531
+ commented JSON-style data can be parsed and formatted as CDN without
485
532
  special handling.
486
533
 
487
- CBOR-EDN is still an Internet-Draft rather than a widely deployed RFC.
534
+ CDN is still an Internet-Draft rather than a widely deployed RFC.
488
535
 
489
536
  ## License
490
537
 
@@ -1,4 +1,4 @@
1
- import { ToEDNOptions, ToJSOptions, ToCBOROptions } from '../types';
1
+ import { ToCDNOptions, ToJSOptions, ToCBOROptions } from '../types';
2
2
  import { CborItem, AnnotatedLine } from './CborItem';
3
3
  import { EncodingWidth } from '../cbor/encode';
4
4
  /** CBOR Major Type 4 — array (definite- or indefinite-length). */
@@ -11,7 +11,7 @@ export declare class CborArray extends CborItem {
11
11
  encodingWidth?: EncodingWidth;
12
12
  });
13
13
  _toCBOR(options?: ToCBOROptions): Uint8Array;
14
- _toEDN(options: ToEDNOptions | undefined, depth: number): string;
15
- _toHexDump(depth: number, options?: ToEDNOptions): AnnotatedLine[];
14
+ _toCDN(options: ToCDNOptions | undefined, depth: number): string;
15
+ _toHexDump(depth: number, options?: ToCDNOptions): AnnotatedLine[];
16
16
  _toJS(options?: ToJSOptions): unknown;
17
17
  }
@@ -1,4 +1,4 @@
1
- import { ToEDNOptions, ToJSOptions } from '../types';
1
+ import { ToCDNOptions, ToJSOptions } from '../types';
2
2
  import { CborTag } from './CborTag';
3
3
  export declare const BIGNUM_UINT_TAG = 2n;
4
4
  export declare const BIGNUM_NINT_TAG = 3n;
@@ -15,22 +15,22 @@ export declare function bytesToBigint(bytes: Uint8Array): bigint;
15
15
  /**
16
16
  * Unsigned bignum — integers ≥ 2^64.
17
17
  * Wire format: tag(2, big-endian byte string).
18
- * toEDN() emits the plain decimal integer.
18
+ * toCDN() emits the plain decimal integer.
19
19
  */
20
20
  export declare class CborBigUint extends CborTag {
21
21
  readonly bigValue: bigint;
22
22
  constructor(value: bigint);
23
- _toEDN(_options: ToEDNOptions | undefined, _depth: number): string;
23
+ _toCDN(_options: ToCDNOptions | undefined, _depth: number): string;
24
24
  _toJS(_options?: ToJSOptions): bigint;
25
25
  }
26
26
  /**
27
27
  * Negative bignum — integers ≤ -(2^64 + 1).
28
28
  * Wire format: tag(3, big-endian byte string of (-1 - value)).
29
- * toEDN() emits the plain decimal integer.
29
+ * toCDN() emits the plain decimal integer.
30
30
  */
31
31
  export declare class CborBigNint extends CborTag {
32
32
  readonly bigValue: bigint;
33
33
  constructor(value: bigint);
34
- _toEDN(_options: ToEDNOptions | undefined, _depth: number): string;
34
+ _toCDN(_options: ToCDNOptions | undefined, _depth: number): string;
35
35
  _toJS(_options?: ToJSOptions): bigint;
36
36
  }
@@ -1,4 +1,4 @@
1
- import { ToEDNOptions, ToJSOptions, ToCBOROptions } from '../types';
1
+ import { ToCDNOptions, ToJSOptions, ToCBOROptions } from '../types';
2
2
  import { CborItem } from './CborItem';
3
3
  import { EncodingWidth } from '../cbor/encode';
4
4
  /** CBOR Major Type 2 — definite-length byte string. */
@@ -15,6 +15,6 @@ export declare class CborByteString extends CborItem {
15
15
  ednSource?: string;
16
16
  });
17
17
  _toCBOR(_options?: ToCBOROptions): Uint8Array;
18
- _toEDN(options: ToEDNOptions | undefined, _depth: number): string;
18
+ _toCDN(options: ToCDNOptions | undefined, _depth: number): string;
19
19
  _toJS(_options?: ToJSOptions): unknown;
20
20
  }
@@ -1,4 +1,4 @@
1
- import { ToEDNOptions } from '../types';
1
+ import { ToCDNOptions } from '../types';
2
2
  import { CborTag } from './CborTag';
3
3
  import { CborItem } from './CborItem';
4
4
  export declare const CPA888_TAG = 888n;
@@ -7,5 +7,5 @@ export declare class CborEllipsis extends CborTag {
7
7
  constructor();
8
8
  /** String/bytes elision: 888([items...]) */
9
9
  constructor(items: CborItem[]);
10
- _toEDN(options: ToEDNOptions | undefined, depth: number): string;
10
+ _toCDN(options: ToCDNOptions | undefined, depth: number): string;
11
11
  }
@@ -1,4 +1,4 @@
1
- import { ToEDNOptions, ToJSOptions, ToCBOROptions } from '../types';
1
+ import { ToCDNOptions, ToJSOptions, ToCBOROptions } from '../types';
2
2
  import { CborItem, AnnotatedLine } from './CborItem';
3
3
  /**
4
4
  * CBOR Sequence Literal (§2.5.6) — `<<item, item, ...>>`.
@@ -16,7 +16,7 @@ export declare class CborEmbeddedCBOR extends CborItem {
16
16
  /** The raw concatenated CBOR bytes of all contained items. */
17
17
  private _content;
18
18
  _toCBOR(options?: ToCBOROptions): Uint8Array;
19
- _toEDN(options: ToEDNOptions | undefined, depth: number): string;
20
- _toHexDump(depth: number, options?: ToEDNOptions): AnnotatedLine[];
19
+ _toCDN(options: ToCDNOptions | undefined, depth: number): string;
20
+ _toHexDump(depth: number, options?: ToCDNOptions): AnnotatedLine[];
21
21
  _toJS(_options?: ToJSOptions): unknown;
22
22
  }
@@ -1,4 +1,4 @@
1
- import { ToEDNOptions, ToJSOptions, ToCBOROptions } from '../types';
1
+ import { ToCDNOptions, ToJSOptions, ToCBOROptions } from '../types';
2
2
  import { CborItem } from './CborItem';
3
3
  export type FloatPrecision = 'half' | 'single' | 'double';
4
4
  /**
@@ -22,6 +22,6 @@ export declare class CborFloat extends CborItem {
22
22
  precision?: FloatPrecision;
23
23
  });
24
24
  _toCBOR(_options?: ToCBOROptions): Uint8Array;
25
- _toEDN(options: ToEDNOptions | undefined, _depth: number): string;
25
+ _toCDN(options: ToCDNOptions | undefined, _depth: number): string;
26
26
  _toJS(_options?: ToJSOptions): unknown;
27
27
  }
@@ -1,4 +1,4 @@
1
- import { ToEDNOptions, ToJSOptions, ToCBOROptions } from '../types';
1
+ import { ToCDNOptions, ToJSOptions, ToCBOROptions } from '../types';
2
2
  import { CborItem, AnnotatedLine } from './CborItem';
3
3
  import { CborByteString } from './CborByteString';
4
4
  /** CBOR Major Type 2 — indefinite-length byte string (chunked). */
@@ -7,7 +7,7 @@ export declare class CborIndefiniteByteString extends CborItem {
7
7
  readonly chunks: CborByteString[];
8
8
  constructor(chunks: CborByteString[]);
9
9
  _toCBOR(options?: ToCBOROptions): Uint8Array;
10
- _toEDN(options: ToEDNOptions | undefined, _depth: number): string;
11
- _toHexDump(depth: number, options?: ToEDNOptions): AnnotatedLine[];
10
+ _toCDN(options: ToCDNOptions | undefined, _depth: number): string;
11
+ _toHexDump(depth: number, options?: ToCDNOptions): AnnotatedLine[];
12
12
  _toJS(_options?: ToJSOptions): unknown;
13
13
  }
@@ -1,4 +1,4 @@
1
- import { ToEDNOptions, ToJSOptions, ToCBOROptions } from '../types';
1
+ import { ToCDNOptions, ToJSOptions, ToCBOROptions } from '../types';
2
2
  import { CborItem, AnnotatedLine } from './CborItem';
3
3
  import { CborTextString } from './CborTextString';
4
4
  /** CBOR Major Type 3 — indefinite-length UTF-8 text string (chunked). */
@@ -7,7 +7,7 @@ export declare class CborIndefiniteTextString extends CborItem {
7
7
  readonly chunks: CborTextString[];
8
8
  constructor(chunks: CborTextString[]);
9
9
  _toCBOR(options?: ToCBOROptions): Uint8Array;
10
- _toEDN(options: ToEDNOptions | undefined, _depth: number): string;
11
- _toHexDump(depth: number, options?: ToEDNOptions): AnnotatedLine[];
10
+ _toCDN(options: ToCDNOptions | undefined, _depth: number): string;
11
+ _toHexDump(depth: number, options?: ToCDNOptions): AnnotatedLine[];
12
12
  _toJS(_options?: ToJSOptions): unknown;
13
13
  }