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