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