What’s New in TC39’s December Meeting? Intl.Segmenter V2, Array.groupBy, RegExp Enhancements
The December TC39 meeting updated several proposals—including moving Intl.Segmenter to Stage 1 as V2, adding new timeZoneName values, expanding Intl.DisplayNames, introducing Array.prototype.groupBy and Array.fromAsync, and refining RegExp modifiers and buffer boundaries—while outlining the criteria for advancing proposals through the stages.
Stage 3 → Stage 4
Advancing from Stage 3 to Stage 4 requires writing tc39/test262 tests for the proposal, having at least two implementations pass those tests in a released version, and submitting a pull request to integrate the proposal into the official ECMAScript specification with editor approval.
Extend timeZoneName
The Intl.Segmenter V2 proposal extends the timeZoneName option of Intl.DateTimeFormat to provide more precise formatting. New values added are shortOffset, longOffset, shortGeneric, and longGeneric, enabling localized GMT formats and generic time‑zone names.
// default (no timeZoneName)
new Intl.DateTimeFormat('zh-cn').format(date);
// short offset
new Intl.DateTimeFormat('zh-cn', { timeZoneName: 'short' }).format(date);
// long (localized) name
new Intl.DateTimeFormat('zh-cn', { timeZoneName: 'long' }).format(date);Intl.DisplayNames V2
The Intl.DisplayNames V2 proposal adds support for calendars and date‑time fields, extending the API beyond language, region, and currency. Example usage:
var regionNames = new Intl.DisplayNames(['zh-CN'], { type: 'region' });
console.log(regionNames.of('419')); // "拉丁美洲"
var dateTimeFieldNames = new Intl.DisplayNames('zh', { type: 'dateTimeField' });
console.log(dateTimeFieldNames.of('year')); // "年"Stage 2 → Stage 3
To move from Stage 2 to Stage 3, a proposal must have a complete standard text reviewed and signed by a TC39 member and receive editor approval.
Array Grouping
The Array.prototype.groupBy proposal adds built‑in array grouping similar to Lodash’s groupBy, plus groupByToMap which returns a Map of groups.
const array = [1, 2, 3, 4, 5];
// => { odd: [1,3,5], even: [2,4] }
array.groupBy((num) => num % 2 === 0 ? 'even' : 'odd');Stage 1 → Stage 2
Advancing from Stage 1 to Stage 2 requires drafting a complete standard text for the proposal.
Array.fromAsync
The Array.fromAsync proposal introduces a native way to create arrays from async iterables, returning a Promise. It also accepts an optional async mapping function and a thisArg.
async function* asyncGen(n) {
for (let i = 0; i < n; i++) yield i * 2;
}
const arr = await Array.fromAsync(asyncGen(4)); // [0,2,4,6]RegExp Modifiers
The RegExp Modifiers proposal adds self‑bounded subexpressions like (?imsx-imsx:subexpression) to enable or disable flags for specific parts of a pattern. The unbounded mode was removed in the latest meeting.
// self‑bounded example
const re = /(?-i:A(?i:B)C)/;
re.test('AbC'); // trueRegExp Buffer Boundaries
The RegExp Buffer Boundaries proposal introduces \A (start of input), \z (end of input), and \Z (end or before final newline). The \Z token was temporarily removed from Stage 2.
const re = new RegExp('\\Afoo\\z', 'u');
re.test('foo'); // trueStage 0 → Stage 1
Moving from Stage 0 to Stage 1 requires a champion TC39 member, a clear problem statement and solution sketch, example use cases, and analysis of the API, algorithms, semantics, and implementation risks.
Intl.Segmenter V2
The Intl.Segmenter V2 proposal adds line granularity and an isHardBreak flag, enabling more accurate text processing for CJK languages and other scripts. Example:
let segmenter = new Intl.Segmenter('zh-CN', { granularity: 'word' });
let segments = segmenter.segment('我不是,我没有,你别瞎说。');
for (let {segment, index, isWordLike} of segments) {
console.log(`segment at [${index}, ${index+segment.length}): «${segment}»${isWordLike ? ' (word-like)' : ''}`);
}Conclusion
The JavaScript Chinese Interest Group (JSCIG) invites developers to discuss ECMAScript topics on GitHub: https://github.com/JSCIG/es-discuss/discussions .
Signed-in readers can open the original source through BestHub's protected redirect.
This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactand we will review it promptly.
How this landed with the community
Was this worth your time?
0 Comments
Thoughtful readers leave field notes, pushback, and hard-won operational detail here.
