@decimalturn/toml-patch 3.3.3-dev → 3.3.3-lite

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 (81) hide show
  1. package/dist/patch.js +20 -0
  2. package/package.json +6 -11
  3. package/dist/dev/comment-alignment.js +0 -371
  4. package/dist/dev/comment-alignment.js.map +0 -1
  5. package/dist/dev/comment-ownership.js +0 -672
  6. package/dist/dev/comment-ownership.js.map +0 -1
  7. package/dist/dev/cst-source.js +0 -117
  8. package/dist/dev/cst-source.js.map +0 -1
  9. package/dist/dev/cst.js +0 -67
  10. package/dist/dev/cst.js.map +0 -1
  11. package/dist/dev/cursor.js +0 -65
  12. package/dist/dev/cursor.js.map +0 -1
  13. package/dist/dev/date-format.js +0 -286
  14. package/dist/dev/date-format.js.map +0 -1
  15. package/dist/dev/decode-utf8.js +0 -26
  16. package/dist/dev/decode-utf8.js.map +0 -1
  17. package/dist/dev/diff-lite.js +0 -107
  18. package/dist/dev/diff-lite.js.map +0 -1
  19. package/dist/dev/diff.js +0 -264
  20. package/dist/dev/diff.js.map +0 -1
  21. package/dist/dev/encode-lite.js +0 -209
  22. package/dist/dev/encode-lite.js.map +0 -1
  23. package/dist/dev/escape-preference.js +0 -165
  24. package/dist/dev/escape-preference.js.map +0 -1
  25. package/dist/dev/find-by-path.js +0 -114
  26. package/dist/dev/find-by-path.js.map +0 -1
  27. package/dist/dev/formatter.js +0 -297
  28. package/dist/dev/formatter.js.map +0 -1
  29. package/dist/dev/generate.js +0 -479
  30. package/dist/dev/generate.js.map +0 -1
  31. package/dist/dev/inline-comma-space.js +0 -12
  32. package/dist/dev/inline-comma-space.js.map +0 -1
  33. package/dist/dev/inline-format.js +0 -105
  34. package/dist/dev/inline-format.js.map +0 -1
  35. package/dist/dev/inline-layout.js +0 -106
  36. package/dist/dev/inline-layout.js.map +0 -1
  37. package/dist/dev/line-ending-backslash.js +0 -319
  38. package/dist/dev/line-ending-backslash.js.map +0 -1
  39. package/dist/dev/literal-string.js +0 -45
  40. package/dist/dev/literal-string.js.map +0 -1
  41. package/dist/dev/location.js +0 -103
  42. package/dist/dev/location.js.map +0 -1
  43. package/dist/dev/parse-error.js +0 -26
  44. package/dist/dev/parse-error.js.map +0 -1
  45. package/dist/dev/parse-js.js +0 -149
  46. package/dist/dev/parse-js.js.map +0 -1
  47. package/dist/dev/parse-string.js +0 -119
  48. package/dist/dev/parse-string.js.map +0 -1
  49. package/dist/dev/parse-toml.js +0 -713
  50. package/dist/dev/parse-toml.js.map +0 -1
  51. package/dist/dev/patch-lite.js +0 -4
  52. package/dist/dev/patch-lite2.js +0 -96
  53. package/dist/dev/patch-lite2.js.map +0 -1
  54. package/dist/dev/patch.js +0 -3143
  55. package/dist/dev/patch.js.map +0 -1
  56. package/dist/dev/smol-toml-date.js +0 -60
  57. package/dist/dev/smol-toml-date.js.map +0 -1
  58. package/dist/dev/to-js.js +0 -307
  59. package/dist/dev/to-js.js.map +0 -1
  60. package/dist/dev/to-toml.js +0 -873
  61. package/dist/dev/to-toml.js.map +0 -1
  62. package/dist/dev/tokenizer.js +0 -224
  63. package/dist/dev/tokenizer.js.map +0 -1
  64. package/dist/dev/toml-document.js +0 -220
  65. package/dist/dev/toml-document.js.map +0 -1
  66. package/dist/dev/toml-format.js +0 -548
  67. package/dist/dev/toml-format.js.map +0 -1
  68. package/dist/dev/toml-patch.js +0 -93
  69. package/dist/dev/toml-patch.js.map +0 -1
  70. package/dist/dev/traverse.js +0 -60
  71. package/dist/dev/traverse.js.map +0 -1
  72. package/dist/dev/truncate.js +0 -63
  73. package/dist/dev/truncate.js.map +0 -1
  74. package/dist/dev/update-order.js +0 -234
  75. package/dist/dev/update-order.js.map +0 -1
  76. package/dist/dev/utils.js +0 -295
  77. package/dist/dev/utils.js.map +0 -1
  78. package/dist/dev/writer.js +0 -757
  79. package/dist/dev/writer.js.map +0 -1
  80. package/dist/toml-patch.d.ts +0 -548
  81. /package/dist/{patch-lite.d.ts → patch.d.ts} +0 -0
@@ -1,548 +0,0 @@
1
-
2
- type MultilineContainerMode = boolean | number | 'auto' | 'parent';
3
- export declare class TomlFormat {
4
- /**
5
- * The line ending character(s) to use in the output TOML.
6
- * This option affects only the stringification process, not the internal representation (CST).
7
- *
8
- * @example
9
- * - '\n' for Unix/Linux line endings
10
- * - '\r\n' for Windows line endings
11
- */
12
- newLine: string;
13
- /**
14
- * The number of trailing newlines to add at the end of the TOML document.
15
- * This option affects only the stringification process, not the internal representation (CST).
16
- *
17
- * @example
18
- * - 0: No trailing newline
19
- * - 1: One trailing newline (standard)
20
- * - 2: Two trailing newlines (adds extra spacing)
21
- */
22
- trailingNewline: number;
23
- /**
24
- * Whether to add trailing commas after the last element in arrays and inline tables.
25
- *
26
- * @example
27
- * - true: [1, 2, 3,] and { x = 1, y = 2, }
28
- * - false: [1, 2, 3] and { x = 1, y = 2 }
29
- */
30
- trailingComma: boolean;
31
- /**
32
- * Whether to add spaces after opening brackets/braces and before closing brackets/braces
33
- * in arrays and inline tables.
34
- *
35
- * @example
36
- * - true: [ 1, 2, 3 ] and { x = 1, y = 2 }
37
- * - false: [1, 2, 3] and {x = 1, y = 2}
38
- */
39
- bracketSpacing: boolean;
40
- /**
41
- * Whether the output should include a leading UTF-8 BOM marker (U+FEFF).
42
- *
43
- * This is auto-detected from the source TOML and preserved during patching.
44
- */
45
- leadingBom: boolean;
46
- /**
47
- * The nesting depth at which new tables should start being formatted as inline tables.
48
- * When adding new tables during patching or stringifying objects:
49
- * - Tables at depth >= inlineTableStart will be formatted as inline tables
50
- * - Tables at depth < inlineTableStart will be formatted as separate table sections
51
- *
52
- * @example
53
- * - 0: All tables are inline tables including top-level tables (root level)
54
- * - 1: Top-level tables as sections, nested tables as inline (default)
55
- * - 2: Two levels as sections, deeper nesting as inline
56
- */
57
- inlineTableStart?: number;
58
- /**
59
- * Whether to truncate time components in UTC date fields when they are zero.
60
- * This setting affects only the stringification process.
61
- *
62
- * @example
63
- * - true: Date('2024-01-15T00:00:00.000Z') serializes as 2024-01-15
64
- * - false: Date('2024-01-15T00:00:00.000Z') serializes as 2024-01-15T00:00:00.000Z
65
- *
66
- */
67
- truncateZeroTimeInDates?: boolean;
68
- /**
69
- * Whether to use tabs instead of spaces for indentation/padding.
70
- * When enabled, lines that need to be indented will use tabs.
71
- *
72
- * @example
73
- * - true: Uses tabs for indentation
74
- * - false: Uses spaces for indentation (default)
75
- *
76
- */
77
- useTabsForIndentation?: boolean;
78
- /**
79
- * The number of columns used for one indentation level in generated multiline values.
80
- * This is auto-detected when patching and defaults to two columns.
81
- */
82
- indentWidth: number;
83
- /**
84
- * The minimum number of decimal places to use when serializing JS numbers as TOML floats.
85
- * When greater than 0, plain JS integer values are serialized as TOML floats padded with
86
- * zeros to reach the specified decimal count. BigInt values are always serialized as integers
87
- * regardless of this setting.
88
- *
89
- * @example
90
- * - 0: stringify({ x: 1, y: 1.5 }) → x = 1 / y = 1.5 (default)
91
- * - 1: stringify({ x: 1, y: 1.5 }) → x = 1.0 / y = 1.5
92
- * - 2: stringify({ x: 1, y: 1.5 }) → x = 1.00 / y = 1.50
93
- */
94
- minimumDecimals?: number;
95
- /**
96
- * The minimum number of fractional-second digits to write for date/time values.
97
- *
98
- * When greater than 0, a time or datetime is padded with zeros to reach the specified digit
99
- * count, and a time written as `HH:MM` gains `:00` before its fraction. Digits already written
100
- * are never removed, so a value with more digits keeps them, and a date-only value is
101
- * unaffected because it carries no time. This is separate from `minimumDecimals`, which
102
- * applies to numbers, so the two can be set independently.
103
- *
104
- * Not auto-detectable — caller must set explicitly.
105
- *
106
- * @example
107
- * - 0: t = 07:32:00 (default)
108
- * - 3: t = 07:32:00.000
109
- */
110
- minimumTimeDecimals?: number;
111
- /**
112
- * Whether `patch()` should reorder root key-values, `[table]`/`[[array]]` section blocks,
113
- * and rows inside table bodies to match the key order of the JS object passed to `patch()`,
114
- * carrying each entry's owned comments along with it (see docs/CommentOwnership.md).
115
- *
116
- * Off by default: with the option unset or `false`, `patch()` only ever changes values that
117
- * actually differ between the existing document and the updated object, preserving the
118
- * existing document's order even when the JS object's key order differs.
119
- *
120
- * Not auto-detectable — the existing document's order says nothing about the caller's
121
- * intent, so `autoDetectFormatWithCst` always resolves this to `false`.
122
- *
123
- * See docs/PLAN-Update-Order.md for the full behavior and current scope limitations.
124
- */
125
- updateOrder?: boolean;
126
- /**
127
- * Whether newly generated inline tables should use multiline layout.
128
- *
129
- * `true` and `false` select a layout directly. A non-negative integer selects
130
- * multiline layout at that structural container depth or deeper. `'auto'`
131
- * keeps new containers compact and `'parent'` follows the immediate parent.
132
- */
133
- multilineTable: MultilineContainerMode;
134
- /**
135
- * Whether newly generated inline arrays should use multiline layout.
136
- *
137
- * `true` and `false` select a layout directly. A non-negative integer selects
138
- * multiline layout at that structural container depth or deeper. `'auto'`
139
- * keeps new containers compact and `'parent'` follows the immediate parent.
140
- */
141
- multilineArray: MultilineContainerMode;
142
- /**
143
- * Whether to write `\uXXXX` / `\UXXXXXXXX` / `\xHH` escape sequences with
144
- * uppercase hex digits. Auto-detected from the first hex escape sequence in
145
- * the document during patching; defaults to `true` (uppercase hex).
146
- */
147
- escapeSequenceUpperCase: boolean;
148
- constructor(newLine?: string, trailingNewline?: number, trailingComma?: boolean, bracketSpacing?: boolean, inlineTableStart?: number, truncateZeroTimeInDates?: boolean, useTabsForIndentation?: boolean, minimumDecimals?: number, leadingBom?: boolean, updateOrder?: boolean, indentWidth?: number, multilineTable?: MultilineContainerMode | null, multilineArray?: MultilineContainerMode | null, escapeSequenceUpperCase?: boolean, minimumTimeDecimals?: number);
149
- /**
150
- * Creates a new TomlFormat instance with default formatting preferences.
151
- *
152
- * @returns A new TomlFormat instance with default values:
153
- * - newLine: '\n'
154
- * - trailingNewline: 1
155
- * - trailingComma: false
156
- * - bracketSpacing: true
157
- * - leadingBom: false
158
- * - inlineTableStart: 1
159
- * - truncateZeroTimeInDates: false
160
- * - useTabsForIndentation: false
161
- * - minimumDecimals: 0
162
- * - minimumTimeDecimals: 0
163
- * - updateOrder: false
164
- */
165
- static default(): TomlFormat;
166
- /**
167
- * Auto-detects formatting preferences from an existing TOML string.
168
- *
169
- * This method analyzes the provided TOML string to determine formatting
170
- * preferences such as line endings, trailing newlines, and comma usage.
171
- *
172
- * @param tomlString - The TOML string to analyze for formatting patterns
173
- * @returns A new TomlFormat instance with detected formatting preferences
174
- *
175
- * @example
176
- * ```typescript
177
- * const toml = 'array = ["a", "b", "c",]\ntable = { x = 1, y = 2, }';
178
- * const format = TomlFormat.autoDetectFormat(toml);
179
- * // format.trailingComma will be true
180
- * // format.newLine will be '\n'
181
- * // format.trailingNewline will be 0 (no trailing newline)
182
- * ```
183
- */
184
- static autoDetectFormat(tomlString: string): TomlFormat;
185
- /**
186
- * Internal method: Auto-detects formatting preferences from a TOML string with optional pre-parsed CST.
187
- *
188
- * This is used internally to avoid redundant parsing when the CST is already available.
189
- * External callers should use `autoDetectFormat(tomlString)` instead.
190
- *
191
- * @internal
192
- * @param tomlString - The TOML string to analyze for formatting patterns
193
- * @param syntaxTree - Optional pre-parsed CST to avoid redundant parsing
194
- * @returns A new TomlFormat instance with detected formatting preferences
195
- */
196
- static autoDetectFormatWithCst(tomlString: string, syntaxTree?: Iterable<any>): TomlFormat;
197
- /** @deprecated Use autoDetectFormatWithCst instead. */
198
- static autoDetectFormatWithAst(tomlString: string, syntaxTree?: Iterable<any>): TomlFormat;
199
- }
200
- type IntegersAsBigInt = boolean | 'asNeeded';
201
- interface ParseOptions {
202
- /**
203
- * Controls how TOML integers are returned in the parsed JavaScript object.
204
- * - `true`: All integers are returned as `bigint`.
205
- * - `false`: All integers are returned as `number` (may lose precision for large integers).
206
- * - `'asNeeded'` (default): Integers that fit within the JavaScript safe-integer range are returned as `number`; larger integers are returned as `bigint`.
207
- */
208
- integersAsBigInt?: IntegersAsBigInt;
209
- /**
210
- * When true, TOML date/time values are parsed into Temporal objects
211
- * (Temporal.PlainDate, Temporal.PlainTime, Temporal.PlainDateTime,
212
- * Temporal.ZonedDateTime) instead of custom Date subclasses.
213
- *
214
- * The Temporal API must be available in the runtime.
215
- * - Node.js >= v26: full native support.
216
- * - Node.js < v26: enable with the `--harmony-temporal` flag.
217
- * - Modern browsers: native support.
218
- * - Other runtimes: use @js-temporal/polyfill.
219
- *
220
- * Default: false (returns custom Date subclasses for backward compatibility).
221
- */
222
- temporal?: boolean;
223
- }
224
- interface Location {
225
- start: Position;
226
- end: Position;
227
- }
228
- interface Position {
229
- line: number;
230
- column: number;
231
- }
232
- declare enum NodeType {
233
- Document = "Document",
234
- Table = "Table",
235
- TableKey = "TableKey",
236
- /**
237
- * Array of Tables node
238
- * More info: https://toml.io/en/latest#array-of-tables
239
- */
240
- TableArray = "TableArray",
241
- TableArrayKey = "TableArrayKey",
242
- KeyValue = "KeyValue",
243
- Key = "Key",
244
- String = "String",
245
- Integer = "Integer",
246
- Float = "Float",
247
- Boolean = "Boolean",
248
- DateTime = "DateTime",
249
- InlineArray = "InlineArray",
250
- InlineItem = "InlineItem",
251
- InlineTable = "InlineTable",
252
- /**
253
- * Comment node
254
- * More info: https://toml.io/en/latest#comment
255
- */
256
- Comment = "Comment"
257
- }
258
- interface Table extends TreeNode {
259
- type: NodeType.Table;
260
- key: TableKey;
261
- items: RowItem[];
262
- }
263
- interface TableKey extends TreeNode {
264
- type: NodeType.TableKey;
265
- item: Key;
266
- }
267
- interface TableArray extends TreeNode {
268
- type: NodeType.TableArray;
269
- key: TableArrayKey;
270
- items: RowItem[];
271
- }
272
- interface TableArrayKey extends TreeNode {
273
- type: NodeType.TableArrayKey;
274
- item: Key;
275
- }
276
- interface KeyValue extends TreeNode {
277
- type: NodeType.KeyValue;
278
- key: Key;
279
- value: Value;
280
- equals: number;
281
- }
282
- interface Key extends TreeNode {
283
- type: NodeType.Key;
284
- raw: string;
285
- value: string[];
286
- }
287
- interface String extends TreeNode {
288
- type: NodeType.String;
289
- raw: string;
290
- value: string;
291
- }
292
- interface Integer extends TreeNode {
293
- type: NodeType.Integer;
294
- raw: string;
295
- value: number | bigint;
296
- }
297
- interface Float extends TreeNode {
298
- type: NodeType.Float;
299
- raw: string;
300
- value: number;
301
- /** Sign prefix for NaN values: '+' for +nan, '-' for -nan, undefined for nan */
302
- nanSign?: '+' | '-';
303
- }
304
- interface Boolean extends TreeNode {
305
- type: NodeType.Boolean;
306
- value: boolean;
307
- }
308
- interface DateTime extends TreeNode {
309
- type: NodeType.DateTime;
310
- raw: string;
311
- value: Date;
312
- }
313
- interface InlineArray<TItem = TreeNode> extends TreeNode {
314
- type: NodeType.InlineArray;
315
- items: InlineArrayItem<TItem>[];
316
- }
317
- interface InlineItem<TItem = TreeNode> extends TreeNode {
318
- type: NodeType.InlineItem;
319
- item: TItem;
320
- comma: boolean;
321
- }
322
- interface InlineArrayItem<TItem = TreeNode> extends InlineItem<TItem> {}
323
- interface InlineTable extends TreeNode {
324
- type: NodeType.InlineTable;
325
- items: InlineTableItem[];
326
- }
327
- interface InlineTableItem extends InlineItem<KeyValue> {}
328
- interface Comment extends TreeNode {
329
- type: NodeType.Comment;
330
- raw: string;
331
- }
332
- /**
333
- * RowItem represents items that can appear inside Table and TableArray sections.
334
- * These are the items that form the "rows" of content within table structures.
335
- *
336
- * Unlike Block items (which include Table and TableArray), RowItems can only be
337
- * KeyValue pairs and Comments - you cannot have nested tables within a table section.
338
- */
339
- type RowItem = KeyValue | Comment;
340
- /**
341
- * Block represents items that can appear at the root level (Document level) in TOML.
342
- *
343
- * Context and Usage:
344
- * - Block items are the fundamental top-level constructs in a TOML document
345
- * - They appear directly in Document containers and regular Table sections
346
- * - This is in contrast to InlineItems, which appear within inline containers
347
- *
348
- * Important Distinction:
349
- * - Table and TableArray can ONLY exist as Block items (they cannot appear inside inline containers)
350
- * - KeyValue and Comment can exist as BOTH Block items AND as InlineItems:
351
- * * As Block: When they appear at root level or inside regular Table sections
352
- * * As InlineItem: When they appear inside InlineTable or InlineArray containers
353
- *
354
- * Examples:
355
- * ```toml
356
- * # These are Block items at root level:
357
- * name = "value" # KeyValue as Block
358
- * # This is a comment # Comment as Block
359
- * [table] # Table as Block
360
- * [[array]] # TableArray as Block
361
- *
362
- * # These are Block items inside a Table:
363
- * [config]
364
- * setting = "value" # KeyValue as Block (inside Table)
365
- * # comment here # Comment as Block (inside Table)
366
- *
367
- * # These are InlineItems (NOT Block items):
368
- * array = [ "a", "b" ] # "a", "b" are InlineItems
369
- * table = { key = "value" } # key="value" is InlineItem
370
- * ```
371
- *
372
- * Type Safety:
373
- * This distinction is crucial for the CST structure because:
374
- * - Document.items: Block[]
375
- * - Table.items: RowItem[] (KeyValue | Comment)
376
- * - TableArray.items: RowItem[] (KeyValue | Comment)
377
- * - InlineArray.items: InlineArrayItem[] (which extends InlineItem)
378
- * - InlineTable.items: InlineTableItem[] (which extends InlineItem)
379
- */
380
- type Block = KeyValue | Table | TableArray | Comment;
381
- type Value<TInlineArrayItem = TreeNode> = String | Integer | Float | Boolean | DateTime | InlineArray<TInlineArrayItem> | InlineTable;
382
- interface TreeNode {
383
- type: NodeType;
384
- loc: Location;
385
- /** Absolute UTF-16 offsets into the source that produced this node. */
386
- readonly range?: readonly [number, number];
387
- /** Set on generated or mutated nodes and propagated to their ancestors. */
388
- dirty?: boolean;
389
- }
390
- /**
391
- * TomlDocument encapsulates a TOML CST and provides methods to interact with it.
392
- */
393
- export declare class TomlDocument {
394
- private _cst;
395
- private _currentTomlString;
396
- private _format;
397
- private _integersAsBigInt;
398
- private _temporal;
399
- /**
400
- * Initializes the TomlDocument with TOML source, parsing it into a CST.
401
- *
402
- * When bytes are provided, they are decoded as UTF-8 in fatal mode.
403
- * This rejects invalid UTF-8 sequences before parsing.
404
- *
405
- * @param tomlSource - The TOML source to parse (string or raw UTF-8 bytes)
406
- * @param options - Optional parse options
407
- * @param options.integersAsBigInt - Controls bigint vs number for TOML integers
408
- * @param options.temporal - When true, returns Temporal objects for date/time values
409
- */
410
- constructor(tomlSource: string | Uint8Array, options?: ParseOptions);
411
- get toTomlString(): string;
412
- /**
413
- * Returns the JavaScript object representation of the TOML document.
414
- */
415
- get toJsObject(): any;
416
- /**
417
- * Returns the internal CST (for testing purposes).
418
- * @internal
419
- */
420
- get cst(): Block[];
421
- /**
422
- * Applies a patch to the current CST using a modified JS object.
423
- * Updates the internal CST. Use toTomlString getter to retrieve the updated TOML string.
424
- *
425
- * @param updatedObject - The modified JS object to patch with
426
- * @param format - Optional formatting options
427
- */
428
- patch(updatedObject: any, format?: Partial<TomlFormat> | TomlFormat): void;
429
- /**
430
- * Updates the internal document by supplying a modified tomlString.
431
- * Use toJsObject getter to retrieve the updated JS object representation.
432
- * @param tomlString - The modified TOML string to update with
433
- */
434
- update(tomlString: string): void;
435
- /**
436
- * Overwrites the internal syntax tree by fully re-parsing the supplied tomlString.
437
- * This is simpler but slower than update() which uses incremental parsing.
438
- * @param tomlString - The TOML string to overwrite with
439
- */
440
- overwrite(tomlString: string): void;
441
- }
442
- /**
443
- * Applies modifications to a TOML document by comparing an existing TOML string with updated JavaScript data.
444
- *
445
- * This function preserves formatting and comments from the existing TOML document while
446
- * applying changes from the updated data structure. It performs a diff between the existing
447
- * and updated data, then strategically applies only the necessary changes to maintain the
448
- * original document structure as much as possible.
449
- *
450
- * @param existing - The original TOML document as a string
451
- * @param updated - The updated JavaScript object with desired changes
452
- * @param format - Optional formatting options to apply to new or modified sections
453
- * @returns A new TOML string with the changes applied
454
- */
455
- declare function patch(existing: string, updated: any, format?: Partial<TomlFormat> | TomlFormat): string;
456
- /**
457
- * Custom Date class for local dates (date-only).
458
- * Format: 1979-05-27
459
- */
460
- export declare class LocalDate extends Date {
461
- constructor(value: string);
462
- toISOString(): string;
463
- }
464
- /**
465
- * Custom Date class for local times (time-only)
466
- * Format: 07:32:00 or 07:32:00.999
467
- */
468
- export declare class LocalTime extends Date {
469
- originalFormat: string;
470
- constructor(value: string, originalFormat?: string);
471
- toISOString(): string;
472
- }
473
- /**
474
- * Custom Date class for local datetime (no timezone)
475
- * Format: 1979-05-27T07:32:00 or 1979-05-27 07:32:00
476
- */
477
- export declare class LocalDateTime extends Date {
478
- useSpaceSeparator: boolean;
479
- originalFormat: string;
480
- constructor(value: string, useSpaceSeparator?: boolean, originalFormat?: string);
481
- toISOString(): string;
482
- }
483
- /**
484
- * Custom Date class for offset datetime that preserves space separator
485
- * Format: 1979-05-27T07:32:00Z or 1979-05-27 07:32:00-07:00
486
- */
487
- export declare class OffsetDateTime extends Date {
488
- useSpaceSeparator: boolean;
489
- originalOffset?: string;
490
- originalFormat: string;
491
- constructor(value: string, useSpaceSeparator?: boolean);
492
- toISOString(): string;
493
- }
494
- /**
495
- * Parses a TOML string or raw UTF-8 bytes into a JavaScript object.
496
- *
497
- * When raw bytes (Uint8Array / Buffer) are provided, they are decoded with
498
- * the WHATWG TextDecoder in fatal mode, which rejects any invalid UTF-8
499
- * byte sequences before parsing begins. This matches the TOML spec requirement
500
- * that "A TOML file must be a valid UTF-8 encoded Unicode document."
501
- *
502
- * The string path has zero overhead — the bytes path incurs one TextDecoder
503
- * decode (which also produces the string needed for parsing).
504
- *
505
- * By default (`options.integersAsBigInt` unset or `'asNeeded'`), integers that
506
- * fit within the JavaScript safe-integer range are returned as `number`; integers
507
- * outside that range are returned as `bigint` to preserve precision. Set
508
- * `options.integersAsBigInt` to `true` to always return `bigint` for all integers,
509
- * or `false` to always return `number` (large integers will lose precision).
510
- *
511
- * Note: the `'asNeeded'` default is a behavioral change from prior versions (<=1.0.7). If
512
- * your code serializes the result to JSON or performs arithmetic mixing `number`
513
- * and `bigint`, set `integersAsBigInt: false` to restore the previous behavior.
514
- *
515
- * By default (`options.temporal` unset or `false`), TOML date/time values are
516
- * returned as custom Date subclasses (LocalDate, LocalTime, LocalDateTime,
517
- * OffsetDateTime). Set `options.temporal` to `true` to return Temporal API
518
- * objects instead (Temporal.PlainDate, Temporal.PlainTime, Temporal.PlainDateTime,
519
- * Temporal.ZonedDateTime). The Temporal API must be available in the runtime.
520
- *
521
- * @param value - TOML source as a string or raw UTF-8 bytes
522
- * @param options - Optional parse options
523
- * @param options.integersAsBigInt - Controls `bigint` vs `number` for integers.
524
- * `'asNeeded'` (default) | `true` | `false`
525
- * @param options.temporal - When true, returns Temporal objects for date/time values.
526
- * Default: false.
527
- * @returns The parsed JavaScript object
528
- */
529
- export declare function parse(value: string | Uint8Array, options?: ParseOptions): any;
530
- /**
531
- * Converts a JavaScript object to a TOML string.
532
- *
533
- * @param value - The JavaScript object to stringify
534
- * @param format - Optional formatting options for the resulting TOML
535
- * @returns The stringified TOML representation
536
- */
537
- export declare function stringify(value: any, format?: Partial<TomlFormat> | TomlFormat): string;
538
- /**
539
- * Parses a TOML string or raw UTF-8 bytes into a {@link TomlDocument}.
540
- *
541
- * This is a convenience alternative to `new TomlDocument(value, options)`.
542
- *
543
- * @param value - TOML source as a string or raw UTF-8 bytes
544
- * @param options - Optional parse options
545
- * @returns A {@link TomlDocument} representing the parsed TOML
546
- */
547
- export declare function parseDocument(value: string | Uint8Array, options?: ParseOptions): TomlDocument;
548
- export { type IntegersAsBigInt, type MultilineContainerMode, type ParseOptions, patch };
File without changes