Skip to content

Commit

Permalink
Update promise.each.md (#1479)
Browse files Browse the repository at this point in the history
Example for promise.each
  • Loading branch information
Wenli Tsai authored and benjamingr committed May 10, 2018
1 parent 77781fe commit 39081ba
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions docs/docs/api/promise.each.md
Expand Up @@ -25,6 +25,18 @@ If all of the iterations resolve successfully, Promise.each resolves to the orig

This method is meant to be used for side effects.

```js
var fileNames = ["1.txt", "2.txt", "3.txt"];

Promise.each(fileNames, function(fileName) {
return fs.readFileAsync(fileName).then(function(val){
// do stuff with 'val' here.
});
}).then(function() {
console.log("done");
});
```

<hr>
</markdown></div>

Expand Down

0 comments on commit 39081ba

Please sign in to comment.