minico
v1.0.1
Published
It's like co, but tiny: Minimal Promise-based coroutines. Performant, with no fluff.
Downloads
8
Maintainers
Readme
minico
It's like co
, but tiny: Minimal Promise-based coroutines. Performant, with no fluff.
Based off of copromise
.
npm install minico
Relies on Promise being global.
- 592 bytes uncompressed
- 453 bytes minified with uglify-js 2.6.2
- 257 bytes minified with uglify-js 2.6.2, and compressed with gzip 1.8
import minico from 'minico'
const doThings = minico(function * doThings (input) {
yield washDishes()
try {
yield makePopcorn()
} catch (err) {
yield someFailureHandler(err)
}
return 'nice' + input
})
doThings(2).then((value) => {
console.log('Coroutine success:', value) // Coroutine success: nice2
}).catch((err) => {
console.log('An error occured', err)
})