Skip to content

Commit 0831322

Browse files
committed
Require Node.js 20
1 parent 28d61f4 commit 0831322

4 files changed

Lines changed: 30 additions & 27 deletions

File tree

.github/workflows/main.yml

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,10 +10,11 @@ jobs:
1010
fail-fast: false
1111
matrix:
1212
node-version:
13-
- 16
13+
- 24
14+
- 20
1415
steps:
15-
- uses: actions/checkout@v4
16-
- uses: actions/setup-node@v4
16+
- uses: actions/checkout@v5
17+
- uses: actions/setup-node@v5
1718
with:
1819
node-version: ${{ matrix.node-version }}
1920
- run: npm install

index.d.ts

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ type DeepMapper<
4848
mapperOptions?: MapperOptions,
4949
] | typeof mapObjectSkip;
5050

51-
export interface Options {
51+
export type Options = {
5252
/**
5353
Recurse nested objects and objects in arrays.
5454
@@ -64,17 +64,17 @@ export interface Options {
6464
@default {}
6565
*/
6666
readonly target?: Record<string, unknown>;
67-
}
67+
};
6868

69-
export interface DeepOptions extends Options {
69+
export type DeepOptions = {
7070
readonly deep: true;
71-
}
71+
} & Options;
7272

73-
export interface TargetOptions<TargetObjectType extends Record<string, unknown>> extends Options {
73+
export type TargetOptions<TargetObjectType extends Record<string, unknown>> = {
7474
readonly target: TargetObjectType;
75-
}
75+
} & Options;
7676

77-
export interface MapperOptions {
77+
export type MapperOptions = {
7878
/**
7979
Whether `targetValue` should be recursed.
8080
@@ -83,7 +83,7 @@ export interface MapperOptions {
8383
@default true
8484
*/
8585
readonly shouldRecurse?: boolean;
86-
}
86+
};
8787

8888
/**
8989
Map object keys and values into a new object.
@@ -139,22 +139,22 @@ export default function mapObject<
139139
>(
140140
source: SourceObjectType,
141141
mapper: Mapper<
142-
SourceObjectType,
143-
MappedObjectKeyType,
144-
MappedObjectValueType
142+
SourceObjectType,
143+
MappedObjectKeyType,
144+
MappedObjectValueType
145145
>,
146146
options: TargetOptions<TargetObjectType>
147-
): TargetObjectType & {[K in MappedObjectKeyType]: MappedObjectValueType};
147+
): TargetObjectType & Record<MappedObjectKeyType, MappedObjectValueType>;
148148
export default function mapObject<
149149
SourceObjectType extends Record<string, unknown>,
150150
MappedObjectKeyType extends string,
151151
MappedObjectValueType,
152152
>(
153153
source: SourceObjectType,
154154
mapper: Mapper<
155-
SourceObjectType,
156-
MappedObjectKeyType,
157-
MappedObjectValueType
155+
SourceObjectType,
156+
MappedObjectKeyType,
157+
MappedObjectValueType
158158
>,
159159
options?: Options
160-
): {[K in MappedObjectKeyType]: MappedObjectValueType};
160+
): Record<MappedObjectKeyType, MappedObjectValueType>;

index.test-d.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import {expectType, expectAssignable} from 'tsd';
2-
import mapObject, {Options, mapObjectSkip} from './index.js';
2+
import mapObject, {type Options, mapObjectSkip} from './index.js';
33

4-
const options: Options = {}; // eslint-disable-line @typescript-eslint/no-unused-vars
4+
const options: Options = {};
55

66
const newObject = mapObject({foo: 'bar'}, (key, value) => [value, key]);
77
expectType<Record<string, 'foo'>>(newObject);

package.json

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -11,11 +11,13 @@
1111
"url": "https://sindresorhus.com"
1212
},
1313
"type": "module",
14-
"exports": "./index.js",
15-
"types": "./index.d.ts",
14+
"exports": {
15+
"types": "./index.d.ts",
16+
"default": "./index.js"
17+
},
1618
"sideEffects": false,
1719
"engines": {
18-
"node": "^12.20.0 || ^14.13.1 || >=16.0.0"
20+
"node": ">=20"
1921
},
2022
"scripts": {
2123
"test": "xo && ava && tsd"
@@ -40,8 +42,8 @@
4042
"recursive"
4143
],
4244
"devDependencies": {
43-
"ava": "^3.15.0",
44-
"tsd": "^0.18.0",
45-
"xo": "^0.45.0"
45+
"ava": "^6.4.1",
46+
"tsd": "^0.33.0",
47+
"xo": "^1.2.2"
4648
}
4749
}

0 commit comments

Comments
 (0)