@jackens/nnn 2026.4.13 → 2026.4.15

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 (4) hide show
  1. package/nnn.d.ts +213 -104
  2. package/nnn.js +17 -17
  3. package/package.json +1 -1
  4. package/readme.md +670 -347
package/nnn.d.ts CHANGED
@@ -1,25 +1,32 @@
1
1
  /**
2
- * Represents a CSS rule node for the {@link c} helper. Keys are CSS properties or nested selectors.
2
+ * Represents a CSS rule node for the {@link c} helper.
3
+ * Keys are CSS properties or nested selectors.
3
4
  */
4
5
  export type CNode = {
5
6
  [attributeOrSelector: string]: string | number | CNode | undefined;
6
7
  };
7
8
  /**
8
- * Represents the root CSS object for the {@link c} helper. Keys are top-level selectors or at-rules.
9
+ * Represents the root CSS object for the {@link c} helper.
10
+ * Keys are top-level selectors or at-rules.
9
11
  */
10
12
  export type CRoot = Record<PropertyKey, CNode>;
11
13
  /**
12
- * A minimal CSS-in-JS helper that converts a JavaScript object hierarchy into a CSS string.
14
+ * A minimal CSS-in-JS helper
15
+ * that converts a JavaScript object hierarchy
16
+ * into a CSS string.
13
17
  *
14
18
  * @param root
15
19
  *
16
20
  * An object describing CSS rules.
17
- * Keys are selectors or at-rules; values are either CSS property values or nested rule objects.
21
+ * Keys are selectors or at-rules;
22
+ * values are either CSS property values
23
+ * or nested rule objects.
18
24
  *
19
25
  * @param splitter
20
26
  *
21
27
  * A delimiter used to create unique keys (default: `'$$'`).
22
- * The substring from `splitter` to the end of a key is ignored (e.g., `src$$1` → `src`).
28
+ * The substring from `splitter` to the end of a key
29
+ * is ignored (e.g., `src$$1` → `src`).
23
30
  *
24
31
  * @returns
25
32
  *
@@ -27,18 +34,27 @@ export type CRoot = Record<PropertyKey, CNode>;
27
34
  *
28
35
  * @remarks
29
36
  *
30
- * - Keys whose values are primitives (`string` | `number`) are treated as CSS properties.
31
- * - In property keys, uppercase letters become lowercase with a `-` prefix (e.g., `fontFamily` → `font-family`);
32
- * underscores become hyphens (e.g., `font_family` `font-family`).
33
- * - Comma-separated selector keys expand into multiple selectors
34
- * (e.g., `{ div: { '.a,.b': { margin: 1 } } }` → `div.a,div.b{margin:1}`).
35
- * - Top-level keys starting with `@` (at-rules) are not concatenated with child selectors.
37
+ * - Keys whose values are primitives (`string` | `number`)
38
+ * are treated as CSS properties.
39
+ * - In property keys, uppercase letters
40
+ * become lowercase with a `-` prefix
41
+ * (e.g., `fontFamily` → `font-family`);
42
+ * underscores become hyphens
43
+ * (e.g., `font_family` → `font-family`).
44
+ * - Comma-separated selector keys
45
+ * expand into multiple selectors
46
+ * (e.g., `{ div: { '.a,.b': { margin: 1 } } }` →
47
+ * `div.a,div.b{margin:1}`).
48
+ * - Top-level keys starting with `@` (at-rules)
49
+ * are not concatenated with child selectors.
36
50
  */
37
51
  export declare const c: (root: CRoot, splitter?: string) => string;
38
52
  /**
39
- * Parses a CSV string into a two-dimensional array of strings.
53
+ * Parses a CSV string
54
+ * into a two-dimensional array of strings.
40
55
  *
41
- * Supports quoted fields with escaped double quotes (`""`). Carriage returns are normalized.
56
+ * Supports quoted fields with escaped double quotes (`""`).
57
+ * Carriage returns are normalized.
42
58
  *
43
59
  * @param csv
44
60
  *
@@ -50,46 +66,63 @@ export declare const c: (root: CRoot, splitter?: string) => string;
50
66
  *
51
67
  * @returns
52
68
  *
53
- * A 2D array where each inner array represents a row of fields.
69
+ * A 2D array where each inner array
70
+ * represents a row of fields.
54
71
  */
55
72
  export declare const csvParse: (csv: string, separator?: string) => string[][];
56
73
  /**
57
- * Applies Polish-specific typographic corrections to a DOM subtree.
74
+ * Applies Polish-specific typographic corrections
75
+ * to a DOM subtree.
58
76
  *
59
- * This function prevents orphaned conjunctions (single-letter words like “a”, “i”, “o”, “u”, “w”, “z”)
60
- * from appearing at the end of a line by wrapping them with the following word in a non-breaking span.
61
- * It also inserts zero-width spaces after slashes and dots to allow line breaks.
77
+ * This function prevents orphaned conjunctions
78
+ * (single-letter words like a”, “i”, “o”, “u”, “w”, “z”)
79
+ * from appearing at the end of a line
80
+ * by wrapping them with the following word
81
+ * in a non-breaking span.
82
+ * It also inserts zero-width spaces
83
+ * after slashes and dots to allow line breaks.
62
84
  *
63
85
  * @param node
64
86
  *
65
- * The root DOM node to process. All descendant text nodes are corrected recursively,
66
- * except those inside `IFRAME`, `NOSCRIPT`, `PRE`, `SCRIPT`, `STYLE`, or `TEXTAREA` elements.
87
+ * The root DOM node to process.
88
+ * All descendant text nodes are corrected recursively,
89
+ * except those inside `IFRAME`, `NOSCRIPT`, `PRE`,
90
+ * `SCRIPT`, `STYLE`, or `TEXTAREA` elements.
67
91
  */
68
92
  export declare const fixPlTypography: (node: Node) => void;
69
93
  /**
70
- * Single argument type for the {@link h} and {@link s} helpers.
94
+ * Single argument type for the {@link h} and {@link s}
95
+ * helpers.
71
96
  */
72
97
  export type HArgs1 = Record<PropertyKey, unknown> | null | undefined | Node | string | number | HArgs;
73
98
  /**
74
- * Tuple argument type for the {@link h} and {@link s} helpers.
99
+ * Tuple argument type for the {@link h} and {@link s}
100
+ * helpers.
75
101
  */
76
102
  export type HArgs = [string | Node, ...HArgs1[]];
77
103
  /**
78
- * A lightweight [HyperScript](https://github.com/hyperhype/hyperscript)-style helper for creating and modifying `HTMLElement`s (see also {@link s}).
104
+ * A lightweight *HyperScript*-style helper
105
+ * for creating and modifying `HTMLElement`s
106
+ * (see also {@link s}).
79
107
  *
80
108
  * @param tagOrNode
81
109
  *
82
- * If a `string`, it is treated as the tag name for a new element.
110
+ * If a `string`, it is treated as the tag name
111
+ * for a new element.
83
112
  * If a `Node`, that node is modified in place.
84
113
  *
85
114
  * @param args
86
115
  *
87
116
  * Additional arguments processed as follows:
88
- * - `Object`: maps attributes/properties. Keys starting with `$` set element properties (without the `$` prefix);
89
- * other keys set attributes via `setAttribute`. A value of `false` removes the attribute.
117
+ * - `Object`: maps attributes/properties.
118
+ * Keys starting with `$` set element properties
119
+ * (without the `$` prefix);
120
+ * other keys set attributes via `setAttribute`.
121
+ * A value of `false` removes the attribute.
90
122
  * - `null`/`undefined`: ignored.
91
123
  * - `Node`: appended as a child.
92
- * - `string`/`number`: converted to a `Text` node and appended.
124
+ * - `string`/`number`: converted to a `Text` node
125
+ * and appended.
93
126
  * - {@link HArgs} array: processed recursively.
94
127
  *
95
128
  * @returns
@@ -102,21 +135,28 @@ export declare const h: {
102
135
  (tagOrNode: string | Node, ...args1: HArgs1[]): Node;
103
136
  };
104
137
  /**
105
- * A lightweight [HyperScript](https://github.com/hyperhype/hyperscript)-style helper for creating and modifying `SVGElement`s (see also {@link h}).
138
+ * A lightweight *HyperScript*-style helper
139
+ * for creating and modifying `SVGElement`s
140
+ * (see also {@link h}).
106
141
  *
107
142
  * @param tagOrNode
108
143
  *
109
- * If a `string`, it is treated as the tag name for a new element.
144
+ * If a `string`, it is treated as the tag name
145
+ * for a new element.
110
146
  * If a `Node`, that node is modified in place.
111
147
  *
112
148
  * @param args
113
149
  *
114
150
  * Additional arguments processed as follows:
115
- * - `Object`: maps attributes/properties. Keys starting with `$` set element properties (without the `$` prefix);
116
- * other keys set attributes via `setAttributeNS`. A value of `false` removes the attribute.
151
+ * - `Object`: maps attributes/properties.
152
+ * Keys starting with `$` set element properties
153
+ * (without the `$` prefix);
154
+ * other keys set attributes via `setAttributeNS`.
155
+ * A value of `false` removes the attribute.
117
156
  * - `null`/`undefined`: ignored.
118
157
  * - `Node`: appended as a child.
119
- * - `string`/`number`: converted to a `Text` node and appended.
158
+ * - `string`/`number`: converted to a `Text` node
159
+ * and appended.
120
160
  * - {@link HArgs} array: processed recursively.
121
161
  *
122
162
  * @returns
@@ -129,13 +169,16 @@ export declare const s: {
129
169
  (tagOrNode: string | Node, ...args1: HArgs1[]): Node;
130
170
  };
131
171
  /**
132
- * Shorthand for creating an SVG element with a `<use>` child referencing an icon by ID.
172
+ * Shorthand for creating an SVG element
173
+ * with a `<use>` child referencing an icon by ID.
133
174
  *
134
- * Equivalent to: `s('svg', ['use', { 'xlink:href': '#' + id }], ...args)`.
175
+ * Equivalent to:
176
+ * `s('svg', ['use', { 'xlink:href': '#' + id }], ...args)`.
135
177
  *
136
178
  * @param id
137
179
  *
138
- * The ID of the symbol to reference (without the `#` prefix).
180
+ * The ID of the symbol to reference
181
+ * (without the `#` prefix).
139
182
  *
140
183
  * @param args
141
184
  *
@@ -147,7 +190,8 @@ export declare const s: {
147
190
  */
148
191
  export declare const svgUse: (id: string, ...args: HArgs1[]) => SVGSVGElement;
149
192
  /**
150
- * Checks whether an object has the specified key as its own property.
193
+ * Checks whether an object has the specified key
194
+ * as its own property.
151
195
  *
152
196
  * A null-safe wrapper around `Object.hasOwn`.
153
197
  *
@@ -161,7 +205,8 @@ export declare const svgUse: (id: string, ...args: HArgs1[]) => SVGSVGElement;
161
205
  *
162
206
  * @returns
163
207
  *
164
- * `true` if `ref` is not nullish and has `key` as an own property, `false` otherwise.
208
+ * `true` if `ref` is not nullish
209
+ * and has `key` as an own property, `false` otherwise.
165
210
  */
166
211
  export declare const hasOwn: (ref: unknown, key: unknown) => boolean;
167
212
  /**
@@ -177,7 +222,8 @@ export declare const hasOwn: (ref: unknown, key: unknown) => boolean;
177
222
  */
178
223
  export declare const isArray: (arg: unknown) => arg is unknown[];
179
224
  /**
180
- * Checks whether the argument is a finite number (excludes `±Infinity` and `NaN`).
225
+ * Checks whether the argument is of type `number`
226
+ * (includes `NaN` and `±Infinity`).
181
227
  *
182
228
  * @param arg
183
229
  *
@@ -185,11 +231,12 @@ export declare const isArray: (arg: unknown) => arg is unknown[];
185
231
  *
186
232
  * @returns
187
233
  *
188
- * `true` if `arg` is a finite number, `false` otherwise.
234
+ * `true` if `typeof arg === 'number'`, `false` otherwise.
189
235
  */
190
- export declare const isFiniteNumber: (arg: unknown) => arg is number;
236
+ export declare const isNumber: (arg: unknown) => arg is number;
191
237
  /**
192
- * Checks whether the argument is an integer number.
238
+ * Checks whether the argument is a finite number
239
+ * (excludes `±Infinity` and `NaN`).
193
240
  *
194
241
  * @param arg
195
242
  *
@@ -197,11 +244,11 @@ export declare const isFiniteNumber: (arg: unknown) => arg is number;
197
244
  *
198
245
  * @returns
199
246
  *
200
- * `true` if `arg` is an integer number, `false` otherwise.
247
+ * `true` if `arg` is a finite number, `false` otherwise.
201
248
  */
202
- export declare const isInteger: (arg: unknown) => arg is number;
249
+ export declare const isFiniteNumber: (arg: unknown) => arg is number;
203
250
  /**
204
- * Checks whether the argument is of type `number` (includes `NaN` and `±Infinity`).
251
+ * Checks whether the argument is an integer number.
205
252
  *
206
253
  * @param arg
207
254
  *
@@ -209,11 +256,11 @@ export declare const isInteger: (arg: unknown) => arg is number;
209
256
  *
210
257
  * @returns
211
258
  *
212
- * `true` if `typeof arg === 'number'`, `false` otherwise.
259
+ * `true` if `arg` is an integer number, `false` otherwise.
213
260
  */
214
- export declare const isNumber: (arg: unknown) => arg is number;
261
+ export declare const isInteger: (arg: unknown) => arg is number;
215
262
  /**
216
- * Checks whether the argument is a plain object (not `null` and not an array).
263
+ * Checks whether the argument is a string.
217
264
  *
218
265
  * @param arg
219
266
  *
@@ -221,11 +268,12 @@ export declare const isNumber: (arg: unknown) => arg is number;
221
268
  *
222
269
  * @returns
223
270
  *
224
- * `true` if `arg` is a plain object, `false` otherwise.
271
+ * `true` if `typeof arg === 'string'`, `false` otherwise.
225
272
  */
226
- export declare const isRecord: (arg: unknown) => arg is Record<PropertyKey, unknown>;
273
+ export declare const isString: (arg: unknown) => arg is string;
227
274
  /**
228
- * Checks whether the argument is a string.
275
+ * Checks whether the argument is a plain object
276
+ * (not `null` and not an array).
229
277
  *
230
278
  * @param arg
231
279
  *
@@ -233,14 +281,18 @@ export declare const isRecord: (arg: unknown) => arg is Record<PropertyKey, unkn
233
281
  *
234
282
  * @returns
235
283
  *
236
- * `true` if `typeof arg === 'string'`, `false` otherwise.
284
+ * `true` if `arg` is a plain object, `false` otherwise.
237
285
  */
238
- export declare const isString: (arg: unknown) => arg is string;
286
+ export declare const isRecord: (arg: unknown) => arg is Record<PropertyKey, unknown>;
239
287
  /**
240
- * Parses JSON with support for handler-based value transformation (“JavaScript ON”).
288
+ * Parses JSON with support for
289
+ * handler-based value transformation (“JavaScript ON”).
241
290
  *
242
- * Objects with exactly one property whose key exists in `handlers` and whose value is an array
243
- * are replaced by invoking the corresponding handler with the array elements as arguments.
291
+ * Objects with exactly one property
292
+ * whose key exists in `handlers`
293
+ * and whose value is an array
294
+ * are replaced by invoking the corresponding handler
295
+ * with the array elements as arguments.
244
296
  *
245
297
  * @param handlers
246
298
  *
@@ -256,11 +308,14 @@ export declare const isString: (arg: unknown) => arg is string;
256
308
  */
257
309
  export declare const jsOnParse: (handlers: Record<PropertyKey, Function>, text: string) => any;
258
310
  /**
259
- * A Monokai-inspired color scheme for use with the {@link c} helper and {@link nanolightTs} tokenizer.
311
+ * A Monokai-inspired color scheme
312
+ * for use with the {@link c} helper
313
+ * and {@link nanolightTs} tokenizer.
260
314
  */
261
315
  export declare const monokai: CRoot;
262
316
  /**
263
- * A TypeScript/JavaScript syntax highlighting tokenizer built using {@link newTokenizer}.
317
+ * A TypeScript/JavaScript syntax highlighting tokenizer
318
+ * built using {@link newTokenizer}.
264
319
  *
265
320
  * @param code
266
321
  *
@@ -268,30 +323,40 @@ export declare const monokai: CRoot;
268
323
  *
269
324
  * @returns
270
325
  *
271
- * An array of {@link HArgs1} elements suitable for rendering with {@link h}.
326
+ * An array of {@link HArgs1} elements
327
+ * suitable for rendering with {@link h}.
272
328
  */
273
329
  export declare const nanolightTs: (code: string) => HArgs1[];
274
330
  /**
275
- * Creates a tag function for escaping interpolated values in template literals.
331
+ * Creates a tag function
332
+ * for escaping interpolated values in template literals.
276
333
  *
277
334
  * @param escapeFn
278
335
  *
279
- * A function that takes a value and returns its escaped string representation.
336
+ * A function that takes a value
337
+ * and returns its escaped string representation.
280
338
  *
281
339
  * @returns
282
340
  *
283
- * A tag function that escapes interpolated values using the provided escape map.
341
+ * A tag function that escapes interpolated values
342
+ * using the provided escape map.
284
343
  */
285
344
  export declare const newEscape: (escapeFn: (value: any) => string) => (template: TemplateStringsArray, ...values: unknown[]) => string;
286
345
  /**
287
- * Creates a function that returns the appropriate noun form based on a numeric value using `Intl.PluralRules`.
346
+ * Creates a function that
347
+ * returns the appropriate noun form
348
+ * based on a numeric value using `Intl.PluralRules`.
288
349
  *
289
- * Different languages have different plural rules. The `Intl.PluralRules` API provides locale-aware plural category selection.
350
+ * Different languages have different plural rules.
351
+ * The `Intl.PluralRules` API provides locale-aware
352
+ * plural category selection.
290
353
  * Possible categories are:
291
354
  *
292
- * - `zero`: for zero items (used in some languages like Arabic, Latvian)
355
+ * - `zero`: for zero items
356
+ * (used in some languages like Arabic, Latvian)
293
357
  * - `one`: for singular (e.g., 1 item)
294
- * - `two`: for dual (used in some languages like Arabic, Hebrew)
358
+ * - `two`: for dual
359
+ * (used in some languages like Arabic, Hebrew)
295
360
  * - `few`: for small plurals (e.g., 2-4 in Polish)
296
361
  * - `many`: for larger plurals (e.g., 5-21 in Polish)
297
362
  * - `other`: fallback category (used by all languages)
@@ -302,44 +367,61 @@ export declare const newEscape: (escapeFn: (value: any) => string) => (template:
302
367
  *
303
368
  * @param forms
304
369
  *
305
- * An object mapping plural categories to noun forms. Not all categories need to be provided;
306
- * if a category is missing, the function falls back to `other`, then to an empty string.
370
+ * An object mapping plural categories to noun forms.
371
+ * Not all categories need to be provided;
372
+ * if a category is missing,
373
+ * the function falls back to `other`,
374
+ * then to an empty string.
307
375
  *
308
376
  * @returns
309
377
  *
310
- * A function that takes a numeric value and returns the appropriate noun form.
378
+ * A function that takes a numeric value
379
+ * and returns the appropriate noun form.
311
380
  */
312
381
  export declare const newNounForm: (locale: string, forms: Partial<Record<Intl.LDMLPluralRule, string>>) => (value: number) => string;
313
382
  /**
314
- * A helper for building simple tokenizers (see also {@link nanolightTs}).
383
+ * A helper for building simple tokenizers
384
+ * (see also {@link nanolightTs}).
315
385
  *
316
386
  * @param decorator
317
387
  *
318
- * A function that wraps each matched chunk. It receives the matched text (`chunk`)
319
- * and optionally the `metadata` associated with the pattern that produced the match.
320
- * For unmatched text between patterns, `metadata` is `undefined`.
388
+ * A function that wraps each matched chunk.
389
+ * It receives the matched text (`chunk`)
390
+ * and optionally the `metadata`
391
+ * associated with the pattern that produced the match.
392
+ * For unmatched text between patterns,
393
+ * `metadata` is `undefined`.
321
394
  *
322
395
  * @param specs
323
396
  *
324
397
  * An array of tuples `[metadata, pattern]` where:
325
- * - `metadata`: arbitrary data (e.g., a CSS class name) passed to `decorator` when the pattern matches.
326
- * - `pattern`: a `string` or `RegExp` to match against the input.
398
+ * - `metadata`: arbitrary data (e.g., a CSS class name)
399
+ * passed to `decorator` when the pattern matches.
400
+ * - `pattern`: a `string` or `RegExp`
401
+ * to match against the input.
327
402
  *
328
403
  * @returns
329
404
  *
330
- * A tokenizer function that accepts a code string and returns an array of decorated tokens.
405
+ * A tokenizer function that accepts a code string
406
+ * and returns an array of decorated tokens.
331
407
  *
332
408
  * @remarks
333
409
  *
334
- * 1. Matches starting at an earlier position take precedence.
335
- * 2. Among matches at the same position, the longer one wins.
336
- * 3. Among matches of the same position and length, the one defined earlier wins.
410
+ * 1. Matches starting at an earlier position
411
+ * take precedence.
412
+ * 2. Among matches at the same position,
413
+ * the longer one wins.
414
+ * 3. Among matches of the same position and length,
415
+ * the one defined earlier wins.
337
416
  */
338
417
  export declare const newTokenizer: <M, T>(decorator: (chunk: string, metadata?: M) => T, ...specs: [M, string | RegExp][]) => (code: string) => T[];
339
418
  /**
340
- * Creates a new object excluding the specified keys from the source object.
419
+ * Creates a new object excluding the specified keys
420
+ * from the source object.
341
421
  *
342
- * A runtime equivalent of TypeScript’s `Omit<T, K>` utility type. See also {@link pick}.
422
+ * A runtime equivalent
423
+ * of TypeScript’s `Omit<T, K>` utility type.
424
+ * See also {@link pick}.
343
425
  *
344
426
  * @param ref
345
427
  *
@@ -355,9 +437,12 @@ export declare const newTokenizer: <M, T>(decorator: (chunk: string, metadata?:
355
437
  */
356
438
  export declare const omit: <T, K extends keyof T>(ref: T, keys: unknown[]) => Omit<T, K>;
357
439
  /**
358
- * Creates a new object containing only the specified keys from the source object.
440
+ * Creates a new object containing only the specified keys
441
+ * from the source object.
359
442
  *
360
- * A runtime equivalent of TypeScript’s `Pick<T, K>` utility type. See also {@link omit}.
443
+ * A runtime equivalent
444
+ * of TypeScript’s `Pick<T, K>` utility type.
445
+ * See also {@link omit}.
361
446
  *
362
447
  * @param ref
363
448
  *
@@ -371,9 +456,10 @@ export declare const omit: <T, K extends keyof T>(ref: T, keys: unknown[]) => Om
371
456
  *
372
457
  * A new object with only the specified keys.
373
458
  */
374
- export declare const pick: <T, K extends keyof T>(ref: T, keys: K[]) => Pick<T, K>;
459
+ export declare const pick: <T, K extends keyof T>(ref: T, keys: unknown[]) => Pick<T, K>;
375
460
  /**
376
- * A responsive web design helper that generates CSS rules for a grid-like layout.
461
+ * A responsive web design helper
462
+ * that generates CSS rules for a grid-like layout.
377
463
  *
378
464
  * @param root
379
465
  *
@@ -394,9 +480,12 @@ export declare const pick: <T, K extends keyof T>(ref: T, keys: K[]) => Pick<T,
394
480
  * @param specs
395
481
  *
396
482
  * An array of breakpoint specifications, each a tuple of:
397
- * - `maxWidth`: maximum number of cells per row (defines the viewport breakpoint).
398
- * - `width` (optional, default `1`): number of horizontal cells the element spans.
399
- * - `height` (optional, default `1`): number of vertical cells the element spans.
483
+ * - `maxWidth`: maximum number of cells per row
484
+ * (defines the viewport breakpoint).
485
+ * - `width` (optional, default `1`):
486
+ * number of horizontal cells the element spans.
487
+ * - `height` (optional, default `1`):
488
+ * number of vertical cells the element spans.
400
489
  */
401
490
  export declare const rwd: (root: CRoot, selector: string, cellWidthPx: number, cellHeightPx: number, ...specs: [number, number?, number?][]) => void;
402
491
  /**
@@ -404,35 +493,54 @@ export declare const rwd: (root: CRoot, selector: string, cellWidthPx: number, c
404
493
  *
405
494
  * @param date
406
495
  *
407
- * The date to use for the timestamp portion (default: current date/time).
496
+ * The date to use for the timestamp portion
497
+ * (default: current date/time).
408
498
  *
409
499
  * @param node
410
500
  *
411
- * A hexadecimal `string` for the node portion (default: random).
412
- * Must match `/^[0-9a-f]*$/`; it is trimmed to the last 12 characters and left-padded with zeros if shorter.
501
+ * A hexadecimal `string` for the node portion
502
+ * (default: random).
503
+ * Must match `/^[0-9a-f]*$/`;
504
+ * it is trimmed to the last 12 characters
505
+ * and left-padded with zeros if shorter.
413
506
  *
414
507
  * @returns
415
508
  *
416
- * A UUID v1 `string` in the standard format `xxxxxxxx-xxxx-1xxx-xxxx-xxxxxxxxxxxx`.
509
+ * A UUID v1 `string` in the standard format
510
+ * `xxxxxxxx-xxxx-1xxx-xxxx-xxxxxxxxxxxx`.
417
511
  */
418
512
  export declare const uuidV1: (date?: Date, node?: string) => string;
419
513
  /**
420
- * A Proxy-based helper for auto-vivification of nested object structures.
421
- *
422
- * Accessing, assigning, or deleting any nested property on the returned proxy automatically creates intermediate objects
423
- * (or arrays for numeric-string keys matching `^(0|[1-9]\d*)$`) as needed, allowing deep operations without explicit null checks.
424
- *
425
- * Intermediates of the last level in a get-only property chain are NOT auto-created.
426
- * For example, `vivify(ref).one.two` will create `ref.one` as `{}`, but will NOT create `ref.one.two`.
514
+ * A Proxy-based helper for auto-vivification
515
+ * of nested object structures.
516
+ *
517
+ * Accessing, assigning, or deleting any nested property
518
+ * on the returned proxy
519
+ * automatically creates intermediate objects
520
+ * (or arrays for numeric-string keys matching
521
+ * `^(0|[1-9]\d*)$`) as needed,
522
+ * allowing deep operations without explicit null checks.
523
+ *
524
+ * Intermediates of the last level
525
+ * in a get-only property chain are NOT auto-created.
526
+ * For example, `vivify(ref).one.two` will create
527
+ * `ref.one` as `{}`, but will NOT create `ref.one.two`.
427
528
  * Only when a deeper access, assignment, or deletion occurs
428
- * (e.g. `delete vivify(ref).one.two.three` or `vivify(ref).one.two.three = 4`) will `ref.one.two` be materialized.
529
+ * (e.g. `delete vivify(ref).one.two.three`
530
+ * or `vivify(ref).one.two.three = 4`)
531
+ * will `ref.one.two` be materialized.
429
532
  *
430
- * When traversal reaches a primitive value, no auto-creation happens;
533
+ * When traversal reaches a primitive value,
534
+ * no auto-creation happens;
431
535
  * the primitive’s own property is returned instead
432
- * (e.g. accessing `.toString.name` on a number yields `'toString'` without modifying the underlying structure).
536
+ * (e.g. accessing `.toString.name` on a number yields
537
+ * `'toString'` without modifying the underlying structure).
433
538
  *
434
- * Deletion on a non-existing intermediate path will auto-create intermediates up to the parent of the deleted key
435
- * (e.g. `delete vivify(ref).one.two.three` will create `ref.one.two` as `{}` if it does not exist).
539
+ * Deletion on a non-existing intermediate path
540
+ * will auto-create intermediates up to the parent
541
+ * of the deleted key
542
+ * (e.g. `delete vivify(ref).one.two.three`
543
+ * will create `ref.one.two` as `{}` if it does not exist).
436
544
  *
437
545
  * @param ref
438
546
  *
@@ -440,6 +548,7 @@ export declare const uuidV1: (date?: Date, node?: string) => string;
440
548
  *
441
549
  * @returns
442
550
  *
443
- * A proxy that auto-creates nested objects/arrays on property access.
551
+ * A proxy that auto-creates nested objects/arrays
552
+ * on property access.
444
553
  */
445
554
  export declare const vivify: (ref: unknown) => any;
package/nnn.js CHANGED
@@ -1,11 +1,9 @@
1
- // src/nnn/isArray.ts
1
+ // src/nnn/is.ts
2
2
  var isArray = Array.isArray;
3
-
4
- // src/nnn/isNumber.ts
5
3
  var isNumber = (arg) => typeof arg === "number";
6
-
7
- // src/nnn/isString.ts
4
+ var isFiniteNumber = Number.isFinite;
8
5
  var isString = (arg) => typeof arg === "string";
6
+ var isRecord = (arg) => typeof arg === "object" && arg != null && !isArray(arg);
9
7
 
10
8
  // src/nnn/c.ts
11
9
  var _c = (node, prefix, result, splitter) => {
@@ -62,9 +60,6 @@ var csvParse = (csv, separator = ",") => {
62
60
  const linePattern = new RegExp(`${separator}|(?<!")\\s*"((?:[^"]|"")*)"\\s*(?!")`, "g");
63
61
  return csv.replace(/\r/g, "").replace(/\n+$/, "").replace(MAIN_PATTERN, (_, chunk) => chunk ?? "\r").split("\r").map((line) => line.replace(linePattern, (_, chunk) => chunk == null ? "\r" : chunk.replace(/""/g, '"')).split("\r"));
64
62
  };
65
- // src/nnn/isRecord.ts
66
- var isRecord = (arg) => typeof arg === "object" && arg != null && !isArray(arg);
67
-
68
63
  // src/nnn/h.ts
69
64
  var XLINK_NS = "http://www.w3.org/1999/xlink";
70
65
  var _h = (createElement, tagOrNode, ...args) => {
@@ -81,8 +76,7 @@ var _h = (createElement, tagOrNode, ...args) => {
81
76
  if (name[0] === "$") {
82
77
  const name1 = name.slice(1);
83
78
  if (isRecord(value)) {
84
- node[name1] ??= {};
85
- Object.assign(node[name1], value);
79
+ Object.assign(node[name1] ??= {}, value);
86
80
  } else {
87
81
  node[name1] = value;
88
82
  }
@@ -120,12 +114,19 @@ var _h = (createElement, tagOrNode, ...args) => {
120
114
  });
121
115
  return node;
122
116
  };
123
- var h = _h.bind(null, document.createElement);
124
- var s = _h.bind(null, document.createElementNS.bind(document, "http://www.w3.org/2000/svg"));
117
+ var h = _h.bind(null, (tag) => document.createElement(tag));
118
+ var s = _h.bind(null, (tag) => document.createElementNS("http://www.w3.org/2000/svg", tag));
125
119
  var svgUse = (id, ...args) => s("svg", ["use", { "xlink:href": "#" + id }], ...args);
126
120
 
127
121
  // src/nnn/fixPlTypography.ts
128
- var TAGS_TO_SKIP = ["IFRAME", "NOSCRIPT", "PRE", "SCRIPT", "STYLE", "TEXTAREA"];
122
+ var TAGS_TO_SKIP = [
123
+ "IFRAME",
124
+ "NOSCRIPT",
125
+ "PRE",
126
+ "SCRIPT",
127
+ "STYLE",
128
+ "TEXTAREA"
129
+ ];
129
130
  var fixPlTypography = (node) => {
130
131
  const queue = [node];
131
132
  while (queue.length > 0) {
@@ -144,7 +145,7 @@ var fixPlTypography = (node) => {
144
145
  let previousNode = node0;
145
146
  nodeValue.split(/(\s|\(|„)([aiouwz—]\s)/gi).forEach((chunk, i) => {
146
147
  i %= 3;
147
- const currentNode = i === 2 ? h("span", { style: "white-space:nowrap" }, chunk) : i === 1 ? document.createTextNode(chunk) : document.createTextNode(chunk.replace(/(\/(?=[^/\s])|\.(?=[^\s]))/g, "$1​"));
148
+ const currentNode = i === 2 ? h("span", { style: "white-space:nowrap" }, chunk) : document.createTextNode(i === 1 ? chunk : chunk.replace(/(\/(?=[^/\s])|\.(?=[^\s]))/g, "$1​"));
148
149
  if (node0.parentNode != null) {
149
150
  node0.parentNode.insertBefore(currentNode, previousNode.nextSibling);
150
151
  }
@@ -157,8 +158,6 @@ var fixPlTypography = (node) => {
157
158
  };
158
159
  // src/nnn/hasOwn.ts
159
160
  var hasOwn = (ref, key) => ref != null && Object.hasOwn(ref, key);
160
- // src/nnn/isFiniteNumber.ts
161
- var isFiniteNumber = Number.isFinite;
162
161
  // src/nnn/jsOnParse.ts
163
162
  var jsOnParse = (handlers, text) => JSON.parse(text, (key, value) => {
164
163
  if (isRecord(value)) {
@@ -178,6 +177,7 @@ var jsOnParse = (handlers, text) => JSON.parse(text, (key, value) => {
178
177
  return value;
179
178
  });
180
179
  // src/nnn/monokai.ts
180
+ var darkKey = "@media only screen and (prefers-color-scheme: dark)" + "$$monokai";
181
181
  var monokai = {
182
182
  ":root$$monokai": {
183
183
  __bg: "#faf4f2",
@@ -222,7 +222,7 @@ var monokai = {
222
222
  punctuation: { color: "var(--punctuation)" },
223
223
  string: { color: "var(--string)" }
224
224
  },
225
- "@media only screen and (prefers-color-scheme: dark)$$monokai": {
225
+ [darkKey]: {
226
226
  ":root": {
227
227
  __bg: "#2d2a2e",
228
228
  __fg: "#fcfcfa",