https://github.com/calebboyd/aceink
Async things that are useful
https://github.com/calebboyd/aceink
Last synced: about 1 year ago
JSON representation
Async things that are useful
- Host: GitHub
- URL: https://github.com/calebboyd/aceink
- Owner: calebboyd
- License: mit
- Created: 2016-07-10T17:08:51.000Z (almost 10 years ago)
- Default Branch: main
- Last Pushed: 2023-09-13T01:34:03.000Z (almost 3 years ago)
- Last Synced: 2025-05-12T19:14:18.668Z (about 1 year ago)
- Language: TypeScript
- Homepage:
- Size: 1.07 MB
- Stars: 5
- Watchers: 1
- Forks: 1
- Open Issues: 2
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
## aceink
Useful async tools.
- `createLock`
- a simple counting sempahore
- `createDeferred`
- simple deferred promise
- `q`
- a concurrent work queue
- `each`, `map`
- *optionally* concurrent iteration functions
- `gowait`
- convert a promise or promise returning function to `[error,result]` tuples
- `delay`
- delay ms, optionally resolve an argument
- `noop`, `identity`, `once`
- Other useful language functions
Get it on npm: `npm install aceink`
See the generated documentation [here](/docs/modules.md)
---
### Example (queue)
```javascript
import { q } from 'aceink'
const { ready, add, empty } = q(10)
function fetchQux(bar) {
return fetch(`https://example.com/${bar}`)
}
for (const foo of Array(100).keys()) {
await ready()
add(fetchQux, foo)
}
return empty()
```
### Example (gowait)
```javascript
import { gowait, delay } from 'aceink'
const [err, value] = await gowait(delay(100, 42))
console.log(value) //42
```