array-comprehensions
Advanced tools
Comparing version 0.5.1 to 0.5.2
{ | ||
"name": "array-comprehensions", | ||
"version": "0.5.1", | ||
"version": "0.5.2", | ||
"description": "Array comprehensions", | ||
@@ -5,0 +5,0 @@ "main": "forOf.js", |
@@ -43,1 +43,39 @@ array-comprehensions | ||
``` | ||
API | ||
--- | ||
### forOf | ||
#### `forOf(iterable, do)` | ||
Execute the function `do` for each item of `iterable`. | ||
```js | ||
forOf([1, 2, 3], function(x){ | ||
return x+1; | ||
}); // => [2, 3, 4] | ||
``` | ||
#### `forOf(iterable, condition, do)` | ||
Execute the function `do` for each item of `iterable` that fullfills the `condition`. | ||
```js | ||
forOf([1, 2, 3, 4], function(x) { | ||
return x % 2 === 0; | ||
}, function(x) { | ||
return x*x; | ||
}); // => [4,16] | ||
``` | ||
#### `forOf(iterable1, iterable2, do)` | ||
Execute the function `do` for each item of `iterable1` with every item of `iterable2`. | ||
```js | ||
forOf([1, 2], [1,2], function(x, y) { | ||
return x*y; | ||
}); // => [1,2,2,4] | ||
``` | ||
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
5517
81