@jackens/nnn 2023.12.3 → 2023.12.5

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/h.d.ts +6 -2
  2. package/package.json +1 -1
  3. package/readme.md +94 -94
package/h.d.ts CHANGED
@@ -23,7 +23,9 @@ export type HArgs1 = Record<string, any> | null | undefined | Node | string | nu
23
23
  * - All other arguments of type `string`/`number` are converted to `Text` nodes and appended to the element being created or modified.
24
24
  * - All other arguments of type `HArgs` are passed to `h` and the results are appended to the element being created or modified.
25
25
  */
26
- export function h<T extends keyof HTMLElementTagNameMap>(tag: T, ...args1: HArgs1[]): HTMLElementTagNameMap[T];,export function h<N extends Node>(node: N, ...args1: HArgs1[]): N;,export function h(tagOrNode: string | Node, ...args1: HArgs1[]): Node;
26
+ export function h<T extends keyof HTMLElementTagNameMap>(tag: T, ...args1: HArgs1[]): HTMLElementTagNameMap[T];
27
+ export function h<N extends Node>(node: N, ...args1: HArgs1[]): N;
28
+ export function h(tagOrNode: string | Node, ...args1: HArgs1[]): Node;
27
29
 
28
30
  /**
29
31
  * A lightweight [HyperScript](https://github.com/hyperhype/hyperscript)-style helper for creating and modifying `SVGElement`s (see also `h`).
@@ -40,6 +42,8 @@ export function h<T extends keyof HTMLElementTagNameMap>(tag: T, ...args1: HArgs
40
42
  * - All other arguments of type `string`/`number` are converted to `Text` nodes and appended to the element being created or modified.
41
43
  * - All other arguments of type `HArgs` are passed to `s` and the results are appended to the element being created or modified.
42
44
  */
43
- export function s<T extends keyof SVGElementTagNameMap>(tag: T, ...args1: HArgs1[]): SVGElementTagNameMap[T];,export function s<N extends Node>(node: N, ...args1: HArgs1[]): N;,export function s(tagOrNode: string | Node, ...args1: HArgs1[]): Node;
45
+ export function s<T extends keyof SVGElementTagNameMap>(tag: T, ...args1: HArgs1[]): SVGElementTagNameMap[T];
46
+ export function s<N extends Node>(node: N, ...args1: HArgs1[]): N;
47
+ export function s(tagOrNode: string | Node, ...args1: HArgs1[]): Node;
44
48
 
45
49
  export const tests: Record<string, () => void>;
package/package.json CHANGED
@@ -40,5 +40,5 @@
40
40
  "types": "nnn.d.ts",
41
41
  "name": "@jackens/nnn",
42
42
  "type": "module",
43
- "version": "2023.12.3"
43
+ "version": "2023.12.5"
44
44
  }
package/readme.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # nnn
2
2
 
3
- Jackens’ JavaScript helpers (version: 2023.12.3).
3
+ Jackens’ JavaScript helpers.
4
4
 
5
5
  ## Installation
6
6
 
@@ -30,33 +30,33 @@ import { «something» } from './node_modules/@jackens/nnn/nnn.js'
30
30
 
31
31
  ## Exports
32
32
 
33
- - `EscapeMap`: The type of arguments of the `escapeValues` and `escape` helpers.
34
- - `HArgs`: The type of arguments of the `h` and `s` helpers.
35
- - `HArgs1`: The type of arguments of the `h` and `s` helpers.
36
- - `JcssNode`: The type of arguments of the `jcss` helper.
37
- - `JcssRoot`: The type of arguments of the `jcss` helper.
38
- - `chartable`: A helper for creating a chart based on a table (conf. <https://jackens.github.io/nnn/chartable/>).
39
- - `eq`: A helper that checks equality of the given arguments.
40
- - `escape`: A generic helper for escaping `values` by given `escapeMap` (in *TemplateStrings* flavor).
41
- - `escapeValues`: A generic helper for escaping `values` by given `escapeMap`.
42
- - `fixTypography`: A helper that implements typographic corrections specific to Polish typography.
43
- - `h`: A lightweight [HyperScript](https://github.com/hyperhype/hyperscript)-style helper for creating and modifying `HTMLElement`s (see also `s`).
44
- - `has`: A replacement for the `in` operator (not to be confused with the `for-in` loop) that works properly.
45
- - `is`: A helper that checks if the given argument is of a certain type.
46
- - `jcss`: A simple CSS-in-JS helper.
47
- - `jsOnParse`: `JSON.parse` with “JavaScript turned on”.
48
- - `locale`: Language translations helper.
49
- - `nanolight`: A generic helper for syntax highlighting (see also `nanolightJs`).
50
- - `nanolightJs`: A helper for highlighting JavaScript.
51
- - `plUral`: A helper for choosing the correct singular and plural.
52
- - `pro`: A helper that protects calls to nested properties by a `Proxy` that initializes non-existent values with an empty object.
53
- - `refsInfo`: A helper that provides information about the given `refs`.
54
- - `s`: A lightweight [HyperScript](https://github.com/hyperhype/hyperscript)-style helper for creating and modifying `SVGElement`s (see also `h`).
55
- - `uuid1`: A helper that generates a UUID v1 identifier (with a creation timestamp).
56
-
57
- <a href="#EscapeMap" id="EscapeMap" name="EscapeMap">
58
- <h3>EscapeMap</h3>
59
- </a>
33
+ - [EscapeMap](#EscapeMap): The type of arguments of the `escapeValues` and `escape` helpers.
34
+ - [HArgs](#HArgs): The type of arguments of the `h` and `s` helpers.
35
+ - [HArgs1](#HArgs1): The type of arguments of the `h` and `s` helpers.
36
+ - [JcssNode](#JcssNode): The type of arguments of the `jcss` helper.
37
+ - [JcssRoot](#JcssRoot): The type of arguments of the `jcss` helper.
38
+ - [chartable](#chartable): A helper for creating a chart based on a table (conf. <https://jackens.github.io/nnn/chartable/>).
39
+ - [eq](#eq): A helper that checks equality of the given arguments.
40
+ - [escape](#escape): A generic helper for escaping `values` by given `escapeMap` (in *TemplateStrings* flavor).
41
+ - [escapeValues](#escapeValues): A generic helper for escaping `values` by given `escapeMap`.
42
+ - [fixTypography](#fixTypography): A helper that implements typographic corrections specific to Polish typography.
43
+ - [h](#h): A lightweight [HyperScript](https://github.com/hyperhype/hyperscript)-style helper for creating and modifying `HTMLElement`s (see also `s`).
44
+ - [has](#has): A replacement for the `in` operator (not to be confused with the `for-in` loop) that works properly.
45
+ - [is](#is): A helper that checks if the given argument is of a certain type.
46
+ - [jcss](#jcss): A simple CSS-in-JS helper.
47
+ - [jsOnParse](#jsOnParse): `JSON.parse` with “JavaScript turned on”.
48
+ - [locale](#locale): Language translations helper.
49
+ - [nanolight](#nanolight): A generic helper for syntax highlighting (see also `nanolightJs`).
50
+ - [nanolightJs](#nanolightJs): A helper for highlighting JavaScript.
51
+ - [plUral](#plUral): A helper for choosing the correct singular and plural.
52
+ - [pro](#pro): A helper that protects calls to nested properties by a `Proxy` that initializes non-existent values with an empty object.
53
+ - [refsInfo](#refsInfo): A helper that provides information about the given `refs`.
54
+ - [s](#s): A lightweight [HyperScript](https://github.com/hyperhype/hyperscript)-style helper for creating and modifying `SVGElement`s (see also `h`).
55
+ - [uuid1](#uuid1): A helper that generates a UUID v1 identifier (with a creation timestamp).
56
+
57
+ <a href="#EscapeMap" id="EscapeMap" name="EscapeMap"></a>
58
+
59
+ ### EscapeMap
60
60
 
61
61
  ```ts
62
62
  export type EscapeMap = Map<any, (value?: any) => string>;
@@ -64,9 +64,9 @@ export type EscapeMap = Map<any, (value?: any) => string>;
64
64
 
65
65
  The type of arguments of the `escapeValues` and `escape` helpers.
66
66
 
67
- <a href="#HArgs" id="HArgs" name="HArgs">
68
- <h3>HArgs</h3>
69
- </a>
67
+ <a href="#HArgs" id="HArgs" name="HArgs"></a>
68
+
69
+ ### HArgs
70
70
 
71
71
  ```ts
72
72
  export type HArgs = [string | Node, ...HArgs1[]];
@@ -74,9 +74,9 @@ export type HArgs = [string | Node, ...HArgs1[]];
74
74
 
75
75
  The type of arguments of the `h` and `s` helpers.
76
76
 
77
- <a href="#HArgs1" id="HArgs1" name="HArgs1">
78
- <h3>HArgs1</h3>
79
- </a>
77
+ <a href="#HArgs1" id="HArgs1" name="HArgs1"></a>
78
+
79
+ ### HArgs1
80
80
 
81
81
  ```ts
82
82
  export type HArgs1 = Record<string, any> | null | undefined | Node | string | number | [string | Node, ...HArgs1[]];
@@ -84,9 +84,9 @@ export type HArgs1 = Record<string, any> | null | undefined | Node | string | nu
84
84
 
85
85
  The type of arguments of the `h` and `s` helpers.
86
86
 
87
- <a href="#JcssNode" id="JcssNode" name="JcssNode">
88
- <h3>JcssNode</h3>
89
- </a>
87
+ <a href="#JcssNode" id="JcssNode" name="JcssNode"></a>
88
+
89
+ ### JcssNode
90
90
 
91
91
  ```ts
92
92
  export type JcssNode = {
@@ -96,9 +96,9 @@ export type JcssNode = {
96
96
 
97
97
  The type of arguments of the `jcss` helper.
98
98
 
99
- <a href="#JcssRoot" id="JcssRoot" name="JcssRoot">
100
- <h3>JcssRoot</h3>
101
- </a>
99
+ <a href="#JcssRoot" id="JcssRoot" name="JcssRoot"></a>
100
+
101
+ ### JcssRoot
102
102
 
103
103
  ```ts
104
104
  export type JcssRoot = Record<string, JcssNode>;
@@ -106,9 +106,9 @@ export type JcssRoot = Record<string, JcssNode>;
106
106
 
107
107
  The type of arguments of the `jcss` helper.
108
108
 
109
- <a href="#chartable" id="chartable" name="chartable">
110
- <h3>chartable</h3>
111
- </a>
109
+ <a href="#chartable" id="chartable" name="chartable"></a>
110
+
111
+ ### chartable
112
112
 
113
113
  ```ts
114
114
  export function chartable({ bottom, gapX, gapY, headerColumn, headerRow, id, left, maxY, right, singleScale, table, title, top, xLabels, zLabels, zxY }?: {
@@ -151,9 +151,9 @@ Options:
151
151
  - `zLabels`: data series labels
152
152
  - `zxY`: chart data
153
153
 
154
- <a href="#eq" id="eq" name="eq">
155
- <h3>eq</h3>
156
- </a>
154
+ <a href="#eq" id="eq" name="eq"></a>
155
+
156
+ ### eq
157
157
 
158
158
  ```ts
159
159
  export function eq(x: any, y: any): boolean;
@@ -195,9 +195,9 @@ console.assert(!eq(
195
195
  ))
196
196
  ```
197
197
 
198
- <a href="#escape" id="escape" name="escape">
199
- <h3>escape</h3>
200
- </a>
198
+ <a href="#escape" id="escape" name="escape"></a>
199
+
200
+ ### escape
201
201
 
202
202
  ```ts
203
203
  export function escape(escapeMap: EscapeMap, template: TemplateStringsArray, ...values: any[]): string;
@@ -232,9 +232,9 @@ const expected = `
232
232
  console.assert(actual === expected)
233
233
  ```
234
234
 
235
- <a href="#escapeValues" id="escapeValues" name="escapeValues">
236
- <h3>escapeValues</h3>
237
- </a>
235
+ <a href="#escapeValues" id="escapeValues" name="escapeValues"></a>
236
+
237
+ ### escapeValues
238
238
 
239
239
  ```ts
240
240
  export function escapeValues(escapeMap: EscapeMap, values: any[]): string[];
@@ -242,9 +242,9 @@ export function escapeValues(escapeMap: EscapeMap, values: any[]): string[];
242
242
 
243
243
  A generic helper for escaping `values` by given `escapeMap`.
244
244
 
245
- <a href="#fixTypography" id="fixTypography" name="fixTypography">
246
- <h3>fixTypography</h3>
247
- </a>
245
+ <a href="#fixTypography" id="fixTypography" name="fixTypography"></a>
246
+
247
+ ### fixTypography
248
248
 
249
249
  ```ts
250
250
  export function fixTypography(node: Node): void;
@@ -264,9 +264,9 @@ console.assert(p.innerHTML ===
264
264
  '(zob. https://\u200Bpl.\u200Bwikipedia.\u200Borg/\u200Bwiki/\u200BPangram).')
265
265
  ```
266
266
 
267
- <a href="#h" id="h" name="h">
268
- <h3>h</h3>
269
- </a>
267
+ <a href="#h" id="h" name="h"></a>
268
+
269
+ ### h
270
270
 
271
271
  ```ts
272
272
  export function h<T extends keyof HTMLElementTagNameMap>(tag: T, ...args1: HArgs1[]): HTMLElementTagNameMap[T];
@@ -356,9 +356,9 @@ h(div, { $key: { two: 2 } })
356
356
  console.assert(eq(div.key, { one: 1, two: 2 }))
357
357
  ```
358
358
 
359
- <a href="#has" id="has" name="has">
360
- <h3>has</h3>
361
- </a>
359
+ <a href="#has" id="has" name="has"></a>
360
+
361
+ ### has
362
362
 
363
363
  ```ts
364
364
  export function has(key: any, ref: any): boolean;
@@ -397,9 +397,9 @@ console.assert(typeError instanceof TypeError) // Cannot use 'in' operator to se
397
397
  console.assert(!has('key', null))
398
398
  ```
399
399
 
400
- <a href="#is" id="is" name="is">
401
- <h3>is</h3>
402
- </a>
400
+ <a href="#is" id="is" name="is"></a>
401
+
402
+ ### is
403
403
 
404
404
  ```ts
405
405
  export const is: {
@@ -459,9 +459,9 @@ console.assert(is(Object, fakeFooBar))
459
459
  console.assert(!iz(Object, fakeFooBar))
460
460
  ```
461
461
 
462
- <a href="#jcss" id="jcss" name="jcss">
463
- <h3>jcss</h3>
464
- </a>
462
+ <a href="#jcss" id="jcss" name="jcss"></a>
463
+
464
+ ### jcss
465
465
 
466
466
  ```ts
467
467
  export function jcss(root: JcssRoot, splitter?: string): string;
@@ -673,9 +673,9 @@ const expected = `
673
673
  console.assert(actual === expected)
674
674
  ```
675
675
 
676
- <a href="#jsOnParse" id="jsOnParse" name="jsOnParse">
677
- <h3>jsOnParse</h3>
678
- </a>
676
+ <a href="#jsOnParse" id="jsOnParse" name="jsOnParse"></a>
677
+
678
+ ### jsOnParse
679
679
 
680
680
  ```ts
681
681
  export function jsOnParse(handlers: Record<string, Function>, text: string): any;
@@ -740,9 +740,9 @@ const expected = [
740
740
  console.assert(eq(actual, expected))
741
741
  ```
742
742
 
743
- <a href="#locale" id="locale" name="locale">
744
- <h3>locale</h3>
745
- </a>
743
+ <a href="#locale" id="locale" name="locale"></a>
744
+
745
+ ### locale
746
746
 
747
747
  ```ts
748
748
  export function locale(locales: Record<string, Record<string, string | Record<string, string>>>, defaultLanguage: string, languages?: readonly string[]): (text?: string | undefined, version?: string | undefined) => string;
@@ -775,9 +775,9 @@ console.assert(_('toString') === 'toString')
775
775
  console.assert(_('toString', 'undefined_version') === 'toString')
776
776
  ```
777
777
 
778
- <a href="#nanolight" id="nanolight" name="nanolight">
779
- <h3>nanolight</h3>
780
- </a>
778
+ <a href="#nanolight" id="nanolight" name="nanolight"></a>
779
+
780
+ ### nanolight
781
781
 
782
782
  ```ts
783
783
  export function nanolight(pattern: RegExp, highlighters: ((chunk: string, index: number) => import('./h.js').HArgs)[], code: string): import("./h.js").HArgs[];
@@ -785,9 +785,9 @@ export function nanolight(pattern: RegExp, highlighters: ((chunk: string, index:
785
785
 
786
786
  A generic helper for syntax highlighting (see also `nanolightJs`).
787
787
 
788
- <a href="#nanolightJs" id="nanolightJs" name="nanolightJs">
789
- <h3>nanolightJs</h3>
790
- </a>
788
+ <a href="#nanolightJs" id="nanolightJs" name="nanolightJs"></a>
789
+
790
+ ### nanolightJs
791
791
 
792
792
  ```ts
793
793
  export const nanolightJs: (code?: string | undefined) => import("./h.js").HArgs[];
@@ -804,9 +804,9 @@ console.assert(h('pre', ['code', ...nanolightJs(codeJs)]).outerHTML ===
804
804
  '<pre><code><b>const</b> <i>answerToLifeTheUniverseAndEverything</i> <b>=</b> <u>42</u></code></pre>')
805
805
  ```
806
806
 
807
- <a href="#plUral" id="plUral" name="plUral">
808
- <h3>plUral</h3>
809
- </a>
807
+ <a href="#plUral" id="plUral" name="plUral"></a>
808
+
809
+ ### plUral
810
810
 
811
811
  ```ts
812
812
  export function plUral(singular: string, plural2: string, plural5: string, value: number): string;
@@ -832,9 +832,9 @@ console.assert(car(17) === 'cars')
832
832
  console.assert(car(42) === 'cars')
833
833
  ```
834
834
 
835
- <a href="#pro" id="pro" name="pro">
836
- <h3>pro</h3>
837
- </a>
835
+ <a href="#pro" id="pro" name="pro"></a>
836
+
837
+ ### pro
838
838
 
839
839
  ```ts
840
840
  export function pro(ref: any): any;
@@ -872,9 +872,9 @@ pro(ref).one.two.three.four = 1234
872
872
  console.assert(eq(ref, { one: { two: { three: { four: 1234 } } } }))
873
873
  ```
874
874
 
875
- <a href="#refsInfo" id="refsInfo" name="refsInfo">
876
- <h3>refsInfo</h3>
877
- </a>
875
+ <a href="#refsInfo" id="refsInfo" name="refsInfo"></a>
876
+
877
+ ### refsInfo
878
878
 
879
879
  ```ts
880
880
  export function refsInfo(...refs: any[]): [string, string, string[]][];
@@ -917,9 +917,9 @@ const browserFingerprint = () => {
917
917
  console.log(browserFingerprint())
918
918
  ```
919
919
 
920
- <a href="#s" id="s" name="s">
921
- <h3>s</h3>
922
- </a>
920
+ <a href="#s" id="s" name="s"></a>
921
+
922
+ ### s
923
923
 
924
924
  ```ts
925
925
  export function s<T extends keyof SVGElementTagNameMap>(tag: T, ...args1: HArgs1[]): SVGElementTagNameMap[T];
@@ -941,9 +941,9 @@ A lightweight [HyperScript](https://github.com/hyperhype/hyperscript)-style help
941
941
  - All other arguments of type `string`/`number` are converted to `Text` nodes and appended to the element being created or modified.
942
942
  - All other arguments of type `HArgs` are passed to `s` and the results are appended to the element being created or modified.
943
943
 
944
- <a href="#uuid1" id="uuid1" name="uuid1">
945
- <h3>uuid1</h3>
946
- </a>
944
+ <a href="#uuid1" id="uuid1" name="uuid1"></a>
945
+
946
+ ### uuid1
947
947
 
948
948
  ```ts
949
949
  export function uuid1({ date, node }?: {