@jackens/nnn 2024.2.20 → 2024.2.24

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.
package/readme.md CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  Jackens’ JavaScript helpers.
4
4
 
5
- <sub>Version: <code class="version">2024.2.20</code></sub>
5
+ <sub>Version: <code class="version">2024.2.24</code></sub>
6
6
 
7
7
  ## Installation
8
8
 
@@ -61,7 +61,7 @@ import { «something» } from './node_modules/@jackens/nnn/nnn.js'
61
61
  ### EscapeMap
62
62
 
63
63
  ```ts
64
- export type EscapeMap = Map<any, (value?: any) => string>;
64
+ type EscapeMap = Map<any, (value?: any) => string>;
65
65
  ```
66
66
 
67
67
  The type of arguments of the `escapeValues` and `escape` helpers.
@@ -69,7 +69,7 @@ The type of arguments of the `escapeValues` and `escape` helpers.
69
69
  ### HArgs
70
70
 
71
71
  ```ts
72
- export type HArgs = [string | Node, ...HArgs1[]];
72
+ type HArgs = [string | Node, ...HArgs1[]];
73
73
  ```
74
74
 
75
75
  The type of arguments of the `h` and `s` helpers.
@@ -77,7 +77,7 @@ The type of arguments of the `h` and `s` helpers.
77
77
  ### HArgs1
78
78
 
79
79
  ```ts
80
- export type HArgs1 = Partial<Record<PropertyKey, any>> | null | undefined | Node | string | number | [string | Node, ...HArgs1[]];
80
+ type HArgs1 = Partial<Record<PropertyKey, any>> | null | undefined | Node | string | number | HArgs;
81
81
  ```
82
82
 
83
83
  The type of arguments of the `h` and `s` helpers.
@@ -85,7 +85,7 @@ The type of arguments of the `h` and `s` helpers.
85
85
  ### JcssNode
86
86
 
87
87
  ```ts
88
- export type JcssNode = {
88
+ type JcssNode = {
89
89
  [attributeOrSelector: string]: string | number | JcssNode | undefined;
90
90
  };
91
91
  ```
@@ -95,7 +95,7 @@ The type of arguments of the `jcss` helper.
95
95
  ### JcssRoot
96
96
 
97
97
  ```ts
98
- export type JcssRoot = Partial<Record<PropertyKey, JcssNode>>;
98
+ type JcssRoot = Partial<Record<PropertyKey, JcssNode>>;
99
99
  ```
100
100
 
101
101
  The type of arguments of the `jcss` helper.
@@ -103,7 +103,7 @@ The type of arguments of the `jcss` helper.
103
103
  ### chartable
104
104
 
105
105
  ```ts
106
- export function chartable({ table, headerColumn, xGap, xLabelsMinHeight, xLabelsRotate, xReverse, yGap, yLabelsLeftMinWidth, yLabelsRightMinWidth, yMax, zLabelsMinWidth, zyMappings }: {
106
+ const chartable: ({ table, headerColumn, xGap, xLabelsMinHeight, xLabelsRotate, xReverse, yGap, yLabelsLeftMinWidth, yLabelsRightMinWidth, yMax, zLabelsMinWidth, zyMappings }: {
107
107
  table: HTMLTableElement;
108
108
  headerColumn?: boolean | undefined;
109
109
  xGap?: number | undefined;
@@ -116,7 +116,7 @@ export function chartable({ table, headerColumn, xGap, xLabelsMinHeight, xLabels
116
116
  yMax?: number | undefined;
117
117
  zLabelsMinWidth?: number | undefined;
118
118
  zyMappings?: [(label: string) => number, (value: number) => string][] | undefined;
119
- }): SVGSVGElement;
119
+ }) => SVGSVGElement;
120
120
  ```
121
121
 
122
122
  A helper for creating a chart based on a table (conf. <https://jackens.github.io/nnn/chartable/>).
@@ -138,7 +138,7 @@ Options:
138
138
  ### eq
139
139
 
140
140
  ```ts
141
- export function eq(x: any, y: any): boolean;
141
+ const eq: (x: any, y: any) => boolean;
142
142
  ```
143
143
 
144
144
  A helper that checks equality of the given arguments.
@@ -146,41 +146,41 @@ A helper that checks equality of the given arguments.
146
146
  #### Usage Examples
147
147
 
148
148
  ```js
149
- expect(eq(true, true)).to.be.true
150
- expect(eq(NaN, NaN)).to.be.true
151
- expect(eq(null, undefined)).to.be.false
152
- expect(eq(42, 42)).to.be.true
153
- expect(eq(42, new Number(42))).to.be.true
154
- expect(eq(42, Number(42))).to.be.true
155
- expect(eq(new Number(42), Number(42))).to.be.true
156
- expect(eq(42, '42')).to.be.false
157
- expect(eq('42', '42')).to.be.true
158
- expect(eq('42', new String('42'))).to.be.true
159
- expect(eq('42', String('42'))).to.be.true
160
- expect(eq(String('42'), new String('42'))).to.be.true
161
- expect(eq(/42/, /42/)).to.be.true
162
- expect(eq(/42/, /42/g)).to.be.false
163
- expect(eq(new Date(42), new Date(42))).to.be.true
164
- expect(eq(new Date(), new Date(42))).to.be.false
165
- expect(eq({ j: '42', c: 42 }, { c: 42, j: '42' })).to.be.true
166
- expect(eq([42, '42'], [42, '42'])).to.be.true
167
- expect(eq(new Set(['42', 42]), new Set([42, '42']))).to.be.true
168
- expect(eq(new Set(['42', 42]), new Set([42]))).to.be.false
169
- expect(eq(new Set([42, undefined]), new Set([42]))).to.be.false
149
+ expect(eq(true, true)).toBeTrue()
150
+ expect(eq(NaN, NaN)).toBeTrue()
151
+ expect(eq(null, undefined)).toBeFalse()
152
+ expect(eq(42, 42)).toBeTrue()
153
+ expect(eq(42, new Number(42))).toBeTrue()
154
+ expect(eq(42, Number(42))).toBeTrue()
155
+ expect(eq(new Number(42), Number(42))).toBeTrue()
156
+ expect(eq(42, '42')).toBeFalse()
157
+ expect(eq('42', '42')).toBeTrue()
158
+ expect(eq('42', new String('42'))).toBeTrue()
159
+ expect(eq('42', String('42'))).toBeTrue()
160
+ expect(eq(String('42'), new String('42'))).toBeTrue()
161
+ expect(eq(/42/, /42/)).toBeTrue()
162
+ expect(eq(/42/, /42/g)).toBeFalse()
163
+ expect(eq(new Date(42), new Date(42))).toBeTrue()
164
+ expect(eq(new Date(), new Date(42))).toBeFalse()
165
+ expect(eq({ j: '42', c: 42 }, { c: 42, j: '42' })).toBeTrue()
166
+ expect(eq([42, '42'], [42, '42'])).toBeTrue()
167
+ expect(eq(new Set(['42', 42]), new Set([42, '42']))).toBeTrue()
168
+ expect(eq(new Set(['42', 42]), new Set([42]))).toBeFalse()
169
+ expect(eq(new Set([42, undefined]), new Set([42]))).toBeFalse()
170
170
  expect(eq(
171
171
  new Map([[{ j: 42 }, { J: '42' }], [{ c: 42 }, { C: '42' }]]),
172
172
  new Map([[{ c: 42 }, { C: '42' }], [{ j: 42 }, { J: '42' }]])
173
- )).to.be.true
173
+ )).toBeTrue()
174
174
  expect(eq(
175
175
  new Map([[{ j: 42 }, { J: '42' }], [{ c: 42 }, { C: '42' }]]),
176
176
  new Map([[{ j: '42' }, { J: 42 }], [{ c: '42' }, { C: 42 }]])
177
- )).to.be.false
177
+ )).toBeFalse()
178
178
  ```
179
179
 
180
180
  ### escape
181
181
 
182
182
  ```ts
183
- export function escape(escapeMap: EscapeMap, template: TemplateStringsArray, ...values: any[]): string;
183
+ const escape: (escapeMap: EscapeMap, template: TemplateStringsArray, ...values: any[]) => string;
184
184
  ```
185
185
 
186
186
  A generic helper for escaping `values` by given `escapeMap` (in *TemplateStrings* flavor).
@@ -188,13 +188,13 @@ A generic helper for escaping `values` by given `escapeMap` (in *TemplateStrings
188
188
  #### Usage Examples
189
189
 
190
190
  ```js
191
- const /** @type {EscapeMap} */ escapeMap = new Map([
191
+ const escapeMap: EscapeMap = new Map([
192
192
  [undefined, () => 'NULL'],
193
- [Array, (/** @type {any[]} */ values) => escapeValues(escapeMap, values).join(', ')],
194
- [Boolean, (/** @type {boolean} */ value) => `b'${+value}'`],
195
- [Date, (/** @type {Date} */ value) => `'${value.toISOString().replace(/^(.+)T(.+)\..*$/, '$1 $2')}'`],
196
- [Number, (/** @type {number} */ value) => `${value}`],
197
- [String, (/** @type {string} */ value) => `'${value.replace(/'/g, "''")}'`]
193
+ [Array, (values: any[]) => escapeValues(escapeMap, values).join(', ')],
194
+ [Boolean, (value: boolean) => `b'${+value}'`],
195
+ [Date, (value: Date) => `'${value.toISOString().replace(/^(.+)T(.+)\..*$/, '$1 $2')}'`],
196
+ [Number, (value: number) => `${value}`],
197
+ [String, (value: string) => `'${value.replace(/'/g, "''")}'`]
198
198
  ])
199
199
 
200
200
  const sql = escape.bind(null, escapeMap)
@@ -209,13 +209,13 @@ const expected = `
209
209
  FROM table_name
210
210
  WHERE column_name IN (b'1', NULL, NULL, 42, '42', '4''2', NULL, '1980-03-31 04:30:00')`
211
211
 
212
- expect(actual).to.deep.equal(expected)
212
+ expect(actual).toStrictEqual(expected)
213
213
  ```
214
214
 
215
215
  ### escapeValues
216
216
 
217
217
  ```ts
218
- export function escapeValues(escapeMap: EscapeMap, values: any[]): string[];
218
+ const escapeValues: (escapeMap: EscapeMap, values: any[]) => string[];
219
219
  ```
220
220
 
221
221
  A generic helper for escaping `values` by given `escapeMap`.
@@ -223,7 +223,7 @@ A generic helper for escaping `values` by given `escapeMap`.
223
223
  ### fixTypography
224
224
 
225
225
  ```ts
226
- export function fixTypography(node: Node): void;
226
+ const fixTypography: (node: Node) => void;
227
227
  ```
228
228
 
229
229
  A helper that implements typographic corrections specific to Polish typography.
@@ -235,7 +235,7 @@ const p = h('p', 'Pchnąć w tę łódź jeża lub ośm skrzyń fig (zob. https:
235
235
 
236
236
  fixTypography(p)
237
237
 
238
- expect(p.innerHTML).to.deep.equal(
238
+ expect(p.innerHTML).toStrictEqual(
239
239
  'Pchnąć <span style="white-space:nowrap">w </span>tę łódź jeża lub ośm skrzyń fig ' +
240
240
  '(zob. https://\u200Bpl.\u200Bwikipedia.\u200Borg/\u200Bwiki/\u200BPangram).')
241
241
  ```
@@ -243,9 +243,11 @@ expect(p.innerHTML).to.deep.equal(
243
243
  ### h
244
244
 
245
245
  ```ts
246
- export function h<T extends keyof HTMLElementTagNameMap>(tag: T, ...args1: HArgs1[]): HTMLElementTagNameMap[T];
247
- export function h<N extends Node>(node: N, ...args1: HArgs1[]): N;
248
- export function h(tagOrNode: string | Node, ...args1: HArgs1[]): Node;
246
+ const h: {
247
+ <T extends keyof HTMLElementTagNameMap>(tag: T, ...args1: HArgs1[]): HTMLElementTagNameMap[T];
248
+ <N extends Node>(node: N, ...args1: HArgs1[]): N;
249
+ (tagOrNode: string | Node, ...args1: HArgs1[]): Node;
250
+ };
249
251
  ```
250
252
 
251
253
  A lightweight [HyperScript](https://github.com/hyperhype/hyperscript)-style helper for creating and modifying `HTMLElement`s (see also `s`).
@@ -267,73 +269,73 @@ A lightweight [HyperScript](https://github.com/hyperhype/hyperscript)-style help
267
269
  ```js
268
270
  const b = h('b')
269
271
 
270
- expect(b.outerHTML).to.deep.equal('<b></b>')
272
+ expect(b.outerHTML).toStrictEqual('<b></b>')
271
273
 
272
274
  const i = h('i', 'text')
273
275
 
274
276
  h(b, i)
275
277
 
276
- expect(i.outerHTML).to.deep.equal('<i>text</i>')
277
- expect(b.outerHTML).to.deep.equal('<b><i>text</i></b>')
278
+ expect(i.outerHTML).toStrictEqual('<i>text</i>')
279
+ expect(b.outerHTML).toStrictEqual('<b><i>text</i></b>')
278
280
 
279
281
  h(i, { $className: 'some class' })
280
282
 
281
- expect(i.outerHTML).to.deep.equal('<i class="some class">text</i>')
282
- expect(b.outerHTML).to.deep.equal('<b><i class="some class">text</i></b>')
283
+ expect(i.outerHTML).toStrictEqual('<i class="some class">text</i>')
284
+ expect(b.outerHTML).toStrictEqual('<b><i class="some class">text</i></b>')
283
285
  ```
284
286
 
285
287
  ```js
286
- expect(h('span', 'text').outerHTML).to.deep.equal('<span>text</span>')
287
- expect(h('span', { $innerText: 'text' }).outerHTML).to.deep.equal('<span>text</span>')
288
+ expect(h('span', 'text').outerHTML).toStrictEqual('<span>text</span>')
289
+ expect(h('span', { $innerText: 'text' }).outerHTML).toStrictEqual('<span>text</span>')
288
290
  ```
289
291
 
290
292
  ```js
291
293
  expect(h('div', { style: 'margin:0;padding:0' }).outerHTML)
292
- .to.deep.equal('<div style="margin:0;padding:0"></div>')
294
+ .toStrictEqual('<div style="margin:0;padding:0"></div>')
293
295
  expect(h('div', { $style: 'margin:0;padding:0' }).outerHTML)
294
- .to.deep.equal('<div style="margin: 0px; padding: 0px;"></div>')
296
+ .toStrictEqual('<div style="margin: 0px; padding: 0px;"></div>')
295
297
  expect(h('div', { $style: { margin: 0, padding: 0 } }).outerHTML)
296
- .to.deep.equal('<div style="margin: 0px; padding: 0px;"></div>')
298
+ .toStrictEqual('<div style="margin: 0px; padding: 0px;"></div>')
297
299
  ```
298
300
 
299
301
  ```js
300
302
  const input1 = h('input', { value: 42 })
301
303
  const input2 = h('input', { $value: '42' })
302
304
 
303
- expect(input1.value).to.deep.equal('42')
304
- expect(input2.value).to.deep.equal('42')
305
+ expect(input1.value).toStrictEqual('42')
306
+ expect(input2.value).toStrictEqual('42')
305
307
 
306
- expect(input1.outerHTML).to.deep.equal('<input value="42">')
307
- expect(input2.outerHTML).to.deep.equal('<input>')
308
+ expect(input1.outerHTML).toStrictEqual('<input value="42">')
309
+ expect(input2.outerHTML).toStrictEqual('<input>')
308
310
 
309
311
  const checkbox1 = h('input', { type: 'checkbox', checked: true })
310
312
  const checkbox2 = h('input', { type: 'checkbox', $checked: true })
311
313
 
312
- expect(checkbox1.checked).to.be.true
313
- expect(checkbox2.checked).to.be.true
314
+ expect(checkbox1.checked).toBeTrue()
315
+ expect(checkbox2.checked).toBeTrue()
314
316
 
315
- expect(checkbox1.outerHTML).to.deep.equal('<input type="checkbox" checked="">')
316
- expect(checkbox2.outerHTML).to.deep.equal('<input type="checkbox">')
317
+ expect(checkbox1.outerHTML).toStrictEqual('<input type="checkbox" checked="">')
318
+ expect(checkbox2.outerHTML).toStrictEqual('<input type="checkbox">')
317
319
  ```
318
320
 
319
321
  ```js
320
322
  const div = h('div')
321
323
 
322
- expect(div.key).to.be.undefined
324
+ expect(div.key).toBeUndefined()
323
325
 
324
326
  h(div, { $key: { one: 1 } })
325
327
 
326
- expect(div.key).to.deep.equal({ one: 1 })
328
+ expect(div.key).toStrictEqual({ one: 1 })
327
329
 
328
330
  h(div, { $key: { two: 2 } })
329
331
 
330
- expect(div.key).to.deep.equal({ one: 1, two: 2 })
332
+ expect(div.key).toStrictEqual({ one: 1, two: 2 })
331
333
  ```
332
334
 
333
335
  ### has
334
336
 
335
337
  ```ts
336
- export function has(key: any, ref: any): boolean;
338
+ const has: (key: any, ref: any) => boolean;
337
339
  ```
338
340
 
339
341
  A replacement for the `in` operator (not to be confused with the `for-in` loop) that works properly.
@@ -343,17 +345,17 @@ A replacement for the `in` operator (not to be confused with the `for-in` loop)
343
345
  ```js
344
346
  const obj = { key: 'K', null: 'N' }
345
347
 
346
- expect('key' in obj).to.be.true
347
- expect(has('key', obj)).to.be.true
348
+ expect('key' in obj).toBeTrue()
349
+ expect(has('key', obj)).toBeTrue()
348
350
 
349
- expect('null' in obj).to.be.true
350
- expect(has('null', obj)).to.be.true
351
+ expect('null' in obj).toBeTrue()
352
+ expect(has('null', obj)).toBeTrue()
351
353
 
352
- expect(null in obj).to.be.true
353
- expect(has(null, obj)).to.be.false
354
+ expect(null in obj).toBeTrue()
355
+ expect(has(null, obj)).toBeFalse()
354
356
 
355
- expect('toString' in obj).to.be.true
356
- expect(has('toString', obj)).to.be.false
357
+ expect('toString' in obj).toBeTrue()
358
+ expect(has('toString', obj)).toBeFalse()
357
359
  ```
358
360
 
359
361
  ```js
@@ -366,21 +368,20 @@ try {
366
368
  }
367
369
 
368
370
  expect(typeError instanceof TypeError) // Cannot use 'in' operator to search for 'key' in null
369
- expect(has('key', null)).to.be.false
371
+ expect(has('key', null)).toBeFalse()
370
372
  ```
371
373
 
372
374
  ### is
373
375
 
374
376
  ```ts
375
- export const is: {
376
- (type: BigIntConstructor, arg: any): arg is bigint;
377
- (type: BooleanConstructor, arg: any): arg is boolean;
378
- (type: NumberConstructor, arg: any): arg is number;
379
- (type: StringConstructor, arg: any): arg is string;
380
- (type: SymbolConstructor, arg: any): arg is symbol;
381
- (type: undefined, arg: any): arg is null | undefined;
382
- <T extends abstract new (...args: any[]) => any>(type: T, arg: any): arg is InstanceType<T>;
383
- };
377
+ function is(type: BigIntConstructor, arg: any): arg is bigint;
378
+ function is(type: BooleanConstructor, arg: any): arg is boolean;
379
+ function is(type: NumberConstructor, arg: any): arg is number;
380
+ function is(type: ObjectConstructor, arg: any): arg is Partial<Record<PropertyKey, any>>;
381
+ function is(type: StringConstructor, arg: any): arg is string;
382
+ function is(type: SymbolConstructor, arg: any): arg is symbol;
383
+ function is(type: undefined, arg: any): arg is undefined | null;
384
+ function is<T extends abstract new (...args: any[]) => any>(type: T, arg: any): arg is InstanceType<T>;
384
385
  ```
385
386
 
386
387
  A helper that checks if the given argument is of a certain type.
@@ -388,51 +389,51 @@ A helper that checks if the given argument is of a certain type.
388
389
  #### Usage Examples
389
390
 
390
391
  ```js
391
- expect(is(Number, 42)).to.be.true
392
- expect(is(Number, Number(42))).to.be.true
393
- expect(is(Number, new Number(42))).to.be.true
394
- expect(is(Number, NaN)).to.be.true
395
- expect(is(String, '42')).to.be.true
396
- expect(is(String, String('42'))).to.be.true
397
- expect(is(String, new String('42'))).to.be.true
398
- expect(is(Symbol, Symbol('42'))).to.be.true
399
- expect(is(Symbol, Object(Symbol('42')))).to.be.true
400
- expect(is(undefined, undefined)).to.be.true
401
- expect(is(undefined, null)).to.be.true
402
- expect(is(Object, {})).to.be.true
403
- expect(is(Array, [])).to.be.true
404
- expect(is(RegExp, /42/)).to.be.true
405
- expect(is(Date, new Date(42))).to.be.true
406
- expect(is(Set, new Set(['42', 42]))).to.be.true
407
- expect(is(Map, new Map([[{ j: 42 }, { J: '42' }], [{ c: 42 }, { C: '42' }]]))).to.be.true
392
+ expect(is(Number, 42)).toBeTrue()
393
+ expect(is(Number, Number(42))).toBeTrue()
394
+ expect(is(Number, new Number(42))).toBeTrue()
395
+ expect(is(Number, NaN)).toBeTrue()
396
+ expect(is(String, '42')).toBeTrue()
397
+ expect(is(String, String('42'))).toBeTrue()
398
+ expect(is(String, new String('42'))).toBeTrue()
399
+ expect(is(Symbol, Symbol('42'))).toBeTrue()
400
+ expect(is(Symbol, Object(Symbol('42')))).toBeTrue()
401
+ expect(is(undefined, undefined)).toBeTrue()
402
+ expect(is(undefined, null)).toBeTrue()
403
+ expect(is(Object, {})).toBeTrue()
404
+ expect(is(Array, [])).toBeTrue()
405
+ expect(is(RegExp, /42/)).toBeTrue()
406
+ expect(is(Date, new Date(42))).toBeTrue()
407
+ expect(is(Set, new Set(['42', 42]))).toBeTrue()
408
+ expect(is(Map, new Map([[{ j: 42 }, { J: '42' }], [{ c: 42 }, { C: '42' }]]))).toBeTrue()
408
409
  ```
409
410
 
410
411
  ```js
411
- const iz = (/** @type {any} */ type, /** @type {any} */ arg) => ({}).toString.call(arg).slice(8, -1) === type?.name
412
+ const iz = (type: any, arg: any) => ({}).toString.call(arg).slice(8, -1) === type?.name
412
413
 
413
414
  class FooBar { }
414
415
 
415
- expect(is(FooBar, new FooBar())).to.be.true
416
- expect(iz(FooBar, new FooBar())).to.be.false
416
+ expect(is(FooBar, new FooBar())).toBeTrue()
417
+ expect(iz(FooBar, new FooBar())).toBeFalse()
417
418
 
418
- expect(is(Object, new FooBar())).to.be.false
419
- expect(iz(Object, new FooBar())).to.be.true
419
+ expect(is(Object, new FooBar())).toBeFalse()
420
+ expect(iz(Object, new FooBar())).toBeTrue()
420
421
 
421
422
  const fakeFooBar = {}
422
423
 
423
424
  fakeFooBar[Symbol.toStringTag] = FooBar.name
424
425
 
425
- expect(is(FooBar, fakeFooBar)).to.be.false
426
- expect(iz(FooBar, fakeFooBar)).to.be.true
426
+ expect(is(FooBar, fakeFooBar)).toBeFalse()
427
+ expect(iz(FooBar, fakeFooBar)).toBeTrue()
427
428
 
428
- expect(is(Object, fakeFooBar)).to.be.true
429
- expect(iz(Object, fakeFooBar)).to.be.false
429
+ expect(is(Object, fakeFooBar)).toBeTrue()
430
+ expect(iz(Object, fakeFooBar)).toBeFalse()
430
431
  ```
431
432
 
432
433
  ### jcss
433
434
 
434
435
  ```ts
435
- export function jcss(root: JcssRoot, splitter?: string): string;
436
+ const jcss: (root: JcssRoot, splitter?: string) => string;
436
437
  ```
437
438
 
438
439
  A simple CSS-in-JS helper.
@@ -470,7 +471,7 @@ a{
470
471
  padding:1
471
472
  }`.replace(/\n\s*/g, '')
472
473
 
473
- expect(actual).to.deep.equal(expected)
474
+ expect(actual).toStrictEqual(expected)
474
475
  ```
475
476
 
476
477
  ```js
@@ -498,7 +499,7 @@ a.b{
498
499
  padding:1
499
500
  }`.replace(/\n\s*/g, '')
500
501
 
501
- expect(actual).to.deep.equal(expected)
502
+ expect(actual).toStrictEqual(expected)
502
503
  ```
503
504
 
504
505
  ```js
@@ -573,7 +574,7 @@ div.c2{
573
574
  }
574
575
  }`.replace(/\n\s*/g, '')
575
576
 
576
- expect(actual).to.deep.equal(expected)
577
+ expect(actual).toStrictEqual(expected)
577
578
  ```
578
579
 
579
580
  ```js
@@ -596,7 +597,7 @@ a.b.d,a.c.d{
596
597
  margin:2
597
598
  }`.replace(/\n\s*/g, '')
598
599
 
599
- expect(actual).to.deep.equal(expected)
600
+ expect(actual).toStrictEqual(expected)
600
601
  ```
601
602
 
602
603
  ```js
@@ -617,7 +618,7 @@ const expected = `
617
618
  margin:2
618
619
  }`.replace(/\n\s*/g, '')
619
620
 
620
- expect(actual).to.deep.equal(expected)
621
+ expect(actual).toStrictEqual(expected)
621
622
  ```
622
623
 
623
624
  ```js
@@ -638,13 +639,13 @@ const expected = `
638
639
  margin:2
639
640
  }`.replace(/\n\s*/g, '')
640
641
 
641
- expect(actual).to.deep.equal(expected)
642
+ expect(actual).toStrictEqual(expected)
642
643
  ```
643
644
 
644
645
  ### jsOnParse
645
646
 
646
647
  ```ts
647
- export function jsOnParse(handlers: Partial<Record<PropertyKey, Function>>, text: string): any;
648
+ const jsOnParse: (handlers: Partial<Record<PropertyKey, Function>>, text: string) => any;
648
649
  ```
649
650
 
650
651
  `JSON.parse` with “JavaScript turned on”.
@@ -665,9 +666,10 @@ handlers['«handlerName»'](...«params»)
665
666
 
666
667
  ```js
667
668
  const handlers = {
668
- $hello: (/** @type {string} */ name) => `Hello ${name}!`,
669
+ $hello: (name: string) => `Hello ${name}!`,
669
670
  $foo: () => 'bar'
670
671
  }
672
+
671
673
  const actual = jsOnParse(handlers, `[
672
674
  {
673
675
  "$hello": ["World"]
@@ -688,6 +690,7 @@ const actual = jsOnParse(handlers, `[
688
690
  "two": 2
689
691
  }
690
692
  ]`)
693
+
691
694
  const expected = [
692
695
  'Hello World!',
693
696
  {
@@ -703,13 +706,13 @@ const expected = [
703
706
  }
704
707
  ]
705
708
 
706
- expect(actual).to.deep.equal(expected)
709
+ expect(actual).toStrictEqual(expected)
707
710
  ```
708
711
 
709
712
  ### locale
710
713
 
711
714
  ```ts
712
- export function locale(map: Partial<Record<PropertyKey, Partial<Record<PropertyKey, string>>>>, defaultVersion: string): (text: string, version?: string) => string;
715
+ const locale: (map: Partial<Record<PropertyKey, Partial<Record<PropertyKey, string>>>>, defaultVersion: string) => (text: string, version?: string) => string;
713
716
  ```
714
717
 
715
718
  Language translations helper.
@@ -722,24 +725,24 @@ const _ = locale({
722
725
  button: { Login: 'Zaloguj' }
723
726
  }, 'default')
724
727
 
725
- expect(_('Login')).to.deep.equal('Login')
726
- expect(_('Password')).to.deep.equal('Hasło')
728
+ expect(_('Login')).toStrictEqual('Login')
729
+ expect(_('Password')).toStrictEqual('Hasło')
727
730
 
728
- expect(_('Undefined text')).to.deep.equal('Undefined text')
731
+ expect(_('Undefined text')).toStrictEqual('Undefined text')
729
732
 
730
- expect(_('Login', 'button')).to.deep.equal('Zaloguj')
733
+ expect(_('Login', 'button')).toStrictEqual('Zaloguj')
731
734
 
732
- expect(_('Password', 'undefined_version')).to.deep.equal('Hasło')
733
- expect(_('Undefined text', 'undefined_version')).to.deep.equal('Undefined text')
735
+ expect(_('Password', 'undefined_version')).toStrictEqual('Hasło')
736
+ expect(_('Undefined text', 'undefined_version')).toStrictEqual('Undefined text')
734
737
 
735
- expect(_('toString')).to.deep.equal('toString')
736
- expect(_('toString', 'undefined_version')).to.deep.equal('toString')
738
+ expect(_('toString')).toStrictEqual('toString')
739
+ expect(_('toString', 'undefined_version')).toStrictEqual('toString')
737
740
  ```
738
741
 
739
742
  ### nanolight
740
743
 
741
744
  ```ts
742
- export function nanolight(pattern: RegExp, highlighters: ((chunk: string, index: number) => import('./h.js').HArgs1)[], code: string): import("./h.js").HArgs1[];
745
+ const nanolight: (pattern: RegExp, highlighters: ((chunk: string, index: number) => HArgs1)[], code: string) => HArgs1[];
743
746
  ```
744
747
 
745
748
  A generic helper for syntax highlighting (see also `nanolightJs`).
@@ -747,7 +750,7 @@ A generic helper for syntax highlighting (see also `nanolightJs`).
747
750
  ### nanolightJs
748
751
 
749
752
  ```ts
750
- export const nanolightJs: (code?: string | undefined) => import("./h.js").HArgs1[];
753
+ const nanolightJs: (code: string) => HArgs1[];
751
754
  ```
752
755
 
753
756
  A helper for highlighting JavaScript.
@@ -757,14 +760,14 @@ A helper for highlighting JavaScript.
757
760
  ```js
758
761
  const codeJs = 'const answerToLifeTheUniverseAndEverything = 42'
759
762
 
760
- expect(h('pre', ['code', ...nanolightJs(codeJs)]).outerHTML).to.deep.equal(
763
+ expect(h('pre', ['code', ...nanolightJs(codeJs)]).outerHTML).toStrictEqual(
761
764
  '<pre><code><span class="keyword">const</span> <span class="literal">answerToLifeTheUniverseAndEverything</span> <span class="operator">=</span> <span class="number">42</span></code></pre>')
762
765
  ```
763
766
 
764
767
  ### omit
765
768
 
766
769
  ```ts
767
- export const omit: <T extends Partial<Record<PropertyKey, any>>, K extends (keyof T)[]>(obj: T, keys: K) => Omit<T, K[number]>;
770
+ const omit: <T extends Partial<Record<PropertyKey, any>>, K extends (keyof T)[]>(obj: Partial<Record<PropertyKey, any>>, keys: any[]) => Omit<T, K[number]>;
768
771
  ```
769
772
 
770
773
  A helper that implements TypeScript’s `Omit` utility type.
@@ -774,13 +777,13 @@ A helper that implements TypeScript’s `Omit` utility type.
774
777
  ```js
775
778
  const obj = { a: 42, b: '42', c: 17 }
776
779
 
777
- expect(omit(obj, ['c'])).to.deep.equal({ a: 42, b: '42' })
780
+ expect(omit(obj, ['c'])).toStrictEqual({ a: 42, b: '42' })
778
781
  ```
779
782
 
780
783
  ### pick
781
784
 
782
785
  ```ts
783
- export const pick: <T extends Partial<Record<PropertyKey, any>>, K extends (keyof T)[]>(obj: T, keys: K) => Pick<T, K[number]>;
786
+ const pick: <T extends Partial<Record<PropertyKey, any>>, K extends (keyof T)[]>(obj: Partial<Record<PropertyKey, any>>, keys: any[]) => Pick<T, K[number]>;
784
787
  ```
785
788
 
786
789
  A helper that implements TypeScript’s `Pick` utility type.
@@ -790,13 +793,13 @@ A helper that implements TypeScript’s `Pick` utility type.
790
793
  ```js
791
794
  const obj = { a: 42, b: '42', c: 17 }
792
795
 
793
- expect(pick(obj, ['a', 'b'])).to.deep.equal({ a: 42, b: '42' })
796
+ expect(pick(obj, ['a', 'b'])).toStrictEqual({ a: 42, b: '42' })
794
797
  ```
795
798
 
796
799
  ### plUral
797
800
 
798
801
  ```ts
799
- export function plUral(singular: string, plural2: string, plural5: string, value: number): string;
802
+ const plUral: (singular: string, plural2: string, plural5: string, value: number) => string;
800
803
  ```
801
804
 
802
805
  A helper for choosing the correct singular and plural.
@@ -806,23 +809,23 @@ A helper for choosing the correct singular and plural.
806
809
  ```js
807
810
  const auto = plUral.bind(null, 'auto', 'auta', 'aut')
808
811
 
809
- expect(auto(0)).to.deep.equal('aut')
810
- expect(auto(1)).to.deep.equal('auto')
811
- expect(auto(17)).to.deep.equal('aut')
812
- expect(auto(42)).to.deep.equal('auta')
812
+ expect(auto(0)).toStrictEqual('aut')
813
+ expect(auto(1)).toStrictEqual('auto')
814
+ expect(auto(17)).toStrictEqual('aut')
815
+ expect(auto(42)).toStrictEqual('auta')
813
816
 
814
817
  const car = plUral.bind(null, 'car', 'cars', 'cars')
815
818
 
816
- expect(car(0)).to.deep.equal('cars')
817
- expect(car(1)).to.deep.equal('car')
818
- expect(car(17)).to.deep.equal('cars')
819
- expect(car(42)).to.deep.equal('cars')
819
+ expect(car(0)).toStrictEqual('cars')
820
+ expect(car(1)).toStrictEqual('car')
821
+ expect(car(17)).toStrictEqual('cars')
822
+ expect(car(42)).toStrictEqual('cars')
820
823
  ```
821
824
 
822
825
  ### pro
823
826
 
824
827
  ```ts
825
- export function pro(ref: any): any;
828
+ const pro: (ref: any) => any;
826
829
  ```
827
830
 
828
831
  A helper that protects calls to nested properties by a `Proxy` that initializes non-existent values with an empty object.
@@ -834,33 +837,33 @@ const ref = {}
834
837
 
835
838
  pro(ref).one.two[3][4] = 1234
836
839
 
837
- expect(ref).to.deep.equal({ one: { two: { 3: { 4: 1234 } } } })
840
+ expect(ref).toStrictEqual({ one: { two: { 3: { 4: 1234 } } } })
838
841
 
839
842
  pro(ref).one.two.tree = 123
840
843
 
841
- expect(ref).to.deep.equal({ one: { two: { 3: { 4: 1234 }, tree: 123 } } })
844
+ expect(ref).toStrictEqual({ one: { two: { 3: { 4: 1234 }, tree: 123 } } })
842
845
 
843
846
  pro(ref).one.two = undefined
844
847
 
845
- expect(ref).to.deep.equal({ one: { two: undefined } })
848
+ expect(ref).toStrictEqual({ one: { two: undefined } })
846
849
 
847
850
  delete pro(ref).one.two
848
851
 
849
- expect(ref).to.deep.equal({ one: {} })
852
+ expect(ref).toStrictEqual({ one: {} })
850
853
 
851
854
  pro(ref).one.two.three.four
852
855
 
853
- expect(ref).to.deep.equal({ one: { two: { three: { four: {} } } } })
856
+ expect(ref).toStrictEqual({ one: { two: { three: { four: {} } } } })
854
857
 
855
858
  pro(ref).one.two.three.four = 1234
856
859
 
857
- expect(ref).to.deep.equal({ one: { two: { three: { four: 1234 } } } })
860
+ expect(ref).toStrictEqual({ one: { two: { three: { four: 1234 } } } })
858
861
  ```
859
862
 
860
863
  ### refsInfo
861
864
 
862
865
  ```ts
863
- export function refsInfo(...refs: any[]): [string, string, string[]][];
866
+ const refsInfo: (...refs: any[]) => [string, string, string[]][];
864
867
  ```
865
868
 
866
869
  A helper that provides information about the given `refs`.
@@ -872,8 +875,8 @@ It returns an array of triples: `[«name», «prototype-name», «array-of-own-p
872
875
  ```js
873
876
  const info = refsInfo(Array, Function)
874
877
 
875
- expect(info.find(([name]) => name === 'Array')?.[2]?.includes('length')).to.be.true
876
- expect(info.find(([name]) => name === 'Function')?.[2]?.includes('length')).to.be.true
878
+ expect(info.find(([name]) => name === 'Array')?.[2]?.includes('length')).toBeTrue()
879
+ expect(info.find(([name]) => name === 'Function')?.[2]?.includes('length')).toBeTrue()
877
880
  ```
878
881
 
879
882
  ```js
@@ -903,9 +906,11 @@ console.log(browserFingerprint())
903
906
  ### s
904
907
 
905
908
  ```ts
906
- export function s<T extends keyof SVGElementTagNameMap>(tag: T, ...args1: HArgs1[]): SVGElementTagNameMap[T];
907
- export function s<N extends Node>(node: N, ...args1: HArgs1[]): N;
908
- export function s(tagOrNode: string | Node, ...args1: HArgs1[]): Node;
909
+ const s: {
910
+ <T extends keyof SVGElementTagNameMap>(tag: T, ...args1: HArgs1[]): SVGElementTagNameMap[T];
911
+ <N extends Node>(node: N, ...args1: HArgs1[]): N;
912
+ (tagOrNode: string | Node, ...args1: HArgs1[]): Node;
913
+ };
909
914
  ```
910
915
 
911
916
  A lightweight [HyperScript](https://github.com/hyperhype/hyperscript)-style helper for creating and modifying `SVGElement`s (see also `h`).
@@ -925,10 +930,10 @@ A lightweight [HyperScript](https://github.com/hyperhype/hyperscript)-style help
925
930
  ### uuid1
926
931
 
927
932
  ```ts
928
- export function uuid1({ date, node }?: {
933
+ const uuid1: ({ date, node }?: {
929
934
  date?: Date | undefined;
930
935
  node?: string | undefined;
931
- }): string;
936
+ }) => string;
932
937
  ```
933
938
 
934
939
  A helper that generates a UUID v1 identifier (with a creation timestamp).
@@ -942,23 +947,23 @@ A helper that generates a UUID v1 identifier (with a creation timestamp).
942
947
  for (let i = 1; i <= 22136; ++i) {
943
948
  const uuid = uuid1()
944
949
 
945
- i === 1 && expect(uuid.split('-')[3]).to.deep.equal('8001')
946
- i === 4095 && expect(uuid.split('-')[3]).to.deep.equal('8fff')
947
- i === 4096 && expect(uuid.split('-')[3]).to.deep.equal('9000')
948
- i === 9029 && expect(uuid.split('-')[3]).to.deep.equal('a345')
949
- i === 13398 && expect(uuid.split('-')[3]).to.deep.equal('b456')
950
- i === 16384 && expect(uuid.split('-')[3]).to.deep.equal('8000')
951
- i === 17767 && expect(uuid.split('-')[3]).to.deep.equal('8567')
950
+ i === 1 && expect(uuid.split('-')[3]).toStrictEqual('8001')
951
+ i === 4095 && expect(uuid.split('-')[3]).toStrictEqual('8fff')
952
+ i === 4096 && expect(uuid.split('-')[3]).toStrictEqual('9000')
953
+ i === 9029 && expect(uuid.split('-')[3]).toStrictEqual('a345')
954
+ i === 13398 && expect(uuid.split('-')[3]).toStrictEqual('b456')
955
+ i === 16384 && expect(uuid.split('-')[3]).toStrictEqual('8000')
956
+ i === 17767 && expect(uuid.split('-')[3]).toStrictEqual('8567')
952
957
  }
953
958
  ```
954
959
 
955
960
  ```js
956
- expect(uuid1({ node: '000123456789abc' }).split('-')[4]).to.deep.equal('123456789abc')
957
- expect(uuid1({ node: '123456789' }).split('-')[4]).to.deep.equal('000123456789')
961
+ expect(uuid1({ node: '000123456789abc' }).split('-')[4]).toStrictEqual('123456789abc')
962
+ expect(uuid1({ node: '123456789' }).split('-')[4]).toStrictEqual('000123456789')
958
963
  ```
959
964
 
960
965
  ```js
961
- expect(uuid1({ date: new Date(323325000000) }).startsWith('c1399400-9a71-11bd')).to.be.true
966
+ expect(uuid1({ date: new Date(323325000000) }).startsWith('c1399400-9a71-11bd')).toBeTrue()
962
967
  ```
963
968
 
964
969
  ## License