Comparing version 0.1.5 to 0.1.6
@@ -0,0 +0,0 @@ var Y = require('..'); |
@@ -0,0 +0,0 @@ var fs = require('fs'); |
@@ -0,0 +0,0 @@ var fs = require('fs'); |
@@ -0,0 +0,0 @@ var Y = require('..'); |
@@ -0,0 +0,0 @@ var Y = require('..'); |
@@ -0,0 +0,0 @@ var Y = require('..'); |
@@ -0,0 +0,0 @@ var q = require('q'); |
@@ -0,0 +0,0 @@ var fs = require('fs'); |
@@ -0,0 +0,0 @@ var Y = require('..'); |
@@ -0,0 +0,0 @@ module.exports = Y; |
{ | ||
"name": "yielding", | ||
"version": "0.1.5", | ||
"version": "0.1.6", | ||
"description": "Easy generators", | ||
@@ -5,0 +5,0 @@ "main": "index.js", |
@@ -33,4 +33,16 @@ yielding | ||
``` | ||
### Async code: | ||
### Parallel execution | ||
```js | ||
var get = Y.nwrap( require('request').get ); | ||
Y(function* () { | ||
var pages = ['http://google.com', 'http://yahoo.com', 'http://bind.com']; | ||
var content = yield pages.map(function(url) { | ||
return get(url); | ||
}); | ||
console.log(content.map(function(c) { return c.body.length; })); | ||
})(); | ||
``` | ||
### Async code with wrapper for node functions | ||
```js | ||
var read = Y.nwrap(fs.readFile); | ||
@@ -68,13 +80,2 @@ | ||
``` | ||
### Wrap node functions | ||
```js | ||
var read = Y.nwrap(fs.readFile); | ||
function* getContent(filename) { | ||
var content = yield read(filename, 'utf-8'); | ||
console.log(content.length); | ||
}; | ||
Y(getContent)('./examples/Y.js'); | ||
``` | ||
###Error handling | ||
@@ -91,1 +92,2 @@ ```js | ||
``` | ||
[See more examples](https://github.com/mikach/yielding/tree/master/examples) |
@@ -0,0 +0,0 @@ var Y = require('..'); |
12276
17
286
91