Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/teabyii/yq
Anthor async control flow by generator without promise.
https://github.com/teabyii/yq
Last synced: about 1 month ago
JSON representation
Anthor async control flow by generator without promise.
- Host: GitHub
- URL: https://github.com/teabyii/yq
- Owner: teabyii
- License: mit
- Created: 2015-03-24T03:14:14.000Z (almost 10 years ago)
- Default Branch: master
- Last Pushed: 2015-03-24T10:56:26.000Z (almost 10 years ago)
- Last Synced: 2024-11-09T00:52:46.153Z (about 2 months ago)
- Language: JavaScript
- Size: 137 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# yq
Anthor async control flow by generator without promise.
## No Promise
```js
const yq = require('yq')
const fs = require('fs')let readFile = function *() {
var caller = yield
fs.readFile('example', { encoding: 'utf-8' }, function (err, content) {
if (err) {
caller.error(err)
} else {
caller.success(content)
}
})
}
```## Yield
```js
const yq = require('yq')
const readFile = yq.yield(require('fs').readFile)yq(function *() {
var content = yield readFile('example', { encoding: 'utf-8' })
console.log(content) // ...
})
```