@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/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('
|
|
22
|
-
expect(is(Number, 42)).
|
|
23
|
-
expect(is(Number, Number(42))).
|
|
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))).
|
|
26
|
-
expect(is(Number, NaN)).
|
|
27
|
-
expect(is(String, '42')).
|
|
28
|
-
expect(is(String, String('42'))).
|
|
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'))).
|
|
31
|
-
expect(is(Symbol, Symbol('42'))).
|
|
32
|
-
expect(is(Symbol, Object(Symbol('42')))).
|
|
33
|
-
expect(is(undefined, undefined)).
|
|
34
|
-
expect(is(undefined, null)).
|
|
35
|
-
expect(is(Object, {})).
|
|
36
|
-
expect(is(Array, [])).
|
|
37
|
-
expect(is(RegExp, /42/)).
|
|
38
|
-
expect(is(Date, new Date(42))).
|
|
39
|
-
expect(is(Set, new Set(['42', 42]))).
|
|
40
|
-
expect(is(Map, new Map([[{ j: 42 }, { J: '42' }], [{ c: 42 }, { C: '42' }]]))).
|
|
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('
|
|
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())).
|
|
49
|
-
expect(iz(FooBar, new FooBar())).
|
|
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())).
|
|
52
|
-
expect(iz(Object, new FooBar())).
|
|
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)).
|
|
60
|
-
expect(iz(FooBar, fakeFooBar)).
|
|
59
|
+
expect(is(FooBar, fakeFooBar)).to.be.false
|
|
60
|
+
expect(iz(FooBar, fakeFooBar)).to.be.true
|
|
61
61
|
|
|
62
|
-
expect(is(Object, fakeFooBar)).
|
|
63
|
-
expect(iz(Object, fakeFooBar)).
|
|
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:
|
|
28
|
-
'jcss: #2': (expect:
|
|
29
|
-
'jcss: #3': (expect:
|
|
30
|
-
'jcss: #4': (expect:
|
|
31
|
-
'jcss: #5': (expect:
|
|
32
|
-
'jcss: #6': (expect:
|
|
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('
|
|
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).
|
|
123
|
+
expect(actual).to.deep.equal(expected)
|
|
124
124
|
},
|
|
125
125
|
|
|
126
|
-
'jcss: #2': (/** @type {import('
|
|
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).
|
|
151
|
+
expect(actual).to.deep.equal(expected)
|
|
152
152
|
},
|
|
153
153
|
|
|
154
|
-
'jcss: #3': (/** @type {import('
|
|
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).
|
|
226
|
+
expect(actual).to.deep.equal(expected)
|
|
227
227
|
},
|
|
228
228
|
|
|
229
|
-
'jcss: #4': (/** @type {import('
|
|
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).
|
|
249
|
+
expect(actual).to.deep.equal(expected)
|
|
250
250
|
},
|
|
251
251
|
|
|
252
|
-
'jcss: #5': (/** @type {import('
|
|
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).
|
|
270
|
+
expect(actual).to.deep.equal(expected)
|
|
271
271
|
},
|
|
272
272
|
|
|
273
|
-
'jcss: #6': (/** @type {import('
|
|
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).
|
|
291
|
+
expect(actual).to.deep.equal(expected)
|
|
292
292
|
}
|
|
293
293
|
}
|
package/jsOnParse.d.ts
CHANGED
package/jsOnParse.js
CHANGED
|
@@ -40,7 +40,7 @@ export const jsOnParse = (
|
|
|
40
40
|
})
|
|
41
41
|
|
|
42
42
|
export const tests = {
|
|
43
|
-
jsOnParse: (/** @type {import('
|
|
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).
|
|
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:
|
|
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('
|
|
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')).
|
|
27
|
-
expect(_('Password')).
|
|
26
|
+
expect(_('Login')).to.deep.equal('Login')
|
|
27
|
+
expect(_('Password')).to.deep.equal('Hasło')
|
|
28
28
|
|
|
29
|
-
expect(_('Undefined text')).
|
|
29
|
+
expect(_('Undefined text')).to.deep.equal('Undefined text')
|
|
30
30
|
|
|
31
|
-
expect(_('Login', 'button')).
|
|
31
|
+
expect(_('Login', 'button')).to.deep.equal('Zaloguj')
|
|
32
32
|
|
|
33
|
-
expect(_('Password', 'undefined_version')).
|
|
34
|
-
expect(_('Undefined text', 'undefined_version')).
|
|
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')).
|
|
37
|
-
expect(_('toString', 'undefined_version')).
|
|
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
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('
|
|
23
|
+
nanolightJs: (/** @type {import('chai').expect} */ expect) => {
|
|
24
24
|
const codeJs = 'const answerToLifeTheUniverseAndEverything = 42'
|
|
25
25
|
|
|
26
|
-
expect(h('pre', ['code', ...nanolightJs(codeJs)]).outerHTML).
|
|
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.
|
|
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:
|
|
13
|
-
function omit(expect:
|
|
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('
|
|
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'])).
|
|
23
|
+
expect(pick(obj, ['a', 'b'])).to.deep.equal({ a: 42, b: '42' })
|
|
24
24
|
},
|
|
25
25
|
|
|
26
|
-
omit: (/** @type {import('
|
|
26
|
+
omit: (/** @type {import('chai').expect} */ expect) => {
|
|
27
27
|
const obj = { a: 42, b: '42', c: 17 }
|
|
28
28
|
|
|
29
|
-
expect(omit(obj, ['c'])).
|
|
29
|
+
expect(omit(obj, ['c'])).to.deep.equal({ a: 42, b: '42' })
|
|
30
30
|
}
|
|
31
31
|
}
|
package/plUral.d.ts
CHANGED
package/plUral.js
CHANGED
|
@@ -19,21 +19,21 @@ export const plUral = (
|
|
|
19
19
|
}
|
|
20
20
|
|
|
21
21
|
export const tests = {
|
|
22
|
-
plUral: (/** @type {import('
|
|
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)).
|
|
27
|
-
expect(auto(1)).
|
|
28
|
-
expect(auto(17)).
|
|
29
|
-
expect(auto(42)).
|
|
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)).
|
|
35
|
-
expect(car(1)).
|
|
36
|
-
expect(car(17)).
|
|
37
|
-
expect(car(42)).
|
|
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
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('
|
|
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).
|
|
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).
|
|
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).
|
|
25
|
+
expect(ref).to.deep.equal({ one: { two: undefined } })
|
|
26
26
|
|
|
27
27
|
delete pro(ref).one.two
|
|
28
28
|
|
|
29
|
-
expect(ref).
|
|
29
|
+
expect(ref).to.deep.equal({ one: {} })
|
|
30
30
|
|
|
31
31
|
pro(ref).one.two.three.four
|
|
32
32
|
|
|
33
|
-
expect(ref).
|
|
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).
|
|
37
|
+
expect(ref).to.deep.equal({ one: { two: { three: { four: 1234 } } } })
|
|
38
38
|
}
|
|
39
39
|
}
|