async-to-gen
Advanced tools
Comparing version 1.0.3 to 1.0.4
{ | ||
"name": "async-to-gen", | ||
"version": "1.0.3", | ||
"version": "1.0.4", | ||
"description": "Transform async functions to generator functions with speed and simplicity.", | ||
@@ -5,0 +5,0 @@ "author": "Lee Byron <lee@leebyron.com> (http://leebyron.com/)", |
@@ -90,2 +90,23 @@ async-to-gen | ||
#### Async I/O | ||
Async functions are great for writing asynchronous code that *looks* synchronous, | ||
and that's perfect for writing code that needs to perform async I/O operations. | ||
One of the original motivations for Node.js was [non-blocking I/O](https://www.youtube.com/watch?v=ztspvPYybIY), perfect! However its core libraries | ||
[do not yet support Promises](https://github.com/nodejs/node/pull/5020), nor do many popular libraries written for Node 😭. | ||
Do not fret, we can fix this with [promisify-node](https://github.com/nodegit/promisify-node)! | ||
```js | ||
const promisify = require('promisify-node'); | ||
const fs = promisify('fs'); | ||
async function emojify(filePath) { | ||
const contents = await fs.readFile(filePath, 'utf8') | ||
const edited = contents.replace(/:\)/g, '😉') | ||
await fs.writeFile(filePath, edited, 'utf8') | ||
} | ||
``` | ||
#### Mocha | ||
@@ -165,6 +186,8 @@ | ||
When `async-to-gen` transforms async functions, it does not affect the location | ||
of lines in a file, leading to easier to understand stack traces when debugging. | ||
When `async-to-gen` transforms async functions, it makes as few edits as | ||
possible, and does not affect the location of lines in a file, leading to easier | ||
to understand stack traces when debugging. | ||
It also includes a very small (217 byte) conversion function at the bottom of the file. | ||
It also includes a very small (217 character) conversion function at the bottom | ||
of the file. | ||
@@ -184,5 +207,5 @@ **Before:** | ||
return yield x | ||
})} | ||
}())} | ||
function __async(f){/* small helper function */} | ||
function __async(g){/* small helper function */} | ||
``` |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
33327
209