Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/jchip/xaa
async/await/Promise helpers - delay, defer, timeout, each, map, filter
https://github.com/jchip/xaa
async await defer delay each filter helpers map promise timeout
Last synced: about 1 month ago
JSON representation
async/await/Promise helpers - delay, defer, timeout, each, map, filter
- Host: GitHub
- URL: https://github.com/jchip/xaa
- Owner: jchip
- License: other
- Created: 2019-01-24T18:00:11.000Z (almost 6 years ago)
- Default Branch: master
- Last Pushed: 2022-03-07T21:52:40.000Z (over 2 years ago)
- Last Synced: 2024-09-14T04:19:43.381Z (2 months ago)
- Topics: async, await, defer, delay, each, filter, helpers, map, promise, timeout
- Language: TypeScript
- Homepage:
- Size: 320 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# xaa
async/await and Promise helpers.
github:
## Install and Usage
```
npm i xaa
```## APIs
API references
Or just use your IDE for hint if it supports TypeScript and typedoc.
## Examples:
### xaa.timeout
```js
import { timeout } from "xaa";async function test() {
// will throw TimeoutError
await timeout(50, "took too long").run(xaa.delay(100));
// will run the two functions and wait for them
await timeout(50, "oops")
.run([
() => xaa.delay(10, 1),
() => xaa.delay(15, 2),
"some value",
Promise.resolve("more value")
])
.then(results => {
// results === [1, 2, "some value", "more value"]
});
}
```### xaa.map
```js
import { map } from xaa;async function test() {
return await map(
["http://url1", "http://url2"],
async url => fetch(url),
{ concurrency: 2 }
);
}
```# License
Licensed under the [Apache License, Version 2.0].
[apache license, version 2.0]: https://www.apache.org/licenses/LICENSE-2.0