Files
test-repo/scripts/build/shims/function-object-group-by.js
T

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

16 lines
338 B
JavaScript
Raw Normal View History

2026-05-27 14:30:27 +08:00
const groupBy =
Object.groupBy ??
((array, callback) => {
const result = Object.create(null);
for (const value of array) {
const key = callback(value);
if (result[key]) {
result[key].push(value);
} else {
result[key] = [value];
}
}
return result;
});
export default groupBy;