2.2.0 • Published 5 years ago

run-duck-run v2.2.0

Weekly downloads
107
License
MIT
Repository
github
Last release
5 years ago

🦆 run-duck-run 🦆

A generator function runner

js-standard-style build status npm downloads Greenkeeper badge

usage

  function * foo () {
    yield (cb) => setTimeout(cb, 1000)
    console.log('done cb')
  }

  const run = require('run-duck-run')

  run(foo, (err) => {
    if (err) {
      console.error(err)
    } else {
      console.log('all good')
    }
  })()

  // done cb
  function * foo () {
    yield new Promise((resolve, reject) => {
      setTimeout(resolve, 1000)
    })
    console.log('done promise')
  }

  const run = require('run-duck-run')

  run(foo, (err) => { })()

  // done promise

yield supports thunks and promises.

Why?

If you find a pattern where error handling can all be done in one place....

When writing http routes, error handling is often performed in multiple places....

Check out server-base for an example of using this module.

license

MIT

2.2.0

5 years ago

2.1.1

6 years ago

2.1.0

6 years ago

2.0.3

6 years ago

2.0.2

7 years ago

2.0.1

7 years ago

2.0.0

7 years ago

1.0.5

7 years ago

1.0.4

7 years ago

1.0.3

7 years ago

1.0.2

7 years ago

1.0.1

7 years ago

1.0.0

7 years ago