Update checked-in dependencies

This commit is contained in:
github-actions[bot] 2023-07-13 09:09:17 +00:00
parent 4fad06f438
commit 40a500c743
4168 changed files with 298222 additions and 374905 deletions

View file

@ -1,16 +1,17 @@
/**
Create an error from multiple errors.
*/
declare class AggregateError extends Error implements Iterable<Error> {
export default class AggregateError<T extends Error = Error> extends Error {
readonly name: 'AggregateError';
readonly errors: readonly [T];
/**
@param errors - If a string, a new `Error` is created with the string as the error message. If a non-Error object, a new `Error` is created with all properties from the object copied over.
@returns An Error that is also an [`Iterable`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Iterators_and_Generators#Iterables) for the individual errors.
@example
```
import AggregateError = require('aggregate-error');
import AggregateError from 'aggregate-error';
const error = new AggregateError([new Error('foo'), 'bar', {message: 'baz'}]);
@ -34,8 +35,7 @@ declare class AggregateError extends Error implements Iterable<Error> {
// at run (bootstrap_node.js:394:7)
// at startup (bootstrap_node.js:149:9)
for (const individualError of error) {
for (const individualError of error.errors) {
console.log(individualError);
}
//=> [Error: foo]
@ -43,9 +43,5 @@ declare class AggregateError extends Error implements Iterable<Error> {
//=> [Error: baz]
```
*/
constructor(errors: ReadonlyArray<Error | {[key: string]: any} | string>);
[Symbol.iterator](): IterableIterator<Error>;
constructor(errors: ReadonlyArray<T | Record<string, any> | string>);
}
export = AggregateError;

View file

@ -1,16 +1,19 @@
'use strict';
const indentString = require('indent-string');
const cleanStack = require('clean-stack');
import indentString from 'indent-string';
import cleanStack from 'clean-stack';
const cleanInternalStack = stack => stack.replace(/\s+at .*aggregate-error\/index.js:\d+:\d+\)?/g, '');
class AggregateError extends Error {
export default class AggregateError extends Error {
#errors;
name = 'AggregateError';
constructor(errors) {
if (!Array.isArray(errors)) {
throw new TypeError(`Expected input to be an Array, got ${typeof errors}`);
}
errors = [...errors].map(error => {
errors = errors.map(error => {
if (error instanceof Error) {
return error;
}
@ -26,22 +29,16 @@ class AggregateError extends Error {
let message = errors
.map(error => {
// The `stack` property is not standardized, so we can't assume it exists
return typeof error.stack === 'string' ? cleanInternalStack(cleanStack(error.stack)) : String(error);
return typeof error.stack === 'string' && error.stack.length > 0 ? cleanInternalStack(cleanStack(error.stack)) : String(error);
})
.join('\n');
message = '\n' + indentString(message, 4);
super(message);
this.name = 'AggregateError';
Object.defineProperty(this, '_errors', {value: errors});
this.#errors = errors;
}
* [Symbol.iterator]() {
for (const error of this._errors) {
yield error;
}
get errors() {
return this.#errors.slice();
}
}
module.exports = AggregateError;

View file

@ -1,6 +1,6 @@
MIT License
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (sindresorhus.com)
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
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:

View file

@ -1,19 +1,23 @@
{
"name": "aggregate-error",
"version": "3.0.1",
"version": "4.0.1",
"description": "Create an error from multiple errors",
"license": "MIT",
"repository": "sindresorhus/aggregate-error",
"funding": "https://github.com/sponsors/sindresorhus",
"author": {
"name": "Sindre Sorhus",
"email": "sindresorhus@gmail.com",
"url": "sindresorhus.com"
"url": "https://sindresorhus.com"
},
"type": "module",
"exports": "./index.js",
"engines": {
"node": ">=8"
"node": ">=12"
},
"scripts": {
"test": "xo && ava && tsd"
"//test": "xo && ava && tsd",
"test": "ava && tsd"
},
"files": [
"index.js",
@ -30,12 +34,12 @@
"iterator"
],
"dependencies": {
"clean-stack": "^2.0.0",
"indent-string": "^4.0.0"
"clean-stack": "^4.0.0",
"indent-string": "^5.0.0"
},
"devDependencies": {
"ava": "^2.4.0",
"tsd": "^0.7.1",
"xo": "^0.25.3"
"ava": "^3.15.0",
"tsd": "^0.14.0",
"xo": "^0.38.2"
}
}

View file

@ -1,7 +1,8 @@
# aggregate-error [![Build Status](https://travis-ci.org/sindresorhus/aggregate-error.svg?branch=master)](https://travis-ci.org/sindresorhus/aggregate-error)
# aggregate-error
> Create an error from multiple errors
*Note: With [Node.js 15](https://medium.com/@nodejs/node-js-v15-0-0-is-here-deb00750f278), there's now a built-in [`AggregateError`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/AggregateError) type.*
## Install
@ -9,11 +10,10 @@
$ npm install aggregate-error
```
## Usage
```js
const AggregateError = require('aggregate-error');
import AggregateError from 'aggregate-error';
const error = new AggregateError([new Error('foo'), 'bar', {message: 'baz'}]);
@ -38,7 +38,7 @@ AggregateError:
at startup (bootstrap_node.js:149:9)
*/
for (const individualError of error) {
for (const individualError of error.errors) {
console.log(individualError);
}
//=> [Error: foo]
@ -46,16 +46,15 @@ for (const individualError of error) {
//=> [Error: baz]
```
## API
### AggregateError(errors)
Returns an `Error` that is also an [`Iterable`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Iterators_and_Generators#Iterables) for the individual errors.
Returns an `Error`.
#### errors
Type: `Array<Error|Object|string>`
Type: `Array<Error|object|string>`
If a string, a new `Error` is created with the string as the error message.<br>
If a string, a new `Error` is created with the string as the error message.\
If a non-Error object, a new `Error` is created with all properties from the object copied over.