Skip to content

Commit 6e107f6

Browse files
committedSep 14, 2023
Require Node.js 18
Fixes #22
1 parent 40f346d commit 6e107f6

File tree

6 files changed

+31
-29
lines changed

6 files changed

+31
-29
lines changed
 

‎.github/workflows/main.yml

+4-4
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ jobs:
1010
fail-fast: false
1111
matrix:
1212
node-version:
13-
- 14
14-
- 12
13+
- 20
14+
- 18
1515
steps:
16-
- uses: actions/checkout@v2
17-
- uses: actions/setup-node@v2
16+
- uses: actions/checkout@v3
17+
- uses: actions/setup-node@v3
1818
with:
1919
node-version: ${{ matrix.node-version }}
2020
- run: npm install

‎index.js

+5-5
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import indentString from 'indent-string';
22
import cleanStack from 'clean-stack';
33

4-
const cleanInternalStack = stack => stack.replace(/\s+at .*aggregate-error\/index.js:\d+:\d+\)?/g, '');
4+
const cleanInternalStack = stack => stack.replaceAll(/\s+at .*aggregate-error\/index.js:\d+:\d+\)?/g, '');
55

66
export default class AggregateError extends Error {
77
#errors;
@@ -27,10 +27,10 @@ export default class AggregateError extends Error {
2727
});
2828

2929
let message = errors
30-
.map(error => {
30+
.map(error =>
3131
// The `stack` property is not standardized, so we can't assume it exists
32-
return typeof error.stack === 'string' && error.stack.length > 0 ? cleanInternalStack(cleanStack(error.stack)) : String(error);
33-
})
32+
typeof error.stack === 'string' && error.stack.length > 0 ? cleanInternalStack(cleanStack(error.stack)) : String(error),
33+
)
3434
.join('\n');
3535
message = '\n' + indentString(message, 4);
3636
super(message);
@@ -39,6 +39,6 @@ export default class AggregateError extends Error {
3939
}
4040

4141
get errors() {
42-
return this.#errors.slice();
42+
return [...this.#errors];
4343
}
4444
}

‎index.test-d.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ import AggregateError from './index.js';
44
const aggregateError = new AggregateError([
55
new Error('foo'),
66
{foo: 'bar'},
7-
'bar'
7+
'bar',
88
]);
99
expectAssignable<Iterable<Error>>(aggregateError.errors);
1010
expectType<IterableIterator<Error>>(aggregateError.errors[Symbol.iterator]());
@@ -23,7 +23,7 @@ class CustomError extends Error {
2323
}
2424
}
2525
const customAggregateError = new AggregateError<CustomError>([
26-
new CustomError('foo')
26+
new CustomError('foo'),
2727
]);
2828

2929
for (const error of customAggregateError.errors) {

‎package.json

+10-8
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,15 @@
1111
"url": "https://sindresorhus.com"
1212
},
1313
"type": "module",
14-
"exports": "./index.js",
14+
"exports": {
15+
"types": "./index.d.ts",
16+
"default": "./index.js"
17+
},
1518
"engines": {
16-
"node": ">=12"
19+
"node": ">=18"
1720
},
1821
"scripts": {
19-
"//test": "xo && ava && tsd",
20-
"test": "ava && tsd"
22+
"test": "xo && ava && tsd"
2123
},
2224
"files": [
2325
"index.js",
@@ -34,12 +36,12 @@
3436
"iterator"
3537
],
3638
"dependencies": {
37-
"clean-stack": "^4.0.0",
39+
"clean-stack": "^5.2.0",
3840
"indent-string": "^5.0.0"
3941
},
4042
"devDependencies": {
41-
"ava": "^3.15.0",
42-
"tsd": "^0.14.0",
43-
"xo": "^0.38.2"
43+
"ava": "^5.3.1",
44+
"tsd": "^0.29.0",
45+
"xo": "^0.56.0"
4446
}
4547
}

‎readme.md

+2-2
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66

77
## Install
88

9-
```
10-
$ npm install aggregate-error
9+
```sh
10+
npm install aggregate-error
1111
```
1212

1313
## Usage

‎test.js

+8-8
Original file line numberDiff line numberDiff line change
@@ -7,11 +7,11 @@ test('main', t => {
77
'bar',
88
{
99
message: 'baz',
10-
code: 'EBAZ'
10+
code: 'EBAZ',
1111
},
1212
{
13-
code: 'EQUX'
14-
}
13+
code: 'EQUX',
14+
},
1515
]);
1616

1717
console.log(error);
@@ -23,7 +23,7 @@ test('main', t => {
2323
new Error('foo'),
2424
new Error('bar'),
2525
Object.assign(new Error('baz'), {code: 'EBAZ'}),
26-
Object.assign(new Error(), {code: 'EQUX'}) // eslint-disable-line unicorn/error-message
26+
Object.assign(new Error(), {code: 'EQUX'}), // eslint-disable-line unicorn/error-message
2727
]);
2828
});
2929

@@ -38,7 +38,7 @@ test('gracefully handle Error instances without a stack', t => {
3838

3939
const error = new AggregateError([
4040
new Error('foo'),
41-
new StacklessError('stackless')
41+
new StacklessError('stackless'),
4242
]);
4343

4444
console.log(error);
@@ -48,7 +48,7 @@ test('gracefully handle Error instances without a stack', t => {
4848

4949
t.deepEqual([...error.errors], [
5050
new Error('foo'),
51-
new StacklessError('stackless')
51+
new StacklessError('stackless'),
5252
]);
5353
});
5454

@@ -63,7 +63,7 @@ test('gracefully handle Error instances with empty stack', t => {
6363

6464
const error = new AggregateError([
6565
new Error('foo'),
66-
new EmptyStackError('emptystack')
66+
new EmptyStackError('emptystack'),
6767
]);
6868

6969
console.log(error);
@@ -73,6 +73,6 @@ test('gracefully handle Error instances with empty stack', t => {
7373

7474
t.deepEqual([...error.errors], [
7575
new Error('foo'),
76-
new EmptyStackError('emptystack')
76+
new EmptyStackError('emptystack'),
7777
]);
7878
});

0 commit comments

Comments
 (0)
Please sign in to comment.