Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
nameofall: Get all const, let, class variables names as strings
// TODO handle destructuring assignment, default values, shorthand assignments, e.g.,
const [{
a = 1,
b = 2
}, cd] = [...[source]];
usage sourceCode.match(nameofall); // ["const x", "let z"];
const nameofall = /((const|let)\s+)\w+(?=\s+(=|in|of))|class\s+\w+(?=\s)/gi;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.