Merge branch 'master' into browser-tests

This commit is contained in:
Angelos Chalaris
2018-01-26 11:22:30 +02:00
committed by GitHub
598 changed files with 6282 additions and 2559 deletions

View File

@ -2,4 +2,4 @@ const JSONToDate = arr => {
const dt = new Date(parseInt(arr.toString().substr(6)));
return `${dt.getDate()}/${dt.getMonth() + 1}/${dt.getFullYear()}`;
};
module.exports = JSONToDate
module.exports = JSONToDate

View File

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

View File

@ -1,4 +1,4 @@
const fs = require('fs');
const JSONToFile = (obj, filename) =>
fs.writeFile(`${filename}.json`, JSON.stringify(obj, null, 2));
module.exports = JSONToFile
module.exports = JSONToFile

View File

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

View File

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

View File

@ -1,2 +1,2 @@
const RGBToHex = (r, g, b) => ((r << 16) + (g << 8) + b).toString(16).padStart(6, '0');
module.exports = RGBToHex
module.exports = RGBToHex

View File

@ -2,13 +2,13 @@ const test = require('tape');
const RGBToHex = require('./RGBToHex.js');
test('Testing RGBToHex', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof RGBToHex === 'function', 'RGBToHex is a Function');
t.equal(RGBToHex(255, 165, 1), 'ffa501', "Converts the values of RGB components to a color code.");
//t.deepEqual(RGBToHex(args..), 'Expected');
//t.equal(RGBToHex(args..), 'Expected');
//t.false(RGBToHex(args..), 'Expected');
//t.throws(RGBToHex(args..), 'Expected');
t.end();
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof RGBToHex === 'function', 'RGBToHex is a Function');
t.equal(RGBToHex(255, 165, 1), 'ffa501', "Converts the values of RGB components to a color code.");
//t.deepEqual(RGBToHex(args..), 'Expected');
//t.equal(RGBToHex(args..), 'Expected');
//t.false(RGBToHex(args..), 'Expected');
//t.throws(RGBToHex(args..), 'Expected');
t.end();
});

View File

@ -7,4 +7,4 @@ args
.replace(/\/(\?|&|#[^!])/g, '$1')
.replace(/\?/g, '&')
.replace('&', '?');
module.exports = URLJoin
module.exports = URLJoin

View File

@ -2,14 +2,14 @@ const test = require('tape');
const URLJoin = require('./URLJoin.js');
test('Testing URLJoin', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof URLJoin === 'function', 'URLJoin is a Function');
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof URLJoin === 'function', 'URLJoin is a Function');
t.equal(URLJoin('http://www.google.com', 'a', '/b/cd', '?foo=123', '?bar=foo'), 'http://www.google.com/a/b/cd?foo=123&bar=foo', 'Returns proper URL');
t.equal(URLJoin('file://www.google.com', 'a', '/b/cd', '?foo=123', '?bar=foo'), 'file:///www.google.com/a/b/cd?foo=123&bar=foo', 'Returns proper URL');
//t.deepEqual(URLJoin(args..), 'Expected');
//t.equal(URLJoin(args..), 'Expected');
//t.false(URLJoin(args..), 'Expected');
//t.throws(URLJoin(args..), 'Expected');
t.end();
//t.deepEqual(URLJoin(args..), 'Expected');
//t.equal(URLJoin(args..), 'Expected');
//t.false(URLJoin(args..), 'Expected');
//t.throws(URLJoin(args..), 'Expected');
t.end();
});

View File

@ -2,4 +2,4 @@ const UUIDGeneratorBrowser = () =>
([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c =>
(c ^ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4)))).toString(16)
);
module.exports = UUIDGeneratorBrowser
module.exports = UUIDGeneratorBrowser

View File

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

View File

@ -3,4 +3,4 @@ const UUIDGeneratorNode = () =>
([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c =>
(c ^ (crypto.randomBytes(1)[0] & (15 >> (c / 4)))).toString(16)
);
module.exports = UUIDGeneratorNode
module.exports = UUIDGeneratorNode

View File

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

View File

@ -8,4 +8,4 @@ acc.concat(anagrams(str.slice(0, i) + str.slice(i + 1)).map(val => letter + val)
[]
);
};
module.exports = anagrams
module.exports = anagrams

View File

@ -2,13 +2,13 @@ const test = require('tape');
const anagrams = require('./anagrams.js');
test('Testing anagrams', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof anagrams === 'function', 'anagrams is a Function');
t.deepEqual(anagrams('abc'), ['abc','acb','bac','bca','cab','cba'], "Generates all anagrams of a string");
//t.deepEqual(anagrams(args..), 'Expected');
//t.equal(anagrams(args..), 'Expected');
//t.false(anagrams(args..), 'Expected');
//t.throws(anagrams(args..), 'Expected');
t.end();
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof anagrams === 'function', 'anagrams is a Function');
t.deepEqual(anagrams('abc'), ['abc','acb','bac','bca','cab','cba'], "Generates all anagrams of a string");
//t.deepEqual(anagrams(args..), 'Expected');
//t.equal(anagrams(args..), 'Expected');
//t.false(anagrams(args..), 'Expected');
//t.throws(anagrams(args..), 'Expected');
t.end();
});

View File

@ -1,3 +1,3 @@
const arrayToHtmlList = (arr, listID) =>
arr.map(item => (document.querySelector('#' + listID).innerHTML += `<li>${item}</li>`));
module.exports = arrayToHtmlList
module.exports = arrayToHtmlList

View File

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

2
test/ary/ary.js Normal file
View File

@ -0,0 +1,2 @@
const ary = (fn, n) => (...args) => fn(...args.slice(0, n));
module.exports = ary

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

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

View File

@ -1,2 +1,2 @@
const atob = str => new Buffer(str, 'base64').toString('binary');
module.exports = atob
module.exports = atob

View File

@ -2,12 +2,14 @@ const test = require('tape');
const atob = require('./atob.js');
test('Testing atob', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof atob === 'function', 'atob is a Function');
//t.deepEqual(atob(args..), 'Expected');
//t.equal(atob(args..), 'Expected');
//t.false(atob(args..), 'Expected');
//t.throws(atob(args..), 'Expected');
t.end();
});
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof atob === 'function', 'atob is a Function');
t.equals(atob('Zm9vYmFy'), 'foobar', 'atob("Zm9vYmFy") equals "foobar"');
t.equals(atob('Z'), '', 'atob("Z") returns ""');
//t.deepEqual(atob(args..), 'Expected');
//t.equal(atob(args..), 'Expected');
//t.false(atob(args..), 'Expected');
//t.throws(atob(args..), 'Expected');
t.end();
});

View File

@ -1,2 +1,2 @@
const average = (...nums) => [...nums].reduce((acc, val) => acc + val, 0) / nums.length;
module.exports = average
module.exports = average

View File

@ -2,23 +2,23 @@ const test = require('tape');
const average = require('./average.js');
test('Testing average', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof average === 'function', 'average is a Function');
t.true(average(true) === 1, 'average(true) returns 0');
t.true(average(false) === 0, 'average(false) returns 1');
t.equal(average(9, 1), 5, 'average(9, 1) returns 5');
t.equal(average(153, 44, 55, 64, 71, 1122, 322774, 2232, 23423, 234, 3631), 32163.909090909092, 'average(153, 44, 55, 64, 71, 1122, 322774, 2232, 23423, 234, 3631) returns 32163.909090909092 ');
t.equal(average(1, 2, 3), 2, 'average(1, 2, 3) returns 2');
t.equal(average(153, 44, 55, 64, 71, 1122, 322774, 2232, 23423, 234, 3631), 32163.909090909092, 'average(153, 44, 55, 64, 71, 1122, 322774, 2232, 23423, 234, 3631) returns 32163.909090909092 ');
t.equal(average(1, 2, 3), 2, 'average(1, 2, 3) returns 2');
t.equal(average(null), 0, 'average(null) returns 0');
t.true(isNaN(average(undefined)), 'average(1, 2, 3) returns NaN');
t.true(isNaN(average('String')), 'average(String) returns NaN');
t.true(isNaN(average({ a: 123})), 'average({ a: 123}) returns NaN');
t.true(isNaN(average([undefined, 0, 'string'])), 'average([undefined, 0, string]) returns NaN');
t.true(isNaN(average(undefined)), 'average(1, 2, 3) returns NaN');
t.true(isNaN(average('String')), 'average(String) returns NaN');
t.true(isNaN(average({ a: 123})), 'average({ a: 123}) returns NaN');
t.true(isNaN(average([undefined, 0, 'string'])), 'average([undefined, 0, string]) returns NaN');
let start = new Date().getTime();
average(153, 44, 55, 64, 71, 1122, 322774, 2232, 23423, 234, 3631);
let end = new Date().getTime();
t.true((end - start) < 2000, 'head([1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 1122, 32124, 23232]) takes less than 2s to run');
t.end();
t.end();
});

View File

@ -1,4 +1,4 @@
const averageBy = (arr, fn) =>
arr.map(typeof fn === 'function' ? fn : val => val[fn]).reduce((acc, val) => acc + val, 0) /
arr.length;
module.exports = averageBy
module.exports = averageBy

View File

@ -2,12 +2,14 @@ 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();
});
//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.equals(averageBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }], o => o.n), 5, 'Produces the right result with a function');
t.equals(averageBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }], 'n'), 5, 'Produces the right result with a property name');
//t.deepEqual(averageBy(args..), 'Expected');
//t.equal(averageBy(args..), 'Expected');
//t.false(averageBy(args..), 'Expected');
//t.throws(averageBy(args..), 'Expected');
t.end();
});

View File

@ -5,4 +5,4 @@ if (arr[mid] > val) return binarySearch(arr, val, start, mid - 1);
if (arr[mid] < val) return binarySearch(arr, val, mid + 1, end);
return mid;
}
module.exports = binarySearch
module.exports = binarySearch

View File

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

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

@ -0,0 +1,5 @@
const bind = (fn, context, ...args) =>
function() {
return fn.apply(context, args.concat(...arguments));
};
module.exports = bind

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

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

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

@ -0,0 +1,5 @@
const bindKey = (context, fn, ...args) =>
function() {
return context[fn].apply(context, args.concat(...arguments));
};
module.exports = bindKey

View File

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

View File

@ -1,4 +1,4 @@
const bottomVisible = () =>
document.documentElement.clientHeight + window.scrollY >=
(document.documentElement.scrollHeight || document.documentElement.clientHeight);
module.exports = bottomVisible
module.exports = bottomVisible

View File

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

View File

@ -1,2 +1,2 @@
const btoa = str => new Buffer(str, 'binary').toString('base64');
module.exports = btoa
module.exports = btoa

View File

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

View File

@ -1,2 +1,2 @@
const byteSize = str => new Blob([str]).size;
module.exports = byteSize
module.exports = byteSize

View File

@ -2,14 +2,14 @@ const test = require('tape');
const byteSize = require('./byteSize.js');
test('Testing byteSize', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof byteSize === 'function', 'byteSize is a Function');
// Works only in browser
// t.equal(byteSize('Hello World'), 11, "Returns the length of a string in bytes");
//t.deepEqual(byteSize(args..), 'Expected');
//t.equal(byteSize(args..), 'Expected');
//t.false(byteSize(args..), 'Expected');
//t.throws(byteSize(args..), 'Expected');
t.end();
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof byteSize === 'function', 'byteSize is a Function');
// Works only in browser
// t.equal(byteSize('Hello World'), 11, "Returns the length of a string in bytes");
//t.deepEqual(byteSize(args..), 'Expected');
//t.equal(byteSize(args..), 'Expected');
//t.false(byteSize(args..), 'Expected');
//t.throws(byteSize(args..), 'Expected');
t.end();
});

View File

@ -1,2 +1,2 @@
const call = (key, ...args) => context => context[key](...args);
module.exports = call
module.exports = call

View File

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

View File

@ -1,3 +1,3 @@
const capitalize = ([first, ...rest], lowerRest = false) =>
first.toUpperCase() + (lowerRest ? rest.join('').toLowerCase() : rest.join(''));
module.exports = capitalize
module.exports = capitalize

View File

@ -2,14 +2,14 @@ const test = require('tape');
const capitalize = require('./capitalize.js');
test('Testing capitalize', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof capitalize === 'function', 'capitalize is a Function');
t.equal(capitalize('fooBar'), 'FooBar', "Capitalizes the first letter of a string");
t.equal(capitalize('fooBar', true), 'Foobar', "Capitalizes the first letter of a string");
//t.deepEqual(capitalize(args..), 'Expected');
//t.equal(capitalize(args..), 'Expected');
//t.false(capitalize(args..), 'Expected');
//t.throws(capitalize(args..), 'Expected');
t.end();
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof capitalize === 'function', 'capitalize is a Function');
t.equal(capitalize('fooBar'), 'FooBar', "Capitalizes the first letter of a string");
t.equal(capitalize('fooBar', true), 'Foobar', "Capitalizes the first letter of a string");
//t.deepEqual(capitalize(args..), 'Expected');
//t.equal(capitalize(args..), 'Expected');
//t.false(capitalize(args..), 'Expected');
//t.throws(capitalize(args..), 'Expected');
t.end();
});

View File

@ -1,2 +1,2 @@
const capitalizeEveryWord = str => str.replace(/\b[a-z]/g, char => char.toUpperCase());
module.exports = capitalizeEveryWord
module.exports = capitalizeEveryWord

View File

@ -2,13 +2,13 @@ const test = require('tape');
const capitalizeEveryWord = require('./capitalizeEveryWord.js');
test('Testing capitalizeEveryWord', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof capitalizeEveryWord === 'function', 'capitalizeEveryWord is a Function');
t.equal(capitalizeEveryWord('hello world!'), 'Hello World!', "Capitalizes the first letter of every word in a string");
//t.deepEqual(capitalizeEveryWord(args..), 'Expected');
//t.equal(capitalizeEveryWord(args..), 'Expected');
//t.false(capitalizeEveryWord(args..), 'Expected');
//t.throws(capitalizeEveryWord(args..), 'Expected');
t.end();
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof capitalizeEveryWord === 'function', 'capitalizeEveryWord is a Function');
t.equal(capitalizeEveryWord('hello world!'), 'Hello World!', "Capitalizes the first letter of every word in a string");
//t.deepEqual(capitalizeEveryWord(args..), 'Expected');
//t.equal(capitalizeEveryWord(args..), 'Expected');
//t.false(capitalizeEveryWord(args..), 'Expected');
//t.throws(capitalizeEveryWord(args..), 'Expected');
t.end();
});

View File

@ -0,0 +1,2 @@
const castArray = val => (Array.isArray(val) ? val : [val]);
module.exports = castArray

View File

@ -0,0 +1,18 @@
const test = require('tape');
const castArray = require('./castArray.js');
test('Testing castArray', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof castArray === 'function', 'castArray is a Function');
t.deepEqual(castArray(1), [1], 'Works for single values');
t.deepEqual(castArray([1]), [1], 'Works for arrays with one value');
t.deepEqual(castArray([1,2,3]), [1,2,3], 'Works for arrays with multiple value');
t.deepEqual(castArray('test'), ['test'], 'Works for strings');
t.deepEqual(castArray({}), [{}], 'Works for objects');
//t.deepEqual(castArray(args..), 'Expected');
//t.equal(castArray(args..), 'Expected');
//t.false(castArray(args..), 'Expected');
//t.throws(castArray(args..), 'Expected');
t.end();
});

View File

@ -3,4 +3,4 @@ let curr = 0;
const next = () => fns[curr++](next);
next();
};
module.exports = chainAsync
module.exports = chainAsync

View File

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

View File

@ -2,4 +2,4 @@ const chunk = (arr, size) =>
Array.from({ length: Math.ceil(arr.length / size) }, (v, i) =>
arr.slice(i * size, i * size + size)
);
module.exports = chunk
module.exports = chunk

View File

@ -2,11 +2,11 @@ const test = require('tape');
const chunk = require('./chunk.js');
test('Testing chunk', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof chunk === 'function', 'chunk is a Function');
t.deepEqual(chunk([1, 2, 3, 4, 5], 2), [[1,2],[3,4],[5]], "chunk([1, 2, 3, 4, 5], 2) returns [[1,2],[3,4],[5]] ");
t.deepEqual(chunk([]), [], 'chunk([]) returns []');
t.deepEqual(chunk([1, 2, 3, 4, 5], 2), [[1,2],[3,4],[5]], "chunk([1, 2, 3, 4, 5], 2) returns [[1,2],[3,4],[5]] ");
t.deepEqual(chunk([]), [], 'chunk([]) returns []');
t.deepEqual(chunk(123), [], 'chunk(123) returns []');
t.deepEqual(chunk({ a: 123}), [], 'chunk({ a: 123}) returns []');
t.deepEqual(chunk('string', 2), [ 'st', 'ri', 'ng' ], 'chunk(string, 2) returns [ st, ri, ng ]');

View File

@ -1,2 +1,2 @@
const clampNumber = (num, a, b) => Math.max(Math.min(num, Math.max(a, b)), Math.min(a, b));
module.exports = clampNumber
module.exports = clampNumber

View File

@ -2,13 +2,13 @@ const test = require('tape');
const clampNumber = require('./clampNumber.js');
test('Testing clampNumber', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof clampNumber === 'function', 'clampNumber is a Function');
t.equal(clampNumber(2, 3, 5), 3, "Clamps num within the inclusive range specified by the boundary values a and b");
//t.deepEqual(clampNumber(args..), 'Expected');
//t.equal(clampNumber(args..), 'Expected');
//t.false(clampNumber(args..), 'Expected');
//t.throws(clampNumber(args..), 'Expected');
t.end();
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof clampNumber === 'function', 'clampNumber is a Function');
t.equal(clampNumber(2, 3, 5), 3, "Clamps num within the inclusive range specified by the boundary values a and b");
//t.deepEqual(clampNumber(args..), 'Expected');
//t.equal(clampNumber(args..), 'Expected');
//t.false(clampNumber(args..), 'Expected');
//t.throws(clampNumber(args..), 'Expected');
t.end();
});

View File

@ -8,4 +8,4 @@ delete obj[key];
});
return obj;
};
module.exports = cleanObj
module.exports = cleanObj

View File

@ -2,14 +2,14 @@ const test = require('tape');
const cleanObj = require('./cleanObj.js');
test('Testing cleanObj', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof cleanObj === 'function', 'cleanObj is a Function');
const testObj = { a: 1, b: 2, children: { a: 1, b: 2 } };
t.deepEqual(cleanObj(testObj, ['a'], 'children'), { a: 1, children : { a: 1}}, "Removes any properties except the ones specified from a JSON object");
//t.deepEqual(cleanObj(args..), 'Expected');
//t.equal(cleanObj(args..), 'Expected');
//t.false(cleanObj(args..), 'Expected');
//t.throws(cleanObj(args..), 'Expected');
t.end();
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof cleanObj === 'function', 'cleanObj is a Function');
const testObj = { a: 1, b: 2, children: { a: 1, b: 2 } };
t.deepEqual(cleanObj(testObj, ['a'], 'children'), { a: 1, children : { a: 1}}, "Removes any properties except the ones specified from a JSON object");
//t.deepEqual(cleanObj(args..), 'Expected');
//t.equal(cleanObj(args..), 'Expected');
//t.false(cleanObj(args..), 'Expected');
//t.throws(cleanObj(args..), 'Expected');
t.end();
});

View File

@ -1,2 +1,2 @@
const cloneRegExp = regExp => new RegExp(regExp.source, regExp.flags);
module.exports = cloneRegExp
module.exports = cloneRegExp

View File

@ -2,12 +2,14 @@ const test = require('tape');
const cloneRegExp = require('./cloneRegExp.js');
test('Testing cloneRegExp', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof cloneRegExp === 'function', 'cloneRegExp is a Function');
//t.deepEqual(cloneRegExp(args..), 'Expected');
//t.equal(cloneRegExp(args..), 'Expected');
//t.false(cloneRegExp(args..), 'Expected');
//t.throws(cloneRegExp(args..), 'Expected');
t.end();
});
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof cloneRegExp === 'function', 'cloneRegExp is a Function');
const rgTest = /./g;
t.notEqual(cloneRegExp(rgTest), rgTest, 'Clones regular expressions properly');
//t.deepEqual(cloneRegExp(args..), 'Expected');
//t.equal(cloneRegExp(args..), 'Expected');
//t.false(cloneRegExp(args..), 'Expected');
//t.throws(cloneRegExp(args..), 'Expected');
t.end();
});

View File

@ -1,2 +1,2 @@
const coalesce = (...args) => args.find(_ => ![undefined, null].includes(_));
module.exports = coalesce
module.exports = coalesce

View File

@ -2,13 +2,13 @@ const test = require('tape');
const coalesce = require('./coalesce.js');
test('Testing coalesce', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof coalesce === 'function', 'coalesce is a Function');
t.deepEqual(coalesce(null, undefined, '', NaN, 'Waldo'), '', "Returns the first non-null/undefined argument");
//t.deepEqual(coalesce(args..), 'Expected');
//t.equal(coalesce(args..), 'Expected');
//t.false(coalesce(args..), 'Expected');
//t.throws(coalesce(args..), 'Expected');
t.end();
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof coalesce === 'function', 'coalesce is a Function');
t.deepEqual(coalesce(null, undefined, '', NaN, 'Waldo'), '', "Returns the first non-null/undefined argument");
//t.deepEqual(coalesce(args..), 'Expected');
//t.equal(coalesce(args..), 'Expected');
//t.false(coalesce(args..), 'Expected');
//t.throws(coalesce(args..), 'Expected');
t.end();
});

View File

@ -1,2 +1,2 @@
const coalesceFactory = valid => (...args) => args.find(valid);
module.exports = coalesceFactory
module.exports = coalesceFactory

View File

@ -2,14 +2,14 @@ const test = require('tape');
const coalesceFactory = require('./coalesceFactory.js');
test('Testing coalesceFactory', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof coalesceFactory === 'function', 'coalesceFactory is a Function');
const customCoalesce = coalesceFactory(_ => ![null, undefined, '', NaN].includes(_));
t.deepEqual(customCoalesce(undefined, null, NaN, '', 'Waldo'), 'Waldo', "Returns a customized coalesce function");
//t.deepEqual(coalesceFactory(args..), 'Expected');
//t.equal(coalesceFactory(args..), 'Expected');
//t.false(coalesceFactory(args..), 'Expected');
//t.throws(coalesceFactory(args..), 'Expected');
t.end();
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof coalesceFactory === 'function', 'coalesceFactory is a Function');
const customCoalesce = coalesceFactory(_ => ![null, undefined, '', NaN].includes(_));
t.deepEqual(customCoalesce(undefined, null, NaN, '', 'Waldo'), 'Waldo', "Returns a customized coalesce function");
//t.deepEqual(coalesceFactory(args..), 'Expected');
//t.equal(coalesceFactory(args..), 'Expected');
//t.false(coalesceFactory(args..), 'Expected');
//t.throws(coalesceFactory(args..), 'Expected');
t.end();
});

View File

@ -1,2 +1,2 @@
const collatz = n => (n % 2 == 0 ? n / 2 : 3 * n + 1);
module.exports = collatz
module.exports = collatz

View File

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

View File

@ -1,2 +1,2 @@
const collectInto = fn => (...args) => fn(args);
module.exports = collectInto
module.exports = collectInto

View File

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

View File

@ -16,4 +16,4 @@ bgMagenta: `\x1b[45m${args.join(' ')}\x1b[0m`,
bgCyan: `\x1b[46m${args.join(' ')}\x1b[0m`,
bgWhite: `\x1b[47m${args.join(' ')}\x1b[0m`
});
module.exports = colorize
module.exports = colorize

View File

@ -2,12 +2,12 @@ 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();
//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();
});

View File

@ -1,2 +1,2 @@
const compact = arr => arr.filter(Boolean);
module.exports = compact
module.exports = compact

View File

@ -2,13 +2,13 @@ const test = require('tape');
const compact = require('./compact.js');
test('Testing compact', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof compact === 'function', 'compact is a Function');
t.deepEqual(compact([0, 1, false, 2, '', 3, 'a', 'e' * 23, NaN, 's', 34]), [ 1, 2, 3, 'a', 's', 34 ], "Removes falsey values from an array");
//t.deepEqual(compact(args..), 'Expected');
//t.equal(compact(args..), 'Expected');
//t.false(compact(args..), 'Expected');
//t.throws(compact(args..), 'Expected');
t.end();
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof compact === 'function', 'compact is a Function');
t.deepEqual(compact([0, 1, false, 2, '', 3, 'a', 'e' * 23, NaN, 's', 34]), [ 1, 2, 3, 'a', 's', 34 ], "Removes falsey values from an array");
//t.deepEqual(compact(args..), 'Expected');
//t.equal(compact(args..), 'Expected');
//t.false(compact(args..), 'Expected');
//t.throws(compact(args..), 'Expected');
t.end();
});

View File

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

View File

@ -2,16 +2,16 @@ const test = require('tape');
const compose = require('./compose.js');
test('Testing compose', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof compose === 'function', 'compose is a Function');
const add5 = x => x + 5;
const multiply = (x, y) => x * y;
const multiplyAndAdd5 = compose(add5, multiply);
t.equal(multiplyAndAdd5(5, 2), 15, "Performs right-to-left function composition");
//t.deepEqual(compose(args..), 'Expected');
//t.equal(compose(args..), 'Expected');
//t.false(compose(args..), 'Expected');
//t.throws(compose(args..), 'Expected');
t.end();
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof compose === 'function', 'compose is a Function');
const add5 = x => x + 5;
const multiply = (x, y) => x * y;
const multiplyAndAdd5 = compose(add5, multiply);
t.equal(multiplyAndAdd5(5, 2), 15, "Performs right-to-left function composition");
//t.deepEqual(compose(args..), 'Expected');
//t.equal(compose(args..), 'Expected');
//t.false(compose(args..), 'Expected');
//t.throws(compose(args..), 'Expected');
t.end();
});

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,17 @@
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');
const add = (x, y) => x + y;
const square = x => x * x;
const addAndSquare = composeRight(add, square);
t.equal(addAndSquare(1, 2), 9, "Performs left-to-right function composition");
//t.deepEqual(composeRight(args..), 'Expected');
//t.equal(composeRight(args..), 'Expected');
//t.false(composeRight(args..), 'Expected');
//t.throws(composeRight(args..), 'Expected');
t.end();
});

View File

@ -15,4 +15,4 @@ document.getSelection().removeAllRanges();
document.getSelection().addRange(selected);
}
};
module.exports = copyToClipboard
module.exports = copyToClipboard

View File

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

View File

@ -3,4 +3,4 @@ arr.map(typeof fn === 'function' ? fn : val => val[fn]).reduce((acc, val, i) =>
acc[val] = (acc[val] || 0) + 1;
return acc;
}, {});
module.exports = countBy
module.exports = countBy

View File

@ -2,12 +2,12 @@ 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();
//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();
});

View File

@ -1,2 +1,2 @@
const countOccurrences = (arr, val) => arr.reduce((a, v) => (v === val ? a + 1 : a + 0), 0);
module.exports = countOccurrences
module.exports = countOccurrences

View File

@ -2,13 +2,13 @@ const test = require('tape');
const countOccurrences = require('./countOccurrences.js');
test('Testing countOccurrences', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof countOccurrences === 'function', 'countOccurrences is a Function');
t.deepEqual(countOccurrences([1, 1, 2, 1, 2, 3], 1), 3, "Counts the occurrences of a value in an array");
//t.deepEqual(countOccurrences(args..), 'Expected');
//t.equal(countOccurrences(args..), 'Expected');
//t.false(countOccurrences(args..), 'Expected');
//t.throws(countOccurrences(args..), 'Expected');
t.end();
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof countOccurrences === 'function', 'countOccurrences is a Function');
t.deepEqual(countOccurrences([1, 1, 2, 1, 2, 3], 1), 3, "Counts the occurrences of a value in an array");
//t.deepEqual(countOccurrences(args..), 'Expected');
//t.equal(countOccurrences(args..), 'Expected');
//t.false(countOccurrences(args..), 'Expected');
//t.throws(countOccurrences(args..), 'Expected');
t.end();
});

View File

@ -1,2 +1,2 @@
const countVowels = str => (str.match(/[aeiou]/gi) || []).length;
module.exports = countVowels
module.exports = countVowels

View File

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

View File

@ -3,4 +3,4 @@ const el = document.createElement('div');
el.innerHTML = str;
return el.firstElementChild;
};
module.exports = createElement
module.exports = createElement

View File

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

View File

@ -12,4 +12,4 @@ const i = (this.hub[event] || []).findIndex(h => h === handler);
if (i > -1) this.hub[event].splice(i, 1);
}
});
module.exports = createEventHub
module.exports = createEventHub

View File

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

View File

@ -1,2 +1,2 @@
const currentURL = () => window.location.href;
module.exports = currentURL
module.exports = currentURL

View File

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

View File

@ -1,3 +1,3 @@
const curry = (fn, arity = fn.length, ...args) =>
arity <= args.length ? fn(...args) : curry.bind(null, fn, arity, ...args);
module.exports = curry
module.exports = curry

View File

@ -2,14 +2,14 @@ const test = require('tape');
const curry = require('./curry.js');
test('Testing curry', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof curry === 'function', 'curry is a Function');
t.equal(curry(Math.pow)(2)(10), 1024, "curries a Math.pow");
t.equal(curry(Math.min, 3)(10)(50)(2), 2, "curries a Math.min");
//t.deepEqual(curry(args..), 'Expected');
//t.equal(curry(args..), 'Expected');
//t.false(curry(args..), 'Expected');
//t.throws(curry(args..), 'Expected');
t.end();
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof curry === 'function', 'curry is a Function');
t.equal(curry(Math.pow)(2)(10), 1024, "curries a Math.pow");
t.equal(curry(Math.min, 3)(10)(50)(2), 2, "curries a Math.min");
//t.deepEqual(curry(args..), 'Expected');
//t.equal(curry(args..), 'Expected');
//t.false(curry(args..), 'Expected');
//t.throws(curry(args..), 'Expected');
t.end();
});

View File

@ -1,3 +1,3 @@
const decapitalize = ([first, ...rest], upperRest = false) =>
first.toLowerCase() + (upperRest ? rest.join('').toUpperCase() : rest.join(''));
module.exports = decapitalize
module.exports = decapitalize

View File

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

View File

@ -0,0 +1,8 @@
const deepClone = obj => {
let clone = Object.assign({}, obj);
Object.keys(clone).forEach(
key => (clone[key] = typeof obj[key] === 'object' ? deepClone(obj[key]) : obj[key])
);
return clone;
};
module.exports = deepClone

View File

@ -0,0 +1,17 @@
const test = require('tape');
const deepClone = require('./deepClone.js');
test('Testing deepClone', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof deepClone === 'function', 'deepClone is a Function');
const a = { foo: 'bar', obj: { a: 1, b: 2 } };
const b = deepClone(a);
t.notEqual(a, b, 'Shallow cloning works');
t.notEqual(a.obj, b.obj, 'Deep cloning works');
//t.deepEqual(deepClone(args..), 'Expected');
//t.equal(deepClone(args..), 'Expected');
//t.false(deepClone(args..), 'Expected');
//t.throws(deepClone(args..), 'Expected');
t.end();
});

View File

@ -1,2 +1,2 @@
const deepFlatten = arr => [].concat(...arr.map(v => (Array.isArray(v) ? deepFlatten(v) : v)));
module.exports = deepFlatten
module.exports = deepFlatten

View File

@ -2,13 +2,13 @@ const test = require('tape');
const deepFlatten = require('./deepFlatten.js');
test('Testing deepFlatten', (t) => {
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof deepFlatten === 'function', 'deepFlatten is a Function');
t.deepEqual(deepFlatten([1, [2], [[3], 4], 5]), [1, 2, 3, 4, 5], "Deep flattens an array");
//t.deepEqual(deepFlatten(args..), 'Expected');
//t.equal(deepFlatten(args..), 'Expected');
//t.false(deepFlatten(args..), 'Expected');
//t.throws(deepFlatten(args..), 'Expected');
t.end();
//For more information on all the methods supported by tape
//Please go to https://github.com/substack/tape
t.true(typeof deepFlatten === 'function', 'deepFlatten is a Function');
t.deepEqual(deepFlatten([1, [2], [[3], 4], 5]), [1, 2, 3, 4, 5], "Deep flattens an array");
//t.deepEqual(deepFlatten(args..), 'Expected');
//t.equal(deepFlatten(args..), 'Expected');
//t.false(deepFlatten(args..), 'Expected');
//t.throws(deepFlatten(args..), 'Expected');
t.end();
});

View File

@ -0,0 +1,2 @@
const defaults = (obj, ...defs) => Object.assign({}, obj, ...defs.reverse(), obj);
module.exports = defaults

View File

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

View File

@ -1,2 +1,2 @@
const defer = (fn, ...args) => setTimeout(fn, 1, ...args);
module.exports = defer
module.exports = defer

View File

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

2
test/delay/delay.js Normal file
View File

@ -0,0 +1,2 @@
const delay = (fn, wait, ...args) => setTimeout(fn, wait, ...args);
module.exports = delay

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

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

View File

@ -2,4 +2,4 @@ const detectDeviceType = () =>
/Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent)
? 'Mobile'
: 'Desktop';
module.exports = detectDeviceType
module.exports = detectDeviceType

Some files were not shown because too many files have changed in this diff Show More