|
Last change
on this file was 9af201e, checked in by MBK <marija.karapandzova@…>, 12 days ago |
|
Fix frontend appearance
|
-
Property mode
set to
100644
|
|
File size:
718 bytes
|
| Line | |
|---|
| 1 | # for-each [![build status][1]][2]
|
|---|
| 2 |
|
|---|
| 3 | [![browser support][3]][4]
|
|---|
| 4 |
|
|---|
| 5 | A better forEach.
|
|---|
| 6 |
|
|---|
| 7 | ## Example
|
|---|
| 8 |
|
|---|
| 9 | Like `Array.prototype.forEach` but works on objects.
|
|---|
| 10 |
|
|---|
| 11 | ```js
|
|---|
| 12 | var forEach = require("for-each")
|
|---|
| 13 |
|
|---|
| 14 | forEach({ key: "value" }, function (value, key, object) {
|
|---|
| 15 | /* code */
|
|---|
| 16 | })
|
|---|
| 17 | ```
|
|---|
| 18 |
|
|---|
| 19 | As a bonus, it's also a perfectly function shim/polyfill for arrays too!
|
|---|
| 20 |
|
|---|
| 21 | ```js
|
|---|
| 22 | var forEach = require("for-each")
|
|---|
| 23 |
|
|---|
| 24 | forEach([1, 2, 3], function (value, index, array) {
|
|---|
| 25 | /* code */
|
|---|
| 26 | })
|
|---|
| 27 | ```
|
|---|
| 28 |
|
|---|
| 29 | ## Installation
|
|---|
| 30 |
|
|---|
| 31 | `npm install for-each`
|
|---|
| 32 |
|
|---|
| 33 | ## MIT Licenced
|
|---|
| 34 |
|
|---|
| 35 | [1]: https://secure.travis-ci.org/Raynos/for-each.png
|
|---|
| 36 | [2]: http://travis-ci.org/Raynos/for-each
|
|---|
| 37 | [3]: https://ci.testling.com/Raynos/for-each.png
|
|---|
| 38 | [4]: https://ci.testling.com/Raynos/for-each
|
|---|
| 39 |
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.