From cb3391f3e03d18ea6f034f722159190971645a82 Mon Sep 17 00:00:00 2001 From: King Date: Wed, 10 Jan 2018 15:20:31 -0500 Subject: [PATCH 1/5] update recursion fix & declare all snippets --- scripts/tdd.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/tdd.js b/scripts/tdd.js index 1eebbf1a7..d008c6933 100644 --- a/scripts/tdd.js +++ b/scripts/tdd.js @@ -62,7 +62,7 @@ snippetFiles .filter((_, i) => blockMarkers[2] < i && i < blockMarkers[3]); // Export template for snippetName.js which takes into account snippet name.length when generating snippetName.js file - const exportFile = `module.exports = ${fileFunction.join('\n').slice(9 + fileName.length)}`; + const exportFile = `module.exports = ${fileName} = ${fileFunction.join('\n').slice(9 + fileName.length)}`; // Export template for snippetName.test.js which generates a example test & other information const exportTest = [ From f0c4404060cfa1287406630e854af9e4edc4709d Mon Sep 17 00:00:00 2001 From: King Date: Wed, 10 Jan 2018 15:22:58 -0500 Subject: [PATCH 2/5] generate new test that did already exist & update all module snippets with declaration --- test/JSONToDate/JSONToDate.js | 2 +- test/README/README.js | 4 ++++ test/README/README.test.js | 13 +++++++++++++ test/RGBToHex/RGBToHex.js | 2 +- test/UUIDGeneratorBrowser/UUIDGeneratorBrowser.js | 2 +- test/anagrams/anagrams.js | 2 +- test/arrayToHtmlList/arrayToHtmlList.js | 2 +- test/average/average.js | 2 +- test/binarySearch/binarySearch.js | 2 +- test/bottomVisible/bottomVisible.js | 2 +- test/byteSize/byteSize.js | 2 +- test/call/call.js | 2 +- test/capitalize/capitalize.js | 2 +- test/capitalizeEveryWord/capitalizeEveryWord.js | 2 +- test/chainAsync/chainAsync.js | 2 +- test/chunk/chunk.js | 2 +- test/clampNumber/clampNumber.js | 2 +- test/cleanObj/cleanObj.js | 2 +- test/cloneRegExp/cloneRegExp.js | 2 +- test/coalesce/coalesce.js | 2 +- test/coalesceFactory/coalesceFactory.js | 2 +- test/collatz/collatz.js | 2 +- test/collectInto/collectInto.js | 2 +- test/compact/compact.js | 2 +- test/compose/compose.js | 2 +- test/copyToClipboard/copyToClipboard.js | 2 +- test/countOccurrences/countOccurrences.js | 2 +- test/countVowels/countVowels.js | 2 +- test/createElement/createElement.js | 2 +- test/createEventHub/createEventHub.js | 14 ++++++++++++++ test/createEventHub/createEventHub.test.js | 13 +++++++++++++ test/currentURL/currentURL.js | 2 +- test/curry/curry.js | 2 +- test/deepFlatten/deepFlatten.js | 2 +- test/defer/defer.js | 2 +- test/detectDeviceType/detectDeviceType.js | 2 +- test/difference/difference.js | 2 +- test/differenceWith/differenceWith.js | 2 +- test/digitize/digitize.js | 2 +- test/distance/distance.js | 2 +- .../distinctValuesOfArray/distinctValuesOfArray.js | 2 +- test/dropElements/dropElements.js | 2 +- test/dropRight/dropRight.js | 2 +- .../elementIsVisibleInViewport.js | 2 +- test/elo/elo.js | 2 +- test/escapeHTML/escapeHTML.js | 2 +- test/escapeRegExp/escapeRegExp.js | 2 +- test/everyNth/everyNth.js | 2 +- test/extendHex/extendHex.js | 2 +- test/factorial/factorial.js | 2 +- test/factors/factors.js | 2 +- test/fibonacci/fibonacci.js | 2 +- .../fibonacciCountUntilNum.js | 2 +- test/fibonacciUntilNum/fibonacciUntilNum.js | 2 +- test/filterNonUnique/filterNonUnique.js | 2 +- test/flatten/flatten.js | 2 +- test/flattenDepth/flattenDepth.js | 2 +- test/flip/flip.js | 2 +- test/forEachRight/forEachRight.js | 2 +- test/formatDuration/formatDuration.js | 2 +- test/fromCamelCase/fromCamelCase.js | 2 +- test/functionName/functionName.js | 2 +- test/gcd/gcd.js | 4 ++-- test/geometricProgression/geometricProgression.js | 2 +- .../getDaysDiffBetweenDates.js | 2 +- test/getScrollPosition/getScrollPosition.js | 2 +- test/getStyle/getStyle.js | 2 +- test/getType/getType.js | 2 +- test/getURLParameters/getURLParameters.js | 2 +- test/groupBy/groupBy.js | 2 +- test/hammingDistance/hammingDistance.js | 2 +- test/hasClass/hasClass.js | 2 +- test/hasFlags/hasFlags.js | 2 +- test/head/head.js | 2 +- test/hexToRGB/hexToRGB.js | 2 +- test/hide/hide.js | 2 +- test/howManyTimes/howManyTimes.js | 2 +- test/httpDelete/httpDelete.js | 7 +++++++ test/httpDelete/httpDelete.test.js | 13 +++++++++++++ test/httpGet/httpGet.js | 7 +++++++ test/httpGet/httpGet.test.js | 13 +++++++++++++ test/httpPost/httpPost.js | 8 ++++++++ test/httpPost/httpPost.test.js | 13 +++++++++++++ test/httpPut/httpPut.js | 8 ++++++++ test/httpPut/httpPut.test.js | 13 +++++++++++++ test/httpsRedirect/httpsRedirect.js | 2 +- test/inRange/inRange.js | 2 +- test/indexOfAll/indexOfAll.js | 2 +- test/initial/initial.js | 2 +- test/initialize2DArray/initialize2DArray.js | 2 +- .../initializeArrayWithRange.js | 2 +- .../initializeArrayWithValues.js | 2 +- test/intersection/intersection.js | 2 +- test/invertKeyValues/invertKeyValues.js | 2 +- test/isAbsoluteURL/isAbsoluteURL.js | 2 +- test/isArmstrongNumber/isArmstrongNumber.js | 2 +- test/isArray/isArray.js | 2 +- test/isArrayLike/isArrayLike.js | 2 +- test/isBoolean/isBoolean.js | 2 +- test/isDivisible/isDivisible.js | 2 +- test/isEven/isEven.js | 2 +- test/isFunction/isFunction.js | 2 +- test/isLowerCase/isLowerCase.js | 2 +- test/isNull/isNull.js | 2 +- test/isNumber/isNumber.js | 2 +- test/isPrime/isPrime.js | 2 +- test/isPrimitive/isPrimitive.js | 2 +- test/isPromiseLike/isPromiseLike.js | 2 +- test/isSorted/isSorted.js | 2 +- test/isString/isString.js | 2 +- test/isSymbol/isSymbol.js | 2 +- test/isTravisCI/isTravisCI.js | 2 +- test/isUpperCase/isUpperCase.js | 2 +- test/isValidJSON/isValidJSON.js | 2 +- test/join/join.js | 2 +- test/last/last.js | 2 +- test/lcm/lcm.js | 2 +- test/longestItem/longestItem.js | 2 +- test/lowercaseKeys/lowercaseKeys.js | 2 +- test/luhnCheck/luhnCheck.js | 2 +- test/mapObject/mapObject.js | 2 +- test/mask/mask.js | 2 +- test/maxN/maxN.js | 2 +- test/median/median.js | 2 +- test/memoize/memoize.js | 2 +- test/minN/minN.js | 2 +- test/negate/negate.js | 2 +- test/nthElement/nthElement.js | 2 +- test/objectFromPairs/objectFromPairs.js | 2 +- test/objectToPairs/objectToPairs.js | 2 +- test/off/off.js | 2 +- test/on/on.js | 2 +- test/onUserInputChange/onUserInputChange.js | 2 +- test/once/once.js | 2 +- test/orderBy/orderBy.js | 2 +- test/palindrome/palindrome.js | 2 +- test/partition/partition.js | 2 +- test/percentile/percentile.js | 2 +- test/pick/pick.js | 2 +- test/pipeFunctions/pipeFunctions.js | 2 +- test/pluralize/pluralize.js | 2 +- test/powerset/powerset.js | 2 +- test/prettyBytes/prettyBytes.js | 2 +- test/primes/primes.js | 2 +- test/promisify/promisify.js | 2 +- test/pull/pull.js | 2 +- test/pullAtIndex/pullAtIndex.js | 2 +- test/pullAtValue/pullAtValue.js | 2 +- test/quickSort/quickSort.js | 2 +- test/randomHexColorCode/randomHexColorCode.js | 2 +- test/randomIntegerInRange/randomIntegerInRange.js | 2 +- test/randomNumberInRange/randomNumberInRange.js | 2 +- test/redirect/redirect.js | 2 +- test/reducedFilter/reducedFilter.js | 2 +- test/remove/remove.js | 2 +- test/removeVowels/removeVowels.js | 1 + test/removeVowels/removeVowels.test.js | 13 +++++++++++++ test/reverseString/reverseString.js | 2 +- test/round/round.js | 2 +- test/runAsync/runAsync.js | 2 +- test/runPromisesInSeries/runPromisesInSeries.js | 2 +- test/sample/sample.js | 2 +- test/sampleSize/sampleSize.js | 2 +- test/scrollToTop/scrollToTop.js | 2 +- test/sdbm/sdbm.js | 2 +- test/select/select.js | 2 +- test/setStyle/setStyle.js | 2 +- test/shallowClone/shallowClone.js | 2 +- test/show/show.js | 2 +- test/shuffle/shuffle.js | 2 +- test/similarity/similarity.js | 2 +- test/size/size.js | 2 +- test/sleep/sleep.js | 2 +- test/solveRPN/solveRPN.js | 2 +- .../sortCharactersInString.js | 2 +- test/sortedIndex/sortedIndex.js | 2 +- test/speechSynthesis/speechSynthesis.js | 2 +- test/splitLines/splitLines.js | 2 +- test/spreadOver/spreadOver.js | 2 +- test/standardDeviation/standardDeviation.js | 2 +- test/sum/sum.js | 2 +- test/sumPower/sumPower.js | 2 +- test/symmetricDifference/symmetricDifference.js | 2 +- test/tail/tail.js | 2 +- test/take/take.js | 2 +- test/takeRight/takeRight.js | 2 +- test/timeTaken/timeTaken.js | 2 +- test/toCamelCase/toCamelCase.js | 2 +- test/toDecimalMark/toDecimalMark.js | 2 +- test/toEnglishDate/toEnglishDate.js | 2 +- test/toKebabCase/toKebabCase.js | 2 +- test/toOrdinalSuffix/toOrdinalSuffix.js | 2 +- test/toSafeInteger/toSafeInteger.js | 2 +- test/toSnakeCase/toSnakeCase.js | 2 +- test/toggleClass/toggleClass.js | 2 +- test/tomorrow/tomorrow.js | 2 +- test/truncateString/truncateString.js | 2 +- test/truthCheckCollection/truthCheckCollection.js | 2 +- test/unescapeHTML/unescapeHTML.js | 2 +- test/union/union.js | 2 +- test/untildify/untildify.js | 2 +- test/validateNumber/validateNumber.js | 2 +- test/without/without.js | 2 +- test/words/words.js | 2 +- test/yesNo/yesNo.js | 2 +- test/zip/zip.js | 2 +- test/zipObject/zipObject.js | 2 +- 207 files changed, 334 insertions(+), 194 deletions(-) create mode 100644 test/README/README.js create mode 100644 test/README/README.test.js create mode 100644 test/createEventHub/createEventHub.js create mode 100644 test/createEventHub/createEventHub.test.js create mode 100644 test/httpDelete/httpDelete.js create mode 100644 test/httpDelete/httpDelete.test.js create mode 100644 test/httpGet/httpGet.js create mode 100644 test/httpGet/httpGet.test.js create mode 100644 test/httpPost/httpPost.js create mode 100644 test/httpPost/httpPost.test.js create mode 100644 test/httpPut/httpPut.js create mode 100644 test/httpPut/httpPut.test.js create mode 100644 test/removeVowels/removeVowels.js create mode 100644 test/removeVowels/removeVowels.test.js diff --git a/test/JSONToDate/JSONToDate.js b/test/JSONToDate/JSONToDate.js index 935c919cd..bceb8129f 100644 --- a/test/JSONToDate/JSONToDate.js +++ b/test/JSONToDate/JSONToDate.js @@ -1,4 +1,4 @@ -module.exports = arr => { +module.exports = 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 diff --git a/test/README/README.js b/test/README/README.js new file mode 100644 index 000000000..7286e4ffb --- /dev/null +++ b/test/README/README.js @@ -0,0 +1,4 @@ +module.exports = README = e = arr => { +const dt = new Date(parseInt(arr.toString().substr(6))); +return `${dt.getDate()}/${dt.getMonth() + 1}/${dt.getFullYear()}`; +}; \ No newline at end of file diff --git a/test/README/README.test.js b/test/README/README.test.js new file mode 100644 index 000000000..bfbab3850 --- /dev/null +++ b/test/README/README.test.js @@ -0,0 +1,13 @@ +const test = require('tape'); +const README = require('./README.js'); + +test('Testing README', (t) => { + //For more information on all the methods supported by tape + //Please go to https://github.com/substack/tape + t.true(typeof README === 'function', 'README is a Function'); + //t.deepEqual(README(args..), 'Expected'); + //t.equal(README(args..), 'Expected'); + //t.false(README(args..), 'Expected'); + //t.throws(README(args..), 'Expected'); + t.end(); +}); \ No newline at end of file diff --git a/test/RGBToHex/RGBToHex.js b/test/RGBToHex/RGBToHex.js index d2f44e32d..a577b0b0f 100644 --- a/test/RGBToHex/RGBToHex.js +++ b/test/RGBToHex/RGBToHex.js @@ -1 +1 @@ -module.exports = (r, g, b) => ((r << 16) + (g << 8) + b).toString(16).padStart(6, '0'); \ No newline at end of file +module.exports = RGBToHex = (r, g, b) => ((r << 16) + (g << 8) + b).toString(16).padStart(6, '0'); \ No newline at end of file diff --git a/test/UUIDGeneratorBrowser/UUIDGeneratorBrowser.js b/test/UUIDGeneratorBrowser/UUIDGeneratorBrowser.js index 260bca776..4907d516b 100644 --- a/test/UUIDGeneratorBrowser/UUIDGeneratorBrowser.js +++ b/test/UUIDGeneratorBrowser/UUIDGeneratorBrowser.js @@ -1,4 +1,4 @@ -module.exports = () => +module.exports = 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 diff --git a/test/anagrams/anagrams.js b/test/anagrams/anagrams.js index 8d41e77f5..2ddf13855 100644 --- a/test/anagrams/anagrams.js +++ b/test/anagrams/anagrams.js @@ -1,4 +1,4 @@ -module.exports = str => { +module.exports = anagrams = str => { if (str.length <= 2) return str.length === 2 ? [str, str[1] + str[0]] : [str]; return str .split('') diff --git a/test/arrayToHtmlList/arrayToHtmlList.js b/test/arrayToHtmlList/arrayToHtmlList.js index d2aa87f0f..a4f583bc1 100644 --- a/test/arrayToHtmlList/arrayToHtmlList.js +++ b/test/arrayToHtmlList/arrayToHtmlList.js @@ -1,2 +1,2 @@ -module.exports = (arr, listID) => +module.exports = arrayToHtmlList = (arr, listID) => arr.map(item => (document.querySelector('#' + listID).innerHTML += `
  • ${item}
  • `)); \ No newline at end of file diff --git a/test/average/average.js b/test/average/average.js index 64e74d7db..5c4ce8ac9 100644 --- a/test/average/average.js +++ b/test/average/average.js @@ -1 +1 @@ -module.exports = (...nums) => [...nums].reduce((acc, val) => acc + val, 0) / nums.length; \ No newline at end of file +module.exports = average = (...nums) => [...nums].reduce((acc, val) => acc + val, 0) / nums.length; \ No newline at end of file diff --git a/test/binarySearch/binarySearch.js b/test/binarySearch/binarySearch.js index 96e71ecc3..b23a47a1b 100644 --- a/test/binarySearch/binarySearch.js +++ b/test/binarySearch/binarySearch.js @@ -1,4 +1,4 @@ -module.exports = (arr, val, start = 0, end = arr.length - 1) => { +module.exports = 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); diff --git a/test/bottomVisible/bottomVisible.js b/test/bottomVisible/bottomVisible.js index eb338f509..8f58bf6ae 100644 --- a/test/bottomVisible/bottomVisible.js +++ b/test/bottomVisible/bottomVisible.js @@ -1,3 +1,3 @@ -module.exports = () => +module.exports = bottomVisible = () => document.documentElement.clientHeight + window.scrollY >= (document.documentElement.scrollHeight || document.documentElement.clientHeight); \ No newline at end of file diff --git a/test/byteSize/byteSize.js b/test/byteSize/byteSize.js index d4334d952..5ec2b2b86 100644 --- a/test/byteSize/byteSize.js +++ b/test/byteSize/byteSize.js @@ -1 +1 @@ -module.exports = str => new Blob([str]).size; \ No newline at end of file +module.exports = byteSize = str => new Blob([str]).size; \ No newline at end of file diff --git a/test/call/call.js b/test/call/call.js index 61bf02b5d..55228e118 100644 --- a/test/call/call.js +++ b/test/call/call.js @@ -1 +1 @@ -module.exports = (key, ...args) => context => context[key](...args); \ No newline at end of file +module.exports = call = (key, ...args) => context => context[key](...args); \ No newline at end of file diff --git a/test/capitalize/capitalize.js b/test/capitalize/capitalize.js index d1dccff21..d13619814 100644 --- a/test/capitalize/capitalize.js +++ b/test/capitalize/capitalize.js @@ -1,2 +1,2 @@ -module.exports = ([first, ...rest], lowerRest = false) => +module.exports = capitalize = ([first, ...rest], lowerRest = false) => first.toUpperCase() + (lowerRest ? rest.join('').toLowerCase() : rest.join('')); \ No newline at end of file diff --git a/test/capitalizeEveryWord/capitalizeEveryWord.js b/test/capitalizeEveryWord/capitalizeEveryWord.js index 6177e8bcc..cc5e114f5 100644 --- a/test/capitalizeEveryWord/capitalizeEveryWord.js +++ b/test/capitalizeEveryWord/capitalizeEveryWord.js @@ -1 +1 @@ -module.exports = str => str.replace(/\b[a-z]/g, char => char.toUpperCase()); \ No newline at end of file +module.exports = capitalizeEveryWord = str => str.replace(/\b[a-z]/g, char => char.toUpperCase()); \ No newline at end of file diff --git a/test/chainAsync/chainAsync.js b/test/chainAsync/chainAsync.js index 0f110e62a..754fe69d0 100644 --- a/test/chainAsync/chainAsync.js +++ b/test/chainAsync/chainAsync.js @@ -1,4 +1,4 @@ -module.exports = fns => { +module.exports = chainAsync = fns => { let curr = 0; const next = () => fns[curr++](next); next(); diff --git a/test/chunk/chunk.js b/test/chunk/chunk.js index 1907e30d9..6dd3a64f9 100644 --- a/test/chunk/chunk.js +++ b/test/chunk/chunk.js @@ -1,4 +1,4 @@ -module.exports = (arr, size) => +module.exports = 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 diff --git a/test/clampNumber/clampNumber.js b/test/clampNumber/clampNumber.js index f82160568..07e9b043a 100644 --- a/test/clampNumber/clampNumber.js +++ b/test/clampNumber/clampNumber.js @@ -1 +1 @@ -module.exports = (num, a, b) => Math.max(Math.min(num, Math.max(a, b)), Math.min(a, b)); \ No newline at end of file +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 diff --git a/test/cleanObj/cleanObj.js b/test/cleanObj/cleanObj.js index ce4ea9bbf..3727b09f2 100644 --- a/test/cleanObj/cleanObj.js +++ b/test/cleanObj/cleanObj.js @@ -1,4 +1,4 @@ -module.exports = (obj, keysToKeep = [], childIndicator) => { +module.exports = cleanObj = (obj, keysToKeep = [], childIndicator) => { Object.keys(obj).forEach(key => { if (key === childIndicator) { cleanObj(obj[key], keysToKeep, childIndicator); diff --git a/test/cloneRegExp/cloneRegExp.js b/test/cloneRegExp/cloneRegExp.js index bc4db3683..e5ca263b7 100644 --- a/test/cloneRegExp/cloneRegExp.js +++ b/test/cloneRegExp/cloneRegExp.js @@ -1 +1 @@ -module.exports = regExp => new RegExp(regExp.source, regExp.flags); \ No newline at end of file +module.exports = cloneRegExp = regExp => new RegExp(regExp.source, regExp.flags); \ No newline at end of file diff --git a/test/coalesce/coalesce.js b/test/coalesce/coalesce.js index 18e4e3793..0f5690f3e 100644 --- a/test/coalesce/coalesce.js +++ b/test/coalesce/coalesce.js @@ -1 +1 @@ -module.exports = (...args) => args.find(_ => ![undefined, null].includes(_)); \ No newline at end of file +module.exports = coalesce = (...args) => args.find(_ => ![undefined, null].includes(_)); \ No newline at end of file diff --git a/test/coalesceFactory/coalesceFactory.js b/test/coalesceFactory/coalesceFactory.js index debdd990c..654756423 100644 --- a/test/coalesceFactory/coalesceFactory.js +++ b/test/coalesceFactory/coalesceFactory.js @@ -1 +1 @@ -module.exports = valid => (...args) => args.find(valid); \ No newline at end of file +module.exports = coalesceFactory = valid => (...args) => args.find(valid); \ No newline at end of file diff --git a/test/collatz/collatz.js b/test/collatz/collatz.js index 3fb44dac9..f78f0006b 100644 --- a/test/collatz/collatz.js +++ b/test/collatz/collatz.js @@ -1 +1 @@ -module.exports = n => (n % 2 == 0 ? n / 2 : 3 * n + 1); \ No newline at end of file +module.exports = collatz = n => (n % 2 == 0 ? n / 2 : 3 * n + 1); \ No newline at end of file diff --git a/test/collectInto/collectInto.js b/test/collectInto/collectInto.js index 8f5ef94ea..e7d85b68b 100644 --- a/test/collectInto/collectInto.js +++ b/test/collectInto/collectInto.js @@ -1 +1 @@ -module.exports = fn => (...args) => fn(args); \ No newline at end of file +module.exports = collectInto = fn => (...args) => fn(args); \ No newline at end of file diff --git a/test/compact/compact.js b/test/compact/compact.js index 73f3f0dcf..b06d62396 100644 --- a/test/compact/compact.js +++ b/test/compact/compact.js @@ -1 +1 @@ -module.exports = arr => arr.filter(Boolean); \ No newline at end of file +module.exports = compact = arr => arr.filter(Boolean); \ No newline at end of file diff --git a/test/compose/compose.js b/test/compose/compose.js index 32886d307..91d9c4989 100644 --- a/test/compose/compose.js +++ b/test/compose/compose.js @@ -1 +1 @@ -module.exports = (...fns) => fns.reduce((f, g) => (...args) => f(g(...args))); \ No newline at end of file +module.exports = compose = (...fns) => fns.reduce((f, g) => (...args) => f(g(...args))); \ No newline at end of file diff --git a/test/copyToClipboard/copyToClipboard.js b/test/copyToClipboard/copyToClipboard.js index c73d01bc5..b7130fd85 100644 --- a/test/copyToClipboard/copyToClipboard.js +++ b/test/copyToClipboard/copyToClipboard.js @@ -1,4 +1,4 @@ -module.exports = str => { +module.exports = copyToClipboard = str => { const el = document.createElement('textarea'); el.value = str; el.setAttribute('readonly', ''); diff --git a/test/countOccurrences/countOccurrences.js b/test/countOccurrences/countOccurrences.js index 6cd81e0ef..a9a4ae75a 100644 --- a/test/countOccurrences/countOccurrences.js +++ b/test/countOccurrences/countOccurrences.js @@ -1 +1 @@ -module.exports = (arr, val) => arr.reduce((a, v) => (v === val ? a + 1 : a + 0), 0); \ No newline at end of file +module.exports = countOccurrences = (arr, val) => arr.reduce((a, v) => (v === val ? a + 1 : a + 0), 0); \ No newline at end of file diff --git a/test/countVowels/countVowels.js b/test/countVowels/countVowels.js index a737d075b..867f63a79 100644 --- a/test/countVowels/countVowels.js +++ b/test/countVowels/countVowels.js @@ -1 +1 @@ -module.exports = str => (str.match(/[aeiou]/gi) || []).length; \ No newline at end of file +module.exports = countVowels = str => (str.match(/[aeiou]/gi) || []).length; \ No newline at end of file diff --git a/test/createElement/createElement.js b/test/createElement/createElement.js index db234e405..9ab5d3017 100644 --- a/test/createElement/createElement.js +++ b/test/createElement/createElement.js @@ -1,4 +1,4 @@ -module.exports = str => { +module.exports = createElement = str => { const el = document.createElement('div'); el.innerHTML = str; return el.firstElementChild; diff --git a/test/createEventHub/createEventHub.js b/test/createEventHub/createEventHub.js new file mode 100644 index 000000000..2f25c0b91 --- /dev/null +++ b/test/createEventHub/createEventHub.js @@ -0,0 +1,14 @@ +module.exports = createEventHub = () => ({ +hub: Object.create(null), +emit(event, data) { +(this.hub[event] || []).forEach(handler => handler(data)); +}, +on(event, handler) { +if (!this.hub[event]) this.hub[event] = []; +this.hub[event].push(handler); +}, +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 diff --git a/test/createEventHub/createEventHub.test.js b/test/createEventHub/createEventHub.test.js new file mode 100644 index 000000000..527237cf4 --- /dev/null +++ b/test/createEventHub/createEventHub.test.js @@ -0,0 +1,13 @@ +const test = require('tape'); +const createEventHub = require('./createEventHub.js'); + +test('Testing createEventHub', (t) => { + //For more information on all the methods supported by tape + //Please go to https://github.com/substack/tape + t.true(typeof createEventHub === 'function', 'createEventHub is a Function'); + //t.deepEqual(createEventHub(args..), 'Expected'); + //t.equal(createEventHub(args..), 'Expected'); + //t.false(createEventHub(args..), 'Expected'); + //t.throws(createEventHub(args..), 'Expected'); + t.end(); +}); \ No newline at end of file diff --git a/test/currentURL/currentURL.js b/test/currentURL/currentURL.js index ad4f466a4..13ddcb6f4 100644 --- a/test/currentURL/currentURL.js +++ b/test/currentURL/currentURL.js @@ -1 +1 @@ -module.exports = () => window.location.href; \ No newline at end of file +module.exports = currentURL = () => window.location.href; \ No newline at end of file diff --git a/test/curry/curry.js b/test/curry/curry.js index 461c172d9..e23630b5b 100644 --- a/test/curry/curry.js +++ b/test/curry/curry.js @@ -1,2 +1,2 @@ -module.exports = (fn, arity = fn.length, ...args) => +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 diff --git a/test/deepFlatten/deepFlatten.js b/test/deepFlatten/deepFlatten.js index 115c1c402..3d9ca6819 100644 --- a/test/deepFlatten/deepFlatten.js +++ b/test/deepFlatten/deepFlatten.js @@ -1 +1 @@ -module.exports = arr => [].concat(...arr.map(v => (Array.isArray(v) ? deepFlatten(v) : v))); \ No newline at end of file +module.exports = deepFlatten = arr => [].concat(...arr.map(v => (Array.isArray(v) ? deepFlatten(v) : v))); \ No newline at end of file diff --git a/test/defer/defer.js b/test/defer/defer.js index 81b0661aa..7f975ac42 100644 --- a/test/defer/defer.js +++ b/test/defer/defer.js @@ -1 +1 @@ -module.exports = (fn, ...args) => setTimeout(fn, 1, ...args); \ No newline at end of file +module.exports = defer = (fn, ...args) => setTimeout(fn, 1, ...args); \ No newline at end of file diff --git a/test/detectDeviceType/detectDeviceType.js b/test/detectDeviceType/detectDeviceType.js index 2b81aec62..0f5eb5f3b 100644 --- a/test/detectDeviceType/detectDeviceType.js +++ b/test/detectDeviceType/detectDeviceType.js @@ -1,4 +1,4 @@ -module.exports = () => +module.exports = detectDeviceType = () => /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ? 'Mobile' : 'Desktop'; \ No newline at end of file diff --git a/test/difference/difference.js b/test/difference/difference.js index fbf6ec7d1..672b5c244 100644 --- a/test/difference/difference.js +++ b/test/difference/difference.js @@ -1,4 +1,4 @@ -module.exports = (a, b) => { +module.exports = difference = (a, b) => { const s = new Set(b); return a.filter(x => !s.has(x)); }; \ No newline at end of file diff --git a/test/differenceWith/differenceWith.js b/test/differenceWith/differenceWith.js index 27b530bef..cd6aefe43 100644 --- a/test/differenceWith/differenceWith.js +++ b/test/differenceWith/differenceWith.js @@ -1 +1 @@ -module.exports = (arr, val, comp) => arr.filter(a => val.findIndex(b => comp(a, b)) === -1); \ No newline at end of file +module.exports = differenceWith = (arr, val, comp) => arr.filter(a => val.findIndex(b => comp(a, b)) === -1); \ No newline at end of file diff --git a/test/digitize/digitize.js b/test/digitize/digitize.js index 1726a01ee..addcc7e16 100644 --- a/test/digitize/digitize.js +++ b/test/digitize/digitize.js @@ -1 +1 @@ -module.exports = n => [...`${n}`].map(i => parseInt(i)); \ No newline at end of file +module.exports = digitize = n => [...`${n}`].map(i => parseInt(i)); \ No newline at end of file diff --git a/test/distance/distance.js b/test/distance/distance.js index 6d166a541..521012787 100644 --- a/test/distance/distance.js +++ b/test/distance/distance.js @@ -1 +1 @@ -module.exports = (x0, y0, x1, y1) => Math.hypot(x1 - x0, y1 - y0); \ No newline at end of file +module.exports = distance = (x0, y0, x1, y1) => Math.hypot(x1 - x0, y1 - y0); \ No newline at end of file diff --git a/test/distinctValuesOfArray/distinctValuesOfArray.js b/test/distinctValuesOfArray/distinctValuesOfArray.js index 0d8915e71..d5b18bd39 100644 --- a/test/distinctValuesOfArray/distinctValuesOfArray.js +++ b/test/distinctValuesOfArray/distinctValuesOfArray.js @@ -1 +1 @@ -module.exports = arr => [...new Set(arr)]; \ No newline at end of file +module.exports = distinctValuesOfArray = arr => [...new Set(arr)]; \ No newline at end of file diff --git a/test/dropElements/dropElements.js b/test/dropElements/dropElements.js index 8df4c8544..cc57fee75 100644 --- a/test/dropElements/dropElements.js +++ b/test/dropElements/dropElements.js @@ -1,4 +1,4 @@ -module.exports = (arr, func) => { +module.exports = dropElements = (arr, func) => { while (arr.length > 0 && !func(arr[0])) arr = arr.slice(1); return arr; }; \ No newline at end of file diff --git a/test/dropRight/dropRight.js b/test/dropRight/dropRight.js index 5007edbd9..62f2bb163 100644 --- a/test/dropRight/dropRight.js +++ b/test/dropRight/dropRight.js @@ -1 +1 @@ -module.exports = (arr, n = 1) => arr.slice(0, -n); \ No newline at end of file +module.exports = dropRight = (arr, n = 1) => arr.slice(0, -n); \ No newline at end of file diff --git a/test/elementIsVisibleInViewport/elementIsVisibleInViewport.js b/test/elementIsVisibleInViewport/elementIsVisibleInViewport.js index 1b5b376db..659dee2c9 100644 --- a/test/elementIsVisibleInViewport/elementIsVisibleInViewport.js +++ b/test/elementIsVisibleInViewport/elementIsVisibleInViewport.js @@ -1,4 +1,4 @@ -module.exports = (el, partiallyVisible = false) => { +module.exports = elementIsVisibleInViewport = (el, partiallyVisible = false) => { const { top, left, bottom, right } = el.getBoundingClientRect(); const { innerHeight, innerWidth } = window; return partiallyVisible diff --git a/test/elo/elo.js b/test/elo/elo.js index b7f39409d..41e1bd060 100644 --- a/test/elo/elo.js +++ b/test/elo/elo.js @@ -1,4 +1,4 @@ -module.exports = ([...ratings], kFactor = 32, selfRating) => { +module.exports = elo = ([...ratings], kFactor = 32, selfRating) => { const [a, b] = ratings; const expectedScore = (self, opponent) => 1 / (1 + 10 ** ((opponent - self) / 400)); const newRating = (rating, i) => diff --git a/test/escapeHTML/escapeHTML.js b/test/escapeHTML/escapeHTML.js index 7684850bc..33c0bc739 100644 --- a/test/escapeHTML/escapeHTML.js +++ b/test/escapeHTML/escapeHTML.js @@ -1,4 +1,4 @@ -module.exports = str => +module.exports = escapeHTML = str => str.replace( /[&<>'"]/g, tag => diff --git a/test/escapeRegExp/escapeRegExp.js b/test/escapeRegExp/escapeRegExp.js index 008ca053b..ad6961ec4 100644 --- a/test/escapeRegExp/escapeRegExp.js +++ b/test/escapeRegExp/escapeRegExp.js @@ -1 +1 @@ -module.exports = str => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); \ No newline at end of file +module.exports = escapeRegExp = str => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); \ No newline at end of file diff --git a/test/everyNth/everyNth.js b/test/everyNth/everyNth.js index 27666f7bf..01096d1f9 100644 --- a/test/everyNth/everyNth.js +++ b/test/everyNth/everyNth.js @@ -1 +1 @@ -module.exports = (arr, nth) => arr.filter((e, i) => i % nth === nth - 1); \ No newline at end of file +module.exports = everyNth = (arr, nth) => arr.filter((e, i) => i % nth === nth - 1); \ No newline at end of file diff --git a/test/extendHex/extendHex.js b/test/extendHex/extendHex.js index 653c083d2..1faf96cc7 100644 --- a/test/extendHex/extendHex.js +++ b/test/extendHex/extendHex.js @@ -1,4 +1,4 @@ -module.exports = shortHex => +module.exports = extendHex = shortHex => '#' + shortHex .slice(shortHex.startsWith('#') ? 1 : 0) diff --git a/test/factorial/factorial.js b/test/factorial/factorial.js index 54182894d..b9a03c2f4 100644 --- a/test/factorial/factorial.js +++ b/test/factorial/factorial.js @@ -1,4 +1,4 @@ -module.exports = n => +module.exports = factorial = n => n < 0 ? (() => { throw new TypeError('Negative numbers are not allowed!'); diff --git a/test/factors/factors.js b/test/factors/factors.js index 4a70e86ba..83e33a823 100644 --- a/test/factors/factors.js +++ b/test/factors/factors.js @@ -1,4 +1,4 @@ -module.exports = (num, primes = false) => { +module.exports = 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; diff --git a/test/fibonacci/fibonacci.js b/test/fibonacci/fibonacci.js index 3d01534fe..e71b31b56 100644 --- a/test/fibonacci/fibonacci.js +++ b/test/fibonacci/fibonacci.js @@ -1,4 +1,4 @@ -module.exports = n => +module.exports = fibonacci = n => Array.from({ length: n }).reduce( (acc, val, i) => acc.concat(i > 1 ? acc[i - 1] + acc[i - 2] : i), [] diff --git a/test/fibonacciCountUntilNum/fibonacciCountUntilNum.js b/test/fibonacciCountUntilNum/fibonacciCountUntilNum.js index a12f28e88..93404fc61 100644 --- a/test/fibonacciCountUntilNum/fibonacciCountUntilNum.js +++ b/test/fibonacciCountUntilNum/fibonacciCountUntilNum.js @@ -1,2 +1,2 @@ -module.exports = num => +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 diff --git a/test/fibonacciUntilNum/fibonacciUntilNum.js b/test/fibonacciUntilNum/fibonacciUntilNum.js index 9966b1222..6ead222a0 100644 --- a/test/fibonacciUntilNum/fibonacciUntilNum.js +++ b/test/fibonacciUntilNum/fibonacciUntilNum.js @@ -1,4 +1,4 @@ -module.exports = num => { +module.exports = 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), diff --git a/test/filterNonUnique/filterNonUnique.js b/test/filterNonUnique/filterNonUnique.js index ff9cc3257..ba922256d 100644 --- a/test/filterNonUnique/filterNonUnique.js +++ b/test/filterNonUnique/filterNonUnique.js @@ -1 +1 @@ -module.exports = arr => arr.filter(i => arr.indexOf(i) === arr.lastIndexOf(i)); \ No newline at end of file +module.exports = filterNonUnique = arr => arr.filter(i => arr.indexOf(i) === arr.lastIndexOf(i)); \ No newline at end of file diff --git a/test/flatten/flatten.js b/test/flatten/flatten.js index 0f37bc778..845b9c916 100644 --- a/test/flatten/flatten.js +++ b/test/flatten/flatten.js @@ -1 +1 @@ -module.exports = arr => [].concat(...arr); \ No newline at end of file +module.exports = flatten = arr => [].concat(...arr); \ No newline at end of file diff --git a/test/flattenDepth/flattenDepth.js b/test/flattenDepth/flattenDepth.js index 1ab16665a..9e4606a75 100644 --- a/test/flattenDepth/flattenDepth.js +++ b/test/flattenDepth/flattenDepth.js @@ -1,4 +1,4 @@ -module.exports = (arr, depth = 1) => +module.exports = flattenDepth = (arr, depth = 1) => depth != 1 ? arr.reduce((a, v) => a.concat(Array.isArray(v) ? flattenDepth(v, depth - 1) : v), []) : arr.reduce((a, v) => a.concat(v), []); \ No newline at end of file diff --git a/test/flip/flip.js b/test/flip/flip.js index 4bac0428c..554d928f7 100644 --- a/test/flip/flip.js +++ b/test/flip/flip.js @@ -1 +1 @@ -module.exports = fn => (...args) => fn(args.pop(), ...args); \ No newline at end of file +module.exports = flip = fn => (...args) => fn(args.pop(), ...args); \ No newline at end of file diff --git a/test/forEachRight/forEachRight.js b/test/forEachRight/forEachRight.js index 2b8b0a526..3b267d120 100644 --- a/test/forEachRight/forEachRight.js +++ b/test/forEachRight/forEachRight.js @@ -1,4 +1,4 @@ -module.exports = (arr, callback) => +module.exports = forEachRight = (arr, callback) => arr .slice(0) .reverse() diff --git a/test/formatDuration/formatDuration.js b/test/formatDuration/formatDuration.js index fe543e7fa..4eb263f8e 100644 --- a/test/formatDuration/formatDuration.js +++ b/test/formatDuration/formatDuration.js @@ -1,4 +1,4 @@ -module.exports = ms => { +module.exports = formatDuration = ms => { if (ms < 0) ms = -ms; const time = { day: Math.floor(ms / 86400000), diff --git a/test/fromCamelCase/fromCamelCase.js b/test/fromCamelCase/fromCamelCase.js index 811857bf2..ae52a0dcf 100644 --- a/test/fromCamelCase/fromCamelCase.js +++ b/test/fromCamelCase/fromCamelCase.js @@ -1,4 +1,4 @@ -module.exports = (str, separator = '_') => +module.exports = 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') diff --git a/test/functionName/functionName.js b/test/functionName/functionName.js index a5248da94..9192ca098 100644 --- a/test/functionName/functionName.js +++ b/test/functionName/functionName.js @@ -1 +1 @@ -module.exports = fn => (console.debug(fn.name), fn); \ No newline at end of file +module.exports = functionName = fn => (console.debug(fn.name), fn); \ No newline at end of file diff --git a/test/gcd/gcd.js b/test/gcd/gcd.js index e65341af6..debfbee0e 100644 --- a/test/gcd/gcd.js +++ b/test/gcd/gcd.js @@ -1,4 +1,4 @@ -module.exports = (...arr) => { -const _gcd = (x, y) => (!y ? x : _gcd(y, x % y)); +module.exports = 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 diff --git a/test/geometricProgression/geometricProgression.js b/test/geometricProgression/geometricProgression.js index 246fb224b..a03ced538 100644 --- a/test/geometricProgression/geometricProgression.js +++ b/test/geometricProgression/geometricProgression.js @@ -1,4 +1,4 @@ -module.exports = (end, start = 1, step = 2) => +module.exports = 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 diff --git a/test/getDaysDiffBetweenDates/getDaysDiffBetweenDates.js b/test/getDaysDiffBetweenDates/getDaysDiffBetweenDates.js index a8abc567f..5a3808d60 100644 --- a/test/getDaysDiffBetweenDates/getDaysDiffBetweenDates.js +++ b/test/getDaysDiffBetweenDates/getDaysDiffBetweenDates.js @@ -1,2 +1,2 @@ -module.exports = (dateInitial, dateFinal) => +module.exports = getDaysDiffBetweenDates = (dateInitial, dateFinal) => (dateFinal - dateInitial) / (1000 * 3600 * 24); \ No newline at end of file diff --git a/test/getScrollPosition/getScrollPosition.js b/test/getScrollPosition/getScrollPosition.js index 89fcdc0f8..a786c099e 100644 --- a/test/getScrollPosition/getScrollPosition.js +++ b/test/getScrollPosition/getScrollPosition.js @@ -1,4 +1,4 @@ -module.exports = (el = window) => ({ +module.exports = 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 diff --git a/test/getStyle/getStyle.js b/test/getStyle/getStyle.js index 8291b4cbc..ea8cbb8fe 100644 --- a/test/getStyle/getStyle.js +++ b/test/getStyle/getStyle.js @@ -1 +1 @@ -module.exports = (el, ruleName) => getComputedStyle(el)[ruleName]; \ No newline at end of file +module.exports = getStyle = (el, ruleName) => getComputedStyle(el)[ruleName]; \ No newline at end of file diff --git a/test/getType/getType.js b/test/getType/getType.js index 757470fbb..0733d9c21 100644 --- a/test/getType/getType.js +++ b/test/getType/getType.js @@ -1,2 +1,2 @@ -module.exports = v => +module.exports = getType = v => v === undefined ? 'undefined' : v === null ? 'null' : v.constructor.name.toLowerCase(); \ No newline at end of file diff --git a/test/getURLParameters/getURLParameters.js b/test/getURLParameters/getURLParameters.js index 326bf6a0d..5b70753c9 100644 --- a/test/getURLParameters/getURLParameters.js +++ b/test/getURLParameters/getURLParameters.js @@ -1,4 +1,4 @@ -module.exports = url => +module.exports = 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 diff --git a/test/groupBy/groupBy.js b/test/groupBy/groupBy.js index bf9b8ff36..612ee15af 100644 --- a/test/groupBy/groupBy.js +++ b/test/groupBy/groupBy.js @@ -1,4 +1,4 @@ -module.exports = (arr, func) => +module.exports = groupBy = (arr, func) => arr.map(typeof func === 'function' ? func : val => val[func]).reduce((acc, val, i) => { acc[val] = (acc[val] || []).concat(arr[i]); return acc; diff --git a/test/hammingDistance/hammingDistance.js b/test/hammingDistance/hammingDistance.js index 3d97f1bd9..4c708616c 100644 --- a/test/hammingDistance/hammingDistance.js +++ b/test/hammingDistance/hammingDistance.js @@ -1 +1 @@ -module.exports = (num1, num2) => ((num1 ^ num2).toString(2).match(/1/g) || '').length; \ No newline at end of file +module.exports = hammingDistance = (num1, num2) => ((num1 ^ num2).toString(2).match(/1/g) || '').length; \ No newline at end of file diff --git a/test/hasClass/hasClass.js b/test/hasClass/hasClass.js index 66a974af3..4587138c7 100644 --- a/test/hasClass/hasClass.js +++ b/test/hasClass/hasClass.js @@ -1 +1 @@ -module.exports = (el, className) => el.classList.contains(className); \ No newline at end of file +module.exports = hasClass = (el, className) => el.classList.contains(className); \ No newline at end of file diff --git a/test/hasFlags/hasFlags.js b/test/hasFlags/hasFlags.js index 7ea90bb31..ccc7889ce 100644 --- a/test/hasFlags/hasFlags.js +++ b/test/hasFlags/hasFlags.js @@ -1,2 +1,2 @@ -module.exports = (...flags) => +module.exports = hasFlags = (...flags) => flags.every(flag => process.argv.includes(/^-{1,2}/.test(flag) ? flag : '--' + flag)); \ No newline at end of file diff --git a/test/head/head.js b/test/head/head.js index 9d7a9c835..f4f85ed5b 100644 --- a/test/head/head.js +++ b/test/head/head.js @@ -1 +1 @@ -module.exports = arr => arr[0]; \ No newline at end of file +module.exports = head = arr => arr[0]; \ No newline at end of file diff --git a/test/hexToRGB/hexToRGB.js b/test/hexToRGB/hexToRGB.js index 9565014b3..25946a262 100644 --- a/test/hexToRGB/hexToRGB.js +++ b/test/hexToRGB/hexToRGB.js @@ -1,4 +1,4 @@ -module.exports = hex => { +module.exports = hexToRGB = hex => { let alpha = false, h = hex.slice(hex.startsWith('#') ? 1 : 0); if (h.length === 3) h = [...h].map(x => x + x).join(''); diff --git a/test/hide/hide.js b/test/hide/hide.js index eab52028f..2ca6d885d 100644 --- a/test/hide/hide.js +++ b/test/hide/hide.js @@ -1 +1 @@ -module.exports = (...el) => [...el].forEach(e => (e.style.display = 'none')); \ No newline at end of file +module.exports = hide = (...el) => [...el].forEach(e => (e.style.display = 'none')); \ No newline at end of file diff --git a/test/howManyTimes/howManyTimes.js b/test/howManyTimes/howManyTimes.js index 7eefb7ecd..0ea05ded9 100644 --- a/test/howManyTimes/howManyTimes.js +++ b/test/howManyTimes/howManyTimes.js @@ -1,4 +1,4 @@ -module.exports = (num, divisor) => { +module.exports = howManyTimes = (num, divisor) => { if (divisor === 1 || divisor === -1) return Infinity; if (divisor === 0) return 0; let i = 0; diff --git a/test/httpDelete/httpDelete.js b/test/httpDelete/httpDelete.js new file mode 100644 index 000000000..1088f9c1b --- /dev/null +++ b/test/httpDelete/httpDelete.js @@ -0,0 +1,7 @@ +module.exports = 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 diff --git a/test/httpDelete/httpDelete.test.js b/test/httpDelete/httpDelete.test.js new file mode 100644 index 000000000..862230e23 --- /dev/null +++ b/test/httpDelete/httpDelete.test.js @@ -0,0 +1,13 @@ +const test = require('tape'); +const httpDelete = require('./httpDelete.js'); + +test('Testing httpDelete', (t) => { + //For more information on all the methods supported by tape + //Please go to https://github.com/substack/tape + t.true(typeof httpDelete === 'function', 'httpDelete is a Function'); + //t.deepEqual(httpDelete(args..), 'Expected'); + //t.equal(httpDelete(args..), 'Expected'); + //t.false(httpDelete(args..), 'Expected'); + //t.throws(httpDelete(args..), 'Expected'); + t.end(); +}); \ No newline at end of file diff --git a/test/httpGet/httpGet.js b/test/httpGet/httpGet.js new file mode 100644 index 000000000..05445e908 --- /dev/null +++ b/test/httpGet/httpGet.js @@ -0,0 +1,7 @@ +module.exports = 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 diff --git a/test/httpGet/httpGet.test.js b/test/httpGet/httpGet.test.js new file mode 100644 index 000000000..c55559714 --- /dev/null +++ b/test/httpGet/httpGet.test.js @@ -0,0 +1,13 @@ +const test = require('tape'); +const httpGet = require('./httpGet.js'); + +test('Testing httpGet', (t) => { + //For more information on all the methods supported by tape + //Please go to https://github.com/substack/tape + t.true(typeof httpGet === 'function', 'httpGet is a Function'); + //t.deepEqual(httpGet(args..), 'Expected'); + //t.equal(httpGet(args..), 'Expected'); + //t.false(httpGet(args..), 'Expected'); + //t.throws(httpGet(args..), 'Expected'); + t.end(); +}); \ No newline at end of file diff --git a/test/httpPost/httpPost.js b/test/httpPost/httpPost.js new file mode 100644 index 000000000..d94b85a95 --- /dev/null +++ b/test/httpPost/httpPost.js @@ -0,0 +1,8 @@ +module.exports = httpPost = (url, callback, data = null, 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 diff --git a/test/httpPost/httpPost.test.js b/test/httpPost/httpPost.test.js new file mode 100644 index 000000000..df8add407 --- /dev/null +++ b/test/httpPost/httpPost.test.js @@ -0,0 +1,13 @@ +const test = require('tape'); +const httpPost = require('./httpPost.js'); + +test('Testing httpPost', (t) => { + //For more information on all the methods supported by tape + //Please go to https://github.com/substack/tape + t.true(typeof httpPost === 'function', 'httpPost is a Function'); + //t.deepEqual(httpPost(args..), 'Expected'); + //t.equal(httpPost(args..), 'Expected'); + //t.false(httpPost(args..), 'Expected'); + //t.throws(httpPost(args..), 'Expected'); + t.end(); +}); \ No newline at end of file diff --git a/test/httpPut/httpPut.js b/test/httpPut/httpPut.js new file mode 100644 index 000000000..f76d8de86 --- /dev/null +++ b/test/httpPut/httpPut.js @@ -0,0 +1,8 @@ +module.exports = 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 diff --git a/test/httpPut/httpPut.test.js b/test/httpPut/httpPut.test.js new file mode 100644 index 000000000..1ca28c87d --- /dev/null +++ b/test/httpPut/httpPut.test.js @@ -0,0 +1,13 @@ +const test = require('tape'); +const httpPut = require('./httpPut.js'); + +test('Testing httpPut', (t) => { + //For more information on all the methods supported by tape + //Please go to https://github.com/substack/tape + t.true(typeof httpPut === 'function', 'httpPut is a Function'); + //t.deepEqual(httpPut(args..), 'Expected'); + //t.equal(httpPut(args..), 'Expected'); + //t.false(httpPut(args..), 'Expected'); + //t.throws(httpPut(args..), 'Expected'); + t.end(); +}); \ No newline at end of file diff --git a/test/httpsRedirect/httpsRedirect.js b/test/httpsRedirect/httpsRedirect.js index a84e98245..8835acac6 100644 --- a/test/httpsRedirect/httpsRedirect.js +++ b/test/httpsRedirect/httpsRedirect.js @@ -1,3 +1,3 @@ -module.exports = () => { +module.exports = httpsRedirect = () => { if (location.protocol !== 'https:') location.replace('https://' + location.href.split('//')[1]); }; \ No newline at end of file diff --git a/test/inRange/inRange.js b/test/inRange/inRange.js index aa644918e..7615d11f7 100644 --- a/test/inRange/inRange.js +++ b/test/inRange/inRange.js @@ -1,4 +1,4 @@ -module.exports = (n, start, end = null) => { +module.exports = 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 diff --git a/test/indexOfAll/indexOfAll.js b/test/indexOfAll/indexOfAll.js index f0a31bf3d..82d6900c8 100644 --- a/test/indexOfAll/indexOfAll.js +++ b/test/indexOfAll/indexOfAll.js @@ -1,4 +1,4 @@ -module.exports = (arr, val) => { +module.exports = indexOfAll = (arr, val) => { const indices = []; arr.forEach((el, i) => el === val && indices.push(i)); return indices; diff --git a/test/initial/initial.js b/test/initial/initial.js index 070dfca5f..99efa7f8a 100644 --- a/test/initial/initial.js +++ b/test/initial/initial.js @@ -1 +1 @@ -module.exports = arr => arr.slice(0, -1); \ No newline at end of file +module.exports = initial = arr => arr.slice(0, -1); \ No newline at end of file diff --git a/test/initialize2DArray/initialize2DArray.js b/test/initialize2DArray/initialize2DArray.js index e699b90d5..8728cc16c 100644 --- a/test/initialize2DArray/initialize2DArray.js +++ b/test/initialize2DArray/initialize2DArray.js @@ -1,4 +1,4 @@ -module.exports = (w, h, val = null) => +module.exports = initialize2DArray = (w, h, val = null) => Array(h) .fill() .map(() => Array(w).fill(val)); \ No newline at end of file diff --git a/test/initializeArrayWithRange/initializeArrayWithRange.js b/test/initializeArrayWithRange/initializeArrayWithRange.js index 2873d15ae..04412e638 100644 --- a/test/initializeArrayWithRange/initializeArrayWithRange.js +++ b/test/initializeArrayWithRange/initializeArrayWithRange.js @@ -1,2 +1,2 @@ -module.exports = (end, start = 0, step = 1) => +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 diff --git a/test/initializeArrayWithValues/initializeArrayWithValues.js b/test/initializeArrayWithValues/initializeArrayWithValues.js index 0d2bbce4b..a8b918cf2 100644 --- a/test/initializeArrayWithValues/initializeArrayWithValues.js +++ b/test/initializeArrayWithValues/initializeArrayWithValues.js @@ -1 +1 @@ -module.exports = (n, val = 0) => Array(n).fill(val); \ No newline at end of file +module.exports = initializeArrayWithValues = (n, val = 0) => Array(n).fill(val); \ No newline at end of file diff --git a/test/intersection/intersection.js b/test/intersection/intersection.js index c2b3f0a01..49b0c7ed7 100644 --- a/test/intersection/intersection.js +++ b/test/intersection/intersection.js @@ -1,4 +1,4 @@ -module.exports = (a, b) => { +module.exports = intersection = (a, b) => { const s = new Set(b); return a.filter(x => s.has(x)); }; \ No newline at end of file diff --git a/test/invertKeyValues/invertKeyValues.js b/test/invertKeyValues/invertKeyValues.js index 3023d7018..f9603b0ba 100644 --- a/test/invertKeyValues/invertKeyValues.js +++ b/test/invertKeyValues/invertKeyValues.js @@ -1,4 +1,4 @@ -module.exports = obj => +module.exports = invertKeyValues = obj => Object.keys(obj).reduce((acc, key) => { acc[obj[key]] = key; return acc; diff --git a/test/isAbsoluteURL/isAbsoluteURL.js b/test/isAbsoluteURL/isAbsoluteURL.js index edec7af0b..eac303d09 100644 --- a/test/isAbsoluteURL/isAbsoluteURL.js +++ b/test/isAbsoluteURL/isAbsoluteURL.js @@ -1 +1 @@ -module.exports = str => /^[a-z][a-z0-9+.-]*:/.test(str); \ No newline at end of file +module.exports = isAbsoluteURL = str => /^[a-z][a-z0-9+.-]*:/.test(str); \ No newline at end of file diff --git a/test/isArmstrongNumber/isArmstrongNumber.js b/test/isArmstrongNumber/isArmstrongNumber.js index 916550639..4384686d7 100644 --- a/test/isArmstrongNumber/isArmstrongNumber.js +++ b/test/isArmstrongNumber/isArmstrongNumber.js @@ -1,4 +1,4 @@ -module.exports = digits => +module.exports = isArmstrongNumber = digits => (arr => arr.reduce((a, d) => a + parseInt(d) ** arr.length, 0) == digits)( (digits + '').split('') ); \ No newline at end of file diff --git a/test/isArray/isArray.js b/test/isArray/isArray.js index 771748c70..0c49b742c 100644 --- a/test/isArray/isArray.js +++ b/test/isArray/isArray.js @@ -1 +1 @@ -module.exports = val => Array.isArray(val); \ No newline at end of file +module.exports = isArray = val => Array.isArray(val); \ No newline at end of file diff --git a/test/isArrayLike/isArrayLike.js b/test/isArrayLike/isArrayLike.js index 2844bc0ee..38639c27b 100644 --- a/test/isArrayLike/isArrayLike.js +++ b/test/isArrayLike/isArrayLike.js @@ -1,4 +1,4 @@ -module.exports = val => { +module.exports = isArrayLike = val => { try { return [...val], true; } catch (e) { diff --git a/test/isBoolean/isBoolean.js b/test/isBoolean/isBoolean.js index e716ff21f..3dacd74f9 100644 --- a/test/isBoolean/isBoolean.js +++ b/test/isBoolean/isBoolean.js @@ -1 +1 @@ -module.exports = val => typeof val === 'boolean'; \ No newline at end of file +module.exports = isBoolean = val => typeof val === 'boolean'; \ No newline at end of file diff --git a/test/isDivisible/isDivisible.js b/test/isDivisible/isDivisible.js index d2adb8267..f121ba660 100644 --- a/test/isDivisible/isDivisible.js +++ b/test/isDivisible/isDivisible.js @@ -1 +1 @@ -module.exports = (dividend, divisor) => dividend % divisor === 0; \ No newline at end of file +module.exports = isDivisible = (dividend, divisor) => dividend % divisor === 0; \ No newline at end of file diff --git a/test/isEven/isEven.js b/test/isEven/isEven.js index bdbcc7967..b7b8a3374 100644 --- a/test/isEven/isEven.js +++ b/test/isEven/isEven.js @@ -1 +1 @@ -module.exports = num => num % 2 === 0; \ No newline at end of file +module.exports = isEven = num => num % 2 === 0; \ No newline at end of file diff --git a/test/isFunction/isFunction.js b/test/isFunction/isFunction.js index 5a4f96273..eea7d6d8f 100644 --- a/test/isFunction/isFunction.js +++ b/test/isFunction/isFunction.js @@ -1 +1 @@ -module.exports = val => typeof val === 'function'; \ No newline at end of file +module.exports = isFunction = val => typeof val === 'function'; \ No newline at end of file diff --git a/test/isLowerCase/isLowerCase.js b/test/isLowerCase/isLowerCase.js index 1bf9ed7d9..2e784aae6 100644 --- a/test/isLowerCase/isLowerCase.js +++ b/test/isLowerCase/isLowerCase.js @@ -1 +1 @@ -module.exports = str => str === str.toLowerCase(); \ No newline at end of file +module.exports = isLowerCase = str => str === str.toLowerCase(); \ No newline at end of file diff --git a/test/isNull/isNull.js b/test/isNull/isNull.js index 3f1ce4693..68e0b1c3d 100644 --- a/test/isNull/isNull.js +++ b/test/isNull/isNull.js @@ -1 +1 @@ -module.exports = val => val === null; \ No newline at end of file +module.exports = isNull = val => val === null; \ No newline at end of file diff --git a/test/isNumber/isNumber.js b/test/isNumber/isNumber.js index ae05b7b27..f5ccf7423 100644 --- a/test/isNumber/isNumber.js +++ b/test/isNumber/isNumber.js @@ -1 +1 @@ -module.exports = val => typeof val === 'number'; \ No newline at end of file +module.exports = isNumber = val => typeof val === 'number'; \ No newline at end of file diff --git a/test/isPrime/isPrime.js b/test/isPrime/isPrime.js index afcc919c4..d30ac46b1 100644 --- a/test/isPrime/isPrime.js +++ b/test/isPrime/isPrime.js @@ -1,4 +1,4 @@ -module.exports = num => { +module.exports = 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; diff --git a/test/isPrimitive/isPrimitive.js b/test/isPrimitive/isPrimitive.js index 2dea7dc1f..72aaf090b 100644 --- a/test/isPrimitive/isPrimitive.js +++ b/test/isPrimitive/isPrimitive.js @@ -1 +1 @@ -module.exports = val => !['object', 'function'].includes(typeof val) || val === null; \ No newline at end of file +module.exports = isPrimitive = val => !['object', 'function'].includes(typeof val) || val === null; \ No newline at end of file diff --git a/test/isPromiseLike/isPromiseLike.js b/test/isPromiseLike/isPromiseLike.js index 7887a0663..ef6f5739e 100644 --- a/test/isPromiseLike/isPromiseLike.js +++ b/test/isPromiseLike/isPromiseLike.js @@ -1,4 +1,4 @@ -module.exports = obj => +module.exports = isPromiseLike = obj => obj !== null && (typeof obj === 'object' || typeof obj === 'function') && typeof obj.then === 'function'; \ No newline at end of file diff --git a/test/isSorted/isSorted.js b/test/isSorted/isSorted.js index 214ee8f17..2f164c70a 100644 --- a/test/isSorted/isSorted.js +++ b/test/isSorted/isSorted.js @@ -1,4 +1,4 @@ -module.exports = arr => { +module.exports = isSorted = arr => { const direction = arr[0] > arr[1] ? -1 : 1; for (let [i, val] of arr.entries()) if (i === arr.length - 1) return direction; diff --git a/test/isString/isString.js b/test/isString/isString.js index be1377c7b..d90ed35a0 100644 --- a/test/isString/isString.js +++ b/test/isString/isString.js @@ -1 +1 @@ -module.exports = val => typeof val === 'string'; \ No newline at end of file +module.exports = isString = val => typeof val === 'string'; \ No newline at end of file diff --git a/test/isSymbol/isSymbol.js b/test/isSymbol/isSymbol.js index 63d623028..dbb8d5b59 100644 --- a/test/isSymbol/isSymbol.js +++ b/test/isSymbol/isSymbol.js @@ -1 +1 @@ -module.exports = val => typeof val === 'symbol'; \ No newline at end of file +module.exports = isSymbol = val => typeof val === 'symbol'; \ No newline at end of file diff --git a/test/isTravisCI/isTravisCI.js b/test/isTravisCI/isTravisCI.js index 6fb689900..2146bb3db 100644 --- a/test/isTravisCI/isTravisCI.js +++ b/test/isTravisCI/isTravisCI.js @@ -1 +1 @@ -module.exports = () => 'TRAVIS' in process.env && 'CI' in process.env; \ No newline at end of file +module.exports = isTravisCI = () => 'TRAVIS' in process.env && 'CI' in process.env; \ No newline at end of file diff --git a/test/isUpperCase/isUpperCase.js b/test/isUpperCase/isUpperCase.js index 374a20638..e93f39f45 100644 --- a/test/isUpperCase/isUpperCase.js +++ b/test/isUpperCase/isUpperCase.js @@ -1 +1 @@ -module.exports = str => str === str.toUpperCase(); \ No newline at end of file +module.exports = isUpperCase = str => str === str.toUpperCase(); \ No newline at end of file diff --git a/test/isValidJSON/isValidJSON.js b/test/isValidJSON/isValidJSON.js index 348383c7a..d3b47281f 100644 --- a/test/isValidJSON/isValidJSON.js +++ b/test/isValidJSON/isValidJSON.js @@ -1,4 +1,4 @@ -module.exports = obj => { +module.exports = isValidJSON = obj => { try { JSON.parse(obj); return true; diff --git a/test/join/join.js b/test/join/join.js index e1e873e9e..57aba3ecf 100644 --- a/test/join/join.js +++ b/test/join/join.js @@ -1,4 +1,4 @@ -module.exports = (arr, separator = ',', end = separator) => +module.exports = join = (arr, separator = ',', end = separator) => arr.reduce( (acc, val, i) => i == arr.length - 2 diff --git a/test/last/last.js b/test/last/last.js index 0e2664931..8eac26a72 100644 --- a/test/last/last.js +++ b/test/last/last.js @@ -1 +1 @@ -module.exports = arr => arr[arr.length - 1]; \ No newline at end of file +module.exports = last = arr => arr[arr.length - 1]; \ No newline at end of file diff --git a/test/lcm/lcm.js b/test/lcm/lcm.js index 642c1b88c..5aba3223d 100644 --- a/test/lcm/lcm.js +++ b/test/lcm/lcm.js @@ -1,4 +1,4 @@ -module.exports = (...arr) => { +module.exports = 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)); diff --git a/test/longestItem/longestItem.js b/test/longestItem/longestItem.js index fcbeea74d..be13fd99f 100644 --- a/test/longestItem/longestItem.js +++ b/test/longestItem/longestItem.js @@ -1 +1 @@ -module.exports = (...vals) => [...vals].sort((a, b) => b.length - a.length)[0]; \ No newline at end of file +module.exports = longestItem = (...vals) => [...vals].sort((a, b) => b.length - a.length)[0]; \ No newline at end of file diff --git a/test/lowercaseKeys/lowercaseKeys.js b/test/lowercaseKeys/lowercaseKeys.js index 7c36e1798..6ec74522a 100644 --- a/test/lowercaseKeys/lowercaseKeys.js +++ b/test/lowercaseKeys/lowercaseKeys.js @@ -1,4 +1,4 @@ -module.exports = obj => +module.exports = lowercaseKeys = obj => Object.keys(obj).reduce((acc, key) => { acc[key.toLowerCase()] = obj[key]; return acc; diff --git a/test/luhnCheck/luhnCheck.js b/test/luhnCheck/luhnCheck.js index 929caae58..34721efb8 100644 --- a/test/luhnCheck/luhnCheck.js +++ b/test/luhnCheck/luhnCheck.js @@ -1,4 +1,4 @@ -module.exports = num => { +module.exports = luhnCheck = num => { let arr = (num + '') .split('') .reverse() diff --git a/test/mapObject/mapObject.js b/test/mapObject/mapObject.js index 81276a042..7dac42859 100644 --- a/test/mapObject/mapObject.js +++ b/test/mapObject/mapObject.js @@ -1,4 +1,4 @@ -module.exports = (arr, fn) => +module.exports = 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 diff --git a/test/mask/mask.js b/test/mask/mask.js index 55abe89df..a51e42c8e 100644 --- a/test/mask/mask.js +++ b/test/mask/mask.js @@ -1,2 +1,2 @@ -module.exports = (cc, num = 4, mask = '*') => +module.exports = mask = (cc, num = 4, mask = '*') => ('' + cc).slice(0, -num).replace(/./g, mask) + ('' + cc).slice(-num); \ No newline at end of file diff --git a/test/maxN/maxN.js b/test/maxN/maxN.js index 38b3de656..f2bd85782 100644 --- a/test/maxN/maxN.js +++ b/test/maxN/maxN.js @@ -1 +1 @@ -module.exports = (arr, n = 1) => [...arr].sort((a, b) => b - a).slice(0, n); \ No newline at end of file +module.exports = maxN = (arr, n = 1) => [...arr].sort((a, b) => b - a).slice(0, n); \ No newline at end of file diff --git a/test/median/median.js b/test/median/median.js index b81efe090..a926c0854 100644 --- a/test/median/median.js +++ b/test/median/median.js @@ -1,4 +1,4 @@ -module.exports = arr => { +module.exports = 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; diff --git a/test/memoize/memoize.js b/test/memoize/memoize.js index 38ac9d810..6eec034d3 100644 --- a/test/memoize/memoize.js +++ b/test/memoize/memoize.js @@ -1,4 +1,4 @@ -module.exports = fn => { +module.exports = 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); diff --git a/test/minN/minN.js b/test/minN/minN.js index 7f9610c9d..23f07fb3f 100644 --- a/test/minN/minN.js +++ b/test/minN/minN.js @@ -1 +1 @@ -module.exports = (arr, n = 1) => [...arr].sort((a, b) => a - b).slice(0, n); \ No newline at end of file +module.exports = minN = (arr, n = 1) => [...arr].sort((a, b) => a - b).slice(0, n); \ No newline at end of file diff --git a/test/negate/negate.js b/test/negate/negate.js index b58091648..b2f1bea17 100644 --- a/test/negate/negate.js +++ b/test/negate/negate.js @@ -1 +1 @@ -module.exports = func => (...args) => !func(...args); \ No newline at end of file +module.exports = negate = func => (...args) => !func(...args); \ No newline at end of file diff --git a/test/nthElement/nthElement.js b/test/nthElement/nthElement.js index a4df58e32..285873819 100644 --- a/test/nthElement/nthElement.js +++ b/test/nthElement/nthElement.js @@ -1 +1 @@ -module.exports = (arr, n = 0) => (n > 0 ? arr.slice(n, n + 1) : arr.slice(n))[0]; \ No newline at end of file +module.exports = nthElement = (arr, n = 0) => (n > 0 ? arr.slice(n, n + 1) : arr.slice(n))[0]; \ No newline at end of file diff --git a/test/objectFromPairs/objectFromPairs.js b/test/objectFromPairs/objectFromPairs.js index edebbda46..d6446c093 100644 --- a/test/objectFromPairs/objectFromPairs.js +++ b/test/objectFromPairs/objectFromPairs.js @@ -1 +1 @@ -module.exports = arr => arr.reduce((a, v) => ((a[v[0]] = v[1]), a), {}); \ No newline at end of file +module.exports = objectFromPairs = arr => arr.reduce((a, v) => ((a[v[0]] = v[1]), a), {}); \ No newline at end of file diff --git a/test/objectToPairs/objectToPairs.js b/test/objectToPairs/objectToPairs.js index 453b58370..7fe20163a 100644 --- a/test/objectToPairs/objectToPairs.js +++ b/test/objectToPairs/objectToPairs.js @@ -1 +1 @@ -module.exports = obj => Object.keys(obj).map(k => [k, obj[k]]); \ No newline at end of file +module.exports = objectToPairs = obj => Object.keys(obj).map(k => [k, obj[k]]); \ No newline at end of file diff --git a/test/off/off.js b/test/off/off.js index 4e8c82b29..8da0bc5a7 100644 --- a/test/off/off.js +++ b/test/off/off.js @@ -1 +1 @@ -module.exports = (el, evt, fn, opts = false) => el.removeEventListener(evt, fn, opts); \ No newline at end of file +module.exports = off = (el, evt, fn, opts = false) => el.removeEventListener(evt, fn, opts); \ No newline at end of file diff --git a/test/on/on.js b/test/on/on.js index b138585e4..cf1dfeb4a 100644 --- a/test/on/on.js +++ b/test/on/on.js @@ -1,4 +1,4 @@ -module.exports = (el, evt, fn, opts = {}) => { +module.exports = 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; diff --git a/test/onUserInputChange/onUserInputChange.js b/test/onUserInputChange/onUserInputChange.js index 635148849..9c090a6ac 100644 --- a/test/onUserInputChange/onUserInputChange.js +++ b/test/onUserInputChange/onUserInputChange.js @@ -1,4 +1,4 @@ -module.exports = callback => { +module.exports = onUserInputChange = callback => { let type = 'mouse', lastTime = 0; const mousemoveHandler = () => { diff --git a/test/once/once.js b/test/once/once.js index 08e0cd3ef..a7d795efb 100644 --- a/test/once/once.js +++ b/test/once/once.js @@ -1,4 +1,4 @@ -module.exports = fn => { +module.exports = once = fn => { let called = false; return function(...args) { if (called) return; diff --git a/test/orderBy/orderBy.js b/test/orderBy/orderBy.js index 396d5c372..23b6eae03 100644 --- a/test/orderBy/orderBy.js +++ b/test/orderBy/orderBy.js @@ -1,4 +1,4 @@ -module.exports = (arr, props, orders) => +module.exports = orderBy = (arr, props, orders) => [...arr].sort((a, b) => props.reduce((acc, prop, i) => { if (acc === 0) { diff --git a/test/palindrome/palindrome.js b/test/palindrome/palindrome.js index 59d0bcd95..abbff943c 100644 --- a/test/palindrome/palindrome.js +++ b/test/palindrome/palindrome.js @@ -1,4 +1,4 @@ -module.exports = str => { +module.exports = palindrome = str => { const s = str.toLowerCase().replace(/[\W_]/g, ''); return ( s === diff --git a/test/partition/partition.js b/test/partition/partition.js index 1c03df53f..a19d1b9bd 100644 --- a/test/partition/partition.js +++ b/test/partition/partition.js @@ -1,4 +1,4 @@ -module.exports = (arr, fn) => +module.exports = partition = (arr, fn) => arr.reduce( (acc, val, i, arr) => { acc[fn(val, i, arr) ? 0 : 1].push(val); diff --git a/test/percentile/percentile.js b/test/percentile/percentile.js index b71944f82..7d4a3b869 100644 --- a/test/percentile/percentile.js +++ b/test/percentile/percentile.js @@ -1,2 +1,2 @@ -module.exports = (arr, val) => +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 diff --git a/test/pick/pick.js b/test/pick/pick.js index 05e97c5b7..54c51376b 100644 --- a/test/pick/pick.js +++ b/test/pick/pick.js @@ -1,2 +1,2 @@ -module.exports = (obj, arr) => +module.exports = pick = (obj, arr) => arr.reduce((acc, curr) => (curr in obj && (acc[curr] = obj[curr]), acc), {}); \ No newline at end of file diff --git a/test/pipeFunctions/pipeFunctions.js b/test/pipeFunctions/pipeFunctions.js index eabdf74b2..0e7835724 100644 --- a/test/pipeFunctions/pipeFunctions.js +++ b/test/pipeFunctions/pipeFunctions.js @@ -1 +1 @@ -module.exports = (...fns) => fns.reduce((f, g) => (...args) => g(f(...args))); \ No newline at end of file +module.exports = pipeFunctions = (...fns) => fns.reduce((f, g) => (...args) => g(f(...args))); \ No newline at end of file diff --git a/test/pluralize/pluralize.js b/test/pluralize/pluralize.js index 1ace8fda7..1db41faff 100644 --- a/test/pluralize/pluralize.js +++ b/test/pluralize/pluralize.js @@ -1,4 +1,4 @@ -module.exports = (val, word, plural = word + 's') => { +module.exports = 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]); diff --git a/test/powerset/powerset.js b/test/powerset/powerset.js index dbe4afaf8..d4bb1959a 100644 --- a/test/powerset/powerset.js +++ b/test/powerset/powerset.js @@ -1 +1 @@ -module.exports = arr => arr.reduce((a, v) => a.concat(a.map(r => [v].concat(r))), [[]]); \ No newline at end of file +module.exports = powerset = arr => arr.reduce((a, v) => a.concat(a.map(r => [v].concat(r))), [[]]); \ No newline at end of file diff --git a/test/prettyBytes/prettyBytes.js b/test/prettyBytes/prettyBytes.js index 0e7b54eb6..173f1d317 100644 --- a/test/prettyBytes/prettyBytes.js +++ b/test/prettyBytes/prettyBytes.js @@ -1,4 +1,4 @@ -module.exports = (num, precision = 3, addSpace = true) => { +module.exports = 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); diff --git a/test/primes/primes.js b/test/primes/primes.js index 6498f2eb7..84b2e7c76 100644 --- a/test/primes/primes.js +++ b/test/primes/primes.js @@ -1,4 +1,4 @@ -module.exports = num => { +module.exports = 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); diff --git a/test/promisify/promisify.js b/test/promisify/promisify.js index 6536d3883..945c475c6 100644 --- a/test/promisify/promisify.js +++ b/test/promisify/promisify.js @@ -1,4 +1,4 @@ -module.exports = func => (...args) => +module.exports = promisify = func => (...args) => new Promise((resolve, reject) => func(...args, (err, result) => (err ? reject(err) : resolve(result))) ); \ No newline at end of file diff --git a/test/pull/pull.js b/test/pull/pull.js index 9e8db9b76..dc98d8cc6 100644 --- a/test/pull/pull.js +++ b/test/pull/pull.js @@ -1,4 +1,4 @@ -module.exports = (arr, ...args) => { +module.exports = pull = (arr, ...args) => { let argState = Array.isArray(args[0]) ? args[0] : args; let pulled = arr.filter((v, i) => !argState.includes(v)); arr.length = 0; diff --git a/test/pullAtIndex/pullAtIndex.js b/test/pullAtIndex/pullAtIndex.js index d294f5db6..9bb222ec7 100644 --- a/test/pullAtIndex/pullAtIndex.js +++ b/test/pullAtIndex/pullAtIndex.js @@ -1,4 +1,4 @@ -module.exports = (arr, pullArr) => { +module.exports = pullAtIndex = (arr, pullArr) => { let removed = []; let pulled = arr .map((v, i) => (pullArr.includes(i) ? removed.push(v) : v)) diff --git a/test/pullAtValue/pullAtValue.js b/test/pullAtValue/pullAtValue.js index 0aee77a64..d756c88d1 100644 --- a/test/pullAtValue/pullAtValue.js +++ b/test/pullAtValue/pullAtValue.js @@ -1,4 +1,4 @@ -module.exports = (arr, pullArr) => { +module.exports = 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)); diff --git a/test/quickSort/quickSort.js b/test/quickSort/quickSort.js index 0e01c23d0..e934c3247 100644 --- a/test/quickSort/quickSort.js +++ b/test/quickSort/quickSort.js @@ -1,4 +1,4 @@ -module.exports = ([n, ...nums], desc) => +module.exports = quickSort = ([n, ...nums], desc) => isNaN(n) ? [] : [ diff --git a/test/randomHexColorCode/randomHexColorCode.js b/test/randomHexColorCode/randomHexColorCode.js index ff0186633..84e165e36 100644 --- a/test/randomHexColorCode/randomHexColorCode.js +++ b/test/randomHexColorCode/randomHexColorCode.js @@ -1,4 +1,4 @@ -module.exports = () => { +module.exports = 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 diff --git a/test/randomIntegerInRange/randomIntegerInRange.js b/test/randomIntegerInRange/randomIntegerInRange.js index 395e81002..c65200432 100644 --- a/test/randomIntegerInRange/randomIntegerInRange.js +++ b/test/randomIntegerInRange/randomIntegerInRange.js @@ -1 +1 @@ -module.exports = (min, max) => Math.floor(Math.random() * (max - min + 1)) + min; \ No newline at end of file +module.exports = randomIntegerInRange = (min, max) => Math.floor(Math.random() * (max - min + 1)) + min; \ No newline at end of file diff --git a/test/randomNumberInRange/randomNumberInRange.js b/test/randomNumberInRange/randomNumberInRange.js index efafeaa04..8ff0b7d5d 100644 --- a/test/randomNumberInRange/randomNumberInRange.js +++ b/test/randomNumberInRange/randomNumberInRange.js @@ -1 +1 @@ -module.exports = (min, max) => Math.random() * (max - min) + min; \ No newline at end of file +module.exports = randomNumberInRange = (min, max) => Math.random() * (max - min) + min; \ No newline at end of file diff --git a/test/redirect/redirect.js b/test/redirect/redirect.js index 38870dc52..4bcc6c690 100644 --- a/test/redirect/redirect.js +++ b/test/redirect/redirect.js @@ -1,2 +1,2 @@ -module.exports = (url, asLink = true) => +module.exports = redirect = (url, asLink = true) => asLink ? (window.location.href = url) : window.location.replace(url); \ No newline at end of file diff --git a/test/reducedFilter/reducedFilter.js b/test/reducedFilter/reducedFilter.js index 4df25b5ae..8e8cd4f34 100644 --- a/test/reducedFilter/reducedFilter.js +++ b/test/reducedFilter/reducedFilter.js @@ -1,4 +1,4 @@ -module.exports = (data, keys, fn) => +module.exports = reducedFilter = (data, keys, fn) => data.filter(fn).map(el => keys.reduce((acc, key) => { acc[key] = el[key]; diff --git a/test/remove/remove.js b/test/remove/remove.js index 8e73d0fa1..300e10348 100644 --- a/test/remove/remove.js +++ b/test/remove/remove.js @@ -1,4 +1,4 @@ -module.exports = (arr, func) => +module.exports = remove = (arr, func) => Array.isArray(arr) ? arr.filter(func).reduce((acc, val) => { arr.splice(arr.indexOf(val), 1); diff --git a/test/removeVowels/removeVowels.js b/test/removeVowels/removeVowels.js new file mode 100644 index 000000000..42006eb0c --- /dev/null +++ b/test/removeVowels/removeVowels.js @@ -0,0 +1 @@ +module.exports = removeVowels = (str, repl = '') => str.replace(/[aeiou]/gi,repl); \ No newline at end of file diff --git a/test/removeVowels/removeVowels.test.js b/test/removeVowels/removeVowels.test.js new file mode 100644 index 000000000..be9566c24 --- /dev/null +++ b/test/removeVowels/removeVowels.test.js @@ -0,0 +1,13 @@ +const test = require('tape'); +const removeVowels = require('./removeVowels.js'); + +test('Testing removeVowels', (t) => { + //For more information on all the methods supported by tape + //Please go to https://github.com/substack/tape + t.true(typeof removeVowels === 'function', 'removeVowels is a Function'); + //t.deepEqual(removeVowels(args..), 'Expected'); + //t.equal(removeVowels(args..), 'Expected'); + //t.false(removeVowels(args..), 'Expected'); + //t.throws(removeVowels(args..), 'Expected'); + t.end(); +}); \ No newline at end of file diff --git a/test/reverseString/reverseString.js b/test/reverseString/reverseString.js index d9ba44226..f2ac18832 100644 --- a/test/reverseString/reverseString.js +++ b/test/reverseString/reverseString.js @@ -1 +1 @@ -module.exports = str => [...str].reverse().join(''); \ No newline at end of file +module.exports = reverseString = str => [...str].reverse().join(''); \ No newline at end of file diff --git a/test/round/round.js b/test/round/round.js index f5466934c..162c56284 100644 --- a/test/round/round.js +++ b/test/round/round.js @@ -1 +1 @@ -module.exports = (n, decimals = 0) => Number(`${Math.round(`${n}e${decimals}`)}e-${decimals}`); \ No newline at end of file +module.exports = round = (n, decimals = 0) => Number(`${Math.round(`${n}e${decimals}`)}e-${decimals}`); \ No newline at end of file diff --git a/test/runAsync/runAsync.js b/test/runAsync/runAsync.js index 09b16fe54..6769a3672 100644 --- a/test/runAsync/runAsync.js +++ b/test/runAsync/runAsync.js @@ -1,4 +1,4 @@ -module.exports = fn => { +module.exports = runAsync = fn => { const blob = `var fn = ${fn.toString()}; postMessage(fn());`; const worker = new Worker( URL.createObjectURL(new Blob([blob]), { diff --git a/test/runPromisesInSeries/runPromisesInSeries.js b/test/runPromisesInSeries/runPromisesInSeries.js index 8bed23ec5..5985d538e 100644 --- a/test/runPromisesInSeries/runPromisesInSeries.js +++ b/test/runPromisesInSeries/runPromisesInSeries.js @@ -1 +1 @@ -module.exports = ps => ps.reduce((p, next) => p.then(next), Promise.resolve()); \ No newline at end of file +module.exports = runPromisesInSeries = ps => ps.reduce((p, next) => p.then(next), Promise.resolve()); \ No newline at end of file diff --git a/test/sample/sample.js b/test/sample/sample.js index 116d6de83..5664f4197 100644 --- a/test/sample/sample.js +++ b/test/sample/sample.js @@ -1 +1 @@ -module.exports = arr => arr[Math.floor(Math.random() * arr.length)]; \ No newline at end of file +module.exports = sample = arr => arr[Math.floor(Math.random() * arr.length)]; \ No newline at end of file diff --git a/test/sampleSize/sampleSize.js b/test/sampleSize/sampleSize.js index 6ded2b389..cb7796b38 100644 --- a/test/sampleSize/sampleSize.js +++ b/test/sampleSize/sampleSize.js @@ -1,4 +1,4 @@ -module.exports = ([...arr], n = 1) => { +module.exports = sampleSize = ([...arr], n = 1) => { let m = arr.length; while (m) { const i = Math.floor(Math.random() * m--); diff --git a/test/scrollToTop/scrollToTop.js b/test/scrollToTop/scrollToTop.js index 4aa1c1dde..903a98d44 100644 --- a/test/scrollToTop/scrollToTop.js +++ b/test/scrollToTop/scrollToTop.js @@ -1,4 +1,4 @@ -module.exports = () => { +module.exports = scrollToTop = () => { const c = document.documentElement.scrollTop || document.body.scrollTop; if (c > 0) { window.requestAnimationFrame(scrollToTop); diff --git a/test/sdbm/sdbm.js b/test/sdbm/sdbm.js index c3ad8ec64..17eb2a60b 100644 --- a/test/sdbm/sdbm.js +++ b/test/sdbm/sdbm.js @@ -1,4 +1,4 @@ -module.exports = str => { +module.exports = sdbm = str => { let arr = str.split(''); return arr.reduce( (hashCode, currentVal) => diff --git a/test/select/select.js b/test/select/select.js index adc0c5240..62aed5333 100644 --- a/test/select/select.js +++ b/test/select/select.js @@ -1,2 +1,2 @@ -module.exports = (from, selector) => +module.exports = select = (from, selector) => selector.split('.').reduce((prev, cur) => prev && prev[cur], from); \ No newline at end of file diff --git a/test/setStyle/setStyle.js b/test/setStyle/setStyle.js index 9e6d93c0e..f4b2497df 100644 --- a/test/setStyle/setStyle.js +++ b/test/setStyle/setStyle.js @@ -1 +1 @@ -module.exports = (el, ruleName, val) => (el.style[ruleName] = val); \ No newline at end of file +module.exports = setStyle = (el, ruleName, val) => (el.style[ruleName] = val); \ No newline at end of file diff --git a/test/shallowClone/shallowClone.js b/test/shallowClone/shallowClone.js index 3fe063166..b6e070181 100644 --- a/test/shallowClone/shallowClone.js +++ b/test/shallowClone/shallowClone.js @@ -1 +1 @@ -module.exports = obj => Object.assign({}, obj); \ No newline at end of file +module.exports = shallowClone = obj => Object.assign({}, obj); \ No newline at end of file diff --git a/test/show/show.js b/test/show/show.js index 52121e7d7..29c808b20 100644 --- a/test/show/show.js +++ b/test/show/show.js @@ -1 +1 @@ -module.exports = (...el) => [...el].forEach(e => (e.style.display = '')); \ No newline at end of file +module.exports = show = (...el) => [...el].forEach(e => (e.style.display = '')); \ No newline at end of file diff --git a/test/shuffle/shuffle.js b/test/shuffle/shuffle.js index cd22089d4..35ba6b488 100644 --- a/test/shuffle/shuffle.js +++ b/test/shuffle/shuffle.js @@ -1,4 +1,4 @@ -module.exports = ([...arr]) => { +module.exports = shuffle = ([...arr]) => { let m = arr.length; while (m) { const i = Math.floor(Math.random() * m--); diff --git a/test/similarity/similarity.js b/test/similarity/similarity.js index f9bd00dd5..624398364 100644 --- a/test/similarity/similarity.js +++ b/test/similarity/similarity.js @@ -1 +1 @@ -module.exports = (arr, values) => arr.filter(v => values.includes(v)); \ No newline at end of file +module.exports = similarity = (arr, values) => arr.filter(v => values.includes(v)); \ No newline at end of file diff --git a/test/size/size.js b/test/size/size.js index 10644d5ca..fe0a268d5 100644 --- a/test/size/size.js +++ b/test/size/size.js @@ -1,4 +1,4 @@ -module.exports = val => +module.exports = size = val => Array.isArray(val) ? val.length : val && typeof val === 'object' diff --git a/test/sleep/sleep.js b/test/sleep/sleep.js index 10732ba83..288fb7cad 100644 --- a/test/sleep/sleep.js +++ b/test/sleep/sleep.js @@ -1 +1 @@ -module.exports = ms => new Promise(resolve => setTimeout(resolve, ms)); \ No newline at end of file +module.exports = sleep = ms => new Promise(resolve => setTimeout(resolve, ms)); \ No newline at end of file diff --git a/test/solveRPN/solveRPN.js b/test/solveRPN/solveRPN.js index 4b25f9e9d..8bd4f105c 100644 --- a/test/solveRPN/solveRPN.js +++ b/test/solveRPN/solveRPN.js @@ -1,4 +1,4 @@ -module.exports = rpn => { +module.exports = solveRPN = rpn => { const OPERATORS = { '*': (a, b) => a * b, '+': (a, b) => a + b, diff --git a/test/sortCharactersInString/sortCharactersInString.js b/test/sortCharactersInString/sortCharactersInString.js index 08db6a93a..526c646ef 100644 --- a/test/sortCharactersInString/sortCharactersInString.js +++ b/test/sortCharactersInString/sortCharactersInString.js @@ -1 +1 @@ -module.exports = str => [...str].sort((a, b) => a.localeCompare(b)).join(''); \ No newline at end of file +module.exports = sortCharactersInString = str => [...str].sort((a, b) => a.localeCompare(b)).join(''); \ No newline at end of file diff --git a/test/sortedIndex/sortedIndex.js b/test/sortedIndex/sortedIndex.js index 806ce2959..8e7e26b10 100644 --- a/test/sortedIndex/sortedIndex.js +++ b/test/sortedIndex/sortedIndex.js @@ -1,4 +1,4 @@ -module.exports = (arr, n) => { +module.exports = 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; diff --git a/test/speechSynthesis/speechSynthesis.js b/test/speechSynthesis/speechSynthesis.js index 71f114c74..a174e4c92 100644 --- a/test/speechSynthesis/speechSynthesis.js +++ b/test/speechSynthesis/speechSynthesis.js @@ -1,4 +1,4 @@ -module.exports = message => { +module.exports = speechSynthesis = message => { const msg = new SpeechSynthesisUtterance(message); msg.voice = window.speechSynthesis.getVoices()[0]; window.speechSynthesis.speak(msg); diff --git a/test/splitLines/splitLines.js b/test/splitLines/splitLines.js index b6a0085e7..c1db2f580 100644 --- a/test/splitLines/splitLines.js +++ b/test/splitLines/splitLines.js @@ -1 +1 @@ -module.exports = str => str.split(/\r?\n/); \ No newline at end of file +module.exports = splitLines = str => str.split(/\r?\n/); \ No newline at end of file diff --git a/test/spreadOver/spreadOver.js b/test/spreadOver/spreadOver.js index 2f5986d58..792f39794 100644 --- a/test/spreadOver/spreadOver.js +++ b/test/spreadOver/spreadOver.js @@ -1 +1 @@ -module.exports = fn => argsArr => fn(...argsArr); \ No newline at end of file +module.exports = spreadOver = fn => argsArr => fn(...argsArr); \ No newline at end of file diff --git a/test/standardDeviation/standardDeviation.js b/test/standardDeviation/standardDeviation.js index cf81acc29..953e80499 100644 --- a/test/standardDeviation/standardDeviation.js +++ b/test/standardDeviation/standardDeviation.js @@ -1,4 +1,4 @@ -module.exports = (arr, usePopulation = false) => { +module.exports = 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) / diff --git a/test/sum/sum.js b/test/sum/sum.js index 45cd30bad..3908fbb67 100644 --- a/test/sum/sum.js +++ b/test/sum/sum.js @@ -1 +1 @@ -module.exports = (...arr) => [...arr].reduce((acc, val) => acc + val, 0); \ No newline at end of file +module.exports = sum = (...arr) => [...arr].reduce((acc, val) => acc + val, 0); \ No newline at end of file diff --git a/test/sumPower/sumPower.js b/test/sumPower/sumPower.js index d74e25e7c..a904a5eaa 100644 --- a/test/sumPower/sumPower.js +++ b/test/sumPower/sumPower.js @@ -1,4 +1,4 @@ -module.exports = (end, power = 2, start = 1) => +module.exports = sumPower = (end, power = 2, start = 1) => Array(end + 1 - start) .fill(0) .map((x, i) => (i + start) ** power) diff --git a/test/symmetricDifference/symmetricDifference.js b/test/symmetricDifference/symmetricDifference.js index a8847e9ff..157a2ce92 100644 --- a/test/symmetricDifference/symmetricDifference.js +++ b/test/symmetricDifference/symmetricDifference.js @@ -1,4 +1,4 @@ -module.exports = (a, b) => { +module.exports = 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))]; diff --git a/test/tail/tail.js b/test/tail/tail.js index c4bf70328..ddee48e18 100644 --- a/test/tail/tail.js +++ b/test/tail/tail.js @@ -1 +1 @@ -module.exports = arr => (arr.length > 1 ? arr.slice(1) : arr); \ No newline at end of file +module.exports = tail = arr => (arr.length > 1 ? arr.slice(1) : arr); \ No newline at end of file diff --git a/test/take/take.js b/test/take/take.js index cd43d2548..38696604c 100644 --- a/test/take/take.js +++ b/test/take/take.js @@ -1 +1 @@ -module.exports = (arr, n = 1) => arr.slice(0, n); \ No newline at end of file +module.exports = take = (arr, n = 1) => arr.slice(0, n); \ No newline at end of file diff --git a/test/takeRight/takeRight.js b/test/takeRight/takeRight.js index a3aedc31d..474aa19bf 100644 --- a/test/takeRight/takeRight.js +++ b/test/takeRight/takeRight.js @@ -1 +1 @@ -module.exports = (arr, n = 1) => arr.slice(arr.length - n, arr.length); \ No newline at end of file +module.exports = takeRight = (arr, n = 1) => arr.slice(arr.length - n, arr.length); \ No newline at end of file diff --git a/test/timeTaken/timeTaken.js b/test/timeTaken/timeTaken.js index d34042e69..0a9213869 100644 --- a/test/timeTaken/timeTaken.js +++ b/test/timeTaken/timeTaken.js @@ -1,4 +1,4 @@ -module.exports = callback => { +module.exports = timeTaken = callback => { console.time('timeTaken'); const r = callback(); console.timeEnd('timeTaken'); diff --git a/test/toCamelCase/toCamelCase.js b/test/toCamelCase/toCamelCase.js index 61070be95..4d84af388 100644 --- a/test/toCamelCase/toCamelCase.js +++ b/test/toCamelCase/toCamelCase.js @@ -1,4 +1,4 @@ -module.exports = str => { +module.exports = toCamelCase = str => { let s = str && str diff --git a/test/toDecimalMark/toDecimalMark.js b/test/toDecimalMark/toDecimalMark.js index ec3562358..563c5efcb 100644 --- a/test/toDecimalMark/toDecimalMark.js +++ b/test/toDecimalMark/toDecimalMark.js @@ -1 +1 @@ -module.exports = num => num.toLocaleString('en-US'); \ No newline at end of file +module.exports = toDecimalMark = num => num.toLocaleString('en-US'); \ No newline at end of file diff --git a/test/toEnglishDate/toEnglishDate.js b/test/toEnglishDate/toEnglishDate.js index 1608ad0c0..9671848e5 100644 --- a/test/toEnglishDate/toEnglishDate.js +++ b/test/toEnglishDate/toEnglishDate.js @@ -1,4 +1,4 @@ -module.exports = time => { +module.exports = toEnglishDate = time => { try { return new Date(time) .toISOString() diff --git a/test/toKebabCase/toKebabCase.js b/test/toKebabCase/toKebabCase.js index 6132c4a38..16680f644 100644 --- a/test/toKebabCase/toKebabCase.js +++ b/test/toKebabCase/toKebabCase.js @@ -1,4 +1,4 @@ -module.exports = str => +module.exports = 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) diff --git a/test/toOrdinalSuffix/toOrdinalSuffix.js b/test/toOrdinalSuffix/toOrdinalSuffix.js index 3a55dba4d..18e3c9d09 100644 --- a/test/toOrdinalSuffix/toOrdinalSuffix.js +++ b/test/toOrdinalSuffix/toOrdinalSuffix.js @@ -1,4 +1,4 @@ -module.exports = num => { +module.exports = toOrdinalSuffix = num => { const int = parseInt(num), digits = [int % 10, int % 100], ordinals = ['st', 'nd', 'rd', 'th'], diff --git a/test/toSafeInteger/toSafeInteger.js b/test/toSafeInteger/toSafeInteger.js index fce9922a8..922725a93 100644 --- a/test/toSafeInteger/toSafeInteger.js +++ b/test/toSafeInteger/toSafeInteger.js @@ -1,2 +1,2 @@ -module.exports = num => +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 diff --git a/test/toSnakeCase/toSnakeCase.js b/test/toSnakeCase/toSnakeCase.js index b98b314d6..5011bd234 100644 --- a/test/toSnakeCase/toSnakeCase.js +++ b/test/toSnakeCase/toSnakeCase.js @@ -1,4 +1,4 @@ -module.exports = str => +module.exports = 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) diff --git a/test/toggleClass/toggleClass.js b/test/toggleClass/toggleClass.js index 17f3caa71..abb5ca097 100644 --- a/test/toggleClass/toggleClass.js +++ b/test/toggleClass/toggleClass.js @@ -1 +1 @@ -module.exports = (el, className) => el.classList.toggle(className); \ No newline at end of file +module.exports = toggleClass = (el, className) => el.classList.toggle(className); \ No newline at end of file diff --git a/test/tomorrow/tomorrow.js b/test/tomorrow/tomorrow.js index 1e75360fc..ab202df3d 100644 --- a/test/tomorrow/tomorrow.js +++ b/test/tomorrow/tomorrow.js @@ -1 +1 @@ -module.exports = () => new Date(new Date().getTime() + 86400000).toISOString().split('T')[0]; \ No newline at end of file +module.exports = tomorrow = () => new Date(new Date().getTime() + 86400000).toISOString().split('T')[0]; \ No newline at end of file diff --git a/test/truncateString/truncateString.js b/test/truncateString/truncateString.js index 04a3a6755..f2de7b8d1 100644 --- a/test/truncateString/truncateString.js +++ b/test/truncateString/truncateString.js @@ -1,2 +1,2 @@ -module.exports = (str, num) => +module.exports = truncateString = (str, num) => str.length > num ? str.slice(0, num > 3 ? num - 3 : num) + '...' : str; \ No newline at end of file diff --git a/test/truthCheckCollection/truthCheckCollection.js b/test/truthCheckCollection/truthCheckCollection.js index 33c508b15..75a1892b8 100644 --- a/test/truthCheckCollection/truthCheckCollection.js +++ b/test/truthCheckCollection/truthCheckCollection.js @@ -1 +1 @@ -module.exports = (collection, pre) => collection.every(obj => obj[pre]); \ No newline at end of file +module.exports = truthCheckCollection = (collection, pre) => collection.every(obj => obj[pre]); \ No newline at end of file diff --git a/test/unescapeHTML/unescapeHTML.js b/test/unescapeHTML/unescapeHTML.js index d051051d2..3c3927c23 100644 --- a/test/unescapeHTML/unescapeHTML.js +++ b/test/unescapeHTML/unescapeHTML.js @@ -1,4 +1,4 @@ -module.exports = str => +module.exports = unescapeHTML = str => str.replace( /&|<|>|'|"/g, tag => diff --git a/test/union/union.js b/test/union/union.js index fce73daff..f5b2514ef 100644 --- a/test/union/union.js +++ b/test/union/union.js @@ -1 +1 @@ -module.exports = (a, b) => Array.from(new Set([...a, ...b])); \ No newline at end of file +module.exports = union = (a, b) => Array.from(new Set([...a, ...b])); \ No newline at end of file diff --git a/test/untildify/untildify.js b/test/untildify/untildify.js index d8fdc33fe..82e8476bf 100644 --- a/test/untildify/untildify.js +++ b/test/untildify/untildify.js @@ -1 +1 @@ -module.exports = str => str.replace(/^~($|\/|\\)/, `${require('os').homedir()}$1`); \ No newline at end of file +module.exports = untildify = str => str.replace(/^~($|\/|\\)/, `${require('os').homedir()}$1`); \ No newline at end of file diff --git a/test/validateNumber/validateNumber.js b/test/validateNumber/validateNumber.js index 08913a160..b4cd036e5 100644 --- a/test/validateNumber/validateNumber.js +++ b/test/validateNumber/validateNumber.js @@ -1 +1 @@ -module.exports = n => !isNaN(parseFloat(n)) && isFinite(n) && Number(n) == n; \ No newline at end of file +module.exports = validateNumber = n => !isNaN(parseFloat(n)) && isFinite(n) && Number(n) == n; \ No newline at end of file diff --git a/test/without/without.js b/test/without/without.js index dab9ff155..7cdf4434b 100644 --- a/test/without/without.js +++ b/test/without/without.js @@ -1 +1 @@ -module.exports = (arr, ...args) => arr.filter(v => !args.includes(v)); \ No newline at end of file +module.exports = without = (arr, ...args) => arr.filter(v => !args.includes(v)); \ No newline at end of file diff --git a/test/words/words.js b/test/words/words.js index 02263bfc1..d6eabc94b 100644 --- a/test/words/words.js +++ b/test/words/words.js @@ -1 +1 @@ -module.exports = (str, pattern = /[^a-zA-Z-]+/) => str.split(pattern).filter(Boolean); \ No newline at end of file +module.exports = words = (str, pattern = /[^a-zA-Z-]+/) => str.split(pattern).filter(Boolean); \ No newline at end of file diff --git a/test/yesNo/yesNo.js b/test/yesNo/yesNo.js index 0b489bdb4..e9fb38b7b 100644 --- a/test/yesNo/yesNo.js +++ b/test/yesNo/yesNo.js @@ -1,2 +1,2 @@ -module.exports = (val, def = false) => +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 diff --git a/test/zip/zip.js b/test/zip/zip.js index 0ae142bce..ae33cbf91 100644 --- a/test/zip/zip.js +++ b/test/zip/zip.js @@ -1,4 +1,4 @@ -module.exports = (...arrays) => { +module.exports = 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]); diff --git a/test/zipObject/zipObject.js b/test/zipObject/zipObject.js index 9e2e0123d..3962e5421 100644 --- a/test/zipObject/zipObject.js +++ b/test/zipObject/zipObject.js @@ -1,2 +1,2 @@ -module.exports = (props, values) => +module.exports = zipObject = (props, values) => props.reduce((obj, prop, index) => ((obj[prop] = values[index]), obj), {}); \ No newline at end of file From 36f0e9261feb2ae99d0fdfebb566692a7a960b78 Mon Sep 17 00:00:00 2001 From: King Date: Wed, 10 Jan 2018 16:23:21 -0500 Subject: [PATCH 3/5] add basic 2 test for zip snippet --- test/zip/zip.test.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/zip/zip.test.js b/test/zip/zip.test.js index 31a138367..842c7abc1 100644 --- a/test/zip/zip.test.js +++ b/test/zip/zip.test.js @@ -5,9 +5,10 @@ test('Testing zip', (t) => { //For more information on all the methods supported by tape //Please go to https://github.com/substack/tape t.true(typeof zip === 'function', 'zip is a Function'); - //t.deepEqual(zip(args..), 'Expected'); + t.deepEqual(zip(['a', 'b'], [1, 2], [true, false]), [['a', 1, true], ['b', 2, false]], 'Object was zipped'); + t.deepEqual(zip(['a'], [1, 2], [true, false]), [['a', 1, true], [undefined, 2, false]], 'Object was zipped'); //t.equal(zip(args..), 'Expected'); //t.false(zip(args..), 'Expected'); //t.throws(zip(args..), 'Expected'); t.end(); -}); \ No newline at end of file +}); From 8f55271baf6e7bb3e0837a7d7de181e406f599de Mon Sep 17 00:00:00 2001 From: King Date: Wed, 10 Jan 2018 16:32:37 -0500 Subject: [PATCH 4/5] add 2 type Array.isArray test for zip return value --- test/zip/zip.test.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/test/zip/zip.test.js b/test/zip/zip.test.js index 842c7abc1..f222d90a5 100644 --- a/test/zip/zip.test.js +++ b/test/zip/zip.test.js @@ -7,7 +7,8 @@ test('Testing zip', (t) => { t.true(typeof zip === 'function', 'zip is a Function'); t.deepEqual(zip(['a', 'b'], [1, 2], [true, false]), [['a', 1, true], ['b', 2, false]], 'Object was zipped'); t.deepEqual(zip(['a'], [1, 2], [true, false]), [['a', 1, true], [undefined, 2, false]], 'Object was zipped'); - //t.equal(zip(args..), 'Expected'); + t.true(Array.isArray(zip(['a', 'b'], [1, 2], [true, false])), 'zip returns an Array'); + t.true(Array.isArray(zip(['a'], [1, 2], [true, false])), 'zip returns an Array'); //t.false(zip(args..), 'Expected'); //t.throws(zip(args..), 'Expected'); t.end(); From 40210c9cd96dcf8a8f3b090c489c33d357de6dbb Mon Sep 17 00:00:00 2001 From: King Date: Wed, 10 Jan 2018 16:37:10 -0500 Subject: [PATCH 5/5] add 2 basic test for zipObject snippet --- test/zipObject/zipObject.test.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/zipObject/zipObject.test.js b/test/zipObject/zipObject.test.js index 2aafee4c7..fb17581eb 100644 --- a/test/zipObject/zipObject.test.js +++ b/test/zipObject/zipObject.test.js @@ -5,9 +5,10 @@ test('Testing zipObject', (t) => { //For more information on all the methods supported by tape //Please go to https://github.com/substack/tape t.true(typeof zipObject === 'function', 'zipObject is a Function'); - //t.deepEqual(zipObject(args..), 'Expected'); + t.deepEqual(zipObject(['a', 'b', 'c'], [1, 2]), {a: 1, b: 2, c: undefined}, 'Array was zipped to object'); + t.deepEqual(zipObject(['a', 'b'], [1, 2, 3]), {a: 1, b: 2}, 'Array was zipped to object'); //t.equal(zipObject(args..), 'Expected'); //t.false(zipObject(args..), 'Expected'); //t.throws(zipObject(args..), 'Expected'); t.end(); -}); \ No newline at end of file +});