assign-gingerly 0.0.71 โ†’ 0.0.72

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/DX/emojis.js CHANGED
@@ -33,7 +33,22 @@ export const akaMethods = {
33
33
  '๐Ÿ”': 'querySelector',
34
34
  '๐Ÿงบ': 'querySelectorAll',
35
35
  '+': 'add',
36
+ '-': 'remove',
36
37
  '๐Ÿงฌ': 'cloneNode',
38
+ '๐Ÿ”„๏ธ': 'reset',
39
+ '๐ŸŽฏ': 'closest',
40
+ 'โœ…': 'matches',
41
+ 'โ˜‘๏ธ': 'checkValidity',
42
+ '๐Ÿ“ค': 'submit',
43
+ '๐ŸŽš๏ธ': 'toggle',
44
+ '๐Ÿ“ฆ': 'contains',
45
+ '๐Ÿท๏ธ': 'setAttribute',
46
+ 'โœ‚๏ธ': 'removeAttribute',
47
+ '๐Ÿ“': 'log',
48
+ 'โš ๏ธ': 'warn',
49
+ '๐Ÿšจ': 'error',
50
+ '๐Ÿคฑ': 'appendChild'
51
+ //'๐Ÿงฉ': 'includes'
37
52
  };
38
53
  export const aka = {
39
54
  'ยฉ๏ธ': 'content?.cloneNode?.true',
@@ -46,5 +61,6 @@ export const aka = {
46
61
  export const emojis = {
47
62
  builtInEmoji,
48
63
  akaMethods,
64
+ aka
49
65
  };
50
66
  export default emojis;
package/DX/emojis.ts CHANGED
@@ -35,7 +35,22 @@ export const akaMethods: Record<string, string> = {
35
35
  '๐Ÿ”': 'querySelector',
36
36
  '๐Ÿงบ': 'querySelectorAll',
37
37
  '+': 'add',
38
+ '-': 'remove',
38
39
  '๐Ÿงฌ': 'cloneNode',
40
+ '๐Ÿ”„๏ธ': 'reset',
41
+ '๐ŸŽฏ': 'closest',
42
+ 'โœ…': 'matches',
43
+ 'โ˜‘๏ธ': 'checkValidity',
44
+ '๐Ÿ“ค': 'submit',
45
+ '๐ŸŽš๏ธ': 'toggle',
46
+ '๐Ÿ“ฆ': 'contains',
47
+ '๐Ÿท๏ธ': 'setAttribute',
48
+ 'โœ‚๏ธ': 'removeAttribute',
49
+ '๐Ÿ“': 'log',
50
+ 'โš ๏ธ': 'warn',
51
+ '๐Ÿšจ': 'error',
52
+ '๐Ÿคฑ': 'appendChild'
53
+ //'๐Ÿงฉ': 'includes'
39
54
  };
40
55
 
41
56
  export const aka: Record<string, string> = {
@@ -51,6 +66,7 @@ export const aka: Record<string, string> = {
51
66
  export const emojis = {
52
67
  builtInEmoji,
53
68
  akaMethods,
69
+ aka
54
70
  }
55
71
 
56
72
  export default emojis;
package/README.md CHANGED
@@ -380,6 +380,30 @@ When a path segment matches a name in the `withMethods` array/set:
380
380
  - If it's a **middle segment** and the next segment is NOT a method: called with the next segment as a string argument
381
381
  - If the property is not a function: silently skipped
382
382
 
383
+ **Zero-argument calls (`|` marker):**
384
+
385
+ Append `|` to a segment to call a listed method with no arguments, without consuming the next segment:
386
+
387
+ ```TypeScript
388
+ assignGingerly(elementRef, {
389
+ '?.deref|?.classList?.add': 'active'
390
+ }, { withMethods: ['deref', 'add'] });
391
+
392
+ // Equivalent to: elementRef.deref().classList.add('active')
393
+ ```
394
+
395
+ On the **last segment**, `|` calls the method with no arguments and ignores the RHS value:
396
+
397
+ ```TypeScript
398
+ assignGingerly(form, {
399
+ '?.reset|': true
400
+ }, { withMethods: ['reset'] });
401
+
402
+ // Equivalent to: form.reset()
403
+ ```
404
+
405
+ The `|` suffix only applies to names listed in `withMethods` โ€” on any other segment it is treated as part of a literal property name.
406
+
383
407
  **Array arguments:**
384
408
 
385
409
  Arrays are spread as multiple arguments:
@@ -403,7 +427,7 @@ const elementRef = {
403
427
  };
404
428
 
405
429
  assignGingerly(elementRef, {
406
- '?.deref?.classList?.add': 'active'
430
+ '?.deref|?.classList?.add': 'active'
407
431
  }, { withMethods: ['deref', 'add'] });
408
432
 
409
433
  // Equivalent to: elementRef.deref().classList.add('active')
@@ -564,10 +588,13 @@ div.innerHTML = `
564
588
  assignGingerly(div, {
565
589
  '?.๐Ÿ”?.my-element?.๐ŸŽจ?.+': 'highlighted'
566
590
  }, {
591
+ aka: {
592
+ //not a method!
593
+ '๐ŸŽจ': 'classList',
594
+ },
567
595
  akaMethods: {
568
596
  '๐Ÿ”': 'querySelector',
569
- '๐ŸŽจ': 'classList',
570
- '+': 'add'
597
+ '+': 'add',
571
598
  }
572
599
  });
573
600
 
package/assignFrom.js CHANGED
@@ -377,7 +377,7 @@ function getEffectiveIds(options) {
377
377
  /**
378
378
  * Process #[x] normal keys synchronously.
379
379
  */
380
- function processIdRefNormalKeys(idRefNormalKeys, expandedPattern, target, options) {
380
+ function processIdRefNormalKeys(idRefNormalKeys, expandedPattern, target, options, permissions) {
381
381
  const ids = getEffectiveIds(options);
382
382
  if (!ids)
383
383
  return;
@@ -392,12 +392,12 @@ function processIdRefNormalKeys(idRefNormalKeys, expandedPattern, target, option
392
392
  const value = expandedPattern[key];
393
393
  if (parsed.remainingPath) {
394
394
  const resolvedValue = getValues({ __v: value }, from, { withMethods, aka, akaMethods, protocols, root: target });
395
- assignGingerly(el, { [parsed.remainingPath]: resolvedValue.__v }, options);
395
+ assignGingerly(el, { [parsed.remainingPath]: resolvedValue.__v }, options, permissions);
396
396
  }
397
397
  else {
398
398
  const resolvedValue = getValues(typeof value === 'object' && value !== null ? value : { __v: value }, from, { withMethods, aka, akaMethods, protocols, root: target });
399
399
  if (!('__v' in resolvedValue)) {
400
- assignGingerly(el, resolvedValue, options);
400
+ assignGingerly(el, resolvedValue, options, permissions);
401
401
  }
402
402
  }
403
403
  }
@@ -436,7 +436,7 @@ export function assignFrom(target, pattern, options, permissions) {
436
436
  }
437
437
  }
438
438
  if (Object.keys(ternaryResolved).length > 0) {
439
- assignGingerly(target, ternaryResolved, options);
439
+ assignGingerly(target, ternaryResolved, options, permissions);
440
440
  }
441
441
  }
442
442
  // Process normal keys via getValues (sync) + assignGingerly
@@ -472,11 +472,11 @@ export function assignFrom(target, pattern, options, permissions) {
472
472
  }
473
473
  const resolved = getValues(normalPattern, options.from, resolveOptions);
474
474
  handleSpreads(resolved);
475
- assignGingerly(target, resolved, options);
475
+ assignGingerly(target, resolved, options, permissions);
476
476
  }
477
477
  // Process #[x] normal keys (sync)
478
478
  if (idRefNormalKeys.length > 0) {
479
- processIdRefNormalKeys(idRefNormalKeys, expandedPattern, target, options);
479
+ processIdRefNormalKeys(idRefNormalKeys, expandedPattern, target, options, permissions);
480
480
  }
481
481
  // Process handler commands โ€” fire-and-forget (async)
482
482
  if (handlerKeys.length > 0) {
package/assignFrom.ts CHANGED
@@ -387,10 +387,11 @@ function getEffectiveIds(options: AssignFromOptions): Record<string, any> | unde
387
387
  * Process #[x] normal keys synchronously.
388
388
  */
389
389
  function processIdRefNormalKeys(
390
- idRefNormalKeys: string[],
391
- expandedPattern: Record<string, any>,
392
- target: any,
393
- options: AssignFromOptions
390
+ idRefNormalKeys: string[],
391
+ expandedPattern: Record<string, any>,
392
+ target: any,
393
+ options: AssignFromOptions,
394
+ permissions?: AssignPermissions
394
395
  ): void {
395
396
  const ids = getEffectiveIds(options);
396
397
  if (!ids) return;
@@ -409,7 +410,7 @@ function processIdRefNormalKeys(
409
410
  { __v: value }, from,
410
411
  { withMethods, aka, akaMethods, protocols, root: target }
411
412
  );
412
- assignGingerly(el, { [parsed.remainingPath]: resolvedValue.__v }, options);
413
+ assignGingerly(el, { [parsed.remainingPath]: resolvedValue.__v }, options, permissions);
413
414
  } else {
414
415
  const resolvedValue = getValues(
415
416
  typeof value === 'object' && value !== null ? value : { __v: value },
@@ -417,7 +418,7 @@ function processIdRefNormalKeys(
417
418
  { withMethods, aka, akaMethods, protocols, root: target }
418
419
  );
419
420
  if (!('__v' in resolvedValue)) {
420
- assignGingerly(el, resolvedValue, options);
421
+ assignGingerly(el, resolvedValue, options, permissions);
421
422
  }
422
423
  }
423
424
  }
@@ -463,7 +464,7 @@ export function assignFrom(
463
464
  }
464
465
  }
465
466
  if (Object.keys(ternaryResolved).length > 0) {
466
- assignGingerly(target, ternaryResolved, options);
467
+ assignGingerly(target, ternaryResolved, options, permissions);
467
468
  }
468
469
  }
469
470
 
@@ -501,12 +502,12 @@ export function assignFrom(
501
502
  const resolved = getValues(normalPattern, options.from, resolveOptions);
502
503
 
503
504
  handleSpreads(resolved);
504
- assignGingerly(target, resolved, options);
505
+ assignGingerly(target, resolved, options, permissions);
505
506
  }
506
507
 
507
508
  // Process #[x] normal keys (sync)
508
509
  if (idRefNormalKeys.length > 0) {
509
- processIdRefNormalKeys(idRefNormalKeys, expandedPattern, target, options);
510
+ processIdRefNormalKeys(idRefNormalKeys, expandedPattern, target, options, permissions);
510
511
  }
511
512
 
512
513
  // Process handler commands โ€” fire-and-forget (async)
@@ -40,7 +40,7 @@ export async function assignFromAsync(target, pattern, options, permissions) {
40
40
  });
41
41
  // Recursively handle "..." spread keys at all nesting levels
42
42
  handleSpreads(resolved);
43
- assignGingerly(target, resolved, options);
43
+ assignGingerly(target, resolved, options, permissions);
44
44
  }
45
45
  // Process #[x] normal keys โ€” resolve element, then apply remaining path + value
46
46
  if (idRefNormalKeys.length > 0 && (options.pin || options.at)) {
@@ -59,7 +59,7 @@ export async function assignFromAsync(target, pattern, options, permissions) {
59
59
  // Resolve the RHS value
60
60
  const resolvedValue = await resolveValues({ __v: value }, from, { withMethods, aka, akaMethods, protocols, root: el });
61
61
  // Apply remaining path on the resolved element
62
- assignGingerly(el, { [parsed.remainingPath]: resolvedValue.__v }, options);
62
+ assignGingerly(el, { [parsed.remainingPath]: resolvedValue.__v }, options, permissions);
63
63
  }
64
64
  else {
65
65
  // No remaining path โ€” resolve and assign directly to the element
@@ -68,7 +68,7 @@ export async function assignFromAsync(target, pattern, options, permissions) {
68
68
  // Single value โ€” can't assign to element root without a path
69
69
  }
70
70
  else {
71
- assignGingerly(el, resolvedValue, options);
71
+ assignGingerly(el, resolvedValue, options, permissions);
72
72
  }
73
73
  }
74
74
  }
@@ -77,7 +77,7 @@ export async function assignFromAsync(
77
77
  // Recursively handle "..." spread keys at all nesting levels
78
78
  handleSpreads(resolved);
79
79
 
80
- assignGingerly(target, resolved, options);
80
+ assignGingerly(target, resolved, options, permissions);
81
81
  }
82
82
 
83
83
  // Process #[x] normal keys โ€” resolve element, then apply remaining path + value
@@ -100,7 +100,7 @@ export async function assignFromAsync(
100
100
  { withMethods, aka, akaMethods, protocols, root: el }
101
101
  );
102
102
  // Apply remaining path on the resolved element
103
- assignGingerly(el, { [parsed.remainingPath]: resolvedValue.__v }, options);
103
+ assignGingerly(el, { [parsed.remainingPath]: resolvedValue.__v }, options, permissions);
104
104
  } else {
105
105
  // No remaining path โ€” resolve and assign directly to the element
106
106
  const resolvedValue = await resolveValues(
@@ -111,7 +111,7 @@ export async function assignFromAsync(
111
111
  if ('__v' in resolvedValue) {
112
112
  // Single value โ€” can't assign to element root without a path
113
113
  } else {
114
- assignGingerly(el, resolvedValue, options);
114
+ assignGingerly(el, resolvedValue, options, permissions);
115
115
  }
116
116
  }
117
117
  }