@jackens/nnn 2024.7.14 → 2024.7.18

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 (3) hide show
  1. package/nnn.d.ts +13 -30
  2. package/package.json +1 -1
  3. package/readme.md +17 -34
package/nnn.d.ts CHANGED
@@ -15,14 +15,10 @@ export type CRoot = Partial<Record<PropertyKey, CNode>>;
15
15
  *
16
16
  * The `root` parameter provides a hierarchical description of CSS rules.
17
17
  *
18
- * - Keys of sub-objects whose values are NOT objects are treated as CSS attribute, and values are treated as values of
19
- * those CSS attributes; the concatenation of keys of all parent objects is a CSS rule.
20
- * - All keys ignore the part starting with a splitter (default: `$$`) sign until the end of the key (e.g. `src$$1` →
21
- * `src`, `@font-face$$1` → `@font-face`).
22
- * - In keys specifying CSS attribute, all uppercase letters are replaced by lowercase letters with an additional `-`
23
- * character preceding them (e.g. `fontFamily` → `font-family`).
24
- * - Commas in keys that makes a CSS rule cause it to “split” and create separate rules for each part (e.g.
25
- * `{div:{margin:1,'.a,.b,.c':{margin:2}}}` → `div{margin:1}div.a,div.b,div.c{margin:2}`).
18
+ * - 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.
19
+ * - 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`).
20
+ * - In keys specifying CSS attribute, all uppercase letters are replaced by lowercase letters with an additional `-` character preceding them (e.g. `fontFamily` → `font-family`).
21
+ * - 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}`).
26
22
  * - Top-level keys that begin with `@` are not concatenated with sub-object keys.
27
23
  */
28
24
  export declare const c: (root: CRoot, splitter?: string) => string;
@@ -70,21 +66,15 @@ export type HArgs1 = Partial<Record<PropertyKey, unknown>> | null | undefined |
70
66
  export type HArgs = [string | Node, ...HArgs1[]];
71
67
 
72
68
  /**
73
- * A lightweight [HyperScript](https://github.com/hyperhype/hyperscript)-style helper for creating and modifying
74
- * `HTMLElement`s (see also `s`).
69
+ * A lightweight [HyperScript](https://github.com/hyperhype/hyperscript)-style helper for creating and modifying `HTMLElement`s (see also `s`).
75
70
  *
76
71
  * - The first argument of type `string` specifies the tag of the element to be created.
77
72
  * - The first argument of type `Node` specifies the element to be modified.
78
- * - All other arguments of type `Partial<Record<PropertyKey, unknown>>` are mappings of attributes and properties.
79
- * Keys starting with `$` specify *properties* (without the leading `$`) to be set on the element being created or
80
- * modified. (Note that `$` is not a valid attribute name character.) All other keys specify *attributes* to be set by
81
- * `setAttribute`. An attribute equal to `false` causes the attribute to be removed by `removeAttribute`.
73
+ * - All other arguments of type `Partial<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`.
82
74
  * - All other arguments of type `null` or `undefined` are simply ignored.
83
75
  * - All other arguments of type `Node` are appended to the element being created or modified.
84
- * - All other arguments of type `string`/`number` are converted to `Text` nodes and appended to the element being
85
- * created or modified.
86
- * - All other arguments of type `HArgs` are passed to `h` and the results are appended to the element being created or
87
- * modified.
76
+ * - All other arguments of type `string`/`number` are converted to `Text` nodes and appended to the element being created or modified.
77
+ * - All other arguments of type `HArgs` are passed to `h` and the results are appended to the element being created or modified.
88
78
  */
89
79
  export declare const h: {
90
80
  <T extends keyof HTMLElementTagNameMap>(tag: T, ...args1: Partial<Array<HArgs1>>): HTMLElementTagNameMap[T];
@@ -93,21 +83,15 @@ export declare const h: {
93
83
  };
94
84
 
95
85
  /**
96
- * A lightweight [HyperScript](https://github.com/hyperhype/hyperscript)-style helper for creating and modifying
97
- * `SVGElement`s (see also `h`).
86
+ * A lightweight [HyperScript](https://github.com/hyperhype/hyperscript)-style helper for creating and modifying `SVGElement`s (see also `h`).
98
87
  *
99
88
  * - The first argument of type `string` specifies the tag of the element to be created.
100
89
  * - The first argument of type `Node` specifies the element to be modified.
101
- * - All other arguments of type `Partial<Record<PropertyKey, unknown>>` are mappings of attributes and properties.
102
- * Keys starting with `$` specify *properties* (without the leading `$`) to be set on the element being created or
103
- * modified. (Note that `$` is not a valid attribute name character.) All other keys specify *attributes* to be set by
104
- * `setAttributeNS`. An attribute equal to `false` causes the attribute to be removed by `removeAttributeNS`.
90
+ * - All other arguments of type `Partial<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`.
105
91
  * - All other arguments of type `null` or `undefined` are simply ignored.
106
92
  * - All other arguments of type `Node` are appended to the element being created or modified.
107
- * - All other arguments of type `string`/`number` are converted to `Text` nodes and appended to the element being
108
- * created or modified.
109
- * - All other arguments of type `HArgs` are passed to `s` and the results are appended to the element being created or
110
- * modified.
93
+ * - All other arguments of type `string`/`number` are converted to `Text` nodes and appended to the element being created or modified.
94
+ * - All other arguments of type `HArgs` are passed to `s` and the results are appended to the element being created or modified.
111
95
  */
112
96
  export declare const s: {
113
97
  <T extends keyof SVGElementTagNameMap>(tag: T, ...args1: Partial<Array<HArgs1>>): SVGElementTagNameMap[T];
@@ -203,8 +187,7 @@ export declare const refsInfo: (...refs: Partial<Array<unknown>>) => Partial<Arr
203
187
  /**
204
188
  * A helper that generates a UUID v1 identifier (with a creation timestamp).
205
189
  *
206
- * - The optional `node` parameter should have the format `/^[0123456789abcdef]+$/`.
207
- * Its value will be trimmed to last 12 characters and left padded with zeros.
190
+ * - The optional `node` parameter should have the format `/^[0123456789abcdef]+$/`. Its value will be trimmed to last 12 characters and left padded with zeros.
208
191
  */
209
192
  export declare const uuid1: ({ date, node }?: {
210
193
  date?: Date | undefined;
package/package.json CHANGED
@@ -36,5 +36,5 @@
36
36
  "name": "@jackens/nnn",
37
37
  "type": "module",
38
38
  "types": "nnn.d.ts",
39
- "version": "2024.7.14"
39
+ "version": "2024.7.18"
40
40
  }
package/readme.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Jackens’ JavaScript helpers.
4
4
 
5
- <sub>Version: <code class="version">2024.7.14</code></sub>
5
+ <sub>Version: <code class="version">2024.7.18</code></sub>
6
6
 
7
7
  ## Installation
8
8
 
@@ -31,7 +31,7 @@ import { «something» } from './node_modules/@jackens/nnn/nnn.js'
31
31
  or:
32
32
 
33
33
  ```js
34
- import { «something» } from 'https://unpkg.com/@jackens/nnn@2024.7.14/nnn.js'
34
+ import { «something» } from 'https://unpkg.com/@jackens/nnn@2024.7.18/nnn.js'
35
35
  ```
36
36
 
37
37
  ## Exports
@@ -46,7 +46,7 @@ import { «something» } from 'https://unpkg.com/@jackens/nnn@2024.7.14/nnn.js'
46
46
  - `escape`: A generic helper for escaping `values` by given `escapeMap` (in *TemplateStrings* flavor).
47
47
  - `escapeValues`: A generic helper for escaping `values` by given `escapeMap`.
48
48
  - `fixTypography`: A helper that implements typographic corrections specific to Polish typography.
49
- - `h`: A lightweight [HyperScript](https://github.com/hyperhype/hyperscript)-style helper for creating and modifying
49
+ - `h`: A lightweight [HyperScript](https://github.com/hyperhype/hyperscript)-style helper for creating and modifying `HTMLElement`s (see also `s`).
50
50
  - `has`: A replacement for the `in` operator (not to be confused with the `for-in` loop) that works properly.
51
51
  - `is`: A helper that checks if the given argument is of a certain type.
52
52
  - `jsOnParse`: `JSON.parse` with “JavaScript turned on”.
@@ -58,7 +58,7 @@ import { «something» } from 'https://unpkg.com/@jackens/nnn@2024.7.14/nnn.js'
58
58
  - `plUral`: A helper for choosing the correct singular and plural.
59
59
  - `pro`: A helper that protects calls to nested properties by a `Proxy` that initializes non-existent values with an empty
60
60
  - `refsInfo`: A helper that provides information about the given `refs`.
61
- - `s`: A lightweight [HyperScript](https://github.com/hyperhype/hyperscript)-style helper for creating and modifying
61
+ - `s`: A lightweight [HyperScript](https://github.com/hyperhype/hyperscript)-style helper for creating and modifying `SVGElement`s (see also `h`).
62
62
  - `svgUse`: A convenient shortcut for `s('svg', ['use', { 'xlink:href': '#' + id }], ...args)`.
63
63
  - `uuid1`: A helper that generates a UUID v1 identifier (with a creation timestamp).
64
64
 
@@ -114,14 +114,10 @@ A simple JS-to-CSS (aka CSS-in-JS) helper.
114
114
 
115
115
  The `root` parameter provides a hierarchical description of CSS rules.
116
116
 
117
- - Keys of sub-objects whose values are NOT objects are treated as CSS attribute, and values are treated as values of
118
- those CSS attributes; the concatenation of keys of all parent objects is a CSS rule.
119
- - All keys ignore the part starting with a splitter (default: `$$`) sign until the end of the key (e.g. `src$$1` →
120
- `src`, `@font-face$$1` → `@font-face`).
121
- - In keys specifying CSS attribute, all uppercase letters are replaced by lowercase letters with an additional `-`
122
- character preceding them (e.g. `fontFamily` → `font-family`).
123
- - Commas in keys that makes a CSS rule cause it to “split” and create separate rules for each part (e.g.
124
- `{div:{margin:1,'.a,.b,.c':{margin:2}}}` → `div{margin:1}div.a,div.b,div.c{margin:2}`).
117
+ - 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.
118
+ - 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`).
119
+ - In keys specifying CSS attribute, all uppercase letters are replaced by lowercase letters with an additional `-` character preceding them (e.g. `fontFamily` → `font-family`).
120
+ - 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}`).
125
121
  - Top-level keys that begin with `@` are not concatenated with sub-object keys.
126
122
 
127
123
  #### Usage Examples
@@ -436,21 +432,15 @@ const h: {
436
432
  };
437
433
  ```
438
434
 
439
- A lightweight [HyperScript](https://github.com/hyperhype/hyperscript)-style helper for creating and modifying
440
- `HTMLElement`s (see also `s`).
435
+ A lightweight [HyperScript](https://github.com/hyperhype/hyperscript)-style helper for creating and modifying `HTMLElement`s (see also `s`).
441
436
 
442
437
  - The first argument of type `string` specifies the tag of the element to be created.
443
438
  - The first argument of type `Node` specifies the element to be modified.
444
- - All other arguments of type `Partial<Record<PropertyKey, unknown>>` are mappings of attributes and properties.
445
- Keys starting with `$` specify *properties* (without the leading `$`) to be set on the element being created or
446
- modified. (Note that `$` is not a valid attribute name character.) All other keys specify *attributes* to be set by
447
- `setAttribute`. An attribute equal to `false` causes the attribute to be removed by `removeAttribute`.
439
+ - All other arguments of type `Partial<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
440
  - All other arguments of type `null` or `undefined` are simply ignored.
449
441
  - 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
451
- created or modified.
452
- - All other arguments of type `HArgs` are passed to `h` and the results are appended to the element being created or
453
- modified.
442
+ - All other arguments of type `string`/`number` are converted to `Text` nodes and appended to the element being created or modified.
443
+ - All other arguments of type `HArgs` are passed to `h` and the results are appended to the element being created or modified.
454
444
 
455
445
  #### Usage Examples
456
446
 
@@ -916,21 +906,15 @@ const s: {
916
906
  };
917
907
  ```
918
908
 
919
- A lightweight [HyperScript](https://github.com/hyperhype/hyperscript)-style helper for creating and modifying
920
- `SVGElement`s (see also `h`).
909
+ A lightweight [HyperScript](https://github.com/hyperhype/hyperscript)-style helper for creating and modifying `SVGElement`s (see also `h`).
921
910
 
922
911
  - The first argument of type `string` specifies the tag of the element to be created.
923
912
  - The first argument of type `Node` specifies the element to be modified.
924
- - All other arguments of type `Partial<Record<PropertyKey, unknown>>` are mappings of attributes and properties.
925
- Keys starting with `$` specify *properties* (without the leading `$`) to be set on the element being created or
926
- modified. (Note that `$` is not a valid attribute name character.) All other keys specify *attributes* to be set by
927
- `setAttributeNS`. An attribute equal to `false` causes the attribute to be removed by `removeAttributeNS`.
913
+ - All other arguments of type `Partial<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`.
928
914
  - All other arguments of type `null` or `undefined` are simply ignored.
929
915
  - All other arguments of type `Node` are appended to the element being created or modified.
930
- - All other arguments of type `string`/`number` are converted to `Text` nodes and appended to the element being
931
- created or modified.
932
- - All other arguments of type `HArgs` are passed to `s` and the results are appended to the element being created or
933
- modified.
916
+ - All other arguments of type `string`/`number` are converted to `Text` nodes and appended to the element being created or modified.
917
+ - All other arguments of type `HArgs` are passed to `s` and the results are appended to the element being created or modified.
934
918
 
935
919
  ### svgUse
936
920
 
@@ -951,8 +935,7 @@ const uuid1: ({ date, node }?: {
951
935
 
952
936
  A helper that generates a UUID v1 identifier (with a creation timestamp).
953
937
 
954
- - The optional `node` parameter should have the format `/^[0123456789abcdef]+$/`.
955
- Its value will be trimmed to last 12 characters and left padded with zeros.
938
+ - The optional `node` parameter should have the format `/^[0123456789abcdef]+$/`. Its value will be trimmed to last 12 characters and left padded with zeros.
956
939
 
957
940
  #### Usage Examples
958
941