@jackens/nnn 2023.12.19 → 2024.1.2

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 CHANGED
@@ -38,4 +38,4 @@ export function chartable({ bottom, gapX, gapY, headerColumn, headerRow, id, lef
38
38
  zxY?: number[][];
39
39
  }): SVGSVGElement;
40
40
 
41
- export const tests: Record<string, () => void>;
41
+ export const tests: {};
package/chartable.js CHANGED
@@ -65,21 +65,22 @@ export const chartable = ({
65
65
  const xLabelsNotPassed = !xLabels.length
66
66
  const zLabelsNotPassed = !zLabels.length
67
67
 
68
- table.querySelectorAll('tr').forEach((row, r) => row.querySelectorAll('td,th').forEach((col, c) => {
69
- const x = r - +headerRow
70
- const z = c - +headerColumn
71
- // @ts-expect-error
72
- const value = col.innerText
73
-
74
- if (x >= 0 && z >= 0 && zxYNotPassed) {
75
- zxY[z] = zxY[z] ?? []
76
- zxY[z][x] = parseFloat(value)
77
- } else if (x >= 0 && z < 0 && xLabelsNotPassed) {
78
- xLabels[x] = value
79
- } else if (x < 0 && z >= 0 && zLabelsNotPassed) {
80
- zLabels[z] = value
81
- }
82
- }))
68
+ table.querySelectorAll('tr').forEach((row, r) =>
69
+ // @ts-ignore
70
+ row.querySelectorAll('td,th').forEach((/** @type {HTMLTableCellElement} */ col, c) => {
71
+ const x = r - +headerRow
72
+ const z = c - +headerColumn
73
+ const value = col.innerText
74
+
75
+ if (x >= 0 && z >= 0 && zxYNotPassed) {
76
+ zxY[z] = zxY[z] ?? []
77
+ zxY[z][x] = parseFloat(value)
78
+ } else if (x >= 0 && z < 0 && xLabelsNotPassed) {
79
+ xLabels[x] = value
80
+ } else if (x < 0 && z >= 0 && zLabelsNotPassed) {
81
+ zLabels[z] = value
82
+ }
83
+ }))
83
84
  }
84
85
 
85
86
  let bestScales = [Infinity, -Infinity, Infinity, -Infinity, Infinity]
@@ -215,4 +216,4 @@ export const chartable = ({
215
216
  )
216
217
  }
217
218
 
218
- export const /** @type {Record<string, () => void>} */ tests = {}
219
+ export const tests = {}
package/eq.d.ts CHANGED
@@ -3,4 +3,6 @@
3
3
  */
4
4
  export function eq(x: any, y: any): boolean;
5
5
 
6
- export const tests: Record<string, () => void>;
6
+ export namespace tests {
7
+ function eq(): void;
8
+ }
package/eq.js CHANGED
@@ -44,7 +44,7 @@ export const eq = /** @return {boolean} */ (/** @type {any} */ x, /** @type {any
44
44
  return false
45
45
  }
46
46
 
47
- export const /** @type {Record<string, () => void>} */ tests = {
47
+ export const tests = {
48
48
  eq: () => {
49
49
  console.assert(eq(true, true))
50
50
  console.assert(eq(NaN, NaN))
package/escape.d.ts CHANGED
@@ -13,4 +13,6 @@ export function escape(escapeMap: EscapeMap, template: TemplateStringsArray, ...
13
13
  */
14
14
  export function escapeValues(escapeMap: EscapeMap, values: any[]): string[];
15
15
 
16
- export const tests: Record<string, () => void>;
16
+ export namespace tests {
17
+ function escape(): void;
18
+ }
package/escape.js CHANGED
@@ -21,9 +21,9 @@ export const escape = (
21
21
  /** @type {any[]} */ ...values
22
22
  ) => String.raw(template, ...escapeValues(escapeMap, values))
23
23
 
24
- export const /** @type {Record<string, () => void>} */ tests = {
24
+ export const tests = {
25
25
  escape: () => {
26
- // @ts-expect-error
26
+ // @ts-ignore
27
27
  const /** @type {EscapeMap} */ escapeMap = new Map([
28
28
  [undefined, () => 'NULL'],
29
29
  [Array, (/** @type {any[]} */ values) => escapeValues(escapeMap, values).join(', ')],
@@ -33,7 +33,7 @@ export const /** @type {Record<string, () => void>} */ tests = {
33
33
  [String, (/** @type {string} */ value) => `'${value.replace(/'/g, "''")}'`]
34
34
  ])
35
35
 
36
- // @ts-expect-error
36
+ // @ts-ignore
37
37
  const sql = escape.bind(null, escapeMap)
38
38
 
39
39
  const actual = sql`
@@ -3,4 +3,6 @@
3
3
  */
4
4
  export function fixTypography(node: Node): void;
5
5
 
6
- export const tests: Record<string, () => void>;
6
+ export namespace tests {
7
+ function fixTypography(): void;
8
+ }
package/fixTypography.js CHANGED
@@ -48,7 +48,7 @@ export const fixTypography = (/** @type {Node} */ node) => {
48
48
  }
49
49
  }
50
50
 
51
- export const /** @type {Record<string, () => void>} */ tests = {
51
+ export const tests = {
52
52
  fixTypography: () => {
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
 
package/h.d.ts CHANGED
@@ -46,4 +46,10 @@ export function s<T extends keyof SVGElementTagNameMap>(tag: T, ...args1: HArgs1
46
46
  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
- export const tests: Record<string, () => void>;
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;
55
+ };
package/h.js CHANGED
@@ -13,7 +13,7 @@ import { is } from './is.js'
13
13
  * @typedef {[string | Node, ...HArgs1[]]} HArgs
14
14
  */
15
15
 
16
- const /** @type {Record<string, string>} */ NS = {
16
+ const NS = {
17
17
  xlink: 'http://www.w3.org/1999/xlink'
18
18
  }
19
19
 
@@ -45,10 +45,10 @@ const _h = (/** @type {string?=} */ namespaceURI) => {
45
45
  if (arg instanceof Node) {
46
46
  child = arg
47
47
  } else if (is(String, arg) || is(Number, arg)) {
48
- // @ts-expect-error
48
+ // @ts-ignore
49
49
  child = new Text(arg)
50
50
  } else if (is(Array, arg)) {
51
- // @ts-expect-error
51
+ // @ts-ignore
52
52
  child = h(...arg)
53
53
  } else if (arg != null) {
54
54
  for (const name in arg) {
@@ -58,18 +58,19 @@ const _h = (/** @type {string?=} */ namespaceURI) => {
58
58
  const name1 = name.slice(1)
59
59
 
60
60
  if (is(Object, value)) {
61
- // @ts-expect-error
61
+ // @ts-ignore
62
62
  node[name1] = node[name1] ?? {}
63
- // @ts-expect-error
63
+ // @ts-ignore
64
64
  Object.assign(node[name1], value)
65
65
  } else {
66
- // @ts-expect-error
66
+ // @ts-ignore
67
67
  node[name1] = value
68
68
  }
69
69
  } else if (node instanceof Element) {
70
70
  const indexOfColon = name.indexOf(':')
71
71
 
72
72
  if (indexOfColon >= 0) {
73
+ // @ts-ignore
73
74
  const /** @type {string=} */ ns = NS[name.slice(0, indexOfColon)]
74
75
 
75
76
  if (ns != null) {
@@ -141,7 +142,7 @@ export const h = _h()
141
142
  */
142
143
  export const s = _h('http://www.w3.org/2000/svg')
143
144
 
144
- export const /** @type {Record<string, () => void>} */ tests = {
145
+ export const tests = {
145
146
  h: () => {
146
147
  const b = h('b')
147
148
 
@@ -197,17 +198,17 @@ export const /** @type {Record<string, () => void>} */ tests = {
197
198
  'h: nested properties': () => {
198
199
  const div = h('div')
199
200
 
200
- // @ts-expect-error
201
+ // @ts-ignore
201
202
  console.assert(div.key === undefined)
202
203
 
203
204
  h(div, { $key: { one: 1 } })
204
205
 
205
- // @ts-expect-error
206
+ // @ts-ignore
206
207
  console.assert(eq(div.key, { one: 1 }))
207
208
 
208
209
  h(div, { $key: { two: 2 } })
209
210
 
210
- // @ts-expect-error
211
+ // @ts-ignore
211
212
  console.assert(eq(div.key, { one: 1, two: 2 }))
212
213
  }
213
214
  }
package/has.d.ts CHANGED
@@ -3,4 +3,7 @@
3
3
  */
4
4
  export function has(key: any, ref: any): boolean;
5
5
 
6
- export const tests: Record<string, () => void>;
6
+ export const tests: {
7
+ has: () => void;
8
+ 'has: null': () => void;
9
+ };
package/has.js CHANGED
@@ -6,7 +6,7 @@ import { is } from './is.js'
6
6
  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
- export const /** @type {Record<string, () => void>} */ tests = {
9
+ export const tests = {
10
10
  has: () => {
11
11
  const obj = { key: 'K', null: 'N' }
12
12
 
@@ -16,7 +16,7 @@ export const /** @type {Record<string, () => void>} */ tests = {
16
16
  console.assert('null' in obj)
17
17
  console.assert(has('null', obj))
18
18
 
19
- // @ts-expect-error
19
+ // @ts-ignore
20
20
  console.assert(null in obj)
21
21
  console.assert(!has(null, obj))
22
22
 
@@ -28,7 +28,7 @@ export const /** @type {Record<string, () => void>} */ tests = {
28
28
  let typeError
29
29
 
30
30
  try {
31
- // @ts-expect-error
31
+ // @ts-ignore
32
32
  console.assert('key' in null)
33
33
  } catch (error) {
34
34
  typeError = error
package/is.d.ts CHANGED
@@ -11,4 +11,7 @@ export const is: {
11
11
  <T extends abstract new (...args: any[]) => any>(type: T, arg: any): arg is InstanceType<T>;
12
12
  };
13
13
 
14
- export const tests: Record<string, () => void>;
14
+ export const tests: {
15
+ is: () => void;
16
+ 'is: toString.call': () => void;
17
+ };
package/is.js CHANGED
@@ -17,7 +17,7 @@
17
17
  */
18
18
  export const is = (/** @type {T} */ type, /** @type {any} */ arg) => arg?.constructor === type
19
19
 
20
- export const /** @type {Record<string, () => void>} */ tests = {
20
+ export const tests = {
21
21
  is: () => {
22
22
  console.assert(is(Number, 42))
23
23
  console.assert(is(Number, Number(42)))
@@ -53,7 +53,7 @@ export const /** @type {Record<string, () => void>} */ tests = {
53
53
 
54
54
  const fakeFooBar = {}
55
55
 
56
- // @ts-expect-error
56
+ // @ts-ignore
57
57
  fakeFooBar[Symbol.toStringTag] = FooBar.name
58
58
 
59
59
  console.assert(!is(FooBar, fakeFooBar))
package/jcss.d.ts CHANGED
@@ -2,13 +2,13 @@
2
2
  * The type of arguments of the `jcss` helper.
3
3
  */
4
4
  export type JcssNode = {
5
- [attributeOrSelector: string]: string | number | JcssNode;
5
+ [attributeOrSelector: string]: string | number | JcssNode | undefined;
6
6
  };
7
7
 
8
8
  /**
9
9
  * The type of arguments of the `jcss` helper.
10
10
  */
11
- export type JcssRoot = Record<string, JcssNode>;
11
+ export type JcssRoot = Partial<Record<string, JcssNode>>;
12
12
 
13
13
  /**
14
14
  * A simple CSS-in-JS helper.
@@ -23,4 +23,11 @@ export type JcssRoot = Record<string, JcssNode>;
23
23
  */
24
24
  export function jcss(root: JcssRoot, splitter?: string): string;
25
25
 
26
- export const tests: Record<string, () => void>;
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;
33
+ };
package/jcss.js CHANGED
@@ -4,14 +4,14 @@ import { is } from './is.js'
4
4
  * The type of arguments of the `jcss` helper.
5
5
  *
6
6
  * @typedef {{
7
- * [attributeOrSelector: string]: string | number | JcssNode;
7
+ * [attributeOrSelector: string]: string | number | JcssNode | undefined;
8
8
  * }} JcssNode
9
9
  */
10
10
 
11
11
  /**
12
12
  * The type of arguments of the `jcss` helper.
13
13
  *
14
- * @typedef {Record<string, JcssNode>} JcssRoot
14
+ * @typedef {Partial<Record<string, JcssNode>>} JcssRoot
15
15
  */
16
16
 
17
17
  const _jcss = (
@@ -47,7 +47,7 @@ const _jcss = (
47
47
  }
48
48
 
49
49
  attributes.push(`${split(key).replace(/([A-Z])/g, (_, letter) => '-' + letter.toLowerCase())}:${value}`)
50
- } else {
50
+ } else if (value != null) {
51
51
  attributesPushed = false
52
52
 
53
53
  const /** @type {string[]} */ prefixN = []
@@ -82,19 +82,21 @@ export const jcss = (/** @type {JcssRoot} */ root, splitter = '$$') => {
82
82
  for (const key in root) {
83
83
  const value = root[key]
84
84
 
85
- if (key[0] === '@') {
86
- chunks.push(split(key) + '{')
87
- _jcss(value, '', chunks, split)
88
- chunks.push('}')
89
- } else {
90
- _jcss(value, split(key), chunks, split)
85
+ if (value != null) {
86
+ if (key[0] === '@') {
87
+ chunks.push(split(key) + '{')
88
+ _jcss(value, '', chunks, split)
89
+ chunks.push('}')
90
+ } else {
91
+ _jcss(value, split(key), chunks, split)
92
+ }
91
93
  }
92
94
  }
93
95
 
94
96
  return chunks.join('')
95
97
  }
96
98
 
97
- export const /** @type {Record<string, () => void>} */ tests = {
99
+ export const tests = {
98
100
  'jcss: #1': () => {
99
101
  const actual = jcss({
100
102
  a: {
package/jsOnParse.d.ts CHANGED
@@ -13,6 +13,8 @@
13
13
  * handlers['«handlerName»'](...«params»)
14
14
  * ```
15
15
  */
16
- export function jsOnParse(handlers: Record<string, Function>, text: string): any;
16
+ export function jsOnParse(handlers: Partial<Record<string, Function>>, text: string): any;
17
17
 
18
- export const tests: Record<string, () => void>;
18
+ export namespace tests {
19
+ function jsOnParse(): void;
20
+ }
package/jsOnParse.js CHANGED
@@ -18,7 +18,7 @@ import { is } from './is.js'
18
18
  * ```
19
19
  */
20
20
  export const jsOnParse = (
21
- /** @type {Record<string, Function>} */ handlers,
21
+ /** @type {Partial<Record<string, Function>>} */ handlers,
22
22
  /** @type {string} */ text
23
23
  ) => JSON.parse(text, (key, value) => {
24
24
  if (is(Object, value)) {
@@ -32,6 +32,7 @@ export const jsOnParse = (
32
32
  }
33
33
 
34
34
  if (has(key, handlers) && is(Array, value[key])) {
35
+ // @ts-ignore
35
36
  return handlers[key](...value[key])
36
37
  }
37
38
  }
@@ -39,7 +40,7 @@ export const jsOnParse = (
39
40
  return value
40
41
  })
41
42
 
42
- export const /** @type {Record<string, () => void>} */ tests = {
43
+ export const tests = {
43
44
  jsOnParse: () => {
44
45
  const handlers = {
45
46
  $hello: (/** @type {string} */ name) => `Hello ${name}!`,
package/locale.d.ts CHANGED
@@ -1,6 +1,8 @@
1
1
  /**
2
2
  * Language translations helper.
3
3
  */
4
- export function locale(locales: Record<string, Record<string, string | Record<string, string>>>, defaultLanguage: string, languages?: readonly string[]): (text?: string | undefined, version?: string | undefined) => string;
4
+ export function locale(map: Partial<Record<string, Partial<Record<string, string>>>>, defaultVersion: string): (text: string, version?: string) => string;
5
5
 
6
- export const tests: Record<string, () => void>;
6
+ export namespace tests {
7
+ function locale(): void;
8
+ }
package/locale.js CHANGED
@@ -1,53 +1,27 @@
1
- import { has } from './has.js'
2
1
  import { is } from './is.js'
3
2
 
4
- const _locale = (
5
- /** @type {Record<string, Record<string, string | Record<string, string>>>} */ locales,
6
- /** @type {string} */ language,
7
- /** @type {string} */ text,
8
- /** @type {string} */ version
9
- ) => {
10
- const l = locales?.[language]
11
- // @ts-expect-error
12
- const v = l?.[version]?.[text]
13
-
14
- if (is(String, v)) {
15
- return v
16
- }
17
-
18
- const t = l?.[text]
19
-
20
- return is(String, t) ? t : text
21
- }
22
-
23
3
  /**
24
4
  * Language translations helper.
25
5
  */
26
6
  export const locale = (
27
- /** @type {Record<string, Record<string, string | Record<string, string>>>} */ locales,
28
- /** @type {string} */ defaultLanguage,
29
- languages = navigator.languages
7
+ /** @type {Partial<Record<string, Partial<Record<string, string>>>>} */ map,
8
+ /** @type {string} */ defaultVersion
9
+ ) => (
10
+ /** @type {string} */ text,
11
+ /** @type {string} */ version = defaultVersion
30
12
  ) => {
31
- for (const language of languages) {
32
- if (has(language, locales)) {
33
- // @ts-expect-error
34
- return _locale.bind(0, locales, language)
35
- }
36
- }
13
+ const textV = map?.[version]?.[text]
14
+ const textD = map?.[defaultVersion]?.[text]
37
15
 
38
- // @ts-expect-error
39
- return _locale.bind(0, locales, defaultLanguage)
16
+ return is(String, textV) ? textV : is(String, textD) ? textD : text
40
17
  }
41
18
 
42
- export const /** @type {Record<string, () => void>} */ tests = {
19
+ export const tests = {
43
20
  locale: () => {
44
- const locales = {
45
- pl: {
46
- Password: 'Hasło',
47
- button: { Login: 'Zaloguj' }
48
- }
49
- }
50
- const _ = locale(locales, 'pl', [])
21
+ const _ = locale({
22
+ default: { Password: 'Hasło' },
23
+ button: { Login: 'Zaloguj' }
24
+ }, 'default')
51
25
 
52
26
  console.assert(_('Login') === 'Login')
53
27
  console.assert(_('Password') === 'Hasło')
package/nanolight.d.ts CHANGED
@@ -3,4 +3,4 @@
3
3
  */
4
4
  export function nanolight(pattern: RegExp, highlighters: ((chunk: string, index: number) => import('./h.js').HArgs1)[], code: string): import("./h.js").HArgs1[];
5
5
 
6
- export const tests: Record<string, () => void>;
6
+ export const tests: {};
package/nanolight.js CHANGED
@@ -9,8 +9,8 @@ export const nanolight = (
9
9
  const /** @type {import('./h.js').HArgs1[]} */ result = []
10
10
 
11
11
  code.split(pattern).forEach((chunk, index) => {
12
- index %= highlighters.length
13
- if (chunk != null) {
12
+ if (chunk != null && chunk !== '') {
13
+ index %= highlighters.length
14
14
  result.push(highlighters[index](chunk, index))
15
15
  }
16
16
  })
@@ -18,4 +18,4 @@ export const nanolight = (
18
18
  return result
19
19
  }
20
20
 
21
- export const /** @type {Record<string, () => void>} */ tests = {}
21
+ export const tests = {}
package/nanolightJs.d.ts CHANGED
@@ -3,4 +3,6 @@
3
3
  */
4
4
  export const nanolightJs: (code?: string | undefined) => import("./h.js").HArgs1[];
5
5
 
6
- export const tests: Record<string, () => void>;
6
+ export namespace tests {
7
+ function nanolightJs(): void;
8
+ }
package/nanolightJs.js CHANGED
@@ -4,7 +4,7 @@ import { nanolight } from './nanolight.js'
4
4
  /**
5
5
  * A helper for highlighting JavaScript.
6
6
  */
7
- // @ts-expect-error
7
+ // @ts-ignore
8
8
  export const nanolightJs = nanolight.bind(0,
9
9
  /('.*?'|".*?"|`[\s\S]*?`)|(\/\/.*?\n|\/\*[\s\S]*?\*\/)|(break|case|catch|const|continue|debugger|default|delete|do|else|eval|export\s+type|export|extends|false|finally|for|from|function|goto|if|import|in|instanceof|is|keyof|let|NaN|new|null|package|return|super|switch|this|throw|true|try|typeof|undefined|var|void|while|with|yield)(?!\w)|([<>=.?:&|!~*/%+-])|(0x[\dabcdef]+|0o[01234567]+|0b[01]+|\d+(?:\.[\d_]+)?(?:e[+-]?[\d_]+)?)|([$\w]+)(?=\()|([$\wąćęłńóśżźĄĆĘŁŃÓŚŻŹ]+)/,
10
10
  [
@@ -19,7 +19,7 @@ export const nanolightJs = nanolight.bind(0,
19
19
  ]
20
20
  )
21
21
 
22
- export const /** @type {Record<string, () => void>} */ tests = {
22
+ export const tests = {
23
23
  nanolightJs: () => {
24
24
  const codeJs = 'const answerToLifeTheUniverseAndEverything = 42'
25
25
 
package/package.json CHANGED
@@ -40,5 +40,5 @@
40
40
  "types": "nnn.d.ts",
41
41
  "name": "@jackens/nnn",
42
42
  "type": "module",
43
- "version": "2023.12.19"
44
- }
43
+ "version": "2024.1.2"
44
+ }
package/plUral.d.ts CHANGED
@@ -3,4 +3,6 @@
3
3
  */
4
4
  export function plUral(singular: string, plural2: string, plural5: string, value: number): string;
5
5
 
6
- export const tests: Record<string, () => void>;
6
+ export namespace tests {
7
+ function plUral(): void;
8
+ }
package/plUral.js CHANGED
@@ -18,9 +18,9 @@ export const plUral = (
18
18
  : plural5
19
19
  }
20
20
 
21
- export const /** @type {Record<string, () => void>} */ tests = {
21
+ export const tests = {
22
22
  plUral: () => {
23
- // @ts-expect-error
23
+ // @ts-ignore
24
24
  const auto = plUral.bind(null, 'auto', 'auta', 'aut')
25
25
 
26
26
  console.assert(auto(0) === 'aut')
@@ -28,7 +28,7 @@ export const /** @type {Record<string, () => void>} */ tests = {
28
28
  console.assert(auto(17) === 'aut')
29
29
  console.assert(auto(42) === 'auta')
30
30
 
31
- // @ts-expect-error
31
+ // @ts-ignore
32
32
  const car = plUral.bind(null, 'car', 'cars', 'cars')
33
33
 
34
34
  console.assert(car(0) === 'cars')
package/pro.d.ts CHANGED
@@ -3,4 +3,6 @@
3
3
  */
4
4
  export function pro(ref: any): any;
5
5
 
6
- export const tests: Record<string, () => void>;
6
+ export namespace tests {
7
+ function pro(): void;
8
+ }
package/pro.js CHANGED
@@ -3,14 +3,14 @@ import { eq } from './eq.js'
3
3
  /**
4
4
  * A helper that protects calls to nested properties by a `Proxy` that initializes non-existent values with an empty object.
5
5
  */
6
- // @ts-expect-error
6
+ // @ts-ignore
7
7
  export const pro = (/** @type {any} */ ref) => new Proxy(ref, {
8
8
  get (target, key) {
9
9
  return pro(target[key] = target[key] ?? {})
10
10
  }
11
11
  })
12
12
 
13
- export const /** @type {Record<string, () => void>} */ tests = {
13
+ export const tests = {
14
14
  pro: () => {
15
15
  const ref = {}
16
16
 
package/readme.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  Jackens’ JavaScript helpers.
4
4
 
5
+ <sub>Version: <code class="version">2024.1.2</code></sub>
6
+
5
7
  ## Installation
6
8
 
7
9
  ```sh
@@ -14,17 +16,17 @@ or
14
16
  npm i @jackens/nnn
15
17
  ```
16
18
 
17
- Usage
19
+ ## Usage
18
20
 
19
21
  Bun (or Node.js):
20
22
 
21
- ```sh
23
+ ```js
22
24
  import { «something» } from '@jackens/nnn'
23
25
  ```
24
26
 
25
27
  The browser (or Bun or Node.js):
26
28
 
27
- ```sh
29
+ ```js
28
30
  import { «something» } from './node_modules/@jackens/nnn/nnn.js'
29
31
  ```
30
32
 
@@ -82,7 +84,7 @@ The type of arguments of the `h` and `s` helpers.
82
84
 
83
85
  ```ts
84
86
  export type JcssNode = {
85
- [attributeOrSelector: string]: string | number | JcssNode;
87
+ [attributeOrSelector: string]: string | number | JcssNode | undefined;
86
88
  };
87
89
  ```
88
90
 
@@ -91,7 +93,7 @@ The type of arguments of the `jcss` helper.
91
93
  ### JcssRoot
92
94
 
93
95
  ```ts
94
- export type JcssRoot = Record<string, JcssNode>;
96
+ export type JcssRoot = Partial<Record<string, JcssNode>>;
95
97
  ```
96
98
 
97
99
  The type of arguments of the `jcss` helper.
@@ -648,7 +650,7 @@ console.assert(actual === expected)
648
650
  ### jsOnParse
649
651
 
650
652
  ```ts
651
- export function jsOnParse(handlers: Record<string, Function>, text: string): any;
653
+ export function jsOnParse(handlers: Partial<Record<string, Function>>, text: string): any;
652
654
  ```
653
655
 
654
656
  `JSON.parse` with “JavaScript turned on”.
@@ -713,7 +715,7 @@ console.assert(eq(actual, expected))
713
715
  ### locale
714
716
 
715
717
  ```ts
716
- export function locale(locales: Record<string, Record<string, string | Record<string, string>>>, defaultLanguage: string, languages?: readonly string[]): (text?: string | undefined, version?: string | undefined) => string;
718
+ export function locale(map: Partial<Record<string, Partial<Record<string, string>>>>, defaultVersion: string): (text: string, version?: string) => string;
717
719
  ```
718
720
 
719
721
  Language translations helper.
@@ -721,13 +723,10 @@ Language translations helper.
721
723
  #### Usage Examples
722
724
 
723
725
  ```js
724
- const locales = {
725
- pl: {
726
- Password: 'Hasło',
727
- button: { Login: 'Zaloguj' }
728
- }
729
- }
730
- const _ = locale(locales, 'pl', [])
726
+ const _ = locale({
727
+ default: { Password: 'Hasło' },
728
+ button: { Login: 'Zaloguj' }
729
+ }, 'default')
731
730
 
732
731
  console.assert(_('Login') === 'Login')
733
732
  console.assert(_('Password') === 'Hasło')
package/refsInfo.d.ts CHANGED
@@ -5,4 +5,7 @@
5
5
  */
6
6
  export function refsInfo(...refs: any[]): [string, string, string[]][];
7
7
 
8
- export const tests: Record<string, () => void>;
8
+ export const tests: {
9
+ refsInfo: () => void;
10
+ 'refsInfo: browserFingerprint': () => void;
11
+ };
package/refsInfo.js CHANGED
@@ -22,7 +22,7 @@ export const refsInfo = (/** @type {any[]} */ ...refs) => {
22
22
  ]).sort((a, b) => -(a[0] < b[0]))
23
23
  }
24
24
 
25
- export const /** @type {Record<string, () => void>} */ tests = {
25
+ export const tests = {
26
26
  refsInfo: () => {
27
27
  const info = refsInfo(Array, Function)
28
28
 
@@ -32,7 +32,7 @@ export const /** @type {Record<string, () => void>} */ tests = {
32
32
 
33
33
  'refsInfo: browserFingerprint': () => {
34
34
  const browserFingerprint = () => {
35
- // @ts-expect-error
35
+ // @ts-ignore
36
36
  const refs = Object.getOwnPropertyNames(window).map(name => window[name])
37
37
  const info = refsInfo(...refs)
38
38
  const json = JSON.stringify(info)
package/tests.d.ts CHANGED
@@ -1 +1,30 @@
1
- export const tests: Record<string, () => void>;
1
+ export const tests: {
2
+ uuid1: () => void;
3
+ 'uuid1: node': () => void;
4
+ 'uuid1: date': () => void;
5
+ refsInfo: () => void;
6
+ 'refsInfo: browserFingerprint': () => void;
7
+ pro: () => void;
8
+ plUral: () => void;
9
+ nanolightJs: () => void;
10
+ locale: () => void;
11
+ jsOnParse: () => void;
12
+ 'jcss: #1': () => void;
13
+ 'jcss: #2': () => void;
14
+ 'jcss: #3': () => void;
15
+ 'jcss: #4': () => void;
16
+ 'jcss: #5': () => void;
17
+ 'jcss: #6': () => void;
18
+ is: () => void;
19
+ 'is: toString.call': () => void;
20
+ has: () => void;
21
+ 'has: null': () => void;
22
+ h: () => void;
23
+ 'h: innerText vs items': () => void;
24
+ 'h: style': () => void;
25
+ 'h: attributes vs properties': () => void;
26
+ 'h: nested properties': () => void;
27
+ fixTypography: () => void;
28
+ escape: () => void;
29
+ eq: () => void;
30
+ };
package/tests.js CHANGED
@@ -15,7 +15,7 @@ import { tests as proTests } from './pro.js'
15
15
  import { tests as refsInfoTests } from './refsInfo.js'
16
16
  import { tests as uuid1Tests } from './uuid1.js'
17
17
 
18
- export const /** @type {Record<string, () => void>} */ tests = {
18
+ export const tests = {
19
19
  ...chartableTests,
20
20
  ...eqTests,
21
21
  ...escapeTests,
package/uuid1.d.ts CHANGED
@@ -1,4 +1,8 @@
1
- export const tests: Record<string, () => void>;
1
+ export const tests: {
2
+ uuid1: () => void;
3
+ 'uuid1: node': () => void;
4
+ 'uuid1: date': () => void;
5
+ };
2
6
 
3
7
  /**
4
8
  * A helper that generates a UUID v1 identifier (with a creation timestamp).
package/uuid1.js CHANGED
@@ -18,7 +18,7 @@ export const uuid1 = ({
18
18
  return time.slice(-8).concat(
19
19
  '-',
20
20
  time.slice(-12, -8),
21
- // @ts-expect-error
21
+ // @ts-ignore
22
22
  -1,
23
23
  time.slice(-15, -12),
24
24
  '-',
@@ -28,7 +28,7 @@ export const uuid1 = ({
28
28
  (ZEROS + node).slice(-12))
29
29
  }
30
30
 
31
- export const /** @type {Record<string, () => void>} */ tests = {
31
+ export const tests = {
32
32
  uuid1: () => {
33
33
  for (let i = 1; i <= 22136; ++i) {
34
34
  const uuid = uuid1()