1.3.0 • Published 8 months ago

aceink v1.3.0

Weekly downloads
-
License
MIT
Repository
github
Last release
8 months ago

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


Example (queue)

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)

import { gowait, delay } from 'aceink'

const [err, value] = await gowait(delay(100, 42))
console.log(value) //42
1.2.0

8 months ago

1.1.0

8 months ago

1.3.0

8 months ago

1.0.1

1 year ago

3.0.1

1 year ago

1.0.0

1 year ago