tc39-weakrefs-shim
Version:
Shim for TC39 Weakrefs proposal
18 lines • 558 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
function makePrivates() {
const privates = new WeakMap();
function get(instance) {
if (!privates.has(instance))
throw new Error("Invalid object");
return privates.get(instance);
}
get.init = function init(instance, data) {
if (privates.has(instance))
throw new Error("Invalid object");
privates.set(instance, data);
};
return get;
}
exports.default = makePrivates;
//# sourceMappingURL=privates.js.map