Sha256: 08e974d6a8cc3655708ea560c34d070829611dccc6052e032fd9f49f389ce9f8
Contents?: true
Size: 1.1 KB
Versions: 10
Compression:
Stored size: 1.1 KB
Contents
import { Node } from 'estree-walker'; interface Extractors { [key: string]: (names: Array<string>, param: Node) => void; } const extractors: Extractors = { ArrayPattern(names: Array<string>, param: Node) { for (const element of param.elements) { if (element) extractors[element.type](names, element); } }, AssignmentPattern(names: Array<string>, param: Node) { extractors[param.left.type](names, param.left); }, Identifier(names: Array<string>, param: Node) { names.push(param.name); }, MemberExpression() {}, ObjectPattern(names: Array<string>, param: Node) { for (const prop of param.properties) { if (prop.type === 'RestElement') { extractors.RestElement(names, prop); } else { extractors[prop.value.type](names, prop.value); } } }, RestElement(names: Array<string>, param: Node) { extractors[param.argument.type](names, param.argument); } }; const extractAssignedNames = function extractAssignedNames(param: Node): Array<string> { const names: Array<string> = []; extractors[param.type](names, param); return names; }; export { extractAssignedNames as default };
Version data entries
10 entries across 10 versions & 1 rubygems