diff --git a/README.md b/README.md index e05a8c5..4bc297f 100644 --- a/README.md +++ b/README.md @@ -217,7 +217,7 @@ import D, { constructedObject } from 'flat-diamond' ### When the class is from a library -Seclusion is your friend +[Seclusion](#seclusion-and-construction) is your friend # Seclusion diff --git a/package.json b/package.json index 0ff35ec..0cd5e5f 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "flat-diamond", - "version": "1.0.3", + "version": "1.0.4", "exports": { ".": { "import": "./lib/esm.js", diff --git a/src/seclude.ts b/src/seclude.ts index 38f06a9..0f5fc21 100644 --- a/src/seclude.ts +++ b/src/seclude.ts @@ -45,10 +45,10 @@ export function Seclude(), + const privates = new WeakMap(), diamondSecluded = !fLegs(base), diamond = diamondSecluded ? (Diamond(PropertyCollector) as TBase) : PropertyCollector - class Secluded extends (diamond as any) { + class GateKeeper extends (diamond as any) { static secluded(obj: TBase): TBase | undefined { return privates.get(obj) } @@ -199,6 +199,6 @@ export function Seclude diamond.prototype }) - Object.setPrototypeOf(Secluded.prototype, fakeCtor.prototype) - return Secluded as any + Object.setPrototypeOf(GateKeeper.prototype, fakeCtor.prototype) + return GateKeeper as any }