tahamajs's picture
download
raw
950 Bytes
// @flow
import type {Expression} from './expression';
/**
* Tracks `let` bindings during expression parsing.
* @private
*/
class Scope {
parent: ?Scope;
bindings: {[_: string]: Expression};
constructor(parent?: Scope, bindings: Array<[string, Expression]> = []) {
this.parent = parent;
this.bindings = {};
for (const [name, expression] of bindings) {
this.bindings[name] = expression;
}
}
concat(bindings: Array<[string, Expression]>) {
return new Scope(this, bindings);
}
get(name: string): Expression {
if (this.bindings[name]) { return this.bindings[name]; }
if (this.parent) { return this.parent.get(name); }
throw new Error(`${name} not found in scope.`);
}
has(name: string): boolean {
if (this.bindings[name]) return true;
return this.parent ? this.parent.has(name) : false;
}
}
export default Scope;

Xet Storage Details

Size:
950 Bytes
·
Xet hash:
b11ff5dd0c9ef324ecc31c8fce3b9c1b54d2dd46e1af0c9db89f82c75f5eea49

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.