@jackens/nnn 2024.2.17 → 2024.2.20
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/chartable.d.ts +24 -22
- package/chartable.js +119 -82
- package/eq.d.ts +1 -1
- package/eq.js +24 -24
- package/escape.d.ts +1 -1
- package/escape.js +2 -2
- package/fixTypography.d.ts +1 -1
- package/fixTypography.js +2 -2
- package/h.d.ts +5 -5
- package/h.js +26 -26
- package/has.d.ts +2 -2
- package/has.js +11 -11
- package/is.d.ts +2 -2
- package/is.js +27 -27
- package/jcss.d.ts +6 -6
- package/jcss.js +12 -12
- package/jsOnParse.d.ts +1 -1
- package/jsOnParse.js +2 -2
- package/locale.d.ts +1 -1
- package/locale.js +9 -9
- package/nanolightJs.d.ts +1 -1
- package/nanolightJs.js +2 -2
- package/package.json +3 -1
- package/pick.d.ts +2 -2
- package/pick.js +4 -4
- package/plUral.d.ts +1 -1
- package/plUral.js +9 -9
- package/pro.d.ts +1 -1
- package/pro.js +7 -7
- package/readme.md +149 -147
- package/refsInfo.d.ts +2 -2
- package/refsInfo.js +4 -4
- package/uuid1.d.ts +3 -3
- package/uuid1.js +13 -13
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.
|
|
5
|
+
<sub>Version: <code class="version">2024.2.20</code></sub>
|
|
6
6
|
|
|
7
7
|
## Installation
|
|
8
8
|
|
|
@@ -103,35 +103,37 @@ The type of arguments of the `jcss` helper.
|
|
|
103
103
|
### chartable
|
|
104
104
|
|
|
105
105
|
```ts
|
|
106
|
-
export function chartable({
|
|
107
|
-
bottom?: number;
|
|
108
|
-
gapX?: number;
|
|
109
|
-
gapY?: number;
|
|
110
|
-
headerColumn?: boolean;
|
|
111
|
-
left?: number;
|
|
112
|
-
maxY?: number;
|
|
113
|
-
reverse?: boolean;
|
|
114
|
-
right?: number;
|
|
115
|
-
rotate?: boolean;
|
|
106
|
+
export function chartable({ table, headerColumn, xGap, xLabelsMinHeight, xLabelsRotate, xReverse, yGap, yLabelsLeftMinWidth, yLabelsRightMinWidth, yMax, zLabelsMinWidth, zyMappings }: {
|
|
116
107
|
table: HTMLTableElement;
|
|
117
|
-
|
|
118
|
-
|
|
108
|
+
headerColumn?: boolean | undefined;
|
|
109
|
+
xGap?: number | undefined;
|
|
110
|
+
xLabelsMinHeight?: number | undefined;
|
|
111
|
+
xLabelsRotate?: boolean | undefined;
|
|
112
|
+
xReverse?: boolean | undefined;
|
|
113
|
+
yGap?: number | undefined;
|
|
114
|
+
yLabelsLeftMinWidth?: number | undefined;
|
|
115
|
+
yLabelsRightMinWidth?: number | undefined;
|
|
116
|
+
yMax?: number | undefined;
|
|
117
|
+
zLabelsMinWidth?: number | undefined;
|
|
118
|
+
zyMappings?: [(label: string) => number, (value: number) => string][] | undefined;
|
|
119
|
+
}): SVGSVGElement;
|
|
119
120
|
```
|
|
120
121
|
|
|
121
122
|
A helper for creating a chart based on a table (conf. <https://jackens.github.io/nnn/chartable/>).
|
|
122
123
|
|
|
123
124
|
Options:
|
|
124
|
-
- `bottom`: bottom padding (for X axis labels)
|
|
125
|
-
- `gapX`: X axis spacing
|
|
126
|
-
- `gapY`: Y axis spacing
|
|
127
|
-
- `headerColumn`: flag indicating that `table` has a header column (with X axis labels)
|
|
128
|
-
- `left`: left padding
|
|
129
|
-
- `maxY`: number of Y axis lines
|
|
130
|
-
- `reverse`: flag to reverse all data series
|
|
131
|
-
- `right`: right padding (for data series labels)
|
|
132
|
-
- `rotate`: flag to rotate X axis labels
|
|
133
125
|
- `table`: `HTMLTableElement` to extract data, data series labels and X axis labels
|
|
134
|
-
- `
|
|
126
|
+
- `headerColumn`: flag indicating that `table` has a header column with X axis labels
|
|
127
|
+
- `xGap`: X axis spacing
|
|
128
|
+
- `xLabelsMinHeight`: minimal height of X axis labels
|
|
129
|
+
- `xLabelsRotate`: flag to rotate X axis labels
|
|
130
|
+
- `xReverse`: flag to reverse all data series
|
|
131
|
+
- `yGap`: Y axis spacing
|
|
132
|
+
- `yLabelsLeftMinWidth`: minimal width of Y axis left labels
|
|
133
|
+
- `yLabelsRightMinWidth`: minimal width of Y axis right labels
|
|
134
|
+
- `yMax`: number of Y axis lines
|
|
135
|
+
- `zLabelsMinWidth`: minimal width of data series labels
|
|
136
|
+
- `zyMappings`: mappings per data series
|
|
135
137
|
|
|
136
138
|
### eq
|
|
137
139
|
|
|
@@ -144,35 +146,35 @@ A helper that checks equality of the given arguments.
|
|
|
144
146
|
#### Usage Examples
|
|
145
147
|
|
|
146
148
|
```js
|
|
147
|
-
expect(eq(true, true)).
|
|
148
|
-
expect(eq(NaN, NaN)).
|
|
149
|
-
expect(eq(null, undefined)).
|
|
150
|
-
expect(eq(42, 42)).
|
|
151
|
-
expect(eq(42, new Number(42))).
|
|
152
|
-
expect(eq(42, Number(42))).
|
|
153
|
-
expect(eq(new Number(42), Number(42))).
|
|
154
|
-
expect(eq(42, '42')).
|
|
155
|
-
expect(eq('42', '42')).
|
|
156
|
-
expect(eq('42', new String('42'))).
|
|
157
|
-
expect(eq('42', String('42'))).
|
|
158
|
-
expect(eq(String('42'), new String('42'))).
|
|
159
|
-
expect(eq(/42/, /42/)).
|
|
160
|
-
expect(eq(/42/, /42/g)).
|
|
161
|
-
expect(eq(new Date(42), new Date(42))).
|
|
162
|
-
expect(eq(new Date(), new Date(42))).
|
|
163
|
-
expect(eq({ j: '42', c: 42 }, { c: 42, j: '42' })).
|
|
164
|
-
expect(eq([42, '42'], [42, '42'])).
|
|
165
|
-
expect(eq(new Set(['42', 42]), new Set([42, '42']))).
|
|
166
|
-
expect(eq(new Set(['42', 42]), new Set([42]))).
|
|
167
|
-
expect(eq(new Set([42, undefined]), new Set([42]))).
|
|
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
|
|
168
170
|
expect(eq(
|
|
169
171
|
new Map([[{ j: 42 }, { J: '42' }], [{ c: 42 }, { C: '42' }]]),
|
|
170
172
|
new Map([[{ c: 42 }, { C: '42' }], [{ j: 42 }, { J: '42' }]])
|
|
171
|
-
)).
|
|
173
|
+
)).to.be.true
|
|
172
174
|
expect(eq(
|
|
173
175
|
new Map([[{ j: 42 }, { J: '42' }], [{ c: 42 }, { C: '42' }]]),
|
|
174
176
|
new Map([[{ j: '42' }, { J: 42 }], [{ c: '42' }, { C: 42 }]])
|
|
175
|
-
)).
|
|
177
|
+
)).to.be.false
|
|
176
178
|
```
|
|
177
179
|
|
|
178
180
|
### escape
|
|
@@ -207,7 +209,7 @@ const expected = `
|
|
|
207
209
|
FROM table_name
|
|
208
210
|
WHERE column_name IN (b'1', NULL, NULL, 42, '42', '4''2', NULL, '1980-03-31 04:30:00')`
|
|
209
211
|
|
|
210
|
-
expect(actual).
|
|
212
|
+
expect(actual).to.deep.equal(expected)
|
|
211
213
|
```
|
|
212
214
|
|
|
213
215
|
### escapeValues
|
|
@@ -233,7 +235,7 @@ const p = h('p', 'Pchnąć w tę łódź jeża lub ośm skrzyń fig (zob. https:
|
|
|
233
235
|
|
|
234
236
|
fixTypography(p)
|
|
235
237
|
|
|
236
|
-
expect(p.innerHTML).
|
|
238
|
+
expect(p.innerHTML).to.deep.equal(
|
|
237
239
|
'Pchnąć <span style="white-space:nowrap">w </span>tę łódź jeża lub ośm skrzyń fig ' +
|
|
238
240
|
'(zob. https://\u200Bpl.\u200Bwikipedia.\u200Borg/\u200Bwiki/\u200BPangram).')
|
|
239
241
|
```
|
|
@@ -265,67 +267,67 @@ A lightweight [HyperScript](https://github.com/hyperhype/hyperscript)-style help
|
|
|
265
267
|
```js
|
|
266
268
|
const b = h('b')
|
|
267
269
|
|
|
268
|
-
expect(b.outerHTML).
|
|
270
|
+
expect(b.outerHTML).to.deep.equal('<b></b>')
|
|
269
271
|
|
|
270
272
|
const i = h('i', 'text')
|
|
271
273
|
|
|
272
274
|
h(b, i)
|
|
273
275
|
|
|
274
|
-
expect(i.outerHTML).
|
|
275
|
-
expect(b.outerHTML).
|
|
276
|
+
expect(i.outerHTML).to.deep.equal('<i>text</i>')
|
|
277
|
+
expect(b.outerHTML).to.deep.equal('<b><i>text</i></b>')
|
|
276
278
|
|
|
277
279
|
h(i, { $className: 'some class' })
|
|
278
280
|
|
|
279
|
-
expect(i.outerHTML).
|
|
280
|
-
expect(b.outerHTML).
|
|
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>')
|
|
281
283
|
```
|
|
282
284
|
|
|
283
285
|
```js
|
|
284
|
-
expect(h('span', 'text').outerHTML).
|
|
285
|
-
expect(h('span', { $innerText: 'text' }).outerHTML).
|
|
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>')
|
|
286
288
|
```
|
|
287
289
|
|
|
288
290
|
```js
|
|
289
291
|
expect(h('div', { style: 'margin:0;padding:0' }).outerHTML)
|
|
290
|
-
.
|
|
292
|
+
.to.deep.equal('<div style="margin:0;padding:0"></div>')
|
|
291
293
|
expect(h('div', { $style: 'margin:0;padding:0' }).outerHTML)
|
|
292
|
-
.
|
|
294
|
+
.to.deep.equal('<div style="margin: 0px; padding: 0px;"></div>')
|
|
293
295
|
expect(h('div', { $style: { margin: 0, padding: 0 } }).outerHTML)
|
|
294
|
-
.
|
|
296
|
+
.to.deep.equal('<div style="margin: 0px; padding: 0px;"></div>')
|
|
295
297
|
```
|
|
296
298
|
|
|
297
299
|
```js
|
|
298
300
|
const input1 = h('input', { value: 42 })
|
|
299
301
|
const input2 = h('input', { $value: '42' })
|
|
300
302
|
|
|
301
|
-
expect(input1.value).
|
|
302
|
-
expect(input2.value).
|
|
303
|
+
expect(input1.value).to.deep.equal('42')
|
|
304
|
+
expect(input2.value).to.deep.equal('42')
|
|
303
305
|
|
|
304
|
-
expect(input1.outerHTML).
|
|
305
|
-
expect(input2.outerHTML).
|
|
306
|
+
expect(input1.outerHTML).to.deep.equal('<input value="42">')
|
|
307
|
+
expect(input2.outerHTML).to.deep.equal('<input>')
|
|
306
308
|
|
|
307
309
|
const checkbox1 = h('input', { type: 'checkbox', checked: true })
|
|
308
310
|
const checkbox2 = h('input', { type: 'checkbox', $checked: true })
|
|
309
311
|
|
|
310
|
-
expect(checkbox1.checked).
|
|
311
|
-
expect(checkbox2.checked).
|
|
312
|
+
expect(checkbox1.checked).to.be.true
|
|
313
|
+
expect(checkbox2.checked).to.be.true
|
|
312
314
|
|
|
313
|
-
expect(checkbox1.outerHTML).
|
|
314
|
-
expect(checkbox2.outerHTML).
|
|
315
|
+
expect(checkbox1.outerHTML).to.deep.equal('<input type="checkbox" checked="">')
|
|
316
|
+
expect(checkbox2.outerHTML).to.deep.equal('<input type="checkbox">')
|
|
315
317
|
```
|
|
316
318
|
|
|
317
319
|
```js
|
|
318
320
|
const div = h('div')
|
|
319
321
|
|
|
320
|
-
expect(div.key).
|
|
322
|
+
expect(div.key).to.be.undefined
|
|
321
323
|
|
|
322
324
|
h(div, { $key: { one: 1 } })
|
|
323
325
|
|
|
324
|
-
expect(div.key).
|
|
326
|
+
expect(div.key).to.deep.equal({ one: 1 })
|
|
325
327
|
|
|
326
328
|
h(div, { $key: { two: 2 } })
|
|
327
329
|
|
|
328
|
-
expect(div.key).
|
|
330
|
+
expect(div.key).to.deep.equal({ one: 1, two: 2 })
|
|
329
331
|
```
|
|
330
332
|
|
|
331
333
|
### has
|
|
@@ -341,17 +343,17 @@ A replacement for the `in` operator (not to be confused with the `for-in` loop)
|
|
|
341
343
|
```js
|
|
342
344
|
const obj = { key: 'K', null: 'N' }
|
|
343
345
|
|
|
344
|
-
expect('key' in obj).
|
|
345
|
-
expect(has('key', obj)).
|
|
346
|
+
expect('key' in obj).to.be.true
|
|
347
|
+
expect(has('key', obj)).to.be.true
|
|
346
348
|
|
|
347
|
-
expect('null' in obj).
|
|
348
|
-
expect(has('null', obj)).
|
|
349
|
+
expect('null' in obj).to.be.true
|
|
350
|
+
expect(has('null', obj)).to.be.true
|
|
349
351
|
|
|
350
|
-
expect(null in obj).
|
|
351
|
-
expect(has(null, obj)).
|
|
352
|
+
expect(null in obj).to.be.true
|
|
353
|
+
expect(has(null, obj)).to.be.false
|
|
352
354
|
|
|
353
|
-
expect('toString' in obj).
|
|
354
|
-
expect(has('toString', obj)).
|
|
355
|
+
expect('toString' in obj).to.be.true
|
|
356
|
+
expect(has('toString', obj)).to.be.false
|
|
355
357
|
```
|
|
356
358
|
|
|
357
359
|
```js
|
|
@@ -364,7 +366,7 @@ try {
|
|
|
364
366
|
}
|
|
365
367
|
|
|
366
368
|
expect(typeError instanceof TypeError) // Cannot use 'in' operator to search for 'key' in null
|
|
367
|
-
expect(has('key', null)).
|
|
369
|
+
expect(has('key', null)).to.be.false
|
|
368
370
|
```
|
|
369
371
|
|
|
370
372
|
### is
|
|
@@ -386,23 +388,23 @@ A helper that checks if the given argument is of a certain type.
|
|
|
386
388
|
#### Usage Examples
|
|
387
389
|
|
|
388
390
|
```js
|
|
389
|
-
expect(is(Number, 42)).
|
|
390
|
-
expect(is(Number, Number(42))).
|
|
391
|
-
expect(is(Number, new Number(42))).
|
|
392
|
-
expect(is(Number, NaN)).
|
|
393
|
-
expect(is(String, '42')).
|
|
394
|
-
expect(is(String, String('42'))).
|
|
395
|
-
expect(is(String, new String('42'))).
|
|
396
|
-
expect(is(Symbol, Symbol('42'))).
|
|
397
|
-
expect(is(Symbol, Object(Symbol('42')))).
|
|
398
|
-
expect(is(undefined, undefined)).
|
|
399
|
-
expect(is(undefined, null)).
|
|
400
|
-
expect(is(Object, {})).
|
|
401
|
-
expect(is(Array, [])).
|
|
402
|
-
expect(is(RegExp, /42/)).
|
|
403
|
-
expect(is(Date, new Date(42))).
|
|
404
|
-
expect(is(Set, new Set(['42', 42]))).
|
|
405
|
-
expect(is(Map, new Map([[{ j: 42 }, { J: '42' }], [{ c: 42 }, { C: '42' }]]))).
|
|
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
|
|
406
408
|
```
|
|
407
409
|
|
|
408
410
|
```js
|
|
@@ -410,21 +412,21 @@ const iz = (/** @type {any} */ type, /** @type {any} */ arg) => ({}).toString.ca
|
|
|
410
412
|
|
|
411
413
|
class FooBar { }
|
|
412
414
|
|
|
413
|
-
expect(is(FooBar, new FooBar())).
|
|
414
|
-
expect(iz(FooBar, new FooBar())).
|
|
415
|
+
expect(is(FooBar, new FooBar())).to.be.true
|
|
416
|
+
expect(iz(FooBar, new FooBar())).to.be.false
|
|
415
417
|
|
|
416
|
-
expect(is(Object, new FooBar())).
|
|
417
|
-
expect(iz(Object, new FooBar())).
|
|
418
|
+
expect(is(Object, new FooBar())).to.be.false
|
|
419
|
+
expect(iz(Object, new FooBar())).to.be.true
|
|
418
420
|
|
|
419
421
|
const fakeFooBar = {}
|
|
420
422
|
|
|
421
423
|
fakeFooBar[Symbol.toStringTag] = FooBar.name
|
|
422
424
|
|
|
423
|
-
expect(is(FooBar, fakeFooBar)).
|
|
424
|
-
expect(iz(FooBar, fakeFooBar)).
|
|
425
|
+
expect(is(FooBar, fakeFooBar)).to.be.false
|
|
426
|
+
expect(iz(FooBar, fakeFooBar)).to.be.true
|
|
425
427
|
|
|
426
|
-
expect(is(Object, fakeFooBar)).
|
|
427
|
-
expect(iz(Object, fakeFooBar)).
|
|
428
|
+
expect(is(Object, fakeFooBar)).to.be.true
|
|
429
|
+
expect(iz(Object, fakeFooBar)).to.be.false
|
|
428
430
|
```
|
|
429
431
|
|
|
430
432
|
### jcss
|
|
@@ -468,7 +470,7 @@ a{
|
|
|
468
470
|
padding:1
|
|
469
471
|
}`.replace(/\n\s*/g, '')
|
|
470
472
|
|
|
471
|
-
expect(actual).
|
|
473
|
+
expect(actual).to.deep.equal(expected)
|
|
472
474
|
```
|
|
473
475
|
|
|
474
476
|
```js
|
|
@@ -496,7 +498,7 @@ a.b{
|
|
|
496
498
|
padding:1
|
|
497
499
|
}`.replace(/\n\s*/g, '')
|
|
498
500
|
|
|
499
|
-
expect(actual).
|
|
501
|
+
expect(actual).to.deep.equal(expected)
|
|
500
502
|
```
|
|
501
503
|
|
|
502
504
|
```js
|
|
@@ -571,7 +573,7 @@ div.c2{
|
|
|
571
573
|
}
|
|
572
574
|
}`.replace(/\n\s*/g, '')
|
|
573
575
|
|
|
574
|
-
expect(actual).
|
|
576
|
+
expect(actual).to.deep.equal(expected)
|
|
575
577
|
```
|
|
576
578
|
|
|
577
579
|
```js
|
|
@@ -594,7 +596,7 @@ a.b.d,a.c.d{
|
|
|
594
596
|
margin:2
|
|
595
597
|
}`.replace(/\n\s*/g, '')
|
|
596
598
|
|
|
597
|
-
expect(actual).
|
|
599
|
+
expect(actual).to.deep.equal(expected)
|
|
598
600
|
```
|
|
599
601
|
|
|
600
602
|
```js
|
|
@@ -615,7 +617,7 @@ const expected = `
|
|
|
615
617
|
margin:2
|
|
616
618
|
}`.replace(/\n\s*/g, '')
|
|
617
619
|
|
|
618
|
-
expect(actual).
|
|
620
|
+
expect(actual).to.deep.equal(expected)
|
|
619
621
|
```
|
|
620
622
|
|
|
621
623
|
```js
|
|
@@ -636,7 +638,7 @@ const expected = `
|
|
|
636
638
|
margin:2
|
|
637
639
|
}`.replace(/\n\s*/g, '')
|
|
638
640
|
|
|
639
|
-
expect(actual).
|
|
641
|
+
expect(actual).to.deep.equal(expected)
|
|
640
642
|
```
|
|
641
643
|
|
|
642
644
|
### jsOnParse
|
|
@@ -701,7 +703,7 @@ const expected = [
|
|
|
701
703
|
}
|
|
702
704
|
]
|
|
703
705
|
|
|
704
|
-
expect(actual).
|
|
706
|
+
expect(actual).to.deep.equal(expected)
|
|
705
707
|
```
|
|
706
708
|
|
|
707
709
|
### locale
|
|
@@ -720,18 +722,18 @@ const _ = locale({
|
|
|
720
722
|
button: { Login: 'Zaloguj' }
|
|
721
723
|
}, 'default')
|
|
722
724
|
|
|
723
|
-
expect(_('Login')).
|
|
724
|
-
expect(_('Password')).
|
|
725
|
+
expect(_('Login')).to.deep.equal('Login')
|
|
726
|
+
expect(_('Password')).to.deep.equal('Hasło')
|
|
725
727
|
|
|
726
|
-
expect(_('Undefined text')).
|
|
728
|
+
expect(_('Undefined text')).to.deep.equal('Undefined text')
|
|
727
729
|
|
|
728
|
-
expect(_('Login', 'button')).
|
|
730
|
+
expect(_('Login', 'button')).to.deep.equal('Zaloguj')
|
|
729
731
|
|
|
730
|
-
expect(_('Password', 'undefined_version')).
|
|
731
|
-
expect(_('Undefined text', 'undefined_version')).
|
|
732
|
+
expect(_('Password', 'undefined_version')).to.deep.equal('Hasło')
|
|
733
|
+
expect(_('Undefined text', 'undefined_version')).to.deep.equal('Undefined text')
|
|
732
734
|
|
|
733
|
-
expect(_('toString')).
|
|
734
|
-
expect(_('toString', 'undefined_version')).
|
|
735
|
+
expect(_('toString')).to.deep.equal('toString')
|
|
736
|
+
expect(_('toString', 'undefined_version')).to.deep.equal('toString')
|
|
735
737
|
```
|
|
736
738
|
|
|
737
739
|
### nanolight
|
|
@@ -755,7 +757,7 @@ A helper for highlighting JavaScript.
|
|
|
755
757
|
```js
|
|
756
758
|
const codeJs = 'const answerToLifeTheUniverseAndEverything = 42'
|
|
757
759
|
|
|
758
|
-
expect(h('pre', ['code', ...nanolightJs(codeJs)]).outerHTML).
|
|
760
|
+
expect(h('pre', ['code', ...nanolightJs(codeJs)]).outerHTML).to.deep.equal(
|
|
759
761
|
'<pre><code><span class="keyword">const</span> <span class="literal">answerToLifeTheUniverseAndEverything</span> <span class="operator">=</span> <span class="number">42</span></code></pre>')
|
|
760
762
|
```
|
|
761
763
|
|
|
@@ -772,7 +774,7 @@ A helper that implements TypeScript’s `Omit` utility type.
|
|
|
772
774
|
```js
|
|
773
775
|
const obj = { a: 42, b: '42', c: 17 }
|
|
774
776
|
|
|
775
|
-
expect(omit(obj, ['c'])).
|
|
777
|
+
expect(omit(obj, ['c'])).to.deep.equal({ a: 42, b: '42' })
|
|
776
778
|
```
|
|
777
779
|
|
|
778
780
|
### pick
|
|
@@ -788,7 +790,7 @@ A helper that implements TypeScript’s `Pick` utility type.
|
|
|
788
790
|
```js
|
|
789
791
|
const obj = { a: 42, b: '42', c: 17 }
|
|
790
792
|
|
|
791
|
-
expect(pick(obj, ['a', 'b'])).
|
|
793
|
+
expect(pick(obj, ['a', 'b'])).to.deep.equal({ a: 42, b: '42' })
|
|
792
794
|
```
|
|
793
795
|
|
|
794
796
|
### plUral
|
|
@@ -804,17 +806,17 @@ A helper for choosing the correct singular and plural.
|
|
|
804
806
|
```js
|
|
805
807
|
const auto = plUral.bind(null, 'auto', 'auta', 'aut')
|
|
806
808
|
|
|
807
|
-
expect(auto(0)).
|
|
808
|
-
expect(auto(1)).
|
|
809
|
-
expect(auto(17)).
|
|
810
|
-
expect(auto(42)).
|
|
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')
|
|
811
813
|
|
|
812
814
|
const car = plUral.bind(null, 'car', 'cars', 'cars')
|
|
813
815
|
|
|
814
|
-
expect(car(0)).
|
|
815
|
-
expect(car(1)).
|
|
816
|
-
expect(car(17)).
|
|
817
|
-
expect(car(42)).
|
|
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')
|
|
818
820
|
```
|
|
819
821
|
|
|
820
822
|
### pro
|
|
@@ -832,27 +834,27 @@ const ref = {}
|
|
|
832
834
|
|
|
833
835
|
pro(ref).one.two[3][4] = 1234
|
|
834
836
|
|
|
835
|
-
expect(ref).
|
|
837
|
+
expect(ref).to.deep.equal({ one: { two: { 3: { 4: 1234 } } } })
|
|
836
838
|
|
|
837
839
|
pro(ref).one.two.tree = 123
|
|
838
840
|
|
|
839
|
-
expect(ref).
|
|
841
|
+
expect(ref).to.deep.equal({ one: { two: { 3: { 4: 1234 }, tree: 123 } } })
|
|
840
842
|
|
|
841
843
|
pro(ref).one.two = undefined
|
|
842
844
|
|
|
843
|
-
expect(ref).
|
|
845
|
+
expect(ref).to.deep.equal({ one: { two: undefined } })
|
|
844
846
|
|
|
845
847
|
delete pro(ref).one.two
|
|
846
848
|
|
|
847
|
-
expect(ref).
|
|
849
|
+
expect(ref).to.deep.equal({ one: {} })
|
|
848
850
|
|
|
849
851
|
pro(ref).one.two.three.four
|
|
850
852
|
|
|
851
|
-
expect(ref).
|
|
853
|
+
expect(ref).to.deep.equal({ one: { two: { three: { four: {} } } } })
|
|
852
854
|
|
|
853
855
|
pro(ref).one.two.three.four = 1234
|
|
854
856
|
|
|
855
|
-
expect(ref).
|
|
857
|
+
expect(ref).to.deep.equal({ one: { two: { three: { four: 1234 } } } })
|
|
856
858
|
```
|
|
857
859
|
|
|
858
860
|
### refsInfo
|
|
@@ -870,8 +872,8 @@ It returns an array of triples: `[«name», «prototype-name», «array-of-own-p
|
|
|
870
872
|
```js
|
|
871
873
|
const info = refsInfo(Array, Function)
|
|
872
874
|
|
|
873
|
-
expect(info.find(([name]) => name === 'Array')?.[2]?.includes('length')).
|
|
874
|
-
expect(info.find(([name]) => name === 'Function')?.[2]?.includes('length')).
|
|
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
|
|
875
877
|
```
|
|
876
878
|
|
|
877
879
|
```js
|
|
@@ -940,23 +942,23 @@ A helper that generates a UUID v1 identifier (with a creation timestamp).
|
|
|
940
942
|
for (let i = 1; i <= 22136; ++i) {
|
|
941
943
|
const uuid = uuid1()
|
|
942
944
|
|
|
943
|
-
i === 1 && expect(uuid.split('-')[3]).
|
|
944
|
-
i === 4095 && expect(uuid.split('-')[3]).
|
|
945
|
-
i === 4096 && expect(uuid.split('-')[3]).
|
|
946
|
-
i === 9029 && expect(uuid.split('-')[3]).
|
|
947
|
-
i === 13398 && expect(uuid.split('-')[3]).
|
|
948
|
-
i === 16384 && expect(uuid.split('-')[3]).
|
|
949
|
-
i === 17767 && expect(uuid.split('-')[3]).
|
|
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
952
|
}
|
|
951
953
|
```
|
|
952
954
|
|
|
953
955
|
```js
|
|
954
|
-
expect(uuid1({ node: '000123456789abc' }).split('-')[4]).
|
|
955
|
-
expect(uuid1({ node: '123456789' }).split('-')[4]).
|
|
956
|
+
expect(uuid1({ node: '000123456789abc' }).split('-')[4]).to.deep.equal('123456789abc')
|
|
957
|
+
expect(uuid1({ node: '123456789' }).split('-')[4]).to.deep.equal('000123456789')
|
|
956
958
|
```
|
|
957
959
|
|
|
958
960
|
```js
|
|
959
|
-
expect(uuid1({ date: new Date(323325000000) })
|
|
961
|
+
expect(uuid1({ date: new Date(323325000000) }).startsWith('c1399400-9a71-11bd')).to.be.true
|
|
960
962
|
```
|
|
961
963
|
|
|
962
964
|
## License
|
package/refsInfo.d.ts
CHANGED
|
@@ -6,6 +6,6 @@
|
|
|
6
6
|
export function refsInfo(...refs: any[]): [string, string, string[]][];
|
|
7
7
|
|
|
8
8
|
export const tests: {
|
|
9
|
-
refsInfo: (expect:
|
|
10
|
-
'refsInfo: browserFingerprint': (expect:
|
|
9
|
+
refsInfo: (expect: Chai.ExpectStatic) => void;
|
|
10
|
+
'refsInfo: browserFingerprint': (expect: Chai.ExpectStatic) => void;
|
|
11
11
|
};
|
package/refsInfo.js
CHANGED
|
@@ -23,14 +23,14 @@ export const refsInfo = (/** @type {any[]} */ ...refs) => {
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
export const tests = {
|
|
26
|
-
refsInfo: (/** @type {import('
|
|
26
|
+
refsInfo: (/** @type {import('chai').expect} */ expect) => {
|
|
27
27
|
const info = refsInfo(Array, Function)
|
|
28
28
|
|
|
29
|
-
expect(info.find(([name]) => name === 'Array')?.[2]?.includes('length')).
|
|
30
|
-
expect(info.find(([name]) => name === 'Function')?.[2]?.includes('length')).
|
|
29
|
+
expect(info.find(([name]) => name === 'Array')?.[2]?.includes('length')).to.be.true
|
|
30
|
+
expect(info.find(([name]) => name === 'Function')?.[2]?.includes('length')).to.be.true
|
|
31
31
|
},
|
|
32
32
|
|
|
33
|
-
'refsInfo: browserFingerprint': (/** @type {import('
|
|
33
|
+
'refsInfo: browserFingerprint': (/** @type {import('chai').expect} */ expect) => {
|
|
34
34
|
const browserFingerprint = () => {
|
|
35
35
|
// @ts-expect-error
|
|
36
36
|
const refs = Object.getOwnPropertyNames(window).map(name => window[name])
|
package/uuid1.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export const tests: {
|
|
2
|
-
uuid1: (expect:
|
|
3
|
-
'uuid1: node': (expect:
|
|
4
|
-
'uuid1: date': (expect:
|
|
2
|
+
uuid1: (expect: Chai.ExpectStatic) => void;
|
|
3
|
+
'uuid1: node': (expect: Chai.ExpectStatic) => void;
|
|
4
|
+
'uuid1: date': (expect: Chai.ExpectStatic) => void;
|
|
5
5
|
};
|
|
6
6
|
|
|
7
7
|
/**
|
package/uuid1.js
CHANGED
|
@@ -29,26 +29,26 @@ export const uuid1 = ({
|
|
|
29
29
|
}
|
|
30
30
|
|
|
31
31
|
export const tests = {
|
|
32
|
-
uuid1: (/** @type {import('
|
|
32
|
+
uuid1: (/** @type {import('chai').expect} */ expect) => {
|
|
33
33
|
for (let i = 1; i <= 22136; ++i) {
|
|
34
34
|
const uuid = uuid1()
|
|
35
35
|
|
|
36
|
-
i === 1 && expect(uuid.split('-')[3]).
|
|
37
|
-
i === 4095 && expect(uuid.split('-')[3]).
|
|
38
|
-
i === 4096 && expect(uuid.split('-')[3]).
|
|
39
|
-
i === 9029 && expect(uuid.split('-')[3]).
|
|
40
|
-
i === 13398 && expect(uuid.split('-')[3]).
|
|
41
|
-
i === 16384 && expect(uuid.split('-')[3]).
|
|
42
|
-
i === 17767 && expect(uuid.split('-')[3]).
|
|
36
|
+
i === 1 && expect(uuid.split('-')[3]).to.deep.equal('8001')
|
|
37
|
+
i === 4095 && expect(uuid.split('-')[3]).to.deep.equal('8fff')
|
|
38
|
+
i === 4096 && expect(uuid.split('-')[3]).to.deep.equal('9000')
|
|
39
|
+
i === 9029 && expect(uuid.split('-')[3]).to.deep.equal('a345')
|
|
40
|
+
i === 13398 && expect(uuid.split('-')[3]).to.deep.equal('b456')
|
|
41
|
+
i === 16384 && expect(uuid.split('-')[3]).to.deep.equal('8000')
|
|
42
|
+
i === 17767 && expect(uuid.split('-')[3]).to.deep.equal('8567')
|
|
43
43
|
}
|
|
44
44
|
},
|
|
45
45
|
|
|
46
|
-
'uuid1: node': (/** @type {import('
|
|
47
|
-
expect(uuid1({ node: '000123456789abc' }).split('-')[4]).
|
|
48
|
-
expect(uuid1({ node: '123456789' }).split('-')[4]).
|
|
46
|
+
'uuid1: node': (/** @type {import('chai').expect} */ expect) => {
|
|
47
|
+
expect(uuid1({ node: '000123456789abc' }).split('-')[4]).to.deep.equal('123456789abc')
|
|
48
|
+
expect(uuid1({ node: '123456789' }).split('-')[4]).to.deep.equal('000123456789')
|
|
49
49
|
},
|
|
50
50
|
|
|
51
|
-
'uuid1: date': (/** @type {import('
|
|
52
|
-
expect(uuid1({ date: new Date(323325000000) })
|
|
51
|
+
'uuid1: date': (/** @type {import('chai').expect} */ expect) => {
|
|
52
|
+
expect(uuid1({ date: new Date(323325000000) }).startsWith('c1399400-9a71-11bd')).to.be.true
|
|
53
53
|
}
|
|
54
54
|
}
|