Initial commit
This commit is contained in:
20
themes/keepit/node_modules/reduce/.editorconfig
generated
vendored
Normal file
20
themes/keepit/node_modules/reduce/.editorconfig
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = tab
|
||||
indent_size = 4
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = true
|
||||
insert_final_newline = true
|
||||
max_line_length = 150
|
||||
|
||||
[CHANGELOG.md]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
|
||||
[*.json]
|
||||
max_line_length = off
|
||||
|
||||
[Makefile]
|
||||
max_line_length = off
|
||||
20
themes/keepit/node_modules/reduce/.eslintrc
generated
vendored
Normal file
20
themes/keepit/node_modules/reduce/.eslintrc
generated
vendored
Normal file
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"root": true,
|
||||
"extends": "@ljharb",
|
||||
"rules": {
|
||||
"array-bracket-newline": 0,
|
||||
"indent": [2, 4],
|
||||
"max-statements": 0,
|
||||
"no-magic-numbers": 0,
|
||||
},
|
||||
"overrides": [
|
||||
{
|
||||
"files": "test/**/*",
|
||||
"rules": {
|
||||
"id-length": 0,
|
||||
"max-params": 0,
|
||||
"max-statements-per-line": 0,
|
||||
},
|
||||
},
|
||||
],
|
||||
}
|
||||
281
themes/keepit/node_modules/reduce/.travis.yml
generated
vendored
Normal file
281
themes/keepit/node_modules/reduce/.travis.yml
generated
vendored
Normal file
@@ -0,0 +1,281 @@
|
||||
language: node_js
|
||||
os:
|
||||
- linux
|
||||
node_js:
|
||||
- "11.10"
|
||||
- "10.15"
|
||||
- "9.11"
|
||||
- "8.15"
|
||||
- "7.10"
|
||||
- "6.17"
|
||||
- "5.12"
|
||||
- "4.9"
|
||||
- "iojs-v3.3"
|
||||
- "iojs-v2.5"
|
||||
- "iojs-v1.8"
|
||||
- "0.12"
|
||||
- "0.10"
|
||||
- "0.8"
|
||||
before_install:
|
||||
- 'case "${TRAVIS_NODE_VERSION}" in 0.*) export NPM_CONFIG_STRICT_SSL=false ;; esac'
|
||||
- 'nvm install-latest-npm'
|
||||
install:
|
||||
- 'if [ "${TRAVIS_NODE_VERSION}" = "0.6" ] || [ "${TRAVIS_NODE_VERSION}" = "0.9" ]; then nvm install --latest-npm 0.8 && npm install && nvm use "${TRAVIS_NODE_VERSION}"; else npm install; fi;'
|
||||
script:
|
||||
- 'if [ -n "${PRETEST-}" ]; then npm run pretest ; fi'
|
||||
- 'if [ -n "${POSTTEST-}" ]; then npm run posttest ; fi'
|
||||
- 'if [ -n "${COVERAGE-}" ]; then npm run coverage ; fi'
|
||||
- 'if [ -n "${TEST-}" ]; then npm run tests-only ; fi'
|
||||
sudo: false
|
||||
env:
|
||||
- TEST=true
|
||||
matrix:
|
||||
fast_finish: true
|
||||
include:
|
||||
- node_js: "lts/*"
|
||||
env: PRETEST=true
|
||||
- node_js: "lts/*"
|
||||
env: POSTTEST=true
|
||||
- node_js: "4"
|
||||
env: COVERAGE=true
|
||||
- node_js: "11.9"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "11.8"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "11.7"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "11.6"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "11.5"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "11.4"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "11.3"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "11.2"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "11.1"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "11.0"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "10.14"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "10.13"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "10.12"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "10.11"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "10.10"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "10.9"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "10.8"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "10.7"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "10.6"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "10.5"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "10.4"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "10.3"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "10.2"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "10.1"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "10.0"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "9.10"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "9.9"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "9.8"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "9.7"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "9.6"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "9.5"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "9.4"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "9.3"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "9.2"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "9.1"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "9.0"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "8.14"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "8.13"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "8.12"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "8.11"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "8.10"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "8.9"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "8.8"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "8.7"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "8.6"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "8.5"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "8.4"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "8.3"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "8.2"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "8.1"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "8.0"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "7.9"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "7.8"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "7.7"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "7.6"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "7.5"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "7.4"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "7.3"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "7.2"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "7.1"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "7.0"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "6.16"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "6.15"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "6.14"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "6.13"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "6.12"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "6.11"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "6.10"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "6.9"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "6.8"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "6.7"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "6.6"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "6.5"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "6.4"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "6.3"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "6.2"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "6.1"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "6.0"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "5.11"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "5.10"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "5.9"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "5.8"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "5.7"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "5.6"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "5.5"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "5.4"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "5.3"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "5.2"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "5.1"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "5.0"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "4.8"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "4.7"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "4.6"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "4.5"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "4.4"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "4.3"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "4.2"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "4.1"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "4.0"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "iojs-v3.2"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "iojs-v3.1"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "iojs-v3.0"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "iojs-v2.4"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "iojs-v2.3"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "iojs-v2.2"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "iojs-v2.1"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "iojs-v2.0"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "iojs-v1.7"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "iojs-v1.6"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "iojs-v1.5"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "iojs-v1.4"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "iojs-v1.3"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "iojs-v1.2"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "iojs-v1.1"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "iojs-v1.0"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "0.11"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "0.9"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "0.6"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
- node_js: "0.4"
|
||||
env: TEST=true ALLOW_FAILURE=true
|
||||
allow_failures:
|
||||
- os: osx
|
||||
- env: TEST=true ALLOW_FAILURE=true
|
||||
19
themes/keepit/node_modules/reduce/LICENCE
generated
vendored
Normal file
19
themes/keepit/node_modules/reduce/LICENCE
generated
vendored
Normal file
@@ -0,0 +1,19 @@
|
||||
Copyright (c) 2012 Raynos.
|
||||
|
||||
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.
|
||||
38
themes/keepit/node_modules/reduce/README.md
generated
vendored
Normal file
38
themes/keepit/node_modules/reduce/README.md
generated
vendored
Normal file
@@ -0,0 +1,38 @@
|
||||
# reduce [![build status][travis-svg]][travis-url]
|
||||
|
||||
## Example
|
||||
|
||||
Like `Array.prototype.reduce` but works on Object and accepts optional
|
||||
`this` value
|
||||
|
||||
``` js
|
||||
var reduce = require("reduce")
|
||||
|
||||
reduce({
|
||||
key: "value"
|
||||
, key2: "value2"
|
||||
, ...
|
||||
}, function (acc, value, key) {
|
||||
/* real code */
|
||||
acc[key] = value
|
||||
return acc
|
||||
}, {
|
||||
this: "context"
|
||||
}, {
|
||||
initial: "value"
|
||||
})
|
||||
```
|
||||
|
||||
## Installation
|
||||
|
||||
`npm install reduce`
|
||||
|
||||
## Contributors
|
||||
|
||||
- Raynos
|
||||
|
||||
## MIT Licenced
|
||||
|
||||
[travis-svg]: https://secure.travis-ci.org/Raynos/reduce.svg
|
||||
[travis-url]: https://travis-ci.org/Raynos/reduce
|
||||
|
||||
28
themes/keepit/node_modules/reduce/index.js
generated
vendored
Normal file
28
themes/keepit/node_modules/reduce/index.js
generated
vendored
Normal file
@@ -0,0 +1,28 @@
|
||||
'use strict';
|
||||
|
||||
var objectKeys = require('object-keys');
|
||||
|
||||
module.exports = function reduce(list, iterator) {
|
||||
var keys = objectKeys(list);
|
||||
var i = 0;
|
||||
var accumulator = list[0];
|
||||
var context = this;
|
||||
|
||||
if (arguments.length === 2) {
|
||||
i = 1;
|
||||
} else if (arguments.length === 3) {
|
||||
accumulator = arguments[2];
|
||||
} else if (arguments.length >= 4) {
|
||||
context = arguments[2];
|
||||
accumulator = arguments[3];
|
||||
}
|
||||
|
||||
for (var len = keys.length; i < len; i++) {
|
||||
var key = keys[i];
|
||||
var value = list[key];
|
||||
|
||||
accumulator = iterator.call(context, accumulator, value, key, list);
|
||||
}
|
||||
|
||||
return accumulator;
|
||||
};
|
||||
59
themes/keepit/node_modules/reduce/package.json
generated
vendored
Normal file
59
themes/keepit/node_modules/reduce/package.json
generated
vendored
Normal file
@@ -0,0 +1,59 @@
|
||||
{
|
||||
"name": "reduce",
|
||||
"version": "1.0.2",
|
||||
"description": "A better [].reduce",
|
||||
"keywords": [],
|
||||
"author": "Raynos <raynos2@gmail.com>",
|
||||
"repository": "git://github.com/Raynos/reduce.git",
|
||||
"main": "index",
|
||||
"homepage": "https://github.com/Raynos/reduce",
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Jake Verbaten"
|
||||
}
|
||||
],
|
||||
"bugs": {
|
||||
"url": "https://github.com/Raynos/reduce/issues",
|
||||
"email": "raynos2@gmail.com"
|
||||
},
|
||||
"dependencies": {
|
||||
"object-keys": "^1.1.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@ljharb/eslint-config": "^13.1.1",
|
||||
"covert": "^1.1.1",
|
||||
"eslint": "^5.14.1",
|
||||
"tape": "^4.10.1"
|
||||
},
|
||||
"licenses": [
|
||||
{
|
||||
"type": "MIT",
|
||||
"url": "http://github.com/Raynos/reduce/raw/master/LICENSE"
|
||||
}
|
||||
],
|
||||
"testling": {
|
||||
"files": "test/*.js",
|
||||
"browsers": [
|
||||
"iexplore/6.0..latest",
|
||||
"firefox/3.0..6.0",
|
||||
"firefox/15.0..latest",
|
||||
"firefox/nightly",
|
||||
"chrome/4.0..10.0",
|
||||
"chrome/20.0..latest",
|
||||
"chrome/canary",
|
||||
"opera/10.0..latest",
|
||||
"opera/next",
|
||||
"safari/4.0..latest",
|
||||
"ipad/6.0..latest",
|
||||
"iphone/6.0..latest"
|
||||
]
|
||||
},
|
||||
"scripts": {
|
||||
"pretest": "npm run lint",
|
||||
"tests-only": "node test/simple.js",
|
||||
"test": "npm run tests-only",
|
||||
"posttest": "npx aud",
|
||||
"coverage": "covert test/simple.js",
|
||||
"lint": "eslint ."
|
||||
}
|
||||
}
|
||||
97
themes/keepit/node_modules/reduce/test/simple.js
generated
vendored
Normal file
97
themes/keepit/node_modules/reduce/test/simple.js
generated
vendored
Normal file
@@ -0,0 +1,97 @@
|
||||
'use strict';
|
||||
|
||||
var test = require('tape');
|
||||
var reduce = require('..');
|
||||
|
||||
var createItem = function createTestItem() {
|
||||
return {
|
||||
a: 'a1',
|
||||
b: 'b1',
|
||||
c: 'c1'
|
||||
};
|
||||
};
|
||||
|
||||
test('reduce calls each iterator', function (t) {
|
||||
var item = createItem();
|
||||
var timesCalled = 0;
|
||||
var accumulator = { key: '' };
|
||||
var expectedKeys = ['a', 'b', 'c'];
|
||||
var expectedValues = ['a1', 'b1', 'c1'];
|
||||
var expectedAccumulatorKeys = ['', 'a1', 'a1b1', 'a1b1c1'];
|
||||
var calledArguments = [];
|
||||
var slice = Array.prototype.slice;
|
||||
var iterator = function (acc, value, key, list) {
|
||||
var expectedKey = expectedKeys[timesCalled];
|
||||
var expectedValue = expectedValues[timesCalled];
|
||||
var expectedAccumulatorKey = expectedAccumulatorKeys[timesCalled];
|
||||
|
||||
calledArguments.push(slice.apply(arguments));
|
||||
|
||||
t.equal(value, expectedValue, 'value ' + value + ' does not match ' + expectedValue);
|
||||
t.equal(key, expectedKey, 'key ' + key + ' does not match ' + expectedKey);
|
||||
t.equal(list, item, 'list arg is not correct');
|
||||
t.equal(acc.key, expectedAccumulatorKey, 'accumulator key ' + acc.key + ' does not match ' + expectedAccumulatorKey);
|
||||
|
||||
timesCalled += 1;
|
||||
acc.key += value;
|
||||
return acc;
|
||||
};
|
||||
|
||||
var result = reduce(item, iterator, accumulator);
|
||||
|
||||
t.equal(timesCalled, 3, 'iterator was not called thrice');
|
||||
t.deepEqual(result, { key: 'a1b1c1' }, 'result is incorrect');
|
||||
|
||||
t.deepEqual(calledArguments[0], [{
|
||||
key: 'a1b1c1'
|
||||
}, 'a1', 'a', item], 'iterator called with wrong arguments');
|
||||
t.deepEqual(calledArguments[1], [{
|
||||
key: 'a1b1c1'
|
||||
}, 'b1', 'b', item], 'iterator called with wrong arguments');
|
||||
t.deepEqual(calledArguments[2], [{
|
||||
key: 'a1b1c1'
|
||||
}, 'c1', 'c', item], 'iterator called with wrong arguments');
|
||||
t.deepEqual(result, {
|
||||
key: 'a1b1c1'
|
||||
});
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('reduce calls iterator with correct this value', function (t) {
|
||||
var item = createItem();
|
||||
var thisValue = {};
|
||||
var iterator = function () {
|
||||
// eslint-disable-next-line no-invalid-this
|
||||
t.equal(this, thisValue, 'this value is incorrect');
|
||||
};
|
||||
|
||||
reduce(item, iterator, thisValue, {});
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('reduce reduces with first value if no initialValue', function (t) {
|
||||
var list = [1, 2];
|
||||
var iterator = function (sum, v) {
|
||||
return sum + v;
|
||||
};
|
||||
|
||||
var result = reduce(list, iterator);
|
||||
|
||||
t.equal(result, 3, 'result is incorrect');
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('reduce throws a TypeError when an invalid iterator is provided', function (t) {
|
||||
t['throws'](function () { reduce([1, 2]); }, TypeError, 'requires a function');
|
||||
|
||||
t.end();
|
||||
});
|
||||
|
||||
test('reduce has a length of 2, mimicking spec', function (t) {
|
||||
t.equal(reduce.length, 2, 'reduce has a length of 2');
|
||||
|
||||
t.end();
|
||||
});
|
||||
Reference in New Issue
Block a user