yeet
This commit is contained in:
4
node_modules/array-reduce/.travis.yml
generated
vendored
Normal file
4
node_modules/array-reduce/.travis.yml
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
language: node_js
|
||||
node_js:
|
||||
- "0.8"
|
||||
- "0.10"
|
18
node_modules/array-reduce/LICENSE
generated
vendored
Normal file
18
node_modules/array-reduce/LICENSE
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
This software is released under the MIT license:
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
||||
this software and associated documentation files (the "Software"), to deal in
|
||||
the Software without restriction, including without limitation the rights to
|
||||
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
||||
the Software, and to permit persons to whom the Software is furnished to do so,
|
||||
subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all
|
||||
copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
||||
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
||||
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
||||
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
||||
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
4
node_modules/array-reduce/example/sum.js
generated
vendored
Normal file
4
node_modules/array-reduce/example/sum.js
generated
vendored
Normal file
@ -0,0 +1,4 @@
|
||||
var reduce = require('../');
|
||||
var xs = [ 1, 2, 3, 4 ];
|
||||
var sum = reduce(xs, function (acc, x) { return acc + x }, 0);
|
||||
console.log(sum);
|
18
node_modules/array-reduce/index.js
generated
vendored
Normal file
18
node_modules/array-reduce/index.js
generated
vendored
Normal file
@ -0,0 +1,18 @@
|
||||
var hasOwn = Object.prototype.hasOwnProperty;
|
||||
|
||||
module.exports = function (xs, f, acc) {
|
||||
var hasAcc = arguments.length >= 3;
|
||||
if (hasAcc && xs.reduce) return xs.reduce(f, acc);
|
||||
if (xs.reduce) return xs.reduce(f);
|
||||
|
||||
for (var i = 0; i < xs.length; i++) {
|
||||
if (!hasOwn.call(xs, i)) continue;
|
||||
if (!hasAcc) {
|
||||
acc = xs[i];
|
||||
hasAcc = true;
|
||||
continue;
|
||||
}
|
||||
acc = f(acc, xs[i], i);
|
||||
}
|
||||
return acc;
|
||||
};
|
48
node_modules/array-reduce/package.json
generated
vendored
Normal file
48
node_modules/array-reduce/package.json
generated
vendored
Normal file
@ -0,0 +1,48 @@
|
||||
{
|
||||
"name": "array-reduce",
|
||||
"version": "0.0.0",
|
||||
"description": "`[].reduce()` for old browsers",
|
||||
"main": "index.js",
|
||||
"devDependencies": {
|
||||
"tape": "~2.3.2"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "tape test/*.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/substack/array-reduce.git"
|
||||
},
|
||||
"homepage": "https://github.com/substack/array-reduce",
|
||||
"keywords": [
|
||||
"array",
|
||||
"reduce",
|
||||
"es5",
|
||||
"ie6",
|
||||
"ie7",
|
||||
"ie8",
|
||||
"fold"
|
||||
],
|
||||
"author": {
|
||||
"name": "James Halliday",
|
||||
"email": "mail@substack.net",
|
||||
"url": "http://substack.net"
|
||||
},
|
||||
"license": "MIT",
|
||||
"testling": {
|
||||
"files": "test/*.js",
|
||||
"browsers": [
|
||||
"ie/8..latest",
|
||||
"firefox/16..latest",
|
||||
"firefox/nightly",
|
||||
"chrome/22..latest",
|
||||
"chrome/canary",
|
||||
"opera/12..latest",
|
||||
"opera/next",
|
||||
"safari/5.1..latest",
|
||||
"ipad/6.0..latest",
|
||||
"iphone/6.0..latest",
|
||||
"android-browser/4.2..latest"
|
||||
]
|
||||
}
|
||||
}
|
46
node_modules/array-reduce/readme.markdown
generated
vendored
Normal file
46
node_modules/array-reduce/readme.markdown
generated
vendored
Normal file
@ -0,0 +1,46 @@
|
||||
# array-reduce
|
||||
|
||||
`[].reduce()` for old browsers
|
||||
|
||||
[](https://ci.testling.com/substack/array-reduce)
|
||||
|
||||
[](http://travis-ci.org/substack/array-reduce)
|
||||
|
||||
# example
|
||||
|
||||
```
|
||||
var reduce = require('array-reduce');
|
||||
var xs = [ 1, 2, 3, 4 ];
|
||||
var sum = reduce(xs, function (acc, x) { return acc + x }, 0);
|
||||
console.log(sum);
|
||||
```
|
||||
|
||||
output:
|
||||
|
||||
```
|
||||
10
|
||||
```
|
||||
|
||||
# methods
|
||||
|
||||
``` js
|
||||
var reduce = require('array-reduce')
|
||||
```
|
||||
|
||||
## var res = reduce(xs, f, init)
|
||||
|
||||
Create a result `res` by folding `acc = f(acc, xs[i], i)` over each element in
|
||||
the array `xs` at element `i`. If `init` is given, the first `acc` value is
|
||||
`init`, otherwise `xs[0]` is used.
|
||||
|
||||
# install
|
||||
|
||||
With [npm](https://npmjs.org) do:
|
||||
|
||||
```
|
||||
npm install array-reduce
|
||||
```
|
||||
|
||||
# license
|
||||
|
||||
MIT
|
85
node_modules/array-reduce/test/reduce.js
generated
vendored
Normal file
85
node_modules/array-reduce/test/reduce.js
generated
vendored
Normal file
@ -0,0 +1,85 @@
|
||||
var reduce = require('../');
|
||||
var test = require('tape');
|
||||
|
||||
test('numeric reduces', function (t) {
|
||||
t.plan(6);
|
||||
|
||||
var xs = [ 1, 2, 3, 4 ];
|
||||
t.equal(
|
||||
reduce(xs, function (acc, x) { return acc + x }, 0),
|
||||
10
|
||||
);
|
||||
t.equal(
|
||||
reduce(xs, function (acc, x) { return acc + x }, 100),
|
||||
110
|
||||
);
|
||||
t.equal(
|
||||
reduce(xs, function (acc, x) { return acc + x }),
|
||||
10
|
||||
);
|
||||
|
||||
var ys = cripple([ 1, 2, 3, 4 ]);
|
||||
t.equal(
|
||||
reduce(ys, function (acc, x) { return acc + x }, 0),
|
||||
10
|
||||
);
|
||||
t.equal(
|
||||
reduce(ys, function (acc, x) { return acc + x }, 100),
|
||||
110
|
||||
);
|
||||
t.equal(
|
||||
reduce(ys, function (acc, x) { return acc + x }),
|
||||
10
|
||||
);
|
||||
});
|
||||
|
||||
test('holes', function (t) {
|
||||
t.plan(4);
|
||||
|
||||
var xs = Array(10);
|
||||
xs[2] = 5; xs[4] = 6; xs[8] = 4;
|
||||
t.equal(
|
||||
reduce(xs, function (acc, x) { return acc + x }),
|
||||
15
|
||||
);
|
||||
t.equal(
|
||||
reduce(xs, function (acc, x) { return acc + x }, 100),
|
||||
115
|
||||
);
|
||||
|
||||
var ys = cripple(Array(10));
|
||||
ys[2] = 5; ys[4] = 6; ys[8] = 4;
|
||||
t.equal(
|
||||
reduce(ys, function (acc, x) { return acc + x }),
|
||||
15
|
||||
);
|
||||
t.equal(
|
||||
reduce(ys, function (acc, x) { return acc + x }, 100),
|
||||
115
|
||||
);
|
||||
});
|
||||
|
||||
test('object', function (t) {
|
||||
t.plan(1);
|
||||
var obj = { a: 3, b: 4, c: 5 };
|
||||
var res = reduce(objectKeys(obj), function (acc, key) {
|
||||
acc[key.toUpperCase()] = obj[key] * 111;
|
||||
return acc;
|
||||
}, {});
|
||||
t.deepEqual(res, { A: 333, B: 444, C: 555 });
|
||||
});
|
||||
|
||||
function cripple (xs) {
|
||||
xs.reduce = undefined;
|
||||
return xs;
|
||||
}
|
||||
|
||||
var objectKeys = function (obj) {
|
||||
var keys = [];
|
||||
for (var key in obj) {
|
||||
if (hasOwn.call(obj, key)) keys.push(key);
|
||||
}
|
||||
return keys;
|
||||
};
|
||||
|
||||
var hasOwn = Object.prototype.hasOwnProperty;
|
Reference in New Issue
Block a user