ran npm run tester -> logged invertKeyValues test are invalid

This commit is contained in:
King
2018-01-24 06:29:38 -05:00
parent d835cf4b40
commit 737acd870d
270 changed files with 1141 additions and 872 deletions

View File

@ -0,0 +1,2 @@
const composeRight = (...fns) => fns.reduce((f, g) => (...args) => g(f(...args)));
module.exports = composeRight

View File

@ -0,0 +1,13 @@
const test = require('tape');
const composeRight = require('./composeRight.js');
test('Testing composeRight', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof composeRight === 'function', 'composeRight is a Function');
//t.deepEqual(composeRight(args..), 'Expected');
//t.equal(composeRight(args..), 'Expected');
//t.false(composeRight(args..), 'Expected');
//t.throws(composeRight(args..), 'Expected');
t.end();
});

View File

@ -0,0 +1,5 @@
const differenceBy = (a, b, fn) => {
const s = new Set(b.map(v => fn(v)));
return a.filter(x => !s.has(fn(x)));
};
module.exports = differenceBy

View File

@ -0,0 +1,13 @@
const test = require('tape');
const differenceBy = require('./differenceBy.js');
test('Testing differenceBy', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof differenceBy === 'function', 'differenceBy is a Function');
//t.deepEqual(differenceBy(args..), 'Expected');
//t.equal(differenceBy(args..), 'Expected');
//t.false(differenceBy(args..), 'Expected');
//t.throws(differenceBy(args..), 'Expected');
t.end();
});

View File

@ -1,2 +1,2 @@
const findLast = (arr, fn) => arr.filter(fn).slice(-1); const findLast = (arr, fn) => arr.filter(fn).slice(-1)[0];
module.exports = findLast module.exports = findLast

View File

@ -0,0 +1,6 @@
const findLastIndex = (arr, fn) =>
arr
.map((val, i) => [i, val])
.filter(val => fn(val[1], val[0], arr))
.slice(-1)[0][0];
module.exports = findLastIndex

View File

@ -0,0 +1,13 @@
const test = require('tape');
const findLastIndex = require('./findLastIndex.js');
test('Testing findLastIndex', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof findLastIndex === 'function', 'findLastIndex is a Function');
//t.deepEqual(findLastIndex(args..), 'Expected');
//t.equal(findLastIndex(args..), 'Expected');
//t.false(findLastIndex(args..), 'Expected');
//t.throws(findLastIndex(args..), 'Expected');
t.end();
});

View File

@ -0,0 +1,5 @@
const intersectionBy = (a, b, fn) => {
const s = new Set(b.map(x => fn(x)));
return a.filter(x => s.has(fn(x)));
};
module.exports = intersectionBy

View File

@ -0,0 +1,13 @@
const test = require('tape');
const intersectionBy = require('./intersectionBy.js');
test('Testing intersectionBy', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof intersectionBy === 'function', 'intersectionBy is a Function');
//t.deepEqual(intersectionBy(args..), 'Expected');
//t.equal(intersectionBy(args..), 'Expected');
//t.false(intersectionBy(args..), 'Expected');
//t.throws(intersectionBy(args..), 'Expected');
t.end();
});

View File

@ -0,0 +1,2 @@
const intersectionWith = (a, b, comp) => a.filter(x => b.findIndex(y => comp(x, y)) !== -1);
module.exports = intersectionWith

View File

@ -0,0 +1,13 @@
const test = require('tape');
const intersectionWith = require('./intersectionWith.js');
test('Testing intersectionWith', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof intersectionWith === 'function', 'intersectionWith is a Function');
//t.deepEqual(intersectionWith(args..), 'Expected');
//t.equal(intersectionWith(args..), 'Expected');
//t.false(intersectionWith(args..), 'Expected');
//t.throws(intersectionWith(args..), 'Expected');
t.end();
});

View File

@ -0,0 +1,9 @@
const sortedLastIndex = (arr, n) => {
const isDescending = arr[0] > arr[arr.length - 1];
const index = arr
.map((val, i) => [i, val])
.filter(el => (isDescending ? n >= el[1] : n >= el[1]))
.slice(-1)[0][0];
return index === -1 ? arr.length : index;
};
module.exports = sortedLastIndex

View File

@ -0,0 +1,13 @@
const test = require('tape');
const sortedLastIndex = require('./sortedLastIndex.js');
test('Testing sortedLastIndex', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof sortedLastIndex === 'function', 'sortedLastIndex is a Function');
//t.deepEqual(sortedLastIndex(args..), 'Expected');
//t.equal(sortedLastIndex(args..), 'Expected');
//t.false(sortedLastIndex(args..), 'Expected');
//t.throws(sortedLastIndex(args..), 'Expected');
t.end();
});

View File

@ -0,0 +1,6 @@
const symmetricDifferenceBy = (a, b, fn) => {
const sA = new Set(a.map(v => fn(v))),
sB = new Set(b.map(v => fn(v)));
return [...a.filter(x => !sB.has(fn(x))), ...b.filter(x => !sA.has(fn(x)))];
};
module.exports = symmetricDifferenceBy

View File

@ -0,0 +1,13 @@
const test = require('tape');
const symmetricDifferenceBy = require('./symmetricDifferenceBy.js');
test('Testing symmetricDifferenceBy', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof symmetricDifferenceBy === 'function', 'symmetricDifferenceBy is a Function');
//t.deepEqual(symmetricDifferenceBy(args..), 'Expected');
//t.equal(symmetricDifferenceBy(args..), 'Expected');
//t.false(symmetricDifferenceBy(args..), 'Expected');
//t.throws(symmetricDifferenceBy(args..), 'Expected');
t.end();
});

View File

@ -0,0 +1,5 @@
const symmetricDifferenceWith = (arr, val, comp) => [
...arr.filter(a => val.findIndex(b => comp(a, b)) === -1),
...val.filter(a => arr.findIndex(b => comp(a, b)) === -1)
];
module.exports = symmetricDifferenceWith

View File

@ -0,0 +1,13 @@
const test = require('tape');
const symmetricDifferenceWith = require('./symmetricDifferenceWith.js');
test('Testing symmetricDifferenceWith', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof symmetricDifferenceWith === 'function', 'symmetricDifferenceWith is a Function');
//t.deepEqual(symmetricDifferenceWith(args..), 'Expected');
//t.equal(symmetricDifferenceWith(args..), 'Expected');
//t.false(symmetricDifferenceWith(args..), 'Expected');
//t.throws(symmetricDifferenceWith(args..), 'Expected');
t.end();
});

File diff suppressed because it is too large Load Diff

5
test/unionBy/unionBy.js Normal file
View File

@ -0,0 +1,5 @@
const unionBy = (a, b, fn) => {
const s = new Set(a.map(v => fn(v)));
return Array.from(new Set([...a, ...b.filter(x => !s.has(fn(x)))]));
};
module.exports = unionBy

View File

@ -0,0 +1,13 @@
const test = require('tape');
const unionBy = require('./unionBy.js');
test('Testing unionBy', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof unionBy === 'function', 'unionBy is a Function');
//t.deepEqual(unionBy(args..), 'Expected');
//t.equal(unionBy(args..), 'Expected');
//t.false(unionBy(args..), 'Expected');
//t.throws(unionBy(args..), 'Expected');
t.end();
});

View File

@ -0,0 +1,3 @@
const unionWith = (a, b, comp) =>
Array.from(new Set([...a, ...b.filter(x => a.findIndex(y => comp(x, y)) === -1)]));
module.exports = unionWith

View File

@ -0,0 +1,13 @@
const test = require('tape');
const unionWith = require('./unionWith.js');
test('Testing unionWith', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof unionWith === 'function', 'unionWith is a Function');
//t.deepEqual(unionWith(args..), 'Expected');
//t.equal(unionWith(args..), 'Expected');
//t.false(unionWith(args..), 'Expected');
//t.throws(unionWith(args..), 'Expected');
t.end();
});

8
test/unzip/unzip.js Normal file
View File

@ -0,0 +1,8 @@
const unzip = arr =>
arr.reduce(
(acc, val) => (val.forEach((v, i) => acc[i].push(v)), acc),
Array.from({
length: Math.max(...arr.map(x => x.length))
}).map(x => [])
);
module.exports = unzip

13
test/unzip/unzip.test.js Normal file
View File

@ -0,0 +1,13 @@
const test = require('tape');
const unzip = require('./unzip.js');
test('Testing unzip', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof unzip === 'function', 'unzip is a Function');
//t.deepEqual(unzip(args..), 'Expected');
//t.equal(unzip(args..), 'Expected');
//t.false(unzip(args..), 'Expected');
//t.throws(unzip(args..), 'Expected');
t.end();
});

View File

@ -0,0 +1,10 @@
const unzipWith = (arr, fn) =>
arr
.reduce(
(acc, val) => (val.forEach((v, i) => acc[i].push(v)), acc),
Array.from({
length: Math.max(...arr.map(x => x.length))
}).map(x => [])
)
.map(val => fn(...val));
module.exports = unzipWith

View File

@ -0,0 +1,13 @@
const test = require('tape');
const unzipWith = require('./unzipWith.js');
test('Testing unzipWith', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof unzipWith === 'function', 'unzipWith is a Function');
//t.deepEqual(unzipWith(args..), 'Expected');
//t.equal(unzipWith(args..), 'Expected');
//t.false(unzipWith(args..), 'Expected');
//t.throws(unzipWith(args..), 'Expected');
t.end();
});