diff options
author | (quasar) nebula <qznebula@protonmail.com> | 2024-03-06 13:35:56 -0400 |
---|---|---|
committer | (quasar) nebula <qznebula@protonmail.com> | 2024-06-18 22:56:01 -0300 |
commit | cca401d4b00c187f069eef25336d2364fb8d448e (patch) | |
tree | d1be65cffda53a011715a2563986482ab7c50cb1 /src/data | |
parent | 23ec39493825d027506ba1a2124c8a8bc51a9cbe (diff) |
cacheable-object: clone, copyUpdateValuesOnto
Diffstat (limited to 'src/data')
-rw-r--r-- | src/data/cacheable-object.js | 12 |
1 files changed, 12 insertions, 0 deletions
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 { |