tc39-weakrefs-shim
Version:
Shim for TC39 Weakrefs proposal
15 lines • 464 B
JavaScript
export default 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;
}
//# sourceMappingURL=privates.js.map