Skip to content

Commit 7fff647

Browse files
committed
first commit
0 parents commit 7fff647

File tree

11 files changed

+363
-0
lines changed

11 files changed

+363
-0
lines changed

.editorconfig

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
# http://editorconfig.org
2+
root = true
3+
4+
[*]
5+
indent_style = space
6+
end_of_line = lf
7+
charset = utf-8
8+
indent_size = 2
9+
trim_trailing_whitespace = true
10+
insert_final_newline = true
11+
12+
[*.json]
13+
indent_style = space
14+
indent_size = 2
15+
16+
[*.yml]
17+
indent_style = space
18+
indent_size = 2
19+
20+
[*.md]
21+
indent_style = space
22+
indent_size = 2
23+
trim_trailing_whitespace = false
24+
25+
[test/fixtures/*]
26+
trim_trailing_whitespace = false
27+
insert_final_newline = false

.gitattributes

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
# Enforce Unix newlines
2+
* text eol=lf
3+
4+
# binaries
5+
*.ai binary
6+
*.psd binary
7+
*.jpg binary
8+
*.gif binary
9+
*.png binary
10+
*.jpeg binary

.gitignore

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
*.DS_Store
2+
*.sublime-*
3+
_gh_pages
4+
bower_components
5+
node_modules
6+
npm-debug.log
7+
actual
8+
test/actual
9+
temp
10+
tmp
11+
TODO.md
12+
vendor
13+
.idea
14+
benchmark
15+
coverage

.jshintrc

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
{
2+
"asi": false,
3+
"boss": true,
4+
"curly": true,
5+
"eqeqeq": true,
6+
"eqnull": true,
7+
"esnext": true,
8+
"immed": true,
9+
"latedef": false,
10+
"laxcomma": false,
11+
"mocha": true,
12+
"newcap": true,
13+
"noarg": true,
14+
"node": true,
15+
"sub": true,
16+
"undef": true,
17+
"unused": true
18+
}

.travis.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
sudo: false
2+
language: node_js
3+
node_js:
4+
- "0.10"
5+
- "0.12"
6+
- "iojs"
7+
git:
8+
depth: 10

.verb.md

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# {%= name %} {%= badge("fury") %}
2+
3+
> {%= description %}
4+
5+
{%= include("install-npm", {save: true}) %}
6+
7+
## Usage
8+
9+
```js
10+
var each = require('{%= name %}');
11+
12+
var result = [];
13+
each(['a', 'b', 'c'], function (ele) {
14+
result.push(ele + ele);
15+
});
16+
17+
console.log(result);
18+
//=> ['aa', 'bb', 'cc']
19+
```
20+
21+
Return `false` to "break" early:
22+
23+
```js
24+
var result = [];
25+
each(['a', 'b', 'c'], function (ele) {
26+
if (ele === 'b') return false;
27+
result.push(ele + ele);
28+
});
29+
30+
console.log(result);
31+
//=> ['aa']
32+
```
33+
34+
## API
35+
{%= apidocs("index.js") %}
36+
37+
## Related projects
38+
{%= related(['arr-filter', 'arr-diff', 'arr-map', 'arr-flatten', 'array-unique', 'array-intersection']) %}
39+
## Running tests
40+
{%= include("tests") %}
41+
42+
## Contributing
43+
{%= include("contributing") %}
44+
45+
## Author
46+
{%= include("author") %}
47+
48+
## License
49+
{%= copyright() %}
50+
{%= license() %}
51+
52+
***
53+
54+
{%= include("footer") %}

LICENSE

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
The MIT License (MIT)
2+
3+
Copyright (c) 2015, Jon Schlinkert.
4+
5+
Permission is hereby granted, free of charge, to any person obtaining a copy
6+
of this software and associated documentation files (the "Software"), to deal
7+
in the Software without restriction, including without limitation the rights
8+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9+
copies of the Software, and to permit persons to whom the Software is
10+
furnished to do so, subject to the following conditions:
11+
12+
The above copyright notice and this permission notice shall be included in
13+
all copies or substantial portions of the Software.
14+
15+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21+
THE SOFTWARE.

README.md

Lines changed: 90 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,90 @@
1+
# array-each [![NPM version](https://badge.fury.io/js/array-each.svg)](http://badge.fury.io/js/array-each)
2+
3+
> Loop over each item in an array and call the given function on every element.
4+
5+
## Install with [npm](npmjs.org)
6+
7+
```bash
8+
npm i array-each --save
9+
```
10+
11+
## Usage
12+
13+
```js
14+
var each = require('array-each');
15+
16+
var result = [];
17+
each(['a', 'b', 'c'], function (ele) {
18+
result.push(ele + ele);
19+
});
20+
21+
console.log(result);
22+
//=> ['aa', 'bb', 'cc']
23+
```
24+
25+
Return `false` to "break" early:
26+
27+
```js
28+
var result = [];
29+
each(['a', 'b', 'c'], function (ele) {
30+
if (ele === 'b') return false;
31+
result.push(ele + ele);
32+
});
33+
34+
console.log(result);
35+
//=> ['aa']
36+
```
37+
38+
## API
39+
### [.each](index.js#L34)
40+
41+
Loop over each item in an array and call the given function on every element.
42+
43+
* `array` **{Array}**
44+
* `fn` **{Function}**
45+
* `thisArg` **{Object}**: Optionally pass a `thisArg` to be used as the context in which to call the function.
46+
* `returns`: {Array}
47+
48+
```js
49+
each(['a', 'b', 'c'], function (ele) {
50+
return ele + ele;
51+
});
52+
//=> ['aa', 'bb', 'cc']
53+
54+
each(['a', 'b', 'c'], function (ele, i) {
55+
return i + ele;
56+
});
57+
//=> ['0a', '1b', '2c']
58+
```
59+
60+
## Related projects
61+
* [arr-filter](https://github.com/jonschlinkert/arr-filter): Faster alternative to javascript's native filter method.
62+
* [arr-diff](https://github.com/jonschlinkert/arr-diff): Returns an array with only the unique values from the first array, by excluding all values from additional arrays using strict equality for comparisons.
63+
* [arr-map](https://github.com/jonschlinkert/arr-map): Faster, node.js focused alternative to JavaScript's native array map.
64+
* [arr-flatten](https://github.com/jonschlinkert/arr-flatten): Recursively flatten an array or arrays. This is the fastest implementation of array flatten.
65+
* [array-unique](https://github.com/jonschlinkert/array-unique): Return an array free of duplicate values. Fastest ES5 implementation.
66+
* [array-intersection](https://github.com/jonschlinkert/array-intersection): Return an array with the unique values present in _all_ given arrays using strict equality for comparisons.
67+
## Running tests
68+
Install dev dependencies:
69+
70+
```bash
71+
npm i -d && npm test
72+
```
73+
74+
## Contributing
75+
Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/array-each/issues)
76+
77+
## Author
78+
79+
**Jon Schlinkert**
80+
81+
+ [github/jonschlinkert](https://github.com/jonschlinkert)
82+
+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert)
83+
84+
## License
85+
Copyright (c) 2015 Jon Schlinkert
86+
Released under the MIT license
87+
88+
***
89+
90+
_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on April 19, 2015._

index.js

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
/*!
2+
* array-each <https://github.com/jonschlinkert/array-each>
3+
*
4+
* Copyright (c) 2015, Jon Schlinkert.
5+
* Licensed under the MIT License.
6+
*/
7+
8+
'use strict';
9+
10+
/**
11+
* Loop over each item in an array and call the given function on every element.
12+
*
13+
* ```js
14+
* each(['a', 'b', 'c'], function (ele) {
15+
* return ele + ele;
16+
* });
17+
* //=> ['aa', 'bb', 'cc']
18+
*
19+
* each(['a', 'b', 'c'], function (ele, i) {
20+
* return i + ele;
21+
* });
22+
* //=> ['0a', '1b', '2c']
23+
* ```
24+
*
25+
* @name .each
26+
* @alias .forEach
27+
* @param {Array} `array`
28+
* @param {Function} `fn`
29+
* @param {Object} `thisArg` Optionally pass a `thisArg` to be used as the context in which to call the function.
30+
* @return {Array}
31+
* @api public
32+
*/
33+
34+
module.exports = function each(arr, cb, thisArg) {
35+
if (arr == null) return;
36+
37+
var len = arr.length, i = 0;
38+
39+
while (len--) {
40+
var ele = arr[i++];
41+
if (cb.call(thisArg, ele, i, arr) === false) {
42+
break;
43+
}
44+
}
45+
};

package.json

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
{
2+
"name": "array-each",
3+
"description": "Loop over each item in an array and call the given function on every element.",
4+
"version": "0.1.0",
5+
"homepage": "https://github.com/jonschlinkert/array-each",
6+
"author": {
7+
"name": "Jon Schlinkert",
8+
"url": "https://github.com/jonschlinkert"
9+
},
10+
"repository": {
11+
"type": "git",
12+
"url": "git://github.com/jonschlinkert/array-each.git"
13+
},
14+
"bugs": {
15+
"url": "https://github.com/jonschlinkert/array-each/issues"
16+
},
17+
"license": {
18+
"type": "MIT",
19+
"url": "https://github.com/jonschlinkert/array-each/blob/master/LICENSE"
20+
},
21+
"files": [
22+
"index.js"
23+
],
24+
"main": "index.js",
25+
"engines": {
26+
"node": ">=0.10.0"
27+
},
28+
"scripts": {
29+
"test": "mocha"
30+
},
31+
"dependencies": {},
32+
"devDependencies": {
33+
"mocha": "*",
34+
"should": "*"
35+
},
36+
"keywords": []
37+
}

0 commit comments

Comments
 (0)