Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/nicholaiii/p-after
Resolve a promise with specified data after an amount of time
https://github.com/nicholaiii/p-after
Last synced: 2 days ago
JSON representation
Resolve a promise with specified data after an amount of time
- Host: GitHub
- URL: https://github.com/nicholaiii/p-after
- Owner: Nicholaiii
- License: mit
- Created: 2020-10-21T09:16:05.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2020-10-21T10:02:47.000Z (about 4 years ago)
- Last Synced: 2024-03-21T03:43:41.347Z (8 months ago)
- Language: JavaScript
- Size: 114 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# p-after
[![Build Status](https://img.shields.io/travis/nicholaiii/p-after)](https://travis-ci.com/Nicholaiii/p-after)
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)> Resolve a promise with specified data after an amount of time
Useful if you want to return data after some time, for example, if you want to sequence data at varying rates.
## Usage
```ts
const after = require('p-after')
(async () => {
const result = await after(1000, 'OK')
// After one second, the promise resolves with 'OK'.
})
```## API
### pAfter(when, what)
#### when
Type: `number`The amount of time to delay returning the data.
#### what
Type: `any`The data to return after delay.
## Related
- [delay](https://github.com/sindresorhus/delay) - Delay a promise a specified amount of time
- [p-min-delay](https://github.com/sindresorhus/p-min-delay) - Delay an existing promise a minimum amount of time
- [p-immediate](https://github.com/sindresorhus/p-immediate) - Returns a promise resolved in the next event loop - think `setImmediate()`
- [p-timeout](https://github.com/sindresorhus/p-timeout) - Timeout a promise after a specified amount of time
- [More…](https://github.com/sindresorhus/promise-fun)