Add lightweight correctness linting and resolve formatting conflicts
This commit is contained in:
Vendored
+16
-5
@@ -2,11 +2,22 @@
|
||||
* the raw ID. These handles do not themselves confer authority or a lease. */
|
||||
const identities = new WeakMap();
|
||||
class Reference {
|
||||
constructor(id) { identities.set(this, id); Object.freeze(this); }
|
||||
equals(other) { return isObjectReference(other) && identities.get(this) === identities.get(other); }
|
||||
toJSON() { throw new Error("Object references cannot be serialized into ordinary data"); }
|
||||
toString() { throw new Error("Object references cannot be coerced to strings"); }
|
||||
[Symbol.toPrimitive]() { throw new Error("Object references cannot be coerced to scalar values"); }
|
||||
constructor(id) {
|
||||
identities.set(this, id);
|
||||
Object.freeze(this);
|
||||
}
|
||||
equals(other) {
|
||||
return isObjectReference(other) && identities.get(this) === identities.get(other);
|
||||
}
|
||||
toJSON() {
|
||||
throw new Error("Object references cannot be serialized into ordinary data");
|
||||
}
|
||||
toString() {
|
||||
throw new Error("Object references cannot be coerced to strings");
|
||||
}
|
||||
[Symbol.toPrimitive]() {
|
||||
throw new Error("Object references cannot be coerced to scalar values");
|
||||
}
|
||||
}
|
||||
export const isObjectReference = (value) => typeof value === "object" && value !== null && identities.has(value);
|
||||
/** Internal transport boundary; intentionally not exported from the SDK entry. */
|
||||
|
||||
Reference in New Issue
Block a user