assign-gingerly 0.0.63 → 0.0.64
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/assignTentatively.ts
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
*
|
|
2
|
+
* assignTentatively — reversible assignment with change tracking.
|
|
3
3
|
*/
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
}
|
|
4
|
+
import type { IAssignTentativelyOptions } from './types/assign-gingerly/types.js';
|
|
5
|
+
export type { IAssignTentativelyOptions };
|
|
7
6
|
|
|
8
7
|
/**
|
|
9
8
|
* Helper function to check if a string key represents an += command
|
package/object-extension.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import assignGingerly, { EnhancementRegistry, ItemscopeRegistry, IAssignGingerlyOptions, getInstanceMap, INSTANCE_MAP_GUID } from './assignGingerly.js';
|
|
2
2
|
import assignTentatively from './assignTentatively.js';
|
|
3
|
+
import type { IAssignTentativelyOptions } from './types/assign-gingerly/types.js';
|
|
3
4
|
import { EnhancementConfig, SpawnContext } from './types/assign-gingerly/types.js';
|
|
4
5
|
import { parseWithAttrs } from './parseWithAttrs.js';
|
|
5
6
|
|
|
@@ -77,7 +78,7 @@ declare global {
|
|
|
77
78
|
*/
|
|
78
79
|
assignTentatively(
|
|
79
80
|
source: Record<string | symbol, any>,
|
|
80
|
-
options?:
|
|
81
|
+
options?: IAssignTentativelyOptions
|
|
81
82
|
): Record<string | symbol, any>;
|
|
82
83
|
}
|
|
83
84
|
}
|
|
@@ -576,10 +577,10 @@ Object.defineProperty(Object.prototype, 'assignTentatively', {
|
|
|
576
577
|
value: function <T extends object>(
|
|
577
578
|
this: T,
|
|
578
579
|
source: Record<string | symbol, any>,
|
|
579
|
-
options?:
|
|
580
|
+
options?: IAssignTentativelyOptions
|
|
580
581
|
): Record<string | symbol, any> {
|
|
581
582
|
const reversal = options?.reversal ?? {};
|
|
582
|
-
assignTentatively(this, source, { reversal });
|
|
583
|
+
assignTentatively(this, source, { ...options, reversal });
|
|
583
584
|
return reversal;
|
|
584
585
|
},
|
|
585
586
|
writable: true,
|
package/package.json
CHANGED
|
@@ -261,6 +261,34 @@ export interface IAssignGingerlyOptions {
|
|
|
261
261
|
signal?: AbortSignal;
|
|
262
262
|
}
|
|
263
263
|
|
|
264
|
+
/**
|
|
265
|
+
* Options for assignTentatively — reversible assignment with change tracking.
|
|
266
|
+
*
|
|
267
|
+
* Supports a subset of assignGingerly's path features (nested paths, +=, =!, -=)
|
|
268
|
+
* with the addition of reversal tracking.
|
|
269
|
+
*/
|
|
270
|
+
export interface IAssignTentativelyOptions {
|
|
271
|
+
/**
|
|
272
|
+
* Object to accumulate reversal entries into.
|
|
273
|
+
* If omitted, a new object is created internally.
|
|
274
|
+
* Pass an existing object to accumulate reversals across multiple calls.
|
|
275
|
+
*
|
|
276
|
+
* The reversal object can be passed to assignGingerly to undo all changes:
|
|
277
|
+
* @example
|
|
278
|
+
* const reversal = {};
|
|
279
|
+
* assignTentatively(obj, { name: 'Bob' }, { reversal });
|
|
280
|
+
* // Later:
|
|
281
|
+
* assignGingerly(obj, reversal); // restores name to original value
|
|
282
|
+
*/
|
|
283
|
+
reversal?: Record<string | symbol, any>;
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* Alias mappings for property and method names.
|
|
287
|
+
* Same semantics as IAssignGingerlyOptions.aka — substituted before path evaluation.
|
|
288
|
+
*/
|
|
289
|
+
aka?: Record<string, string>;
|
|
290
|
+
}
|
|
291
|
+
|
|
264
292
|
/**
|
|
265
293
|
* Options for synchronous value resolution (getValues / getValue).
|
|
266
294
|
* Extends IAssignGingerlyOptions with synchronous protocol handlers.
|