Right now, in JavaScript, named capturing groups in a regex need to be unique. So
str.match(/(?<year>[0-9]{4})-[0-9]{2}|[0-9]{2}-(?<year>[0-9]{4})/)
is an error, because you've reused the year group name. But sometimes you want to match a thing which can be written in multiple formats (as above). It would be nice to be able to use the same group name for that case. Tags: regex, variable names
Implement a String.dedent
tag template function, for a tagged template literal behaving almost the same as a regular single backticked template literal, with a few key differences:
Tags: template literals, indentations, whitespace interpolation
This proposal seeks to extend the Decorators proposal by adding the ability for decorators to associate metadata with the value being decorated.
Decorators are functions that allow users to metaprogram by wrapping and replacing existing values. This allows them to solve a number of use cases quite well, such as memoization, reactivity, method binding, and more. However, there are a number of use cases which require code external to the decorator and decorated class to be able to introspect and understand what decorations were applied
Tags sugar, DX, static analysis
The Faster Promise Adoption proposal aims to reduce the number of ticks required for an outer promise to adopt the state of an inner promise.
In the current specification, it requires 2 ticks for the outer promise to finally "settle" with the inner promise's 1 value. This comes up in initial promise resolution (like above), chained promises p.then(() => Promise.resolve(1)), and with async functions:
// Directly returning a promise settles `direct` after 2 ticks.
const direct = (async () => Promise.resolve(1))();
// Returning an awaited promise's value settles `awaited` after 1 ticks.
const awaited = (async () => await Promise.resolve(1))();
This proposal seeks to introduce syntax to ECMAScript regular expressions to control backtracking in certain scenarios by treating certain portions of a pattern as "atomic", where backtracking information specific to that portion of the pattern is discarded when it matches successfully.
For example, currently the pattern a(bc|b)c will match both "abcc" and "abc". In the case of "abcc", we match the term a, then the alternative bc, and finally the term c. In the case of "abc", we match the term a, then the alternative bc (consuming the rest of the input), but fail to match the final term c. Since the rest of the match failed, we backtrack to the beginning of the disjunction bc|b and attempt the alternative. We then match the alternative b, and finally the term c.