Skip to content

Commit 263960c

Browse files
committed
Fix: revert "chore: drop support for Nodejs 20 (#412)"
This reverts commit 94c3904.
1 parent 0f2dc7a commit 263960c

5 files changed

Lines changed: 23 additions & 7 deletions

File tree

.github/workflows/pr.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ jobs:
1212
# - 'macos-latest'
1313
# - 'windows-latest'
1414
node_version:
15-
- '25'
1615
- '24'
1716
- '22'
17+
- '20'
1818
name: Node.js ${{ matrix.node_version }} on ${{ matrix.os }}
1919
runs-on: ${{ matrix.os }}
2020
steps:

eslint.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export default [
1313
languageOptions: {
1414
globals: { ...globals.builtin, ...globals.node },
1515
},
16-
settings: { node: { version: '22' } },
16+
settings: { node: { version: '20' } },
1717
},
1818
{ ignores: ['index.cjs'] },
1919
]

index.js

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,22 @@ const sortObjectBy = (comparator, deep) => {
3434

3535
return over
3636
}
37+
const objectGroupBy =
38+
// eslint-disable-next-line n/no-unsupported-features/es-builtins, n/no-unsupported-features/es-syntax -- Safe
39+
Object.groupBy ||
40+
// Remove this when we drop support for Node.js 20
41+
((array, callback) => {
42+
const result = Object.create(null)
43+
for (const value of array) {
44+
const key = callback(value)
45+
if (result[key]) {
46+
result[key].push(value)
47+
} else {
48+
result[key] = [value]
49+
}
50+
}
51+
return result
52+
})
3753
const sortObject = sortObjectBy()
3854
const sortURLObject = sortObjectBy(['type', 'url'])
3955
const sortPeopleObject = sortObjectBy(['name', 'email', 'url'])
@@ -414,7 +430,7 @@ const sortScripts = onObject((scripts, packageJson) => {
414430
- Move `default` condition to bottom
415431
*/
416432
const sortConditions = (conditions) => {
417-
const { defaultConditions = [], restConditions = [] } = Object.groupBy(
433+
const { defaultConditions = [], restConditions = [] } = objectGroupBy(
418434
conditions,
419435
(condition) => {
420436
if (condition === 'default') {
@@ -429,7 +445,7 @@ const sortConditions = (conditions) => {
429445
}
430446

431447
const sortExports = onObject((exports) => {
432-
const { paths = [], conditions = [] } = Object.groupBy(
448+
const { paths = [], conditions = [] } = objectGroupBy(
433449
Object.keys(exports),
434450
(key) => (key.startsWith('.') ? 'paths' : 'conditions'),
435451
)
@@ -619,7 +635,7 @@ function sortPackageJson(jsonIsh, options = {}) {
619635

620636
if (Array.isArray(sortOrder)) {
621637
const keys = Object.keys(json)
622-
const { privateKeys = [], publicKeys = [] } = Object.groupBy(
638+
const { privateKeys = [], publicKeys = [] } = objectGroupBy(
623639
keys,
624640
(key) => (key[0] === '_' ? 'privateKeys' : 'publicKeys'),
625641
)

package-lock.json

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,6 +103,6 @@
103103
"tstyche": "^5.0.1"
104104
},
105105
"engines": {
106-
"node": ">=22"
106+
"node": ">=20"
107107
}
108108
}

0 commit comments

Comments
 (0)