From 83e699623803d1d63346ccdaacada196c88b26f0 Mon Sep 17 00:00:00 2001 From: King Date: Thu, 25 Jan 2018 18:42:58 -0500 Subject: [PATCH 01/33] update round.test.js with time, omit, types, error, NaN --- test/round/round.test.js | 20 +++++++++++++++----- 1 file changed, 15 insertions(+), 5 deletions(-) diff --git a/test/round/round.test.js b/test/round/round.test.js index 7af718c04..2aa705899 100644 --- a/test/round/round.test.js +++ b/test/round/round.test.js @@ -5,9 +5,19 @@ test('Testing round', (t) => { //For more information on all the methods supported by tape //Please go to https://github.com/substack/tape t.true(typeof round === 'function', 'round is a Function'); - t.equal(round(1.005, 2), 1.01, "Rounds a number to a specified amount of digits."); - //t.equal(round(args..), 'Expected'); - //t.false(round(args..), 'Expected'); - //t.throws(round(args..), 'Expected'); + t.equal(round(1.005, 2), 1.01, "round(1.005, 2) returns 1.01"); + t.equal(round(123.3423345345345345344, 11), 123.34233453453, "round(123.3423345345345345344, 11) returns 123.34233453453"); + t.equal(round(3.342, 11), 3.342, "round(3.342, 11) returns 3.342"); + t.equal(round(1.005), 1, "round(1.005) returns 1"); + t.true(isNaN(round([1.005, 2])), 'round([1.005, 2]) returns NaN'); + t.true(isNaN(round('string')), 'round(string) returns NaN'); + t.true(isNaN(round()), 'round() returns NaN'); + t.true(isNaN(round(132, 413, 4134)), 'round(132, 413, 4134) returns NaN'); + t.true(isNaN(round({a: 132}, 413)), 'round({a: 132}, 413) returns NaN'); + + let start = new Date().getTime(); + round(123.3423345345345345344, 11); + let end = new Date().getTime(); + t.true((end - start) < 2000, 'round(123.3423345345345345344, 11) takes less than 2s to run'); t.end(); -}); \ No newline at end of file +}); From 62aae1c41fe7ea4954b6ba35f8a167b1add26039 Mon Sep 17 00:00:00 2001 From: King Date: Fri, 26 Jan 2018 16:56:37 -0500 Subject: [PATCH 02/33] update toCamelCase omit, type, time test, error --- test/toCamelCase/toCamelCase.test.js | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/test/toCamelCase/toCamelCase.test.js b/test/toCamelCase/toCamelCase.test.js index b41794011..0f3efc557 100644 --- a/test/toCamelCase/toCamelCase.test.js +++ b/test/toCamelCase/toCamelCase.test.js @@ -5,13 +5,18 @@ test('Testing toCamelCase', (t) => { //For more information on all the methods supported by tape //Please go to https://github.com/substack/tape t.true(typeof toCamelCase === 'function', 'toCamelCase is a Function'); - t.equal(toCamelCase('some_database_field_name'), 'someDatabaseFieldName', "Converts a string to camelCase"); - t.equal(toCamelCase('Some label that needs to be camelized'), 'someLabelThatNeedsToBeCamelized', "Converts a string to camelCase"); - t.equal(toCamelCase('some-javascript-property'), 'someJavascriptProperty', "Converts a string to camelCase"); - t.equal(toCamelCase('some-mixed_string with spaces_underscores-and-hyphens'), 'someMixedStringWithSpacesUnderscoresAndHyphens', "Converts a string to camelCase"); - //t.deepEqual(toCamelCase(args..), 'Expected'); - //t.equal(toCamelCase(args..), 'Expected'); - //t.false(toCamelCase(args..), 'Expected'); - //t.throws(toCamelCase(args..), 'Expected'); + t.equal(toCamelCase('some_database_field_name'), 'someDatabaseFieldName', "toCamelCase('some_database_field_name') returns someDatabaseFieldName"); + t.equal(toCamelCase('Some label that needs to be camelized'), 'someLabelThatNeedsToBeCamelized', "toCamelCase('Some label that needs to be camelized') returns someLabelThatNeedsToBeCamelized"); + t.equal(toCamelCase('some-javascript-property'), 'someJavascriptProperty', "toCamelCase('some-javascript-property') return someJavascriptProperty"); + t.equal(toCamelCase('some-mixed_string with spaces_underscores-and-hyphens'), 'someMixedStringWithSpacesUnderscoresAndHyphens', "toCamelCase('some-mixed_string with spaces_underscores-and-hyphens') returns someMixedStringWithSpacesUnderscoresAndHyphens"); + t.throws(() => toCamelCase(), 'toCamelCase() throws a error'); + t.throws(() => toCamelCase([]), 'toCamelCase([]) throws a error'); + t.throws(() => toCamelCase({}), 'toCamelCase({}) throws a error'); + t.throws(() => toCamelCase(123), 'toCamelCase(123) throws a error'); + + let start = new Date().getTime(); + toCamelCase('some-mixed_string with spaces_underscores-and-hyphens'); + let end = new Date().getTime(); + t.true((end - start) < 2000, 'toCamelCase(some-mixed_string with spaces_underscores-and-hyphens) takes less than 2s to run'); t.end(); -}); \ No newline at end of file +}); From c77ec48ab40a41d7b9c2e76f63d2aa099a90e30b Mon Sep 17 00:00:00 2001 From: King Date: Fri, 26 Jan 2018 17:04:49 -0500 Subject: [PATCH 03/33] update toKebabCase.test.js omit, type, timed, error test --- test/toKebabCase/toKebabCase.test.js | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/test/toKebabCase/toKebabCase.test.js b/test/toKebabCase/toKebabCase.test.js index fe305e2b2..caa4c25ea 100644 --- a/test/toKebabCase/toKebabCase.test.js +++ b/test/toKebabCase/toKebabCase.test.js @@ -5,13 +5,18 @@ test('Testing toKebabCase', (t) => { //For more information on all the methods supported by tape //Please go to https://github.com/substack/tape t.true(typeof toKebabCase === 'function', 'toKebabCase is a Function'); - t.equal(toKebabCase('camelCase'), 'camel-case', "string converts to snake case"); - t.equal(toKebabCase('some text'), 'some-text', "string converts to snake case"); - t.equal(toKebabCase('some-mixed-string With spaces-underscores-and-hyphens'), 'some-mixed-string-with-spaces-underscores-and-hyphens', "string converts to snake case"); - t.equal(toKebabCase('IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML'), 'i-am-listening-to-fm-while-loading-different-url-on-my-browser-and-also-editing-some-xml-and-html', "string converts to snake case"); - //t.deepEqual(toKebabCase(args..), 'Expected'); - //t.equal(toKebabCase(args..), 'Expected'); - //t.false(toKebabCase(args..), 'Expected'); - //t.throws(toKebabCase(args..), 'Expected'); + t.equal(toKebabCase('camelCase'), 'camel-case', "toKebabCase('camelCase') returns camel-case"); + t.equal(toKebabCase('some text'), 'some-text', "toKebabCase('some text') returns some-text"); + t.equal(toKebabCase('some-mixed-string With spaces-underscores-and-hyphens'), 'some-mixed-string-with-spaces-underscores-and-hyphens', "toKebabCase('some-mixed-string With spaces-underscores-and-hyphens') returns some-mixed-string-with-spaces-underscores-and-hyphens"); + t.equal(toKebabCase('IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML'), 'i-am-listening-to-fm-while-loading-different-url-on-my-browser-and-also-editing-some-xml-and-html', "toKebabCase('IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML') returns i-am-listening-to-fm-while-loading-different-url-on-my-browser-and-also-editing-some-xml-and-html"); + t.equal(toKebabCase(), undefined, 'toKebabCase() return undefined'); + t.throws(() => toKebabCase([]), 'Expected'); + t.throws(() => toKebabCase({}), 'Expected'); + t.throws(() => toKebabCase(123), 'Expected'); + + let start = new Date().getTime(); + toKebabCase('IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML') + let end = new Date().getTime(); + t.true((end - start) < 2000, 'toKebabCase(IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML) takes less than 2s to run'); t.end(); -}); \ No newline at end of file +}); From 93d88d396a5f20787e9aac6d872768e2cf8b8a39 Mon Sep 17 00:00:00 2001 From: King Date: Fri, 26 Jan 2018 17:09:04 -0500 Subject: [PATCH 04/33] fix testing message for toKebabCase --- test/toKebabCase/toKebabCase.test.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/toKebabCase/toKebabCase.test.js b/test/toKebabCase/toKebabCase.test.js index caa4c25ea..e2dfd8891 100644 --- a/test/toKebabCase/toKebabCase.test.js +++ b/test/toKebabCase/toKebabCase.test.js @@ -10,9 +10,9 @@ test('Testing toKebabCase', (t) => { t.equal(toKebabCase('some-mixed-string With spaces-underscores-and-hyphens'), 'some-mixed-string-with-spaces-underscores-and-hyphens', "toKebabCase('some-mixed-string With spaces-underscores-and-hyphens') returns some-mixed-string-with-spaces-underscores-and-hyphens"); t.equal(toKebabCase('IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML'), 'i-am-listening-to-fm-while-loading-different-url-on-my-browser-and-also-editing-some-xml-and-html', "toKebabCase('IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML') returns i-am-listening-to-fm-while-loading-different-url-on-my-browser-and-also-editing-some-xml-and-html"); t.equal(toKebabCase(), undefined, 'toKebabCase() return undefined'); - t.throws(() => toKebabCase([]), 'Expected'); - t.throws(() => toKebabCase({}), 'Expected'); - t.throws(() => toKebabCase(123), 'Expected'); + t.throws(() => toKebabCase([]), 'toKebabCase([]) throws an error'); + t.throws(() => toKebabCase({}), 'toKebabCase({}) throws an error'); + t.throws(() => toKebabCase(123), 'toKebabCase(123) throws an error'); let start = new Date().getTime(); toKebabCase('IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML') From 88452262163b8a8294d25bc0b90e4a68f7754b43 Mon Sep 17 00:00:00 2001 From: King Date: Fri, 26 Jan 2018 17:16:42 -0500 Subject: [PATCH 05/33] update toSnakeCase.test.js with omit, type, time, return test --- test/toSnakeCase/toSnakeCase.test.js | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/test/toSnakeCase/toSnakeCase.test.js b/test/toSnakeCase/toSnakeCase.test.js index 14bed623d..72190fda2 100644 --- a/test/toSnakeCase/toSnakeCase.test.js +++ b/test/toSnakeCase/toSnakeCase.test.js @@ -5,14 +5,18 @@ test('Testing toSnakeCase', (t) => { //For more information on all the methods supported by tape //Please go to https://github.com/substack/tape t.true(typeof toSnakeCase === 'function', 'toSnakeCase is a Function'); - t.equal(toSnakeCase('camelCase'), 'camel_case', "string converts to snake case"); - t.equal(toSnakeCase('some text'), 'some_text', "string converts to snake case"); - t.equal(toSnakeCase('some-mixed_string With spaces_underscores-and-hyphens'), 'some_mixed_string_with_spaces_underscores_and_hyphens', "string converts to snake case"); - t.equal(toSnakeCase('IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML'), 'i_am_listening_to_fm_while_loading_different_url_on_my_browser_and_also_editing_some_xml_and_html', "string converts to snake case"); + t.equal(toSnakeCase('camelCase'), 'camel_case', "toSnakeCase('camelCase') returns camel_case"); + t.equal(toSnakeCase('some text'), 'some_text', "toSnakeCase('some text') returns some_text"); + t.equal(toSnakeCase('some-mixed_string With spaces_underscores-and-hyphens'), 'some_mixed_string_with_spaces_underscores_and_hyphens', "toSnakeCase('some-mixed_string With spaces_underscores-and-hyphens') returns some_mixed_string_with_spaces_underscores_and_hyphens"); + t.equal(toSnakeCase('IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML'), 'i_am_listening_to_fm_while_loading_different_url_on_my_browser_and_also_editing_some_xml_and_html', "toSnakeCase('IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML') returns i_am_listening_to_fm_while_loading_different_url_on_my_browser_and_also_editing_some_xml_and_html"); + t.equal(toSnakeCase(), undefined, 'toSnakeCase() returns undefined'); + t.throws(() => toSnakeCase([]), 'toSnakeCase([]) throws an error'); + t.throws(() => toSnakeCase({}), 'toSnakeCase({}) throws an error'); + t.throws(() => toSnakeCase(123), 'toSnakeCase(123) throws an error'); - //t.deepEqual(toSnakeCase(args..), 'Expected'); - //t.equal(toSnakeCase(args..), 'Expected'); - //t.false(toSnakeCase(args..), 'Expected'); - //t.throws(toSnakeCase(args..), 'Expected'); + let start = new Date().getTime(); + toSnakeCase('IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML'); + let end = new Date().getTime(); + t.true((end - start) < 2000, 'toSnakeCase(IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML) takes less than 2s to run'); t.end(); -}); \ No newline at end of file +}); From 22522be3e072568f466a60235798a6af607f877d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Feje=C5=A1?= Date: Sat, 27 Jan 2018 14:42:55 +0100 Subject: [PATCH 06/33] Add browser specific docs for tests --- CONTRIBUTING.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index fc5760ff8..7721a3434 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -45,6 +45,11 @@ Here's what you can do to help: - Be sure to run `npm run test`. It is going to run all tests for all snippets. - Make a new pull request **only if all the tests are passing**. +#### Browser specific tests +- If your snippet belongs to `browser` category then you will need to modify the tests to make them work. +- By default, `NodeJS` isn't browser environment. That said we have to use external package to help us simulate the browser for our tests. +- We use [jsdom](https://www.npmjs.com/package/jsdom) for our browser specific tests. You can find their [documentation](https://github.com/jsdom/jsdom) on GitHub as well. + ### Additional guidelines and conventions regarding snippets From edf2a73ff6c92e1ede84e58e9f4ffe36c538786a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Feje=C5=A1?= Date: Sat, 27 Jan 2018 15:02:51 +0100 Subject: [PATCH 07/33] fix spacing --- CONTRIBUTING.md | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 7721a3434..27e1a819e 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -47,11 +47,9 @@ Here's what you can do to help: #### Browser specific tests - If your snippet belongs to `browser` category then you will need to modify the tests to make them work. -- By default, `NodeJS` isn't browser environment. That said we have to use external package to help us simulate the browser for our tests. +- By default, `Node.js` isn't browser environment. That said we have to use external package to help us simulate the browser for our tests. - We use [jsdom](https://www.npmjs.com/package/jsdom) for our browser specific tests. You can find their [documentation](https://github.com/jsdom/jsdom) on GitHub as well. - - ### Additional guidelines and conventions regarding snippets - When describing snippets, refer to methods, using their full name. For example, use `Array.reduce()`, instead of `reduce()`. From 7f885abed645fcd684eabf74ff6dcd27b99cc26d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Stefan=20Feje=C5=A1?= Date: Sat, 27 Jan 2018 15:04:34 +0100 Subject: [PATCH 08/33] fix typos --- CONTRIBUTING.md | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 27e1a819e..026cf9b05 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -46,8 +46,8 @@ Here's what you can do to help: - Make a new pull request **only if all the tests are passing**. #### Browser specific tests -- If your snippet belongs to `browser` category then you will need to modify the tests to make them work. -- By default, `Node.js` isn't browser environment. That said we have to use external package to help us simulate the browser for our tests. +- If your snippet belongs to `browser` category, then you will need to modify the tests to make them work. +- By default, `Node.js` isn't browser environment. That said we have to use an external package to help us simulate the browser for our tests. - We use [jsdom](https://www.npmjs.com/package/jsdom) for our browser specific tests. You can find their [documentation](https://github.com/jsdom/jsdom) on GitHub as well. ### Additional guidelines and conventions regarding snippets From f269e7b3117180008ad9c5fdf0e228619b29b325 Mon Sep 17 00:00:00 2001 From: King Date: Sat, 27 Jan 2018 09:06:25 -0500 Subject: [PATCH 09/33] update UniqueElements.test.js with omit, type, throws, timed, and usage test --- test/uniqueElements/uniqueElements.test.js | 26 +++++++++++++++++----- 1 file changed, 20 insertions(+), 6 deletions(-) diff --git a/test/uniqueElements/uniqueElements.test.js b/test/uniqueElements/uniqueElements.test.js index 38d55aea5..7e55dfd7e 100644 --- a/test/uniqueElements/uniqueElements.test.js +++ b/test/uniqueElements/uniqueElements.test.js @@ -5,10 +5,24 @@ test('Testing uniqueElements', (t) => { //For more information on all the methods supported by tape //Please go to https://github.com/substack/tape t.true(typeof uniqueElements === 'function', 'uniqueElements is a Function'); - t.deepEqual(uniqueElements([1, 2, 2, 3, 4, 4, 5]), [1,2,3,4,5], "Returns all unique values of an array"); - //t.deepEqual(uniqueElements(args..), 'Expected'); - //t.equal(uniqueElements(args..), 'Expected'); - //t.false(uniqueElements(args..), 'Expected'); - //t.throws(uniqueElements(args..), 'Expected'); + t.deepEqual(uniqueElements([1, 2, 2, 3, 4, 4, 5]), [1,2,3,4,5], "uniqueElements([1, 2, 2, 3, 4, 4, 5]) returns [1,2,3,4,5]"); + t.deepEqual(uniqueElements([1, 23, 53]), [1, 23, 53], "uniqueElements([1, 23, 53]) returns [1, 23, 53]"); + t.deepEqual(uniqueElements([true, 0, 1, false, false, undefined, null, '']), [true, 0, 1, false, undefined, null, ''], "uniqueElements([true, 0, 1, false, false, undefined, null, '']) returns [true, 0, 1, false, false, undefined, null, '']"); + t.deepEqual(uniqueElements(), [], "uniqueElements() returns []"); + t.deepEqual(uniqueElements(null), [], "uniqueElements(null) returns []"); + t.deepEqual(uniqueElements(undefined), [], "uniqueElements(undefined) returns []"); + t.deepEqual(uniqueElements('strt'), ['s', 't', 'r'], "uniqueElements('strt') returns ['s', 't', 'r']"); + t.throws(() => uniqueElements(1, 1, 2543, 534, 5), 'Expected'); + t.throws(() => uniqueElements({}), 'Expected'); + t.throws(() => uniqueElements(true), 'Expected'); + t.throws(() => uniqueElements(false), 'Expected'); + + let start = new Date().getTime(); + uniqueElements([true, 0, 1, false, false, undefined, null, '']) + let end = new Date().getTime(); + t.true((end - start) < 2000, 'uniqueElements([true, 0, 1, false, false, undefined, null]) takes less than 2s to run'); + t.end(); -}); \ No newline at end of file +}); + +uniqueElements([1, 2, 2, '1', 4, 4, 4, 5, true]); // [1,2,3,4,5] From 7b505fde57f45f88d8d86eef152e8064e4b1901e Mon Sep 17 00:00:00 2001 From: King Date: Sat, 27 Jan 2018 09:08:11 -0500 Subject: [PATCH 10/33] fix message for test --- test/uniqueElements/uniqueElements.test.js | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/test/uniqueElements/uniqueElements.test.js b/test/uniqueElements/uniqueElements.test.js index 7e55dfd7e..137f791dc 100644 --- a/test/uniqueElements/uniqueElements.test.js +++ b/test/uniqueElements/uniqueElements.test.js @@ -12,10 +12,10 @@ test('Testing uniqueElements', (t) => { t.deepEqual(uniqueElements(null), [], "uniqueElements(null) returns []"); t.deepEqual(uniqueElements(undefined), [], "uniqueElements(undefined) returns []"); t.deepEqual(uniqueElements('strt'), ['s', 't', 'r'], "uniqueElements('strt') returns ['s', 't', 'r']"); - t.throws(() => uniqueElements(1, 1, 2543, 534, 5), 'Expected'); - t.throws(() => uniqueElements({}), 'Expected'); - t.throws(() => uniqueElements(true), 'Expected'); - t.throws(() => uniqueElements(false), 'Expected'); + t.throws(() => uniqueElements(1, 1, 2543, 534, 5), 'uniqueElements(1, 1, 2543, 534, 5) throws an error'); + t.throws(() => uniqueElements({}), 'uniqueElements({}) throws an error'); + t.throws(() => uniqueElements(true), 'uniqueElements(true) throws an error'); + t.throws(() => uniqueElements(false), 'uniqueElements(false) throws an error'); let start = new Date().getTime(); uniqueElements([true, 0, 1, false, false, undefined, null, '']) From 323a5631647fd2ac7c6698c5b34bac98090918a1 Mon Sep 17 00:00:00 2001 From: King Date: Sat, 27 Jan 2018 09:20:03 -0500 Subject: [PATCH 11/33] update union.test.js with timed test, omit, type, throws, and expected output --- test/union/union.test.js | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/test/union/union.test.js b/test/union/union.test.js index 73427934a..fd6157918 100644 --- a/test/union/union.test.js +++ b/test/union/union.test.js @@ -5,10 +5,20 @@ test('Testing union', (t) => { //For more information on all the methods supported by tape //Please go to https://github.com/substack/tape t.true(typeof union === 'function', 'union is a Function'); - t.deepEqual(union([1, 2, 3], [4, 3, 2]), [1, 2, 3, 4], "Returns every element that exists in any of the two arrays once"); - //t.deepEqual(union(args..), 'Expected'); - //t.equal(union(args..), 'Expected'); - //t.false(union(args..), 'Expected'); - //t.throws(union(args..), 'Expected'); + t.deepEqual(union([1, 2, 3], [4, 3, 2]), [1, 2, 3, 4], "union([1, 2, 3], [4, 3, 2]) returns [1, 2, 3, 4]"); + t.deepEqual(union('str', 'asd'), [ 's', 't', 'r', 'a', 'd' ], "union('str', 'asd') returns [ 's', 't', 'r', 'a', 'd' ]"); + t.deepEqual(union([[], {}], [1, 2, 3]), [[], {}, 1, 2, 3], "union([[], {}], [1, 2, 3]) returns [[], {}, 1, 2, 3]"); + t.deepEqual(union([], []), [], "union([], []) returns []"); + t.throws(() => union(), 'union() throws an error'); + t.throws(() => union(true, 'str'), 'union(true, str) throws an error'); + t.throws(() => union('false', true), 'union(false, true) throws an error'); + t.throws(() => union(123, {}), 'union(123, {}) throws an error'); + t.throws(() => union([], {}), 'union([], {}) throws an error'); + t.throws(() => union(undefined, null), 'union(undefined, null) throws an error'); + + let start = new Date().getTime(); + union([1, 2, 3], [4, 3, 2]); + let end = new Date().getTime(); + t.true((end - start) < 2000, 'union([1, 2, 3], [4, 3, 2]) takes less than 2s to run'); t.end(); -}); \ No newline at end of file +}); From a4da28129080c2132a61f44df6088fc012dacea9 Mon Sep 17 00:00:00 2001 From: King Date: Sat, 27 Jan 2018 09:38:36 -0500 Subject: [PATCH 12/33] update toSafeInter.test.js type test, omit test, expected test, time test --- test/toSafeInteger/toSafeInteger.test.js | 24 +++++++++++++++--------- 1 file changed, 15 insertions(+), 9 deletions(-) diff --git a/test/toSafeInteger/toSafeInteger.test.js b/test/toSafeInteger/toSafeInteger.test.js index 508da718a..885f6e324 100644 --- a/test/toSafeInteger/toSafeInteger.test.js +++ b/test/toSafeInteger/toSafeInteger.test.js @@ -5,14 +5,20 @@ test('Testing toSafeInteger', (t) => { //For more information on all the methods supported by tape //Please go to https://github.com/substack/tape t.true(typeof toSafeInteger === 'function', 'toSafeInteger is a Function'); + t.true(Number(toSafeInteger(3.2)), 'Number(toSafeInteger(3.2)) is a number'); t.equal(toSafeInteger(3.2), 3, "Converts a value to a safe integer"); - t.equal(toSafeInteger('4.2'), 4, "Converts a value to a safe integer"); - t.equal(toSafeInteger(4.6), 5, "Converts a value to a safe integer"); - t.equal(toSafeInteger(1.5), 2, "Converts a value to a safe integer"); - t.equal(toSafeInteger(Infinity), 9007199254740991, "Converts a value to a safe integer"); - //t.deepEqual(toSafeInteger(args..), 'Expected'); - //t.equal(toSafeInteger(args..), 'Expected'); - //t.false(toSafeInteger(args..), 'Expected'); - //t.throws(toSafeInteger(args..), 'Expected'); + t.equal(toSafeInteger('4.2'), 4, "toSafeInteger('4.2') returns 4"); + t.equal(toSafeInteger(4.6), 5, "toSafeInteger(4.6) returns 5"); + t.equal(toSafeInteger([]), 0, "toSafeInteger([]) returns 0"); + t.true(isNaN(toSafeInteger([1.5, 3124])), "isNaN(toSafeInteger([1.5, 3124])) is true"); + t.true(isNaN(toSafeInteger('string')), "isNaN(toSafeInteger('string')) is true"); + t.true(isNaN(toSafeInteger({})), "isNaN(toSafeInteger({})) is true"); + t.true(isNaN(toSafeInteger()), "isNaN(toSafeInteger()) is true"); + t.equal(toSafeInteger(Infinity), 9007199254740991, "toSafeInteger(Infinity) returns 9007199254740991"); + + let start = new Date().getTime(); + toSafeInteger(3.2); + let end = new Date().getTime(); + t.true((end - start) < 2000, 'toSafeInteger(3.2) takes less than 2s to run'); t.end(); -}); \ No newline at end of file +}); From 75a2b9e9ff0faccdb4b69f567db4b53a372a798d Mon Sep 17 00:00:00 2001 From: simov Date: Sat, 27 Jan 2018 18:17:44 +0200 Subject: [PATCH 13/33] Add pipeAsyncFunctions --- snippets/pipeAsyncFunctions.md | 22 +++++++++++++++++ tag_database | 1 + test/pipeAsyncFunctions/pipeAsyncFunctions.js | 2 ++ .../pipeAsyncFunctions.test.js | 24 +++++++++++++++++++ 4 files changed, 49 insertions(+) create mode 100644 snippets/pipeAsyncFunctions.md create mode 100644 test/pipeAsyncFunctions/pipeAsyncFunctions.js create mode 100644 test/pipeAsyncFunctions/pipeAsyncFunctions.test.js diff --git a/snippets/pipeAsyncFunctions.md b/snippets/pipeAsyncFunctions.md new file mode 100644 index 000000000..95423ce28 --- /dev/null +++ b/snippets/pipeAsyncFunctions.md @@ -0,0 +1,22 @@ +### pipeAsyncFunctions + +Performs left-to-right function composition. + +Use `Array.reduce()` with the spread operator (`...`) to perform left-to-right function composition using `Promise.then()`. The functions can return a combination of: simple values, `Promise`'s, or they can be defined as `async` ones returning through `await`. +All functions must be unary. + +```js +const pipeAsyncFunctions = (...fns) => arg => fns.reduce((p, f) => p.then(f), Promise.resolve(arg)); +``` + +```js +const sum = pipeAsyncFunctions( + x => x + 1, + x => new Promise(resolve => setTimeout(() => resolve(x + 2), 1000)), + x => x + 3, + async x => (await x) + 4 +); +(async () => { + console.log(await sum(5)); // 15 (after one second) +})(); +``` diff --git a/tag_database b/tag_database index 9a84845df..f5baa13d8 100644 --- a/tag_database +++ b/tag_database @@ -169,6 +169,7 @@ partition:array,object,function percentile:math pick:object,array pickBy:object,array,function +pipeAsyncFunctions:adapter,function,async pipeFunctions:adapter,function pluralize:string powerset:math diff --git a/test/pipeAsyncFunctions/pipeAsyncFunctions.js b/test/pipeAsyncFunctions/pipeAsyncFunctions.js new file mode 100644 index 000000000..09091affc --- /dev/null +++ b/test/pipeAsyncFunctions/pipeAsyncFunctions.js @@ -0,0 +1,2 @@ +const pipeAsyncFunctions = (...fns) => arg => fns.reduce((p, f) => p.then(f), Promise.resolve(arg)); +module.exports = pipeAsyncFunctions \ No newline at end of file diff --git a/test/pipeAsyncFunctions/pipeAsyncFunctions.test.js b/test/pipeAsyncFunctions/pipeAsyncFunctions.test.js new file mode 100644 index 000000000..7a4ae346e --- /dev/null +++ b/test/pipeAsyncFunctions/pipeAsyncFunctions.test.js @@ -0,0 +1,24 @@ +const test = require('tape'); +const pipeAsyncFunctions = require('./pipeAsyncFunctions.js'); + +test('Testing pipeAsyncFunctions', async (t) => { + //For more information on all the methods supported by tape + //Please go to https://github.com/substack/tape + t.true(typeof pipeAsyncFunctions === 'function', 'pipeAsyncFunctions is a Function'); + //t.deepEqual(pipeAsyncFunctions(args..), 'Expected'); + //t.equal(pipeAsyncFunctions(args..), 'Expected'); + //t.false(pipeAsyncFunctions(args..), 'Expected'); + //t.throws(pipeAsyncFunctions(args..), 'Expected'); + t.equal( + await pipeAsyncFunctions( + (x) => x + 1, + (x) => new Promise((resolve) => setTimeout(() => resolve(x + 2), 0)), + (x) => x + 3, + async (x) => await x + 4, + ) + (5), + 15, + 'pipeAsyncFunctions result should be 15' + ); + t.end(); +}); \ No newline at end of file From 66e6a7c0bb3271da5842c78bb57e4c4bf2fa8f70 Mon Sep 17 00:00:00 2001 From: Rob-Rychs Date: Sat, 27 Jan 2018 09:56:18 -0800 Subject: [PATCH 14/33] fix typo, removed pr template header --- snippets/bindAll.md | 2 -- 1 file changed, 2 deletions(-) diff --git a/snippets/bindAll.md b/snippets/bindAll.md index e5e618ae0..26093013c 100644 --- a/snippets/bindAll.md +++ b/snippets/bindAll.md @@ -1,7 +1,5 @@ ### bindAll -Explain briefly what the snippet does. - Use `Array.forEach()` to return a `function` that uses `Function.apply()` to apply the given context (`obj`) to `fn` for each function specified. ```js From b40ef07f5e5c6a88c0a0c1ba686f8f4c3a55d1af Mon Sep 17 00:00:00 2001 From: 30secondsofcode <30secondsofcode@gmail.com> Date: Sat, 27 Jan 2018 19:15:18 +0000 Subject: [PATCH 15/33] Travis build: 1458 --- README.md | 2 -- docs/index.html | 2 +- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/README.md b/README.md index 92f8a301f..4a577f558 100644 --- a/README.md +++ b/README.md @@ -5095,8 +5095,6 @@ UUIDGeneratorNode(); // '79c7c136-60ee-40a2-beb2-856f1feabefc' ### bindAll -Explain briefly what the snippet does. - Use `Array.forEach()` to return a `function` that uses `Function.apply()` to apply the given context (`obj`) to `fn` for each function specified. ```js diff --git a/docs/index.html b/docs/index.html index 6df6bfcae..75bfadaa9 100644 --- a/docs/index.html +++ b/docs/index.html @@ -1137,7 +1137,7 @@ console.log< (c ^ (crypto.randomBytes(1)[0] & (15 >> (c / 4)))).toString(16) );
UUIDGeneratorNode(); // '79c7c136-60ee-40a2-beb2-856f1feabefc'
-

Object

bindAll

Explain briefly what the snippet does.

Use Array.forEach() to return a function that uses Function.apply() to apply the given context (obj) to fn for each function specified.

const bindAll = (obj, ...fns) =>
+

Object

bindAll

Use Array.forEach() to return a function that uses Function.apply() to apply the given context (obj) to fn for each function specified.

const bindAll = (obj, ...fns) =>
   fns.forEach(
     fn =>
       (obj[fn] = function() {

From c9771e94f083e1b0011bbe76582b8ed6da02b5d8 Mon Sep 17 00:00:00 2001
From: 30secondsofcode <30secondsofcode@gmail.com>
Date: Sat, 27 Jan 2018 20:13:42 +0000
Subject: [PATCH 16/33] Travis build: 1460 [cron]

---
 test/testlog | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/test/testlog b/test/testlog
index eebfee7dc..a38f215cc 100644
--- a/test/testlog
+++ b/test/testlog
@@ -1,4 +1,4 @@
-Test log for: Fri Jan 26 2018 20:13:29 GMT+0000 (UTC)
+Test log for: Sat Jan 27 2018 20:13:38 GMT+0000 (UTC)
 
 > 30-seconds-of-code@0.0.1 test /home/travis/build/Chalarangelo/30-seconds-of-code
 > tape test/**/*.test.js | tap-spec

From 50f64e374c78e31d27b8557cd224e2b3c4f70049 Mon Sep 17 00:00:00 2001
From: Angelos Chalaris 
Date: Sun, 28 Jan 2018 14:28:57 +0200
Subject: [PATCH 17/33] Description updated and snippet tested

---
 snippets/pipeAsyncFunctions.md         |    5 +-
 tag_database                           |    2 +-
 test/dropElements/dropElements.js      |    5 -
 test/dropElements/dropElements.test.js |   14 -
 test/dropWhile/dropWhile.test.js       |    2 +-
 test/testlog                           | 1529 +++++++++++++++++++++++-
 6 files changed, 1531 insertions(+), 26 deletions(-)
 delete mode 100644 test/dropElements/dropElements.js
 delete mode 100644 test/dropElements/dropElements.test.js

diff --git a/snippets/pipeAsyncFunctions.md b/snippets/pipeAsyncFunctions.md
index 95423ce28..574591cb0 100644
--- a/snippets/pipeAsyncFunctions.md
+++ b/snippets/pipeAsyncFunctions.md
@@ -1,8 +1,9 @@
 ### pipeAsyncFunctions
 
-Performs left-to-right function composition.
+Performs left-to-right function composition for asynchronous functions.
 
-Use `Array.reduce()` with the spread operator (`...`) to perform left-to-right function composition using `Promise.then()`. The functions can return a combination of: simple values, `Promise`'s, or they can be defined as `async` ones returning through `await`.
+Use `Array.reduce()` with the spread operator (`...`) to perform left-to-right function composition using `Promise.then()`.
+The functions can return a combination of: simple values, `Promise`'s, or they can be defined as `async` ones returning through `await`.
 All functions must be unary.
 
 ```js
diff --git a/tag_database b/tag_database
index f5baa13d8..4e52b9a38 100644
--- a/tag_database
+++ b/tag_database
@@ -169,7 +169,7 @@ partition:array,object,function
 percentile:math
 pick:object,array
 pickBy:object,array,function
-pipeAsyncFunctions:adapter,function,async
+pipeAsyncFunctions:adapter,function,promise
 pipeFunctions:adapter,function
 pluralize:string
 powerset:math
diff --git a/test/dropElements/dropElements.js b/test/dropElements/dropElements.js
deleted file mode 100644
index 655598419..000000000
--- a/test/dropElements/dropElements.js
+++ /dev/null
@@ -1,5 +0,0 @@
-const dropWhile = (arr, func) => {
-while (arr.length > 0 && !func(arr[0])) arr = arr.slice(1);
-return arr;
-};
-module.exports = dropWhile
\ No newline at end of file
diff --git a/test/dropElements/dropElements.test.js b/test/dropElements/dropElements.test.js
deleted file mode 100644
index bfd4e4b0b..000000000
--- a/test/dropElements/dropElements.test.js
+++ /dev/null
@@ -1,14 +0,0 @@
-const test = require('tape');
-const dropWhile = require('./dropWhile.js');
-
-test('Testing dropWhile', (t) => {
-  //For more information on all the methods supported by tape
-  //Please go to https://github.com/substack/tape
-  t.true(typeof dropWhile === 'function', 'dropWhile is a Function');
-  t.deepEqual(dropWhile([1, 2, 3, 4], n => n >= 3), [3,4], "Removes elements in an array until the passed function returns true");
-  //t.deepEqual(dropWhile(args..), 'Expected');
-  //t.equal(dropWhile(args..), 'Expected');
-  //t.false(dropWhile(args..), 'Expected');
-  //t.throws(dropWhile(args..), 'Expected');
-  t.end();
-});
\ No newline at end of file
diff --git a/test/dropWhile/dropWhile.test.js b/test/dropWhile/dropWhile.test.js
index 6e0ecf54e..198d8202a 100644
--- a/test/dropWhile/dropWhile.test.js
+++ b/test/dropWhile/dropWhile.test.js
@@ -10,4 +10,4 @@ test('Testing dropWhile', (t) => {
   //t.false(dropWhile(args..), 'Expected');
   //t.throws(dropWhile(args..), 'Expected');
   t.end();
-});
\ No newline at end of file
+});
diff --git a/test/testlog b/test/testlog
index eebfee7dc..56314eed1 100644
--- a/test/testlog
+++ b/test/testlog
@@ -1,8 +1,1531 @@
-Test log for: Fri Jan 26 2018 20:13:29 GMT+0000 (UTC)
+Test log for: Sun Jan 28 2018 14:28:04 GMT+0200 (GTB Standard Time)
 
-> 30-seconds-of-code@0.0.1 test /home/travis/build/Chalarangelo/30-seconds-of-code
+> 30-seconds-of-code@0.0.1 test G:\My Files\git Repositories\30-seconds-of-code
 > tape test/**/*.test.js | tap-spec
 
 
+  Testing anagrams
+
+    √ anagrams is a Function
+    √ Generates all anagrams of a string
+
+  Testing arrayToHtmlList
+
+    √ arrayToHtmlList is a Function
+    √ Generates and fills a list element
+
+  Testing ary
+
+    √ ary is a Function
+
+  Testing atob
+
+    √ atob is a Function
+    √ atob("Zm9vYmFy") equals "foobar"
+    √ atob("Z") returns ""
+
+  Testing average
+
+    √ average is a Function
+    √ average(true) returns 0
+    √ average(false) returns 1
+    √ average(9, 1) returns 5
+    √ average(153, 44, 55, 64, 71, 1122, 322774, 2232, 23423, 234, 3631) returns 32163.909090909092 
+    √ average(1, 2, 3) returns 2
+    √ average(null) returns 0
+    √ average(1, 2, 3) returns NaN
+    √ average(String) returns NaN
+    √ average({ a: 123}) returns NaN
+    √ average([undefined, 0, string]) returns NaN
+    √ head([1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 1122, 32124, 23232]) takes less than 2s to run
+
+  Testing averageBy
+
+    √ averageBy is a Function
+    √ Produces the right result with a function
+    √ Produces the right result with a property name
+
+  Testing binarySearch
+
+    √ binarySearch is a Function
+
+  Testing bind
+
+    √ bind is a Function
+
+  Testing bindAll
+
+    √ bindAll is a Function
+
+  Testing bindKey
+
+    √ bindKey is a Function
+
+  Testing bottomVisible
+
+    √ bottomVisible is a Function
+
+  Testing btoa
+
+    √ btoa is a Function
+    √ btoa("foobar") equals "Zm9vYmFy"
+
+  Testing byteSize
+
+    √ byteSize is a Function
+
+  Testing call
+
+    √ call is a Function
+
+  Testing capitalize
+
+    √ capitalize is a Function
+    √ Capitalizes the first letter of a string
+    √ Capitalizes the first letter of a string
+
+  Testing capitalizeEveryWord
+
+    √ capitalizeEveryWord is a Function
+    √ Capitalizes the first letter of every word in a string
+
+  Testing castArray
+
+    √ castArray is a Function
+    √ Works for single values
+    √ Works for arrays with one value
+    √ Works for arrays with multiple value
+    √ Works for strings
+    √ Works for objects
+
+  Testing chainAsync
+
+    √ chainAsync is a Function
+
+  Testing chunk
+
+    √ chunk is a Function
+    √ chunk([1, 2, 3, 4, 5], 2) returns [[1,2],[3,4],[5]] 
+    √ chunk([]) returns []
+    √ chunk(123) returns []
+    √ chunk({ a: 123}) returns []
+    √ chunk(string, 2) returns [ st, ri, ng ]
+    √ chunk() throws an error
+    √ chunk(undefined) throws an error
+    √ chunk(null) throws an error
+    √ chunk(This is a string, 2) takes less than 2s to run
+
+  Testing clampNumber
+
+    √ clampNumber is a Function
+    √ Clamps num within the inclusive range specified by the boundary values a and b
+
+  Testing cleanObj
+
+    √ cleanObj is a Function
+    √ Removes any properties except the ones specified from a JSON object
+
+  Testing cloneRegExp
+
+    √ cloneRegExp is a Function
+    √ Clones regular expressions properly
+
+  Testing coalesce
+
+    √ coalesce is a Function
+    √ Returns the first non-null/undefined argument
+
+  Testing coalesceFactory
+
+    √ coalesceFactory is a Function
+    √ Returns a customized coalesce function
+
+  Testing collatz
+
+    √ collatz is a Function
+
+  Testing collectInto
+
+    √ collectInto is a Function
+
+  Testing colorize
+
+    √ colorize is a Function
+
+  Testing compact
+
+    √ compact is a Function
+    √ Removes falsey values from an array
+
+  Testing compose
+
+    √ compose is a Function
+    √ Performs right-to-left function composition
+
+  Testing composeRight
+
+    √ composeRight is a Function
+    √ Performs left-to-right function composition
+
+  Testing copyToClipboard
+
+    √ copyToClipboard is a Function
+
+  Testing countBy
+
+    √ countBy is a Function
+
+  Testing countOccurrences
+
+    √ countOccurrences is a Function
+    √ Counts the occurrences of a value in an array
+
+  Testing countVowels
+
+    √ countVowels is a Function
+
+  Testing createElement
+
+    √ createElement is a Function
+
+  Testing createEventHub
+
+    √ createEventHub is a Function
+
+  Testing currentURL
+
+    √ currentURL is a Function
+
+  Testing curry
+
+    √ curry is a Function
+    √ curries a Math.pow
+    √ curries a Math.min
+
+  Testing decapitalize
+
+    √ decapitalize is a Function
+
+  Testing deepClone
+
+    √ deepClone is a Function
+    √ Shallow cloning works
+    √ Deep cloning works
+
+  Testing deepFlatten
+
+    √ deepFlatten is a Function
+    √ Deep flattens an array
+
+  Testing defaults
+
+    √ defaults is a Function
+
+  Testing defer
+
+    √ defer is a Function
+
+  Testing delay
+
+    √ delay is a Function
+
+  Testing detectDeviceType
+
+    √ detectDeviceType is a Function
+
+  Testing difference
+
+    √ difference is a Function
+    √ Returns the difference between two arrays
+
+  Testing differenceBy
+
+    √ differenceBy is a Function
+
+  Testing differenceWith
+
+    √ differenceWith is a Function
+    √ Filters out all values from an array
+
+  Testing digitize
+
+    √ digitize is a Function
+    √ Converts a number to an array of digits
+
+  Testing distance
+
+    √ distance is a Function
+
+  Testing drop
+
+    √ drop is a Function
+
+  Testing dropRight
+
+    √ dropRight is a Function
+    √ Returns a new array with n elements removed from the right
+    √ Returns a new array with n elements removed from the right
+    √ Returns a new array with n elements removed from the right
+
+  Testing dropRightWhile
+
+    √ dropRightWhile is a Function
+
+  Testing dropWhile
+
+    √ dropWhile is a Function
+
+  Testing elementIsVisibleInViewport
+
+    √ elementIsVisibleInViewport is a Function
+
+  Testing elo
+
+    √ elo is a Function
+    √ Standard 1v1s
+    √ should be equivalent
+    √ 4 player FFA, all same rank
+
+  Testing equals
+
+    √ equals is a Function
+    √ { a: [2, {e: 3}], b: [4], c: 'foo' } is equal to { a: [2, {e: 3}], b: [4], c: 'foo' }
+    √ [1,2,3] is equal to [1,2,3]
+    √ { a: [2, 3], b: [4] } is not equal to { a: [2, 3], b: [6] }
+    √ [1,2,3] is not equal to [1,2,4]
+    √ [1, 2, 3] should be equal to { 0: 1, 1: 2, 2: 3 }) - type is different, but their enumerable properties match.
+
+  Testing escapeHTML
+
+    √ escapeHTML is a Function
+    √ Escapes a string for use in HTML
+
+  Testing escapeRegExp
+
+    √ escapeRegExp is a Function
+    √ Escapes a string to use in a regular expression
+
+  Testing everyNth
+
+    √ everyNth is a Function
+    √ Returns every nth element in an array
+
+  Testing extendHex
+
+    √ extendHex is a Function
+    √ Extends a 3-digit color code to a 6-digit color code
+    √ Extends a 3-digit color code to a 6-digit color code
+
+  Testing factorial
+
+    √ factorial is a Function
+    √ Calculates the factorial of 720
+    √ Calculates the factorial of 0
+    √ Calculates the factorial of 1
+    √ Calculates the factorial of 4
+    √ Calculates the factorial of 10
+
+  Testing factors
+
+    √ factors is a Function
+
+  Testing fibonacci
+
+    √ fibonacci is a Function
+    √ Generates an array, containing the Fibonacci sequence
+
+  Testing fibonacciCountUntilNum
+
+    √ fibonacciCountUntilNum is a Function
+
+  Testing fibonacciUntilNum
+
+    √ fibonacciUntilNum is a Function
+
+  Testing filterNonUnique
+
+    √ filterNonUnique is a Function
+    √ Filters out the non-unique values in an array
+
+  Testing findKey
+
+    √ findKey is a Function
+
+  Testing findLast
+
+    √ findLast is a Function
+
+  Testing findLastIndex
+
+    √ findLastIndex is a Function
+
+  Testing findLastKey
+
+    √ findLastKey is a Function
+
+  Testing flatten
+
+    √ flatten is a Function
+    √ Flattens an array
+    √ Flattens an array
+
+  Testing flip
+
+    √ flip is a Function
+
+  Testing forEachRight
+
+    √ forEachRight is a Function
+
+  Testing formatDuration
+
+    √ formatDuration is a Function
+    √ Returns the human readable format of the given number of milliseconds
+    √ Returns the human readable format of the given number of milliseconds
+
+  Testing forOwn
+
+    √ forOwn is a Function
+
+  Testing forOwnRight
+
+    √ forOwnRight is a Function
+
+  Testing fromCamelCase
+
+    √ fromCamelCase is a Function
+    √ Converts a string from camelcase
+    √ Converts a string from camelcase
+    √ Converts a string from camelcase
+
+  Testing functionName
+
+    √ functionName is a Function
+
+  Testing functions
+
+    √ functions is a Function
+
+  Testing gcd
+
+    √ gcd is a Function
+    √ Calculates the greatest common divisor between two or more numbers/arrays
+    √ Calculates the greatest common divisor between two or more numbers/arrays
+
+  Testing geometricProgression
+
+    √ geometricProgression is a Function
+    √ Initializes an array containing the numbers in the specified range
+    √ Initializes an array containing the numbers in the specified range
+    √ Initializes an array containing the numbers in the specified range
+
+  Testing get
+
+    √ get is a Function
+    √ Retrieve a property indicated by the selector from an object.
+
+  Testing getDaysDiffBetweenDates
+
+    √ getDaysDiffBetweenDates is a Function
+    √ Returns the difference in days between two dates
+
+  Testing getScrollPosition
+
+    √ getScrollPosition is a Function
+
+  Testing getStyle
+
+    √ getStyle is a Function
+
+  Testing getType
+
+    √ getType is a Function
+    √ Returns the native type of a value
+
+  Testing getURLParameters
+
+    √ getURLParameters is a Function
+    √ Returns an object containing the parameters of the current URL
+
+  Testing groupBy
+
+    √ groupBy is a Function
+    √ Groups the elements of an array based on the given function
+    √ Groups the elements of an array based on the given function
+
+  Testing hammingDistance
+
+    √ hammingDistance is a Function
+    √ retuns hamming disance between 2 values
+
+  Testing hasClass
+
+    √ hasClass is a Function
+    √ element has the specified class
+
+  Testing hasFlags
+
+    √ hasFlags is a Function
+
+  Testing hashBrowser
+
+    √ hashBrowser is a Function
+
+  Testing hashNode
+
+    √ hashNode is a Function
+
+  Testing head
+
+    √ head is a Function
+    √ head({ a: 1234}) returns undefined
+    √ head([1, 2, 3]) returns 1
+    √ head({ 0: false}) returns false
+    √ head(String) returns S
+    √ head(null) throws an Error
+    √ head(undefined) throws an Error
+    √ head() throws an Error
+    √ head([1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 1122, 32124, 23232]) takes less than 2s to run
+
+  Testing hexToRGB
+
+    √ hexToRGB is a Function
+    √ Converts a color code to a rgb() or rgba() string
+    √ Converts a color code to a rgb() or rgba() string
+    √ Converts a color code to a rgb() or rgba() string
+
+  Testing hide
+
+    √ hide is a Function
+
+  Testing howManyTimes
+
+    √ howManyTimes is a Function
+
+  Testing httpDelete
+
+    √ httpDelete is a Function
+
+  Testing httpGet
+
+    √ httpGet is a Function
+
+  Testing httpPost
+
+    √ httpPost is a Function
+
+  Testing httpPut
+
+    √ httpPut is a Function
+
+  Testing httpsRedirect
+
+    √ httpsRedirect is a Function
+
+  Testing indexOfAll
+
+    √ indexOfAll is a Function
+    √ Returns all indices of val in an array
+    √ Returns all indices of val in an array
+
+  Testing initial
+
+    √ initial is a Function
+    √ Returns all the elements of an array except the last one
+
+  Testing initialize2DArray
+
+    √ initialize2DArray is a Function
+    √ Initializes a 2D array of given width and height and value
+
+  Testing initializeArrayWithRange
+
+    √ initializeArrayWithRange is a Function
+    √ Initializes an array containing the numbers in the specified range
+
+  Testing initializeArrayWithRangeRight
+
+    √ initializeArrayWithRangeRight is a Function
+
+  Testing initializeArrayWithValues
+
+    √ initializeArrayWithValues is a Function
+    √ Initializes and fills an array with the specified values
+
+  Testing inRange
+
+    √ inRange is a Function
+    √ The given number falls within the given range
+    √ The given number falls within the given range
+    √ The given number does not falls within the given range
+    √ The given number does not falls within the given range
+
+  Testing intersection
+
+    √ intersection is a Function
+    √ Returns a list of elements that exist in both arrays
+
+  Testing intersectionBy
+
+    √ intersectionBy is a Function
+
+  Testing intersectionWith
+
+    √ intersectionWith is a Function
+
+  Testing invertKeyValues
+
+    √ invertKeyValues is a Function
+    √ invertKeyValues({ a: 1, b: 2, c: 1 }) returns { 1: [ 'a', 'c' ], 2: [ 'b' ] }
+    √ invertKeyValues({ a: 1, b: 2, c: 1 }, value => 'group' + value) returns { group1: [ 'a', 'c' ], group2: [ 'b' ] }
+
+  Testing is
+
+    √ is is a Function
+    √ Works for arrays with data
+    √ Works for empty arrays
+    √ Works for arrays, not objects
+    √ Works for objects
+    √ Works for maps
+    √ Works for regular expressions
+    √ Works for sets
+    √ Works for weak maps
+    √ Works for weak sets
+    √ Works for strings - returns false for primitive
+    √ Works for strings - returns true when using constructor
+    √ Works for numbers - returns false for primitive
+    √ Works for numbers - returns true when using constructor
+    √ Works for booleans - returns false for primitive
+    √ Works for booleans - returns true when using constructor
+    √ Works for functions
+
+  Testing isAbsoluteURL
+
+    √ isAbsoluteURL is a Function
+    √ Given string is an absolute URL
+    √ Given string is an absolute URL
+    √ Given string is not an absolute URL
+
+  Testing isArmstrongNumber
+
+    √ isArmstrongNumber is a Function
+
+  Testing isArray
+
+    √ isArray is a Function
+    √ passed value is an array
+    √ passed value is not an array
+
+  Testing isArrayBuffer
+
+    √ isArrayBuffer is a Function
+
+  Testing isArrayLike
+
+    √ isArrayLike is a Function
+
+  Testing isBoolean
+
+    √ isBoolean is a Function
+    √ passed value is not a boolean
+    √ passed value is not a boolean
+
+  Testing isDivisible
+
+    √ isDivisible is a Function
+    √ The number 6 is divisible by 3
+
+  Testing isEmpty
+
+    √ isEmpty is a Function
+
+  Testing isEven
+
+    √ isEven is a Function
+    √ 4 is even number
+    √ undefined
+
+  Testing isFunction
+
+    √ isFunction is a Function
+    √ passed value is a function
+    √ passed value is not a function
+
+  Testing isLowerCase
+
+    √ isLowerCase is a Function
+    √ passed string is a lowercase
+    √ passed string is a lowercase
+    √ passed value is not a lowercase
+
+  Testing isMap
+
+    √ isMap is a Function
+
+  Testing isNil
+
+    √ isNil is a Function
+
+  Testing isNull
+
+    √ isNull is a Function
+    √ passed argument is a null
+    √ passed argument is a null
+
+  Testing isNumber
+
+    √ isNumber is a Function
+    √ passed argument is a number
+    √ passed argument is not a number
+
+  Testing isObject
+
+    √ isObject is a Function
+    √ isObject([1, 2, 3, 4]) is a object
+    √ isObject([]) is a object
+    √ isObject({ a:1 }) is a object
+    √ isObject(true) is not a object
+
+  Testing isObjectLike
+
+    √ isObjectLike is a Function
+
+  Testing isPlainObject
+
+    √ isPlainObject is a Function
+
+  Testing isPrime
+
+    √ isPrime is a Function
+    √ passed number is a prime
+
+  Testing isPrimitive
+
+    √ isPrimitive is a Function
+    √ isPrimitive(null) is primitive
+    √ isPrimitive(undefined) is primitive
+    √ isPrimitive(string) is primitive
+    √ isPrimitive(true) is primitive
+    √ isPrimitive(50) is primitive
+    √ isPrimitive('Hello') is primitive
+    √ isPrimitive(false) is primitive
+    √ isPrimitive(Symbol()) is primitive
+    √ isPrimitive([1, 2, 3]) is not primitive
+    √ isPrimitive({ a: 123 }) is not primitive
+    √ isPrimitive({ a: 123 }) takes less than 2s to run
+
+  Testing isPromiseLike
+
+    √ isPromiseLike is a Function
+
+  Testing isRegExp
+
+    √ isRegExp is a Function
+
+  Testing isSet
+
+    √ isSet is a Function
+
+  Testing isSorted
+
+    √ isSorted is a Function
+    √ Array is sorted in ascending order
+    √ Array is sorted in descending order
+    √ Array is not sorted, direction changed in array
+
+  Testing isString
+
+    √ isString is a Function
+    √ foo is a string
+    √ "10" is a string
+    √ Empty string is a string
+    √ 10 is not a string
+    √ true is not string
+
+  Testing isSymbol
+
+    √ isSymbol is a Function
+    √ Checks if the given argument is a symbol
+
+  Testing isTravisCI
+
+    √ isTravisCI is a Function
+
+  Testing isTypedArray
+
+    √ isTypedArray is a Function
+
+  Testing isUndefined
+
+    √ isUndefined is a Function
+
+  Testing isUpperCase
+
+    √ isUpperCase is a Function
+    √ ABC is all upper case
+    √ abc is not all upper case
+    √ A3@$ is all uppercase
+
+  Testing isValidJSON
+
+    √ isValidJSON is a Function
+    √ {"name":"Adam","age":20} is a valid JSON
+    √ {"name":"Adam",age:"20"} is not a valid JSON
+    √ null is a valid JSON
+
+  Testing isWeakMap
+
+    √ isWeakMap is a Function
+
+  Testing isWeakSet
+
+    √ isWeakSet is a Function
+
+  Testing join
+
+    √ join is a Function
+    √ Joins all elements of an array into a string and returns this string
+    √ Joins all elements of an array into a string and returns this string
+    √ Joins all elements of an array into a string and returns this string
+
+  Testing JSONToDate
+
+    √ JSONToDate is a Function
+
+  Testing JSONToFile
+
+    √ JSONToFile is a Function
+
+  Testing last
+
+    √ last is a Function
+    √ last({ a: 1234}) returns undefined
+    √ last([1, 2, 3]) returns 3
+    √ last({ 0: false}) returns undefined
+    √ last(String) returns g
+    √ last(null) throws an Error
+    √ last(undefined) throws an Error
+    √ last() throws an Error
+    √ last([1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 1122, 32124, 23232]) takes less than 2s to run
+
+  Testing lcm
+
+    √ lcm is a Function
+    √ Returns the least common multiple of two or more numbers.
+    √ Returns the least common multiple of two or more numbers.
+
+  Testing longestItem
+
+    √ longestItem is a Function
+    √ Returns the longest object
+
+  Testing lowercaseKeys
+
+    √ lowercaseKeys is a Function
+
+  Testing luhnCheck
+
+    √ luhnCheck is a Function
+    √ validates identification number
+    √ validates identification number
+    √ validates identification number
+
+  Testing mapKeys
+
+    √ mapKeys is a Function
+
+  Testing mapObject
+
+    √ mapObject is a Function
+    √ Maps the values of an array to an object using a function
+
+  Testing mapValues
+
+    √ mapValues is a Function
+
+  Testing mask
+
+    √ mask is a Function
+    √ Replaces all but the last num of characters with the specified mask character
+    √ Replaces all but the last num of characters with the specified mask character
+    √ Replaces all but the last num of characters with the specified mask character
+
+  Testing matches
+
+    √ matches is a Function
+
+  Testing matchesWith
+
+    √ matchesWith is a Function
+
+  Testing maxBy
+
+    √ maxBy is a Function
+    √ Produces the right result with a function
+    √ Produces the right result with a property name
+
+  Testing maxN
+
+    √ maxN is a Function
+    √ Returns the n maximum elements from the provided array
+    √ Returns the n maximum elements from the provided array
+
+  Testing median
+
+    √ median is a Function
+    √ Returns the median of an array of numbers
+    √ Returns the median of an array of numbers
+
+  Testing memoize
+
+    √ memoize is a Function
+
+  Testing merge
+
+    √ merge is a Function
+
+  Testing minBy
+
+    √ minBy is a Function
+    √ Produces the right result with a function
+    √ Produces the right result with a property name
+
+  Testing minN
+
+    √ minN is a Function
+    √ Returns the n minimum elements from the provided array
+    √ Returns the n minimum elements from the provided array
+
+  Testing negate
+
+    √ negate is a Function
+    √ Negates a predicate function
+
+  Testing nthArg
+
+    √ nthArg is a Function
+
+  Testing nthElement
+
+    √ nthElement is a Function
+    √ Returns the nth element of an array.
+    √ Returns the nth element of an array.
+
+  Testing objectFromPairs
+
+    √ objectFromPairs is a Function
+    √ Creates an object from the given key-value pairs.
+
+  Testing objectToPairs
+
+    √ objectToPairs is a Function
+    √ Creates an array of key-value pair arrays from an object.
+
+  Testing observeMutations
+
+    √ observeMutations is a Function
+
+  Testing off
+
+    √ off is a Function
+
+  Testing omit
+
+    √ omit is a Function
+
+  Testing omitBy
+
+    √ omitBy is a Function
+
+  Testing on
+
+    √ on is a Function
+
+  Testing once
+
+    √ once is a Function
+
+  Testing onUserInputChange
+
+    √ onUserInputChange is a Function
+
+  Testing orderBy
+
+    √ orderBy is a Function
+    √ Returns a sorted array of objects ordered by properties and orders.
+    √ Returns a sorted array of objects ordered by properties and orders.
+
+  Testing over
+
+    √ over is a Function
+
+  Testing palindrome
+
+    √ palindrome is a Function
+    √ Given string is a palindrome
+    √ Given string is not a palindrome
+
+  Testing parseCookie
+
+    √ parseCookie is a Function
+
+  Testing partial
+
+    √ partial is a Function
+
+  Testing partialRight
+
+    √ partialRight is a Function
+
+  Testing partition
+
+    √ partition is a Function
+    √ Groups the elements into two arrays, depending on the provided function's truthiness for each element.
+
+  Testing percentile
+
+    √ percentile is a Function
+    √ Uses the percentile formula to calculate how many numbers in the given array are less or equal to the given value.
+
+  Testing pick
+
+    √ pick is a Function
+    √ Picks the key-value pairs corresponding to the given keys from an object.
+
+  Testing pickBy
+
+    √ pickBy is a Function
+
+  Testing pipeAsyncFunctions
+
+    √ pipeAsyncFunctions is a Function
+    √ pipeAsyncFunctions result should be 15
+
+  Testing pipeFunctions
+
+    √ pipeFunctions is a Function
+
+  Testing pluralize
+
+    √ pluralize is a Function
+
+  Testing powerset
+
+    √ powerset is a Function
+    √ Returns the powerset of a given array of numbers.
+
+  Testing prettyBytes
+
+    √ prettyBytes is a Function
+    √ Converts a number in bytes to a human-readable string.
+    √ Converts a number in bytes to a human-readable string.
+    √ Converts a number in bytes to a human-readable string.
+
+  Testing primes
+
+    √ primes is a Function
+    √ Generates primes up to a given number, using the Sieve of Eratosthenes.
+
+  Testing promisify
+
+    √ promisify is a Function
+
+  Testing pull
+
+    √ pull is a Function
+
+  Testing pullAtIndex
+
+    √ pullAtIndex is a Function
+
+  Testing pullAtValue
+
+    √ pullAtValue is a Function
+
+  Testing pullBy
+
+    √ pullBy is a Function
+
+  Testing quickSort
+
+    √ quickSort is a Function
+    √ quickSort([5, 6, 4, 3, 1, 2]) returns [1, 2, 3, 4, 5, 6]
+    √ quickSort([-1, 0, -2]) returns [-2, -1, 0]
+    √ quickSort() throws an error
+    √ quickSort(123) throws an error
+    √ quickSort({ 234: string}) throws an error
+    √ quickSort(null) throws an error
+    √ quickSort(undefined) throws an error
+    √ quickSort([11, 1, 324, 23232, -1, 53, 2, 524, 32, 13, 156, 133, 62, 12, 4]) takes less than 2s to run
+
+  Testing randomHexColorCode
+
+    √ randomHexColorCode is a Function
+
+  Testing randomIntArrayInRange
+
+    √ randomIntArrayInRange is a Function
+
+  Testing randomIntegerInRange
+
+    √ randomIntegerInRange is a Function
+
+  Testing randomNumberInRange
+
+    √ randomNumberInRange is a Function
+
+  Testing readFileLines
+
+    √ readFileLines is a Function
+
+  Testing README
+
+    √ README is a Function
+
+  Testing redirect
+
+    √ redirect is a Function
+
+  Testing reducedFilter
+
+    √ reducedFilter is a Function
+    √ Filter an array of objects based on a condition while also filtering out unspecified keys.
+
+  Testing reduceSuccessive
+
+    √ reduceSuccessive is a Function
+
+  Testing reduceWhich
+
+    √ reduceWhich is a Function
+
+  Testing remove
+
+    √ remove is a Function
+    √ Removes elements from an array for which the given function returns false
+
+  Testing removeNonASCII
+
+    √ removeNonASCII is a Function
+
+  Testing removeVowels
+
+    √ removeVowels is a Function
+
+  Testing reverseString
+
+    √ reverseString is a Function
+    √ Reverses a string.
+
+  Testing RGBToHex
+
+    √ RGBToHex is a Function
+    √ Converts the values of RGB components to a color code.
+
+  Testing round
+
+    √ round is a Function
+    √ Rounds a number to a specified amount of digits.
+
+  Testing runAsync
+
+    √ runAsync is a Function
+
+  Testing runPromisesInSeries
+
+    √ runPromisesInSeries is a Function
+
+  Testing sample
+
+    √ sample is a Function
+
+  Testing sampleSize
+
+    √ sampleSize is a Function
+
+  Testing scrollToTop
+
+    √ scrollToTop is a Function
+
+  Testing sdbm
+
+    √ sdbm is a Function
+    √ Hashes the input string into a whole number.
+
+  Testing serializeCookie
+
+    √ serializeCookie is a Function
+
+  Testing setStyle
+
+    √ setStyle is a Function
+
+  Testing shallowClone
+
+    √ shallowClone is a Function
+    √ Shallow cloning works
+    √ Does not clone deeply
+
+  Testing show
+
+    √ show is a Function
+
+  Testing shuffle
+
+    √ shuffle is a Function
+
+  Testing similarity
+
+    √ similarity is a Function
+    √ Returns an array of elements that appear in both arrays.
+
+  Testing size
+
+    √ size is a Function
+    √ Get size of arrays, objects or strings.
+    √ Get size of arrays, objects or strings.
+
+  Testing sleep
+
+    √ sleep is a Function
+
+  Testing solveRPN
+
+    √ solveRPN is a Function
+
+  Testing sortCharactersInString
+
+    √ sortCharactersInString is a Function
+    √ Alphabetically sorts the characters in a string.
+
+  Testing sortedIndex
+
+    √ sortedIndex is a Function
+    √ Returns the lowest index at which value should be inserted into array in order to maintain its sort order.
+    √ Returns the lowest index at which value should be inserted into array in order to maintain its sort order.
+
+  Testing sortedIndexBy
+
+    √ sortedIndexBy is a Function
+
+  Testing sortedLastIndex
+
+    √ sortedLastIndex is a Function
+
+  Testing sortedLastIndexBy
+
+    √ sortedLastIndexBy is a Function
+
+  Testing speechSynthesis
+
+    √ speechSynthesis is a Function
+
+  Testing splitLines
+
+    √ splitLines is a Function
+    √ Splits a multiline string into an array of lines.
+
+  Testing spreadOver
+
+    √ spreadOver is a Function
+    √ Takes a variadic function and returns a closure that accepts an array of arguments to map to the inputs of the function.
+
+  Testing standardDeviation
+
+    √ standardDeviation is a Function
+    √ Returns the standard deviation of an array of numbers
+    √ Returns the standard deviation of an array of numbers
+
+  Testing stripHTMLTags
+
+    √ stripHTMLTags is a Function
+
+  Testing sum
+
+    √ sum is a Function
+    √ Returns the sum of two or more numbers/arrays.
+
+  Testing sumBy
+
+    √ sumBy is a Function
+
+  Testing sumPower
+
+    √ sumPower is a Function
+    √ Returns the sum of the powers of all the numbers from start to end
+    √ Returns the sum of the powers of all the numbers from start to end
+    √ Returns the sum of the powers of all the numbers from start to end
+
+  Testing symmetricDifference
+
+    √ symmetricDifference is a Function
+    √ Returns the symmetric difference between two arrays.
+
+  Testing symmetricDifferenceBy
+
+    √ symmetricDifferenceBy is a Function
+
+  Testing symmetricDifferenceWith
+
+    √ symmetricDifferenceWith is a Function
+
+  Testing tail
+
+    √ tail is a Function
+    √ Returns tail
+    √ Returns tail
+
+  Testing take
+
+    √ take is a Function
+    √ Returns an array with n elements removed from the beginning.
+    √ Returns an array with n elements removed from the beginning.
+
+  Testing takeRight
+
+    √ takeRight is a Function
+    √ Returns an array with n elements removed from the end
+    √ Returns an array with n elements removed from the end
+
+  Testing takeRightWhile
+
+    √ takeRightWhile is a Function
+
+  Testing takeWhile
+
+    √ takeWhile is a Function
+
+  Testing times
+
+    √ times is a Function
+
+  Testing timeTaken
+
+    √ timeTaken is a Function
+
+  Testing toCamelCase
+
+    √ toCamelCase is a Function
+    √ Converts a string to camelCase
+    √ Converts a string to camelCase
+    √ Converts a string to camelCase
+    √ Converts a string to camelCase
+
+  Testing toDecimalMark
+
+    √ toDecimalMark is a Function
+    √ convert a float-point arithmetic to the Decimal mark form
+
+  Testing toggleClass
+
+    √ toggleClass is a Function
+
+  Testing toKebabCase
+
+    √ toKebabCase is a Function
+    √ string converts to snake case
+    √ string converts to snake case
+    √ string converts to snake case
+    √ string converts to snake case
+
+  Testing tomorrow
+
+    √ tomorrow is a Function
+
+  Testing toOrdinalSuffix
+
+    √ toOrdinalSuffix is a Function
+    √ Adds an ordinal suffix to a number
+    √ Adds an ordinal suffix to a number
+    √ Adds an ordinal suffix to a number
+    √ Adds an ordinal suffix to a number
+
+  Testing toSafeInteger
+
+    √ toSafeInteger is a Function
+    √ Converts a value to a safe integer
+    √ Converts a value to a safe integer
+    √ Converts a value to a safe integer
+    √ Converts a value to a safe integer
+    √ Converts a value to a safe integer
+
+  Testing toSnakeCase
+
+    √ toSnakeCase is a Function
+    √ string converts to snake case
+    √ string converts to snake case
+    √ string converts to snake case
+    √ string converts to snake case
+
+  Testing transform
+
+    √ transform is a Function
+
+  Testing truncateString
+
+    √ truncateString is a Function
+    √ Truncates a "boomerang" up to a specified length.
+
+  Testing truthCheckCollection
+
+    √ truthCheckCollection is a Function
+    √ second argument is truthy on all elements of a collection
+
+  Testing unary
+
+    √ unary is a Function
+
+  Testing unescapeHTML
+
+    √ unescapeHTML is a Function
+    √ Unescapes escaped HTML characters.
+
+  Testing unfold
+
+    √ unfold is a Function
+
+  Testing union
+
+    √ union is a Function
+    √ Returns every element that exists in any of the two arrays once
+
+  Testing unionBy
+
+    √ unionBy is a Function
+
+  Testing unionWith
+
+    √ unionWith is a Function
+
+  Testing uniqueElements
+
+    √ uniqueElements is a Function
+    √ Returns all unique values of an array
+
+  Testing untildify
+
+    √ untildify is a Function
+
+  Testing unzip
+
+    √ unzip is a Function
+    √ unzip([['a', 1, true], ['b', 2, false]]) equals [['a', 'b'], [1, 2], [true, false]]
+    √ unzip([['a', 1, true], ['b', 2]]) equals [['a', 'b'], [1, 2], [true]]
+
+  Testing unzipWith
+
+    √ unzipWith is a Function
+    √ unzipWith([[1, 10, 100], [2, 20, 200]], (...args) => args.reduce((acc, v) => acc + v, 0)) equals [3, 30, 300]
+
+  Testing URLJoin
+
+    √ URLJoin is a Function
+    √ Returns proper URL
+    √ Returns proper URL
+
+  Testing UUIDGeneratorBrowser
+
+    √ UUIDGeneratorBrowser is a Function
+
+  Testing UUIDGeneratorNode
+
+    √ UUIDGeneratorNode is a Function
+
+  Testing validateNumber
+
+    √ validateNumber is a Function
+    √ validateNumber(9) returns true
+    √ validateNumber(234asd.slice(0, 2)) returns true
+    √ validateNumber(1232) returns true
+    √ validateNumber(1232 + 13423) returns true
+    √ validateNumber(1232 * 2342 * 123) returns true
+    √ validateNumber(1232.23423536) returns true
+    √ validateNumber(234asd) returns false
+    √ validateNumber(e234d) returns false
+    √ validateNumber(false) returns false
+    √ validateNumber(true) returns false
+    √ validateNumber(null) returns false
+    √ validateNumber(123 * asd) returns false
+
+  Testing without
+
+    √ without is a Function
+    √ without([2, 1, 2, 3], 1, 2) returns [3]
+    √ without([]) returns []
+    √ without([3, 1, true, '3', true], '3', true) returns [3, 1]
+    √ without('string'.split(''), 's', 't', 'g') returns ['r', 'i', 'n']
+    √ without() throws an error
+    √ without(null) throws an error
+    √ without(undefined) throws an error
+    √ without() throws an error
+    √ without({}) throws an error
+
+  Testing words
+
+    √ words is a Function
+    √ words('I love javaScript!!') returns [I, love, javaScript]
+    √ words('python, javaScript & coffee') returns [python, javaScript, coffee]
+    √ words(I love javaScript!!) returns an array
+    √ words() throws a error
+    √ words(null) throws a error
+    √ words(undefined) throws a error
+    √ words({}) throws a error
+    √ words([]) throws a error
+    √ words(1234) throws a error
+
+  Testing xProd
+
+    √ xProd is a Function
+    √ xProd([1, 2], ['a', 'b']) returns [[1, 'a'], [1, 'b'], [2, 'a'], [2, 'b']]
+
+  Testing yesNo
+
+    √ yesNo is a Function
+    √ yesNo(Y) returns true
+    √ yesNo(yes) returns true
+    √ yesNo(foo, true) returns true
+    √ yesNo(No) returns false
+    √ yesNo() returns false
+    √ yesNo(null) returns false
+    √ yesNo(undefined) returns false
+    √ yesNo([123, null]) returns false
+    √ yesNo([Yes, No]) returns false
+    √ yesNo({ 2: Yes }) returns false
+    √ yesNo([Yes, No], true) returns true
+    √ yesNo({ 2: Yes }, true) returns true
+
+  Testing zip
+
+    √ zip is a Function
+    √ zip([a, b], [1, 2], [true, false]) returns [[a, 1, true], [b, 2, false]]
+    √ zip([a], [1, 2], [true, false]) returns [[a, 1, true], [undefined, 2, false]]
+    √ zip([]) returns []
+    √ zip(123) returns []
+    √ zip([a, b], [1, 2], [true, false]) returns an Array
+    √ zip([a], [1, 2], [true, false]) returns an Array
+    √ zip(null) throws an error
+    √ zip(undefined) throws an error
+
+  Testing zipObject
+
+    √ zipObject is a Function
+    √ zipObject([a, b, c], [1, 2]) returns {a: 1, b: 2, c: undefined}
+    √ zipObject([a, b], [1, 2, 3]) returns {a: 1, b: 2}
+    √ zipObject([a, b, c], string) returns { a: s, b: t, c: r }
+    √ zipObject([a], string) returns { a: s }
+    √ zipObject() throws an error
+    √ zipObject([string], null) throws an error
+    √ zipObject(null, [1]) throws an error
+    √ zipObject(string) throws an error
+    √ zipObject(test, string) throws an error
+
+  Testing zipWith
+
+    √ zipWith is a Function
+
+
+  total:     652
+  passing:   652
+  duration:  1.7s
+
 
-undefined
\ No newline at end of file

From 90fc391fa2768e098dab782285d58c2dddf3c073 Mon Sep 17 00:00:00 2001
From: 30secondsofcode <30secondsofcode@gmail.com>
Date: Sun, 28 Jan 2018 12:31:14 +0000
Subject: [PATCH 18/33] Travis build: 1463

---
 README.md       | 33 +++++++++++++++++++++++++++++++++
 docs/index.html | 12 +++++++++++-
 2 files changed, 44 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 4a577f558..0d12c1943 100644
--- a/README.md
+++ b/README.md
@@ -82,6 +82,7 @@ average(1, 2, 3);
 * [`collectInto`](#collectinto)
 * [`flip`](#flip)
 * [`over`](#over)
+* [`pipeAsyncFunctions`](#pipeasyncfunctions)
 * [`pipeFunctions`](#pipefunctions)
 * [`promisify`](#promisify)
 * [`spreadOver`](#spreadover)
@@ -554,6 +555,38 @@ minMax(1, 2, 3, 4, 5); // [1,5]
 
[⬆ Back to top](#table-of-contents) +### pipeAsyncFunctions + +Performs left-to-right function composition for asynchronous functions. + +Use `Array.reduce()` with the spread operator (`...`) to perform left-to-right function composition using `Promise.then()`. +The functions can return a combination of: simple values, `Promise`'s, or they can be defined as `async` ones returning through `await`. +All functions must be unary. + +```js +const pipeAsyncFunctions = (...fns) => arg => fns.reduce((p, f) => p.then(f), Promise.resolve(arg)); +``` + +
+Examples + +```js +const sum = pipeAsyncFunctions( + x => x + 1, + x => new Promise(resolve => setTimeout(() => resolve(x + 2), 1000)), + x => x + 3, + async x => (await x) + 4 +); +(async () => { + console.log(await sum(5)); // 15 (after one second) +})(); +``` + +
+ +
[⬆ Back to top](#table-of-contents) + + ### pipeFunctions Performs left-to-right function composition. diff --git a/docs/index.html b/docs/index.html index 75bfadaa9..772a0519d 100644 --- a/docs/index.html +++ b/docs/index.html @@ -50,7 +50,7 @@ scrollToTop(); } }, false); - }

logo 30 seconds of code Curated collection of useful JavaScript snippets that you can understand in 30 seconds or less.

 

Adapter

ary

Creates a function that accepts up to n arguments, ignoring any additional arguments.

Call the provided function, fn, with up to n arguments, using Array.slice(0,n) and the spread operator (...).

const ary = (fn, n) => (...args) => fn(...args.slice(0, n));
+      }

logo 30 seconds of code Curated collection of useful JavaScript snippets that you can understand in 30 seconds or less.

 

Adapter

ary

Creates a function that accepts up to n arguments, ignoring any additional arguments.

Call the provided function, fn, with up to n arguments, using Array.slice(0,n) and the spread operator (...).

const ary = (fn, n) => (...args) => fn(...args.slice(0, n));
 
const firstTwoMax = ary(Math.max, 2);
 [[2, 6, 'a'], [8, 4, 6], [10]].map(x => firstTwoMax(...x)); // [6, 8, 10]
 

call

Given a key and a set of arguments, call them when given a context. Primarily useful in composition.

Use a closure to call a stored key with stored arguments.

const call = (key, ...args) => context => context[key](...args);
@@ -78,6 +78,16 @@ Object.assig
 

over

Creates a function that invokes each provided function with the arguments it receives and returns the results.

Use Array.map() and Function.apply() to apply each function to the given arguments.

const over = (...fns) => (...args) => fns.map(fn => fn.apply(null, args));
 
const minMax = over(Math.min, Math.max);
 minMax(1, 2, 3, 4, 5); // [1,5]
+

pipeAsyncFunctions

Performs left-to-right function composition for asynchronous functions.

Use Array.reduce() with the spread operator (...) to perform left-to-right function composition using Promise.then(). The functions can return a combination of: simple values, Promise's, or they can be defined as async ones returning through await. All functions must be unary.

const pipeAsyncFunctions = (...fns) => arg => fns.reduce((p, f) => p.then(f), Promise.resolve(arg));
+
const sum = pipeAsyncFunctions(
+  x => x + 1,
+  x => new Promise(resolve => setTimeout(() => resolve(x + 2), 1000)),
+  x => x + 3,
+  async x => (await x) + 4
+);
+(async () => {
+  console.log(await sum(5)); // 15 (after one second)
+})();
 

pipeFunctions

Performs left-to-right function composition.

Use Array.reduce() with the spread operator (...) to perform left-to-right function composition. The first (leftmost) function can accept one or more arguments; the remaining functions must be unary.

const pipeFunctions = (...fns) => fns.reduce((f, g) => (...args) => g(f(...args)));
 
const add5 = x => x + 5;
 const multiply = (x, y) => x * y;

From abac9e4c784db9b6f04f12e38c15e72316e4aca6 Mon Sep 17 00:00:00 2001
From: Angelos Chalaris 
Date: Sun, 28 Jan 2018 14:44:40 +0200
Subject: [PATCH 19/33] Add attempt

---
 snippets/attempt.md | 22 ++++++++++++++++++++++
 tag_database        |  1 +
 2 files changed, 23 insertions(+)
 create mode 100644 snippets/attempt.md

diff --git a/snippets/attempt.md b/snippets/attempt.md
new file mode 100644
index 000000000..c3dae169e
--- /dev/null
+++ b/snippets/attempt.md
@@ -0,0 +1,22 @@
+### attempt
+
+Attempts to invoke a function with the provided arguments, returning either the result or the caught error object.
+
+Use a `try... catch` block to return either the result of the function or an appropriate error.
+
+```js
+const attempt = (fn, ...args) => {
+  try {
+    return fn(args);
+  } catch (e) {
+    return e instanceof Error ? e : new Error(e);
+  }
+};
+```
+
+```js
+var elements = attempt(function(selector) {
+  return document.querySelectorAll(selector);
+}, '>_>');
+if (elements instanceof Error) elements = []; // elements = []
+```
diff --git a/tag_database b/tag_database
index 4e52b9a38..a556e5be3 100644
--- a/tag_database
+++ b/tag_database
@@ -2,6 +2,7 @@ anagrams:string,recursion
 arrayToHtmlList:browser,array
 ary:adapter,function
 atob:node,string,utility
+attempt:function
 average:math,array
 averageBy:math,array,function
 bind:function,object

From 6b22af223afcbfa26cf45fd72b32b6501590cee7 Mon Sep 17 00:00:00 2001
From: 30secondsofcode <30secondsofcode@gmail.com>
Date: Sun, 28 Jan 2018 12:45:54 +0000
Subject: [PATCH 20/33] Travis build: 1465

---
 README.md       | 32 ++++++++++++++++++++++++++++++++
 docs/index.html | 15 +++++++++++++--
 2 files changed, 45 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index 0d12c1943..69cd7b84d 100644
--- a/README.md
+++ b/README.md
@@ -220,6 +220,7 @@ average(1, 2, 3);
 
View contents +* [`attempt`](#attempt) * [`bind`](#bind) * [`bindKey`](#bindkey) * [`chainAsync`](#chainasync) @@ -3465,6 +3466,37 @@ tomorrow(); // 2017-12-27 (if current date is 2017-12-26) --- ## 🎛️ Function +### attempt + +Attempts to invoke a function with the provided arguments, returning either the result or the caught error object. + +Use a `try... catch` block to return either the result of the function or an appropriate error. + +```js +const attempt = (fn, ...args) => { + try { + return fn(args); + } catch (e) { + return e instanceof Error ? e : new Error(e); + } +}; +``` + +
+Examples + +```js +var elements = attempt(function(selector) { + return document.querySelectorAll(selector); +}, '>_>'); +if (elements instanceof Error) elements = []; // elements = [] +``` + +
+ +
[⬆ Back to top](#table-of-contents) + + ### bind Creates a function that invokes `fn` with a given context, optionally adding any additional supplied parameters to the beginning of the arguments. diff --git a/docs/index.html b/docs/index.html index 772a0519d..89387e63a 100644 --- a/docs/index.html +++ b/docs/index.html @@ -50,7 +50,7 @@ scrollToTop(); } }, false); - }

logo 30 seconds of code Curated collection of useful JavaScript snippets that you can understand in 30 seconds or less.

 

Adapter

ary

Creates a function that accepts up to n arguments, ignoring any additional arguments.

Call the provided function, fn, with up to n arguments, using Array.slice(0,n) and the spread operator (...).

const ary = (fn, n) => (...args) => fn(...args.slice(0, n));
+      }

logo 30 seconds of code Curated collection of useful JavaScript snippets that you can understand in 30 seconds or less.

 

Adapter

ary

Creates a function that accepts up to n arguments, ignoring any additional arguments.

Call the provided function, fn, with up to n arguments, using Array.slice(0,n) and the spread operator (...).

const ary = (fn, n) => (...args) => fn(...args.slice(0, n));
 
const firstTwoMax = ary(Math.max, 2);
 [[2, 6, 'a'], [8, 4, 6], [10]].map(x => firstTwoMax(...x)); // [6, 8, 10]
 

call

Given a key and a set of arguments, call them when given a context. Primarily useful in composition.

Use a closure to call a stored key with stored arguments.

const call = (key, ...args) => context => context[key](...args);
@@ -762,7 +762,18 @@ document.bodypadStart(2, '0')}`;
 };
 
tomorrow(); // 2017-12-27 (if current date is 2017-12-26)
-

Function

bind

Creates a function that invokes fn with a given context, optionally adding any additional supplied parameters to the beginning of the arguments.

Return a function that uses Function.apply() to apply the given context to fn. Use Array.concat() to prepend any additional supplied parameters to the arguments.

const bind = (fn, context, ...args) =>
+

Function

attempt

Attempts to invoke a function with the provided arguments, returning either the result or the caught error object.

Use a try... catch block to return either the result of the function or an appropriate error.

const attempt = (fn, ...args) => {
+  try {
+    return fn(args);
+  } catch (e) {
+    return e instanceof Error ? e : new Error(e);
+  }
+};
+
var elements = attempt(function(selector) {
+  return document.querySelectorAll(selector);
+}, '>_>');
+if (elements instanceof Error) elements = []; // elements = []
+

bind

Creates a function that invokes fn with a given context, optionally adding any additional supplied parameters to the beginning of the arguments.

Return a function that uses Function.apply() to apply the given context to fn. Use Array.concat() to prepend any additional supplied parameters to the arguments.

const bind = (fn, context, ...args) =>
   function() {
     return fn.apply(context, args.concat(...arguments));
   };

From b005826fdec0dbb9f05ff63d9bfecdc895b4a5d0 Mon Sep 17 00:00:00 2001
From: Angelos Chalaris 
Date: Sun, 28 Jan 2018 14:54:16 +0200
Subject: [PATCH 21/33] Add overArgs

---
 snippets/overArgs.md | 20 ++++++++++++++++++++
 tag_database         |  1 +
 2 files changed, 21 insertions(+)
 create mode 100644 snippets/overArgs.md

diff --git a/snippets/overArgs.md b/snippets/overArgs.md
new file mode 100644
index 000000000..0c54fa726
--- /dev/null
+++ b/snippets/overArgs.md
@@ -0,0 +1,20 @@
+### overArgs
+
+Creates a function that invokes the provided function with its arguments transformed.
+
+Use `Array.map()` to apply `transforms` to `args` in combination with the spread operator (`...`) to pass the transformed arguments to `fn`.
+
+```js
+const overArgs = (fn, transforms) => (...args) =>
+  fn(...args.map((val, i) => transforms[i](val)));
+```
+
+```js
+var func = overArgs(
+  function(x, y) {
+    return [x, y];
+  },
+  [square, doubled]
+);
+func(9, 3); // [81, 6]
+```
diff --git a/tag_database b/tag_database
index a556e5be3..8a8a891bc 100644
--- a/tag_database
+++ b/tag_database
@@ -162,6 +162,7 @@ once:function
 onUserInputChange:browser,event,advanced
 orderBy:object,array
 over:adapter,function
+overArgs:adapter,function
 palindrome:string
 parseCookie:utility,string
 partial:function

From d1f222bc628ae0fc74fa6030679eb039dc254449 Mon Sep 17 00:00:00 2001
From: 30secondsofcode <30secondsofcode@gmail.com>
Date: Sun, 28 Jan 2018 12:55:37 +0000
Subject: [PATCH 22/33] Travis build: 1467

---
 README.md            | 29 +++++++++++++++++++++++++++++
 docs/index.html      | 10 +++++++++-
 snippets/overArgs.md |  3 +--
 3 files changed, 39 insertions(+), 3 deletions(-)

diff --git a/README.md b/README.md
index 69cd7b84d..e1a4779c6 100644
--- a/README.md
+++ b/README.md
@@ -82,6 +82,7 @@ average(1, 2, 3);
 * [`collectInto`](#collectinto)
 * [`flip`](#flip)
 * [`over`](#over)
+* [`overArgs`](#overargs)
 * [`pipeAsyncFunctions`](#pipeasyncfunctions)
 * [`pipeFunctions`](#pipefunctions)
 * [`promisify`](#promisify)
@@ -556,6 +557,34 @@ minMax(1, 2, 3, 4, 5); // [1,5]
 
[⬆ Back to top](#table-of-contents) +### overArgs + +Creates a function that invokes the provided function with its arguments transformed. + +Use `Array.map()` to apply `transforms` to `args` in combination with the spread operator (`...`) to pass the transformed arguments to `fn`. + +```js +const overArgs = (fn, transforms) => (...args) => fn(...args.map((val, i) => transforms[i](val))); +``` + +
+Examples + +```js +var func = overArgs( + function(x, y) { + return [x, y]; + }, + [square, doubled] +); +func(9, 3); // [81, 6] +``` + +
+ +
[⬆ Back to top](#table-of-contents) + + ### pipeAsyncFunctions Performs left-to-right function composition for asynchronous functions. diff --git a/docs/index.html b/docs/index.html index 89387e63a..ca0cc9869 100644 --- a/docs/index.html +++ b/docs/index.html @@ -50,7 +50,7 @@ scrollToTop(); } }, false); - }

logo 30 seconds of code Curated collection of useful JavaScript snippets that you can understand in 30 seconds or less.

 

Adapter

ary

Creates a function that accepts up to n arguments, ignoring any additional arguments.

Call the provided function, fn, with up to n arguments, using Array.slice(0,n) and the spread operator (...).

const ary = (fn, n) => (...args) => fn(...args.slice(0, n));
+      }

logo 30 seconds of code Curated collection of useful JavaScript snippets that you can understand in 30 seconds or less.

 

Adapter

ary

Creates a function that accepts up to n arguments, ignoring any additional arguments.

Call the provided function, fn, with up to n arguments, using Array.slice(0,n) and the spread operator (...).

const ary = (fn, n) => (...args) => fn(...args.slice(0, n));
 
const firstTwoMax = ary(Math.max, 2);
 [[2, 6, 'a'], [8, 4, 6], [10]].map(x => firstTwoMax(...x)); // [6, 8, 10]
 

call

Given a key and a set of arguments, call them when given a context. Primarily useful in composition.

Use a closure to call a stored key with stored arguments.

const call = (key, ...args) => context => context[key](...args);
@@ -78,6 +78,14 @@ Object.assig
 

over

Creates a function that invokes each provided function with the arguments it receives and returns the results.

Use Array.map() and Function.apply() to apply each function to the given arguments.

const over = (...fns) => (...args) => fns.map(fn => fn.apply(null, args));
 
const minMax = over(Math.min, Math.max);
 minMax(1, 2, 3, 4, 5); // [1,5]
+

overArgs

Creates a function that invokes the provided function with its arguments transformed.

Use Array.map() to apply transforms to args in combination with the spread operator (...) to pass the transformed arguments to fn.

const overArgs = (fn, transforms) => (...args) => fn(...args.map((val, i) => transforms[i](val)));
+
var func = overArgs(
+  function(x, y) {
+    return [x, y];
+  },
+  [square, doubled]
+);
+func(9, 3); // [81, 6]
 

pipeAsyncFunctions

Performs left-to-right function composition for asynchronous functions.

Use Array.reduce() with the spread operator (...) to perform left-to-right function composition using Promise.then(). The functions can return a combination of: simple values, Promise's, or they can be defined as async ones returning through await. All functions must be unary.

const pipeAsyncFunctions = (...fns) => arg => fns.reduce((p, f) => p.then(f), Promise.resolve(arg));
 
const sum = pipeAsyncFunctions(
   x => x + 1,
diff --git a/snippets/overArgs.md b/snippets/overArgs.md
index 0c54fa726..9a913e049 100644
--- a/snippets/overArgs.md
+++ b/snippets/overArgs.md
@@ -5,8 +5,7 @@ Creates a function that invokes the provided function with its arguments transfo
 Use `Array.map()` to apply `transforms` to `args` in combination with the spread operator (`...`) to pass the transformed arguments to `fn`.
 
 ```js
-const overArgs = (fn, transforms) => (...args) =>
-  fn(...args.map((val, i) => transforms[i](val)));
+const overArgs = (fn, transforms) => (...args) => fn(...args.map((val, i) => transforms[i](val)));
 ```
 
 ```js

From fd358202930d4fa3b56fbfcd074e4dc7b1a5b0dd Mon Sep 17 00:00:00 2001
From: Angelos Chalaris 
Date: Sun, 28 Jan 2018 15:04:21 +0200
Subject: [PATCH 23/33] Add rearg

---
 snippets/rearg.md | 25 +++++++++++++++++++++++++
 tag_database      |  1 +
 2 files changed, 26 insertions(+)
 create mode 100644 snippets/rearg.md

diff --git a/snippets/rearg.md b/snippets/rearg.md
new file mode 100644
index 000000000..f58ea2f58
--- /dev/null
+++ b/snippets/rearg.md
@@ -0,0 +1,25 @@
+### rearg
+
+Creates a function that invokes the provided function with its arguments arranged according to the specified indexes.
+
+Use `Array.reduce()` and `Array.indexOf()` to reorder arguments based on `indexes` in combination with the spread operator (`...`) to pass the transformed arguments to `fn`.
+
+```js
+const rearg = (fn, indexes) => (...args) =>
+  fn(
+    ...args.reduce(
+      (acc, val, i) => ((acc[indexes.indexOf(i)] = val), acc),
+      Array.from({ length: indexes.length })
+    )
+  );
+```
+
+```js
+var rearged = rearg(
+  function(a, b, c) {
+    return [a, b, c];
+  },
+  [2, 0, 1]
+);
+rearged('b', 'c', 'a'); // ['a', 'b', 'c']
+```
diff --git a/tag_database b/tag_database
index 8a8a891bc..18fa151c3 100644
--- a/tag_database
+++ b/tag_database
@@ -187,6 +187,7 @@ randomIntArrayInRange:math,utility,random
 randomIntegerInRange:math,utility,random
 randomNumberInRange:math,utility,random
 readFileLines:node,array,string
+rearg:adapter,function
 redirect:browser,url
 reducedFilter:array
 reduceSuccessive:array,function

From 7c95c0096c32613301aa59230ab69137236d65a4 Mon Sep 17 00:00:00 2001
From: 30secondsofcode <30secondsofcode@gmail.com>
Date: Sun, 28 Jan 2018 13:05:40 +0000
Subject: [PATCH 24/33] Travis build: 1469

---
 README.md       | 35 +++++++++++++++++++++++++++++++++++
 docs/index.html | 16 +++++++++++++++-
 2 files changed, 50 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
index e1a4779c6..cdfe87fdd 100644
--- a/README.md
+++ b/README.md
@@ -86,6 +86,7 @@ average(1, 2, 3);
 * [`pipeAsyncFunctions`](#pipeasyncfunctions)
 * [`pipeFunctions`](#pipefunctions)
 * [`promisify`](#promisify)
+* [`rearg`](#rearg)
 * [`spreadOver`](#spreadover)
 * [`unary`](#unary)
 
@@ -672,6 +673,40 @@ delay(2000).then(() => console.log('Hi!')); // // Promise resolves after 2s
 
[⬆ Back to top](#table-of-contents) +### rearg + +Creates a function that invokes the provided function with its arguments arranged according to the specified indexes. + +Use `Array.reduce()` and `Array.indexOf()` to reorder arguments based on `indexes` in combination with the spread operator (`...`) to pass the transformed arguments to `fn`. + +```js +const rearg = (fn, indexes) => (...args) => + fn( + ...args.reduce( + (acc, val, i) => ((acc[indexes.indexOf(i)] = val), acc), + Array.from({ length: indexes.length }) + ) + ); +``` + +
+Examples + +```js +var rearged = rearg( + function(a, b, c) { + return [a, b, c]; + }, + [2, 0, 1] +); +rearged('b', 'c', 'a'); // ['a', 'b', 'c'] +``` + +
+ +
[⬆ Back to top](#table-of-contents) + + ### spreadOver Takes a variadic function and returns a closure that accepts an array of arguments to map to the inputs of the function. diff --git a/docs/index.html b/docs/index.html index ca0cc9869..c29967d9b 100644 --- a/docs/index.html +++ b/docs/index.html @@ -50,7 +50,7 @@ scrollToTop(); } }, false); - }

logo 30 seconds of code Curated collection of useful JavaScript snippets that you can understand in 30 seconds or less.

 

Adapter

ary

Creates a function that accepts up to n arguments, ignoring any additional arguments.

Call the provided function, fn, with up to n arguments, using Array.slice(0,n) and the spread operator (...).

const ary = (fn, n) => (...args) => fn(...args.slice(0, n));
+      }

logo 30 seconds of code Curated collection of useful JavaScript snippets that you can understand in 30 seconds or less.

 

Adapter

ary

Creates a function that accepts up to n arguments, ignoring any additional arguments.

Call the provided function, fn, with up to n arguments, using Array.slice(0,n) and the spread operator (...).

const ary = (fn, n) => (...args) => fn(...args.slice(0, n));
 
const firstTwoMax = ary(Math.max, 2);
 [[2, 6, 'a'], [8, 4, 6], [10]].map(x => firstTwoMax(...x)); // [6, 8, 10]
 

call

Given a key and a set of arguments, call them when given a context. Primarily useful in composition.

Use a closure to call a stored key with stored arguments.

const call = (key, ...args) => context => context[key](...args);
@@ -107,6 +107,20 @@ Object.assig
   );
 
const delay = promisify((d, cb) => setTimeout(cb, d));
 delay(2000).then(() => console.log('Hi!')); // // Promise resolves after 2s
+

rearg

Creates a function that invokes the provided function with its arguments arranged according to the specified indexes.

Use Array.reduce() and Array.indexOf() to reorder arguments based on indexes in combination with the spread operator (...) to pass the transformed arguments to fn.

const rearg = (fn, indexes) => (...args) =>
+  fn(
+    ...args.reduce(
+      (acc, val, i) => ((acc[indexes.indexOf(i)] = val), acc),
+      Array.from({ length: indexes.length })
+    )
+  );
+
var rearged = rearg(
+  function(a, b, c) {
+    return [a, b, c];
+  },
+  [2, 0, 1]
+);
+rearged('b', 'c', 'a'); // ['a', 'b', 'c']
 

spreadOver

Takes a variadic function and returns a closure that accepts an array of arguments to map to the inputs of the function.

Use closures and the spread operator (...) to map the array of arguments to the inputs of the function.

const spreadOver = fn => argsArr => fn(...argsArr);
 
const arrayMax = spreadOver(Math.max);
 arrayMax([1, 2, 3]); // 3

From 5e374d99f45977f08abed12c7a7568c0157bdcdf Mon Sep 17 00:00:00 2001
From: Angelos Chalaris 
Date: Sun, 28 Jan 2018 15:18:26 +0200
Subject: [PATCH 25/33] Add debounce

---
 snippets/debounce.md | 29 +++++++++++++++++++++++++++++
 tag_database         |  1 +
 2 files changed, 30 insertions(+)
 create mode 100644 snippets/debounce.md

diff --git a/snippets/debounce.md b/snippets/debounce.md
new file mode 100644
index 000000000..941ab59a3
--- /dev/null
+++ b/snippets/debounce.md
@@ -0,0 +1,29 @@
+### debounce
+
+Creates a debounced function that delays invoking the provided function until after `wait` milliseconds have elapsed since the last time the debounced function was invoked.
+
+Use `setTimeout()` and `clearTimeout()` to debounce the given method, `fn`.
+Use `Function.apply()` to apply the `this` context to the function and provide the necessary `arguments`.
+Omit the second argument, `wait`, to set the timeout at a default of 0 ms.
+
+```js
+const debounce = (fn, wait = 0) => {
+  let inDebounce;
+  return function() {
+    const context = this,
+      args = arguments;
+    clearTimeout(inDebounce);
+    inDebounce = setTimeout(() => fn.apply(context, args), wait);
+  };
+};
+```
+
+```js
+window.addEventListener(
+  'resize',
+  debounce(function(evt) {
+    console.log(window.innerWidth);
+    console.log(window.innerHeight);
+  }, 250)
+); // Will log the window dimensions at most every 250ms
+```
diff --git a/tag_database b/tag_database
index 18fa151c3..6b4c7e9ff 100644
--- a/tag_database
+++ b/tag_database
@@ -33,6 +33,7 @@ createElement:browser,utility
 createEventHub:browser,event,advanced
 currentURL:browser,url
 curry:function,recursion
+debounce:function
 decapitalize:string,array
 deepClone:object,recursion
 deepFlatten:array,recursion

From 1841b29bacf73e38b00a1059d883e4ed34dd14ac Mon Sep 17 00:00:00 2001
From: 30secondsofcode <30secondsofcode@gmail.com>
Date: Sun, 28 Jan 2018 13:20:02 +0000
Subject: [PATCH 26/33] Travis build: 1471

---
 README.md       | 39 +++++++++++++++++++++++++++++++++++++++
 docs/index.html | 18 +++++++++++++++++-
 2 files changed, 56 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
index cdfe87fdd..13648d57b 100644
--- a/README.md
+++ b/README.md
@@ -229,6 +229,7 @@ average(1, 2, 3);
 * [`compose`](#compose)
 * [`composeRight`](#composeright)
 * [`curry`](#curry)
+* [`debounce`](#debounce)
 * [`defer`](#defer)
 * [`delay`](#delay)
 * [`functionName`](#functionname)
@@ -3738,6 +3739,44 @@ curry(Math.min, 3)(10)(50)(2); // 2
 
[⬆ Back to top](#table-of-contents) +### debounce + +Creates a debounced function that delays invoking the provided function until after `wait` milliseconds have elapsed since the last time the debounced function was invoked. + +Use `setTimeout()` and `clearTimeout()` to debounce the given method, `fn`. +Use `Function.apply()` to apply the `this` context to the function and provide the necessary `arguments`. +Omit the second argument, `wait`, to set the timeout at a default of 0 ms. + +```js +const debounce = (fn, wait = 0) => { + let inDebounce; + return function() { + const context = this, + args = arguments; + clearTimeout(inDebounce); + inDebounce = setTimeout(() => fn.apply(context, args), wait); + }; +}; +``` + +
+Examples + +```js +window.addEventListener( + 'resize', + debounce(function(evt) { + console.log(window.innerWidth); + console.log(window.innerHeight); + }, 250) +); // Will log the window dimensions at most every 250ms +``` + +
+ +
[⬆ Back to top](#table-of-contents) + + ### defer Defers invoking a function until the current call stack has cleared. diff --git a/docs/index.html b/docs/index.html index c29967d9b..e1f6a069e 100644 --- a/docs/index.html +++ b/docs/index.html @@ -50,7 +50,7 @@ scrollToTop(); } }, false); - }

logo 30 seconds of code Curated collection of useful JavaScript snippets that you can understand in 30 seconds or less.

 

Adapter

ary

Creates a function that accepts up to n arguments, ignoring any additional arguments.

Call the provided function, fn, with up to n arguments, using Array.slice(0,n) and the spread operator (...).

const ary = (fn, n) => (...args) => fn(...args.slice(0, n));
+      }

logo 30 seconds of code Curated collection of useful JavaScript snippets that you can understand in 30 seconds or less.

 

Adapter

ary

Creates a function that accepts up to n arguments, ignoring any additional arguments.

Call the provided function, fn, with up to n arguments, using Array.slice(0,n) and the spread operator (...).

const ary = (fn, n) => (...args) => fn(...args.slice(0, n));
 
const firstTwoMax = ary(Math.max, 2);
 [[2, 6, 'a'], [8, 4, 6], [10]].map(x => firstTwoMax(...x)); // [6, 8, 10]
 

call

Given a key and a set of arguments, call them when given a context. Primarily useful in composition.

Use a closure to call a stored key with stored arguments.

const call = (key, ...args) => context => context[key](...args);
@@ -845,6 +845,22 @@ console.log<
   arity <= args.length ? fn(...args) : curry.bind(null, fn, arity, ...args);
 
curry(Math.pow)(2)(10); // 1024
 curry(Math.min, 3)(10)(50)(2); // 2
+

debounce

Creates a debounced function that delays invoking the provided function until after wait milliseconds have elapsed since the last time the debounced function was invoked.

Use setTimeout() and clearTimeout() to debounce the given method, fn. Use Function.apply() to apply the this context to the function and provide the necessary arguments. Omit the second argument, wait, to set the timeout at a default of 0 ms.

const debounce = (fn, wait = 0) => {
+  let inDebounce;
+  return function() {
+    const context = this,
+      args = arguments;
+    clearTimeout(inDebounce);
+    inDebounce = setTimeout(() => fn.apply(context, args), wait);
+  };
+};
+
window.addEventListener(
+  'resize',
+  debounce(function(evt) {
+    console.log(window.innerWidth);
+    console.log(window.innerHeight);
+  }, 250)
+); // Will log the window dimensions at most every 250ms
 

defer

Defers invoking a function until the current call stack has cleared.

Use setTimeout() with a timeout of 1ms to add a new event to the browser event queue and allow the rendering engine to complete its work. Use the spread (...) operator to supply the function with an arbitrary number of arguments.

const defer = (fn, ...args) => setTimeout(fn, 1, ...args);
 
// Example A:
 defer(console.log, 'a'), console.log('b'); // logs 'b' then 'a'

From 6ddb4989a2ea8e89c67ff49aea4868925a87ef0b Mon Sep 17 00:00:00 2001
From: Angelos Chalaris 
Date: Sun, 28 Jan 2018 15:23:01 +0200
Subject: [PATCH 27/33] Add throttle

---
 snippets/throttle.md | 41 +++++++++++++++++++++++++++++++++++++++++
 tag_database         |  1 +
 2 files changed, 42 insertions(+)
 create mode 100644 snippets/throttle.md

diff --git a/snippets/throttle.md b/snippets/throttle.md
new file mode 100644
index 000000000..5e1d01fd7
--- /dev/null
+++ b/snippets/throttle.md
@@ -0,0 +1,41 @@
+### throttle
+
+Creates a throttled function that only invokes the provided function at most once per every `wait` milliseconds
+
+Use `setTimeout()` and `clearTimeout()` to throttle the given method, `fn`.
+Use `Function.apply()` to apply the `this` context to the function and provide the necessary `arguments`.
+Use `Date.now()` to keep track of the last time the throttled function was invoked.
+Omit the second argument, `wait`, to set the timeout at a default of 0 ms.
+
+```js
+const throttle = (fn, wait) => {
+  let inThrottle, lastFn, lastTime;
+  return function() {
+    const context = this,
+      args = arguments;
+    if (!inThrottle) {
+      fn.apply(context, args);
+      lastTime = Date.now();
+      inThrottle = true;
+    } else {
+      clearTimeout(lastFn);
+      lastFn = setTimeout(function() {
+        if (Date.now() - lastTime >= wait) {
+          fn.apply(context, args);
+          lastTime = Date.now();
+        }
+      }, wait - (Date.now() - lastTime));
+    }
+  };
+};
+```
+
+```js
+window.addEventListener(
+  'resize',
+  throttle(function(evt) {
+    console.log(window.innerWidth);
+    console.log(window.innerHeight);
+  }, 250)
+); // Will log the window dimensions at most every 250ms
+```
diff --git a/tag_database b/tag_database
index 6b4c7e9ff..f95213c09 100644
--- a/tag_database
+++ b/tag_database
@@ -232,6 +232,7 @@ take:array
 takeRight:array
 takeRightWhile:array,function
 takeWhile:array,function
+throttle:function
 times:function
 timeTaken:utility
 toCamelCase:string,regexp

From 5358f1b908052c6dda36a2fadd223adc1116bf4c Mon Sep 17 00:00:00 2001
From: 30secondsofcode <30secondsofcode@gmail.com>
Date: Sun, 28 Jan 2018 13:24:21 +0000
Subject: [PATCH 28/33] Travis build: 1473

---
 README.md       | 51 +++++++++++++++++++++++++++++++++++++++++++++++++
 docs/index.html | 29 +++++++++++++++++++++++++++-
 2 files changed, 79 insertions(+), 1 deletion(-)

diff --git a/README.md b/README.md
index 13648d57b..49895db9e 100644
--- a/README.md
+++ b/README.md
@@ -240,6 +240,7 @@ average(1, 2, 3);
 * [`partialRight`](#partialright)
 * [`runPromisesInSeries`](#runpromisesinseries)
 * [`sleep`](#sleep)
+* [`throttle`](#throttle)
 * [`times`](#times)
 * [`unfold`](#unfold)
 
@@ -4047,6 +4048,56 @@ async function sleepyWork() {
 
[⬆ Back to top](#table-of-contents) +### throttle + +Creates a throttled function that only invokes the provided function at most once per every `wait` milliseconds + +Use `setTimeout()` and `clearTimeout()` to throttle the given method, `fn`. +Use `Function.apply()` to apply the `this` context to the function and provide the necessary `arguments`. +Use `Date.now()` to keep track of the last time the throttled function was invoked. +Omit the second argument, `wait`, to set the timeout at a default of 0 ms. + +```js +const throttle = (fn, wait) => { + let inThrottle, lastFn, lastTime; + return function() { + const context = this, + args = arguments; + if (!inThrottle) { + fn.apply(context, args); + lastTime = Date.now(); + inThrottle = true; + } else { + clearTimeout(lastFn); + lastFn = setTimeout(function() { + if (Date.now() - lastTime >= wait) { + fn.apply(context, args); + lastTime = Date.now(); + } + }, wait - (Date.now() - lastTime)); + } + }; +}; +``` + +
+Examples + +```js +window.addEventListener( + 'resize', + throttle(function(evt) { + console.log(window.innerWidth); + console.log(window.innerHeight); + }, 250) +); // Will log the window dimensions at most every 250ms +``` + +
+ +
[⬆ Back to top](#table-of-contents) + + ### times Iterates over a callback `n` times diff --git a/docs/index.html b/docs/index.html index e1f6a069e..a14acc8f7 100644 --- a/docs/index.html +++ b/docs/index.html @@ -50,7 +50,7 @@ scrollToTop(); } }, false); - }

logo 30 seconds of code Curated collection of useful JavaScript snippets that you can understand in 30 seconds or less.

 

Adapter

ary

Creates a function that accepts up to n arguments, ignoring any additional arguments.

Call the provided function, fn, with up to n arguments, using Array.slice(0,n) and the spread operator (...).

const ary = (fn, n) => (...args) => fn(...args.slice(0, n));
+      }

logo 30 seconds of code Curated collection of useful JavaScript snippets that you can understand in 30 seconds or less.

 

Adapter

ary

Creates a function that accepts up to n arguments, ignoring any additional arguments.

Call the provided function, fn, with up to n arguments, using Array.slice(0,n) and the spread operator (...).

const ary = (fn, n) => (...args) => fn(...args.slice(0, n));
 
const firstTwoMax = ary(Math.max, 2);
 [[2, 6, 'a'], [8, 4, 6], [10]].map(x => firstTwoMax(...x)); // [6, 8, 10]
 

call

Given a key and a set of arguments, call them when given a context. Primarily useful in composition.

Use a closure to call a stored key with stored arguments.

const call = (key, ...args) => context => context[key](...args);
@@ -927,6 +927,33 @@ document.bodyawait sleep(1000);
   console.log('I woke up after 1 second.');
 }
+

throttle

Creates a throttled function that only invokes the provided function at most once per every wait milliseconds

Use setTimeout() and clearTimeout() to throttle the given method, fn. Use Function.apply() to apply the this context to the function and provide the necessary arguments. Use Date.now() to keep track of the last time the throttled function was invoked. Omit the second argument, wait, to set the timeout at a default of 0 ms.

const throttle = (fn, wait) => {
+  let inThrottle, lastFn, lastTime;
+  return function() {
+    const context = this,
+      args = arguments;
+    if (!inThrottle) {
+      fn.apply(context, args);
+      lastTime = Date.now();
+      inThrottle = true;
+    } else {
+      clearTimeout(lastFn);
+      lastFn = setTimeout(function() {
+        if (Date.now() - lastTime >= wait) {
+          fn.apply(context, args);
+          lastTime = Date.now();
+        }
+      }, wait - (Date.now() - lastTime));
+    }
+  };
+};
+
window.addEventListener(
+  'resize',
+  throttle(function(evt) {
+    console.log(window.innerWidth);
+    console.log(window.innerHeight);
+  }, 250)
+); // Will log the window dimensions at most every 250ms
 

times

Iterates over a callback n times

Use Function.call() to call fn n times or until it returns false. Omit the last argument, context, to use an undefined object (or the global object in non-strict mode).

const times = (n, fn, context = undefined) => {
   let i = 0;
   while (fn.call(context, i) !== false && ++i < n) {}

From 06d7e0422018215b883f5c8285541199354cf103 Mon Sep 17 00:00:00 2001
From: Angelos Chalaris 
Date: Sun, 28 Jan 2018 16:28:54 +0200
Subject: [PATCH 29/33] Added some tests

---
 snippets/bindAll.md            |   4 +-
 test/anagrams/anagrams.test.js |   4 +-
 test/ary/ary.test.js           |   4 +-
 test/attempt/attempt.js        |   8 +++
 test/attempt/attempt.test.js   |  15 ++++
 test/bind/bind.test.js         |   8 ++-
 test/bindAll/bindAll.js        |   4 +-
 test/bindAll/bindAll.test.js   |  10 ++-
 test/bindKey/bindKey.test.js   |  10 ++-
 test/byteSize/byteSize.test.js |   5 +-
 test/debounce/debounce.js      |  10 +++
 test/debounce/debounce.test.js |  13 ++++
 test/overArgs/overArgs.js      |   2 +
 test/overArgs/overArgs.test.js |  13 ++++
 test/rearg/rearg.js            |   8 +++
 test/rearg/rearg.test.js       |  13 ++++
 test/testlog                   | 125 +++++++++++++++++++++++++++------
 test/throttle/throttle.js      |  21 ++++++
 test/throttle/throttle.test.js |  13 ++++
 19 files changed, 257 insertions(+), 33 deletions(-)
 create mode 100644 test/attempt/attempt.js
 create mode 100644 test/attempt/attempt.test.js
 create mode 100644 test/debounce/debounce.js
 create mode 100644 test/debounce/debounce.test.js
 create mode 100644 test/overArgs/overArgs.js
 create mode 100644 test/overArgs/overArgs.test.js
 create mode 100644 test/rearg/rearg.js
 create mode 100644 test/rearg/rearg.test.js
 create mode 100644 test/throttle/throttle.js
 create mode 100644 test/throttle/throttle.test.js

diff --git a/snippets/bindAll.md b/snippets/bindAll.md
index 26093013c..5a38d2439 100644
--- a/snippets/bindAll.md
+++ b/snippets/bindAll.md
@@ -6,8 +6,8 @@ Use `Array.forEach()` to return a `function` that uses `Function.apply()` to app
 const bindAll = (obj, ...fns) =>
   fns.forEach(
     fn =>
-      (obj[fn] = function() {
-        return fn.apply(obj);
+      (f = obj[fn], obj[fn] = function() {
+        return f.apply(obj);
       })
   );
 ```
diff --git a/test/anagrams/anagrams.test.js b/test/anagrams/anagrams.test.js
index 4318f4c46..a7987d63f 100644
--- a/test/anagrams/anagrams.test.js
+++ b/test/anagrams/anagrams.test.js
@@ -6,9 +6,11 @@ test('Testing anagrams', (t) => {
   //Please go to https://github.com/substack/tape
   t.true(typeof anagrams === 'function', 'anagrams is a Function');
   t.deepEqual(anagrams('abc'), ['abc','acb','bac','bca','cab','cba'], "Generates all anagrams of a string");
+  t.deepEqual(anagrams('a'), ['a'], "Works for single-letter strings");
+  t.deepEqual(anagrams(''), [''], "Works for empty strings");
   //t.deepEqual(anagrams(args..), 'Expected');
   //t.equal(anagrams(args..), 'Expected');
   //t.false(anagrams(args..), 'Expected');
   //t.throws(anagrams(args..), 'Expected');
   t.end();
-});
\ No newline at end of file
+});
diff --git a/test/ary/ary.test.js b/test/ary/ary.test.js
index 445b40618..065b18a96 100644
--- a/test/ary/ary.test.js
+++ b/test/ary/ary.test.js
@@ -5,9 +5,11 @@ test('Testing ary', (t) => {
   //For more information on all the methods supported by tape
   //Please go to https://github.com/substack/tape
   t.true(typeof ary === 'function', 'ary is a Function');
+  const firstTwoMax = ary(Math.max, 2);
+  t.deepEquals([[2, 6, 'a'], [8, 4, 6], [10]].map(x => firstTwoMax(...x)), [6, 8, 10], 'Discards arguments with index >=n')
   //t.deepEqual(ary(args..), 'Expected');
   //t.equal(ary(args..), 'Expected');
   //t.false(ary(args..), 'Expected');
   //t.throws(ary(args..), 'Expected');
   t.end();
-});
\ No newline at end of file
+});
diff --git a/test/attempt/attempt.js b/test/attempt/attempt.js
new file mode 100644
index 000000000..6d079c71e
--- /dev/null
+++ b/test/attempt/attempt.js
@@ -0,0 +1,8 @@
+const attempt = (fn, ...args) => {
+try {
+return fn(args);
+} catch (e) {
+return e instanceof Error ? e : new Error(e);
+}
+};
+module.exports = attempt
\ No newline at end of file
diff --git a/test/attempt/attempt.test.js b/test/attempt/attempt.test.js
new file mode 100644
index 000000000..13ae65686
--- /dev/null
+++ b/test/attempt/attempt.test.js
@@ -0,0 +1,15 @@
+const test = require('tape');
+const attempt = require('./attempt.js');
+
+test('Testing attempt', (t) => {
+  //For more information on all the methods supported by tape
+  //Please go to https://github.com/substack/tape
+  t.true(typeof attempt === 'function', 'attempt is a Function');
+  t.equals(attempt(() => 0), 0, 'Returns a value');
+  t.true(attempt(() => {throw new Error()}) instanceof Error, 'Returns an error');
+  //t.deepEqual(attempt(args..), 'Expected');
+  //t.equal(attempt(args..), 'Expected');
+  //t.false(attempt(args..), 'Expected');
+  //t.throws(attempt(args..), 'Expected');
+  t.end();
+});
diff --git a/test/bind/bind.test.js b/test/bind/bind.test.js
index 6ad403682..e3ba1054c 100644
--- a/test/bind/bind.test.js
+++ b/test/bind/bind.test.js
@@ -5,9 +5,15 @@ test('Testing bind', (t) => {
   //For more information on all the methods supported by tape
   //Please go to https://github.com/substack/tape
   t.true(typeof bind === 'function', 'bind is a Function');
+  function greet(greeting, punctuation) {
+    return greeting + ' ' + this.user + punctuation;
+  }
+  const freddy = { user: 'fred' };
+  const freddyBound = bind(greet, freddy);
+  t.equals(freddyBound('hi', '!'),'hi fred!', 'Binds to an object context');
   //t.deepEqual(bind(args..), 'Expected');
   //t.equal(bind(args..), 'Expected');
   //t.false(bind(args..), 'Expected');
   //t.throws(bind(args..), 'Expected');
   t.end();
-});
\ No newline at end of file
+});
diff --git a/test/bindAll/bindAll.js b/test/bindAll/bindAll.js
index cf66ad583..507a4a9bc 100644
--- a/test/bindAll/bindAll.js
+++ b/test/bindAll/bindAll.js
@@ -1,8 +1,8 @@
 const bindAll = (obj, ...fns) =>
 fns.forEach(
 fn =>
-(obj[fn] = function() {
-return fn.apply(obj);
+(f = obj[fn], obj[fn] = function() {
+return f.apply(obj);
 })
 );
 module.exports = bindAll
\ No newline at end of file
diff --git a/test/bindAll/bindAll.test.js b/test/bindAll/bindAll.test.js
index 513eae230..90c9e23a8 100644
--- a/test/bindAll/bindAll.test.js
+++ b/test/bindAll/bindAll.test.js
@@ -5,9 +5,17 @@ test('Testing bindAll', (t) => {
   //For more information on all the methods supported by tape
   //Please go to https://github.com/substack/tape
   t.true(typeof bindAll === 'function', 'bindAll is a Function');
+  var view = {
+    label: 'docs',
+    'click': function() {
+      return 'clicked ' + this.label;
+    }
+  }
+  bindAll(view, 'click');
+  t.equal(view.click(), 'clicked docs', 'Binds to an object context')
   //t.deepEqual(bindAll(args..), 'Expected');
   //t.equal(bindAll(args..), 'Expected');
   //t.false(bindAll(args..), 'Expected');
   //t.throws(bindAll(args..), 'Expected');
   t.end();
-});
\ No newline at end of file
+});
diff --git a/test/bindKey/bindKey.test.js b/test/bindKey/bindKey.test.js
index 36619ebcd..2aed1fb1e 100644
--- a/test/bindKey/bindKey.test.js
+++ b/test/bindKey/bindKey.test.js
@@ -5,9 +5,17 @@ test('Testing bindKey', (t) => {
   //For more information on all the methods supported by tape
   //Please go to https://github.com/substack/tape
   t.true(typeof bindKey === 'function', 'bindKey is a Function');
+  const freddy = {
+    user: 'fred',
+    greet: function(greeting, punctuation) {
+      return greeting + ' ' + this.user + punctuation;
+    }
+  };
+  const freddyBound = bindKey(freddy, 'greet');
+  t.equal(freddyBound('hi', '!'), 'hi fred!', 'Binds function to an object context');
   //t.deepEqual(bindKey(args..), 'Expected');
   //t.equal(bindKey(args..), 'Expected');
   //t.false(bindKey(args..), 'Expected');
   //t.throws(bindKey(args..), 'Expected');
   t.end();
-});
\ No newline at end of file
+});
diff --git a/test/byteSize/byteSize.test.js b/test/byteSize/byteSize.test.js
index 32718fada..b79b83889 100644
--- a/test/byteSize/byteSize.test.js
+++ b/test/byteSize/byteSize.test.js
@@ -5,6 +5,9 @@ test('Testing byteSize', (t) => {
   //For more information on all the methods supported by tape
   //Please go to https://github.com/substack/tape
   t.true(typeof byteSize === 'function', 'byteSize is a Function');
+  // Blob is not part of Node apparently?
+  //t.equal(byteSize('Hello World'), 11, 'Works for text');
+  //t.equal(byteSize('😀'), 4, 'Works for emojis');
   // Works only in browser
   // t.equal(byteSize('Hello World'), 11, "Returns the length of a string in bytes");
   //t.deepEqual(byteSize(args..), 'Expected');
@@ -12,4 +15,4 @@ test('Testing byteSize', (t) => {
   //t.false(byteSize(args..), 'Expected');
   //t.throws(byteSize(args..), 'Expected');
   t.end();
-});
\ No newline at end of file
+});
diff --git a/test/debounce/debounce.js b/test/debounce/debounce.js
new file mode 100644
index 000000000..430bfeaed
--- /dev/null
+++ b/test/debounce/debounce.js
@@ -0,0 +1,10 @@
+const debounce = (fn, wait = 0) => {
+let inDebounce;
+return function() {
+const context = this,
+args = arguments;
+clearTimeout(inDebounce);
+inDebounce = setTimeout(() => fn.apply(context, args), wait);
+};
+};
+module.exports = debounce
\ No newline at end of file
diff --git a/test/debounce/debounce.test.js b/test/debounce/debounce.test.js
new file mode 100644
index 000000000..f1a35323c
--- /dev/null
+++ b/test/debounce/debounce.test.js
@@ -0,0 +1,13 @@
+const test = require('tape');
+const debounce = require('./debounce.js');
+
+test('Testing debounce', (t) => {
+  //For more information on all the methods supported by tape
+  //Please go to https://github.com/substack/tape
+  t.true(typeof debounce === 'function', 'debounce is a Function');
+  //t.deepEqual(debounce(args..), 'Expected');
+  //t.equal(debounce(args..), 'Expected');
+  //t.false(debounce(args..), 'Expected');
+  //t.throws(debounce(args..), 'Expected');
+  t.end();
+});
\ No newline at end of file
diff --git a/test/overArgs/overArgs.js b/test/overArgs/overArgs.js
new file mode 100644
index 000000000..41250eb89
--- /dev/null
+++ b/test/overArgs/overArgs.js
@@ -0,0 +1,2 @@
+const overArgs = (fn, transforms) => (...args) => fn(...args.map((val, i) => transforms[i](val)));
+module.exports = overArgs
\ No newline at end of file
diff --git a/test/overArgs/overArgs.test.js b/test/overArgs/overArgs.test.js
new file mode 100644
index 000000000..81c194c90
--- /dev/null
+++ b/test/overArgs/overArgs.test.js
@@ -0,0 +1,13 @@
+const test = require('tape');
+const overArgs = require('./overArgs.js');
+
+test('Testing overArgs', (t) => {
+  //For more information on all the methods supported by tape
+  //Please go to https://github.com/substack/tape
+  t.true(typeof overArgs === 'function', 'overArgs is a Function');
+  //t.deepEqual(overArgs(args..), 'Expected');
+  //t.equal(overArgs(args..), 'Expected');
+  //t.false(overArgs(args..), 'Expected');
+  //t.throws(overArgs(args..), 'Expected');
+  t.end();
+});
\ No newline at end of file
diff --git a/test/rearg/rearg.js b/test/rearg/rearg.js
new file mode 100644
index 000000000..b2f97244c
--- /dev/null
+++ b/test/rearg/rearg.js
@@ -0,0 +1,8 @@
+const rearg = (fn, indexes) => (...args) =>
+fn(
+...args.reduce(
+(acc, val, i) => ((acc[indexes.indexOf(i)] = val), acc),
+Array.from({ length: indexes.length })
+)
+);
+module.exports = rearg
\ No newline at end of file
diff --git a/test/rearg/rearg.test.js b/test/rearg/rearg.test.js
new file mode 100644
index 000000000..9139d3f64
--- /dev/null
+++ b/test/rearg/rearg.test.js
@@ -0,0 +1,13 @@
+const test = require('tape');
+const rearg = require('./rearg.js');
+
+test('Testing rearg', (t) => {
+  //For more information on all the methods supported by tape
+  //Please go to https://github.com/substack/tape
+  t.true(typeof rearg === 'function', 'rearg is a Function');
+  //t.deepEqual(rearg(args..), 'Expected');
+  //t.equal(rearg(args..), 'Expected');
+  //t.false(rearg(args..), 'Expected');
+  //t.throws(rearg(args..), 'Expected');
+  t.end();
+});
\ No newline at end of file
diff --git a/test/testlog b/test/testlog
index 56314eed1..9c0f4f3cb 100644
--- a/test/testlog
+++ b/test/testlog
@@ -1,4 +1,4 @@
-Test log for: Sun Jan 28 2018 14:28:04 GMT+0200 (GTB Standard Time)
+Test log for: Sun Jan 28 2018 16:28:45 GMT+0200 (GTB Standard Time)
 
 > 30-seconds-of-code@0.0.1 test G:\My Files\git Repositories\30-seconds-of-code
 > tape test/**/*.test.js | tap-spec
@@ -8,6 +8,8 @@ Test log for: Sun Jan 28 2018 14:28:04 GMT+0200 (GTB Standard Time)
 
     √ anagrams is a Function
     √ Generates all anagrams of a string
+    √ Works for single-letter strings
+    √ Works for empty strings
 
   Testing arrayToHtmlList
 
@@ -17,6 +19,7 @@ Test log for: Sun Jan 28 2018 14:28:04 GMT+0200 (GTB Standard Time)
   Testing ary
 
     √ ary is a Function
+    √ Discards arguments with index >=n
 
   Testing atob
 
@@ -24,6 +27,12 @@ Test log for: Sun Jan 28 2018 14:28:04 GMT+0200 (GTB Standard Time)
     √ atob("Zm9vYmFy") equals "foobar"
     √ atob("Z") returns ""
 
+  Testing attempt
+
+    √ attempt is a Function
+    √ Returns a value
+    √ Returns an error
+
   Testing average
 
     √ average is a Function
@@ -52,14 +61,17 @@ Test log for: Sun Jan 28 2018 14:28:04 GMT+0200 (GTB Standard Time)
   Testing bind
 
     √ bind is a Function
+    √ Binds to an object context
 
   Testing bindAll
 
     √ bindAll is a Function
+    √ Binds to an object context
 
   Testing bindKey
 
     √ bindKey is a Function
+    √ Binds function to an object context
 
   Testing bottomVisible
 
@@ -202,6 +214,10 @@ Test log for: Sun Jan 28 2018 14:28:04 GMT+0200 (GTB Standard Time)
     √ curries a Math.pow
     √ curries a Math.min
 
+  Testing debounce
+
+    √ debounce is a Function
+
   Testing decapitalize
 
     √ decapitalize is a Function
@@ -959,6 +975,10 @@ Test log for: Sun Jan 28 2018 14:28:04 GMT+0200 (GTB Standard Time)
 
     √ over is a Function
 
+  Testing overArgs
+
+    √ overArgs is a Function
+
   Testing palindrome
 
     √ palindrome is a Function
@@ -1082,6 +1102,10 @@ Test log for: Sun Jan 28 2018 14:28:04 GMT+0200 (GTB Standard Time)
 
     √ README is a Function
 
+  Testing rearg
+
+    √ rearg is a Function
+
   Testing redirect
 
     √ redirect is a Function
@@ -1125,7 +1149,16 @@ Test log for: Sun Jan 28 2018 14:28:04 GMT+0200 (GTB Standard Time)
   Testing round
 
     √ round is a Function
-    √ Rounds a number to a specified amount of digits.
+    √ round(1.005, 2) returns 1.01
+    √ round(123.3423345345345345344, 11) returns 123.34233453453
+    √ round(3.342, 11) returns 3.342
+    √ round(1.005) returns 1
+    √ round([1.005, 2]) returns NaN
+    √ round(string) returns NaN
+    √ round() returns NaN
+    √ round(132, 413, 4134) returns NaN
+    √ round({a: 132}, 413) returns NaN
+    √ round(123.3423345345345345344, 11) takes less than 2s to run
 
   Testing runAsync
 
@@ -1295,6 +1328,10 @@ Test log for: Sun Jan 28 2018 14:28:04 GMT+0200 (GTB Standard Time)
 
     √ takeWhile is a Function
 
+  Testing throttle
+
+    √ throttle is a Function
+
   Testing times
 
     √ times is a Function
@@ -1306,10 +1343,15 @@ Test log for: Sun Jan 28 2018 14:28:04 GMT+0200 (GTB Standard Time)
   Testing toCamelCase
 
     √ toCamelCase is a Function
-    √ Converts a string to camelCase
-    √ Converts a string to camelCase
-    √ Converts a string to camelCase
-    √ Converts a string to camelCase
+    √ toCamelCase('some_database_field_name') returns someDatabaseFieldName
+    √ toCamelCase('Some label that needs to be camelized') returns someLabelThatNeedsToBeCamelized
+    √ toCamelCase('some-javascript-property') return someJavascriptProperty
+    √ toCamelCase('some-mixed_string with spaces_underscores-and-hyphens') returns someMixedStringWithSpacesUnderscoresAndHyphens
+    √ toCamelCase() throws a error
+    √ toCamelCase([]) throws a error
+    √ toCamelCase({}) throws a error
+    √ toCamelCase(123) throws a error
+    √ toCamelCase(some-mixed_string with spaces_underscores-and-hyphens) takes less than 2s to run
 
   Testing toDecimalMark
 
@@ -1323,10 +1365,15 @@ Test log for: Sun Jan 28 2018 14:28:04 GMT+0200 (GTB Standard Time)
   Testing toKebabCase
 
     √ toKebabCase is a Function
-    √ string converts to snake case
-    √ string converts to snake case
-    √ string converts to snake case
-    √ string converts to snake case
+    √ toKebabCase('camelCase') returns camel-case
+    √ toKebabCase('some text') returns some-text
+    √ toKebabCase('some-mixed-string With spaces-underscores-and-hyphens') returns some-mixed-string-with-spaces-underscores-and-hyphens
+    √ toKebabCase('IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML') returns i-am-listening-to-fm-while-loading-different-url-on-my-browser-and-also-editing-some-xml-and-html
+    √ toKebabCase() return undefined
+    √ toKebabCase([]) throws an error
+    √ toKebabCase({}) throws an error
+    √ toKebabCase(123) throws an error
+    √ toKebabCase(IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML) takes less than 2s to run
 
   Testing tomorrow
 
@@ -1343,19 +1390,30 @@ Test log for: Sun Jan 28 2018 14:28:04 GMT+0200 (GTB Standard Time)
   Testing toSafeInteger
 
     √ toSafeInteger is a Function
+    √ Number(toSafeInteger(3.2)) is a number
     √ Converts a value to a safe integer
-    √ Converts a value to a safe integer
-    √ Converts a value to a safe integer
-    √ Converts a value to a safe integer
-    √ Converts a value to a safe integer
+    √ toSafeInteger('4.2') returns 4
+    √ toSafeInteger(4.6) returns 5
+    √ toSafeInteger([]) returns 0
+    √ isNaN(toSafeInteger([1.5, 3124])) is true
+    √ isNaN(toSafeInteger('string')) is true
+    √ isNaN(toSafeInteger({})) is true
+    √ isNaN(toSafeInteger()) is true
+    √ toSafeInteger(Infinity) returns 9007199254740991
+    √ toSafeInteger(3.2) takes less than 2s to run
 
   Testing toSnakeCase
 
     √ toSnakeCase is a Function
-    √ string converts to snake case
-    √ string converts to snake case
-    √ string converts to snake case
-    √ string converts to snake case
+    √ toSnakeCase('camelCase') returns camel_case
+    √ toSnakeCase('some text') returns some_text
+    √ toSnakeCase('some-mixed_string With spaces_underscores-and-hyphens') returns some_mixed_string_with_spaces_underscores_and_hyphens
+    √ toSnakeCase('IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML') returns i_am_listening_to_fm_while_loading_different_url_on_my_browser_and_also_editing_some_xml_and_html
+    √ toSnakeCase() returns undefined
+    √ toSnakeCase([]) throws an error
+    √ toSnakeCase({}) throws an error
+    √ toSnakeCase(123) throws an error
+    √ toSnakeCase(IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML) takes less than 2s to run
 
   Testing transform
 
@@ -1387,7 +1445,17 @@ Test log for: Sun Jan 28 2018 14:28:04 GMT+0200 (GTB Standard Time)
   Testing union
 
     √ union is a Function
-    √ Returns every element that exists in any of the two arrays once
+    √ union([1, 2, 3], [4, 3, 2]) returns [1, 2, 3, 4]
+    √ union('str', 'asd') returns [ 's', 't', 'r', 'a', 'd' ]
+    √ union([[], {}], [1, 2, 3]) returns [[], {}, 1, 2, 3]
+    √ union([], []) returns []
+    √ union() throws an error
+    √ union(true, str) throws an error
+    √ union(false, true) throws an error
+    √ union(123, {}) throws an error
+    √ union([], {}) throws an error
+    √ union(undefined, null) throws an error
+    √ union([1, 2, 3], [4, 3, 2]) takes less than 2s to run
 
   Testing unionBy
 
@@ -1400,7 +1468,18 @@ Test log for: Sun Jan 28 2018 14:28:04 GMT+0200 (GTB Standard Time)
   Testing uniqueElements
 
     √ uniqueElements is a Function
-    √ Returns all unique values of an array
+    √ uniqueElements([1, 2, 2, 3, 4, 4, 5]) returns [1,2,3,4,5]
+    √ uniqueElements([1, 23, 53]) returns [1, 23, 53]
+    √ uniqueElements([true, 0, 1, false, false, undefined, null, '']) returns [true, 0, 1, false, false, undefined, null, '']
+    √ uniqueElements() returns []
+    √ uniqueElements(null) returns []
+    √ uniqueElements(undefined) returns []
+    √ uniqueElements('strt') returns ['s', 't', 'r']
+    √ uniqueElements(1, 1, 2543, 534, 5) throws an error
+    √ uniqueElements({}) throws an error
+    √ uniqueElements(true) throws an error
+    √ uniqueElements(false) throws an error
+    √ uniqueElements([true, 0, 1, false, false, undefined, null]) takes less than 2s to run
 
   Testing untildify
 
@@ -1524,8 +1603,8 @@ Test log for: Sun Jan 28 2018 14:28:04 GMT+0200 (GTB Standard Time)
     √ zipWith is a Function
 
 
-  total:     652
-  passing:   652
-  duration:  1.7s
+  total:     716
+  passing:   716
+  duration:  1.1s
 
 
diff --git a/test/throttle/throttle.js b/test/throttle/throttle.js
new file mode 100644
index 000000000..b26b6b74b
--- /dev/null
+++ b/test/throttle/throttle.js
@@ -0,0 +1,21 @@
+const throttle = (fn, wait) => {
+let inThrottle, lastFn, lastTime;
+return function() {
+const context = this,
+args = arguments;
+if (!inThrottle) {
+fn.apply(context, args);
+lastTime = Date.now();
+inThrottle = true;
+} else {
+clearTimeout(lastFn);
+lastFn = setTimeout(function() {
+if (Date.now() - lastTime >= wait) {
+fn.apply(context, args);
+lastTime = Date.now();
+}
+}, wait - (Date.now() - lastTime));
+}
+};
+};
+module.exports = throttle
\ No newline at end of file
diff --git a/test/throttle/throttle.test.js b/test/throttle/throttle.test.js
new file mode 100644
index 000000000..4de75afdb
--- /dev/null
+++ b/test/throttle/throttle.test.js
@@ -0,0 +1,13 @@
+const test = require('tape');
+const throttle = require('./throttle.js');
+
+test('Testing throttle', (t) => {
+  //For more information on all the methods supported by tape
+  //Please go to https://github.com/substack/tape
+  t.true(typeof throttle === 'function', 'throttle is a Function');
+  //t.deepEqual(throttle(args..), 'Expected');
+  //t.equal(throttle(args..), 'Expected');
+  //t.false(throttle(args..), 'Expected');
+  //t.throws(throttle(args..), 'Expected');
+  t.end();
+});
\ No newline at end of file

From f5ac87f242744c3982a06b18746058faca1b2afd Mon Sep 17 00:00:00 2001
From: 30secondsofcode <30secondsofcode@gmail.com>
Date: Sun, 28 Jan 2018 14:30:09 +0000
Subject: [PATCH 30/33] Travis build: 1475

---
 README.md           | 6 ++++--
 docs/index.html     | 8 +++++---
 snippets/bindAll.md | 6 ++++--
 3 files changed, 13 insertions(+), 7 deletions(-)

diff --git a/README.md b/README.md
index 49895db9e..1b93c9293 100644
--- a/README.md
+++ b/README.md
@@ -5319,10 +5319,12 @@ Use `Array.forEach()` to return a `function` that uses `Function.apply()` to app
 ```js
 const bindAll = (obj, ...fns) =>
   fns.forEach(
-    fn =>
+    fn => (
+      (f = obj[fn]),
       (obj[fn] = function() {
-        return fn.apply(obj);
+        return f.apply(obj);
       })
+    )
   );
 ```
 
diff --git a/docs/index.html b/docs/index.html
index a14acc8f7..1abfa80f7 100644
--- a/docs/index.html
+++ b/docs/index.html
@@ -1225,10 +1225,12 @@ console.log<
 
UUIDGeneratorNode(); // '79c7c136-60ee-40a2-beb2-856f1feabefc'
 

Object

bindAll

Use Array.forEach() to return a function that uses Function.apply() to apply the given context (obj) to fn for each function specified.

const bindAll = (obj, ...fns) =>
   fns.forEach(
-    fn =>
-      (obj[fn] = function() {
-        return fn.apply(obj);
+    fn => (
+      (f = obj[fn]),
+      (obj[fn] = function() {
+        return f.apply(obj);
       })
+    )
   );
 
var view = {
   label: 'docs',
diff --git a/snippets/bindAll.md b/snippets/bindAll.md
index 5a38d2439..da869957f 100644
--- a/snippets/bindAll.md
+++ b/snippets/bindAll.md
@@ -5,10 +5,12 @@ Use `Array.forEach()` to return a `function` that uses `Function.apply()` to app
 ```js
 const bindAll = (obj, ...fns) =>
   fns.forEach(
-    fn =>
-      (f = obj[fn], obj[fn] = function() {
+    fn => (
+      (f = obj[fn]),
+      (obj[fn] = function() {
         return f.apply(obj);
       })
+    )
   );
 ```
 

From 10d2de5fabb5ac077854a4cf3726c14f954cd24a Mon Sep 17 00:00:00 2001
From: Angelos Chalaris 
Date: Sun, 28 Jan 2018 16:41:20 +0200
Subject: [PATCH 31/33] Added some tests

---
 snippets/collectInto.md                |  2 +-
 test/collectInto/collectInto.test.js   |  7 ++++++-
 test/countBy/countBy.test.js           |  4 +++-
 test/decapitalize/decapitalize.test.js |  4 +++-
 test/testlog                           | 13 +++++++++----
 5 files changed, 22 insertions(+), 8 deletions(-)

diff --git a/snippets/collectInto.md b/snippets/collectInto.md
index 3da1173bd..da37626a2 100644
--- a/snippets/collectInto.md
+++ b/snippets/collectInto.md
@@ -13,5 +13,5 @@ const Pall = collectInto(Promise.all.bind(Promise));
 let p1 = Promise.resolve(1);
 let p2 = Promise.resolve(2);
 let p3 = new Promise(resolve => setTimeout(resolve, 2000, 3));
-Pall(p1, p2, p3).then(console.log);
+Pall(p1, p2, p3).then(console.log); // [1, 2, 3] (after about 2 seconds)
 ```
diff --git a/test/collectInto/collectInto.test.js b/test/collectInto/collectInto.test.js
index a3d303e5a..557134336 100644
--- a/test/collectInto/collectInto.test.js
+++ b/test/collectInto/collectInto.test.js
@@ -5,9 +5,14 @@ test('Testing collectInto', (t) => {
   //For more information on all the methods supported by tape
   //Please go to https://github.com/substack/tape
   t.true(typeof collectInto === 'function', 'collectInto is a Function');
+  const Pall = collectInto(Promise.all.bind(Promise));
+  let p1 = Promise.resolve(1);
+  let p2 = Promise.resolve(2);
+  let p3 = new Promise(resolve => setTimeout(resolve, 2000, 3));
+  Pall(p1, p2, p3).then(function(val){ t.deepEqual(val, [1,2,3], 'Works with multiple promises')}, function(reason){});
   //t.deepEqual(collectInto(args..), 'Expected');
   //t.equal(collectInto(args..), 'Expected');
   //t.false(collectInto(args..), 'Expected');
   //t.throws(collectInto(args..), 'Expected');
   t.end();
-});
\ No newline at end of file
+});
diff --git a/test/countBy/countBy.test.js b/test/countBy/countBy.test.js
index ea6c3b748..94296d017 100644
--- a/test/countBy/countBy.test.js
+++ b/test/countBy/countBy.test.js
@@ -5,9 +5,11 @@ test('Testing countBy', (t) => {
   //For more information on all the methods supported by tape
   //Please go to https://github.com/substack/tape
   t.true(typeof countBy === 'function', 'countBy is a Function');
+  t.deepEqual(countBy([6.1, 4.2, 6.3], Math.floor), {4: 1, 6: 2}, 'Works for functions');
+  t.deepEqual(countBy(['one', 'two', 'three'], 'length'), {3: 2, 5: 1}, 'Works for property names');
   //t.deepEqual(countBy(args..), 'Expected');
   //t.equal(countBy(args..), 'Expected');
   //t.false(countBy(args..), 'Expected');
   //t.throws(countBy(args..), 'Expected');
   t.end();
-});
\ No newline at end of file
+});
diff --git a/test/decapitalize/decapitalize.test.js b/test/decapitalize/decapitalize.test.js
index c18264447..83bf6b32a 100644
--- a/test/decapitalize/decapitalize.test.js
+++ b/test/decapitalize/decapitalize.test.js
@@ -5,9 +5,11 @@ test('Testing decapitalize', (t) => {
   //For more information on all the methods supported by tape
   //Please go to https://github.com/substack/tape
   t.true(typeof decapitalize === 'function', 'decapitalize is a Function');
+  t.equal(decapitalize('FooBar'), 'fooBar', 'Works with default parameter');
+  t.equal(decapitalize('FooBar', true), 'fOOBAR', 'Works with second parameter set to true');
   //t.deepEqual(decapitalize(args..), 'Expected');
   //t.equal(decapitalize(args..), 'Expected');
   //t.false(decapitalize(args..), 'Expected');
   //t.throws(decapitalize(args..), 'Expected');
   t.end();
-});
\ No newline at end of file
+});
diff --git a/test/testlog b/test/testlog
index 9c0f4f3cb..34922d51d 100644
--- a/test/testlog
+++ b/test/testlog
@@ -1,4 +1,4 @@
-Test log for: Sun Jan 28 2018 16:28:45 GMT+0200 (GTB Standard Time)
+Test log for: Sun Jan 28 2018 16:40:59 GMT+0200 (GTB Standard Time)
 
 > 30-seconds-of-code@0.0.1 test G:\My Files\git Repositories\30-seconds-of-code
 > tape test/**/*.test.js | tap-spec
@@ -186,6 +186,8 @@ Test log for: Sun Jan 28 2018 16:28:45 GMT+0200 (GTB Standard Time)
   Testing countBy
 
     √ countBy is a Function
+    √ Works for functions
+    √ Works for property names
 
   Testing countOccurrences
 
@@ -221,6 +223,8 @@ Test log for: Sun Jan 28 2018 16:28:45 GMT+0200 (GTB Standard Time)
   Testing decapitalize
 
     √ decapitalize is a Function
+    √ Works with default parameter
+    √ Works with second parameter set to true
 
   Testing deepClone
 
@@ -1601,10 +1605,11 @@ Test log for: Sun Jan 28 2018 16:28:45 GMT+0200 (GTB Standard Time)
   Testing zipWith
 
     √ zipWith is a Function
+    √ Works with multiple promises
 
 
-  total:     716
-  passing:   716
-  duration:  1.1s
+  total:     721
+  passing:   721
+  duration:  3.1s
 
 

From d2703a72b0326301a8ed907b6048b239824604f7 Mon Sep 17 00:00:00 2001
From: 30secondsofcode <30secondsofcode@gmail.com>
Date: Sun, 28 Jan 2018 14:42:38 +0000
Subject: [PATCH 32/33] Travis build: 1477

---
 README.md       | 2 +-
 docs/index.html | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/README.md b/README.md
index 1b93c9293..923e59745 100644
--- a/README.md
+++ b/README.md
@@ -501,7 +501,7 @@ const Pall = collectInto(Promise.all.bind(Promise));
 let p1 = Promise.resolve(1);
 let p2 = Promise.resolve(2);
 let p3 = new Promise(resolve => setTimeout(resolve, 2000, 3));
-Pall(p1, p2, p3).then(console.log);
+Pall(p1, p2, p3).then(console.log); // [1, 2, 3] (after about 2 seconds)
 ```
 
 
diff --git a/docs/index.html b/docs/index.html index 1abfa80f7..366cc80a2 100644 --- a/docs/index.html +++ b/docs/index.html @@ -66,7 +66,7 @@ Promise.reso let p1 = Promise.resolve(1); let p2 = Promise.resolve(2); let p3 = new Promise(resolve => setTimeout(resolve, 2000, 3)); -Pall(p1, p2, p3).then(console.log); +Pall(p1, p2, p3).then(console.log); // [1, 2, 3] (after about 2 seconds)

flip

Flip takes a function as an argument, then makes the first argument the last.

Return a closure that takes variadic inputs, and splices the last argument to make it the first argument before applying the rest.

const flip = fn => (first, ...rest) => fn(...rest, first);
 
let a = { name: 'John Smith' };
 let b = {};

From acba8af5f4934363bc7f228e665526c6af7b6aca Mon Sep 17 00:00:00 2001
From: King David Martins 
Date: Sun, 28 Jan 2018 14:48:10 -0500
Subject: [PATCH 33/33] Update CONTRIBUTING.md

Fix typo

Replace `npm run tdd` with `npm run tester`
---
 CONTRIBUTING.md | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md
index 026cf9b05..a44c16ba7 100644
--- a/CONTRIBUTING.md
+++ b/CONTRIBUTING.md
@@ -38,7 +38,7 @@ Here's what you can do to help:
 - You can start creating a new snippet, by using the [snippet template](snippet-template.md) to format your snippets.
 
 ### Writing tests
-- Before writing any tests run `npm run tdd` script. It will update test directory to include new snippets as well as update old ones if needed.
+- Before writing any tests run `npm run tester` script. It will update test directory to include new snippets as well as update old ones if needed.
 - **DO NOT MODIFY THE snippetName.js files** under test directory.
 - We are using [tape](https://github.com/substack/tape) for testing.
 - Write tests under `snippetName.test.js` file. If you have trouble doing so, check out tests of other snippets.