svelte-eslint-parser
Version:
Svelte parser for ESLint
37 lines (36 loc) • 887 B
JavaScript
/** A class that collects pattern nodes for Let directives. */
export class LetDirectiveCollection {
constructor() {
this.list = [];
}
getLetParams() {
return this.list;
}
addPattern(pattern, directive, typing, ...callbacks) {
this.list.push({
node: pattern,
parent: directive,
typing,
callback(node, options) {
for (const callback of callbacks) {
callback(node, options);
}
},
});
return callbacks;
}
}
export class LetDirectiveCollections {
constructor() {
this.stack = [];
}
beginExtract() {
this.stack.push(new LetDirectiveCollection());
}
getCollection() {
return this.stack[this.stack.length - 1];
}
extract() {
return this.stack.pop();
}
}