Updated the test system

This commit is contained in:
Angelos Chalaris
2018-10-10 23:36:17 +03:00
parent 0f334e1431
commit 1edaed51e4
725 changed files with 385 additions and 2332 deletions

View File

@ -14,79 +14,38 @@ if (util.isTravisCI() && util.isNotTravisCronOrAPI()) {
process.exit(0);
}
// Declare paths
const SNIPPETS_ACTIVE = './snippets';
const SNIPPETS_ARCHIVE = './snippets_archive';
const SNIPPETS_PATH = './snippets';
const SNIPPETS_ARCHIVE_PATH = './snippets_archive';
const TEST_PATH = './test';
// Array of snippet names
const snippetFiles = [];
const snippetFilesActive = fs
.readdirSync(SNIPPETS_ACTIVE, 'utf8')
.map(fileName => fileName.slice(0, -3));
const snippetFilesArchive = fs
.readdirSync(SNIPPETS_ARCHIVE, 'utf8')
.filter(fileName => !fileName.includes('README')) // -> Filters out main README.md file in Archieve which isn't a snippet
.map(fileName => fileName.slice(0, -3));
snippetFiles.push(...snippetFilesActive);
snippetFiles.push(...snippetFilesArchive);
console.time('Tester');
snippetFiles
.map(fileName => {
// Check if fileName for snippet exist in test/ dir, if doesnt create
fs.ensureDirSync(path.join(TEST_PATH, fileName));
// return fileName for later use
return fileName;
try {
// Read snippets, archive and tests, find which tests are not defined
const snippets = fs.readdirSync(SNIPPETS_PATH).map(v => v.replace('.md', ''));
const archivedSnippets = fs.readdirSync(SNIPPETS_ARCHIVE_PATH).filter(v => v !== 'README.md').map(v => v.replace('.md', ''));
const definedTests = fs.readdirSync(TEST_PATH).map(v => v.replace('.test.js', '')).filter(v => v !== '_30s.js' && v !== 'testlog');
const undefinedTests = [...snippets, ...archivedSnippets].filter(v => !definedTests.includes(v));
const orphanedTests = [...definedTests.filter(v => ![...snippets, ...archivedSnippets].includes(v))];
orphanedTests.forEach(snippet => {
console.log(`${chalk.yellow('WARNING!')} Orphaned test: ${snippet}`);
})
.map(fileName => {
const activeOrArchive = snippetFilesActive.includes(fileName)
? SNIPPETS_ACTIVE
: SNIPPETS_ARCHIVE;
// Grab snippetData
const fileData = fs.readFileSync(path.join(activeOrArchive, `${fileName}.md`), 'utf8');
// Grab snippet Code blocks
const fileCode = fileData.slice(fileData.search(/```\s*js/i), fileData.lastIndexOf('```') + 3);
// Split code based on code markers
const blockMarkers = fileCode
.split('\n')
.map((line, lineIndex) => (line.slice(0, 3) === '```' ? lineIndex : '//CLEAR//'))
.filter(x => !(x === '//CLEAR//'));
// Grab snippet function based on code markers
const fileFunction = fileCode
.split('\n')
.map(line => line)
.filter((_, i) => blockMarkers[0] < i && i < blockMarkers[1]);
// Export template for snippetName.js
const exportFile = `${fileFunction.join('\n')}\nmodule.exports = ${fileName};\n`;
// Export template for snippetName.test.js which generates a example test & other information
// Create files for undefined tests
undefinedTests.forEach(snippet => {
const exportTest = [
`const expect = require('expect');`,
`const ${fileName} = require('./${fileName}.js');`,
`\ntest('${fileName} is a Function', () => {`,
` expect(${fileName}).toBeInstanceOf(Function);`,
`const {${snippet}} = require('._30s.js');`,
`\ntest('${snippet} is a Function', () => {`,
` expect(${snippet}).toBeInstanceOf(Function);`,
`});\n`
].join('\n');
// Write/Update exportFile which is snippetName.js in respective dir
fs.writeFileSync(path.join(TEST_PATH, fileName, `${fileName}.js`), exportFile);
if (!fs.existsSync(path.join(TEST_PATH, fileName, `${fileName}.test.js`))) {
// if snippetName.test.js doesn't exist inrespective dir exportTest
fs.writeFileSync(`${TEST_PATH}/${fileName}/${fileName}.test.js`, exportTest);
}
// return fileName for later use
return fileName;
fs.writeFileSync(path.join(TEST_PATH, `${snippet}.test.js`), exportTest);
});
try {
// Run tests
fs.writeFileSync(path.join(TEST_PATH, 'testlog'), `Test log for: ${new Date().toString()}\n`);
childProcess.execSync('npm test');
} catch (e) {
fs.appendFileSync(path.join(TEST_PATH, 'testlog'));
console.log(`${chalk.green('SUCCESS!')} All tests ran successfully!`);
} catch (err) {
console.log(`${chalk.red('ERROR!')} During test runs: ${err}`);
process.exit(1);
}
console.timeEnd('Tester');

View File

@ -1,5 +1,5 @@
const expect = require('expect');
const CSVToArray = require('./CSVToArray.js');
const {CSVToArray} = require('./_30s.js');
test('CSVToArray is a Function', () => {
expect(CSVToArray).toBeInstanceOf(Function);

View File

@ -1,6 +0,0 @@
const CSVToArray = (data, delimiter = ',', omitFirstRow = false) =>
data
.slice(omitFirstRow ? data.indexOf('\n') + 1 : 0)
.split('\n')
.map(v => v.split(delimiter));
module.exports = CSVToArray;

View File

@ -1,5 +1,5 @@
const expect = require('expect');
const CSVToJSON = require('./CSVToJSON.js');
const {CSVToJSON} = require('./_30s.js');
test('CSVToJSON is a Function', () => {
expect(CSVToJSON).toBeInstanceOf(Function);

View File

@ -1,11 +0,0 @@
const CSVToJSON = (data, delimiter = ',') => {
const titles = data.slice(0, data.indexOf('\n')).split(delimiter);
return data
.slice(data.indexOf('\n') + 1)
.split('\n')
.map(v => {
const values = v.split(delimiter);
return titles.reduce((obj, title, index) => ((obj[title] = values[index]), obj), {});
});
};
module.exports = CSVToJSON;

View File

@ -1,5 +1,5 @@
const expect = require('expect');
const JSONToDate = require('./JSONToDate.js');
const {JSONToDate} = require('./_30s.js');
test('JSONToDate is a Function', () => {
expect(JSONToDate).toBeInstanceOf(Function);

View File

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

View File

@ -1,5 +1,5 @@
const expect = require('expect');
const JSONToFile = require('./JSONToFile.js');
const {JSONToFile} = require('./_30s.js');
test('JSONToFile is a Function', () => {
expect(JSONToFile).toBeInstanceOf(Function);

View File

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

View File

@ -1,5 +1,5 @@
const expect = require('expect');
const JSONtoCSV = require('./JSONtoCSV.js');
const {JSONtoCSV} = require('./_30s.js');
test('JSONtoCSV is a Function', () => {
expect(JSONtoCSV).toBeInstanceOf(Function);

View File

@ -1,11 +0,0 @@
const JSONtoCSV = (arr, columns, delimiter = ',') =>
[
columns.join(delimiter),
...arr.map(obj =>
columns.reduce(
(acc, key) => `${acc}${!acc.length ? '' : delimiter}"${!obj[key] ? '' : obj[key]}"`,
''
)
)
].join('\n');
module.exports = JSONtoCSV;

View File

@ -1,5 +1,5 @@
const expect = require('expect');
const RGBToHex = require('./RGBToHex.js');
const {RGBToHex} = require('./_30s.js');
test('RGBToHex is a Function', () => {
expect(RGBToHex).toBeInstanceOf(Function);

View File

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

View File

@ -1,5 +1,5 @@
const expect = require('expect');
const URLJoin = require('./URLJoin.js');
const {URLJoin} = require('./_30s.js');
test('URLJoin is a Function', () => {
expect(URLJoin).toBeInstanceOf(Function);

View File

@ -1,10 +0,0 @@
const URLJoin = (...args) =>
args
.join('/')
.replace(/[\/]+/g, '/')
.replace(/^(.+):\//, '$1://')
.replace(/^file:/, 'file:/')
.replace(/\/(\?|&|#[^!])/g, '$1')
.replace(/\?/g, '&')
.replace('&', '?');
module.exports = URLJoin;

View File

@ -1,5 +1,5 @@
const expect = require('expect');
const UUIDGeneratorBrowser = require('./UUIDGeneratorBrowser.js');
const {UUIDGeneratorBrowser} = require('./_30s.js');
test('UUIDGeneratorBrowser is a Function', () => {
expect(UUIDGeneratorBrowser).toBeInstanceOf(Function);

View File

@ -1,5 +0,0 @@
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;

View File

@ -1,5 +1,5 @@
const expect = require('expect');
const UUIDGeneratorNode = require('./UUIDGeneratorNode.js');
const {UUIDGeneratorNode} = require('./_30s.js');
test('UUIDGeneratorNode is a Function', () => {
expect(UUIDGeneratorNode).toBeInstanceOf(Function);

View File

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

View File

@ -1,5 +1,5 @@
const expect = require('expect');
const all = require('./all.js');
const {all} = require('./_30s.js');
test('all is a Function', () => {
expect(all).toBeInstanceOf(Function);

View File

@ -1,2 +0,0 @@
const all = (arr, fn = Boolean) => arr.every(fn);
module.exports = all;

View File

@ -1,5 +1,5 @@
const expect = require('expect');
const allEqual = require('./allEqual.js');
const {allEqual} = require('./_30s.js');
test('allEqual is a Function', () => {
expect(allEqual).toBeInstanceOf(Function);

View File

@ -1,2 +0,0 @@
const allEqual = arr => arr.every(val => val === arr[0]);
module.exports = allEqual;

View File

@ -1,5 +1,5 @@
const expect = require('expect');
const any = require('./any.js');
const {any} = require('./_30s.js');
test('any is a Function', () => {
expect(any).toBeInstanceOf(Function);

View File

@ -1,2 +0,0 @@
const any = (arr, fn = Boolean) => arr.some(fn);
module.exports = any;

View File

@ -1,5 +1,5 @@
const expect = require('expect');
const approximatelyEqual = require('./approximatelyEqual.js');
const {approximatelyEqual} = require('./_30s.js');
test('approximatelyEqual is a Function', () => {
expect(approximatelyEqual).toBeInstanceOf(Function);

View File

@ -1,2 +0,0 @@
const approximatelyEqual = (v1, v2, epsilon = 0.001) => Math.abs(v1 - v2) < epsilon;
module.exports = approximatelyEqual;

View File

@ -1,5 +1,5 @@
const expect = require('expect');
const arrayToCSV = require('./arrayToCSV.js');
const {arrayToCSV} = require('./_30s.js');
test('arrayToCSV is a Function', () => {
expect(arrayToCSV).toBeInstanceOf(Function);

View File

@ -1,3 +0,0 @@
const arrayToCSV = (arr, delimiter = ',') =>
arr.map(v => v.map(x => `"${x}"`).join(delimiter)).join('\n');
module.exports = arrayToCSV;

View File

@ -1,5 +1,5 @@
const expect = require('expect');
const arrayToHtmlList = require('./arrayToHtmlList.js');
const {arrayToHtmlList} = require('./_30s.js');
test('arrayToHtmlList is a Function', () => {
expect(arrayToHtmlList).toBeInstanceOf(Function);

View File

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

View File

@ -1,5 +1,5 @@
const expect = require('expect');
const ary = require('./ary.js');
const {ary} = require('./_30s.js');
test('ary is a Function', () => {
expect(ary).toBeInstanceOf(Function);

View File

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

View File

@ -1,5 +1,5 @@
const expect = require('expect');
const atob = require('./atob.js');
const {atob} = require('./_30s.js');
test('atob is a Function', () => {
expect(atob).toBeInstanceOf(Function);

View File

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

View File

@ -1,5 +1,5 @@
const expect = require('expect');
const attempt = require('./attempt.js');
const {attempt} = require('./_30s.js');
test('attempt is a Function', () => {
expect(attempt).toBeInstanceOf(Function);

View File

@ -1,8 +0,0 @@
const attempt = (fn, ...args) => {
try {
return fn(...args);
} catch (e) {
return e instanceof Error ? e : new Error(e);
}
};
module.exports = attempt;

View File

@ -1,5 +1,5 @@
const expect = require('expect');
const average = require('./average.js');
const {average} = require('./_30s.js');
test('average is a Function', () => {
expect(average).toBeInstanceOf(Function);

View File

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

View File

@ -1,5 +1,5 @@
const expect = require('expect');
const averageBy = require('./averageBy.js');
const {averageBy} = require('./_30s.js');
test('averageBy is a Function', () => {
expect(averageBy).toBeInstanceOf(Function);

View File

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

View File

@ -1,5 +1,5 @@
const expect = require('expect');
const bifurcate = require('./bifurcate.js');
const {bifurcate} = require('./_30s.js');
test('bifurcate is a Function', () => {
expect(bifurcate).toBeInstanceOf(Function);

View File

@ -1,3 +0,0 @@
const bifurcate = (arr, filter) =>
arr.reduce((acc, val, i) => (acc[filter[i] ? 0 : 1].push(val), acc), [[], []]);
module.exports = bifurcate;

View File

@ -1,5 +1,5 @@
const expect = require('expect');
const bifurcateBy = require('./bifurcateBy.js');
const {bifurcateBy} = require('./_30s.js');
test('bifurcateBy is a Function', () => {
expect(bifurcateBy).toBeInstanceOf(Function);

View File

@ -1,3 +0,0 @@
const bifurcateBy = (arr, fn) =>
arr.reduce((acc, val, i) => (acc[fn(val, i) ? 0 : 1].push(val), acc), [[], []]);
module.exports = bifurcateBy;

View File

@ -1,5 +1,5 @@
const expect = require('expect');
const binarySearch = require('./binarySearch.js');
const {binarySearch} = require('./_30s.js');
test('binarySearch is a Function', () => {
expect(binarySearch).toBeInstanceOf(Function);

View File

@ -1,8 +0,0 @@
const binarySearch = (arr, val, start = 0, end = arr.length - 1) => {
if (start > end) return -1;
const mid = Math.floor((start + end) / 2);
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;

View File

@ -1,5 +1,5 @@
const expect = require('expect');
const bind = require('./bind.js');
const {bind} = require('./_30s.js');
test('bind is a Function', () => {
expect(bind).toBeInstanceOf(Function);

View File

@ -1,2 +0,0 @@
const bind = (fn, context, ...boundArgs) => (...args) => fn.apply(context, [...boundArgs, ...args]);
module.exports = bind;

View File

@ -1,5 +1,5 @@
const expect = require('expect');
const bindAll = require('./bindAll.js');
const {bindAll} = require('./_30s.js');
test('bindAll is a Function', () => {
expect(bindAll).toBeInstanceOf(Function);

View File

@ -1,10 +0,0 @@
const bindAll = (obj, ...fns) =>
fns.forEach(
fn => (
(f = obj[fn]),
(obj[fn] = function() {
return f.apply(obj);
})
)
);
module.exports = bindAll;

View File

@ -1,5 +1,5 @@
const expect = require('expect');
const bindKey = require('./bindKey.js');
const {bindKey} = require('./_30s.js');
test('bindKey is a Function', () => {
expect(bindKey).toBeInstanceOf(Function);

View File

@ -1,3 +0,0 @@
const bindKey = (context, fn, ...boundArgs) => (...args) =>
context[fn].apply(context, [...boundArgs, ...args]);
module.exports = bindKey;

View File

@ -1,5 +1,5 @@
const expect = require('expect');
const binomialCoefficient = require('./binomialCoefficient.js');
const {binomialCoefficient} = require('./_30s.js');
test('binomialCoefficient is a Function', () => {
expect(binomialCoefficient).toBeInstanceOf(Function);

View File

@ -1,11 +0,0 @@
const binomialCoefficient = (n, k) => {
if (Number.isNaN(n) || Number.isNaN(k)) return NaN;
if (k < 0 || k > n) return 0;
if (k === 0 || k === n) return 1;
if (k === 1 || k === n - 1) return n;
if (n - k < k) k = n - k;
let res = n;
for (let j = 2; j <= k; j++) res *= (n - j + 1) / j;
return Math.round(res);
};
module.exports = binomialCoefficient;

View File

@ -1,5 +1,5 @@
const expect = require('expect');
const bottomVisible = require('./bottomVisible.js');
const {bottomVisible} = require('./_30s.js');
test('bottomVisible is a Function', () => {
expect(bottomVisible).toBeInstanceOf(Function);

View File

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

View File

@ -1,5 +1,5 @@
const expect = require('expect');
const btoa = require('./btoa.js');
const {btoa} = require('./_30s.js');
test('btoa is a Function', () => {
expect(btoa).toBeInstanceOf(Function);

View File

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

View File

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

View File

@ -1,5 +1,5 @@
const expect = require('expect');
const call = require('./call.js');
const {call} = require('./_30s.js');
test('call is a Function', () => {
expect(call).toBeInstanceOf(Function);

View File

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

View File

@ -1,5 +1,5 @@
const expect = require('expect');
const capitalize = require('./capitalize.js');
const {capitalize} = require('./_30s.js');
test('capitalize is a Function', () => {
expect(capitalize).toBeInstanceOf(Function);

View File

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

View File

@ -1,5 +1,5 @@
const expect = require('expect');
const capitalizeEveryWord = require('./capitalizeEveryWord.js');
const {capitalizeEveryWord} = require('./_30s.js');
test('capitalizeEveryWord is a Function', () => {
expect(capitalizeEveryWord).toBeInstanceOf(Function);

View File

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

View File

@ -1,5 +1,5 @@
const expect = require('expect');
const castArray = require('./castArray.js');
const {castArray} = require('./_30s.js');
test('castArray is a Function', () => {
expect(castArray).toBeInstanceOf(Function);

View File

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

View File

@ -1,5 +1,5 @@
const expect = require('expect');
const chainAsync = require('./chainAsync.js');
const {chainAsync} = require('./_30s.js');
test('chainAsync is a Function', () => {
expect(chainAsync).toBeInstanceOf(Function);

View File

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

View File

@ -1,5 +1,5 @@
const expect = require('expect');
const chunk = require('./chunk.js');
const {chunk} = require('./_30s.js');
test('chunk is a Function', () => {
expect(chunk).toBeInstanceOf(Function);

View File

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

View File

@ -1,5 +1,5 @@
const expect = require('expect');
const clampNumber = require('./clampNumber.js');
const {clampNumber} = require('./_30s.js');
test('clampNumber is a Function', () => {
expect(clampNumber).toBeInstanceOf(Function);

View File

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

View File

@ -1,5 +1,5 @@
const expect = require('expect');
const cleanObj = require('./cleanObj.js');
const {cleanObj} = require('./_30s.js');
test('cleanObj is a Function', () => {
expect(cleanObj).toBeInstanceOf(Function);

View File

@ -1,11 +0,0 @@
const cleanObj = (obj, keysToKeep = [], childIndicator) => {
Object.keys(obj).forEach(key => {
if (key === childIndicator) {
cleanObj(obj[key], keysToKeep, childIndicator);
} else if (!keysToKeep.includes(key)) {
delete obj[key];
}
});
return obj;
};
module.exports = cleanObj;

View File

@ -1,5 +1,5 @@
const expect = require('expect');
const cloneRegExp = require('./cloneRegExp.js');
const {cloneRegExp} = require('./_30s.js');
test('cloneRegExp is a Function', () => {
expect(cloneRegExp).toBeInstanceOf(Function);

View File

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

View File

@ -1,5 +1,5 @@
const expect = require('expect');
const coalesce = require('./coalesce.js');
const {coalesce} = require('./_30s.js');
test('coalesce is a Function', () => {
expect(coalesce).toBeInstanceOf(Function);

View File

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

View File

@ -1,5 +1,5 @@
const expect = require('expect');
const coalesceFactory = require('./coalesceFactory.js');
const {coalesceFactory} = require('./_30s.js');
test('coalesceFactory is a Function', () => {
expect(coalesceFactory).toBeInstanceOf(Function);

View File

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

View File

@ -1,5 +1,5 @@
const expect = require('expect');
const collatz = require('./collatz.js');
const {collatz} = require('./_30s.js');
test('collatz is a Function', () => {
expect(collatz).toBeInstanceOf(Function);

View File

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

View File

@ -1,5 +1,5 @@
const expect = require('expect');
const collectInto = require('./collectInto.js');
const {collectInto} = require('./_30s.js');
test('collectInto is a Function', () => {
expect(collectInto).toBeInstanceOf(Function);

View File

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

View File

@ -1,5 +1,5 @@
const expect = require('expect');
const colorize = require('./colorize.js');
const {colorize} = require('./_30s.js');
test('colorize is a Function', () => {
expect(colorize).toBeInstanceOf(Function);

View File

@ -1,19 +0,0 @@
const 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`
});
module.exports = colorize;

View File

@ -1,5 +1,5 @@
const expect = require('expect');
const compact = require('./compact.js');
const {compact} = require('./_30s.js');
test('compact is a Function', () => {
expect(compact).toBeInstanceOf(Function);

View File

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

View File

@ -1,5 +1,5 @@
const expect = require('expect');
const compose = require('./compose.js');
const {compose} = require('./_30s.js');
test('compose is a Function', () => {
expect(compose).toBeInstanceOf(Function);

View File

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

View File

@ -1,5 +1,5 @@
const expect = require('expect');
const composeRight = require('./composeRight.js');
const {composeRight} = require('./_30s.js');
test('composeRight is a Function', () => {
expect(composeRight).toBeInstanceOf(Function);

View File

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

View File

@ -1,5 +1,5 @@
const expect = require('expect');
const converge = require('./converge.js');
const {converge} = require('./_30s.js');
test('converge is a Function', () => {
expect(converge).toBeInstanceOf(Function);

View File

@ -1,2 +0,0 @@
const converge = (converger, fns) => (...args) => converger(...fns.map(fn => fn.apply(null, args)));
module.exports = converge;

View File

@ -1,5 +1,5 @@
const expect = require('expect');
const copyToClipboard = require('./copyToClipboard.js');
const {copyToClipboard} = require('./_30s.js');
test('copyToClipboard is a Function', () => {
expect(copyToClipboard).toBeInstanceOf(Function);

View File

@ -1,18 +0,0 @@
const copyToClipboard = str => {
const el = document.createElement('textarea');
el.value = str;
el.setAttribute('readonly', '');
el.style.position = 'absolute';
el.style.left = '-9999px';
document.body.appendChild(el);
const selected =
document.getSelection().rangeCount > 0 ? document.getSelection().getRangeAt(0) : false;
el.select();
document.execCommand('copy');
document.body.removeChild(el);
if (selected) {
document.getSelection().removeAllRanges();
document.getSelection().addRange(selected);
}
};
module.exports = copyToClipboard;

View File

@ -1,5 +1,5 @@
const expect = require('expect');
const countBy = require('./countBy.js');
const {countBy} = require('./_30s.js');
test('countBy is a Function', () => {
expect(countBy).toBeInstanceOf(Function);

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