ran npm run tdd
This commit is contained in:
3
test/averageBy/averageBy.js
Normal file
3
test/averageBy/averageBy.js
Normal file
@ -0,0 +1,3 @@
|
|||||||
|
module.exports = averageBy = (arr, fn) =>
|
||||||
|
arr.map(typeof fn === 'function' ? fn : val => val[fn]).reduce((acc, val) => acc + val, 0) /
|
||||||
|
arr.length;
|
||||||
13
test/averageBy/averageBy.test.js
Normal file
13
test/averageBy/averageBy.test.js
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
const test = require('tape');
|
||||||
|
const averageBy = require('./averageBy.js');
|
||||||
|
|
||||||
|
test('Testing averageBy', (t) => {
|
||||||
|
//For more information on all the methods supported by tape
|
||||||
|
//Please go to https://github.com/substack/tape
|
||||||
|
t.true(typeof averageBy === 'function', 'averageBy is a Function');
|
||||||
|
//t.deepEqual(averageBy(args..), 'Expected');
|
||||||
|
//t.equal(averageBy(args..), 'Expected');
|
||||||
|
//t.false(averageBy(args..), 'Expected');
|
||||||
|
//t.throws(averageBy(args..), 'Expected');
|
||||||
|
t.end();
|
||||||
|
});
|
||||||
18
test/colorize/colorize.js
Normal file
18
test/colorize/colorize.js
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
module.exports = colorize = (...args) => ({
|
||||||
|
black: `\x1b[30m${args.join(' ')}`,
|
||||||
|
red: `\x1b[31m${args.join(' ')}`,
|
||||||
|
green: `\x1b[32m${args.join(' ')}`,
|
||||||
|
yellow: `\x1b[33m${args.join(' ')}`,
|
||||||
|
blue: `\x1b[34m${args.join(' ')}`,
|
||||||
|
magenta: `\x1b[35m${args.join(' ')}`,
|
||||||
|
cyan: `\x1b[36m${args.join(' ')}`,
|
||||||
|
white: `\x1b[37m${args.join(' ')}`,
|
||||||
|
bgBlack: `\x1b[40m${args.join(' ')}\x1b[0m`,
|
||||||
|
bgRed: `\x1b[41m${args.join(' ')}\x1b[0m`,
|
||||||
|
bgGreen: `\x1b[42m${args.join(' ')}\x1b[0m`,
|
||||||
|
bgYellow: `\x1b[43m${args.join(' ')}\x1b[0m`,
|
||||||
|
bgBlue: `\x1b[44m${args.join(' ')}\x1b[0m`,
|
||||||
|
bgMagenta: `\x1b[45m${args.join(' ')}\x1b[0m`,
|
||||||
|
bgCyan: `\x1b[46m${args.join(' ')}\x1b[0m`,
|
||||||
|
bgWhite: `\x1b[47m${args.join(' ')}\x1b[0m`
|
||||||
|
});
|
||||||
13
test/colorize/colorize.test.js
Normal file
13
test/colorize/colorize.test.js
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
const test = require('tape');
|
||||||
|
const colorize = require('./colorize.js');
|
||||||
|
|
||||||
|
test('Testing colorize', (t) => {
|
||||||
|
//For more information on all the methods supported by tape
|
||||||
|
//Please go to https://github.com/substack/tape
|
||||||
|
t.true(typeof colorize === 'function', 'colorize is a Function');
|
||||||
|
//t.deepEqual(colorize(args..), 'Expected');
|
||||||
|
//t.equal(colorize(args..), 'Expected');
|
||||||
|
//t.false(colorize(args..), 'Expected');
|
||||||
|
//t.throws(colorize(args..), 'Expected');
|
||||||
|
t.end();
|
||||||
|
});
|
||||||
5
test/countBy/countBy.js
Normal file
5
test/countBy/countBy.js
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
module.exports = countBy = (arr, fn) =>
|
||||||
|
arr.map(typeof fn === 'function' ? fn : val => val[fn]).reduce((acc, val, i) => {
|
||||||
|
acc[val] = (acc[val] || 0) + 1;
|
||||||
|
return acc;
|
||||||
|
}, {});
|
||||||
13
test/countBy/countBy.test.js
Normal file
13
test/countBy/countBy.test.js
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
const test = require('tape');
|
||||||
|
const countBy = require('./countBy.js');
|
||||||
|
|
||||||
|
test('Testing countBy', (t) => {
|
||||||
|
//For more information on all the methods supported by tape
|
||||||
|
//Please go to https://github.com/substack/tape
|
||||||
|
t.true(typeof countBy === 'function', 'countBy is a Function');
|
||||||
|
//t.deepEqual(countBy(args..), 'Expected');
|
||||||
|
//t.equal(countBy(args..), 'Expected');
|
||||||
|
//t.false(countBy(args..), 'Expected');
|
||||||
|
//t.throws(countBy(args..), 'Expected');
|
||||||
|
t.end();
|
||||||
|
});
|
||||||
1
test/findLast/findLast.js
Normal file
1
test/findLast/findLast.js
Normal file
@ -0,0 +1 @@
|
|||||||
|
module.exports = findLast = (arr, fn) => arr.filter(fn).slice(-1);
|
||||||
13
test/findLast/findLast.test.js
Normal file
13
test/findLast/findLast.test.js
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
const test = require('tape');
|
||||||
|
const findLast = require('./findLast.js');
|
||||||
|
|
||||||
|
test('Testing findLast', (t) => {
|
||||||
|
//For more information on all the methods supported by tape
|
||||||
|
//Please go to https://github.com/substack/tape
|
||||||
|
t.true(typeof findLast === 'function', 'findLast is a Function');
|
||||||
|
//t.deepEqual(findLast(args..), 'Expected');
|
||||||
|
//t.equal(findLast(args..), 'Expected');
|
||||||
|
//t.false(findLast(args..), 'Expected');
|
||||||
|
//t.throws(findLast(args..), 'Expected');
|
||||||
|
t.end();
|
||||||
|
});
|
||||||
5
test/functions/functions.js
Normal file
5
test/functions/functions.js
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
module.exports = functions = (obj, inherited = false) =>
|
||||||
|
(inherited
|
||||||
|
? [...Object.keys(obj), ...Object.keys(Object.getPrototypeOf(obj))]
|
||||||
|
: Object.keys(obj)
|
||||||
|
).filter(key => typeof obj[key] === 'function');
|
||||||
13
test/functions/functions.test.js
Normal file
13
test/functions/functions.test.js
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
const test = require('tape');
|
||||||
|
const functions = require('./functions.js');
|
||||||
|
|
||||||
|
test('Testing functions', (t) => {
|
||||||
|
//For more information on all the methods supported by tape
|
||||||
|
//Please go to https://github.com/substack/tape
|
||||||
|
t.true(typeof functions === 'function', 'functions is a Function');
|
||||||
|
//t.deepEqual(functions(args..), 'Expected');
|
||||||
|
//t.equal(functions(args..), 'Expected');
|
||||||
|
//t.false(functions(args..), 'Expected');
|
||||||
|
//t.throws(functions(args..), 'Expected');
|
||||||
|
t.end();
|
||||||
|
});
|
||||||
5
test/mapKeys/mapKeys.js
Normal file
5
test/mapKeys/mapKeys.js
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
module.exports = mapKeys = (obj, fn) =>
|
||||||
|
Object.keys(obj).reduce((acc, k) => {
|
||||||
|
acc[fn(obj[k], k, obj)] = obj[k];
|
||||||
|
return acc;
|
||||||
|
}, {});
|
||||||
13
test/mapKeys/mapKeys.test.js
Normal file
13
test/mapKeys/mapKeys.test.js
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
const test = require('tape');
|
||||||
|
const mapKeys = require('./mapKeys.js');
|
||||||
|
|
||||||
|
test('Testing mapKeys', (t) => {
|
||||||
|
//For more information on all the methods supported by tape
|
||||||
|
//Please go to https://github.com/substack/tape
|
||||||
|
t.true(typeof mapKeys === 'function', 'mapKeys is a Function');
|
||||||
|
//t.deepEqual(mapKeys(args..), 'Expected');
|
||||||
|
//t.equal(mapKeys(args..), 'Expected');
|
||||||
|
//t.false(mapKeys(args..), 'Expected');
|
||||||
|
//t.throws(mapKeys(args..), 'Expected');
|
||||||
|
t.end();
|
||||||
|
});
|
||||||
5
test/mapValues/mapValues.js
Normal file
5
test/mapValues/mapValues.js
Normal file
@ -0,0 +1,5 @@
|
|||||||
|
module.exports = mapValues = (obj, fn) =>
|
||||||
|
Object.keys(obj).reduce((acc, k) => {
|
||||||
|
acc[k] = fn(obj[k], k, obj);
|
||||||
|
return acc;
|
||||||
|
}, {});
|
||||||
13
test/mapValues/mapValues.test.js
Normal file
13
test/mapValues/mapValues.test.js
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
const test = require('tape');
|
||||||
|
const mapValues = require('./mapValues.js');
|
||||||
|
|
||||||
|
test('Testing mapValues', (t) => {
|
||||||
|
//For more information on all the methods supported by tape
|
||||||
|
//Please go to https://github.com/substack/tape
|
||||||
|
t.true(typeof mapValues === 'function', 'mapValues is a Function');
|
||||||
|
//t.deepEqual(mapValues(args..), 'Expected');
|
||||||
|
//t.equal(mapValues(args..), 'Expected');
|
||||||
|
//t.false(mapValues(args..), 'Expected');
|
||||||
|
//t.throws(mapValues(args..), 'Expected');
|
||||||
|
t.end();
|
||||||
|
});
|
||||||
1
test/maxBy/maxBy.js
Normal file
1
test/maxBy/maxBy.js
Normal file
@ -0,0 +1 @@
|
|||||||
|
module.exports = maxBy = (arr, fn) => Math.max(...arr.map(typeof fn === 'function' ? fn : val => val[fn]));
|
||||||
13
test/maxBy/maxBy.test.js
Normal file
13
test/maxBy/maxBy.test.js
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
const test = require('tape');
|
||||||
|
const maxBy = require('./maxBy.js');
|
||||||
|
|
||||||
|
test('Testing maxBy', (t) => {
|
||||||
|
//For more information on all the methods supported by tape
|
||||||
|
//Please go to https://github.com/substack/tape
|
||||||
|
t.true(typeof maxBy === 'function', 'maxBy is a Function');
|
||||||
|
//t.deepEqual(maxBy(args..), 'Expected');
|
||||||
|
//t.equal(maxBy(args..), 'Expected');
|
||||||
|
//t.false(maxBy(args..), 'Expected');
|
||||||
|
//t.throws(maxBy(args..), 'Expected');
|
||||||
|
t.end();
|
||||||
|
});
|
||||||
9
test/merge/merge.js
Normal file
9
test/merge/merge.js
Normal file
@ -0,0 +1,9 @@
|
|||||||
|
module.exports = merge = (...objs) =>
|
||||||
|
[...objs].reduce(
|
||||||
|
(acc, obj) =>
|
||||||
|
Object.keys(obj).reduce((a, k) => {
|
||||||
|
acc[k] = acc.hasOwnProperty(k) ? [].concat(acc[k]).concat(obj[k]) : obj[k];
|
||||||
|
return acc;
|
||||||
|
}, {}),
|
||||||
|
{}
|
||||||
|
);
|
||||||
13
test/merge/merge.test.js
Normal file
13
test/merge/merge.test.js
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
const test = require('tape');
|
||||||
|
const merge = require('./merge.js');
|
||||||
|
|
||||||
|
test('Testing merge', (t) => {
|
||||||
|
//For more information on all the methods supported by tape
|
||||||
|
//Please go to https://github.com/substack/tape
|
||||||
|
t.true(typeof merge === 'function', 'merge is a Function');
|
||||||
|
//t.deepEqual(merge(args..), 'Expected');
|
||||||
|
//t.equal(merge(args..), 'Expected');
|
||||||
|
//t.false(merge(args..), 'Expected');
|
||||||
|
//t.throws(merge(args..), 'Expected');
|
||||||
|
t.end();
|
||||||
|
});
|
||||||
1
test/minBy/minBy.js
Normal file
1
test/minBy/minBy.js
Normal file
@ -0,0 +1 @@
|
|||||||
|
module.exports = minBy = (arr, fn) => Math.min(...arr.map(typeof fn === 'function' ? fn : val => val[fn]));
|
||||||
13
test/minBy/minBy.test.js
Normal file
13
test/minBy/minBy.test.js
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
const test = require('tape');
|
||||||
|
const minBy = require('./minBy.js');
|
||||||
|
|
||||||
|
test('Testing minBy', (t) => {
|
||||||
|
//For more information on all the methods supported by tape
|
||||||
|
//Please go to https://github.com/substack/tape
|
||||||
|
t.true(typeof minBy === 'function', 'minBy is a Function');
|
||||||
|
//t.deepEqual(minBy(args..), 'Expected');
|
||||||
|
//t.equal(minBy(args..), 'Expected');
|
||||||
|
//t.false(minBy(args..), 'Expected');
|
||||||
|
//t.throws(minBy(args..), 'Expected');
|
||||||
|
t.end();
|
||||||
|
});
|
||||||
8
test/parseCookie/parseCookie.js
Normal file
8
test/parseCookie/parseCookie.js
Normal file
@ -0,0 +1,8 @@
|
|||||||
|
module.exports = parseCookie = str =>
|
||||||
|
str
|
||||||
|
.split(';')
|
||||||
|
.map(v => v.split('='))
|
||||||
|
.reduce((acc, v) => {
|
||||||
|
acc[decodeURIComponent(v[0].trim())] = decodeURIComponent(v[1].trim());
|
||||||
|
return acc;
|
||||||
|
}, {});
|
||||||
13
test/parseCookie/parseCookie.test.js
Normal file
13
test/parseCookie/parseCookie.test.js
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
const test = require('tape');
|
||||||
|
const parseCookie = require('./parseCookie.js');
|
||||||
|
|
||||||
|
test('Testing parseCookie', (t) => {
|
||||||
|
//For more information on all the methods supported by tape
|
||||||
|
//Please go to https://github.com/substack/tape
|
||||||
|
t.true(typeof parseCookie === 'function', 'parseCookie is a Function');
|
||||||
|
//t.deepEqual(parseCookie(args..), 'Expected');
|
||||||
|
//t.equal(parseCookie(args..), 'Expected');
|
||||||
|
//t.false(parseCookie(args..), 'Expected');
|
||||||
|
//t.throws(parseCookie(args..), 'Expected');
|
||||||
|
t.end();
|
||||||
|
});
|
||||||
1
test/serializeCookie/serializeCookie.js
Normal file
1
test/serializeCookie/serializeCookie.js
Normal file
@ -0,0 +1 @@
|
|||||||
|
module.exports = serializeCookie = (name, val) => `${encodeURIComponent(name)}=${encodeURIComponent(val)}`;
|
||||||
13
test/serializeCookie/serializeCookie.test.js
Normal file
13
test/serializeCookie/serializeCookie.test.js
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
const test = require('tape');
|
||||||
|
const serializeCookie = require('./serializeCookie.js');
|
||||||
|
|
||||||
|
test('Testing serializeCookie', (t) => {
|
||||||
|
//For more information on all the methods supported by tape
|
||||||
|
//Please go to https://github.com/substack/tape
|
||||||
|
t.true(typeof serializeCookie === 'function', 'serializeCookie is a Function');
|
||||||
|
//t.deepEqual(serializeCookie(args..), 'Expected');
|
||||||
|
//t.equal(serializeCookie(args..), 'Expected');
|
||||||
|
//t.false(serializeCookie(args..), 'Expected');
|
||||||
|
//t.throws(serializeCookie(args..), 'Expected');
|
||||||
|
t.end();
|
||||||
|
});
|
||||||
2
test/sumBy/sumBy.js
Normal file
2
test/sumBy/sumBy.js
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
module.exports = sumBy = (arr, fn) =>
|
||||||
|
arr.map(typeof fn === 'function' ? fn : val => val[fn]).reduce((acc, val) => acc + val, 0);
|
||||||
13
test/sumBy/sumBy.test.js
Normal file
13
test/sumBy/sumBy.test.js
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
const test = require('tape');
|
||||||
|
const sumBy = require('./sumBy.js');
|
||||||
|
|
||||||
|
test('Testing sumBy', (t) => {
|
||||||
|
//For more information on all the methods supported by tape
|
||||||
|
//Please go to https://github.com/substack/tape
|
||||||
|
t.true(typeof sumBy === 'function', 'sumBy is a Function');
|
||||||
|
//t.deepEqual(sumBy(args..), 'Expected');
|
||||||
|
//t.equal(sumBy(args..), 'Expected');
|
||||||
|
//t.false(sumBy(args..), 'Expected');
|
||||||
|
//t.throws(sumBy(args..), 'Expected');
|
||||||
|
t.end();
|
||||||
|
});
|
||||||
1
test/transform/transform.js
Normal file
1
test/transform/transform.js
Normal file
@ -0,0 +1 @@
|
|||||||
|
module.exports = transform = (obj, fn, acc) => Object.keys(obj).reduce((a, k) => fn(a, obj[k], k, obj), acc);
|
||||||
13
test/transform/transform.test.js
Normal file
13
test/transform/transform.test.js
Normal file
@ -0,0 +1,13 @@
|
|||||||
|
const test = require('tape');
|
||||||
|
const transform = require('./transform.js');
|
||||||
|
|
||||||
|
test('Testing transform', (t) => {
|
||||||
|
//For more information on all the methods supported by tape
|
||||||
|
//Please go to https://github.com/substack/tape
|
||||||
|
t.true(typeof transform === 'function', 'transform is a Function');
|
||||||
|
//t.deepEqual(transform(args..), 'Expected');
|
||||||
|
//t.equal(transform(args..), 'Expected');
|
||||||
|
//t.false(transform(args..), 'Expected');
|
||||||
|
//t.throws(transform(args..), 'Expected');
|
||||||
|
t.end();
|
||||||
|
});
|
||||||
Reference in New Issue
Block a user