Added logging, changed some directory structure

This commit is contained in:
2018-01-13 21:33:40 -05:00
parent f079a5f067
commit 8e72ffb917
73656 changed files with 35284 additions and 53718 deletions

View File

@@ -0,0 +1,4 @@
language: node_js
node_js:
- "0.8"
- "0.10"

View 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.

View 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);

View 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;
};

View File

@@ -0,0 +1,79 @@
{
"_args": [
[
"array-reduce@0.0.0",
"C:\\Users\\deranjer\\go\\src\\github.com\\deranjer\\goTorrent\\torrent-project"
]
],
"_from": "array-reduce@0.0.0",
"_id": "array-reduce@0.0.0",
"_inBundle": false,
"_integrity": "sha1-FziZ0//Rx9k4PkR5Ul2+J4yrXys=",
"_location": "/react-scripts/array-reduce",
"_phantomChildren": {},
"_requested": {
"type": "version",
"registry": true,
"raw": "array-reduce@0.0.0",
"name": "array-reduce",
"escapedName": "array-reduce",
"rawSpec": "0.0.0",
"saveSpec": null,
"fetchSpec": "0.0.0"
},
"_requiredBy": [
"/react-scripts/shell-quote"
],
"_resolved": "https://registry.npmjs.org/array-reduce/-/array-reduce-0.0.0.tgz",
"_spec": "0.0.0",
"_where": "C:\\Users\\deranjer\\go\\src\\github.com\\deranjer\\goTorrent\\torrent-project",
"author": {
"name": "James Halliday",
"email": "mail@substack.net",
"url": "http://substack.net"
},
"bugs": {
"url": "https://github.com/substack/array-reduce/issues"
},
"description": "`[].reduce()` for old browsers",
"devDependencies": {
"tape": "~2.3.2"
},
"homepage": "https://github.com/substack/array-reduce",
"keywords": [
"array",
"reduce",
"es5",
"ie6",
"ie7",
"ie8",
"fold"
],
"license": "MIT",
"main": "index.js",
"name": "array-reduce",
"repository": {
"type": "git",
"url": "git://github.com/substack/array-reduce.git"
},
"scripts": {
"test": "tape test/*.js"
},
"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"
]
},
"version": "0.0.0"
}

View File

@@ -0,0 +1,46 @@
# array-reduce
`[].reduce()` for old browsers
[![testling badge](https://ci.testling.com/substack/array-reduce.png)](https://ci.testling.com/substack/array-reduce)
[![build status](https://secure.travis-ci.org/substack/array-reduce.png)](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

View 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;