@jackens/nnn 2024.2.11 → 2024.2.12
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/eq.d.ts +1 -1
- package/eq.js +26 -26
- 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 +29 -30
- package/has.d.ts +2 -2
- package/has.js +13 -13
- 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 -3
- package/locale.d.ts +1 -1
- package/locale.js +9 -9
- package/nanolightJs.d.ts +1 -1
- package/nanolightJs.js +2 -2
- package/nnn.d.ts +3 -1
- package/nnn.js +5 -1
- package/package.json +1 -1
- package/pick.d.ts +14 -0
- package/pick.js +57 -0
- package/plUral.d.ts +1 -1
- package/plUral.js +9 -9
- package/pro.d.ts +1 -1
- package/pro.js +7 -9
- package/readme.md +164 -130
- package/refsInfo.d.ts +2 -2
- package/refsInfo.js +4 -4
- package/uuid1.d.ts +3 -3
- package/uuid1.js +13 -13
- package/tests.d.ts +0 -30
- package/tests.js +0 -35
package/eq.d.ts
CHANGED
package/eq.js
CHANGED
|
@@ -45,39 +45,39 @@ export const eq = /** @return {boolean} */ (/** @type {any} */ x, /** @type {any
|
|
|
45
45
|
}
|
|
46
46
|
|
|
47
47
|
export const tests = {
|
|
48
|
-
eq: () => {
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
48
|
+
eq: (/** @type {import('bun:test').Expect} */ expect) => {
|
|
49
|
+
expect(eq(true, true)).toBe(true)
|
|
50
|
+
expect(eq(NaN, NaN)).toBe(true)
|
|
51
|
+
expect(eq(null, undefined)).toBe(false)
|
|
52
|
+
expect(eq(42, 42)).toBe(true)
|
|
53
53
|
// eslint-disable-next-line no-new-wrappers
|
|
54
|
-
|
|
55
|
-
|
|
54
|
+
expect(eq(42, new Number(42))).toBe(true)
|
|
55
|
+
expect(eq(42, Number(42))).toBe(true)
|
|
56
56
|
// eslint-disable-next-line no-new-wrappers
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
57
|
+
expect(eq(new Number(42), Number(42))).toBe(true)
|
|
58
|
+
expect(eq(42, '42')).toBe(false)
|
|
59
|
+
expect(eq('42', '42')).toBe(true)
|
|
60
60
|
// eslint-disable-next-line no-new-wrappers
|
|
61
|
-
|
|
62
|
-
|
|
61
|
+
expect(eq('42', new String('42'))).toBe(true)
|
|
62
|
+
expect(eq('42', String('42'))).toBe(true)
|
|
63
63
|
// eslint-disable-next-line no-new-wrappers
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
64
|
+
expect(eq(String('42'), new String('42'))).toBe(true)
|
|
65
|
+
expect(eq(/42/, /42/)).toBe(true)
|
|
66
|
+
expect(eq(/42/, /42/g)).toBe(false)
|
|
67
|
+
expect(eq(new Date(42), new Date(42))).toBe(true)
|
|
68
|
+
expect(eq(new Date(), new Date(42))).toBe(false)
|
|
69
|
+
expect(eq({ j: '42', c: 42 }, { c: 42, j: '42' })).toBe(true)
|
|
70
|
+
expect(eq([42, '42'], [42, '42'])).toBe(true)
|
|
71
|
+
expect(eq(new Set(['42', 42]), new Set([42, '42']))).toBe(true)
|
|
72
|
+
expect(eq(new Set(['42', 42]), new Set([42]))).toBe(false)
|
|
73
|
+
expect(eq(new Set([42, undefined]), new Set([42]))).toBe(false)
|
|
74
|
+
expect(eq(
|
|
75
75
|
new Map([[{ j: 42 }, { J: '42' }], [{ c: 42 }, { C: '42' }]]),
|
|
76
76
|
new Map([[{ c: 42 }, { C: '42' }], [{ j: 42 }, { J: '42' }]])
|
|
77
|
-
))
|
|
78
|
-
|
|
77
|
+
)).toBe(true)
|
|
78
|
+
expect(eq(
|
|
79
79
|
new Map([[{ j: 42 }, { J: '42' }], [{ c: 42 }, { C: '42' }]]),
|
|
80
80
|
new Map([[{ j: '42' }, { J: 42 }], [{ c: '42' }, { C: 42 }]])
|
|
81
|
-
))
|
|
81
|
+
)).toBe(false)
|
|
82
82
|
}
|
|
83
83
|
}
|
package/escape.d.ts
CHANGED
|
@@ -14,5 +14,5 @@ export function escape(escapeMap: EscapeMap, template: TemplateStringsArray, ...
|
|
|
14
14
|
export function escapeValues(escapeMap: EscapeMap, values: any[]): string[];
|
|
15
15
|
|
|
16
16
|
export namespace tests {
|
|
17
|
-
function escape(): void;
|
|
17
|
+
function escape(expect: import("bun:test").Expect): void;
|
|
18
18
|
}
|
package/escape.js
CHANGED
|
@@ -22,7 +22,7 @@ export const escape = (
|
|
|
22
22
|
) => String.raw(template, ...escapeValues(escapeMap, values))
|
|
23
23
|
|
|
24
24
|
export const tests = {
|
|
25
|
-
escape: () => {
|
|
25
|
+
escape: (/** @type {import('bun:test').Expect} */ expect) => {
|
|
26
26
|
// @ts-ignore
|
|
27
27
|
const /** @type {EscapeMap} */ escapeMap = new Map([
|
|
28
28
|
[undefined, () => 'NULL'],
|
|
@@ -46,6 +46,6 @@ export const tests = {
|
|
|
46
46
|
FROM table_name
|
|
47
47
|
WHERE column_name IN (b'1', NULL, NULL, 42, '42', '4''2', NULL, '1980-03-31 04:30:00')`
|
|
48
48
|
|
|
49
|
-
|
|
49
|
+
expect(actual).toEqual(expected)
|
|
50
50
|
}
|
|
51
51
|
}
|
package/fixTypography.d.ts
CHANGED
package/fixTypography.js
CHANGED
|
@@ -49,12 +49,12 @@ export const fixTypography = (/** @type {Node} */ node) => {
|
|
|
49
49
|
}
|
|
50
50
|
|
|
51
51
|
export const tests = {
|
|
52
|
-
fixTypography: () => {
|
|
52
|
+
fixTypography: (/** @type {import('bun:test').Expect} */ expect) => {
|
|
53
53
|
const p = h('p', 'Pchnąć w tę łódź jeża lub ośm skrzyń fig (zob. https://pl.wikipedia.org/wiki/Pangram).')
|
|
54
54
|
|
|
55
55
|
fixTypography(p)
|
|
56
56
|
|
|
57
|
-
|
|
57
|
+
expect(p.innerHTML).toEqual(
|
|
58
58
|
'Pchnąć <span style="white-space:nowrap">w </span>tę łódź jeża lub ośm skrzyń fig ' +
|
|
59
59
|
'(zob. https://\u200Bpl.\u200Bwikipedia.\u200Borg/\u200Bwiki/\u200BPangram).')
|
|
60
60
|
}
|
package/h.d.ts
CHANGED
|
@@ -47,9 +47,9 @@ export function s<N extends Node>(node: N, ...args1: HArgs1[]): N;
|
|
|
47
47
|
export function s(tagOrNode: string | Node, ...args1: HArgs1[]): Node;
|
|
48
48
|
|
|
49
49
|
export const tests: {
|
|
50
|
-
h: () => void;
|
|
51
|
-
'h: innerText vs items': () => void;
|
|
52
|
-
'h: style': () => void;
|
|
53
|
-
'h: attributes vs properties': () => void;
|
|
54
|
-
'h: nested properties': () => void;
|
|
50
|
+
h: (expect: import('bun:test').Expect) => void;
|
|
51
|
+
'h: innerText vs items': (expect: import('bun:test').Expect) => void;
|
|
52
|
+
'h: style': (expect: import('bun:test').Expect) => void;
|
|
53
|
+
'h: attributes vs properties': (expect: import('bun:test').Expect) => void;
|
|
54
|
+
'h: nested properties': (expect: import('bun:test').Expect) => void;
|
|
55
55
|
};
|
package/h.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { eq } from './eq.js'
|
|
2
1
|
import { is } from './is.js'
|
|
3
2
|
|
|
4
3
|
/**
|
|
@@ -143,72 +142,72 @@ export const h = _h()
|
|
|
143
142
|
export const s = _h('http://www.w3.org/2000/svg')
|
|
144
143
|
|
|
145
144
|
export const tests = {
|
|
146
|
-
h: () => {
|
|
145
|
+
h: (/** @type {import('bun:test').Expect} */ expect) => {
|
|
147
146
|
const b = h('b')
|
|
148
147
|
|
|
149
|
-
|
|
148
|
+
expect(b.outerHTML).toEqual('<b></b>')
|
|
150
149
|
|
|
151
150
|
const i = h('i', 'text')
|
|
152
151
|
|
|
153
152
|
h(b, i)
|
|
154
153
|
|
|
155
|
-
|
|
156
|
-
|
|
154
|
+
expect(i.outerHTML).toEqual('<i>text</i>')
|
|
155
|
+
expect(b.outerHTML).toEqual('<b><i>text</i></b>')
|
|
157
156
|
|
|
158
157
|
h(i, { $className: 'some class' })
|
|
159
158
|
|
|
160
|
-
|
|
161
|
-
|
|
159
|
+
expect(i.outerHTML).toEqual('<i class="some class">text</i>')
|
|
160
|
+
expect(b.outerHTML).toEqual('<b><i class="some class">text</i></b>')
|
|
162
161
|
},
|
|
163
162
|
|
|
164
|
-
'h: innerText vs items': () => {
|
|
165
|
-
|
|
166
|
-
|
|
163
|
+
'h: innerText vs items': (/** @type {import('bun:test').Expect} */ expect) => {
|
|
164
|
+
expect(h('span', 'text').outerHTML).toEqual('<span>text</span>')
|
|
165
|
+
expect(h('span', { $innerText: 'text' }).outerHTML).toEqual('<span>text</span>')
|
|
167
166
|
},
|
|
168
167
|
|
|
169
|
-
'h: style': () => {
|
|
170
|
-
|
|
171
|
-
'<div style="margin:0;padding:0"></div>')
|
|
172
|
-
|
|
173
|
-
'<div style="margin: 0px; padding: 0px;"></div>')
|
|
174
|
-
|
|
175
|
-
'<div style="margin: 0px; padding: 0px;"></div>')
|
|
168
|
+
'h: style': (/** @type {import('bun:test').Expect} */ expect) => {
|
|
169
|
+
expect(h('div', { style: 'margin:0;padding:0' }).outerHTML)
|
|
170
|
+
.toEqual('<div style="margin:0;padding:0"></div>')
|
|
171
|
+
expect(h('div', { $style: 'margin:0;padding:0' }).outerHTML)
|
|
172
|
+
.toEqual('<div style="margin: 0px; padding: 0px;"></div>')
|
|
173
|
+
expect(h('div', { $style: { margin: 0, padding: 0 } }).outerHTML)
|
|
174
|
+
.toEqual('<div style="margin: 0px; padding: 0px;"></div>')
|
|
176
175
|
},
|
|
177
176
|
|
|
178
|
-
'h: attributes vs properties': () => {
|
|
177
|
+
'h: attributes vs properties': (/** @type {import('bun:test').Expect} */ expect) => {
|
|
179
178
|
const input1 = h('input', { value: 42 })
|
|
180
179
|
const input2 = h('input', { $value: '42' })
|
|
181
180
|
|
|
182
|
-
|
|
183
|
-
|
|
181
|
+
expect(input1.value).toEqual('42')
|
|
182
|
+
expect(input2.value).toEqual('42')
|
|
184
183
|
|
|
185
|
-
|
|
186
|
-
|
|
184
|
+
expect(input1.outerHTML).toEqual('<input value="42">')
|
|
185
|
+
expect(input2.outerHTML).toEqual('<input>')
|
|
187
186
|
|
|
188
187
|
const checkbox1 = h('input', { type: 'checkbox', checked: true })
|
|
189
188
|
const checkbox2 = h('input', { type: 'checkbox', $checked: true })
|
|
190
189
|
|
|
191
|
-
|
|
192
|
-
|
|
190
|
+
expect(checkbox1.checked).toBe(true)
|
|
191
|
+
expect(checkbox2.checked).toBe(true)
|
|
193
192
|
|
|
194
|
-
|
|
195
|
-
|
|
193
|
+
expect(checkbox1.outerHTML).toEqual('<input type="checkbox" checked="">')
|
|
194
|
+
expect(checkbox2.outerHTML).toEqual('<input type="checkbox">')
|
|
196
195
|
},
|
|
197
196
|
|
|
198
|
-
'h: nested properties': () => {
|
|
197
|
+
'h: nested properties': (/** @type {import('bun:test').Expect} */ expect) => {
|
|
199
198
|
const div = h('div')
|
|
200
199
|
|
|
201
200
|
// @ts-ignore
|
|
202
|
-
|
|
201
|
+
expect(div.key).toBeUndefined()
|
|
203
202
|
|
|
204
203
|
h(div, { $key: { one: 1 } })
|
|
205
204
|
|
|
206
205
|
// @ts-ignore
|
|
207
|
-
|
|
206
|
+
expect(div.key).toEqual({ one: 1 })
|
|
208
207
|
|
|
209
208
|
h(div, { $key: { two: 2 } })
|
|
210
209
|
|
|
211
210
|
// @ts-ignore
|
|
212
|
-
|
|
211
|
+
expect(div.key).toEqual({ one: 1, two: 2 })
|
|
213
212
|
}
|
|
214
213
|
}
|
package/has.d.ts
CHANGED
package/has.js
CHANGED
|
@@ -7,34 +7,34 @@ export const has = (/** @type {any} */ key, /** @type {any} */ ref) =>
|
|
|
7
7
|
(is(String, key) || is(Number, key) || is(Symbol, key)) && Object.hasOwnProperty.call(ref ?? Object, key)
|
|
8
8
|
|
|
9
9
|
export const tests = {
|
|
10
|
-
has: () => {
|
|
10
|
+
has: (/** @type {import('bun:test').Expect} */ expect) => {
|
|
11
11
|
const obj = { key: 'K', null: 'N' }
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
13
|
+
expect('key' in obj).toBe(true)
|
|
14
|
+
expect(has('key', obj)).toBe(true)
|
|
15
15
|
|
|
16
|
-
|
|
17
|
-
|
|
16
|
+
expect('null' in obj).toBe(true)
|
|
17
|
+
expect(has('null', obj)).toBe(true)
|
|
18
18
|
|
|
19
19
|
// @ts-ignore
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
expect(null in obj).toBe(true)
|
|
21
|
+
expect(has(null, obj)).toBe(false)
|
|
22
22
|
|
|
23
|
-
|
|
24
|
-
|
|
23
|
+
expect('toString' in obj).toBe(true)
|
|
24
|
+
expect(has('toString', obj)).toBe(false)
|
|
25
25
|
},
|
|
26
26
|
|
|
27
|
-
'has: null': () => {
|
|
27
|
+
'has: null': (/** @type {import('bun:test').Expect} */ expect) => {
|
|
28
28
|
let typeError
|
|
29
29
|
|
|
30
30
|
try {
|
|
31
31
|
// @ts-ignore
|
|
32
|
-
|
|
32
|
+
'key' in null
|
|
33
33
|
} catch (error) {
|
|
34
34
|
typeError = error
|
|
35
35
|
}
|
|
36
36
|
|
|
37
|
-
|
|
38
|
-
|
|
37
|
+
expect(typeError instanceof TypeError) // Cannot use 'in' operator to search for 'key' in null
|
|
38
|
+
expect(has('key', null)).toBe(false)
|
|
39
39
|
}
|
|
40
40
|
}
|
package/is.d.ts
CHANGED
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: () => {
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
is: (/** @type {import('bun:test').Expect} */ expect) => {
|
|
22
|
+
expect(is(Number, 42)).toBe(true)
|
|
23
|
+
expect(is(Number, Number(42))).toBe(true)
|
|
24
24
|
// eslint-disable-next-line no-new-wrappers
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
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)
|
|
29
29
|
// eslint-disable-next-line no-new-wrappers
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
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)
|
|
41
41
|
},
|
|
42
42
|
|
|
43
|
-
'is: toString.call': () => {
|
|
43
|
+
'is: toString.call': (/** @type {import('bun:test').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
|
-
|
|
49
|
-
|
|
48
|
+
expect(is(FooBar, new FooBar())).toBe(true)
|
|
49
|
+
expect(iz(FooBar, new FooBar())).toBe(false)
|
|
50
50
|
|
|
51
|
-
|
|
52
|
-
|
|
51
|
+
expect(is(Object, new FooBar())).toBe(false)
|
|
52
|
+
expect(iz(Object, new FooBar())).toBe(true)
|
|
53
53
|
|
|
54
54
|
const fakeFooBar = {}
|
|
55
55
|
|
|
56
56
|
// @ts-ignore
|
|
57
57
|
fakeFooBar[Symbol.toStringTag] = FooBar.name
|
|
58
58
|
|
|
59
|
-
|
|
60
|
-
|
|
59
|
+
expect(is(FooBar, fakeFooBar)).toBe(false)
|
|
60
|
+
expect(iz(FooBar, fakeFooBar)).toBe(true)
|
|
61
61
|
|
|
62
|
-
|
|
63
|
-
|
|
62
|
+
expect(is(Object, fakeFooBar)).toBe(true)
|
|
63
|
+
expect(iz(Object, fakeFooBar)).toBe(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': () => void;
|
|
28
|
-
'jcss: #2': () => void;
|
|
29
|
-
'jcss: #3': () => void;
|
|
30
|
-
'jcss: #4': () => void;
|
|
31
|
-
'jcss: #5': () => void;
|
|
32
|
-
'jcss: #6': () => void;
|
|
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;
|
|
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': () => {
|
|
100
|
+
'jcss: #1': (/** @type {import('bun:test').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
|
-
|
|
123
|
+
expect(actual).toEqual(expected)
|
|
124
124
|
},
|
|
125
125
|
|
|
126
|
-
'jcss: #2': () => {
|
|
126
|
+
'jcss: #2': (/** @type {import('bun:test').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
|
-
|
|
151
|
+
expect(actual).toEqual(expected)
|
|
152
152
|
},
|
|
153
153
|
|
|
154
|
-
'jcss: #3': () => {
|
|
154
|
+
'jcss: #3': (/** @type {import('bun:test').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
|
-
|
|
226
|
+
expect(actual).toEqual(expected)
|
|
227
227
|
},
|
|
228
228
|
|
|
229
|
-
'jcss: #4': () => {
|
|
229
|
+
'jcss: #4': (/** @type {import('bun:test').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
|
-
|
|
249
|
+
expect(actual).toEqual(expected)
|
|
250
250
|
},
|
|
251
251
|
|
|
252
|
-
'jcss: #5': () => {
|
|
252
|
+
'jcss: #5': (/** @type {import('bun:test').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
|
-
|
|
270
|
+
expect(actual).toEqual(expected)
|
|
271
271
|
},
|
|
272
272
|
|
|
273
|
-
'jcss: #6': () => {
|
|
273
|
+
'jcss: #6': (/** @type {import('bun:test').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
|
-
|
|
291
|
+
expect(actual).toEqual(expected)
|
|
292
292
|
}
|
|
293
293
|
}
|
package/jsOnParse.d.ts
CHANGED
package/jsOnParse.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { eq } from './eq.js'
|
|
2
1
|
import { has } from './has.js'
|
|
3
2
|
import { is } from './is.js'
|
|
4
3
|
|
|
@@ -41,7 +40,7 @@ export const jsOnParse = (
|
|
|
41
40
|
})
|
|
42
41
|
|
|
43
42
|
export const tests = {
|
|
44
|
-
jsOnParse: () => {
|
|
43
|
+
jsOnParse: (/** @type {import('bun:test').Expect} */ expect) => {
|
|
45
44
|
const handlers = {
|
|
46
45
|
$hello: (/** @type {string} */ name) => `Hello ${name}!`,
|
|
47
46
|
$foo: () => 'bar'
|
|
@@ -81,6 +80,6 @@ export const tests = {
|
|
|
81
80
|
}
|
|
82
81
|
]
|
|
83
82
|
|
|
84
|
-
|
|
83
|
+
expect(actual).toEqual(expected)
|
|
85
84
|
}
|
|
86
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(): void;
|
|
7
|
+
function locale(expect: import("bun:test").Expect): 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: () => {
|
|
20
|
+
locale: (/** @type {import('bun:test').Expect} */ expect) => {
|
|
21
21
|
const _ = locale({
|
|
22
22
|
default: { Password: 'Hasło' },
|
|
23
23
|
button: { Login: 'Zaloguj' }
|
|
24
24
|
}, 'default')
|
|
25
25
|
|
|
26
|
-
|
|
27
|
-
|
|
26
|
+
expect(_('Login')).toEqual('Login')
|
|
27
|
+
expect(_('Password')).toEqual('Hasło')
|
|
28
28
|
|
|
29
|
-
|
|
29
|
+
expect(_('Undefined text')).toEqual('Undefined text')
|
|
30
30
|
|
|
31
|
-
|
|
31
|
+
expect(_('Login', 'button')).toEqual('Zaloguj')
|
|
32
32
|
|
|
33
|
-
|
|
34
|
-
|
|
33
|
+
expect(_('Password', 'undefined_version')).toEqual('Hasło')
|
|
34
|
+
expect(_('Undefined text', 'undefined_version')).toEqual('Undefined text')
|
|
35
35
|
|
|
36
|
-
|
|
37
|
-
|
|
36
|
+
expect(_('toString')).toEqual('toString')
|
|
37
|
+
expect(_('toString', 'undefined_version')).toEqual('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: () => {
|
|
23
|
+
nanolightJs: (/** @type {import('bun:test').Expect} */ expect) => {
|
|
24
24
|
const codeJs = 'const answerToLifeTheUniverseAndEverything = 42'
|
|
25
25
|
|
|
26
|
-
|
|
26
|
+
expect(h('pre', ['code', ...nanolightJs(codeJs)]).outerHTML).toEqual(
|
|
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/nnn.d.ts
CHANGED
|
@@ -11,9 +11,11 @@ import { jsOnParse } from './jsOnParse.js';
|
|
|
11
11
|
import { locale } from './locale.js';
|
|
12
12
|
import { nanolight } from './nanolight.js';
|
|
13
13
|
import { nanolightJs } from './nanolightJs.js';
|
|
14
|
+
import { omit } from './pick.js';
|
|
15
|
+
import { pick } from './pick.js';
|
|
14
16
|
import { plUral } from './plUral.js';
|
|
15
17
|
import { pro } from './pro.js';
|
|
16
18
|
import { refsInfo } from './refsInfo.js';
|
|
17
19
|
import { s } from './h.js';
|
|
18
20
|
import { uuid1 } from './uuid1.js';
|
|
19
|
-
export { chartable, eq, escape, escapeValues, fixTypography, h, has, is, jcss, jsOnParse, locale, nanolight, nanolightJs, plUral, pro, refsInfo, s, uuid1 };
|
|
21
|
+
export { chartable, eq, escape, escapeValues, fixTypography, h, has, is, jcss, jsOnParse, locale, nanolight, nanolightJs, omit, pick, plUral, pro, refsInfo, s, uuid1 };
|
package/nnn.js
CHANGED
|
@@ -10,6 +10,7 @@ import { jsOnParse } from './jsOnParse.js'
|
|
|
10
10
|
import { locale } from './locale.js'
|
|
11
11
|
import { nanolight } from './nanolight.js'
|
|
12
12
|
import { nanolightJs } from './nanolightJs.js'
|
|
13
|
+
import { omit, pick } from './pick.js'
|
|
13
14
|
import { plUral } from './plUral.js'
|
|
14
15
|
import { pro } from './pro.js'
|
|
15
16
|
import { refsInfo } from './refsInfo.js'
|
|
@@ -18,7 +19,8 @@ import { uuid1 } from './uuid1.js'
|
|
|
18
19
|
export {
|
|
19
20
|
chartable,
|
|
20
21
|
eq,
|
|
21
|
-
escape,
|
|
22
|
+
escape,
|
|
23
|
+
escapeValues,
|
|
22
24
|
fixTypography,
|
|
23
25
|
h,
|
|
24
26
|
has,
|
|
@@ -28,6 +30,8 @@ export {
|
|
|
28
30
|
locale,
|
|
29
31
|
nanolight,
|
|
30
32
|
nanolightJs,
|
|
33
|
+
omit,
|
|
34
|
+
pick,
|
|
31
35
|
plUral,
|
|
32
36
|
pro,
|
|
33
37
|
refsInfo,
|
package/package.json
CHANGED