From cca401d4b00c187f069eef25336d2364fb8d448e Mon Sep 17 00:00:00 2001 From: "(quasar) nebula" Date: Wed, 6 Mar 2024 13:35:56 -0400 Subject: cacheable-object: clone, copyUpdateValuesOnto --- src/data/cacheable-object.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'src/data') diff --git a/src/data/cacheable-object.js b/src/data/cacheable-object.js index 71dc5bde..010d967a 100644 --- a/src/data/cacheable-object.js +++ b/src/data/cacheable-object.js @@ -374,6 +374,18 @@ export default class CacheableObject { return object.#propertyUpdateValues[key] ?? null; } + + static clone(object) { + const newObject = Reflect.construct(object.constructor, []); + + this.copyUpdateValuesOnto(object, newObject); + + return newObject; + } + + static copyUpdateValuesOnto(source, target) { + Object.assign(target, source.#propertyUpdateValues); + } } export class CacheableObjectPropertyValueError extends Error { -- cgit 1.3.0-6-gf8a5