Scene save operations (in-place overwrite vs copy) (#126)

This commit is contained in:
Danny McGee
2024-04-09 15:39:32 -04:00
committed by GitHub
parent 5cd98b4a35
commit 03f90eee47
16 changed files with 418 additions and 105 deletions
+5
View File
@@ -35,4 +35,9 @@ describe("deref", () => {
const v3 = deref((() => {})());
expect(v3).toBe(undefined);
});
it("should return `undefined` when given an empty Ref", () => {
const derefed = deref(createRef());
expect(derefed).toBe(undefined);
});
});
+4 -1
View File
@@ -11,6 +11,9 @@ function isRef<T>(refOrValue: Ref<T> | T): refOrValue is Ref<T> {
if (!refOrValue || typeof refOrValue !== "object")
return false;
if (refOrValue instanceof Element)
return false;
const keys = Object.keys(refOrValue);
return keys.length === 1 && keys[0] === "value"
return keys.length === 0 || (keys.length === 1 && keys[0] === "value")
}