Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
nameofall: Get all const, let, class variables names as strings
// https://esdiscuss.org/topic/what-do-you-think-about-a-c-6-like-nameof-expression-for
// 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.