@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/is.js CHANGED
@@ -18,48 +18,48 @@
18
18
  export const is = (/** @type {T} */ type, /** @type {any} */ arg) => arg?.constructor === type
19
19
 
20
20
  export const tests = {
21
- is: (/** @type {import('bun:test').Expect} */ expect) => {
22
- expect(is(Number, 42)).toBe(true)
23
- expect(is(Number, Number(42))).toBe(true)
21
+ is: (/** @type {import('chai').expect} */ expect) => {
22
+ expect(is(Number, 42)).to.be.true
23
+ expect(is(Number, Number(42))).to.be.true
24
24
  // eslint-disable-next-line no-new-wrappers
25
- expect(is(Number, new Number(42))).toBe(true)
26
- expect(is(Number, NaN)).toBe(true)
27
- expect(is(String, '42')).toBe(true)
28
- expect(is(String, String('42'))).toBe(true)
25
+ expect(is(Number, new Number(42))).to.be.true
26
+ expect(is(Number, NaN)).to.be.true
27
+ expect(is(String, '42')).to.be.true
28
+ expect(is(String, String('42'))).to.be.true
29
29
  // eslint-disable-next-line no-new-wrappers
30
- expect(is(String, new String('42'))).toBe(true)
31
- expect(is(Symbol, Symbol('42'))).toBe(true)
32
- expect(is(Symbol, Object(Symbol('42')))).toBe(true)
33
- expect(is(undefined, undefined)).toBe(true)
34
- expect(is(undefined, null)).toBe(true)
35
- expect(is(Object, {})).toBe(true)
36
- expect(is(Array, [])).toBe(true)
37
- expect(is(RegExp, /42/)).toBe(true)
38
- expect(is(Date, new Date(42))).toBe(true)
39
- expect(is(Set, new Set(['42', 42]))).toBe(true)
40
- expect(is(Map, new Map([[{ j: 42 }, { J: '42' }], [{ c: 42 }, { C: '42' }]]))).toBe(true)
30
+ expect(is(String, new String('42'))).to.be.true
31
+ expect(is(Symbol, Symbol('42'))).to.be.true
32
+ expect(is(Symbol, Object(Symbol('42')))).to.be.true
33
+ expect(is(undefined, undefined)).to.be.true
34
+ expect(is(undefined, null)).to.be.true
35
+ expect(is(Object, {})).to.be.true
36
+ expect(is(Array, [])).to.be.true
37
+ expect(is(RegExp, /42/)).to.be.true
38
+ expect(is(Date, new Date(42))).to.be.true
39
+ expect(is(Set, new Set(['42', 42]))).to.be.true
40
+ expect(is(Map, new Map([[{ j: 42 }, { J: '42' }], [{ c: 42 }, { C: '42' }]]))).to.be.true
41
41
  },
42
42
 
43
- 'is: toString.call': (/** @type {import('bun:test').Expect} */ expect) => {
43
+ 'is: toString.call': (/** @type {import('chai').expect} */ expect) => {
44
44
  const iz = (/** @type {any} */ type, /** @type {any} */ arg) => ({}).toString.call(arg).slice(8, -1) === type?.name
45
45
 
46
46
  class FooBar { }
47
47
 
48
- expect(is(FooBar, new FooBar())).toBe(true)
49
- expect(iz(FooBar, new FooBar())).toBe(false)
48
+ expect(is(FooBar, new FooBar())).to.be.true
49
+ expect(iz(FooBar, new FooBar())).to.be.false
50
50
 
51
- expect(is(Object, new FooBar())).toBe(false)
52
- expect(iz(Object, new FooBar())).toBe(true)
51
+ expect(is(Object, new FooBar())).to.be.false
52
+ expect(iz(Object, new FooBar())).to.be.true
53
53
 
54
54
  const fakeFooBar = {}
55
55
 
56
56
  // @ts-expect-error
57
57
  fakeFooBar[Symbol.toStringTag] = FooBar.name
58
58
 
59
- expect(is(FooBar, fakeFooBar)).toBe(false)
60
- expect(iz(FooBar, fakeFooBar)).toBe(true)
59
+ expect(is(FooBar, fakeFooBar)).to.be.false
60
+ expect(iz(FooBar, fakeFooBar)).to.be.true
61
61
 
62
- expect(is(Object, fakeFooBar)).toBe(true)
63
- expect(iz(Object, fakeFooBar)).toBe(false)
62
+ expect(is(Object, fakeFooBar)).to.be.true
63
+ expect(iz(Object, fakeFooBar)).to.be.false
64
64
  }
65
65
  }
package/jcss.d.ts CHANGED
@@ -24,10 +24,10 @@ export type JcssRoot = Partial<Record<PropertyKey, JcssNode>>;
24
24
  export function jcss(root: JcssRoot, splitter?: string): string;
25
25
 
26
26
  export const tests: {
27
- 'jcss: #1': (expect: import('bun:test').Expect) => void;
28
- 'jcss: #2': (expect: import('bun:test').Expect) => void;
29
- 'jcss: #3': (expect: import('bun:test').Expect) => void;
30
- 'jcss: #4': (expect: import('bun:test').Expect) => void;
31
- 'jcss: #5': (expect: import('bun:test').Expect) => void;
32
- 'jcss: #6': (expect: import('bun:test').Expect) => void;
27
+ 'jcss: #1': (expect: Chai.ExpectStatic) => void;
28
+ 'jcss: #2': (expect: Chai.ExpectStatic) => void;
29
+ 'jcss: #3': (expect: Chai.ExpectStatic) => void;
30
+ 'jcss: #4': (expect: Chai.ExpectStatic) => void;
31
+ 'jcss: #5': (expect: Chai.ExpectStatic) => void;
32
+ 'jcss: #6': (expect: Chai.ExpectStatic) => void;
33
33
  };
package/jcss.js CHANGED
@@ -97,7 +97,7 @@ export const jcss = (/** @type {JcssRoot} */ root, splitter = '$$') => {
97
97
  }
98
98
 
99
99
  export const tests = {
100
- 'jcss: #1': (/** @type {import('bun:test').Expect} */ expect) => {
100
+ 'jcss: #1': (/** @type {import('chai').expect} */ expect) => {
101
101
  const actual = jcss({
102
102
  a: {
103
103
  color: 'red',
@@ -120,10 +120,10 @@ export const tests = {
120
120
  padding:1
121
121
  }`.replace(/\n\s*/g, '')
122
122
 
123
- expect(actual).toEqual(expected)
123
+ expect(actual).to.deep.equal(expected)
124
124
  },
125
125
 
126
- 'jcss: #2': (/** @type {import('bun:test').Expect} */ expect) => {
126
+ 'jcss: #2': (/** @type {import('chai').expect} */ expect) => {
127
127
  const actual = jcss({
128
128
  a: {
129
129
  '.b': {
@@ -148,10 +148,10 @@ export const tests = {
148
148
  padding:1
149
149
  }`.replace(/\n\s*/g, '')
150
150
 
151
- expect(actual).toEqual(expected)
151
+ expect(actual).to.deep.equal(expected)
152
152
  },
153
153
 
154
- 'jcss: #3': (/** @type {import('bun:test').Expect} */ expect) => {
154
+ 'jcss: #3': (/** @type {import('chai').expect} */ expect) => {
155
155
  const actual = jcss({
156
156
  '@font-face$$1': {
157
157
  fontFamily: 'Jackens',
@@ -223,10 +223,10 @@ export const tests = {
223
223
  }
224
224
  }`.replace(/\n\s*/g, '')
225
225
 
226
- expect(actual).toEqual(expected)
226
+ expect(actual).to.deep.equal(expected)
227
227
  },
228
228
 
229
- 'jcss: #4': (/** @type {import('bun:test').Expect} */ expect) => {
229
+ 'jcss: #4': (/** @type {import('chai').expect} */ expect) => {
230
230
  const actual = jcss({
231
231
  a: {
232
232
  '.b,.c': {
@@ -246,10 +246,10 @@ export const tests = {
246
246
  margin:2
247
247
  }`.replace(/\n\s*/g, '')
248
248
 
249
- expect(actual).toEqual(expected)
249
+ expect(actual).to.deep.equal(expected)
250
250
  },
251
251
 
252
- 'jcss: #5': (/** @type {import('bun:test').Expect} */ expect) => {
252
+ 'jcss: #5': (/** @type {import('chai').expect} */ expect) => {
253
253
  const actual = jcss({
254
254
  '.b,.c': {
255
255
  margin: 1,
@@ -267,10 +267,10 @@ export const tests = {
267
267
  margin:2
268
268
  }`.replace(/\n\s*/g, '')
269
269
 
270
- expect(actual).toEqual(expected)
270
+ expect(actual).to.deep.equal(expected)
271
271
  },
272
272
 
273
- 'jcss: #6': (/** @type {import('bun:test').Expect} */ expect) => {
273
+ 'jcss: #6': (/** @type {import('chai').expect} */ expect) => {
274
274
  const actual = jcss({
275
275
  '.a,.b': {
276
276
  margin: 1,
@@ -288,6 +288,6 @@ export const tests = {
288
288
  margin:2
289
289
  }`.replace(/\n\s*/g, '')
290
290
 
291
- expect(actual).toEqual(expected)
291
+ expect(actual).to.deep.equal(expected)
292
292
  }
293
293
  }
package/jsOnParse.d.ts CHANGED
@@ -16,5 +16,5 @@
16
16
  export function jsOnParse(handlers: Partial<Record<PropertyKey, Function>>, text: string): any;
17
17
 
18
18
  export namespace tests {
19
- function jsOnParse(expect: import("bun:test").Expect): void;
19
+ function jsOnParse(expect: Chai.ExpectStatic): void;
20
20
  }
package/jsOnParse.js CHANGED
@@ -40,7 +40,7 @@ export const jsOnParse = (
40
40
  })
41
41
 
42
42
  export const tests = {
43
- jsOnParse: (/** @type {import('bun:test').Expect} */ expect) => {
43
+ jsOnParse: (/** @type {import('chai').expect} */ expect) => {
44
44
  const handlers = {
45
45
  $hello: (/** @type {string} */ name) => `Hello ${name}!`,
46
46
  $foo: () => 'bar'
@@ -80,6 +80,6 @@ export const tests = {
80
80
  }
81
81
  ]
82
82
 
83
- expect(actual).toEqual(expected)
83
+ expect(actual).to.deep.equal(expected)
84
84
  }
85
85
  }
package/locale.d.ts CHANGED
@@ -4,5 +4,5 @@
4
4
  export function locale(map: Partial<Record<PropertyKey, Partial<Record<PropertyKey, string>>>>, defaultVersion: string): (text: string, version?: string) => string;
5
5
 
6
6
  export namespace tests {
7
- function locale(expect: import("bun:test").Expect): void;
7
+ function locale(expect: Chai.ExpectStatic): void;
8
8
  }
package/locale.js CHANGED
@@ -17,23 +17,23 @@ export const locale = (
17
17
  }
18
18
 
19
19
  export const tests = {
20
- locale: (/** @type {import('bun:test').Expect} */ expect) => {
20
+ locale: (/** @type {import('chai').expect} */ expect) => {
21
21
  const _ = locale({
22
22
  default: { Password: 'Hasło' },
23
23
  button: { Login: 'Zaloguj' }
24
24
  }, 'default')
25
25
 
26
- expect(_('Login')).toEqual('Login')
27
- expect(_('Password')).toEqual('Hasło')
26
+ expect(_('Login')).to.deep.equal('Login')
27
+ expect(_('Password')).to.deep.equal('Hasło')
28
28
 
29
- expect(_('Undefined text')).toEqual('Undefined text')
29
+ expect(_('Undefined text')).to.deep.equal('Undefined text')
30
30
 
31
- expect(_('Login', 'button')).toEqual('Zaloguj')
31
+ expect(_('Login', 'button')).to.deep.equal('Zaloguj')
32
32
 
33
- expect(_('Password', 'undefined_version')).toEqual('Hasło')
34
- expect(_('Undefined text', 'undefined_version')).toEqual('Undefined text')
33
+ expect(_('Password', 'undefined_version')).to.deep.equal('Hasło')
34
+ expect(_('Undefined text', 'undefined_version')).to.deep.equal('Undefined text')
35
35
 
36
- expect(_('toString')).toEqual('toString')
37
- expect(_('toString', 'undefined_version')).toEqual('toString')
36
+ expect(_('toString')).to.deep.equal('toString')
37
+ expect(_('toString', 'undefined_version')).to.deep.equal('toString')
38
38
  }
39
39
  }
package/nanolightJs.d.ts CHANGED
@@ -4,5 +4,5 @@
4
4
  export const nanolightJs: (code?: string | undefined) => import("./h.js").HArgs1[];
5
5
 
6
6
  export namespace tests {
7
- function nanolightJs(expect: import("bun:test").Expect): void;
7
+ function nanolightJs(expect: Chai.ExpectStatic): void;
8
8
  }
package/nanolightJs.js CHANGED
@@ -20,10 +20,10 @@ export const nanolightJs = nanolight.bind(0,
20
20
  )
21
21
 
22
22
  export const tests = {
23
- nanolightJs: (/** @type {import('bun:test').Expect} */ expect) => {
23
+ nanolightJs: (/** @type {import('chai').expect} */ expect) => {
24
24
  const codeJs = 'const answerToLifeTheUniverseAndEverything = 42'
25
25
 
26
- expect(h('pre', ['code', ...nanolightJs(codeJs)]).outerHTML).toEqual(
26
+ expect(h('pre', ['code', ...nanolightJs(codeJs)]).outerHTML).to.deep.equal(
27
27
  '<pre><code><span class="keyword">const</span> <span class="literal">answerToLifeTheUniverseAndEverything</span> <span class="operator">=</span> <span class="number">42</span></code></pre>')
28
28
  }
29
29
  }
package/package.json CHANGED
@@ -27,6 +27,8 @@
27
27
  "localization",
28
28
  "nanolight",
29
29
  "nnn",
30
+ "omit",
31
+ "pick",
30
32
  "RWD",
31
33
  "SVG",
32
34
  "translation",
@@ -40,5 +42,5 @@
40
42
  "types": "nnn.d.ts",
41
43
  "name": "@jackens/nnn",
42
44
  "type": "module",
43
- "version": "2024.2.17"
45
+ "version": "2024.2.20"
44
46
  }
package/pick.d.ts CHANGED
@@ -9,6 +9,6 @@ export const omit: <T extends Partial<Record<PropertyKey, any>>, K extends (keyo
9
9
  export const pick: <T extends Partial<Record<PropertyKey, any>>, K extends (keyof T)[]>(obj: T, keys: K) => Pick<T, K[number]>;
10
10
 
11
11
  export namespace tests {
12
- function pick(expect: import("bun:test").Expect): void;
13
- function omit(expect: import("bun:test").Expect): void;
12
+ function pick(expect: Chai.ExpectStatic): void;
13
+ function omit(expect: Chai.ExpectStatic): void;
14
14
  }
package/pick.js CHANGED
@@ -17,15 +17,15 @@ export const omit = (/** @type {Partial<Record<PropertyKey, any>>} */ obj, /** @
17
17
  Object.fromEntries(Object.entries(obj).filter(([key]) => !keys.includes(key)))
18
18
 
19
19
  export const tests = {
20
- pick: (/** @type {import('bun:test').Expect} */ expect) => {
20
+ pick: (/** @type {import('chai').expect} */ expect) => {
21
21
  const obj = { a: 42, b: '42', c: 17 }
22
22
 
23
- expect(pick(obj, ['a', 'b'])).toEqual({ a: 42, b: '42' })
23
+ expect(pick(obj, ['a', 'b'])).to.deep.equal({ a: 42, b: '42' })
24
24
  },
25
25
 
26
- omit: (/** @type {import('bun:test').Expect} */ expect) => {
26
+ omit: (/** @type {import('chai').expect} */ expect) => {
27
27
  const obj = { a: 42, b: '42', c: 17 }
28
28
 
29
- expect(omit(obj, ['c'])).toEqual({ a: 42, b: '42' })
29
+ expect(omit(obj, ['c'])).to.deep.equal({ a: 42, b: '42' })
30
30
  }
31
31
  }
package/plUral.d.ts CHANGED
@@ -4,5 +4,5 @@
4
4
  export function plUral(singular: string, plural2: string, plural5: string, value: number): string;
5
5
 
6
6
  export namespace tests {
7
- function plUral(expect: import("bun:test").Expect): void;
7
+ function plUral(expect: Chai.ExpectStatic): void;
8
8
  }
package/plUral.js CHANGED
@@ -19,21 +19,21 @@ export const plUral = (
19
19
  }
20
20
 
21
21
  export const tests = {
22
- plUral: (/** @type {import('bun:test').Expect} */ expect) => {
22
+ plUral: (/** @type {import('chai').expect} */ expect) => {
23
23
  // @ts-expect-error
24
24
  const auto = plUral.bind(null, 'auto', 'auta', 'aut')
25
25
 
26
- expect(auto(0)).toEqual('aut')
27
- expect(auto(1)).toEqual('auto')
28
- expect(auto(17)).toEqual('aut')
29
- expect(auto(42)).toEqual('auta')
26
+ expect(auto(0)).to.deep.equal('aut')
27
+ expect(auto(1)).to.deep.equal('auto')
28
+ expect(auto(17)).to.deep.equal('aut')
29
+ expect(auto(42)).to.deep.equal('auta')
30
30
 
31
31
  // @ts-expect-error
32
32
  const car = plUral.bind(null, 'car', 'cars', 'cars')
33
33
 
34
- expect(car(0)).toEqual('cars')
35
- expect(car(1)).toEqual('car')
36
- expect(car(17)).toEqual('cars')
37
- expect(car(42)).toEqual('cars')
34
+ expect(car(0)).to.deep.equal('cars')
35
+ expect(car(1)).to.deep.equal('car')
36
+ expect(car(17)).to.deep.equal('cars')
37
+ expect(car(42)).to.deep.equal('cars')
38
38
  }
39
39
  }
package/pro.d.ts CHANGED
@@ -4,5 +4,5 @@
4
4
  export function pro(ref: any): any;
5
5
 
6
6
  export namespace tests {
7
- function pro(expect: import("bun:test").Expect): void;
7
+ function pro(expect: Chai.ExpectStatic): void;
8
8
  }
package/pro.js CHANGED
@@ -9,31 +9,31 @@ export const pro = (/** @type {any} */ ref) => new Proxy(ref, {
9
9
  })
10
10
 
11
11
  export const tests = {
12
- pro: (/** @type {import('bun:test').Expect} */ expect) => {
12
+ pro: (/** @type {import('chai').expect} */ expect) => {
13
13
  const ref = {}
14
14
 
15
15
  pro(ref).one.two[3][4] = 1234
16
16
 
17
- expect(ref).toEqual({ one: { two: { 3: { 4: 1234 } } } })
17
+ expect(ref).to.deep.equal({ one: { two: { 3: { 4: 1234 } } } })
18
18
 
19
19
  pro(ref).one.two.tree = 123
20
20
 
21
- expect(ref).toEqual({ one: { two: { 3: { 4: 1234 }, tree: 123 } } })
21
+ expect(ref).to.deep.equal({ one: { two: { 3: { 4: 1234 }, tree: 123 } } })
22
22
 
23
23
  pro(ref).one.two = undefined
24
24
 
25
- expect(ref).toEqual({ one: { two: undefined } })
25
+ expect(ref).to.deep.equal({ one: { two: undefined } })
26
26
 
27
27
  delete pro(ref).one.two
28
28
 
29
- expect(ref).toEqual({ one: {} })
29
+ expect(ref).to.deep.equal({ one: {} })
30
30
 
31
31
  pro(ref).one.two.three.four
32
32
 
33
- expect(ref).toEqual({ one: { two: { three: { four: {} } } } })
33
+ expect(ref).to.deep.equal({ one: { two: { three: { four: {} } } } })
34
34
 
35
35
  pro(ref).one.two.three.four = 1234
36
36
 
37
- expect(ref).toEqual({ one: { two: { three: { four: 1234 } } } })
37
+ expect(ref).to.deep.equal({ one: { two: { three: { four: 1234 } } } })
38
38
  }
39
39
  }