@jackens/nnn 2025.3.5 → 2025.4.29

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.
Files changed (4) hide show
  1. package/nnn.d.ts +0 -4
  2. package/nnn.js +0 -7
  3. package/package.json +6 -5
  4. package/readme.md +31 -76
package/nnn.d.ts CHANGED
@@ -136,10 +136,6 @@ export declare const isString: (arg: any) => arg is string;
136
136
  * ```
137
137
  */
138
138
  export declare const jsOnParse: (handlers: Partial<Record<PropertyKey, Function>>, text: string) => any;
139
- /**
140
- * Language translations helper.
141
- */
142
- export declare const locale: (map: Partial<Record<PropertyKey, Partial<Record<PropertyKey, string>>>>, defaultVersion: string) => (text: string, version?: string) => string;
143
139
  /**
144
140
  * A generic helper for syntax highlighting (see also `nanolightJs`).
145
141
  */
package/nnn.js CHANGED
@@ -189,12 +189,6 @@ var jsOnParse = (handlers, text) => JSON.parse(text, (key, value) => {
189
189
  }
190
190
  return value;
191
191
  });
192
- // src/nnn/locale.ts
193
- var locale = (map, defaultVersion) => (text, version = defaultVersion) => {
194
- const textV = map?.[version]?.[text];
195
- const textD = map?.[defaultVersion]?.[text];
196
- return isString(textV) ? textV : isString(textD) ? textD : text;
197
- };
198
192
  // src/nnn/nanolight.ts
199
193
  var nanolight = (pattern, highlighters, code) => {
200
194
  const result = [];
@@ -250,7 +244,6 @@ export {
250
244
  omit,
251
245
  nanolightJs,
252
246
  nanolight,
253
- locale,
254
247
  jsOnParse,
255
248
  isString,
256
249
  isRecord,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "author": "Jackens",
3
3
  "description": "Jackens’ JavaScript helpers.",
4
- "homepage": "https://jackens.github.io/nnn/doc/",
4
+ "homepage": "https://jackens.github.io/doc/",
5
5
  "keywords": [
6
6
  "c",
7
7
  "CSS-in-JS",
@@ -15,17 +15,18 @@
15
15
  "HyperScript",
16
16
  "in",
17
17
  "is",
18
+ "isArray",
19
+ "isNumber",
20
+ "isRecord",
21
+ "isString",
18
22
  "JS-to-CSS",
19
23
  "JSON",
20
24
  "jsOnParse",
21
- "locale",
22
- "localization",
23
25
  "nanolight",
24
26
  "nnn",
25
27
  "omit",
26
28
  "pick",
27
29
  "SVG",
28
- "translation",
29
30
  "typography",
30
31
  "uuid",
31
32
  "uuid1",
@@ -36,5 +37,5 @@
36
37
  "name": "@jackens/nnn",
37
38
  "type": "module",
38
39
  "types": "nnn.d.ts",
39
- "version": "2025.3.5"
40
+ "version": "2025.4.29"
40
41
  }
package/readme.md CHANGED
@@ -2,14 +2,6 @@
2
2
 
3
3
  Jackens’ JavaScript helpers.
4
4
 
5
- <sub>Version: <code class="version">2025.3.5</code></sub>
6
-
7
- * [Documentation](https://jackens.github.io/nnn/doc/)
8
- * [Tests](https://jackens.github.io/nnn/test/)
9
- * [Chessboard Demo](https://jackens.github.io/nnn/chessboard/)
10
- * [Gantt Chart Demo](https://jackens.github.io/nnn/gantt/)
11
- * [Responsive Web Design Demo](https://jackens.github.io/nnn/rwd/)
12
-
13
5
  ## Installation
14
6
 
15
7
  ```sh
@@ -34,12 +26,6 @@ or
34
26
  import { «something» } from './node_modules/@jackens/nnn/nnn.js'
35
27
  ```
36
28
 
37
- or
38
-
39
- ```js
40
- import { «something» } from 'https://unpkg.com/@jackens/nnn@2025.3.5/nnn.js'
41
- ```
42
-
43
29
  ## Exports
44
30
 
45
31
  - `CNode`: The type of arguments of the `c` helper.
@@ -59,7 +45,6 @@ import { «something» } from 'https://unpkg.com/@jackens/nnn@2025.3.5/nnn.js'
59
45
  - `isRecord`: A helper that checks if the given argument is of type `Partial<Record<PropertyKey, unknown>>`.
60
46
  - `isString`: A helper that checks if the given argument is of type `string`.
61
47
  - `jsOnParse`: `JSON.parse` with “JavaScript turned on”.
62
- - `locale`: Language translations helper.
63
48
  - `nanolight`: A generic helper for syntax highlighting (see also `nanolightJs`).
64
49
  - `nanolightJs`: A helper for highlighting JavaScript (see also `nanolight`).
65
50
  - `omit`: A helper that implements TypeScript’s `Omit` utility type (see also `pick`).
@@ -130,7 +115,7 @@ The `root` parameter provides a hierarchical description of CSS rules.
130
115
 
131
116
  #### Usage Examples
132
117
 
133
- ```js
118
+ ```ts
134
119
  const actual = c({
135
120
  a: {
136
121
  color: 'red',
@@ -156,7 +141,7 @@ a{
156
141
  expect(actual).to.deep.equal(expected)
157
142
  ```
158
143
 
159
- ```js
144
+ ```ts
160
145
  const actual = c({
161
146
  a: {
162
147
  '.b': {
@@ -184,7 +169,7 @@ a.b{
184
169
  expect(actual).to.deep.equal(expected)
185
170
  ```
186
171
 
187
- ```js
172
+ ```ts
188
173
  const actual = c({
189
174
  '@font-face$$1': {
190
175
  fontFamily: 'Jackens',
@@ -259,7 +244,7 @@ div.c2{
259
244
  expect(actual).to.deep.equal(expected)
260
245
  ```
261
246
 
262
- ```js
247
+ ```ts
263
248
  const actual = c({
264
249
  a: {
265
250
  '.b,.c': {
@@ -282,7 +267,7 @@ a.b.d,a.c.d{
282
267
  expect(actual).to.deep.equal(expected)
283
268
  ```
284
269
 
285
- ```js
270
+ ```ts
286
271
  const actual = c({
287
272
  '.b,.c': {
288
273
  margin: 1,
@@ -303,7 +288,7 @@ const expected = `
303
288
  expect(actual).to.deep.equal(expected)
304
289
  ```
305
290
 
306
- ```js
291
+ ```ts
307
292
  const actual = c({
308
293
  '.a,.b': {
309
294
  margin: 1,
@@ -350,7 +335,7 @@ Options:
350
335
 
351
336
  #### Usage Examples
352
337
 
353
- ```js
338
+ ```ts
354
339
  const text = `"aaa
355
340
  ""aaa""
356
341
  aaa",bbb, "ccc,ccc"
@@ -386,14 +371,14 @@ A generic helper for escaping `values` by given `escapeMap` (in *TemplateStrings
386
371
 
387
372
  #### Usage Examples
388
373
 
389
- ```js
390
- const /** @type {EscapeMap} */ escapeMap = new Map([
374
+ ```ts
375
+ const escapeMap: EscapeMap = new Map([
391
376
  [undefined, () => 'NULL'],
392
- [Array, (/** @type {Partial<Array<unknown>>} */ values) => escapeValues(escapeMap, values).join(', ')],
393
- [Boolean, (/** @type {boolean} */ value) => `b'${+value}'`],
394
- [Date, (/** @type {Date} */ value) => `'${value.toISOString().replace(/^(.+)T(.+)\..*$/, '$1 $2')}'`],
395
- [Number, (/** @type {number} */ value) => `${value}`],
396
- [String, (/** @type {string} */ value) => `'${value.replace(/'/g, "''")}'`]
377
+ [Array, (values: Partial<Array<unknown>>) => escapeValues(escapeMap, values).join(', ')],
378
+ [Boolean, (value: boolean) => `b'${+value}'`],
379
+ [Date, (value: Date) => `'${value.toISOString().replace(/^(.+)T(.+)\..*$/, '$1 $2')}'`],
380
+ [Number, (value: number) => `${value}`],
381
+ [String, (value: string) => `'${value.replace(/'/g, "''")}'`]
397
382
  ])
398
383
 
399
384
  const sql = escape.bind(null, escapeMap)
@@ -429,7 +414,7 @@ A helper that implements typographic corrections specific to Polish typography.
429
414
 
430
415
  #### Usage Examples
431
416
 
432
- ```js
417
+ ```ts
433
418
  const p = h('p', 'Pchnąć w tę łódź jeża lub ośm skrzyń fig (zob. https://pl.wikipedia.org/wiki/Pangram).')
434
419
 
435
420
  fixTypography(p)
@@ -461,7 +446,7 @@ A lightweight [HyperScript](https://github.com/hyperhype/hyperscript)-style help
461
446
 
462
447
  #### Usage Examples
463
448
 
464
- ```js
449
+ ```ts
465
450
  const b = h('b')
466
451
 
467
452
  expect(b.outerHTML).to.deep.equal('<b></b>')
@@ -479,12 +464,12 @@ expect(i.outerHTML).to.deep.equal('<i class="some class">text</i>')
479
464
  expect(b.outerHTML).to.deep.equal('<b><i class="some class">text</i></b>')
480
465
  ```
481
466
 
482
- ```js
467
+ ```ts
483
468
  expect(h('span', 'text').outerHTML).to.deep.equal('<span>text</span>')
484
469
  expect(h('span', { $innerText: 'text' }).outerHTML).to.deep.equal('<span>text</span>')
485
470
  ```
486
471
 
487
- ```js
472
+ ```ts
488
473
  expect(h('div', { style: 'margin:0;padding:0' }).outerHTML)
489
474
  .to.deep.equal('<div style="margin:0;padding:0"></div>')
490
475
  expect(h('div', { $style: 'margin:0;padding:0' }).outerHTML)
@@ -493,7 +478,7 @@ expect(h('div', { $style: { margin: 0, padding: 0 } }).outerHTML)
493
478
  .to.deep.equal('<div style="margin: 0px; padding: 0px;"></div>')
494
479
  ```
495
480
 
496
- ```js
481
+ ```ts
497
482
  const input1 = h('input', { value: 42 })
498
483
  const input2 = h('input', { $value: '42' })
499
484
 
@@ -513,7 +498,7 @@ expect(checkbox1.outerHTML).to.deep.equal('<input type="checkbox" checked="">')
513
498
  expect(checkbox2.outerHTML).to.deep.equal('<input type="checkbox">')
514
499
  ```
515
500
 
516
- ```js
501
+ ```ts
517
502
  const div = h('div')
518
503
 
519
504
  expect(div.key).to.be.undefined
@@ -537,7 +522,7 @@ A replacement for the `in` operator (not to be confused with the `for-in` loop)
537
522
 
538
523
  #### Usage Examples
539
524
 
540
- ```js
525
+ ```ts
541
526
  const obj = { 42: null, null: 'k,e,y', 'k,e,y': 42 }
542
527
 
543
528
  expect(42 in obj).to.be.true
@@ -622,9 +607,9 @@ handlers['«handlerName»'](...«params»)
622
607
 
623
608
  #### Usage Examples
624
609
 
625
- ```js
610
+ ```ts
626
611
  const handlers = {
627
- $hello: (/** @type {string} */ name) => `Hello ${name}!`,
612
+ $hello: (name: string) => `Hello ${name}!`,
628
613
  $foo: () => 'bar'
629
614
  }
630
615
 
@@ -667,36 +652,6 @@ const expected = [
667
652
  expect(actual).to.deep.equal(expected)
668
653
  ```
669
654
 
670
- ### locale
671
-
672
- ```ts
673
- const locale: (map: Partial<Record<PropertyKey, Partial<Record<PropertyKey, string>>>>, defaultVersion: string) => (text: string, version?: string) => string;
674
- ```
675
-
676
- Language translations helper.
677
-
678
- #### Usage Examples
679
-
680
- ```js
681
- const _ = locale({
682
- default: { Password: 'Hasło' },
683
- button: { Login: 'Zaloguj' }
684
- }, 'default')
685
-
686
- expect(_('Login')).to.deep.equal('Login')
687
- expect(_('Password')).to.deep.equal('Hasło')
688
-
689
- expect(_('Undefined text')).to.deep.equal('Undefined text')
690
-
691
- expect(_('Login', 'button')).to.deep.equal('Zaloguj')
692
-
693
- expect(_('Password', 'undefined_version')).to.deep.equal('Hasło')
694
- expect(_('Undefined text', 'undefined_version')).to.deep.equal('Undefined text')
695
-
696
- expect(_('toString')).to.deep.equal('toString')
697
- expect(_('toString', 'undefined_version')).to.deep.equal('toString')
698
- ```
699
-
700
655
  ### nanolight
701
656
 
702
657
  ```ts
@@ -715,7 +670,7 @@ A helper for highlighting JavaScript (see also `nanolight`).
715
670
 
716
671
  #### Usage Examples
717
672
 
718
- ```js
673
+ ```ts
719
674
  const codeJs = 'const answerToLifeTheUniverseAndEverything = 42'
720
675
 
721
676
  expect(nanolightJs(codeJs)).to.deep.equal([
@@ -739,7 +694,7 @@ A helper that implements TypeScript’s `Omit` utility type (see also `pick`).
739
694
 
740
695
  #### Usage Examples
741
696
 
742
- ```js
697
+ ```ts
743
698
  const obj = { a: 42, b: '42', c: 17 }
744
699
 
745
700
  expect(omit(obj, ['c'])).to.deep.equal({ a: 42, b: '42' })
@@ -755,7 +710,7 @@ A helper that implements TypeScript’s `Pick` utility type (see also `omit`).
755
710
 
756
711
  #### Usage Examples
757
712
 
758
- ```js
713
+ ```ts
759
714
  const obj = { a: 42, b: '42', c: 17 }
760
715
 
761
716
  expect(pick(obj, ['a', 'b'])).to.deep.equal({ a: 42, b: '42' })
@@ -771,7 +726,7 @@ A helper for choosing the correct singular and plural.
771
726
 
772
727
  #### Usage Examples
773
728
 
774
- ```js
729
+ ```ts
775
730
  const auto = plUral.bind(null, 'auto', 'auta', 'aut')
776
731
 
777
732
  expect(auto(0)).to.deep.equal('aut')
@@ -798,7 +753,7 @@ object.
798
753
 
799
754
  #### Usage Examples
800
755
 
801
- ```js
756
+ ```ts
802
757
  const ref = {}
803
758
 
804
759
  pro(ref).one.two[3][4] = 1234
@@ -866,7 +821,7 @@ A helper that generates a UUID v1 identifier (with a creation timestamp).
866
821
 
867
822
  #### Usage Examples
868
823
 
869
- ```js
824
+ ```ts
870
825
  for (let i = 1; i <= 22136; ++i) {
871
826
  const uuid = uuid1()
872
827
 
@@ -880,12 +835,12 @@ for (let i = 1; i <= 22136; ++i) {
880
835
  }
881
836
  ```
882
837
 
883
- ```js
838
+ ```ts
884
839
  expect(uuid1(new Date(), '000123456789abc').split('-')[4]).to.deep.equal('123456789abc')
885
840
  expect(uuid1(new Date(), '123456789').split('-')[4]).to.deep.equal('000123456789')
886
841
  ```
887
842
 
888
- ```js
843
+ ```ts
889
844
  expect(uuid1(new Date(323325000000)).startsWith('c1399400-9a71-11bd')).to.be.true
890
845
  ```
891
846