@jackens/nnn 2026.9.7 → 2026.9.9

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 -50
  2. package/nnn.js +1 -23
  3. package/package.json +1 -1
  4. package/readme.md +24 -195
package/nnn.d.ts CHANGED
@@ -242,53 +242,3 @@ export declare const rwd: (root: CNode, selector: string, cellWidthPx: number, c
242
242
  * `xxxxxxxx-xxxx-1xxx-xxxx-xxxxxxxxxxxx`.
243
243
  */
244
244
  export declare const uuidV1: (date?: Date, node?: string) => string;
245
- /**
246
- * A Proxy-based helper for auto-vivification of nested
247
- * object structures.
248
- *
249
- * Accessing, assigning, or deleting any nested property on
250
- * the returned proxy automatically creates intermediate
251
- * objects (or arrays for numeric-string keys matching
252
- * `^(0|[1-9]\d*)$`) as needed, allowing deep operations
253
- * without explicit null checks.
254
- *
255
- * Intermediates of the last level in a get-only property
256
- * chain are NOT auto-created. For example,
257
- * `vivify(ref).one.two` will create `ref.one` as `{}`, but
258
- * will NOT create `ref.one.two`. Only when a deeper access,
259
- * assignment, or deletion occurs, e.g.
260
- *
261
- * ```ts
262
- * delete vivify(ref).one.two.three
263
- * ```
264
- *
265
- * or
266
- *
267
- * ```ts
268
- * vivify(ref).one.two.three = 4
269
- * ```
270
- *
271
- * Will `ref.one.two` be materialized.
272
- *
273
- * When traversal reaches a primitive value, no
274
- * auto-creation happens; the primitive’s own property is
275
- * returned instead (e.g. accessing `.toString.name` on a
276
- * number yields `'toString'` without modifying the
277
- * underlying structure).
278
- *
279
- * Deletion on a non-existing intermediate path will
280
- * auto-create intermediates up to the parent of the deleted
281
- * key, e.g.
282
- *
283
- * ```ts
284
- * delete vivify(ref).one.two.three
285
- * ```
286
- *
287
- * Will create `ref.one.two` as `{}` if it does not exist.
288
- *
289
- * @param ref The root object to wrap.
290
- *
291
- * @returns A proxy that auto-creates nested objects/arrays
292
- * on property access.
293
- */
294
- export declare const vivify: (ref: unknown) => any;
package/nnn.js CHANGED
@@ -318,27 +318,6 @@ var uuidV1 = (date = new Date, node = Math.random().toString(16).slice(2)) => {
318
318
  counter = counter + 1 & 16383;
319
319
  return time.slice(-8).concat("-", time.slice(-12, -8), -1, time.slice(-15, -12), "-", (8 | counter >> 12).toString(16), (ZEROS + (counter & 4095).toString(16)).slice(-3), "-", (ZEROS + node).slice(-12));
320
320
  };
321
- // src/nnn/vivify.ts
322
- var ARRAY_INDEX_REGEXP = /^(0|[1-9]\d*)$/;
323
- var isObject = (ref) => typeof ref === "object";
324
- var getTarget = (parent, parentKey, key) => parent[parentKey] ??= typeof key === "string" && ARRAY_INDEX_REGEXP.test(key) ? [] : {};
325
- var _vivify = (parent, parentKey) => new Proxy(parent, {
326
- get(_, key) {
327
- const target = getTarget(parent, parentKey, key);
328
- const value = target[key];
329
- return typeof key === "string" && isObject(target) && (value == null || isObject(value)) ? _vivify(target, key) : value;
330
- },
331
- set(_, key, value) {
332
- const target = getTarget(parent, parentKey, key);
333
- target[key] = value;
334
- return true;
335
- },
336
- deleteProperty(_, key) {
337
- const target = getTarget(parent, parentKey, key);
338
- return delete target[key];
339
- }
340
- });
341
- var vivify = (ref) => _vivify({ _: ref }, "_");
342
321
  export {
343
322
  c,
344
323
  createEscape,
@@ -351,6 +330,5 @@ export {
351
330
  rwd,
352
331
  s,
353
332
  svgUse,
354
- uuidV1,
355
- vivify
333
+ uuidV1
356
334
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jackens/nnn",
3
- "version": "2026.9.7",
3
+ "version": "2026.9.9",
4
4
  "description": "Jackens’ JavaScript helpers.",
5
5
  "keywords": [
6
6
  "CSS-in-JS",
package/readme.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # nnn
2
2
 
3
- A collection of Jackens’ JavaScript helper utilities (version: `2026.9.7`).
3
+ A collection of Jackens’ JavaScript helper utilities (version: `2026.9.9`).
4
4
 
5
5
  ## Installation
6
6
 
@@ -33,7 +33,6 @@ import {
33
33
  s,
34
34
  svgUse,
35
35
  uuidV1,
36
- vivify,
37
36
  } from '@jackens/nnn' // or './node_modules/@jackens/nnn/nnn.js'
38
37
  ```
39
38
 
@@ -83,9 +82,6 @@ import {
83
82
  child referencing an icon by ID.
84
83
  - [`uuidV1`](#uuidV1):
85
84
  Generates a UUID v1 (time-based) identifier.
86
- - [`vivify`](#vivify):
87
- A Proxy-based helper for auto-vivification of nested
88
- object structures.
89
85
 
90
86
  ### CNode
91
87
 
@@ -479,29 +475,31 @@ const escapeFn = (value: any): string =>
479
475
  const sql = createEscape(escapeFn)
480
476
 
481
477
  const actual = sql`
482
- SELECT *
483
- FROM table_name
484
- WHERE column_name IN (
485
- ${[
486
- true,
487
- null,
488
- undefined,
489
- NaN,
490
- Infinity,
491
- 42,
492
- '42',
493
- "4'2",
494
- /42/,
495
- new Date(323325000000),
496
- ]}
497
- )`
478
+ SELECT *
479
+ FROM table_name
480
+ WHERE column_name IN (
481
+ ${[
482
+ true,
483
+ null,
484
+ undefined,
485
+ NaN,
486
+ Infinity,
487
+ 42,
488
+ '42',
489
+ "4'2",
490
+ /42/,
491
+ new Date(323325000000),
492
+ ]}
493
+ )
494
+ `
498
495
 
499
496
  const expected = `
500
- SELECT *
501
- FROM table_name
502
- WHERE column_name IN (
503
- b'1', NULL, NULL, NULL, NULL, 42, '42', '4''2', NULL, '1980-03-31 04:30:00'
504
- )`
497
+ SELECT *
498
+ FROM table_name
499
+ WHERE column_name IN (
500
+ b'1', NULL, NULL, NULL, NULL, 42, '42', '4''2', NULL, '1980-03-31 04:30:00'
501
+ )
502
+ `
505
503
 
506
504
  expect(actual).toBe(expected)
507
505
  ```
@@ -1359,175 +1357,6 @@ expect(
1359
1357
  ).toBe(true)
1360
1358
  ```
1361
1359
 
1362
- ### vivify
1363
-
1364
- ```ts
1365
- const vivify: (ref: unknown) => any;
1366
- ```
1367
-
1368
- A Proxy-based helper for auto-vivification of nested
1369
- object structures.
1370
-
1371
- Accessing, assigning, or deleting any nested property on
1372
- the returned proxy automatically creates intermediate
1373
- objects (or arrays for numeric-string keys matching
1374
- `^(0|[1-9]\d*)$`) as needed, allowing deep operations
1375
- without explicit null checks.
1376
-
1377
- Intermediates of the last level in a get-only property
1378
- chain are NOT auto-created. For example,
1379
- `vivify(ref).one.two` will create `ref.one` as `{}`, but
1380
- will NOT create `ref.one.two`. Only when a deeper access,
1381
- assignment, or deletion occurs, e.g.
1382
-
1383
- ```ts
1384
- delete vivify(ref).one.two.three
1385
- ```
1386
-
1387
- or
1388
-
1389
- ```ts
1390
- vivify(ref).one.two.three = 4
1391
- ```
1392
-
1393
- Will `ref.one.two` be materialized.
1394
-
1395
- When traversal reaches a primitive value, no
1396
- auto-creation happens; the primitive’s own property is
1397
- returned instead (e.g. accessing `.toString.name` on a
1398
- number yields `'toString'` without modifying the
1399
- underlying structure).
1400
-
1401
- Deletion on a non-existing intermediate path will
1402
- auto-create intermediates up to the parent of the deleted
1403
- key, e.g.
1404
-
1405
- ```ts
1406
- delete vivify(ref).one.two.three
1407
- ```
1408
-
1409
- Will create `ref.one.two` as `{}` if it does not exist.
1410
-
1411
- #### ref
1412
-
1413
- The root object to wrap.
1414
-
1415
- #### Returns
1416
-
1417
- A proxy that auto-creates nested objects/arrays
1418
- on property access.
1419
-
1420
- #### Usage Examples
1421
-
1422
- ```ts
1423
- const ref: any = {}
1424
-
1425
- vivify(ref).one.two[3][4]
1426
-
1427
- expect(ref).toEqual({
1428
- one: {
1429
- two: [undefined, undefined, undefined, []],
1430
- },
1431
- })
1432
-
1433
- vivify(ref).one.two[3][4] = 5
1434
-
1435
- expect(ref).toEqual({
1436
- one: {
1437
- two: [
1438
- undefined,
1439
- undefined,
1440
- undefined,
1441
- [undefined, undefined, undefined, undefined, 5],
1442
- ],
1443
- },
1444
- })
1445
-
1446
- vivify(ref).one.two[3].length = 1
1447
-
1448
- expect(ref).toEqual({
1449
- one: {
1450
- two: [undefined, undefined, undefined, [undefined]],
1451
- },
1452
- })
1453
-
1454
- vivify(ref).one.two[3] = 4
1455
-
1456
- expect(ref).toEqual({
1457
- one: {
1458
- two: [undefined, undefined, undefined, 4],
1459
- },
1460
- })
1461
-
1462
- expect(vivify(ref).one.two.length).toBe(4)
1463
-
1464
- expect(ref).toEqual({
1465
- one: {
1466
- two: [undefined, undefined, undefined, 4],
1467
- },
1468
- })
1469
-
1470
- vivify(ref).one.two = 3
1471
-
1472
- expect(ref).toEqual({ one: { two: 3 } })
1473
-
1474
- vivify(ref).one.two = undefined
1475
-
1476
- expect(ref).toEqual({ one: { two: undefined } })
1477
-
1478
- delete vivify(ref).one.two
1479
-
1480
- expect(ref).toEqual({ one: {} })
1481
-
1482
- expect(vivify(ref).one.toString instanceof Function).toBe(
1483
- true
1484
- )
1485
-
1486
- expect(vivify(ref).one.toString.name).toBe('toString')
1487
-
1488
- expect(ref).toEqual({ one: {} })
1489
-
1490
- delete vivify(ref).one.two.three
1491
-
1492
- expect(ref).toEqual({ one: { two: {} } })
1493
-
1494
- vivify(ref).one.two.three.four
1495
-
1496
- expect(ref).toEqual({ one: { two: { three: {} } } })
1497
-
1498
- vivify(ref).one.two[3]
1499
-
1500
- expect(ref).toEqual({ one: { two: { three: {} } } })
1501
-
1502
- vivify(ref).one.two.three.four = 5
1503
-
1504
- expect(ref).toEqual({
1505
- one: { two: { three: { four: 5 } } },
1506
- })
1507
-
1508
- expect(vivify(ref).one.two.three.four.toString.name).toBe(
1509
- 'toString'
1510
- )
1511
-
1512
- expect(ref).toEqual({
1513
- one: { two: { three: { four: 5 } } },
1514
- })
1515
- ```
1516
-
1517
- ```ts
1518
- const u = undefined
1519
-
1520
- vivify(u).one.two = 3
1521
-
1522
- expect(u).toBeUndefined()
1523
-
1524
- const n = null
1525
-
1526
- delete vivify(n).one.two.three
1527
-
1528
- expect(n).toBeNull()
1529
- ```
1530
-
1531
1360
  ## License
1532
1361
 
1533
1362
  The MIT License (MIT)