@jackens/nnn 2025.6.20 → 2025.9.4

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 +65 -54
  2. package/nnn.js +5 -12
  3. package/package.json +2 -1
  4. package/readme.md +95 -107
package/nnn.d.ts CHANGED
@@ -1,67 +1,66 @@
1
1
  /**
2
- * The type of arguments of the `c` helper.
2
+ * Argument type for the `c` helper.
3
3
  */
4
4
  export type C_Node = {
5
5
  [attribute_or_selector: string]: string | number | C_Node | undefined;
6
6
  };
7
7
  /**
8
- * The type of arguments of the `c` helper.
8
+ * Argument type for the `c` helper.
9
9
  */
10
10
  export type C_Root = Record<PropertyKey, C_Node>;
11
11
  /**
12
- * A simple JS-to-CSS (aka CSS-in-JS) helper.
12
+ * A minimal JS-to-CSS (CSSinJS) helper.
13
13
  *
14
- * The `root` parameter provides a hierarchical description of CSS rules.
14
+ * The `root` object describes a hierarchy of CSS rules.
15
15
  *
16
- * - Keys of sub-objects whose values are NOT objects are treated as CSS attribute, and values are treated as values of those CSS attributes; the concatenation of keys of all parent objects is a CSS rule.
17
- * - All keys ignore the part starting with a splitter (default: `$$`) sign until the end of the key (e.g. `src$$1` → `src`, `@font-face$$1` → `@font-face`).
18
- * - In keys specifying CSS attribute, all uppercase letters are replaced by lowercase letters with an additional `-` character preceding them (e.g. `fontFamily` → `font-family`), while all `_` characters are replaced by `-` character (e.g. `font_family` → `font-family`).
19
- * - Commas in keys that makes a CSS rule cause it to “split” and create separate rules for each part (e.g. `{div:{margin:1,'.a,.b,.c':{margin:2}}}` → `div{margin:1}div.a,div.b,div.c{margin:2}`).
20
- * - Top-level keys that begin with `@` are not concatenated with sub-object keys.
16
+ * - Keys whose values are not objects are treated as CSS property names; their values become property values. The concatenation of parent keys produces a selector.
17
+ * - For every key, the substring starting with the splitter (default: `$$`) to the end is ignored (e.g. `src$$1` → `src`, `@font-face$$1` → `@font-face`).
18
+ * - In property keys, uppercase letters are converted to lowercase and prefixed with `-` (e.g. `fontFamily` → `font-family`); underscores are converted to `-` (e.g. `font_family` → `font-family`).
19
+ * - Commas inside selector keys cause them to expand into multiple selectors (e.g. `{div:{margin:1,'.a,.b,.c':{margin:2}}}` → `div{margin:1}div.a,div.b,div.c{margin:2}`).
20
+ * - Top-level keys beginning with `@` (at-rules) are not concatenated with parent keys.
21
21
  */
22
22
  export declare const c: (root: C_Root, splitter?: string) => string;
23
23
  /**
24
- * A tiny helper for parsing CSV.
24
+ * A tiny CSV parsing helper.
25
25
  */
26
- export declare const csv_parse_raw: (csv: string, separator?: string) => string[][];
26
+ export declare const csv_parse: (csv: string, separator?: string) => string[][];
27
27
  /**
28
- * A tiny helper for parsing CSV.
29
- */
30
- export declare const csv_parse: (csv: string, separator?: string) => Record<PropertyKey, string>[];
31
- /**
32
- * The type of arguments of the `escape_values` and `escape` helpers.
28
+ * Argument type accepted by the `escape_values` and `escape` helpers.
33
29
  */
34
30
  export type Escape_Map = Map<unknown, (value?: unknown) => string>;
35
31
  /**
36
- * A generic helper for escaping `values` by given `escape_map`.
32
+ * Escapes array `values` using the provided `escape_map`.
37
33
  */
38
34
  export declare const escape_values: (escape_map: Escape_Map, values: unknown[]) => string[];
39
35
  /**
40
- * A generic helper for escaping `values` by given `escape_map` (in *TemplateStrings* flavor).
36
+ * Escapes interpolated template `values` using the provided `escape_map`.
41
37
  */
42
38
  export declare const escape: (escape_map: Escape_Map, template: TemplateStringsArray, ...values: unknown[]) => string;
43
39
  /**
44
- * A helper that implements typographic corrections specific to Polish typography.
40
+ * Applies Polish‑specific typographic corrections.
45
41
  */
46
42
  export declare const fix_typography: (node: Node) => void;
47
43
  /**
48
- * The type of arguments of the `h` and `s` helpers.
44
+ * Argument type for the `h` and `s` helpers.
49
45
  */
50
46
  export type H_Args_1 = Record<PropertyKey, unknown> | null | undefined | Node | string | number | H_Args;
51
47
  /**
52
- * The type of arguments of the `h` and `s` helpers.
48
+ * Argument type for the `h` and `s` helpers.
53
49
  */
54
50
  export type H_Args = [string | Node, ...H_Args_1[]];
55
51
  /**
56
52
  * A lightweight [HyperScript](https://github.com/hyperhype/hyperscript)-style helper for creating and modifying `HTMLElement`s (see also `s`).
57
53
  *
58
- * - The first argument of type `string` specifies the tag of the element to be created.
59
- * - The first argument of type `Node` specifies the element to be modified.
60
- * - All other arguments of type `Record<PropertyKey, unknown>` are mappings of attributes and properties. Keys starting with `$` specify *properties* (without the leading `$`) to be set on the element being created or modified. (Note that `$` is not a valid attribute name character.) All other keys specify *attributes* to be set by `setAttribute`. An attribute equal to `false` causes the attribute to be removed by `removeAttribute`.
61
- * - All other arguments of type `null` or `undefined` are simply ignored.
62
- * - All other arguments of type `Node` are appended to the element being created or modified.
63
- * - All other arguments of type `string`/`number` are converted to `Text` nodes and appended to the element being created or modified.
64
- * - All other arguments of type `HArgs` are passed to `h` and the results are appended to the element being created or modified.
54
+ * - If the first argument is a `string`, it is treated as the tag name to create.
55
+ * - If the first argument is a `Node`, that node is modified.
56
+ * - Object arguments map attributes/properties:
57
+ * - Keys starting with `$` set element properties (without `$`).
58
+ * - Other keys set attributes via `setAttribute`.
59
+ * - Attributes with value `false` are removed via `removeAttribute`.
60
+ * - `null` / `undefined` are ignored.
61
+ * - `Node` arguments are appended.
62
+ * - `string` / `number` arguments become `Text` nodes.
63
+ * - `H_Args` arrays are processed recursively.
65
64
  */
66
65
  export declare const h: {
67
66
  <T extends keyof HTMLElementTagNameMap>(tag: T, ...args1: H_Args_1[]): HTMLElementTagNameMap[T];
@@ -71,13 +70,16 @@ export declare const h: {
71
70
  /**
72
71
  * A lightweight [HyperScript](https://github.com/hyperhype/hyperscript)-style helper for creating and modifying `SVGElement`s (see also `h`).
73
72
  *
74
- * - The first argument of type `string` specifies the tag of the element to be created.
75
- * - The first argument of type `Node` specifies the element to be modified.
76
- * - All other arguments of type `Record<PropertyKey, unknown>` are mappings of attributes and properties. Keys starting with `$` specify *properties* (without the leading `$`) to be set on the element being created or modified. (Note that `$` is not a valid attribute name character.) All other keys specify *attributes* to be set by `setAttributeNS`. An attribute equal to `false` causes the attribute to be removed by `removeAttributeNS`.
77
- * - All other arguments of type `null` or `undefined` are simply ignored.
78
- * - All other arguments of type `Node` are appended to the element being created or modified.
79
- * - All other arguments of type `string`/`number` are converted to `Text` nodes and appended to the element being created or modified.
80
- * - All other arguments of type `HArgs` are passed to `s` and the results are appended to the element being created or modified.
73
+ * - If the first argument is a `string`, it is treated as the tag name to create.
74
+ * - If the first argument is a `Node`, that node is modified.
75
+ * - Object arguments map attributes/properties:
76
+ * - Keys starting with `$` set element properties (without `$`).
77
+ * - Other keys set attributes via `setAttributeNS`.
78
+ * - Attributes with value `false` are removed via `removeAttributeNS`.
79
+ * - `null` / `undefined` are ignored.
80
+ * - `Node` arguments are appended.
81
+ * - `string` / `number` arguments become `Text` nodes.
82
+ * - `H_Args` arrays are processed recursively.
81
83
  */
82
84
  export declare const s: {
83
85
  <T extends keyof SVGElementTagNameMap>(tag: T, ...args1: H_Args_1[]): SVGElementTagNameMap[T];
@@ -85,39 +87,48 @@ export declare const s: {
85
87
  (tag_or_node: string | Node, ...args1: H_Args_1[]): Node;
86
88
  };
87
89
  /**
88
- * A convenient shortcut for `s('svg', ['use', { 'xlink:href': '#' + id }], ...args)`.
90
+ * Shorthand for: `s('svg', ['use', { 'xlink:href': '#' + id }], ...args)`.
89
91
  */
90
92
  export declare const svg_use: (id: string, ...args: H_Args_1[]) => SVGSVGElement;
91
93
  /**
92
- * A replacement for the `in` operator (not to be confused with the `for-in` loop) that works properly.
94
+ * A replacement to the `in` operator (not to be confused with `for-in`).
93
95
  */
94
96
  export declare const has_own: (ref: unknown, key: unknown) => boolean;
95
97
  /**
96
- * A helper that checks if the given argument is of type `any[]`.
98
+ * Checks whether the argument is an array.
97
99
  */
98
100
  export declare const is_array: (arg: any) => arg is any[];
101
+ declare const FINITE_NUMBER: unique symbol;
102
+ type Finite_Number = number & {
103
+ readonly [FINITE_NUMBER]: true;
104
+ };
105
+ /**
106
+ * Checks whether the argument is a finite number (excluding `±Infinity` and `NaN`).
107
+ */
108
+ export declare const is_finite_number: ((arg: unknown) => arg is Finite_Number);
99
109
  /**
100
- * A helper that checks if the given argument is of type `number`.
110
+ * Checks whether the argument is a number.
101
111
  */
102
- export declare const is_number: (arg: any) => arg is number;
112
+ export declare const is_number: (arg: unknown) => arg is number;
103
113
  /**
104
- * A helper that checks if the given argument is of type `Record<PropertyKey, unknown>`.
114
+ * Checks whether the argument is a plain object record.
105
115
  */
106
- export declare const is_record: (arg: any) => arg is Record<PropertyKey, unknown>;
116
+ export declare const is_record: (arg: unknown) => arg is Record<PropertyKey, unknown>;
107
117
  /**
108
- * A helper that checks if the given argument is of type `string`.
118
+ * Checks whether the argument is a string.
109
119
  */
110
- export declare const is_string: (arg: any) => arg is string;
120
+ export declare const is_string: (arg: unknown) => arg is string;
121
+ export {};
111
122
  /**
112
123
  * `JSON.parse` with “JavaScript turned on”.
113
124
  *
114
- * Objects having *exactly* one property which is present in the `handlers` map, i.e. objects of the form:
125
+ * Objects having *exactly* one property whose name exists in `handlers`, i.e.:
115
126
  *
116
127
  * ```js
117
128
  * { "«handler_name»": [«params»] }
118
129
  * ```
119
130
  *
120
- * are replaced by the result of call
131
+ * are replaced with:
121
132
  *
122
133
  * ```js
123
134
  * handlers['«handler_name»'](...«params»)
@@ -126,32 +137,32 @@ export declare const is_string: (arg: any) => arg is string;
126
137
  export declare const js_on_parse: (handlers: Record<PropertyKey, Function>, text: string) => any;
127
138
  import type { H_Args_1 } from './h.js';
128
139
  /**
129
- * A generic helper for syntax highlighting (see also `nanolight_js`).
140
+ * Generic syntax highlighting helper (see also `nanolight_js`).
130
141
  */
131
142
  export declare const nanolight: (pattern: RegExp, highlighters: ((chunk: string, index: number) => H_Args_1)[], code: string) => H_Args_1[];
132
143
  /**
133
- * A helper for highlighting JavaScript (see also `nanolight`).
144
+ * JavaScript syntax highlighting helper (built on `nanolight`).
134
145
  */
135
146
  export declare const nanolight_js: (code: string) => H_Args_1[];
136
147
  /**
137
- * A helper that implements TypeScript’s `Pick` utility type (see also `omit`).
148
+ * Runtime implementation of TypeScript’s `Pick` (see also `omit`).
138
149
  */
139
150
  export declare const pick: <T, K extends keyof T>(ref: T, keys: K[]) => Pick<T, K>;
140
151
  /**
141
- * A helper that implements TypeScript’s `Omit` utility type (see also `pick`).
152
+ * Runtime implementation of TypeScript’s `Omit` (see also `pick`).
142
153
  */
143
154
  export declare const omit: <T, K extends keyof T>(ref: T, keys: unknown[]) => Omit<T, K>;
144
155
  /**
145
- * A helper for choosing the correct singular and plural.
156
+ * Chooses the appropriate Polish noun form based on a numeric value.
146
157
  */
147
158
  export declare const pl_ural: (singular: string, plural_2: string, plural_5: string, value: number) => string;
148
159
  /**
149
- * A helper that protects calls to nested properties by a `Proxy` that initializes non-existent values with an empty object.
160
+ * A `Proxy`-based helper that safely creates nested structures on access and allows deep assignment without guards.
150
161
  */
151
162
  export declare const pro: (ref: unknown) => any;
152
163
  /**
153
- * A helper that generates a UUID v1 identifier (with a creation timestamp).
164
+ * Generates a UUID v1 (time-based) identifier.
154
165
  *
155
- * - The optional `node` parameter should have the format `/^[0123456789abcdef]+$/`. Its value will be trimmed to last 12 characters and left padded with zeros.
166
+ * - Optional `node` must match `/^[0-9a-f]*$/`; it is trimmed to the last 12 characters and left-padded with zeros.
156
167
  */
157
168
  export declare const uuid_v1: (date?: Date, node?: string) => string;
package/nnn.js CHANGED
@@ -1,5 +1,6 @@
1
1
  // src/nnn/is.ts
2
2
  var is_array = Array.isArray;
3
+ var is_finite_number = Number.isFinite;
3
4
  var is_number = (arg) => typeof arg === "number";
4
5
  var is_record = (arg) => typeof arg === "object" && arg != null && !is_array(arg);
5
6
  var is_string = (arg) => typeof arg === "string";
@@ -57,19 +58,11 @@ var c = (root, splitter = "$$") => {
57
58
  return chunks.join("");
58
59
  };
59
60
  // src/nnn/csv_parse.ts
60
- var csv_parse_raw = (csv, separator = ",") => {
61
+ var csv_parse = (csv, separator = ",") => {
61
62
  const main_pattern = /\n|(?<!")("(?:[^"]|"")*")(?!")/g;
62
63
  const line_pattern = new RegExp(`${separator}|(?<!")\\s*"((?:[^"]|"")*)"\\s*(?!")`, "g");
63
64
  return csv.replace(/\r/g, "").replace(/\n+$/, "").replace(main_pattern, (_, chunk) => chunk ?? "\r").split("\r").map((line) => line.replace(line_pattern, (_, chunk) => chunk == null ? "\r" : chunk.replace(/""/g, '"')).split("\r"));
64
65
  };
65
- var csv_parse = (csv, separator = ",") => {
66
- const rows = csv_parse_raw(csv, separator);
67
- const keys = rows.shift();
68
- return keys != null ? rows.map((row) => keys.reduce((record, key, index) => {
69
- record[key] = row[index];
70
- return record;
71
- }, {})) : [];
72
- };
73
66
  // src/nnn/escape.ts
74
67
  var escape_values = (escape_map, values) => values.map((value) => (escape_map.get(value?.constructor) ?? escape_map.get(undefined))?.(value) ?? "");
75
68
  var escape = (escape_map, template, ...values) => String.raw(template, ...escape_values(escape_map, values));
@@ -90,7 +83,7 @@ var _h = (namespace_uri) => {
90
83
  if (name[0] === "$") {
91
84
  const name1 = name.slice(1);
92
85
  if (is_record(value)) {
93
- node[name1] = node[name1] ?? {};
86
+ node[name1] ??= {};
94
87
  Object.assign(node[name1], value);
95
88
  } else {
96
89
  node[name1] = value;
@@ -221,7 +214,7 @@ var pl_ural = (singular, plural_2, plural_5, value) => {
221
214
  // src/nnn/pro.ts
222
215
  var pro = (ref) => new Proxy(ref, {
223
216
  get(target, key) {
224
- return pro(target[key] = target[key] ?? {});
217
+ return pro(target[key] ??= {});
225
218
  }
226
219
  });
227
220
  // src/nnn/uuid_v1.ts
@@ -246,13 +239,13 @@ export {
246
239
  is_string,
247
240
  is_record,
248
241
  is_number,
242
+ is_finite_number,
249
243
  is_array,
250
244
  has_own,
251
245
  h,
252
246
  fix_typography,
253
247
  escape_values,
254
248
  escape,
255
- csv_parse_raw,
256
249
  csv_parse,
257
250
  c
258
251
  };
package/package.json CHANGED
@@ -15,6 +15,7 @@
15
15
  "in",
16
16
  "is",
17
17
  "is_array",
18
+ "is_finite_number",
18
19
  "is_number",
19
20
  "is_record",
20
21
  "is_string",
@@ -35,5 +36,5 @@
35
36
  "name": "@jackens/nnn",
36
37
  "type": "module",
37
38
  "types": "nnn.d.ts",
38
- "version": "2025.6.20"
39
+ "version": "2025.9.4"
39
40
  }
package/readme.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # nnn
2
2
 
3
- Jackens’ JavaScript helpers.
3
+ A collection of Jackens’ JavaScript helper utilities.
4
4
 
5
5
  ## Installation
6
6
 
@@ -28,33 +28,33 @@ import { «something» } from './node_modules/@jackens/nnn/nnn.js'
28
28
 
29
29
  ## Exports
30
30
 
31
- - `C_Node`: The type of arguments of the `c` helper.
32
- - `C_Root`: The type of arguments of the `c` helper.
33
- - `Escape_Map`: The type of arguments of the `escape_values` and `escape` helpers.
34
- - `H_Args`: The type of arguments of the `h` and `s` helpers.
35
- - `H_Args_1`: The type of arguments of the `h` and `s` helpers.
36
- - `c`: A simple JS-to-CSS (aka CSS-in-JS) helper.
37
- - `csv_parse`: A tiny helper for parsing CSV.
38
- - `csv_parse_raw`: A tiny helper for parsing CSV.
39
- - `escape`: A generic helper for escaping `values` by given `escape_map` (in *TemplateStrings* flavor).
40
- - `escape_values`: A generic helper for escaping `values` by given `escape_map`.
41
- - `fix_typography`: A helper that implements typographic corrections specific to Polish typography.
31
+ - `C_Node`: Argument type for the `c` helper.
32
+ - `C_Root`: Argument type for the `c` helper.
33
+ - `Escape_Map`: Argument type accepted by the `escape_values` and `escape` helpers.
34
+ - `H_Args`: Argument type for the `h` and `s` helpers.
35
+ - `H_Args_1`: Argument type for the `h` and `s` helpers.
36
+ - `c`: A minimal JS-to-CSS (CSSinJS) helper.
37
+ - `csv_parse`: A tiny CSV parsing helper.
38
+ - `escape`: Escapes interpolated template `values` using the provided `escape_map`.
39
+ - `escape_values`: Escapes array `values` using the provided `escape_map`.
40
+ - `fix_typography`: Applies Polish‑specific typographic corrections.
42
41
  - `h`: A lightweight [HyperScript](https://github.com/hyperhype/hyperscript)-style helper for creating and modifying `HTMLElement`s (see also `s`).
43
- - `has_own`: A replacement for the `in` operator (not to be confused with the `for-in` loop) that works properly.
44
- - `is_array`: A helper that checks if the given argument is of type `any[]`.
45
- - `is_number`: A helper that checks if the given argument is of type `number`.
46
- - `is_record`: A helper that checks if the given argument is of type `Record<PropertyKey, unknown>`.
47
- - `is_string`: A helper that checks if the given argument is of type `string`.
42
+ - `has_own`: A replacement to the `in` operator (not to be confused with `for-in`).
43
+ - `is_array`: Checks whether the argument is an array.
44
+ - `is_finite_number`: Checks whether the argument is a finite number (excluding `±Infinity` and `NaN`).
45
+ - `is_number`: Checks whether the argument is a number.
46
+ - `is_record`: Checks whether the argument is a plain object record.
47
+ - `is_string`: Checks whether the argument is a string.
48
48
  - `js_on_parse`: `JSON.parse` with “JavaScript turned on”.
49
- - `nanolight`: A generic helper for syntax highlighting (see also `nanolight_js`).
50
- - `nanolight_js`: A helper for highlighting JavaScript (see also `nanolight`).
51
- - `omit`: A helper that implements TypeScript’s `Omit` utility type (see also `pick`).
52
- - `pick`: A helper that implements TypeScript’s `Pick` utility type (see also `omit`).
53
- - `pl_ural`: A helper for choosing the correct singular and plural.
54
- - `pro`: A helper that protects calls to nested properties by a `Proxy` that initializes non-existent values with an empty object.
49
+ - `nanolight`: Generic syntax highlighting helper (see also `nanolight_js`).
50
+ - `nanolight_js`: JavaScript syntax highlighting helper (built on `nanolight`).
51
+ - `omit`: Runtime implementation of TypeScript’s `Omit` (see also `pick`).
52
+ - `pick`: Runtime implementation of TypeScript’s `Pick` (see also `omit`).
53
+ - `pl_ural`: Chooses the appropriate Polish noun form based on a numeric value.
54
+ - `pro`: A `Proxy`-based helper that safely creates nested structures on access and allows deep assignment without guards.
55
55
  - `s`: A lightweight [HyperScript](https://github.com/hyperhype/hyperscript)-style helper for creating and modifying `SVGElement`s (see also `h`).
56
- - `svg_use`: A convenient shortcut for `s('svg', ['use', { 'xlink:href': '#' + id }], ...args)`.
57
- - `uuid_v1`: A helper that generates a UUID v1 identifier (with a creation timestamp).
56
+ - `svg_use`: Shorthand for: `s('svg', ['use', { 'xlink:href': '#' + id }], ...args)`.
57
+ - `uuid_v1`: Generates a UUID v1 (time-based) identifier.
58
58
 
59
59
  ### C_Node
60
60
 
@@ -64,7 +64,7 @@ type C_Node = {
64
64
  };
65
65
  ```
66
66
 
67
- The type of arguments of the `c` helper.
67
+ Argument type for the `c` helper.
68
68
 
69
69
  ### C_Root
70
70
 
@@ -72,7 +72,7 @@ The type of arguments of the `c` helper.
72
72
  type C_Root = Record<PropertyKey, C_Node>;
73
73
  ```
74
74
 
75
- The type of arguments of the `c` helper.
75
+ Argument type for the `c` helper.
76
76
 
77
77
  ### Escape_Map
78
78
 
@@ -80,7 +80,7 @@ The type of arguments of the `c` helper.
80
80
  type Escape_Map = Map<unknown, (value?: unknown) => string>;
81
81
  ```
82
82
 
83
- The type of arguments of the `escape_values` and `escape` helpers.
83
+ Argument type accepted by the `escape_values` and `escape` helpers.
84
84
 
85
85
  ### H_Args
86
86
 
@@ -88,7 +88,7 @@ The type of arguments of the `escape_values` and `escape` helpers.
88
88
  type H_Args = [string | Node, ...H_Args_1[]];
89
89
  ```
90
90
 
91
- The type of arguments of the `h` and `s` helpers.
91
+ Argument type for the `h` and `s` helpers.
92
92
 
93
93
  ### H_Args_1
94
94
 
@@ -96,7 +96,7 @@ The type of arguments of the `h` and `s` helpers.
96
96
  type H_Args_1 = Record<PropertyKey, unknown> | null | undefined | Node | string | number | H_Args;
97
97
  ```
98
98
 
99
- The type of arguments of the `h` and `s` helpers.
99
+ Argument type for the `h` and `s` helpers.
100
100
 
101
101
  ### c
102
102
 
@@ -104,15 +104,15 @@ The type of arguments of the `h` and `s` helpers.
104
104
  const c: (root: C_Root, splitter?: string) => string;
105
105
  ```
106
106
 
107
- A simple JS-to-CSS (aka CSS-in-JS) helper.
107
+ A minimal JS-to-CSS (CSSinJS) helper.
108
108
 
109
- The `root` parameter provides a hierarchical description of CSS rules.
109
+ The `root` object describes a hierarchy of CSS rules.
110
110
 
111
- - Keys of sub-objects whose values are NOT objects are treated as CSS attribute, and values are treated as values of those CSS attributes; the concatenation of keys of all parent objects is a CSS rule.
112
- - All keys ignore the part starting with a splitter (default: `$$`) sign until the end of the key (e.g. `src$$1` → `src`, `@font-face$$1` → `@font-face`).
113
- - In keys specifying CSS attribute, all uppercase letters are replaced by lowercase letters with an additional `-` character preceding them (e.g. `fontFamily` → `font-family`), while all `_` characters are replaced by `-` character (e.g. `font_family` → `font-family`).
114
- - Commas in keys that makes a CSS rule cause it to “split” and create separate rules for each part (e.g. `{div:{margin:1,'.a,.b,.c':{margin:2}}}` → `div{margin:1}div.a,div.b,div.c{margin:2}`).
115
- - Top-level keys that begin with `@` are not concatenated with sub-object keys.
111
+ - Keys whose values are not objects are treated as CSS property names; their values become property values. The concatenation of parent keys produces a selector.
112
+ - For every key, the substring starting with the splitter (default: `$$`) to the end is ignored (e.g. `src$$1` → `src`, `@font-face$$1` → `@font-face`).
113
+ - In property keys, uppercase letters are converted to lowercase and prefixed with `-` (e.g. `fontFamily` → `font-family`); underscores are converted to `-` (e.g. `font_family` → `font-family`).
114
+ - Commas inside selector keys cause them to expand into multiple selectors (e.g. `{div:{margin:1,'.a,.b,.c':{margin:2}}}` → `div{margin:1}div.a,div.b,div.c{margin:2}`).
115
+ - Top-level keys beginning with `@` (at-rules) are not concatenated with parent keys.
116
116
 
117
117
  #### Usage Examples
118
118
 
@@ -313,10 +313,10 @@ expect(actual).to.deep.equal(expected)
313
313
  ### csv_parse
314
314
 
315
315
  ```ts
316
- const csv_parse: (csv: string, separator?: string) => Record<PropertyKey, string>[];
316
+ const csv_parse: (csv: string, separator?: string) => string[][];
317
317
  ```
318
318
 
319
- A tiny helper for parsing CSV.
319
+ A tiny CSV parsing helper.
320
320
 
321
321
  #### Usage Examples
322
322
 
@@ -329,38 +329,7 @@ yyy",zzz
329
329
  42 , "42" , 17
330
330
 
331
331
  `
332
-
333
- expect(csv_parse(text)).to.deep.equal([{
334
- 'aaa\n"aaa"\naaa': 'xxx,xxx',
335
- bbb: 'yyy\nyyy',
336
- 'ccc,ccc': 'zzz'
337
- }, {
338
- 'aaa\n"aaa"\naaa': ' 42 ',
339
- bbb: '42',
340
- 'ccc,ccc': ' 17'
341
- }])
342
- ```
343
-
344
- ### csv_parse_raw
345
-
346
- ```ts
347
- const csv_parse_raw: (csv: string, separator?: string) => string[][];
348
- ```
349
-
350
- A tiny helper for parsing CSV.
351
-
352
- #### Usage Examples
353
-
354
- ```ts
355
- const text = `"aaa
356
- ""aaa""
357
- aaa",bbb, "ccc,ccc"
358
- "xxx,xxx", "yyy
359
- yyy",zzz
360
- 42 , "42" , 17
361
-
362
- `
363
- expect(csv_parse_raw(text)).to.deep.equal([
332
+ expect(csv_parse(text)).to.deep.equal([
364
333
  ['aaa\n"aaa"\naaa', 'bbb', 'ccc,ccc'],
365
334
  ['xxx,xxx', 'yyy\nyyy', 'zzz'],
366
335
  [' 42 ', '42', ' 17']
@@ -373,7 +342,7 @@ expect(csv_parse_raw(text)).to.deep.equal([
373
342
  const escape: (escape_map: Escape_Map, template: TemplateStringsArray, ...values: unknown[]) => string;
374
343
  ```
375
344
 
376
- A generic helper for escaping `values` by given `escape_map` (in *TemplateStrings* flavor).
345
+ Escapes interpolated template `values` using the provided `escape_map`.
377
346
 
378
347
  #### Usage Examples
379
348
 
@@ -408,7 +377,7 @@ expect(actual).to.deep.equal(expected)
408
377
  const escape_values: (escape_map: Escape_Map, values: unknown[]) => string[];
409
378
  ```
410
379
 
411
- A generic helper for escaping `values` by given `escape_map`.
380
+ Escapes array `values` using the provided `escape_map`.
412
381
 
413
382
  ### fix_typography
414
383
 
@@ -416,7 +385,7 @@ A generic helper for escaping `values` by given `escape_map`.
416
385
  const fix_typography: (node: Node) => void;
417
386
  ```
418
387
 
419
- A helper that implements typographic corrections specific to Polish typography.
388
+ Applies Polish‑specific typographic corrections.
420
389
 
421
390
  #### Usage Examples
422
391
 
@@ -442,13 +411,16 @@ const h: {
442
411
 
443
412
  A lightweight [HyperScript](https://github.com/hyperhype/hyperscript)-style helper for creating and modifying `HTMLElement`s (see also `s`).
444
413
 
445
- - The first argument of type `string` specifies the tag of the element to be created.
446
- - The first argument of type `Node` specifies the element to be modified.
447
- - All other arguments of type `Record<PropertyKey, unknown>` are mappings of attributes and properties. Keys starting with `$` specify *properties* (without the leading `$`) to be set on the element being created or modified. (Note that `$` is not a valid attribute name character.) All other keys specify *attributes* to be set by `setAttribute`. An attribute equal to `false` causes the attribute to be removed by `removeAttribute`.
448
- - All other arguments of type `null` or `undefined` are simply ignored.
449
- - All other arguments of type `Node` are appended to the element being created or modified.
450
- - All other arguments of type `string`/`number` are converted to `Text` nodes and appended to the element being created or modified.
451
- - All other arguments of type `HArgs` are passed to `h` and the results are appended to the element being created or modified.
414
+ - If the first argument is a `string`, it is treated as the tag name to create.
415
+ - If the first argument is a `Node`, that node is modified.
416
+ - Object arguments map attributes/properties:
417
+ - Keys starting with `$` set element properties (without `$`).
418
+ - Other keys set attributes via `setAttribute`.
419
+ - Attributes with value `false` are removed via `removeAttribute`.
420
+ - `null` / `undefined` are ignored.
421
+ - `Node` arguments are appended.
422
+ - `string` / `number` arguments become `Text` nodes.
423
+ - `H_Args` arrays are processed recursively.
452
424
 
453
425
  #### Usage Examples
454
426
 
@@ -524,7 +496,7 @@ expect(div.key).to.deep.equal({ one: 1, two: 2 })
524
496
  const has_own: (ref: unknown, key: unknown) => boolean;
525
497
  ```
526
498
 
527
- A replacement for the `in` operator (not to be confused with the `for-in` loop) that works properly.
499
+ A replacement to the `in` operator (not to be confused with `for-in`).
528
500
 
529
501
  #### Usage Examples
530
502
 
@@ -563,33 +535,46 @@ expect(has_own(undefined, 'key')).to.be.false
563
535
 
564
536
  ```ts
565
537
  const is_array: (arg: any) => arg is any[];
538
+ declare const FINITE_NUMBER: unique symbol;
539
+ type Finite_Number = number & {
540
+ readonly [FINITE_NUMBER]: true;
541
+ };
542
+ ```
543
+
544
+ Checks whether the argument is an array.
545
+
546
+ ### is_finite_number
547
+
548
+ ```ts
549
+ const is_finite_number: ((arg: unknown) => arg is Finite_Number);
566
550
  ```
567
551
 
568
- A helper that checks if the given argument is of type `any[]`.
552
+ Checks whether the argument is a finite number (excluding `±Infinity` and `NaN`).
569
553
 
570
554
  ### is_number
571
555
 
572
556
  ```ts
573
- const is_number: (arg: any) => arg is number;
557
+ const is_number: (arg: unknown) => arg is number;
574
558
  ```
575
559
 
576
- A helper that checks if the given argument is of type `number`.
560
+ Checks whether the argument is a number.
577
561
 
578
562
  ### is_record
579
563
 
580
564
  ```ts
581
- const is_record: (arg: any) => arg is Record<PropertyKey, unknown>;
565
+ const is_record: (arg: unknown) => arg is Record<PropertyKey, unknown>;
582
566
  ```
583
567
 
584
- A helper that checks if the given argument is of type `Record<PropertyKey, unknown>`.
568
+ Checks whether the argument is a plain object record.
585
569
 
586
570
  ### is_string
587
571
 
588
572
  ```ts
589
- const is_string: (arg: any) => arg is string;
573
+ const is_string: (arg: unknown) => arg is string;
574
+ export {};
590
575
  ```
591
576
 
592
- A helper that checks if the given argument is of type `string`.
577
+ Checks whether the argument is a string.
593
578
 
594
579
  ### js_on_parse
595
580
 
@@ -599,13 +584,13 @@ const js_on_parse: (handlers: Record<PropertyKey, Function>, text: string) => an
599
584
 
600
585
  `JSON.parse` with “JavaScript turned on”.
601
586
 
602
- Objects having *exactly* one property which is present in the `handlers` map, i.e. objects of the form:
587
+ Objects having *exactly* one property whose name exists in `handlers`, i.e.:
603
588
 
604
589
  ```js
605
590
  { "«handler_name»": [«params»] }
606
591
  ```
607
592
 
608
- are replaced by the result of call
593
+ are replaced with:
609
594
 
610
595
  ```js
611
596
  handlers['«handler_name»'](...«params»)
@@ -664,7 +649,7 @@ expect(actual).to.deep.equal(expected)
664
649
  const nanolight: (pattern: RegExp, highlighters: ((chunk: string, index: number) => H_Args_1)[], code: string) => H_Args_1[];
665
650
  ```
666
651
 
667
- A generic helper for syntax highlighting (see also `nanolight_js`).
652
+ Generic syntax highlighting helper (see also `nanolight_js`).
668
653
 
669
654
  ### nanolight_js
670
655
 
@@ -672,7 +657,7 @@ A generic helper for syntax highlighting (see also `nanolight_js`).
672
657
  const nanolight_js: (code: string) => H_Args_1[];
673
658
  ```
674
659
 
675
- A helper for highlighting JavaScript (see also `nanolight`).
660
+ JavaScript syntax highlighting helper (built on `nanolight`).
676
661
 
677
662
  #### Usage Examples
678
663
 
@@ -696,7 +681,7 @@ expect(nanolight_js(code_js)).to.deep.equal([
696
681
  const omit: <T, K extends keyof T>(ref: T, keys: unknown[]) => Omit<T, K>;
697
682
  ```
698
683
 
699
- A helper that implements TypeScript’s `Omit` utility type (see also `pick`).
684
+ Runtime implementation of TypeScript’s `Omit` (see also `pick`).
700
685
 
701
686
  #### Usage Examples
702
687
 
@@ -712,7 +697,7 @@ expect(omit(obj, ['c'])).to.deep.equal({ a: 42, b: '42' })
712
697
  const pick: <T, K extends keyof T>(ref: T, keys: K[]) => Pick<T, K>;
713
698
  ```
714
699
 
715
- A helper that implements TypeScript’s `Pick` utility type (see also `omit`).
700
+ Runtime implementation of TypeScript’s `Pick` (see also `omit`).
716
701
 
717
702
  #### Usage Examples
718
703
 
@@ -728,7 +713,7 @@ expect(pick(obj, ['a', 'b'])).to.deep.equal({ a: 42, b: '42' })
728
713
  const pl_ural: (singular: string, plural_2: string, plural_5: string, value: number) => string;
729
714
  ```
730
715
 
731
- A helper for choosing the correct singular and plural.
716
+ Chooses the appropriate Polish noun form based on a numeric value.
732
717
 
733
718
  #### Usage Examples
734
719
 
@@ -754,7 +739,7 @@ expect(car(42)).to.deep.equal('cars')
754
739
  const pro: (ref: unknown) => any;
755
740
  ```
756
741
 
757
- A helper that protects calls to nested properties by a `Proxy` that initializes non-existent values with an empty object.
742
+ A `Proxy`-based helper that safely creates nested structures on access and allows deep assignment without guards.
758
743
 
759
744
  #### Usage Examples
760
745
 
@@ -798,13 +783,16 @@ const s: {
798
783
 
799
784
  A lightweight [HyperScript](https://github.com/hyperhype/hyperscript)-style helper for creating and modifying `SVGElement`s (see also `h`).
800
785
 
801
- - The first argument of type `string` specifies the tag of the element to be created.
802
- - The first argument of type `Node` specifies the element to be modified.
803
- - All other arguments of type `Record<PropertyKey, unknown>` are mappings of attributes and properties. Keys starting with `$` specify *properties* (without the leading `$`) to be set on the element being created or modified. (Note that `$` is not a valid attribute name character.) All other keys specify *attributes* to be set by `setAttributeNS`. An attribute equal to `false` causes the attribute to be removed by `removeAttributeNS`.
804
- - All other arguments of type `null` or `undefined` are simply ignored.
805
- - All other arguments of type `Node` are appended to the element being created or modified.
806
- - All other arguments of type `string`/`number` are converted to `Text` nodes and appended to the element being created or modified.
807
- - All other arguments of type `HArgs` are passed to `s` and the results are appended to the element being created or modified.
786
+ - If the first argument is a `string`, it is treated as the tag name to create.
787
+ - If the first argument is a `Node`, that node is modified.
788
+ - Object arguments map attributes/properties:
789
+ - Keys starting with `$` set element properties (without `$`).
790
+ - Other keys set attributes via `setAttributeNS`.
791
+ - Attributes with value `false` are removed via `removeAttributeNS`.
792
+ - `null` / `undefined` are ignored.
793
+ - `Node` arguments are appended.
794
+ - `string` / `number` arguments become `Text` nodes.
795
+ - `H_Args` arrays are processed recursively.
808
796
 
809
797
  ### svg_use
810
798
 
@@ -812,7 +800,7 @@ A lightweight [HyperScript](https://github.com/hyperhype/hyperscript)-style help
812
800
  const svg_use: (id: string, ...args: H_Args_1[]) => SVGSVGElement;
813
801
  ```
814
802
 
815
- A convenient shortcut for `s('svg', ['use', { 'xlink:href': '#' + id }], ...args)`.
803
+ Shorthand for: `s('svg', ['use', { 'xlink:href': '#' + id }], ...args)`.
816
804
 
817
805
  ### uuid_v1
818
806
 
@@ -820,9 +808,9 @@ A convenient shortcut for `s('svg', ['use', { 'xlink:href': '#' + id }], ...args
820
808
  const uuid_v1: (date?: Date, node?: string) => string;
821
809
  ```
822
810
 
823
- A helper that generates a UUID v1 identifier (with a creation timestamp).
811
+ Generates a UUID v1 (time-based) identifier.
824
812
 
825
- - The optional `node` parameter should have the format `/^[0123456789abcdef]+$/`. Its value will be trimmed to last 12 characters and left padded with zeros.
813
+ - Optional `node` must match `/^[0-9a-f]*$/`; it is trimmed to the last 12 characters and left-padded with zeros.
826
814
 
827
815
  ## License
828
816