UNPKG

calcium-js

Version:
39 lines 1.04 kB
export class Namespace { constructor(parent) { this.parent = parent; this.dict = new Map(); } lookUp(key) { var _a; let value = this.dict.get(key); if (value !== undefined) { return value; } else { value = (_a = this.parent) === null || _a === void 0 ? void 0 : _a.lookUp(key); if (value === undefined) { if (key === 'document') { // NOT allow to access DOM return undefined; } else { return (window || global)[key]; } } else { return value; } } } register(key, value) { this.dict.set(key, value); } /** * the parent scope of a function or a method. * When this namespace is not a class scope, then returns this. */ get nestingScope() { return this.parent; } } //# sourceMappingURL=namespace.js.map