Upgrade Ava to v4

This commit is contained in:
Henry Mercer 2022-02-01 18:01:11 +00:00
parent 9a40cc5274
commit ce89f1b611
1153 changed files with 27264 additions and 95308 deletions

64
node_modules/p-timeout/readme.md generated vendored
View file

@ -1,34 +1,31 @@
# p-timeout [![Build Status](https://travis-ci.org/sindresorhus/p-timeout.svg?branch=master)](https://travis-ci.org/sindresorhus/p-timeout)
# p-timeout
> Timeout a promise after a specified amount of time
## Install
```
$ npm install p-timeout
```
## Usage
```js
const delay = require('delay');
const pTimeout = require('p-timeout');
import {setTimeout} from 'timers/promises';
import pTimeout from 'p-timeout';
const delayedPromise = delay(200);
const delayedPromise = setTimeout(200);
pTimeout(delayedPromise, 50).then(() => 'foo');
await pTimeout(delayedPromise, 50);
//=> [TimeoutError: Promise timed out after 50 milliseconds]
```
## API
### pTimeout(input, milliseconds, message?)
### pTimeout(input, milliseconds, fallback?)
### pTimeout(input, milliseconds, message?, options?)
### pTimeout(input, milliseconds, fallback?, options?)
Returns a decorated `input` that times out after `milliseconds` time.
Returns a decorated `input` that times out after `milliseconds` time. It has a `.clear()` method that clears the timeout.
If you pass in a cancelable promise, specifically a promise with a `.cancel()` method, that method will be called when the `pTimeout` promise times out.
@ -48,7 +45,7 @@ Passing `Infinity` will cause it to never time out.
#### message
Type: `string` `Error`<br>
Type: `string | Error`\
Default: `'Promise timed out after 50 milliseconds'`
Specify a custom error message or error.
@ -64,21 +61,52 @@ Do something other than rejecting with an error on timeout.
You could for example retry:
```js
const delay = require('delay');
const pTimeout = require('p-timeout');
import {setTimeout} from 'timers/promises';
import pTimeout from 'p-timeout';
const delayedPromise = () => delay(200);
const delayedPromise = () => setTimeout(200);
pTimeout(delayedPromise(), 50, () => {
await pTimeout(delayedPromise(), 50, () => {
return pTimeout(delayedPromise(), 300);
});
```
### pTimeout.TimeoutError
#### options
Type: `object`
##### customTimers
Type: `object` with function properties `setTimeout` and `clearTimeout`
Custom implementations for the `setTimeout` and `clearTimeout` functions.
Useful for testing purposes, in particular to work around [`sinon.useFakeTimers()`](https://sinonjs.org/releases/latest/fake-timers/).
Example:
```js
import {setTimeout} from 'timers/promises';
import pTimeout from 'p-timeout';
const originalSetTimeout = setTimeout;
const originalClearTimeout = clearTimeout;
sinon.useFakeTimers();
// Use `pTimeout` without being affected by `sinon.useFakeTimers()`:
await pTimeout(doSomething(), 2000, undefined, {
customTimers: {
setTimeout: originalSetTimeout,
clearTimeout: originalClearTimeout
}
});
```
### TimeoutError
Exposed for instance checking and sub-classing.
## Related
- [delay](https://github.com/sindresorhus/delay) - Delay a promise a specified amount of time