There is inconsistent ordering for named capture groups from v12.10.0 to v12.11.0. It appears that versions that came before v12.11.0 ordered the keys by the way they were ordered in the regular expression. v12.11.0 seems to sort the keys.
const r = /(?<BKey>.+)\s(?<AKey>.+)/;
const s = 'example string';
// node v12.10.0
r.exec(s).groups;
// { "BKey": "example", "AKey": "string" }
// node v12.11.0
r.exec(s).groups;
// { "AKey": "string", "BKey": "example" }
Interesting – my understand of the spec would indicate to me that the former behaviour is correct: https://tc39.es/ecma262/#sec-regexpbuiltinexec
/cc @nodejs/v8
Filed V8 bug https://crbug.com/v8/9822.
Fixed upstream in https://crrev.com/c/1864829.
Most helpful comment
Filed V8 bug https://crbug.com/v8/9822.