diff --git a/test/JSONToDate/JSONToDate.js b/test/JSONToDate/JSONToDate.js index bceb8129f..b22d17b2c 100644 --- a/test/JSONToDate/JSONToDate.js +++ b/test/JSONToDate/JSONToDate.js @@ -1,4 +1,5 @@ -module.exports = JSONToDate = arr => { +const JSONToDate = arr => { const dt = new Date(parseInt(arr.toString().substr(6))); return `${dt.getDate()}/${dt.getMonth() + 1}/${dt.getFullYear()}`; -}; \ No newline at end of file +}; + module.exports = JSONToDate \ No newline at end of file diff --git a/test/JSONToFile/JSONToFile.js b/test/JSONToFile/JSONToFile.js new file mode 100644 index 000000000..695fd5ecd --- /dev/null +++ b/test/JSONToFile/JSONToFile.js @@ -0,0 +1,4 @@ +const fs = require('fs'); +const JSONToFile = (obj, filename) => +fs.writeFile(`${filename}.json`, JSON.stringify(obj, null, 2)); + module.exports = JSONToFile \ No newline at end of file diff --git a/test/JSONToFile/JSONToFile.test.js b/test/JSONToFile/JSONToFile.test.js new file mode 100644 index 000000000..7dbfeaf94 --- /dev/null +++ b/test/JSONToFile/JSONToFile.test.js @@ -0,0 +1,13 @@ +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(); +}); \ No newline at end of file diff --git a/test/RGBToHex/RGBToHex.js b/test/RGBToHex/RGBToHex.js index a577b0b0f..1caaf7cd4 100644 --- a/test/RGBToHex/RGBToHex.js +++ b/test/RGBToHex/RGBToHex.js @@ -1 +1,2 @@ -module.exports = RGBToHex = (r, g, b) => ((r << 16) + (g << 8) + b).toString(16).padStart(6, '0'); \ No newline at end of file +const RGBToHex = (r, g, b) => ((r << 16) + (g << 8) + b).toString(16).padStart(6, '0'); + module.exports = RGBToHex \ No newline at end of file diff --git a/test/URLJoin/URLJoin.js b/test/URLJoin/URLJoin.js index 3093f2c26..0ba1bad9a 100644 --- a/test/URLJoin/URLJoin.js +++ b/test/URLJoin/URLJoin.js @@ -1,8 +1,10 @@ -module.exports = URLJoin = (...args) => -args.join('/') -.replace(/[\/]+/g,'/') -.replace(/^(.+):\//,'$1://') -.replace(/^file:/,'file:/') +const URLJoin = (...args) => +args +.join('/') +.replace(/[\/]+/g, '/') +.replace(/^(.+):\//, '$1://') +.replace(/^file:/, 'file:/') .replace(/\/(\?|&|#[^!])/g, '$1') -.replace(/\?/g,'&') -.replace('&','?'); \ No newline at end of file +.replace(/\?/g, '&') +.replace('&', '?'); + module.exports = URLJoin \ No newline at end of file diff --git a/test/UUIDGeneratorBrowser/UUIDGeneratorBrowser.js b/test/UUIDGeneratorBrowser/UUIDGeneratorBrowser.js index 4907d516b..78f421fef 100644 --- a/test/UUIDGeneratorBrowser/UUIDGeneratorBrowser.js +++ b/test/UUIDGeneratorBrowser/UUIDGeneratorBrowser.js @@ -1,4 +1,5 @@ -module.exports = UUIDGeneratorBrowser = () => +const UUIDGeneratorBrowser = () => ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c => (c ^ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4)))).toString(16) -); \ No newline at end of file +); + module.exports = UUIDGeneratorBrowser \ No newline at end of file diff --git a/test/UUIDGeneratorNode/UUIDGeneratorNode.js b/test/UUIDGeneratorNode/UUIDGeneratorNode.js new file mode 100644 index 000000000..956d887c3 --- /dev/null +++ b/test/UUIDGeneratorNode/UUIDGeneratorNode.js @@ -0,0 +1,6 @@ +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 \ No newline at end of file diff --git a/test/UUIDGeneratorNode/UUIDGeneratorNode.test.js b/test/UUIDGeneratorNode/UUIDGeneratorNode.test.js new file mode 100644 index 000000000..44b7040e1 --- /dev/null +++ b/test/UUIDGeneratorNode/UUIDGeneratorNode.test.js @@ -0,0 +1,13 @@ +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(); +}); \ No newline at end of file diff --git a/test/anagrams/anagrams.js b/test/anagrams/anagrams.js index 2ddf13855..2b31ca520 100644 --- a/test/anagrams/anagrams.js +++ b/test/anagrams/anagrams.js @@ -1,4 +1,4 @@ -module.exports = anagrams = str => { +const anagrams = str => { if (str.length <= 2) return str.length === 2 ? [str, str[1] + str[0]] : [str]; return str .split('') @@ -7,4 +7,5 @@ return str acc.concat(anagrams(str.slice(0, i) + str.slice(i + 1)).map(val => letter + val)), [] ); -}; \ No newline at end of file +}; + module.exports = anagrams \ No newline at end of file diff --git a/test/arrayToHtmlList/arrayToHtmlList.js b/test/arrayToHtmlList/arrayToHtmlList.js index a4f583bc1..e85f273e7 100644 --- a/test/arrayToHtmlList/arrayToHtmlList.js +++ b/test/arrayToHtmlList/arrayToHtmlList.js @@ -1,2 +1,3 @@ -module.exports = arrayToHtmlList = (arr, listID) => -arr.map(item => (document.querySelector('#' + listID).innerHTML += `
  • ${item}
  • `)); \ No newline at end of file +const arrayToHtmlList = (arr, listID) => +arr.map(item => (document.querySelector('#' + listID).innerHTML += `
  • ${item}
  • `)); + module.exports = arrayToHtmlList \ No newline at end of file diff --git a/test/average/average.js b/test/average/average.js index 5c4ce8ac9..4f414ff98 100644 --- a/test/average/average.js +++ b/test/average/average.js @@ -1 +1,2 @@ -module.exports = average = (...nums) => [...nums].reduce((acc, val) => acc + val, 0) / nums.length; \ No newline at end of file +const average = (...nums) => [...nums].reduce((acc, val) => acc + val, 0) / nums.length; + module.exports = average \ No newline at end of file diff --git a/test/averageBy/averageBy.js b/test/averageBy/averageBy.js index 510263fa7..5e8bb3a27 100644 --- a/test/averageBy/averageBy.js +++ b/test/averageBy/averageBy.js @@ -1,3 +1,4 @@ -module.exports = averageBy = (arr, fn) => +const averageBy = (arr, fn) => arr.map(typeof fn === 'function' ? fn : val => val[fn]).reduce((acc, val) => acc + val, 0) / -arr.length; \ No newline at end of file +arr.length; + module.exports = averageBy \ No newline at end of file diff --git a/test/binarySearch/binarySearch.js b/test/binarySearch/binarySearch.js index b23a47a1b..b34d667bf 100644 --- a/test/binarySearch/binarySearch.js +++ b/test/binarySearch/binarySearch.js @@ -1,7 +1,8 @@ -module.exports = binarySearch = (arr, val, start = 0, end = arr.length - 1) => { +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; -} \ No newline at end of file +} + module.exports = binarySearch \ No newline at end of file diff --git a/test/bottomVisible/bottomVisible.js b/test/bottomVisible/bottomVisible.js index 8f58bf6ae..abf32b046 100644 --- a/test/bottomVisible/bottomVisible.js +++ b/test/bottomVisible/bottomVisible.js @@ -1,3 +1,4 @@ -module.exports = bottomVisible = () => +const bottomVisible = () => document.documentElement.clientHeight + window.scrollY >= -(document.documentElement.scrollHeight || document.documentElement.clientHeight); \ No newline at end of file +(document.documentElement.scrollHeight || document.documentElement.clientHeight); + module.exports = bottomVisible \ No newline at end of file diff --git a/test/byteSize/byteSize.js b/test/byteSize/byteSize.js index 5ec2b2b86..74a857863 100644 --- a/test/byteSize/byteSize.js +++ b/test/byteSize/byteSize.js @@ -1 +1,2 @@ -module.exports = byteSize = str => new Blob([str]).size; \ No newline at end of file +const byteSize = str => new Blob([str]).size; + module.exports = byteSize \ No newline at end of file diff --git a/test/call/call.js b/test/call/call.js index 55228e118..660de98a8 100644 --- a/test/call/call.js +++ b/test/call/call.js @@ -1 +1,2 @@ -module.exports = call = (key, ...args) => context => context[key](...args); \ No newline at end of file +const call = (key, ...args) => context => context[key](...args); + module.exports = call \ No newline at end of file diff --git a/test/capitalize/capitalize.js b/test/capitalize/capitalize.js index d13619814..edd95c811 100644 --- a/test/capitalize/capitalize.js +++ b/test/capitalize/capitalize.js @@ -1,2 +1,3 @@ -module.exports = capitalize = ([first, ...rest], lowerRest = false) => -first.toUpperCase() + (lowerRest ? rest.join('').toLowerCase() : rest.join('')); \ No newline at end of file +const capitalize = ([first, ...rest], lowerRest = false) => +first.toUpperCase() + (lowerRest ? rest.join('').toLowerCase() : rest.join('')); + module.exports = capitalize \ No newline at end of file diff --git a/test/capitalizeEveryWord/capitalizeEveryWord.js b/test/capitalizeEveryWord/capitalizeEveryWord.js index cc5e114f5..2bec22dcf 100644 --- a/test/capitalizeEveryWord/capitalizeEveryWord.js +++ b/test/capitalizeEveryWord/capitalizeEveryWord.js @@ -1 +1,2 @@ -module.exports = capitalizeEveryWord = str => str.replace(/\b[a-z]/g, char => char.toUpperCase()); \ No newline at end of file +const capitalizeEveryWord = str => str.replace(/\b[a-z]/g, char => char.toUpperCase()); + module.exports = capitalizeEveryWord \ No newline at end of file diff --git a/test/chainAsync/chainAsync.js b/test/chainAsync/chainAsync.js index 754fe69d0..4454d477d 100644 --- a/test/chainAsync/chainAsync.js +++ b/test/chainAsync/chainAsync.js @@ -1,5 +1,6 @@ -module.exports = chainAsync = fns => { +const chainAsync = fns => { let curr = 0; const next = () => fns[curr++](next); next(); -}; \ No newline at end of file +}; + module.exports = chainAsync \ No newline at end of file diff --git a/test/chunk/chunk.js b/test/chunk/chunk.js index 6dd3a64f9..6b27e7f1c 100644 --- a/test/chunk/chunk.js +++ b/test/chunk/chunk.js @@ -1,4 +1,5 @@ -module.exports = chunk = (arr, size) => +const chunk = (arr, size) => Array.from({ length: Math.ceil(arr.length / size) }, (v, i) => arr.slice(i * size, i * size + size) -); \ No newline at end of file +); + module.exports = chunk \ No newline at end of file diff --git a/test/clampNumber/clampNumber.js b/test/clampNumber/clampNumber.js index 07e9b043a..5033a0372 100644 --- a/test/clampNumber/clampNumber.js +++ b/test/clampNumber/clampNumber.js @@ -1 +1,2 @@ -module.exports = clampNumber = (num, a, b) => Math.max(Math.min(num, Math.max(a, b)), Math.min(a, b)); \ No newline at end of file +const clampNumber = (num, a, b) => Math.max(Math.min(num, Math.max(a, b)), Math.min(a, b)); + module.exports = clampNumber \ No newline at end of file diff --git a/test/cleanObj/cleanObj.js b/test/cleanObj/cleanObj.js index 3727b09f2..16f414bec 100644 --- a/test/cleanObj/cleanObj.js +++ b/test/cleanObj/cleanObj.js @@ -1,4 +1,4 @@ -module.exports = cleanObj = (obj, keysToKeep = [], childIndicator) => { +const cleanObj = (obj, keysToKeep = [], childIndicator) => { Object.keys(obj).forEach(key => { if (key === childIndicator) { cleanObj(obj[key], keysToKeep, childIndicator); @@ -7,4 +7,5 @@ delete obj[key]; } }); return obj; -}; \ No newline at end of file +}; + module.exports = cleanObj \ No newline at end of file diff --git a/test/cloneRegExp/cloneRegExp.js b/test/cloneRegExp/cloneRegExp.js index e5ca263b7..41d81e621 100644 --- a/test/cloneRegExp/cloneRegExp.js +++ b/test/cloneRegExp/cloneRegExp.js @@ -1 +1,2 @@ -module.exports = cloneRegExp = regExp => new RegExp(regExp.source, regExp.flags); \ No newline at end of file +const cloneRegExp = regExp => new RegExp(regExp.source, regExp.flags); + module.exports = cloneRegExp \ No newline at end of file diff --git a/test/coalesce/coalesce.js b/test/coalesce/coalesce.js index 0f5690f3e..6147c753e 100644 --- a/test/coalesce/coalesce.js +++ b/test/coalesce/coalesce.js @@ -1 +1,2 @@ -module.exports = coalesce = (...args) => args.find(_ => ![undefined, null].includes(_)); \ No newline at end of file +const coalesce = (...args) => args.find(_ => ![undefined, null].includes(_)); + module.exports = coalesce \ No newline at end of file diff --git a/test/coalesceFactory/coalesceFactory.js b/test/coalesceFactory/coalesceFactory.js index 654756423..808d4c517 100644 --- a/test/coalesceFactory/coalesceFactory.js +++ b/test/coalesceFactory/coalesceFactory.js @@ -1 +1,2 @@ -module.exports = coalesceFactory = valid => (...args) => args.find(valid); \ No newline at end of file +const coalesceFactory = valid => (...args) => args.find(valid); + module.exports = coalesceFactory \ No newline at end of file diff --git a/test/collatz/collatz.js b/test/collatz/collatz.js index f78f0006b..90f826b59 100644 --- a/test/collatz/collatz.js +++ b/test/collatz/collatz.js @@ -1 +1,2 @@ -module.exports = collatz = n => (n % 2 == 0 ? n / 2 : 3 * n + 1); \ No newline at end of file +const collatz = n => (n % 2 == 0 ? n / 2 : 3 * n + 1); + module.exports = collatz \ No newline at end of file diff --git a/test/collectInto/collectInto.js b/test/collectInto/collectInto.js index e7d85b68b..d8873dcec 100644 --- a/test/collectInto/collectInto.js +++ b/test/collectInto/collectInto.js @@ -1 +1,2 @@ -module.exports = collectInto = fn => (...args) => fn(args); \ No newline at end of file +const collectInto = fn => (...args) => fn(args); + module.exports = collectInto \ No newline at end of file diff --git a/test/colorize/colorize.js b/test/colorize/colorize.js index 25c23fad7..47c88dd49 100644 --- a/test/colorize/colorize.js +++ b/test/colorize/colorize.js @@ -1,4 +1,4 @@ -module.exports = colorize = (...args) => ({ +const colorize = (...args) => ({ black: `\x1b[30m${args.join(' ')}`, red: `\x1b[31m${args.join(' ')}`, green: `\x1b[32m${args.join(' ')}`, @@ -15,4 +15,5 @@ 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` -}); \ No newline at end of file +}); + module.exports = colorize \ No newline at end of file diff --git a/test/compact/compact.js b/test/compact/compact.js index b06d62396..da480df6b 100644 --- a/test/compact/compact.js +++ b/test/compact/compact.js @@ -1 +1,2 @@ -module.exports = compact = arr => arr.filter(Boolean); \ No newline at end of file +const compact = arr => arr.filter(Boolean); + module.exports = compact \ No newline at end of file diff --git a/test/compose/compose.js b/test/compose/compose.js index 91d9c4989..ec5564b31 100644 --- a/test/compose/compose.js +++ b/test/compose/compose.js @@ -1 +1,2 @@ -module.exports = compose = (...fns) => fns.reduce((f, g) => (...args) => f(g(...args))); \ No newline at end of file +const compose = (...fns) => fns.reduce((f, g) => (...args) => f(g(...args))); + module.exports = compose \ No newline at end of file diff --git a/test/copyToClipboard/copyToClipboard.js b/test/copyToClipboard/copyToClipboard.js index b7130fd85..c1a18c196 100644 --- a/test/copyToClipboard/copyToClipboard.js +++ b/test/copyToClipboard/copyToClipboard.js @@ -1,4 +1,4 @@ -module.exports = copyToClipboard = str => { +const copyToClipboard = str => { const el = document.createElement('textarea'); el.value = str; el.setAttribute('readonly', ''); @@ -14,4 +14,5 @@ if (selected) { document.getSelection().removeAllRanges(); document.getSelection().addRange(selected); } -}; \ No newline at end of file +}; + module.exports = copyToClipboard \ No newline at end of file diff --git a/test/countBy/countBy.js b/test/countBy/countBy.js index 661df57cb..dc5aea920 100644 --- a/test/countBy/countBy.js +++ b/test/countBy/countBy.js @@ -1,5 +1,6 @@ -module.exports = countBy = (arr, fn) => +const countBy = (arr, fn) => arr.map(typeof fn === 'function' ? fn : val => val[fn]).reduce((acc, val, i) => { acc[val] = (acc[val] || 0) + 1; return acc; -}, {}); \ No newline at end of file +}, {}); + module.exports = countBy \ No newline at end of file diff --git a/test/countOccurrences/countOccurrences.js b/test/countOccurrences/countOccurrences.js index a9a4ae75a..cb03497f6 100644 --- a/test/countOccurrences/countOccurrences.js +++ b/test/countOccurrences/countOccurrences.js @@ -1 +1,2 @@ -module.exports = countOccurrences = (arr, val) => arr.reduce((a, v) => (v === val ? a + 1 : a + 0), 0); \ No newline at end of file +const countOccurrences = (arr, val) => arr.reduce((a, v) => (v === val ? a + 1 : a + 0), 0); + module.exports = countOccurrences \ No newline at end of file diff --git a/test/countVowels/countVowels.js b/test/countVowels/countVowels.js index 867f63a79..62194dc8b 100644 --- a/test/countVowels/countVowels.js +++ b/test/countVowels/countVowels.js @@ -1 +1,2 @@ -module.exports = countVowels = str => (str.match(/[aeiou]/gi) || []).length; \ No newline at end of file +const countVowels = str => (str.match(/[aeiou]/gi) || []).length; + module.exports = countVowels \ No newline at end of file diff --git a/test/createElement/createElement.js b/test/createElement/createElement.js index 9ab5d3017..8786e0056 100644 --- a/test/createElement/createElement.js +++ b/test/createElement/createElement.js @@ -1,5 +1,6 @@ -module.exports = createElement = str => { +const createElement = str => { const el = document.createElement('div'); el.innerHTML = str; return el.firstElementChild; -}; \ No newline at end of file +}; + module.exports = createElement \ No newline at end of file diff --git a/test/createEventHub/createEventHub.js b/test/createEventHub/createEventHub.js index 2f25c0b91..6b85e5613 100644 --- a/test/createEventHub/createEventHub.js +++ b/test/createEventHub/createEventHub.js @@ -1,4 +1,4 @@ -module.exports = createEventHub = () => ({ +const createEventHub = () => ({ hub: Object.create(null), emit(event, data) { (this.hub[event] || []).forEach(handler => handler(data)); @@ -11,4 +11,5 @@ off(event, handler) { const i = (this.hub[event] || []).findIndex(h => h === handler); if (i > -1) this.hub[event].splice(i, 1); } -}); \ No newline at end of file +}); + module.exports = createEventHub \ No newline at end of file diff --git a/test/currentURL/currentURL.js b/test/currentURL/currentURL.js index 13ddcb6f4..e7f2b6885 100644 --- a/test/currentURL/currentURL.js +++ b/test/currentURL/currentURL.js @@ -1 +1,2 @@ -module.exports = currentURL = () => window.location.href; \ No newline at end of file +const currentURL = () => window.location.href; + module.exports = currentURL \ No newline at end of file diff --git a/test/curry/curry.js b/test/curry/curry.js index e23630b5b..d0109e427 100644 --- a/test/curry/curry.js +++ b/test/curry/curry.js @@ -1,2 +1,3 @@ -module.exports = curry = (fn, arity = fn.length, ...args) => -arity <= args.length ? fn(...args) : curry.bind(null, fn, arity, ...args); \ No newline at end of file +const curry = (fn, arity = fn.length, ...args) => +arity <= args.length ? fn(...args) : curry.bind(null, fn, arity, ...args); + module.exports = curry \ No newline at end of file diff --git a/test/decapitalize/decapitalize.js b/test/decapitalize/decapitalize.js index 6e84e5d6e..c42322649 100644 --- a/test/decapitalize/decapitalize.js +++ b/test/decapitalize/decapitalize.js @@ -1,2 +1,3 @@ -module.exports = decapitalize = ([first, ...rest], upperRest = false) => -first.toLowerCase() + (upperRest ? rest.join('').toUpperCase() : rest.join('')); \ No newline at end of file +const decapitalize = ([first, ...rest], upperRest = false) => +first.toLowerCase() + (upperRest ? rest.join('').toUpperCase() : rest.join('')); + module.exports = decapitalize \ No newline at end of file diff --git a/test/deepFlatten/deepFlatten.js b/test/deepFlatten/deepFlatten.js index 3d9ca6819..f6e7cc6d6 100644 --- a/test/deepFlatten/deepFlatten.js +++ b/test/deepFlatten/deepFlatten.js @@ -1 +1,2 @@ -module.exports = deepFlatten = arr => [].concat(...arr.map(v => (Array.isArray(v) ? deepFlatten(v) : v))); \ No newline at end of file +const deepFlatten = arr => [].concat(...arr.map(v => (Array.isArray(v) ? deepFlatten(v) : v))); + module.exports = deepFlatten \ No newline at end of file diff --git a/test/defer/defer.js b/test/defer/defer.js index 7f975ac42..f5562f3c7 100644 --- a/test/defer/defer.js +++ b/test/defer/defer.js @@ -1 +1,2 @@ -module.exports = defer = (fn, ...args) => setTimeout(fn, 1, ...args); \ No newline at end of file +const defer = (fn, ...args) => setTimeout(fn, 1, ...args); + module.exports = defer \ No newline at end of file diff --git a/test/detectDeviceType/detectDeviceType.js b/test/detectDeviceType/detectDeviceType.js index 0f5eb5f3b..d66cb7429 100644 --- a/test/detectDeviceType/detectDeviceType.js +++ b/test/detectDeviceType/detectDeviceType.js @@ -1,4 +1,5 @@ -module.exports = detectDeviceType = () => +const detectDeviceType = () => /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ? 'Mobile' -: 'Desktop'; \ No newline at end of file +: 'Desktop'; + module.exports = detectDeviceType \ No newline at end of file diff --git a/test/difference/difference.js b/test/difference/difference.js index 672b5c244..48fa645c5 100644 --- a/test/difference/difference.js +++ b/test/difference/difference.js @@ -1,4 +1,5 @@ -module.exports = difference = (a, b) => { +const difference = (a, b) => { const s = new Set(b); return a.filter(x => !s.has(x)); -}; \ No newline at end of file +}; + module.exports = difference \ No newline at end of file diff --git a/test/differenceWith/differenceWith.js b/test/differenceWith/differenceWith.js index cd6aefe43..2d173c9c3 100644 --- a/test/differenceWith/differenceWith.js +++ b/test/differenceWith/differenceWith.js @@ -1 +1,2 @@ -module.exports = differenceWith = (arr, val, comp) => arr.filter(a => val.findIndex(b => comp(a, b)) === -1); \ No newline at end of file +const differenceWith = (arr, val, comp) => arr.filter(a => val.findIndex(b => comp(a, b)) === -1); + module.exports = differenceWith \ No newline at end of file diff --git a/test/digitize/digitize.js b/test/digitize/digitize.js index addcc7e16..d34c01e6a 100644 --- a/test/digitize/digitize.js +++ b/test/digitize/digitize.js @@ -1 +1,2 @@ -module.exports = digitize = n => [...`${n}`].map(i => parseInt(i)); \ No newline at end of file +const digitize = n => [...`${n}`].map(i => parseInt(i)); + module.exports = digitize \ No newline at end of file diff --git a/test/distance/distance.js b/test/distance/distance.js index 521012787..426517fd3 100644 --- a/test/distance/distance.js +++ b/test/distance/distance.js @@ -1 +1,2 @@ -module.exports = distance = (x0, y0, x1, y1) => Math.hypot(x1 - x0, y1 - y0); \ No newline at end of file +const distance = (x0, y0, x1, y1) => Math.hypot(x1 - x0, y1 - y0); + module.exports = distance \ No newline at end of file diff --git a/test/dropElements/dropElements.js b/test/dropElements/dropElements.js index cc57fee75..6484de16d 100644 --- a/test/dropElements/dropElements.js +++ b/test/dropElements/dropElements.js @@ -1,4 +1,5 @@ -module.exports = dropElements = (arr, func) => { +const dropElements = (arr, func) => { while (arr.length > 0 && !func(arr[0])) arr = arr.slice(1); return arr; -}; \ No newline at end of file +}; + module.exports = dropElements \ No newline at end of file diff --git a/test/dropRight/dropRight.js b/test/dropRight/dropRight.js index 62f2bb163..8e89e36b4 100644 --- a/test/dropRight/dropRight.js +++ b/test/dropRight/dropRight.js @@ -1 +1,2 @@ -module.exports = dropRight = (arr, n = 1) => arr.slice(0, -n); \ No newline at end of file +const dropRight = (arr, n = 1) => arr.slice(0, -n); + module.exports = dropRight \ No newline at end of file diff --git a/test/elementIsVisibleInViewport/elementIsVisibleInViewport.js b/test/elementIsVisibleInViewport/elementIsVisibleInViewport.js index 659dee2c9..1925c72cd 100644 --- a/test/elementIsVisibleInViewport/elementIsVisibleInViewport.js +++ b/test/elementIsVisibleInViewport/elementIsVisibleInViewport.js @@ -1,8 +1,9 @@ -module.exports = elementIsVisibleInViewport = (el, partiallyVisible = false) => { +const elementIsVisibleInViewport = (el, partiallyVisible = false) => { const { top, left, bottom, right } = el.getBoundingClientRect(); const { innerHeight, innerWidth } = window; return partiallyVisible ? ((top > 0 && top < innerHeight) || (bottom > 0 && bottom < innerHeight)) && ((left > 0 && left < innerWidth) || (right > 0 && right < innerWidth)) : top >= 0 && left >= 0 && bottom <= innerHeight && right <= innerWidth; -}; \ No newline at end of file +}; + module.exports = elementIsVisibleInViewport \ No newline at end of file diff --git a/test/elo/elo.js b/test/elo/elo.js index 41e1bd060..812ee1af1 100644 --- a/test/elo/elo.js +++ b/test/elo/elo.js @@ -1,4 +1,4 @@ -module.exports = elo = ([...ratings], kFactor = 32, selfRating) => { +const elo = ([...ratings], kFactor = 32, selfRating) => { const [a, b] = ratings; const expectedScore = (self, opponent) => 1 / (1 + 10 ** ((opponent - self) / 400)); const newRating = (rating, i) => @@ -15,4 +15,5 @@ j++; } } return ratings; -}; \ No newline at end of file +}; + module.exports = elo \ No newline at end of file diff --git a/test/equals/equals.js b/test/equals/equals.js index 61ce5819c..f418aa5cd 100644 --- a/test/equals/equals.js +++ b/test/equals/equals.js @@ -1,4 +1,4 @@ -module.exports = equals = (a, b) => { +const equals = (a, b) => { if (a === b) return true; if (a instanceof Date && b instanceof Date) return a.getTime() === b.getTime(); if (!a || !b || (typeof a != 'object' && typeof b !== 'object')) return a === b; @@ -7,4 +7,5 @@ if (a.prototype !== b.prototype) return false; let keys = Object.keys(a); if (keys.length !== Object.keys(b).length) return false; return keys.every(k => equals(a[k], b[k])); -}; \ No newline at end of file +}; + module.exports = equals \ No newline at end of file diff --git a/test/escapeHTML/escapeHTML.js b/test/escapeHTML/escapeHTML.js index 33c0bc739..94cb8e7fe 100644 --- a/test/escapeHTML/escapeHTML.js +++ b/test/escapeHTML/escapeHTML.js @@ -1,4 +1,4 @@ -module.exports = escapeHTML = str => +const escapeHTML = str => str.replace( /[&<>'"]/g, tag => @@ -9,4 +9,5 @@ tag => "'": ''', '"': '"' }[tag] || tag) -); \ No newline at end of file +); + module.exports = escapeHTML \ No newline at end of file diff --git a/test/escapeRegExp/escapeRegExp.js b/test/escapeRegExp/escapeRegExp.js index ad6961ec4..9164cc532 100644 --- a/test/escapeRegExp/escapeRegExp.js +++ b/test/escapeRegExp/escapeRegExp.js @@ -1 +1,2 @@ -module.exports = escapeRegExp = str => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); \ No newline at end of file +const escapeRegExp = str => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); + module.exports = escapeRegExp \ No newline at end of file diff --git a/test/everyNth/everyNth.js b/test/everyNth/everyNth.js index 01096d1f9..723c4f5ca 100644 --- a/test/everyNth/everyNth.js +++ b/test/everyNth/everyNth.js @@ -1 +1,2 @@ -module.exports = everyNth = (arr, nth) => arr.filter((e, i) => i % nth === nth - 1); \ No newline at end of file +const everyNth = (arr, nth) => arr.filter((e, i) => i % nth === nth - 1); + module.exports = everyNth \ No newline at end of file diff --git a/test/extendHex/extendHex.js b/test/extendHex/extendHex.js index 1faf96cc7..6e1b6d535 100644 --- a/test/extendHex/extendHex.js +++ b/test/extendHex/extendHex.js @@ -1,7 +1,8 @@ -module.exports = extendHex = shortHex => +const extendHex = shortHex => '#' + shortHex .slice(shortHex.startsWith('#') ? 1 : 0) .split('') .map(x => x + x) -.join(''); \ No newline at end of file +.join(''); + module.exports = extendHex \ No newline at end of file diff --git a/test/factorial/factorial.js b/test/factorial/factorial.js index b9a03c2f4..928826dea 100644 --- a/test/factorial/factorial.js +++ b/test/factorial/factorial.js @@ -1,6 +1,7 @@ -module.exports = factorial = n => +const factorial = n => n < 0 ? (() => { throw new TypeError('Negative numbers are not allowed!'); })() -: n <= 1 ? 1 : n * factorial(n - 1); \ No newline at end of file +: n <= 1 ? 1 : n * factorial(n - 1); + module.exports = factorial \ No newline at end of file diff --git a/test/factors/factors.js b/test/factors/factors.js index 83e33a823..b34e1ded4 100644 --- a/test/factors/factors.js +++ b/test/factors/factors.js @@ -1,4 +1,4 @@ -module.exports = factors = (num, primes = false) => { +const factors = (num, primes = false) => { const isPrime = num => { const boundary = Math.floor(Math.sqrt(num)); for (var i = 2; i <= boundary; i++) if (num % i === 0) return false; @@ -16,4 +16,5 @@ acc.push(-val); return acc; }, []); return primes ? array.filter(isPrime) : array; -}; \ No newline at end of file +}; + module.exports = factors \ No newline at end of file diff --git a/test/fibonacci/fibonacci.js b/test/fibonacci/fibonacci.js index e71b31b56..c6dbaf313 100644 --- a/test/fibonacci/fibonacci.js +++ b/test/fibonacci/fibonacci.js @@ -1,5 +1,6 @@ -module.exports = fibonacci = n => +const fibonacci = n => Array.from({ length: n }).reduce( (acc, val, i) => acc.concat(i > 1 ? acc[i - 1] + acc[i - 2] : i), [] -); \ No newline at end of file +); + module.exports = fibonacci \ No newline at end of file diff --git a/test/fibonacciCountUntilNum/fibonacciCountUntilNum.js b/test/fibonacciCountUntilNum/fibonacciCountUntilNum.js index 93404fc61..a23fab23b 100644 --- a/test/fibonacciCountUntilNum/fibonacciCountUntilNum.js +++ b/test/fibonacciCountUntilNum/fibonacciCountUntilNum.js @@ -1,2 +1,3 @@ -module.exports = fibonacciCountUntilNum = num => -Math.ceil(Math.log(num * Math.sqrt(5) + 1 / 2) / Math.log((Math.sqrt(5) + 1) / 2)); \ No newline at end of file +const fibonacciCountUntilNum = num => +Math.ceil(Math.log(num * Math.sqrt(5) + 1 / 2) / Math.log((Math.sqrt(5) + 1) / 2)); + module.exports = fibonacciCountUntilNum \ No newline at end of file diff --git a/test/fibonacciUntilNum/fibonacciUntilNum.js b/test/fibonacciUntilNum/fibonacciUntilNum.js index 6ead222a0..9f5a4ac32 100644 --- a/test/fibonacciUntilNum/fibonacciUntilNum.js +++ b/test/fibonacciUntilNum/fibonacciUntilNum.js @@ -1,7 +1,8 @@ -module.exports = fibonacciUntilNum = num => { +const fibonacciUntilNum = num => { let n = Math.ceil(Math.log(num * Math.sqrt(5) + 1 / 2) / Math.log((Math.sqrt(5) + 1) / 2)); return Array.from({ length: n }).reduce( (acc, val, i) => acc.concat(i > 1 ? acc[i - 1] + acc[i - 2] : i), [] ); -}; \ No newline at end of file +}; + module.exports = fibonacciUntilNum \ No newline at end of file diff --git a/test/filterNonUnique/filterNonUnique.js b/test/filterNonUnique/filterNonUnique.js index ba922256d..712cf074e 100644 --- a/test/filterNonUnique/filterNonUnique.js +++ b/test/filterNonUnique/filterNonUnique.js @@ -1 +1,2 @@ -module.exports = filterNonUnique = arr => arr.filter(i => arr.indexOf(i) === arr.lastIndexOf(i)); \ No newline at end of file +const filterNonUnique = arr => arr.filter(i => arr.indexOf(i) === arr.lastIndexOf(i)); + module.exports = filterNonUnique \ No newline at end of file diff --git a/test/findLast/findLast.js b/test/findLast/findLast.js index cbd294f72..00daa5d5d 100644 --- a/test/findLast/findLast.js +++ b/test/findLast/findLast.js @@ -1 +1,2 @@ -module.exports = findLast = (arr, fn) => arr.filter(fn).slice(-1); \ No newline at end of file +const findLast = (arr, fn) => arr.filter(fn).slice(-1); + module.exports = findLast \ No newline at end of file diff --git a/test/flatten/flatten.js b/test/flatten/flatten.js index 727e22a60..027441ea1 100644 --- a/test/flatten/flatten.js +++ b/test/flatten/flatten.js @@ -1,4 +1,5 @@ -module.exports = flatten = (arr, depth = 1) => +const flatten = (arr, depth = 1) => depth != 1 ? arr.reduce((a, v) => a.concat(Array.isArray(v) ? flatten(v, depth - 1) : v), []) -: arr.reduce((a, v) => a.concat(v), []); \ No newline at end of file +: arr.reduce((a, v) => a.concat(v), []); + module.exports = flatten \ No newline at end of file diff --git a/test/flip/flip.js b/test/flip/flip.js index 554d928f7..2bb3f3cd4 100644 --- a/test/flip/flip.js +++ b/test/flip/flip.js @@ -1 +1,2 @@ -module.exports = flip = fn => (...args) => fn(args.pop(), ...args); \ No newline at end of file +const flip = fn => (...args) => fn(args.pop(), ...args); + module.exports = flip \ No newline at end of file diff --git a/test/forEachRight/forEachRight.js b/test/forEachRight/forEachRight.js index 3b267d120..a6e0f7a9e 100644 --- a/test/forEachRight/forEachRight.js +++ b/test/forEachRight/forEachRight.js @@ -1,5 +1,6 @@ -module.exports = forEachRight = (arr, callback) => +const forEachRight = (arr, callback) => arr .slice(0) .reverse() -.forEach(callback); \ No newline at end of file +.forEach(callback); + module.exports = forEachRight \ No newline at end of file diff --git a/test/formatDuration/formatDuration.js b/test/formatDuration/formatDuration.js index 4eb263f8e..ae1075e92 100644 --- a/test/formatDuration/formatDuration.js +++ b/test/formatDuration/formatDuration.js @@ -1,4 +1,4 @@ -module.exports = formatDuration = ms => { +const formatDuration = ms => { if (ms < 0) ms = -ms; const time = { day: Math.floor(ms / 86400000), @@ -11,4 +11,5 @@ return Object.entries(time) .filter(val => val[1] !== 0) .map(val => val[1] + ' ' + (val[1] !== 1 ? val[0] + 's' : val[0])) .join(', '); -}; \ No newline at end of file +}; + module.exports = formatDuration \ No newline at end of file diff --git a/test/fromCamelCase/fromCamelCase.js b/test/fromCamelCase/fromCamelCase.js index ae52a0dcf..10c6fac30 100644 --- a/test/fromCamelCase/fromCamelCase.js +++ b/test/fromCamelCase/fromCamelCase.js @@ -1,5 +1,6 @@ -module.exports = fromCamelCase = (str, separator = '_') => +const fromCamelCase = (str, separator = '_') => str .replace(/([a-z\d])([A-Z])/g, '$1' + separator + '$2') .replace(/([A-Z]+)([A-Z][a-z\d]+)/g, '$1' + separator + '$2') -.toLowerCase(); \ No newline at end of file +.toLowerCase(); + module.exports = fromCamelCase \ No newline at end of file diff --git a/test/functionName/functionName.js b/test/functionName/functionName.js index 9192ca098..2181fe74a 100644 --- a/test/functionName/functionName.js +++ b/test/functionName/functionName.js @@ -1 +1,2 @@ -module.exports = functionName = fn => (console.debug(fn.name), fn); \ No newline at end of file +const functionName = fn => (console.debug(fn.name), fn); + module.exports = functionName \ No newline at end of file diff --git a/test/functions/functions.js b/test/functions/functions.js index d0760b8b0..7a451527d 100644 --- a/test/functions/functions.js +++ b/test/functions/functions.js @@ -1,5 +1,6 @@ -module.exports = functions = (obj, inherited = false) => +const functions = (obj, inherited = false) => (inherited ? [...Object.keys(obj), ...Object.keys(Object.getPrototypeOf(obj))] : Object.keys(obj) -).filter(key => typeof obj[key] === 'function'); \ No newline at end of file +).filter(key => typeof obj[key] === 'function'); + module.exports = functions \ No newline at end of file diff --git a/test/gcd/gcd.js b/test/gcd/gcd.js index debfbee0e..201d996ae 100644 --- a/test/gcd/gcd.js +++ b/test/gcd/gcd.js @@ -1,4 +1,5 @@ -module.exports = gcd = (...arr) => { +const gcd = (...arr) => { const _gcd = (x, y) => (!y ? x : gcd(y, x % y)); return [...arr].reduce((a, b) => _gcd(a, b)); -}; \ No newline at end of file +}; + module.exports = gcd \ No newline at end of file diff --git a/test/geometricProgression/geometricProgression.js b/test/geometricProgression/geometricProgression.js index a03ced538..c42691c59 100644 --- a/test/geometricProgression/geometricProgression.js +++ b/test/geometricProgression/geometricProgression.js @@ -1,4 +1,5 @@ -module.exports = geometricProgression = (end, start = 1, step = 2) => +const geometricProgression = (end, start = 1, step = 2) => Array.from({ length: Math.floor(Math.log(end / start) / Math.log(step)) + 1 }).map( (v, i) => start * step ** i -); \ No newline at end of file +); + module.exports = geometricProgression \ No newline at end of file diff --git a/test/getDaysDiffBetweenDates/getDaysDiffBetweenDates.js b/test/getDaysDiffBetweenDates/getDaysDiffBetweenDates.js index 5a3808d60..e2157f0d3 100644 --- a/test/getDaysDiffBetweenDates/getDaysDiffBetweenDates.js +++ b/test/getDaysDiffBetweenDates/getDaysDiffBetweenDates.js @@ -1,2 +1,3 @@ -module.exports = getDaysDiffBetweenDates = (dateInitial, dateFinal) => -(dateFinal - dateInitial) / (1000 * 3600 * 24); \ No newline at end of file +const getDaysDiffBetweenDates = (dateInitial, dateFinal) => +(dateFinal - dateInitial) / (1000 * 3600 * 24); + module.exports = getDaysDiffBetweenDates \ No newline at end of file diff --git a/test/getScrollPosition/getScrollPosition.js b/test/getScrollPosition/getScrollPosition.js index a786c099e..4d3e12a62 100644 --- a/test/getScrollPosition/getScrollPosition.js +++ b/test/getScrollPosition/getScrollPosition.js @@ -1,4 +1,5 @@ -module.exports = getScrollPosition = (el = window) => ({ +const getScrollPosition = (el = window) => ({ x: el.pageXOffset !== undefined ? el.pageXOffset : el.scrollLeft, y: el.pageYOffset !== undefined ? el.pageYOffset : el.scrollTop -}); \ No newline at end of file +}); + module.exports = getScrollPosition \ No newline at end of file diff --git a/test/getStyle/getStyle.js b/test/getStyle/getStyle.js index ea8cbb8fe..6df1c1394 100644 --- a/test/getStyle/getStyle.js +++ b/test/getStyle/getStyle.js @@ -1 +1,2 @@ -module.exports = getStyle = (el, ruleName) => getComputedStyle(el)[ruleName]; \ No newline at end of file +const getStyle = (el, ruleName) => getComputedStyle(el)[ruleName]; + module.exports = getStyle \ No newline at end of file diff --git a/test/getType/getType.js b/test/getType/getType.js index 0733d9c21..02973563b 100644 --- a/test/getType/getType.js +++ b/test/getType/getType.js @@ -1,2 +1,3 @@ -module.exports = getType = v => -v === undefined ? 'undefined' : v === null ? 'null' : v.constructor.name.toLowerCase(); \ No newline at end of file +const getType = v => +v === undefined ? 'undefined' : v === null ? 'null' : v.constructor.name.toLowerCase(); + module.exports = getType \ No newline at end of file diff --git a/test/getURLParameters/getURLParameters.js b/test/getURLParameters/getURLParameters.js index 5b70753c9..029711f48 100644 --- a/test/getURLParameters/getURLParameters.js +++ b/test/getURLParameters/getURLParameters.js @@ -1,4 +1,5 @@ -module.exports = getURLParameters = url => +const getURLParameters = url => url .match(/([^?=&]+)(=([^&]*))/g) -.reduce((a, v) => ((a[v.slice(0, v.indexOf('='))] = v.slice(v.indexOf('=') + 1)), a), {}); \ No newline at end of file +.reduce((a, v) => ((a[v.slice(0, v.indexOf('='))] = v.slice(v.indexOf('=') + 1)), a), {}); + module.exports = getURLParameters \ No newline at end of file diff --git a/test/groupBy/groupBy.js b/test/groupBy/groupBy.js index 3aa523053..f1083e4fe 100644 --- a/test/groupBy/groupBy.js +++ b/test/groupBy/groupBy.js @@ -1,5 +1,6 @@ -module.exports = groupBy = (arr, fn) => +const groupBy = (arr, fn) => arr.map(typeof fn === 'function' ? fn : val => val[fn]).reduce((acc, val, i) => { acc[val] = (acc[val] || []).concat(arr[i]); return acc; -}, {}); \ No newline at end of file +}, {}); + module.exports = groupBy \ No newline at end of file diff --git a/test/hammingDistance/hammingDistance.js b/test/hammingDistance/hammingDistance.js index 4c708616c..e6e4c81e0 100644 --- a/test/hammingDistance/hammingDistance.js +++ b/test/hammingDistance/hammingDistance.js @@ -1 +1,2 @@ -module.exports = hammingDistance = (num1, num2) => ((num1 ^ num2).toString(2).match(/1/g) || '').length; \ No newline at end of file +const hammingDistance = (num1, num2) => ((num1 ^ num2).toString(2).match(/1/g) || '').length; + module.exports = hammingDistance \ No newline at end of file diff --git a/test/hasClass/hasClass.js b/test/hasClass/hasClass.js index 4587138c7..8f6f09234 100644 --- a/test/hasClass/hasClass.js +++ b/test/hasClass/hasClass.js @@ -1 +1,2 @@ -module.exports = hasClass = (el, className) => el.classList.contains(className); \ No newline at end of file +const hasClass = (el, className) => el.classList.contains(className); + module.exports = hasClass \ No newline at end of file diff --git a/test/hasFlags/hasFlags.js b/test/hasFlags/hasFlags.js index ccc7889ce..c0312e5fc 100644 --- a/test/hasFlags/hasFlags.js +++ b/test/hasFlags/hasFlags.js @@ -1,2 +1,3 @@ -module.exports = hasFlags = (...flags) => -flags.every(flag => process.argv.includes(/^-{1,2}/.test(flag) ? flag : '--' + flag)); \ No newline at end of file +const hasFlags = (...flags) => +flags.every(flag => process.argv.includes(/^-{1,2}/.test(flag) ? flag : '--' + flag)); + module.exports = hasFlags \ No newline at end of file diff --git a/test/head/head.js b/test/head/head.js index f4f85ed5b..0c4e9eb90 100644 --- a/test/head/head.js +++ b/test/head/head.js @@ -1 +1,2 @@ -module.exports = head = arr => arr[0]; \ No newline at end of file +const head = arr => arr[0]; + module.exports = head \ No newline at end of file diff --git a/test/hexToRGB/hexToRGB.js b/test/hexToRGB/hexToRGB.js index 25946a262..090ec2a35 100644 --- a/test/hexToRGB/hexToRGB.js +++ b/test/hexToRGB/hexToRGB.js @@ -1,4 +1,4 @@ -module.exports = hexToRGB = hex => { +const hexToRGB = hex => { let alpha = false, h = hex.slice(hex.startsWith('#') ? 1 : 0); if (h.length === 3) h = [...h].map(x => x + x).join(''); @@ -16,4 +16,5 @@ return ( (alpha ? `, ${h & 0x000000ff}` : '') + ')' ); -}; \ No newline at end of file +}; + module.exports = hexToRGB \ No newline at end of file diff --git a/test/hide/hide.js b/test/hide/hide.js index 2ca6d885d..56bc848c9 100644 --- a/test/hide/hide.js +++ b/test/hide/hide.js @@ -1 +1,2 @@ -module.exports = hide = (...el) => [...el].forEach(e => (e.style.display = 'none')); \ No newline at end of file +const hide = (...el) => [...el].forEach(e => (e.style.display = 'none')); + module.exports = hide \ No newline at end of file diff --git a/test/howManyTimes/howManyTimes.js b/test/howManyTimes/howManyTimes.js index 0ea05ded9..85d57b0d5 100644 --- a/test/howManyTimes/howManyTimes.js +++ b/test/howManyTimes/howManyTimes.js @@ -1,4 +1,4 @@ -module.exports = howManyTimes = (num, divisor) => { +const howManyTimes = (num, divisor) => { if (divisor === 1 || divisor === -1) return Infinity; if (divisor === 0) return 0; let i = 0; @@ -7,4 +7,5 @@ i++; num = num / divisor; } return i; -}; \ No newline at end of file +}; + module.exports = howManyTimes \ No newline at end of file diff --git a/test/httpDelete/httpDelete.js b/test/httpDelete/httpDelete.js index 1088f9c1b..8a3ff97e6 100644 --- a/test/httpDelete/httpDelete.js +++ b/test/httpDelete/httpDelete.js @@ -1,7 +1,8 @@ -module.exports = httpDelete = (url, callback, err = console.error) => { +const httpDelete = (url, callback, err = console.error) => { const request = new XMLHttpRequest(); request.open("DELETE", url, true); request.onload = () => callback(request); request.onerror = () => err(request); request.send(); -}; \ No newline at end of file +}; + module.exports = httpDelete \ No newline at end of file diff --git a/test/httpGet/httpGet.js b/test/httpGet/httpGet.js index 05445e908..04564234a 100644 --- a/test/httpGet/httpGet.js +++ b/test/httpGet/httpGet.js @@ -1,7 +1,8 @@ -module.exports = httpGet = (url, callback, err = console.error) => { +const httpGet = (url, callback, err = console.error) => { const request = new XMLHttpRequest(); request.open('GET', url, true); request.onload = () => callback(request.responseText); request.onerror = () => err(request); request.send(); -}; \ No newline at end of file +}; + module.exports = httpGet \ No newline at end of file diff --git a/test/httpPost/httpPost.js b/test/httpPost/httpPost.js index d94b85a95..bb7345f83 100644 --- a/test/httpPost/httpPost.js +++ b/test/httpPost/httpPost.js @@ -1,8 +1,9 @@ -module.exports = httpPost = (url, callback, data = null, err = console.error) => { +const httpPost = (url, data, callback, err = console.error) => { const request = new XMLHttpRequest(); request.open('POST', url, true); request.setRequestHeader('Content-type', 'application/json; charset=utf-8'); request.onload = () => callback(request.responseText); request.onerror = () => err(request); request.send(data); -}; \ No newline at end of file +}; + module.exports = httpPost \ No newline at end of file diff --git a/test/httpPut/httpPut.js b/test/httpPut/httpPut.js index f76d8de86..fba715694 100644 --- a/test/httpPut/httpPut.js +++ b/test/httpPut/httpPut.js @@ -1,8 +1,9 @@ -module.exports = httpPut = (url, data, callback, err = console.error) => { +const httpPut = (url, data, callback, err = console.error) => { const request = new XMLHttpRequest(); request.open("PUT", url, true); request.setRequestHeader('Content-type','application/json; charset=utf-8'); request.onload = () => callback(request); request.onerror = () => err(request); request.send(data); -}; \ No newline at end of file +}; + module.exports = httpPut \ No newline at end of file diff --git a/test/httpsRedirect/httpsRedirect.js b/test/httpsRedirect/httpsRedirect.js index 8835acac6..832563f07 100644 --- a/test/httpsRedirect/httpsRedirect.js +++ b/test/httpsRedirect/httpsRedirect.js @@ -1,3 +1,4 @@ -module.exports = httpsRedirect = () => { +const httpsRedirect = () => { if (location.protocol !== 'https:') location.replace('https://' + location.href.split('//')[1]); -}; \ No newline at end of file +}; + module.exports = httpsRedirect \ No newline at end of file diff --git a/test/inRange/inRange.js b/test/inRange/inRange.js index 7615d11f7..f0f16154b 100644 --- a/test/inRange/inRange.js +++ b/test/inRange/inRange.js @@ -1,4 +1,5 @@ -module.exports = inRange = (n, start, end = null) => { +const inRange = (n, start, end = null) => { if (end && start > end) end = [start, (start = end)][0]; return end == null ? n >= 0 && n < start : n >= start && n < end; -}; \ No newline at end of file +}; + module.exports = inRange \ No newline at end of file diff --git a/test/indexOfAll/indexOfAll.js b/test/indexOfAll/indexOfAll.js index 82d6900c8..8eebcf8a4 100644 --- a/test/indexOfAll/indexOfAll.js +++ b/test/indexOfAll/indexOfAll.js @@ -1,5 +1,6 @@ -module.exports = indexOfAll = (arr, val) => { +const indexOfAll = (arr, val) => { const indices = []; arr.forEach((el, i) => el === val && indices.push(i)); return indices; -}; \ No newline at end of file +}; + module.exports = indexOfAll \ No newline at end of file diff --git a/test/initial/initial.js b/test/initial/initial.js index 99efa7f8a..66869d7d1 100644 --- a/test/initial/initial.js +++ b/test/initial/initial.js @@ -1 +1,2 @@ -module.exports = initial = arr => arr.slice(0, -1); \ No newline at end of file +const initial = arr => arr.slice(0, -1); + module.exports = initial \ No newline at end of file diff --git a/test/initialize2DArray/initialize2DArray.js b/test/initialize2DArray/initialize2DArray.js index 43876649b..b8a85fd93 100644 --- a/test/initialize2DArray/initialize2DArray.js +++ b/test/initialize2DArray/initialize2DArray.js @@ -1,2 +1,3 @@ -module.exports = initialize2DArray = (w, h, val = null) => -Array.from({ length: h }).map(() => Array.from({ length: w }).fill(val)); \ No newline at end of file +const initialize2DArray = (w, h, val = null) => +Array.from({ length: h }).map(() => Array.from({ length: w }).fill(val)); + module.exports = initialize2DArray \ No newline at end of file diff --git a/test/initializeArrayWithRange/initializeArrayWithRange.js b/test/initializeArrayWithRange/initializeArrayWithRange.js index 04412e638..2b875d6b9 100644 --- a/test/initializeArrayWithRange/initializeArrayWithRange.js +++ b/test/initializeArrayWithRange/initializeArrayWithRange.js @@ -1,2 +1,3 @@ -module.exports = initializeArrayWithRange = (end, start = 0, step = 1) => -Array.from({ length: Math.ceil((end + 1 - start) / step) }).map((v, i) => i * step + start); \ No newline at end of file +const initializeArrayWithRange = (end, start = 0, step = 1) => +Array.from({ length: Math.ceil((end + 1 - start) / step) }).map((v, i) => i * step + start); + module.exports = initializeArrayWithRange \ No newline at end of file diff --git a/test/initializeArrayWithRangeRight/initializeArrayWithRangeRight.js b/test/initializeArrayWithRangeRight/initializeArrayWithRangeRight.js new file mode 100644 index 000000000..957361046 --- /dev/null +++ b/test/initializeArrayWithRangeRight/initializeArrayWithRangeRight.js @@ -0,0 +1,5 @@ +const initializeArrayWithRangeRight = (end, start = 0, step = 1) => +Array.from({ length: Math.ceil((end + 1 - start) / step) }).map( +(v, i, arr) => (arr.length - i - 1) * step + start +); + module.exports = initializeArrayWithRangeRight \ No newline at end of file diff --git a/test/initializeArrayWithRangeRight/initializeArrayWithRangeRight.test.js b/test/initializeArrayWithRangeRight/initializeArrayWithRangeRight.test.js new file mode 100644 index 000000000..34418ca28 --- /dev/null +++ b/test/initializeArrayWithRangeRight/initializeArrayWithRangeRight.test.js @@ -0,0 +1,13 @@ +const test = require('tape'); +const initializeArrayWithRangeRight = require('./initializeArrayWithRangeRight.js'); + +test('Testing initializeArrayWithRangeRight', (t) => { + //For more information on all the methods supported by tape + //Please go to https://github.com/substack/tape + t.true(typeof initializeArrayWithRangeRight === 'function', 'initializeArrayWithRangeRight is a Function'); + //t.deepEqual(initializeArrayWithRangeRight(args..), 'Expected'); + //t.equal(initializeArrayWithRangeRight(args..), 'Expected'); + //t.false(initializeArrayWithRangeRight(args..), 'Expected'); + //t.throws(initializeArrayWithRangeRight(args..), 'Expected'); + t.end(); +}); \ No newline at end of file diff --git a/test/initializeArrayWithValues/initializeArrayWithValues.js b/test/initializeArrayWithValues/initializeArrayWithValues.js index a8b918cf2..a9e77c805 100644 --- a/test/initializeArrayWithValues/initializeArrayWithValues.js +++ b/test/initializeArrayWithValues/initializeArrayWithValues.js @@ -1 +1,2 @@ -module.exports = initializeArrayWithValues = (n, val = 0) => Array(n).fill(val); \ No newline at end of file +const initializeArrayWithValues = (n, val = 0) => Array(n).fill(val); + module.exports = initializeArrayWithValues \ No newline at end of file diff --git a/test/intersection/intersection.js b/test/intersection/intersection.js index 49b0c7ed7..b547b9136 100644 --- a/test/intersection/intersection.js +++ b/test/intersection/intersection.js @@ -1,4 +1,5 @@ -module.exports = intersection = (a, b) => { +const intersection = (a, b) => { const s = new Set(b); return a.filter(x => s.has(x)); -}; \ No newline at end of file +}; + module.exports = intersection \ No newline at end of file diff --git a/test/invertKeyValues/invertKeyValues.js b/test/invertKeyValues/invertKeyValues.js index f9603b0ba..bbb96740f 100644 --- a/test/invertKeyValues/invertKeyValues.js +++ b/test/invertKeyValues/invertKeyValues.js @@ -1,5 +1,6 @@ -module.exports = invertKeyValues = obj => +const invertKeyValues = obj => Object.keys(obj).reduce((acc, key) => { acc[obj[key]] = key; return acc; -}, {}); \ No newline at end of file +}, {}); + module.exports = invertKeyValues \ No newline at end of file diff --git a/test/isAbsoluteURL/isAbsoluteURL.js b/test/isAbsoluteURL/isAbsoluteURL.js index eac303d09..fcfb3e490 100644 --- a/test/isAbsoluteURL/isAbsoluteURL.js +++ b/test/isAbsoluteURL/isAbsoluteURL.js @@ -1 +1,2 @@ -module.exports = isAbsoluteURL = str => /^[a-z][a-z0-9+.-]*:/.test(str); \ No newline at end of file +const isAbsoluteURL = str => /^[a-z][a-z0-9+.-]*:/.test(str); + module.exports = isAbsoluteURL \ No newline at end of file diff --git a/test/isArmstrongNumber/isArmstrongNumber.js b/test/isArmstrongNumber/isArmstrongNumber.js index 4384686d7..dbbb3bc7f 100644 --- a/test/isArmstrongNumber/isArmstrongNumber.js +++ b/test/isArmstrongNumber/isArmstrongNumber.js @@ -1,4 +1,5 @@ -module.exports = isArmstrongNumber = digits => +const isArmstrongNumber = digits => (arr => arr.reduce((a, d) => a + parseInt(d) ** arr.length, 0) == digits)( (digits + '').split('') -); \ No newline at end of file +); + module.exports = isArmstrongNumber \ No newline at end of file diff --git a/test/isArray/isArray.js b/test/isArray/isArray.js index 0c49b742c..267942368 100644 --- a/test/isArray/isArray.js +++ b/test/isArray/isArray.js @@ -1 +1,2 @@ -module.exports = isArray = val => Array.isArray(val); \ No newline at end of file +const isArray = val => Array.isArray(val); + module.exports = isArray \ No newline at end of file diff --git a/test/isArrayBuffer/isArrayBuffer.js b/test/isArrayBuffer/isArrayBuffer.js new file mode 100644 index 000000000..a6ea3fabb --- /dev/null +++ b/test/isArrayBuffer/isArrayBuffer.js @@ -0,0 +1,2 @@ +const isArrayBuffer = val => val instanceof ArrayBuffer; + module.exports = isArrayBuffer \ No newline at end of file diff --git a/test/isArrayBuffer/isArrayBuffer.test.js b/test/isArrayBuffer/isArrayBuffer.test.js new file mode 100644 index 000000000..8b3656960 --- /dev/null +++ b/test/isArrayBuffer/isArrayBuffer.test.js @@ -0,0 +1,13 @@ +const test = require('tape'); +const isArrayBuffer = require('./isArrayBuffer.js'); + +test('Testing isArrayBuffer', (t) => { + //For more information on all the methods supported by tape + //Please go to https://github.com/substack/tape + t.true(typeof isArrayBuffer === 'function', 'isArrayBuffer is a Function'); + //t.deepEqual(isArrayBuffer(args..), 'Expected'); + //t.equal(isArrayBuffer(args..), 'Expected'); + //t.false(isArrayBuffer(args..), 'Expected'); + //t.throws(isArrayBuffer(args..), 'Expected'); + t.end(); +}); \ No newline at end of file diff --git a/test/isArrayLike/isArrayLike.js b/test/isArrayLike/isArrayLike.js index 38639c27b..ce5a35eb5 100644 --- a/test/isArrayLike/isArrayLike.js +++ b/test/isArrayLike/isArrayLike.js @@ -1,7 +1,8 @@ -module.exports = isArrayLike = val => { +const isArrayLike = val => { try { return [...val], true; } catch (e) { return false; } -}; \ No newline at end of file +}; + module.exports = isArrayLike \ No newline at end of file diff --git a/test/isBoolean/isBoolean.js b/test/isBoolean/isBoolean.js index 3dacd74f9..96d35cc5b 100644 --- a/test/isBoolean/isBoolean.js +++ b/test/isBoolean/isBoolean.js @@ -1 +1,2 @@ -module.exports = isBoolean = val => typeof val === 'boolean'; \ No newline at end of file +const isBoolean = val => typeof val === 'boolean'; + module.exports = isBoolean \ No newline at end of file diff --git a/test/isDivisible/isDivisible.js b/test/isDivisible/isDivisible.js index f121ba660..cb4cf5ace 100644 --- a/test/isDivisible/isDivisible.js +++ b/test/isDivisible/isDivisible.js @@ -1 +1,2 @@ -module.exports = isDivisible = (dividend, divisor) => dividend % divisor === 0; \ No newline at end of file +const isDivisible = (dividend, divisor) => dividend % divisor === 0; + module.exports = isDivisible \ No newline at end of file diff --git a/test/isEven/isEven.js b/test/isEven/isEven.js index b7b8a3374..255ea706e 100644 --- a/test/isEven/isEven.js +++ b/test/isEven/isEven.js @@ -1 +1,2 @@ -module.exports = isEven = num => num % 2 === 0; \ No newline at end of file +const isEven = num => num % 2 === 0; + module.exports = isEven \ No newline at end of file diff --git a/test/isFunction/isFunction.js b/test/isFunction/isFunction.js index eea7d6d8f..c7879e596 100644 --- a/test/isFunction/isFunction.js +++ b/test/isFunction/isFunction.js @@ -1 +1,2 @@ -module.exports = isFunction = val => typeof val === 'function'; \ No newline at end of file +const isFunction = val => typeof val === 'function'; + module.exports = isFunction \ No newline at end of file diff --git a/test/isLowerCase/isLowerCase.js b/test/isLowerCase/isLowerCase.js index 2e784aae6..2eb3496a3 100644 --- a/test/isLowerCase/isLowerCase.js +++ b/test/isLowerCase/isLowerCase.js @@ -1 +1,2 @@ -module.exports = isLowerCase = str => str === str.toLowerCase(); \ No newline at end of file +const isLowerCase = str => str === str.toLowerCase(); + module.exports = isLowerCase \ No newline at end of file diff --git a/test/isMap/isMap.js b/test/isMap/isMap.js new file mode 100644 index 000000000..9c62ac7ce --- /dev/null +++ b/test/isMap/isMap.js @@ -0,0 +1,2 @@ +const isMap = val => val instanceof Map; + module.exports = isMap \ No newline at end of file diff --git a/test/isMap/isMap.test.js b/test/isMap/isMap.test.js new file mode 100644 index 000000000..4f73f16de --- /dev/null +++ b/test/isMap/isMap.test.js @@ -0,0 +1,13 @@ +const test = require('tape'); +const isMap = require('./isMap.js'); + +test('Testing isMap', (t) => { + //For more information on all the methods supported by tape + //Please go to https://github.com/substack/tape + t.true(typeof isMap === 'function', 'isMap is a Function'); + //t.deepEqual(isMap(args..), 'Expected'); + //t.equal(isMap(args..), 'Expected'); + //t.false(isMap(args..), 'Expected'); + //t.throws(isMap(args..), 'Expected'); + t.end(); +}); \ No newline at end of file diff --git a/test/isNil/isNil.js b/test/isNil/isNil.js new file mode 100644 index 000000000..f7a372152 --- /dev/null +++ b/test/isNil/isNil.js @@ -0,0 +1,2 @@ +const isNil = val => val === undefined || val === null; + module.exports = isNil \ No newline at end of file diff --git a/test/isNil/isNil.test.js b/test/isNil/isNil.test.js new file mode 100644 index 000000000..324d68b84 --- /dev/null +++ b/test/isNil/isNil.test.js @@ -0,0 +1,13 @@ +const test = require('tape'); +const isNil = require('./isNil.js'); + +test('Testing isNil', (t) => { + //For more information on all the methods supported by tape + //Please go to https://github.com/substack/tape + t.true(typeof isNil === 'function', 'isNil is a Function'); + //t.deepEqual(isNil(args..), 'Expected'); + //t.equal(isNil(args..), 'Expected'); + //t.false(isNil(args..), 'Expected'); + //t.throws(isNil(args..), 'Expected'); + t.end(); +}); \ No newline at end of file diff --git a/test/isNull/isNull.js b/test/isNull/isNull.js index 68e0b1c3d..89d25db2d 100644 --- a/test/isNull/isNull.js +++ b/test/isNull/isNull.js @@ -1 +1,2 @@ -module.exports = isNull = val => val === null; \ No newline at end of file +const isNull = val => val === null; + module.exports = isNull \ No newline at end of file diff --git a/test/isNumber/isNumber.js b/test/isNumber/isNumber.js index f5ccf7423..49ada847c 100644 --- a/test/isNumber/isNumber.js +++ b/test/isNumber/isNumber.js @@ -1 +1,2 @@ -module.exports = isNumber = val => typeof val === 'number'; \ No newline at end of file +const isNumber = val => typeof val === 'number'; + module.exports = isNumber \ No newline at end of file diff --git a/test/isObject/isObject.js b/test/isObject/isObject.js index 98dbe499e..e6b532d48 100644 --- a/test/isObject/isObject.js +++ b/test/isObject/isObject.js @@ -1 +1,2 @@ -module.exports = isObject = obj => obj === Object(obj); \ No newline at end of file +const isObject = obj => obj === Object(obj); + module.exports = isObject \ No newline at end of file diff --git a/test/isPrime/isPrime.js b/test/isPrime/isPrime.js index d30ac46b1..227aae1d4 100644 --- a/test/isPrime/isPrime.js +++ b/test/isPrime/isPrime.js @@ -1,5 +1,6 @@ -module.exports = isPrime = num => { +const isPrime = num => { const boundary = Math.floor(Math.sqrt(num)); for (var i = 2; i <= boundary; i++) if (num % i == 0) return false; return num >= 2; -}; \ No newline at end of file +}; + module.exports = isPrime \ No newline at end of file diff --git a/test/isPrimitive/isPrimitive.js b/test/isPrimitive/isPrimitive.js index 72aaf090b..45a2bc136 100644 --- a/test/isPrimitive/isPrimitive.js +++ b/test/isPrimitive/isPrimitive.js @@ -1 +1,2 @@ -module.exports = isPrimitive = val => !['object', 'function'].includes(typeof val) || val === null; \ No newline at end of file +const isPrimitive = val => !['object', 'function'].includes(typeof val) || val === null; + module.exports = isPrimitive \ No newline at end of file diff --git a/test/isPromiseLike/isPromiseLike.js b/test/isPromiseLike/isPromiseLike.js index ef6f5739e..a25cb7b37 100644 --- a/test/isPromiseLike/isPromiseLike.js +++ b/test/isPromiseLike/isPromiseLike.js @@ -1,4 +1,5 @@ -module.exports = isPromiseLike = obj => +const isPromiseLike = obj => obj !== null && (typeof obj === 'object' || typeof obj === 'function') && -typeof obj.then === 'function'; \ No newline at end of file +typeof obj.then === 'function'; + module.exports = isPromiseLike \ No newline at end of file diff --git a/test/isRegExp/isRegExp.js b/test/isRegExp/isRegExp.js new file mode 100644 index 000000000..dca645dfe --- /dev/null +++ b/test/isRegExp/isRegExp.js @@ -0,0 +1,2 @@ +const isRegExp = val => val instanceof RegExp; + module.exports = isRegExp \ No newline at end of file diff --git a/test/isRegExp/isRegExp.test.js b/test/isRegExp/isRegExp.test.js new file mode 100644 index 000000000..f896a6a62 --- /dev/null +++ b/test/isRegExp/isRegExp.test.js @@ -0,0 +1,13 @@ +const test = require('tape'); +const isRegExp = require('./isRegExp.js'); + +test('Testing isRegExp', (t) => { + //For more information on all the methods supported by tape + //Please go to https://github.com/substack/tape + t.true(typeof isRegExp === 'function', 'isRegExp is a Function'); + //t.deepEqual(isRegExp(args..), 'Expected'); + //t.equal(isRegExp(args..), 'Expected'); + //t.false(isRegExp(args..), 'Expected'); + //t.throws(isRegExp(args..), 'Expected'); + t.end(); +}); \ No newline at end of file diff --git a/test/isSet/isSet.js b/test/isSet/isSet.js new file mode 100644 index 000000000..679d9add6 --- /dev/null +++ b/test/isSet/isSet.js @@ -0,0 +1,2 @@ +const isSet = val => val instanceof Set; + module.exports = isSet \ No newline at end of file diff --git a/test/isSet/isSet.test.js b/test/isSet/isSet.test.js new file mode 100644 index 000000000..757064687 --- /dev/null +++ b/test/isSet/isSet.test.js @@ -0,0 +1,13 @@ +const test = require('tape'); +const isSet = require('./isSet.js'); + +test('Testing isSet', (t) => { + //For more information on all the methods supported by tape + //Please go to https://github.com/substack/tape + t.true(typeof isSet === 'function', 'isSet is a Function'); + //t.deepEqual(isSet(args..), 'Expected'); + //t.equal(isSet(args..), 'Expected'); + //t.false(isSet(args..), 'Expected'); + //t.throws(isSet(args..), 'Expected'); + t.end(); +}); \ No newline at end of file diff --git a/test/isSorted/isSorted.js b/test/isSorted/isSorted.js index 2f164c70a..51f645c54 100644 --- a/test/isSorted/isSorted.js +++ b/test/isSorted/isSorted.js @@ -1,6 +1,7 @@ -module.exports = isSorted = arr => { +const isSorted = arr => { const direction = arr[0] > arr[1] ? -1 : 1; for (let [i, val] of arr.entries()) if (i === arr.length - 1) return direction; else if ((val - arr[i + 1]) * direction > 0) return 0; -}; \ No newline at end of file +}; + module.exports = isSorted \ No newline at end of file diff --git a/test/isString/isString.js b/test/isString/isString.js index d90ed35a0..4d866cf60 100644 --- a/test/isString/isString.js +++ b/test/isString/isString.js @@ -1 +1,2 @@ -module.exports = isString = val => typeof val === 'string'; \ No newline at end of file +const isString = val => typeof val === 'string'; + module.exports = isString \ No newline at end of file diff --git a/test/isSymbol/isSymbol.js b/test/isSymbol/isSymbol.js index dbb8d5b59..cf18ba27d 100644 --- a/test/isSymbol/isSymbol.js +++ b/test/isSymbol/isSymbol.js @@ -1 +1,2 @@ -module.exports = isSymbol = val => typeof val === 'symbol'; \ No newline at end of file +const isSymbol = val => typeof val === 'symbol'; + module.exports = isSymbol \ No newline at end of file diff --git a/test/isTravisCI/isTravisCI.js b/test/isTravisCI/isTravisCI.js index 2146bb3db..19a9125c6 100644 --- a/test/isTravisCI/isTravisCI.js +++ b/test/isTravisCI/isTravisCI.js @@ -1 +1,2 @@ -module.exports = isTravisCI = () => 'TRAVIS' in process.env && 'CI' in process.env; \ No newline at end of file +const isTravisCI = () => 'TRAVIS' in process.env && 'CI' in process.env; + module.exports = isTravisCI \ No newline at end of file diff --git a/test/isTypedArray/isTypedArray.js b/test/isTypedArray/isTypedArray.js new file mode 100644 index 000000000..007bb179c --- /dev/null +++ b/test/isTypedArray/isTypedArray.js @@ -0,0 +1,2 @@ +const isTypedArray = val => val instanceof TypedArray; + module.exports = isTypedArray \ No newline at end of file diff --git a/test/isTypedArray/isTypedArray.test.js b/test/isTypedArray/isTypedArray.test.js new file mode 100644 index 000000000..abe111200 --- /dev/null +++ b/test/isTypedArray/isTypedArray.test.js @@ -0,0 +1,13 @@ +const test = require('tape'); +const isTypedArray = require('./isTypedArray.js'); + +test('Testing isTypedArray', (t) => { + //For more information on all the methods supported by tape + //Please go to https://github.com/substack/tape + t.true(typeof isTypedArray === 'function', 'isTypedArray is a Function'); + //t.deepEqual(isTypedArray(args..), 'Expected'); + //t.equal(isTypedArray(args..), 'Expected'); + //t.false(isTypedArray(args..), 'Expected'); + //t.throws(isTypedArray(args..), 'Expected'); + t.end(); +}); \ No newline at end of file diff --git a/test/isUndefined/isUndefined.js b/test/isUndefined/isUndefined.js new file mode 100644 index 000000000..fa0f75d88 --- /dev/null +++ b/test/isUndefined/isUndefined.js @@ -0,0 +1,2 @@ +const isUndefined = val => val === undefined; + module.exports = isUndefined \ No newline at end of file diff --git a/test/isUndefined/isUndefined.test.js b/test/isUndefined/isUndefined.test.js new file mode 100644 index 000000000..701faed0a --- /dev/null +++ b/test/isUndefined/isUndefined.test.js @@ -0,0 +1,13 @@ +const test = require('tape'); +const isUndefined = require('./isUndefined.js'); + +test('Testing isUndefined', (t) => { + //For more information on all the methods supported by tape + //Please go to https://github.com/substack/tape + t.true(typeof isUndefined === 'function', 'isUndefined is a Function'); + //t.deepEqual(isUndefined(args..), 'Expected'); + //t.equal(isUndefined(args..), 'Expected'); + //t.false(isUndefined(args..), 'Expected'); + //t.throws(isUndefined(args..), 'Expected'); + t.end(); +}); \ No newline at end of file diff --git a/test/isUpperCase/isUpperCase.js b/test/isUpperCase/isUpperCase.js index e93f39f45..319409a0b 100644 --- a/test/isUpperCase/isUpperCase.js +++ b/test/isUpperCase/isUpperCase.js @@ -1 +1,2 @@ -module.exports = isUpperCase = str => str === str.toUpperCase(); \ No newline at end of file +const isUpperCase = str => str === str.toUpperCase(); + module.exports = isUpperCase \ No newline at end of file diff --git a/test/isValidJSON/isValidJSON.js b/test/isValidJSON/isValidJSON.js index d3b47281f..c18f03a49 100644 --- a/test/isValidJSON/isValidJSON.js +++ b/test/isValidJSON/isValidJSON.js @@ -1,8 +1,9 @@ -module.exports = isValidJSON = obj => { +const isValidJSON = obj => { try { JSON.parse(obj); return true; } catch (e) { return false; } -}; \ No newline at end of file +}; + module.exports = isValidJSON \ No newline at end of file diff --git a/test/isWeakMap/isWeakMap.js b/test/isWeakMap/isWeakMap.js new file mode 100644 index 000000000..7d3936490 --- /dev/null +++ b/test/isWeakMap/isWeakMap.js @@ -0,0 +1,2 @@ +const isWeakMap = val => val instanceof WeakMap; + module.exports = isWeakMap \ No newline at end of file diff --git a/test/isWeakMap/isWeakMap.test.js b/test/isWeakMap/isWeakMap.test.js new file mode 100644 index 000000000..f691dad74 --- /dev/null +++ b/test/isWeakMap/isWeakMap.test.js @@ -0,0 +1,13 @@ +const test = require('tape'); +const isWeakMap = require('./isWeakMap.js'); + +test('Testing isWeakMap', (t) => { + //For more information on all the methods supported by tape + //Please go to https://github.com/substack/tape + t.true(typeof isWeakMap === 'function', 'isWeakMap is a Function'); + //t.deepEqual(isWeakMap(args..), 'Expected'); + //t.equal(isWeakMap(args..), 'Expected'); + //t.false(isWeakMap(args..), 'Expected'); + //t.throws(isWeakMap(args..), 'Expected'); + t.end(); +}); \ No newline at end of file diff --git a/test/isWeakSet/isWeakSet.js b/test/isWeakSet/isWeakSet.js new file mode 100644 index 000000000..66237e12e --- /dev/null +++ b/test/isWeakSet/isWeakSet.js @@ -0,0 +1,2 @@ +const isWeakSet = val => val instanceof WeakSet; + module.exports = isWeakSet \ No newline at end of file diff --git a/test/isWeakSet/isWeakSet.test.js b/test/isWeakSet/isWeakSet.test.js new file mode 100644 index 000000000..ca333cf3a --- /dev/null +++ b/test/isWeakSet/isWeakSet.test.js @@ -0,0 +1,13 @@ +const test = require('tape'); +const isWeakSet = require('./isWeakSet.js'); + +test('Testing isWeakSet', (t) => { + //For more information on all the methods supported by tape + //Please go to https://github.com/substack/tape + t.true(typeof isWeakSet === 'function', 'isWeakSet is a Function'); + //t.deepEqual(isWeakSet(args..), 'Expected'); + //t.equal(isWeakSet(args..), 'Expected'); + //t.false(isWeakSet(args..), 'Expected'); + //t.throws(isWeakSet(args..), 'Expected'); + t.end(); +}); \ No newline at end of file diff --git a/test/join/join.js b/test/join/join.js index 57aba3ecf..0d24968e8 100644 --- a/test/join/join.js +++ b/test/join/join.js @@ -1,8 +1,9 @@ -module.exports = join = (arr, separator = ',', end = separator) => +const join = (arr, separator = ',', end = separator) => arr.reduce( (acc, val, i) => i == arr.length - 2 ? acc + val + end : i == arr.length - 1 ? acc + val : acc + val + separator, '' -); \ No newline at end of file +); + module.exports = join \ No newline at end of file diff --git a/test/last/last.js b/test/last/last.js index 8eac26a72..294839092 100644 --- a/test/last/last.js +++ b/test/last/last.js @@ -1 +1,2 @@ -module.exports = last = arr => arr[arr.length - 1]; \ No newline at end of file +const last = arr => arr[arr.length - 1]; + module.exports = last \ No newline at end of file diff --git a/test/lcm/lcm.js b/test/lcm/lcm.js index 5aba3223d..fd197ae0c 100644 --- a/test/lcm/lcm.js +++ b/test/lcm/lcm.js @@ -1,5 +1,6 @@ -module.exports = lcm = (...arr) => { +const lcm = (...arr) => { const gcd = (x, y) => (!y ? x : gcd(y, x % y)); const _lcm = (x, y) => x * y / gcd(x, y); return [...arr].reduce((a, b) => _lcm(a, b)); -}; \ No newline at end of file +}; + module.exports = lcm \ No newline at end of file diff --git a/test/longestItem/longestItem.js b/test/longestItem/longestItem.js index be13fd99f..2df777176 100644 --- a/test/longestItem/longestItem.js +++ b/test/longestItem/longestItem.js @@ -1 +1,2 @@ -module.exports = longestItem = (...vals) => [...vals].sort((a, b) => b.length - a.length)[0]; \ No newline at end of file +const longestItem = (...vals) => [...vals].sort((a, b) => b.length - a.length)[0]; + module.exports = longestItem \ No newline at end of file diff --git a/test/lowercaseKeys/lowercaseKeys.js b/test/lowercaseKeys/lowercaseKeys.js index 6ec74522a..34abc71ff 100644 --- a/test/lowercaseKeys/lowercaseKeys.js +++ b/test/lowercaseKeys/lowercaseKeys.js @@ -1,5 +1,6 @@ -module.exports = lowercaseKeys = obj => +const lowercaseKeys = obj => Object.keys(obj).reduce((acc, key) => { acc[key.toLowerCase()] = obj[key]; return acc; -}, {}); \ No newline at end of file +}, {}); + module.exports = lowercaseKeys \ No newline at end of file diff --git a/test/luhnCheck/luhnCheck.js b/test/luhnCheck/luhnCheck.js index 34721efb8..240a8b0a3 100644 --- a/test/luhnCheck/luhnCheck.js +++ b/test/luhnCheck/luhnCheck.js @@ -1,4 +1,4 @@ -module.exports = luhnCheck = num => { +const luhnCheck = num => { let arr = (num + '') .split('') .reverse() @@ -7,4 +7,5 @@ let lastDigit = arr.splice(0, 1)[0]; let sum = arr.reduce((acc, val, i) => (i % 2 !== 0 ? acc + val : acc + (val * 2) % 9 || 9), 0); sum += lastDigit; return sum % 10 === 0; -}; \ No newline at end of file +}; + module.exports = luhnCheck \ No newline at end of file diff --git a/test/mapKeys/mapKeys.js b/test/mapKeys/mapKeys.js index 6105240a7..6d53b64c7 100644 --- a/test/mapKeys/mapKeys.js +++ b/test/mapKeys/mapKeys.js @@ -1,5 +1,6 @@ -module.exports = mapKeys = (obj, fn) => +const mapKeys = (obj, fn) => Object.keys(obj).reduce((acc, k) => { acc[fn(obj[k], k, obj)] = obj[k]; return acc; -}, {}); \ No newline at end of file +}, {}); + module.exports = mapKeys \ No newline at end of file diff --git a/test/mapObject/mapObject.js b/test/mapObject/mapObject.js index 7dac42859..821847f1b 100644 --- a/test/mapObject/mapObject.js +++ b/test/mapObject/mapObject.js @@ -1,4 +1,5 @@ -module.exports = mapObject = (arr, fn) => +const mapObject = (arr, fn) => (a => ( (a = [arr, arr.map(fn)]), a[0].reduce((acc, val, ind) => ((acc[val] = a[1][ind]), acc), {}) -))(); \ No newline at end of file +))(); + module.exports = mapObject \ No newline at end of file diff --git a/test/mapValues/mapValues.js b/test/mapValues/mapValues.js index 80977c929..bebb7700e 100644 --- a/test/mapValues/mapValues.js +++ b/test/mapValues/mapValues.js @@ -1,5 +1,6 @@ -module.exports = mapValues = (obj, fn) => +const mapValues = (obj, fn) => Object.keys(obj).reduce((acc, k) => { acc[k] = fn(obj[k], k, obj); return acc; -}, {}); \ No newline at end of file +}, {}); + module.exports = mapValues \ No newline at end of file diff --git a/test/mask/mask.js b/test/mask/mask.js index a51e42c8e..fab75a1ea 100644 --- a/test/mask/mask.js +++ b/test/mask/mask.js @@ -1,2 +1,3 @@ -module.exports = mask = (cc, num = 4, mask = '*') => -('' + cc).slice(0, -num).replace(/./g, mask) + ('' + cc).slice(-num); \ No newline at end of file +const mask = (cc, num = 4, mask = '*') => +('' + cc).slice(0, -num).replace(/./g, mask) + ('' + cc).slice(-num); + module.exports = mask \ No newline at end of file diff --git a/test/maxBy/maxBy.js b/test/maxBy/maxBy.js index 546503bd7..66cbfe8f6 100644 --- a/test/maxBy/maxBy.js +++ b/test/maxBy/maxBy.js @@ -1 +1,2 @@ -module.exports = maxBy = (arr, fn) => Math.max(...arr.map(typeof fn === 'function' ? fn : val => val[fn])); \ No newline at end of file +const maxBy = (arr, fn) => Math.max(...arr.map(typeof fn === 'function' ? fn : val => val[fn])); + module.exports = maxBy \ No newline at end of file diff --git a/test/maxN/maxN.js b/test/maxN/maxN.js index f2bd85782..d7da949d0 100644 --- a/test/maxN/maxN.js +++ b/test/maxN/maxN.js @@ -1 +1,2 @@ -module.exports = maxN = (arr, n = 1) => [...arr].sort((a, b) => b - a).slice(0, n); \ No newline at end of file +const maxN = (arr, n = 1) => [...arr].sort((a, b) => b - a).slice(0, n); + module.exports = maxN \ No newline at end of file diff --git a/test/median/median.js b/test/median/median.js index a926c0854..59f6c6641 100644 --- a/test/median/median.js +++ b/test/median/median.js @@ -1,5 +1,6 @@ -module.exports = median = arr => { +const median = arr => { const mid = Math.floor(arr.length / 2), nums = [...arr].sort((a, b) => a - b); return arr.length % 2 !== 0 ? nums[mid] : (nums[mid - 1] + nums[mid]) / 2; -}; \ No newline at end of file +}; + module.exports = median \ No newline at end of file diff --git a/test/memoize/memoize.js b/test/memoize/memoize.js index 6eec034d3..6f7ebc106 100644 --- a/test/memoize/memoize.js +++ b/test/memoize/memoize.js @@ -1,8 +1,9 @@ -module.exports = memoize = fn => { +const memoize = fn => { const cache = new Map(); const cached = function(val) { return cache.has(val) ? cache.get(val) : cache.set(val, fn.call(this, val)) && cache.get(val); }; cached.cache = cache; return cached; -}; \ No newline at end of file +}; + module.exports = memoize \ No newline at end of file diff --git a/test/merge/merge.js b/test/merge/merge.js index 0b454216f..bc9774fb4 100644 --- a/test/merge/merge.js +++ b/test/merge/merge.js @@ -1,4 +1,4 @@ -module.exports = merge = (...objs) => +const merge = (...objs) => [...objs].reduce( (acc, obj) => Object.keys(obj).reduce((a, k) => { @@ -6,4 +6,5 @@ acc[k] = acc.hasOwnProperty(k) ? [].concat(acc[k]).concat(obj[k]) : obj[k]; return acc; }, {}), {} -); \ No newline at end of file +); + module.exports = merge \ No newline at end of file diff --git a/test/minBy/minBy.js b/test/minBy/minBy.js index 7d0db026a..135bbecb3 100644 --- a/test/minBy/minBy.js +++ b/test/minBy/minBy.js @@ -1 +1,2 @@ -module.exports = minBy = (arr, fn) => Math.min(...arr.map(typeof fn === 'function' ? fn : val => val[fn])); \ No newline at end of file +const minBy = (arr, fn) => Math.min(...arr.map(typeof fn === 'function' ? fn : val => val[fn])); + module.exports = minBy \ No newline at end of file diff --git a/test/minN/minN.js b/test/minN/minN.js index 23f07fb3f..18b052d21 100644 --- a/test/minN/minN.js +++ b/test/minN/minN.js @@ -1 +1,2 @@ -module.exports = minN = (arr, n = 1) => [...arr].sort((a, b) => a - b).slice(0, n); \ No newline at end of file +const minN = (arr, n = 1) => [...arr].sort((a, b) => a - b).slice(0, n); + module.exports = minN \ No newline at end of file diff --git a/test/negate/negate.js b/test/negate/negate.js index b2f1bea17..65a7033e3 100644 --- a/test/negate/negate.js +++ b/test/negate/negate.js @@ -1 +1,2 @@ -module.exports = negate = func => (...args) => !func(...args); \ No newline at end of file +const negate = func => (...args) => !func(...args); + module.exports = negate \ No newline at end of file diff --git a/test/nthElement/nthElement.js b/test/nthElement/nthElement.js index 285873819..0fb6ce650 100644 --- a/test/nthElement/nthElement.js +++ b/test/nthElement/nthElement.js @@ -1 +1,2 @@ -module.exports = nthElement = (arr, n = 0) => (n > 0 ? arr.slice(n, n + 1) : arr.slice(n))[0]; \ No newline at end of file +const nthElement = (arr, n = 0) => (n > 0 ? arr.slice(n, n + 1) : arr.slice(n))[0]; + module.exports = nthElement \ No newline at end of file diff --git a/test/objectFromPairs/objectFromPairs.js b/test/objectFromPairs/objectFromPairs.js index d6446c093..2114c882f 100644 --- a/test/objectFromPairs/objectFromPairs.js +++ b/test/objectFromPairs/objectFromPairs.js @@ -1 +1,2 @@ -module.exports = objectFromPairs = arr => arr.reduce((a, v) => ((a[v[0]] = v[1]), a), {}); \ No newline at end of file +const objectFromPairs = arr => arr.reduce((a, v) => ((a[v[0]] = v[1]), a), {}); + module.exports = objectFromPairs \ No newline at end of file diff --git a/test/objectToPairs/objectToPairs.js b/test/objectToPairs/objectToPairs.js index 7fe20163a..0f06a0cbe 100644 --- a/test/objectToPairs/objectToPairs.js +++ b/test/objectToPairs/objectToPairs.js @@ -1 +1,2 @@ -module.exports = objectToPairs = obj => Object.keys(obj).map(k => [k, obj[k]]); \ No newline at end of file +const objectToPairs = obj => Object.keys(obj).map(k => [k, obj[k]]); + module.exports = objectToPairs \ No newline at end of file diff --git a/test/observeMutations/observeMutations.js b/test/observeMutations/observeMutations.js index 15a462fac..065f7fff3 100644 --- a/test/observeMutations/observeMutations.js +++ b/test/observeMutations/observeMutations.js @@ -1,4 +1,4 @@ -module.exports = observeMutations = (element, callback, options) => { +const observeMutations = (element, callback, options) => { const observer = new MutationObserver(mutations => mutations.forEach(m => callback(m))); observer.observe( element, @@ -15,4 +15,5 @@ options ) ); return observer; -}; \ No newline at end of file +}; + module.exports = observeMutations \ No newline at end of file diff --git a/test/off/off.js b/test/off/off.js index 8da0bc5a7..94c2aa43d 100644 --- a/test/off/off.js +++ b/test/off/off.js @@ -1 +1,2 @@ -module.exports = off = (el, evt, fn, opts = false) => el.removeEventListener(evt, fn, opts); \ No newline at end of file +const off = (el, evt, fn, opts = false) => el.removeEventListener(evt, fn, opts); + module.exports = off \ No newline at end of file diff --git a/test/on/on.js b/test/on/on.js index cf1dfeb4a..12c958ab5 100644 --- a/test/on/on.js +++ b/test/on/on.js @@ -1,5 +1,6 @@ -module.exports = on = (el, evt, fn, opts = {}) => { +const on = (el, evt, fn, opts = {}) => { const delegatorFn = e => e.target.matches(opts.target) && fn.call(e.target, e); el.addEventListener(evt, opts.target ? delegatorFn : fn, opts.options || false); if (opts.target) return delegatorFn; -}; \ No newline at end of file +}; + module.exports = on \ No newline at end of file diff --git a/test/onUserInputChange/onUserInputChange.js b/test/onUserInputChange/onUserInputChange.js index 9c090a6ac..13cd2b44f 100644 --- a/test/onUserInputChange/onUserInputChange.js +++ b/test/onUserInputChange/onUserInputChange.js @@ -1,4 +1,4 @@ -module.exports = onUserInputChange = callback => { +const onUserInputChange = callback => { let type = 'mouse', lastTime = 0; const mousemoveHandler = () => { @@ -11,4 +11,5 @@ document.addEventListener('touchstart', () => { if (type === 'touch') return; (type = 'touch'), callback(type), document.addEventListener('mousemove', mousemoveHandler); }); -}; \ No newline at end of file +}; + module.exports = onUserInputChange \ No newline at end of file diff --git a/test/once/once.js b/test/once/once.js index a7d795efb..36225aa17 100644 --- a/test/once/once.js +++ b/test/once/once.js @@ -1,8 +1,9 @@ -module.exports = once = fn => { +const once = fn => { let called = false; return function(...args) { if (called) return; called = true; return fn.apply(this, args); }; -}; \ No newline at end of file +}; + module.exports = once \ No newline at end of file diff --git a/test/orderBy/orderBy.js b/test/orderBy/orderBy.js index 23b6eae03..e7db465e5 100644 --- a/test/orderBy/orderBy.js +++ b/test/orderBy/orderBy.js @@ -1,4 +1,4 @@ -module.exports = orderBy = (arr, props, orders) => +const orderBy = (arr, props, orders) => [...arr].sort((a, b) => props.reduce((acc, prop, i) => { if (acc === 0) { @@ -7,4 +7,5 @@ acc = p1 > p2 ? 1 : p1 < p2 ? -1 : 0; } return acc; }, 0) -); \ No newline at end of file +); + module.exports = orderBy \ No newline at end of file diff --git a/test/palindrome/palindrome.js b/test/palindrome/palindrome.js index abbff943c..59557dcd3 100644 --- a/test/palindrome/palindrome.js +++ b/test/palindrome/palindrome.js @@ -1,4 +1,4 @@ -module.exports = palindrome = str => { +const palindrome = str => { const s = str.toLowerCase().replace(/[\W_]/g, ''); return ( s === @@ -7,4 +7,5 @@ s .reverse() .join('') ); -}; \ No newline at end of file +}; + module.exports = palindrome \ No newline at end of file diff --git a/test/parseCookie/parseCookie.js b/test/parseCookie/parseCookie.js index d05ea6cf4..20dcb1039 100644 --- a/test/parseCookie/parseCookie.js +++ b/test/parseCookie/parseCookie.js @@ -1,8 +1,9 @@ -module.exports = parseCookie = str => +const parseCookie = str => str .split(';') .map(v => v.split('=')) .reduce((acc, v) => { acc[decodeURIComponent(v[0].trim())] = decodeURIComponent(v[1].trim()); return acc; -}, {}); \ No newline at end of file +}, {}); + module.exports = parseCookie \ No newline at end of file diff --git a/test/partition/partition.js b/test/partition/partition.js index a19d1b9bd..9acd0309f 100644 --- a/test/partition/partition.js +++ b/test/partition/partition.js @@ -1,8 +1,9 @@ -module.exports = partition = (arr, fn) => +const partition = (arr, fn) => arr.reduce( (acc, val, i, arr) => { acc[fn(val, i, arr) ? 0 : 1].push(val); return acc; }, [[], []] -); \ No newline at end of file +); + module.exports = partition \ No newline at end of file diff --git a/test/percentile/percentile.js b/test/percentile/percentile.js index 7d4a3b869..b345bb0d8 100644 --- a/test/percentile/percentile.js +++ b/test/percentile/percentile.js @@ -1,2 +1,3 @@ -module.exports = percentile = (arr, val) => -100 * arr.reduce((acc, v) => acc + (v < val ? 1 : 0) + (v === val ? 0.5 : 0), 0) / arr.length; \ No newline at end of file +const percentile = (arr, val) => +100 * arr.reduce((acc, v) => acc + (v < val ? 1 : 0) + (v === val ? 0.5 : 0), 0) / arr.length; + module.exports = percentile \ No newline at end of file diff --git a/test/pick/pick.js b/test/pick/pick.js index 54c51376b..465a5373a 100644 --- a/test/pick/pick.js +++ b/test/pick/pick.js @@ -1,2 +1,3 @@ -module.exports = pick = (obj, arr) => -arr.reduce((acc, curr) => (curr in obj && (acc[curr] = obj[curr]), acc), {}); \ No newline at end of file +const pick = (obj, arr) => +arr.reduce((acc, curr) => (curr in obj && (acc[curr] = obj[curr]), acc), {}); + module.exports = pick \ No newline at end of file diff --git a/test/pipeFunctions/pipeFunctions.js b/test/pipeFunctions/pipeFunctions.js index 0e7835724..ea4ac5fb1 100644 --- a/test/pipeFunctions/pipeFunctions.js +++ b/test/pipeFunctions/pipeFunctions.js @@ -1 +1,2 @@ -module.exports = pipeFunctions = (...fns) => fns.reduce((f, g) => (...args) => g(f(...args))); \ No newline at end of file +const pipeFunctions = (...fns) => fns.reduce((f, g) => (...args) => g(f(...args))); + module.exports = pipeFunctions \ No newline at end of file diff --git a/test/pluralize/pluralize.js b/test/pluralize/pluralize.js index 1db41faff..df86b72dd 100644 --- a/test/pluralize/pluralize.js +++ b/test/pluralize/pluralize.js @@ -1,6 +1,7 @@ -module.exports = pluralize = (val, word, plural = word + 's') => { +const pluralize = (val, word, plural = word + 's') => { const _pluralize = (num, word, plural = word + 's') => [1, -1].includes(Number(num)) ? word : plural; if (typeof val === 'object') return (num, word) => _pluralize(num, word, val[word]); return _pluralize(val, word, plural); -}; \ No newline at end of file +}; + module.exports = pluralize \ No newline at end of file diff --git a/test/powerset/powerset.js b/test/powerset/powerset.js index d4bb1959a..0e71c52b1 100644 --- a/test/powerset/powerset.js +++ b/test/powerset/powerset.js @@ -1 +1,2 @@ -module.exports = powerset = arr => arr.reduce((a, v) => a.concat(a.map(r => [v].concat(r))), [[]]); \ No newline at end of file +const powerset = arr => arr.reduce((a, v) => a.concat(a.map(r => [v].concat(r))), [[]]); + module.exports = powerset \ No newline at end of file diff --git a/test/prettyBytes/prettyBytes.js b/test/prettyBytes/prettyBytes.js index 173f1d317..dc5d0a5a1 100644 --- a/test/prettyBytes/prettyBytes.js +++ b/test/prettyBytes/prettyBytes.js @@ -1,7 +1,8 @@ -module.exports = prettyBytes = (num, precision = 3, addSpace = true) => { +const prettyBytes = (num, precision = 3, addSpace = true) => { const UNITS = ['B', 'KB', 'MB', 'GB', 'TB', 'PB', 'EB', 'ZB', 'YB']; if (Math.abs(num) < 1) return num + (addSpace ? ' ' : '') + UNITS[0]; const exponent = Math.min(Math.floor(Math.log10(num < 0 ? -num : num) / 3), UNITS.length - 1); const n = Number(((num < 0 ? -num : num) / 1000 ** exponent).toPrecision(precision)); return (num < 0 ? '-' : '') + n + (addSpace ? ' ' : '') + UNITS[exponent]; -}; \ No newline at end of file +}; + module.exports = prettyBytes \ No newline at end of file diff --git a/test/primes/primes.js b/test/primes/primes.js index 84b2e7c76..3ac251eed 100644 --- a/test/primes/primes.js +++ b/test/primes/primes.js @@ -1,7 +1,8 @@ -module.exports = primes = num => { +const primes = num => { let arr = Array.from({ length: num - 1 }).map((x, i) => i + 2), sqroot = Math.floor(Math.sqrt(num)), numsTillSqroot = Array.from({ length: sqroot - 1 }).map((x, i) => i + 2); numsTillSqroot.forEach(x => (arr = arr.filter(y => y % x !== 0 || y == x))); return arr; -}; \ No newline at end of file +}; + module.exports = primes \ No newline at end of file diff --git a/test/promisify/promisify.js b/test/promisify/promisify.js index 945c475c6..a642e309e 100644 --- a/test/promisify/promisify.js +++ b/test/promisify/promisify.js @@ -1,4 +1,5 @@ -module.exports = promisify = func => (...args) => +const promisify = func => (...args) => new Promise((resolve, reject) => func(...args, (err, result) => (err ? reject(err) : resolve(result))) -); \ No newline at end of file +); + module.exports = promisify \ No newline at end of file diff --git a/test/pull/pull.js b/test/pull/pull.js index dc98d8cc6..08e191399 100644 --- a/test/pull/pull.js +++ b/test/pull/pull.js @@ -1,6 +1,7 @@ -module.exports = pull = (arr, ...args) => { +const pull = (arr, ...args) => { let argState = Array.isArray(args[0]) ? args[0] : args; let pulled = arr.filter((v, i) => !argState.includes(v)); arr.length = 0; pulled.forEach(v => arr.push(v)); -}; \ No newline at end of file +}; + module.exports = pull \ No newline at end of file diff --git a/test/pullAtIndex/pullAtIndex.js b/test/pullAtIndex/pullAtIndex.js index 9bb222ec7..965071754 100644 --- a/test/pullAtIndex/pullAtIndex.js +++ b/test/pullAtIndex/pullAtIndex.js @@ -1,4 +1,4 @@ -module.exports = pullAtIndex = (arr, pullArr) => { +const pullAtIndex = (arr, pullArr) => { let removed = []; let pulled = arr .map((v, i) => (pullArr.includes(i) ? removed.push(v) : v)) @@ -6,4 +6,5 @@ let pulled = arr arr.length = 0; pulled.forEach(v => arr.push(v)); return removed; -}; \ No newline at end of file +}; + module.exports = pullAtIndex \ No newline at end of file diff --git a/test/pullAtValue/pullAtValue.js b/test/pullAtValue/pullAtValue.js index d756c88d1..db317da51 100644 --- a/test/pullAtValue/pullAtValue.js +++ b/test/pullAtValue/pullAtValue.js @@ -1,8 +1,9 @@ -module.exports = pullAtValue = (arr, pullArr) => { +const pullAtValue = (arr, pullArr) => { let removed = [], pushToRemove = arr.forEach((v, i) => (pullArr.includes(v) ? removed.push(v) : v)), mutateTo = arr.filter((v, i) => !pullArr.includes(v)); arr.length = 0; mutateTo.forEach(v => arr.push(v)); return removed; -}; \ No newline at end of file +}; + module.exports = pullAtValue \ No newline at end of file diff --git a/test/quickSort/quickSort.js b/test/quickSort/quickSort.js index e934c3247..06075d924 100644 --- a/test/quickSort/quickSort.js +++ b/test/quickSort/quickSort.js @@ -1,8 +1,9 @@ -module.exports = quickSort = ([n, ...nums], desc) => +const quickSort = ([n, ...nums], desc) => isNaN(n) ? [] : [ ...quickSort(nums.filter(v => (desc ? v > n : v <= n)), desc), n, ...quickSort(nums.filter(v => (!desc ? v > n : v <= n)), desc) -]; \ No newline at end of file +]; + module.exports = quickSort \ No newline at end of file diff --git a/test/randomHexColorCode/randomHexColorCode.js b/test/randomHexColorCode/randomHexColorCode.js index 84e165e36..ae49ab185 100644 --- a/test/randomHexColorCode/randomHexColorCode.js +++ b/test/randomHexColorCode/randomHexColorCode.js @@ -1,4 +1,5 @@ -module.exports = randomHexColorCode = () => { +const randomHexColorCode = () => { let n = ((Math.random() * 0xfffff) | 0).toString(16); return '#' + (n.length !== 6 ? ((Math.random() * 0xf) | 0).toString(16) + n : n); -}; \ No newline at end of file +}; + module.exports = randomHexColorCode \ No newline at end of file diff --git a/test/randomIntArrayInRange/randomIntArrayInRange.js b/test/randomIntArrayInRange/randomIntArrayInRange.js index 1f392f255..74c999acc 100644 --- a/test/randomIntArrayInRange/randomIntArrayInRange.js +++ b/test/randomIntArrayInRange/randomIntArrayInRange.js @@ -1,2 +1,3 @@ -module.exports = randomIntArrayInRange = (min, max, n = 1) => -Array.from({ length: n }, () => Math.floor(Math.random() * (max - min + 1)) + min); \ No newline at end of file +const randomIntArrayInRange = (min, max, n = 1) => +Array.from({ length: n }, () => Math.floor(Math.random() * (max - min + 1)) + min); + module.exports = randomIntArrayInRange \ No newline at end of file diff --git a/test/randomIntegerInRange/randomIntegerInRange.js b/test/randomIntegerInRange/randomIntegerInRange.js index c65200432..7c6ad38db 100644 --- a/test/randomIntegerInRange/randomIntegerInRange.js +++ b/test/randomIntegerInRange/randomIntegerInRange.js @@ -1 +1,2 @@ -module.exports = randomIntegerInRange = (min, max) => Math.floor(Math.random() * (max - min + 1)) + min; \ No newline at end of file +const randomIntegerInRange = (min, max) => Math.floor(Math.random() * (max - min + 1)) + min; + module.exports = randomIntegerInRange \ No newline at end of file diff --git a/test/randomNumberInRange/randomNumberInRange.js b/test/randomNumberInRange/randomNumberInRange.js index 8ff0b7d5d..15a6d3169 100644 --- a/test/randomNumberInRange/randomNumberInRange.js +++ b/test/randomNumberInRange/randomNumberInRange.js @@ -1 +1,2 @@ -module.exports = randomNumberInRange = (min, max) => Math.random() * (max - min) + min; \ No newline at end of file +const randomNumberInRange = (min, max) => Math.random() * (max - min) + min; + module.exports = randomNumberInRange \ No newline at end of file diff --git a/test/readFileLines/readFileLines.js b/test/readFileLines/readFileLines.js new file mode 100644 index 000000000..8e7db19aa --- /dev/null +++ b/test/readFileLines/readFileLines.js @@ -0,0 +1,7 @@ +const fs = require('fs'); +const readFileLines = filename => +fs +.readFileSync(filename) +.toString('UTF8') +.split('\n'); + module.exports = readFileLines \ No newline at end of file diff --git a/test/readFileLines/readFileLines.test.js b/test/readFileLines/readFileLines.test.js new file mode 100644 index 000000000..481741a58 --- /dev/null +++ b/test/readFileLines/readFileLines.test.js @@ -0,0 +1,13 @@ +const test = require('tape'); +const readFileLines = require('./readFileLines.js'); + +test('Testing readFileLines', (t) => { + //For more information on all the methods supported by tape + //Please go to https://github.com/substack/tape + t.true(typeof readFileLines === 'function', 'readFileLines is a Function'); + //t.deepEqual(readFileLines(args..), 'Expected'); + //t.equal(readFileLines(args..), 'Expected'); + //t.false(readFileLines(args..), 'Expected'); + //t.throws(readFileLines(args..), 'Expected'); + t.end(); +}); \ No newline at end of file diff --git a/test/redirect/redirect.js b/test/redirect/redirect.js index 4bcc6c690..f7cecfd2b 100644 --- a/test/redirect/redirect.js +++ b/test/redirect/redirect.js @@ -1,2 +1,3 @@ -module.exports = redirect = (url, asLink = true) => -asLink ? (window.location.href = url) : window.location.replace(url); \ No newline at end of file +const redirect = (url, asLink = true) => +asLink ? (window.location.href = url) : window.location.replace(url); + module.exports = redirect \ No newline at end of file diff --git a/test/reducedFilter/reducedFilter.js b/test/reducedFilter/reducedFilter.js index 8e8cd4f34..778c6179f 100644 --- a/test/reducedFilter/reducedFilter.js +++ b/test/reducedFilter/reducedFilter.js @@ -1,7 +1,8 @@ -module.exports = reducedFilter = (data, keys, fn) => +const reducedFilter = (data, keys, fn) => data.filter(fn).map(el => keys.reduce((acc, key) => { acc[key] = el[key]; return acc; }, {}) -); \ No newline at end of file +); + module.exports = reducedFilter \ No newline at end of file diff --git a/test/remove/remove.js b/test/remove/remove.js index 300e10348..75afb01bc 100644 --- a/test/remove/remove.js +++ b/test/remove/remove.js @@ -1,7 +1,8 @@ -module.exports = remove = (arr, func) => +const remove = (arr, func) => Array.isArray(arr) ? arr.filter(func).reduce((acc, val) => { arr.splice(arr.indexOf(val), 1); return acc.concat(val); }, []) -: []; \ No newline at end of file +: []; + module.exports = remove \ No newline at end of file diff --git a/test/removeVowels/removeVowels.js b/test/removeVowels/removeVowels.js index 42006eb0c..770f01b90 100644 --- a/test/removeVowels/removeVowels.js +++ b/test/removeVowels/removeVowels.js @@ -1 +1,2 @@ -module.exports = removeVowels = (str, repl = '') => str.replace(/[aeiou]/gi,repl); \ No newline at end of file +const removeVowels = (str, repl = '') => str.replace(/[aeiou]/gi,repl); + module.exports = removeVowels \ No newline at end of file diff --git a/test/reverseString/reverseString.js b/test/reverseString/reverseString.js index f2ac18832..b5abbf1d5 100644 --- a/test/reverseString/reverseString.js +++ b/test/reverseString/reverseString.js @@ -1 +1,2 @@ -module.exports = reverseString = str => [...str].reverse().join(''); \ No newline at end of file +const reverseString = str => [...str].reverse().join(''); + module.exports = reverseString \ No newline at end of file diff --git a/test/round/round.js b/test/round/round.js index 162c56284..778e00441 100644 --- a/test/round/round.js +++ b/test/round/round.js @@ -1 +1,2 @@ -module.exports = round = (n, decimals = 0) => Number(`${Math.round(`${n}e${decimals}`)}e-${decimals}`); \ No newline at end of file +const round = (n, decimals = 0) => Number(`${Math.round(`${n}e${decimals}`)}e-${decimals}`); + module.exports = round \ No newline at end of file diff --git a/test/runAsync/runAsync.js b/test/runAsync/runAsync.js index 6769a3672..1778fde70 100644 --- a/test/runAsync/runAsync.js +++ b/test/runAsync/runAsync.js @@ -1,4 +1,4 @@ -module.exports = runAsync = fn => { +const runAsync = fn => { const blob = `var fn = ${fn.toString()}; postMessage(fn());`; const worker = new Worker( URL.createObjectURL(new Blob([blob]), { @@ -13,4 +13,5 @@ worker.onerror = err => { rej(err), worker.terminate(); }; }); -}; \ No newline at end of file +}; + module.exports = runAsync \ No newline at end of file diff --git a/test/runPromisesInSeries/runPromisesInSeries.js b/test/runPromisesInSeries/runPromisesInSeries.js index 5985d538e..ced59e23e 100644 --- a/test/runPromisesInSeries/runPromisesInSeries.js +++ b/test/runPromisesInSeries/runPromisesInSeries.js @@ -1 +1,2 @@ -module.exports = runPromisesInSeries = ps => ps.reduce((p, next) => p.then(next), Promise.resolve()); \ No newline at end of file +const runPromisesInSeries = ps => ps.reduce((p, next) => p.then(next), Promise.resolve()); + module.exports = runPromisesInSeries \ No newline at end of file diff --git a/test/sample/sample.js b/test/sample/sample.js index 5664f4197..992949efe 100644 --- a/test/sample/sample.js +++ b/test/sample/sample.js @@ -1 +1,2 @@ -module.exports = sample = arr => arr[Math.floor(Math.random() * arr.length)]; \ No newline at end of file +const sample = arr => arr[Math.floor(Math.random() * arr.length)]; + module.exports = sample \ No newline at end of file diff --git a/test/sampleSize/sampleSize.js b/test/sampleSize/sampleSize.js index cb7796b38..231810f54 100644 --- a/test/sampleSize/sampleSize.js +++ b/test/sampleSize/sampleSize.js @@ -1,8 +1,9 @@ -module.exports = sampleSize = ([...arr], n = 1) => { +const sampleSize = ([...arr], n = 1) => { let m = arr.length; while (m) { const i = Math.floor(Math.random() * m--); [arr[m], arr[i]] = [arr[i], arr[m]]; } return arr.slice(0, n); -}; \ No newline at end of file +}; + module.exports = sampleSize \ No newline at end of file diff --git a/test/scrollToTop/scrollToTop.js b/test/scrollToTop/scrollToTop.js index 903a98d44..d45b2a44e 100644 --- a/test/scrollToTop/scrollToTop.js +++ b/test/scrollToTop/scrollToTop.js @@ -1,7 +1,8 @@ -module.exports = scrollToTop = () => { +const scrollToTop = () => { const c = document.documentElement.scrollTop || document.body.scrollTop; if (c > 0) { window.requestAnimationFrame(scrollToTop); window.scrollTo(0, c - c / 8); } -}; \ No newline at end of file +}; + module.exports = scrollToTop \ No newline at end of file diff --git a/test/sdbm/sdbm.js b/test/sdbm/sdbm.js index 17eb2a60b..ff9012a7f 100644 --- a/test/sdbm/sdbm.js +++ b/test/sdbm/sdbm.js @@ -1,8 +1,9 @@ -module.exports = sdbm = str => { +const sdbm = str => { let arr = str.split(''); return arr.reduce( (hashCode, currentVal) => (hashCode = currentVal.charCodeAt(0) + (hashCode << 6) + (hashCode << 16) - hashCode), 0 ); -}; \ No newline at end of file +}; + module.exports = sdbm \ No newline at end of file diff --git a/test/select/select.js b/test/select/select.js index ab3fea695..58ef08f84 100644 --- a/test/select/select.js +++ b/test/select/select.js @@ -1,2 +1,3 @@ -module.exports = select = (from, ...selectors) => -[...selectors].map(s => s.split('.').reduce((prev, cur) => prev && prev[cur], from)); \ No newline at end of file +const select = (from, ...selectors) => +[...selectors].map(s => s.split('.').reduce((prev, cur) => prev && prev[cur], from)); + module.exports = select \ No newline at end of file diff --git a/test/serializeCookie/serializeCookie.js b/test/serializeCookie/serializeCookie.js index 16467650a..ed4f462a7 100644 --- a/test/serializeCookie/serializeCookie.js +++ b/test/serializeCookie/serializeCookie.js @@ -1 +1,2 @@ -module.exports = serializeCookie = (name, val) => `${encodeURIComponent(name)}=${encodeURIComponent(val)}`; \ No newline at end of file +const serializeCookie = (name, val) => `${encodeURIComponent(name)}=${encodeURIComponent(val)}`; + module.exports = serializeCookie \ No newline at end of file diff --git a/test/setStyle/setStyle.js b/test/setStyle/setStyle.js index f4b2497df..71db449eb 100644 --- a/test/setStyle/setStyle.js +++ b/test/setStyle/setStyle.js @@ -1 +1,2 @@ -module.exports = setStyle = (el, ruleName, val) => (el.style[ruleName] = val); \ No newline at end of file +const setStyle = (el, ruleName, val) => (el.style[ruleName] = val); + module.exports = setStyle \ No newline at end of file diff --git a/test/shallowClone/shallowClone.js b/test/shallowClone/shallowClone.js index b6e070181..8247d3f8e 100644 --- a/test/shallowClone/shallowClone.js +++ b/test/shallowClone/shallowClone.js @@ -1 +1,2 @@ -module.exports = shallowClone = obj => Object.assign({}, obj); \ No newline at end of file +const shallowClone = obj => Object.assign({}, obj); + module.exports = shallowClone \ No newline at end of file diff --git a/test/show/show.js b/test/show/show.js index 29c808b20..db22eab4f 100644 --- a/test/show/show.js +++ b/test/show/show.js @@ -1 +1,2 @@ -module.exports = show = (...el) => [...el].forEach(e => (e.style.display = '')); \ No newline at end of file +const show = (...el) => [...el].forEach(e => (e.style.display = '')); + module.exports = show \ No newline at end of file diff --git a/test/shuffle/shuffle.js b/test/shuffle/shuffle.js index 35ba6b488..d2d3980ee 100644 --- a/test/shuffle/shuffle.js +++ b/test/shuffle/shuffle.js @@ -1,8 +1,9 @@ -module.exports = shuffle = ([...arr]) => { +const shuffle = ([...arr]) => { let m = arr.length; while (m) { const i = Math.floor(Math.random() * m--); [arr[m], arr[i]] = [arr[i], arr[m]]; } return arr; -}; \ No newline at end of file +}; + module.exports = shuffle \ No newline at end of file diff --git a/test/similarity/similarity.js b/test/similarity/similarity.js index 624398364..3a3cc41e5 100644 --- a/test/similarity/similarity.js +++ b/test/similarity/similarity.js @@ -1 +1,2 @@ -module.exports = similarity = (arr, values) => arr.filter(v => values.includes(v)); \ No newline at end of file +const similarity = (arr, values) => arr.filter(v => values.includes(v)); + module.exports = similarity \ No newline at end of file diff --git a/test/size/size.js b/test/size/size.js index fe0a268d5..639c8351f 100644 --- a/test/size/size.js +++ b/test/size/size.js @@ -1,6 +1,7 @@ -module.exports = size = val => +const size = val => Array.isArray(val) ? val.length : val && typeof val === 'object' ? val.size || val.length || Object.keys(val).length -: typeof val === 'string' ? new Blob([val]).size : 0; \ No newline at end of file +: typeof val === 'string' ? new Blob([val]).size : 0; + module.exports = size \ No newline at end of file diff --git a/test/sleep/sleep.js b/test/sleep/sleep.js index 288fb7cad..4cfc9e189 100644 --- a/test/sleep/sleep.js +++ b/test/sleep/sleep.js @@ -1 +1,2 @@ -module.exports = sleep = ms => new Promise(resolve => setTimeout(resolve, ms)); \ No newline at end of file +const sleep = ms => new Promise(resolve => setTimeout(resolve, ms)); + module.exports = sleep \ No newline at end of file diff --git a/test/solveRPN/solveRPN.js b/test/solveRPN/solveRPN.js index 8bd4f105c..43e3d509a 100644 --- a/test/solveRPN/solveRPN.js +++ b/test/solveRPN/solveRPN.js @@ -1,4 +1,4 @@ -module.exports = solveRPN = rpn => { +const solveRPN = rpn => { const OPERATORS = { '*': (a, b) => a * b, '+': (a, b) => a + b, @@ -25,4 +25,5 @@ throw `${symbol} is not a recognized symbol`; }); if (stack.length === 1) return stack.pop(); else throw `${rpn} is not a proper RPN. Please check it and try again`; -}; \ No newline at end of file +}; + module.exports = solveRPN \ No newline at end of file diff --git a/test/sortCharactersInString/sortCharactersInString.js b/test/sortCharactersInString/sortCharactersInString.js index 526c646ef..74e6f2811 100644 --- a/test/sortCharactersInString/sortCharactersInString.js +++ b/test/sortCharactersInString/sortCharactersInString.js @@ -1 +1,2 @@ -module.exports = sortCharactersInString = str => [...str].sort((a, b) => a.localeCompare(b)).join(''); \ No newline at end of file +const sortCharactersInString = str => [...str].sort((a, b) => a.localeCompare(b)).join(''); + module.exports = sortCharactersInString \ No newline at end of file diff --git a/test/sortedIndex/sortedIndex.js b/test/sortedIndex/sortedIndex.js index 8e7e26b10..b4eb24061 100644 --- a/test/sortedIndex/sortedIndex.js +++ b/test/sortedIndex/sortedIndex.js @@ -1,5 +1,6 @@ -module.exports = sortedIndex = (arr, n) => { +const sortedIndex = (arr, n) => { const isDescending = arr[0] > arr[arr.length - 1]; const index = arr.findIndex(el => (isDescending ? n >= el : n <= el)); return index === -1 ? arr.length : index; -}; \ No newline at end of file +}; + module.exports = sortedIndex \ No newline at end of file diff --git a/test/speechSynthesis/speechSynthesis.js b/test/speechSynthesis/speechSynthesis.js index a174e4c92..eff6d4ce7 100644 --- a/test/speechSynthesis/speechSynthesis.js +++ b/test/speechSynthesis/speechSynthesis.js @@ -1,5 +1,6 @@ -module.exports = speechSynthesis = message => { +const speechSynthesis = message => { const msg = new SpeechSynthesisUtterance(message); msg.voice = window.speechSynthesis.getVoices()[0]; window.speechSynthesis.speak(msg); -}; \ No newline at end of file +}; + module.exports = speechSynthesis \ No newline at end of file diff --git a/test/splitLines/splitLines.js b/test/splitLines/splitLines.js index c1db2f580..b112b6e0f 100644 --- a/test/splitLines/splitLines.js +++ b/test/splitLines/splitLines.js @@ -1 +1,2 @@ -module.exports = splitLines = str => str.split(/\r?\n/); \ No newline at end of file +const splitLines = str => str.split(/\r?\n/); + module.exports = splitLines \ No newline at end of file diff --git a/test/spreadOver/spreadOver.js b/test/spreadOver/spreadOver.js index 792f39794..0048bff7f 100644 --- a/test/spreadOver/spreadOver.js +++ b/test/spreadOver/spreadOver.js @@ -1 +1,2 @@ -module.exports = spreadOver = fn => argsArr => fn(...argsArr); \ No newline at end of file +const spreadOver = fn => argsArr => fn(...argsArr); + module.exports = spreadOver \ No newline at end of file diff --git a/test/standardDeviation/standardDeviation.js b/test/standardDeviation/standardDeviation.js index 953e80499..e9a033e68 100644 --- a/test/standardDeviation/standardDeviation.js +++ b/test/standardDeviation/standardDeviation.js @@ -1,7 +1,8 @@ -module.exports = standardDeviation = (arr, usePopulation = false) => { +const standardDeviation = (arr, usePopulation = false) => { const mean = arr.reduce((acc, val) => acc + val, 0) / arr.length; return Math.sqrt( arr.reduce((acc, val) => acc.concat((val - mean) ** 2), []).reduce((acc, val) => acc + val, 0) / (arr.length - (usePopulation ? 0 : 1)) ); -}; \ No newline at end of file +}; + module.exports = standardDeviation \ No newline at end of file diff --git a/test/sum/sum.js b/test/sum/sum.js index 3908fbb67..22db1d186 100644 --- a/test/sum/sum.js +++ b/test/sum/sum.js @@ -1 +1,2 @@ -module.exports = sum = (...arr) => [...arr].reduce((acc, val) => acc + val, 0); \ No newline at end of file +const sum = (...arr) => [...arr].reduce((acc, val) => acc + val, 0); + module.exports = sum \ No newline at end of file diff --git a/test/sumBy/sumBy.js b/test/sumBy/sumBy.js index f12789d24..4c499baf5 100644 --- a/test/sumBy/sumBy.js +++ b/test/sumBy/sumBy.js @@ -1,2 +1,3 @@ -module.exports = sumBy = (arr, fn) => -arr.map(typeof fn === 'function' ? fn : val => val[fn]).reduce((acc, val) => acc + val, 0); \ No newline at end of file +const sumBy = (arr, fn) => +arr.map(typeof fn === 'function' ? fn : val => val[fn]).reduce((acc, val) => acc + val, 0); + module.exports = sumBy \ No newline at end of file diff --git a/test/sumPower/sumPower.js b/test/sumPower/sumPower.js index a904a5eaa..51b80ab57 100644 --- a/test/sumPower/sumPower.js +++ b/test/sumPower/sumPower.js @@ -1,5 +1,6 @@ -module.exports = sumPower = (end, power = 2, start = 1) => +const sumPower = (end, power = 2, start = 1) => Array(end + 1 - start) .fill(0) .map((x, i) => (i + start) ** power) -.reduce((a, b) => a + b, 0); \ No newline at end of file +.reduce((a, b) => a + b, 0); + module.exports = sumPower \ No newline at end of file diff --git a/test/symmetricDifference/symmetricDifference.js b/test/symmetricDifference/symmetricDifference.js index 157a2ce92..862698500 100644 --- a/test/symmetricDifference/symmetricDifference.js +++ b/test/symmetricDifference/symmetricDifference.js @@ -1,5 +1,6 @@ -module.exports = symmetricDifference = (a, b) => { +const symmetricDifference = (a, b) => { const sA = new Set(a), sB = new Set(b); return [...a.filter(x => !sB.has(x)), ...b.filter(x => !sA.has(x))]; -}; \ No newline at end of file +}; + module.exports = symmetricDifference \ No newline at end of file diff --git a/test/tail/tail.js b/test/tail/tail.js index ddee48e18..4a32f24a3 100644 --- a/test/tail/tail.js +++ b/test/tail/tail.js @@ -1 +1,2 @@ -module.exports = tail = arr => (arr.length > 1 ? arr.slice(1) : arr); \ No newline at end of file +const tail = arr => (arr.length > 1 ? arr.slice(1) : arr); + module.exports = tail \ No newline at end of file diff --git a/test/take/take.js b/test/take/take.js index 38696604c..a5b82b446 100644 --- a/test/take/take.js +++ b/test/take/take.js @@ -1 +1,2 @@ -module.exports = take = (arr, n = 1) => arr.slice(0, n); \ No newline at end of file +const take = (arr, n = 1) => arr.slice(0, n); + module.exports = take \ No newline at end of file diff --git a/test/takeRight/takeRight.js b/test/takeRight/takeRight.js index 474aa19bf..b5bcef3d6 100644 --- a/test/takeRight/takeRight.js +++ b/test/takeRight/takeRight.js @@ -1 +1,2 @@ -module.exports = takeRight = (arr, n = 1) => arr.slice(arr.length - n, arr.length); \ No newline at end of file +const takeRight = (arr, n = 1) => arr.slice(arr.length - n, arr.length); + module.exports = takeRight \ No newline at end of file diff --git a/test/testlog b/test/testlog index 958ea9de0..d21866fa7 100644 --- a/test/testlog +++ b/test/testlog @@ -1,6 +1,6 @@ -Test log for: Tue Jan 16 2018 15:31:32 GMT+0200 (GTB Standard Time) +Test log for: Wed Jan 17 2018 13:39:53 GMT-0500 (Eastern Standard Time) -> 30-seconds-of-code@0.0.1 test G:\My Files\git Repositories\30-seconds-of-code +> 30-seconds-of-code@0.0.1 test C:\Users\King David\Desktop\github-repo\30-seconds-of-code > tape test/**/*.test.js | tap-spec @@ -193,11 +193,6 @@ Test log for: Tue Jan 16 2018 15:31:32 GMT+0200 (GTB Standard Time) √ distance is a Function - Testing distinctValuesOfArray - - √ distinctValuesOfArray is a Function - √ Returns all the distinct values of an array - Testing dropElements √ dropElements is a Function @@ -444,6 +439,10 @@ Test log for: Tue Jan 16 2018 15:31:32 GMT+0200 (GTB Standard Time) √ initializeArrayWithRange is a Function √ Initializes an array containing the numbers in the specified range + Testing initializeArrayWithRangeRight + + √ initializeArrayWithRangeRight is a Function + Testing initializeArrayWithValues √ initializeArrayWithValues is a Function @@ -484,6 +483,10 @@ Test log for: Tue Jan 16 2018 15:31:32 GMT+0200 (GTB Standard Time) √ passed value is an array √ passed value is not an array + Testing isArrayBuffer + + √ isArrayBuffer is a Function + Testing isArrayLike √ isArrayLike is a Function @@ -518,6 +521,14 @@ Test log for: Tue Jan 16 2018 15:31:32 GMT+0200 (GTB Standard Time) √ passed string is a lowercase √ passed value is not a lowercase + Testing isMap + + √ isMap is a Function + + Testing isNil + + √ isNil is a Function + Testing isNull √ isNull is a Function @@ -562,6 +573,14 @@ Test log for: Tue Jan 16 2018 15:31:32 GMT+0200 (GTB Standard Time) √ isPromiseLike is a Function + Testing isRegExp + + √ isRegExp is a Function + + Testing isSet + + √ isSet is a Function + Testing isSorted √ isSorted is a Function @@ -587,6 +606,14 @@ Test log for: Tue Jan 16 2018 15:31:32 GMT+0200 (GTB Standard Time) √ isTravisCI is a Function + Testing isTypedArray + + √ isTypedArray is a Function + + Testing isUndefined + + √ isUndefined is a Function + Testing isUpperCase √ isUpperCase is a Function @@ -601,6 +628,14 @@ Test log for: Tue Jan 16 2018 15:31:32 GMT+0200 (GTB Standard Time) √ {"name":"Adam",age:"20"} is not a valid JSON √ null is a valid JSON + Testing isWeakMap + + √ isWeakMap is a Function + + Testing isWeakSet + + √ isWeakSet is a Function + Testing join √ join is a Function @@ -612,6 +647,10 @@ Test log for: Tue Jan 16 2018 15:31:32 GMT+0200 (GTB Standard Time) √ JSONToDate is a Function + Testing JSONToFile + + √ JSONToFile is a Function + Testing last √ last is a Function @@ -723,7 +762,7 @@ Test log for: Tue Jan 16 2018 15:31:32 GMT+0200 (GTB Standard Time) Testing observeMutations - ✔ observeMutations is a Function + √ observeMutations is a Function Testing off @@ -841,6 +880,10 @@ Test log for: Tue Jan 16 2018 15:31:32 GMT+0200 (GTB Standard Time) √ randomNumberInRange is a Function + Testing readFileLines + + √ readFileLines is a Function + Testing README √ README is a Function @@ -1099,6 +1142,11 @@ Test log for: Tue Jan 16 2018 15:31:32 GMT+0200 (GTB Standard Time) √ union is a Function √ Returns every element that exists in any of the two arrays once + Testing uniqueElements + + √ uniqueElements is a Function + √ Returns all unique values of an array + Testing untildify √ untildify is a Function @@ -1113,48 +1161,96 @@ Test log for: Tue Jan 16 2018 15:31:32 GMT+0200 (GTB Standard Time) √ UUIDGeneratorBrowser is a Function + Testing UUIDGeneratorNode + + √ UUIDGeneratorNode is a Function + Testing validateNumber √ validateNumber is a Function - √ 9 is a number + √ validateNumber(9) returns true + √ validateNumber(234asd.slice(0, 2)) returns true + √ validateNumber(1232) returns true + √ validateNumber(1232 + 13423) returns true + √ validateNumber(1232 * 2342 * 123) returns true + √ validateNumber(1232.23423536) returns true + √ validateNumber(234asd) returns false + √ validateNumber(e234d) returns false + √ validateNumber(false) returns false + √ validateNumber(true) returns false + √ validateNumber(null) returns false + √ validateNumber(123 * asd) returns false Testing without √ without is a Function - √ Filters out the elements of an array, that have one of the specified values. + √ without([2, 1, 2, 3], 1, 2) returns [3] + √ without([]) returns [] + √ without([3, 1, true, '3', true], '3', true) returns [3, 1] + √ without('string'.split(''), 's', 't', 'g') returns ['r', 'i', 'n'] + √ without() throws an error + √ without(null) throws an error + √ without(undefined) throws an error + √ without() throws an error + √ without({}) throws an error Testing words √ words is a Function - √ Returns words from a string - √ Returns words from a string + √ words('I love javaScript!!') returns [I, love, javaScript] + √ words('python, javaScript & coffee') returns [python, javaScript, coffee] + √ words(I love javaScript!!) returns an array + √ words() throws a error + √ words(null) throws a error + √ words(undefined) throws a error + √ words({}) throws a error + √ words([]) throws a error + √ words(1234) throws a error Testing yesNo √ yesNo is a Function - √ Returns true as the provided string is y/yes - √ Returns true as the provided string is y/yes - √ Returns false as the provided string is n/no - √ Returns true since the 2nd argument is ommited + √ yesNo(Y) returns true + √ yesNo(yes) returns true + √ yesNo(foo, true) returns true + √ yesNo(No) returns false + √ yesNo() returns false + √ yesNo(null) returns false + √ yesNo(undefined) returns false + √ yesNo([123, null]) returns false + √ yesNo([Yes, No]) returns false + √ yesNo({ 2: Yes }) returns false + √ yesNo([Yes, No], true) returns true + √ yesNo({ 2: Yes }, true) returns true Testing zip √ zip is a Function - √ Object was zipped - √ Object was zipped - √ zip returns an Array - √ zip returns an Array + √ zip([a, b], [1, 2], [true, false]) returns [[a, 1, true], [b, 2, false]] + √ zip([a], [1, 2], [true, false]) returns [[a, 1, true], [undefined, 2, false]] + √ zip([]) returns [] + √ zip(123) returns [] + √ zip([a, b], [1, 2], [true, false]) returns an Array + √ zip([a], [1, 2], [true, false]) returns an Array + √ zip(null) throws an error + √ zip(undefined) throws an error Testing zipObject √ zipObject is a Function - √ Array was zipped to object - √ Array was zipped to object + √ zipObject([a, b, c], [1, 2]) returns {a: 1, b: 2, c: undefined} + √ zipObject([a, b], [1, 2, 3]) returns {a: 1, b: 2} + √ zipObject([a, b, c], string) returns { a: s, b: t, c: r } + √ zipObject([a], string) returns { a: s } + √ zipObject() throws an error + √ zipObject([string], null) throws an error + √ zipObject(null, [1]) throws an error + √ zipObject(string) throws an error + √ zipObject(test, string) throws an error - total: 492 - passing: 492 - duration: 345ms - + total: 551 + passing: 551 + duration: 399ms diff --git a/test/timeTaken/timeTaken.js b/test/timeTaken/timeTaken.js index 0a9213869..ae31b01a2 100644 --- a/test/timeTaken/timeTaken.js +++ b/test/timeTaken/timeTaken.js @@ -1,6 +1,7 @@ -module.exports = timeTaken = callback => { +const timeTaken = callback => { console.time('timeTaken'); const r = callback(); console.timeEnd('timeTaken'); return r; -}; \ No newline at end of file +}; + module.exports = timeTaken \ No newline at end of file diff --git a/test/toCamelCase/toCamelCase.js b/test/toCamelCase/toCamelCase.js index 4d84af388..44ee52a34 100644 --- a/test/toCamelCase/toCamelCase.js +++ b/test/toCamelCase/toCamelCase.js @@ -1,4 +1,4 @@ -module.exports = toCamelCase = str => { +const toCamelCase = str => { let s = str && str @@ -6,4 +6,5 @@ str .map(x => x.slice(0, 1).toUpperCase() + x.slice(1).toLowerCase()) .join(''); return s.slice(0, 1).toLowerCase() + s.slice(1); -}; \ No newline at end of file +}; + module.exports = toCamelCase \ No newline at end of file diff --git a/test/toDecimalMark/toDecimalMark.js b/test/toDecimalMark/toDecimalMark.js index 563c5efcb..e7de2e7d9 100644 --- a/test/toDecimalMark/toDecimalMark.js +++ b/test/toDecimalMark/toDecimalMark.js @@ -1 +1,2 @@ -module.exports = toDecimalMark = num => num.toLocaleString('en-US'); \ No newline at end of file +const toDecimalMark = num => num.toLocaleString('en-US'); + module.exports = toDecimalMark \ No newline at end of file diff --git a/test/toKebabCase/toKebabCase.js b/test/toKebabCase/toKebabCase.js index 16680f644..2b313a66d 100644 --- a/test/toKebabCase/toKebabCase.js +++ b/test/toKebabCase/toKebabCase.js @@ -1,6 +1,7 @@ -module.exports = toKebabCase = str => +const toKebabCase = str => str && str .match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g) .map(x => x.toLowerCase()) -.join('-'); \ No newline at end of file +.join('-'); + module.exports = toKebabCase \ No newline at end of file diff --git a/test/toOrdinalSuffix/toOrdinalSuffix.js b/test/toOrdinalSuffix/toOrdinalSuffix.js index 18e3c9d09..6afa22b31 100644 --- a/test/toOrdinalSuffix/toOrdinalSuffix.js +++ b/test/toOrdinalSuffix/toOrdinalSuffix.js @@ -1,4 +1,4 @@ -module.exports = toOrdinalSuffix = num => { +const toOrdinalSuffix = num => { const int = parseInt(num), digits = [int % 10, int % 100], ordinals = ['st', 'nd', 'rd', 'th'], @@ -7,4 +7,5 @@ tPattern = [11, 12, 13, 14, 15, 16, 17, 18, 19]; return oPattern.includes(digits[0]) && !tPattern.includes(digits[1]) ? int + ordinals[digits[0] - 1] : int + ordinals[3]; -}; \ No newline at end of file +}; + module.exports = toOrdinalSuffix \ No newline at end of file diff --git a/test/toSafeInteger/toSafeInteger.js b/test/toSafeInteger/toSafeInteger.js index 922725a93..166e465a4 100644 --- a/test/toSafeInteger/toSafeInteger.js +++ b/test/toSafeInteger/toSafeInteger.js @@ -1,2 +1,3 @@ -module.exports = toSafeInteger = num => -Math.round(Math.max(Math.min(num, Number.MAX_SAFE_INTEGER), Number.MIN_SAFE_INTEGER)); \ No newline at end of file +const toSafeInteger = num => +Math.round(Math.max(Math.min(num, Number.MAX_SAFE_INTEGER), Number.MIN_SAFE_INTEGER)); + module.exports = toSafeInteger \ No newline at end of file diff --git a/test/toSnakeCase/toSnakeCase.js b/test/toSnakeCase/toSnakeCase.js index 5011bd234..9fffb9201 100644 --- a/test/toSnakeCase/toSnakeCase.js +++ b/test/toSnakeCase/toSnakeCase.js @@ -1,6 +1,7 @@ -module.exports = toSnakeCase = str => +const toSnakeCase = str => str && str .match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g) .map(x => x.toLowerCase()) -.join('_'); \ No newline at end of file +.join('_'); + module.exports = toSnakeCase \ No newline at end of file diff --git a/test/toggleClass/toggleClass.js b/test/toggleClass/toggleClass.js index abb5ca097..2ad186b51 100644 --- a/test/toggleClass/toggleClass.js +++ b/test/toggleClass/toggleClass.js @@ -1 +1,2 @@ -module.exports = toggleClass = (el, className) => el.classList.toggle(className); \ No newline at end of file +const toggleClass = (el, className) => el.classList.toggle(className); + module.exports = toggleClass \ No newline at end of file diff --git a/test/tomorrow/tomorrow.js b/test/tomorrow/tomorrow.js index ab202df3d..5f70ab9af 100644 --- a/test/tomorrow/tomorrow.js +++ b/test/tomorrow/tomorrow.js @@ -1 +1,2 @@ -module.exports = tomorrow = () => new Date(new Date().getTime() + 86400000).toISOString().split('T')[0]; \ No newline at end of file +const tomorrow = () => new Date(new Date().getTime() + 86400000).toISOString().split('T')[0]; + module.exports = tomorrow \ No newline at end of file diff --git a/test/transform/transform.js b/test/transform/transform.js index d6cf8a9ab..e6f4c6ef8 100644 --- a/test/transform/transform.js +++ b/test/transform/transform.js @@ -1 +1,2 @@ -module.exports = transform = (obj, fn, acc) => Object.keys(obj).reduce((a, k) => fn(a, obj[k], k, obj), acc); \ No newline at end of file +const transform = (obj, fn, acc) => Object.keys(obj).reduce((a, k) => fn(a, obj[k], k, obj), acc); + module.exports = transform \ No newline at end of file diff --git a/test/truncateString/truncateString.js b/test/truncateString/truncateString.js index f2de7b8d1..307d0c12b 100644 --- a/test/truncateString/truncateString.js +++ b/test/truncateString/truncateString.js @@ -1,2 +1,3 @@ -module.exports = truncateString = (str, num) => -str.length > num ? str.slice(0, num > 3 ? num - 3 : num) + '...' : str; \ No newline at end of file +const truncateString = (str, num) => +str.length > num ? str.slice(0, num > 3 ? num - 3 : num) + '...' : str; + module.exports = truncateString \ No newline at end of file diff --git a/test/truthCheckCollection/truthCheckCollection.js b/test/truthCheckCollection/truthCheckCollection.js index 75a1892b8..3841a8dce 100644 --- a/test/truthCheckCollection/truthCheckCollection.js +++ b/test/truthCheckCollection/truthCheckCollection.js @@ -1 +1,2 @@ -module.exports = truthCheckCollection = (collection, pre) => collection.every(obj => obj[pre]); \ No newline at end of file +const truthCheckCollection = (collection, pre) => collection.every(obj => obj[pre]); + module.exports = truthCheckCollection \ No newline at end of file diff --git a/test/unescapeHTML/unescapeHTML.js b/test/unescapeHTML/unescapeHTML.js index 3c3927c23..c4b6c379e 100644 --- a/test/unescapeHTML/unescapeHTML.js +++ b/test/unescapeHTML/unescapeHTML.js @@ -1,4 +1,4 @@ -module.exports = unescapeHTML = str => +const unescapeHTML = str => str.replace( /&|<|>|'|"/g, tag => @@ -9,4 +9,5 @@ tag => ''': "'", '"': '"' }[tag] || tag) -); \ No newline at end of file +); + module.exports = unescapeHTML \ No newline at end of file diff --git a/test/union/union.js b/test/union/union.js index f5b2514ef..1f86c4442 100644 --- a/test/union/union.js +++ b/test/union/union.js @@ -1 +1,2 @@ -module.exports = union = (a, b) => Array.from(new Set([...a, ...b])); \ No newline at end of file +const union = (a, b) => Array.from(new Set([...a, ...b])); + module.exports = union \ No newline at end of file diff --git a/test/uniqueElements/uniqueElements.js b/test/uniqueElements/uniqueElements.js index 3ef175c0b..5e5b4315d 100644 --- a/test/uniqueElements/uniqueElements.js +++ b/test/uniqueElements/uniqueElements.js @@ -1 +1,2 @@ -module.exports = uniqueElements = arr => [...new Set(arr)]; \ No newline at end of file +const uniqueElements = arr => [...new Set(arr)]; + module.exports = uniqueElements \ No newline at end of file diff --git a/test/untildify/untildify.js b/test/untildify/untildify.js index 82e8476bf..a95120fb9 100644 --- a/test/untildify/untildify.js +++ b/test/untildify/untildify.js @@ -1 +1,2 @@ -module.exports = untildify = str => str.replace(/^~($|\/|\\)/, `${require('os').homedir()}$1`); \ No newline at end of file +const untildify = str => str.replace(/^~($|\/|\\)/, `${require('os').homedir()}$1`); + module.exports = untildify \ No newline at end of file diff --git a/test/validateNumber/validateNumber.js b/test/validateNumber/validateNumber.js index b4cd036e5..05e4a8a06 100644 --- a/test/validateNumber/validateNumber.js +++ b/test/validateNumber/validateNumber.js @@ -1 +1,2 @@ -module.exports = validateNumber = n => !isNaN(parseFloat(n)) && isFinite(n) && Number(n) == n; \ No newline at end of file +const validateNumber = n => !isNaN(parseFloat(n)) && isFinite(n) && Number(n) == n; + module.exports = validateNumber \ No newline at end of file diff --git a/test/without/without.js b/test/without/without.js index 7cdf4434b..ffd99a9d3 100644 --- a/test/without/without.js +++ b/test/without/without.js @@ -1 +1,2 @@ -module.exports = without = (arr, ...args) => arr.filter(v => !args.includes(v)); \ No newline at end of file +const without = (arr, ...args) => arr.filter(v => !args.includes(v)); + module.exports = without \ No newline at end of file diff --git a/test/words/words.js b/test/words/words.js index d6eabc94b..936b7d6ca 100644 --- a/test/words/words.js +++ b/test/words/words.js @@ -1 +1,2 @@ -module.exports = words = (str, pattern = /[^a-zA-Z-]+/) => str.split(pattern).filter(Boolean); \ No newline at end of file +const words = (str, pattern = /[^a-zA-Z-]+/) => str.split(pattern).filter(Boolean); + module.exports = words \ No newline at end of file diff --git a/test/yesNo/yesNo.js b/test/yesNo/yesNo.js index e9fb38b7b..437338d17 100644 --- a/test/yesNo/yesNo.js +++ b/test/yesNo/yesNo.js @@ -1,2 +1,3 @@ -module.exports = yesNo = (val, def = false) => -/^(y|yes)$/i.test(val) ? true : /^(n|no)$/i.test(val) ? false : def; \ No newline at end of file +const yesNo = (val, def = false) => +/^(y|yes)$/i.test(val) ? true : /^(n|no)$/i.test(val) ? false : def; + module.exports = yesNo \ No newline at end of file diff --git a/test/zip/zip.js b/test/zip/zip.js index ae33cbf91..e248b5de5 100644 --- a/test/zip/zip.js +++ b/test/zip/zip.js @@ -1,6 +1,7 @@ -module.exports = zip = (...arrays) => { +const zip = (...arrays) => { const maxLength = Math.max(...arrays.map(x => x.length)); return Array.from({ length: maxLength }).map((_, i) => { return Array.from({ length: arrays.length }, (_, k) => arrays[k][i]); }); -}; \ No newline at end of file +}; + module.exports = zip \ No newline at end of file diff --git a/test/zipObject/zipObject.js b/test/zipObject/zipObject.js index 3962e5421..7e1f6f633 100644 --- a/test/zipObject/zipObject.js +++ b/test/zipObject/zipObject.js @@ -1,2 +1,3 @@ -module.exports = zipObject = (props, values) => -props.reduce((obj, prop, index) => ((obj[prop] = values[index]), obj), {}); \ No newline at end of file +const zipObject = (props, values) => +props.reduce((obj, prop, index) => ((obj[prop] = values[index]), obj), {}); + module.exports = zipObject \ No newline at end of file