Skip to content

Commit

Permalink
readme file updated
Browse files Browse the repository at this point in the history
  • Loading branch information
jaroslav-kubicek committed Mar 25, 2016
1 parent beb4419 commit 0fe562f
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,2 +1,29 @@
# spawn-generator
Write the synchronous-like code with promises and generators

[![Coverage Status](https://coveralls.io/repos/github/jaroslav-kubicek/spawn-generator/badge.svg?branch=master)](https://coveralls.io/github/jaroslav-kubicek/spawn-generator?branch=master)
[![Build Status](https://travis-ci.org/romadur-js/romadur.svg?branch=master)](https://travis-ci.org/romadur-js/romadur)

## Example

```
let spawnGenerator = require('spawn-generator');
let generatorFunction = function*(fruit) {
let fruits = [];
fruits.push(yield asyncMethod('apple')); // asyncMethod returns Promise
fruits.push(yield asyncMethod(fruit));
return fruits;
};
let functionToCall = spawnGenerator(generatorFunction);
functionToCall('banana')
.then(
(fruits) => console.log(fruits) // outputs ['apple', 'banana']
);
spawnGenerator(generatorFunction, 'orange')
.then(
(fruits) => console.log(fruits) // outputs ['apple', 'orange']
);
```

0 comments on commit 0fe562f

Please sign in to comment.