Skip to content

Commit 4135565

Browse files
committed
Require Node.js 6
1 parent 156215d commit 4135565

10 files changed

+81
-80
lines changed

.editorconfig

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ charset = utf-8
77
trim_trailing_whitespace = true
88
insert_final_newline = true
99

10-
[{package.json,*.yml}]
10+
[*.yml]
1111
indent_style = space
1212
indent_size = 2

.gitattributes

+1-2
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
1-
* text=auto
2-
*.js text eol=lf
1+
* text=auto eol=lf

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
node_modules
2+
yarn.lock

.npmrc

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
package-lock=false

.travis.yml

+2-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
language: node_js
22
node_js:
3+
- '10'
4+
- '8'
35
- '6'
4-
- '4'

index.js

+11-8
Original file line numberDiff line numberDiff line change
@@ -11,22 +11,25 @@ class AggregateError extends Error {
1111
throw new TypeError(`Expected input to be iterable, got ${typeof errors}`);
1212
}
1313

14-
errors = Array.from(errors).map(err => {
15-
if (err instanceof Error) {
16-
return err;
14+
errors = [...errors].map(error => {
15+
if (error instanceof Error) {
16+
return error;
1717
}
18-
if (err && typeof err === 'object') {
18+
19+
if (error !== null && typeof error === 'object') {
1920
// Handle plain error objects with message property and/or possibly other metadata
20-
return Object.assign(new Error(err.message), err);
21+
return Object.assign(new Error(error.message), error);
2122
}
22-
return new Error(err);
23+
24+
return new Error(error);
2325
});
2426

25-
let message = errors.map(err => cleanInternalStack(cleanStack(err.stack))).join('\n');
27+
let message = errors.map(error => cleanInternalStack(cleanStack(error.stack))).join('\n');
2628
message = '\n' + indentString(message, 4);
27-
2829
super(message);
30+
2931
this.name = 'AggregateError';
32+
3033
Object.defineProperty(this, '_errors', {value: errors});
3134
}
3235

license

+4-16
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,9 @@
1-
The MIT License (MIT)
1+
MIT License
22

33
Copyright (c) Sindre Sorhus <[email protected]> (sindresorhus.com)
44

5-
Permission is hereby granted, free of charge, to any person obtaining a copy
6-
of this software and associated documentation files (the "Software"), to deal
7-
in the Software without restriction, including without limitation the rights
8-
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9-
copies of the Software, and to permit persons to whom the Software is
10-
furnished to do so, subject to the following conditions:
5+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
116

12-
The above copyright notice and this permission notice shall be included in
13-
all copies or substantial portions of the Software.
7+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
148

15-
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16-
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17-
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18-
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19-
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20-
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21-
THE SOFTWARE.
9+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

package.json

+38-38
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,40 @@
11
{
2-
"name": "aggregate-error",
3-
"version": "1.0.0",
4-
"description": "Create an error from multiple errors",
5-
"license": "MIT",
6-
"repository": "sindresorhus/aggregate-error",
7-
"author": {
8-
"name": "Sindre Sorhus",
9-
"email": "[email protected]",
10-
"url": "sindresorhus.com"
11-
},
12-
"engines": {
13-
"node": ">=4"
14-
},
15-
"scripts": {
16-
"test": "xo && ava"
17-
},
18-
"files": [
19-
"index.js"
20-
],
21-
"keywords": [
22-
"aggregate",
23-
"error",
24-
"err",
25-
"combine",
26-
"multiple",
27-
"many",
28-
"collection",
29-
"iterable",
30-
"iterator"
31-
],
32-
"dependencies": {
33-
"clean-stack": "^1.0.0",
34-
"indent-string": "^3.0.0"
35-
},
36-
"devDependencies": {
37-
"ava": "*",
38-
"xo": "*"
39-
}
2+
"name": "aggregate-error",
3+
"version": "1.0.0",
4+
"description": "Create an error from multiple errors",
5+
"license": "MIT",
6+
"repository": "sindresorhus/aggregate-error",
7+
"author": {
8+
"name": "Sindre Sorhus",
9+
"email": "[email protected]",
10+
"url": "sindresorhus.com"
11+
},
12+
"engines": {
13+
"node": ">=6"
14+
},
15+
"scripts": {
16+
"test": "xo && ava"
17+
},
18+
"files": [
19+
"index.js"
20+
],
21+
"keywords": [
22+
"aggregate",
23+
"error",
24+
"err",
25+
"combine",
26+
"multiple",
27+
"many",
28+
"collection",
29+
"iterable",
30+
"iterator"
31+
],
32+
"dependencies": {
33+
"clean-stack": "^2.0.0",
34+
"indent-string": "^3.0.0"
35+
},
36+
"devDependencies": {
37+
"ava": "^1.0.1",
38+
"xo": "^0.23.0"
39+
}
4040
}

readme.md

+5-5
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
## Install
77

88
```
9-
$ npm install --save aggregate-error
9+
$ npm install aggregate-error
1010
```
1111

1212

@@ -15,9 +15,9 @@ $ npm install --save aggregate-error
1515
```js
1616
const AggregateError = require('aggregate-error');
1717

18-
const err = new AggregateError([new Error('foo'), 'bar', {message: 'baz'}]);
18+
const error = new AggregateError([new Error('foo'), 'bar', {message: 'baz'}]);
1919

20-
throw err;
20+
throw error;
2121
/*
2222
AggregateError:
2323
Error: foo
@@ -38,8 +38,8 @@ AggregateError:
3838
at startup (bootstrap_node.js:149:9)
3939
*/
4040

41-
for (const el of err) {
42-
console.log(el);
41+
for (const individualError of error) {
42+
console.log(individualError);
4343
}
4444
//=> [Error: foo]
4545
//=> [Error: bar]

test.js

+17-9
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,25 @@
11
import test from 'ava';
2-
import AggregateError from './';
2+
import AggregateError from '.';
33

4-
test(t => {
5-
const err = new AggregateError([
4+
test('main', t => {
5+
const error = new AggregateError([
66
new Error('foo'),
77
'bar',
8-
{message: 'baz', code: 'EBAZ'},
9-
{code: 'EQUX'}
8+
{
9+
message: 'baz',
10+
code: 'EBAZ'
11+
},
12+
{
13+
code: 'EQUX'
14+
}
1015
]);
11-
console.log(err);
12-
t.regex(err.message, /Error: foo\n {8}at /);
13-
t.regex(err.message, /Error: bar\n {8}at /);
14-
t.deepEqual(Array.from(err), [
16+
17+
console.log(error);
18+
19+
t.regex(error.message, /Error: foo\n {8}at /);
20+
t.regex(error.message, /Error: bar\n {8}at /);
21+
22+
t.deepEqual([...error], [
1523
new Error('foo'),
1624
new Error('bar'),
1725
Object.assign(new Error('baz'), {code: 'EBAZ'}),

0 commit comments

Comments
 (0)