From f71c0ca2285b9e7230fa7858bde2dc754a1aff71 Mon Sep 17 00:00:00 2001 From: Felix Wu Date: Fri, 14 Sep 2018 12:49:36 +0200 Subject: [PATCH 01/15] add markdown-builder --- package-lock.json | 260 ++++++++++++++++++++++++++++++++++++---------- package.json | 4 +- 2 files changed, 211 insertions(+), 53 deletions(-) diff --git a/package-lock.json b/package-lock.json index 7dda8bc10..cde2cebe0 100644 --- a/package-lock.json +++ b/package-lock.json @@ -207,7 +207,6 @@ "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", - "dev": true, "requires": { "sprintf-js": "1.0.3" } @@ -1534,8 +1533,7 @@ "builtin-modules": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", - "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=", - "dev": true + "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=" }, "cache-base": { "version": "1.0.1", @@ -1894,6 +1892,27 @@ "integrity": "sha1-tf1UIgqivFq1eqtxQMlAdUUDwac=", "dev": true }, + "cosmiconfig": { + "version": "5.0.6", + "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-5.0.6.tgz", + "integrity": "sha512-6DWfizHriCrFWURP1/qyhsiFvYdlJzbCzmtFWh744+KyWsJo5+kPzUZZaMRSSItoYc0pxFX7gEO7ZC1/gN/7AQ==", + "requires": { + "is-directory": "0.3.1", + "js-yaml": "3.12.0", + "parse-json": "4.0.0" + }, + "dependencies": { + "parse-json": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-4.0.0.tgz", + "integrity": "sha1-vjX1Qlvh9/bHRxhPmKeIy5lHfuA=", + "requires": { + "error-ex": "1.3.1", + "json-parse-better-errors": "1.0.2" + } + } + } + }, "cross-spawn": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-3.0.1.tgz", @@ -2204,7 +2223,6 @@ "version": "1.3.1", "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.1.tgz", "integrity": "sha1-+FWobOYa3E6GIcPNoh56dhLDqNw=", - "dev": true, "requires": { "is-arrayish": "0.2.1" } @@ -2558,8 +2576,7 @@ "esprima": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz", - "integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw==", - "dev": true + "integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw==" }, "esquery": { "version": "1.0.1", @@ -3681,14 +3698,12 @@ "get-stdin": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-6.0.0.tgz", - "integrity": "sha512-jp4tHawyV7+fkkSKyvjuLZswblUtz+SQKzSWnBbii16BuZksJlU1wuBYXY75r+duh/llF1ur6oNwi+2ZzjKZ7g==", - "dev": true + "integrity": "sha512-jp4tHawyV7+fkkSKyvjuLZswblUtz+SQKzSWnBbii16BuZksJlU1wuBYXY75r+duh/llF1ur6oNwi+2ZzjKZ7g==" }, "get-stream": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", - "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=", - "dev": true + "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=" }, "get-value": { "version": "2.0.6", @@ -4009,8 +4024,7 @@ "hosted-git-info": { "version": "2.6.0", "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.6.0.tgz", - "integrity": "sha512-lIbgIIQA3lz5XaB6vxakj6sDHADJiZadYEJB+FgA+C4nubM1NwcuvUr9EJPmnH1skZqpqUzWborWo8EIUi0Sdw==", - "dev": true + "integrity": "sha512-lIbgIIQA3lz5XaB6vxakj6sDHADJiZadYEJB+FgA+C4nubM1NwcuvUr9EJPmnH1skZqpqUzWborWo8EIUi0Sdw==" }, "html-encoding-sniffer": { "version": "1.0.2", @@ -4047,6 +4061,142 @@ "sshpk": "1.14.1" } }, + "husky": { + "version": "1.0.0-rc.14", + "resolved": "https://registry.npmjs.org/husky/-/husky-1.0.0-rc.14.tgz", + "integrity": "sha512-lxdl0+FrKhRXvhOW978oCHCiaXQAtwoR0hdaPY1CwKd+dgbtktepEvk/3DXwQ7L1YriuG/9HDc4AHlzQ0T6cNw==", + "requires": { + "cosmiconfig": "5.0.6", + "execa": "0.9.0", + "find-up": "3.0.0", + "get-stdin": "6.0.0", + "is-ci": "1.2.1", + "pkg-dir": "3.0.0", + "please-upgrade-node": "3.1.1", + "read-pkg": "4.0.1", + "run-node": "1.0.0", + "slash": "2.0.0" + }, + "dependencies": { + "ci-info": { + "version": "1.5.1", + "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-1.5.1.tgz", + "integrity": "sha512-fKFIKXaYiL1exImwJ0AhR/6jxFPSKQBk2ayV5NiNoruUs2+rxC2kNw0EG+1Z9dugZRdCrppskQ8DN2cyaUM1Hw==" + }, + "cross-spawn": { + "version": "5.1.0", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-5.1.0.tgz", + "integrity": "sha1-6L0O/uWPz/b4+UUQoKVUu/ojVEk=", + "requires": { + "lru-cache": "4.1.2", + "shebang-command": "1.2.0", + "which": "1.3.0" + } + }, + "execa": { + "version": "0.9.0", + "resolved": "https://registry.npmjs.org/execa/-/execa-0.9.0.tgz", + "integrity": "sha512-BbUMBiX4hqiHZUA5+JujIjNb6TyAlp2D5KLheMjMluwOuzcnylDL4AxZYLLn1n2AGB49eSWwyKvvEQoRpnAtmA==", + "requires": { + "cross-spawn": "5.1.0", + "get-stream": "3.0.0", + "is-stream": "1.1.0", + "npm-run-path": "2.0.2", + "p-finally": "1.0.0", + "signal-exit": "3.0.2", + "strip-eof": "1.0.0" + } + }, + "find-up": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", + "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", + "requires": { + "locate-path": "3.0.0" + } + }, + "is-ci": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/is-ci/-/is-ci-1.2.1.tgz", + "integrity": "sha512-s6tfsaQaQi3JNciBH6shVqEDvhGut0SUXr31ag8Pd8BBbVVlcGfWhpPmEOoM6RJ5TFhbypvf5yyRw/VXW1IiWg==", + "requires": { + "ci-info": "1.5.1" + } + }, + "locate-path": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", + "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", + "requires": { + "p-locate": "3.0.0", + "path-exists": "3.0.0" + } + }, + "p-limit": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.0.0.tgz", + "integrity": "sha512-fl5s52lI5ahKCernzzIyAP0QAZbGIovtVHGwpcu1Jr/EpzLVDI2myISHwGqK7m8uQFugVWSrbxH7XnhGtvEc+A==", + "requires": { + "p-try": "2.0.0" + } + }, + "p-locate": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", + "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", + "requires": { + "p-limit": "2.0.0" + } + }, + "p-try": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.0.0.tgz", + "integrity": "sha512-hMp0onDKIajHfIkdRk3P4CdCmErkYAxxDtP3Wx/4nZ3aGlau2VKh3mZpcuFkH27WQkL/3WBCPOktzA9ZOAnMQQ==" + }, + "parse-json": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-4.0.0.tgz", + "integrity": "sha1-vjX1Qlvh9/bHRxhPmKeIy5lHfuA=", + "requires": { + "error-ex": "1.3.1", + "json-parse-better-errors": "1.0.2" + } + }, + "path-exists": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", + "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=" + }, + "pify": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", + "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=" + }, + "pkg-dir": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-3.0.0.tgz", + "integrity": "sha512-/E57AYkoeQ25qkxMj5PBOVgF8Kiu/h7cYS30Z5+R7WaiCCBfLq58ZI/dSeaEKb9WVJV5n/03QwrN3IeWIFllvw==", + "requires": { + "find-up": "3.0.0" + } + }, + "read-pkg": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-4.0.1.tgz", + "integrity": "sha1-ljYlN48+HE1IyFhytabsfV0JMjc=", + "requires": { + "normalize-package-data": "2.4.0", + "parse-json": "4.0.0", + "pify": "3.0.0" + } + }, + "slash": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/slash/-/slash-2.0.0.tgz", + "integrity": "sha512-ZYKh3Wh2z1PpEXWr0MpSBZ0V6mZHAQfYevttO11c51CaWjGTaadiKZ+wVt1PbMlDV5qhMFslpZCemhwOK7C89A==" + } + } + }, "iconv-lite": { "version": "0.4.19", "resolved": "https://registry.npmjs.org/iconv-lite/-/iconv-lite-0.4.19.tgz", @@ -4181,8 +4331,7 @@ "is-arrayish": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", - "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=", - "dev": true + "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=" }, "is-buffer": { "version": "1.1.6", @@ -4194,7 +4343,6 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-1.0.0.tgz", "integrity": "sha1-VAVy0096wxGfj3bDDLwbHgN6/74=", - "dev": true, "requires": { "builtin-modules": "1.1.1" } @@ -4248,6 +4396,11 @@ } } }, + "is-directory": { + "version": "0.3.1", + "resolved": "https://registry.npmjs.org/is-directory/-/is-directory-0.3.1.tgz", + "integrity": "sha1-YTObbyR1/Hcv2cnYP1yFddwVSuE=" + }, "is-dotfile": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/is-dotfile/-/is-dotfile-1.0.3.tgz", @@ -4425,8 +4578,7 @@ "is-stream": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", - "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=", - "dev": true + "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=" }, "is-symbol": { "version": "1.0.1", @@ -4461,8 +4613,7 @@ "isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", - "dev": true + "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=" }, "isobject": { "version": "3.0.1", @@ -5208,7 +5359,6 @@ "version": "3.12.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.12.0.tgz", "integrity": "sha512-PIt2cnwmPfL4hKNwqeiuz4bKfnzHTBv6HyVgjahA6mPLwPDzjDWrplJBMjHUFxku/N3FlmrbyPclad+I+4mJ3A==", - "dev": true, "requires": { "argparse": "1.0.10", "esprima": "4.0.0" @@ -5264,8 +5414,7 @@ "json-parse-better-errors": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz", - "integrity": "sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw==", - "dev": true + "integrity": "sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw==" }, "json-schema": { "version": "0.2.3", @@ -5502,7 +5651,6 @@ "version": "4.1.2", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.2.tgz", "integrity": "sha512-wgeVXhrDwAWnIF/yZARsFnMBtdFXOg1b8RIrhilp+0iDYN4mdQcNZElDZ0e4B64BhaxeQ5zN7PMyvu7we1kPeQ==", - "dev": true, "requires": { "pseudomap": "1.0.2", "yallist": "2.1.2" @@ -5547,6 +5695,14 @@ "object-visit": "1.0.1" } }, + "markdown-builder": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/markdown-builder/-/markdown-builder-0.8.1.tgz", + "integrity": "sha512-zqOAYg8jqUM6gB4WkcJ/K5HkqPUL33VAqNrebHSxlkXcEcjDTeKMNqUC8/bND4tKRu72lRFrTmmGYRtlevvXZQ==", + "requires": { + "husky": "1.0.0-rc.14" + } + }, "markdown-it": { "version": "8.4.1", "resolved": "https://registry.npmjs.org/markdown-it/-/markdown-it-8.4.1.tgz", @@ -6077,7 +6233,6 @@ "version": "2.4.0", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz", "integrity": "sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw==", - "dev": true, "requires": { "hosted-git-info": "2.6.0", "is-builtin-module": "1.0.0", @@ -6098,7 +6253,6 @@ "version": "2.0.2", "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz", "integrity": "sha1-NakjLfo11wZ7TLLd8jV7GHFTbF8=", - "dev": true, "requires": { "path-key": "2.0.1" } @@ -6304,8 +6458,7 @@ "p-finally": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz", - "integrity": "sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4=", - "dev": true + "integrity": "sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4=" }, "p-limit": { "version": "1.3.0", @@ -6397,8 +6550,7 @@ "path-key": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", - "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=", - "dev": true + "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=" }, "path-parse": { "version": "1.0.5", @@ -6524,6 +6676,14 @@ } } }, + "please-upgrade-node": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/please-upgrade-node/-/please-upgrade-node-3.1.1.tgz", + "integrity": "sha512-KY1uHnQ2NlQHqIJQpnh/i54rKkuxCEBx+voJIS/Mvb+L2iYd2NMotwduhKTMjfC1uKoX3VXOxLjIYG66dfJTVQ==", + "requires": { + "semver-compare": "1.0.0" + } + }, "pluralize": { "version": "7.0.0", "resolved": "https://registry.npmjs.org/pluralize/-/pluralize-7.0.0.tgz", @@ -6637,8 +6797,7 @@ "pseudomap": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz", - "integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM=", - "dev": true + "integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM=" }, "punycode": { "version": "2.1.0", @@ -7076,6 +7235,11 @@ "is-promise": "2.1.0" } }, + "run-node": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/run-node/-/run-node-1.0.0.tgz", + "integrity": "sha512-kc120TBlQ3mih1LSzdAJXo4xn/GWS2ec0l3S+syHDXP9uRr0JAT8Qd3mdMuyjqCzeZktgP3try92cEgf9Nks8A==" + }, "run-parallel": { "version": "1.1.9", "resolved": "https://registry.npmjs.org/run-parallel/-/run-parallel-1.1.9.tgz", @@ -7225,8 +7389,12 @@ "semver": { "version": "5.4.1", "resolved": "https://registry.npmjs.org/semver/-/semver-5.4.1.tgz", - "integrity": "sha512-WfG/X9+oATh81XtllIo/I8gOiY9EXRdv1cQdyykeXK17YcUW3EXUAi2To4pcH6nZtJPr7ZOpM5OMyWJZm+8Rsg==", - "dev": true + "integrity": "sha512-WfG/X9+oATh81XtllIo/I8gOiY9EXRdv1cQdyykeXK17YcUW3EXUAi2To4pcH6nZtJPr7ZOpM5OMyWJZm+8Rsg==" + }, + "semver-compare": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/semver-compare/-/semver-compare-1.0.0.tgz", + "integrity": "sha1-De4hahyUGrN+nvsXiPavxf9VN/w=" }, "set-blocking": { "version": "2.0.0", @@ -7267,7 +7435,6 @@ "version": "1.2.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", - "dev": true, "requires": { "shebang-regex": "1.0.0" } @@ -7275,8 +7442,7 @@ "shebang-regex": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", - "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=", - "dev": true + "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=" }, "shellwords": { "version": "0.1.1", @@ -7287,8 +7453,7 @@ "signal-exit": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", - "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", - "dev": true + "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=" }, "slash": { "version": "1.0.0", @@ -7463,7 +7628,6 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.0.0.tgz", "integrity": "sha512-N19o9z5cEyc8yQQPukRCZ9EUmb4HUpnrmaL/fxS2pBo2jbfcFRVuFZ/oFC+vZz0MNNk0h80iMn5/S6qGZOL5+g==", - "dev": true, "requires": { "spdx-expression-parse": "3.0.0", "spdx-license-ids": "3.0.0" @@ -7472,14 +7636,12 @@ "spdx-exceptions": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.1.0.tgz", - "integrity": "sha512-4K1NsmrlCU1JJgUrtgEeTVyfx8VaYea9J9LvARxhbHtVtohPs/gFGG5yy49beySjlIMhhXZ4QqujIZEfS4l6Cg==", - "dev": true + "integrity": "sha512-4K1NsmrlCU1JJgUrtgEeTVyfx8VaYea9J9LvARxhbHtVtohPs/gFGG5yy49beySjlIMhhXZ4QqujIZEfS4l6Cg==" }, "spdx-expression-parse": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz", "integrity": "sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg==", - "dev": true, "requires": { "spdx-exceptions": "2.1.0", "spdx-license-ids": "3.0.0" @@ -7488,8 +7650,7 @@ "spdx-license-ids": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.0.tgz", - "integrity": "sha512-2+EPwgbnmOIl8HjGBXXMd9NAu02vLjOO1nWw4kmeRDFyHn+M/ETfHxQUK0oXg8ctgVnl9t3rosNVsZ1jG61nDA==", - "dev": true + "integrity": "sha512-2+EPwgbnmOIl8HjGBXXMd9NAu02vLjOO1nWw4kmeRDFyHn+M/ETfHxQUK0oXg8ctgVnl9t3rosNVsZ1jG61nDA==" }, "split-string": { "version": "3.1.0", @@ -7503,8 +7664,7 @@ "sprintf-js": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", - "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", - "dev": true + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=" }, "sshpk": { "version": "1.14.1", @@ -7685,8 +7845,7 @@ "strip-eof": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", - "integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8=", - "dev": true + "integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8=" }, "strip-indent": { "version": "1.0.1", @@ -8145,7 +8304,6 @@ "version": "3.0.3", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.3.tgz", "integrity": "sha512-63ZOUnL4SIXj4L0NixR3L1lcjO38crAbgrTpl28t8jjrfuiOBL5Iygm+60qPs/KsZGzPNg6Smnc/oY16QTjF0g==", - "dev": true, "requires": { "spdx-correct": "3.0.0", "spdx-expression-parse": "3.0.0" @@ -8238,7 +8396,6 @@ "version": "1.3.0", "resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz", "integrity": "sha512-xcJpopdamTuY5duC/KnTTNBraPK54YwpenP4lzxU8H91GudWpFv38u0CKjclE1Wi2EH2EDz5LRcHcKbCIzqGyg==", - "dev": true, "requires": { "isexe": "2.0.0" } @@ -8382,8 +8539,7 @@ "yallist": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", - "integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=", - "dev": true + "integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=" }, "yargs": { "version": "7.1.0", diff --git a/package.json b/package.json index 791b4c204..2952c6c1f 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,9 @@ "url": "https://github.com/Chalarangelo/30-seconds-of-code/issues" }, "homepage": "https://github.com/Chalarangelo/30-seconds-of-code#readme", - "dependencies": {}, + "dependencies": { + "markdown-builder": "^0.8.1" + }, "jest": { "reporters": [ [ From c9663c376fe2782be6e2e90253a6466304ae512a Mon Sep 17 00:00:00 2001 From: Felix Wu Date: Fri, 14 Sep 2018 12:49:48 +0200 Subject: [PATCH 02/15] generate TOC with markdown-builder --- scripts/build.js | 94 +++++++++++++++++++++++++++++++++--------------- 1 file changed, 65 insertions(+), 29 deletions(-) diff --git a/scripts/build.js b/scripts/build.js index a85f4fcb8..d314e5729 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -7,21 +7,36 @@ const fs = require('fs-extra'); const path = require('path'); const chalk = require('chalk'); const util = require('./util'); +const markdown = require('markdown-builder'); +const { headers, misc, lists } = markdown; + // Paths const SNIPPETS_PATH = './snippets'; const SNIPPETS_ARCHIVE_PATH = './snippets_archive'; const STATIC_PARTS_PATH = './static-parts'; -if (util.isTravisCI() && /^Travis build: \d+/g.test(process.env['TRAVIS_COMMIT_MESSAGE'])) { + +if ( + util.isTravisCI() && + /^Travis build: \d+/g.test(process.env['TRAVIS_COMMIT_MESSAGE']) +) { console.log( - `${chalk.green('NOBUILD')} README build terminated, parent commit is a Travis build!` + `${chalk.green( + 'NOBUILD' + )} README build terminated, parent commit is a Travis build!` ); process.exit(0); } if ( - util.isTravisCI() && - (process.env['TRAVIS_EVENT_TYPE'] === 'cron' || process.env['TRAVIS_EVENT_TYPE'] === 'api') + // util.isTravisCI() && + // (process.env['TRAVIS_EVENT_TYPE'] === 'cron' || + // process.env['TRAVIS_EVENT_TYPE'] === 'api') + true ) { - console.log(`${chalk.green('ARCHIVE')} Cron job or custom build, building archive README!`); + console.log( + `${chalk.green( + 'ARCHIVE' + )} Cron job or custom build, building archive README!` + ); console.time('Builder'); let snippets = {}; // Synchronously read all snippets from snippets_archive folder and sort them as necessary (case-insensitive) @@ -31,7 +46,10 @@ if ( .sort((a, b) => a.toLowerCase() - b.toLowerCase()); // Store the data read from each snippet in the appropriate object for (const name of snippetFilenames.filter(s => s !== 'README.md')) { - snippets[name] = fs.readFileSync(path.join(SNIPPETS_ARCHIVE_PATH, name), 'utf8'); + snippets[name] = fs.readFileSync( + path.join(SNIPPETS_ARCHIVE_PATH, name), + 'utf8' + ); } } catch (err) { console.log(`${chalk.red('ERROR!')} During snippet loading: ${err}`); @@ -39,37 +57,43 @@ if ( } try { // Add the start static part - let output = `![Logo](/logo.png) + let output = + misc.image('Logo', '/logo.png') + + headers.h1('Snippets Archive') + + "These snippets, while useful and interesting, didn't quite make it into the repository due to either having very specific use-cases or being outdated. However we felt like they might still be useful to some readers, so here they are." + + headers.h2('Table of Contents'); -# Snippets Archive + output += lists.ul(Object.entries(snippets), snippet => + misc.link(`\`${snippet[0].slice(0, -3)}\``, misc.anchor(snippet[0].slice(0, -3))) + ); + output += misc.hr(); -These snippets, while useful and interesting, didn\'t quite make it into the repository due to either having very specific use-cases or being outdated. However we felt like they might still be useful to some readers, so here they are. - -## Table of Contents - -`; - for (const snippet of Object.entries(snippets)) - output += `* [\`${snippet[0].slice(0, -3)}\`](#${snippet[0].toLowerCase().slice(0, -3)})\n`; - output += '\n---\n'; for (const snippet of Object.entries(snippets)) { let data = snippet[1]; data = - data.slice(0, data.lastIndexOf('```js')) + - '
\nExamples\n\n' + - data.slice(data.lastIndexOf('```js'), data.lastIndexOf('```')) + - data.slice(data.lastIndexOf('```')) + - '\n
\n'; - output += `\n${data + '\n
[⬆ Back to top](#table-of-contents)\n\n'}`; + data.slice(0, data.lastIndexOf('```js')).trim() + + misc.collapsible( + 'Examples', + '\n' + data.slice(data.lastIndexOf('```js'), data.lastIndexOf('```')) + + data.slice(data.lastIndexOf('```')) + ); + output += data + '\n' + misc.link('⬆ Back to top', misc.anchor('Table of Contents')) + '\n\n'; } // Write to the README file of the archive fs.writeFileSync(path.join(SNIPPETS_ARCHIVE_PATH, 'README.md'), output); } catch (err) { - console.log(`${chalk.red('ERROR!')} During README generation for snippets archive: ${err}`); + console.log( + `${chalk.red( + 'ERROR!' + )} During README generation for snippets archive: ${err}` + ); process.exit(1); } - console.log(`${chalk.green('SUCCESS!')} README file generated for snippets archive!`); + console.log( + `${chalk.green('SUCCESS!')} README file generated for snippets archive!` + ); console.timeEnd('Builder'); } let snippets = {}; @@ -101,8 +125,14 @@ snippets = util.readSnippets(SNIPPETS_PATH); // Load static parts for the README file try { - startPart = fs.readFileSync(path.join(STATIC_PARTS_PATH, 'README-start.md'), 'utf8'); - endPart = fs.readFileSync(path.join(STATIC_PARTS_PATH, 'README-end.md'), 'utf8'); + startPart = fs.readFileSync( + path.join(STATIC_PARTS_PATH, 'README-start.md'), + 'utf8' + ); + endPart = fs.readFileSync( + path.join(STATIC_PARTS_PATH, 'README-end.md'), + 'utf8' + ); } catch (err) { console.log(`${chalk.red('ERROR!')} During static part loading: ${err}`); process.exit(1); @@ -139,8 +169,12 @@ try { const capitalizedTag = util.capitalize(tag, true); output += `### ${EMOJIS[tag] || ''} ${capitalizedTag}\n\n
\nView contents\n\n`; - for (const taggedSnippet of Object.entries(tagDbData).filter(v => v[1][0] === tag)) { - output += `* [\`${taggedSnippet[0]}\`](#${taggedSnippet[0].toLowerCase()}${ + for (const taggedSnippet of Object.entries(tagDbData).filter( + v => v[1][0] === tag + )) { + output += `* [\`${ + taggedSnippet[0] + }\`](#${taggedSnippet[0].toLowerCase()}${ taggedSnippet[1].includes('advanced') ? '-' : '' })\n`; } @@ -151,7 +185,9 @@ try { for (const tag of tags) { const capitalizedTag = util.capitalize(tag, true); output += `---\n ## ${EMOJIS[tag] || ''} ${capitalizedTag}\n`; - for (const taggedSnippet of Object.entries(tagDbData).filter(v => v[1][0] === tag)) { + for (const taggedSnippet of Object.entries(tagDbData).filter( + v => v[1][0] === tag + )) { let data = snippets[taggedSnippet[0] + '.md']; // Add advanced tag if (taggedSnippet[1].includes('advanced')) { From 6821da38acb285adf5cfae269bc67b43d5d613be Mon Sep 17 00:00:00 2001 From: Felix Wu Date: Fri, 14 Sep 2018 12:58:54 +0200 Subject: [PATCH 03/15] fix isSimilar --- snippets_archive/isSimilar.md | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/snippets_archive/isSimilar.md b/snippets_archive/isSimilar.md index 7ed53b2ae..e6b2a8360 100644 --- a/snippets_archive/isSimilar.md +++ b/snippets_archive/isSimilar.md @@ -5,15 +5,14 @@ Determines if the `pattern` matches with `str`. Use `String.toLowerCase()` to convert both strings to lowercase, then loop through `str` and determine if it contains all characters of `pattern` and in the correct order. Adapted from [here](https://github.com/forrestthewoods/lib_fts/blob/80f3f8c52db53428247e741b9efe2cde9667050c/code/fts_fuzzy_match.js#L18). -``` js +```js const isSimilar = (pattern, str) => [...str].reduce( (matchIndex, char) => char.toLowerCase() === (pattern[matchIndex] || '').toLowerCase() ? matchIndex + 1 : matchIndex, 0 ) === pattern.length ? true : false; ``` - -``` js +```js isSimilar('rt','Rohit'); // true isSimilar('tr','Rohit'); // false ``` From 7b3a386504cc1e233fdeb8bd9294179a558faf92 Mon Sep 17 00:00:00 2001 From: Felix Wu Date: Fri, 14 Sep 2018 12:59:01 +0200 Subject: [PATCH 04/15] fix isSimilar line breaks --- snippet_data/snippetsArchive.json | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/snippet_data/snippetsArchive.json b/snippet_data/snippetsArchive.json index bb66d5741..48a45dfac 100644 --- a/snippet_data/snippetsArchive.json +++ b/snippet_data/snippetsArchive.json @@ -194,14 +194,14 @@ "fileName": "isSimilar.md", "text": "Determines if the `pattern` matches with `str`.\n\nUse `String.toLowerCase()` to convert both strings to lowercase, then loop through `str` and determine if it contains all characters of `pattern` and in the correct order.\nAdapted from [here](https://github.com/forrestthewoods/lib_fts/blob/80f3f8c52db53428247e741b9efe2cde9667050c/code/fts_fuzzy_match.js#L18).", "codeBlocks": [ - "``` js\nconst isSimilar = (pattern, str) =>\n\t[...str].reduce(\n\t\t(matchIndex, char) => char.toLowerCase() === (pattern[matchIndex] || '').toLowerCase() ? matchIndex + 1 : matchIndex, 0\n\t) === pattern.length ? true : false;\n```", - "``` js\nisSimilar('rt','Rohit'); // true\nisSimilar('tr','Rohit'); // false\n```" + "const isSimilar = (pattern, str) =>\n\t[...str].reduce(\n\t\t(matchIndex, char) => char.toLowerCase() === (pattern[matchIndex] || '').toLowerCase() ? matchIndex + 1 : matchIndex, 0\n\t) === pattern.length ? true : false;", + "isSimilar('rt','Rohit'); // true\nisSimilar('tr','Rohit'); // false" ], "tags": [] }, "meta": { "archived": true, - "hash": "b821ad7f7e34c6905f88e1618b629506e265e1a3459288ab7d7b3501b2476dd2" + "hash": "669cc6d3a6f96a65b6e4bf678bb0b95cde711baaabe206db66d69599f6e93a51" } }, { @@ -288,22 +288,22 @@ "isArmstrongNumber(1634); // true\nisArmstrongNumber(56); // false", "``` js\nconst isSimilar = (pattern, str) =>\n\t[...str].reduce(\n\t\t(matchIndex, char) => char.toLowerCase() === (pattern[matchIndex] || '').toLowerCase() ? matchIndex + 1 : matchIndex, 0\n\t) === pattern.length ? true : false;\n```", "``` js\nisSimilar('rt','Rohit'); // true\nisSimilar('tr','Rohit'); // false\n```", - "```\n\n
\n\n
[⬆ Back to top](#table-of-contents)\n\n\n### levenshteinDistance\n\nCalculates the [Levenshtein distance](https://en.wikipedia.org/wiki/Levenshtein_distance) between two strings.\n\nCalculates the number of changes (substitutions, deletions or additions) required to convert `string1` to `string2`. \nCan also be used to compare two strings as shown in the second example.\n\n```", - "```\n\n
\nExamples\n\n```", - "```\n\n
\n\n
[⬆ Back to top](#table-of-contents)\n\n\n### quickSort\n\nQuickSort an Array (ascending sort by default).\n\nUse recursion. \nUse `Array.filter` and spread operator (`...`) to create an array that all elements with values less than the pivot come before the pivot, and all elements with values greater than the pivot come after it. \nIf the parameter `desc` is truthy, return array sorts in descending order.\n\n```", - "```\n\n
\nExamples\n\n```", - "```\n\n
\n\n
[⬆ Back to top](#table-of-contents)\n\n\n### removeVowels\n\nReturns all the vowels in a `str` replaced by `repl`.\n\nUse `String.replace()` with a regexp to replace all vowels in `str`.\nOmot `repl` to use a default value of `''`.\n\n```", - "```\n\n
\nExamples\n\n```", - "```\n\n
\n\n
[⬆ Back to top](#table-of-contents)\n\n\n### solveRPN\n\nSolves the given mathematical expression in [reverse polish notation](https://en.wikipedia.org/wiki/Reverse_Polish_notation).\nThrows appropriate errors if there are unrecognized symbols or the expression is wrong. The valid operators are :- `+`,`-`,`*`,`/`,`^`,`**` (`^`&`**` are the exponential symbols and are same). This snippet does not supports any unary operators.\n\nUse a dictionary, `OPERATORS` to specify each operator's matching mathematical operation.\nUse `String.replace()` with a regular expression to replace `^` with `**`, `String.split()` to tokenize the string and `Array.filter()` to remove empty tokens.\nUse `Array.forEach()` to parse each `symbol`, evaluate it as a numeric value or operator and solve the mathematical expression.\nNumeric values are converted to floating point numbers and pushed to a `stack`, while operators are evaluated using the `OPERATORS` dictionary and pop elements from the `stack` to apply operations.\n\n```", - "```\n\n
\nExamples\n\n```", - "```\n\n
\n\n
[⬆ Back to top](#table-of-contents)\n\n\n### howManyTimes\n\nReturns the number of times `num` can be divided by `divisor` (integer or fractional) without getting a fractional answer.\nWorks for both negative and positive integers.\n\nIf `divisor` is `-1` or `1` return `Infinity`.\nIf `divisor` is `-0` or `0` return `0`.\nOtherwise, keep dividing `num` with `divisor` and incrementing `i`, while the result is an integer.\nReturn the number of times the loop was executed, `i`.\n\n```", - "```\n\n
\nExamples\n\n```" + "```\n\n
\n \n[⬆ Back to top](#table-of-contents)\n\n### levenshteinDistance\n\nCalculates the [Levenshtein distance](https://en.wikipedia.org/wiki/Levenshtein_distance) between two strings.\n\nCalculates the number of changes (substitutions, deletions or additions) required to convert `string1` to `string2`. \nCan also be used to compare two strings as shown in the second example.\n\n```", + "``` \n\n
\n Examples\n \n```", + "```\n\n
\n \n[⬆ Back to top](#table-of-contents)\n\n### quickSort\n\nQuickSort an Array (ascending sort by default).\n\nUse recursion. \nUse `Array.filter` and spread operator (`...`) to create an array that all elements with values less than the pivot come before the pivot, and all elements with values greater than the pivot come after it. \nIf the parameter `desc` is truthy, return array sorts in descending order.\n\n```", + "``` \n\n
\n Examples\n \n```", + "```\n\n
\n \n[⬆ Back to top](#table-of-contents)\n\n### removeVowels\n\nReturns all the vowels in a `str` replaced by `repl`.\n\nUse `String.replace()` with a regexp to replace all vowels in `str`.\nOmot `repl` to use a default value of `''`.\n\n```", + "``` \n\n
\n Examples\n \n```", + "```\n\n
\n \n[⬆ Back to top](#table-of-contents)\n\n### solveRPN\n\nSolves the given mathematical expression in [reverse polish notation](https://en.wikipedia.org/wiki/Reverse_Polish_notation).\nThrows appropriate errors if there are unrecognized symbols or the expression is wrong. The valid operators are :- `+`,`-`,`*`,`/`,`^`,`**` (`^`&`**` are the exponential symbols and are same). This snippet does not supports any unary operators.\n\nUse a dictionary, `OPERATORS` to specify each operator's matching mathematical operation.\nUse `String.replace()` with a regular expression to replace `^` with `**`, `String.split()` to tokenize the string and `Array.filter()` to remove empty tokens.\nUse `Array.forEach()` to parse each `symbol`, evaluate it as a numeric value or operator and solve the mathematical expression.\nNumeric values are converted to floating point numbers and pushed to a `stack`, while operators are evaluated using the `OPERATORS` dictionary and pop elements from the `stack` to apply operations.\n\n```", + "``` \n\n
\n Examples\n \n```", + "```\n\n
\n \n[⬆ Back to top](#table-of-contents)\n\n### howManyTimes\n\nReturns the number of times `num` can be divided by `divisor` (integer or fractional) without getting a fractional answer.\nWorks for both negative and positive integers.\n\nIf `divisor` is `-1` or `1` return `Infinity`.\nIf `divisor` is `-0` or `0` return `0`.\nOtherwise, keep dividing `num` with `divisor` and incrementing `i`, while the result is an integer.\nReturn the number of times the loop was executed, `i`.\n\n```", + "``` \n\n
\n Examples\n \n```" ], "tags": [] }, "meta": { "archived": true, - "hash": "878970d0bdefe60f7f61db64b85bbb36b6869e2875a2c278fb269b8cff3b42b4" + "hash": "4c776a716fd3fd197ce7d6bf3f18e73e647f0363a8668b72cb980b53d355fe20" } }, { From 66489215b6d42b1c9aa9b6d863866af008cce538 Mon Sep 17 00:00:00 2001 From: Felix Wu Date: Fri, 14 Sep 2018 13:00:38 +0200 Subject: [PATCH 05/15] rebuild README --- snippets_archive/README.md | 203 ++-- test/testlog | 2319 ++++-------------------------------- 2 files changed, 346 insertions(+), 2176 deletions(-) diff --git a/snippets_archive/README.md b/snippets_archive/README.md index ba47f4c3f..abc633d5c 100644 --- a/snippets_archive/README.md +++ b/snippets_archive/README.md @@ -1,11 +1,7 @@ -![Logo](/logo.png) - -# Snippets Archive - -These snippets, while useful and interesting, didn't quite make it into the repository due to either having very specific use-cases or being outdated. However we felt like they might still be useful to some readers, so here they are. - -## Table of Contents - +![Logo](/logo.png "") +# Snippets Archive +These snippets, while useful and interesting, didn't quite make it into the repository due to either having very specific use-cases or being outdated. However we felt like they might still be useful to some readers, so here they are. +## Table of Contents * [`JSONToDate`](#jsontodate) * [`speechSynthesis`](#speechsynthesis) * [`binarySearch`](#binarysearch) @@ -24,9 +20,8 @@ These snippets, while useful and interesting, didn't quite make it into the repo * [`removeVowels`](#removevowels) * [`solveRPN`](#solverpn) * [`howManyTimes`](#howmanytimes) - ---- - + +--- ### JSONToDate Converts a JSON object to a date. @@ -38,19 +33,19 @@ const JSONToDate = arr => { const dt = new Date(parseInt(arr.toString().substr(6))); return `${dt.getDate()}/${dt.getMonth() + 1}/${dt.getFullYear()}`; }; -``` +```
-Examples - + Examples + ```js JSONToDate(/Date(1489525200000)/); // "14/3/2017" ```
+ -
[⬆ Back to top](#table-of-contents) - +[⬆ Back to top](#table-of-contents) ### speechSynthesis @@ -67,19 +62,19 @@ const speechSynthesis = message => { msg.voice = window.speechSynthesis.getVoices()[0]; window.speechSynthesis.speak(msg); }; -``` +```
-Examples - + Examples + ```js speechSynthesis('Hello, World'); // // plays the message ```
+ -
[⬆ Back to top](#table-of-contents) - +[⬆ Back to top](#table-of-contents) ### binarySearch @@ -99,20 +94,20 @@ const binarySearch = (arr, val, start = 0, end = arr.length - 1) => { if (arr[mid] < val) return binarySearch(arr, val, mid + 1, end); return mid; }; -``` +```
-Examples - + Examples + ```js binarySearch([1, 4, 6, 7, 12, 13, 15, 18, 19, 20, 22, 24], 6); // 2 binarySearch([1, 4, 6, 7, 12, 13, 15, 18, 19, 20, 22, 24], 21); // -1 ```
+ -
[⬆ Back to top](#table-of-contents) - +[⬆ Back to top](#table-of-contents) ### cleanObj @@ -132,20 +127,20 @@ const cleanObj = (obj, keysToKeep = [], childIndicator) => { }); return obj; }; -``` +```
-Examples - + Examples + ```js const testObj = { a: 1, b: 2, children: { a: 1, b: 2 } }; cleanObj(testObj, ['a'], 'children'); // { a: 1, children : { a: 1}} ```
+ -
[⬆ Back to top](#table-of-contents) - +[⬆ Back to top](#table-of-contents) ### collatz @@ -155,19 +150,19 @@ If `n` is even, return `n/2`. Otherwise, return `3n+1`. ```js const collatz = n => (n % 2 === 0 ? n / 2 : 3 * n + 1); -``` +```
-Examples - + Examples + ```js collatz(8); // 4 ```
+ -
[⬆ Back to top](#table-of-contents) - +[⬆ Back to top](#table-of-contents) ### countVowels @@ -177,20 +172,20 @@ Use a regular expression to count the number of vowels `(A, E, I, O, U)` in a `s ```js const countVowels = str => (str.match(/[aeiou]/gi) || []).length; -``` +```
-Examples - + Examples + ```js countVowels('foobar'); // 3 countVowels('gym'); // 0 ```
+ -
[⬆ Back to top](#table-of-contents) - +[⬆ Back to top](#table-of-contents) ### factors @@ -226,11 +221,11 @@ const factors = (num, primes = false) => { }, []); return primes ? array.filter(isPrime) : array; }; -``` +```
-Examples - + Examples + ```js factors(12); // [2,3,4,6,12] factors(12, true); // [2,3] @@ -239,9 +234,9 @@ factors(-12, true); // [2,3] ```
+ -
[⬆ Back to top](#table-of-contents) - +[⬆ Back to top](#table-of-contents) ### fibonacciCountUntilNum @@ -252,19 +247,19 @@ Use a mathematical formula to calculate the number of fibonacci numbers until `n ```js const fibonacciCountUntilNum = num => Math.ceil(Math.log(num * Math.sqrt(5) + 1 / 2) / Math.log((Math.sqrt(5) + 1) / 2)); -``` +```
-Examples - + Examples + ```js fibonacciCountUntilNum(10); // 7 ```
+ -
[⬆ Back to top](#table-of-contents) - +[⬆ Back to top](#table-of-contents) ### fibonacciUntilNum @@ -282,19 +277,19 @@ const fibonacciUntilNum = num => { [] ); }; -``` +```
-Examples - + Examples + ```js fibonacciUntilNum(10); // [ 0, 1, 1, 2, 3, 5, 8 ] ```
+ -
[⬆ Back to top](#table-of-contents) - +[⬆ Back to top](#table-of-contents) ### httpDelete @@ -313,11 +308,11 @@ const httpDelete = (url, callback, err = console.error) => { request.onerror = () => err(request); request.send(); }; -``` +```
-Examples - + Examples + ```js httpDelete('https://website.com/users/123', request => { console.log(request.responseText); @@ -325,9 +320,9 @@ httpDelete('https://website.com/users/123', request => { ```
+ -
[⬆ Back to top](#table-of-contents) - +[⬆ Back to top](#table-of-contents) ### httpPut @@ -348,11 +343,11 @@ const httpPut = (url, data, callback, err = console.error) => { request.onerror = () => err(request); request.send(data); }; -``` +```
-Examples - + Examples + ```js const password = "fooBaz"; const data = JSON.stringify(password); @@ -362,9 +357,9 @@ httpPut('https://website.com/users/123', data, request => { ```
+ -
[⬆ Back to top](#table-of-contents) - +[⬆ Back to top](#table-of-contents) ### isArmstrongNumber @@ -377,20 +372,20 @@ const isArmstrongNumber = digits => (arr => arr.reduce((a, d) => a + parseInt(d) ** arr.length, 0) == digits)( (digits + '').split('') ); -``` +```
-Examples - + Examples + ```js isArmstrongNumber(1634); // true isArmstrongNumber(56); // false ```
+ -
[⬆ Back to top](#table-of-contents) - +[⬆ Back to top](#table-of-contents) ### isSimilar @@ -399,26 +394,25 @@ Determines if the `pattern` matches with `str`. Use `String.toLowerCase()` to convert both strings to lowercase, then loop through `str` and determine if it contains all characters of `pattern` and in the correct order. Adapted from [here](https://github.com/forrestthewoods/lib_fts/blob/80f3f8c52db53428247e741b9efe2cde9667050c/code/fts_fuzzy_match.js#L18). -``` js +```js const isSimilar = (pattern, str) => [...str].reduce( (matchIndex, char) => char.toLowerCase() === (pattern[matchIndex] || '').toLowerCase() ? matchIndex + 1 : matchIndex, 0 ) === pattern.length ? true : false; -``` +``` - -``` js +
+ Examples + +```js isSimilar('rt','Rohit'); // true isSimilar('tr','Rohit'); // false -```
-Examples - ```
+ -
[⬆ Back to top](#table-of-contents) - +[⬆ Back to top](#table-of-contents) ### levenshteinDistance @@ -445,11 +439,11 @@ const levenshteinDistance = (string1, string2) => { } return matrix[string2.length][string1.length]; }; -``` +```
-Examples - + Examples + ```js levenshteinDistance('30-seconds-of-code','30-seconds-of-python-code'); // 7 const compareStrings = (string1,string2) => (100 - levenshteinDistance(string1,string2) / Math.max(string1.length,string2.length)); @@ -457,9 +451,9 @@ compareStrings('30-seconds-of-code', '30-seconds-of-python-code'); // 99.72 (%) ```
+ -
[⬆ Back to top](#table-of-contents) - +[⬆ Back to top](#table-of-contents) ### quickSort @@ -478,20 +472,20 @@ const quickSort = ([n, ...nums], desc) => n, ...quickSort(nums.filter(v => (!desc ? v > n : v <= n)), desc) ]; -``` +```
-Examples - + Examples + ```js quickSort([4, 1, 3, 2]); // [1,2,3,4] quickSort([4, 1, 3, 2], true); // [4,3,2,1] ```
+ -
[⬆ Back to top](#table-of-contents) - +[⬆ Back to top](#table-of-contents) ### removeVowels @@ -502,20 +496,20 @@ Omot `repl` to use a default value of `''`. ```js const removeVowels = (str, repl = '') => str.replace(/[aeiou]/gi,repl); -``` +```
-Examples - + Examples + ```js removeVowels("foobAr"); // "fbr" removeVowels("foobAr","*"); // "f**b*r" ```
+ -
[⬆ Back to top](#table-of-contents) - +[⬆ Back to top](#table-of-contents) ### solveRPN @@ -556,20 +550,20 @@ const solveRPN = rpn => { if (stack.length === 1) return stack.pop(); else throw `${rpn} is not a proper RPN. Please check it and try again`; }; -``` +```
-Examples - + Examples + ```js solveRPN('15 7 1 1 + - / 3 * 2 1 1 + + -'); // 5 solveRPN('2 3 ^'); // 8 ```
+ -
[⬆ Back to top](#table-of-contents) - +[⬆ Back to top](#table-of-contents) ### howManyTimes @@ -592,11 +586,11 @@ const howManyTimes = (num, divisor) => { } return i; }; -``` +```
-Examples - + Examples + ```js howManyTimes(100, 2); // 2 howManyTimes(100, 2.5); // 2 @@ -605,6 +599,7 @@ howManyTimes(100, -1); // Infinity ```
+ -
[⬆ Back to top](#table-of-contents) +[⬆ Back to top](#table-of-contents) diff --git a/test/testlog b/test/testlog index 183e988c5..6cf70f8ba 100644 --- a/test/testlog +++ b/test/testlog @@ -3,2099 +3,274 @@ # Starting... # 347 test suites found. -# PASS test/isPrimitive/isPrimitive.test.js +# PASS test/uniqueElements/uniqueElements.test.js -ok 1 — isPrimitive is a Function -ok 2 — isPrimitive(null) is primitive -ok 3 — isPrimitive(undefined) is primitive -ok 4 — isPrimitive(string) is primitive -ok 5 — isPrimitive(true) is primitive -ok 6 — isPrimitive(50) is primitive -ok 7 — isPrimitive('Hello') is primitive -ok 8 — isPrimitive(false) is primitive -ok 9 — isPrimitive(Symbol()) is primitive -ok 10 — isPrimitive([1, 2, 3]) is not primitive -ok 11 — isPrimitive({ a: 123 }) is not primitive -ok 12 — isPrimitive({ a: 123 }) takes less than 2s to run - -# PASS test/toKebabCase/toKebabCase.test.js - -ok 13 — toKebabCase is a Function -ok 14 — toKebabCase('camelCase') returns camel-case -ok 15 — toKebabCase('some text') returns some-text -ok 16 — toKebabCase('some-mixed-string With spaces-underscores-and-hyphens') returns some-mixed-string-with-spaces-underscores-and-hyphens -ok 17 — toKebabCase('IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML') returns i-am-listening-to-fm-while-loading-different-url-on-my-browser-and-also-editing-some-xml-and-html -ok 18 — toKebabCase() returns undefined -ok 19 — toKebabCase([]) throws an erro -ok 20 — toKebabCase({}) throws an erro -ok 21 — toKebabCase(123) throws an erro -ok 22 — toKebabCase(IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML) takes less than 2s to run - -# PASS test/is/is.test.js - -ok 23 — is is a Function -ok 24 — Works for arrays with data -ok 25 — Works for empty arrays -ok 26 — Works for arrays, not objects -ok 27 — Works for objects -ok 28 — Works for maps -ok 29 — Works for regular expressions -ok 30 — Works for sets -ok 31 — Works for weak maps -ok 32 — Works for weak sets -ok 33 — Works for strings - returns true for primitive -ok 34 — Works for strings - returns true when using constructor -ok 35 — Works for numbers - returns true for primitive -ok 36 — Works for numbers - returns true when using constructor -ok 37 — Works for booleans - returns true for primitive -ok 38 — Works for booleans - returns true when using constructor -ok 39 — Works for functions - -# PASS test/yesNo/yesNo.test.js - -ok 40 — yesNo is a Function -ok 41 — yesNo(Y) returns true -ok 42 — yesNo(yes) returns true -ok 43 — yesNo(foo, true) returns true -ok 44 — yesNo(No) returns false -ok 45 — yesNo() returns false -ok 46 — yesNo(null) returns false -ok 47 — yesNo(undefined) returns false -ok 48 — yesNo([123, null]) returns false -ok 49 — yesNo([Yes, No]) returns false -ok 50 — yesNo({ 2: Yes }) returns false -ok 51 — yesNo([Yes, No], true) returns true -ok 52 — yesNo({ 2: Yes }, true) returns true - -# PASS test/toSafeInteger/toSafeInteger.test.js - -ok 53 — toSafeInteger is a Function -ok 54 — Number(toSafeInteger(3.2)) is a number -ok 55 — Converts a value to a safe integer -ok 56 — toSafeInteger('4.2') returns 4 -ok 57 — toSafeInteger(4.6) returns 5 -ok 58 — toSafeInteger([]) returns 0 -ok 59 — isNaN(toSafeInteger([1.5, 3124])) is true -ok 60 — isNaN(toSafeInteger('string')) is true -ok 61 — isNaN(toSafeInteger({})) is true -ok 62 — isNaN(toSafeInteger()) is true -ok 63 — toSafeInteger(Infinity) returns 9007199254740991 -ok 64 — toSafeInteger(3.2) takes less than 2s to run - -# PASS test/head/head.test.js - -ok 65 — head is a Function -ok 66 — head({ a: 1234}) returns undefined -ok 67 — head([1, 2, 3]) returns 1 -ok 68 — head({ 0: false}) returns false -ok 69 — head(String) returns S -ok 70 — head(null) throws an Error -ok 71 — head(undefined) throws an Error -ok 72 — head() throws an Error -ok 73 — head([1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 1122, 32124, 23232]) takes less than 2s to run - -# PASS test/union/union.test.js - -ok 74 — union is a Function -ok 75 — union([1, 2, 3], [4, 3, 2]) returns [1, 2, 3, 4] -ok 76 — union('str', 'asd') returns [ 's', 't', 'r', 'a', 'd' ] -ok 77 — union([[], {}], [1, 2, 3]) returns [[], {}, 1, 2, 3] -ok 78 — union([], []) returns [] -ok 79 — union() throws an error -ok 80 — union(true, 'str') throws an error -ok 81 — union('false', true) throws an error -ok 82 — union((123, {}) throws an error -ok 83 — union([], {}) throws an error -ok 84 — union(undefined, null) throws an error -ok 85 — union([1, 2, 3], [4, 3, 2]) takes less than 2s to run - -# PASS test/longestItem/longestItem.test.js - -ok 86 — longestItem is a Function -ok 87 — Returns the longest object from plain values -ok 88 — Returns the longest object from a spread array -ok 89 — Returns the longest object from mixed input -ok 90 — Returns the longest array -ok 91 — Returns the longest object when comparing arrays and strings -ok 92 — Returns undefined without any input -ok 93 — Returns first found of all similar -ok 94 — Throws TypeError if all inputs are undefined - -# PASS test/zip/zip.test.js - -ok 95 — zip is a Function -ok 96 — zip([a, b], [1, 2], [true, false]) returns [[a, 1, true], [b, 2, false]] -ok 97 — zip([a], [1, 2], [true, false]) returns [[a, 1, true], [undefined, 2, false]] -ok 98 — zip([]) returns [] -ok 99 — zip(123) returns [] -ok 100 — zip([a, b], [1, 2], [true, false]) returns an Array -ok 101 — zip([a], [1, 2], [true, false]) returns an Array -ok 102 — zip(null) throws an error -ok 103 — zip(undefined) throws an error - -# PASS test/isSorted/isSorted.test.js - -ok 104 — isSorted is a Function -ok 105 — Array is sorted in ascending order -ok 106 — Array is sorted in ascending order -ok 107 — Array is sorted in ascending order -ok 108 — Array is sorted in ascending order -ok 109 — Array is sorted in descending order -ok 110 — Array is sorted in descending order -ok 111 — Array is sorted in descending order -ok 112 — Array is sorted in descending order -ok 113 — Array is empty -ok 114 — Array is not sorted, direction changed in array -ok 115 — Array is not sorted, direction changed in array - -# PASS test/all/all.test.js - -ok 116 — all is a Function -ok 117 — Returns true for arrays with no falsey values -ok 118 — Returns false for arrays with 0 -ok 119 — Returns false for arrays with NaN -ok 120 — Returns false for arrays with undefined -ok 121 — Returns false for arrays with null -ok 122 — Returns false for arrays with empty strings -ok 123 — Returns true with predicate function -ok 124 — Returns false with a predicate function - -# PASS test/equals/equals.test.js - -ok 125 — equals is a Function -ok 126 — { a: [2, {e: 3}], b: [4], c: 'foo' } is equal to { a: [2, {e: 3}], b: [4], c: 'foo' } -ok 127 — [1,2,3] is equal to [1,2,3] -ok 128 — { a: [2, 3], b: [4] } is not equal to { a: [2, 3], b: [6] } -ok 129 — [1,2,3] is not equal to [1,2,4] -ok 130 — [1, 2, 3] should be equal to { 0: 1, 1: 2, 2: 3 }) - type is different, but their enumerable properties match. - -# PASS test/pluralize/pluralize.test.js - -ok 131 — pluralize is a Function -ok 132 — Produces the plural of the word -ok 133 — Produces the singular of the word -ok 134 — Produces the plural of the word -ok 135 — Prodices the defined plural of the word -ok 136 — Works with a dictionary - -# PASS test/CSVToArray/CSVToArray.test.js - -ok 137 — CSVToArray is a Function -ok 138 — CSVToArray works with default delimiter -ok 139 — CSVToArray works with custom delimiter -ok 140 — CSVToArray omits the first row -ok 141 — CSVToArray omits the first row and works with a custom delimiter - -# PASS test/randomIntArrayInRange/randomIntArrayInRange.test.js - -ok 142 — randomIntArrayInRange is a Function -ok 143 — The returned array contains only integers -ok 144 — The returned array has the proper length -ok 145 — The returned array's values lie between provided lowerLimit and upperLimit (both inclusive). - -# PASS test/randomIntegerInRange/randomIntegerInRange.test.js - -ok 146 — randomIntegerInRange is a Function -ok 147 — The returned value is an integer -ok 148 — The returned value lies between provided lowerLimit and upperLimit (both inclusive). - -# PASS test/offset/offset.test.js - -ok 149 — offset is a Function -ok 150 — Offset of 0 returns the same array. -ok 151 — Offset > 0 returns the offsetted array. -ok 152 — Offset < 0 returns the reverse offsetted array. -ok 153 — Offset greater than the length of the array returns the same array. -ok 154 — Offset less than the negative length of the array returns the same array. -ok 155 — Offsetting empty array returns an empty array. - -# PASS test/initializeArrayWithRange/initializeArrayWithRange.test.js - -ok 156 — initializeArrayWithRange is a Function -ok 157 — Initializes an array containing the numbers in the specified range (witout start value) -ok 158 — Initializes an array containing the numbers in the specified range -ok 159 — Initializes an array containing the numbers in the specified range (with step) - -# PASS test/orderBy/orderBy.test.js - -ok 160 — orderBy is a Function -ok 161 — Returns a sorted array of objects ordered by properties and orders. -ok 162 — Returns a sorted array of objects ordered by properties and orders. - -# PASS test/randomNumberInRange/randomNumberInRange.test.js - -ok 163 — randomNumberInRange is a Function -ok 164 — The returned value is a number -ok 165 — The returned value lies between provided lowerLimit and upperLimit (both inclusive). - -# PASS test/allEqual/allEqual.test.js - -ok 166 — allEqual is a Function -ok 167 — Truthy numbers -ok 168 — Falsy numbers -ok 169 — Truthy strings -ok 170 — Falsy numbers -ok 171 — Truthy trues -ok 172 — Truthy falses -ok 173 — Falsy trues -ok 174 — Falsy falses - -# PASS test/sampleSize/sampleSize.test.js - -ok 175 — sampleSize is a Function -ok 176 — Returns a single element without n specified -ok 177 — Returns a random sample of specified size from an array -ok 178 — Returns all elements in an array if n >= length -ok 179 — Returns an empty array if original array is empty -ok 180 — Returns an empty array if n = 0 - -# PASS test/any/any.test.js - -ok 181 — any is a Function -ok 182 — Returns true for arrays with at least one truthy value -ok 183 — Returns false for arrays with no truthy values -ok 184 — Returns false for arrays with no truthy values -ok 185 — Returns true with predicate function -ok 186 — Returns false with a predicate function - -# PASS test/without/without.test.js - -ok 187 — without is a Function -ok 188 — without([2, 1, 2, 3], 1, 2) returns [3] -ok 189 — without([]) returns [] -ok 190 — without([3, 1, true, '3', true], '3', true) returns [3, 1] -ok 191 — without('string'.split(''), 's', 't', 'g') returns ['r', 'i', 'n'] -ok 192 — without() throws an error -ok 193 — without(null) throws an error -ok 194 — without(undefined) throws an error -ok 195 — without(123) throws an error -ok 196 — without({}) throws an error - -# PASS test/isEmpty/isEmpty.test.js - -ok 197 — isEmpty is a Function -ok 198 — Returns true for empty Map -ok 199 — Returns true for empty Set -ok 200 — Returns true for empty array -ok 201 — Returns true for empty object -ok 202 — Returns true for empty string -ok 203 — Returns false for non-empty array -ok 204 — Returns false for non-empty object -ok 205 — Returns false for non-empty string -ok 206 — Returns true - type is not considered a collection -ok 207 — Returns true - type is not considered a collection +ok 1 — uniqueElements is a Function +ok 2 — uniqueElements([1, 2, 2, 3, 4, 4, 5]) returns [1,2,3,4,5] +ok 3 — uniqueElements([1, 23, 53]) returns [1, 23, 53] +ok 4 — uniqueElements([true, 0, 1, false, false, undefined, null, '']) returns [true, 0, 1, false, false, undefined, null, ''] +ok 5 — uniqueElements() returns [] +ok 6 — uniqueElements(null) returns [] +ok 7 — uniqueElements(undefined) returns [] +ok 8 — uniqueElements('strt') returns ['s', 't', 'r'] +ok 9 — uniqueElements(1, 1, 2543, 534, 5) throws an error +ok 10 — uniqueElements({}) throws an error +ok 11 — uniqueElements(true) throws an error +ok 12 — uniqueElements(false) throws an error +ok 13 — uniqueElements([true, 0, 1, false, false, undefined, null]) takes less than 2s to run # PASS test/toSnakeCase/toSnakeCase.test.js -ok 208 — toSnakeCase is a Function -ok 209 — toSnakeCase('camelCase') returns camel_case -ok 210 — toSnakeCase('some text') returns some_text -ok 211 — toSnakeCase('some-mixed_string With spaces_underscores-and-hyphens') returns some_mixed_string_with_spaces_underscores_and_hyphens -ok 212 — toSnakeCase('IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML') returns i_am_listening_to_fm_while_loading_different_url_on_my_browser_and_also_editing_some_xml_and_html -ok 213 — toSnakeCase() returns undefined -ok 214 — toSnakeCase([]) throws an error -ok 215 — toSnakeCase({}) throws an error -ok 216 — toSnakeCase(123) throws an error -ok 217 — toSnakeCase(IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML) takes less than 2s to run +ok 14 — toSnakeCase is a Function +ok 15 — toSnakeCase('camelCase') returns camel_case +ok 16 — toSnakeCase('some text') returns some_text +ok 17 — toSnakeCase('some-mixed_string With spaces_underscores-and-hyphens') returns some_mixed_string_with_spaces_underscores_and_hyphens +ok 18 — toSnakeCase('IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML') returns i_am_listening_to_fm_while_loading_different_url_on_my_browser_and_also_editing_some_xml_and_html +ok 19 — toSnakeCase() returns undefined +ok 20 — toSnakeCase([]) throws an error +ok 21 — toSnakeCase({}) throws an error +ok 22 — toSnakeCase(123) throws an error +ok 23 — toSnakeCase(IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML) takes less than 2s to run -# PASS test/toCurrency/toCurrency.test.js +# PASS test/toKebabCase/toKebabCase.test.js -ok 218 — toCurrency is a Function -ok 219 — currency: Euro | currencyLangFormat: Local -ok 220 — currency: US Dollar | currencyLangFormat: English (United States) -ok 221 — currency: Japanese Yen | currencyLangFormat: Local - -# PASS test/mapObject/mapObject.test.js - -ok 222 — mapObject is a Function -ok 223 — mapObject([1, 2, 3], a => a * a) returns { 1: 1, 2: 4, 3: 9 } -ok 224 — mapObject([1, 2, 3, 4], (a, b) => b - a) returns { 1: -1, 2: -1, 3: -1, 4: -1 } -ok 225 — mapObject([1, 2, 3, 4], (a, b) => a - b) returns { 1: 1, 2: 1, 3: 1, 4: 1 } - -# PASS test/average/average.test.js - -ok 226 — average is a Function -ok 227 — average(true) returns 0 -ok 228 — average(false) returns 1 -ok 229 — average(9, 1) returns 5 -ok 230 — average(153, 44, 55, 64, 71, 1122, 322774, 2232, 23423, 234, 3631) returns 32163.909090909092 -ok 231 — average(1, 2, 3) returns 2 -ok 232 — average(null) returns 0 -ok 233 — average(1, 2, 3) returns NaN -ok 234 — average(String) returns NaN -ok 235 — average({ a: 123}) returns NaN -ok 236 — average([undefined, 0, string]) returns NaN -ok 237 — average([1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 1122, 32124, 23232]) takes less than 2s to run - -# PASS test/validateNumber/validateNumber.test.js - -ok 238 — validateNumber is a Function -ok 239 — validateNumber(9) returns true -ok 240 — validateNumber(234asd.slice(0, 2)) returns true -ok 241 — validateNumber(1232) returns true -ok 242 — validateNumber(1232 + 13423) returns true -ok 243 — validateNumber(1232 * 2342 * 123) returns true -ok 244 — validateNumber(1232.23423536) returns true -ok 245 — validateNumber(234asd) returns false -ok 246 — validateNumber(e234d) returns false -ok 247 — validateNumber(false) returns false -ok 248 — validateNumber(true) returns false -ok 249 — validateNumber(null) returns false -ok 250 — validateNumber(123 * asd) returns false - -# PASS test/quickSort/quickSort.test.js - -ok 251 — quickSort is a Function -ok 252 — quickSort([5, 6, 4, 3, 1, 2]) returns [1, 2, 3, 4, 5, 6] -ok 253 — quickSort([-1, 0, -2]) returns [-2, -1, 0] -ok 254 — quickSort() throws an error -ok 255 — quickSort(123) throws an error -ok 256 — quickSort({ 234: string}) throws an error -ok 257 — quickSort(null) throws an error -ok 258 — quickSort(undefined) throws an error -ok 259 — quickSort([11, 1, 324, 23232, -1, 53, 2, 524, 32, 13, 156, 133, 62, 12, 4]) takes less than 2s to run +ok 24 — toKebabCase is a Function +ok 25 — toKebabCase('camelCase') returns camel-case +ok 26 — toKebabCase('some text') returns some-text +ok 27 — toKebabCase('some-mixed-string With spaces-underscores-and-hyphens') returns some-mixed-string-with-spaces-underscores-and-hyphens +ok 28 — toKebabCase('IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML') returns i-am-listening-to-fm-while-loading-different-url-on-my-browser-and-also-editing-some-xml-and-html +ok 29 — toKebabCase() returns undefined +ok 30 — toKebabCase([]) throws an erro +ok 31 — toKebabCase({}) throws an erro +ok 32 — toKebabCase(123) throws an erro +ok 33 — toKebabCase(IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML) takes less than 2s to run # PASS test/toCamelCase/toCamelCase.test.js -ok 260 — toCamelCase is a Function -ok 261 — toCamelCase('some_database_field_name') returns someDatabaseFieldName -ok 262 — toCamelCase('Some label that needs to be camelized') returns someLabelThatNeedsToBeCamelized -ok 263 — toCamelCase('some-javascript-property') return someJavascriptProperty -ok 264 — toCamelCase('some-mixed_string with spaces_underscores-and-hyphens') returns someMixedStringWithSpacesUnderscoresAndHyphens -ok 265 — toCamelCase() throws a error -ok 266 — toCamelCase([]) throws a error -ok 267 — toCamelCase({}) throws a error -ok 268 — toCamelCase(123) throws a error -ok 269 — toCamelCase(some-mixed_string with spaces_underscores-and-hyphens) takes less than 2s to run +ok 34 — toCamelCase is a Function +ok 35 — toCamelCase('some_database_field_name') returns someDatabaseFieldName +ok 36 — toCamelCase('Some label that needs to be camelized') returns someLabelThatNeedsToBeCamelized +ok 37 — toCamelCase('some-javascript-property') return someJavascriptProperty +ok 38 — toCamelCase('some-mixed_string with spaces_underscores-and-hyphens') returns someMixedStringWithSpacesUnderscoresAndHyphens +ok 39 — toCamelCase() throws a error +ok 40 — toCamelCase([]) throws a error +ok 41 — toCamelCase({}) throws a error +ok 42 — toCamelCase(123) throws a error +ok 43 — toCamelCase(some-mixed_string with spaces_underscores-and-hyphens) takes less than 2s to run -# PASS test/fromCamelCase/fromCamelCase.test.js +# PASS test/is/is.test.js -ok 270 — fromCamelCase is a Function -ok 271 — Converts a string from camelcase -ok 272 — Converts a string from camelcase -ok 273 — Converts a string from camelcase +ok 44 — is is a Function +ok 45 — Works for arrays with data +ok 46 — Works for empty arrays +ok 47 — Works for arrays, not objects +ok 48 — Works for objects +ok 49 — Works for maps +ok 50 — Works for regular expressions +ok 51 — Works for sets +ok 52 — Works for weak maps +ok 53 — Works for weak sets +ok 54 — Works for strings - returns true for primitive +ok 55 — Works for strings - returns true when using constructor +ok 56 — Works for numbers - returns true for primitive +ok 57 — Works for numbers - returns true when using constructor +ok 58 — Works for booleans - returns true for primitive +ok 59 — Works for booleans - returns true when using constructor +ok 60 — Works for functions -# PASS test/mapString/mapString.test.js +# PASS test/average/average.test.js -ok 274 — mapString is a Function -ok 275 — mapString returns a capitalized string -ok 276 — mapString can deal with indexes -ok 277 — mapString can deal with the full string +ok 61 — average is a Function +ok 62 — average(true) returns 0 +ok 63 — average(false) returns 1 +ok 64 — average(9, 1) returns 5 +ok 65 — average(153, 44, 55, 64, 71, 1122, 322774, 2232, 23423, 234, 3631) returns 32163.909090909092 +ok 66 — average(1, 2, 3) returns 2 +ok 67 — average(null) returns 0 +ok 68 — average(1, 2, 3) returns NaN +ok 69 — average(String) returns NaN +ok 70 — average({ a: 123}) returns NaN +ok 71 — average([undefined, 0, string]) returns NaN +ok 72 — average([1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 1122, 32124, 23232]) takes less than 2s to run -# PASS test/reduceWhich/reduceWhich.test.js +# PASS test/union/union.test.js -ok 278 — reduceWhich is a Function -ok 279 — Returns the minimum of an array -ok 280 — Returns the maximum of an array -ok 281 — Returns the object with the minimum specified value in an array +ok 73 — union is a Function +ok 74 — union([1, 2, 3], [4, 3, 2]) returns [1, 2, 3, 4] +ok 75 — union('str', 'asd') returns [ 's', 't', 'r', 'a', 'd' ] +ok 76 — union([[], {}], [1, 2, 3]) returns [[], {}, 1, 2, 3] +ok 77 — union([], []) returns [] +ok 78 — union() throws an error +ok 79 — union(true, 'str') throws an error +ok 80 — union('false', true) throws an error +ok 81 — union((123, {}) throws an error +ok 82 — union([], {}) throws an error +ok 83 — union(undefined, null) throws an error +ok 84 — union([1, 2, 3], [4, 3, 2]) takes less than 2s to run -# PASS test/geometricProgression/geometricProgression.test.js +# PASS test/validateNumber/validateNumber.test.js -ok 282 — geometricProgression is a Function -ok 283 — Initializes an array containing the numbers in the specified range -ok 284 — Initializes an array containing the numbers in the specified range -ok 285 — Initializes an array containing the numbers in the specified range +ok 85 — validateNumber is a Function +ok 86 — validateNumber(9) returns true +ok 87 — validateNumber(234asd.slice(0, 2)) returns true +ok 88 — validateNumber(1232) returns true +ok 89 — validateNumber(1232 + 13423) returns true +ok 90 — validateNumber(1232 * 2342 * 123) returns true +ok 91 — validateNumber(1232.23423536) returns true +ok 92 — validateNumber(234asd) returns false +ok 93 — validateNumber(e234d) returns false +ok 94 — validateNumber(false) returns false +ok 95 — validateNumber(true) returns false +ok 96 — validateNumber(null) returns false +ok 97 — validateNumber(123 * asd) returns false -# PASS test/approximatelyEqual/approximatelyEqual.test.js +# PASS test/toSafeInteger/toSafeInteger.test.js -ok 286 — approximatelyEqual is a Function -ok 287 — Works for PI / 2 -ok 288 — Works for 0.1 + 0.2 === 0.3 -ok 289 — Works for exactly equal values -ok 290 — Works for a custom epsilon +ok 98 — toSafeInteger is a Function +ok 99 — Number(toSafeInteger(3.2)) is a number +ok 100 — Converts a value to a safe integer +ok 101 — toSafeInteger('4.2') returns 4 +ok 102 — toSafeInteger(4.6) returns 5 +ok 103 — toSafeInteger([]) returns 0 +ok 104 — isNaN(toSafeInteger([1.5, 3124])) is true +ok 105 — isNaN(toSafeInteger('string')) is true +ok 106 — isNaN(toSafeInteger({})) is true +ok 107 — isNaN(toSafeInteger()) is true +ok 108 — toSafeInteger(Infinity) returns 9007199254740991 +ok 109 — toSafeInteger(3.2) takes less than 2s to run -# PASS test/filterNonUniqueBy/filterNonUniqueBy.test.js +# PASS test/isPrimitive/isPrimitive.test.js -ok 291 — filterNonUniqueBy is a Function -ok 292 — filterNonUniqueBy works for properties -ok 293 — filterNonUniqueBy works for nested properties - -# PASS test/last/last.test.js - -ok 294 — last is a Function -ok 295 — last({ a: 1234}) returns undefined -ok 296 — last([1, 2, 3]) returns 3 -ok 297 — last({ 0: false}) returns undefined -ok 298 — last(String) returns g -ok 299 — last(null) throws an Error -ok 300 — last(undefined) throws an Error -ok 301 — last() throws an Error -ok 302 — last([1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 1122, 32124, 23232]) takes less than 2s to run - -# PASS test/capitalize/capitalize.test.js - -ok 303 — capitalize is a Function -ok 304 — Capitalizes the first letter of a string -ok 305 — Capitalizes the first letter of a string -ok 306 — Works with characters -ok 307 — "Works with single character words - -# PASS test/chunk/chunk.test.js - -ok 308 — chunk is a Function -ok 309 — chunk([1, 2, 3, 4, 5], 2) returns [[1,2],[3,4],[5]] -ok 310 — chunk([]) returns [] -ok 311 — chunk(123) returns [] -ok 312 — chunk({ a: 123}) returns [] -ok 313 — chunk(string, 2) returns [ st, ri, ng ] -ok 314 — chunk() throws an error -ok 315 — chunk(undefined) throws an error -ok 316 — chunk(null) throws an error -ok 317 — chunk(This is a string, 2) takes less than 2s to run - -# PASS test/words/words.test.js - -ok 318 — words is a Function -ok 319 — words('I love javaScript!!') returns [I, love, javaScript] -ok 320 — words('python, javaScript & coffee') returns [python, javaScript, coffee] -ok 321 — words(I love javaScript!!) returns an array -ok 322 — words() throws an error -ok 323 — words(null) throws an error -ok 324 — words(undefined) throws an error -ok 325 — words({}) throws an error -ok 326 — words([]) throws an error -ok 327 — words(1234) throws an error - -# PASS test/none/none.test.js - -ok 328 — none is a Function -ok 329 — Returns true for arrays with no truthy values -ok 330 — Returns false for arrays with at least one truthy value -ok 331 — Returns true with a predicate function -ok 332 — Returns false with predicate function - -# PASS test/JSONtoCSV/JSONtoCSV.test.js - -ok 333 — JSONtoCSV is a Function -ok 334 — JSONtoCSV works with default delimiter -ok 335 — JSONtoCSV works with custom delimiter - -# PASS test/uniqueElements/uniqueElements.test.js - -ok 336 — uniqueElements is a Function -ok 337 — uniqueElements([1, 2, 2, 3, 4, 4, 5]) returns [1,2,3,4,5] -ok 338 — uniqueElements([1, 23, 53]) returns [1, 23, 53] -ok 339 — uniqueElements([true, 0, 1, false, false, undefined, null, '']) returns [true, 0, 1, false, false, undefined, null, ''] -ok 340 — uniqueElements() returns [] -ok 341 — uniqueElements(null) returns [] -ok 342 — uniqueElements(undefined) returns [] -ok 343 — uniqueElements('strt') returns ['s', 't', 'r'] -ok 344 — uniqueElements(1, 1, 2543, 534, 5) throws an error -ok 345 — uniqueElements({}) throws an error -ok 346 — uniqueElements(true) throws an error -ok 347 — uniqueElements(false) throws an error -ok 348 — uniqueElements([true, 0, 1, false, false, undefined, null]) takes less than 2s to run - -# PASS test/dig/dig.test.js - -ok 349 — dig is a Function -ok 350 — Dig target success -ok 351 — Dig target with falsey value -ok 352 — Dig target with array -ok 353 — Unknown target return undefined - -# PASS test/uniqueElementsByRight/uniqueElementsByRight.test.js - -ok 354 — uniqueElementsByRight is a Function -ok 355 — uniqueElementsByRight works for properties -ok 356 — uniqueElementsByRight works for nested properties - -# PASS test/mask/mask.test.js - -ok 357 — mask is a Function -ok 358 — Replaces all but the last num of characters with the specified mask character -ok 359 — Replaces all but the last num of characters with the specified mask character -ok 360 — Replaces all but the last num of characters with the specified mask character - -# PASS test/deepClone/deepClone.test.js - -ok 361 — deepClone is a Function -ok 362 — Shallow cloning works -ok 363 — Deep cloning works -ok 364 — Array shallow cloning works -ok 365 — Array deep cloning works - -# PASS test/round/round.test.js - -ok 366 — round is a Function -ok 367 — round(1.005, 2) returns 1.01 -ok 368 — round(123.3423345345345345344, 11) returns 123.34233453453 -ok 369 — round(3.342, 11) returns 3.342 -ok 370 — round(1.005) returns 1 -ok 371 — round([1.005, 2]) returns NaN -ok 372 — round(string) returns NaN -ok 373 — round() returns NaN -ok 374 — round(132, 413, 4134) returns NaN -ok 375 — round({a: 132}, 413) returns NaN -ok 376 — round(123.3423345345345345344, 11) takes less than 2s to run - -# PASS test/binomialCoefficient/binomialCoefficient.test.js - -ok 377 — binomialCoefficient is a Function -ok 378 — Returns the appropriate value -ok 379 — Returns the appropriate value -ok 380 — Returns the appropriate value -ok 381 — Returns NaN -ok 382 — Returns NaN - -# PASS test/isAnagram/isAnagram.test.js - -ok 383 — isAnagram is a Function -ok 384 — Checks valid anagram -ok 385 — Works with spaces -ok 386 — Ignores case -ok 387 — Ignores special characters - -# PASS test/converge/converge.test.js - -ok 388 — converge is a Function -ok 389 — Produces the average of the array -ok 390 — Produces the strange concatenation - -# PASS test/inRange/inRange.test.js - -ok 391 — inRange is a Function -ok 392 — The given number falls within the given range -ok 393 — The given number falls within the given range -ok 394 — The given number does not falls within the given range -ok 395 — The given number does not falls within the given range - -# PASS test/factorial/factorial.test.js - -ok 396 — factorial is a Function -ok 397 — Calculates the factorial of 720 -ok 398 — Calculates the factorial of 0 -ok 399 — Calculates the factorial of 1 -ok 400 — Calculates the factorial of 4 -ok 401 — Calculates the factorial of 10 - -# PASS test/randomHexColorCode/randomHexColorCode.test.js - -ok 402 — randomHexColorCode is a Function -ok 403 — randomHexColorCode has to proper length -ok 404 — The color code starts with "#" -ok 405 — The color code contains only valid hex-digits - -# PASS test/join/join.test.js - -ok 406 — join is a Function -ok 407 — Joins all elements of an array into a string and returns this string -ok 408 — Joins all elements of an array into a string and returns this string -ok 409 — Joins all elements of an array into a string and returns this string - -# PASS test/castArray/castArray.test.js - -ok 410 — castArray is a Function -ok 411 — Works for single values -ok 412 — Works for arrays with one value -ok 413 — Works for arrays with multiple value -ok 414 — Works for strings -ok 415 — Works for objects - -# PASS test/invertKeyValues/invertKeyValues.test.js - -ok 416 — invertKeyValues is a Function -ok 417 — invertKeyValues({ a: 1, b: 2, c: 1 }) returns { 1: [ 'a', 'c' ], 2: [ 'b' ] } -ok 418 — invertKeyValues({ a: 1, b: 2, c: 1 }, value => 'group' + value) returns { group1: [ 'a', 'c' ], group2: [ 'b' ] } +ok 110 — isPrimitive is a Function +ok 111 — isPrimitive(null) is primitive +ok 112 — isPrimitive(undefined) is primitive +ok 113 — isPrimitive(string) is primitive +ok 114 — isPrimitive(true) is primitive +ok 115 — isPrimitive(50) is primitive +ok 116 — isPrimitive('Hello') is primitive +ok 117 — isPrimitive(false) is primitive +ok 118 — isPrimitive(Symbol()) is primitive +ok 119 — isPrimitive([1, 2, 3]) is not primitive +ok 120 — isPrimitive({ a: 123 }) is not primitive +ok 121 — isPrimitive({ a: 123 }) takes less than 2s to run # PASS test/zipObject/zipObject.test.js -ok 419 — zipObject is a Function -ok 420 — zipObject([a, b, c], [1, 2]) returns {a: 1, b: 2, c: undefined} -ok 421 — zipObject([a, b], [1, 2, 3]) returns {a: 1, b: 2} -ok 422 — zipObject([a, b, c], string) returns { a: s, b: t, c: r } -ok 423 — zipObject([a], string) returns { a: s } -ok 424 — zipObject() throws an error -ok 425 — zipObject((['string'], null) throws an error -ok 426 — zipObject(null, [1]) throws an error -ok 427 — zipObject('string') throws an error -ok 428 — zipObject('test', 'string') throws an error - -# PASS test/binarySearch/binarySearch.test.js - -ok 429 — binarySearch is a Function -ok 430 — Finds item in array -ok 431 — Returns -1 when not found -ok 432 — Works with empty arrays -ok 433 — Works for one element arrays - -# PASS test/toOrdinalSuffix/toOrdinalSuffix.test.js - -ok 434 — toOrdinalSuffix is a Function -ok 435 — Adds an ordinal suffix to a number -ok 436 — Adds an ordinal suffix to a number -ok 437 — Adds an ordinal suffix to a number -ok 438 — Adds an ordinal suffix to a number - -# PASS test/uniqueElementsBy/uniqueElementsBy.test.js - -ok 439 — uniqueElementsBy is a Function -ok 440 — uniqueElementsBy works for properties -ok 441 — uniqueElementsBy works for nested properties - -# PASS test/isString/isString.test.js - -ok 442 — isString is a Function -ok 443 — foo is a string -ok 444 — "10" is a string -ok 445 — Empty string is a string -ok 446 — 10 is not a string -ok 447 — true is not string - -# PASS test/stringPermutations/stringPermutations.test.js - -ok 448 — stringPermutations is a Function -ok 449 — Generates all stringPermutations of a string -ok 450 — Works for single-letter strings -ok 451 — Works for empty strings - -# PASS test/tomorrow/tomorrow.test.js - -ok 452 — tomorrow is a Function -ok 453 — Returns the correct year -ok 454 — Returns the correct month -ok 455 — Returns the correct date - -# PASS test/untildify/untildify.test.js - -ok 456 — untildify is a Function -ok 457 — Contains no tildes -ok 458 — Does not alter the rest of the path -ok 459 — Does not alter paths without tildes - -# PASS test/URLJoin/URLJoin.test.js - -ok 460 — URLJoin is a Function -ok 461 — Returns proper URL -ok 462 — Returns proper URL - -# PASS test/dropRight/dropRight.test.js - -ok 463 — dropRight is a Function -ok 464 — Returns a new array with n elements removed from the right -ok 465 — Returns a new array with n elements removed from the right -ok 466 — Returns a new array with n elements removed from the right - -# PASS test/capitalizeEveryWord/capitalizeEveryWord.test.js - -ok 467 — capitalizeEveryWord is a Function -ok 468 — Capitalizes the first letter of every word in a string -ok 469 — Works with characters -ok 470 — Works with one word string - -# PASS test/sortedIndex/sortedIndex.test.js - -ok 471 — sortedIndex is a Function -ok 472 — Returns the lowest index at which value should be inserted into array in order to maintain its sort order. -ok 473 — Returns the lowest index at which value should be inserted into array in order to maintain its sort order. - -# PASS test/unzip/unzip.test.js - -ok 474 — unzip is a Function -ok 475 — unzip([['a', 1, true], ['b', 2, false]]) equals [['a','b'], [1, 2], [true, false]] -ok 476 — unzip([['a', 1, true], ['b', 2]]) equals [['a','b'], [1, 2], [true]] - -# PASS test/hexToRGB/hexToRGB.test.js - -ok 477 — hexToRGB is a Function -ok 478 — Converts a color code to a rgb() or rgba() string -ok 479 — Converts a color code to a rgb() or rgba() string -ok 480 — Converts a color code to a rgb() or rgba() string - -# PASS test/reducedFilter/reducedFilter.test.js - -ok 481 — reducedFilter is a Function -ok 482 — Filter an array of objects based on a condition while also filtering out unspecified keys. - -# PASS test/collectInto/collectInto.test.js - -ok 483 — collectInto is a Function -ok 484 — Works with multiple promises - -# PASS test/uniqueSymmetricDifference/uniqueSymmetricDifference.test.js - -ok 485 — uniqueSymmetricDifference is a Function -ok 486 — Returns the symmetric difference between two arrays. -ok 487 — Does not return duplicates from one array - -# PASS test/sumPower/sumPower.test.js - -ok 488 — sumPower is a Function -ok 489 — Returns the sum of the powers of all the numbers from start to end -ok 490 — Returns the sum of the powers of all the numbers from start to end -ok 491 — Returns the sum of the powers of all the numbers from start to end - -# PASS test/standardDeviation/standardDeviation.test.js - -ok 492 — standardDeviation is a Function -ok 493 — Returns the standard deviation of an array of numbers -ok 494 — Returns the standard deviation of an array of numbers - -# PASS test/shuffle/shuffle.test.js - -ok 495 — shuffle is a Function -ok 496 — Shuffles the array -ok 497 — New array contains all original elements -ok 498 — Works for empty arrays -ok 499 — Works for single-element arrays - -# PASS test/CSVToJSON/CSVToJSON.test.js - -ok 500 — CSVToJSON is a Function -ok 501 — CSVToJSON works with default delimiter -ok 502 — CSVToJSON works with custom delimiter - -# PASS test/isObjectLike/isObjectLike.test.js - -ok 503 — isObjectLike is a Function -ok 504 — Returns true for an object -ok 505 — Returns true for an array -ok 506 — Returns false for a function -ok 507 — Returns false for null - -# PASS test/partition/partition.test.js - -ok 508 — partition is a Function -ok 509 — Groups the elements into two arrays, depending on the provided function's truthiness for each element. - -# PASS test/isObject/isObject.test.js - -ok 510 — isObject is a Function -ok 511 — isObject([1, 2, 3, 4]) is a object -ok 512 — isObject([]) is a object -ok 513 — isObject({ a:1 }) is a object -ok 514 — isObject(true) is not a object - -# PASS test/formatDuration/formatDuration.test.js - -ok 515 — formatDuration is a Function -ok 516 — Returns the human readable format of the given number of milliseconds -ok 517 — Returns the human readable format of the given number of milliseconds - -# PASS test/prettyBytes/prettyBytes.test.js - -ok 518 — prettyBytes is a Function -ok 519 — Converts a number in bytes to a human-readable string. -ok 520 — Converts a number in bytes to a human-readable string. -ok 521 — Converts a number in bytes to a human-readable string. - -# PASS test/isAbsoluteURL/isAbsoluteURL.test.js - -ok 522 — isAbsoluteURL is a Function -ok 523 — Given string is an absolute URL -ok 524 — Given string is an absolute URL -ok 525 — Given string is not an absolute URL - -# PASS test/byteSize/byteSize.test.js - -ok 526 — byteSize is a Function -ok 527 — Works for a single letter -ok 528 — Works for a common string -ok 529 — Works for emoji - -# PASS test/symmetricDifferenceWith/symmetricDifferenceWith.test.js - -ok 530 — symmetricDifferenceWith is a Function -ok 531 — Returns the symmetric difference between two arrays, using a provided function as a comparator - -# PASS test/matches/matches.test.js - -ok 532 — matches is a Function -ok 533 — Matches returns true for two similar objects -ok 534 — Matches returns false for two non-similar objects - -# PASS test/pad/pad.test.js - -ok 535 — pad is a Function -ok 536 — cat is padded on both sides -ok 537 — length of string is 8 -ok 538 — pads 42 with "0" -ok 539 — does not truncates if string exceeds length - -# PASS test/isValidJSON/isValidJSON.test.js - -ok 540 — isValidJSON is a Function -ok 541 — {"name":"Adam","age":20} is a valid JSON -ok 542 — {"name":"Adam",age:"20"} is not a valid JSON -ok 543 — null is a valid JSON - -# PASS test/groupBy/groupBy.test.js - -ok 544 — groupBy is a Function -ok 545 — Groups the elements of an array based on the given function -ok 546 — Groups the elements of an array based on the given function - -# PASS test/uncurry/uncurry.test.js - -ok 547 — uncurry is a Function -ok 548 — Works without a provided value for n -ok 549 — Works with n = 2 -ok 550 — Works with n = 3 - -# PASS test/reject/reject.test.js - -ok 551 — reject is a Function -ok 552 — Works with numbers -ok 553 — Works with strings - -# PASS test/functionName/functionName.test.js - -ok 554 — functionName is a Function -ok 555 — Works for native functions -ok 556 — Works for functions -ok 557 — Works for arrow functions - -# PASS test/lowercaseKeys/lowercaseKeys.test.js - -ok 558 — lowercaseKeys is a Function -ok 559 — Lowercases object keys -ok 560 — Does not mutate original object - -# PASS test/collatz/collatz.test.js - -ok 561 — collatz is a Function -ok 562 — When n is even, divide by 2 -ok 563 — When n is odd, times by 3 and add 1 -ok 564 — Eventually reaches 1 - -# PASS test/matchesWith/matchesWith.test.js - -ok 565 — matchesWith is a Function -ok 566 — Returns true for two objects with similar values, based on the provided function - -# PASS test/UUIDGeneratorNode/UUIDGeneratorNode.test.js - -ok 567 — UUIDGeneratorNode is a Function -ok 568 — Contains dashes in the proper places -ok 569 — Only contains hexadecimal digits - -# PASS test/intersectionWith/intersectionWith.test.js - -ok 570 — intersectionWith is a Function -ok 571 — Returns a list of elements that exist in both arrays, using a provided comparator function - -# PASS test/luhnCheck/luhnCheck.test.js - -ok 572 — luhnCheck is a Function -ok 573 — validates identification number -ok 574 — validates identification number -ok 575 — validates identification number - -# PASS test/drop/drop.test.js - -ok 576 — drop is a Function -ok 577 — Works without the last argument -ok 578 — Removes appropriate element count as specified -ok 579 — Empties array given a count greater than length - -# PASS test/differenceBy/differenceBy.test.js - -ok 580 — differenceBy is a Function -ok 581 — Works using a native function and numbers -ok 582 — Works with arrow function and objects - -# PASS test/memoize/memoize.test.js - -ok 583 — memoize is a Function -ok 584 — Function works properly -ok 585 — Function works properly -ok 586 — Cache stores values - -# PASS test/functions/functions.test.js - -ok 587 — functions is a Function -ok 588 — Returns own methods -ok 589 — Returns own and inherited methods - -# PASS test/pipeAsyncFunctions/pipeAsyncFunctions.test.js - -ok 590 — pipeAsyncFunctions is a Function -ok 591 — pipeAsyncFunctions result should be 15 - -# PASS test/renameKeys/renameKeys.test.js - -ok 592 — renameKeys is a Function -ok 593 — renameKeys is a Function - -# PASS test/symmetricDifference/symmetricDifference.test.js - -ok 594 — symmetricDifference is a Function -ok 595 — Returns the symmetric difference between two arrays. -ok 596 — Returns duplicates from one array - -# PASS test/nthArg/nthArg.test.js - -ok 597 — nthArg is a Function -ok 598 — Returns the nth argument -ok 599 — Returns undefined if arguments too few -ok 600 — Works for negative values - -# PASS test/isPromiseLike/isPromiseLike.test.js - -ok 601 — isPromiseLike is a Function -ok 602 — Returns true for a promise-like object -ok 603 — Returns false for an empty object - -# PASS test/findLastKey/findLastKey.test.js - -ok 604 — findLastKey is a Function -ok 605 — eturns the appropriate key - -# PASS test/elo/elo.test.js - -ok 606 — elo is a Function -ok 607 — Standard 1v1s -ok 608 — Standard 1v1s -ok 609 — 4 player FFA, all same rank - -# PASS test/isArrayLike/isArrayLike.test.js - -ok 610 — isArrayLike is a Function -ok 611 — Returns true for a string -ok 612 — Returns true for an array -ok 613 — Returns false for null - -# PASS test/sample/sample.test.js - -ok 614 — sample is a Function -ok 615 — Returns a random element from the array -ok 616 — Works for single-element arrays -ok 617 — Returns undefined for empty array - -# PASS test/isLowerCase/isLowerCase.test.js - -ok 618 — isLowerCase is a Function -ok 619 — passed string is a lowercase -ok 620 — passed string is a lowercase -ok 621 — passed value is not a lowercase - -# PASS test/symmetricDifferenceBy/symmetricDifferenceBy.test.js - -ok 622 — symmetricDifferenceBy is a Function -ok 623 — Returns the symmetric difference between two arrays, after applying the provided function to each array element of both - -# PASS test/bindKey/bindKey.test.js - -ok 624 — bindKey is a Function -ok 625 — Binds function to an object context - -# PASS test/flattenObject/flattenObject.test.js - -ok 626 — flattenObject is a Function -ok 627 — Flattens an object with the paths for keys -ok 628 — Works with arrays - -# PASS test/averageBy/averageBy.test.js - -ok 629 — averageBy is a Function -ok 630 — Produces the right result with a function -ok 631 — Produces the right result with a property name - -# PASS test/arrayToCSV/arrayToCSV.test.js - -ok 632 — arrayToCSV is a Function -ok 633 — arrayToCSV works with default delimiter -ok 634 — arrayToCSV works with custom delimiter - -# PASS test/unzipWith/unzipWith.test.js - -ok 635 — unzipWith is a Function -ok 636 — unzipWith([[1, 10, 100], [2, 20, 200]], (...args) => args.reduce((acc, v) => acc + v, 0)) equals [3, 30, 300] - -# PASS test/findKey/findKey.test.js - -ok 637 — findKey is a Function -ok 638 — Returns the appropriate key - -# PASS test/pullAtValue/pullAtValue.test.js - -ok 639 — pullAtValue is a Function -ok 640 — Pulls the specified values -ok 641 — Pulls the specified values - -# PASS test/merge/merge.test.js - -ok 642 — merge is a Function -ok 643 — Merges two objects - -# PASS test/pullAtIndex/pullAtIndex.test.js - -ok 644 — pullAtIndex is a Function -ok 645 — Pulls the given values -ok 646 — Pulls the given values - -# PASS test/truthCheckCollection/truthCheckCollection.test.js - -ok 647 — truthCheckCollection is a Function -ok 648 — second argument is truthy on all elements of a collection - -# PASS test/promisify/promisify.test.js - -ok 649 — promisify is a Function -ok 650 — Returns a promise -ok 651 — Runs the function provided - -# PASS test/takeRight/takeRight.test.js - -ok 652 — takeRight is a Function -ok 653 — Returns an array with n elements removed from the end -ok 654 — Returns an array with n elements removed from the end - -# PASS test/runPromisesInSeries/runPromisesInSeries.test.js - -ok 655 — runPromisesInSeries is a Function -ok 656 — Runs promises in series - -# PASS test/isUpperCase/isUpperCase.test.js - -ok 657 — isUpperCase is a Function -ok 658 — ABC is all upper case -ok 659 — abc is not all upper case -ok 660 — A3@$ is all uppercase - -# PASS test/minBy/minBy.test.js - -ok 661 — minBy is a Function -ok 662 — Produces the right result with a function -ok 663 — Produces the right result with a property name - -# PASS test/reduceSuccessive/reduceSuccessive.test.js - -ok 664 — reduceSuccessive is a Function -ok 665 — Returns the array of successively reduced values - -# PASS test/getURLParameters/getURLParameters.test.js - -ok 666 — getURLParameters is a Function -ok 667 — Returns an object containing the parameters of the current URL - -# PASS test/transform/transform.test.js - -ok 668 — transform is a Function -ok 669 — Transforms an object - -# PASS test/maxBy/maxBy.test.js - -ok 670 — maxBy is a Function -ok 671 — Produces the right result with a function -ok 672 — Produces the right result with a property name - -# PASS test/gcd/gcd.test.js - -ok 673 — gcd is a Function -ok 674 — Calculates the greatest common divisor between two or more numbers/arrays -ok 675 — Calculates the greatest common divisor between two or more numbers/arrays - -# PASS test/extendHex/extendHex.test.js - -ok 676 — extendHex is a Function -ok 677 — Extends a 3-digit color code to a 6-digit color code -ok 678 — Extends a 3-digit color code to a 6-digit color code - -# PASS test/pipeFunctions/pipeFunctions.test.js - -ok 679 — pipeFunctions is a Function -ok 680 — Performs left-to-right function composition - -# PASS test/isTravisCI/isTravisCI.test.js - -ok 681 — isTravisCI is a Function -ok 682 — Running on Travis, correctly evaluates - -# PASS test/take/take.test.js - -ok 683 — take is a Function -ok 684 — Returns an array with n elements removed from the beginning. -ok 685 — Returns an array with n elements removed from the beginning. - -# PASS test/coalesceFactory/coalesceFactory.test.js - -ok 686 — coalesceFactory is a Function -ok 687 — Returns a customized coalesce function - -# PASS test/bind/bind.test.js - -ok 688 — bind is a Function -ok 689 — Binds to an object context - -# PASS test/isNil/isNil.test.js - -ok 690 — isNil is a Function -ok 691 — Returns true for null -ok 692 — Returns true for undefined -ok 693 — Returns false for an empty string - -# PASS test/intersectionBy/intersectionBy.test.js - -ok 694 — intersectionBy is a Function -ok 695 — Returns a list of elements that exist in both arrays, after applying the provided function to each array element of both - -# PASS test/isPlainObject/isPlainObject.test.js - -ok 696 — isPlainObject is a Function -ok 697 — Returns true for a plain object -ok 698 — Returns false for a Map (example of non-plain object) - -# PASS test/spreadOver/spreadOver.test.js - -ok 699 — spreadOver is a Function -ok 700 — Takes a variadic function and returns a closure that accepts an array of arguments to map to the inputs of the function. - -# PASS test/nthElement/nthElement.test.js - -ok 701 — nthElement is a Function -ok 702 — Returns the nth element of an array. -ok 703 — Returns the nth element of an array. - -# PASS test/shallowClone/shallowClone.test.js - -ok 704 — shallowClone is a Function -ok 705 — Shallow cloning works -ok 706 — Does not clone deeply - -# PASS test/overArgs/overArgs.test.js - -ok 707 — overArgs is a Function -ok 708 — Invokes the provided function with its arguments transformed - -# PASS test/indexOfAll/indexOfAll.test.js - -ok 709 — indexOfAll is a Function -ok 710 — Returns all indices of val in an array -ok 711 — Returns all indices of val in an array - -# PASS test/decapitalize/decapitalize.test.js - -ok 712 — decapitalize is a Function -ok 713 — Works with default parameter -ok 714 — Works with second parameter set to true - -# PASS test/hashNode/hashNode.test.js - -ok 715 — hashNode is a Function -ok 716 — Produces the appropriate hash - -# PASS test/chainAsync/chainAsync.test.js - -ok 717 — chainAsync is a Function -ok 718 — Calls all functions in an array - -# PASS test/cleanObj/cleanObj.test.js - -ok 719 — cleanObj is a Function -ok 720 — Removes any properties except the ones specified from a JSON object - -# PASS test/countBy/countBy.test.js - -ok 721 — countBy is a Function -ok 722 — Works for functions -ok 723 — Works for property names - -# PASS test/partialRight/partialRight.test.js - -ok 724 — partialRight is a Function -ok 725 — Appends arguments - -# PASS test/getDaysDiffBetweenDates/getDaysDiffBetweenDates.test.js - -ok 726 — getDaysDiffBetweenDates is a Function -ok 727 — Returns the difference in days between two dates - -# PASS test/minN/minN.test.js - -ok 728 — minN is a Function -ok 729 — Returns the n minimum elements from the provided array -ok 730 — Returns the n minimum elements from the provided array - -# PASS test/splitLines/splitLines.test.js - -ok 731 — splitLines is a Function -ok 732 — Splits a multiline string into an array of lines. - -# PASS test/composeRight/composeRight.test.js - -ok 733 — composeRight is a Function -ok 734 — Performs left-to-right function composition - -# PASS test/when/when.test.js - -ok 735 — when is a Function -ok 736 — Returns the proper result -ok 737 — Returns the proper result - -# PASS test/maxN/maxN.test.js - -ok 738 — maxN is a Function -ok 739 — Returns the n maximum elements from the provided array -ok 740 — Returns the n maximum elements from the provided array - -# PASS test/permutations/permutations.test.js - -ok 741 — permutations is a Function -ok 742 — Generates all permutations of an array - -# PASS test/initializeArrayWithValues/initializeArrayWithValues.test.js - -ok 743 — initializeArrayWithValues is a Function -ok 744 — Initializes and fills an array with the specified values - -# PASS test/compose/compose.test.js - -ok 745 — compose is a Function -ok 746 — Performs right-to-left function composition - -# PASS test/sortedLastIndexBy/sortedLastIndexBy.test.js - -ok 747 — sortedLastIndexBy is a Function -ok 748 — Returns the highest index to insert the element without messing up the list order - -# PASS test/mapValues/mapValues.test.js - -ok 749 — mapValues is a Function -ok 750 — Maps values - -# PASS test/percentile/percentile.test.js - -ok 751 — percentile is a Function -ok 752 — Uses the percentile formula to calculate how many numbers in the given array are less or equal to the given value. - -# PASS test/flatten/flatten.test.js - -ok 753 — flatten is a Function -ok 754 — Flattens an array -ok 755 — Flattens an array - -# PASS test/unionWith/unionWith.test.js - -ok 756 — unionWith is a Function -ok 757 — Produces the appropriate results - -# PASS test/partial/partial.test.js - -ok 758 — partial is a Function -ok 759 — Prepends arguments - -# PASS test/differenceWith/differenceWith.test.js - -ok 760 — differenceWith is a Function -ok 761 — Filters out all values from an array - -# PASS test/palindrome/palindrome.test.js - -ok 762 — palindrome is a Function -ok 763 — Given string is a palindrome -ok 764 — Given string is not a palindrome - -# PASS test/bifurcateBy/bifurcateBy.test.js - -ok 765 — bifurcateBy is a Function -ok 766 — Splits the collection into two groups - -# PASS test/bindAll/bindAll.test.js - -ok 767 — bindAll is a Function -ok 768 — Binds to an object context - -# PASS test/dropRightWhile/dropRightWhile.test.js - -ok 769 — dropRightWhile is a Function -ok 770 — Removes elements from the end of an array until the passed function returns true. - -# PASS test/lcm/lcm.test.js - -ok 771 — lcm is a Function -ok 772 — Returns the least common multiple of two or more numbers. -ok 773 — Returns the least common multiple of two or more numbers. - -# PASS test/median/median.test.js - -ok 774 — median is a Function -ok 775 — Returns the median of an array of numbers -ok 776 — Returns the median of an array of numbers - -# PASS test/degreesToRads/degreesToRads.test.js - -ok 777 — degreesToRads is a Function -ok 778 — Returns the appropriate value - -# PASS test/attempt/attempt.test.js - -ok 779 — attempt is a Function -ok 780 — Returns a value -ok 781 — Returns an error - -# PASS test/sortedIndexBy/sortedIndexBy.test.js - -ok 782 — sortedIndexBy is a Function -ok 783 — Returns the lowest index to insert the element without messing up the list order - -# PASS test/forOwnRight/forOwnRight.test.js - -ok 784 — forOwnRight is a Function -ok 785 — Iterates over an element's key-value pairs in reverse - -# PASS test/bifurcate/bifurcate.test.js - -ok 786 — bifurcate is a Function -ok 787 — Splits the collection into two groups - -# PASS test/size/size.test.js - -ok 788 — size is a Function -ok 789 — Get size of arrays, objects or strings. -ok 790 — Get size of arrays, objects or strings. - -# PASS test/compact/compact.test.js - -ok 791 — compact is a Function -ok 792 — Removes falsey values from an array - -# PASS test/sortedLastIndex/sortedLastIndex.test.js - -ok 793 — sortedLastIndex is a Function -ok 794 — Returns the highest index to insert the element without messing up the list order - -# PASS test/rearg/rearg.test.js - -ok 795 — rearg is a Function -ok 796 — Reorders arguments in invoked function - -# PASS test/unescapeHTML/unescapeHTML.test.js - -ok 797 — unescapeHTML is a Function -ok 798 — Unescapes escaped HTML characters. - -# PASS test/flip/flip.test.js - -ok 799 — flip is a Function -ok 800 — Flips argument order - -# PASS test/isFunction/isFunction.test.js - -ok 801 — isFunction is a Function -ok 802 — passed value is a function -ok 803 — passed value is not a function - -# PASS test/pickBy/pickBy.test.js - -ok 804 — pickBy is a Function -ok 805 — Creates an object composed of the properties the given function returns truthy for. - -# PASS test/omitBy/omitBy.test.js - -ok 806 — omitBy is a Function -ok 807 — Creates an object composed of the properties the given function returns falsey for - -# PASS test/isBoolean/isBoolean.test.js - -ok 808 — isBoolean is a Function -ok 809 — passed value is not a boolean -ok 810 — passed value is not a boolean - -# PASS test/initialize2DArray/initialize2DArray.test.js - -ok 811 — initialize2DArray is a Function -ok 812 — Initializes a 2D array of given width and height and value - -# PASS test/unflattenObject/unflattenObject.test.js - -ok 813 — unflattenObject is a Function -ok 814 — Unflattens an object with the paths for keys - -# PASS test/sortCharactersInString/sortCharactersInString.test.js - -ok 815 — sortCharactersInString is a Function -ok 816 — Alphabetically sorts the characters in a string. - -# PASS test/get/get.test.js - -ok 817 — get is a Function -ok 818 — Retrieve a property indicated by the selector from an object. - -# PASS test/escapeHTML/escapeHTML.test.js - -ok 819 — escapeHTML is a Function -ok 820 — Escapes a string for use in HTML - -# PASS test/pullBy/pullBy.test.js - -ok 821 — pullBy is a Function -ok 822 — Pulls the specified values - -# PASS test/objectFromPairs/objectFromPairs.test.js - -ok 823 — objectFromPairs is a Function -ok 824 — Creates an object from the given key-value pairs. - -# PASS test/objectToPairs/objectToPairs.test.js - -ok 825 — objectToPairs is a Function -ok 826 — Creates an array of key-value pair arrays from an object. - -# PASS test/findLastIndex/findLastIndex.test.js - -ok 827 — findLastIndex is a Function -ok 828 — Finds last index for which the given function returns true - -# PASS test/stableSort/stableSort.test.js - -ok 829 — stableSort is a Function -ok 830 — Array is properly sorted - -# PASS test/isNumber/isNumber.test.js - -ok 831 — isNumber is a Function -ok 832 — passed argument is a number -ok 833 — passed argument is not a number - -# PASS test/unfold/unfold.test.js - -ok 834 — unfold is a Function -ok 835 — Works with a given function, producing an array - -# PASS test/isArray/isArray.test.js - -ok 836 — isArray is a Function -ok 837 — passed value is an array -ok 838 — passed value is not an array - -# PASS test/forEachRight/forEachRight.test.js - -ok 839 — forEachRight is a Function -ok 840 — Iterates over the array in reverse - -# PASS test/takeRightWhile/takeRightWhile.test.js - -ok 841 — takeRightWhile is a Function -ok 842 — Removes elements until the function returns true - -# PASS test/xProd/xProd.test.js - -ok 843 — xProd is a Function -ok 844 — xProd([1, 2], ['a', 'b']) returns [[1, 'a'], [1, 'b'], [2, 'a'], [2, 'b']] - -# PASS test/isNull/isNull.test.js - -ok 845 — isNull is a Function -ok 846 — passed argument is a null -ok 847 — passed argument is a null - -# PASS test/stripHTMLTags/stripHTMLTags.test.js - -ok 848 — stripHTMLTags is a Function -ok 849 — Removes HTML tags - -# PASS test/pick/pick.test.js - -ok 850 — pick is a Function -ok 851 — Picks the key-value pairs corresponding to the given keys from an object. - -# PASS test/toDecimalMark/toDecimalMark.test.js - -ok 852 — toDecimalMark is a Function -ok 853 — convert a float-point arithmetic to the Decimal mark form - -# PASS test/remove/remove.test.js - -ok 854 — remove is a Function -ok 855 — Removes elements from an array for which the given function returns false - -# PASS test/filterNonUnique/filterNonUnique.test.js - -ok 856 — filterNonUnique is a Function -ok 857 — Filters out the non-unique values in an array - -# PASS test/curry/curry.test.js - -ok 858 — curry is a Function -ok 859 — curries a Math.pow -ok 860 — curries a Math.min - -# PASS test/ary/ary.test.js - -ok 861 — ary is a Function -ok 862 — Discards arguments with index >=n - -# PASS test/truncateString/truncateString.test.js - -ok 863 — truncateString is a Function -ok 864 — Truncates a "boomerang" up to a specified length. - -# PASS test/similarity/similarity.test.js - -ok 865 — similarity is a Function -ok 866 — Returns an array of elements that appear in both arrays. - -# PASS test/omit/omit.test.js - -ok 867 — omit is a Function -ok 868 — Omits the key-value pairs corresponding to the given keys from an object - -# PASS test/delay/delay.test.js - -ok 869 — delay is a Function -ok 870 — Works as expecting, passing arguments properly - -# PASS test/defaults/defaults.test.js - -ok 871 — defaults is a Function -ok 872 — Assigns default values for undefined properties - -# PASS test/removeNonASCII/removeNonASCII.test.js - -ok 873 — removeNonASCII is a Function -ok 874 — Removes non-ASCII characters - -# PASS test/forOwn/forOwn.test.js - -ok 875 — forOwn is a Function -ok 876 — Iterates over an element's key-value pairs - -# PASS test/countOccurrences/countOccurrences.test.js - -ok 877 — countOccurrences is a Function -ok 878 — Counts the occurrences of a value in an array - -# PASS test/dropWhile/dropWhile.test.js - -ok 879 — dropWhile is a Function -ok 880 — Removes elements in an array until the passed function returns true. - -# PASS test/intersection/intersection.test.js - -ok 881 — intersection is a Function -ok 882 — Returns a list of elements that exist in both arrays - -# PASS test/over/over.test.js - -ok 883 — over is a Function -ok 884 — Applies given functions over multiple arguments - -# PASS test/pull/pull.test.js - -ok 885 — pull is a Function -ok 886 — Pulls the specified values - -# PASS test/findLast/findLast.test.js - -ok 887 — findLast is a Function -ok 888 — Finds last element for which the given function returns true - -# PASS test/takeWhile/takeWhile.test.js - -ok 889 — takeWhile is a Function -ok 890 — Removes elements until the function returns true - -# PASS test/isEven/isEven.test.js - -ok 891 — isEven is a Function -ok 892 — 4 is even number -ok 893 — 5 is not an even number - -# PASS test/escapeRegExp/escapeRegExp.test.js - -ok 894 — escapeRegExp is a Function -ok 895 — Escapes a string to use in a regular expression - -# PASS test/clampNumber/clampNumber.test.js - -ok 896 — clampNumber is a Function -ok 897 — Clamps num within the inclusive range specified by the boundary values a and b - -# PASS test/coalesce/coalesce.test.js - -ok 898 — coalesce is a Function -ok 899 — Returns the first non-null/undefined argument - -# PASS test/cloneRegExp/cloneRegExp.test.js - -ok 900 — cloneRegExp is a Function -ok 901 — Clones regular expressions properly - -# PASS test/parseCookie/parseCookie.test.js - -ok 902 — parseCookie is a Function -ok 903 — Parses the cookie - -# PASS test/atob/atob.test.js - -ok 904 — atob is a Function -ok 905 — atob("Zm9vYmFy") equals "foobar" -ok 906 — atob("Z") returns "" - -# PASS test/distance/distance.test.js - -ok 907 — distance is a Function -ok 908 — Calculates the distance between two points - -# PASS test/fibonacci/fibonacci.test.js - -ok 909 — fibonacci is a Function -ok 910 — Generates an array, containing the Fibonacci sequence - -# PASS test/tail/tail.test.js - -ok 911 — tail is a Function -ok 912 — Returns tail -ok 913 — Returns tail - -# PASS test/hammingDistance/hammingDistance.test.js - -ok 914 — hammingDistance is a Function -ok 915 — retuns hamming disance between 2 values - -# PASS test/negate/negate.test.js - -ok 916 — negate is a Function -ok 917 — Negates a predicate function - -# PASS test/times/times.test.js - -ok 918 — times is a Function -ok 919 — Runs a function the specified amount of times - -# PASS test/primes/primes.test.js - -ok 920 — primes is a Function -ok 921 — Generates primes up to a given number, using the Sieve of Eratosthenes. - -# PASS test/powerset/powerset.test.js - -ok 922 — powerset is a Function -ok 923 — Returns the powerset of a given array of numbers. - -# PASS test/serializeCookie/serializeCookie.test.js - -ok 924 — serializeCookie is a Function -ok 925 — Serializes the cookie - -# PASS test/difference/difference.test.js - -ok 926 — difference is a Function -ok 927 — Returns the difference between two arrays - -# PASS test/RGBToHex/RGBToHex.test.js - -ok 928 — RGBToHex is a Function -ok 929 — Converts the values of RGB components to a color code. - -# PASS test/initial/initial.test.js - -ok 930 — initial is a Function -ok 931 — Returns all the elements of an array except the last one - -# PASS test/unary/unary.test.js - -ok 932 — unary is a Function -ok 933 — Discards arguments after the first one - -# PASS test/reverseString/reverseString.test.js - -ok 934 — reverseString is a Function -ok 935 — Reverses a string. - -# PASS test/radsToDegrees/radsToDegrees.test.js - -ok 936 — radsToDegrees is a Function -ok 937 — Returns the appropriate value - -# PASS test/unionBy/unionBy.test.js - -ok 938 — unionBy is a Function -ok 939 — Produces the appropriate results - -# PASS test/everyNth/everyNth.test.js - -ok 940 — everyNth is a Function -ok 941 — Returns every nth element in an array - -# PASS test/deepFlatten/deepFlatten.test.js - -ok 942 — deepFlatten is a Function -ok 943 — Deep flattens an array - -# PASS test/sleep/sleep.test.js - -ok 944 — sleep is a Function -ok 945 — Works as expected - -# PASS test/isUndefined/isUndefined.test.js - -ok 946 — isUndefined is a Function -ok 947 — Returns true for undefined - -# PASS test/isSymbol/isSymbol.test.js - -ok 948 — isSymbol is a Function -ok 949 — Checks if the given argument is a symbol - -# PASS test/isDivisible/isDivisible.test.js - -ok 950 — isDivisible is a Function -ok 951 — The number 6 is divisible by 3 - -# PASS test/digitize/digitize.test.js - -ok 952 — digitize is a Function -ok 953 — Converts a number to an array of digits - -# PASS test/call/call.test.js - -ok 954 — call is a Function -ok 955 — Calls function on given object - -# PASS test/mapKeys/mapKeys.test.js - -ok 956 — mapKeys is a Function -ok 957 — Maps keys - -# PASS test/debounce/debounce.test.js - -ok 958 — debounce is a Function -ok 959 — Works as expected - -# PASS test/getType/getType.test.js - -ok 960 — getType is a Function -ok 961 — Returns the native type of a value - -# PASS test/sdbm/sdbm.test.js - -ok 962 — sdbm is a Function -ok 963 — Hashes the input string into a whole number. - -# PASS test/btoa/btoa.test.js - -ok 964 — btoa is a Function -ok 965 — btoa("foobar") equals "Zm9vYmFy" - -# PASS test/sum/sum.test.js - -ok 966 — sum is a Function -ok 967 — Returns the sum of two or more numbers/arrays. - -# PASS test/isPrime/isPrime.test.js - -ok 968 — isPrime is a Function -ok 969 — passed number is a prime - -# PASS test/initializeArrayWithRangeRight/initializeArrayWithRangeRight.test.js - -ok 970 — initializeArrayWithRangeRight is a Function - -# PASS test/getMeridiemSuffixOfInteger/getMeridiemSuffixOfInteger.test.js - -ok 971 — getMeridiemSuffixOfInteger is a Function - -# PASS test/elementIsVisibleInViewport/elementIsVisibleInViewport.test.js - -ok 972 — elementIsVisibleInViewport is a Function - -# PASS test/isArmstrongNumber/isArmstrongNumber.test.js - -ok 973 — isArmstrongNumber is a Function - -# PASS test/initializeNDArray/initializeNDArray.test.js - -ok 974 — initializeNDArray is a Function - -# PASS test/copyToClipboard/copyToClipboard.test.js - -ok 975 — copyToClipboard is a Function - -# PASS test/UUIDGeneratorBrowser/UUIDGeneratorBrowser.test.js - -ok 976 — UUIDGeneratorBrowser is a Function - -# PASS test/arrayToHtmlList/arrayToHtmlList.test.js - -ok 977 — arrayToHtmlList is a Function - -# PASS test/speechSynthesis/speechSynthesis.test.js - -ok 978 — speechSynthesis is a Function - -# PASS test/isBrowserTabFocused/isBrowserTabFocused.test.js - -ok 979 — isBrowserTabFocused is a Function - -# PASS test/getColonTimeFromDate/getColonTimeFromDate.test.js - -ok 980 — getColonTimeFromDate is a Function - -# PASS test/mostPerformant/mostPerformant.test.js - -ok 981 — mostPerformant is a Function - -# PASS test/fibonacciCountUntilNum/fibonacciCountUntilNum.test.js - -ok 982 — fibonacciCountUntilNum is a Function - -# PASS test/bottomVisible/bottomVisible.test.js - -ok 983 — bottomVisible is a Function - -# PASS test/recordAnimationFrames/recordAnimationFrames.test.js - -ok 984 — recordAnimationFrames is a Function - -# PASS test/createEventHub/createEventHub.test.js - -ok 985 — createEventHub is a Function - -# PASS test/isArrayBuffer/isArrayBuffer.test.js - -ok 986 — isArrayBuffer is a Function - -# PASS test/createElement/createElement.test.js - -ok 987 — createElement is a Function - -# PASS test/httpsRedirect/httpsRedirect.test.js - -ok 988 — httpsRedirect is a Function - -# PASS test/readFileLines/readFileLines.test.js - -ok 989 — readFileLines is a Function - -# PASS test/detectDeviceType/detectDeviceType.test.js - -ok 990 — detectDeviceType is a Function - -# PASS test/isTypedArray/isTypedArray.test.js - -ok 991 — isTypedArray is a Function - -# PASS test/getScrollPosition/getScrollPosition.test.js - -ok 992 — getScrollPosition is a Function - -# PASS test/nodeListToArray/nodeListToArray.test.js - -ok 993 — nodeListToArray is a Function - -# PASS test/fibonacciUntilNum/fibonacciUntilNum.test.js - -ok 994 — fibonacciUntilNum is a Function - -# PASS test/triggerEvent/triggerEvent.test.js - -ok 995 — triggerEvent is a Function - -# PASS test/observeMutations/observeMutations.test.js - -ok 996 — observeMutations is a Function - -# PASS test/onUserInputChange/onUserInputChange.test.js - -ok 997 — onUserInputChange is a Function - -# PASS test/levenshteinDistance/levenshteinDistance.test.js - -ok 998 — levenshteinDistance is a Function - -# PASS test/elementContains/elementContains.test.js - -ok 999 — elementContains is a Function - -# PASS test/smoothScroll/smoothScroll.test.js - -ok 1000 — smoothScroll is a Function - -# PASS test/insertBefore/insertBefore.test.js - -ok 1001 — insertBefore is a Function - -# PASS test/removeVowels/removeVowels.test.js - -ok 1002 — removeVowels is a Function - -# PASS test/howManyTimes/howManyTimes.test.js - -ok 1003 — howManyTimes is a Function - -# PASS test/insertAfter/insertAfter.test.js - -ok 1004 — insertAfter is a Function - -# PASS test/toggleClass/toggleClass.test.js - -ok 1005 — toggleClass is a Function - -# PASS test/scrollToTop/scrollToTop.test.js - -ok 1006 — scrollToTop is a Function - -# PASS test/httpDelete/httpDelete.test.js - -ok 1007 — httpDelete is a Function - -# PASS test/countVowels/countVowels.test.js - -ok 1008 — countVowels is a Function - -# PASS test/JSONToDate/JSONToDate.test.js - -ok 1009 — JSONToDate is a Function - -# PASS test/deepFreeze/deepFreeze.test.js - -ok 1010 — deepFreeze is a Function - -# PASS test/JSONToFile/JSONToFile.test.js - -ok 1011 — JSONToFile is a Function - -# PASS test/currentURL/currentURL.test.js - -ok 1012 — currentURL is a Function - -# PASS test/isWeakSet/isWeakSet.test.js - -ok 1013 — isWeakSet is a Function - -# PASS test/isSimilar/isSimilar.test.js - -ok 1014 — isSimilar is a Function - -# PASS test/timeTaken/timeTaken.test.js - -ok 1015 — timeTaken is a Function - -# PASS test/isBrowser/isBrowser.test.js - -ok 1016 — isBrowser is a Function - -# PASS test/getStyle/getStyle.test.js - -ok 1017 — getStyle is a Function - -# PASS test/redirect/redirect.test.js - -ok 1018 — redirect is a Function - -# PASS test/hashBrowser/hashBrowser.test.js - -ok 1019 — hashBrowser is a Function - -# PASS test/hasFlags/hasFlags.test.js - -ok 1020 — hasFlags is a Function - -# PASS test/setStyle/setStyle.test.js - -ok 1021 — setStyle is a Function - -# PASS test/isRegExp/isRegExp.test.js - -ok 1022 — isRegExp is a Function - -# PASS test/isWeakMap/isWeakMap.test.js - -ok 1023 — isWeakMap is a Function - -# PASS test/colorize/colorize.test.js - -ok 1024 — colorize is a Function - -# PASS test/throttle/throttle.test.js - -ok 1025 — throttle is a Function - -# PASS test/httpPut/httpPut.test.js - -ok 1026 — httpPut is a Function - -# PASS test/hasClass/hasClass.test.js - -ok 1027 — hasClass is a Function - -# PASS test/solveRPN/solveRPN.test.js - -ok 1028 — solveRPN is a Function - -# PASS test/httpPost/httpPost.test.js - -ok 1029 — httpPost is a Function - -# PASS test/counter/counter.test.js - -ok 1030 — counter is a Function - -# PASS test/runAsync/runAsync.test.js - -ok 1031 — runAsync is a Function - -# PASS test/zipWith/zipWith.test.js - -ok 1032 — zipWith is a Function - -# PASS test/factors/factors.test.js - -ok 1033 — factors is a Function - -# PASS test/defer/defer.test.js - -ok 1034 — defer is a Function - -# PASS test/httpGet/httpGet.test.js - -ok 1035 — httpGet is a Function - -# PASS test/off/off.test.js - -ok 1036 — off is a Function - -# PASS test/on/on.test.js - -ok 1037 — on is a Function - -# PASS test/hz/hz.test.js - -ok 1038 — hz is a Function - -# PASS test/toHash/toHash.test.js - -ok 1039 — toHash is a Function - -# PASS test/isSet/isSet.test.js - -ok 1040 — isSet is a Function - -# PASS test/sumBy/sumBy.test.js - -ok 1041 — sumBy is a Function - -# PASS test/show/show.test.js - -ok 1042 — show is a Function - -# PASS test/once/once.test.js - -ok 1043 — once is a Function - -# PASS test/prefix/prefix.test.js - -ok 1044 — prefix is a Function - -# PASS test/isMap/isMap.test.js - -ok 1045 — isMap is a Function - -# PASS test/hide/hide.test.js - -ok 1046 — hide is a Function - -# PASS test/nest/nest.test.js - -ok 1047 — nest is a Function - -1..1047 - -# Test Suites: 100% ██████████, 347 passed, 347 total -# Tests: 100% ██████████, 1047 passed, 1047 total -# Time: 48.693s - -# Ran all test suites. - +ok 122 — zipObject is a Function +ok 123 — zipObject([a, b, c], [1, 2]) returns {a: 1, b: 2, c: undefined} +ok 124 — zipObject([a, b], [1, 2, 3]) returns {a: 1, b: 2} +ok 125 — zipObject([a, b, c], string) returns { a: s, b: t, c: r } +ok 126 — zipObject([a], string) returns { a: s } +ok 127 — zipObject() throws an error +ok 128 — zipObject((['string'], null) throws an error +ok 129 — zipObject(null, [1]) throws an error +ok 130 — zipObject('string') throws an error +ok 131 — zipObject('test', 'string') throws an error + +# PASS test/quickSort/quickSort.test.js + +ok 132 — quickSort is a Function +ok 133 — quickSort([5, 6, 4, 3, 1, 2]) returns [1, 2, 3, 4, 5, 6] +ok 134 — quickSort([-1, 0, -2]) returns [-2, -1, 0] +ok 135 — quickSort() throws an error +ok 136 — quickSort(123) throws an error +ok 137 — quickSort({ 234: string}) throws an error +ok 138 — quickSort(null) throws an error +ok 139 — quickSort(undefined) throws an error +ok 140 — quickSort([11, 1, 324, 23232, -1, 53, 2, 524, 32, 13, 156, 133, 62, 12, 4]) takes less than 2s to run + +# PASS test/round/round.test.js + +ok 141 — round is a Function +ok 142 — round(1.005, 2) returns 1.01 +ok 143 — round(123.3423345345345345344, 11) returns 123.34233453453 +ok 144 — round(3.342, 11) returns 3.342 +ok 145 — round(1.005) returns 1 +ok 146 — round([1.005, 2]) returns NaN +ok 147 — round(string) returns NaN +ok 148 — round() returns NaN +ok 149 — round(132, 413, 4134) returns NaN +ok 150 — round({a: 132}, 413) returns NaN +ok 151 — round(123.3423345345345345344, 11) takes less than 2s to run + +# PASS test/yesNo/yesNo.test.js + +ok 152 — yesNo is a Function +ok 153 — yesNo(Y) returns true +ok 154 — yesNo(yes) returns true +ok 155 — yesNo(foo, true) returns true +ok 156 — yesNo(No) returns false +ok 157 — yesNo() returns false +ok 158 — yesNo(null) returns false +ok 159 — yesNo(undefined) returns false +ok 160 — yesNo([123, null]) returns false +ok 161 — yesNo([Yes, No]) returns false +ok 162 — yesNo({ 2: Yes }) returns false +ok 163 — yesNo([Yes, No], true) returns true +ok 164 — yesNo({ 2: Yes }, true) returns true + +# PASS test/isSorted/isSorted.test.js + +ok 165 — isSorted is a Function +ok 166 — Array is sorted in ascending order +ok 167 — Array is sorted in ascending order +ok 168 — Array is sorted in ascending order +ok 169 — Array is sorted in ascending order +ok 170 — Array is sorted in descending order +ok 171 — Array is sorted in descending order +ok 172 — Array is sorted in descending order +ok 173 — Array is sorted in descending order +ok 174 — Array is empty +ok 175 — Array is not sorted, direction changed in array +ok 176 — Array is not sorted, direction changed in array + +# PASS test/words/words.test.js + +ok 177 — words is a Function +ok 178 — words('I love javaScript!!') returns [I, love, javaScript] +ok 179 — words('python, javaScript & coffee') returns [python, javaScript, coffee] +ok 180 — words(I love javaScript!!) returns an array +ok 181 — words() throws an error +ok 182 — words(null) throws an error +ok 183 — words(undefined) throws an error +ok 184 — words({}) throws an error +ok 185 — words([]) throws an error +ok 186 — words(1234) throws an error + +# PASS test/longestItem/longestItem.test.js + +ok 187 — longestItem is a Function +ok 188 — Returns the longest object from plain values +ok 189 — Returns the longest object from a spread array +ok 190 — Returns the longest object from mixed input +ok 191 — Returns the longest array +ok 192 — Returns the longest object when comparing arrays and strings +ok 193 — Returns undefined without any input +ok 194 — Returns first found of all similar +ok 195 — Throws TypeError if all inputs are undefined + +# PASS test/without/without.test.js + +ok 196 — without is a Function +ok 197 — without([2, 1, 2, 3], 1, 2) returns [3] +ok 198 — without([]) returns [] +ok 199 — without([3, 1, true, '3', true], '3', true) returns [3, 1] +ok 200 — without('string'.split(''), 's', 't', 'g') returns ['r', 'i', 'n'] +ok 201 — without() throws an error +ok 202 — without(null) throws an error +ok 203 — without(undefined) throws an error +ok 204 — without(123) throws an error +ok 205 — without({}) throws an error + +# PASS test/chunk/chunk.test.js + +ok 206 — chunk is a Function +ok 207 — chunk([1, 2, 3, 4, 5], 2) returns [[1,2],[3,4],[5]] +ok 208 — chunk([]) returns [] +ok 209 — chunk(123) returns [] +ok 210 — chunk({ a: 123}) returns [] +ok 211 — chunk(string, 2) returns [ st, ri, ng ] +ok 212 — chunk() throws an error +ok 213 — chunk(undefined) throws an error +ok 214 — chunk(null) throws an error +ok 215 — chunk(This is a string, 2) takes less than 2s to run From b9817e3344cecc94f6f1cc3f45026f23f78af91d Mon Sep 17 00:00:00 2001 From: Felix Wu Date: Fri, 14 Sep 2018 15:15:31 +0200 Subject: [PATCH 06/15] generate main README using markdown-builder --- scripts/build.js | 64 ++++++++++++++++++++++++++---------------------- 1 file changed, 35 insertions(+), 29 deletions(-) diff --git a/scripts/build.js b/scripts/build.js index d314e5729..9f1a0c506 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -74,7 +74,7 @@ if ( data.slice(0, data.lastIndexOf('```js')).trim() + misc.collapsible( 'Examples', - '\n' + data.slice(data.lastIndexOf('```js'), data.lastIndexOf('```')) + + data.slice(data.lastIndexOf('```js'), data.lastIndexOf('```')) + data.slice(data.lastIndexOf('```')) ); output += data + '\n' + misc.link('⬆ Back to top', misc.anchor('Table of Contents')) + '\n\n'; @@ -141,6 +141,7 @@ try { // Load tag data from the database tagDbData = util.readTags(); console.log(tagDbData); + // Create the output for the README file try { const tags = [ @@ -162,46 +163,51 @@ try { console.log(tags); // Add the start static part - output += `${startPart + '\n'}`; + output += `${startPart}\n`; // Loop over tags and snippets to create the table of contents for (const tag of tags) { const capitalizedTag = util.capitalize(tag, true); - output += `### ${EMOJIS[tag] || - ''} ${capitalizedTag}\n\n
\nView contents\n\n`; - for (const taggedSnippet of Object.entries(tagDbData).filter( - v => v[1][0] === tag - )) { - output += `* [\`${ - taggedSnippet[0] - }\`](#${taggedSnippet[0].toLowerCase()}${ - taggedSnippet[1].includes('advanced') ? '-' : '' - })\n`; - } - output += '\n
\n\n'; + const taggedSnippets = Object.entries(tagDbData).filter(v => v[1][0] === tag); + output += headers.h3((EMOJIS[tag] || '') + ' ' + capitalizedTag).trim(); + + output += misc.collapsible( + 'View contents', + lists.ul(taggedSnippets, (snippet) => + misc.link( + `\`${snippet[0]}\``, + misc.anchor(snippet[0]) + ) + ) + ) + '\n'; } // Loop over tags and snippets to create the list of snippets for (const tag of tags) { const capitalizedTag = util.capitalize(tag, true); - output += `---\n ## ${EMOJIS[tag] || ''} ${capitalizedTag}\n`; - for (const taggedSnippet of Object.entries(tagDbData).filter( - v => v[1][0] === tag - )) { - let data = snippets[taggedSnippet[0] + '.md']; + const taggedSnippets = Object.entries(tagDbData).filter(v => v[1][0] === tag); + + output += misc.hr() + headers.h2((EMOJIS[tag] || '') + ' ' + capitalizedTag).trim(); + + for (const taggedSnippet of taggedSnippets) { + let snippet = snippets[taggedSnippet[0] + '.md']; + // Add advanced tag if (taggedSnippet[1].includes('advanced')) { - data = data.split(/\r?\n/); - data[0] = data[0] + ' ![advanced](/advanced.svg)'; - data = data.join('\n'); + snippet = snippet.split(/\r?\n/); + // add label to snippet title (first line) + snippet[0] += ' ' + misc.image('advanced', '/advanced.svg'); + snippet = snippet.join('\n'); } - data = - data.slice(0, data.lastIndexOf('```js')) + - '
\nExamples\n\n' + - data.slice(data.lastIndexOf('```js'), data.lastIndexOf('```')) + - data.slice(data.lastIndexOf('```')) + - '\n
\n'; - output += `\n${data + '\n
[⬆ Back to top](#table-of-contents)\n\n'}`; + + snippet = snippet.slice(0, snippet.lastIndexOf('```js')).trim() + + misc.collapsible( + 'Examples', + snippet.slice(snippet.lastIndexOf('```js'), snippet.lastIndexOf('```')) + + snippet.slice(snippet.lastIndexOf('```')) + ); + + output += snippet + '\n' + misc.link('⬆ Back to top', misc.anchor('Table of Contents')) + '\n\n'; } } From 5727cb4ff059e4efd9ba6a04892a2b2bc671078b Mon Sep 17 00:00:00 2001 From: Felix Wu Date: Fri, 14 Sep 2018 15:15:41 +0200 Subject: [PATCH 07/15] build --- README.md | 4414 +++++++++++++++++------------------- package-lock.json | 6 +- package.json | 2 +- snippets_archive/README.md | 56 +- 4 files changed, 2070 insertions(+), 2408 deletions(-) diff --git a/README.md b/README.md index b13302e49..cd61099f9 100644 --- a/README.md +++ b/README.md @@ -81,12 +81,12 @@ average(1, 2, 3); ## Table of Contents -### 🔌 Adapter +### 🔌 Adapter
-View contents - -* [`ary`](#ary) + View contents + + * [`ary`](#ary) * [`call`](#call) * [`collectInto`](#collectinto) * [`flip`](#flip) @@ -100,13 +100,13 @@ average(1, 2, 3); * [`unary`](#unary)
- -### 📚 Array + +### 📚 Array
-View contents - -* [`all`](#all) + View contents + + * [`all`](#all) * [`allEqual`](#allequal) * [`any`](#any) * [`arrayToCSV`](#arraytocsv) @@ -145,21 +145,21 @@ average(1, 2, 3); * [`intersectionWith`](#intersectionwith) * [`isSorted`](#issorted) * [`join`](#join) -* [`JSONtoCSV`](#jsontocsv-) +* [`JSONtoCSV`](#jsontocsv) * [`last`](#last) * [`longestItem`](#longestitem) -* [`mapObject`](#mapobject-) +* [`mapObject`](#mapobject) * [`maxN`](#maxn) * [`minN`](#minn) * [`none`](#none) * [`nthElement`](#nthelement) * [`offset`](#offset) * [`partition`](#partition) -* [`permutations`](#permutations-) +* [`permutations`](#permutations) * [`pull`](#pull) -* [`pullAtIndex`](#pullatindex-) -* [`pullAtValue`](#pullatvalue-) -* [`pullBy`](#pullby-) +* [`pullAtIndex`](#pullatindex) +* [`pullAtValue`](#pullatvalue) +* [`pullBy`](#pullby) * [`reducedFilter`](#reducedfilter) * [`reduceSuccessive`](#reducesuccessive) * [`reduceWhich`](#reducewhich) @@ -173,7 +173,7 @@ average(1, 2, 3); * [`sortedIndexBy`](#sortedindexby) * [`sortedLastIndex`](#sortedlastindex) * [`sortedLastIndexBy`](#sortedlastindexby) -* [`stableSort`](#stablesort-) +* [`stableSort`](#stablesort) * [`symmetricDifference`](#symmetricdifference) * [`symmetricDifferenceBy`](#symmetricdifferenceby) * [`symmetricDifferenceWith`](#symmetricdifferencewith) @@ -191,48 +191,48 @@ average(1, 2, 3); * [`uniqueElementsByRight`](#uniqueelementsbyright) * [`uniqueSymmetricDifference`](#uniquesymmetricdifference) * [`unzip`](#unzip) -* [`unzipWith`](#unzipwith-) +* [`unzipWith`](#unzipwith) * [`without`](#without) * [`xProd`](#xprod) * [`zip`](#zip) * [`zipObject`](#zipobject) -* [`zipWith`](#zipwith-) +* [`zipWith`](#zipwith)
- -### 🌐 Browser + +### 🌐 Browser
-View contents - -* [`arrayToHtmlList`](#arraytohtmllist) + View contents + + * [`arrayToHtmlList`](#arraytohtmllist) * [`bottomVisible`](#bottomvisible) -* [`copyToClipboard`](#copytoclipboard-) -* [`counter`](#counter-) +* [`copyToClipboard`](#copytoclipboard) +* [`counter`](#counter) * [`createElement`](#createelement) -* [`createEventHub`](#createeventhub-) +* [`createEventHub`](#createeventhub) * [`currentURL`](#currenturl) * [`detectDeviceType`](#detectdevicetype) * [`elementContains`](#elementcontains) -* [`elementIsVisibleInViewport`](#elementisvisibleinviewport-) +* [`elementIsVisibleInViewport`](#elementisvisibleinviewport) * [`getScrollPosition`](#getscrollposition) * [`getStyle`](#getstyle) * [`hasClass`](#hasclass) -* [`hashBrowser`](#hashbrowser-) +* [`hashBrowser`](#hashbrowser) * [`hide`](#hide) * [`httpsRedirect`](#httpsredirect) * [`insertAfter`](#insertafter) * [`insertBefore`](#insertbefore) * [`isBrowserTabFocused`](#isbrowsertabfocused) * [`nodeListToArray`](#nodelisttoarray) -* [`observeMutations`](#observemutations-) +* [`observeMutations`](#observemutations) * [`off`](#off) * [`on`](#on) -* [`onUserInputChange`](#onuserinputchange-) +* [`onUserInputChange`](#onuserinputchange) * [`prefix`](#prefix) * [`recordAnimationFrames`](#recordanimationframes) * [`redirect`](#redirect) -* [`runAsync`](#runasync-) +* [`runAsync`](#runasync) * [`scrollToTop`](#scrolltotop) * [`setStyle`](#setstyle) * [`show`](#show) @@ -242,26 +242,26 @@ average(1, 2, 3); * [`UUIDGeneratorBrowser`](#uuidgeneratorbrowser)
- -### ⏱️ Date + +### ⏱️ Date
-View contents - -* [`formatDuration`](#formatduration) + View contents + + * [`formatDuration`](#formatduration) * [`getColonTimeFromDate`](#getcolontimefromdate) * [`getDaysDiffBetweenDates`](#getdaysdiffbetweendates) * [`getMeridiemSuffixOfInteger`](#getmeridiemsuffixofinteger) * [`tomorrow`](#tomorrow)
- -### 🎛️ Function + +### 🎛️ Function
-View contents - -* [`attempt`](#attempt) + View contents + + * [`attempt`](#attempt) * [`bind`](#bind) * [`bindKey`](#bindkey) * [`chainAsync`](#chainasync) @@ -274,27 +274,27 @@ average(1, 2, 3); * [`delay`](#delay) * [`functionName`](#functionname) * [`hz`](#hz) -* [`memoize`](#memoize-) +* [`memoize`](#memoize) * [`negate`](#negate) * [`once`](#once) * [`partial`](#partial) * [`partialRight`](#partialright) * [`runPromisesInSeries`](#runpromisesinseries) * [`sleep`](#sleep) -* [`throttle`](#throttle-) +* [`throttle`](#throttle) * [`times`](#times) * [`uncurry`](#uncurry) * [`unfold`](#unfold) * [`when`](#when)
- -### ➗ Math + +### ➗ Math
-View contents - -* [`approximatelyEqual`](#approximatelyequal) + View contents + + * [`approximatelyEqual`](#approximatelyequal) * [`average`](#average) * [`averageBy`](#averageby) * [`binomialCoefficient`](#binomialcoefficient) @@ -302,7 +302,7 @@ average(1, 2, 3); * [`degreesToRads`](#degreestorads) * [`digitize`](#digitize) * [`distance`](#distance) -* [`elo`](#elo-) +* [`elo`](#elo) * [`factorial`](#factorial) * [`fibonacci`](#fibonacci) * [`gcd`](#gcd) @@ -313,7 +313,7 @@ average(1, 2, 3); * [`isEven`](#iseven) * [`isPrime`](#isprime) * [`lcm`](#lcm) -* [`luhnCheck`](#luhncheck-) +* [`luhnCheck`](#luhncheck) * [`maxBy`](#maxby) * [`median`](#median) * [`minBy`](#minby) @@ -333,13 +333,13 @@ average(1, 2, 3); * [`toSafeInteger`](#tosafeinteger)
- -### 📦 Node + +### 📦 Node
-View contents - -* [`atob`](#atob) + View contents + + * [`atob`](#atob) * [`btoa`](#btoa) * [`colorize`](#colorize) * [`hasFlags`](#hasflags) @@ -351,18 +351,18 @@ average(1, 2, 3); * [`UUIDGeneratorNode`](#uuidgeneratornode)
- -### 🗃️ Object + +### 🗃️ Object
-View contents - -* [`bindAll`](#bindall) + View contents + + * [`bindAll`](#bindall) * [`deepClone`](#deepclone) * [`deepFreeze`](#deepfreeze) * [`defaults`](#defaults) * [`dig`](#dig) -* [`equals`](#equals-) +* [`equals`](#equals) * [`findKey`](#findkey) * [`findLastKey`](#findlastkey) * [`flattenObject`](#flattenobject) @@ -390,20 +390,20 @@ average(1, 2, 3); * [`size`](#size) * [`transform`](#transform) * [`truthCheckCollection`](#truthcheckcollection) -* [`unflattenObject`](#unflattenobject-) +* [`unflattenObject`](#unflattenobject)
- -### 📜 String + +### 📜 String
-View contents - -* [`byteSize`](#bytesize) + View contents + + * [`byteSize`](#bytesize) * [`capitalize`](#capitalize) * [`capitalizeEveryWord`](#capitalizeeveryword) * [`CSVToArray`](#csvtoarray) -* [`CSVToJSON`](#csvtojson-) +* [`CSVToJSON`](#csvtojson) * [`decapitalize`](#decapitalize) * [`escapeHTML`](#escapehtml) * [`escapeRegExp`](#escaperegexp) @@ -421,24 +421,24 @@ average(1, 2, 3); * [`reverseString`](#reversestring) * [`sortCharactersInString`](#sortcharactersinstring) * [`splitLines`](#splitlines) -* [`stringPermutations`](#stringpermutations-) +* [`stringPermutations`](#stringpermutations) * [`stripHTMLTags`](#striphtmltags) * [`toCamelCase`](#tocamelcase) * [`toKebabCase`](#tokebabcase) * [`toSnakeCase`](#tosnakecase) * [`truncateString`](#truncatestring) * [`unescapeHTML`](#unescapehtml) -* [`URLJoin`](#urljoin-) +* [`URLJoin`](#urljoin) * [`words`](#words)
- -### 📃 Type + +### 📃 Type
-View contents - -* [`getType`](#gettype) + View contents + + * [`getType`](#gettype) * [`is`](#is) * [`isArrayLike`](#isarraylike) * [`isBoolean`](#isboolean) @@ -458,26 +458,26 @@ average(1, 2, 3); * [`isValidJSON`](#isvalidjson)
- -### 🔧 Utility + +### 🔧 Utility
-View contents - -* [`castArray`](#castarray) + View contents + + * [`castArray`](#castarray) * [`cloneRegExp`](#cloneregexp) * [`coalesce`](#coalesce) * [`coalesceFactory`](#coalescefactory) * [`extendHex`](#extendhex) * [`getURLParameters`](#geturlparameters) -* [`hexToRGB`](#hextorgb-) +* [`hexToRGB`](#hextorgb) * [`httpGet`](#httpget) * [`httpPost`](#httppost) * [`isBrowser`](#isbrowser) * [`mostPerformant`](#mostperformant) * [`nthArg`](#ntharg) * [`parseCookie`](#parsecookie) -* [`prettyBytes`](#prettybytes-) +* [`prettyBytes`](#prettybytes) * [`randomHexColorCode`](#randomhexcolorcode) * [`RGBToHex`](#rgbtohex) * [`serializeCookie`](#serializecookie) @@ -489,11 +489,10 @@ average(1, 2, 3); * [`yesNo`](#yesno)
- ---- - ## 🔌 Adapter - -### ary + + +--- +## 🔌 Adapter### ary Creates a function that accepts up to `n` arguments, ignoring any additional arguments. @@ -501,20 +500,19 @@ Call the provided function, `fn`, with up to `n` arguments, using `Array.slice(0 ```js const ary = (fn, n) => (...args) => fn(...args.slice(0, n)); -``` +```
-Examples - -```js + Examples + + ```js const firstTwoMax = ary(Math.max, 2); [[2, 6, 'a'], [8, 4, 6], [10]].map(x => firstTwoMax(...x)); // [6, 8, 10] ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### call @@ -524,12 +522,12 @@ Use a closure to call a stored key with stored arguments. ```js const call = (key, ...args) => context => context[key](...args); -``` - -
-Examples +``` -```js +
+ Examples + + ```js Promise.resolve([1, 2, 3]) .then(call('map', x => 2 * x)) .then(console.log); //[ 2, 4, 6 ] @@ -540,9 +538,8 @@ Promise.resolve([1, 2, 3]) ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### collectInto @@ -552,12 +549,12 @@ Given a function, return a closure that collects all inputs into an array-accept ```js const collectInto = fn => (...args) => fn(args); -``` - -
-Examples +``` -```js +
+ Examples + + ```js const Pall = collectInto(Promise.all.bind(Promise)); let p1 = Promise.resolve(1); let p2 = Promise.resolve(2); @@ -566,9 +563,8 @@ Pall(p1, p2, p3).then(console.log); // [1, 2, 3] (after about 2 seconds) ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### flip @@ -578,12 +574,12 @@ Return a closure that takes variadic inputs, and splices the last argument to ma ```js const flip = fn => (first, ...rest) => fn(...rest, first); -``` - -
-Examples +``` -```js +
+ Examples + + ```js let a = { name: 'John Smith' }; let b = {}; const mergeFrom = flip(Object.assign); @@ -594,9 +590,8 @@ Object.assign(b, a); // == b ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### over @@ -606,20 +601,19 @@ Use `Array.map()` and `Function.apply()` to apply each function to the given arg ```js const over = (...fns) => (...args) => fns.map(fn => fn.apply(null, args)); -``` +```
-Examples - -```js + Examples + + ```js const minMax = over(Math.min, Math.max); minMax(1, 2, 3, 4, 5); // [1,5] ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### overArgs @@ -629,12 +623,12 @@ Use `Array.map()` to apply `transforms` to `args` in combination with the spread ```js const overArgs = (fn, transforms) => (...args) => fn(...args.map((val, i) => transforms[i](val))); -``` +```
-Examples - -```js + Examples + + ```js const square = n => n * n; const double = n => n * 2; const fn = overArgs((x, y) => [x, y], [square, double]); @@ -642,9 +636,8 @@ fn(9, 3); // [81, 6] ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### pipeAsyncFunctions @@ -656,12 +649,12 @@ All functions must be unary. ```js const pipeAsyncFunctions = (...fns) => arg => fns.reduce((p, f) => p.then(f), Promise.resolve(arg)); -``` +```
-Examples - -```js + Examples + + ```js const sum = pipeAsyncFunctions( x => x + 1, x => new Promise(resolve => setTimeout(() => resolve(x + 2), 1000)), @@ -674,9 +667,8 @@ const sum = pipeAsyncFunctions( ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### pipeFunctions @@ -687,12 +679,12 @@ The first (leftmost) function can accept one or more arguments; the remaining fu ```js const pipeFunctions = (...fns) => fns.reduce((f, g) => (...args) => g(f(...args))); -``` +```
-Examples - -```js + Examples + + ```js const add5 = x => x + 5; const multiply = (x, y) => x * y; const multiplyAndAdd5 = pipeFunctions(multiply, add5); @@ -700,9 +692,8 @@ multiplyAndAdd5(5, 2); // 15 ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### promisify @@ -718,20 +709,19 @@ const promisify = func => (...args) => new Promise((resolve, reject) => func(...args, (err, result) => (err ? reject(err) : resolve(result))) ); -``` +```
-Examples - -```js + Examples + + ```js const delay = promisify((d, cb) => setTimeout(cb, d)); delay(2000).then(() => console.log('Hi!')); // // Promise resolves after 2s ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### rearg @@ -741,12 +731,12 @@ Use `Array.map()` to reorder arguments based on `indexes` in combination with th ```js const rearg = (fn, indexes) => (...args) => fn(...indexes.map(i => args[i])); -``` +```
-Examples - -```js + Examples + + ```js var rearged = rearg( function(a, b, c) { return [a, b, c]; @@ -757,9 +747,8 @@ rearged('b', 'c', 'a'); // ['a', 'b', 'c'] ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### spreadOver @@ -769,20 +758,19 @@ Use closures and the spread operator (`...`) to map the array of arguments to th ```js const spreadOver = fn => argsArr => fn(...argsArr); -``` - -
-Examples +``` -```js +
+ Examples + + ```js const arrayMax = spreadOver(Math.max); arrayMax([1, 2, 3]); // 3 ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### unary @@ -792,23 +780,22 @@ Call the provided function, `fn`, with just the first argument given. ```js const unary = fn => val => fn(val); -``` +```
-Examples - -```js + Examples + + ```js ['6', '8', '10'].map(unary(parseInt)); // [6, 8, 10] ```
+ +[⬆ Back to top](#table-of-contents) -
[⬆ Back to top](#table-of-contents) - ---- - ## 📚 Array - -### all + +--- +## 📚 Array### all Returns `true` if the provided predicate function returns `true` for all elements in a collection, `false` otherwise. @@ -817,20 +804,19 @@ Omit the second argument, `fn`, to use `Boolean` as a default. ```js const all = (arr, fn = Boolean) => arr.every(fn); -``` +```
-Examples - -```js + Examples + + ```js all([4, 2, 3], x => x > 1); // true all([1, 2, 3]); // true ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### allEqual @@ -840,20 +826,19 @@ Use `Array.every()` to check if all the elements of the array are the same as th ```js const allEqual = arr => arr.every(val => val === arr[0]); -``` +```
-Examples - -```js + Examples + + ```js allEqual([1, 2, 3, 4, 5, 6]); // false allEqual([1, 1, 1, 1]); // true ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### any @@ -864,20 +849,19 @@ Omit the second argument, `fn`, to use `Boolean` as a default. ```js const any = (arr, fn = Boolean) => arr.some(fn); -``` +```
-Examples - -```js + Examples + + ```js any([0, 1, 2, 0], x => x >= 2); // true any([0, 0, 1, 0]); // true ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### arrayToCSV @@ -890,20 +874,19 @@ Omit the second argument, `delimiter`, to use a default delimiter of `,`. ```js const arrayToCSV = (arr, delimiter = ',') => arr.map(v => v.map(x => `"${x}"`).join(delimiter)).join('\n'); -``` +```
-Examples - -```js + Examples + + ```js arrayToCSV([['a', 'b'], ['c', 'd']]); // '"a","b"\n"c","d"' arrayToCSV([['a', 'b'], ['c', 'd']], ';'); // '"a";"b"\n"c";"d"' ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### bifurcate @@ -914,19 +897,18 @@ Use `Array.reduce()` and `Array.push()` to add elements to groups, based on `fil ```js const bifurcate = (arr, filter) => arr.reduce((acc, val, i) => (acc[filter[i] ? 0 : 1].push(val), acc), [[], []]); -``` +```
-Examples - -```js + Examples + + ```js bifurcate(['beep', 'boop', 'foo', 'bar'], [true, true, false, true]); // [ ['beep', 'boop', 'bar'], ['foo'] ] ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### bifurcateBy @@ -937,19 +919,18 @@ Use `Array.reduce()` and `Array.push()` to add elements to groups, based on the ```js const bifurcateBy = (arr, fn) => arr.reduce((acc, val, i) => (acc[fn(val, i) ? 0 : 1].push(val), acc), [[], []]); -``` +```
-Examples - -```js + Examples + + ```js bifurcateBy(['beep', 'boop', 'foo', 'bar'], x => x[0] === 'b'); // [ ['beep', 'boop', 'bar'], ['foo'] ] ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### chunk @@ -964,19 +945,18 @@ const chunk = (arr, size) => Array.from({ length: Math.ceil(arr.length / size) }, (v, i) => arr.slice(i * size, i * size + size) ); -``` +```
-Examples - -```js + Examples + + ```js chunk([1, 2, 3, 4, 5], 2); // [[1,2],[3,4],[5]] ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### compact @@ -986,19 +966,18 @@ Use `Array.filter()` to filter out falsey values (`false`, `null`, `0`, `""`, `u ```js const compact = arr => arr.filter(Boolean); -``` +```
-Examples - -```js + Examples + + ```js compact([0, 1, false, 2, '', 3, 'a', 'e' * 23, NaN, 's', 34]); // [ 1, 2, 3, 'a', 's', 34 ] ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### countBy @@ -1013,20 +992,19 @@ const countBy = (arr, fn) => acc[val] = (acc[val] || 0) + 1; return acc; }, {}); -``` +```
-Examples - -```js + Examples + + ```js countBy([6.1, 4.2, 6.3], Math.floor); // {4: 1, 6: 2} countBy(['one', 'two', 'three'], 'length'); // {3: 2, 5: 1} ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### countOccurrences @@ -1036,19 +1014,18 @@ Use `Array.reduce()` to increment a counter each time you encounter the specific ```js const countOccurrences = (arr, val) => arr.reduce((a, v) => (v === val ? a + 1 : a), 0); -``` +```
-Examples - -```js + Examples + + ```js countOccurrences([1, 1, 2, 1, 2, 3], 1); // 3 ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### deepFlatten @@ -1060,19 +1037,18 @@ Recursively flatten each element that is an array. ```js const deepFlatten = arr => [].concat(...arr.map(v => (Array.isArray(v) ? deepFlatten(v) : v))); -``` +```
-Examples - -```js + Examples + + ```js deepFlatten([1, [2], [[3], 4], 5]); // [1,2,3,4,5] ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### difference @@ -1085,19 +1061,18 @@ const difference = (a, b) => { const s = new Set(b); return a.filter(x => !s.has(x)); }; -``` +```
-Examples - -```js + Examples + + ```js difference([1, 2, 3], [1, 2, 4]); // [3] ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### differenceBy @@ -1110,20 +1085,19 @@ const differenceBy = (a, b, fn) => { const s = new Set(b.map(v => fn(v))); return a.filter(x => !s.has(fn(x))); }; -``` +```
-Examples - -```js + Examples + + ```js differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor); // [1.2] differenceBy([{ x: 2 }, { x: 1 }], [{ x: 1 }], v => v.x); // [ { x: 2 } ] ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### differenceWith @@ -1133,19 +1107,18 @@ Use `Array.filter()` and `Array.findIndex()` to find the appropriate values. ```js const differenceWith = (arr, val, comp) => arr.filter(a => val.findIndex(b => comp(a, b)) === -1); -``` +```
-Examples - -```js + Examples + + ```js differenceWith([1, 1.2, 1.5, 3, 0], [1.9, 3, 0], (a, b) => Math.round(a) === Math.round(b)); // [1, 1.2] ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### drop @@ -1155,21 +1128,20 @@ Use `Array.slice()` to slice the remove the specified number of elements from th ```js const drop = (arr, n = 1) => arr.slice(n); -``` +```
-Examples - -```js + Examples + + ```js drop([1, 2, 3]); // [2,3] drop([1, 2, 3], 2); // [3] drop([1, 2, 3], 42); // [] ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### dropRight @@ -1179,21 +1151,20 @@ Use `Array.slice()` to slice the remove the specified number of elements from th ```js const dropRight = (arr, n = 1) => arr.slice(0, -n); -``` +```
-Examples - -```js + Examples + + ```js dropRight([1, 2, 3]); // [1,2] dropRight([1, 2, 3], 2); // [1] dropRight([1, 2, 3], 42); // [] ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### dropRightWhile @@ -1207,19 +1178,18 @@ const dropRightWhile = (arr, func) => { while (arr.length > 0 && !func(arr[arr.length - 1])) arr = arr.slice(0, -1); return arr; }; -``` +```
-Examples - -```js + Examples + + ```js dropRightWhile([1, 2, 3, 4], n => n < 3); // [1, 2] ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### dropWhile @@ -1233,19 +1203,18 @@ const dropWhile = (arr, func) => { while (arr.length > 0 && !func(arr[0])) arr = arr.slice(1); return arr; }; -``` +```
-Examples - -```js + Examples + + ```js dropWhile([1, 2, 3, 4], n => n >= 3); // [3,4] ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### everyNth @@ -1255,19 +1224,18 @@ Use `Array.filter()` to create a new array that contains every nth element of a ```js const everyNth = (arr, nth) => arr.filter((e, i) => i % nth === nth - 1); -``` +```
-Examples - -```js + Examples + + ```js everyNth([1, 2, 3, 4, 5, 6], 2); // [ 2, 4, 6 ] ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### filterNonUnique @@ -1277,19 +1245,18 @@ Use `Array.filter()` for an array containing only the unique values. ```js const filterNonUnique = arr => arr.filter(i => arr.indexOf(i) === arr.lastIndexOf(i)); -``` +```
-Examples - -```js + Examples + + ```js filterNonUnique([1, 2, 2, 3, 4, 4, 5]); // [1,3,5] ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### filterNonUniqueBy @@ -1301,12 +1268,12 @@ The comparator function takes four arguments: the values of the two elements bei ```js const filterNonUniqueBy = (arr, fn) => arr.filter((v, i) => arr.every((x, j) => (i === j) === fn(v, x, i, j))); -``` +```
-Examples - -```js + Examples + + ```js filterNonUniqueBy( [ { id: 0, value: 'a' }, @@ -1320,9 +1287,8 @@ filterNonUniqueBy( ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### findLast @@ -1332,19 +1298,18 @@ Use `Array.filter()` to remove elements for which `fn` returns falsey values, `A ```js const findLast = (arr, fn) => arr.filter(fn).pop(); -``` +```
-Examples - -```js + Examples + + ```js findLast([1, 2, 3, 4], n => n % 2 === 1); // 3 ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### findLastIndex @@ -1359,19 +1324,18 @@ const findLastIndex = (arr, fn) => .map((val, i) => [i, val]) .filter(([i, val]) => fn(val, i, arr)) .pop()[0]; -``` +```
-Examples - -```js + Examples + + ```js findLastIndex([1, 2, 3, 4], n => n % 2 === 1); // 2 (index of the value 3) ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### flatten @@ -1385,20 +1349,19 @@ Omit the second argument, `depth` to flatten only to a depth of `1` (single flat ```js const flatten = (arr, depth = 1) => arr.reduce((a, v) => a.concat(depth > 1 && Array.isArray(v) ? flatten(v, depth - 1) : v), []); -``` +```
-Examples - -```js + Examples + + ```js flatten([1, [2], 3, 4]); // [1, 2, 3, 4] flatten([1, [2, [3, [4, 5], 6], 7], 8], 2); // [1, 2, 3, [4, 5], 6, 7, 8] ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### forEachRight @@ -1412,19 +1375,18 @@ const forEachRight = (arr, callback) => .slice(0) .reverse() .forEach(callback); -``` +```
-Examples - -```js + Examples + + ```js forEachRight([1, 2, 3, 4], val => console.log(val)); // '4', '3', '2', '1' ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### groupBy @@ -1439,20 +1401,19 @@ const groupBy = (arr, fn) => acc[val] = (acc[val] || []).concat(arr[i]); return acc; }, {}); -``` +```
-Examples - -```js + Examples + + ```js groupBy([6.1, 4.2, 6.3], Math.floor); // {4: [4.2], 6: [6.1, 6.3]} groupBy(['one', 'two', 'three'], 'length'); // {3: ['one', 'two'], 5: ['three']} ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### head @@ -1462,19 +1423,18 @@ Use `arr[0]` to return the first element of the passed array. ```js const head = arr => arr[0]; -``` +```
-Examples - -```js + Examples + + ```js head([1, 2, 3]); // 1 ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### indexOfAll @@ -1485,20 +1445,19 @@ Return the array of indices. ```js const indexOfAll = (arr, val) => arr.reduce((acc, el, i) => (el === val ? [...acc, i] : acc), []); -``` +```
-Examples - -```js + Examples + + ```js indexOfAll([1, 2, 3, 1, 2, 3], 1); // [0,3] indexOfAll([1, 2, 3], 4); // [] ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### initial @@ -1508,19 +1467,18 @@ Use `arr.slice(0,-1)` to return all but the last element of the array. ```js const initial = arr => arr.slice(0, -1); -``` +```
-Examples - -```js + Examples + + ```js initial([1, 2, 3]); // [1,2] ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### initialize2DArray @@ -1531,19 +1489,18 @@ Use `Array.map()` to generate h rows where each is a new array of size w initial ```js const initialize2DArray = (w, h, val = null) => Array.from({ length: h }).map(() => Array.from({ length: w }).fill(val)); -``` +```
-Examples - -```js + Examples + + ```js initialize2DArray(2, 2, 0); // [[0,0], [0,0]] ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### initializeArrayWithRange @@ -1556,21 +1513,20 @@ You can omit `step` to use a default value of `1`. ```js const initializeArrayWithRange = (end, start = 0, step = 1) => Array.from({ length: Math.ceil((end - start + 1) / step) }, (v, i) => i * step + start); -``` +```
-Examples - -```js + Examples + + ```js initializeArrayWithRange(5); // [0,1,2,3,4,5] initializeArrayWithRange(7, 3); // [3,4,5,6,7] initializeArrayWithRange(9, 0, 2); // [0,2,4,6,8] ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### initializeArrayWithRangeRight @@ -1585,21 +1541,20 @@ const initializeArrayWithRangeRight = (end, start = 0, step = 1) => Array.from({ length: Math.ceil((end + 1 - start) / step) }).map( (v, i, arr) => (arr.length - i - 1) * step + start ); -``` +```
-Examples - -```js + Examples + + ```js initializeArrayWithRangeRight(5); // [5,4,3,2,1,0] initializeArrayWithRangeRight(7, 3); // [7,6,5,4,3] initializeArrayWithRangeRight(9, 0, 2); // [8,6,4,2,0] ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### initializeArrayWithValues @@ -1610,19 +1565,18 @@ You can omit `val` to use a default value of `0`. ```js const initializeArrayWithValues = (n, val = 0) => Array(n).fill(val); -``` +```
-Examples - -```js + Examples + + ```js initializeArrayWithValues(5, 2); // [2,2,2,2,2] ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### initializeNDArray @@ -1636,20 +1590,19 @@ const initializeNDArray = (val, ...args) => args.length === 0 ? val : Array.from({ length: args[0] }).map(() => initializeNDArray(val, ...args.slice(1))); -``` +```
-Examples - -```js + Examples + + ```js initializeNDArray(1, 3); // [1,1,1] initializeNDArray(5, 2, 2, 2); // [[[5,5],[5,5]],[[5,5],[5,5]]] ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### intersection @@ -1662,19 +1615,18 @@ const intersection = (a, b) => { const s = new Set(b); return a.filter(x => s.has(x)); }; -``` +```
-Examples - -```js + Examples + + ```js intersection([1, 2, 3], [4, 3, 2]); // [2,3] ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### intersectionBy @@ -1687,19 +1639,18 @@ const intersectionBy = (a, b, fn) => { const s = new Set(b.map(fn)); return a.filter(x => s.has(fn(x))); }; -``` +```
-Examples - -```js + Examples + + ```js intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor); // [2.1] ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### intersectionWith @@ -1709,19 +1660,18 @@ Use `Array.filter()` and `Array.findIndex()` in combination with the provided co ```js const intersectionWith = (a, b, comp) => a.filter(x => b.findIndex(y => comp(x, y)) !== -1); -``` +```
-Examples - -```js + Examples + + ```js intersectionWith([1, 1.2, 1.5, 3, 0], [1.9, 3, 0, 3.9], (a, b) => Math.round(a) === Math.round(b)); // [1.5, 3, 0] ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### isSorted @@ -1740,21 +1690,20 @@ const isSorted = arr => { else if ((val - arr[i + 1]) * direction > 0) return 0; } }; -``` +```
-Examples - -```js + Examples + + ```js isSorted([0, 1, 2, 2]); // 1 isSorted([4, 3, 2]); // -1 isSorted([4, 3, 5]); // 0 ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### join @@ -1775,21 +1724,20 @@ const join = (arr, separator = ',', end = separator) => : acc + val + separator, '' ); -``` +```
-Examples - -```js + Examples + + ```js join(['pen', 'pineapple', 'apple', 'pen'], ',', '&'); // "pen,pineapple,apple&pen" join(['pen', 'pineapple', 'apple', 'pen'], ','); // "pen,pineapple,apple,pen" join(['pen', 'pineapple', 'apple', 'pen']); // "pen,pineapple,apple,pen" ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### JSONtoCSV ![advanced](/advanced.svg) @@ -1811,20 +1759,19 @@ const JSONtoCSV = (arr, columns, delimiter = ',') => ) ) ].join('\n'); -``` +```
-Examples - -```js + Examples + + ```js JSONtoCSV([{ a: 1, b: 2 }, { a: 3, b: 4, c: 5 }, { a: 6 }, { b: 7 }], ['a', 'b']); // 'a,b\n"1","2"\n"3","4"\n"6",""\n"","7"' JSONtoCSV([{ a: 1, b: 2 }, { a: 3, b: 4, c: 5 }, { a: 6 }, { b: 7 }], ['a', 'b'], ';'); // 'a;b\n"1";"2"\n"3";"4"\n"6";""\n"";"7"' ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### last @@ -1834,19 +1781,18 @@ Use `arr.length - 1` to compute the index of the last element of the given array ```js const last = arr => arr[arr.length - 1]; -``` +```
-Examples - -```js + Examples + + ```js last([1, 2, 3]); // 3 ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### longestItem @@ -1859,12 +1805,12 @@ Use `Array.reduce()`, comparing the `length` of objects to find the longest one. ```js const longestItem = (val, ...vals) => [val, ...vals].reduce((a, x) => (x.length > a.length ? x : a)); -``` +```
-Examples - -```js + Examples + + ```js longestItem('this', 'is', 'a', 'testcase'); // 'testcase' longestItem(...['a', 'ab', 'abc']); // 'abc' longestItem(...['a', 'ab', 'abc'], 'abcd'); // 'abcd' @@ -1873,9 +1819,8 @@ longestItem([1, 2, 3], 'foobar'); // 'foobar' ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### mapObject ![advanced](/advanced.svg) @@ -1888,20 +1833,19 @@ const mapObject = (arr, fn) => (a => ( (a = [arr, arr.map(fn)]), a[0].reduce((acc, val, ind) => ((acc[val] = a[1][ind]), acc), {}) ))(); -``` +```
-Examples - -```js + Examples + + ```js const squareIt = arr => mapObject(arr, a => a * a); squareIt([1, 2, 3]); // { 1: 1, 2: 4, 3: 9 } ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### maxN @@ -1913,20 +1857,19 @@ Omit the second argument, `n`, to get a one-element array. ```js const maxN = (arr, n = 1) => [...arr].sort((a, b) => b - a).slice(0, n); -``` +```
-Examples - -```js + Examples + + ```js maxN([1, 2, 3]); // [3] maxN([1, 2, 3], 2); // [3,2] ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### minN @@ -1938,19 +1881,19 @@ Omit the second argument, `n`, to get a one-element array. ```js const minN = (arr, n = 1) => [...arr].sort((a, b) => a - b).slice(0, n); -``` -
-Examples +``` -```js +
+ Examples + + ```js minN([1, 2, 3]); // [1] minN([1, 2, 3], 2); // [1,2] ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### none @@ -1961,20 +1904,19 @@ Omit the second argument, `fn`, to use `Boolean` as a default. ```js const none = (arr, fn = Boolean) => !arr.some(fn); -``` +```
-Examples - -```js + Examples + + ```js none([0, 1, 3, 0], x => x == 2); // true none([0, 0, 0]); // true ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### nthElement @@ -1986,20 +1928,19 @@ Omit the second argument, `n`, to get the first element of the array. ```js const nthElement = (arr, n = 0) => (n === -1 ? arr.slice(n) : arr.slice(n, n + 1))[0]; -``` +```
-Examples - -```js + Examples + + ```js nthElement(['a', 'b', 'c'], 1); // 'b' nthElement(['a', 'b', 'b'], -3); // 'a' ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### offset @@ -2011,20 +1952,19 @@ If `offset` is negative, the elements will be moved from end to start. ```js const offset = (arr, offset) => [...arr.slice(offset), ...arr.slice(0, offset)]; -``` +```
-Examples - -```js + Examples + + ```js offset([1, 2, 3, 4, 5], 2); // [3, 4, 5, 1, 2] offset([1, 2, 3, 4, 5], -2); // [4, 5, 1, 2, 3] ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### partition @@ -2042,20 +1982,19 @@ const partition = (arr, fn) => }, [[], []] ); -``` +```
-Examples - -```js + Examples + + ```js const users = [{ user: 'barney', age: 36, active: false }, { user: 'fred', age: 40, active: true }]; partition(users, o => o.active); // [[{ 'user': 'fred', 'age': 40, 'active': true }],[{ 'user': 'barney', 'age': 36, 'active': false }]] ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### permutations ![advanced](/advanced.svg) @@ -2079,19 +2018,18 @@ const permutations = arr => { [] ); }; -``` +```
-Examples - -```js + Examples + + ```js permutations([1, 33, 5]); // [ [ 1, 33, 5 ], [ 1, 5, 33 ], [ 33, 1, 5 ], [ 33, 5, 1 ], [ 5, 1, 33 ], [ 5, 33, 1 ] ] ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### pull @@ -2109,20 +2047,19 @@ const pull = (arr, ...args) => { arr.length = 0; pulled.forEach(v => arr.push(v)); }; -``` +```
-Examples - -```js + Examples + + ```js let myArray = ['a', 'b', 'c', 'a', 'b', 'c']; pull(myArray, 'a', 'c'); // myArray = [ 'b', 'b' ] ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### pullAtIndex ![advanced](/advanced.svg) @@ -2142,20 +2079,19 @@ const pullAtIndex = (arr, pullArr) => { pulled.forEach(v => arr.push(v)); return removed; }; -``` +```
-Examples - -```js + Examples + + ```js let myArray = ['a', 'b', 'c', 'd']; let pulled = pullAtIndex(myArray, [1, 3]); // myArray = [ 'a', 'c' ] , pulled = [ 'b', 'd' ] ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### pullAtValue ![advanced](/advanced.svg) @@ -2174,20 +2110,19 @@ const pullAtValue = (arr, pullArr) => { mutateTo.forEach(v => arr.push(v)); return removed; }; -``` +```
-Examples - -```js + Examples + + ```js let myArray = ['a', 'b', 'c', 'd']; let pulled = pullAtValue(myArray, ['b', 'd']); // myArray = [ 'a', 'c' ] , pulled = [ 'b', 'd' ] ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### pullBy ![advanced](/advanced.svg) @@ -2208,20 +2143,19 @@ const pullBy = (arr, ...args) => { arr.length = 0; pulled.forEach(v => arr.push(v)); }; -``` +```
-Examples - -```js + Examples + + ```js var myArray = [{ x: 1 }, { x: 2 }, { x: 3 }, { x: 1 }]; pullBy(myArray, [{ x: 1 }, { x: 3 }], o => o.x); // myArray = [{ x: 2 }] ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### reducedFilter @@ -2238,12 +2172,12 @@ const reducedFilter = (data, keys, fn) => return acc; }, {}) ); -``` +```
-Examples - -```js + Examples + + ```js const data = [ { id: 1, @@ -2261,9 +2195,8 @@ reducedFilter(data, ['id', 'name'], item => item.age > 24); // [{ id: 2, name: ' ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### reduceSuccessive @@ -2274,19 +2207,18 @@ Use `Array.reduce()` to apply the given function to the given array, storing eac ```js const reduceSuccessive = (arr, fn, acc) => arr.reduce((res, val, i, arr) => (res.push(fn(res.slice(-1)[0], val, i, arr)), res), [acc]); -``` +```
-Examples - -```js + Examples + + ```js reduceSuccessive([1, 2, 3, 4, 5, 6], (acc, val) => acc + val, 0); // [0, 1, 3, 6, 10, 15, 21] ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### reduceWhich @@ -2298,12 +2230,12 @@ You can omit the second parameter, `comparator`, to use the default one that ret ```js const reduceWhich = (arr, comparator = (a, b) => a - b) => arr.reduce((a, b) => (comparator(a, b) >= 0 ? b : a)); -``` +```
-Examples - -```js + Examples + + ```js reduceWhich([1, 3, 2]); // 1 reduceWhich([1, 3, 2], (a, b) => b - a); // 3 reduceWhich( @@ -2313,9 +2245,8 @@ reduceWhich( ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### reject @@ -2323,20 +2254,19 @@ Takes a predicate and array, like `Array.filter()`, but only keeps `x` if `pred( ```js const reject = (pred, array) => array.filter((...args) => !pred(...args)); -``` +```
-Examples - -```js + Examples + + ```js reject(x => x % 2 === 0, [1, 2, 3, 4, 5]); // [1, 3, 5] reject(word => word.length > 4, ['Apple', 'Pear', 'Kiwi', 'Banana']); // ['Pear', 'Kiwi'] ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### remove @@ -2353,19 +2283,18 @@ const remove = (arr, func) => return acc.concat(val); }, []) : []; -``` +```
-Examples - -```js + Examples + + ```js remove([1, 2, 3, 4], n => n % 2 === 0); // [2, 4] ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### sample @@ -2376,19 +2305,18 @@ This method also works with strings. ```js const sample = arr => arr[Math.floor(Math.random() * arr.length)]; -``` +```
-Examples - -```js + Examples + + ```js sample([3, 7, 9, 11]); // 9 ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### sampleSize @@ -2407,20 +2335,19 @@ const sampleSize = ([...arr], n = 1) => { } return arr.slice(0, n); }; -``` +```
-Examples - -```js + Examples + + ```js sampleSize([1, 2, 3], 2); // [3,1] sampleSize([1, 2, 3], 4); // [2,3,1] ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### shuffle @@ -2437,20 +2364,19 @@ const shuffle = ([...arr]) => { } return arr; }; -``` +```
-Examples - -```js + Examples + + ```js const foo = [1, 2, 3]; shuffle(foo); // [2,3,1], foo = [1,2,3] ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### similarity @@ -2460,19 +2386,18 @@ Use `Array.filter()` to remove values that are not part of `values`, determined ```js const similarity = (arr, values) => arr.filter(v => values.includes(v)); -``` +```
-Examples - -```js + Examples + + ```js similarity([1, 2, 3], [1, 2, 4]); // [1,2] ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### sortedIndex @@ -2487,20 +2412,19 @@ const sortedIndex = (arr, n) => { const index = arr.findIndex(el => (isDescending ? n >= el : n <= el)); return index === -1 ? arr.length : index; }; -``` +```
-Examples - -```js + Examples + + ```js sortedIndex([5, 3, 2, 1], 4); // 1 sortedIndex([30, 50], 40); // 1 ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### sortedIndexBy @@ -2516,19 +2440,18 @@ const sortedIndexBy = (arr, n, fn) => { const index = arr.findIndex(el => (isDescending ? val >= fn(el) : val <= fn(el))); return index === -1 ? arr.length : index; }; -``` +```
-Examples - -```js + Examples + + ```js sortedIndexBy([{ x: 4 }, { x: 5 }], { x: 4 }, o => o.x); // 0 ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### sortedLastIndex @@ -2543,19 +2466,18 @@ const sortedLastIndex = (arr, n) => { const index = arr.reverse().findIndex(el => (isDescending ? n <= el : n >= el)); return index === -1 ? 0 : arr.length - index; }; -``` +```
-Examples - -```js + Examples + + ```js sortedLastIndex([10, 20, 30, 30, 40], 30); // 4 ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### sortedLastIndexBy @@ -2575,19 +2497,18 @@ const sortedLastIndexBy = (arr, n, fn) => { .findIndex(el => (isDescending ? val <= el : val >= el)); return index === -1 ? 0 : arr.length - index; }; -``` +```
-Examples - -```js + Examples + + ```js sortedLastIndexBy([{ x: 4 }, { x: 5 }], { x: 4 }, o => o.x); // 1 ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### stableSort ![advanced](/advanced.svg) @@ -2604,20 +2525,19 @@ const stableSort = (arr, compare) => .map((item, index) => ({ item, index })) .sort((a, b) => compare(a.item, b.item) || a.index - b.index) .map(({ item }) => item); -``` +```
-Examples - -```js + Examples + + ```js const arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; const stable = stableSort(arr, () => 0); // [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### symmetricDifference @@ -2631,20 +2551,19 @@ const symmetricDifference = (a, b) => { sB = new Set(b); return [...a.filter(x => !sB.has(x)), ...b.filter(x => !sA.has(x))]; }; -``` +```
-Examples - -```js + Examples + + ```js symmetricDifference([1, 2, 3], [1, 2, 4]); // [3, 4] symmetricDifference([1, 2, 2], [1, 3, 1]); // [2, 2, 3] ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### symmetricDifferenceBy @@ -2658,19 +2577,18 @@ const symmetricDifferenceBy = (a, b, fn) => { sB = new Set(b.map(v => fn(v))); return [...a.filter(x => !sB.has(fn(x))), ...b.filter(x => !sA.has(fn(x)))]; }; -``` +```
-Examples - -```js + Examples + + ```js symmetricDifferenceBy([2.1, 1.2], [2.3, 3.4], Math.floor); // [ 1.2, 3.4 ] ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### symmetricDifferenceWith @@ -2683,12 +2601,12 @@ const symmetricDifferenceWith = (arr, val, comp) => [ ...arr.filter(a => val.findIndex(b => comp(a, b)) === -1), ...val.filter(a => arr.findIndex(b => comp(a, b)) === -1) ]; -``` +```
-Examples - -```js + Examples + + ```js symmetricDifferenceWith( [1, 1.2, 1.5, 3, 0], [1.9, 3, 0, 3.9], @@ -2697,9 +2615,8 @@ symmetricDifferenceWith( ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### tail @@ -2709,20 +2626,19 @@ Return `Array.slice(1)` if the array's `length` is more than `1`, otherwise, ret ```js const tail = arr => (arr.length > 1 ? arr.slice(1) : arr); -``` +```
-Examples - -```js + Examples + + ```js tail([1, 2, 3]); // [2,3] tail([1]); // [1] ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### take @@ -2732,20 +2648,19 @@ Use `Array.slice()` to create a slice of the array with `n` elements taken from ```js const take = (arr, n = 1) => arr.slice(0, n); -``` +```
-Examples - -```js + Examples + + ```js take([1, 2, 3], 5); // [1, 2, 3] take([1, 2, 3], 0); // [] ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### takeRight @@ -2755,20 +2670,19 @@ Use `Array.slice()` to create a slice of the array with `n` elements taken from ```js const takeRight = (arr, n = 1) => arr.slice(arr.length - n, arr.length); -``` +```
-Examples - -```js + Examples + + ```js takeRight([1, 2, 3], 2); // [ 2, 3 ] takeRight([1, 2, 3]); // [3] ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### takeRightWhile @@ -2783,19 +2697,18 @@ const takeRightWhile = (arr, func) => { if (func(arr[i])) return arr.reverse().slice(arr.length - i, arr.length); return arr; }; -``` +```
-Examples - -```js + Examples + + ```js takeRightWhile([1, 2, 3, 4], n => n < 3); // [3, 4] ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### takeWhile @@ -2809,19 +2722,18 @@ const takeWhile = (arr, func) => { for (const [i, val] of arr.entries()) if (func(val)) return arr.slice(0, i); return arr; }; -``` +```
-Examples - -```js + Examples + + ```js takeWhile([1, 2, 3, 4], n => n >= 3); // [1, 2] ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### toHash @@ -2836,12 +2748,12 @@ const toHash = (object, key) => (acc, data, index) => ((acc[!key ? index : data[key]] = data), acc), {} ); -``` +```
-Examples - -```js + Examples + + ```js toHash([4, 3, 2, 1]); // { 0: 4, 1: 3, 2: 2, 1: 1 } toHash([{ a: 'label' }], 'a'); // { label: { a: 'label' } } // A more in depth example: @@ -2858,9 +2770,8 @@ managers; // [ { manager:1, employees: [ { id: 2, first: "Joe" }, { id: 3, first ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### union @@ -2870,19 +2781,18 @@ Create a `Set` with all values of `a` and `b` and convert to an array. ```js const union = (a, b) => Array.from(new Set([...a, ...b])); -``` +```
-Examples - -```js + Examples + + ```js union([1, 2, 3], [4, 3, 2]); // [1,2,3,4] ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### unionBy @@ -2897,19 +2807,18 @@ const unionBy = (a, b, fn) => { const s = new Set(a.map(v => fn(v))); return Array.from(new Set([...a, ...b.filter(x => !s.has(fn(x)))])); }; -``` +```
-Examples - -```js + Examples + + ```js unionBy([2.1], [1.2, 2.3], Math.floor); // [2.1, 1.2] ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### unionWith @@ -2920,19 +2829,18 @@ Create a `Set` with all values of `a` and values in `b` for which the comparator ```js const unionWith = (a, b, comp) => Array.from(new Set([...a, ...b.filter(x => a.findIndex(y => comp(x, y)) === -1)])); -``` +```
-Examples - -```js + Examples + + ```js unionWith([1, 1.2, 1.5, 3, 0], [1.9, 3, 0, 3.9], (a, b) => Math.round(a) === Math.round(b)); // [1, 1.2, 1.5, 3, 0, 3.9] ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### uniqueElements @@ -2942,19 +2850,18 @@ Use ES6 `Set` and the `...rest` operator to discard all duplicated values. ```js const uniqueElements = arr => [...new Set(arr)]; -``` +```
-Examples - -```js + Examples + + ```js uniqueElements([1, 2, 2, 3, 4, 4, 5]); // [1,2,3,4,5] ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### uniqueElementsBy @@ -2969,12 +2876,12 @@ const uniqueElementsBy = (arr, fn) => if (!acc.some(x => fn(v, x))) acc.push(v); return acc; }, []); -``` +```
-Examples - -```js + Examples + + ```js uniqueElementsBy( [ { id: 0, value: 'a' }, @@ -2988,9 +2895,8 @@ uniqueElementsBy( ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### uniqueElementsByRight @@ -3005,12 +2911,12 @@ const uniqueElementsByRight = (arr, fn) => if (!acc.some(x => fn(v, x))) acc.push(v); return acc; }, []); -``` +```
-Examples - -```js + Examples + + ```js uniqueElementsByRight( [ { id: 0, value: 'a' }, @@ -3024,9 +2930,8 @@ uniqueElementsByRight( ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### uniqueSymmetricDifference @@ -3038,20 +2943,19 @@ Use `Array.filter()` and `Array.includes()` on each array to remove values conta const uniqueSymmetricDifference = (a, b) => [ ...new Set([...a.filter(v => !b.includes(v)), ...b.filter(v => !a.includes(v))]) ]; -``` +```
-Examples - -```js + Examples + + ```js uniqueSymmetricDifference([1, 2, 3], [1, 2, 4]); // [3, 4] uniqueSymmetricDifference([1, 2, 2], [1, 3, 1]); // [2, 3] ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### unzip @@ -3068,20 +2972,19 @@ const unzip = arr => length: Math.max(...arr.map(x => x.length)) }).map(x => []) ); -``` +```
-Examples - -```js + Examples + + ```js unzip([['a', 1, true], ['b', 2, false]]); //[['a', 'b'], [1, 2], [true, false]] unzip([['a', 1, true], ['b', 2]]); //[['a', 'b'], [1, 2], [true]] ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### unzipWith ![advanced](/advanced.svg) @@ -3101,19 +3004,18 @@ const unzipWith = (arr, fn) => }).map(x => []) ) .map(val => fn(...val)); -``` +```
-Examples - -```js + Examples + + ```js unzipWith([[1, 10, 100], [2, 20, 200]], (...args) => args.reduce((acc, v) => acc + v, 0)); // [3, 30, 300] ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### without @@ -3125,19 +3027,18 @@ _(For a snippet that mutates the original array see [`pull`](#pull))_ ```js const without = (arr, ...args) => arr.filter(v => !args.includes(v)); -``` +```
-Examples - -```js + Examples + + ```js without([2, 1, 2, 3], 1, 2); // [3] ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### xProd @@ -3147,19 +3048,18 @@ Use `Array.reduce()`, `Array.map()` and `Array.concat()` to produce every possib ```js const xProd = (a, b) => a.reduce((acc, x) => acc.concat(b.map(y => [x, y])), []); -``` +```
-Examples - -```js + Examples + + ```js xProd([1, 2], ['a', 'b']); // [[1, 'a'], [1, 'b'], [2, 'a'], [2, 'b']] ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### zip @@ -3176,20 +3076,19 @@ const zip = (...arrays) => { return Array.from({ length: arrays.length }, (_, k) => arrays[k][i]); }); }; -``` +```
-Examples - -```js + Examples + + ```js zip(['a', 'b'], [1, 2], [true, false]); // [['a', 1, true], ['b', 2, false]] zip(['a'], [1, 2], [true, false]); // [['a', 1, true], [undefined, 2, false]] ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### zipObject @@ -3200,20 +3099,19 @@ Since an object can have undefined values but not undefined property pointers, t ```js const zipObject = (props, values) => props.reduce((obj, prop, index) => ((obj[prop] = values[index]), obj), {}); -``` +```
-Examples - -```js + Examples + + ```js zipObject(['a', 'b', 'c'], [1, 2]); // {a: 1, b: 2, c: undefined} zipObject(['a', 'b'], [1, 2, 3]); // {a: 1, b: 2} ```
- -
[⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### zipWith ![advanced](/advanced.svg) @@ -3233,12 +3131,12 @@ const zipWith = (...array) => { (_, i) => (fn ? fn(...array.map(a => a[i])) : array.map(a => a[i])) ); }; -``` +```
-Examples - -```js + Examples + + ```js zipWith([1, 2], [10, 20], [100, 200], (a, b, c) => a + b + c); // [111,222] zipWith( [1, 2, 3], @@ -3249,13 +3147,12 @@ zipWith( ```
+ +[⬆ Back to top](#table-of-contents) -
[⬆ Back to top](#table-of-contents) - ---- - ## 🌐 Browser - -### arrayToHtmlList + +--- +## 🌐 Browser### arrayToHtmlList Converts the given array elements into `
  • ` tags and appends them to the list of the given id. @@ -3267,19 +3164,18 @@ const arrayToHtmlList = (arr, listID) => (el = document.querySelector('#' + listID)), (el.innerHTML += arr.map(item => `
  • ${item}
  • `).join('')) ))(); -``` +```
    -Examples - -```js + Examples + + ```js arrayToHtmlList(['item 1', 'item 2'], 'myListID'); ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### bottomVisible @@ -3291,19 +3187,18 @@ Use `scrollY`, `scrollHeight` and `clientHeight` to determine if the bottom of t const bottomVisible = () => document.documentElement.clientHeight + window.scrollY >= (document.documentElement.scrollHeight || document.documentElement.clientHeight); -``` +```
    -Examples - -```js + Examples + + ```js bottomVisible(); // true ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### copyToClipboard ![advanced](/advanced.svg) @@ -3335,19 +3230,18 @@ const copyToClipboard = str => { document.getSelection().addRange(selected); } }; -``` +```
    -Examples - -```js + Examples + + ```js copyToClipboard('Lorem ipsum'); // 'Lorem ipsum' copied to clipboard. ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### counter ![advanced](/advanced.svg) @@ -3371,19 +3265,18 @@ const counter = (selector, start, end, step = 1, duration = 2000) => { }, Math.abs(Math.floor(duration / (end - start)))); return timer; }; -``` +```
    -Examples - -```js + Examples + + ```js counter('#my-id', 1, 1000, 5, 2000); // Creates a 2-second timer for the element with id="my-id" ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### createElement @@ -3400,12 +3293,12 @@ const createElement = str => { el.innerHTML = str; return el.firstElementChild; }; -``` +```
    -Examples - -```js + Examples + + ```js const el = createElement( `

    Hello!

    @@ -3415,9 +3308,8 @@ console.log(el.className); // 'container' ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### createEventHub ![advanced](/advanced.svg) @@ -3444,12 +3336,12 @@ const createEventHub = () => ({ if (i > -1) this.hub[event].splice(i, 1); } }); -``` +```
    -Examples - -```js + Examples + + ```js const handler = data => console.log(data); const hub = createEventHub(); let increment = 0; @@ -3469,9 +3361,8 @@ hub.off('message', handler); ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### currentURL @@ -3481,19 +3372,18 @@ Use `window.location.href` to get current URL. ```js const currentURL = () => window.location.href; -``` +```
    -Examples - -```js + Examples + + ```js currentURL(); // 'https://google.com' ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### detectDeviceType @@ -3506,19 +3396,18 @@ const detectDeviceType = () => /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ? 'Mobile' : 'Desktop'; -``` +```
    -Examples - -```js + Examples + + ```js detectDeviceType(); // "Mobile" or "Desktop" ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### elementContains @@ -3528,20 +3417,19 @@ Check that `parent` is not the same element as `child`, use `parent.contains(chi ```js const elementContains = (parent, child) => parent !== child && parent.contains(child); -``` +```
    -Examples - -```js + Examples + + ```js elementContains(document.querySelector('head'), document.querySelector('title')); // true elementContains(document.querySelector('body'), document.querySelector('body')); // false ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### elementIsVisibleInViewport ![advanced](/advanced.svg) @@ -3561,21 +3449,20 @@ const elementIsVisibleInViewport = (el, partiallyVisible = false) => { ((left > 0 && left < innerWidth) || (right > 0 && right < innerWidth)) : top >= 0 && left >= 0 && bottom <= innerHeight && right <= innerWidth; }; -``` +```
    -Examples - -```js + Examples + + ```js // e.g. 100x100 viewport and a 10x10px element at position {top: -1, left: 0, bottom: 9, right: 10} elementIsVisibleInViewport(el); // false - (not fully visible) elementIsVisibleInViewport(el, true); // true - (partially visible) ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### getScrollPosition @@ -3589,19 +3476,18 @@ const getScrollPosition = (el = window) => ({ x: el.pageXOffset !== undefined ? el.pageXOffset : el.scrollLeft, y: el.pageYOffset !== undefined ? el.pageYOffset : el.scrollTop }); -``` +```
    -Examples - -```js + Examples + + ```js getScrollPosition(); // {x: 0, y: 200} ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### getStyle @@ -3611,19 +3497,18 @@ Use `Window.getComputedStyle()` to get the value of the CSS rule for the specifi ```js const getStyle = (el, ruleName) => getComputedStyle(el)[ruleName]; -``` +```
    -Examples - -```js + Examples + + ```js getStyle(document.querySelector('p'), 'font-size'); // '16px' ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### hasClass @@ -3633,19 +3518,18 @@ Use `element.classList.contains()` to check if the element has the specified cla ```js const hasClass = (el, className) => el.classList.contains(className); -``` +```
    -Examples - -```js + Examples + + ```js hasClass(document.querySelector('p.special'), 'special'); // true ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### hashBrowser ![advanced](/advanced.svg) @@ -3662,19 +3546,18 @@ const hashBrowser = val => hexes.push(('00000000' + view.getUint32(i).toString(16)).slice(-8)); return hexes.join(''); }); -``` +```
    -Examples - -```js + Examples + + ```js hashBrowser(JSON.stringify({ a: 'a', b: [1, 2, 3, 4], foo: { c: 'bar' } })).then(console.log); // '04aa106279f5977f59f9067fa9712afc4aedc6f5862a8defc34552d8c7206393' ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### hide @@ -3684,19 +3567,18 @@ Use `NodeList.prototype.forEach()` to apply `display: none` to each element spec ```js const hide = els => els.forEach(e => (e.style.display = 'none')); -``` +```
    -Examples - -```js + Examples + + ```js hide(document.querySelectorAll('img')); // Hides all elements on the page ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### httpsRedirect @@ -3708,19 +3590,18 @@ Use `location.protocol` to get the protocol currently being used. If it's not HT const httpsRedirect = () => { if (location.protocol !== 'https:') location.replace('https://' + location.href.split('//')[1]); }; -``` +```
    -Examples - -```js + Examples + + ```js httpsRedirect(); // If you are on http://mydomain.com, you are redirected to https://mydomain.com ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### insertAfter @@ -3730,19 +3611,18 @@ Use `el.insertAdjacentHTML()` with a position of `'afterend'` to parse `htmlStri ```js const insertAfter = (el, htmlString) => el.insertAdjacentHTML('afterend', htmlString); -``` +```
    -Examples - -```js + Examples + + ```js insertAfter(document.getElementById('myId'), '

    after

    '); //
    ...

    after

    ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### insertBefore @@ -3752,19 +3632,18 @@ Use `el.insertAdjacentHTML()` with a position of `'beforebegin'` to parse `htmlS ```js const insertBefore = (el, htmlString) => el.insertAdjacentHTML('beforebegin', htmlString); -``` +```
    -Examples - -```js + Examples + + ```js insertBefore(document.getElementById('myId'), '

    before

    '); //

    before

    ...
    ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### isBrowserTabFocused @@ -3774,19 +3653,18 @@ Use the `Document.hidden` property, introduced by the Page Visibility API to che ```js const isBrowserTabFocused = () => !document.hidden; -``` +```
    -Examples - -```js + Examples + + ```js isBrowserTabFocused(); // true ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### nodeListToArray @@ -3796,19 +3674,18 @@ Use spread operator inside new array to convert a `NodeList` to an array. ```js const nodeListToArray = nodeList => [...nodeList]; -``` +```
    -Examples - -```js + Examples + + ```js nodeListToArray(document.childNodes); // [ , html ] ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### observeMutations ![advanced](/advanced.svg) @@ -3837,20 +3714,19 @@ const observeMutations = (element, callback, options) => { ); return observer; }; -``` +```
    -Examples - -```js + Examples + + ```js const obs = observeMutations(document, console.log); // Logs all mutations that happen on the page obs.disconnect(); // Disconnects the observer and stops logging mutations on the page ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### off @@ -3861,21 +3737,20 @@ Omit the fourth argument `opts` to use `false` or specify it based on the option ```js const off = (el, evt, fn, opts = false) => el.removeEventListener(evt, fn, opts); -``` +```
    -Examples - -```js + Examples + + ```js const fn = () => console.log('!'); document.body.addEventListener('click', fn); off(document.body, 'click', fn); // no longer logs '!' upon clicking on the page ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### on @@ -3891,12 +3766,12 @@ const on = (el, evt, fn, opts = {}) => { el.addEventListener(evt, opts.target ? delegatorFn : fn, opts.options || false); if (opts.target) return delegatorFn; }; -``` +```
    -Examples - -```js + Examples + + ```js const fn = () => console.log('!'); on(document.body, 'click', fn); // logs '!' upon clicking the body on(document.body, 'click', fn, { target: 'p' }); // logs '!' upon clicking a `p` element child of the body @@ -3904,9 +3779,8 @@ on(document.body, 'click', fn, { options: true }); // use capturing instead of b ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### onUserInputChange ![advanced](/advanced.svg) @@ -3931,21 +3805,20 @@ const onUserInputChange = callback => { (type = 'touch'), callback(type), document.addEventListener('mousemove', mousemoveHandler); }); }; -``` +```
    -Examples - -```js + Examples + + ```js onUserInputChange(type => { console.log('The user is now using', type, 'as an input method.'); }); ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### prefix @@ -3963,19 +3836,18 @@ const prefix = prop => { ); return i !== -1 ? (i === 0 ? prop : prefixes[i] + capitalizedProp) : null; }; -``` +```
    -Examples - -```js + Examples + + ```js prefix('appearance'); // 'appearance' on a supported browser, otherwise 'webkitAppearance', 'mozAppearance', 'msAppearance' or 'oAppearance' ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### recordAnimationFrames @@ -4007,12 +3879,12 @@ const recordAnimationFrames = (callback, autoStart = true) => { if (autoStart) start(); return { start, stop }; }; -``` +```
    -Examples - -```js + Examples + + ```js const cb = () => console.log('Animation frame fired'); const recorder = recordAnimationFrames(cb); // logs 'Animation frame fired' on each animation frame recorder.stop(); // stops logging @@ -4021,9 +3893,8 @@ const recorder2 = recordAnimationFrames(cb, false); // `start` needs to be expli ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### redirect @@ -4035,19 +3906,18 @@ Pass a second argument to simulate a link click (`true` - default) or an HTTP re ```js const redirect = (url, asLink = true) => asLink ? (window.location.href = url) : window.location.replace(url); -``` +```
    -Examples - -```js + Examples + + ```js redirect('https://google.com'); ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### runAsync ![advanced](/advanced.svg) @@ -4073,12 +3943,12 @@ const runAsync = fn => { }; }); }; -``` +```
    -Examples - -```js + Examples + + ```js const longRunningFunction = () => { let result = 0; for (let i = 0; i < 1000; i++) { @@ -4102,9 +3972,8 @@ runAsync(() => typeof outsideVariable).then(console.log); // 'undefined' ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### scrollToTop @@ -4121,19 +3990,18 @@ const scrollToTop = () => { window.scrollTo(0, c - c / 8); } }; -``` +```
    -Examples - -```js + Examples + + ```js scrollToTop(); ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### setStyle @@ -4143,19 +4011,18 @@ Use `element.style` to set the value of the CSS rule for the specified element t ```js const setStyle = (el, ruleName, val) => (el.style[ruleName] = val); -``` +```
    -Examples - -```js + Examples + + ```js setStyle(document.querySelector('p'), 'font-size', '20px'); // The first

    element on the page will have a font-size of 20px ```

    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### show @@ -4165,19 +4032,18 @@ Use the spread operator (`...`) and `Array.forEach()` to clear the `display` pro ```js const show = (...el) => [...el].forEach(e => (e.style.display = '')); -``` +```
    -Examples - -```js + Examples + + ```js show(...document.querySelectorAll('img')); // Shows all elements on the page ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### smoothScroll @@ -4191,20 +4057,19 @@ const smoothScroll = element => document.querySelector(element).scrollIntoView({ behavior: 'smooth' }); -``` +```
    -Examples - -```js + Examples + + ```js smoothScroll('#fooBar'); // scrolls smoothly to the element with the id fooBar smoothScroll('.fooBar'); // scrolls smoothly to the first element with a class of fooBar ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### toggleClass @@ -4214,19 +4079,18 @@ Use `element.classList.toggle()` to toggle the specified class for the element. ```js const toggleClass = (el, className) => el.classList.toggle(className); -``` +```
    -Examples - -```js + Examples + + ```js toggleClass(document.querySelector('p.special'), 'special'); // The paragraph will not have the 'special' class anymore ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### triggerEvent @@ -4239,20 +4103,19 @@ Omit the third argument, `detail`, if you do not want to pass custom data to the ```js const triggerEvent = (el, eventType, detail = undefined) => el.dispatchEvent(new CustomEvent(eventType, { detail: detail })); -``` +```
    -Examples - -```js + Examples + + ```js triggerEvent(document.getElementById('myId'), 'click'); triggerEvent(document.getElementById('myId'), 'click', { username: 'bob' }); ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### UUIDGeneratorBrowser @@ -4265,23 +4128,22 @@ const UUIDGeneratorBrowser = () => ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c => (c ^ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4)))).toString(16) ); -``` +```
    -Examples - -```js + Examples + + ```js UUIDGeneratorBrowser(); // '7982fcfe-5721-4632-bede-6000885be57d' ```
    + +[⬆ Back to top](#table-of-contents) -
    [⬆ Back to top](#table-of-contents) - ---- - ## ⏱️ Date - -### formatDuration + +--- +## ⏱️ Date### formatDuration Returns the human readable format of the given number of milliseconds. @@ -4305,20 +4167,19 @@ const formatDuration = ms => { .map(([key, val]) => `${val} ${key}${val !== 1 ? 's' : ''}`) .join(', '); }; -``` +```
    -Examples - -```js + Examples + + ```js formatDuration(1001); // '1 second, 1 millisecond' formatDuration(34325055574); // '397 days, 6 hours, 44 minutes, 15 seconds, 574 milliseconds' ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### getColonTimeFromDate @@ -4328,19 +4189,18 @@ Use `Date.toString()` and `String.slice()` to get the `HH:MM:SS` part of a given ```js const getColonTimeFromDate = date => date.toTimeString().slice(0, 8); -``` +```
    -Examples - -```js + Examples + + ```js getColonTimeFromDate(new Date()); // "08:38:00" ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### getDaysDiffBetweenDates @@ -4351,19 +4211,18 @@ Calculate the difference (in days) between two `Date` objects. ```js const getDaysDiffBetweenDates = (dateInitial, dateFinal) => (dateFinal - dateInitial) / (1000 * 3600 * 24); -``` +```
    -Examples - -```js + Examples + + ```js getDaysDiffBetweenDates(new Date('2017-12-13'), new Date('2017-12-22')); // 9 ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### getMeridiemSuffixOfInteger @@ -4380,12 +4239,12 @@ const getMeridiemSuffixOfInteger = num => : num < 12 ? (num % 12) + 'am' : (num % 12) + 'pm'; -``` +```
    -Examples - -```js + Examples + + ```js getMeridiemSuffixOfInteger(0); // "12am" getMeridiemSuffixOfInteger(11); // "11am" getMeridiemSuffixOfInteger(13); // "1pm" @@ -4393,9 +4252,8 @@ getMeridiemSuffixOfInteger(25); // "1pm" ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### tomorrow @@ -4411,24 +4269,23 @@ const tomorrow = (long = false) => { ).padStart(2, '0')}`; return !long ? ret : `${ret}T00:00:00`; }; -``` +```
    -Examples - -```js + Examples + + ```js tomorrow(); // 2017-12-27 (if current date is 2017-12-26) tomorrow(true); // 2017-12-27T00:00:00 (if current date is 2017-12-26) ```
    + +[⬆ Back to top](#table-of-contents) -
    [⬆ Back to top](#table-of-contents) - ---- - ## 🎛️ Function - -### attempt + +--- +## 🎛️ Function### attempt Attempts to invoke a function with the provided arguments, returning either the result or the caught error object. @@ -4442,12 +4299,12 @@ const attempt = (fn, ...args) => { return e instanceof Error ? e : new Error(e); } }; -``` +```
    -Examples - -```js + Examples + + ```js var elements = attempt(function(selector) { return document.querySelectorAll(selector); }, '>_>'); @@ -4455,9 +4312,8 @@ if (elements instanceof Error) elements = []; // elements = [] ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### bind @@ -4468,12 +4324,12 @@ Use `Array.concat()` to prepend any additional supplied parameters to the argume ```js const bind = (fn, context, ...boundArgs) => (...args) => fn.apply(context, [...boundArgs, ...args]); -``` +```
    -Examples - -```js + Examples + + ```js function greet(greeting, punctuation) { return greeting + ' ' + this.user + punctuation; } @@ -4483,9 +4339,8 @@ console.log(freddyBound('hi', '!')); // 'hi fred!' ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### bindKey @@ -4497,12 +4352,12 @@ Use the spread operator (`...`) to prepend any additional supplied parameters to ```js const bindKey = (context, fn, ...boundArgs) => (...args) => context[fn].apply(context, [...boundArgs, ...args]); -``` +```
    -Examples - -```js + Examples + + ```js const freddy = { user: 'fred', greet: function(greeting, punctuation) { @@ -4514,9 +4369,8 @@ console.log(freddyBound('hi', '!')); // 'hi fred!' ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### chainAsync @@ -4530,12 +4384,12 @@ const chainAsync = fns => { const next = () => fns[curr++](next); next(); }; -``` +```
    -Examples - -```js + Examples + + ```js chainAsync([ next => { console.log('0 seconds'); @@ -4548,9 +4402,8 @@ chainAsync([ ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### compose @@ -4561,12 +4414,12 @@ The last (rightmost) function can accept one or more arguments; the remaining fu ```js const compose = (...fns) => fns.reduce((f, g) => (...args) => f(g(...args))); -``` +```
    -Examples - -```js + Examples + + ```js const add5 = x => x + 5; const multiply = (x, y) => x * y; const multiplyAndAdd5 = compose( @@ -4577,9 +4430,8 @@ multiplyAndAdd5(5, 2); // 15 ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### composeRight @@ -4590,12 +4442,12 @@ The first (leftmost) function can accept one or more arguments; the remaining fu ```js const composeRight = (...fns) => fns.reduce((f, g) => (...args) => g(f(...args))); -``` +```
    -Examples - -```js + Examples + + ```js const add = (x, y) => x + y; const square = x => x * x; const addAndSquare = composeRight(add, square); @@ -4603,9 +4455,8 @@ addAndSquare(1, 2); // 9 ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### converge @@ -4616,12 +4467,12 @@ Use the spread operator (`...`) to call `coverger` with the results of all other ```js const converge = (converger, fns) => (...args) => converger(...fns.map(fn => fn.apply(null, args))); -``` +```
    -Examples - -```js + Examples + + ```js const average = converge((a, b) => a / b, [ arr => arr.reduce((a, v) => a + v, 0), arr => arr.length @@ -4630,9 +4481,8 @@ average([1, 2, 3, 4, 5, 6, 7]); // 4 ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### curry @@ -4646,20 +4496,19 @@ If you want to curry a function that accepts a variable number of arguments (a v ```js const curry = (fn, arity = fn.length, ...args) => arity <= args.length ? fn(...args) : curry.bind(null, fn, arity, ...args); -``` +```
    -Examples - -```js + Examples + + ```js curry(Math.pow)(2)(10); // 1024 curry(Math.min, 3)(10)(50)(2); // 2 ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### debounce @@ -4676,12 +4525,12 @@ const debounce = (fn, ms = 0) => { timeoutId = setTimeout(() => fn.apply(this, args), ms); }; }; -``` +```
    -Examples - -```js + Examples + + ```js window.addEventListener( 'resize', debounce(() => { @@ -4692,9 +4541,8 @@ window.addEventListener( ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### defer @@ -4704,12 +4552,12 @@ Use `setTimeout()` with a timeout of 1ms to add a new event to the browser event ```js const defer = (fn, ...args) => setTimeout(fn, 1, ...args); -``` +```
    -Examples - -```js + Examples + + ```js // Example A: defer(console.log, 'a'), console.log('b'); // logs 'b' then 'a' @@ -4720,9 +4568,8 @@ defer(longRunningFunction); // Browser will update the HTML then run the functio ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### delay @@ -4733,12 +4580,12 @@ Use the spread (`...`) operator to supply the function with an arbitrary number ```js const delay = (fn, wait, ...args) => setTimeout(fn, wait, ...args); -``` +```
    -Examples - -```js + Examples + + ```js delay( function(text) { console.log(text); @@ -4749,9 +4596,8 @@ delay( ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### functionName @@ -4761,19 +4607,18 @@ Use `console.debug()` and the `name` property of the passed method to log the me ```js const functionName = fn => (console.debug(fn.name), fn); -``` +```
    -Examples - -```js + Examples + + ```js functionName(Math.max); // max (logged in debug channel of console) ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### hz @@ -4790,12 +4635,12 @@ const hz = (fn, iterations = 100) => { for (let i = 0; i < iterations; i++) fn(); return (1000 * iterations) / (performance.now() - before); }; -``` +```
    -Examples - -```js + Examples + + ```js // 10,000 element array const numbers = Array(10000) .fill() @@ -4815,9 +4660,8 @@ Math.round(hz(sumForLoop)); // 4784 ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### memoize ![advanced](/advanced.svg) @@ -4836,12 +4680,12 @@ const memoize = fn => { cached.cache = cache; return cached; }; -``` +```
    -Examples - -```js + Examples + + ```js // See the `anagrams` snippet. const anagramsCached = memoize(anagrams); anagramsCached('javascript'); // takes a long time @@ -4850,9 +4694,8 @@ console.log(anagramsCached.cache); // The cached anagrams map ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### negate @@ -4862,19 +4705,18 @@ Take a predicate function and apply the not operator (`!`) to it with its argume ```js const negate = func => (...args) => !func(...args); -``` +```
    -Examples - -```js + Examples + + ```js [1, 2, 3, 4, 5, 6].filter(negate(n => n % 2 === 0)); // [ 1, 3, 5 ] ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### once @@ -4892,12 +4734,12 @@ const once = fn => { return fn.apply(this, args); }; }; -``` +```
    -Examples - -```js + Examples + + ```js const startApp = function(event) { console.log(this, event); // document.body, MouseEvent }; @@ -4905,9 +4747,8 @@ document.body.addEventListener('click', once(startApp)); // only runs `startApp` ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### partial @@ -4917,21 +4758,20 @@ Use the spread operator (`...`) to prepend `partials` to the list of arguments o ```js const partial = (fn, ...partials) => (...args) => fn(...partials, ...args); -``` +```
    -Examples - -```js + Examples + + ```js const greet = (greeting, name) => greeting + ' ' + name + '!'; const greetHello = partial(greet, 'Hello'); greetHello('John'); // 'Hello John!' ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### partialRight @@ -4941,21 +4781,20 @@ Use the spread operator (`...`) to append `partials` to the list of arguments of ```js const partialRight = (fn, ...partials) => (...args) => fn(...args, ...partials); -``` +```
    -Examples - -```js + Examples + + ```js const greet = (greeting, name) => greeting + ' ' + name + '!'; const greetJohn = partialRight(greet, 'John'); greetJohn('Hello'); // 'Hello John!' ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### runPromisesInSeries @@ -4965,20 +4804,19 @@ Use `Array.reduce()` to create a promise chain, where each promise returns the n ```js const runPromisesInSeries = ps => ps.reduce((p, next) => p.then(next), Promise.resolve()); -``` +```
    -Examples - -```js + Examples + + ```js const delay = d => new Promise(r => setTimeout(r, d)); runPromisesInSeries([() => delay(1000), () => delay(2000)]); // Executes each promise sequentially, taking a total of 3 seconds to complete ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### sleep @@ -4988,12 +4826,12 @@ Delay executing part of an `async` function, by putting it to sleep, returning a ```js const sleep = ms => new Promise(resolve => setTimeout(resolve, ms)); -``` +```
    -Examples - -```js + Examples + + ```js async function sleepyWork() { console.log("I'm going to sleep for 1 second."); await sleep(1000); @@ -5002,9 +4840,8 @@ async function sleepyWork() { ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### throttle ![advanced](/advanced.svg) @@ -5036,12 +4873,12 @@ const throttle = (fn, wait) => { } }; }; -``` +```
    -Examples - -```js + Examples + + ```js window.addEventListener( 'resize', throttle(function(evt) { @@ -5052,9 +4889,8 @@ window.addEventListener( ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### times @@ -5068,21 +4904,20 @@ const times = (n, fn, context = undefined) => { let i = 0; while (fn.call(context, i) !== false && ++i < n) {} }; -``` +```
    -Examples - -```js + Examples + + ```js var output = ''; times(5, i => (output += i)); console.log(output); // 01234 ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### uncurry @@ -5100,21 +4935,20 @@ const uncurry = (fn, n = 1) => (...args) => { if (n > args.length) throw new RangeError('Arguments too few!'); return next(fn)(args.slice(0, n)); }; -``` +```
    -Examples - -```js + Examples + + ```js const add = x => y => z => x + y + z; const uncurriedAdd = uncurry(add, 3); uncurriedAdd(1, 2, 3); // 6 ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### unfold @@ -5130,20 +4964,19 @@ const unfold = (fn, seed) => { while ((val = fn(val[1]))) result.push(val[0]); return result; }; -``` +```
    -Examples - -```js + Examples + + ```js var f = n => (n > 50 ? false : [-n, n + 10]); unfold(f, 10); // [-10, -20, -30, -40, -50] ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### when @@ -5153,25 +4986,24 @@ Return a function expecting a single value, `x`, that returns the appropriate va ```js const when = (pred, whenTrue) => x => (pred(x) ? whenTrue(x) : x); -``` +```
    -Examples - -```js + Examples + + ```js const doubleEvenNumbers = when(x => x % 2 === 0, x => x * 2); doubleEvenNumbers(2); // 4 doubleEvenNumbers(1); // 1 ```
    + +[⬆ Back to top](#table-of-contents) -
    [⬆ Back to top](#table-of-contents) - ---- - ## ➗ Math - -### approximatelyEqual + +--- +## ➗ Math### approximatelyEqual Checks if two numbers are approximately equal to each other. @@ -5180,19 +5012,18 @@ Omit the third parameter, `epsilon`, to use a default value of `0.001`. ```js const approximatelyEqual = (v1, v2, epsilon = 0.001) => Math.abs(v1 - v2) < epsilon; -``` +```
    -Examples - -```js + Examples + + ```js approximatelyEqual(Math.PI / 2.0, 1.5708); // true ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### average @@ -5202,20 +5033,19 @@ Use `Array.reduce()` to add each value to an accumulator, initialized with a val ```js const average = (...nums) => nums.reduce((acc, val) => acc + val, 0) / nums.length; -``` +```
    -Examples - -```js + Examples + + ```js average(...[1, 2, 3]); // 2 average(1, 2, 3); // 2 ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### averageBy @@ -5227,20 +5057,19 @@ Use `Array.map()` to map each element to the value returned by `fn`, `Array.redu const averageBy = (arr, fn) => arr.map(typeof fn === 'function' ? fn : val => val[fn]).reduce((acc, val) => acc + val, 0) / arr.length; -``` +```
    -Examples - -```js + Examples + + ```js averageBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }], o => o.n); // 5 averageBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }], 'n'); // 5 ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### binomialCoefficient @@ -5263,19 +5092,18 @@ const binomialCoefficient = (n, k) => { for (let j = 2; j <= k; j++) res *= (n - j + 1) / j; return Math.round(res); }; -``` +```
    -Examples - -```js + Examples + + ```js binomialCoefficient(8, 2); // 28 ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### clampNumber @@ -5286,20 +5114,19 @@ Otherwise, return the nearest number in the range. ```js const clampNumber = (num, a, b) => Math.max(Math.min(num, Math.max(a, b)), Math.min(a, b)); -``` +```
    -Examples - -```js + Examples + + ```js clampNumber(2, 3, 5); // 3 clampNumber(1, -1, -5); // -1 ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### degreesToRads @@ -5309,19 +5136,18 @@ Use `Math.PI` and the degree to radian formula to convert the angle from degrees ```js const degreesToRads = deg => (deg * Math.PI) / 180.0; -``` +```
    -Examples - -```js + Examples + + ```js degreesToRads(90.0); // ~1.5708 ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### digitize @@ -5332,19 +5158,18 @@ Use `Array.map()` and `parseInt()` to transform each value to an integer. ```js const digitize = n => [...`${n}`].map(i => parseInt(i)); -``` +```
    -Examples - -```js + Examples + + ```js digitize(123); // [1, 2, 3] ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### distance @@ -5354,19 +5179,18 @@ Use `Math.hypot()` to calculate the Euclidean distance between two points. ```js const distance = (x0, y0, x1, y1) => Math.hypot(x1 - x0, y1 - y0); -``` +```
    -Examples - -```js + Examples + + ```js distance(1, 1, 2, 3); // 2.23606797749979 ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### elo ![advanced](/advanced.svg) @@ -5397,12 +5221,12 @@ const elo = ([...ratings], kFactor = 32, selfRating) => { } return ratings; }; -``` +```
    -Examples - -```js + Examples + + ```js // Standard 1v1s elo([1200, 1200]); // [1216, 1184] elo([1200, 1200], 64); // [1232, 1168] @@ -5416,9 +5240,8 @@ own individual rating by supplying it as the third argument. ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### factorial @@ -5438,19 +5261,18 @@ const factorial = n => : n <= 1 ? 1 : n * factorial(n - 1); -``` +```
    -Examples - -```js + Examples + + ```js factorial(6); // 720 ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### fibonacci @@ -5465,19 +5287,18 @@ const fibonacci = n => (acc, val, i) => acc.concat(i > 1 ? acc[i - 1] + acc[i - 2] : i), [] ); -``` +```
    -Examples - -```js + Examples + + ```js fibonacci(6); // [0, 1, 1, 2, 3, 5] ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### gcd @@ -5492,20 +5313,19 @@ const gcd = (...arr) => { const _gcd = (x, y) => (!y ? x : gcd(y, x % y)); return [...arr].reduce((a, b) => _gcd(a, b)); }; -``` +```
    -Examples - -```js + Examples + + ```js gcd(8, 36); // 4 gcd(...[12, 8, 32]); // 4 ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### geometricProgression @@ -5521,21 +5341,20 @@ const geometricProgression = (end, start = 1, step = 2) => Array.from({ length: Math.floor(Math.log(end / start) / Math.log(step)) + 1 }).map( (v, i) => start * step ** i ); -``` +```
    -Examples - -```js + Examples + + ```js geometricProgression(256); // [1, 2, 4, 8, 16, 32, 64, 128, 256] geometricProgression(256, 3); // [3, 6, 12, 24, 48, 96, 192] geometricProgression(256, 1, 4); // [1, 4, 16, 64, 256] ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### hammingDistance @@ -5546,19 +5365,18 @@ Count and return the number of `1`s in the string, using `match(/1/g)`. ```js const hammingDistance = (num1, num2) => ((num1 ^ num2).toString(2).match(/1/g) || '').length; -``` +```
    -Examples - -```js + Examples + + ```js hammingDistance(2, 3); // 1 ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### inRange @@ -5572,12 +5390,12 @@ const inRange = (n, start, end = null) => { if (end && start > end) [end, start] = [start, end]; return end == null ? n >= 0 && n < start : n >= start && n < end; }; -``` +```
    -Examples - -```js + Examples + + ```js inRange(3, 2, 5); // true inRange(3, 4); // true inRange(2, 3, 5); // false @@ -5585,9 +5403,8 @@ inRange(3, 2); // false ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### isDivisible @@ -5597,19 +5414,18 @@ Use the modulo operator (`%`) to check if the remainder is equal to `0`. ```js const isDivisible = (dividend, divisor) => dividend % divisor === 0; -``` +```
    -Examples - -```js + Examples + + ```js isDivisible(6, 3); // true ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### isEven @@ -5620,19 +5436,18 @@ Returns `true` if the number is even, `false` if the number is odd. ```js const isEven = num => num % 2 === 0; -``` +```
    -Examples - -```js + Examples + + ```js isEven(3); // false ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### isPrime @@ -5647,19 +5462,18 @@ const isPrime = num => { for (var i = 2; i <= boundary; i++) if (num % i === 0) return false; return num >= 2; }; -``` +```
    -Examples - -```js + Examples + + ```js isPrime(11); // true ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### lcm @@ -5674,20 +5488,19 @@ const lcm = (...arr) => { const _lcm = (x, y) => (x * y) / gcd(x, y); return [...arr].reduce((a, b) => _lcm(a, b)); }; -``` +```
    -Examples - -```js + Examples + + ```js lcm(12, 7); // 84 lcm(...[1, 3, 4, 5]); // 60 ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### luhnCheck ![advanced](/advanced.svg) @@ -5710,21 +5523,20 @@ const luhnCheck = num => { sum += lastDigit; return sum % 10 === 0; }; -``` +```
    -Examples - -```js + Examples + + ```js luhnCheck('4485275742308327'); // true luhnCheck(6011329933655299); // false luhnCheck(123456789); // false ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### maxBy @@ -5734,20 +5546,19 @@ Use `Array.map()` to map each element to the value returned by `fn`, `Math.max() ```js const maxBy = (arr, fn) => Math.max(...arr.map(typeof fn === 'function' ? fn : val => val[fn])); -``` +```
    -Examples - -```js + Examples + + ```js maxBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }], o => o.n); // 8 maxBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }], 'n'); // 8 ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### median @@ -5762,19 +5573,18 @@ const median = arr => { nums = [...arr].sort((a, b) => a - b); return arr.length % 2 !== 0 ? nums[mid] : (nums[mid - 1] + nums[mid]) / 2; }; -``` +```
    -Examples - -```js + Examples + + ```js median([5, 6, 50, 1, -5]); // 5 ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### minBy @@ -5784,20 +5594,19 @@ Use `Array.map()` to map each element to the value returned by `fn`, `Math.min() ```js const minBy = (arr, fn) => Math.min(...arr.map(typeof fn === 'function' ? fn : val => val[fn])); -``` +```
    -Examples - -```js + Examples + + ```js minBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }], o => o.n); // 2 minBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }], 'n'); // 2 ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### percentile @@ -5808,19 +5617,18 @@ Use `Array.reduce()` to calculate how many numbers are below the value and how m ```js const percentile = (arr, val) => (100 * arr.reduce((acc, v) => acc + (v < val ? 1 : 0) + (v === val ? 0.5 : 0), 0)) / arr.length; -``` +```
    -Examples - -```js + Examples + + ```js percentile([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 6); // 55 ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### powerset @@ -5830,19 +5638,18 @@ Use `Array.reduce()` combined with `Array.map()` to iterate over elements and co ```js const powerset = arr => arr.reduce((a, v) => a.concat(a.map(r => [v].concat(r))), [[]]); -``` +```
    -Examples - -```js + Examples + + ```js powerset([1, 2]); // [[], [1], [2], [2,1]] ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### primes @@ -5858,19 +5665,18 @@ const primes = num => { numsTillSqroot.forEach(x => (arr = arr.filter(y => y % x !== 0 || y === x))); return arr; }; -``` +```
    -Examples - -```js + Examples + + ```js primes(10); // [2,3,5,7] ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### radsToDegrees @@ -5880,19 +5686,18 @@ Use `Math.PI` and the radian to degree formula to convert the angle from radians ```js const radsToDegrees = rad => (rad * 180.0) / Math.PI; -``` +```
    -Examples - -```js + Examples + + ```js radsToDegrees(Math.PI / 2); // 90 ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### randomIntArrayInRange @@ -5903,19 +5708,18 @@ Use `Array.from()` to create an empty array of the specific length, `Math.random ```js const randomIntArrayInRange = (min, max, n = 1) => Array.from({ length: n }, () => Math.floor(Math.random() * (max - min + 1)) + min); -``` +```
    -Examples - -```js + Examples + + ```js randomIntArrayInRange(12, 35, 10); // [ 34, 14, 27, 17, 30, 27, 20, 26, 21, 14 ] ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### randomIntegerInRange @@ -5925,19 +5729,18 @@ Use `Math.random()` to generate a random number and map it to the desired range, ```js const randomIntegerInRange = (min, max) => Math.floor(Math.random() * (max - min + 1)) + min; -``` +```
    -Examples - -```js + Examples + + ```js randomIntegerInRange(0, 5); // 2 ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### randomNumberInRange @@ -5947,19 +5750,18 @@ Use `Math.random()` to generate a random value, map it to the desired range usin ```js const randomNumberInRange = (min, max) => Math.random() * (max - min) + min; -``` +```
    -Examples - -```js + Examples + + ```js randomNumberInRange(2, 10); // 6.0211363285087005 ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### round @@ -5970,19 +5772,18 @@ Omit the second argument, `decimals` to round to an integer. ```js const round = (n, decimals = 0) => Number(`${Math.round(`${n}e${decimals}`)}e-${decimals}`); -``` +```
    -Examples - -```js + Examples + + ```js round(1.005, 2); // 1.01 ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### sdbm @@ -5999,19 +5800,18 @@ const sdbm = str => { 0 ); }; -``` +```
    -Examples - -```js + Examples + + ```js sdbm('name'); // -3521204949 ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### standardDeviation @@ -6029,20 +5829,19 @@ const standardDeviation = (arr, usePopulation = false) => { (arr.length - (usePopulation ? 0 : 1)) ); }; -``` +```
    -Examples - -```js + Examples + + ```js standardDeviation([10, 2, 38, 23, 38, 23, 21]); // 13.284434142114991 (sample) standardDeviation([10, 2, 38, 23, 38, 23, 21], true); // 12.29899614287479 (population) ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### sum @@ -6052,19 +5851,18 @@ Use `Array.reduce()` to add each value to an accumulator, initialized with a val ```js const sum = (...arr) => [...arr].reduce((acc, val) => acc + val, 0); -``` +```
    -Examples - -```js + Examples + + ```js sum(...[1, 2, 3, 4]); // 10 ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### sumBy @@ -6075,20 +5873,19 @@ Use `Array.map()` to map each element to the value returned by `fn`, `Array.redu ```js const sumBy = (arr, fn) => arr.map(typeof fn === 'function' ? fn : val => val[fn]).reduce((acc, val) => acc + val, 0); -``` +```
    -Examples - -```js + Examples + + ```js sumBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }], o => o.n); // 20 sumBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }], 'n'); // 20 ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### sumPower @@ -6104,21 +5901,20 @@ const sumPower = (end, power = 2, start = 1) => .fill(0) .map((x, i) => (i + start) ** power) .reduce((a, b) => a + b, 0); -``` +```
    -Examples - -```js + Examples + + ```js sumPower(10); // 385 sumPower(10, 3); //3025 sumPower(10, 3, 5); //2925 ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### toSafeInteger @@ -6130,24 +5926,23 @@ Use `Math.round()` to convert to an integer. ```js const toSafeInteger = num => Math.round(Math.max(Math.min(num, Number.MAX_SAFE_INTEGER), Number.MIN_SAFE_INTEGER)); -``` +```
    -Examples - -```js + Examples + + ```js toSafeInteger('3.2'); // 3 toSafeInteger(Infinity); // 9007199254740991 ```
    + +[⬆ Back to top](#table-of-contents) -
    [⬆ Back to top](#table-of-contents) - ---- - ## 📦 Node - -### atob + +--- +## 📦 Node### atob Decodes a string of data which has been encoded using base-64 encoding. @@ -6155,19 +5950,18 @@ Create a `Buffer` for the given string with base-64 encoding and use `Buffer.toS ```js const atob = str => new Buffer(str, 'base64').toString('binary'); -``` +```
    -Examples - -```js + Examples + + ```js atob('Zm9vYmFy'); // 'foobar' ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### btoa @@ -6177,19 +5971,18 @@ Create a `Buffer` for the given string with binary encoding and use `Buffer.toSt ```js const btoa = str => new Buffer(str, 'binary').toString('base64'); -``` +```
    -Examples - -```js + Examples + + ```js btoa('foobar'); // 'Zm9vYmFy' ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### colorize @@ -6217,21 +6010,20 @@ const colorize = (...args) => ({ bgCyan: `\x1b[46m${args.join(' ')}\x1b[0m`, bgWhite: `\x1b[47m${args.join(' ')}\x1b[0m` }); -``` +```
    -Examples - -```js + Examples + + ```js console.log(colorize('foo').red); // 'foo' (red letters) console.log(colorize('foo', 'bar').bgBlue); // 'foo bar' (blue background) console.log(colorize(colorize('foo').yellow, colorize('foo').green).bgWhite); // 'foo bar' (first word in yellow letters, second word in green letters, white background for both) ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### hasFlags @@ -6243,12 +6035,12 @@ Use a regular expression to test if the specified flags are prefixed with `-` or ```js const hasFlags = (...flags) => flags.every(flag => process.argv.includes(/^-{1,2}/.test(flag) ? flag : '--' + flag)); -``` +```
    -Examples - -```js + Examples + + ```js // node myScript.js -s --test --cool=true hasFlags('-s'); // true hasFlags('--test', 'cool=true', '-s'); // true @@ -6256,9 +6048,8 @@ hasFlags('special'); // false ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### hashNode @@ -6281,19 +6072,18 @@ const hashNode = val => 0 ) ); -``` +```
    -Examples - -```js + Examples + + ```js hashNode(JSON.stringify({ a: 'a', b: [1, 2, 3, 4], foo: { c: 'bar' } })).then(console.log); // '04aa106279f5977f59f9067fa9712afc4aedc6f5862a8defc34552d8c7206393' ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### isTravisCI @@ -6303,19 +6093,18 @@ Checks if the current environment has the `TRAVIS` and `CI` environment variable ```js const isTravisCI = () => 'TRAVIS' in process.env && 'CI' in process.env; -``` +```
    -Examples - -```js + Examples + + ```js isTravisCI(); // true (if code is running on Travis CI) ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### JSONToFile @@ -6327,19 +6116,18 @@ Use `fs.writeFile()`, template literals and `JSON.stringify()` to write a `json` const fs = require('fs'); const JSONToFile = (obj, filename) => fs.writeFile(`${filename}.json`, JSON.stringify(obj, null, 2)); -``` +```
    -Examples - -```js + Examples + + ```js JSONToFile({ test: 'is passed' }, 'testJsonFile'); // writes the object to 'testJsonFile.json' ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### readFileLines @@ -6356,12 +6144,12 @@ const readFileLines = filename => .readFileSync(filename) .toString('UTF8') .split('\n'); -``` +```
    -Examples - -```js + Examples + + ```js /* contents of test.txt : line1 @@ -6375,9 +6163,8 @@ console.log(arr); // ['line1', 'line2', 'line3']
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### untildify @@ -6387,19 +6174,18 @@ Use `String.replace()` with a regular expression and `OS.homedir()` to replace t ```js const untildify = str => str.replace(/^~($|\/|\\)/, `${require('os').homedir()}$1`); -``` +```
    -Examples - -```js + Examples + + ```js untildify('~/node'); // '/Users/aUser/node' ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### UUIDGeneratorNode @@ -6413,23 +6199,22 @@ const UUIDGeneratorNode = () => ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c => (c ^ (crypto.randomBytes(1)[0] & (15 >> (c / 4)))).toString(16) ); -``` +```
    -Examples - -```js + Examples + + ```js UUIDGeneratorNode(); // '79c7c136-60ee-40a2-beb2-856f1feabefc' ```
    + +[⬆ Back to top](#table-of-contents) -
    [⬆ Back to top](#table-of-contents) - ---- - ## 🗃️ Object - -### bindAll + +--- +## 🗃️ Object### bindAll Binds methods of an object to the object itself, overwriting the existing method. @@ -6445,12 +6230,12 @@ const bindAll = (obj, ...fns) => }) ) ); -``` +```
    -Examples - -```js + Examples + + ```js var view = { label: 'docs', click: function() { @@ -6462,9 +6247,8 @@ jQuery(element).on('click', view.click); // Logs 'clicked docs' when clicked. ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### deepClone @@ -6482,20 +6266,19 @@ const deepClone = obj => { ); return Array.isArray(obj) ? (clone.length = obj.length) && Array.from(clone) : clone; }; -``` +```
    -Examples - -```js + Examples + + ```js const a = { foo: 'bar', obj: { a: 1, b: 2 } }; const b = deepClone(a); // a !== b, a.obj !== b.obj ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### deepFreeze @@ -6509,12 +6292,12 @@ const deepFreeze = obj => prop => !obj[prop] instanceof Object || Object.isFrozen(obj[prop]) ? null : deepFreeze(obj[prop]) ) || Object.freeze(obj); -``` +```
    -Examples - -```js + Examples + + ```js 'use strict'; const o = deepFreeze([1, [2, 3]]); @@ -6524,9 +6307,8 @@ o[1][0] = 4; // not allowed as well ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### defaults @@ -6536,19 +6318,18 @@ Use `Object.assign()` to create a new empty object and copy the original one to ```js const defaults = (obj, ...defs) => Object.assign({}, obj, ...defs.reverse(), obj); -``` +```
    -Examples - -```js + Examples + + ```js defaults({ a: 1 }, { b: 2 }, { b: 6 }, { a: 3 }); // { a: 1, b: 2 } ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### dig @@ -6565,12 +6346,12 @@ const dig = (obj, target) => if (acc !== undefined) return acc; if (typeof val === 'object') return dig(val, target); }, undefined); -``` +```
    -Examples - -```js + Examples + + ```js const data = { level1: { level2: { @@ -6583,9 +6364,8 @@ dig(data, 'level4'); // undefined ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### equals ![advanced](/advanced.svg) @@ -6606,19 +6386,18 @@ const equals = (a, b) => { if (keys.length !== Object.keys(b).length) return false; return keys.every(k => equals(a[k], b[k])); }; -``` +```
    -Examples - -```js + Examples + + ```js equals({ a: [2, { e: 3 }], b: [4], c: 'foo' }, { a: [2, { e: 3 }], b: [4], c: 'foo' }); // true ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### findKey @@ -6628,12 +6407,12 @@ Use `Object.keys(obj)` to get all the properties of the object, `Array.find()` t ```js const findKey = (obj, fn) => Object.keys(obj).find(key => fn(obj[key], key, obj)); -``` +```
    -Examples - -```js + Examples + + ```js findKey( { barney: { age: 36, active: true }, @@ -6645,9 +6424,8 @@ findKey( ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### findLastKey @@ -6660,12 +6438,12 @@ const findLastKey = (obj, fn) => Object.keys(obj) .reverse() .find(key => fn(obj[key], key, obj)); -``` +```
    -Examples - -```js + Examples + + ```js findLastKey( { barney: { age: 36, active: true }, @@ -6677,9 +6455,8 @@ findLastKey( ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### flattenObject @@ -6699,19 +6476,18 @@ const flattenObject = (obj, prefix = '') => else acc[pre + k] = obj[k]; return acc; }, {}); -``` +```
    -Examples - -```js + Examples + + ```js flattenObject({ a: { b: { c: 1 } }, d: 1 }); // { 'a.b.c': 1, d: 1 } ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### forOwn @@ -6721,19 +6497,18 @@ Use `Object.keys(obj)` to get all the properties of the object, `Array.forEach() ```js const forOwn = (obj, fn) => Object.keys(obj).forEach(key => fn(obj[key], key, obj)); -``` +```
    -Examples - -```js + Examples + + ```js forOwn({ foo: 'bar', a: 1 }, v => console.log(v)); // 'bar', 1 ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### forOwnRight @@ -6746,19 +6521,18 @@ const forOwnRight = (obj, fn) => Object.keys(obj) .reverse() .forEach(key => fn(obj[key], key, obj)); -``` +```
    -Examples - -```js + Examples + + ```js forOwnRight({ foo: 'bar', a: 1 }, v => console.log(v)); // 1, 'bar' ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### functions @@ -6775,12 +6549,12 @@ const functions = (obj, inherited = false) => ? [...Object.keys(obj), ...Object.keys(Object.getPrototypeOf(obj))] : Object.keys(obj) ).filter(key => typeof obj[key] === 'function'); -``` +```
    -Examples - -```js + Examples + + ```js function Foo() { this.a = () => 1; this.b = () => 2; @@ -6791,9 +6565,8 @@ functions(new Foo(), true); // ['a', 'b', 'c'] ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### get @@ -6810,20 +6583,19 @@ const get = (from, ...selectors) => .filter(t => t !== '') .reduce((prev, cur) => prev && prev[cur], from) ); -``` +```
    -Examples - -```js + Examples + + ```js const obj = { selector: { to: { val: 'val to select' } }, target: [1, 2, { a: 'test' }] }; get(obj, 'selector.to.val', 'target[0]', 'target[2].a'); // ['val to select', 1, 'test'] ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### invertKeyValues @@ -6840,20 +6612,19 @@ const invertKeyValues = (obj, fn) => acc[val].push(key); return acc; }, {}); -``` +```
    -Examples - -```js + Examples + + ```js invertKeyValues({ a: 1, b: 2, c: 1 }); // { 1: [ 'a', 'c' ], 2: [ 'b' ] } invertKeyValues({ a: 1, b: 2, c: 1 }, value => 'group' + value); // { group1: [ 'a', 'c' ], group2: [ 'b' ] } ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### lowercaseKeys @@ -6868,20 +6639,19 @@ const lowercaseKeys = obj => acc[key.toLowerCase()] = obj[key]; return acc; }, {}); -``` +```
    -Examples - -```js + Examples + + ```js const myObj = { Name: 'Adam', sUrnAME: 'Smith' }; const myObjLower = lowercaseKeys(myObj); // {name: 'Adam', surname: 'Smith'}; ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### mapKeys @@ -6896,19 +6666,18 @@ const mapKeys = (obj, fn) => acc[fn(obj[k], k, obj)] = obj[k]; return acc; }, {}); -``` +```
    -Examples - -```js + Examples + + ```js mapKeys({ a: 1, b: 2 }, (val, key) => key + val); // { a1: 1, b2: 2 } ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### mapValues @@ -6923,12 +6692,12 @@ const mapValues = (obj, fn) => acc[k] = fn(obj[k], k, obj); return acc; }, {}); -``` +```
    -Examples - -```js + Examples + + ```js const users = { fred: { user: 'fred', age: 40 }, pebbles: { user: 'pebbles', age: 1 } @@ -6937,9 +6706,8 @@ mapValues(users, u => u.age); // { fred: 40, pebbles: 1 } ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### matches @@ -6950,20 +6718,19 @@ Use `Object.keys(source)` to get all the keys of the second object, then `Array. ```js const matches = (obj, source) => Object.keys(source).every(key => obj.hasOwnProperty(key) && obj[key] === source[key]); -``` +```
    -Examples - -```js + Examples + + ```js matches({ age: 25, hair: 'long', beard: true }, { hair: 'long', beard: true }); // true matches({ hair: 'long', beard: true }, { age: 25, hair: 'long', beard: true }); // false ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### matchesWith @@ -6980,12 +6747,12 @@ const matchesWith = (obj, source, fn) => ? fn(obj[key], source[key], key, obj, source) : obj[key] == source[key] ); -``` +```
    -Examples - -```js + Examples + + ```js const isGreeting = val => /^h(?:i|ello)$/.test(val); matchesWith( { greeting: 'hello' }, @@ -6995,9 +6762,8 @@ matchesWith( ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### merge @@ -7016,12 +6782,12 @@ const merge = (...objs) => }, {}), {} ); -``` +```
    -Examples - -```js + Examples + + ```js const object = { a: [{ x: 2 }, { y: 4 }], b: 1 @@ -7035,9 +6801,8 @@ merge(object, other); // { a: [ { x: 2 }, { y: 4 }, { z: 3 } ], b: [ 1, 2, 3 ], ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### nest @@ -7054,12 +6819,12 @@ const nest = (items, id = null, link = 'parent_id') => items .filter(item => item[link] === id) .map(item => ({ ...item, children: nest(items, item.id) })); -``` +```
    -Examples - -```js + Examples + + ```js // One top level comment const comments = [ { id: 1, parent_id: null }, @@ -7073,9 +6838,8 @@ const nestedComments = nest(comments); // [{ id: 1, parent_id: null, children: [
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### objectFromPairs @@ -7085,19 +6849,18 @@ Use `Array.reduce()` to create and combine key-value pairs. ```js const objectFromPairs = arr => arr.reduce((a, [key, val]) => ((a[key] = val), a), {}); -``` +```
    -Examples - -```js + Examples + + ```js objectFromPairs([['a', 1], ['b', 2]]); // {a: 1, b: 2} ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### objectToPairs @@ -7107,19 +6870,18 @@ Use `Object.keys()` and `Array.map()` to iterate over the object's keys and prod ```js const objectToPairs = obj => Object.keys(obj).map(k => [k, obj[k]]); -``` +```
    -Examples - -```js + Examples + + ```js objectToPairs({ a: 1, b: 2 }); // [['a',1],['b',2]] ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### omit @@ -7133,19 +6895,18 @@ const omit = (obj, arr) => Object.keys(obj) .filter(k => !arr.includes(k)) .reduce((acc, key) => ((acc[key] = obj[key]), acc), {}); -``` +```
    -Examples - -```js + Examples + + ```js omit({ a: 1, b: '2', c: 3 }, ['b']); // { 'a': 1, 'c': 3 } ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### omitBy @@ -7159,19 +6920,18 @@ const omitBy = (obj, fn) => Object.keys(obj) .filter(k => !fn(obj[k], k)) .reduce((acc, key) => ((acc[key] = obj[key]), acc), {}); -``` +```
    -Examples - -```js + Examples + + ```js omitBy({ a: 1, b: '2', c: 3 }, x => typeof x === 'number'); // { b: '2' } ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### orderBy @@ -7191,21 +6951,20 @@ const orderBy = (arr, props, orders) => return acc; }, 0) ); -``` +```
    -Examples - -```js + Examples + + ```js const users = [{ name: 'fred', age: 48 }, { name: 'barney', age: 36 }, { name: 'fred', age: 40 }]; orderBy(users, ['name', 'age'], ['asc', 'desc']); // [{name: 'barney', age: 36}, {name: 'fred', age: 48}, {name: 'fred', age: 40}] orderBy(users, ['name', 'age']); // [{name: 'barney', age: 36}, {name: 'fred', age: 40}, {name: 'fred', age: 48}] ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### pick @@ -7216,19 +6975,18 @@ Use `Array.reduce()` to convert the filtered/picked keys back to an object with ```js const pick = (obj, arr) => arr.reduce((acc, curr) => (curr in obj && (acc[curr] = obj[curr]), acc), {}); -``` +```
    -Examples - -```js + Examples + + ```js pick({ a: 1, b: '2', c: 3 }, ['a', 'c']); // { 'a': 1, 'c': 3 } ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### pickBy @@ -7242,19 +7000,18 @@ const pickBy = (obj, fn) => Object.keys(obj) .filter(k => fn(obj[k], k)) .reduce((acc, key) => ((acc[key] = obj[key]), acc), {}); -``` +```
    -Examples - -```js + Examples + + ```js pickBy({ a: 1, b: '2', c: 3 }, x => typeof x === 'number'); // { 'a': 1, 'c': 3 } ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### renameKeys @@ -7271,20 +7028,19 @@ const renameKeys = (keysMap, obj) => }), {} ); -``` +```
    -Examples - -```js + Examples + + ```js const obj = { name: 'Bobo', job: 'Front-End Master', shoeSize: 100 }; renameKeys({ name: 'firstName', job: 'passion' }, obj); // { firstName: 'Bobo', passion: 'Front-End Master', shoeSize: 100 } ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### shallowClone @@ -7294,20 +7050,19 @@ Use `Object.assign()` and an empty object (`{}`) to create a shallow clone of th ```js const shallowClone = obj => Object.assign({}, obj); -``` +```
    -Examples - -```js + Examples + + ```js const a = { x: true, y: 1 }; const b = shallowClone(a); // a !== b ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### size @@ -7329,21 +7084,20 @@ const size = val => : typeof val === 'string' ? new Blob([val]).size : 0; -``` +```
    -Examples - -```js + Examples + + ```js size([1, 2, 3, 4, 5]); // 5 size('size'); // 4 size({ one: 1, two: 2, three: 3 }); // 3 ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### transform @@ -7353,12 +7107,12 @@ Use `Object.keys(obj)` to iterate over each key in the object, `Array.reduce()` ```js const transform = (obj, fn, acc) => Object.keys(obj).reduce((a, k) => fn(a, obj[k], k, obj), acc); -``` +```
    -Examples - -```js + Examples + + ```js transform( { a: 1, b: 2, c: 1 }, (r, v, k) => { @@ -7370,9 +7124,8 @@ transform( ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### truthCheckCollection @@ -7382,19 +7135,18 @@ Use `Array.every()` to check if each passed object has the specified property an ```js const truthCheckCollection = (collection, pre) => collection.every(obj => obj[pre]); -``` +```
    -Examples - -```js + Examples + + ```js truthCheckCollection([{ user: 'Tinky-Winky', sex: 'male' }, { user: 'Dipsy', sex: 'male' }], 'sex'); // true ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### unflattenObject ![advanced](/advanced.svg) @@ -7421,23 +7173,22 @@ const unflattenObject = obj => } else acc[k] = obj[k]; return acc; }, {}); -``` +```
    -Examples - -```js + Examples + + ```js unflattenObject({ 'a.b.c': 1, d: 1 }); // { a: { b: { c: 1 } }, d: 1 } ```
    + +[⬆ Back to top](#table-of-contents) -
    [⬆ Back to top](#table-of-contents) - ---- - ## 📜 String - -### byteSize + +--- +## 📜 String### byteSize Returns the length of a string in bytes. @@ -7445,20 +7196,19 @@ Convert a given string to a [`Blob` Object](https://developer.mozilla.org/en-US/ ```js const byteSize = str => new Blob([str]).size; -``` +```
    -Examples - -```js + Examples + + ```js byteSize('😀'); // 4 byteSize('Hello World'); // 11 ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### capitalize @@ -7470,20 +7220,19 @@ Omit the `lowerRest` parameter to keep the rest of the string intact, or set it ```js const capitalize = ([first, ...rest], lowerRest = false) => first.toUpperCase() + (lowerRest ? rest.join('').toLowerCase() : rest.join('')); -``` +```
    -Examples - -```js + Examples + + ```js capitalize('fooBar'); // 'FooBar' capitalize('fooBar', true); // 'Foobar' ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### capitalizeEveryWord @@ -7493,19 +7242,18 @@ Use `String.replace()` to match the first character of each word and `String.toU ```js const capitalizeEveryWord = str => str.replace(/\b[a-z]/g, char => char.toUpperCase()); -``` +```
    -Examples - -```js + Examples + + ```js capitalizeEveryWord('hello world!'); // 'Hello World!' ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### CSVToArray @@ -7522,21 +7270,20 @@ const CSVToArray = (data, delimiter = ',', omitFirstRow = false) => .slice(omitFirstRow ? data.indexOf('\n') + 1 : 0) .split('\n') .map(v => v.split(delimiter)); -``` +```
    -Examples - -```js + Examples + + ```js CSVToArray('a,b\nc,d'); // [['a','b'],['c','d']]; CSVToArray('a;b\nc;d', ';'); // [['a','b'],['c','d']]; CSVToArray('col1,col2\na,b\nc,d', ',', true); // [['a','b'],['c','d']]; ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### CSVToJSON ![advanced](/advanced.svg) @@ -7559,20 +7306,19 @@ const CSVToJSON = (data, delimiter = ',') => { return titles.reduce((obj, title, index) => ((obj[title] = values[index]), obj), {}); }); }; -``` +```
    -Examples - -```js + Examples + + ```js CSVToJSON('col1,col2\na,b\nc,d'); // [{'col1': 'a', 'col2': 'b'}, {'col1': 'c', 'col2': 'd'}]; CSVToJSON('col1;col2\na;b\nc;d', ';'); // [{'col1': 'a', 'col2': 'b'}, {'col1': 'c', 'col2': 'd'}]; ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### decapitalize @@ -7584,20 +7330,19 @@ Omit the `upperRest` parameter to keep the rest of the string intact, or set it ```js const decapitalize = ([first, ...rest], upperRest = false) => first.toLowerCase() + (upperRest ? rest.join('').toUpperCase() : rest.join('')); -``` +```
    -Examples - -```js + Examples + + ```js decapitalize('FooBar'); // 'fooBar' decapitalize('FooBar', true); // 'fOOBAR' ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### escapeHTML @@ -7618,19 +7363,18 @@ const escapeHTML = str => '"': '"' }[tag] || tag) ); -``` +```
    -Examples - -```js + Examples + + ```js escapeHTML('Me & you'); // '<a href="#">Me & you</a>' ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### escapeRegExp @@ -7640,19 +7384,18 @@ Use `String.replace()` to escape special characters. ```js const escapeRegExp = str => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); -``` +```
    -Examples - -```js + Examples + + ```js escapeRegExp('(test)'); // \\(test\\) ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### fromCamelCase @@ -7667,21 +7410,20 @@ const fromCamelCase = (str, separator = '_') => .replace(/([a-z\d])([A-Z])/g, '$1' + separator + '$2') .replace(/([A-Z]+)([A-Z][a-z\d]+)/g, '$1' + separator + '$2') .toLowerCase(); -``` +```
    -Examples - -```js + Examples + + ```js fromCamelCase('someDatabaseFieldName', ' '); // 'some database field name' fromCamelCase('someLabelThatNeedsToBeCamelized', '-'); // 'some-label-that-needs-to-be-camelized' fromCamelCase('someJavascriptProperty', '_'); // 'some_javascript_property' ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### isAbsoluteURL @@ -7691,21 +7433,20 @@ Use a regular expression to test if the string is an absolute URL. ```js const isAbsoluteURL = str => /^[a-z][a-z0-9+.-]*:/.test(str); -``` +```
    -Examples - -```js + Examples + + ```js isAbsoluteURL('https://google.com'); // true isAbsoluteURL('ftp://www.myserver.net'); // true isAbsoluteURL('/foo/bar'); // false ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### isAnagram @@ -7724,19 +7465,18 @@ const isAnagram = (str1, str2) => { .join(''); return normalize(str1) === normalize(str2); }; -``` +```
    -Examples - -```js + Examples + + ```js isAnagram('iceman', 'cinema'); // true ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### isLowerCase @@ -7746,21 +7486,20 @@ Convert the given string to lower case, using `String.toLowerCase()` and compare ```js const isLowerCase = str => str === str.toLowerCase(); -``` +```
    -Examples - -```js + Examples + + ```js isLowerCase('abc'); // true isLowerCase('a3@$'); // true isLowerCase('Ab4'); // false ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### isUpperCase @@ -7771,21 +7510,20 @@ Convert the given string to upper case, using `String.toUpperCase()` and compare ```js const isUpperCase = str => str === str.toUpperCase(); -``` +```
    -Examples - -```js + Examples + + ```js isUpperCase('ABC'); // true isLowerCase('A3@$'); // true isLowerCase('aB4'); // false ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### mapString @@ -7801,19 +7539,18 @@ const mapString = (str, fn) => .split('') .map((c, i) => fn(c, i, str)) .join(''); -``` +```
    -Examples - -```js + Examples + + ```js mapString('lorem ipsum', c => c.toUpperCase()); // 'LOREM IPSUM' ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### mask @@ -7827,21 +7564,20 @@ Omit the third argument, `mask`, to use a default character of `'*'` for the mas ```js const mask = (cc, num = 4, mask = '*') => ('' + cc).slice(0, -num).replace(/./g, mask) + ('' + cc).slice(-num); -``` +```
    -Examples - -```js + Examples + + ```js mask(1234567890); // '******7890' mask(1234567890, 3); // '*******890' mask(1234567890, -4, '$'); // '$$$$567890' ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### pad @@ -7853,21 +7589,20 @@ Omit the third argument, `char`, to use the whitespace character as the default ```js const pad = (str, length, char = ' ') => str.padStart((str.length + length) / 2, char).padEnd(length, char); -``` +```
    -Examples - -```js + Examples + + ```js pad('cat', 8); // ' cat ' pad(String(42), 6, '0'); // '004200' pad('foobar', 3); // 'foobar' ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### palindrome @@ -7881,19 +7616,18 @@ const palindrome = str => { const s = str.toLowerCase().replace(/[\W_]/g, ''); return s === [...s].reverse().join(''); }; -``` +```
    -Examples - -```js + Examples + + ```js palindrome('taco cat'); // true ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### pluralize @@ -7908,12 +7642,12 @@ const pluralize = (val, word, plural = word + 's') => { if (typeof val === 'object') return (num, word) => _pluralize(num, word, val[word]); return _pluralize(val, word, plural); }; -``` +```
    -Examples - -```js + Examples + + ```js pluralize(0, 'apple'); // 'apples' pluralize(1, 'apple'); // 'apple' pluralize(2, 'apple'); // 'apples' @@ -7928,9 +7662,8 @@ autoPluralize(2, 'person'); // 'people' ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### removeNonASCII @@ -7940,19 +7673,18 @@ Use a regular expression to remove non-printable ASCII characters. ```js const removeNonASCII = str => str.replace(/[^\x20-\x7E]/g, ''); -``` +```
    -Examples - -```js + Examples + + ```js removeNonASCII('äÄçÇéÉêlorem-ipsumöÖÐþúÚ'); // 'lorem-ipsum' ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### reverseString @@ -7963,19 +7695,18 @@ Combine characters to get a string using `String.join('')`. ```js const reverseString = str => [...str].reverse().join(''); -``` +```
    -Examples - -```js + Examples + + ```js reverseString('foobar'); // 'raboof' ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### sortCharactersInString @@ -7985,19 +7716,18 @@ Use the spread operator (`...`), `Array.sort()` and `String.localeCompare()` to ```js const sortCharactersInString = str => [...str].sort((a, b) => a.localeCompare(b)).join(''); -``` +```
    -Examples - -```js + Examples + + ```js sortCharactersInString('cabbage'); // 'aabbceg' ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### splitLines @@ -8007,19 +7737,18 @@ Use `String.split()` and a regular expression to match line breaks and create an ```js const splitLines = str => str.split(/\r?\n/); -``` +```
    -Examples - -```js + Examples + + ```js splitLines('This\nis a\nmultiline\nstring.\n'); // ['This', 'is a', 'multiline', 'string.' , ''] ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### stringPermutations ![advanced](/advanced.svg) @@ -8043,19 +7772,18 @@ const stringPermutations = str => { [] ); }; -``` +```
    -Examples - -```js + Examples + + ```js stringPermutations('abc'); // ['abc','acb','bac','bca','cab','cba'] ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### stripHTMLTags @@ -8065,19 +7793,18 @@ Use a regular expression to remove HTML/XML tags from a string. ```js const stripHTMLTags = str => str.replace(/<[^>]*>/g, ''); -``` +```
    -Examples - -```js + Examples + + ```js stripHTMLTags('

    lorem ipsum

    '); // 'lorem ipsum' ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### toCamelCase @@ -8095,12 +7822,12 @@ const toCamelCase = str => { .join(''); return s.slice(0, 1).toLowerCase() + s.slice(1); }; -``` +```
    -Examples - -```js + Examples + + ```js toCamelCase('some_database_field_name'); // 'someDatabaseFieldName' toCamelCase('Some label that needs to be camelized'); // 'someLabelThatNeedsToBeCamelized' toCamelCase('some-javascript-property'); // 'someJavascriptProperty' @@ -8108,9 +7835,8 @@ toCamelCase('some-mixed_string with spaces_underscores-and-hyphens'); // 'someMi ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### toKebabCase @@ -8125,12 +7851,12 @@ const toKebabCase = str => .match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g) .map(x => x.toLowerCase()) .join('-'); -``` +```
    -Examples - -```js + Examples + + ```js toKebabCase('camelCase'); // 'camel-case' toKebabCase('some text'); // 'some-text' toKebabCase('some-mixed_string With spaces_underscores-and-hyphens'); // 'some-mixed-string-with-spaces-underscores-and-hyphens' @@ -8139,9 +7865,8 @@ toKebabCase('IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSo ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### toSnakeCase @@ -8156,12 +7881,12 @@ const toSnakeCase = str => .match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g) .map(x => x.toLowerCase()) .join('_'); -``` +```
    -Examples - -```js + Examples + + ```js toSnakeCase('camelCase'); // 'camel_case' toSnakeCase('some text'); // 'some_text' toSnakeCase('some-mixed_string With spaces_underscores-and-hyphens'); // 'some_mixed_string_with_spaces_underscores_and_hyphens' @@ -8170,9 +7895,8 @@ toSnakeCase('IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSo ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### truncateString @@ -8184,19 +7908,18 @@ Return the string truncated to the desired length, with `'...'` appended to the ```js const truncateString = (str, num) => str.length > num ? str.slice(0, num > 3 ? num - 3 : num) + '...' : str; -``` +```
    -Examples - -```js + Examples + + ```js truncateString('boomerang', 7); // 'boom...' ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### unescapeHTML @@ -8217,19 +7940,18 @@ const unescapeHTML = str => '"': '"' }[tag] || tag) ); -``` +```
    -Examples - -```js + Examples + + ```js unescapeHTML('<a href="#">Me & you</a>'); // 'Me & you' ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### URLJoin ![advanced](/advanced.svg) @@ -8247,19 +7969,18 @@ const URLJoin = (...args) => .replace(/\/(\?|&|#[^!])/g, '$1') .replace(/\?/g, '&') .replace('&', '?'); -``` +```
    -Examples - -```js + Examples + + ```js URLJoin('http://www.google.com', 'a', '/b/cd', '?foo=123', '?bar=foo'); // 'http://www.google.com/a/b/cd?foo=123&bar=foo' ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### words @@ -8270,24 +7991,23 @@ Omit the second argument to use the default regexp. ```js const words = (str, pattern = /[^a-zA-Z-]+/) => str.split(pattern).filter(Boolean); -``` +```
    -Examples - -```js + Examples + + ```js words('I love javaScript!!'); // ["I", "love", "javaScript"] words('python, javaScript & coffee'); // ["python", "javaScript", "coffee"] ```
    + +[⬆ Back to top](#table-of-contents) -
    [⬆ Back to top](#table-of-contents) - ---- - ## 📃 Type - -### getType + +--- +## 📃 Type### getType Returns the native type of a value. @@ -8296,19 +8016,18 @@ Returns lowercased constructor name of value, `"undefined"` or `"null"` if value ```js const getType = v => v === undefined ? 'undefined' : v === null ? 'null' : v.constructor.name.toLowerCase(); -``` +```
    -Examples - -```js + Examples + + ```js getType(new Set([1, 2, 3])); // 'set' ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### is @@ -8318,12 +8037,12 @@ Ensure the value is not `undefined` or `null` using `Array.includes()`, and comp ```js const is = (type, val) => ![, null].includes(val) && val.constructor === type; -``` +```
    -Examples - -```js + Examples + + ```js is(Array, [1]); // true is(ArrayBuffer, new ArrayBuffer()); // true is(Map, new Map()); // true @@ -8340,9 +8059,8 @@ is(Boolean, new Boolean(true)); // true ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### isArrayLike @@ -8352,21 +8070,20 @@ Check if the provided argument is not `null` and that its `Symbol.iterator` prop ```js const isArrayLike = obj => obj != null && typeof obj[Symbol.iterator] === 'function'; -``` +```
    -Examples - -```js + Examples + + ```js isArrayLike(document.querySelectorAll('.className')); // true isArrayLike('abc'); // true isArrayLike(null); // false ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### isBoolean @@ -8376,20 +8093,19 @@ Use `typeof` to check if a value is classified as a boolean primitive. ```js const isBoolean = val => typeof val === 'boolean'; -``` +```
    -Examples - -```js + Examples + + ```js isBoolean(null); // false isBoolean(false); // true ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### isEmpty @@ -8399,12 +8115,12 @@ Check if the provided value is `null` or if its `length` is equal to `0`. ```js const isEmpty = val => val == null || !(Object.keys(val) || val).length; -``` +```
    -Examples - -```js + Examples + + ```js isEmpty(new Map()); // true isEmpty(new Set()); // true isEmpty([]); // true @@ -8418,9 +8134,8 @@ isEmpty(true); // true - type is not considered a collection ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### isFunction @@ -8430,20 +8145,19 @@ Use `typeof` to check if a value is classified as a function primitive. ```js const isFunction = val => typeof val === 'function'; -``` +```
    -Examples - -```js + Examples + + ```js isFunction('x'); // false isFunction(x => x); // true ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### isNil @@ -8453,20 +8167,19 @@ Use the strict equality operator to check if the value and of `val` are equal to ```js const isNil = val => val === undefined || val === null; -``` +```
    -Examples - -```js + Examples + + ```js isNil(null); // true isNil(undefined); // true ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### isNull @@ -8476,19 +8189,18 @@ Use the strict equality operator to check if the value and of `val` are equal to ```js const isNull = val => val === null; -``` +```
    -Examples - -```js + Examples + + ```js isNull(null); // true ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### isNumber @@ -8498,20 +8210,19 @@ Use `typeof` to check if a value is classified as a number primitive. ```js const isNumber = val => typeof val === 'number'; -``` +```
    -Examples - -```js + Examples + + ```js isNumber('1'); // false isNumber(1); // true ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### isObject @@ -8522,12 +8233,12 @@ If the value is `null` or `undefined`, create and return an empty object. Οther ```js const isObject = obj => obj === Object(obj); -``` +```
    -Examples - -```js + Examples + + ```js isObject([1, 2, 3, 4]); // true isObject([]); // true isObject(['Hello!']); // true @@ -8537,9 +8248,8 @@ isObject(true); // false ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### isObjectLike @@ -8549,12 +8259,12 @@ Check if the provided value is not `null` and its `typeof` is equal to `'object' ```js const isObjectLike = val => val !== null && typeof val === 'object'; -``` +```
    -Examples - -```js + Examples + + ```js isObjectLike({}); // true isObjectLike([1, 2, 3]); // true isObjectLike(x => x); // false @@ -8562,9 +8272,8 @@ isObjectLike(null); // false ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### isPlainObject @@ -8574,20 +8283,19 @@ Check if the provided value is truthy, use `typeof` to check if it is an object ```js const isPlainObject = val => !!val && typeof val === 'object' && val.constructor === Object; -``` +```
    -Examples - -```js + Examples + + ```js isPlainObject({ a: 1 }); // true isPlainObject(new Map()); // false ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### isPrimitive @@ -8599,12 +8307,12 @@ Since `typeof null` evaluates to `'object'`, it needs to be directly compared. ```js const isPrimitive = val => !['object', 'function'].includes(typeof val) || val === null; -``` +```
    -Examples - -```js + Examples + + ```js isPrimitive(null); // true isPrimitive(50); // true isPrimitive('Hello!'); // true @@ -8614,9 +8322,8 @@ isPrimitive([]); // false ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### isPromiseLike @@ -8629,12 +8336,12 @@ const isPromiseLike = obj => obj !== null && (typeof obj === 'object' || typeof obj === 'function') && typeof obj.then === 'function'; -``` +```
    -Examples - -```js + Examples + + ```js isPromiseLike({ then: function() { return ''; @@ -8645,9 +8352,8 @@ isPromiseLike({}); // false ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### isString @@ -8657,19 +8363,18 @@ Use `typeof` to check if a value is classified as a string primitive. ```js const isString = val => typeof val === 'string'; -``` +```
    -Examples - -```js + Examples + + ```js isString('10'); // true ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### isSymbol @@ -8679,19 +8384,18 @@ Use `typeof` to check if a value is classified as a symbol primitive. ```js const isSymbol = val => typeof val === 'symbol'; -``` +```
    -Examples - -```js + Examples + + ```js isSymbol(Symbol('x')); // true ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### isUndefined @@ -8701,19 +8405,18 @@ Use the strict equality operator to check if the value and of `val` are equal to ```js const isUndefined = val => val === undefined; -``` +```
    -Examples - -```js + Examples + + ```js isUndefined(undefined); // true ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### isValidJSON @@ -8730,25 +8433,24 @@ const isValidJSON = obj => { return false; } }; -``` +```
    -Examples - -```js + Examples + + ```js isValidJSON('{"name":"Adam","age":20}'); // true isValidJSON('{"name":"Adam",age:"20"}'); // false isValidJSON(null); // true ```
    + +[⬆ Back to top](#table-of-contents) -
    [⬆ Back to top](#table-of-contents) - ---- - ## 🔧 Utility - -### castArray + +--- +## 🔧 Utility### castArray Casts the provided value as an array if it's not one. @@ -8756,20 +8458,19 @@ Use `Array.isArray()` to determine if `val` is an array and return it as-is or e ```js const castArray = val => (Array.isArray(val) ? val : [val]); -``` +```
    -Examples - -```js + Examples + + ```js castArray('foo'); // ['foo'] castArray([1]); // [1] ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### cloneRegExp @@ -8779,20 +8480,19 @@ Use `new RegExp()`, `RegExp.source` and `RegExp.flags` to clone the given regula ```js const cloneRegExp = regExp => new RegExp(regExp.source, regExp.flags); -``` +```
    -Examples - -```js + Examples + + ```js const regExp = /lorem ipsum/gi; const regExp2 = cloneRegExp(regExp); // /lorem ipsum/gi ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### coalesce @@ -8802,19 +8502,18 @@ Use `Array.find()` to return the first non `null`/`undefined` argument. ```js const coalesce = (...args) => args.find(_ => ![undefined, null].includes(_)); -``` +```
    -Examples - -```js + Examples + + ```js coalesce(null, undefined, '', NaN, 'Waldo'); // "" ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### coalesceFactory @@ -8824,20 +8523,19 @@ Use `Array.find()` to return the first argument that returns `true` from the pro ```js const coalesceFactory = valid => (...args) => args.find(valid); -``` +```
    -Examples - -```js + Examples + + ```js const customCoalesce = coalesceFactory(_ => ![null, undefined, '', NaN].includes(_)); customCoalesce(undefined, null, NaN, '', 'Waldo'); // "Waldo" ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### extendHex @@ -8854,20 +8552,19 @@ const extendHex = shortHex => .split('') .map(x => x + x) .join(''); -``` +```
    -Examples - -```js + Examples + + ```js extendHex('#03f'); // '#0033ff' extendHex('05a'); // '#0055aa' ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### getURLParameters @@ -8882,20 +8579,19 @@ const getURLParameters = url => (a, v) => ((a[v.slice(0, v.indexOf('='))] = v.slice(v.indexOf('=') + 1)), a), {} ); -``` +```
    -Examples - -```js + Examples + + ```js getURLParameters('http://url.com/page?name=Adam&surname=Smith'); // {name: 'Adam', surname: 'Smith'} getURLParameters('google.com'); // {} ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### hexToRGB ![advanced](/advanced.svg) @@ -8923,21 +8619,20 @@ const hexToRGB = hex => { ')' ); }; -``` +```
    -Examples - -```js + Examples + + ```js hexToRGB('#27ae60ff'); // 'rgba(39, 174, 96, 255)' hexToRGB('27ae60'); // 'rgb(39, 174, 96)' hexToRGB('#fff'); // 'rgb(255, 255, 255)' ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### httpGet @@ -8956,12 +8651,12 @@ const httpGet = (url, callback, err = console.error) => { request.onerror = () => err(request); request.send(); }; -``` +```
    -Examples - -```js + Examples + + ```js httpGet( 'https://jsonplaceholder.typicode.com/posts/1', console.log @@ -8976,9 +8671,8 @@ Logs: { ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### httpPost @@ -9000,12 +8694,12 @@ const httpPost = (url, data, callback, err = console.error) => { request.onerror = () => err(request); request.send(data); }; -``` +```
    -Examples - -```js + Examples + + ```js const newPost = { userId: 1, id: 1337, @@ -9037,9 +8731,8 @@ Logs: { ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### isBrowser @@ -9051,20 +8744,19 @@ If both of them are not `undefined`, then the current environment is assumed to ```js const isBrowser = () => ![typeof window, typeof document].includes('undefined'); -``` +```
    -Examples - -```js + Examples + + ```js isBrowser(); // true (browser) isBrowser(); // false (Node) ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### mostPerformant @@ -9083,12 +8775,12 @@ const mostPerformant = (fns, iterations = 10000) => { }); return times.indexOf(Math.min(...times)); }; -``` +```
    -Examples - -```js + Examples + + ```js mostPerformant([ () => { // Loops through the entire array before returning `false` @@ -9102,9 +8794,8 @@ mostPerformant([ ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### nthArg @@ -9114,12 +8805,12 @@ Use `Array.slice()` to get the desired argument at index `n`. ```js const nthArg = n => (...args) => args.slice(n)[0]; -``` +```
    -Examples - -```js + Examples + + ```js const third = nthArg(2); third(1, 2, 3); // 3 third(1, 2); // undefined @@ -9128,9 +8819,8 @@ last(1, 2, 3, 4, 5); // 5 ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### parseCookie @@ -9149,19 +8839,18 @@ const parseCookie = str => acc[decodeURIComponent(v[0].trim())] = decodeURIComponent(v[1].trim()); return acc; }, {}); -``` +```
    -Examples - -```js + Examples + + ```js parseCookie('foo=bar; equation=E%3Dmc%5E2'); // { foo: 'bar', equation: 'E=mc^2' } ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### prettyBytes ![advanced](/advanced.svg) @@ -9181,21 +8870,20 @@ const prettyBytes = (num, precision = 3, addSpace = true) => { const n = Number(((num < 0 ? -num : num) / 1000 ** exponent).toPrecision(precision)); return (num < 0 ? '-' : '') + n + (addSpace ? ' ' : '') + UNITS[exponent]; }; -``` +```
    -Examples - -```js + Examples + + ```js prettyBytes(1000); // "1 KB" prettyBytes(-27145424323.5821, 5); // "-27.145 GB" prettyBytes(123456789, 3, false); // "123MB" ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### randomHexColorCode @@ -9208,19 +8896,18 @@ const randomHexColorCode = () => { let n = (Math.random() * 0xfffff * 1000000).toString(16); return '#' + n.slice(0, 6); }; -``` +```
    -Examples - -```js + Examples + + ```js randomHexColorCode(); // "#e34155" ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### RGBToHex @@ -9230,19 +8917,18 @@ Convert given RGB parameters to hexadecimal string using bitwise left-shift oper ```js const RGBToHex = (r, g, b) => ((r << 16) + (g << 8) + b).toString(16).padStart(6, '0'); -``` +```
    -Examples - -```js + Examples + + ```js RGBToHex(255, 165, 1); // 'ffa501' ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### serializeCookie @@ -9252,19 +8938,18 @@ Use template literals and `encodeURIComponent()` to create the appropriate strin ```js const serializeCookie = (name, val) => `${encodeURIComponent(name)}=${encodeURIComponent(val)}`; -``` +```
    -Examples - -```js + Examples + + ```js serializeCookie('foo', 'bar'); // 'foo=bar' ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### timeTaken @@ -9279,19 +8964,18 @@ const timeTaken = callback => { console.timeEnd('timeTaken'); return r; }; -``` +```
    -Examples - -```js + Examples + + ```js timeTaken(() => Math.pow(2, 10)); // 1024, (logged): timeTaken: 0.02099609375ms ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### toCurrency @@ -9302,12 +8986,12 @@ Use `Intl.NumberFormat` to enable country / currency sensitive formatting. ```js const toCurrency = (n, curr, LanguageFormat = undefined) => Intl.NumberFormat(LanguageFormat, { style: 'currency', currency: curr }).format(n); -``` +```
    -Examples - -```js + Examples + + ```js toCurrency(123456.789, 'EUR'); // €123,456.79 | currency: Euro | currencyLangFormat: Local toCurrency(123456.789, 'USD', 'en-us'); // $123,456.79 | currency: US Dollar | currencyLangFormat: English (United States) toCurrency(123456.789, 'USD', 'fa'); // ۱۲۳٬۴۵۶٫۷۹ ؜$ | currency: US Dollar | currencyLangFormat: Farsi @@ -9316,9 +9000,8 @@ toCurrency(322342436423.2435, 'JPY', 'fi'); // 322 342 436 423 ¥ | currency: Ja ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### toDecimalMark @@ -9326,19 +9009,18 @@ Use `toLocaleString()` to convert a float-point arithmetic to the [Decimal mark] ```js const toDecimalMark = num => num.toLocaleString('en-US'); -``` +```
    -Examples - -```js + Examples + + ```js toDecimalMark(12305030388.9087); // "12,305,030,388.909" ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### toOrdinalSuffix @@ -9359,19 +9041,18 @@ const toOrdinalSuffix = num => { ? int + ordinals[digits[0] - 1] : int + ordinals[3]; }; -``` +```
    -Examples - -```js + Examples + + ```js toOrdinalSuffix('123'); // "123rd" ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### validateNumber @@ -9383,19 +9064,18 @@ Use `Number()` to check if the coercion holds. ```js const validateNumber = n => !isNaN(parseFloat(n)) && isFinite(n) && Number(n) == n; -``` +```
    -Examples - -```js + Examples + + ```js validateNumber('10'); // true ```
    - -
    [⬆ Back to top](#table-of-contents) - + +[⬆ Back to top](#table-of-contents) ### yesNo @@ -9407,12 +9087,12 @@ Omit the second argument, `def` to set the default answer as `no`. ```js const yesNo = (val, def = false) => /^(y|yes)$/i.test(val) ? true : /^(n|no)$/i.test(val) ? false : def; -``` +```
    -Examples - -```js + Examples + + ```js yesNo('Y'); // true yesNo('yes'); // true yesNo('No'); // false @@ -9420,8 +9100,8 @@ yesNo('Foo', true); // true ```
    - -
    [⬆ Back to top](#table-of-contents) + +[⬆ Back to top](#table-of-contents) ## Collaborators diff --git a/package-lock.json b/package-lock.json index cde2cebe0..a1a8dbdde 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5696,9 +5696,9 @@ } }, "markdown-builder": { - "version": "0.8.1", - "resolved": "https://registry.npmjs.org/markdown-builder/-/markdown-builder-0.8.1.tgz", - "integrity": "sha512-zqOAYg8jqUM6gB4WkcJ/K5HkqPUL33VAqNrebHSxlkXcEcjDTeKMNqUC8/bND4tKRu72lRFrTmmGYRtlevvXZQ==", + "version": "0.8.3-dev", + "resolved": "https://registry.npmjs.org/markdown-builder/-/markdown-builder-0.8.3-dev.tgz", + "integrity": "sha512-NJp9MW/odYYP8z1lEEwDW3k+iVnzW1xaJqwWbjlzsAAA1kZohi6Cf3bQkWKZsxPJTZACgYd/aKpmunLSD1u2Bw==", "requires": { "husky": "1.0.0-rc.14" } diff --git a/package.json b/package.json index 2952c6c1f..92d5c0451 100644 --- a/package.json +++ b/package.json @@ -52,7 +52,7 @@ }, "homepage": "https://github.com/Chalarangelo/30-seconds-of-code#readme", "dependencies": { - "markdown-builder": "^0.8.1" + "markdown-builder": "^0.8.3-dev" }, "jest": { "reporters": [ diff --git a/snippets_archive/README.md b/snippets_archive/README.md index abc633d5c..51ace3c7e 100644 --- a/snippets_archive/README.md +++ b/snippets_archive/README.md @@ -1,4 +1,4 @@ -![Logo](/logo.png "") +![Logo](/logo.png) # Snippets Archive These snippets, while useful and interesting, didn't quite make it into the repository due to either having very specific use-cases or being outdated. However we felt like they might still be useful to some readers, so here they are. ## Table of Contents @@ -38,13 +38,12 @@ const JSONToDate = arr => {
    Examples -```js + ```js JSONToDate(/Date(1489525200000)/); // "14/3/2017" ```
    - [⬆ Back to top](#table-of-contents) ### speechSynthesis @@ -67,13 +66,12 @@ const speechSynthesis = message => {
    Examples -```js + ```js speechSynthesis('Hello, World'); // // plays the message ```
    - [⬆ Back to top](#table-of-contents) ### binarySearch @@ -99,14 +97,13 @@ const binarySearch = (arr, val, start = 0, end = arr.length - 1) => {
    Examples -```js + ```js binarySearch([1, 4, 6, 7, 12, 13, 15, 18, 19, 20, 22, 24], 6); // 2 binarySearch([1, 4, 6, 7, 12, 13, 15, 18, 19, 20, 22, 24], 21); // -1 ```
    - [⬆ Back to top](#table-of-contents) ### cleanObj @@ -132,14 +129,13 @@ const cleanObj = (obj, keysToKeep = [], childIndicator) => {
    Examples -```js + ```js const testObj = { a: 1, b: 2, children: { a: 1, b: 2 } }; cleanObj(testObj, ['a'], 'children'); // { a: 1, children : { a: 1}} ```
    - [⬆ Back to top](#table-of-contents) ### collatz @@ -155,13 +151,12 @@ const collatz = n => (n % 2 === 0 ? n / 2 : 3 * n + 1);
    Examples -```js + ```js collatz(8); // 4 ```
    - [⬆ Back to top](#table-of-contents) ### countVowels @@ -177,14 +172,13 @@ const countVowels = str => (str.match(/[aeiou]/gi) || []).length;
    Examples -```js + ```js countVowels('foobar'); // 3 countVowels('gym'); // 0 ```
    - [⬆ Back to top](#table-of-contents) ### factors @@ -226,7 +220,7 @@ const factors = (num, primes = false) => {
    Examples -```js + ```js factors(12); // [2,3,4,6,12] factors(12, true); // [2,3] factors(-12); // [2, -2, 3, -3, 4, -4, 6, -6, 12, -12] @@ -235,7 +229,6 @@ factors(-12, true); // [2,3]
    - [⬆ Back to top](#table-of-contents) ### fibonacciCountUntilNum @@ -252,13 +245,12 @@ const fibonacciCountUntilNum = num =>
    Examples -```js + ```js fibonacciCountUntilNum(10); // 7 ```
    - [⬆ Back to top](#table-of-contents) ### fibonacciUntilNum @@ -282,13 +274,12 @@ const fibonacciUntilNum = num => {
    Examples -```js + ```js fibonacciUntilNum(10); // [ 0, 1, 1, 2, 3, 5, 8 ] ```
    - [⬆ Back to top](#table-of-contents) ### httpDelete @@ -313,7 +304,7 @@ const httpDelete = (url, callback, err = console.error) => {
    Examples -```js + ```js httpDelete('https://website.com/users/123', request => { console.log(request.responseText); }); // 'Deletes a user from the database' @@ -321,7 +312,6 @@ httpDelete('https://website.com/users/123', request => {
    - [⬆ Back to top](#table-of-contents) ### httpPut @@ -348,7 +338,7 @@ const httpPut = (url, data, callback, err = console.error) => {
    Examples -```js + ```js const password = "fooBaz"; const data = JSON.stringify(password); httpPut('https://website.com/users/123', data, request => { @@ -358,7 +348,6 @@ httpPut('https://website.com/users/123', data, request => {
    - [⬆ Back to top](#table-of-contents) ### isArmstrongNumber @@ -377,14 +366,13 @@ const isArmstrongNumber = digits =>
    Examples -```js + ```js isArmstrongNumber(1634); // true isArmstrongNumber(56); // false ```
    - [⬆ Back to top](#table-of-contents) ### isSimilar @@ -404,14 +392,13 @@ const isSimilar = (pattern, str) =>
    Examples -```js + ```js isSimilar('rt','Rohit'); // true isSimilar('tr','Rohit'); // false ```
    - [⬆ Back to top](#table-of-contents) ### levenshteinDistance @@ -444,7 +431,7 @@ const levenshteinDistance = (string1, string2) => {
    Examples -```js + ```js levenshteinDistance('30-seconds-of-code','30-seconds-of-python-code'); // 7 const compareStrings = (string1,string2) => (100 - levenshteinDistance(string1,string2) / Math.max(string1.length,string2.length)); compareStrings('30-seconds-of-code', '30-seconds-of-python-code'); // 99.72 (%) @@ -452,7 +439,6 @@ compareStrings('30-seconds-of-code', '30-seconds-of-python-code'); // 99.72 (%)
    - [⬆ Back to top](#table-of-contents) ### quickSort @@ -477,14 +463,13 @@ const quickSort = ([n, ...nums], desc) =>
    Examples -```js + ```js quickSort([4, 1, 3, 2]); // [1,2,3,4] quickSort([4, 1, 3, 2], true); // [4,3,2,1] ```
    - [⬆ Back to top](#table-of-contents) ### removeVowels @@ -501,14 +486,13 @@ const removeVowels = (str, repl = '') => str.replace(/[aeiou]/gi,repl);
    Examples -```js + ```js removeVowels("foobAr"); // "fbr" removeVowels("foobAr","*"); // "f**b*r" ```
    - [⬆ Back to top](#table-of-contents) ### solveRPN @@ -555,14 +539,13 @@ const solveRPN = rpn => {
    Examples -```js + ```js solveRPN('15 7 1 1 + - / 3 * 2 1 1 + + -'); // 5 solveRPN('2 3 ^'); // 8 ```
    - [⬆ Back to top](#table-of-contents) ### howManyTimes @@ -591,7 +574,7 @@ const howManyTimes = (num, divisor) => {
    Examples -```js + ```js howManyTimes(100, 2); // 2 howManyTimes(100, 2.5); // 2 howManyTimes(100, 0); // 0 @@ -600,6 +583,5 @@ howManyTimes(100, -1); // Infinity
    - [⬆ Back to top](#table-of-contents) From 8579e6cbb4c15a7cd8225cef08015f35c54d5221 Mon Sep 17 00:00:00 2001 From: Felix Wu Date: Fri, 14 Sep 2018 15:39:22 +0200 Subject: [PATCH 08/15] append hyphen for advanced links --- README.md | 56 +- scripts/build.js | 2 +- test/testlog | 2283 +++++++++++++++++++++++++++++++++++++++++----- 3 files changed, 2083 insertions(+), 258 deletions(-) diff --git a/README.md b/README.md index cd61099f9..0d6740bb9 100644 --- a/README.md +++ b/README.md @@ -145,21 +145,21 @@ average(1, 2, 3); * [`intersectionWith`](#intersectionwith) * [`isSorted`](#issorted) * [`join`](#join) -* [`JSONtoCSV`](#jsontocsv) +* [`JSONtoCSV`](#jsontocsv-) * [`last`](#last) * [`longestItem`](#longestitem) -* [`mapObject`](#mapobject) +* [`mapObject`](#mapobject-) * [`maxN`](#maxn) * [`minN`](#minn) * [`none`](#none) * [`nthElement`](#nthelement) * [`offset`](#offset) * [`partition`](#partition) -* [`permutations`](#permutations) +* [`permutations`](#permutations-) * [`pull`](#pull) -* [`pullAtIndex`](#pullatindex) -* [`pullAtValue`](#pullatvalue) -* [`pullBy`](#pullby) +* [`pullAtIndex`](#pullatindex-) +* [`pullAtValue`](#pullatvalue-) +* [`pullBy`](#pullby-) * [`reducedFilter`](#reducedfilter) * [`reduceSuccessive`](#reducesuccessive) * [`reduceWhich`](#reducewhich) @@ -173,7 +173,7 @@ average(1, 2, 3); * [`sortedIndexBy`](#sortedindexby) * [`sortedLastIndex`](#sortedlastindex) * [`sortedLastIndexBy`](#sortedlastindexby) -* [`stableSort`](#stablesort) +* [`stableSort`](#stablesort-) * [`symmetricDifference`](#symmetricdifference) * [`symmetricDifferenceBy`](#symmetricdifferenceby) * [`symmetricDifferenceWith`](#symmetricdifferencewith) @@ -191,12 +191,12 @@ average(1, 2, 3); * [`uniqueElementsByRight`](#uniqueelementsbyright) * [`uniqueSymmetricDifference`](#uniquesymmetricdifference) * [`unzip`](#unzip) -* [`unzipWith`](#unzipwith) +* [`unzipWith`](#unzipwith-) * [`without`](#without) * [`xProd`](#xprod) * [`zip`](#zip) * [`zipObject`](#zipobject) -* [`zipWith`](#zipwith) +* [`zipWith`](#zipwith-)
    @@ -207,32 +207,32 @@ average(1, 2, 3); * [`arrayToHtmlList`](#arraytohtmllist) * [`bottomVisible`](#bottomvisible) -* [`copyToClipboard`](#copytoclipboard) -* [`counter`](#counter) +* [`copyToClipboard`](#copytoclipboard-) +* [`counter`](#counter-) * [`createElement`](#createelement) -* [`createEventHub`](#createeventhub) +* [`createEventHub`](#createeventhub-) * [`currentURL`](#currenturl) * [`detectDeviceType`](#detectdevicetype) * [`elementContains`](#elementcontains) -* [`elementIsVisibleInViewport`](#elementisvisibleinviewport) +* [`elementIsVisibleInViewport`](#elementisvisibleinviewport-) * [`getScrollPosition`](#getscrollposition) * [`getStyle`](#getstyle) * [`hasClass`](#hasclass) -* [`hashBrowser`](#hashbrowser) +* [`hashBrowser`](#hashbrowser-) * [`hide`](#hide) * [`httpsRedirect`](#httpsredirect) * [`insertAfter`](#insertafter) * [`insertBefore`](#insertbefore) * [`isBrowserTabFocused`](#isbrowsertabfocused) * [`nodeListToArray`](#nodelisttoarray) -* [`observeMutations`](#observemutations) +* [`observeMutations`](#observemutations-) * [`off`](#off) * [`on`](#on) -* [`onUserInputChange`](#onuserinputchange) +* [`onUserInputChange`](#onuserinputchange-) * [`prefix`](#prefix) * [`recordAnimationFrames`](#recordanimationframes) * [`redirect`](#redirect) -* [`runAsync`](#runasync) +* [`runAsync`](#runasync-) * [`scrollToTop`](#scrolltotop) * [`setStyle`](#setstyle) * [`show`](#show) @@ -274,14 +274,14 @@ average(1, 2, 3); * [`delay`](#delay) * [`functionName`](#functionname) * [`hz`](#hz) -* [`memoize`](#memoize) +* [`memoize`](#memoize-) * [`negate`](#negate) * [`once`](#once) * [`partial`](#partial) * [`partialRight`](#partialright) * [`runPromisesInSeries`](#runpromisesinseries) * [`sleep`](#sleep) -* [`throttle`](#throttle) +* [`throttle`](#throttle-) * [`times`](#times) * [`uncurry`](#uncurry) * [`unfold`](#unfold) @@ -302,7 +302,7 @@ average(1, 2, 3); * [`degreesToRads`](#degreestorads) * [`digitize`](#digitize) * [`distance`](#distance) -* [`elo`](#elo) +* [`elo`](#elo-) * [`factorial`](#factorial) * [`fibonacci`](#fibonacci) * [`gcd`](#gcd) @@ -313,7 +313,7 @@ average(1, 2, 3); * [`isEven`](#iseven) * [`isPrime`](#isprime) * [`lcm`](#lcm) -* [`luhnCheck`](#luhncheck) +* [`luhnCheck`](#luhncheck-) * [`maxBy`](#maxby) * [`median`](#median) * [`minBy`](#minby) @@ -362,7 +362,7 @@ average(1, 2, 3); * [`deepFreeze`](#deepfreeze) * [`defaults`](#defaults) * [`dig`](#dig) -* [`equals`](#equals) +* [`equals`](#equals-) * [`findKey`](#findkey) * [`findLastKey`](#findlastkey) * [`flattenObject`](#flattenobject) @@ -390,7 +390,7 @@ average(1, 2, 3); * [`size`](#size) * [`transform`](#transform) * [`truthCheckCollection`](#truthcheckcollection) -* [`unflattenObject`](#unflattenobject) +* [`unflattenObject`](#unflattenobject-)
    @@ -403,7 +403,7 @@ average(1, 2, 3); * [`capitalize`](#capitalize) * [`capitalizeEveryWord`](#capitalizeeveryword) * [`CSVToArray`](#csvtoarray) -* [`CSVToJSON`](#csvtojson) +* [`CSVToJSON`](#csvtojson-) * [`decapitalize`](#decapitalize) * [`escapeHTML`](#escapehtml) * [`escapeRegExp`](#escaperegexp) @@ -421,14 +421,14 @@ average(1, 2, 3); * [`reverseString`](#reversestring) * [`sortCharactersInString`](#sortcharactersinstring) * [`splitLines`](#splitlines) -* [`stringPermutations`](#stringpermutations) +* [`stringPermutations`](#stringpermutations-) * [`stripHTMLTags`](#striphtmltags) * [`toCamelCase`](#tocamelcase) * [`toKebabCase`](#tokebabcase) * [`toSnakeCase`](#tosnakecase) * [`truncateString`](#truncatestring) * [`unescapeHTML`](#unescapehtml) -* [`URLJoin`](#urljoin) +* [`URLJoin`](#urljoin-) * [`words`](#words)
    @@ -470,14 +470,14 @@ average(1, 2, 3); * [`coalesceFactory`](#coalescefactory) * [`extendHex`](#extendhex) * [`getURLParameters`](#geturlparameters) -* [`hexToRGB`](#hextorgb) +* [`hexToRGB`](#hextorgb-) * [`httpGet`](#httpget) * [`httpPost`](#httppost) * [`isBrowser`](#isbrowser) * [`mostPerformant`](#mostperformant) * [`nthArg`](#ntharg) * [`parseCookie`](#parsecookie) -* [`prettyBytes`](#prettybytes) +* [`prettyBytes`](#prettybytes-) * [`randomHexColorCode`](#randomhexcolorcode) * [`RGBToHex`](#rgbtohex) * [`serializeCookie`](#serializecookie) diff --git a/scripts/build.js b/scripts/build.js index 9f1a0c506..bdc92911a 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -176,7 +176,7 @@ try { lists.ul(taggedSnippets, (snippet) => misc.link( `\`${snippet[0]}\``, - misc.anchor(snippet[0]) + `${misc.anchor(snippet[0])}${snippet[1].includes('advanced') ? '-' : ''}` ) ) ) + '\n'; diff --git a/test/testlog b/test/testlog index 6cf70f8ba..2812fb738 100644 --- a/test/testlog +++ b/test/testlog @@ -3,274 +3,2099 @@ # Starting... # 347 test suites found. -# PASS test/uniqueElements/uniqueElements.test.js +# PASS test/isEmpty/isEmpty.test.js -ok 1 — uniqueElements is a Function -ok 2 — uniqueElements([1, 2, 2, 3, 4, 4, 5]) returns [1,2,3,4,5] -ok 3 — uniqueElements([1, 23, 53]) returns [1, 23, 53] -ok 4 — uniqueElements([true, 0, 1, false, false, undefined, null, '']) returns [true, 0, 1, false, false, undefined, null, ''] -ok 5 — uniqueElements() returns [] -ok 6 — uniqueElements(null) returns [] -ok 7 — uniqueElements(undefined) returns [] -ok 8 — uniqueElements('strt') returns ['s', 't', 'r'] -ok 9 — uniqueElements(1, 1, 2543, 534, 5) throws an error -ok 10 — uniqueElements({}) throws an error -ok 11 — uniqueElements(true) throws an error -ok 12 — uniqueElements(false) throws an error -ok 13 — uniqueElements([true, 0, 1, false, false, undefined, null]) takes less than 2s to run +ok 1 — isEmpty is a Function +ok 2 — Returns true for empty Map +ok 3 — Returns true for empty Set +ok 4 — Returns true for empty array +ok 5 — Returns true for empty object +ok 6 — Returns true for empty string +ok 7 — Returns false for non-empty array +ok 8 — Returns false for non-empty object +ok 9 — Returns false for non-empty string +ok 10 — Returns true - type is not considered a collection +ok 11 — Returns true - type is not considered a collection + +# PASS test/last/last.test.js + +ok 12 — last is a Function +ok 13 — last({ a: 1234}) returns undefined +ok 14 — last([1, 2, 3]) returns 3 +ok 15 — last({ 0: false}) returns undefined +ok 16 — last(String) returns g +ok 17 — last(null) throws an Error +ok 18 — last(undefined) throws an Error +ok 19 — last() throws an Error +ok 20 — last([1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 1122, 32124, 23232]) takes less than 2s to run + +# PASS test/uniqueElementsBy/uniqueElementsBy.test.js + +ok 21 — uniqueElementsBy is a Function +ok 22 — uniqueElementsBy works for properties +ok 23 — uniqueElementsBy works for nested properties # PASS test/toSnakeCase/toSnakeCase.test.js -ok 14 — toSnakeCase is a Function -ok 15 — toSnakeCase('camelCase') returns camel_case -ok 16 — toSnakeCase('some text') returns some_text -ok 17 — toSnakeCase('some-mixed_string With spaces_underscores-and-hyphens') returns some_mixed_string_with_spaces_underscores_and_hyphens -ok 18 — toSnakeCase('IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML') returns i_am_listening_to_fm_while_loading_different_url_on_my_browser_and_also_editing_some_xml_and_html -ok 19 — toSnakeCase() returns undefined -ok 20 — toSnakeCase([]) throws an error -ok 21 — toSnakeCase({}) throws an error -ok 22 — toSnakeCase(123) throws an error -ok 23 — toSnakeCase(IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML) takes less than 2s to run +ok 24 — toSnakeCase is a Function +ok 25 — toSnakeCase('camelCase') returns camel_case +ok 26 — toSnakeCase('some text') returns some_text +ok 27 — toSnakeCase('some-mixed_string With spaces_underscores-and-hyphens') returns some_mixed_string_with_spaces_underscores_and_hyphens +ok 28 — toSnakeCase('IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML') returns i_am_listening_to_fm_while_loading_different_url_on_my_browser_and_also_editing_some_xml_and_html +ok 29 — toSnakeCase() returns undefined +ok 30 — toSnakeCase([]) throws an error +ok 31 — toSnakeCase({}) throws an error +ok 32 — toSnakeCase(123) throws an error +ok 33 — toSnakeCase(IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML) takes less than 2s to run + +# PASS test/uniqueElements/uniqueElements.test.js + +ok 34 — uniqueElements is a Function +ok 35 — uniqueElements([1, 2, 2, 3, 4, 4, 5]) returns [1,2,3,4,5] +ok 36 — uniqueElements([1, 23, 53]) returns [1, 23, 53] +ok 37 — uniqueElements([true, 0, 1, false, false, undefined, null, '']) returns [true, 0, 1, false, false, undefined, null, ''] +ok 38 — uniqueElements() returns [] +ok 39 — uniqueElements(null) returns [] +ok 40 — uniqueElements(undefined) returns [] +ok 41 — uniqueElements('strt') returns ['s', 't', 'r'] +ok 42 — uniqueElements(1, 1, 2543, 534, 5) throws an error +ok 43 — uniqueElements({}) throws an error +ok 44 — uniqueElements(true) throws an error +ok 45 — uniqueElements(false) throws an error +ok 46 — uniqueElements([true, 0, 1, false, false, undefined, null]) takes less than 2s to run # PASS test/toKebabCase/toKebabCase.test.js -ok 24 — toKebabCase is a Function -ok 25 — toKebabCase('camelCase') returns camel-case -ok 26 — toKebabCase('some text') returns some-text -ok 27 — toKebabCase('some-mixed-string With spaces-underscores-and-hyphens') returns some-mixed-string-with-spaces-underscores-and-hyphens -ok 28 — toKebabCase('IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML') returns i-am-listening-to-fm-while-loading-different-url-on-my-browser-and-also-editing-some-xml-and-html -ok 29 — toKebabCase() returns undefined -ok 30 — toKebabCase([]) throws an erro -ok 31 — toKebabCase({}) throws an erro -ok 32 — toKebabCase(123) throws an erro -ok 33 — toKebabCase(IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML) takes less than 2s to run +ok 47 — toKebabCase is a Function +ok 48 — toKebabCase('camelCase') returns camel-case +ok 49 — toKebabCase('some text') returns some-text +ok 50 — toKebabCase('some-mixed-string With spaces-underscores-and-hyphens') returns some-mixed-string-with-spaces-underscores-and-hyphens +ok 51 — toKebabCase('IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML') returns i-am-listening-to-fm-while-loading-different-url-on-my-browser-and-also-editing-some-xml-and-html +ok 52 — toKebabCase() returns undefined +ok 53 — toKebabCase([]) throws an erro +ok 54 — toKebabCase({}) throws an erro +ok 55 — toKebabCase(123) throws an erro +ok 56 — toKebabCase(IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSomeXMLAndHTML) takes less than 2s to run -# PASS test/toCamelCase/toCamelCase.test.js +# PASS test/isNil/isNil.test.js -ok 34 — toCamelCase is a Function -ok 35 — toCamelCase('some_database_field_name') returns someDatabaseFieldName -ok 36 — toCamelCase('Some label that needs to be camelized') returns someLabelThatNeedsToBeCamelized -ok 37 — toCamelCase('some-javascript-property') return someJavascriptProperty -ok 38 — toCamelCase('some-mixed_string with spaces_underscores-and-hyphens') returns someMixedStringWithSpacesUnderscoresAndHyphens -ok 39 — toCamelCase() throws a error -ok 40 — toCamelCase([]) throws a error -ok 41 — toCamelCase({}) throws a error -ok 42 — toCamelCase(123) throws a error -ok 43 — toCamelCase(some-mixed_string with spaces_underscores-and-hyphens) takes less than 2s to run +ok 57 — isNil is a Function +ok 58 — Returns true for null +ok 59 — Returns true for undefined +ok 60 — Returns false for an empty string -# PASS test/is/is.test.js +# PASS test/gcd/gcd.test.js -ok 44 — is is a Function -ok 45 — Works for arrays with data -ok 46 — Works for empty arrays -ok 47 — Works for arrays, not objects -ok 48 — Works for objects -ok 49 — Works for maps -ok 50 — Works for regular expressions -ok 51 — Works for sets -ok 52 — Works for weak maps -ok 53 — Works for weak sets -ok 54 — Works for strings - returns true for primitive -ok 55 — Works for strings - returns true when using constructor -ok 56 — Works for numbers - returns true for primitive -ok 57 — Works for numbers - returns true when using constructor -ok 58 — Works for booleans - returns true for primitive -ok 59 — Works for booleans - returns true when using constructor -ok 60 — Works for functions +ok 61 — gcd is a Function +ok 62 — Calculates the greatest common divisor between two or more numbers/arrays +ok 63 — Calculates the greatest common divisor between two or more numbers/arrays -# PASS test/average/average.test.js +# PASS test/factors/factors.test.js -ok 61 — average is a Function -ok 62 — average(true) returns 0 -ok 63 — average(false) returns 1 -ok 64 — average(9, 1) returns 5 -ok 65 — average(153, 44, 55, 64, 71, 1122, 322774, 2232, 23423, 234, 3631) returns 32163.909090909092 -ok 66 — average(1, 2, 3) returns 2 -ok 67 — average(null) returns 0 -ok 68 — average(1, 2, 3) returns NaN -ok 69 — average(String) returns NaN -ok 70 — average({ a: 123}) returns NaN -ok 71 — average([undefined, 0, string]) returns NaN -ok 72 — average([1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 1122, 32124, 23232]) takes less than 2s to run +ok 64 — factors is a Function -# PASS test/union/union.test.js +# PASS test/filterNonUniqueBy/filterNonUniqueBy.test.js -ok 73 — union is a Function -ok 74 — union([1, 2, 3], [4, 3, 2]) returns [1, 2, 3, 4] -ok 75 — union('str', 'asd') returns [ 's', 't', 'r', 'a', 'd' ] -ok 76 — union([[], {}], [1, 2, 3]) returns [[], {}, 1, 2, 3] -ok 77 — union([], []) returns [] -ok 78 — union() throws an error -ok 79 — union(true, 'str') throws an error -ok 80 — union('false', true) throws an error -ok 81 — union((123, {}) throws an error -ok 82 — union([], {}) throws an error -ok 83 — union(undefined, null) throws an error -ok 84 — union([1, 2, 3], [4, 3, 2]) takes less than 2s to run +ok 65 — filterNonUniqueBy is a Function +ok 66 — filterNonUniqueBy works for properties +ok 67 — filterNonUniqueBy works for nested properties -# PASS test/validateNumber/validateNumber.test.js +# PASS test/compose/compose.test.js -ok 85 — validateNumber is a Function -ok 86 — validateNumber(9) returns true -ok 87 — validateNumber(234asd.slice(0, 2)) returns true -ok 88 — validateNumber(1232) returns true -ok 89 — validateNumber(1232 + 13423) returns true -ok 90 — validateNumber(1232 * 2342 * 123) returns true -ok 91 — validateNumber(1232.23423536) returns true -ok 92 — validateNumber(234asd) returns false -ok 93 — validateNumber(e234d) returns false -ok 94 — validateNumber(false) returns false -ok 95 — validateNumber(true) returns false -ok 96 — validateNumber(null) returns false -ok 97 — validateNumber(123 * asd) returns false +ok 68 — compose is a Function +ok 69 — Performs right-to-left function composition -# PASS test/toSafeInteger/toSafeInteger.test.js +# PASS test/head/head.test.js -ok 98 — toSafeInteger is a Function -ok 99 — Number(toSafeInteger(3.2)) is a number -ok 100 — Converts a value to a safe integer -ok 101 — toSafeInteger('4.2') returns 4 -ok 102 — toSafeInteger(4.6) returns 5 -ok 103 — toSafeInteger([]) returns 0 -ok 104 — isNaN(toSafeInteger([1.5, 3124])) is true -ok 105 — isNaN(toSafeInteger('string')) is true -ok 106 — isNaN(toSafeInteger({})) is true -ok 107 — isNaN(toSafeInteger()) is true -ok 108 — toSafeInteger(Infinity) returns 9007199254740991 -ok 109 — toSafeInteger(3.2) takes less than 2s to run +ok 70 — head is a Function +ok 71 — head({ a: 1234}) returns undefined +ok 72 — head([1, 2, 3]) returns 1 +ok 73 — head({ 0: false}) returns false +ok 74 — head(String) returns S +ok 75 — head(null) throws an Error +ok 76 — head(undefined) throws an Error +ok 77 — head() throws an Error +ok 78 — head([1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 1122, 32124, 23232]) takes less than 2s to run -# PASS test/isPrimitive/isPrimitive.test.js +# PASS test/sortedLastIndexBy/sortedLastIndexBy.test.js -ok 110 — isPrimitive is a Function -ok 111 — isPrimitive(null) is primitive -ok 112 — isPrimitive(undefined) is primitive -ok 113 — isPrimitive(string) is primitive -ok 114 — isPrimitive(true) is primitive -ok 115 — isPrimitive(50) is primitive -ok 116 — isPrimitive('Hello') is primitive -ok 117 — isPrimitive(false) is primitive -ok 118 — isPrimitive(Symbol()) is primitive -ok 119 — isPrimitive([1, 2, 3]) is not primitive -ok 120 — isPrimitive({ a: 123 }) is not primitive -ok 121 — isPrimitive({ a: 123 }) takes less than 2s to run +ok 79 — sortedLastIndexBy is a Function +ok 80 — Returns the highest index to insert the element without messing up the list order -# PASS test/zipObject/zipObject.test.js +# PASS test/sdbm/sdbm.test.js -ok 122 — zipObject is a Function -ok 123 — zipObject([a, b, c], [1, 2]) returns {a: 1, b: 2, c: undefined} -ok 124 — zipObject([a, b], [1, 2, 3]) returns {a: 1, b: 2} -ok 125 — zipObject([a, b, c], string) returns { a: s, b: t, c: r } -ok 126 — zipObject([a], string) returns { a: s } -ok 127 — zipObject() throws an error -ok 128 — zipObject((['string'], null) throws an error -ok 129 — zipObject(null, [1]) throws an error -ok 130 — zipObject('string') throws an error -ok 131 — zipObject('test', 'string') throws an error +ok 81 — sdbm is a Function +ok 82 — Hashes the input string into a whole number. -# PASS test/quickSort/quickSort.test.js +# PASS test/powerset/powerset.test.js -ok 132 — quickSort is a Function -ok 133 — quickSort([5, 6, 4, 3, 1, 2]) returns [1, 2, 3, 4, 5, 6] -ok 134 — quickSort([-1, 0, -2]) returns [-2, -1, 0] -ok 135 — quickSort() throws an error -ok 136 — quickSort(123) throws an error -ok 137 — quickSort({ 234: string}) throws an error -ok 138 — quickSort(null) throws an error -ok 139 — quickSort(undefined) throws an error -ok 140 — quickSort([11, 1, 324, 23232, -1, 53, 2, 524, 32, 13, 156, 133, 62, 12, 4]) takes less than 2s to run +ok 83 — powerset is a Function +ok 84 — Returns the powerset of a given array of numbers. -# PASS test/round/round.test.js +# PASS test/overArgs/overArgs.test.js -ok 141 — round is a Function -ok 142 — round(1.005, 2) returns 1.01 -ok 143 — round(123.3423345345345345344, 11) returns 123.34233453453 -ok 144 — round(3.342, 11) returns 3.342 -ok 145 — round(1.005) returns 1 -ok 146 — round([1.005, 2]) returns NaN -ok 147 — round(string) returns NaN -ok 148 — round() returns NaN -ok 149 — round(132, 413, 4134) returns NaN -ok 150 — round({a: 132}, 413) returns NaN -ok 151 — round(123.3423345345345345344, 11) takes less than 2s to run +ok 85 — overArgs is a Function +ok 86 — Invokes the provided function with its arguments transformed -# PASS test/yesNo/yesNo.test.js +# PASS test/formatDuration/formatDuration.test.js -ok 152 — yesNo is a Function -ok 153 — yesNo(Y) returns true -ok 154 — yesNo(yes) returns true -ok 155 — yesNo(foo, true) returns true -ok 156 — yesNo(No) returns false -ok 157 — yesNo() returns false -ok 158 — yesNo(null) returns false -ok 159 — yesNo(undefined) returns false -ok 160 — yesNo([123, null]) returns false -ok 161 — yesNo([Yes, No]) returns false -ok 162 — yesNo({ 2: Yes }) returns false -ok 163 — yesNo([Yes, No], true) returns true -ok 164 — yesNo({ 2: Yes }, true) returns true +ok 87 — formatDuration is a Function +ok 88 — Returns the human readable format of the given number of milliseconds +ok 89 — Returns the human readable format of the given number of milliseconds + +# PASS test/any/any.test.js + +ok 90 — any is a Function +ok 91 — Returns true for arrays with at least one truthy value +ok 92 — Returns false for arrays with no truthy values +ok 93 — Returns false for arrays with no truthy values +ok 94 — Returns true with predicate function +ok 95 — Returns false with a predicate function + +# PASS test/equals/equals.test.js + +ok 96 — equals is a Function +ok 97 — { a: [2, {e: 3}], b: [4], c: 'foo' } is equal to { a: [2, {e: 3}], b: [4], c: 'foo' } +ok 98 — [1,2,3] is equal to [1,2,3] +ok 99 — { a: [2, 3], b: [4] } is not equal to { a: [2, 3], b: [6] } +ok 100 — [1,2,3] is not equal to [1,2,4] +ok 101 — [1, 2, 3] should be equal to { 0: 1, 1: 2, 2: 3 }) - type is different, but their enumerable properties match. + +# PASS test/all/all.test.js + +ok 102 — all is a Function +ok 103 — Returns true for arrays with no falsey values +ok 104 — Returns false for arrays with 0 +ok 105 — Returns false for arrays with NaN +ok 106 — Returns false for arrays with undefined +ok 107 — Returns false for arrays with null +ok 108 — Returns false for arrays with empty strings +ok 109 — Returns true with predicate function +ok 110 — Returns false with a predicate function + +# PASS test/offset/offset.test.js + +ok 111 — offset is a Function +ok 112 — Offset of 0 returns the same array. +ok 113 — Offset > 0 returns the offsetted array. +ok 114 — Offset < 0 returns the reverse offsetted array. +ok 115 — Offset greater than the length of the array returns the same array. +ok 116 — Offset less than the negative length of the array returns the same array. +ok 117 — Offsetting empty array returns an empty array. + +# PASS test/prettyBytes/prettyBytes.test.js + +ok 118 — prettyBytes is a Function +ok 119 — Converts a number in bytes to a human-readable string. +ok 120 — Converts a number in bytes to a human-readable string. +ok 121 — Converts a number in bytes to a human-readable string. + +# PASS test/decapitalize/decapitalize.test.js + +ok 122 — decapitalize is a Function +ok 123 — Works with default parameter +ok 124 — Works with second parameter set to true + +# PASS test/when/when.test.js + +ok 125 — when is a Function +ok 126 — Returns the proper result +ok 127 — Returns the proper result + +# PASS test/isMap/isMap.test.js + +ok 128 — isMap is a Function + +# PASS test/UUIDGeneratorNode/UUIDGeneratorNode.test.js + +ok 129 — UUIDGeneratorNode is a Function +ok 130 — Contains dashes in the proper places +ok 131 — Only contains hexadecimal digits + +# PASS test/isWeakMap/isWeakMap.test.js + +ok 132 — isWeakMap is a Function + +# PASS test/mapKeys/mapKeys.test.js + +ok 133 — mapKeys is a Function +ok 134 — Maps keys + +# PASS test/groupBy/groupBy.test.js + +ok 135 — groupBy is a Function +ok 136 — Groups the elements of an array based on the given function +ok 137 — Groups the elements of an array based on the given function + +# PASS test/countBy/countBy.test.js + +ok 138 — countBy is a Function +ok 139 — Works for functions +ok 140 — Works for property names + +# PASS test/hide/hide.test.js + +ok 141 — hide is a Function + +# PASS test/createEventHub/createEventHub.test.js + +ok 142 — createEventHub is a Function + +# PASS test/isPlainObject/isPlainObject.test.js + +ok 143 — isPlainObject is a Function +ok 144 — Returns true for a plain object +ok 145 — Returns false for a Map (example of non-plain object) + +# PASS test/factorial/factorial.test.js + +ok 146 — factorial is a Function +ok 147 — Calculates the factorial of 720 +ok 148 — Calculates the factorial of 0 +ok 149 — Calculates the factorial of 1 +ok 150 — Calculates the factorial of 4 +ok 151 — Calculates the factorial of 10 + +# PASS test/nodeListToArray/nodeListToArray.test.js + +ok 152 — nodeListToArray is a Function + +# PASS test/isRegExp/isRegExp.test.js + +ok 153 — isRegExp is a Function + +# PASS test/allEqual/allEqual.test.js + +ok 154 — allEqual is a Function +ok 155 — Truthy numbers +ok 156 — Falsy numbers +ok 157 — Truthy strings +ok 158 — Falsy numbers +ok 159 — Truthy trues +ok 160 — Truthy falses +ok 161 — Falsy trues +ok 162 — Falsy falses + +# PASS test/countOccurrences/countOccurrences.test.js + +ok 163 — countOccurrences is a Function +ok 164 — Counts the occurrences of a value in an array + +# PASS test/prefix/prefix.test.js + +ok 165 — prefix is a Function + +# PASS test/matches/matches.test.js + +ok 166 — matches is a Function +ok 167 — Matches returns true for two similar objects +ok 168 — Matches returns false for two non-similar objects + +# PASS test/pluralize/pluralize.test.js + +ok 169 — pluralize is a Function +ok 170 — Produces the plural of the word +ok 171 — Produces the singular of the word +ok 172 — Produces the plural of the word +ok 173 — Prodices the defined plural of the word +ok 174 — Works with a dictionary + +# PASS test/splitLines/splitLines.test.js + +ok 175 — splitLines is a Function +ok 176 — Splits a multiline string into an array of lines. + +# PASS test/shallowClone/shallowClone.test.js + +ok 177 — shallowClone is a Function +ok 178 — Shallow cloning works +ok 179 — Does not clone deeply + +# PASS test/unflattenObject/unflattenObject.test.js + +ok 180 — unflattenObject is a Function +ok 181 — Unflattens an object with the paths for keys + +# PASS test/timeTaken/timeTaken.test.js + +ok 182 — timeTaken is a Function + +# PASS test/zipWith/zipWith.test.js + +ok 183 — zipWith is a Function + +# PASS test/renameKeys/renameKeys.test.js + +ok 184 — renameKeys is a Function +ok 185 — renameKeys is a Function + +# PASS test/defaults/defaults.test.js + +ok 186 — defaults is a Function +ok 187 — Assigns default values for undefined properties + +# PASS test/mapObject/mapObject.test.js + +ok 188 — mapObject is a Function +ok 189 — mapObject([1, 2, 3], a => a * a) returns { 1: 1, 2: 4, 3: 9 } +ok 190 — mapObject([1, 2, 3, 4], (a, b) => b - a) returns { 1: -1, 2: -1, 3: -1, 4: -1 } +ok 191 — mapObject([1, 2, 3, 4], (a, b) => a - b) returns { 1: 1, 2: 1, 3: 1, 4: 1 } + +# PASS test/toHash/toHash.test.js + +ok 192 — toHash is a Function + +# PASS test/copyToClipboard/copyToClipboard.test.js + +ok 193 — copyToClipboard is a Function + +# PASS test/maxBy/maxBy.test.js + +ok 194 — maxBy is a Function +ok 195 — Produces the right result with a function +ok 196 — Produces the right result with a property name + +# PASS test/isSimilar/isSimilar.test.js + +ok 197 — isSimilar is a Function + +# PASS test/forEachRight/forEachRight.test.js + +ok 198 — forEachRight is a Function +ok 199 — Iterates over the array in reverse + +# PASS test/runAsync/runAsync.test.js + +ok 200 — runAsync is a Function + +# PASS test/isNumber/isNumber.test.js + +ok 201 — isNumber is a Function +ok 202 — passed argument is a number +ok 203 — passed argument is not a number + +# PASS test/take/take.test.js + +ok 204 — take is a Function +ok 205 — Returns an array with n elements removed from the beginning. +ok 206 — Returns an array with n elements removed from the beginning. + +# PASS test/cleanObj/cleanObj.test.js + +ok 207 — cleanObj is a Function +ok 208 — Removes any properties except the ones specified from a JSON object + +# PASS test/runPromisesInSeries/runPromisesInSeries.test.js + +ok 209 — runPromisesInSeries is a Function +ok 210 — Runs promises in series + +# PASS test/takeRight/takeRight.test.js + +ok 211 — takeRight is a Function +ok 212 — Returns an array with n elements removed from the end +ok 213 — Returns an array with n elements removed from the end + +# PASS test/tomorrow/tomorrow.test.js + +ok 214 — tomorrow is a Function +ok 215 — Returns the correct year +ok 216 — Returns the correct month +ok 217 — Returns the correct date + +# PASS test/matchesWith/matchesWith.test.js + +ok 218 — matchesWith is a Function +ok 219 — Returns true for two objects with similar values, based on the provided function + +# PASS test/capitalize/capitalize.test.js + +ok 220 — capitalize is a Function +ok 221 — Capitalizes the first letter of a string +ok 222 — Capitalizes the first letter of a string +ok 223 — Works with characters +ok 224 — "Works with single character words + +# PASS test/radsToDegrees/radsToDegrees.test.js + +ok 225 — radsToDegrees is a Function +ok 226 — Returns the appropriate value + +# PASS test/CSVToArray/CSVToArray.test.js + +ok 227 — CSVToArray is a Function +ok 228 — CSVToArray works with default delimiter +ok 229 — CSVToArray works with custom delimiter +ok 230 — CSVToArray omits the first row +ok 231 — CSVToArray omits the first row and works with a custom delimiter + +# PASS test/spreadOver/spreadOver.test.js + +ok 232 — spreadOver is a Function +ok 233 — Takes a variadic function and returns a closure that accepts an array of arguments to map to the inputs of the function. + +# PASS test/fibonacci/fibonacci.test.js + +ok 234 — fibonacci is a Function +ok 235 — Generates an array, containing the Fibonacci sequence + +# PASS test/toCurrency/toCurrency.test.js + +ok 236 — toCurrency is a Function +ok 237 — currency: Euro | currencyLangFormat: Local +ok 238 — currency: US Dollar | currencyLangFormat: English (United States) +ok 239 — currency: Japanese Yen | currencyLangFormat: Local + +# PASS test/toOrdinalSuffix/toOrdinalSuffix.test.js + +ok 240 — toOrdinalSuffix is a Function +ok 241 — Adds an ordinal suffix to a number +ok 242 — Adds an ordinal suffix to a number +ok 243 — Adds an ordinal suffix to a number +ok 244 — Adds an ordinal suffix to a number + +# PASS test/getType/getType.test.js + +ok 245 — getType is a Function +ok 246 — Returns the native type of a value + +# PASS test/sumPower/sumPower.test.js + +ok 247 — sumPower is a Function +ok 248 — Returns the sum of the powers of all the numbers from start to end +ok 249 — Returns the sum of the powers of all the numbers from start to end +ok 250 — Returns the sum of the powers of all the numbers from start to end + +# PASS test/counter/counter.test.js + +ok 251 — counter is a Function + +# PASS test/chainAsync/chainAsync.test.js + +ok 252 — chainAsync is a Function +ok 253 — Calls all functions in an array + +# PASS test/pad/pad.test.js + +ok 254 — pad is a Function +ok 255 — cat is padded on both sides +ok 256 — length of string is 8 +ok 257 — pads 42 with "0" +ok 258 — does not truncates if string exceeds length + +# PASS test/orderBy/orderBy.test.js + +ok 259 — orderBy is a Function +ok 260 — Returns a sorted array of objects ordered by properties and orders. +ok 261 — Returns a sorted array of objects ordered by properties and orders. + +# PASS test/dig/dig.test.js + +ok 262 — dig is a Function +ok 263 — Dig target success +ok 264 — Dig target with falsey value +ok 265 — Dig target with array +ok 266 — Unknown target return undefined + +# PASS test/randomIntArrayInRange/randomIntArrayInRange.test.js + +ok 267 — randomIntArrayInRange is a Function +ok 268 — The returned array contains only integers +ok 269 — The returned array has the proper length +ok 270 — The returned array's values lie between provided lowerLimit and upperLimit (both inclusive). + +# PASS test/atob/atob.test.js + +ok 271 — atob is a Function +ok 272 — atob("Zm9vYmFy") equals "foobar" +ok 273 — atob("Z") returns "" + +# PASS test/times/times.test.js + +ok 274 — times is a Function +ok 275 — Runs a function the specified amount of times + +# PASS test/uniqueSymmetricDifference/uniqueSymmetricDifference.test.js + +ok 276 — uniqueSymmetricDifference is a Function +ok 277 — Returns the symmetric difference between two arrays. +ok 278 — Does not return duplicates from one array + +# PASS test/takeRightWhile/takeRightWhile.test.js + +ok 279 — takeRightWhile is a Function +ok 280 — Removes elements until the function returns true + +# PASS test/unescapeHTML/unescapeHTML.test.js + +ok 281 — unescapeHTML is a Function +ok 282 — Unescapes escaped HTML characters. + +# PASS test/coalesce/coalesce.test.js + +ok 283 — coalesce is a Function +ok 284 — Returns the first non-null/undefined argument + +# PASS test/similarity/similarity.test.js + +ok 285 — similarity is a Function +ok 286 — Returns an array of elements that appear in both arrays. + +# PASS test/binarySearch/binarySearch.test.js + +ok 287 — binarySearch is a Function +ok 288 — Finds item in array +ok 289 — Returns -1 when not found +ok 290 — Works with empty arrays +ok 291 — Works for one element arrays + +# PASS test/percentile/percentile.test.js + +ok 292 — percentile is a Function +ok 293 — Uses the percentile formula to calculate how many numbers in the given array are less or equal to the given value. + +# PASS test/throttle/throttle.test.js + +ok 294 — throttle is a Function + +# PASS test/degreesToRads/degreesToRads.test.js + +ok 295 — degreesToRads is a Function +ok 296 — Returns the appropriate value + +# PASS test/hashNode/hashNode.test.js + +ok 297 — hashNode is a Function +ok 298 — Produces the appropriate hash + +# PASS test/isWeakSet/isWeakSet.test.js + +ok 299 — isWeakSet is a Function + +# PASS test/ary/ary.test.js + +ok 300 — ary is a Function +ok 301 — Discards arguments with index >=n + +# PASS test/setStyle/setStyle.test.js + +ok 302 — setStyle is a Function + +# PASS test/sleep/sleep.test.js + +ok 303 — sleep is a Function +ok 304 — Works as expected + +# PASS test/initializeArrayWithRangeRight/initializeArrayWithRangeRight.test.js + +ok 305 — initializeArrayWithRangeRight is a Function + +# PASS test/reject/reject.test.js + +ok 306 — reject is a Function +ok 307 — Works with numbers +ok 308 — Works with strings + +# PASS test/observeMutations/observeMutations.test.js + +ok 309 — observeMutations is a Function + +# PASS test/once/once.test.js + +ok 310 — once is a Function + +# PASS test/averageBy/averageBy.test.js + +ok 311 — averageBy is a Function +ok 312 — Produces the right result with a function +ok 313 — Produces the right result with a property name + +# PASS test/isTravisCI/isTravisCI.test.js + +ok 314 — isTravisCI is a Function +ok 315 — Not running on Travis, correctly evaluates + +# PASS test/symmetricDifferenceWith/symmetricDifferenceWith.test.js + +ok 316 — symmetricDifferenceWith is a Function +ok 317 — Returns the symmetric difference between two arrays, using a provided function as a comparator + +# PASS test/initializeArrayWithValues/initializeArrayWithValues.test.js + +ok 318 — initializeArrayWithValues is a Function +ok 319 — Initializes and fills an array with the specified values + +# PASS test/solveRPN/solveRPN.test.js + +ok 320 — solveRPN is a Function + +# PASS test/sortedIndex/sortedIndex.test.js + +ok 321 — sortedIndex is a Function +ok 322 — Returns the lowest index at which value should be inserted into array in order to maintain its sort order. +ok 323 — Returns the lowest index at which value should be inserted into array in order to maintain its sort order. + +# PASS test/deepClone/deepClone.test.js + +ok 324 — deepClone is a Function +ok 325 — Shallow cloning works +ok 326 — Deep cloning works +ok 327 — Array shallow cloning works +ok 328 — Array deep cloning works + +# PASS test/JSONtoCSV/JSONtoCSV.test.js + +ok 329 — JSONtoCSV is a Function +ok 330 — JSONtoCSV works with default delimiter +ok 331 — JSONtoCSV works with custom delimiter + +# PASS test/howManyTimes/howManyTimes.test.js + +ok 332 — howManyTimes is a Function + +# PASS test/pull/pull.test.js + +ok 333 — pull is a Function +ok 334 — Pulls the specified values + +# PASS test/initializeNDArray/initializeNDArray.test.js + +ok 335 — initializeNDArray is a Function + +# PASS test/sum/sum.test.js + +ok 336 — sum is a Function +ok 337 — Returns the sum of two or more numbers/arrays. + +# PASS test/serializeCookie/serializeCookie.test.js + +ok 338 — serializeCookie is a Function +ok 339 — Serializes the cookie + +# PASS test/detectDeviceType/detectDeviceType.test.js + +ok 340 — detectDeviceType is a Function + +# PASS test/nest/nest.test.js + +ok 341 — nest is a Function + +# PASS test/drop/drop.test.js + +ok 342 — drop is a Function +ok 343 — Works without the last argument +ok 344 — Removes appropriate element count as specified +ok 345 — Empties array given a count greater than length + +# PASS test/countVowels/countVowels.test.js + +ok 346 — countVowels is a Function + +# PASS test/pipeFunctions/pipeFunctions.test.js + +ok 347 — pipeFunctions is a Function +ok 348 — Performs left-to-right function composition + +# PASS test/isAbsoluteURL/isAbsoluteURL.test.js + +ok 349 — isAbsoluteURL is a Function +ok 350 — Given string is an absolute URL +ok 351 — Given string is an absolute URL +ok 352 — Given string is not an absolute URL + +# PASS test/call/call.test.js + +ok 353 — call is a Function +ok 354 — Calls function on given object + +# PASS test/objectFromPairs/objectFromPairs.test.js + +ok 355 — objectFromPairs is a Function +ok 356 — Creates an object from the given key-value pairs. + +# PASS test/httpGet/httpGet.test.js + +ok 357 — httpGet is a Function + +# PASS test/initializeArrayWithRange/initializeArrayWithRange.test.js + +ok 358 — initializeArrayWithRange is a Function +ok 359 — Initializes an array containing the numbers in the specified range (witout start value) +ok 360 — Initializes an array containing the numbers in the specified range +ok 361 — Initializes an array containing the numbers in the specified range (with step) + +# PASS test/castArray/castArray.test.js + +ok 362 — castArray is a Function +ok 363 — Works for single values +ok 364 — Works for arrays with one value +ok 365 — Works for arrays with multiple value +ok 366 — Works for strings +ok 367 — Works for objects + +# PASS test/compact/compact.test.js + +ok 368 — compact is a Function +ok 369 — Removes falsey values from an array + +# PASS test/hexToRGB/hexToRGB.test.js + +ok 370 — hexToRGB is a Function +ok 371 — Converts a color code to a rgb() or rgba() string +ok 372 — Converts a color code to a rgb() or rgba() string +ok 373 — Converts a color code to a rgb() or rgba() string + +# PASS test/truthCheckCollection/truthCheckCollection.test.js + +ok 374 — truthCheckCollection is a Function +ok 375 — second argument is truthy on all elements of a collection + +# PASS test/sampleSize/sampleSize.test.js + +ok 376 — sampleSize is a Function +ok 377 — Returns a single element without n specified +ok 378 — Returns a random sample of specified size from an array +ok 379 — Returns all elements in an array if n >= length +ok 380 — Returns an empty array if original array is empty +ok 381 — Returns an empty array if n = 0 + +# PASS test/nthArg/nthArg.test.js + +ok 382 — nthArg is a Function +ok 383 — Returns the nth argument +ok 384 — Returns undefined if arguments too few +ok 385 — Works for negative values + +# PASS test/sumBy/sumBy.test.js + +ok 386 — sumBy is a Function + +# PASS test/get/get.test.js + +ok 387 — get is a Function +ok 388 — Retrieve a property indicated by the selector from an object. + +# PASS test/getURLParameters/getURLParameters.test.js + +ok 389 — getURLParameters is a Function +ok 390 — Returns an object containing the parameters of the current URL + +# PASS test/promisify/promisify.test.js + +ok 391 — promisify is a Function +ok 392 — Returns a promise +ok 393 — Runs the function provided + +# PASS test/none/none.test.js + +ok 394 — none is a Function +ok 395 — Returns true for arrays with no truthy values +ok 396 — Returns false for arrays with at least one truthy value +ok 397 — Returns true with a predicate function +ok 398 — Returns false with predicate function + +# PASS test/tail/tail.test.js + +ok 399 — tail is a Function +ok 400 — Returns tail +ok 401 — Returns tail + +# PASS test/JSONToDate/JSONToDate.test.js + +ok 402 — JSONToDate is a Function + +# PASS test/isBrowser/isBrowser.test.js + +ok 403 — isBrowser is a Function + +# PASS test/transform/transform.test.js + +ok 404 — transform is a Function +ok 405 — Transforms an object + +# PASS test/omit/omit.test.js + +ok 406 — omit is a Function +ok 407 — Omits the key-value pairs corresponding to the given keys from an object + +# PASS test/takeWhile/takeWhile.test.js + +ok 408 — takeWhile is a Function +ok 409 — Removes elements until the function returns true + +# PASS test/triggerEvent/triggerEvent.test.js + +ok 410 — triggerEvent is a Function + +# PASS test/hasFlags/hasFlags.test.js + +ok 411 — hasFlags is a Function + +# PASS test/randomNumberInRange/randomNumberInRange.test.js + +ok 412 — randomNumberInRange is a Function +ok 413 — The returned value is a number +ok 414 — The returned value lies between provided lowerLimit and upperLimit (both inclusive). + +# PASS test/reduceWhich/reduceWhich.test.js + +ok 415 — reduceWhich is a Function +ok 416 — Returns the minimum of an array +ok 417 — Returns the maximum of an array +ok 418 — Returns the object with the minimum specified value in an array + +# PASS test/show/show.test.js + +ok 419 — show is a Function + +# PASS test/intersectionWith/intersectionWith.test.js + +ok 420 — intersectionWith is a Function +ok 421 — Returns a list of elements that exist in both arrays, using a provided comparator function + +# PASS test/mapString/mapString.test.js + +ok 422 — mapString is a Function +ok 423 — mapString returns a capitalized string +ok 424 — mapString can deal with indexes +ok 425 — mapString can deal with the full string + +# PASS test/differenceBy/differenceBy.test.js + +ok 426 — differenceBy is a Function +ok 427 — Works using a native function and numbers +ok 428 — Works with arrow function and objects + +# PASS test/on/on.test.js + +ok 429 — on is a Function + +# PASS test/isArrayBuffer/isArrayBuffer.test.js + +ok 430 — isArrayBuffer is a Function + +# PASS test/randomIntegerInRange/randomIntegerInRange.test.js + +ok 431 — randomIntegerInRange is a Function +ok 432 — The returned value is an integer +ok 433 — The returned value lies between provided lowerLimit and upperLimit (both inclusive). + +# PASS test/sample/sample.test.js + +ok 434 — sample is a Function +ok 435 — Returns a random element from the array +ok 436 — Works for single-element arrays +ok 437 — Returns undefined for empty array + +# PASS test/isObject/isObject.test.js + +ok 438 — isObject is a Function +ok 439 — isObject([1, 2, 3, 4]) is a object +ok 440 — isObject([]) is a object +ok 441 — isObject({ a:1 }) is a object +ok 442 — isObject(true) is not a object + +# PASS test/lowercaseKeys/lowercaseKeys.test.js + +ok 443 — lowercaseKeys is a Function +ok 444 — Lowercases object keys +ok 445 — Does not mutate original object + +# PASS test/over/over.test.js + +ok 446 — over is a Function +ok 447 — Applies given functions over multiple arguments + +# PASS test/filterNonUnique/filterNonUnique.test.js + +ok 448 — filterNonUnique is a Function +ok 449 — Filters out the non-unique values in an array + +# PASS test/randomHexColorCode/randomHexColorCode.test.js + +ok 450 — randomHexColorCode is a Function +ok 451 — randomHexColorCode has to proper length +ok 452 — The color code starts with "#" +ok 453 — The color code contains only valid hex-digits + +# PASS test/URLJoin/URLJoin.test.js + +ok 454 — URLJoin is a Function +ok 455 — Returns proper URL +ok 456 — Returns proper URL + +# PASS test/primes/primes.test.js + +ok 457 — primes is a Function +ok 458 — Generates primes up to a given number, using the Sieve of Eratosthenes. + +# PASS test/mapValues/mapValues.test.js + +ok 459 — mapValues is a Function +ok 460 — Maps values + +# PASS test/permutations/permutations.test.js + +ok 461 — permutations is a Function +ok 462 — Generates all permutations of an array + +# PASS test/standardDeviation/standardDeviation.test.js + +ok 463 — standardDeviation is a Function +ok 464 — Returns the standard deviation of an array of numbers +ok 465 — Returns the standard deviation of an array of numbers + +# PASS test/currentURL/currentURL.test.js + +ok 466 — currentURL is a Function + +# PASS test/isEven/isEven.test.js + +ok 467 — isEven is a Function +ok 468 — 4 is even number +ok 469 — 5 is not an even number + +# PASS test/forOwn/forOwn.test.js + +ok 470 — forOwn is a Function +ok 471 — Iterates over an element's key-value pairs + +# PASS test/composeRight/composeRight.test.js + +ok 472 — composeRight is a Function +ok 473 — Performs left-to-right function composition + +# PASS test/shuffle/shuffle.test.js + +ok 474 — shuffle is a Function +ok 475 — Shuffles the array +ok 476 — New array contains all original elements +ok 477 — Works for empty arrays +ok 478 — Works for single-element arrays + +# PASS test/elementIsVisibleInViewport/elementIsVisibleInViewport.test.js + +ok 479 — elementIsVisibleInViewport is a Function + +# PASS test/isFunction/isFunction.test.js + +ok 480 — isFunction is a Function +ok 481 — passed value is a function +ok 482 — passed value is not a function + +# PASS test/JSONToFile/JSONToFile.test.js + +ok 483 — JSONToFile is a Function + +# PASS test/hasClass/hasClass.test.js + +ok 484 — hasClass is a Function + +# PASS test/deepFreeze/deepFreeze.test.js + +ok 485 — deepFreeze is a Function + +# PASS test/geometricProgression/geometricProgression.test.js + +ok 486 — geometricProgression is a Function +ok 487 — Initializes an array containing the numbers in the specified range +ok 488 — Initializes an array containing the numbers in the specified range +ok 489 — Initializes an array containing the numbers in the specified range + +# PASS test/deepFlatten/deepFlatten.test.js + +ok 490 — deepFlatten is a Function +ok 491 — Deep flattens an array + +# PASS test/sortedLastIndex/sortedLastIndex.test.js + +ok 492 — sortedLastIndex is a Function +ok 493 — Returns the highest index to insert the element without messing up the list order + +# PASS test/reduceSuccessive/reduceSuccessive.test.js + +ok 494 — reduceSuccessive is a Function +ok 495 — Returns the array of successively reduced values + +# PASS test/httpsRedirect/httpsRedirect.test.js + +ok 496 — httpsRedirect is a Function + +# PASS test/lcm/lcm.test.js + +ok 497 — lcm is a Function +ok 498 — Returns the least common multiple of two or more numbers. +ok 499 — Returns the least common multiple of two or more numbers. + +# PASS test/btoa/btoa.test.js + +ok 500 — btoa is a Function +ok 501 — btoa("foobar") equals "Zm9vYmFy" + +# PASS test/unionWith/unionWith.test.js + +ok 502 — unionWith is a Function +ok 503 — Produces the appropriate results + +# PASS test/httpDelete/httpDelete.test.js + +ok 504 — httpDelete is a Function + +# PASS test/partialRight/partialRight.test.js + +ok 505 — partialRight is a Function +ok 506 — Appends arguments + +# PASS test/unfold/unfold.test.js + +ok 507 — unfold is a Function +ok 508 — Works with a given function, producing an array + +# PASS test/unzipWith/unzipWith.test.js + +ok 509 — unzipWith is a Function +ok 510 — unzipWith([[1, 10, 100], [2, 20, 200]], (...args) => args.reduce((acc, v) => acc + v, 0)) equals [3, 30, 300] + +# PASS test/fibonacciCountUntilNum/fibonacciCountUntilNum.test.js + +ok 511 — fibonacciCountUntilNum is a Function + +# PASS test/symmetricDifferenceBy/symmetricDifferenceBy.test.js + +ok 512 — symmetricDifferenceBy is a Function +ok 513 — Returns the symmetric difference between two arrays, after applying the provided function to each array element of both + +# PASS test/stableSort/stableSort.test.js + +ok 514 — stableSort is a Function +ok 515 — Array is properly sorted + +# PASS test/onUserInputChange/onUserInputChange.test.js + +ok 516 — onUserInputChange is a Function + +# PASS test/flip/flip.test.js + +ok 517 — flip is a Function +ok 518 — Flips argument order + +# PASS test/binomialCoefficient/binomialCoefficient.test.js + +ok 519 — binomialCoefficient is a Function +ok 520 — Returns the appropriate value +ok 521 — Returns the appropriate value +ok 522 — Returns the appropriate value +ok 523 — Returns NaN +ok 524 — Returns NaN + +# PASS test/off/off.test.js + +ok 525 — off is a Function + +# PASS test/collatz/collatz.test.js + +ok 526 — collatz is a Function +ok 527 — When n is even, divide by 2 +ok 528 — When n is odd, times by 3 and add 1 +ok 529 — Eventually reaches 1 + +# PASS test/memoize/memoize.test.js + +ok 530 — memoize is a Function +ok 531 — Function works properly +ok 532 — Function works properly +ok 533 — Cache stores values + +# PASS test/isBrowserTabFocused/isBrowserTabFocused.test.js + +ok 534 — isBrowserTabFocused is a Function + +# PASS test/isAnagram/isAnagram.test.js + +ok 535 — isAnagram is a Function +ok 536 — Checks valid anagram +ok 537 — Works with spaces +ok 538 — Ignores case +ok 539 — Ignores special characters + +# PASS test/fibonacciUntilNum/fibonacciUntilNum.test.js + +ok 540 — fibonacciUntilNum is a Function + +# PASS test/inRange/inRange.test.js + +ok 541 — inRange is a Function +ok 542 — The given number falls within the given range +ok 543 — The given number falls within the given range +ok 544 — The given number does not falls within the given range +ok 545 — The given number does not falls within the given range + +# PASS test/unzip/unzip.test.js + +ok 546 — unzip is a Function +ok 547 — unzip([['a', 1, true], ['b', 2, false]]) equals [['a','b'], [1, 2], [true, false]] +ok 548 — unzip([['a', 1, true], ['b', 2]]) equals [['a','b'], [1, 2], [true]] + +# PASS test/dropRightWhile/dropRightWhile.test.js + +ok 549 — dropRightWhile is a Function +ok 550 — Removes elements from the end of an array until the passed function returns true. + +# PASS test/flattenObject/flattenObject.test.js + +ok 551 — flattenObject is a Function +ok 552 — Flattens an object with the paths for keys +ok 553 — Works with arrays + +# PASS test/isValidJSON/isValidJSON.test.js + +ok 554 — isValidJSON is a Function +ok 555 — {"name":"Adam","age":20} is a valid JSON +ok 556 — {"name":"Adam",age:"20"} is not a valid JSON +ok 557 — null is a valid JSON + +# PASS test/converge/converge.test.js + +ok 558 — converge is a Function +ok 559 — Produces the average of the array +ok 560 — Produces the strange concatenation + +# PASS test/attempt/attempt.test.js + +ok 561 — attempt is a Function +ok 562 — Returns a value +ok 563 — Returns an error + +# PASS test/symmetricDifference/symmetricDifference.test.js + +ok 564 — symmetricDifference is a Function +ok 565 — Returns the symmetric difference between two arrays. +ok 566 — Returns duplicates from one array + +# PASS test/removeVowels/removeVowels.test.js + +ok 567 — removeVowels is a Function + +# PASS test/parseCookie/parseCookie.test.js + +ok 568 — parseCookie is a Function +ok 569 — Parses the cookie + +# PASS test/recordAnimationFrames/recordAnimationFrames.test.js + +ok 570 — recordAnimationFrames is a Function + +# PASS test/createElement/createElement.test.js + +ok 571 — createElement is a Function + +# PASS test/pullAtValue/pullAtValue.test.js + +ok 572 — pullAtValue is a Function +ok 573 — Pulls the specified values +ok 574 — Pulls the specified values + +# PASS test/isObjectLike/isObjectLike.test.js + +ok 575 — isObjectLike is a Function +ok 576 — Returns true for an object +ok 577 — Returns true for an array +ok 578 — Returns false for a function +ok 579 — Returns false for null + +# PASS test/distance/distance.test.js + +ok 580 — distance is a Function +ok 581 — Calculates the distance between two points + +# PASS test/insertBefore/insertBefore.test.js + +ok 582 — insertBefore is a Function + +# PASS test/reducedFilter/reducedFilter.test.js + +ok 583 — reducedFilter is a Function +ok 584 — Filter an array of objects based on a condition while also filtering out unspecified keys. + +# PASS test/bind/bind.test.js + +ok 585 — bind is a Function +ok 586 — Binds to an object context + +# PASS test/bindKey/bindKey.test.js + +ok 587 — bindKey is a Function +ok 588 — Binds function to an object context + +# PASS test/intersection/intersection.test.js + +ok 589 — intersection is a Function +ok 590 — Returns a list of elements that exist in both arrays + +# PASS test/pipeAsyncFunctions/pipeAsyncFunctions.test.js + +ok 591 — pipeAsyncFunctions is a Function +ok 592 — pipeAsyncFunctions result should be 15 + +# PASS test/findLastIndex/findLastIndex.test.js + +ok 593 — findLastIndex is a Function +ok 594 — Finds last index for which the given function returns true + +# PASS test/intersectionBy/intersectionBy.test.js + +ok 595 — intersectionBy is a Function +ok 596 — Returns a list of elements that exist in both arrays, after applying the provided function to each array element of both + +# PASS test/isSet/isSet.test.js + +ok 597 — isSet is a Function + +# PASS test/reverseString/reverseString.test.js + +ok 598 — reverseString is a Function +ok 599 — Reverses a string. + +# PASS test/capitalizeEveryWord/capitalizeEveryWord.test.js + +ok 600 — capitalizeEveryWord is a Function +ok 601 — Capitalizes the first letter of every word in a string +ok 602 — Works with characters +ok 603 — Works with one word string + +# PASS test/bifurcateBy/bifurcateBy.test.js + +ok 604 — bifurcateBy is a Function +ok 605 — Splits the collection into two groups + +# PASS test/invertKeyValues/invertKeyValues.test.js + +ok 606 — invertKeyValues is a Function +ok 607 — invertKeyValues({ a: 1, b: 2, c: 1 }) returns { 1: [ 'a', 'c' ], 2: [ 'b' ] } +ok 608 — invertKeyValues({ a: 1, b: 2, c: 1 }, value => 'group' + value) returns { group1: [ 'a', 'c' ], group2: [ 'b' ] } + +# PASS test/rearg/rearg.test.js + +ok 609 — rearg is a Function +ok 610 — Reorders arguments in invoked function + +# PASS test/fromCamelCase/fromCamelCase.test.js + +ok 611 — fromCamelCase is a Function +ok 612 — Converts a string from camelcase +ok 613 — Converts a string from camelcase +ok 614 — Converts a string from camelcase + +# PASS test/isPromiseLike/isPromiseLike.test.js + +ok 615 — isPromiseLike is a Function +ok 616 — Returns true for a promise-like object +ok 617 — Returns false for an empty object + +# PASS test/pullBy/pullBy.test.js + +ok 618 — pullBy is a Function +ok 619 — Pulls the specified values + +# PASS test/stringPermutations/stringPermutations.test.js + +ok 620 — stringPermutations is a Function +ok 621 — Generates all stringPermutations of a string +ok 622 — Works for single-letter strings +ok 623 — Works for empty strings + +# PASS test/dropRight/dropRight.test.js + +ok 624 — dropRight is a Function +ok 625 — Returns a new array with n elements removed from the right +ok 626 — Returns a new array with n elements removed from the right +ok 627 — Returns a new array with n elements removed from the right + +# PASS test/extendHex/extendHex.test.js + +ok 628 — extendHex is a Function +ok 629 — Extends a 3-digit color code to a 6-digit color code +ok 630 — Extends a 3-digit color code to a 6-digit color code + +# PASS test/initial/initial.test.js + +ok 631 — initial is a Function +ok 632 — Returns all the elements of an array except the last one + +# PASS test/getColonTimeFromDate/getColonTimeFromDate.test.js + +ok 633 — getColonTimeFromDate is a Function + +# PASS test/httpPut/httpPut.test.js + +ok 634 — httpPut is a Function + +# PASS test/isSymbol/isSymbol.test.js + +ok 635 — isSymbol is a Function +ok 636 — Checks if the given argument is a symbol + +# PASS test/isArmstrongNumber/isArmstrongNumber.test.js + +ok 637 — isArmstrongNumber is a Function + +# PASS test/uncurry/uncurry.test.js + +ok 638 — uncurry is a Function +ok 639 — Works without a provided value for n +ok 640 — Works with n = 2 +ok 641 — Works with n = 3 + +# PASS test/luhnCheck/luhnCheck.test.js + +ok 642 — luhnCheck is a Function +ok 643 — validates identification number +ok 644 — validates identification number +ok 645 — validates identification number + +# PASS test/unary/unary.test.js + +ok 646 — unary is a Function +ok 647 — Discards arguments after the first one + +# PASS test/sortedIndexBy/sortedIndexBy.test.js + +ok 648 — sortedIndexBy is a Function +ok 649 — Returns the lowest index to insert the element without messing up the list order + +# PASS test/pickBy/pickBy.test.js + +ok 650 — pickBy is a Function +ok 651 — Creates an object composed of the properties the given function returns truthy for. + +# PASS test/approximatelyEqual/approximatelyEqual.test.js + +ok 652 — approximatelyEqual is a Function +ok 653 — Works for PI / 2 +ok 654 — Works for 0.1 + 0.2 === 0.3 +ok 655 — Works for exactly equal values +ok 656 — Works for a custom epsilon + +# PASS test/escapeHTML/escapeHTML.test.js + +ok 657 — escapeHTML is a Function +ok 658 — Escapes a string for use in HTML + +# PASS test/findLast/findLast.test.js + +ok 659 — findLast is a Function +ok 660 — Finds last element for which the given function returns true + +# PASS test/elementContains/elementContains.test.js + +ok 661 — elementContains is a Function + +# PASS test/getStyle/getStyle.test.js + +ok 662 — getStyle is a Function + +# PASS test/arrayToCSV/arrayToCSV.test.js + +ok 663 — arrayToCSV is a Function +ok 664 — arrayToCSV works with default delimiter +ok 665 — arrayToCSV works with custom delimiter + +# PASS test/isArrayLike/isArrayLike.test.js + +ok 666 — isArrayLike is a Function +ok 667 — Returns true for a string +ok 668 — Returns true for an array +ok 669 — Returns false for null + +# PASS test/stripHTMLTags/stripHTMLTags.test.js + +ok 670 — stripHTMLTags is a Function +ok 671 — Removes HTML tags + +# PASS test/getMeridiemSuffixOfInteger/getMeridiemSuffixOfInteger.test.js + +ok 672 — getMeridiemSuffixOfInteger is a Function + +# PASS test/maxN/maxN.test.js + +ok 673 — maxN is a Function +ok 674 — Returns the n maximum elements from the provided array +ok 675 — Returns the n maximum elements from the provided array + +# PASS test/bottomVisible/bottomVisible.test.js + +ok 676 — bottomVisible is a Function + +# PASS test/hashBrowser/hashBrowser.test.js + +ok 677 — hashBrowser is a Function + +# PASS test/smoothScroll/smoothScroll.test.js + +ok 678 — smoothScroll is a Function + +# PASS test/getDaysDiffBetweenDates/getDaysDiffBetweenDates.test.js + +ok 679 — getDaysDiffBetweenDates is a Function +ok 680 — Returns the difference in days between two dates + +# PASS test/sortCharactersInString/sortCharactersInString.test.js + +ok 681 — sortCharactersInString is a Function +ok 682 — Alphabetically sorts the characters in a string. + +# PASS test/bindAll/bindAll.test.js + +ok 683 — bindAll is a Function +ok 684 — Binds to an object context + +# PASS test/difference/difference.test.js + +ok 685 — difference is a Function +ok 686 — Returns the difference between two arrays + +# PASS test/debounce/debounce.test.js + +ok 687 — debounce is a Function +ok 688 — Works as expected + +# PASS test/indexOfAll/indexOfAll.test.js + +ok 689 — indexOfAll is a Function +ok 690 — Returns all indices of val in an array +ok 691 — Returns all indices of val in an array + +# PASS test/pullAtIndex/pullAtIndex.test.js + +ok 692 — pullAtIndex is a Function +ok 693 — Pulls the given values +ok 694 — Pulls the given values + +# PASS test/minN/minN.test.js + +ok 695 — minN is a Function +ok 696 — Returns the n minimum elements from the provided array +ok 697 — Returns the n minimum elements from the provided array + +# PASS test/remove/remove.test.js + +ok 698 — remove is a Function +ok 699 — Removes elements from an array for which the given function returns false + +# PASS test/curry/curry.test.js + +ok 700 — curry is a Function +ok 701 — curries a Math.pow +ok 702 — curries a Math.min + +# PASS test/UUIDGeneratorBrowser/UUIDGeneratorBrowser.test.js + +ok 703 — UUIDGeneratorBrowser is a Function + +# PASS test/getScrollPosition/getScrollPosition.test.js + +ok 704 — getScrollPosition is a Function + +# PASS test/cloneRegExp/cloneRegExp.test.js + +ok 705 — cloneRegExp is a Function +ok 706 — Clones regular expressions properly + +# PASS test/mask/mask.test.js + +ok 707 — mask is a Function +ok 708 — Replaces all but the last num of characters with the specified mask character +ok 709 — Replaces all but the last num of characters with the specified mask character +ok 710 — Replaces all but the last num of characters with the specified mask character + +# PASS test/partition/partition.test.js + +ok 711 — partition is a Function +ok 712 — Groups the elements into two arrays, depending on the provided function's truthiness for each element. + +# PASS test/flatten/flatten.test.js + +ok 713 — flatten is a Function +ok 714 — Flattens an array +ok 715 — Flattens an array + +# PASS test/RGBToHex/RGBToHex.test.js + +ok 716 — RGBToHex is a Function +ok 717 — Converts the values of RGB components to a color code. + +# PASS test/hammingDistance/hammingDistance.test.js + +ok 718 — hammingDistance is a Function +ok 719 — retuns hamming disance between 2 values + +# PASS test/isPrime/isPrime.test.js + +ok 720 — isPrime is a Function +ok 721 — passed number is a prime + +# PASS test/defer/defer.test.js + +ok 722 — defer is a Function + +# PASS test/collectInto/collectInto.test.js + +ok 723 — collectInto is a Function +ok 724 — Works with multiple promises + +# PASS test/findLastKey/findLastKey.test.js + +ok 725 — findLastKey is a Function +ok 726 — eturns the appropriate key + +# PASS test/nthElement/nthElement.test.js + +ok 727 — nthElement is a Function +ok 728 — Returns the nth element of an array. +ok 729 — Returns the nth element of an array. + +# PASS test/everyNth/everyNth.test.js + +ok 730 — everyNth is a Function +ok 731 — Returns every nth element in an array + +# PASS test/CSVToJSON/CSVToJSON.test.js + +ok 732 — CSVToJSON is a Function +ok 733 — CSVToJSON works with default delimiter +ok 734 — CSVToJSON works with custom delimiter + +# PASS test/colorize/colorize.test.js + +ok 735 — colorize is a Function + +# PASS test/mostPerformant/mostPerformant.test.js + +ok 736 — mostPerformant is a Function + +# PASS test/untildify/untildify.test.js + +ok 737 — untildify is a Function +ok 738 — Contains no tildes +ok 739 — Does not alter the rest of the path +ok 740 — Does not alter paths without tildes + +# PASS test/partial/partial.test.js + +ok 741 — partial is a Function +ok 742 — Prepends arguments + +# PASS test/join/join.test.js + +ok 743 — join is a Function +ok 744 — Joins all elements of an array into a string and returns this string +ok 745 — Joins all elements of an array into a string and returns this string +ok 746 — Joins all elements of an array into a string and returns this string + +# PASS test/elo/elo.test.js + +ok 747 — elo is a Function +ok 748 — Standard 1v1s +ok 749 — Standard 1v1s +ok 750 — 4 player FFA, all same rank + +# PASS test/forOwnRight/forOwnRight.test.js + +ok 751 — forOwnRight is a Function +ok 752 — Iterates over an element's key-value pairs in reverse + +# PASS test/removeNonASCII/removeNonASCII.test.js + +ok 753 — removeNonASCII is a Function +ok 754 — Removes non-ASCII characters + +# PASS test/functions/functions.test.js + +ok 755 — functions is a Function +ok 756 — Returns own methods +ok 757 — Returns own and inherited methods + +# PASS test/omitBy/omitBy.test.js + +ok 758 — omitBy is a Function +ok 759 — Creates an object composed of the properties the given function returns falsey for + +# PASS test/median/median.test.js + +ok 760 — median is a Function +ok 761 — Returns the median of an array of numbers +ok 762 — Returns the median of an array of numbers + +# PASS test/negate/negate.test.js + +ok 763 — negate is a Function +ok 764 — Negates a predicate function + +# PASS test/redirect/redirect.test.js + +ok 765 — redirect is a Function + +# PASS test/toDecimalMark/toDecimalMark.test.js + +ok 766 — toDecimalMark is a Function +ok 767 — convert a float-point arithmetic to the Decimal mark form + +# PASS test/levenshteinDistance/levenshteinDistance.test.js + +ok 768 — levenshteinDistance is a Function + +# PASS test/escapeRegExp/escapeRegExp.test.js + +ok 769 — escapeRegExp is a Function +ok 770 — Escapes a string to use in a regular expression + +# PASS test/digitize/digitize.test.js + +ok 771 — digitize is a Function +ok 772 — Converts a number to an array of digits + +# PASS test/initialize2DArray/initialize2DArray.test.js + +ok 773 — initialize2DArray is a Function +ok 774 — Initializes a 2D array of given width and height and value + +# PASS test/readFileLines/readFileLines.test.js + +ok 775 — readFileLines is a Function + +# PASS test/isDivisible/isDivisible.test.js + +ok 776 — isDivisible is a Function +ok 777 — The number 6 is divisible by 3 + +# PASS test/httpPost/httpPost.test.js + +ok 778 — httpPost is a Function + +# PASS test/bifurcate/bifurcate.test.js + +ok 779 — bifurcate is a Function +ok 780 — Splits the collection into two groups + +# PASS test/speechSynthesis/speechSynthesis.test.js + +ok 781 — speechSynthesis is a Function + +# PASS test/isArray/isArray.test.js + +ok 782 — isArray is a Function +ok 783 — passed value is an array +ok 784 — passed value is not an array + +# PASS test/toggleClass/toggleClass.test.js + +ok 785 — toggleClass is a Function + +# PASS test/minBy/minBy.test.js + +ok 786 — minBy is a Function +ok 787 — Produces the right result with a function +ok 788 — Produces the right result with a property name + +# PASS test/arrayToHtmlList/arrayToHtmlList.test.js + +ok 789 — arrayToHtmlList is a Function + +# PASS test/coalesceFactory/coalesceFactory.test.js + +ok 790 — coalesceFactory is a Function +ok 791 — Returns a customized coalesce function + +# PASS test/hz/hz.test.js + +ok 792 — hz is a Function + +# PASS test/isTypedArray/isTypedArray.test.js + +ok 793 — isTypedArray is a Function + +# PASS test/truncateString/truncateString.test.js + +ok 794 — truncateString is a Function +ok 795 — Truncates a "boomerang" up to a specified length. + +# PASS test/dropWhile/dropWhile.test.js + +ok 796 — dropWhile is a Function +ok 797 — Removes elements in an array until the passed function returns true. + +# PASS test/xProd/xProd.test.js + +ok 798 — xProd is a Function +ok 799 — xProd([1, 2], ['a', 'b']) returns [[1, 'a'], [1, 'b'], [2, 'a'], [2, 'b']] + +# PASS test/size/size.test.js + +ok 800 — size is a Function +ok 801 — Get size of arrays, objects or strings. +ok 802 — Get size of arrays, objects or strings. + +# PASS test/isLowerCase/isLowerCase.test.js + +ok 803 — isLowerCase is a Function +ok 804 — passed string is a lowercase +ok 805 — passed string is a lowercase +ok 806 — passed value is not a lowercase + +# PASS test/isNull/isNull.test.js + +ok 807 — isNull is a Function +ok 808 — passed argument is a null +ok 809 — passed argument is a null + +# PASS test/scrollToTop/scrollToTop.test.js + +ok 810 — scrollToTop is a Function # PASS test/isSorted/isSorted.test.js -ok 165 — isSorted is a Function -ok 166 — Array is sorted in ascending order -ok 167 — Array is sorted in ascending order -ok 168 — Array is sorted in ascending order -ok 169 — Array is sorted in ascending order -ok 170 — Array is sorted in descending order -ok 171 — Array is sorted in descending order -ok 172 — Array is sorted in descending order -ok 173 — Array is sorted in descending order -ok 174 — Array is empty -ok 175 — Array is not sorted, direction changed in array -ok 176 — Array is not sorted, direction changed in array +ok 811 — isSorted is a Function +ok 812 — Array is sorted in ascending order +ok 813 — Array is sorted in ascending order +ok 814 — Array is sorted in ascending order +ok 815 — Array is sorted in ascending order +ok 816 — Array is sorted in descending order +ok 817 — Array is sorted in descending order +ok 818 — Array is sorted in descending order +ok 819 — Array is sorted in descending order +ok 820 — Array is empty +ok 821 — Array is not sorted, direction changed in array +ok 822 — Array is not sorted, direction changed in array -# PASS test/words/words.test.js +# PASS test/findKey/findKey.test.js -ok 177 — words is a Function -ok 178 — words('I love javaScript!!') returns [I, love, javaScript] -ok 179 — words('python, javaScript & coffee') returns [python, javaScript, coffee] -ok 180 — words(I love javaScript!!) returns an array -ok 181 — words() throws an error -ok 182 — words(null) throws an error -ok 183 — words(undefined) throws an error -ok 184 — words({}) throws an error -ok 185 — words([]) throws an error -ok 186 — words(1234) throws an error +ok 823 — findKey is a Function +ok 824 — Returns the appropriate key -# PASS test/longestItem/longestItem.test.js +# PASS test/delay/delay.test.js -ok 187 — longestItem is a Function -ok 188 — Returns the longest object from plain values -ok 189 — Returns the longest object from a spread array -ok 190 — Returns the longest object from mixed input -ok 191 — Returns the longest array -ok 192 — Returns the longest object when comparing arrays and strings -ok 193 — Returns undefined without any input -ok 194 — Returns first found of all similar -ok 195 — Throws TypeError if all inputs are undefined +ok 825 — delay is a Function +ok 826 — Works as expecting, passing arguments properly + +# PASS test/insertAfter/insertAfter.test.js + +ok 827 — insertAfter is a Function + +# PASS test/differenceWith/differenceWith.test.js + +ok 828 — differenceWith is a Function +ok 829 — Filters out all values from an array + +# PASS test/pick/pick.test.js + +ok 830 — pick is a Function +ok 831 — Picks the key-value pairs corresponding to the given keys from an object. + +# PASS test/unionBy/unionBy.test.js + +ok 832 — unionBy is a Function +ok 833 — Produces the appropriate results + +# PASS test/palindrome/palindrome.test.js + +ok 834 — palindrome is a Function +ok 835 — Given string is a palindrome +ok 836 — Given string is not a palindrome + +# PASS test/isUndefined/isUndefined.test.js + +ok 837 — isUndefined is a Function +ok 838 — Returns true for undefined + +# PASS test/isBoolean/isBoolean.test.js + +ok 839 — isBoolean is a Function +ok 840 — passed value is not a boolean +ok 841 — passed value is not a boolean + +# PASS test/objectToPairs/objectToPairs.test.js + +ok 842 — objectToPairs is a Function +ok 843 — Creates an array of key-value pair arrays from an object. + +# PASS test/merge/merge.test.js + +ok 844 — merge is a Function +ok 845 — Merges two objects + +# PASS test/clampNumber/clampNumber.test.js + +ok 846 — clampNumber is a Function +ok 847 — Clamps num within the inclusive range specified by the boundary values a and b + +# PASS test/isString/isString.test.js + +ok 848 — isString is a Function +ok 849 — foo is a string +ok 850 — "10" is a string +ok 851 — Empty string is a string +ok 852 — 10 is not a string +ok 853 — true is not string + +# PASS test/round/round.test.js + +ok 854 — round is a Function +ok 855 — round(1.005, 2) returns 1.01 +ok 856 — round(123.3423345345345345344, 11) returns 123.34233453453 +ok 857 — round(3.342, 11) returns 3.342 +ok 858 — round(1.005) returns 1 +ok 859 — round([1.005, 2]) returns NaN +ok 860 — round(string) returns NaN +ok 861 — round() returns NaN +ok 862 — round(132, 413, 4134) returns NaN +ok 863 — round({a: 132}, 413) returns NaN +ok 864 — round(123.3423345345345345344, 11) takes less than 2s to run + +# PASS test/isUpperCase/isUpperCase.test.js + +ok 865 — isUpperCase is a Function +ok 866 — ABC is all upper case +ok 867 — abc is not all upper case +ok 868 — A3@$ is all uppercase + +# PASS test/zipObject/zipObject.test.js + +ok 869 — zipObject is a Function +ok 870 — zipObject([a, b, c], [1, 2]) returns {a: 1, b: 2, c: undefined} +ok 871 — zipObject([a, b], [1, 2, 3]) returns {a: 1, b: 2} +ok 872 — zipObject([a, b, c], string) returns { a: s, b: t, c: r } +ok 873 — zipObject([a], string) returns { a: s } +ok 874 — zipObject() throws an error +ok 875 — zipObject((['string'], null) throws an error +ok 876 — zipObject(null, [1]) throws an error +ok 877 — zipObject('string') throws an error +ok 878 — zipObject('test', 'string') throws an error + +# PASS test/average/average.test.js + +ok 879 — average is a Function +ok 880 — average(true) returns 0 +ok 881 — average(false) returns 1 +ok 882 — average(9, 1) returns 5 +ok 883 — average(153, 44, 55, 64, 71, 1122, 322774, 2232, 23423, 234, 3631) returns 32163.909090909092 +ok 884 — average(1, 2, 3) returns 2 +ok 885 — average(null) returns 0 +ok 886 — average(1, 2, 3) returns NaN +ok 887 — average(String) returns NaN +ok 888 — average({ a: 123}) returns NaN +ok 889 — average([undefined, 0, string]) returns NaN +ok 890 — average([1, 2, 3, 4, 5, 6, 7, 8, 9, 11, 1122, 32124, 23232]) takes less than 2s to run + +# PASS test/isPrimitive/isPrimitive.test.js + +ok 891 — isPrimitive is a Function +ok 892 — isPrimitive(null) is primitive +ok 893 — isPrimitive(undefined) is primitive +ok 894 — isPrimitive(string) is primitive +ok 895 — isPrimitive(true) is primitive +ok 896 — isPrimitive(50) is primitive +ok 897 — isPrimitive('Hello') is primitive +ok 898 — isPrimitive(false) is primitive +ok 899 — isPrimitive(Symbol()) is primitive +ok 900 — isPrimitive([1, 2, 3]) is not primitive +ok 901 — isPrimitive({ a: 123 }) is not primitive +ok 902 — isPrimitive({ a: 123 }) takes less than 2s to run + +# PASS test/yesNo/yesNo.test.js + +ok 903 — yesNo is a Function +ok 904 — yesNo(Y) returns true +ok 905 — yesNo(yes) returns true +ok 906 — yesNo(foo, true) returns true +ok 907 — yesNo(No) returns false +ok 908 — yesNo() returns false +ok 909 — yesNo(null) returns false +ok 910 — yesNo(undefined) returns false +ok 911 — yesNo([123, null]) returns false +ok 912 — yesNo([Yes, No]) returns false +ok 913 — yesNo({ 2: Yes }) returns false +ok 914 — yesNo([Yes, No], true) returns true +ok 915 — yesNo({ 2: Yes }, true) returns true + +# PASS test/uniqueElementsByRight/uniqueElementsByRight.test.js + +ok 916 — uniqueElementsByRight is a Function +ok 917 — uniqueElementsByRight works for properties +ok 918 — uniqueElementsByRight works for nested properties + +# PASS test/is/is.test.js + +ok 919 — is is a Function +ok 920 — Works for arrays with data +ok 921 — Works for empty arrays +ok 922 — Works for arrays, not objects +ok 923 — Works for objects +ok 924 — Works for maps +ok 925 — Works for regular expressions +ok 926 — Works for sets +ok 927 — Works for weak maps +ok 928 — Works for weak sets +ok 929 — Works for strings - returns true for primitive +ok 930 — Works for strings - returns true when using constructor +ok 931 — Works for numbers - returns true for primitive +ok 932 — Works for numbers - returns true when using constructor +ok 933 — Works for booleans - returns true for primitive +ok 934 — Works for booleans - returns true when using constructor +ok 935 — Works for functions + +# PASS test/quickSort/quickSort.test.js + +ok 936 — quickSort is a Function +ok 937 — quickSort([5, 6, 4, 3, 1, 2]) returns [1, 2, 3, 4, 5, 6] +ok 938 — quickSort([-1, 0, -2]) returns [-2, -1, 0] +ok 939 — quickSort() throws an error +ok 940 — quickSort(123) throws an error +ok 941 — quickSort({ 234: string}) throws an error +ok 942 — quickSort(null) throws an error +ok 943 — quickSort(undefined) throws an error +ok 944 — quickSort([11, 1, 324, 23232, -1, 53, 2, 524, 32, 13, 156, 133, 62, 12, 4]) takes less than 2s to run # PASS test/without/without.test.js -ok 196 — without is a Function -ok 197 — without([2, 1, 2, 3], 1, 2) returns [3] -ok 198 — without([]) returns [] -ok 199 — without([3, 1, true, '3', true], '3', true) returns [3, 1] -ok 200 — without('string'.split(''), 's', 't', 'g') returns ['r', 'i', 'n'] -ok 201 — without() throws an error -ok 202 — without(null) throws an error -ok 203 — without(undefined) throws an error -ok 204 — without(123) throws an error -ok 205 — without({}) throws an error +ok 945 — without is a Function +ok 946 — without([2, 1, 2, 3], 1, 2) returns [3] +ok 947 — without([]) returns [] +ok 948 — without([3, 1, true, '3', true], '3', true) returns [3, 1] +ok 949 — without('string'.split(''), 's', 't', 'g') returns ['r', 'i', 'n'] +ok 950 — without() throws an error +ok 951 — without(null) throws an error +ok 952 — without(undefined) throws an error +ok 953 — without(123) throws an error +ok 954 — without({}) throws an error + +# PASS test/zip/zip.test.js + +ok 955 — zip is a Function +ok 956 — zip([a, b], [1, 2], [true, false]) returns [[a, 1, true], [b, 2, false]] +ok 957 — zip([a], [1, 2], [true, false]) returns [[a, 1, true], [undefined, 2, false]] +ok 958 — zip([]) returns [] +ok 959 — zip(123) returns [] +ok 960 — zip([a, b], [1, 2], [true, false]) returns an Array +ok 961 — zip([a], [1, 2], [true, false]) returns an Array +ok 962 — zip(null) throws an error +ok 963 — zip(undefined) throws an error + +# PASS test/union/union.test.js + +ok 964 — union is a Function +ok 965 — union([1, 2, 3], [4, 3, 2]) returns [1, 2, 3, 4] +ok 966 — union('str', 'asd') returns [ 's', 't', 'r', 'a', 'd' ] +ok 967 — union([[], {}], [1, 2, 3]) returns [[], {}, 1, 2, 3] +ok 968 — union([], []) returns [] +ok 969 — union() throws an error +ok 970 — union(true, 'str') throws an error +ok 971 — union('false', true) throws an error +ok 972 — union((123, {}) throws an error +ok 973 — union([], {}) throws an error +ok 974 — union(undefined, null) throws an error +ok 975 — union([1, 2, 3], [4, 3, 2]) takes less than 2s to run + +# PASS test/validateNumber/validateNumber.test.js + +ok 976 — validateNumber is a Function +ok 977 — validateNumber(9) returns true +ok 978 — validateNumber(234asd.slice(0, 2)) returns true +ok 979 — validateNumber(1232) returns true +ok 980 — validateNumber(1232 + 13423) returns true +ok 981 — validateNumber(1232 * 2342 * 123) returns true +ok 982 — validateNumber(1232.23423536) returns true +ok 983 — validateNumber(234asd) returns false +ok 984 — validateNumber(e234d) returns false +ok 985 — validateNumber(false) returns false +ok 986 — validateNumber(true) returns false +ok 987 — validateNumber(null) returns false +ok 988 — validateNumber(123 * asd) returns false # PASS test/chunk/chunk.test.js -ok 206 — chunk is a Function -ok 207 — chunk([1, 2, 3, 4, 5], 2) returns [[1,2],[3,4],[5]] -ok 208 — chunk([]) returns [] -ok 209 — chunk(123) returns [] -ok 210 — chunk({ a: 123}) returns [] -ok 211 — chunk(string, 2) returns [ st, ri, ng ] -ok 212 — chunk() throws an error -ok 213 — chunk(undefined) throws an error -ok 214 — chunk(null) throws an error -ok 215 — chunk(This is a string, 2) takes less than 2s to run +ok 989 — chunk is a Function +ok 990 — chunk([1, 2, 3, 4, 5], 2) returns [[1,2],[3,4],[5]] +ok 991 — chunk([]) returns [] +ok 992 — chunk(123) returns [] +ok 993 — chunk({ a: 123}) returns [] +ok 994 — chunk(string, 2) returns [ st, ri, ng ] +ok 995 — chunk() throws an error +ok 996 — chunk(undefined) throws an error +ok 997 — chunk(null) throws an error +ok 998 — chunk(This is a string, 2) takes less than 2s to run + +# PASS test/toCamelCase/toCamelCase.test.js + +ok 999 — toCamelCase is a Function +ok 1000 — toCamelCase('some_database_field_name') returns someDatabaseFieldName +ok 1001 — toCamelCase('Some label that needs to be camelized') returns someLabelThatNeedsToBeCamelized +ok 1002 — toCamelCase('some-javascript-property') return someJavascriptProperty +ok 1003 — toCamelCase('some-mixed_string with spaces_underscores-and-hyphens') returns someMixedStringWithSpacesUnderscoresAndHyphens +ok 1004 — toCamelCase() throws a error +ok 1005 — toCamelCase([]) throws a error +ok 1006 — toCamelCase({}) throws a error +ok 1007 — toCamelCase(123) throws a error +ok 1008 — toCamelCase(some-mixed_string with spaces_underscores-and-hyphens) takes less than 2s to run + +# PASS test/longestItem/longestItem.test.js + +ok 1009 — longestItem is a Function +ok 1010 — Returns the longest object from plain values +ok 1011 — Returns the longest object from a spread array +ok 1012 — Returns the longest object from mixed input +ok 1013 — Returns the longest array +ok 1014 — Returns the longest object when comparing arrays and strings +ok 1015 — Returns undefined without any input +ok 1016 — Returns first found of all similar +ok 1017 — Throws TypeError if all inputs are undefined + +# PASS test/functionName/functionName.test.js + +ok 1018 — functionName is a Function +ok 1019 — Works for native functions +ok 1020 — Works for functions +ok 1021 — Works for arrow functions + +# PASS test/toSafeInteger/toSafeInteger.test.js + +ok 1022 — toSafeInteger is a Function +ok 1023 — Number(toSafeInteger(3.2)) is a number +ok 1024 — Converts a value to a safe integer +ok 1025 — toSafeInteger('4.2') returns 4 +ok 1026 — toSafeInteger(4.6) returns 5 +ok 1027 — toSafeInteger([]) returns 0 +ok 1028 — isNaN(toSafeInteger([1.5, 3124])) is true +ok 1029 — isNaN(toSafeInteger('string')) is true +ok 1030 — isNaN(toSafeInteger({})) is true +ok 1031 — isNaN(toSafeInteger()) is true +ok 1032 — toSafeInteger(Infinity) returns 9007199254740991 +ok 1033 — toSafeInteger(3.2) takes less than 2s to run + +# PASS test/words/words.test.js + +ok 1034 — words is a Function +ok 1035 — words('I love javaScript!!') returns [I, love, javaScript] +ok 1036 — words('python, javaScript & coffee') returns [python, javaScript, coffee] +ok 1037 — words(I love javaScript!!) returns an array +ok 1038 — words() throws an error +ok 1039 — words(null) throws an error +ok 1040 — words(undefined) throws an error +ok 1041 — words({}) throws an error +ok 1042 — words([]) throws an error +ok 1043 — words(1234) throws an error + +# PASS test/byteSize/byteSize.test.js + +ok 1044 — byteSize is a Function +ok 1045 — Works for a single letter +ok 1046 — Works for a common string +ok 1047 — Works for emoji + +1..1047 + +# Test Suites: 100% ██████████, 347 passed, 347 total +# Tests: 100% ██████████, 1047 passed, 1047 total +# Time: 17.019s, estimated 17s + +# Ran all test suites. + From a40f46315618eb80590e2dc403268f7f40a4e18e Mon Sep 17 00:00:00 2001 From: Felix Wu Date: Fri, 14 Sep 2018 15:46:23 +0200 Subject: [PATCH 09/15] fix category header -> snippet header --- README.md | 55 ++++++++++++++++++++++++++++++++++++++---------- scripts/build.js | 2 +- 2 files changed, 45 insertions(+), 12 deletions(-) diff --git a/README.md b/README.md index 0d6740bb9..0ad824575 100644 --- a/README.md +++ b/README.md @@ -492,7 +492,10 @@ average(1, 2, 3); --- -## 🔌 Adapter### ary + +## 🔌 Adapter + +### ary Creates a function that accepts up to `n` arguments, ignoring any additional arguments. @@ -795,7 +798,10 @@ const unary = fn => val => fn(val); --- -## 📚 Array### all + +## 📚 Array + +### all Returns `true` if the provided predicate function returns `true` for all elements in a collection, `false` otherwise. @@ -3152,7 +3158,10 @@ zipWith( --- -## 🌐 Browser### arrayToHtmlList + +## 🌐 Browser + +### arrayToHtmlList Converts the given array elements into `
  • ` tags and appends them to the list of the given id. @@ -4143,7 +4152,10 @@ UUIDGeneratorBrowser(); // '7982fcfe-5721-4632-bede-6000885be57d' --- -## ⏱️ Date### formatDuration + +## ⏱️ Date + +### formatDuration Returns the human readable format of the given number of milliseconds. @@ -4285,7 +4297,10 @@ tomorrow(true); // 2017-12-27T00:00:00 (if current date is 2017-12-26) --- -## 🎛️ Function### attempt + +## 🎛️ Function + +### attempt Attempts to invoke a function with the provided arguments, returning either the result or the caught error object. @@ -5003,7 +5018,10 @@ doubleEvenNumbers(1); // 1 --- -## ➗ Math### approximatelyEqual + +## ➗ Math + +### approximatelyEqual Checks if two numbers are approximately equal to each other. @@ -5942,7 +5960,10 @@ toSafeInteger(Infinity); // 9007199254740991 --- -## 📦 Node### atob + +## 📦 Node + +### atob Decodes a string of data which has been encoded using base-64 encoding. @@ -6214,7 +6235,10 @@ UUIDGeneratorNode(); // '79c7c136-60ee-40a2-beb2-856f1feabefc' --- -## 🗃️ Object### bindAll + +## 🗃️ Object + +### bindAll Binds methods of an object to the object itself, overwriting the existing method. @@ -7188,7 +7212,10 @@ unflattenObject({ 'a.b.c': 1, d: 1 }); // { a: { b: { c: 1 } }, d: 1 } --- -## 📜 String### byteSize + +## 📜 String + +### byteSize Returns the length of a string in bytes. @@ -8007,7 +8034,10 @@ words('python, javaScript & coffee'); // ["python", "javaScript", "coffee"] --- -## 📃 Type### getType + +## 📃 Type + +### getType Returns the native type of a value. @@ -8450,7 +8480,10 @@ isValidJSON(null); // true --- -## 🔧 Utility### castArray + +## 🔧 Utility + +### castArray Casts the provided value as an array if it's not one. diff --git a/scripts/build.js b/scripts/build.js index bdc92911a..29071df16 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -187,7 +187,7 @@ try { const capitalizedTag = util.capitalize(tag, true); const taggedSnippets = Object.entries(tagDbData).filter(v => v[1][0] === tag); - output += misc.hr() + headers.h2((EMOJIS[tag] || '') + ' ' + capitalizedTag).trim(); + output += misc.hr() + headers.h2((EMOJIS[tag] || '') + ' ' + capitalizedTag) + '\n'; for (const taggedSnippet of taggedSnippets) { let snippet = snippets[taggedSnippet[0] + '.md']; From c1d0521fab9aff4be974ddc03ceee7666062dccb Mon Sep 17 00:00:00 2001 From: Felix Wu Date: Fri, 14 Sep 2018 15:51:48 +0200 Subject: [PATCH 10/15] only build on travis --- scripts/build.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/scripts/build.js b/scripts/build.js index 29071df16..9d817d4ff 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -27,10 +27,9 @@ if ( process.exit(0); } if ( - // util.isTravisCI() && - // (process.env['TRAVIS_EVENT_TYPE'] === 'cron' || - // process.env['TRAVIS_EVENT_TYPE'] === 'api') - true + util.isTravisCI() && + (process.env['TRAVIS_EVENT_TYPE'] === 'cron' || + process.env['TRAVIS_EVENT_TYPE'] === 'api') ) { console.log( `${chalk.green( From a6e87655a5298768418fecdf1e6ba99d04e40cff Mon Sep 17 00:00:00 2001 From: Felix Wu Date: Fri, 14 Sep 2018 15:52:45 +0200 Subject: [PATCH 11/15] move markdown-builder to devDependencies --- package.json | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/package.json b/package.json index 92d5c0451..5f9b4105e 100644 --- a/package.json +++ b/package.json @@ -15,7 +15,8 @@ "rollup": "^0.58.2", "rollup-plugin-babel": "^3.0.4", "rollup-plugin-babel-minify": "^4.0.0", - "semistandard": "^12.0.1" + "semistandard": "^12.0.1", + "markdown-builder": "^0.8.3-dev" }, "name": "30-seconds-of-code", "description": "A collection of useful JavaScript snippets.", @@ -51,9 +52,7 @@ "url": "https://github.com/Chalarangelo/30-seconds-of-code/issues" }, "homepage": "https://github.com/Chalarangelo/30-seconds-of-code#readme", - "dependencies": { - "markdown-builder": "^0.8.3-dev" - }, + "dependencies": {}, "jest": { "reporters": [ [ From a27892141607fd010a7f3d92ff86cf22a6dbc68b Mon Sep 17 00:00:00 2001 From: Felix Wu Date: Fri, 14 Sep 2018 17:52:23 +0200 Subject: [PATCH 12/15] remove indentation --- README.md | 1992 ++++++++++++++++++++++----------------------- package-lock.json | 117 ++- package.json | 4 +- 3 files changed, 1084 insertions(+), 1029 deletions(-) diff --git a/README.md b/README.md index 0ad824575..f03694e55 100644 --- a/README.md +++ b/README.md @@ -84,9 +84,9 @@ average(1, 2, 3); ### 🔌 Adapter
    - View contents - - * [`ary`](#ary) +View contents + +* [`ary`](#ary) * [`call`](#call) * [`collectInto`](#collectinto) * [`flip`](#flip) @@ -104,9 +104,9 @@ average(1, 2, 3); ### 📚 Array
    - View contents - - * [`all`](#all) +View contents + +* [`all`](#all) * [`allEqual`](#allequal) * [`any`](#any) * [`arrayToCSV`](#arraytocsv) @@ -203,9 +203,9 @@ average(1, 2, 3); ### 🌐 Browser
    - View contents - - * [`arrayToHtmlList`](#arraytohtmllist) +View contents + +* [`arrayToHtmlList`](#arraytohtmllist) * [`bottomVisible`](#bottomvisible) * [`copyToClipboard`](#copytoclipboard-) * [`counter`](#counter-) @@ -246,9 +246,9 @@ average(1, 2, 3); ### ⏱️ Date
    - View contents - - * [`formatDuration`](#formatduration) +View contents + +* [`formatDuration`](#formatduration) * [`getColonTimeFromDate`](#getcolontimefromdate) * [`getDaysDiffBetweenDates`](#getdaysdiffbetweendates) * [`getMeridiemSuffixOfInteger`](#getmeridiemsuffixofinteger) @@ -259,9 +259,9 @@ average(1, 2, 3); ### 🎛️ Function
    - View contents - - * [`attempt`](#attempt) +View contents + +* [`attempt`](#attempt) * [`bind`](#bind) * [`bindKey`](#bindkey) * [`chainAsync`](#chainasync) @@ -292,9 +292,9 @@ average(1, 2, 3); ### ➗ Math
    - View contents - - * [`approximatelyEqual`](#approximatelyequal) +View contents + +* [`approximatelyEqual`](#approximatelyequal) * [`average`](#average) * [`averageBy`](#averageby) * [`binomialCoefficient`](#binomialcoefficient) @@ -337,9 +337,9 @@ average(1, 2, 3); ### 📦 Node
    - View contents - - * [`atob`](#atob) +View contents + +* [`atob`](#atob) * [`btoa`](#btoa) * [`colorize`](#colorize) * [`hasFlags`](#hasflags) @@ -355,9 +355,9 @@ average(1, 2, 3); ### 🗃️ Object
    - View contents - - * [`bindAll`](#bindall) +View contents + +* [`bindAll`](#bindall) * [`deepClone`](#deepclone) * [`deepFreeze`](#deepfreeze) * [`defaults`](#defaults) @@ -397,9 +397,9 @@ average(1, 2, 3); ### 📜 String
    - View contents - - * [`byteSize`](#bytesize) +View contents + +* [`byteSize`](#bytesize) * [`capitalize`](#capitalize) * [`capitalizeEveryWord`](#capitalizeeveryword) * [`CSVToArray`](#csvtoarray) @@ -436,9 +436,9 @@ average(1, 2, 3); ### 📃 Type
    - View contents - - * [`getType`](#gettype) +View contents + +* [`getType`](#gettype) * [`is`](#is) * [`isArrayLike`](#isarraylike) * [`isBoolean`](#isboolean) @@ -462,9 +462,9 @@ average(1, 2, 3); ### 🔧 Utility
    - View contents - - * [`castArray`](#castarray) +View contents + +* [`castArray`](#castarray) * [`cloneRegExp`](#cloneregexp) * [`coalesce`](#coalesce) * [`coalesceFactory`](#coalescefactory) @@ -506,9 +506,9 @@ const ary = (fn, n) => (...args) => fn(...args.slice(0, n)); ```
    - Examples - - ```js +Examples + +```js const firstTwoMax = ary(Math.max, 2); [[2, 6, 'a'], [8, 4, 6], [10]].map(x => firstTwoMax(...x)); // [6, 8, 10] ``` @@ -528,9 +528,9 @@ const call = (key, ...args) => context => context[key](...args); ```
    - Examples - - ```js +Examples + +```js Promise.resolve([1, 2, 3]) .then(call('map', x => 2 * x)) .then(console.log); //[ 2, 4, 6 ] @@ -555,9 +555,9 @@ const collectInto = fn => (...args) => fn(args); ```
    - Examples - - ```js +Examples + +```js const Pall = collectInto(Promise.all.bind(Promise)); let p1 = Promise.resolve(1); let p2 = Promise.resolve(2); @@ -580,9 +580,9 @@ const flip = fn => (first, ...rest) => fn(...rest, first); ```
    - Examples - - ```js +Examples + +```js let a = { name: 'John Smith' }; let b = {}; const mergeFrom = flip(Object.assign); @@ -607,9 +607,9 @@ const over = (...fns) => (...args) => fns.map(fn => fn.apply(null, args)); ```
    - Examples - - ```js +Examples + +```js const minMax = over(Math.min, Math.max); minMax(1, 2, 3, 4, 5); // [1,5] ``` @@ -629,9 +629,9 @@ const overArgs = (fn, transforms) => (...args) => fn(...args.map((val, i) => tra ```
    - Examples - - ```js +Examples + +```js const square = n => n * n; const double = n => n * 2; const fn = overArgs((x, y) => [x, y], [square, double]); @@ -655,9 +655,9 @@ const pipeAsyncFunctions = (...fns) => arg => fns.reduce((p, f) => p.then(f), Pr ```
    - Examples - - ```js +Examples + +```js const sum = pipeAsyncFunctions( x => x + 1, x => new Promise(resolve => setTimeout(() => resolve(x + 2), 1000)), @@ -685,9 +685,9 @@ const pipeFunctions = (...fns) => fns.reduce((f, g) => (...args) => g(f(...args) ```
    - Examples - - ```js +Examples + +```js const add5 = x => x + 5; const multiply = (x, y) => x * y; const multiplyAndAdd5 = pipeFunctions(multiply, add5); @@ -715,9 +715,9 @@ const promisify = func => (...args) => ```
    - Examples - - ```js +Examples + +```js const delay = promisify((d, cb) => setTimeout(cb, d)); delay(2000).then(() => console.log('Hi!')); // // Promise resolves after 2s ``` @@ -737,9 +737,9 @@ const rearg = (fn, indexes) => (...args) => fn(...indexes.map(i => args[i])); ```
    - Examples - - ```js +Examples + +```js var rearged = rearg( function(a, b, c) { return [a, b, c]; @@ -764,9 +764,9 @@ const spreadOver = fn => argsArr => fn(...argsArr); ```
    - Examples - - ```js +Examples + +```js const arrayMax = spreadOver(Math.max); arrayMax([1, 2, 3]); // 3 ``` @@ -786,9 +786,9 @@ const unary = fn => val => fn(val); ```
    - Examples - - ```js +Examples + +```js ['6', '8', '10'].map(unary(parseInt)); // [6, 8, 10] ``` @@ -813,9 +813,9 @@ const all = (arr, fn = Boolean) => arr.every(fn); ```
    - Examples - - ```js +Examples + +```js all([4, 2, 3], x => x > 1); // true all([1, 2, 3]); // true ``` @@ -835,9 +835,9 @@ const allEqual = arr => arr.every(val => val === arr[0]); ```
    - Examples - - ```js +Examples + +```js allEqual([1, 2, 3, 4, 5, 6]); // false allEqual([1, 1, 1, 1]); // true ``` @@ -858,9 +858,9 @@ const any = (arr, fn = Boolean) => arr.some(fn); ```
    - Examples - - ```js +Examples + +```js any([0, 1, 2, 0], x => x >= 2); // true any([0, 0, 1, 0]); // true ``` @@ -883,9 +883,9 @@ const arrayToCSV = (arr, delimiter = ',') => ```
    - Examples - - ```js +Examples + +```js arrayToCSV([['a', 'b'], ['c', 'd']]); // '"a","b"\n"c","d"' arrayToCSV([['a', 'b'], ['c', 'd']], ';'); // '"a";"b"\n"c";"d"' ``` @@ -906,9 +906,9 @@ const bifurcate = (arr, filter) => ```
    - Examples - - ```js +Examples + +```js bifurcate(['beep', 'boop', 'foo', 'bar'], [true, true, false, true]); // [ ['beep', 'boop', 'bar'], ['foo'] ] ``` @@ -928,9 +928,9 @@ const bifurcateBy = (arr, fn) => ```
    - Examples - - ```js +Examples + +```js bifurcateBy(['beep', 'boop', 'foo', 'bar'], x => x[0] === 'b'); // [ ['beep', 'boop', 'bar'], ['foo'] ] ``` @@ -954,9 +954,9 @@ const chunk = (arr, size) => ```
    - Examples - - ```js +Examples + +```js chunk([1, 2, 3, 4, 5], 2); // [[1,2],[3,4],[5]] ``` @@ -975,9 +975,9 @@ const compact = arr => arr.filter(Boolean); ```
    - Examples - - ```js +Examples + +```js compact([0, 1, false, 2, '', 3, 'a', 'e' * 23, NaN, 's', 34]); // [ 1, 2, 3, 'a', 's', 34 ] ``` @@ -1001,9 +1001,9 @@ const countBy = (arr, fn) => ```
    - Examples - - ```js +Examples + +```js countBy([6.1, 4.2, 6.3], Math.floor); // {4: 1, 6: 2} countBy(['one', 'two', 'three'], 'length'); // {3: 2, 5: 1} ``` @@ -1023,9 +1023,9 @@ const countOccurrences = (arr, val) => arr.reduce((a, v) => (v === val ? a + 1 : ```
    - Examples - - ```js +Examples + +```js countOccurrences([1, 1, 2, 1, 2, 3], 1); // 3 ``` @@ -1046,9 +1046,9 @@ const deepFlatten = arr => [].concat(...arr.map(v => (Array.isArray(v) ? deepFla ```
    - Examples - - ```js +Examples + +```js deepFlatten([1, [2], [[3], 4], 5]); // [1,2,3,4,5] ``` @@ -1070,9 +1070,9 @@ const difference = (a, b) => { ```
    - Examples - - ```js +Examples + +```js difference([1, 2, 3], [1, 2, 4]); // [3] ``` @@ -1094,9 +1094,9 @@ const differenceBy = (a, b, fn) => { ```
    - Examples - - ```js +Examples + +```js differenceBy([2.1, 1.2], [2.3, 3.4], Math.floor); // [1.2] differenceBy([{ x: 2 }, { x: 1 }], [{ x: 1 }], v => v.x); // [ { x: 2 } ] ``` @@ -1116,9 +1116,9 @@ const differenceWith = (arr, val, comp) => arr.filter(a => val.findIndex(b => co ```
    - Examples - - ```js +Examples + +```js differenceWith([1, 1.2, 1.5, 3, 0], [1.9, 3, 0], (a, b) => Math.round(a) === Math.round(b)); // [1, 1.2] ``` @@ -1137,9 +1137,9 @@ const drop = (arr, n = 1) => arr.slice(n); ```
    - Examples - - ```js +Examples + +```js drop([1, 2, 3]); // [2,3] drop([1, 2, 3], 2); // [3] drop([1, 2, 3], 42); // [] @@ -1160,9 +1160,9 @@ const dropRight = (arr, n = 1) => arr.slice(0, -n); ```
    - Examples - - ```js +Examples + +```js dropRight([1, 2, 3]); // [1,2] dropRight([1, 2, 3], 2); // [1] dropRight([1, 2, 3], 42); // [] @@ -1187,9 +1187,9 @@ const dropRightWhile = (arr, func) => { ```
    - Examples - - ```js +Examples + +```js dropRightWhile([1, 2, 3, 4], n => n < 3); // [1, 2] ``` @@ -1212,9 +1212,9 @@ const dropWhile = (arr, func) => { ```
    - Examples - - ```js +Examples + +```js dropWhile([1, 2, 3, 4], n => n >= 3); // [3,4] ``` @@ -1233,9 +1233,9 @@ const everyNth = (arr, nth) => arr.filter((e, i) => i % nth === nth - 1); ```
    - Examples - - ```js +Examples + +```js everyNth([1, 2, 3, 4, 5, 6], 2); // [ 2, 4, 6 ] ``` @@ -1254,9 +1254,9 @@ const filterNonUnique = arr => arr.filter(i => arr.indexOf(i) === arr.lastIndexO ```
    - Examples - - ```js +Examples + +```js filterNonUnique([1, 2, 2, 3, 4, 4, 5]); // [1,3,5] ``` @@ -1277,9 +1277,9 @@ const filterNonUniqueBy = (arr, fn) => ```
    - Examples - - ```js +Examples + +```js filterNonUniqueBy( [ { id: 0, value: 'a' }, @@ -1307,9 +1307,9 @@ const findLast = (arr, fn) => arr.filter(fn).pop(); ```
    - Examples - - ```js +Examples + +```js findLast([1, 2, 3, 4], n => n % 2 === 1); // 3 ``` @@ -1333,9 +1333,9 @@ const findLastIndex = (arr, fn) => ```
    - Examples - - ```js +Examples + +```js findLastIndex([1, 2, 3, 4], n => n % 2 === 1); // 2 (index of the value 3) ``` @@ -1358,9 +1358,9 @@ const flatten = (arr, depth = 1) => ```
    - Examples - - ```js +Examples + +```js flatten([1, [2], 3, 4]); // [1, 2, 3, 4] flatten([1, [2, [3, [4, 5], 6], 7], 8], 2); // [1, 2, 3, [4, 5], 6, 7, 8] ``` @@ -1384,9 +1384,9 @@ const forEachRight = (arr, callback) => ```
    - Examples - - ```js +Examples + +```js forEachRight([1, 2, 3, 4], val => console.log(val)); // '4', '3', '2', '1' ``` @@ -1410,9 +1410,9 @@ const groupBy = (arr, fn) => ```
    - Examples - - ```js +Examples + +```js groupBy([6.1, 4.2, 6.3], Math.floor); // {4: [4.2], 6: [6.1, 6.3]} groupBy(['one', 'two', 'three'], 'length'); // {3: ['one', 'two'], 5: ['three']} ``` @@ -1432,9 +1432,9 @@ const head = arr => arr[0]; ```
    - Examples - - ```js +Examples + +```js head([1, 2, 3]); // 1 ``` @@ -1454,9 +1454,9 @@ const indexOfAll = (arr, val) => arr.reduce((acc, el, i) => (el === val ? [...ac ```
    - Examples - - ```js +Examples + +```js indexOfAll([1, 2, 3, 1, 2, 3], 1); // [0,3] indexOfAll([1, 2, 3], 4); // [] ``` @@ -1476,9 +1476,9 @@ const initial = arr => arr.slice(0, -1); ```
    - Examples - - ```js +Examples + +```js initial([1, 2, 3]); // [1,2] ``` @@ -1498,9 +1498,9 @@ const initialize2DArray = (w, h, val = null) => ```
    - Examples - - ```js +Examples + +```js initialize2DArray(2, 2, 0); // [[0,0], [0,0]] ``` @@ -1522,9 +1522,9 @@ const initializeArrayWithRange = (end, start = 0, step = 1) => ```
    - Examples - - ```js +Examples + +```js initializeArrayWithRange(5); // [0,1,2,3,4,5] initializeArrayWithRange(7, 3); // [3,4,5,6,7] initializeArrayWithRange(9, 0, 2); // [0,2,4,6,8] @@ -1550,9 +1550,9 @@ const initializeArrayWithRangeRight = (end, start = 0, step = 1) => ```
    - Examples - - ```js +Examples + +```js initializeArrayWithRangeRight(5); // [5,4,3,2,1,0] initializeArrayWithRangeRight(7, 3); // [7,6,5,4,3] initializeArrayWithRangeRight(9, 0, 2); // [8,6,4,2,0] @@ -1574,9 +1574,9 @@ const initializeArrayWithValues = (n, val = 0) => Array(n).fill(val); ```
    - Examples - - ```js +Examples + +```js initializeArrayWithValues(5, 2); // [2,2,2,2,2] ``` @@ -1599,9 +1599,9 @@ const initializeNDArray = (val, ...args) => ```
    - Examples - - ```js +Examples + +```js initializeNDArray(1, 3); // [1,1,1] initializeNDArray(5, 2, 2, 2); // [[[5,5],[5,5]],[[5,5],[5,5]]] ``` @@ -1624,9 +1624,9 @@ const intersection = (a, b) => { ```
    - Examples - - ```js +Examples + +```js intersection([1, 2, 3], [4, 3, 2]); // [2,3] ``` @@ -1648,9 +1648,9 @@ const intersectionBy = (a, b, fn) => { ```
    - Examples - - ```js +Examples + +```js intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor); // [2.1] ``` @@ -1669,9 +1669,9 @@ const intersectionWith = (a, b, comp) => a.filter(x => b.findIndex(y => comp(x, ```
    - Examples - - ```js +Examples + +```js intersectionWith([1, 1.2, 1.5, 3, 0], [1.9, 3, 0, 3.9], (a, b) => Math.round(a) === Math.round(b)); // [1.5, 3, 0] ``` @@ -1699,9 +1699,9 @@ const isSorted = arr => { ```
    - Examples - - ```js +Examples + +```js isSorted([0, 1, 2, 2]); // 1 isSorted([4, 3, 2]); // -1 isSorted([4, 3, 5]); // 0 @@ -1733,9 +1733,9 @@ const join = (arr, separator = ',', end = separator) => ```
    - Examples - - ```js +Examples + +```js join(['pen', 'pineapple', 'apple', 'pen'], ',', '&'); // "pen,pineapple,apple&pen" join(['pen', 'pineapple', 'apple', 'pen'], ','); // "pen,pineapple,apple,pen" join(['pen', 'pineapple', 'apple', 'pen']); // "pen,pineapple,apple,pen" @@ -1768,9 +1768,9 @@ const JSONtoCSV = (arr, columns, delimiter = ',') => ```
    - Examples - - ```js +Examples + +```js JSONtoCSV([{ a: 1, b: 2 }, { a: 3, b: 4, c: 5 }, { a: 6 }, { b: 7 }], ['a', 'b']); // 'a,b\n"1","2"\n"3","4"\n"6",""\n"","7"' JSONtoCSV([{ a: 1, b: 2 }, { a: 3, b: 4, c: 5 }, { a: 6 }, { b: 7 }], ['a', 'b'], ';'); // 'a;b\n"1";"2"\n"3";"4"\n"6";""\n"";"7"' ``` @@ -1790,9 +1790,9 @@ const last = arr => arr[arr.length - 1]; ```
    - Examples - - ```js +Examples + +```js last([1, 2, 3]); // 3 ``` @@ -1814,9 +1814,9 @@ const longestItem = (val, ...vals) => ```
    - Examples - - ```js +Examples + +```js longestItem('this', 'is', 'a', 'testcase'); // 'testcase' longestItem(...['a', 'ab', 'abc']); // 'abc' longestItem(...['a', 'ab', 'abc'], 'abcd'); // 'abcd' @@ -1842,9 +1842,9 @@ const mapObject = (arr, fn) => ```
    - Examples - - ```js +Examples + +```js const squareIt = arr => mapObject(arr, a => a * a); squareIt([1, 2, 3]); // { 1: 1, 2: 4, 3: 9 } ``` @@ -1866,9 +1866,9 @@ const maxN = (arr, n = 1) => [...arr].sort((a, b) => b - a).slice(0, n); ```
    - Examples - - ```js +Examples + +```js maxN([1, 2, 3]); // [3] maxN([1, 2, 3], 2); // [3,2] ``` @@ -1890,9 +1890,9 @@ const minN = (arr, n = 1) => [...arr].sort((a, b) => a - b).slice(0, n); ```
    - Examples - - ```js +Examples + +```js minN([1, 2, 3]); // [1] minN([1, 2, 3], 2); // [1,2] ``` @@ -1913,9 +1913,9 @@ const none = (arr, fn = Boolean) => !arr.some(fn); ```
    - Examples - - ```js +Examples + +```js none([0, 1, 3, 0], x => x == 2); // true none([0, 0, 0]); // true ``` @@ -1937,9 +1937,9 @@ const nthElement = (arr, n = 0) => (n === -1 ? arr.slice(n) : arr.slice(n, n + 1 ```
    - Examples - - ```js +Examples + +```js nthElement(['a', 'b', 'c'], 1); // 'b' nthElement(['a', 'b', 'b'], -3); // 'a' ``` @@ -1961,9 +1961,9 @@ const offset = (arr, offset) => [...arr.slice(offset), ...arr.slice(0, offset)]; ```
    - Examples - - ```js +Examples + +```js offset([1, 2, 3, 4, 5], 2); // [3, 4, 5, 1, 2] offset([1, 2, 3, 4, 5], -2); // [4, 5, 1, 2, 3] ``` @@ -1991,9 +1991,9 @@ const partition = (arr, fn) => ```
    - Examples - - ```js +Examples + +```js const users = [{ user: 'barney', age: 36, active: false }, { user: 'fred', age: 40, active: true }]; partition(users, o => o.active); // [[{ 'user': 'fred', 'age': 40, 'active': true }],[{ 'user': 'barney', 'age': 36, 'active': false }]] ``` @@ -2027,9 +2027,9 @@ const permutations = arr => { ```
    - Examples - - ```js +Examples + +```js permutations([1, 33, 5]); // [ [ 1, 33, 5 ], [ 1, 5, 33 ], [ 33, 1, 5 ], [ 33, 5, 1 ], [ 5, 1, 33 ], [ 5, 33, 1 ] ] ``` @@ -2056,9 +2056,9 @@ const pull = (arr, ...args) => { ```
    - Examples - - ```js +Examples + +```js let myArray = ['a', 'b', 'c', 'a', 'b', 'c']; pull(myArray, 'a', 'c'); // myArray = [ 'b', 'b' ] ``` @@ -2088,9 +2088,9 @@ const pullAtIndex = (arr, pullArr) => { ```
    - Examples - - ```js +Examples + +```js let myArray = ['a', 'b', 'c', 'd']; let pulled = pullAtIndex(myArray, [1, 3]); // myArray = [ 'a', 'c' ] , pulled = [ 'b', 'd' ] ``` @@ -2119,9 +2119,9 @@ const pullAtValue = (arr, pullArr) => { ```
    - Examples - - ```js +Examples + +```js let myArray = ['a', 'b', 'c', 'd']; let pulled = pullAtValue(myArray, ['b', 'd']); // myArray = [ 'a', 'c' ] , pulled = [ 'b', 'd' ] ``` @@ -2152,9 +2152,9 @@ const pullBy = (arr, ...args) => { ```
    - Examples - - ```js +Examples + +```js var myArray = [{ x: 1 }, { x: 2 }, { x: 3 }, { x: 1 }]; pullBy(myArray, [{ x: 1 }, { x: 3 }], o => o.x); // myArray = [{ x: 2 }] ``` @@ -2181,9 +2181,9 @@ const reducedFilter = (data, keys, fn) => ```
    - Examples - - ```js +Examples + +```js const data = [ { id: 1, @@ -2216,9 +2216,9 @@ const reduceSuccessive = (arr, fn, acc) => ```
    - Examples - - ```js +Examples + +```js reduceSuccessive([1, 2, 3, 4, 5, 6], (acc, val) => acc + val, 0); // [0, 1, 3, 6, 10, 15, 21] ``` @@ -2239,9 +2239,9 @@ const reduceWhich = (arr, comparator = (a, b) => a - b) => ```
    - Examples - - ```js +Examples + +```js reduceWhich([1, 3, 2]); // 1 reduceWhich([1, 3, 2], (a, b) => b - a); // 3 reduceWhich( @@ -2263,9 +2263,9 @@ const reject = (pred, array) => array.filter((...args) => !pred(...args)); ```
    - Examples - - ```js +Examples + +```js reject(x => x % 2 === 0, [1, 2, 3, 4, 5]); // [1, 3, 5] reject(word => word.length > 4, ['Apple', 'Pear', 'Kiwi', 'Banana']); // ['Pear', 'Kiwi'] ``` @@ -2292,9 +2292,9 @@ const remove = (arr, func) => ```
    - Examples - - ```js +Examples + +```js remove([1, 2, 3, 4], n => n % 2 === 0); // [2, 4] ``` @@ -2314,9 +2314,9 @@ const sample = arr => arr[Math.floor(Math.random() * arr.length)]; ```
    - Examples - - ```js +Examples + +```js sample([3, 7, 9, 11]); // 9 ``` @@ -2344,9 +2344,9 @@ const sampleSize = ([...arr], n = 1) => { ```
    - Examples - - ```js +Examples + +```js sampleSize([1, 2, 3], 2); // [3,1] sampleSize([1, 2, 3], 4); // [2,3,1] ``` @@ -2373,9 +2373,9 @@ const shuffle = ([...arr]) => { ```
    - Examples - - ```js +Examples + +```js const foo = [1, 2, 3]; shuffle(foo); // [2,3,1], foo = [1,2,3] ``` @@ -2395,9 +2395,9 @@ const similarity = (arr, values) => arr.filter(v => values.includes(v)); ```
    - Examples - - ```js +Examples + +```js similarity([1, 2, 3], [1, 2, 4]); // [1,2] ``` @@ -2421,9 +2421,9 @@ const sortedIndex = (arr, n) => { ```
    - Examples - - ```js +Examples + +```js sortedIndex([5, 3, 2, 1], 4); // 1 sortedIndex([30, 50], 40); // 1 ``` @@ -2449,9 +2449,9 @@ const sortedIndexBy = (arr, n, fn) => { ```
    - Examples - - ```js +Examples + +```js sortedIndexBy([{ x: 4 }, { x: 5 }], { x: 4 }, o => o.x); // 0 ``` @@ -2475,9 +2475,9 @@ const sortedLastIndex = (arr, n) => { ```
    - Examples - - ```js +Examples + +```js sortedLastIndex([10, 20, 30, 30, 40], 30); // 4 ``` @@ -2506,9 +2506,9 @@ const sortedLastIndexBy = (arr, n, fn) => { ```
    - Examples - - ```js +Examples + +```js sortedLastIndexBy([{ x: 4 }, { x: 5 }], { x: 4 }, o => o.x); // 1 ``` @@ -2534,9 +2534,9 @@ const stableSort = (arr, compare) => ```
    - Examples - - ```js +Examples + +```js const arr = [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; const stable = stableSort(arr, () => 0); // [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] ``` @@ -2560,9 +2560,9 @@ const symmetricDifference = (a, b) => { ```
    - Examples - - ```js +Examples + +```js symmetricDifference([1, 2, 3], [1, 2, 4]); // [3, 4] symmetricDifference([1, 2, 2], [1, 3, 1]); // [2, 2, 3] ``` @@ -2586,9 +2586,9 @@ const symmetricDifferenceBy = (a, b, fn) => { ```
    - Examples - - ```js +Examples + +```js symmetricDifferenceBy([2.1, 1.2], [2.3, 3.4], Math.floor); // [ 1.2, 3.4 ] ``` @@ -2610,9 +2610,9 @@ const symmetricDifferenceWith = (arr, val, comp) => [ ```
    - Examples - - ```js +Examples + +```js symmetricDifferenceWith( [1, 1.2, 1.5, 3, 0], [1.9, 3, 0, 3.9], @@ -2635,9 +2635,9 @@ const tail = arr => (arr.length > 1 ? arr.slice(1) : arr); ```
    - Examples - - ```js +Examples + +```js tail([1, 2, 3]); // [2,3] tail([1]); // [1] ``` @@ -2657,9 +2657,9 @@ const take = (arr, n = 1) => arr.slice(0, n); ```
    - Examples - - ```js +Examples + +```js take([1, 2, 3], 5); // [1, 2, 3] take([1, 2, 3], 0); // [] ``` @@ -2679,9 +2679,9 @@ const takeRight = (arr, n = 1) => arr.slice(arr.length - n, arr.length); ```
    - Examples - - ```js +Examples + +```js takeRight([1, 2, 3], 2); // [ 2, 3 ] takeRight([1, 2, 3]); // [3] ``` @@ -2706,9 +2706,9 @@ const takeRightWhile = (arr, func) => { ```
    - Examples - - ```js +Examples + +```js takeRightWhile([1, 2, 3, 4], n => n < 3); // [3, 4] ``` @@ -2731,9 +2731,9 @@ const takeWhile = (arr, func) => { ```
    - Examples - - ```js +Examples + +```js takeWhile([1, 2, 3, 4], n => n >= 3); // [1, 2] ``` @@ -2757,9 +2757,9 @@ const toHash = (object, key) => ```
    - Examples - - ```js +Examples + +```js toHash([4, 3, 2, 1]); // { 0: 4, 1: 3, 2: 2, 1: 1 } toHash([{ a: 'label' }], 'a'); // { label: { a: 'label' } } // A more in depth example: @@ -2790,9 +2790,9 @@ const union = (a, b) => Array.from(new Set([...a, ...b])); ```
    - Examples - - ```js +Examples + +```js union([1, 2, 3], [4, 3, 2]); // [1,2,3,4] ``` @@ -2816,9 +2816,9 @@ const unionBy = (a, b, fn) => { ```
    - Examples - - ```js +Examples + +```js unionBy([2.1], [1.2, 2.3], Math.floor); // [2.1, 1.2] ``` @@ -2838,9 +2838,9 @@ const unionWith = (a, b, comp) => ```
    - Examples - - ```js +Examples + +```js unionWith([1, 1.2, 1.5, 3, 0], [1.9, 3, 0, 3.9], (a, b) => Math.round(a) === Math.round(b)); // [1, 1.2, 1.5, 3, 0, 3.9] ``` @@ -2859,9 +2859,9 @@ const uniqueElements = arr => [...new Set(arr)]; ```
    - Examples - - ```js +Examples + +```js uniqueElements([1, 2, 2, 3, 4, 4, 5]); // [1,2,3,4,5] ``` @@ -2885,9 +2885,9 @@ const uniqueElementsBy = (arr, fn) => ```
    - Examples - - ```js +Examples + +```js uniqueElementsBy( [ { id: 0, value: 'a' }, @@ -2920,9 +2920,9 @@ const uniqueElementsByRight = (arr, fn) => ```
    - Examples - - ```js +Examples + +```js uniqueElementsByRight( [ { id: 0, value: 'a' }, @@ -2952,9 +2952,9 @@ const uniqueSymmetricDifference = (a, b) => [ ```
    - Examples - - ```js +Examples + +```js uniqueSymmetricDifference([1, 2, 3], [1, 2, 4]); // [3, 4] uniqueSymmetricDifference([1, 2, 2], [1, 3, 1]); // [2, 3] ``` @@ -2981,9 +2981,9 @@ const unzip = arr => ```
    - Examples - - ```js +Examples + +```js unzip([['a', 1, true], ['b', 2, false]]); //[['a', 'b'], [1, 2], [true, false]] unzip([['a', 1, true], ['b', 2]]); //[['a', 'b'], [1, 2], [true]] ``` @@ -3013,9 +3013,9 @@ const unzipWith = (arr, fn) => ```
    - Examples - - ```js +Examples + +```js unzipWith([[1, 10, 100], [2, 20, 200]], (...args) => args.reduce((acc, v) => acc + v, 0)); // [3, 30, 300] ``` @@ -3036,9 +3036,9 @@ const without = (arr, ...args) => arr.filter(v => !args.includes(v)); ```
    - Examples - - ```js +Examples + +```js without([2, 1, 2, 3], 1, 2); // [3] ``` @@ -3057,9 +3057,9 @@ const xProd = (a, b) => a.reduce((acc, x) => acc.concat(b.map(y => [x, y])), []) ```
    - Examples - - ```js +Examples + +```js xProd([1, 2], ['a', 'b']); // [[1, 'a'], [1, 'b'], [2, 'a'], [2, 'b']] ``` @@ -3085,9 +3085,9 @@ const zip = (...arrays) => { ```
    - Examples - - ```js +Examples + +```js zip(['a', 'b'], [1, 2], [true, false]); // [['a', 1, true], ['b', 2, false]] zip(['a'], [1, 2], [true, false]); // [['a', 1, true], [undefined, 2, false]] ``` @@ -3108,9 +3108,9 @@ const zipObject = (props, values) => ```
    - Examples - - ```js +Examples + +```js zipObject(['a', 'b', 'c'], [1, 2]); // {a: 1, b: 2, c: undefined} zipObject(['a', 'b'], [1, 2, 3]); // {a: 1, b: 2} ``` @@ -3140,9 +3140,9 @@ const zipWith = (...array) => { ```
    - Examples - - ```js +Examples + +```js zipWith([1, 2], [10, 20], [100, 200], (a, b, c) => a + b + c); // [111,222] zipWith( [1, 2, 3], @@ -3176,9 +3176,9 @@ const arrayToHtmlList = (arr, listID) => ```
    - Examples - - ```js +Examples + +```js arrayToHtmlList(['item 1', 'item 2'], 'myListID'); ``` @@ -3199,9 +3199,9 @@ const bottomVisible = () => ```
    - Examples - - ```js +Examples + +```js bottomVisible(); // true ``` @@ -3242,9 +3242,9 @@ const copyToClipboard = str => { ```
    - Examples - - ```js +Examples + +```js copyToClipboard('Lorem ipsum'); // 'Lorem ipsum' copied to clipboard. ``` @@ -3277,9 +3277,9 @@ const counter = (selector, start, end, step = 1, duration = 2000) => { ```
    - Examples - - ```js +Examples + +```js counter('#my-id', 1, 1000, 5, 2000); // Creates a 2-second timer for the element with id="my-id" ``` @@ -3305,9 +3305,9 @@ const createElement = str => { ```
    - Examples - - ```js +Examples + +```js const el = createElement( `

    Hello!

    @@ -3348,9 +3348,9 @@ const createEventHub = () => ({ ```
    - Examples - - ```js +Examples + +```js const handler = data => console.log(data); const hub = createEventHub(); let increment = 0; @@ -3384,9 +3384,9 @@ const currentURL = () => window.location.href; ```
    - Examples - - ```js +Examples + +```js currentURL(); // 'https://google.com' ``` @@ -3408,9 +3408,9 @@ const detectDeviceType = () => ```
    - Examples - - ```js +Examples + +```js detectDeviceType(); // "Mobile" or "Desktop" ``` @@ -3429,9 +3429,9 @@ const elementContains = (parent, child) => parent !== child && parent.contains(c ```
    - Examples - - ```js +Examples + +```js elementContains(document.querySelector('head'), document.querySelector('title')); // true elementContains(document.querySelector('body'), document.querySelector('body')); // false ``` @@ -3461,9 +3461,9 @@ const elementIsVisibleInViewport = (el, partiallyVisible = false) => { ```
    - Examples - - ```js +Examples + +```js // e.g. 100x100 viewport and a 10x10px element at position {top: -1, left: 0, bottom: 9, right: 10} elementIsVisibleInViewport(el); // false - (not fully visible) elementIsVisibleInViewport(el, true); // true - (partially visible) @@ -3488,9 +3488,9 @@ const getScrollPosition = (el = window) => ({ ```
    - Examples - - ```js +Examples + +```js getScrollPosition(); // {x: 0, y: 200} ``` @@ -3509,9 +3509,9 @@ const getStyle = (el, ruleName) => getComputedStyle(el)[ruleName]; ```
    - Examples - - ```js +Examples + +```js getStyle(document.querySelector('p'), 'font-size'); // '16px' ``` @@ -3530,9 +3530,9 @@ const hasClass = (el, className) => el.classList.contains(className); ```
    - Examples - - ```js +Examples + +```js hasClass(document.querySelector('p.special'), 'special'); // true ``` @@ -3558,9 +3558,9 @@ const hashBrowser = val => ```
    - Examples - - ```js +Examples + +```js hashBrowser(JSON.stringify({ a: 'a', b: [1, 2, 3, 4], foo: { c: 'bar' } })).then(console.log); // '04aa106279f5977f59f9067fa9712afc4aedc6f5862a8defc34552d8c7206393' ``` @@ -3579,9 +3579,9 @@ const hide = els => els.forEach(e => (e.style.display = 'none')); ```
    - Examples - - ```js +Examples + +```js hide(document.querySelectorAll('img')); // Hides all elements on the page ``` @@ -3602,9 +3602,9 @@ const httpsRedirect = () => { ```
    - Examples - - ```js +Examples + +```js httpsRedirect(); // If you are on http://mydomain.com, you are redirected to https://mydomain.com ``` @@ -3623,9 +3623,9 @@ const insertAfter = (el, htmlString) => el.insertAdjacentHTML('afterend', htmlSt ```
    - Examples - - ```js +Examples + +```js insertAfter(document.getElementById('myId'), '

    after

    '); //
    ...

    after

    ``` @@ -3644,9 +3644,9 @@ const insertBefore = (el, htmlString) => el.insertAdjacentHTML('beforebegin', ht ```
    - Examples - - ```js +Examples + +```js insertBefore(document.getElementById('myId'), '

    before

    '); //

    before

    ...
    ``` @@ -3665,9 +3665,9 @@ const isBrowserTabFocused = () => !document.hidden; ```
    - Examples - - ```js +Examples + +```js isBrowserTabFocused(); // true ``` @@ -3686,9 +3686,9 @@ const nodeListToArray = nodeList => [...nodeList]; ```
    - Examples - - ```js +Examples + +```js nodeListToArray(document.childNodes); // [ , html ] ``` @@ -3726,9 +3726,9 @@ const observeMutations = (element, callback, options) => { ```
    - Examples - - ```js +Examples + +```js const obs = observeMutations(document, console.log); // Logs all mutations that happen on the page obs.disconnect(); // Disconnects the observer and stops logging mutations on the page ``` @@ -3749,9 +3749,9 @@ const off = (el, evt, fn, opts = false) => el.removeEventListener(evt, fn, opts) ```
    - Examples - - ```js +Examples + +```js const fn = () => console.log('!'); document.body.addEventListener('click', fn); off(document.body, 'click', fn); // no longer logs '!' upon clicking on the page @@ -3778,9 +3778,9 @@ const on = (el, evt, fn, opts = {}) => { ```
    - Examples - - ```js +Examples + +```js const fn = () => console.log('!'); on(document.body, 'click', fn); // logs '!' upon clicking the body on(document.body, 'click', fn, { target: 'p' }); // logs '!' upon clicking a `p` element child of the body @@ -3817,9 +3817,9 @@ const onUserInputChange = callback => { ```
    - Examples - - ```js +Examples + +```js onUserInputChange(type => { console.log('The user is now using', type, 'as an input method.'); }); @@ -3848,9 +3848,9 @@ const prefix = prop => { ```
    - Examples - - ```js +Examples + +```js prefix('appearance'); // 'appearance' on a supported browser, otherwise 'webkitAppearance', 'mozAppearance', 'msAppearance' or 'oAppearance' ``` @@ -3891,9 +3891,9 @@ const recordAnimationFrames = (callback, autoStart = true) => { ```
    - Examples - - ```js +Examples + +```js const cb = () => console.log('Animation frame fired'); const recorder = recordAnimationFrames(cb); // logs 'Animation frame fired' on each animation frame recorder.stop(); // stops logging @@ -3918,9 +3918,9 @@ const redirect = (url, asLink = true) => ```
    - Examples - - ```js +Examples + +```js redirect('https://google.com'); ``` @@ -3955,9 +3955,9 @@ const runAsync = fn => { ```
    - Examples - - ```js +Examples + +```js const longRunningFunction = () => { let result = 0; for (let i = 0; i < 1000; i++) { @@ -4002,9 +4002,9 @@ const scrollToTop = () => { ```
    - Examples - - ```js +Examples + +```js scrollToTop(); ``` @@ -4023,9 +4023,9 @@ const setStyle = (el, ruleName, val) => (el.style[ruleName] = val); ```
    - Examples - - ```js +Examples + +```js setStyle(document.querySelector('p'), 'font-size', '20px'); // The first

    element on the page will have a font-size of 20px ``` @@ -4044,9 +4044,9 @@ const show = (...el) => [...el].forEach(e => (e.style.display = '')); ```

    - Examples - - ```js +Examples + +```js show(...document.querySelectorAll('img')); // Shows all elements on the page ``` @@ -4069,9 +4069,9 @@ const smoothScroll = element => ```
    - Examples - - ```js +Examples + +```js smoothScroll('#fooBar'); // scrolls smoothly to the element with the id fooBar smoothScroll('.fooBar'); // scrolls smoothly to the first element with a class of fooBar ``` @@ -4091,9 +4091,9 @@ const toggleClass = (el, className) => el.classList.toggle(className); ```
    - Examples - - ```js +Examples + +```js toggleClass(document.querySelector('p.special'), 'special'); // The paragraph will not have the 'special' class anymore ``` @@ -4115,9 +4115,9 @@ const triggerEvent = (el, eventType, detail = undefined) => ```
    - Examples - - ```js +Examples + +```js triggerEvent(document.getElementById('myId'), 'click'); triggerEvent(document.getElementById('myId'), 'click', { username: 'bob' }); ``` @@ -4140,9 +4140,9 @@ const UUIDGeneratorBrowser = () => ```
    - Examples - - ```js +Examples + +```js UUIDGeneratorBrowser(); // '7982fcfe-5721-4632-bede-6000885be57d' ``` @@ -4182,9 +4182,9 @@ const formatDuration = ms => { ```
    - Examples - - ```js +Examples + +```js formatDuration(1001); // '1 second, 1 millisecond' formatDuration(34325055574); // '397 days, 6 hours, 44 minutes, 15 seconds, 574 milliseconds' ``` @@ -4204,9 +4204,9 @@ const getColonTimeFromDate = date => date.toTimeString().slice(0, 8); ```
    - Examples - - ```js +Examples + +```js getColonTimeFromDate(new Date()); // "08:38:00" ``` @@ -4226,9 +4226,9 @@ const getDaysDiffBetweenDates = (dateInitial, dateFinal) => ```
    - Examples - - ```js +Examples + +```js getDaysDiffBetweenDates(new Date('2017-12-13'), new Date('2017-12-22')); // 9 ``` @@ -4254,9 +4254,9 @@ const getMeridiemSuffixOfInteger = num => ```
    - Examples - - ```js +Examples + +```js getMeridiemSuffixOfInteger(0); // "12am" getMeridiemSuffixOfInteger(11); // "11am" getMeridiemSuffixOfInteger(13); // "1pm" @@ -4284,9 +4284,9 @@ const tomorrow = (long = false) => { ```
    - Examples - - ```js +Examples + +```js tomorrow(); // 2017-12-27 (if current date is 2017-12-26) tomorrow(true); // 2017-12-27T00:00:00 (if current date is 2017-12-26) ``` @@ -4317,9 +4317,9 @@ const attempt = (fn, ...args) => { ```
    - Examples - - ```js +Examples + +```js var elements = attempt(function(selector) { return document.querySelectorAll(selector); }, '>_>'); @@ -4342,9 +4342,9 @@ const bind = (fn, context, ...boundArgs) => (...args) => fn.apply(context, [...b ```
    - Examples - - ```js +Examples + +```js function greet(greeting, punctuation) { return greeting + ' ' + this.user + punctuation; } @@ -4370,9 +4370,9 @@ const bindKey = (context, fn, ...boundArgs) => (...args) => ```
    - Examples - - ```js +Examples + +```js const freddy = { user: 'fred', greet: function(greeting, punctuation) { @@ -4402,9 +4402,9 @@ const chainAsync = fns => { ```
    - Examples - - ```js +Examples + +```js chainAsync([ next => { console.log('0 seconds'); @@ -4432,9 +4432,9 @@ const compose = (...fns) => fns.reduce((f, g) => (...args) => f(g(...args))); ```
    - Examples - - ```js +Examples + +```js const add5 = x => x + 5; const multiply = (x, y) => x * y; const multiplyAndAdd5 = compose( @@ -4460,9 +4460,9 @@ const composeRight = (...fns) => fns.reduce((f, g) => (...args) => g(f(...args)) ```
    - Examples - - ```js +Examples + +```js const add = (x, y) => x + y; const square = x => x * x; const addAndSquare = composeRight(add, square); @@ -4485,9 +4485,9 @@ const converge = (converger, fns) => (...args) => converger(...fns.map(fn => fn. ```
    - Examples - - ```js +Examples + +```js const average = converge((a, b) => a / b, [ arr => arr.reduce((a, v) => a + v, 0), arr => arr.length @@ -4514,9 +4514,9 @@ const curry = (fn, arity = fn.length, ...args) => ```
    - Examples - - ```js +Examples + +```js curry(Math.pow)(2)(10); // 1024 curry(Math.min, 3)(10)(50)(2); // 2 ``` @@ -4543,9 +4543,9 @@ const debounce = (fn, ms = 0) => { ```
    - Examples - - ```js +Examples + +```js window.addEventListener( 'resize', debounce(() => { @@ -4570,9 +4570,9 @@ const defer = (fn, ...args) => setTimeout(fn, 1, ...args); ```
    - Examples - - ```js +Examples + +```js // Example A: defer(console.log, 'a'), console.log('b'); // logs 'b' then 'a' @@ -4598,9 +4598,9 @@ const delay = (fn, wait, ...args) => setTimeout(fn, wait, ...args); ```
    - Examples - - ```js +Examples + +```js delay( function(text) { console.log(text); @@ -4625,9 +4625,9 @@ const functionName = fn => (console.debug(fn.name), fn); ```
    - Examples - - ```js +Examples + +```js functionName(Math.max); // max (logged in debug channel of console) ``` @@ -4653,9 +4653,9 @@ const hz = (fn, iterations = 100) => { ```
    - Examples - - ```js +Examples + +```js // 10,000 element array const numbers = Array(10000) .fill() @@ -4698,9 +4698,9 @@ const memoize = fn => { ```
    - Examples - - ```js +Examples + +```js // See the `anagrams` snippet. const anagramsCached = memoize(anagrams); anagramsCached('javascript'); // takes a long time @@ -4723,9 +4723,9 @@ const negate = func => (...args) => !func(...args); ```
    - Examples - - ```js +Examples + +```js [1, 2, 3, 4, 5, 6].filter(negate(n => n % 2 === 0)); // [ 1, 3, 5 ] ``` @@ -4752,9 +4752,9 @@ const once = fn => { ```
    - Examples - - ```js +Examples + +```js const startApp = function(event) { console.log(this, event); // document.body, MouseEvent }; @@ -4776,9 +4776,9 @@ const partial = (fn, ...partials) => (...args) => fn(...partials, ...args); ```
    - Examples - - ```js +Examples + +```js const greet = (greeting, name) => greeting + ' ' + name + '!'; const greetHello = partial(greet, 'Hello'); greetHello('John'); // 'Hello John!' @@ -4799,9 +4799,9 @@ const partialRight = (fn, ...partials) => (...args) => fn(...args, ...partials); ```
    - Examples - - ```js +Examples + +```js const greet = (greeting, name) => greeting + ' ' + name + '!'; const greetJohn = partialRight(greet, 'John'); greetJohn('Hello'); // 'Hello John!' @@ -4822,9 +4822,9 @@ const runPromisesInSeries = ps => ps.reduce((p, next) => p.then(next), Promise.r ```
    - Examples - - ```js +Examples + +```js const delay = d => new Promise(r => setTimeout(r, d)); runPromisesInSeries([() => delay(1000), () => delay(2000)]); // Executes each promise sequentially, taking a total of 3 seconds to complete ``` @@ -4844,9 +4844,9 @@ const sleep = ms => new Promise(resolve => setTimeout(resolve, ms)); ```
    - Examples - - ```js +Examples + +```js async function sleepyWork() { console.log("I'm going to sleep for 1 second."); await sleep(1000); @@ -4891,9 +4891,9 @@ const throttle = (fn, wait) => { ```
    - Examples - - ```js +Examples + +```js window.addEventListener( 'resize', throttle(function(evt) { @@ -4922,9 +4922,9 @@ const times = (n, fn, context = undefined) => { ```
    - Examples - - ```js +Examples + +```js var output = ''; times(5, i => (output += i)); console.log(output); // 01234 @@ -4953,9 +4953,9 @@ const uncurry = (fn, n = 1) => (...args) => { ```
    - Examples - - ```js +Examples + +```js const add = x => y => z => x + y + z; const uncurriedAdd = uncurry(add, 3); uncurriedAdd(1, 2, 3); // 6 @@ -4982,9 +4982,9 @@ const unfold = (fn, seed) => { ```
    - Examples - - ```js +Examples + +```js var f = n => (n > 50 ? false : [-n, n + 10]); unfold(f, 10); // [-10, -20, -30, -40, -50] ``` @@ -5004,9 +5004,9 @@ const when = (pred, whenTrue) => x => (pred(x) ? whenTrue(x) : x); ```
    - Examples - - ```js +Examples + +```js const doubleEvenNumbers = when(x => x % 2 === 0, x => x * 2); doubleEvenNumbers(2); // 4 doubleEvenNumbers(1); // 1 @@ -5033,9 +5033,9 @@ const approximatelyEqual = (v1, v2, epsilon = 0.001) => Math.abs(v1 - v2) < epsi ```
    - Examples - - ```js +Examples + +```js approximatelyEqual(Math.PI / 2.0, 1.5708); // true ``` @@ -5054,9 +5054,9 @@ const average = (...nums) => nums.reduce((acc, val) => acc + val, 0) / nums.leng ```
    - Examples - - ```js +Examples + +```js average(...[1, 2, 3]); // 2 average(1, 2, 3); // 2 ``` @@ -5078,9 +5078,9 @@ const averageBy = (arr, fn) => ```
    - Examples - - ```js +Examples + +```js averageBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }], o => o.n); // 5 averageBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }], 'n'); // 5 ``` @@ -5113,9 +5113,9 @@ const binomialCoefficient = (n, k) => { ```
    - Examples - - ```js +Examples + +```js binomialCoefficient(8, 2); // 28 ``` @@ -5135,9 +5135,9 @@ const clampNumber = (num, a, b) => Math.max(Math.min(num, Math.max(a, b)), Math. ```
    - Examples - - ```js +Examples + +```js clampNumber(2, 3, 5); // 3 clampNumber(1, -1, -5); // -1 ``` @@ -5157,9 +5157,9 @@ const degreesToRads = deg => (deg * Math.PI) / 180.0; ```
    - Examples - - ```js +Examples + +```js degreesToRads(90.0); // ~1.5708 ``` @@ -5179,9 +5179,9 @@ const digitize = n => [...`${n}`].map(i => parseInt(i)); ```
    - Examples - - ```js +Examples + +```js digitize(123); // [1, 2, 3] ``` @@ -5200,9 +5200,9 @@ const distance = (x0, y0, x1, y1) => Math.hypot(x1 - x0, y1 - y0); ```
    - Examples - - ```js +Examples + +```js distance(1, 1, 2, 3); // 2.23606797749979 ``` @@ -5242,9 +5242,9 @@ const elo = ([...ratings], kFactor = 32, selfRating) => { ```
    - Examples - - ```js +Examples + +```js // Standard 1v1s elo([1200, 1200]); // [1216, 1184] elo([1200, 1200], 64); // [1232, 1168] @@ -5282,9 +5282,9 @@ const factorial = n => ```
    - Examples - - ```js +Examples + +```js factorial(6); // 720 ``` @@ -5308,9 +5308,9 @@ const fibonacci = n => ```
    - Examples - - ```js +Examples + +```js fibonacci(6); // [0, 1, 1, 2, 3, 5] ``` @@ -5334,9 +5334,9 @@ const gcd = (...arr) => { ```
    - Examples - - ```js +Examples + +```js gcd(8, 36); // 4 gcd(...[12, 8, 32]); // 4 ``` @@ -5362,9 +5362,9 @@ const geometricProgression = (end, start = 1, step = 2) => ```
    - Examples - - ```js +Examples + +```js geometricProgression(256); // [1, 2, 4, 8, 16, 32, 64, 128, 256] geometricProgression(256, 3); // [3, 6, 12, 24, 48, 96, 192] geometricProgression(256, 1, 4); // [1, 4, 16, 64, 256] @@ -5386,9 +5386,9 @@ const hammingDistance = (num1, num2) => ((num1 ^ num2).toString(2).match(/1/g) | ```
    - Examples - - ```js +Examples + +```js hammingDistance(2, 3); // 1 ``` @@ -5411,9 +5411,9 @@ const inRange = (n, start, end = null) => { ```
    - Examples - - ```js +Examples + +```js inRange(3, 2, 5); // true inRange(3, 4); // true inRange(2, 3, 5); // false @@ -5435,9 +5435,9 @@ const isDivisible = (dividend, divisor) => dividend % divisor === 0; ```
    - Examples - - ```js +Examples + +```js isDivisible(6, 3); // true ``` @@ -5457,9 +5457,9 @@ const isEven = num => num % 2 === 0; ```
    - Examples - - ```js +Examples + +```js isEven(3); // false ``` @@ -5483,9 +5483,9 @@ const isPrime = num => { ```
    - Examples - - ```js +Examples + +```js isPrime(11); // true ``` @@ -5509,9 +5509,9 @@ const lcm = (...arr) => { ```
    - Examples - - ```js +Examples + +```js lcm(12, 7); // 84 lcm(...[1, 3, 4, 5]); // 60 ``` @@ -5544,9 +5544,9 @@ const luhnCheck = num => { ```
    - Examples - - ```js +Examples + +```js luhnCheck('4485275742308327'); // true luhnCheck(6011329933655299); // false luhnCheck(123456789); // false @@ -5567,9 +5567,9 @@ const maxBy = (arr, fn) => Math.max(...arr.map(typeof fn === 'function' ? fn : v ```
    - Examples - - ```js +Examples + +```js maxBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }], o => o.n); // 8 maxBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }], 'n'); // 8 ``` @@ -5594,9 +5594,9 @@ const median = arr => { ```
    - Examples - - ```js +Examples + +```js median([5, 6, 50, 1, -5]); // 5 ``` @@ -5615,9 +5615,9 @@ const minBy = (arr, fn) => Math.min(...arr.map(typeof fn === 'function' ? fn : v ```
    - Examples - - ```js +Examples + +```js minBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }], o => o.n); // 2 minBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }], 'n'); // 2 ``` @@ -5638,9 +5638,9 @@ const percentile = (arr, val) => ```
    - Examples - - ```js +Examples + +```js percentile([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 6); // 55 ``` @@ -5659,9 +5659,9 @@ const powerset = arr => arr.reduce((a, v) => a.concat(a.map(r => [v].concat(r))) ```
    - Examples - - ```js +Examples + +```js powerset([1, 2]); // [[], [1], [2], [2,1]] ``` @@ -5686,9 +5686,9 @@ const primes = num => { ```
    - Examples - - ```js +Examples + +```js primes(10); // [2,3,5,7] ``` @@ -5707,9 +5707,9 @@ const radsToDegrees = rad => (rad * 180.0) / Math.PI; ```
    - Examples - - ```js +Examples + +```js radsToDegrees(Math.PI / 2); // 90 ``` @@ -5729,9 +5729,9 @@ const randomIntArrayInRange = (min, max, n = 1) => ```
    - Examples - - ```js +Examples + +```js randomIntArrayInRange(12, 35, 10); // [ 34, 14, 27, 17, 30, 27, 20, 26, 21, 14 ] ``` @@ -5750,9 +5750,9 @@ const randomIntegerInRange = (min, max) => Math.floor(Math.random() * (max - min ```
    - Examples - - ```js +Examples + +```js randomIntegerInRange(0, 5); // 2 ``` @@ -5771,9 +5771,9 @@ const randomNumberInRange = (min, max) => Math.random() * (max - min) + min; ```
    - Examples - - ```js +Examples + +```js randomNumberInRange(2, 10); // 6.0211363285087005 ``` @@ -5793,9 +5793,9 @@ const round = (n, decimals = 0) => Number(`${Math.round(`${n}e${decimals}`)}e-${ ```
    - Examples - - ```js +Examples + +```js round(1.005, 2); // 1.01 ``` @@ -5821,9 +5821,9 @@ const sdbm = str => { ```
    - Examples - - ```js +Examples + +```js sdbm('name'); // -3521204949 ``` @@ -5850,9 +5850,9 @@ const standardDeviation = (arr, usePopulation = false) => { ```
    - Examples - - ```js +Examples + +```js standardDeviation([10, 2, 38, 23, 38, 23, 21]); // 13.284434142114991 (sample) standardDeviation([10, 2, 38, 23, 38, 23, 21], true); // 12.29899614287479 (population) ``` @@ -5872,9 +5872,9 @@ const sum = (...arr) => [...arr].reduce((acc, val) => acc + val, 0); ```
    - Examples - - ```js +Examples + +```js sum(...[1, 2, 3, 4]); // 10 ``` @@ -5894,9 +5894,9 @@ const sumBy = (arr, fn) => ```
    - Examples - - ```js +Examples + +```js sumBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }], o => o.n); // 20 sumBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }], 'n'); // 20 ``` @@ -5922,9 +5922,9 @@ const sumPower = (end, power = 2, start = 1) => ```
    - Examples - - ```js +Examples + +```js sumPower(10); // 385 sumPower(10, 3); //3025 sumPower(10, 3, 5); //2925 @@ -5947,9 +5947,9 @@ const toSafeInteger = num => ```
    - Examples - - ```js +Examples + +```js toSafeInteger('3.2'); // 3 toSafeInteger(Infinity); // 9007199254740991 ``` @@ -5974,9 +5974,9 @@ const atob = str => new Buffer(str, 'base64').toString('binary'); ```
    - Examples - - ```js +Examples + +```js atob('Zm9vYmFy'); // 'foobar' ``` @@ -5995,9 +5995,9 @@ const btoa = str => new Buffer(str, 'binary').toString('base64'); ```
    - Examples - - ```js +Examples + +```js btoa('foobar'); // 'Zm9vYmFy' ``` @@ -6034,9 +6034,9 @@ const colorize = (...args) => ({ ```
    - Examples - - ```js +Examples + +```js console.log(colorize('foo').red); // 'foo' (red letters) console.log(colorize('foo', 'bar').bgBlue); // 'foo bar' (blue background) console.log(colorize(colorize('foo').yellow, colorize('foo').green).bgWhite); // 'foo bar' (first word in yellow letters, second word in green letters, white background for both) @@ -6059,9 +6059,9 @@ const hasFlags = (...flags) => ```
    - Examples - - ```js +Examples + +```js // node myScript.js -s --test --cool=true hasFlags('-s'); // true hasFlags('--test', 'cool=true', '-s'); // true @@ -6096,9 +6096,9 @@ const hashNode = val => ```
    - Examples - - ```js +Examples + +```js hashNode(JSON.stringify({ a: 'a', b: [1, 2, 3, 4], foo: { c: 'bar' } })).then(console.log); // '04aa106279f5977f59f9067fa9712afc4aedc6f5862a8defc34552d8c7206393' ``` @@ -6117,9 +6117,9 @@ const isTravisCI = () => 'TRAVIS' in process.env && 'CI' in process.env; ```
    - Examples - - ```js +Examples + +```js isTravisCI(); // true (if code is running on Travis CI) ``` @@ -6140,9 +6140,9 @@ const JSONToFile = (obj, filename) => ```
    - Examples - - ```js +Examples + +```js JSONToFile({ test: 'is passed' }, 'testJsonFile'); // writes the object to 'testJsonFile.json' ``` @@ -6168,9 +6168,9 @@ const readFileLines = filename => ```
    - Examples - - ```js +Examples + +```js /* contents of test.txt : line1 @@ -6198,9 +6198,9 @@ const untildify = str => str.replace(/^~($|\/|\\)/, `${require('os').homedir()}$ ```
    - Examples - - ```js +Examples + +```js untildify('~/node'); // '/Users/aUser/node' ``` @@ -6223,9 +6223,9 @@ const UUIDGeneratorNode = () => ```
    - Examples - - ```js +Examples + +```js UUIDGeneratorNode(); // '79c7c136-60ee-40a2-beb2-856f1feabefc' ``` @@ -6257,9 +6257,9 @@ const bindAll = (obj, ...fns) => ```
    - Examples - - ```js +Examples + +```js var view = { label: 'docs', click: function() { @@ -6293,9 +6293,9 @@ const deepClone = obj => { ```
    - Examples - - ```js +Examples + +```js const a = { foo: 'bar', obj: { a: 1, b: 2 } }; const b = deepClone(a); // a !== b, a.obj !== b.obj ``` @@ -6319,9 +6319,9 @@ const deepFreeze = obj => ```
    - Examples - - ```js +Examples + +```js 'use strict'; const o = deepFreeze([1, [2, 3]]); @@ -6345,9 +6345,9 @@ const defaults = (obj, ...defs) => Object.assign({}, obj, ...defs.reverse(), obj ```
    - Examples - - ```js +Examples + +```js defaults({ a: 1 }, { b: 2 }, { b: 6 }, { a: 3 }); // { a: 1, b: 2 } ``` @@ -6373,9 +6373,9 @@ const dig = (obj, target) => ```
    - Examples - - ```js +Examples + +```js const data = { level1: { level2: { @@ -6413,9 +6413,9 @@ const equals = (a, b) => { ```
    - Examples - - ```js +Examples + +```js equals({ a: [2, { e: 3 }], b: [4], c: 'foo' }, { a: [2, { e: 3 }], b: [4], c: 'foo' }); // true ``` @@ -6434,9 +6434,9 @@ const findKey = (obj, fn) => Object.keys(obj).find(key => fn(obj[key], key, obj) ```
    - Examples - - ```js +Examples + +```js findKey( { barney: { age: 36, active: true }, @@ -6465,9 +6465,9 @@ const findLastKey = (obj, fn) => ```
    - Examples - - ```js +Examples + +```js findLastKey( { barney: { age: 36, active: true }, @@ -6503,9 +6503,9 @@ const flattenObject = (obj, prefix = '') => ```
    - Examples - - ```js +Examples + +```js flattenObject({ a: { b: { c: 1 } }, d: 1 }); // { 'a.b.c': 1, d: 1 } ``` @@ -6524,9 +6524,9 @@ const forOwn = (obj, fn) => Object.keys(obj).forEach(key => fn(obj[key], key, ob ```
    - Examples - - ```js +Examples + +```js forOwn({ foo: 'bar', a: 1 }, v => console.log(v)); // 'bar', 1 ``` @@ -6548,9 +6548,9 @@ const forOwnRight = (obj, fn) => ```
    - Examples - - ```js +Examples + +```js forOwnRight({ foo: 'bar', a: 1 }, v => console.log(v)); // 1, 'bar' ``` @@ -6576,9 +6576,9 @@ const functions = (obj, inherited = false) => ```
    - Examples - - ```js +Examples + +```js function Foo() { this.a = () => 1; this.b = () => 2; @@ -6610,9 +6610,9 @@ const get = (from, ...selectors) => ```
    - Examples - - ```js +Examples + +```js const obj = { selector: { to: { val: 'val to select' } }, target: [1, 2, { a: 'test' }] }; get(obj, 'selector.to.val', 'target[0]', 'target[2].a'); // ['val to select', 1, 'test'] ``` @@ -6639,9 +6639,9 @@ const invertKeyValues = (obj, fn) => ```
    - Examples - - ```js +Examples + +```js invertKeyValues({ a: 1, b: 2, c: 1 }); // { 1: [ 'a', 'c' ], 2: [ 'b' ] } invertKeyValues({ a: 1, b: 2, c: 1 }, value => 'group' + value); // { group1: [ 'a', 'c' ], group2: [ 'b' ] } ``` @@ -6666,9 +6666,9 @@ const lowercaseKeys = obj => ```
    - Examples - - ```js +Examples + +```js const myObj = { Name: 'Adam', sUrnAME: 'Smith' }; const myObjLower = lowercaseKeys(myObj); // {name: 'Adam', surname: 'Smith'}; ``` @@ -6693,9 +6693,9 @@ const mapKeys = (obj, fn) => ```
    - Examples - - ```js +Examples + +```js mapKeys({ a: 1, b: 2 }, (val, key) => key + val); // { a1: 1, b2: 2 } ``` @@ -6719,9 +6719,9 @@ const mapValues = (obj, fn) => ```
    - Examples - - ```js +Examples + +```js const users = { fred: { user: 'fred', age: 40 }, pebbles: { user: 'pebbles', age: 1 } @@ -6745,9 +6745,9 @@ const matches = (obj, source) => ```
    - Examples - - ```js +Examples + +```js matches({ age: 25, hair: 'long', beard: true }, { hair: 'long', beard: true }); // true matches({ hair: 'long', beard: true }, { age: 25, hair: 'long', beard: true }); // false ``` @@ -6774,9 +6774,9 @@ const matchesWith = (obj, source, fn) => ```
    - Examples - - ```js +Examples + +```js const isGreeting = val => /^h(?:i|ello)$/.test(val); matchesWith( { greeting: 'hello' }, @@ -6809,9 +6809,9 @@ const merge = (...objs) => ```
    - Examples - - ```js +Examples + +```js const object = { a: [{ x: 2 }, { y: 4 }], b: 1 @@ -6846,9 +6846,9 @@ const nest = (items, id = null, link = 'parent_id') => ```
    - Examples - - ```js +Examples + +```js // One top level comment const comments = [ { id: 1, parent_id: null }, @@ -6876,9 +6876,9 @@ const objectFromPairs = arr => arr.reduce((a, [key, val]) => ((a[key] = val), a) ```
    - Examples - - ```js +Examples + +```js objectFromPairs([['a', 1], ['b', 2]]); // {a: 1, b: 2} ``` @@ -6897,9 +6897,9 @@ const objectToPairs = obj => Object.keys(obj).map(k => [k, obj[k]]); ```
    - Examples - - ```js +Examples + +```js objectToPairs({ a: 1, b: 2 }); // [['a',1],['b',2]] ``` @@ -6922,9 +6922,9 @@ const omit = (obj, arr) => ```
    - Examples - - ```js +Examples + +```js omit({ a: 1, b: '2', c: 3 }, ['b']); // { 'a': 1, 'c': 3 } ``` @@ -6947,9 +6947,9 @@ const omitBy = (obj, fn) => ```
    - Examples - - ```js +Examples + +```js omitBy({ a: 1, b: '2', c: 3 }, x => typeof x === 'number'); // { b: '2' } ``` @@ -6978,9 +6978,9 @@ const orderBy = (arr, props, orders) => ```
    - Examples - - ```js +Examples + +```js const users = [{ name: 'fred', age: 48 }, { name: 'barney', age: 36 }, { name: 'fred', age: 40 }]; orderBy(users, ['name', 'age'], ['asc', 'desc']); // [{name: 'barney', age: 36}, {name: 'fred', age: 48}, {name: 'fred', age: 40}] orderBy(users, ['name', 'age']); // [{name: 'barney', age: 36}, {name: 'fred', age: 40}, {name: 'fred', age: 48}] @@ -7002,9 +7002,9 @@ const pick = (obj, arr) => ```
    - Examples - - ```js +Examples + +```js pick({ a: 1, b: '2', c: 3 }, ['a', 'c']); // { 'a': 1, 'c': 3 } ``` @@ -7027,9 +7027,9 @@ const pickBy = (obj, fn) => ```
    - Examples - - ```js +Examples + +```js pickBy({ a: 1, b: '2', c: 3 }, x => typeof x === 'number'); // { 'a': 1, 'c': 3 } ``` @@ -7055,9 +7055,9 @@ const renameKeys = (keysMap, obj) => ```
    - Examples - - ```js +Examples + +```js const obj = { name: 'Bobo', job: 'Front-End Master', shoeSize: 100 }; renameKeys({ name: 'firstName', job: 'passion' }, obj); // { firstName: 'Bobo', passion: 'Front-End Master', shoeSize: 100 } ``` @@ -7077,9 +7077,9 @@ const shallowClone = obj => Object.assign({}, obj); ```
    - Examples - - ```js +Examples + +```js const a = { x: true, y: 1 }; const b = shallowClone(a); // a !== b ``` @@ -7111,9 +7111,9 @@ const size = val => ```
    - Examples - - ```js +Examples + +```js size([1, 2, 3, 4, 5]); // 5 size('size'); // 4 size({ one: 1, two: 2, three: 3 }); // 3 @@ -7134,9 +7134,9 @@ const transform = (obj, fn, acc) => Object.keys(obj).reduce((a, k) => fn(a, obj[ ```
    - Examples - - ```js +Examples + +```js transform( { a: 1, b: 2, c: 1 }, (r, v, k) => { @@ -7162,9 +7162,9 @@ const truthCheckCollection = (collection, pre) => collection.every(obj => obj[pr ```
    - Examples - - ```js +Examples + +```js truthCheckCollection([{ user: 'Tinky-Winky', sex: 'male' }, { user: 'Dipsy', sex: 'male' }], 'sex'); // true ``` @@ -7200,9 +7200,9 @@ const unflattenObject = obj => ```
    - Examples - - ```js +Examples + +```js unflattenObject({ 'a.b.c': 1, d: 1 }); // { a: { b: { c: 1 } }, d: 1 } ``` @@ -7226,9 +7226,9 @@ const byteSize = str => new Blob([str]).size; ```
    - Examples - - ```js +Examples + +```js byteSize('😀'); // 4 byteSize('Hello World'); // 11 ``` @@ -7250,9 +7250,9 @@ const capitalize = ([first, ...rest], lowerRest = false) => ```
    - Examples - - ```js +Examples + +```js capitalize('fooBar'); // 'FooBar' capitalize('fooBar', true); // 'Foobar' ``` @@ -7272,9 +7272,9 @@ const capitalizeEveryWord = str => str.replace(/\b[a-z]/g, char => char.toUpperC ```
    - Examples - - ```js +Examples + +```js capitalizeEveryWord('hello world!'); // 'Hello World!' ``` @@ -7300,9 +7300,9 @@ const CSVToArray = (data, delimiter = ',', omitFirstRow = false) => ```
    - Examples - - ```js +Examples + +```js CSVToArray('a,b\nc,d'); // [['a','b'],['c','d']]; CSVToArray('a;b\nc;d', ';'); // [['a','b'],['c','d']]; CSVToArray('col1,col2\na,b\nc,d', ',', true); // [['a','b'],['c','d']]; @@ -7336,9 +7336,9 @@ const CSVToJSON = (data, delimiter = ',') => { ```
    - Examples - - ```js +Examples + +```js CSVToJSON('col1,col2\na,b\nc,d'); // [{'col1': 'a', 'col2': 'b'}, {'col1': 'c', 'col2': 'd'}]; CSVToJSON('col1;col2\na;b\nc;d', ';'); // [{'col1': 'a', 'col2': 'b'}, {'col1': 'c', 'col2': 'd'}]; ``` @@ -7360,9 +7360,9 @@ const decapitalize = ([first, ...rest], upperRest = false) => ```
    - Examples - - ```js +Examples + +```js decapitalize('FooBar'); // 'fooBar' decapitalize('FooBar', true); // 'fOOBAR' ``` @@ -7393,9 +7393,9 @@ const escapeHTML = str => ```
    - Examples - - ```js +Examples + +```js escapeHTML('Me & you'); // '<a href="#">Me & you</a>' ``` @@ -7414,9 +7414,9 @@ const escapeRegExp = str => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); ```
    - Examples - - ```js +Examples + +```js escapeRegExp('(test)'); // \\(test\\) ``` @@ -7440,9 +7440,9 @@ const fromCamelCase = (str, separator = '_') => ```
    - Examples - - ```js +Examples + +```js fromCamelCase('someDatabaseFieldName', ' '); // 'some database field name' fromCamelCase('someLabelThatNeedsToBeCamelized', '-'); // 'some-label-that-needs-to-be-camelized' fromCamelCase('someJavascriptProperty', '_'); // 'some_javascript_property' @@ -7463,9 +7463,9 @@ const isAbsoluteURL = str => /^[a-z][a-z0-9+.-]*:/.test(str); ```
    - Examples - - ```js +Examples + +```js isAbsoluteURL('https://google.com'); // true isAbsoluteURL('ftp://www.myserver.net'); // true isAbsoluteURL('/foo/bar'); // false @@ -7495,9 +7495,9 @@ const isAnagram = (str1, str2) => { ```
    - Examples - - ```js +Examples + +```js isAnagram('iceman', 'cinema'); // true ``` @@ -7516,9 +7516,9 @@ const isLowerCase = str => str === str.toLowerCase(); ```
    - Examples - - ```js +Examples + +```js isLowerCase('abc'); // true isLowerCase('a3@$'); // true isLowerCase('Ab4'); // false @@ -7540,9 +7540,9 @@ const isUpperCase = str => str === str.toUpperCase(); ```
    - Examples - - ```js +Examples + +```js isUpperCase('ABC'); // true isLowerCase('A3@$'); // true isLowerCase('aB4'); // false @@ -7569,9 +7569,9 @@ const mapString = (str, fn) => ```
    - Examples - - ```js +Examples + +```js mapString('lorem ipsum', c => c.toUpperCase()); // 'LOREM IPSUM' ``` @@ -7594,9 +7594,9 @@ const mask = (cc, num = 4, mask = '*') => ```
    - Examples - - ```js +Examples + +```js mask(1234567890); // '******7890' mask(1234567890, 3); // '*******890' mask(1234567890, -4, '$'); // '$$$$567890' @@ -7619,9 +7619,9 @@ const pad = (str, length, char = ' ') => ```
    - Examples - - ```js +Examples + +```js pad('cat', 8); // ' cat ' pad(String(42), 6, '0'); // '004200' pad('foobar', 3); // 'foobar' @@ -7646,9 +7646,9 @@ const palindrome = str => { ```
    - Examples - - ```js +Examples + +```js palindrome('taco cat'); // true ``` @@ -7672,9 +7672,9 @@ const pluralize = (val, word, plural = word + 's') => { ```
    - Examples - - ```js +Examples + +```js pluralize(0, 'apple'); // 'apples' pluralize(1, 'apple'); // 'apple' pluralize(2, 'apple'); // 'apples' @@ -7703,9 +7703,9 @@ const removeNonASCII = str => str.replace(/[^\x20-\x7E]/g, ''); ```
    - Examples - - ```js +Examples + +```js removeNonASCII('äÄçÇéÉêlorem-ipsumöÖÐþúÚ'); // 'lorem-ipsum' ``` @@ -7725,9 +7725,9 @@ const reverseString = str => [...str].reverse().join(''); ```
    - Examples - - ```js +Examples + +```js reverseString('foobar'); // 'raboof' ``` @@ -7746,9 +7746,9 @@ const sortCharactersInString = str => [...str].sort((a, b) => a.localeCompare(b) ```
    - Examples - - ```js +Examples + +```js sortCharactersInString('cabbage'); // 'aabbceg' ``` @@ -7767,9 +7767,9 @@ const splitLines = str => str.split(/\r?\n/); ```
    - Examples - - ```js +Examples + +```js splitLines('This\nis a\nmultiline\nstring.\n'); // ['This', 'is a', 'multiline', 'string.' , ''] ``` @@ -7802,9 +7802,9 @@ const stringPermutations = str => { ```
    - Examples - - ```js +Examples + +```js stringPermutations('abc'); // ['abc','acb','bac','bca','cab','cba'] ``` @@ -7823,9 +7823,9 @@ const stripHTMLTags = str => str.replace(/<[^>]*>/g, ''); ```
    - Examples - - ```js +Examples + +```js stripHTMLTags('

    lorem ipsum

    '); // 'lorem ipsum' ``` @@ -7852,9 +7852,9 @@ const toCamelCase = str => { ```
    - Examples - - ```js +Examples + +```js toCamelCase('some_database_field_name'); // 'someDatabaseFieldName' toCamelCase('Some label that needs to be camelized'); // 'someLabelThatNeedsToBeCamelized' toCamelCase('some-javascript-property'); // 'someJavascriptProperty' @@ -7881,9 +7881,9 @@ const toKebabCase = str => ```
    - Examples - - ```js +Examples + +```js toKebabCase('camelCase'); // 'camel-case' toKebabCase('some text'); // 'some-text' toKebabCase('some-mixed_string With spaces_underscores-and-hyphens'); // 'some-mixed-string-with-spaces-underscores-and-hyphens' @@ -7911,9 +7911,9 @@ const toSnakeCase = str => ```
    - Examples - - ```js +Examples + +```js toSnakeCase('camelCase'); // 'camel_case' toSnakeCase('some text'); // 'some_text' toSnakeCase('some-mixed_string With spaces_underscores-and-hyphens'); // 'some_mixed_string_with_spaces_underscores_and_hyphens' @@ -7938,9 +7938,9 @@ const truncateString = (str, num) => ```
    - Examples - - ```js +Examples + +```js truncateString('boomerang', 7); // 'boom...' ``` @@ -7970,9 +7970,9 @@ const unescapeHTML = str => ```
    - Examples - - ```js +Examples + +```js unescapeHTML('<a href="#">Me & you</a>'); // 'Me & you' ``` @@ -7999,9 +7999,9 @@ const URLJoin = (...args) => ```
    - Examples - - ```js +Examples + +```js URLJoin('http://www.google.com', 'a', '/b/cd', '?foo=123', '?bar=foo'); // 'http://www.google.com/a/b/cd?foo=123&bar=foo' ``` @@ -8021,9 +8021,9 @@ const words = (str, pattern = /[^a-zA-Z-]+/) => str.split(pattern).filter(Boolea ```
    - Examples - - ```js +Examples + +```js words('I love javaScript!!'); // ["I", "love", "javaScript"] words('python, javaScript & coffee'); // ["python", "javaScript", "coffee"] ``` @@ -8049,9 +8049,9 @@ const getType = v => ```
    - Examples - - ```js +Examples + +```js getType(new Set([1, 2, 3])); // 'set' ``` @@ -8070,9 +8070,9 @@ const is = (type, val) => ![, null].includes(val) && val.constructor === type; ```
    - Examples - - ```js +Examples + +```js is(Array, [1]); // true is(ArrayBuffer, new ArrayBuffer()); // true is(Map, new Map()); // true @@ -8103,9 +8103,9 @@ const isArrayLike = obj => obj != null && typeof obj[Symbol.iterator] === 'funct ```
    - Examples - - ```js +Examples + +```js isArrayLike(document.querySelectorAll('.className')); // true isArrayLike('abc'); // true isArrayLike(null); // false @@ -8126,9 +8126,9 @@ const isBoolean = val => typeof val === 'boolean'; ```
    - Examples - - ```js +Examples + +```js isBoolean(null); // false isBoolean(false); // true ``` @@ -8148,9 +8148,9 @@ const isEmpty = val => val == null || !(Object.keys(val) || val).length; ```
    - Examples - - ```js +Examples + +```js isEmpty(new Map()); // true isEmpty(new Set()); // true isEmpty([]); // true @@ -8178,9 +8178,9 @@ const isFunction = val => typeof val === 'function'; ```
    - Examples - - ```js +Examples + +```js isFunction('x'); // false isFunction(x => x); // true ``` @@ -8200,9 +8200,9 @@ const isNil = val => val === undefined || val === null; ```
    - Examples - - ```js +Examples + +```js isNil(null); // true isNil(undefined); // true ``` @@ -8222,9 +8222,9 @@ const isNull = val => val === null; ```
    - Examples - - ```js +Examples + +```js isNull(null); // true ``` @@ -8243,9 +8243,9 @@ const isNumber = val => typeof val === 'number'; ```
    - Examples - - ```js +Examples + +```js isNumber('1'); // false isNumber(1); // true ``` @@ -8266,9 +8266,9 @@ const isObject = obj => obj === Object(obj); ```
    - Examples - - ```js +Examples + +```js isObject([1, 2, 3, 4]); // true isObject([]); // true isObject(['Hello!']); // true @@ -8292,9 +8292,9 @@ const isObjectLike = val => val !== null && typeof val === 'object'; ```
    - Examples - - ```js +Examples + +```js isObjectLike({}); // true isObjectLike([1, 2, 3]); // true isObjectLike(x => x); // false @@ -8316,9 +8316,9 @@ const isPlainObject = val => !!val && typeof val === 'object' && val.constructor ```
    - Examples - - ```js +Examples + +```js isPlainObject({ a: 1 }); // true isPlainObject(new Map()); // false ``` @@ -8340,9 +8340,9 @@ const isPrimitive = val => !['object', 'function'].includes(typeof val) || val = ```
    - Examples - - ```js +Examples + +```js isPrimitive(null); // true isPrimitive(50); // true isPrimitive('Hello!'); // true @@ -8369,9 +8369,9 @@ const isPromiseLike = obj => ```
    - Examples - - ```js +Examples + +```js isPromiseLike({ then: function() { return ''; @@ -8396,9 +8396,9 @@ const isString = val => typeof val === 'string'; ```
    - Examples - - ```js +Examples + +```js isString('10'); // true ``` @@ -8417,9 +8417,9 @@ const isSymbol = val => typeof val === 'symbol'; ```
    - Examples - - ```js +Examples + +```js isSymbol(Symbol('x')); // true ``` @@ -8438,9 +8438,9 @@ const isUndefined = val => val === undefined; ```
    - Examples - - ```js +Examples + +```js isUndefined(undefined); // true ``` @@ -8466,9 +8466,9 @@ const isValidJSON = obj => { ```
    - Examples - - ```js +Examples + +```js isValidJSON('{"name":"Adam","age":20}'); // true isValidJSON('{"name":"Adam",age:"20"}'); // false isValidJSON(null); // true @@ -8494,9 +8494,9 @@ const castArray = val => (Array.isArray(val) ? val : [val]); ```
    - Examples - - ```js +Examples + +```js castArray('foo'); // ['foo'] castArray([1]); // [1] ``` @@ -8516,9 +8516,9 @@ const cloneRegExp = regExp => new RegExp(regExp.source, regExp.flags); ```
    - Examples - - ```js +Examples + +```js const regExp = /lorem ipsum/gi; const regExp2 = cloneRegExp(regExp); // /lorem ipsum/gi ``` @@ -8538,9 +8538,9 @@ const coalesce = (...args) => args.find(_ => ![undefined, null].includes(_)); ```
    - Examples - - ```js +Examples + +```js coalesce(null, undefined, '', NaN, 'Waldo'); // "" ``` @@ -8559,9 +8559,9 @@ const coalesceFactory = valid => (...args) => args.find(valid); ```
    - Examples - - ```js +Examples + +```js const customCoalesce = coalesceFactory(_ => ![null, undefined, '', NaN].includes(_)); customCoalesce(undefined, null, NaN, '', 'Waldo'); // "Waldo" ``` @@ -8588,9 +8588,9 @@ const extendHex = shortHex => ```
    - Examples - - ```js +Examples + +```js extendHex('#03f'); // '#0033ff' extendHex('05a'); // '#0055aa' ``` @@ -8615,9 +8615,9 @@ const getURLParameters = url => ```
    - Examples - - ```js +Examples + +```js getURLParameters('http://url.com/page?name=Adam&surname=Smith'); // {name: 'Adam', surname: 'Smith'} getURLParameters('google.com'); // {} ``` @@ -8655,9 +8655,9 @@ const hexToRGB = hex => { ```
    - Examples - - ```js +Examples + +```js hexToRGB('#27ae60ff'); // 'rgba(39, 174, 96, 255)' hexToRGB('27ae60'); // 'rgb(39, 174, 96)' hexToRGB('#fff'); // 'rgb(255, 255, 255)' @@ -8687,9 +8687,9 @@ const httpGet = (url, callback, err = console.error) => { ```
    - Examples - - ```js +Examples + +```js httpGet( 'https://jsonplaceholder.typicode.com/posts/1', console.log @@ -8730,9 +8730,9 @@ const httpPost = (url, data, callback, err = console.error) => { ```
    - Examples - - ```js +Examples + +```js const newPost = { userId: 1, id: 1337, @@ -8780,9 +8780,9 @@ const isBrowser = () => ![typeof window, typeof document].includes('undefined'); ```
    - Examples - - ```js +Examples + +```js isBrowser(); // true (browser) isBrowser(); // false (Node) ``` @@ -8811,9 +8811,9 @@ const mostPerformant = (fns, iterations = 10000) => { ```
    - Examples - - ```js +Examples + +```js mostPerformant([ () => { // Loops through the entire array before returning `false` @@ -8841,9 +8841,9 @@ const nthArg = n => (...args) => args.slice(n)[0]; ```
    - Examples - - ```js +Examples + +```js const third = nthArg(2); third(1, 2, 3); // 3 third(1, 2); // undefined @@ -8875,9 +8875,9 @@ const parseCookie = str => ```
    - Examples - - ```js +Examples + +```js parseCookie('foo=bar; equation=E%3Dmc%5E2'); // { foo: 'bar', equation: 'E=mc^2' } ``` @@ -8906,9 +8906,9 @@ const prettyBytes = (num, precision = 3, addSpace = true) => { ```
    - Examples - - ```js +Examples + +```js prettyBytes(1000); // "1 KB" prettyBytes(-27145424323.5821, 5); // "-27.145 GB" prettyBytes(123456789, 3, false); // "123MB" @@ -8932,9 +8932,9 @@ const randomHexColorCode = () => { ```
    - Examples - - ```js +Examples + +```js randomHexColorCode(); // "#e34155" ``` @@ -8953,9 +8953,9 @@ const RGBToHex = (r, g, b) => ((r << 16) + (g << 8) + b).toString(16).padStart(6 ```
    - Examples - - ```js +Examples + +```js RGBToHex(255, 165, 1); // 'ffa501' ``` @@ -8974,9 +8974,9 @@ const serializeCookie = (name, val) => `${encodeURIComponent(name)}=${encodeURIC ```
    - Examples - - ```js +Examples + +```js serializeCookie('foo', 'bar'); // 'foo=bar' ``` @@ -9000,9 +9000,9 @@ const timeTaken = callback => { ```
    - Examples - - ```js +Examples + +```js timeTaken(() => Math.pow(2, 10)); // 1024, (logged): timeTaken: 0.02099609375ms ``` @@ -9022,9 +9022,9 @@ const toCurrency = (n, curr, LanguageFormat = undefined) => ```
    - Examples - - ```js +Examples + +```js toCurrency(123456.789, 'EUR'); // €123,456.79 | currency: Euro | currencyLangFormat: Local toCurrency(123456.789, 'USD', 'en-us'); // $123,456.79 | currency: US Dollar | currencyLangFormat: English (United States) toCurrency(123456.789, 'USD', 'fa'); // ۱۲۳٬۴۵۶٫۷۹ ؜$ | currency: US Dollar | currencyLangFormat: Farsi @@ -9045,9 +9045,9 @@ const toDecimalMark = num => num.toLocaleString('en-US'); ```
    - Examples - - ```js +Examples + +```js toDecimalMark(12305030388.9087); // "12,305,030,388.909" ``` @@ -9077,9 +9077,9 @@ const toOrdinalSuffix = num => { ```
    - Examples - - ```js +Examples + +```js toOrdinalSuffix('123'); // "123rd" ``` @@ -9100,9 +9100,9 @@ const validateNumber = n => !isNaN(parseFloat(n)) && isFinite(n) && Number(n) == ```
    - Examples - - ```js +Examples + +```js validateNumber('10'); // true ``` @@ -9123,9 +9123,9 @@ const yesNo = (val, def = false) => ```
    - Examples - - ```js +Examples + +```js yesNo('Y'); // true yesNo('yes'); // true yesNo('No'); // false diff --git a/package-lock.json b/package-lock.json index a1a8dbdde..991795cd9 100644 --- a/package-lock.json +++ b/package-lock.json @@ -207,6 +207,7 @@ "version": "1.0.10", "resolved": "https://registry.npmjs.org/argparse/-/argparse-1.0.10.tgz", "integrity": "sha512-o5Roy6tNG4SL/FOkCAN6RzjiakZS25RLYFrcMttJqbdd8BWrnA+fGz57iN5Pb06pvBGvl5gQ0B48dJlslXvoTg==", + "dev": true, "requires": { "sprintf-js": "1.0.3" } @@ -1533,7 +1534,8 @@ "builtin-modules": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-1.1.1.tgz", - "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=" + "integrity": "sha1-Jw8HbFpywC9bZaR9+Uxf46J4iS8=", + "dev": true }, "cache-base": { "version": "1.0.1", @@ -1896,6 +1898,7 @@ "version": "5.0.6", "resolved": "https://registry.npmjs.org/cosmiconfig/-/cosmiconfig-5.0.6.tgz", "integrity": "sha512-6DWfizHriCrFWURP1/qyhsiFvYdlJzbCzmtFWh744+KyWsJo5+kPzUZZaMRSSItoYc0pxFX7gEO7ZC1/gN/7AQ==", + "dev": true, "requires": { "is-directory": "0.3.1", "js-yaml": "3.12.0", @@ -1906,6 +1909,7 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-4.0.0.tgz", "integrity": "sha1-vjX1Qlvh9/bHRxhPmKeIy5lHfuA=", + "dev": true, "requires": { "error-ex": "1.3.1", "json-parse-better-errors": "1.0.2" @@ -2223,6 +2227,7 @@ "version": "1.3.1", "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.1.tgz", "integrity": "sha1-+FWobOYa3E6GIcPNoh56dhLDqNw=", + "dev": true, "requires": { "is-arrayish": "0.2.1" } @@ -2576,7 +2581,8 @@ "esprima": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/esprima/-/esprima-4.0.0.tgz", - "integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw==" + "integrity": "sha512-oftTcaMu/EGrEIu904mWteKIv8vMuOgGYo7EhVJJN00R/EED9DCua/xxHRdYnKtcECzVg7xOWhflvJMnqcFZjw==", + "dev": true }, "esquery": { "version": "1.0.1", @@ -3698,12 +3704,14 @@ "get-stdin": { "version": "6.0.0", "resolved": "https://registry.npmjs.org/get-stdin/-/get-stdin-6.0.0.tgz", - "integrity": "sha512-jp4tHawyV7+fkkSKyvjuLZswblUtz+SQKzSWnBbii16BuZksJlU1wuBYXY75r+duh/llF1ur6oNwi+2ZzjKZ7g==" + "integrity": "sha512-jp4tHawyV7+fkkSKyvjuLZswblUtz+SQKzSWnBbii16BuZksJlU1wuBYXY75r+duh/llF1ur6oNwi+2ZzjKZ7g==", + "dev": true }, "get-stream": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-3.0.0.tgz", - "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=" + "integrity": "sha1-jpQ9E1jcN1VQVOy+LtsFqhdO3hQ=", + "dev": true }, "get-value": { "version": "2.0.6", @@ -4024,7 +4032,8 @@ "hosted-git-info": { "version": "2.6.0", "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.6.0.tgz", - "integrity": "sha512-lIbgIIQA3lz5XaB6vxakj6sDHADJiZadYEJB+FgA+C4nubM1NwcuvUr9EJPmnH1skZqpqUzWborWo8EIUi0Sdw==" + "integrity": "sha512-lIbgIIQA3lz5XaB6vxakj6sDHADJiZadYEJB+FgA+C4nubM1NwcuvUr9EJPmnH1skZqpqUzWborWo8EIUi0Sdw==", + "dev": true }, "html-encoding-sniffer": { "version": "1.0.2", @@ -4065,6 +4074,7 @@ "version": "1.0.0-rc.14", "resolved": "https://registry.npmjs.org/husky/-/husky-1.0.0-rc.14.tgz", "integrity": "sha512-lxdl0+FrKhRXvhOW978oCHCiaXQAtwoR0hdaPY1CwKd+dgbtktepEvk/3DXwQ7L1YriuG/9HDc4AHlzQ0T6cNw==", + "dev": true, "requires": { "cosmiconfig": "5.0.6", "execa": "0.9.0", @@ -4081,12 +4091,14 @@ "ci-info": { "version": "1.5.1", "resolved": "https://registry.npmjs.org/ci-info/-/ci-info-1.5.1.tgz", - "integrity": "sha512-fKFIKXaYiL1exImwJ0AhR/6jxFPSKQBk2ayV5NiNoruUs2+rxC2kNw0EG+1Z9dugZRdCrppskQ8DN2cyaUM1Hw==" + "integrity": "sha512-fKFIKXaYiL1exImwJ0AhR/6jxFPSKQBk2ayV5NiNoruUs2+rxC2kNw0EG+1Z9dugZRdCrppskQ8DN2cyaUM1Hw==", + "dev": true }, "cross-spawn": { "version": "5.1.0", "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-5.1.0.tgz", "integrity": "sha1-6L0O/uWPz/b4+UUQoKVUu/ojVEk=", + "dev": true, "requires": { "lru-cache": "4.1.2", "shebang-command": "1.2.0", @@ -4097,6 +4109,7 @@ "version": "0.9.0", "resolved": "https://registry.npmjs.org/execa/-/execa-0.9.0.tgz", "integrity": "sha512-BbUMBiX4hqiHZUA5+JujIjNb6TyAlp2D5KLheMjMluwOuzcnylDL4AxZYLLn1n2AGB49eSWwyKvvEQoRpnAtmA==", + "dev": true, "requires": { "cross-spawn": "5.1.0", "get-stream": "3.0.0", @@ -4111,6 +4124,7 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-3.0.0.tgz", "integrity": "sha512-1yD6RmLI1XBfxugvORwlck6f75tYL+iR0jqwsOrOxMZyGYqUuDhJ0l4AXdO1iX/FTs9cBAMEk1gWSEx1kSbylg==", + "dev": true, "requires": { "locate-path": "3.0.0" } @@ -4119,6 +4133,7 @@ "version": "1.2.1", "resolved": "https://registry.npmjs.org/is-ci/-/is-ci-1.2.1.tgz", "integrity": "sha512-s6tfsaQaQi3JNciBH6shVqEDvhGut0SUXr31ag8Pd8BBbVVlcGfWhpPmEOoM6RJ5TFhbypvf5yyRw/VXW1IiWg==", + "dev": true, "requires": { "ci-info": "1.5.1" } @@ -4127,6 +4142,7 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", "integrity": "sha512-7AO748wWnIhNqAuaty2ZWHkQHRSNfPVIsPIfwEOWO22AmaoVrWavlOcMR5nzTLNYvp36X220/maaRsrec1G65A==", + "dev": true, "requires": { "p-locate": "3.0.0", "path-exists": "3.0.0" @@ -4136,6 +4152,7 @@ "version": "2.0.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-2.0.0.tgz", "integrity": "sha512-fl5s52lI5ahKCernzzIyAP0QAZbGIovtVHGwpcu1Jr/EpzLVDI2myISHwGqK7m8uQFugVWSrbxH7XnhGtvEc+A==", + "dev": true, "requires": { "p-try": "2.0.0" } @@ -4144,6 +4161,7 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-3.0.0.tgz", "integrity": "sha512-x+12w/To+4GFfgJhBEpiDcLozRJGegY+Ei7/z0tSLkMmxGZNybVMSfWj9aJn8Z5Fc7dBUNJOOVgPv2H7IwulSQ==", + "dev": true, "requires": { "p-limit": "2.0.0" } @@ -4151,12 +4169,14 @@ "p-try": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.0.0.tgz", - "integrity": "sha512-hMp0onDKIajHfIkdRk3P4CdCmErkYAxxDtP3Wx/4nZ3aGlau2VKh3mZpcuFkH27WQkL/3WBCPOktzA9ZOAnMQQ==" + "integrity": "sha512-hMp0onDKIajHfIkdRk3P4CdCmErkYAxxDtP3Wx/4nZ3aGlau2VKh3mZpcuFkH27WQkL/3WBCPOktzA9ZOAnMQQ==", + "dev": true }, "parse-json": { "version": "4.0.0", "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-4.0.0.tgz", "integrity": "sha1-vjX1Qlvh9/bHRxhPmKeIy5lHfuA=", + "dev": true, "requires": { "error-ex": "1.3.1", "json-parse-better-errors": "1.0.2" @@ -4165,17 +4185,20 @@ "path-exists": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-3.0.0.tgz", - "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=" + "integrity": "sha1-zg6+ql94yxiSXqfYENe1mwEP1RU=", + "dev": true }, "pify": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/pify/-/pify-3.0.0.tgz", - "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=" + "integrity": "sha1-5aSs0sEB/fPZpNB/DbxNtJ3SgXY=", + "dev": true }, "pkg-dir": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-3.0.0.tgz", "integrity": "sha512-/E57AYkoeQ25qkxMj5PBOVgF8Kiu/h7cYS30Z5+R7WaiCCBfLq58ZI/dSeaEKb9WVJV5n/03QwrN3IeWIFllvw==", + "dev": true, "requires": { "find-up": "3.0.0" } @@ -4184,6 +4207,7 @@ "version": "4.0.1", "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-4.0.1.tgz", "integrity": "sha1-ljYlN48+HE1IyFhytabsfV0JMjc=", + "dev": true, "requires": { "normalize-package-data": "2.4.0", "parse-json": "4.0.0", @@ -4193,7 +4217,8 @@ "slash": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/slash/-/slash-2.0.0.tgz", - "integrity": "sha512-ZYKh3Wh2z1PpEXWr0MpSBZ0V6mZHAQfYevttO11c51CaWjGTaadiKZ+wVt1PbMlDV5qhMFslpZCemhwOK7C89A==" + "integrity": "sha512-ZYKh3Wh2z1PpEXWr0MpSBZ0V6mZHAQfYevttO11c51CaWjGTaadiKZ+wVt1PbMlDV5qhMFslpZCemhwOK7C89A==", + "dev": true } } }, @@ -4331,7 +4356,8 @@ "is-arrayish": { "version": "0.2.1", "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", - "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=" + "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=", + "dev": true }, "is-buffer": { "version": "1.1.6", @@ -4343,6 +4369,7 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/is-builtin-module/-/is-builtin-module-1.0.0.tgz", "integrity": "sha1-VAVy0096wxGfj3bDDLwbHgN6/74=", + "dev": true, "requires": { "builtin-modules": "1.1.1" } @@ -4399,7 +4426,8 @@ "is-directory": { "version": "0.3.1", "resolved": "https://registry.npmjs.org/is-directory/-/is-directory-0.3.1.tgz", - "integrity": "sha1-YTObbyR1/Hcv2cnYP1yFddwVSuE=" + "integrity": "sha1-YTObbyR1/Hcv2cnYP1yFddwVSuE=", + "dev": true }, "is-dotfile": { "version": "1.0.3", @@ -4578,7 +4606,8 @@ "is-stream": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", - "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=" + "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=", + "dev": true }, "is-symbol": { "version": "1.0.1", @@ -4613,7 +4642,8 @@ "isexe": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/isexe/-/isexe-2.0.0.tgz", - "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=" + "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", + "dev": true }, "isobject": { "version": "3.0.1", @@ -5359,6 +5389,7 @@ "version": "3.12.0", "resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-3.12.0.tgz", "integrity": "sha512-PIt2cnwmPfL4hKNwqeiuz4bKfnzHTBv6HyVgjahA6mPLwPDzjDWrplJBMjHUFxku/N3FlmrbyPclad+I+4mJ3A==", + "dev": true, "requires": { "argparse": "1.0.10", "esprima": "4.0.0" @@ -5414,7 +5445,8 @@ "json-parse-better-errors": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/json-parse-better-errors/-/json-parse-better-errors-1.0.2.tgz", - "integrity": "sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw==" + "integrity": "sha512-mrqyZKfX5EhL7hvqcV6WG1yYjnjeuYDzDhhcAAUrq8Po85NBQBJP+ZDUT75qZQ98IkUoBqdkExkukOU7Ts2wrw==", + "dev": true }, "json-schema": { "version": "0.2.3", @@ -5651,6 +5683,7 @@ "version": "4.1.2", "resolved": "https://registry.npmjs.org/lru-cache/-/lru-cache-4.1.2.tgz", "integrity": "sha512-wgeVXhrDwAWnIF/yZARsFnMBtdFXOg1b8RIrhilp+0iDYN4mdQcNZElDZ0e4B64BhaxeQ5zN7PMyvu7we1kPeQ==", + "dev": true, "requires": { "pseudomap": "1.0.2", "yallist": "2.1.2" @@ -5696,9 +5729,10 @@ } }, "markdown-builder": { - "version": "0.8.3-dev", - "resolved": "https://registry.npmjs.org/markdown-builder/-/markdown-builder-0.8.3-dev.tgz", - "integrity": "sha512-NJp9MW/odYYP8z1lEEwDW3k+iVnzW1xaJqwWbjlzsAAA1kZohi6Cf3bQkWKZsxPJTZACgYd/aKpmunLSD1u2Bw==", + "version": "0.8.4-dev", + "resolved": "https://registry.npmjs.org/markdown-builder/-/markdown-builder-0.8.4-dev.tgz", + "integrity": "sha512-egn7ENFiFmc1E/xcRGgXi2Q6oPxWUPYtSJY7RSb3WOdjyVoRQ3JVGMykiM98kMdrRb1QqNYoa+OI/4GdqGsTYw==", + "dev": true, "requires": { "husky": "1.0.0-rc.14" } @@ -6233,6 +6267,7 @@ "version": "2.4.0", "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.4.0.tgz", "integrity": "sha512-9jjUFbTPfEy3R/ad/2oNbKtW9Hgovl5O1FvFWKkKblNXoN/Oou6+9+KKohPK13Yc3/TyunyWhJp6gvRNR/PPAw==", + "dev": true, "requires": { "hosted-git-info": "2.6.0", "is-builtin-module": "1.0.0", @@ -6253,6 +6288,7 @@ "version": "2.0.2", "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz", "integrity": "sha1-NakjLfo11wZ7TLLd8jV7GHFTbF8=", + "dev": true, "requires": { "path-key": "2.0.1" } @@ -6458,7 +6494,8 @@ "p-finally": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/p-finally/-/p-finally-1.0.0.tgz", - "integrity": "sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4=" + "integrity": "sha1-P7z7FbiZpEEjs0ttzBi3JDNqLK4=", + "dev": true }, "p-limit": { "version": "1.3.0", @@ -6550,7 +6587,8 @@ "path-key": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/path-key/-/path-key-2.0.1.tgz", - "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=" + "integrity": "sha1-QRyttXTFoUDTpLGRDUDYDMn0C0A=", + "dev": true }, "path-parse": { "version": "1.0.5", @@ -6680,6 +6718,7 @@ "version": "3.1.1", "resolved": "https://registry.npmjs.org/please-upgrade-node/-/please-upgrade-node-3.1.1.tgz", "integrity": "sha512-KY1uHnQ2NlQHqIJQpnh/i54rKkuxCEBx+voJIS/Mvb+L2iYd2NMotwduhKTMjfC1uKoX3VXOxLjIYG66dfJTVQ==", + "dev": true, "requires": { "semver-compare": "1.0.0" } @@ -6797,7 +6836,8 @@ "pseudomap": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/pseudomap/-/pseudomap-1.0.2.tgz", - "integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM=" + "integrity": "sha1-8FKijacOYYkX7wqKw0wa5aaChrM=", + "dev": true }, "punycode": { "version": "2.1.0", @@ -7238,7 +7278,8 @@ "run-node": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/run-node/-/run-node-1.0.0.tgz", - "integrity": "sha512-kc120TBlQ3mih1LSzdAJXo4xn/GWS2ec0l3S+syHDXP9uRr0JAT8Qd3mdMuyjqCzeZktgP3try92cEgf9Nks8A==" + "integrity": "sha512-kc120TBlQ3mih1LSzdAJXo4xn/GWS2ec0l3S+syHDXP9uRr0JAT8Qd3mdMuyjqCzeZktgP3try92cEgf9Nks8A==", + "dev": true }, "run-parallel": { "version": "1.1.9", @@ -7389,12 +7430,14 @@ "semver": { "version": "5.4.1", "resolved": "https://registry.npmjs.org/semver/-/semver-5.4.1.tgz", - "integrity": "sha512-WfG/X9+oATh81XtllIo/I8gOiY9EXRdv1cQdyykeXK17YcUW3EXUAi2To4pcH6nZtJPr7ZOpM5OMyWJZm+8Rsg==" + "integrity": "sha512-WfG/X9+oATh81XtllIo/I8gOiY9EXRdv1cQdyykeXK17YcUW3EXUAi2To4pcH6nZtJPr7ZOpM5OMyWJZm+8Rsg==", + "dev": true }, "semver-compare": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/semver-compare/-/semver-compare-1.0.0.tgz", - "integrity": "sha1-De4hahyUGrN+nvsXiPavxf9VN/w=" + "integrity": "sha1-De4hahyUGrN+nvsXiPavxf9VN/w=", + "dev": true }, "set-blocking": { "version": "2.0.0", @@ -7435,6 +7478,7 @@ "version": "1.2.0", "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-1.2.0.tgz", "integrity": "sha1-RKrGW2lbAzmJaMOfNj/uXer98eo=", + "dev": true, "requires": { "shebang-regex": "1.0.0" } @@ -7442,7 +7486,8 @@ "shebang-regex": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-1.0.0.tgz", - "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=" + "integrity": "sha1-2kL0l0DAtC2yypcoVxyxkMmO/qM=", + "dev": true }, "shellwords": { "version": "0.1.1", @@ -7453,7 +7498,8 @@ "signal-exit": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", - "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=" + "integrity": "sha1-tf3AjxKH6hF4Yo5BXiUTK3NkbG0=", + "dev": true }, "slash": { "version": "1.0.0", @@ -7628,6 +7674,7 @@ "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.0.0.tgz", "integrity": "sha512-N19o9z5cEyc8yQQPukRCZ9EUmb4HUpnrmaL/fxS2pBo2jbfcFRVuFZ/oFC+vZz0MNNk0h80iMn5/S6qGZOL5+g==", + "dev": true, "requires": { "spdx-expression-parse": "3.0.0", "spdx-license-ids": "3.0.0" @@ -7636,12 +7683,14 @@ "spdx-exceptions": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.1.0.tgz", - "integrity": "sha512-4K1NsmrlCU1JJgUrtgEeTVyfx8VaYea9J9LvARxhbHtVtohPs/gFGG5yy49beySjlIMhhXZ4QqujIZEfS4l6Cg==" + "integrity": "sha512-4K1NsmrlCU1JJgUrtgEeTVyfx8VaYea9J9LvARxhbHtVtohPs/gFGG5yy49beySjlIMhhXZ4QqujIZEfS4l6Cg==", + "dev": true }, "spdx-expression-parse": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.0.tgz", "integrity": "sha512-Yg6D3XpRD4kkOmTpdgbUiEJFKghJH03fiC1OPll5h/0sO6neh2jqRDVHOQ4o/LMea0tgCkbMgea5ip/e+MkWyg==", + "dev": true, "requires": { "spdx-exceptions": "2.1.0", "spdx-license-ids": "3.0.0" @@ -7650,7 +7699,8 @@ "spdx-license-ids": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.0.tgz", - "integrity": "sha512-2+EPwgbnmOIl8HjGBXXMd9NAu02vLjOO1nWw4kmeRDFyHn+M/ETfHxQUK0oXg8ctgVnl9t3rosNVsZ1jG61nDA==" + "integrity": "sha512-2+EPwgbnmOIl8HjGBXXMd9NAu02vLjOO1nWw4kmeRDFyHn+M/ETfHxQUK0oXg8ctgVnl9t3rosNVsZ1jG61nDA==", + "dev": true }, "split-string": { "version": "3.1.0", @@ -7664,7 +7714,8 @@ "sprintf-js": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/sprintf-js/-/sprintf-js-1.0.3.tgz", - "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=" + "integrity": "sha1-BOaSb2YolTVPPdAVIDYzuFcpfiw=", + "dev": true }, "sshpk": { "version": "1.14.1", @@ -7845,7 +7896,8 @@ "strip-eof": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", - "integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8=" + "integrity": "sha1-u0P/VZim6wXYm1n80SnJgzE2Br8=", + "dev": true }, "strip-indent": { "version": "1.0.1", @@ -8304,6 +8356,7 @@ "version": "3.0.3", "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.3.tgz", "integrity": "sha512-63ZOUnL4SIXj4L0NixR3L1lcjO38crAbgrTpl28t8jjrfuiOBL5Iygm+60qPs/KsZGzPNg6Smnc/oY16QTjF0g==", + "dev": true, "requires": { "spdx-correct": "3.0.0", "spdx-expression-parse": "3.0.0" @@ -8396,6 +8449,7 @@ "version": "1.3.0", "resolved": "https://registry.npmjs.org/which/-/which-1.3.0.tgz", "integrity": "sha512-xcJpopdamTuY5duC/KnTTNBraPK54YwpenP4lzxU8H91GudWpFv38u0CKjclE1Wi2EH2EDz5LRcHcKbCIzqGyg==", + "dev": true, "requires": { "isexe": "2.0.0" } @@ -8539,7 +8593,8 @@ "yallist": { "version": "2.1.2", "resolved": "https://registry.npmjs.org/yallist/-/yallist-2.1.2.tgz", - "integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=" + "integrity": "sha1-HBH5IY8HYImkfdUS+TxmmaaoHVI=", + "dev": true }, "yargs": { "version": "7.1.0", diff --git a/package.json b/package.json index 5f9b4105e..063572c9c 100644 --- a/package.json +++ b/package.json @@ -6,6 +6,7 @@ "html-minifier": "^3.5.15", "jest": "^23.1.0", "jest-tap-reporter": "^1.9.0", + "markdown-builder": "^0.8.4-dev", "markdown-it": "^8.4.1", "mini.css": "^2.3.7", "node-sass": "^4.9.0", @@ -15,8 +16,7 @@ "rollup": "^0.58.2", "rollup-plugin-babel": "^3.0.4", "rollup-plugin-babel-minify": "^4.0.0", - "semistandard": "^12.0.1", - "markdown-builder": "^0.8.3-dev" + "semistandard": "^12.0.1" }, "name": "30-seconds-of-code", "description": "A collection of useful JavaScript snippets.", From 7382f2bec3a4dad07733bbdda912ee2ac2d41c32 Mon Sep 17 00:00:00 2001 From: Felix Wu Date: Fri, 14 Sep 2018 17:54:57 +0200 Subject: [PATCH 13/15] add back linebreak --- README.md | 642 +++++++++++++++++++++++------------------------ scripts/build.js | 4 +- 2 files changed, 323 insertions(+), 323 deletions(-) diff --git a/README.md b/README.md index f03694e55..3f7defad2 100644 --- a/README.md +++ b/README.md @@ -515,7 +515,7 @@ const firstTwoMax = ary(Math.max, 2);
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### call @@ -542,7 +542,7 @@ Promise.resolve([1, 2, 3])
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### collectInto @@ -567,7 +567,7 @@ Pall(p1, p2, p3).then(console.log); // [1, 2, 3] (after about 2 seconds)
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### flip @@ -594,7 +594,7 @@ Object.assign(b, a); // == b
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### over @@ -616,7 +616,7 @@ minMax(1, 2, 3, 4, 5); // [1,5]
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### overArgs @@ -640,7 +640,7 @@ fn(9, 3); // [81, 6]
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### pipeAsyncFunctions @@ -671,7 +671,7 @@ const sum = pipeAsyncFunctions(
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### pipeFunctions @@ -696,7 +696,7 @@ multiplyAndAdd5(5, 2); // 15
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### promisify @@ -724,7 +724,7 @@ delay(2000).then(() => console.log('Hi!')); // // Promise resolves after 2s
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### rearg @@ -751,7 +751,7 @@ rearged('b', 'c', 'a'); // ['a', 'b', 'c']
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### spreadOver @@ -773,7 +773,7 @@ arrayMax([1, 2, 3]); // 3
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### unary @@ -794,7 +794,7 @@ const unary = fn => val => fn(val);
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) --- @@ -822,7 +822,7 @@ all([1, 2, 3]); // true
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### allEqual @@ -844,7 +844,7 @@ allEqual([1, 1, 1, 1]); // true
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### any @@ -867,7 +867,7 @@ any([0, 0, 1, 0]); // true
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### arrayToCSV @@ -892,7 +892,7 @@ arrayToCSV([['a', 'b'], ['c', 'd']], ';'); // '"a";"b"\n"c";"d"'
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### bifurcate @@ -914,7 +914,7 @@ bifurcate(['beep', 'boop', 'foo', 'bar'], [true, true, false, true]); // [ ['bee
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### bifurcateBy @@ -936,7 +936,7 @@ bifurcateBy(['beep', 'boop', 'foo', 'bar'], x => x[0] === 'b'); // [ ['beep', 'b
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### chunk @@ -962,7 +962,7 @@ chunk([1, 2, 3, 4, 5], 2); // [[1,2],[3,4],[5]]
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### compact @@ -983,7 +983,7 @@ compact([0, 1, false, 2, '', 3, 'a', 'e' * 23, NaN, 's', 34]); // [ 1, 2, 3, 'a'
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### countBy @@ -1010,7 +1010,7 @@ countBy(['one', 'two', 'three'], 'length'); // {3: 2, 5: 1}
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### countOccurrences @@ -1031,7 +1031,7 @@ countOccurrences([1, 1, 2, 1, 2, 3], 1); // 3
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### deepFlatten @@ -1054,7 +1054,7 @@ deepFlatten([1, [2], [[3], 4], 5]); // [1,2,3,4,5]
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### difference @@ -1078,7 +1078,7 @@ difference([1, 2, 3], [1, 2, 4]); // [3]
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### differenceBy @@ -1103,7 +1103,7 @@ differenceBy([{ x: 2 }, { x: 1 }], [{ x: 1 }], v => v.x); // [ { x: 2 } ]
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### differenceWith @@ -1124,7 +1124,7 @@ differenceWith([1, 1.2, 1.5, 3, 0], [1.9, 3, 0], (a, b) => Math.round(a) === Mat
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### drop @@ -1147,7 +1147,7 @@ drop([1, 2, 3], 42); // []
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### dropRight @@ -1170,7 +1170,7 @@ dropRight([1, 2, 3], 42); // []
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### dropRightWhile @@ -1195,7 +1195,7 @@ dropRightWhile([1, 2, 3, 4], n => n < 3); // [1, 2]
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### dropWhile @@ -1220,7 +1220,7 @@ dropWhile([1, 2, 3, 4], n => n >= 3); // [3,4]
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### everyNth @@ -1241,7 +1241,7 @@ everyNth([1, 2, 3, 4, 5, 6], 2); // [ 2, 4, 6 ]
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### filterNonUnique @@ -1262,7 +1262,7 @@ filterNonUnique([1, 2, 2, 3, 4, 4, 5]); // [1,3,5]
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### filterNonUniqueBy @@ -1294,7 +1294,7 @@ filterNonUniqueBy(
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### findLast @@ -1315,7 +1315,7 @@ findLast([1, 2, 3, 4], n => n % 2 === 1); // 3
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### findLastIndex @@ -1341,7 +1341,7 @@ findLastIndex([1, 2, 3, 4], n => n % 2 === 1); // 2 (index of the value 3)
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### flatten @@ -1367,7 +1367,7 @@ flatten([1, [2, [3, [4, 5], 6], 7], 8], 2); // [1, 2, 3, [4, 5], 6, 7, 8]
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### forEachRight @@ -1392,7 +1392,7 @@ forEachRight([1, 2, 3, 4], val => console.log(val)); // '4', '3', '2', '1'
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### groupBy @@ -1419,7 +1419,7 @@ groupBy(['one', 'two', 'three'], 'length'); // {3: ['one', 'two'], 5: ['three']}
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### head @@ -1440,7 +1440,7 @@ head([1, 2, 3]); // 1
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### indexOfAll @@ -1463,7 +1463,7 @@ indexOfAll([1, 2, 3], 4); // []
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### initial @@ -1484,7 +1484,7 @@ initial([1, 2, 3]); // [1,2]
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### initialize2DArray @@ -1506,7 +1506,7 @@ initialize2DArray(2, 2, 0); // [[0,0], [0,0]]
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### initializeArrayWithRange @@ -1532,7 +1532,7 @@ initializeArrayWithRange(9, 0, 2); // [0,2,4,6,8]
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### initializeArrayWithRangeRight @@ -1560,7 +1560,7 @@ initializeArrayWithRangeRight(9, 0, 2); // [8,6,4,2,0]
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### initializeArrayWithValues @@ -1582,7 +1582,7 @@ initializeArrayWithValues(5, 2); // [2,2,2,2,2]
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### initializeNDArray @@ -1608,7 +1608,7 @@ initializeNDArray(5, 2, 2, 2); // [[[5,5],[5,5]],[[5,5],[5,5]]]
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### intersection @@ -1632,7 +1632,7 @@ intersection([1, 2, 3], [4, 3, 2]); // [2,3]
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### intersectionBy @@ -1656,7 +1656,7 @@ intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor); // [2.1]
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### intersectionWith @@ -1677,7 +1677,7 @@ intersectionWith([1, 1.2, 1.5, 3, 0], [1.9, 3, 0, 3.9], (a, b) => Math.round(a)
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### isSorted @@ -1709,7 +1709,7 @@ isSorted([4, 3, 5]); // 0
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### join @@ -1743,7 +1743,7 @@ join(['pen', 'pineapple', 'apple', 'pen']); // "pen,pineapple,apple,pen"
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### JSONtoCSV ![advanced](/advanced.svg) @@ -1777,7 +1777,7 @@ JSONtoCSV([{ a: 1, b: 2 }, { a: 3, b: 4, c: 5 }, { a: 6 }, { b: 7 }], ['a', 'b']
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### last @@ -1798,7 +1798,7 @@ last([1, 2, 3]); // 3
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### longestItem @@ -1826,7 +1826,7 @@ longestItem([1, 2, 3], 'foobar'); // 'foobar'
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### mapObject ![advanced](/advanced.svg) @@ -1851,7 +1851,7 @@ squareIt([1, 2, 3]); // { 1: 1, 2: 4, 3: 9 }
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### maxN @@ -1875,7 +1875,7 @@ maxN([1, 2, 3], 2); // [3,2]
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### minN @@ -1899,7 +1899,7 @@ minN([1, 2, 3], 2); // [1,2]
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### none @@ -1922,7 +1922,7 @@ none([0, 0, 0]); // true
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### nthElement @@ -1946,7 +1946,7 @@ nthElement(['a', 'b', 'b'], -3); // 'a'
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### offset @@ -1970,7 +1970,7 @@ offset([1, 2, 3, 4, 5], -2); // [4, 5, 1, 2, 3]
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### partition @@ -2000,7 +2000,7 @@ partition(users, o => o.active); // [[{ 'user': 'fred', 'age': 40, 'active':
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### permutations ![advanced](/advanced.svg) @@ -2035,7 +2035,7 @@ permutations([1, 33, 5]); // [ [ 1, 33, 5 ], [ 1, 5, 33 ], [ 33, 1, 5 ], [ 33, 5
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### pull @@ -2065,7 +2065,7 @@ pull(myArray, 'a', 'c'); // myArray = [ 'b', 'b' ]
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### pullAtIndex ![advanced](/advanced.svg) @@ -2097,7 +2097,7 @@ let pulled = pullAtIndex(myArray, [1, 3]); // myArray = [ 'a', 'c' ] , pulled =
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### pullAtValue ![advanced](/advanced.svg) @@ -2128,7 +2128,7 @@ let pulled = pullAtValue(myArray, ['b', 'd']); // myArray = [ 'a', 'c' ] , pulle
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### pullBy ![advanced](/advanced.svg) @@ -2161,7 +2161,7 @@ pullBy(myArray, [{ x: 1 }, { x: 3 }], o => o.x); // myArray = [{ x: 2 }]
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### reducedFilter @@ -2202,7 +2202,7 @@ reducedFilter(data, ['id', 'name'], item => item.age > 24); // [{ id: 2, name: '
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### reduceSuccessive @@ -2224,7 +2224,7 @@ reduceSuccessive([1, 2, 3, 4, 5, 6], (acc, val) => acc + val, 0); // [0, 1, 3, 6
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### reduceWhich @@ -2252,7 +2252,7 @@ reduceWhich(
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### reject @@ -2272,7 +2272,7 @@ reject(word => word.length > 4, ['Apple', 'Pear', 'Kiwi', 'Banana']); // ['Pear'
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### remove @@ -2300,7 +2300,7 @@ remove([1, 2, 3, 4], n => n % 2 === 0); // [2, 4]
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### sample @@ -2322,7 +2322,7 @@ sample([3, 7, 9, 11]); // 9
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### sampleSize @@ -2353,7 +2353,7 @@ sampleSize([1, 2, 3], 4); // [2,3,1]
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### shuffle @@ -2382,7 +2382,7 @@ shuffle(foo); // [2,3,1], foo = [1,2,3]
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### similarity @@ -2403,7 +2403,7 @@ similarity([1, 2, 3], [1, 2, 4]); // [1,2]
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### sortedIndex @@ -2430,7 +2430,7 @@ sortedIndex([30, 50], 40); // 1
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### sortedIndexBy @@ -2457,7 +2457,7 @@ sortedIndexBy([{ x: 4 }, { x: 5 }], { x: 4 }, o => o.x); // 0
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### sortedLastIndex @@ -2483,7 +2483,7 @@ sortedLastIndex([10, 20, 30, 30, 40], 30); // 4
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### sortedLastIndexBy @@ -2514,7 +2514,7 @@ sortedLastIndexBy([{ x: 4 }, { x: 5 }], { x: 4 }, o => o.x); // 1
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### stableSort ![advanced](/advanced.svg) @@ -2543,7 +2543,7 @@ const stable = stableSort(arr, () => 0); // [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10]
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### symmetricDifference @@ -2569,7 +2569,7 @@ symmetricDifference([1, 2, 2], [1, 3, 1]); // [2, 2, 3]
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### symmetricDifferenceBy @@ -2594,7 +2594,7 @@ symmetricDifferenceBy([2.1, 1.2], [2.3, 3.4], Math.floor); // [ 1.2, 3.4 ]
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### symmetricDifferenceWith @@ -2622,7 +2622,7 @@ symmetricDifferenceWith(
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### tail @@ -2644,7 +2644,7 @@ tail([1]); // [1]
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### take @@ -2666,7 +2666,7 @@ take([1, 2, 3], 0); // []
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### takeRight @@ -2688,7 +2688,7 @@ takeRight([1, 2, 3]); // [3]
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### takeRightWhile @@ -2714,7 +2714,7 @@ takeRightWhile([1, 2, 3, 4], n => n < 3); // [3, 4]
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### takeWhile @@ -2739,7 +2739,7 @@ takeWhile([1, 2, 3, 4], n => n >= 3); // [1, 2]
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### toHash @@ -2777,7 +2777,7 @@ managers; // [ { manager:1, employees: [ { id: 2, first: "Joe" }, { id: 3, first
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### union @@ -2798,7 +2798,7 @@ union([1, 2, 3], [4, 3, 2]); // [1,2,3,4]
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### unionBy @@ -2824,7 +2824,7 @@ unionBy([2.1], [1.2, 2.3], Math.floor); // [2.1, 1.2]
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### unionWith @@ -2846,7 +2846,7 @@ unionWith([1, 1.2, 1.5, 3, 0], [1.9, 3, 0, 3.9], (a, b) => Math.round(a) === Mat
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### uniqueElements @@ -2867,7 +2867,7 @@ uniqueElements([1, 2, 2, 3, 4, 4, 5]); // [1,2,3,4,5]
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### uniqueElementsBy @@ -2902,7 +2902,7 @@ uniqueElementsBy(
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### uniqueElementsByRight @@ -2937,7 +2937,7 @@ uniqueElementsByRight(
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### uniqueSymmetricDifference @@ -2961,7 +2961,7 @@ uniqueSymmetricDifference([1, 2, 2], [1, 3, 1]); // [2, 3]
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### unzip @@ -2990,7 +2990,7 @@ unzip([['a', 1, true], ['b', 2]]); //[['a', 'b'], [1, 2], [true]]
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### unzipWith ![advanced](/advanced.svg) @@ -3021,7 +3021,7 @@ unzipWith([[1, 10, 100], [2, 20, 200]], (...args) => args.reduce((acc, v) => acc
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### without @@ -3044,7 +3044,7 @@ without([2, 1, 2, 3], 1, 2); // [3]
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### xProd @@ -3065,7 +3065,7 @@ xProd([1, 2], ['a', 'b']); // [[1, 'a'], [1, 'b'], [2, 'a'], [2, 'b']]
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### zip @@ -3094,7 +3094,7 @@ zip(['a'], [1, 2], [true, false]); // [['a', 1, true], [undefined, 2, false]]
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### zipObject @@ -3117,7 +3117,7 @@ zipObject(['a', 'b'], [1, 2, 3]); // {a: 1, b: 2}
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### zipWith ![advanced](/advanced.svg) @@ -3154,7 +3154,7 @@ zipWith(
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) --- @@ -3184,7 +3184,7 @@ arrayToHtmlList(['item 1', 'item 2'], 'myListID');
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### bottomVisible @@ -3207,7 +3207,7 @@ bottomVisible(); // true
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### copyToClipboard ![advanced](/advanced.svg) @@ -3250,7 +3250,7 @@ copyToClipboard('Lorem ipsum'); // 'Lorem ipsum' copied to clipboard.
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### counter ![advanced](/advanced.svg) @@ -3285,7 +3285,7 @@ counter('#my-id', 1, 1000, 5, 2000); // Creates a 2-second timer for the element
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### createElement @@ -3318,7 +3318,7 @@ console.log(el.className); // 'container'
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### createEventHub ![advanced](/advanced.svg) @@ -3371,7 +3371,7 @@ hub.off('message', handler);
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### currentURL @@ -3392,7 +3392,7 @@ currentURL(); // 'https://google.com'
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### detectDeviceType @@ -3416,7 +3416,7 @@ detectDeviceType(); // "Mobile" or "Desktop"
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### elementContains @@ -3438,7 +3438,7 @@ elementContains(document.querySelector('body'), document.querySelector('body'));
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### elementIsVisibleInViewport ![advanced](/advanced.svg) @@ -3471,7 +3471,7 @@ elementIsVisibleInViewport(el, true); // true - (partially visible)
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### getScrollPosition @@ -3496,7 +3496,7 @@ getScrollPosition(); // {x: 0, y: 200}
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### getStyle @@ -3517,7 +3517,7 @@ getStyle(document.querySelector('p'), 'font-size'); // '16px'
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### hasClass @@ -3538,7 +3538,7 @@ hasClass(document.querySelector('p.special'), 'special'); // true
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### hashBrowser ![advanced](/advanced.svg) @@ -3566,7 +3566,7 @@ hashBrowser(JSON.stringify({ a: 'a', b: [1, 2, 3, 4], foo: { c: 'bar' } })).then
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### hide @@ -3587,7 +3587,7 @@ hide(document.querySelectorAll('img')); // Hides all elements on the page
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### httpsRedirect @@ -3610,7 +3610,7 @@ httpsRedirect(); // If you are on http://mydomain.com, you are redirected to htt
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### insertAfter @@ -3631,7 +3631,7 @@ insertAfter(document.getElementById('myId'), '

    after

    '); //
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### insertBefore @@ -3652,7 +3652,7 @@ insertBefore(document.getElementById('myId'), '

    before

    '); //

    before

    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### isBrowserTabFocused @@ -3673,7 +3673,7 @@ isBrowserTabFocused(); // true
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### nodeListToArray @@ -3694,7 +3694,7 @@ nodeListToArray(document.childNodes); // [ , html ]
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### observeMutations ![advanced](/advanced.svg) @@ -3735,7 +3735,7 @@ obs.disconnect(); // Disconnects the observer and stops logging mutations on the
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### off @@ -3759,7 +3759,7 @@ off(document.body, 'click', fn); // no longer logs '!' upon clicking on the page
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### on @@ -3789,7 +3789,7 @@ on(document.body, 'click', fn, { options: true }); // use capturing instead of b
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### onUserInputChange ![advanced](/advanced.svg) @@ -3827,7 +3827,7 @@ onUserInputChange(type => {
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### prefix @@ -3856,7 +3856,7 @@ prefix('appearance'); // 'appearance' on a supported browser, otherwise 'webkitA
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### recordAnimationFrames @@ -3903,7 +3903,7 @@ const recorder2 = recordAnimationFrames(cb, false); // `start` needs to be expli
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### redirect @@ -3926,7 +3926,7 @@ redirect('https://google.com');
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### runAsync ![advanced](/advanced.svg) @@ -3982,7 +3982,7 @@ runAsync(() => typeof outsideVariable).then(console.log); // 'undefined'
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### scrollToTop @@ -4010,7 +4010,7 @@ scrollToTop();
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### setStyle @@ -4031,7 +4031,7 @@ setStyle(document.querySelector('p'), 'font-size', '20px'); // The first

    ele

    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### show @@ -4052,7 +4052,7 @@ show(...document.querySelectorAll('img')); // Shows all elements on the pa
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### smoothScroll @@ -4078,7 +4078,7 @@ smoothScroll('.fooBar'); // scrolls smoothly to the first element with a class o
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### toggleClass @@ -4099,7 +4099,7 @@ toggleClass(document.querySelector('p.special'), 'special'); // The paragraph wi
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### triggerEvent @@ -4124,7 +4124,7 @@ triggerEvent(document.getElementById('myId'), 'click', { username: 'bob' });
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### UUIDGeneratorBrowser @@ -4148,7 +4148,7 @@ UUIDGeneratorBrowser(); // '7982fcfe-5721-4632-bede-6000885be57d'
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) --- @@ -4191,7 +4191,7 @@ formatDuration(34325055574); // '397 days, 6 hours, 44 minutes, 15 seconds, 574
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### getColonTimeFromDate @@ -4212,7 +4212,7 @@ getColonTimeFromDate(new Date()); // "08:38:00"
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### getDaysDiffBetweenDates @@ -4234,7 +4234,7 @@ getDaysDiffBetweenDates(new Date('2017-12-13'), new Date('2017-12-22')); // 9
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### getMeridiemSuffixOfInteger @@ -4265,7 +4265,7 @@ getMeridiemSuffixOfInteger(25); // "1pm"
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### tomorrow @@ -4293,7 +4293,7 @@ tomorrow(true); // 2017-12-27T00:00:00 (if current date is 2017-12-26)
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) --- @@ -4328,7 +4328,7 @@ if (elements instanceof Error) elements = []; // elements = []
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### bind @@ -4355,7 +4355,7 @@ console.log(freddyBound('hi', '!')); // 'hi fred!'
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### bindKey @@ -4385,7 +4385,7 @@ console.log(freddyBound('hi', '!')); // 'hi fred!'
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### chainAsync @@ -4418,7 +4418,7 @@ chainAsync([
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### compose @@ -4446,7 +4446,7 @@ multiplyAndAdd5(5, 2); // 15
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### composeRight @@ -4471,7 +4471,7 @@ addAndSquare(1, 2); // 9
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### converge @@ -4497,7 +4497,7 @@ average([1, 2, 3, 4, 5, 6, 7]); // 4
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### curry @@ -4523,7 +4523,7 @@ curry(Math.min, 3)(10)(50)(2); // 2
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### debounce @@ -4557,7 +4557,7 @@ window.addEventListener(
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### defer @@ -4584,7 +4584,7 @@ defer(longRunningFunction); // Browser will update the HTML then run the functio
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### delay @@ -4612,7 +4612,7 @@ delay(
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### functionName @@ -4633,7 +4633,7 @@ functionName(Math.max); // max (logged in debug channel of console)
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### hz @@ -4676,7 +4676,7 @@ Math.round(hz(sumForLoop)); // 4784
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### memoize ![advanced](/advanced.svg) @@ -4710,7 +4710,7 @@ console.log(anagramsCached.cache); // The cached anagrams map
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### negate @@ -4731,7 +4731,7 @@ const negate = func => (...args) => !func(...args);
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### once @@ -4763,7 +4763,7 @@ document.body.addEventListener('click', once(startApp)); // only runs `startApp`
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### partial @@ -4786,7 +4786,7 @@ greetHello('John'); // 'Hello John!'
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### partialRight @@ -4809,7 +4809,7 @@ greetJohn('Hello'); // 'Hello John!'
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### runPromisesInSeries @@ -4831,7 +4831,7 @@ runPromisesInSeries([() => delay(1000), () => delay(2000)]); // Executes each pr
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### sleep @@ -4856,7 +4856,7 @@ async function sleepyWork() {
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### throttle ![advanced](/advanced.svg) @@ -4905,7 +4905,7 @@ window.addEventListener(
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### times @@ -4932,7 +4932,7 @@ console.log(output); // 01234
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### uncurry @@ -4963,7 +4963,7 @@ uncurriedAdd(1, 2, 3); // 6
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### unfold @@ -4991,7 +4991,7 @@ unfold(f, 10); // [-10, -20, -30, -40, -50]
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### when @@ -5014,7 +5014,7 @@ doubleEvenNumbers(1); // 1
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) --- @@ -5041,7 +5041,7 @@ approximatelyEqual(Math.PI / 2.0, 1.5708); // true
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### average @@ -5063,7 +5063,7 @@ average(1, 2, 3); // 2
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### averageBy @@ -5087,7 +5087,7 @@ averageBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }], 'n'); // 5
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### binomialCoefficient @@ -5121,7 +5121,7 @@ binomialCoefficient(8, 2); // 28
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### clampNumber @@ -5144,7 +5144,7 @@ clampNumber(1, -1, -5); // -1
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### degreesToRads @@ -5165,7 +5165,7 @@ degreesToRads(90.0); // ~1.5708
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### digitize @@ -5187,7 +5187,7 @@ digitize(123); // [1, 2, 3]
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### distance @@ -5208,7 +5208,7 @@ distance(1, 1, 2, 3); // 2.23606797749979
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### elo ![advanced](/advanced.svg) @@ -5259,7 +5259,7 @@ own individual rating by supplying it as the third argument.
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### factorial @@ -5290,7 +5290,7 @@ factorial(6); // 720
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### fibonacci @@ -5316,7 +5316,7 @@ fibonacci(6); // [0, 1, 1, 2, 3, 5]
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### gcd @@ -5343,7 +5343,7 @@ gcd(...[12, 8, 32]); // 4
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### geometricProgression @@ -5372,7 +5372,7 @@ geometricProgression(256, 1, 4); // [1, 4, 16, 64, 256]
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### hammingDistance @@ -5394,7 +5394,7 @@ hammingDistance(2, 3); // 1
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### inRange @@ -5422,7 +5422,7 @@ inRange(3, 2); // false
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### isDivisible @@ -5443,7 +5443,7 @@ isDivisible(6, 3); // true
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### isEven @@ -5465,7 +5465,7 @@ isEven(3); // false
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### isPrime @@ -5491,7 +5491,7 @@ isPrime(11); // true
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### lcm @@ -5518,7 +5518,7 @@ lcm(...[1, 3, 4, 5]); // 60
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### luhnCheck ![advanced](/advanced.svg) @@ -5554,7 +5554,7 @@ luhnCheck(123456789); // false
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### maxBy @@ -5576,7 +5576,7 @@ maxBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }], 'n'); // 8
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### median @@ -5602,7 +5602,7 @@ median([5, 6, 50, 1, -5]); // 5
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### minBy @@ -5624,7 +5624,7 @@ minBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }], 'n'); // 2
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### percentile @@ -5646,7 +5646,7 @@ percentile([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 6); // 55
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### powerset @@ -5667,7 +5667,7 @@ powerset([1, 2]); // [[], [1], [2], [2,1]]
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### primes @@ -5694,7 +5694,7 @@ primes(10); // [2,3,5,7]
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### radsToDegrees @@ -5715,7 +5715,7 @@ radsToDegrees(Math.PI / 2); // 90
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### randomIntArrayInRange @@ -5737,7 +5737,7 @@ randomIntArrayInRange(12, 35, 10); // [ 34, 14, 27, 17, 30, 27, 20, 26, 21, 14 ]
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### randomIntegerInRange @@ -5758,7 +5758,7 @@ randomIntegerInRange(0, 5); // 2
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### randomNumberInRange @@ -5779,7 +5779,7 @@ randomNumberInRange(2, 10); // 6.0211363285087005
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### round @@ -5801,7 +5801,7 @@ round(1.005, 2); // 1.01
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### sdbm @@ -5829,7 +5829,7 @@ sdbm('name'); // -3521204949
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### standardDeviation @@ -5859,7 +5859,7 @@ standardDeviation([10, 2, 38, 23, 38, 23, 21], true); // 12.29899614287479 (popu
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### sum @@ -5880,7 +5880,7 @@ sum(...[1, 2, 3, 4]); // 10
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### sumBy @@ -5903,7 +5903,7 @@ sumBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }], 'n'); // 20
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### sumPower @@ -5932,7 +5932,7 @@ sumPower(10, 3, 5); //2925
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### toSafeInteger @@ -5956,7 +5956,7 @@ toSafeInteger(Infinity); // 9007199254740991
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) --- @@ -5982,7 +5982,7 @@ atob('Zm9vYmFy'); // 'foobar'
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### btoa @@ -6003,7 +6003,7 @@ btoa('foobar'); // 'Zm9vYmFy'
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### colorize @@ -6044,7 +6044,7 @@ console.log(colorize(colorize('foo').yellow, colorize('foo').green).bgWhite); //
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### hasFlags @@ -6070,7 +6070,7 @@ hasFlags('special'); // false
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### hashNode @@ -6104,7 +6104,7 @@ hashNode(JSON.stringify({ a: 'a', b: [1, 2, 3, 4], foo: { c: 'bar' } })).then(co
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### isTravisCI @@ -6125,7 +6125,7 @@ isTravisCI(); // true (if code is running on Travis CI)
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### JSONToFile @@ -6148,7 +6148,7 @@ JSONToFile({ test: 'is passed' }, 'testJsonFile'); // writes the object to 'test
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### readFileLines @@ -6185,7 +6185,7 @@ console.log(arr); // ['line1', 'line2', 'line3']
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### untildify @@ -6206,7 +6206,7 @@ untildify('~/node'); // '/Users/aUser/node'
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### UUIDGeneratorNode @@ -6231,7 +6231,7 @@ UUIDGeneratorNode(); // '79c7c136-60ee-40a2-beb2-856f1feabefc'
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) --- @@ -6272,7 +6272,7 @@ jQuery(element).on('click', view.click); // Logs 'clicked docs' when clicked.
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### deepClone @@ -6302,7 +6302,7 @@ const b = deepClone(a); // a !== b, a.obj !== b.obj
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### deepFreeze @@ -6332,7 +6332,7 @@ o[1][0] = 4; // not allowed as well
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### defaults @@ -6353,7 +6353,7 @@ defaults({ a: 1 }, { b: 2 }, { b: 6 }, { a: 3 }); // { a: 1, b: 2 }
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### dig @@ -6389,7 +6389,7 @@ dig(data, 'level4'); // undefined
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### equals ![advanced](/advanced.svg) @@ -6421,7 +6421,7 @@ equals({ a: [2, { e: 3 }], b: [4], c: 'foo' }, { a: [2, { e: 3 }], b: [4], c: 'f
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### findKey @@ -6449,7 +6449,7 @@ findKey(
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### findLastKey @@ -6480,7 +6480,7 @@ findLastKey(
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### flattenObject @@ -6511,7 +6511,7 @@ flattenObject({ a: { b: { c: 1 } }, d: 1 }); // { 'a.b.c': 1, d: 1 }
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### forOwn @@ -6532,7 +6532,7 @@ forOwn({ foo: 'bar', a: 1 }, v => console.log(v)); // 'bar', 1
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### forOwnRight @@ -6556,7 +6556,7 @@ forOwnRight({ foo: 'bar', a: 1 }, v => console.log(v)); // 1, 'bar'
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### functions @@ -6590,7 +6590,7 @@ functions(new Foo(), true); // ['a', 'b', 'c']
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### get @@ -6619,7 +6619,7 @@ get(obj, 'selector.to.val', 'target[0]', 'target[2].a'); // ['val to select', 1,
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### invertKeyValues @@ -6648,7 +6648,7 @@ invertKeyValues({ a: 1, b: 2, c: 1 }, value => 'group' + value); // { group1: [
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### lowercaseKeys @@ -6675,7 +6675,7 @@ const myObjLower = lowercaseKeys(myObj); // {name: 'Adam', surname: 'Smith'};
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### mapKeys @@ -6701,7 +6701,7 @@ mapKeys({ a: 1, b: 2 }, (val, key) => key + val); // { a1: 1, b2: 2 }
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### mapValues @@ -6731,7 +6731,7 @@ mapValues(users, u => u.age); // { fred: 40, pebbles: 1 }
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### matches @@ -6754,7 +6754,7 @@ matches({ hair: 'long', beard: true }, { age: 25, hair: 'long', beard: true });
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### matchesWith @@ -6787,7 +6787,7 @@ matchesWith(
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### merge @@ -6826,7 +6826,7 @@ merge(object, other); // { a: [ { x: 2 }, { y: 4 }, { z: 3 } ], b: [ 1, 2, 3 ],
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### nest @@ -6863,7 +6863,7 @@ const nestedComments = nest(comments); // [{ id: 1, parent_id: null, children: [
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### objectFromPairs @@ -6884,7 +6884,7 @@ objectFromPairs([['a', 1], ['b', 2]]); // {a: 1, b: 2}
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### objectToPairs @@ -6905,7 +6905,7 @@ objectToPairs({ a: 1, b: 2 }); // [['a',1],['b',2]]
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### omit @@ -6930,7 +6930,7 @@ omit({ a: 1, b: '2', c: 3 }, ['b']); // { 'a': 1, 'c': 3 }
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### omitBy @@ -6955,7 +6955,7 @@ omitBy({ a: 1, b: '2', c: 3 }, x => typeof x === 'number'); // { b: '2' }
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### orderBy @@ -6988,7 +6988,7 @@ orderBy(users, ['name', 'age']); // [{name: 'barney', age: 36}, {name: 'fred', a
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### pick @@ -7010,7 +7010,7 @@ pick({ a: 1, b: '2', c: 3 }, ['a', 'c']); // { 'a': 1, 'c': 3 }
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### pickBy @@ -7035,7 +7035,7 @@ pickBy({ a: 1, b: '2', c: 3 }, x => typeof x === 'number'); // { 'a': 1, 'c': 3
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### renameKeys @@ -7064,7 +7064,7 @@ renameKeys({ name: 'firstName', job: 'passion' }, obj); // { firstName: 'Bobo',
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### shallowClone @@ -7086,7 +7086,7 @@ const b = shallowClone(a); // a !== b
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### size @@ -7121,7 +7121,7 @@ size({ one: 1, two: 2, three: 3 }); // 3
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### transform @@ -7149,7 +7149,7 @@ transform(
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### truthCheckCollection @@ -7170,7 +7170,7 @@ truthCheckCollection([{ user: 'Tinky-Winky', sex: 'male' }, { user: 'Dipsy', sex
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### unflattenObject ![advanced](/advanced.svg) @@ -7208,7 +7208,7 @@ unflattenObject({ 'a.b.c': 1, d: 1 }); // { a: { b: { c: 1 } }, d: 1 }
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) --- @@ -7235,7 +7235,7 @@ byteSize('Hello World'); // 11
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### capitalize @@ -7259,7 +7259,7 @@ capitalize('fooBar', true); // 'Foobar'
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### capitalizeEveryWord @@ -7280,7 +7280,7 @@ capitalizeEveryWord('hello world!'); // 'Hello World!'
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### CSVToArray @@ -7310,7 +7310,7 @@ CSVToArray('col1,col2\na,b\nc,d', ',', true); // [['a','b'],['c','d']];
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### CSVToJSON ![advanced](/advanced.svg) @@ -7345,7 +7345,7 @@ CSVToJSON('col1;col2\na;b\nc;d', ';'); // [{'col1': 'a', 'col2': 'b'}, {'col1':
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### decapitalize @@ -7369,7 +7369,7 @@ decapitalize('FooBar', true); // 'fOOBAR'
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### escapeHTML @@ -7401,7 +7401,7 @@ escapeHTML('Me & you'); // '<a href="#">Me &
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### escapeRegExp @@ -7422,7 +7422,7 @@ escapeRegExp('(test)'); // \\(test\\)
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### fromCamelCase @@ -7450,7 +7450,7 @@ fromCamelCase('someJavascriptProperty', '_'); // 'some_javascript_property'
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### isAbsoluteURL @@ -7473,7 +7473,7 @@ isAbsoluteURL('/foo/bar'); // false
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### isAnagram @@ -7503,7 +7503,7 @@ isAnagram('iceman', 'cinema'); // true
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### isLowerCase @@ -7526,7 +7526,7 @@ isLowerCase('Ab4'); // false
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### isUpperCase @@ -7550,7 +7550,7 @@ isLowerCase('aB4'); // false
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### mapString @@ -7577,7 +7577,7 @@ mapString('lorem ipsum', c => c.toUpperCase()); // 'LOREM IPSUM'
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### mask @@ -7604,7 +7604,7 @@ mask(1234567890, -4, '$'); // '$$$$567890'
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### pad @@ -7629,7 +7629,7 @@ pad('foobar', 3); // 'foobar'
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### palindrome @@ -7654,7 +7654,7 @@ palindrome('taco cat'); // true
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### pluralize @@ -7690,7 +7690,7 @@ autoPluralize(2, 'person'); // 'people'
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### removeNonASCII @@ -7711,7 +7711,7 @@ removeNonASCII('äÄçÇéÉêlorem-ipsumöÖÐþúÚ'); // 'lorem-ipsum'
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### reverseString @@ -7733,7 +7733,7 @@ reverseString('foobar'); // 'raboof'
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### sortCharactersInString @@ -7754,7 +7754,7 @@ sortCharactersInString('cabbage'); // 'aabbceg'
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### splitLines @@ -7775,7 +7775,7 @@ splitLines('This\nis a\nmultiline\nstring.\n'); // ['This', 'is a', 'multiline',
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### stringPermutations ![advanced](/advanced.svg) @@ -7810,7 +7810,7 @@ stringPermutations('abc'); // ['abc','acb','bac','bca','cab','cba']
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### stripHTMLTags @@ -7831,7 +7831,7 @@ stripHTMLTags('

    lorem ipsum

    '); // 'lorem ipsum'
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### toCamelCase @@ -7863,7 +7863,7 @@ toCamelCase('some-mixed_string with spaces_underscores-and-hyphens'); // 'someMi
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### toKebabCase @@ -7893,7 +7893,7 @@ toKebabCase('IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSo
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### toSnakeCase @@ -7923,7 +7923,7 @@ toSnakeCase('IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSo
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### truncateString @@ -7946,7 +7946,7 @@ truncateString('boomerang', 7); // 'boom...'
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### unescapeHTML @@ -7978,7 +7978,7 @@ unescapeHTML('<a href="#">Me & you</a>'); // ' -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### URLJoin ![advanced](/advanced.svg) @@ -8007,7 +8007,7 @@ URLJoin('http://www.google.com', 'a', '/b/cd', '?foo=123', '?bar=foo'); // 'http
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### words @@ -8030,7 +8030,7 @@ words('python, javaScript & coffee'); // ["python", "javaScript", "coffee"]
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) --- @@ -8057,7 +8057,7 @@ getType(new Set([1, 2, 3])); // 'set'
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### is @@ -8090,7 +8090,7 @@ is(Boolean, new Boolean(true)); // true
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### isArrayLike @@ -8113,7 +8113,7 @@ isArrayLike(null); // false
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### isBoolean @@ -8135,7 +8135,7 @@ isBoolean(false); // true
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### isEmpty @@ -8165,7 +8165,7 @@ isEmpty(true); // true - type is not considered a collection
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### isFunction @@ -8187,7 +8187,7 @@ isFunction(x => x); // true
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### isNil @@ -8209,7 +8209,7 @@ isNil(undefined); // true
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### isNull @@ -8230,7 +8230,7 @@ isNull(null); // true
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### isNumber @@ -8252,7 +8252,7 @@ isNumber(1); // true
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### isObject @@ -8279,7 +8279,7 @@ isObject(true); // false
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### isObjectLike @@ -8303,7 +8303,7 @@ isObjectLike(null); // false
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### isPlainObject @@ -8325,7 +8325,7 @@ isPlainObject(new Map()); // false
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### isPrimitive @@ -8353,7 +8353,7 @@ isPrimitive([]); // false
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### isPromiseLike @@ -8383,7 +8383,7 @@ isPromiseLike({}); // false
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### isString @@ -8404,7 +8404,7 @@ isString('10'); // true
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### isSymbol @@ -8425,7 +8425,7 @@ isSymbol(Symbol('x')); // true
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### isUndefined @@ -8446,7 +8446,7 @@ isUndefined(undefined); // true
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### isValidJSON @@ -8476,7 +8476,7 @@ isValidJSON(null); // true
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) --- @@ -8503,7 +8503,7 @@ castArray([1]); // [1]
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### cloneRegExp @@ -8525,7 +8525,7 @@ const regExp2 = cloneRegExp(regExp); // /lorem ipsum/gi
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### coalesce @@ -8546,7 +8546,7 @@ coalesce(null, undefined, '', NaN, 'Waldo'); // ""
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### coalesceFactory @@ -8568,7 +8568,7 @@ customCoalesce(undefined, null, NaN, '', 'Waldo'); // "Waldo"
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### extendHex @@ -8597,7 +8597,7 @@ extendHex('05a'); // '#0055aa'
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### getURLParameters @@ -8624,7 +8624,7 @@ getURLParameters('google.com'); // {}
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### hexToRGB ![advanced](/advanced.svg) @@ -8665,7 +8665,7 @@ hexToRGB('#fff'); // 'rgb(255, 255, 255)'
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### httpGet @@ -8705,7 +8705,7 @@ Logs: {
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### httpPost @@ -8765,7 +8765,7 @@ Logs: {
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### isBrowser @@ -8789,7 +8789,7 @@ isBrowser(); // false (Node)
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### mostPerformant @@ -8828,7 +8828,7 @@ mostPerformant([
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### nthArg @@ -8853,7 +8853,7 @@ last(1, 2, 3, 4, 5); // 5
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### parseCookie @@ -8883,7 +8883,7 @@ parseCookie('foo=bar; equation=E%3Dmc%5E2'); // { foo: 'bar', equation: 'E=mc^2'
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### prettyBytes ![advanced](/advanced.svg) @@ -8916,7 +8916,7 @@ prettyBytes(123456789, 3, false); // "123MB"
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### randomHexColorCode @@ -8940,7 +8940,7 @@ randomHexColorCode(); // "#e34155"
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### RGBToHex @@ -8961,7 +8961,7 @@ RGBToHex(255, 165, 1); // 'ffa501'
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### serializeCookie @@ -8982,7 +8982,7 @@ serializeCookie('foo', 'bar'); // 'foo=bar'
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### timeTaken @@ -9008,7 +9008,7 @@ timeTaken(() => Math.pow(2, 10)); // 1024, (logged): timeTaken: 0.02099609375ms
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### toCurrency @@ -9034,7 +9034,7 @@ toCurrency(322342436423.2435, 'JPY', 'fi'); // 322 342 436 423 ¥ | currency: Ja
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### toDecimalMark @@ -9053,7 +9053,7 @@ toDecimalMark(12305030388.9087); // "12,305,030,388.909"
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### toOrdinalSuffix @@ -9085,7 +9085,7 @@ toOrdinalSuffix('123'); // "123rd"
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### validateNumber @@ -9108,7 +9108,7 @@ validateNumber('10'); // true
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ### yesNo @@ -9134,7 +9134,7 @@ yesNo('Foo', true); // true
    -[⬆ Back to top](#table-of-contents) +
    [⬆ Back to top](#table-of-contents) ## Collaborators diff --git a/scripts/build.js b/scripts/build.js index 9d817d4ff..686b742b8 100644 --- a/scripts/build.js +++ b/scripts/build.js @@ -76,7 +76,7 @@ if ( data.slice(data.lastIndexOf('```js'), data.lastIndexOf('```')) + data.slice(data.lastIndexOf('```')) ); - output += data + '\n' + misc.link('⬆ Back to top', misc.anchor('Table of Contents')) + '\n\n'; + output += data + '\n
    ' + misc.link('⬆ Back to top', misc.anchor('Table of Contents')) + '\n\n'; } // Write to the README file of the archive @@ -206,7 +206,7 @@ try { snippet.slice(snippet.lastIndexOf('```')) ); - output += snippet + '\n' + misc.link('⬆ Back to top', misc.anchor('Table of Contents')) + '\n\n'; + output += snippet + '\n
    ' + misc.link('⬆ Back to top', misc.anchor('Table of Contents')) + '\n\n'; } } From 6a6a160868eaeac139dba39557b3ccb496222745 Mon Sep 17 00:00:00 2001 From: Felix Wu Date: Fri, 14 Sep 2018 18:22:34 +0200 Subject: [PATCH 14/15] remove the trailing spaces --- README.md | 664 +++++++++++++++++++++++----------------------- package-lock.json | 6 +- package.json | 2 +- 3 files changed, 336 insertions(+), 336 deletions(-) diff --git a/README.md b/README.md index 3f7defad2..88ddc8bdd 100644 --- a/README.md +++ b/README.md @@ -100,7 +100,7 @@ average(1, 2, 3); * [`unary`](#unary)
    - + ### 📚 Array
    @@ -199,7 +199,7 @@ average(1, 2, 3); * [`zipWith`](#zipwith-)
    - + ### 🌐 Browser
    @@ -242,7 +242,7 @@ average(1, 2, 3); * [`UUIDGeneratorBrowser`](#uuidgeneratorbrowser)
    - + ### ⏱️ Date
    @@ -255,7 +255,7 @@ average(1, 2, 3); * [`tomorrow`](#tomorrow)
    - + ### 🎛️ Function
    @@ -288,7 +288,7 @@ average(1, 2, 3); * [`when`](#when)
    - + ### ➗ Math
    @@ -333,7 +333,7 @@ average(1, 2, 3); * [`toSafeInteger`](#tosafeinteger)
    - + ### 📦 Node
    @@ -351,7 +351,7 @@ average(1, 2, 3); * [`UUIDGeneratorNode`](#uuidgeneratornode)
    - + ### 🗃️ Object
    @@ -393,7 +393,7 @@ average(1, 2, 3); * [`unflattenObject`](#unflattenobject-)
    - + ### 📜 String
    @@ -432,7 +432,7 @@ average(1, 2, 3); * [`words`](#words)
    - + ### 📃 Type
    @@ -458,7 +458,7 @@ average(1, 2, 3); * [`isValidJSON`](#isvalidjson)
    - + ### 🔧 Utility
    @@ -489,7 +489,7 @@ average(1, 2, 3); * [`yesNo`](#yesno)
    - + --- @@ -514,7 +514,7 @@ const firstTwoMax = ary(Math.max, 2); ```
    - +
    [⬆ Back to top](#table-of-contents) ### call @@ -541,7 +541,7 @@ Promise.resolve([1, 2, 3]) ```
    - +
    [⬆ Back to top](#table-of-contents) ### collectInto @@ -566,7 +566,7 @@ Pall(p1, p2, p3).then(console.log); // [1, 2, 3] (after about 2 seconds) ```
    - +
    [⬆ Back to top](#table-of-contents) ### flip @@ -593,7 +593,7 @@ Object.assign(b, a); // == b ```
    - +
    [⬆ Back to top](#table-of-contents) ### over @@ -615,7 +615,7 @@ minMax(1, 2, 3, 4, 5); // [1,5] ```
    - +
    [⬆ Back to top](#table-of-contents) ### overArgs @@ -639,7 +639,7 @@ fn(9, 3); // [81, 6] ```
    - +
    [⬆ Back to top](#table-of-contents) ### pipeAsyncFunctions @@ -670,7 +670,7 @@ const sum = pipeAsyncFunctions( ```
    - +
    [⬆ Back to top](#table-of-contents) ### pipeFunctions @@ -695,7 +695,7 @@ multiplyAndAdd5(5, 2); // 15 ```
    - +
    [⬆ Back to top](#table-of-contents) ### promisify @@ -723,7 +723,7 @@ delay(2000).then(() => console.log('Hi!')); // // Promise resolves after 2s ```
    - +
    [⬆ Back to top](#table-of-contents) ### rearg @@ -750,7 +750,7 @@ rearged('b', 'c', 'a'); // ['a', 'b', 'c'] ```
    - +
    [⬆ Back to top](#table-of-contents) ### spreadOver @@ -772,7 +772,7 @@ arrayMax([1, 2, 3]); // 3 ```
    - +
    [⬆ Back to top](#table-of-contents) ### unary @@ -793,7 +793,7 @@ const unary = fn => val => fn(val); ```
  • - +
    [⬆ Back to top](#table-of-contents) @@ -821,7 +821,7 @@ all([1, 2, 3]); // true ```
    - +
    [⬆ Back to top](#table-of-contents) ### allEqual @@ -843,7 +843,7 @@ allEqual([1, 1, 1, 1]); // true ```
    - +
    [⬆ Back to top](#table-of-contents) ### any @@ -866,7 +866,7 @@ any([0, 0, 1, 0]); // true ```
    - +
    [⬆ Back to top](#table-of-contents) ### arrayToCSV @@ -891,7 +891,7 @@ arrayToCSV([['a', 'b'], ['c', 'd']], ';'); // '"a";"b"\n"c";"d"' ``` - +
    [⬆ Back to top](#table-of-contents) ### bifurcate @@ -913,7 +913,7 @@ bifurcate(['beep', 'boop', 'foo', 'bar'], [true, true, false, true]); // [ ['bee ``` - +
    [⬆ Back to top](#table-of-contents) ### bifurcateBy @@ -935,7 +935,7 @@ bifurcateBy(['beep', 'boop', 'foo', 'bar'], x => x[0] === 'b'); // [ ['beep', 'b ``` - +
    [⬆ Back to top](#table-of-contents) ### chunk @@ -961,7 +961,7 @@ chunk([1, 2, 3, 4, 5], 2); // [[1,2],[3,4],[5]] ``` - +
    [⬆ Back to top](#table-of-contents) ### compact @@ -982,7 +982,7 @@ compact([0, 1, false, 2, '', 3, 'a', 'e' * 23, NaN, 's', 34]); // [ 1, 2, 3, 'a' ``` - +
    [⬆ Back to top](#table-of-contents) ### countBy @@ -1009,7 +1009,7 @@ countBy(['one', 'two', 'three'], 'length'); // {3: 2, 5: 1} ``` - +
    [⬆ Back to top](#table-of-contents) ### countOccurrences @@ -1030,7 +1030,7 @@ countOccurrences([1, 1, 2, 1, 2, 3], 1); // 3 ``` - +
    [⬆ Back to top](#table-of-contents) ### deepFlatten @@ -1053,7 +1053,7 @@ deepFlatten([1, [2], [[3], 4], 5]); // [1,2,3,4,5] ``` - +
    [⬆ Back to top](#table-of-contents) ### difference @@ -1077,7 +1077,7 @@ difference([1, 2, 3], [1, 2, 4]); // [3] ``` - +
    [⬆ Back to top](#table-of-contents) ### differenceBy @@ -1102,7 +1102,7 @@ differenceBy([{ x: 2 }, { x: 1 }], [{ x: 1 }], v => v.x); // [ { x: 2 } ] ``` - +
    [⬆ Back to top](#table-of-contents) ### differenceWith @@ -1123,7 +1123,7 @@ differenceWith([1, 1.2, 1.5, 3, 0], [1.9, 3, 0], (a, b) => Math.round(a) === Mat ``` - +
    [⬆ Back to top](#table-of-contents) ### drop @@ -1146,7 +1146,7 @@ drop([1, 2, 3], 42); // [] ``` - +
    [⬆ Back to top](#table-of-contents) ### dropRight @@ -1169,7 +1169,7 @@ dropRight([1, 2, 3], 42); // [] ``` - +
    [⬆ Back to top](#table-of-contents) ### dropRightWhile @@ -1194,7 +1194,7 @@ dropRightWhile([1, 2, 3, 4], n => n < 3); // [1, 2] ``` - +
    [⬆ Back to top](#table-of-contents) ### dropWhile @@ -1219,7 +1219,7 @@ dropWhile([1, 2, 3, 4], n => n >= 3); // [3,4] ``` - +
    [⬆ Back to top](#table-of-contents) ### everyNth @@ -1240,7 +1240,7 @@ everyNth([1, 2, 3, 4, 5, 6], 2); // [ 2, 4, 6 ] ``` - +
    [⬆ Back to top](#table-of-contents) ### filterNonUnique @@ -1261,7 +1261,7 @@ filterNonUnique([1, 2, 2, 3, 4, 4, 5]); // [1,3,5] ``` - +
    [⬆ Back to top](#table-of-contents) ### filterNonUniqueBy @@ -1293,7 +1293,7 @@ filterNonUniqueBy( ``` - +
    [⬆ Back to top](#table-of-contents) ### findLast @@ -1314,7 +1314,7 @@ findLast([1, 2, 3, 4], n => n % 2 === 1); // 3 ``` - +
    [⬆ Back to top](#table-of-contents) ### findLastIndex @@ -1340,7 +1340,7 @@ findLastIndex([1, 2, 3, 4], n => n % 2 === 1); // 2 (index of the value 3) ``` - +
    [⬆ Back to top](#table-of-contents) ### flatten @@ -1366,7 +1366,7 @@ flatten([1, [2, [3, [4, 5], 6], 7], 8], 2); // [1, 2, 3, [4, 5], 6, 7, 8] ``` - +
    [⬆ Back to top](#table-of-contents) ### forEachRight @@ -1391,7 +1391,7 @@ forEachRight([1, 2, 3, 4], val => console.log(val)); // '4', '3', '2', '1' ``` - +
    [⬆ Back to top](#table-of-contents) ### groupBy @@ -1418,7 +1418,7 @@ groupBy(['one', 'two', 'three'], 'length'); // {3: ['one', 'two'], 5: ['three']} ``` - +
    [⬆ Back to top](#table-of-contents) ### head @@ -1439,7 +1439,7 @@ head([1, 2, 3]); // 1 ``` - +
    [⬆ Back to top](#table-of-contents) ### indexOfAll @@ -1462,7 +1462,7 @@ indexOfAll([1, 2, 3], 4); // [] ``` - +
    [⬆ Back to top](#table-of-contents) ### initial @@ -1483,7 +1483,7 @@ initial([1, 2, 3]); // [1,2] ``` - +
    [⬆ Back to top](#table-of-contents) ### initialize2DArray @@ -1505,7 +1505,7 @@ initialize2DArray(2, 2, 0); // [[0,0], [0,0]] ``` - +
    [⬆ Back to top](#table-of-contents) ### initializeArrayWithRange @@ -1531,7 +1531,7 @@ initializeArrayWithRange(9, 0, 2); // [0,2,4,6,8] ``` - +
    [⬆ Back to top](#table-of-contents) ### initializeArrayWithRangeRight @@ -1559,7 +1559,7 @@ initializeArrayWithRangeRight(9, 0, 2); // [8,6,4,2,0] ``` - +
    [⬆ Back to top](#table-of-contents) ### initializeArrayWithValues @@ -1581,7 +1581,7 @@ initializeArrayWithValues(5, 2); // [2,2,2,2,2] ``` - +
    [⬆ Back to top](#table-of-contents) ### initializeNDArray @@ -1607,7 +1607,7 @@ initializeNDArray(5, 2, 2, 2); // [[[5,5],[5,5]],[[5,5],[5,5]]] ``` - +
    [⬆ Back to top](#table-of-contents) ### intersection @@ -1631,7 +1631,7 @@ intersection([1, 2, 3], [4, 3, 2]); // [2,3] ``` - +
    [⬆ Back to top](#table-of-contents) ### intersectionBy @@ -1655,7 +1655,7 @@ intersectionBy([2.1, 1.2], [2.3, 3.4], Math.floor); // [2.1] ``` - +
    [⬆ Back to top](#table-of-contents) ### intersectionWith @@ -1676,7 +1676,7 @@ intersectionWith([1, 1.2, 1.5, 3, 0], [1.9, 3, 0, 3.9], (a, b) => Math.round(a) ``` - +
    [⬆ Back to top](#table-of-contents) ### isSorted @@ -1708,7 +1708,7 @@ isSorted([4, 3, 5]); // 0 ``` - +
    [⬆ Back to top](#table-of-contents) ### join @@ -1742,7 +1742,7 @@ join(['pen', 'pineapple', 'apple', 'pen']); // "pen,pineapple,apple,pen" ``` - +
    [⬆ Back to top](#table-of-contents) ### JSONtoCSV ![advanced](/advanced.svg) @@ -1776,7 +1776,7 @@ JSONtoCSV([{ a: 1, b: 2 }, { a: 3, b: 4, c: 5 }, { a: 6 }, { b: 7 }], ['a', 'b'] ``` - +
    [⬆ Back to top](#table-of-contents) ### last @@ -1797,7 +1797,7 @@ last([1, 2, 3]); // 3 ``` - +
    [⬆ Back to top](#table-of-contents) ### longestItem @@ -1825,7 +1825,7 @@ longestItem([1, 2, 3], 'foobar'); // 'foobar' ``` - +
    [⬆ Back to top](#table-of-contents) ### mapObject ![advanced](/advanced.svg) @@ -1850,7 +1850,7 @@ squareIt([1, 2, 3]); // { 1: 1, 2: 4, 3: 9 } ``` - +
    [⬆ Back to top](#table-of-contents) ### maxN @@ -1874,7 +1874,7 @@ maxN([1, 2, 3], 2); // [3,2] ``` - +
    [⬆ Back to top](#table-of-contents) ### minN @@ -1898,7 +1898,7 @@ minN([1, 2, 3], 2); // [1,2] ``` - +
    [⬆ Back to top](#table-of-contents) ### none @@ -1921,7 +1921,7 @@ none([0, 0, 0]); // true ``` - +
    [⬆ Back to top](#table-of-contents) ### nthElement @@ -1945,7 +1945,7 @@ nthElement(['a', 'b', 'b'], -3); // 'a' ``` - +
    [⬆ Back to top](#table-of-contents) ### offset @@ -1969,7 +1969,7 @@ offset([1, 2, 3, 4, 5], -2); // [4, 5, 1, 2, 3] ``` - +
    [⬆ Back to top](#table-of-contents) ### partition @@ -1999,7 +1999,7 @@ partition(users, o => o.active); // [[{ 'user': 'fred', 'age': 40, 'active': ``` - +
    [⬆ Back to top](#table-of-contents) ### permutations ![advanced](/advanced.svg) @@ -2034,7 +2034,7 @@ permutations([1, 33, 5]); // [ [ 1, 33, 5 ], [ 1, 5, 33 ], [ 33, 1, 5 ], [ 33, 5 ``` - +
    [⬆ Back to top](#table-of-contents) ### pull @@ -2064,7 +2064,7 @@ pull(myArray, 'a', 'c'); // myArray = [ 'b', 'b' ] ``` - +
    [⬆ Back to top](#table-of-contents) ### pullAtIndex ![advanced](/advanced.svg) @@ -2096,7 +2096,7 @@ let pulled = pullAtIndex(myArray, [1, 3]); // myArray = [ 'a', 'c' ] , pulled = ``` - +
    [⬆ Back to top](#table-of-contents) ### pullAtValue ![advanced](/advanced.svg) @@ -2127,7 +2127,7 @@ let pulled = pullAtValue(myArray, ['b', 'd']); // myArray = [ 'a', 'c' ] , pulle ``` - +
    [⬆ Back to top](#table-of-contents) ### pullBy ![advanced](/advanced.svg) @@ -2160,7 +2160,7 @@ pullBy(myArray, [{ x: 1 }, { x: 3 }], o => o.x); // myArray = [{ x: 2 }] ``` - +
    [⬆ Back to top](#table-of-contents) ### reducedFilter @@ -2201,7 +2201,7 @@ reducedFilter(data, ['id', 'name'], item => item.age > 24); // [{ id: 2, name: ' ``` - +
    [⬆ Back to top](#table-of-contents) ### reduceSuccessive @@ -2223,7 +2223,7 @@ reduceSuccessive([1, 2, 3, 4, 5, 6], (acc, val) => acc + val, 0); // [0, 1, 3, 6 ``` - +
    [⬆ Back to top](#table-of-contents) ### reduceWhich @@ -2251,7 +2251,7 @@ reduceWhich( ``` - +
    [⬆ Back to top](#table-of-contents) ### reject @@ -2271,7 +2271,7 @@ reject(word => word.length > 4, ['Apple', 'Pear', 'Kiwi', 'Banana']); // ['Pear' ``` - +
    [⬆ Back to top](#table-of-contents) ### remove @@ -2299,7 +2299,7 @@ remove([1, 2, 3, 4], n => n % 2 === 0); // [2, 4] ``` - +
    [⬆ Back to top](#table-of-contents) ### sample @@ -2321,7 +2321,7 @@ sample([3, 7, 9, 11]); // 9 ``` - +
    [⬆ Back to top](#table-of-contents) ### sampleSize @@ -2352,7 +2352,7 @@ sampleSize([1, 2, 3], 4); // [2,3,1] ``` - +
    [⬆ Back to top](#table-of-contents) ### shuffle @@ -2381,7 +2381,7 @@ shuffle(foo); // [2,3,1], foo = [1,2,3] ``` - +
    [⬆ Back to top](#table-of-contents) ### similarity @@ -2402,7 +2402,7 @@ similarity([1, 2, 3], [1, 2, 4]); // [1,2] ``` - +
    [⬆ Back to top](#table-of-contents) ### sortedIndex @@ -2429,7 +2429,7 @@ sortedIndex([30, 50], 40); // 1 ``` - +
    [⬆ Back to top](#table-of-contents) ### sortedIndexBy @@ -2456,7 +2456,7 @@ sortedIndexBy([{ x: 4 }, { x: 5 }], { x: 4 }, o => o.x); // 0 ``` - +
    [⬆ Back to top](#table-of-contents) ### sortedLastIndex @@ -2482,7 +2482,7 @@ sortedLastIndex([10, 20, 30, 30, 40], 30); // 4 ``` - +
    [⬆ Back to top](#table-of-contents) ### sortedLastIndexBy @@ -2513,7 +2513,7 @@ sortedLastIndexBy([{ x: 4 }, { x: 5 }], { x: 4 }, o => o.x); // 1 ``` - +
    [⬆ Back to top](#table-of-contents) ### stableSort ![advanced](/advanced.svg) @@ -2542,7 +2542,7 @@ const stable = stableSort(arr, () => 0); // [0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10] ``` - +
    [⬆ Back to top](#table-of-contents) ### symmetricDifference @@ -2568,7 +2568,7 @@ symmetricDifference([1, 2, 2], [1, 3, 1]); // [2, 2, 3] ``` - +
    [⬆ Back to top](#table-of-contents) ### symmetricDifferenceBy @@ -2593,7 +2593,7 @@ symmetricDifferenceBy([2.1, 1.2], [2.3, 3.4], Math.floor); // [ 1.2, 3.4 ] ``` - +
    [⬆ Back to top](#table-of-contents) ### symmetricDifferenceWith @@ -2621,7 +2621,7 @@ symmetricDifferenceWith( ``` - +
    [⬆ Back to top](#table-of-contents) ### tail @@ -2643,7 +2643,7 @@ tail([1]); // [1] ``` - +
    [⬆ Back to top](#table-of-contents) ### take @@ -2665,7 +2665,7 @@ take([1, 2, 3], 0); // [] ``` - +
    [⬆ Back to top](#table-of-contents) ### takeRight @@ -2687,7 +2687,7 @@ takeRight([1, 2, 3]); // [3] ``` - +
    [⬆ Back to top](#table-of-contents) ### takeRightWhile @@ -2713,7 +2713,7 @@ takeRightWhile([1, 2, 3, 4], n => n < 3); // [3, 4] ``` - +
    [⬆ Back to top](#table-of-contents) ### takeWhile @@ -2738,7 +2738,7 @@ takeWhile([1, 2, 3, 4], n => n >= 3); // [1, 2] ``` - +
    [⬆ Back to top](#table-of-contents) ### toHash @@ -2776,7 +2776,7 @@ managers; // [ { manager:1, employees: [ { id: 2, first: "Joe" }, { id: 3, first ``` - +
    [⬆ Back to top](#table-of-contents) ### union @@ -2797,7 +2797,7 @@ union([1, 2, 3], [4, 3, 2]); // [1,2,3,4] ``` - +
    [⬆ Back to top](#table-of-contents) ### unionBy @@ -2823,7 +2823,7 @@ unionBy([2.1], [1.2, 2.3], Math.floor); // [2.1, 1.2] ``` - +
    [⬆ Back to top](#table-of-contents) ### unionWith @@ -2845,7 +2845,7 @@ unionWith([1, 1.2, 1.5, 3, 0], [1.9, 3, 0, 3.9], (a, b) => Math.round(a) === Mat ``` - +
    [⬆ Back to top](#table-of-contents) ### uniqueElements @@ -2866,7 +2866,7 @@ uniqueElements([1, 2, 2, 3, 4, 4, 5]); // [1,2,3,4,5] ``` - +
    [⬆ Back to top](#table-of-contents) ### uniqueElementsBy @@ -2901,7 +2901,7 @@ uniqueElementsBy( ``` - +
    [⬆ Back to top](#table-of-contents) ### uniqueElementsByRight @@ -2936,7 +2936,7 @@ uniqueElementsByRight( ``` - +
    [⬆ Back to top](#table-of-contents) ### uniqueSymmetricDifference @@ -2960,7 +2960,7 @@ uniqueSymmetricDifference([1, 2, 2], [1, 3, 1]); // [2, 3] ``` - +
    [⬆ Back to top](#table-of-contents) ### unzip @@ -2989,7 +2989,7 @@ unzip([['a', 1, true], ['b', 2]]); //[['a', 'b'], [1, 2], [true]] ``` - +
    [⬆ Back to top](#table-of-contents) ### unzipWith ![advanced](/advanced.svg) @@ -3020,7 +3020,7 @@ unzipWith([[1, 10, 100], [2, 20, 200]], (...args) => args.reduce((acc, v) => acc ``` - +
    [⬆ Back to top](#table-of-contents) ### without @@ -3043,7 +3043,7 @@ without([2, 1, 2, 3], 1, 2); // [3] ``` - +
    [⬆ Back to top](#table-of-contents) ### xProd @@ -3064,7 +3064,7 @@ xProd([1, 2], ['a', 'b']); // [[1, 'a'], [1, 'b'], [2, 'a'], [2, 'b']] ``` - +
    [⬆ Back to top](#table-of-contents) ### zip @@ -3093,7 +3093,7 @@ zip(['a'], [1, 2], [true, false]); // [['a', 1, true], [undefined, 2, false]] ``` - +
    [⬆ Back to top](#table-of-contents) ### zipObject @@ -3116,7 +3116,7 @@ zipObject(['a', 'b'], [1, 2, 3]); // {a: 1, b: 2} ``` - +
    [⬆ Back to top](#table-of-contents) ### zipWith ![advanced](/advanced.svg) @@ -3153,7 +3153,7 @@ zipWith( ``` - +
    [⬆ Back to top](#table-of-contents) @@ -3183,7 +3183,7 @@ arrayToHtmlList(['item 1', 'item 2'], 'myListID'); ``` - +
    [⬆ Back to top](#table-of-contents) ### bottomVisible @@ -3206,7 +3206,7 @@ bottomVisible(); // true ``` - +
    [⬆ Back to top](#table-of-contents) ### copyToClipboard ![advanced](/advanced.svg) @@ -3249,7 +3249,7 @@ copyToClipboard('Lorem ipsum'); // 'Lorem ipsum' copied to clipboard. ``` - +
    [⬆ Back to top](#table-of-contents) ### counter ![advanced](/advanced.svg) @@ -3284,7 +3284,7 @@ counter('#my-id', 1, 1000, 5, 2000); // Creates a 2-second timer for the element ``` - +
    [⬆ Back to top](#table-of-contents) ### createElement @@ -3317,7 +3317,7 @@ console.log(el.className); // 'container' ``` - +
    [⬆ Back to top](#table-of-contents) ### createEventHub ![advanced](/advanced.svg) @@ -3370,7 +3370,7 @@ hub.off('message', handler); ``` - +
    [⬆ Back to top](#table-of-contents) ### currentURL @@ -3391,7 +3391,7 @@ currentURL(); // 'https://google.com' ``` - +
    [⬆ Back to top](#table-of-contents) ### detectDeviceType @@ -3415,7 +3415,7 @@ detectDeviceType(); // "Mobile" or "Desktop" ``` - +
    [⬆ Back to top](#table-of-contents) ### elementContains @@ -3437,7 +3437,7 @@ elementContains(document.querySelector('body'), document.querySelector('body')); ``` - +
    [⬆ Back to top](#table-of-contents) ### elementIsVisibleInViewport ![advanced](/advanced.svg) @@ -3470,7 +3470,7 @@ elementIsVisibleInViewport(el, true); // true - (partially visible) ``` - +
    [⬆ Back to top](#table-of-contents) ### getScrollPosition @@ -3495,7 +3495,7 @@ getScrollPosition(); // {x: 0, y: 200} ``` - +
    [⬆ Back to top](#table-of-contents) ### getStyle @@ -3516,7 +3516,7 @@ getStyle(document.querySelector('p'), 'font-size'); // '16px' ``` - +
    [⬆ Back to top](#table-of-contents) ### hasClass @@ -3537,7 +3537,7 @@ hasClass(document.querySelector('p.special'), 'special'); // true ``` - +
    [⬆ Back to top](#table-of-contents) ### hashBrowser ![advanced](/advanced.svg) @@ -3565,7 +3565,7 @@ hashBrowser(JSON.stringify({ a: 'a', b: [1, 2, 3, 4], foo: { c: 'bar' } })).then ``` - +
    [⬆ Back to top](#table-of-contents) ### hide @@ -3586,7 +3586,7 @@ hide(document.querySelectorAll('img')); // Hides all elements on the page ``` - +
    [⬆ Back to top](#table-of-contents) ### httpsRedirect @@ -3609,7 +3609,7 @@ httpsRedirect(); // If you are on http://mydomain.com, you are redirected to htt ``` - +
    [⬆ Back to top](#table-of-contents) ### insertAfter @@ -3630,7 +3630,7 @@ insertAfter(document.getElementById('myId'), '

    after

    '); //
    ``` - +
    [⬆ Back to top](#table-of-contents) ### insertBefore @@ -3651,7 +3651,7 @@ insertBefore(document.getElementById('myId'), '

    before

    '); //

    before

    ``` - +
    [⬆ Back to top](#table-of-contents) ### isBrowserTabFocused @@ -3672,7 +3672,7 @@ isBrowserTabFocused(); // true ``` - +
    [⬆ Back to top](#table-of-contents) ### nodeListToArray @@ -3693,7 +3693,7 @@ nodeListToArray(document.childNodes); // [ , html ] ``` - +
    [⬆ Back to top](#table-of-contents) ### observeMutations ![advanced](/advanced.svg) @@ -3734,7 +3734,7 @@ obs.disconnect(); // Disconnects the observer and stops logging mutations on the ``` - +
    [⬆ Back to top](#table-of-contents) ### off @@ -3758,7 +3758,7 @@ off(document.body, 'click', fn); // no longer logs '!' upon clicking on the page ``` - +
    [⬆ Back to top](#table-of-contents) ### on @@ -3788,7 +3788,7 @@ on(document.body, 'click', fn, { options: true }); // use capturing instead of b ``` - +
    [⬆ Back to top](#table-of-contents) ### onUserInputChange ![advanced](/advanced.svg) @@ -3826,7 +3826,7 @@ onUserInputChange(type => { ``` - +
    [⬆ Back to top](#table-of-contents) ### prefix @@ -3855,7 +3855,7 @@ prefix('appearance'); // 'appearance' on a supported browser, otherwise 'webkitA ``` - +
    [⬆ Back to top](#table-of-contents) ### recordAnimationFrames @@ -3902,7 +3902,7 @@ const recorder2 = recordAnimationFrames(cb, false); // `start` needs to be expli ``` - +
    [⬆ Back to top](#table-of-contents) ### redirect @@ -3925,7 +3925,7 @@ redirect('https://google.com'); ``` - +
    [⬆ Back to top](#table-of-contents) ### runAsync ![advanced](/advanced.svg) @@ -3981,7 +3981,7 @@ runAsync(() => typeof outsideVariable).then(console.log); // 'undefined' ``` - +
    [⬆ Back to top](#table-of-contents) ### scrollToTop @@ -4009,7 +4009,7 @@ scrollToTop(); ``` - +
    [⬆ Back to top](#table-of-contents) ### setStyle @@ -4030,7 +4030,7 @@ setStyle(document.querySelector('p'), 'font-size', '20px'); // The first

    ele ``` - +
    [⬆ Back to top](#table-of-contents) ### show @@ -4051,7 +4051,7 @@ show(...document.querySelectorAll('img')); // Shows all elements on the pa ``` - +
    [⬆ Back to top](#table-of-contents) ### smoothScroll @@ -4077,7 +4077,7 @@ smoothScroll('.fooBar'); // scrolls smoothly to the first element with a class o ``` - +
    [⬆ Back to top](#table-of-contents) ### toggleClass @@ -4098,7 +4098,7 @@ toggleClass(document.querySelector('p.special'), 'special'); // The paragraph wi ``` - +
    [⬆ Back to top](#table-of-contents) ### triggerEvent @@ -4123,7 +4123,7 @@ triggerEvent(document.getElementById('myId'), 'click', { username: 'bob' }); ``` - +
    [⬆ Back to top](#table-of-contents) ### UUIDGeneratorBrowser @@ -4147,7 +4147,7 @@ UUIDGeneratorBrowser(); // '7982fcfe-5721-4632-bede-6000885be57d' ``` - +
    [⬆ Back to top](#table-of-contents) @@ -4190,7 +4190,7 @@ formatDuration(34325055574); // '397 days, 6 hours, 44 minutes, 15 seconds, 574 ``` - +
    [⬆ Back to top](#table-of-contents) ### getColonTimeFromDate @@ -4211,7 +4211,7 @@ getColonTimeFromDate(new Date()); // "08:38:00" ``` - +
    [⬆ Back to top](#table-of-contents) ### getDaysDiffBetweenDates @@ -4233,7 +4233,7 @@ getDaysDiffBetweenDates(new Date('2017-12-13'), new Date('2017-12-22')); // 9 ``` - +
    [⬆ Back to top](#table-of-contents) ### getMeridiemSuffixOfInteger @@ -4264,7 +4264,7 @@ getMeridiemSuffixOfInteger(25); // "1pm" ``` - +
    [⬆ Back to top](#table-of-contents) ### tomorrow @@ -4292,7 +4292,7 @@ tomorrow(true); // 2017-12-27T00:00:00 (if current date is 2017-12-26) ``` - +
    [⬆ Back to top](#table-of-contents) @@ -4327,7 +4327,7 @@ if (elements instanceof Error) elements = []; // elements = [] ``` - +
    [⬆ Back to top](#table-of-contents) ### bind @@ -4354,7 +4354,7 @@ console.log(freddyBound('hi', '!')); // 'hi fred!' ``` - +
    [⬆ Back to top](#table-of-contents) ### bindKey @@ -4384,7 +4384,7 @@ console.log(freddyBound('hi', '!')); // 'hi fred!' ``` - +
    [⬆ Back to top](#table-of-contents) ### chainAsync @@ -4417,7 +4417,7 @@ chainAsync([ ``` - +
    [⬆ Back to top](#table-of-contents) ### compose @@ -4445,7 +4445,7 @@ multiplyAndAdd5(5, 2); // 15 ``` - +
    [⬆ Back to top](#table-of-contents) ### composeRight @@ -4470,7 +4470,7 @@ addAndSquare(1, 2); // 9 ``` - +
    [⬆ Back to top](#table-of-contents) ### converge @@ -4496,7 +4496,7 @@ average([1, 2, 3, 4, 5, 6, 7]); // 4 ``` - +
    [⬆ Back to top](#table-of-contents) ### curry @@ -4522,7 +4522,7 @@ curry(Math.min, 3)(10)(50)(2); // 2 ``` - +
    [⬆ Back to top](#table-of-contents) ### debounce @@ -4556,7 +4556,7 @@ window.addEventListener( ``` - +
    [⬆ Back to top](#table-of-contents) ### defer @@ -4583,7 +4583,7 @@ defer(longRunningFunction); // Browser will update the HTML then run the functio ``` - +
    [⬆ Back to top](#table-of-contents) ### delay @@ -4611,7 +4611,7 @@ delay( ``` - +
    [⬆ Back to top](#table-of-contents) ### functionName @@ -4632,7 +4632,7 @@ functionName(Math.max); // max (logged in debug channel of console) ``` - +
    [⬆ Back to top](#table-of-contents) ### hz @@ -4675,7 +4675,7 @@ Math.round(hz(sumForLoop)); // 4784 ``` - +
    [⬆ Back to top](#table-of-contents) ### memoize ![advanced](/advanced.svg) @@ -4709,7 +4709,7 @@ console.log(anagramsCached.cache); // The cached anagrams map ``` - +
    [⬆ Back to top](#table-of-contents) ### negate @@ -4730,7 +4730,7 @@ const negate = func => (...args) => !func(...args); ``` - +
    [⬆ Back to top](#table-of-contents) ### once @@ -4762,7 +4762,7 @@ document.body.addEventListener('click', once(startApp)); // only runs `startApp` ``` - +
    [⬆ Back to top](#table-of-contents) ### partial @@ -4785,7 +4785,7 @@ greetHello('John'); // 'Hello John!' ``` - +
    [⬆ Back to top](#table-of-contents) ### partialRight @@ -4808,7 +4808,7 @@ greetJohn('Hello'); // 'Hello John!' ``` - +
    [⬆ Back to top](#table-of-contents) ### runPromisesInSeries @@ -4830,7 +4830,7 @@ runPromisesInSeries([() => delay(1000), () => delay(2000)]); // Executes each pr ``` - +
    [⬆ Back to top](#table-of-contents) ### sleep @@ -4855,7 +4855,7 @@ async function sleepyWork() { ``` - +
    [⬆ Back to top](#table-of-contents) ### throttle ![advanced](/advanced.svg) @@ -4904,7 +4904,7 @@ window.addEventListener( ``` - +
    [⬆ Back to top](#table-of-contents) ### times @@ -4931,7 +4931,7 @@ console.log(output); // 01234 ``` - +
    [⬆ Back to top](#table-of-contents) ### uncurry @@ -4962,7 +4962,7 @@ uncurriedAdd(1, 2, 3); // 6 ``` - +
    [⬆ Back to top](#table-of-contents) ### unfold @@ -4990,7 +4990,7 @@ unfold(f, 10); // [-10, -20, -30, -40, -50] ``` - +
    [⬆ Back to top](#table-of-contents) ### when @@ -5013,7 +5013,7 @@ doubleEvenNumbers(1); // 1 ``` - +
    [⬆ Back to top](#table-of-contents) @@ -5040,7 +5040,7 @@ approximatelyEqual(Math.PI / 2.0, 1.5708); // true ``` - +
    [⬆ Back to top](#table-of-contents) ### average @@ -5062,7 +5062,7 @@ average(1, 2, 3); // 2 ``` - +
    [⬆ Back to top](#table-of-contents) ### averageBy @@ -5086,7 +5086,7 @@ averageBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }], 'n'); // 5 ``` - +
    [⬆ Back to top](#table-of-contents) ### binomialCoefficient @@ -5120,7 +5120,7 @@ binomialCoefficient(8, 2); // 28 ``` - +
    [⬆ Back to top](#table-of-contents) ### clampNumber @@ -5143,7 +5143,7 @@ clampNumber(1, -1, -5); // -1 ``` - +
    [⬆ Back to top](#table-of-contents) ### degreesToRads @@ -5164,7 +5164,7 @@ degreesToRads(90.0); // ~1.5708 ``` - +
    [⬆ Back to top](#table-of-contents) ### digitize @@ -5186,7 +5186,7 @@ digitize(123); // [1, 2, 3] ``` - +
    [⬆ Back to top](#table-of-contents) ### distance @@ -5207,7 +5207,7 @@ distance(1, 1, 2, 3); // 2.23606797749979 ``` - +
    [⬆ Back to top](#table-of-contents) ### elo ![advanced](/advanced.svg) @@ -5258,7 +5258,7 @@ own individual rating by supplying it as the third argument. ``` - +
    [⬆ Back to top](#table-of-contents) ### factorial @@ -5289,7 +5289,7 @@ factorial(6); // 720 ``` - +
    [⬆ Back to top](#table-of-contents) ### fibonacci @@ -5315,7 +5315,7 @@ fibonacci(6); // [0, 1, 1, 2, 3, 5] ``` - +
    [⬆ Back to top](#table-of-contents) ### gcd @@ -5342,7 +5342,7 @@ gcd(...[12, 8, 32]); // 4 ``` - +
    [⬆ Back to top](#table-of-contents) ### geometricProgression @@ -5371,7 +5371,7 @@ geometricProgression(256, 1, 4); // [1, 4, 16, 64, 256] ``` - +
    [⬆ Back to top](#table-of-contents) ### hammingDistance @@ -5393,7 +5393,7 @@ hammingDistance(2, 3); // 1 ``` - +
    [⬆ Back to top](#table-of-contents) ### inRange @@ -5421,7 +5421,7 @@ inRange(3, 2); // false ``` - +
    [⬆ Back to top](#table-of-contents) ### isDivisible @@ -5442,7 +5442,7 @@ isDivisible(6, 3); // true ``` - +
    [⬆ Back to top](#table-of-contents) ### isEven @@ -5464,7 +5464,7 @@ isEven(3); // false ``` - +
    [⬆ Back to top](#table-of-contents) ### isPrime @@ -5490,7 +5490,7 @@ isPrime(11); // true ``` - +
    [⬆ Back to top](#table-of-contents) ### lcm @@ -5517,7 +5517,7 @@ lcm(...[1, 3, 4, 5]); // 60 ``` - +
    [⬆ Back to top](#table-of-contents) ### luhnCheck ![advanced](/advanced.svg) @@ -5553,7 +5553,7 @@ luhnCheck(123456789); // false ``` - +
    [⬆ Back to top](#table-of-contents) ### maxBy @@ -5575,7 +5575,7 @@ maxBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }], 'n'); // 8 ``` - +
    [⬆ Back to top](#table-of-contents) ### median @@ -5601,7 +5601,7 @@ median([5, 6, 50, 1, -5]); // 5 ``` - +
    [⬆ Back to top](#table-of-contents) ### minBy @@ -5623,7 +5623,7 @@ minBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }], 'n'); // 2 ``` - +
    [⬆ Back to top](#table-of-contents) ### percentile @@ -5645,7 +5645,7 @@ percentile([1, 2, 3, 4, 5, 6, 7, 8, 9, 10], 6); // 55 ``` - +
    [⬆ Back to top](#table-of-contents) ### powerset @@ -5666,7 +5666,7 @@ powerset([1, 2]); // [[], [1], [2], [2,1]] ``` - +
    [⬆ Back to top](#table-of-contents) ### primes @@ -5693,7 +5693,7 @@ primes(10); // [2,3,5,7] ``` - +
    [⬆ Back to top](#table-of-contents) ### radsToDegrees @@ -5714,7 +5714,7 @@ radsToDegrees(Math.PI / 2); // 90 ``` - +
    [⬆ Back to top](#table-of-contents) ### randomIntArrayInRange @@ -5736,7 +5736,7 @@ randomIntArrayInRange(12, 35, 10); // [ 34, 14, 27, 17, 30, 27, 20, 26, 21, 14 ] ``` - +
    [⬆ Back to top](#table-of-contents) ### randomIntegerInRange @@ -5757,7 +5757,7 @@ randomIntegerInRange(0, 5); // 2 ``` - +
    [⬆ Back to top](#table-of-contents) ### randomNumberInRange @@ -5778,7 +5778,7 @@ randomNumberInRange(2, 10); // 6.0211363285087005 ``` - +
    [⬆ Back to top](#table-of-contents) ### round @@ -5800,7 +5800,7 @@ round(1.005, 2); // 1.01 ``` - +
    [⬆ Back to top](#table-of-contents) ### sdbm @@ -5828,7 +5828,7 @@ sdbm('name'); // -3521204949 ``` - +
    [⬆ Back to top](#table-of-contents) ### standardDeviation @@ -5858,7 +5858,7 @@ standardDeviation([10, 2, 38, 23, 38, 23, 21], true); // 12.29899614287479 (popu ``` - +
    [⬆ Back to top](#table-of-contents) ### sum @@ -5879,7 +5879,7 @@ sum(...[1, 2, 3, 4]); // 10 ``` - +
    [⬆ Back to top](#table-of-contents) ### sumBy @@ -5902,7 +5902,7 @@ sumBy([{ n: 4 }, { n: 2 }, { n: 8 }, { n: 6 }], 'n'); // 20 ``` - +
    [⬆ Back to top](#table-of-contents) ### sumPower @@ -5931,7 +5931,7 @@ sumPower(10, 3, 5); //2925 ``` - +
    [⬆ Back to top](#table-of-contents) ### toSafeInteger @@ -5955,7 +5955,7 @@ toSafeInteger(Infinity); // 9007199254740991 ``` - +
    [⬆ Back to top](#table-of-contents) @@ -5981,7 +5981,7 @@ atob('Zm9vYmFy'); // 'foobar' ``` - +
    [⬆ Back to top](#table-of-contents) ### btoa @@ -6002,7 +6002,7 @@ btoa('foobar'); // 'Zm9vYmFy' ``` - +
    [⬆ Back to top](#table-of-contents) ### colorize @@ -6043,7 +6043,7 @@ console.log(colorize(colorize('foo').yellow, colorize('foo').green).bgWhite); // ``` - +
    [⬆ Back to top](#table-of-contents) ### hasFlags @@ -6069,7 +6069,7 @@ hasFlags('special'); // false ``` - +
    [⬆ Back to top](#table-of-contents) ### hashNode @@ -6103,7 +6103,7 @@ hashNode(JSON.stringify({ a: 'a', b: [1, 2, 3, 4], foo: { c: 'bar' } })).then(co ``` - +
    [⬆ Back to top](#table-of-contents) ### isTravisCI @@ -6124,7 +6124,7 @@ isTravisCI(); // true (if code is running on Travis CI) ``` - +
    [⬆ Back to top](#table-of-contents) ### JSONToFile @@ -6147,7 +6147,7 @@ JSONToFile({ test: 'is passed' }, 'testJsonFile'); // writes the object to 'test ``` - +
    [⬆ Back to top](#table-of-contents) ### readFileLines @@ -6184,7 +6184,7 @@ console.log(arr); // ['line1', 'line2', 'line3'] - +
    [⬆ Back to top](#table-of-contents) ### untildify @@ -6205,7 +6205,7 @@ untildify('~/node'); // '/Users/aUser/node' ``` - +
    [⬆ Back to top](#table-of-contents) ### UUIDGeneratorNode @@ -6230,7 +6230,7 @@ UUIDGeneratorNode(); // '79c7c136-60ee-40a2-beb2-856f1feabefc' ``` - +
    [⬆ Back to top](#table-of-contents) @@ -6271,7 +6271,7 @@ jQuery(element).on('click', view.click); // Logs 'clicked docs' when clicked. ``` - +
    [⬆ Back to top](#table-of-contents) ### deepClone @@ -6301,7 +6301,7 @@ const b = deepClone(a); // a !== b, a.obj !== b.obj ``` - +
    [⬆ Back to top](#table-of-contents) ### deepFreeze @@ -6331,7 +6331,7 @@ o[1][0] = 4; // not allowed as well ``` - +
    [⬆ Back to top](#table-of-contents) ### defaults @@ -6352,7 +6352,7 @@ defaults({ a: 1 }, { b: 2 }, { b: 6 }, { a: 3 }); // { a: 1, b: 2 } ``` - +
    [⬆ Back to top](#table-of-contents) ### dig @@ -6388,7 +6388,7 @@ dig(data, 'level4'); // undefined ``` - +
    [⬆ Back to top](#table-of-contents) ### equals ![advanced](/advanced.svg) @@ -6420,7 +6420,7 @@ equals({ a: [2, { e: 3 }], b: [4], c: 'foo' }, { a: [2, { e: 3 }], b: [4], c: 'f ``` - +
    [⬆ Back to top](#table-of-contents) ### findKey @@ -6448,7 +6448,7 @@ findKey( ``` - +
    [⬆ Back to top](#table-of-contents) ### findLastKey @@ -6479,7 +6479,7 @@ findLastKey( ``` - +
    [⬆ Back to top](#table-of-contents) ### flattenObject @@ -6510,7 +6510,7 @@ flattenObject({ a: { b: { c: 1 } }, d: 1 }); // { 'a.b.c': 1, d: 1 } ``` - +
    [⬆ Back to top](#table-of-contents) ### forOwn @@ -6531,7 +6531,7 @@ forOwn({ foo: 'bar', a: 1 }, v => console.log(v)); // 'bar', 1 ``` - +
    [⬆ Back to top](#table-of-contents) ### forOwnRight @@ -6555,7 +6555,7 @@ forOwnRight({ foo: 'bar', a: 1 }, v => console.log(v)); // 1, 'bar' ``` - +
    [⬆ Back to top](#table-of-contents) ### functions @@ -6589,7 +6589,7 @@ functions(new Foo(), true); // ['a', 'b', 'c'] ``` - +
    [⬆ Back to top](#table-of-contents) ### get @@ -6618,7 +6618,7 @@ get(obj, 'selector.to.val', 'target[0]', 'target[2].a'); // ['val to select', 1, ``` - +
    [⬆ Back to top](#table-of-contents) ### invertKeyValues @@ -6647,7 +6647,7 @@ invertKeyValues({ a: 1, b: 2, c: 1 }, value => 'group' + value); // { group1: [ ``` - +
    [⬆ Back to top](#table-of-contents) ### lowercaseKeys @@ -6674,7 +6674,7 @@ const myObjLower = lowercaseKeys(myObj); // {name: 'Adam', surname: 'Smith'}; ``` - +
    [⬆ Back to top](#table-of-contents) ### mapKeys @@ -6700,7 +6700,7 @@ mapKeys({ a: 1, b: 2 }, (val, key) => key + val); // { a1: 1, b2: 2 } ``` - +
    [⬆ Back to top](#table-of-contents) ### mapValues @@ -6730,7 +6730,7 @@ mapValues(users, u => u.age); // { fred: 40, pebbles: 1 } ``` - +
    [⬆ Back to top](#table-of-contents) ### matches @@ -6753,7 +6753,7 @@ matches({ hair: 'long', beard: true }, { age: 25, hair: 'long', beard: true }); ``` - +
    [⬆ Back to top](#table-of-contents) ### matchesWith @@ -6786,7 +6786,7 @@ matchesWith( ``` - +
    [⬆ Back to top](#table-of-contents) ### merge @@ -6825,7 +6825,7 @@ merge(object, other); // { a: [ { x: 2 }, { y: 4 }, { z: 3 } ], b: [ 1, 2, 3 ], ``` - +
    [⬆ Back to top](#table-of-contents) ### nest @@ -6862,7 +6862,7 @@ const nestedComments = nest(comments); // [{ id: 1, parent_id: null, children: [ - +
    [⬆ Back to top](#table-of-contents) ### objectFromPairs @@ -6883,7 +6883,7 @@ objectFromPairs([['a', 1], ['b', 2]]); // {a: 1, b: 2} ``` - +
    [⬆ Back to top](#table-of-contents) ### objectToPairs @@ -6904,7 +6904,7 @@ objectToPairs({ a: 1, b: 2 }); // [['a',1],['b',2]] ``` - +
    [⬆ Back to top](#table-of-contents) ### omit @@ -6929,7 +6929,7 @@ omit({ a: 1, b: '2', c: 3 }, ['b']); // { 'a': 1, 'c': 3 } ``` - +
    [⬆ Back to top](#table-of-contents) ### omitBy @@ -6954,7 +6954,7 @@ omitBy({ a: 1, b: '2', c: 3 }, x => typeof x === 'number'); // { b: '2' } ``` - +
    [⬆ Back to top](#table-of-contents) ### orderBy @@ -6987,7 +6987,7 @@ orderBy(users, ['name', 'age']); // [{name: 'barney', age: 36}, {name: 'fred', a ``` - +
    [⬆ Back to top](#table-of-contents) ### pick @@ -7009,7 +7009,7 @@ pick({ a: 1, b: '2', c: 3 }, ['a', 'c']); // { 'a': 1, 'c': 3 } ``` - +
    [⬆ Back to top](#table-of-contents) ### pickBy @@ -7034,7 +7034,7 @@ pickBy({ a: 1, b: '2', c: 3 }, x => typeof x === 'number'); // { 'a': 1, 'c': 3 ``` - +
    [⬆ Back to top](#table-of-contents) ### renameKeys @@ -7063,7 +7063,7 @@ renameKeys({ name: 'firstName', job: 'passion' }, obj); // { firstName: 'Bobo', ``` - +
    [⬆ Back to top](#table-of-contents) ### shallowClone @@ -7085,7 +7085,7 @@ const b = shallowClone(a); // a !== b ``` - +
    [⬆ Back to top](#table-of-contents) ### size @@ -7120,7 +7120,7 @@ size({ one: 1, two: 2, three: 3 }); // 3 ``` - +
    [⬆ Back to top](#table-of-contents) ### transform @@ -7148,7 +7148,7 @@ transform( ``` - +
    [⬆ Back to top](#table-of-contents) ### truthCheckCollection @@ -7169,7 +7169,7 @@ truthCheckCollection([{ user: 'Tinky-Winky', sex: 'male' }, { user: 'Dipsy', sex ``` - +
    [⬆ Back to top](#table-of-contents) ### unflattenObject ![advanced](/advanced.svg) @@ -7207,7 +7207,7 @@ unflattenObject({ 'a.b.c': 1, d: 1 }); // { a: { b: { c: 1 } }, d: 1 } ``` - +
    [⬆ Back to top](#table-of-contents) @@ -7234,7 +7234,7 @@ byteSize('Hello World'); // 11 ``` - +
    [⬆ Back to top](#table-of-contents) ### capitalize @@ -7258,7 +7258,7 @@ capitalize('fooBar', true); // 'Foobar' ``` - +
    [⬆ Back to top](#table-of-contents) ### capitalizeEveryWord @@ -7279,7 +7279,7 @@ capitalizeEveryWord('hello world!'); // 'Hello World!' ``` - +
    [⬆ Back to top](#table-of-contents) ### CSVToArray @@ -7309,7 +7309,7 @@ CSVToArray('col1,col2\na,b\nc,d', ',', true); // [['a','b'],['c','d']]; ``` - +
    [⬆ Back to top](#table-of-contents) ### CSVToJSON ![advanced](/advanced.svg) @@ -7344,7 +7344,7 @@ CSVToJSON('col1;col2\na;b\nc;d', ';'); // [{'col1': 'a', 'col2': 'b'}, {'col1': ``` - +
    [⬆ Back to top](#table-of-contents) ### decapitalize @@ -7368,7 +7368,7 @@ decapitalize('FooBar', true); // 'fOOBAR' ``` - +
    [⬆ Back to top](#table-of-contents) ### escapeHTML @@ -7400,7 +7400,7 @@ escapeHTML('
    Me & you'); // '<a href="#">Me & ``` - +
    [⬆ Back to top](#table-of-contents) ### escapeRegExp @@ -7421,7 +7421,7 @@ escapeRegExp('(test)'); // \\(test\\) ``` - +
    [⬆ Back to top](#table-of-contents) ### fromCamelCase @@ -7449,7 +7449,7 @@ fromCamelCase('someJavascriptProperty', '_'); // 'some_javascript_property' ``` - +
    [⬆ Back to top](#table-of-contents) ### isAbsoluteURL @@ -7472,7 +7472,7 @@ isAbsoluteURL('/foo/bar'); // false ``` - +
    [⬆ Back to top](#table-of-contents) ### isAnagram @@ -7502,7 +7502,7 @@ isAnagram('iceman', 'cinema'); // true ``` - +
    [⬆ Back to top](#table-of-contents) ### isLowerCase @@ -7525,7 +7525,7 @@ isLowerCase('Ab4'); // false ``` - +
    [⬆ Back to top](#table-of-contents) ### isUpperCase @@ -7549,7 +7549,7 @@ isLowerCase('aB4'); // false ``` - +
    [⬆ Back to top](#table-of-contents) ### mapString @@ -7576,7 +7576,7 @@ mapString('lorem ipsum', c => c.toUpperCase()); // 'LOREM IPSUM' ``` - +
    [⬆ Back to top](#table-of-contents) ### mask @@ -7603,7 +7603,7 @@ mask(1234567890, -4, '$'); // '$$$$567890' ``` - +
    [⬆ Back to top](#table-of-contents) ### pad @@ -7628,7 +7628,7 @@ pad('foobar', 3); // 'foobar' ``` - +
    [⬆ Back to top](#table-of-contents) ### palindrome @@ -7653,7 +7653,7 @@ palindrome('taco cat'); // true ``` - +
    [⬆ Back to top](#table-of-contents) ### pluralize @@ -7689,7 +7689,7 @@ autoPluralize(2, 'person'); // 'people' ``` - +
    [⬆ Back to top](#table-of-contents) ### removeNonASCII @@ -7710,7 +7710,7 @@ removeNonASCII('äÄçÇéÉêlorem-ipsumöÖÐþúÚ'); // 'lorem-ipsum' ``` - +
    [⬆ Back to top](#table-of-contents) ### reverseString @@ -7732,7 +7732,7 @@ reverseString('foobar'); // 'raboof' ``` - +
    [⬆ Back to top](#table-of-contents) ### sortCharactersInString @@ -7753,7 +7753,7 @@ sortCharactersInString('cabbage'); // 'aabbceg' ``` - +
    [⬆ Back to top](#table-of-contents) ### splitLines @@ -7774,7 +7774,7 @@ splitLines('This\nis a\nmultiline\nstring.\n'); // ['This', 'is a', 'multiline', ``` - +
    [⬆ Back to top](#table-of-contents) ### stringPermutations ![advanced](/advanced.svg) @@ -7809,7 +7809,7 @@ stringPermutations('abc'); // ['abc','acb','bac','bca','cab','cba'] ``` - +
    [⬆ Back to top](#table-of-contents) ### stripHTMLTags @@ -7830,7 +7830,7 @@ stripHTMLTags('

    lorem ipsum

    '); // 'lorem ipsum' ``` - +
    [⬆ Back to top](#table-of-contents) ### toCamelCase @@ -7862,7 +7862,7 @@ toCamelCase('some-mixed_string with spaces_underscores-and-hyphens'); // 'someMi ``` - +
    [⬆ Back to top](#table-of-contents) ### toKebabCase @@ -7892,7 +7892,7 @@ toKebabCase('IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSo ``` - +
    [⬆ Back to top](#table-of-contents) ### toSnakeCase @@ -7922,7 +7922,7 @@ toSnakeCase('IAmListeningToFMWhileLoadingDifferentURLOnMyBrowserAndAlsoEditingSo ``` - +
    [⬆ Back to top](#table-of-contents) ### truncateString @@ -7945,7 +7945,7 @@ truncateString('boomerang', 7); // 'boom...' ``` - +
    [⬆ Back to top](#table-of-contents) ### unescapeHTML @@ -7977,7 +7977,7 @@ unescapeHTML('<a href="#">Me & you</a>'); // ' - +
    [⬆ Back to top](#table-of-contents) ### URLJoin ![advanced](/advanced.svg) @@ -8006,7 +8006,7 @@ URLJoin('http://www.google.com', 'a', '/b/cd', '?foo=123', '?bar=foo'); // 'http ``` - +
    [⬆ Back to top](#table-of-contents) ### words @@ -8029,7 +8029,7 @@ words('python, javaScript & coffee'); // ["python", "javaScript", "coffee"] ``` - +
    [⬆ Back to top](#table-of-contents) @@ -8056,7 +8056,7 @@ getType(new Set([1, 2, 3])); // 'set' ``` - +
    [⬆ Back to top](#table-of-contents) ### is @@ -8089,7 +8089,7 @@ is(Boolean, new Boolean(true)); // true ``` - +
    [⬆ Back to top](#table-of-contents) ### isArrayLike @@ -8112,7 +8112,7 @@ isArrayLike(null); // false ``` - +
    [⬆ Back to top](#table-of-contents) ### isBoolean @@ -8134,7 +8134,7 @@ isBoolean(false); // true ``` - +
    [⬆ Back to top](#table-of-contents) ### isEmpty @@ -8164,7 +8164,7 @@ isEmpty(true); // true - type is not considered a collection ``` - +
    [⬆ Back to top](#table-of-contents) ### isFunction @@ -8186,7 +8186,7 @@ isFunction(x => x); // true ``` - +
    [⬆ Back to top](#table-of-contents) ### isNil @@ -8208,7 +8208,7 @@ isNil(undefined); // true ``` - +
    [⬆ Back to top](#table-of-contents) ### isNull @@ -8229,7 +8229,7 @@ isNull(null); // true ``` - +
    [⬆ Back to top](#table-of-contents) ### isNumber @@ -8251,7 +8251,7 @@ isNumber(1); // true ``` - +
    [⬆ Back to top](#table-of-contents) ### isObject @@ -8278,7 +8278,7 @@ isObject(true); // false ``` - +
    [⬆ Back to top](#table-of-contents) ### isObjectLike @@ -8302,7 +8302,7 @@ isObjectLike(null); // false ``` - +
    [⬆ Back to top](#table-of-contents) ### isPlainObject @@ -8324,7 +8324,7 @@ isPlainObject(new Map()); // false ``` - +
    [⬆ Back to top](#table-of-contents) ### isPrimitive @@ -8352,7 +8352,7 @@ isPrimitive([]); // false ``` - +
    [⬆ Back to top](#table-of-contents) ### isPromiseLike @@ -8382,7 +8382,7 @@ isPromiseLike({}); // false ``` - +
    [⬆ Back to top](#table-of-contents) ### isString @@ -8403,7 +8403,7 @@ isString('10'); // true ``` - +
    [⬆ Back to top](#table-of-contents) ### isSymbol @@ -8424,7 +8424,7 @@ isSymbol(Symbol('x')); // true ``` - +
    [⬆ Back to top](#table-of-contents) ### isUndefined @@ -8445,7 +8445,7 @@ isUndefined(undefined); // true ``` - +
    [⬆ Back to top](#table-of-contents) ### isValidJSON @@ -8475,7 +8475,7 @@ isValidJSON(null); // true ``` - +
    [⬆ Back to top](#table-of-contents) @@ -8502,7 +8502,7 @@ castArray([1]); // [1] ``` - +
    [⬆ Back to top](#table-of-contents) ### cloneRegExp @@ -8524,7 +8524,7 @@ const regExp2 = cloneRegExp(regExp); // /lorem ipsum/gi ``` - +
    [⬆ Back to top](#table-of-contents) ### coalesce @@ -8545,7 +8545,7 @@ coalesce(null, undefined, '', NaN, 'Waldo'); // "" ``` - +
    [⬆ Back to top](#table-of-contents) ### coalesceFactory @@ -8567,7 +8567,7 @@ customCoalesce(undefined, null, NaN, '', 'Waldo'); // "Waldo" ``` - +
    [⬆ Back to top](#table-of-contents) ### extendHex @@ -8596,7 +8596,7 @@ extendHex('05a'); // '#0055aa' ``` - +
    [⬆ Back to top](#table-of-contents) ### getURLParameters @@ -8623,7 +8623,7 @@ getURLParameters('google.com'); // {} ``` - +
    [⬆ Back to top](#table-of-contents) ### hexToRGB ![advanced](/advanced.svg) @@ -8664,7 +8664,7 @@ hexToRGB('#fff'); // 'rgb(255, 255, 255)' ``` - +
    [⬆ Back to top](#table-of-contents) ### httpGet @@ -8704,7 +8704,7 @@ Logs: { ``` - +
    [⬆ Back to top](#table-of-contents) ### httpPost @@ -8764,7 +8764,7 @@ Logs: { ``` - +
    [⬆ Back to top](#table-of-contents) ### isBrowser @@ -8788,7 +8788,7 @@ isBrowser(); // false (Node) ``` - +
    [⬆ Back to top](#table-of-contents) ### mostPerformant @@ -8827,7 +8827,7 @@ mostPerformant([ ``` - +
    [⬆ Back to top](#table-of-contents) ### nthArg @@ -8852,7 +8852,7 @@ last(1, 2, 3, 4, 5); // 5 ``` - +
    [⬆ Back to top](#table-of-contents) ### parseCookie @@ -8882,7 +8882,7 @@ parseCookie('foo=bar; equation=E%3Dmc%5E2'); // { foo: 'bar', equation: 'E=mc^2' ``` - +
    [⬆ Back to top](#table-of-contents) ### prettyBytes ![advanced](/advanced.svg) @@ -8915,7 +8915,7 @@ prettyBytes(123456789, 3, false); // "123MB" ``` - +
    [⬆ Back to top](#table-of-contents) ### randomHexColorCode @@ -8939,7 +8939,7 @@ randomHexColorCode(); // "#e34155" ``` - +
    [⬆ Back to top](#table-of-contents) ### RGBToHex @@ -8960,7 +8960,7 @@ RGBToHex(255, 165, 1); // 'ffa501' ``` - +
    [⬆ Back to top](#table-of-contents) ### serializeCookie @@ -8981,7 +8981,7 @@ serializeCookie('foo', 'bar'); // 'foo=bar' ``` - +
    [⬆ Back to top](#table-of-contents) ### timeTaken @@ -9007,7 +9007,7 @@ timeTaken(() => Math.pow(2, 10)); // 1024, (logged): timeTaken: 0.02099609375ms ``` - +
    [⬆ Back to top](#table-of-contents) ### toCurrency @@ -9033,7 +9033,7 @@ toCurrency(322342436423.2435, 'JPY', 'fi'); // 322 342 436 423 ¥ | currency: Ja ``` - +
    [⬆ Back to top](#table-of-contents) ### toDecimalMark @@ -9052,7 +9052,7 @@ toDecimalMark(12305030388.9087); // "12,305,030,388.909" ``` - +
    [⬆ Back to top](#table-of-contents) ### toOrdinalSuffix @@ -9084,7 +9084,7 @@ toOrdinalSuffix('123'); // "123rd" ``` - +
    [⬆ Back to top](#table-of-contents) ### validateNumber @@ -9107,7 +9107,7 @@ validateNumber('10'); // true ``` - +
    [⬆ Back to top](#table-of-contents) ### yesNo @@ -9133,7 +9133,7 @@ yesNo('Foo', true); // true ``` - +
    [⬆ Back to top](#table-of-contents) diff --git a/package-lock.json b/package-lock.json index 991795cd9..6d5bc52e4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5729,9 +5729,9 @@ } }, "markdown-builder": { - "version": "0.8.4-dev", - "resolved": "https://registry.npmjs.org/markdown-builder/-/markdown-builder-0.8.4-dev.tgz", - "integrity": "sha512-egn7ENFiFmc1E/xcRGgXi2Q6oPxWUPYtSJY7RSb3WOdjyVoRQ3JVGMykiM98kMdrRb1QqNYoa+OI/4GdqGsTYw==", + "version": "0.8.4-hotfix", + "resolved": "https://registry.npmjs.org/markdown-builder/-/markdown-builder-0.8.4-hotfix.tgz", + "integrity": "sha512-hpqPx1i+UPVFeSG3rLgPFPp7/Zb62zNsrPsULGUPNgHo1z8HHnAiwkV+sbtz9N3adn7g4xJUVTN7A2BZ1V0ZLQ==", "dev": true, "requires": { "husky": "1.0.0-rc.14" diff --git a/package.json b/package.json index 063572c9c..7cbc99549 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "html-minifier": "^3.5.15", "jest": "^23.1.0", "jest-tap-reporter": "^1.9.0", - "markdown-builder": "^0.8.4-dev", + "markdown-builder": "^0.8.4-hotfix", "markdown-it": "^8.4.1", "mini.css": "^2.3.7", "node-sass": "^4.9.0", From 48b4b785e812d4b9596b7af19811c593024bfe68 Mon Sep 17 00:00:00 2001 From: Felix Wu Date: Fri, 14 Sep 2018 18:29:36 +0200 Subject: [PATCH 15/15] remove all trailing spaces --- README.md | 752 +++++++++++++++++++++++----------------------- package-lock.json | 6 +- package.json | 2 +- 3 files changed, 380 insertions(+), 380 deletions(-) diff --git a/README.md b/README.md index 88ddc8bdd..2eb60cd94 100644 --- a/README.md +++ b/README.md @@ -81,7 +81,7 @@ average(1, 2, 3); ## Table of Contents -### 🔌 Adapter +### 🔌 Adapter
    View contents @@ -101,7 +101,7 @@ average(1, 2, 3);
    -### 📚 Array +### 📚 Array
    View contents @@ -200,7 +200,7 @@ average(1, 2, 3);
    -### 🌐 Browser +### 🌐 Browser
    View contents @@ -243,7 +243,7 @@ average(1, 2, 3);
    -### ⏱️ Date +### ⏱️ Date
    View contents @@ -256,7 +256,7 @@ average(1, 2, 3);
    -### 🎛️ Function +### 🎛️ Function
    View contents @@ -289,7 +289,7 @@ average(1, 2, 3);
    -### ➗ Math +### ➗ Math
    View contents @@ -334,7 +334,7 @@ average(1, 2, 3);
    -### 📦 Node +### 📦 Node
    View contents @@ -352,7 +352,7 @@ average(1, 2, 3);
    -### 🗃️ Object +### 🗃️ Object
    View contents @@ -394,7 +394,7 @@ average(1, 2, 3);
    -### 📜 String +### 📜 String
    View contents @@ -433,7 +433,7 @@ average(1, 2, 3);
    -### 📃 Type +### 📃 Type
    View contents @@ -459,7 +459,7 @@ average(1, 2, 3);
    -### 🔧 Utility +### 🔧 Utility
    View contents @@ -490,10 +490,10 @@ average(1, 2, 3);
    - ---- - -## 🔌 Adapter + +--- + +## 🔌 Adapter ### ary @@ -503,7 +503,7 @@ Call the provided function, `fn`, with up to `n` arguments, using `Array.slice(0 ```js const ary = (fn, n) => (...args) => fn(...args.slice(0, n)); -``` +```
    Examples @@ -525,7 +525,7 @@ Use a closure to call a stored key with stored arguments. ```js const call = (key, ...args) => context => context[key](...args); -``` +```
    Examples @@ -552,7 +552,7 @@ Given a function, return a closure that collects all inputs into an array-accept ```js const collectInto = fn => (...args) => fn(args); -``` +```
    Examples @@ -577,7 +577,7 @@ Return a closure that takes variadic inputs, and splices the last argument to ma ```js const flip = fn => (first, ...rest) => fn(...rest, first); -``` +```
    Examples @@ -604,7 +604,7 @@ Use `Array.map()` and `Function.apply()` to apply each function to the given arg ```js const over = (...fns) => (...args) => fns.map(fn => fn.apply(null, args)); -``` +```
    Examples @@ -626,7 +626,7 @@ Use `Array.map()` to apply `transforms` to `args` in combination with the spread ```js const overArgs = (fn, transforms) => (...args) => fn(...args.map((val, i) => transforms[i](val))); -``` +```
    Examples @@ -652,7 +652,7 @@ All functions must be unary. ```js const pipeAsyncFunctions = (...fns) => arg => fns.reduce((p, f) => p.then(f), Promise.resolve(arg)); -``` +```
    Examples @@ -682,7 +682,7 @@ The first (leftmost) function can accept one or more arguments; the remaining fu ```js const pipeFunctions = (...fns) => fns.reduce((f, g) => (...args) => g(f(...args))); -``` +```
    Examples @@ -712,7 +712,7 @@ const promisify = func => (...args) => new Promise((resolve, reject) => func(...args, (err, result) => (err ? reject(err) : resolve(result))) ); -``` +```
    Examples @@ -734,7 +734,7 @@ Use `Array.map()` to reorder arguments based on `indexes` in combination with th ```js const rearg = (fn, indexes) => (...args) => fn(...indexes.map(i => args[i])); -``` +```
    Examples @@ -761,7 +761,7 @@ Use closures and the spread operator (`...`) to map the array of arguments to th ```js const spreadOver = fn => argsArr => fn(...argsArr); -``` +```
    Examples @@ -783,7 +783,7 @@ Call the provided function, `fn`, with just the first argument given. ```js const unary = fn => val => fn(val); -``` +```
    Examples @@ -796,10 +796,10 @@ const unary = fn => val => fn(val);
    [⬆ Back to top](#table-of-contents) - ---- - -## 📚 Array + +--- + +## 📚 Array ### all @@ -810,7 +810,7 @@ Omit the second argument, `fn`, to use `Boolean` as a default. ```js const all = (arr, fn = Boolean) => arr.every(fn); -``` +```
    Examples @@ -832,7 +832,7 @@ Use `Array.every()` to check if all the elements of the array are the same as th ```js const allEqual = arr => arr.every(val => val === arr[0]); -``` +```
    Examples @@ -855,7 +855,7 @@ Omit the second argument, `fn`, to use `Boolean` as a default. ```js const any = (arr, fn = Boolean) => arr.some(fn); -``` +```
    Examples @@ -880,7 +880,7 @@ Omit the second argument, `delimiter`, to use a default delimiter of `,`. ```js const arrayToCSV = (arr, delimiter = ',') => arr.map(v => v.map(x => `"${x}"`).join(delimiter)).join('\n'); -``` +```
    Examples @@ -903,7 +903,7 @@ Use `Array.reduce()` and `Array.push()` to add elements to groups, based on `fil ```js const bifurcate = (arr, filter) => arr.reduce((acc, val, i) => (acc[filter[i] ? 0 : 1].push(val), acc), [[], []]); -``` +```
    Examples @@ -925,7 +925,7 @@ Use `Array.reduce()` and `Array.push()` to add elements to groups, based on the ```js const bifurcateBy = (arr, fn) => arr.reduce((acc, val, i) => (acc[fn(val, i) ? 0 : 1].push(val), acc), [[], []]); -``` +```
    Examples @@ -951,7 +951,7 @@ const chunk = (arr, size) => Array.from({ length: Math.ceil(arr.length / size) }, (v, i) => arr.slice(i * size, i * size + size) ); -``` +```
    Examples @@ -972,7 +972,7 @@ Use `Array.filter()` to filter out falsey values (`false`, `null`, `0`, `""`, `u ```js const compact = arr => arr.filter(Boolean); -``` +```
    Examples @@ -998,7 +998,7 @@ const countBy = (arr, fn) => acc[val] = (acc[val] || 0) + 1; return acc; }, {}); -``` +```
    Examples @@ -1020,7 +1020,7 @@ Use `Array.reduce()` to increment a counter each time you encounter the specific ```js const countOccurrences = (arr, val) => arr.reduce((a, v) => (v === val ? a + 1 : a), 0); -``` +```
    Examples @@ -1043,7 +1043,7 @@ Recursively flatten each element that is an array. ```js const deepFlatten = arr => [].concat(...arr.map(v => (Array.isArray(v) ? deepFlatten(v) : v))); -``` +```
    Examples @@ -1067,7 +1067,7 @@ const difference = (a, b) => { const s = new Set(b); return a.filter(x => !s.has(x)); }; -``` +```
    Examples @@ -1091,7 +1091,7 @@ const differenceBy = (a, b, fn) => { const s = new Set(b.map(v => fn(v))); return a.filter(x => !s.has(fn(x))); }; -``` +```
    Examples @@ -1113,7 +1113,7 @@ Use `Array.filter()` and `Array.findIndex()` to find the appropriate values. ```js const differenceWith = (arr, val, comp) => arr.filter(a => val.findIndex(b => comp(a, b)) === -1); -``` +```
    Examples @@ -1134,7 +1134,7 @@ Use `Array.slice()` to slice the remove the specified number of elements from th ```js const drop = (arr, n = 1) => arr.slice(n); -``` +```
    Examples @@ -1157,7 +1157,7 @@ Use `Array.slice()` to slice the remove the specified number of elements from th ```js const dropRight = (arr, n = 1) => arr.slice(0, -n); -``` +```
    Examples @@ -1184,7 +1184,7 @@ const dropRightWhile = (arr, func) => { while (arr.length > 0 && !func(arr[arr.length - 1])) arr = arr.slice(0, -1); return arr; }; -``` +```
    Examples @@ -1209,7 +1209,7 @@ const dropWhile = (arr, func) => { while (arr.length > 0 && !func(arr[0])) arr = arr.slice(1); return arr; }; -``` +```
    Examples @@ -1230,7 +1230,7 @@ Use `Array.filter()` to create a new array that contains every nth element of a ```js const everyNth = (arr, nth) => arr.filter((e, i) => i % nth === nth - 1); -``` +```
    Examples @@ -1251,7 +1251,7 @@ Use `Array.filter()` for an array containing only the unique values. ```js const filterNonUnique = arr => arr.filter(i => arr.indexOf(i) === arr.lastIndexOf(i)); -``` +```
    Examples @@ -1274,7 +1274,7 @@ The comparator function takes four arguments: the values of the two elements bei ```js const filterNonUniqueBy = (arr, fn) => arr.filter((v, i) => arr.every((x, j) => (i === j) === fn(v, x, i, j))); -``` +```
    Examples @@ -1304,7 +1304,7 @@ Use `Array.filter()` to remove elements for which `fn` returns falsey values, `A ```js const findLast = (arr, fn) => arr.filter(fn).pop(); -``` +```
    Examples @@ -1330,7 +1330,7 @@ const findLastIndex = (arr, fn) => .map((val, i) => [i, val]) .filter(([i, val]) => fn(val, i, arr)) .pop()[0]; -``` +```
    Examples @@ -1355,7 +1355,7 @@ Omit the second argument, `depth` to flatten only to a depth of `1` (single flat ```js const flatten = (arr, depth = 1) => arr.reduce((a, v) => a.concat(depth > 1 && Array.isArray(v) ? flatten(v, depth - 1) : v), []); -``` +```
    Examples @@ -1381,7 +1381,7 @@ const forEachRight = (arr, callback) => .slice(0) .reverse() .forEach(callback); -``` +```
    Examples @@ -1407,7 +1407,7 @@ const groupBy = (arr, fn) => acc[val] = (acc[val] || []).concat(arr[i]); return acc; }, {}); -``` +```
    Examples @@ -1429,7 +1429,7 @@ Use `arr[0]` to return the first element of the passed array. ```js const head = arr => arr[0]; -``` +```
    Examples @@ -1451,7 +1451,7 @@ Return the array of indices. ```js const indexOfAll = (arr, val) => arr.reduce((acc, el, i) => (el === val ? [...acc, i] : acc), []); -``` +```
    Examples @@ -1473,7 +1473,7 @@ Use `arr.slice(0,-1)` to return all but the last element of the array. ```js const initial = arr => arr.slice(0, -1); -``` +```
    Examples @@ -1495,7 +1495,7 @@ Use `Array.map()` to generate h rows where each is a new array of size w initial ```js const initialize2DArray = (w, h, val = null) => Array.from({ length: h }).map(() => Array.from({ length: w }).fill(val)); -``` +```
    Examples @@ -1519,7 +1519,7 @@ You can omit `step` to use a default value of `1`. ```js const initializeArrayWithRange = (end, start = 0, step = 1) => Array.from({ length: Math.ceil((end - start + 1) / step) }, (v, i) => i * step + start); -``` +```
    Examples @@ -1547,7 +1547,7 @@ const initializeArrayWithRangeRight = (end, start = 0, step = 1) => Array.from({ length: Math.ceil((end + 1 - start) / step) }).map( (v, i, arr) => (arr.length - i - 1) * step + start ); -``` +```
    Examples @@ -1571,7 +1571,7 @@ You can omit `val` to use a default value of `0`. ```js const initializeArrayWithValues = (n, val = 0) => Array(n).fill(val); -``` +```
    Examples @@ -1596,7 +1596,7 @@ const initializeNDArray = (val, ...args) => args.length === 0 ? val : Array.from({ length: args[0] }).map(() => initializeNDArray(val, ...args.slice(1))); -``` +```
    Examples @@ -1621,7 +1621,7 @@ const intersection = (a, b) => { const s = new Set(b); return a.filter(x => s.has(x)); }; -``` +```
    Examples @@ -1645,7 +1645,7 @@ const intersectionBy = (a, b, fn) => { const s = new Set(b.map(fn)); return a.filter(x => s.has(fn(x))); }; -``` +```
    Examples @@ -1666,7 +1666,7 @@ Use `Array.filter()` and `Array.findIndex()` in combination with the provided co ```js const intersectionWith = (a, b, comp) => a.filter(x => b.findIndex(y => comp(x, y)) !== -1); -``` +```
    Examples @@ -1696,7 +1696,7 @@ const isSorted = arr => { else if ((val - arr[i + 1]) * direction > 0) return 0; } }; -``` +```
    Examples @@ -1730,7 +1730,7 @@ const join = (arr, separator = ',', end = separator) => : acc + val + separator, '' ); -``` +```
    Examples @@ -1765,7 +1765,7 @@ const JSONtoCSV = (arr, columns, delimiter = ',') => ) ) ].join('\n'); -``` +```
    Examples @@ -1787,7 +1787,7 @@ Use `arr.length - 1` to compute the index of the last element of the given array ```js const last = arr => arr[arr.length - 1]; -``` +```
    Examples @@ -1811,7 +1811,7 @@ Use `Array.reduce()`, comparing the `length` of objects to find the longest one. ```js const longestItem = (val, ...vals) => [val, ...vals].reduce((a, x) => (x.length > a.length ? x : a)); -``` +```
    Examples @@ -1839,7 +1839,7 @@ const mapObject = (arr, fn) => (a => ( (a = [arr, arr.map(fn)]), a[0].reduce((acc, val, ind) => ((acc[val] = a[1][ind]), acc), {}) ))(); -``` +```
    Examples @@ -1863,7 +1863,7 @@ Omit the second argument, `n`, to get a one-element array. ```js const maxN = (arr, n = 1) => [...arr].sort((a, b) => b - a).slice(0, n); -``` +```
    Examples @@ -1887,7 +1887,7 @@ Omit the second argument, `n`, to get a one-element array. ```js const minN = (arr, n = 1) => [...arr].sort((a, b) => a - b).slice(0, n); -``` +```
    Examples @@ -1910,7 +1910,7 @@ Omit the second argument, `fn`, to use `Boolean` as a default. ```js const none = (arr, fn = Boolean) => !arr.some(fn); -``` +```
    Examples @@ -1934,7 +1934,7 @@ Omit the second argument, `n`, to get the first element of the array. ```js const nthElement = (arr, n = 0) => (n === -1 ? arr.slice(n) : arr.slice(n, n + 1))[0]; -``` +```
    Examples @@ -1958,7 +1958,7 @@ If `offset` is negative, the elements will be moved from end to start. ```js const offset = (arr, offset) => [...arr.slice(offset), ...arr.slice(0, offset)]; -``` +```
    Examples @@ -1988,7 +1988,7 @@ const partition = (arr, fn) => }, [[], []] ); -``` +```
    Examples @@ -2024,7 +2024,7 @@ const permutations = arr => { [] ); }; -``` +```
    Examples @@ -2053,7 +2053,7 @@ const pull = (arr, ...args) => { arr.length = 0; pulled.forEach(v => arr.push(v)); }; -``` +```
    Examples @@ -2085,7 +2085,7 @@ const pullAtIndex = (arr, pullArr) => { pulled.forEach(v => arr.push(v)); return removed; }; -``` +```
    Examples @@ -2116,7 +2116,7 @@ const pullAtValue = (arr, pullArr) => { mutateTo.forEach(v => arr.push(v)); return removed; }; -``` +```
    Examples @@ -2149,7 +2149,7 @@ const pullBy = (arr, ...args) => { arr.length = 0; pulled.forEach(v => arr.push(v)); }; -``` +```
    Examples @@ -2178,7 +2178,7 @@ const reducedFilter = (data, keys, fn) => return acc; }, {}) ); -``` +```
    Examples @@ -2213,7 +2213,7 @@ Use `Array.reduce()` to apply the given function to the given array, storing eac ```js const reduceSuccessive = (arr, fn, acc) => arr.reduce((res, val, i, arr) => (res.push(fn(res.slice(-1)[0], val, i, arr)), res), [acc]); -``` +```
    Examples @@ -2236,7 +2236,7 @@ You can omit the second parameter, `comparator`, to use the default one that ret ```js const reduceWhich = (arr, comparator = (a, b) => a - b) => arr.reduce((a, b) => (comparator(a, b) >= 0 ? b : a)); -``` +```
    Examples @@ -2260,7 +2260,7 @@ Takes a predicate and array, like `Array.filter()`, but only keeps `x` if `pred( ```js const reject = (pred, array) => array.filter((...args) => !pred(...args)); -``` +```
    Examples @@ -2289,7 +2289,7 @@ const remove = (arr, func) => return acc.concat(val); }, []) : []; -``` +```
    Examples @@ -2311,7 +2311,7 @@ This method also works with strings. ```js const sample = arr => arr[Math.floor(Math.random() * arr.length)]; -``` +```
    Examples @@ -2341,7 +2341,7 @@ const sampleSize = ([...arr], n = 1) => { } return arr.slice(0, n); }; -``` +```
    Examples @@ -2370,7 +2370,7 @@ const shuffle = ([...arr]) => { } return arr; }; -``` +```
    Examples @@ -2392,7 +2392,7 @@ Use `Array.filter()` to remove values that are not part of `values`, determined ```js const similarity = (arr, values) => arr.filter(v => values.includes(v)); -``` +```
    Examples @@ -2418,7 +2418,7 @@ const sortedIndex = (arr, n) => { const index = arr.findIndex(el => (isDescending ? n >= el : n <= el)); return index === -1 ? arr.length : index; }; -``` +```
    Examples @@ -2446,7 +2446,7 @@ const sortedIndexBy = (arr, n, fn) => { const index = arr.findIndex(el => (isDescending ? val >= fn(el) : val <= fn(el))); return index === -1 ? arr.length : index; }; -``` +```
    Examples @@ -2472,7 +2472,7 @@ const sortedLastIndex = (arr, n) => { const index = arr.reverse().findIndex(el => (isDescending ? n <= el : n >= el)); return index === -1 ? 0 : arr.length - index; }; -``` +```
    Examples @@ -2503,7 +2503,7 @@ const sortedLastIndexBy = (arr, n, fn) => { .findIndex(el => (isDescending ? val <= el : val >= el)); return index === -1 ? 0 : arr.length - index; }; -``` +```
    Examples @@ -2531,7 +2531,7 @@ const stableSort = (arr, compare) => .map((item, index) => ({ item, index })) .sort((a, b) => compare(a.item, b.item) || a.index - b.index) .map(({ item }) => item); -``` +```
    Examples @@ -2557,7 +2557,7 @@ const symmetricDifference = (a, b) => { sB = new Set(b); return [...a.filter(x => !sB.has(x)), ...b.filter(x => !sA.has(x))]; }; -``` +```
    Examples @@ -2583,7 +2583,7 @@ const symmetricDifferenceBy = (a, b, fn) => { sB = new Set(b.map(v => fn(v))); return [...a.filter(x => !sB.has(fn(x))), ...b.filter(x => !sA.has(fn(x)))]; }; -``` +```
    Examples @@ -2607,7 +2607,7 @@ const symmetricDifferenceWith = (arr, val, comp) => [ ...arr.filter(a => val.findIndex(b => comp(a, b)) === -1), ...val.filter(a => arr.findIndex(b => comp(a, b)) === -1) ]; -``` +```
    Examples @@ -2632,7 +2632,7 @@ Return `Array.slice(1)` if the array's `length` is more than `1`, otherwise, ret ```js const tail = arr => (arr.length > 1 ? arr.slice(1) : arr); -``` +```
    Examples @@ -2654,7 +2654,7 @@ Use `Array.slice()` to create a slice of the array with `n` elements taken from ```js const take = (arr, n = 1) => arr.slice(0, n); -``` +```
    Examples @@ -2676,7 +2676,7 @@ Use `Array.slice()` to create a slice of the array with `n` elements taken from ```js const takeRight = (arr, n = 1) => arr.slice(arr.length - n, arr.length); -``` +```
    Examples @@ -2703,7 +2703,7 @@ const takeRightWhile = (arr, func) => { if (func(arr[i])) return arr.reverse().slice(arr.length - i, arr.length); return arr; }; -``` +```
    Examples @@ -2728,7 +2728,7 @@ const takeWhile = (arr, func) => { for (const [i, val] of arr.entries()) if (func(val)) return arr.slice(0, i); return arr; }; -``` +```
    Examples @@ -2754,7 +2754,7 @@ const toHash = (object, key) => (acc, data, index) => ((acc[!key ? index : data[key]] = data), acc), {} ); -``` +```
    Examples @@ -2787,7 +2787,7 @@ Create a `Set` with all values of `a` and `b` and convert to an array. ```js const union = (a, b) => Array.from(new Set([...a, ...b])); -``` +```
    Examples @@ -2813,7 +2813,7 @@ const unionBy = (a, b, fn) => { const s = new Set(a.map(v => fn(v))); return Array.from(new Set([...a, ...b.filter(x => !s.has(fn(x)))])); }; -``` +```
    Examples @@ -2835,7 +2835,7 @@ Create a `Set` with all values of `a` and values in `b` for which the comparator ```js const unionWith = (a, b, comp) => Array.from(new Set([...a, ...b.filter(x => a.findIndex(y => comp(x, y)) === -1)])); -``` +```
    Examples @@ -2856,7 +2856,7 @@ Use ES6 `Set` and the `...rest` operator to discard all duplicated values. ```js const uniqueElements = arr => [...new Set(arr)]; -``` +```
    Examples @@ -2882,7 +2882,7 @@ const uniqueElementsBy = (arr, fn) => if (!acc.some(x => fn(v, x))) acc.push(v); return acc; }, []); -``` +```
    Examples @@ -2917,7 +2917,7 @@ const uniqueElementsByRight = (arr, fn) => if (!acc.some(x => fn(v, x))) acc.push(v); return acc; }, []); -``` +```
    Examples @@ -2949,7 +2949,7 @@ Use `Array.filter()` and `Array.includes()` on each array to remove values conta const uniqueSymmetricDifference = (a, b) => [ ...new Set([...a.filter(v => !b.includes(v)), ...b.filter(v => !a.includes(v))]) ]; -``` +```
    Examples @@ -2978,7 +2978,7 @@ const unzip = arr => length: Math.max(...arr.map(x => x.length)) }).map(x => []) ); -``` +```
    Examples @@ -3010,7 +3010,7 @@ const unzipWith = (arr, fn) => }).map(x => []) ) .map(val => fn(...val)); -``` +```
    Examples @@ -3033,7 +3033,7 @@ _(For a snippet that mutates the original array see [`pull`](#pull))_ ```js const without = (arr, ...args) => arr.filter(v => !args.includes(v)); -``` +```
    Examples @@ -3054,7 +3054,7 @@ Use `Array.reduce()`, `Array.map()` and `Array.concat()` to produce every possib ```js const xProd = (a, b) => a.reduce((acc, x) => acc.concat(b.map(y => [x, y])), []); -``` +```
    Examples @@ -3082,7 +3082,7 @@ const zip = (...arrays) => { return Array.from({ length: arrays.length }, (_, k) => arrays[k][i]); }); }; -``` +```
    Examples @@ -3105,7 +3105,7 @@ Since an object can have undefined values but not undefined property pointers, t ```js const zipObject = (props, values) => props.reduce((obj, prop, index) => ((obj[prop] = values[index]), obj), {}); -``` +```
    Examples @@ -3137,7 +3137,7 @@ const zipWith = (...array) => { (_, i) => (fn ? fn(...array.map(a => a[i])) : array.map(a => a[i])) ); }; -``` +```
    Examples @@ -3156,10 +3156,10 @@ zipWith(
    [⬆ Back to top](#table-of-contents) - ---- - -## 🌐 Browser + +--- + +## 🌐 Browser ### arrayToHtmlList @@ -3173,7 +3173,7 @@ const arrayToHtmlList = (arr, listID) => (el = document.querySelector('#' + listID)), (el.innerHTML += arr.map(item => `
  • ${item}
  • `).join('')) ))(); -``` +```
    Examples @@ -3196,7 +3196,7 @@ Use `scrollY`, `scrollHeight` and `clientHeight` to determine if the bottom of t const bottomVisible = () => document.documentElement.clientHeight + window.scrollY >= (document.documentElement.scrollHeight || document.documentElement.clientHeight); -``` +```
    Examples @@ -3239,7 +3239,7 @@ const copyToClipboard = str => { document.getSelection().addRange(selected); } }; -``` +```
    Examples @@ -3274,7 +3274,7 @@ const counter = (selector, start, end, step = 1, duration = 2000) => { }, Math.abs(Math.floor(duration / (end - start)))); return timer; }; -``` +```
    Examples @@ -3302,7 +3302,7 @@ const createElement = str => { el.innerHTML = str; return el.firstElementChild; }; -``` +```
    Examples @@ -3345,7 +3345,7 @@ const createEventHub = () => ({ if (i > -1) this.hub[event].splice(i, 1); } }); -``` +```
    Examples @@ -3381,7 +3381,7 @@ Use `window.location.href` to get current URL. ```js const currentURL = () => window.location.href; -``` +```
    Examples @@ -3405,7 +3405,7 @@ const detectDeviceType = () => /Android|webOS|iPhone|iPad|iPod|BlackBerry|IEMobile|Opera Mini/i.test(navigator.userAgent) ? 'Mobile' : 'Desktop'; -``` +```
    Examples @@ -3426,7 +3426,7 @@ Check that `parent` is not the same element as `child`, use `parent.contains(chi ```js const elementContains = (parent, child) => parent !== child && parent.contains(child); -``` +```
    Examples @@ -3458,7 +3458,7 @@ const elementIsVisibleInViewport = (el, partiallyVisible = false) => { ((left > 0 && left < innerWidth) || (right > 0 && right < innerWidth)) : top >= 0 && left >= 0 && bottom <= innerHeight && right <= innerWidth; }; -``` +```
    Examples @@ -3485,7 +3485,7 @@ const getScrollPosition = (el = window) => ({ x: el.pageXOffset !== undefined ? el.pageXOffset : el.scrollLeft, y: el.pageYOffset !== undefined ? el.pageYOffset : el.scrollTop }); -``` +```
    Examples @@ -3506,7 +3506,7 @@ Use `Window.getComputedStyle()` to get the value of the CSS rule for the specifi ```js const getStyle = (el, ruleName) => getComputedStyle(el)[ruleName]; -``` +```
    Examples @@ -3527,7 +3527,7 @@ Use `element.classList.contains()` to check if the element has the specified cla ```js const hasClass = (el, className) => el.classList.contains(className); -``` +```
    Examples @@ -3555,7 +3555,7 @@ const hashBrowser = val => hexes.push(('00000000' + view.getUint32(i).toString(16)).slice(-8)); return hexes.join(''); }); -``` +```
    Examples @@ -3576,7 +3576,7 @@ Use `NodeList.prototype.forEach()` to apply `display: none` to each element spec ```js const hide = els => els.forEach(e => (e.style.display = 'none')); -``` +```
    Examples @@ -3599,7 +3599,7 @@ Use `location.protocol` to get the protocol currently being used. If it's not HT const httpsRedirect = () => { if (location.protocol !== 'https:') location.replace('https://' + location.href.split('//')[1]); }; -``` +```
    Examples @@ -3620,7 +3620,7 @@ Use `el.insertAdjacentHTML()` with a position of `'afterend'` to parse `htmlStri ```js const insertAfter = (el, htmlString) => el.insertAdjacentHTML('afterend', htmlString); -``` +```
    Examples @@ -3641,7 +3641,7 @@ Use `el.insertAdjacentHTML()` with a position of `'beforebegin'` to parse `htmlS ```js const insertBefore = (el, htmlString) => el.insertAdjacentHTML('beforebegin', htmlString); -``` +```
    Examples @@ -3662,7 +3662,7 @@ Use the `Document.hidden` property, introduced by the Page Visibility API to che ```js const isBrowserTabFocused = () => !document.hidden; -``` +```
    Examples @@ -3683,7 +3683,7 @@ Use spread operator inside new array to convert a `NodeList` to an array. ```js const nodeListToArray = nodeList => [...nodeList]; -``` +```
    Examples @@ -3723,7 +3723,7 @@ const observeMutations = (element, callback, options) => { ); return observer; }; -``` +```
    Examples @@ -3746,7 +3746,7 @@ Omit the fourth argument `opts` to use `false` or specify it based on the option ```js const off = (el, evt, fn, opts = false) => el.removeEventListener(evt, fn, opts); -``` +```
    Examples @@ -3775,7 +3775,7 @@ const on = (el, evt, fn, opts = {}) => { el.addEventListener(evt, opts.target ? delegatorFn : fn, opts.options || false); if (opts.target) return delegatorFn; }; -``` +```
    Examples @@ -3814,7 +3814,7 @@ const onUserInputChange = callback => { (type = 'touch'), callback(type), document.addEventListener('mousemove', mousemoveHandler); }); }; -``` +```
    Examples @@ -3845,7 +3845,7 @@ const prefix = prop => { ); return i !== -1 ? (i === 0 ? prop : prefixes[i] + capitalizedProp) : null; }; -``` +```
    Examples @@ -3888,7 +3888,7 @@ const recordAnimationFrames = (callback, autoStart = true) => { if (autoStart) start(); return { start, stop }; }; -``` +```
    Examples @@ -3915,7 +3915,7 @@ Pass a second argument to simulate a link click (`true` - default) or an HTTP re ```js const redirect = (url, asLink = true) => asLink ? (window.location.href = url) : window.location.replace(url); -``` +```
    Examples @@ -3952,7 +3952,7 @@ const runAsync = fn => { }; }); }; -``` +```
    Examples @@ -3999,7 +3999,7 @@ const scrollToTop = () => { window.scrollTo(0, c - c / 8); } }; -``` +```
    Examples @@ -4020,7 +4020,7 @@ Use `element.style` to set the value of the CSS rule for the specified element t ```js const setStyle = (el, ruleName, val) => (el.style[ruleName] = val); -``` +```
    Examples @@ -4041,7 +4041,7 @@ Use the spread operator (`...`) and `Array.forEach()` to clear the `display` pro ```js const show = (...el) => [...el].forEach(e => (e.style.display = '')); -``` +```
    Examples @@ -4066,7 +4066,7 @@ const smoothScroll = element => document.querySelector(element).scrollIntoView({ behavior: 'smooth' }); -``` +```
    Examples @@ -4088,7 +4088,7 @@ Use `element.classList.toggle()` to toggle the specified class for the element. ```js const toggleClass = (el, className) => el.classList.toggle(className); -``` +```
    Examples @@ -4112,7 +4112,7 @@ Omit the third argument, `detail`, if you do not want to pass custom data to the ```js const triggerEvent = (el, eventType, detail = undefined) => el.dispatchEvent(new CustomEvent(eventType, { detail: detail })); -``` +```
    Examples @@ -4137,7 +4137,7 @@ const UUIDGeneratorBrowser = () => ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c => (c ^ (crypto.getRandomValues(new Uint8Array(1))[0] & (15 >> (c / 4)))).toString(16) ); -``` +```
    Examples @@ -4150,10 +4150,10 @@ UUIDGeneratorBrowser(); // '7982fcfe-5721-4632-bede-6000885be57d'
    [⬆ Back to top](#table-of-contents) - ---- - -## ⏱️ Date + +--- + +## ⏱️ Date ### formatDuration @@ -4179,7 +4179,7 @@ const formatDuration = ms => { .map(([key, val]) => `${val} ${key}${val !== 1 ? 's' : ''}`) .join(', '); }; -``` +```
    Examples @@ -4201,7 +4201,7 @@ Use `Date.toString()` and `String.slice()` to get the `HH:MM:SS` part of a given ```js const getColonTimeFromDate = date => date.toTimeString().slice(0, 8); -``` +```
    Examples @@ -4223,7 +4223,7 @@ Calculate the difference (in days) between two `Date` objects. ```js const getDaysDiffBetweenDates = (dateInitial, dateFinal) => (dateFinal - dateInitial) / (1000 * 3600 * 24); -``` +```
    Examples @@ -4251,7 +4251,7 @@ const getMeridiemSuffixOfInteger = num => : num < 12 ? (num % 12) + 'am' : (num % 12) + 'pm'; -``` +```
    Examples @@ -4281,7 +4281,7 @@ const tomorrow = (long = false) => { ).padStart(2, '0')}`; return !long ? ret : `${ret}T00:00:00`; }; -``` +```
    Examples @@ -4295,10 +4295,10 @@ tomorrow(true); // 2017-12-27T00:00:00 (if current date is 2017-12-26)
    [⬆ Back to top](#table-of-contents) - ---- - -## 🎛️ Function + +--- + +## 🎛️ Function ### attempt @@ -4314,7 +4314,7 @@ const attempt = (fn, ...args) => { return e instanceof Error ? e : new Error(e); } }; -``` +```
    Examples @@ -4339,7 +4339,7 @@ Use `Array.concat()` to prepend any additional supplied parameters to the argume ```js const bind = (fn, context, ...boundArgs) => (...args) => fn.apply(context, [...boundArgs, ...args]); -``` +```
    Examples @@ -4367,7 +4367,7 @@ Use the spread operator (`...`) to prepend any additional supplied parameters to ```js const bindKey = (context, fn, ...boundArgs) => (...args) => context[fn].apply(context, [...boundArgs, ...args]); -``` +```
    Examples @@ -4399,7 +4399,7 @@ const chainAsync = fns => { const next = () => fns[curr++](next); next(); }; -``` +```
    Examples @@ -4429,7 +4429,7 @@ The last (rightmost) function can accept one or more arguments; the remaining fu ```js const compose = (...fns) => fns.reduce((f, g) => (...args) => f(g(...args))); -``` +```
    Examples @@ -4457,7 +4457,7 @@ The first (leftmost) function can accept one or more arguments; the remaining fu ```js const composeRight = (...fns) => fns.reduce((f, g) => (...args) => g(f(...args))); -``` +```
    Examples @@ -4482,7 +4482,7 @@ Use the spread operator (`...`) to call `coverger` with the results of all other ```js const converge = (converger, fns) => (...args) => converger(...fns.map(fn => fn.apply(null, args))); -``` +```
    Examples @@ -4511,7 +4511,7 @@ If you want to curry a function that accepts a variable number of arguments (a v ```js const curry = (fn, arity = fn.length, ...args) => arity <= args.length ? fn(...args) : curry.bind(null, fn, arity, ...args); -``` +```
    Examples @@ -4540,7 +4540,7 @@ const debounce = (fn, ms = 0) => { timeoutId = setTimeout(() => fn.apply(this, args), ms); }; }; -``` +```
    Examples @@ -4567,7 +4567,7 @@ Use `setTimeout()` with a timeout of 1ms to add a new event to the browser event ```js const defer = (fn, ...args) => setTimeout(fn, 1, ...args); -``` +```
    Examples @@ -4595,7 +4595,7 @@ Use the spread (`...`) operator to supply the function with an arbitrary number ```js const delay = (fn, wait, ...args) => setTimeout(fn, wait, ...args); -``` +```
    Examples @@ -4622,7 +4622,7 @@ Use `console.debug()` and the `name` property of the passed method to log the me ```js const functionName = fn => (console.debug(fn.name), fn); -``` +```
    Examples @@ -4650,7 +4650,7 @@ const hz = (fn, iterations = 100) => { for (let i = 0; i < iterations; i++) fn(); return (1000 * iterations) / (performance.now() - before); }; -``` +```
    Examples @@ -4695,7 +4695,7 @@ const memoize = fn => { cached.cache = cache; return cached; }; -``` +```
    Examples @@ -4720,7 +4720,7 @@ Take a predicate function and apply the not operator (`!`) to it with its argume ```js const negate = func => (...args) => !func(...args); -``` +```
    Examples @@ -4749,7 +4749,7 @@ const once = fn => { return fn.apply(this, args); }; }; -``` +```
    Examples @@ -4773,7 +4773,7 @@ Use the spread operator (`...`) to prepend `partials` to the list of arguments o ```js const partial = (fn, ...partials) => (...args) => fn(...partials, ...args); -``` +```
    Examples @@ -4796,7 +4796,7 @@ Use the spread operator (`...`) to append `partials` to the list of arguments of ```js const partialRight = (fn, ...partials) => (...args) => fn(...args, ...partials); -``` +```
    Examples @@ -4819,7 +4819,7 @@ Use `Array.reduce()` to create a promise chain, where each promise returns the n ```js const runPromisesInSeries = ps => ps.reduce((p, next) => p.then(next), Promise.resolve()); -``` +```
    Examples @@ -4841,7 +4841,7 @@ Delay executing part of an `async` function, by putting it to sleep, returning a ```js const sleep = ms => new Promise(resolve => setTimeout(resolve, ms)); -``` +```
    Examples @@ -4888,7 +4888,7 @@ const throttle = (fn, wait) => { } }; }; -``` +```
    Examples @@ -4919,7 +4919,7 @@ const times = (n, fn, context = undefined) => { let i = 0; while (fn.call(context, i) !== false && ++i < n) {} }; -``` +```
    Examples @@ -4950,7 +4950,7 @@ const uncurry = (fn, n = 1) => (...args) => { if (n > args.length) throw new RangeError('Arguments too few!'); return next(fn)(args.slice(0, n)); }; -``` +```
    Examples @@ -4979,7 +4979,7 @@ const unfold = (fn, seed) => { while ((val = fn(val[1]))) result.push(val[0]); return result; }; -``` +```
    Examples @@ -5001,7 +5001,7 @@ Return a function expecting a single value, `x`, that returns the appropriate va ```js const when = (pred, whenTrue) => x => (pred(x) ? whenTrue(x) : x); -``` +```
    Examples @@ -5016,10 +5016,10 @@ doubleEvenNumbers(1); // 1
    [⬆ Back to top](#table-of-contents) - ---- - -## ➗ Math + +--- + +## ➗ Math ### approximatelyEqual @@ -5030,7 +5030,7 @@ Omit the third parameter, `epsilon`, to use a default value of `0.001`. ```js const approximatelyEqual = (v1, v2, epsilon = 0.001) => Math.abs(v1 - v2) < epsilon; -``` +```
    Examples @@ -5051,7 +5051,7 @@ Use `Array.reduce()` to add each value to an accumulator, initialized with a val ```js const average = (...nums) => nums.reduce((acc, val) => acc + val, 0) / nums.length; -``` +```
    Examples @@ -5075,7 +5075,7 @@ Use `Array.map()` to map each element to the value returned by `fn`, `Array.redu const averageBy = (arr, fn) => arr.map(typeof fn === 'function' ? fn : val => val[fn]).reduce((acc, val) => acc + val, 0) / arr.length; -``` +```
    Examples @@ -5110,7 +5110,7 @@ const binomialCoefficient = (n, k) => { for (let j = 2; j <= k; j++) res *= (n - j + 1) / j; return Math.round(res); }; -``` +```
    Examples @@ -5132,7 +5132,7 @@ Otherwise, return the nearest number in the range. ```js const clampNumber = (num, a, b) => Math.max(Math.min(num, Math.max(a, b)), Math.min(a, b)); -``` +```
    Examples @@ -5154,7 +5154,7 @@ Use `Math.PI` and the degree to radian formula to convert the angle from degrees ```js const degreesToRads = deg => (deg * Math.PI) / 180.0; -``` +```
    Examples @@ -5176,7 +5176,7 @@ Use `Array.map()` and `parseInt()` to transform each value to an integer. ```js const digitize = n => [...`${n}`].map(i => parseInt(i)); -``` +```
    Examples @@ -5197,7 +5197,7 @@ Use `Math.hypot()` to calculate the Euclidean distance between two points. ```js const distance = (x0, y0, x1, y1) => Math.hypot(x1 - x0, y1 - y0); -``` +```
    Examples @@ -5239,7 +5239,7 @@ const elo = ([...ratings], kFactor = 32, selfRating) => { } return ratings; }; -``` +```
    Examples @@ -5279,7 +5279,7 @@ const factorial = n => : n <= 1 ? 1 : n * factorial(n - 1); -``` +```
    Examples @@ -5305,7 +5305,7 @@ const fibonacci = n => (acc, val, i) => acc.concat(i > 1 ? acc[i - 1] + acc[i - 2] : i), [] ); -``` +```
    Examples @@ -5331,7 +5331,7 @@ const gcd = (...arr) => { const _gcd = (x, y) => (!y ? x : gcd(y, x % y)); return [...arr].reduce((a, b) => _gcd(a, b)); }; -``` +```
    Examples @@ -5359,7 +5359,7 @@ const geometricProgression = (end, start = 1, step = 2) => Array.from({ length: Math.floor(Math.log(end / start) / Math.log(step)) + 1 }).map( (v, i) => start * step ** i ); -``` +```
    Examples @@ -5383,7 +5383,7 @@ Count and return the number of `1`s in the string, using `match(/1/g)`. ```js const hammingDistance = (num1, num2) => ((num1 ^ num2).toString(2).match(/1/g) || '').length; -``` +```
    Examples @@ -5408,7 +5408,7 @@ const inRange = (n, start, end = null) => { if (end && start > end) [end, start] = [start, end]; return end == null ? n >= 0 && n < start : n >= start && n < end; }; -``` +```
    Examples @@ -5432,7 +5432,7 @@ Use the modulo operator (`%`) to check if the remainder is equal to `0`. ```js const isDivisible = (dividend, divisor) => dividend % divisor === 0; -``` +```
    Examples @@ -5454,7 +5454,7 @@ Returns `true` if the number is even, `false` if the number is odd. ```js const isEven = num => num % 2 === 0; -``` +```
    Examples @@ -5480,7 +5480,7 @@ const isPrime = num => { for (var i = 2; i <= boundary; i++) if (num % i === 0) return false; return num >= 2; }; -``` +```
    Examples @@ -5506,7 +5506,7 @@ const lcm = (...arr) => { const _lcm = (x, y) => (x * y) / gcd(x, y); return [...arr].reduce((a, b) => _lcm(a, b)); }; -``` +```
    Examples @@ -5541,7 +5541,7 @@ const luhnCheck = num => { sum += lastDigit; return sum % 10 === 0; }; -``` +```
    Examples @@ -5564,7 +5564,7 @@ Use `Array.map()` to map each element to the value returned by `fn`, `Math.max() ```js const maxBy = (arr, fn) => Math.max(...arr.map(typeof fn === 'function' ? fn : val => val[fn])); -``` +```
    Examples @@ -5591,7 +5591,7 @@ const median = arr => { nums = [...arr].sort((a, b) => a - b); return arr.length % 2 !== 0 ? nums[mid] : (nums[mid - 1] + nums[mid]) / 2; }; -``` +```
    Examples @@ -5612,7 +5612,7 @@ Use `Array.map()` to map each element to the value returned by `fn`, `Math.min() ```js const minBy = (arr, fn) => Math.min(...arr.map(typeof fn === 'function' ? fn : val => val[fn])); -``` +```
    Examples @@ -5635,7 +5635,7 @@ Use `Array.reduce()` to calculate how many numbers are below the value and how m ```js const percentile = (arr, val) => (100 * arr.reduce((acc, v) => acc + (v < val ? 1 : 0) + (v === val ? 0.5 : 0), 0)) / arr.length; -``` +```
    Examples @@ -5656,7 +5656,7 @@ Use `Array.reduce()` combined with `Array.map()` to iterate over elements and co ```js const powerset = arr => arr.reduce((a, v) => a.concat(a.map(r => [v].concat(r))), [[]]); -``` +```
    Examples @@ -5683,7 +5683,7 @@ const primes = num => { numsTillSqroot.forEach(x => (arr = arr.filter(y => y % x !== 0 || y === x))); return arr; }; -``` +```
    Examples @@ -5704,7 +5704,7 @@ Use `Math.PI` and the radian to degree formula to convert the angle from radians ```js const radsToDegrees = rad => (rad * 180.0) / Math.PI; -``` +```
    Examples @@ -5726,7 +5726,7 @@ Use `Array.from()` to create an empty array of the specific length, `Math.random ```js const randomIntArrayInRange = (min, max, n = 1) => Array.from({ length: n }, () => Math.floor(Math.random() * (max - min + 1)) + min); -``` +```
    Examples @@ -5747,7 +5747,7 @@ Use `Math.random()` to generate a random number and map it to the desired range, ```js const randomIntegerInRange = (min, max) => Math.floor(Math.random() * (max - min + 1)) + min; -``` +```
    Examples @@ -5768,7 +5768,7 @@ Use `Math.random()` to generate a random value, map it to the desired range usin ```js const randomNumberInRange = (min, max) => Math.random() * (max - min) + min; -``` +```
    Examples @@ -5790,7 +5790,7 @@ Omit the second argument, `decimals` to round to an integer. ```js const round = (n, decimals = 0) => Number(`${Math.round(`${n}e${decimals}`)}e-${decimals}`); -``` +```
    Examples @@ -5818,7 +5818,7 @@ const sdbm = str => { 0 ); }; -``` +```
    Examples @@ -5847,7 +5847,7 @@ const standardDeviation = (arr, usePopulation = false) => { (arr.length - (usePopulation ? 0 : 1)) ); }; -``` +```
    Examples @@ -5869,7 +5869,7 @@ Use `Array.reduce()` to add each value to an accumulator, initialized with a val ```js const sum = (...arr) => [...arr].reduce((acc, val) => acc + val, 0); -``` +```
    Examples @@ -5891,7 +5891,7 @@ Use `Array.map()` to map each element to the value returned by `fn`, `Array.redu ```js const sumBy = (arr, fn) => arr.map(typeof fn === 'function' ? fn : val => val[fn]).reduce((acc, val) => acc + val, 0); -``` +```
    Examples @@ -5919,7 +5919,7 @@ const sumPower = (end, power = 2, start = 1) => .fill(0) .map((x, i) => (i + start) ** power) .reduce((a, b) => a + b, 0); -``` +```
    Examples @@ -5944,7 +5944,7 @@ Use `Math.round()` to convert to an integer. ```js const toSafeInteger = num => Math.round(Math.max(Math.min(num, Number.MAX_SAFE_INTEGER), Number.MIN_SAFE_INTEGER)); -``` +```
    Examples @@ -5958,10 +5958,10 @@ toSafeInteger(Infinity); // 9007199254740991
    [⬆ Back to top](#table-of-contents) - ---- - -## 📦 Node + +--- + +## 📦 Node ### atob @@ -5971,7 +5971,7 @@ Create a `Buffer` for the given string with base-64 encoding and use `Buffer.toS ```js const atob = str => new Buffer(str, 'base64').toString('binary'); -``` +```
    Examples @@ -5992,7 +5992,7 @@ Create a `Buffer` for the given string with binary encoding and use `Buffer.toSt ```js const btoa = str => new Buffer(str, 'binary').toString('base64'); -``` +```
    Examples @@ -6031,7 +6031,7 @@ const colorize = (...args) => ({ bgCyan: `\x1b[46m${args.join(' ')}\x1b[0m`, bgWhite: `\x1b[47m${args.join(' ')}\x1b[0m` }); -``` +```
    Examples @@ -6056,7 +6056,7 @@ Use a regular expression to test if the specified flags are prefixed with `-` or ```js const hasFlags = (...flags) => flags.every(flag => process.argv.includes(/^-{1,2}/.test(flag) ? flag : '--' + flag)); -``` +```
    Examples @@ -6093,7 +6093,7 @@ const hashNode = val => 0 ) ); -``` +```
    Examples @@ -6114,7 +6114,7 @@ Checks if the current environment has the `TRAVIS` and `CI` environment variable ```js const isTravisCI = () => 'TRAVIS' in process.env && 'CI' in process.env; -``` +```
    Examples @@ -6137,7 +6137,7 @@ Use `fs.writeFile()`, template literals and `JSON.stringify()` to write a `json` const fs = require('fs'); const JSONToFile = (obj, filename) => fs.writeFile(`${filename}.json`, JSON.stringify(obj, null, 2)); -``` +```
    Examples @@ -6165,7 +6165,7 @@ const readFileLines = filename => .readFileSync(filename) .toString('UTF8') .split('\n'); -``` +```
    Examples @@ -6195,7 +6195,7 @@ Use `String.replace()` with a regular expression and `OS.homedir()` to replace t ```js const untildify = str => str.replace(/^~($|\/|\\)/, `${require('os').homedir()}$1`); -``` +```
    Examples @@ -6220,7 +6220,7 @@ const UUIDGeneratorNode = () => ([1e7] + -1e3 + -4e3 + -8e3 + -1e11).replace(/[018]/g, c => (c ^ (crypto.randomBytes(1)[0] & (15 >> (c / 4)))).toString(16) ); -``` +```
    Examples @@ -6233,10 +6233,10 @@ UUIDGeneratorNode(); // '79c7c136-60ee-40a2-beb2-856f1feabefc'
    [⬆ Back to top](#table-of-contents) - ---- - -## 🗃️ Object + +--- + +## 🗃️ Object ### bindAll @@ -6254,7 +6254,7 @@ const bindAll = (obj, ...fns) => }) ) ); -``` +```
    Examples @@ -6290,7 +6290,7 @@ const deepClone = obj => { ); return Array.isArray(obj) ? (clone.length = obj.length) && Array.from(clone) : clone; }; -``` +```
    Examples @@ -6316,7 +6316,7 @@ const deepFreeze = obj => prop => !obj[prop] instanceof Object || Object.isFrozen(obj[prop]) ? null : deepFreeze(obj[prop]) ) || Object.freeze(obj); -``` +```
    Examples @@ -6342,7 +6342,7 @@ Use `Object.assign()` to create a new empty object and copy the original one to ```js const defaults = (obj, ...defs) => Object.assign({}, obj, ...defs.reverse(), obj); -``` +```
    Examples @@ -6370,7 +6370,7 @@ const dig = (obj, target) => if (acc !== undefined) return acc; if (typeof val === 'object') return dig(val, target); }, undefined); -``` +```
    Examples @@ -6410,7 +6410,7 @@ const equals = (a, b) => { if (keys.length !== Object.keys(b).length) return false; return keys.every(k => equals(a[k], b[k])); }; -``` +```
    Examples @@ -6431,7 +6431,7 @@ Use `Object.keys(obj)` to get all the properties of the object, `Array.find()` t ```js const findKey = (obj, fn) => Object.keys(obj).find(key => fn(obj[key], key, obj)); -``` +```
    Examples @@ -6462,7 +6462,7 @@ const findLastKey = (obj, fn) => Object.keys(obj) .reverse() .find(key => fn(obj[key], key, obj)); -``` +```
    Examples @@ -6500,7 +6500,7 @@ const flattenObject = (obj, prefix = '') => else acc[pre + k] = obj[k]; return acc; }, {}); -``` +```
    Examples @@ -6521,7 +6521,7 @@ Use `Object.keys(obj)` to get all the properties of the object, `Array.forEach() ```js const forOwn = (obj, fn) => Object.keys(obj).forEach(key => fn(obj[key], key, obj)); -``` +```
    Examples @@ -6545,7 +6545,7 @@ const forOwnRight = (obj, fn) => Object.keys(obj) .reverse() .forEach(key => fn(obj[key], key, obj)); -``` +```
    Examples @@ -6573,7 +6573,7 @@ const functions = (obj, inherited = false) => ? [...Object.keys(obj), ...Object.keys(Object.getPrototypeOf(obj))] : Object.keys(obj) ).filter(key => typeof obj[key] === 'function'); -``` +```
    Examples @@ -6607,7 +6607,7 @@ const get = (from, ...selectors) => .filter(t => t !== '') .reduce((prev, cur) => prev && prev[cur], from) ); -``` +```
    Examples @@ -6636,7 +6636,7 @@ const invertKeyValues = (obj, fn) => acc[val].push(key); return acc; }, {}); -``` +```
    Examples @@ -6663,7 +6663,7 @@ const lowercaseKeys = obj => acc[key.toLowerCase()] = obj[key]; return acc; }, {}); -``` +```
    Examples @@ -6690,7 +6690,7 @@ const mapKeys = (obj, fn) => acc[fn(obj[k], k, obj)] = obj[k]; return acc; }, {}); -``` +```
    Examples @@ -6716,7 +6716,7 @@ const mapValues = (obj, fn) => acc[k] = fn(obj[k], k, obj); return acc; }, {}); -``` +```
    Examples @@ -6742,7 +6742,7 @@ Use `Object.keys(source)` to get all the keys of the second object, then `Array. ```js const matches = (obj, source) => Object.keys(source).every(key => obj.hasOwnProperty(key) && obj[key] === source[key]); -``` +```
    Examples @@ -6771,7 +6771,7 @@ const matchesWith = (obj, source, fn) => ? fn(obj[key], source[key], key, obj, source) : obj[key] == source[key] ); -``` +```
    Examples @@ -6806,7 +6806,7 @@ const merge = (...objs) => }, {}), {} ); -``` +```
    Examples @@ -6843,7 +6843,7 @@ const nest = (items, id = null, link = 'parent_id') => items .filter(item => item[link] === id) .map(item => ({ ...item, children: nest(items, item.id) })); -``` +```
    Examples @@ -6873,7 +6873,7 @@ Use `Array.reduce()` to create and combine key-value pairs. ```js const objectFromPairs = arr => arr.reduce((a, [key, val]) => ((a[key] = val), a), {}); -``` +```
    Examples @@ -6894,7 +6894,7 @@ Use `Object.keys()` and `Array.map()` to iterate over the object's keys and prod ```js const objectToPairs = obj => Object.keys(obj).map(k => [k, obj[k]]); -``` +```
    Examples @@ -6919,7 +6919,7 @@ const omit = (obj, arr) => Object.keys(obj) .filter(k => !arr.includes(k)) .reduce((acc, key) => ((acc[key] = obj[key]), acc), {}); -``` +```
    Examples @@ -6944,7 +6944,7 @@ const omitBy = (obj, fn) => Object.keys(obj) .filter(k => !fn(obj[k], k)) .reduce((acc, key) => ((acc[key] = obj[key]), acc), {}); -``` +```
    Examples @@ -6975,7 +6975,7 @@ const orderBy = (arr, props, orders) => return acc; }, 0) ); -``` +```
    Examples @@ -6999,7 +6999,7 @@ Use `Array.reduce()` to convert the filtered/picked keys back to an object with ```js const pick = (obj, arr) => arr.reduce((acc, curr) => (curr in obj && (acc[curr] = obj[curr]), acc), {}); -``` +```
    Examples @@ -7024,7 +7024,7 @@ const pickBy = (obj, fn) => Object.keys(obj) .filter(k => fn(obj[k], k)) .reduce((acc, key) => ((acc[key] = obj[key]), acc), {}); -``` +```
    Examples @@ -7052,7 +7052,7 @@ const renameKeys = (keysMap, obj) => }), {} ); -``` +```
    Examples @@ -7074,7 +7074,7 @@ Use `Object.assign()` and an empty object (`{}`) to create a shallow clone of th ```js const shallowClone = obj => Object.assign({}, obj); -``` +```
    Examples @@ -7108,7 +7108,7 @@ const size = val => : typeof val === 'string' ? new Blob([val]).size : 0; -``` +```
    Examples @@ -7131,7 +7131,7 @@ Use `Object.keys(obj)` to iterate over each key in the object, `Array.reduce()` ```js const transform = (obj, fn, acc) => Object.keys(obj).reduce((a, k) => fn(a, obj[k], k, obj), acc); -``` +```
    Examples @@ -7159,7 +7159,7 @@ Use `Array.every()` to check if each passed object has the specified property an ```js const truthCheckCollection = (collection, pre) => collection.every(obj => obj[pre]); -``` +```
    Examples @@ -7197,7 +7197,7 @@ const unflattenObject = obj => } else acc[k] = obj[k]; return acc; }, {}); -``` +```
    Examples @@ -7210,10 +7210,10 @@ unflattenObject({ 'a.b.c': 1, d: 1 }); // { a: { b: { c: 1 } }, d: 1 }
    [⬆ Back to top](#table-of-contents) - ---- - -## 📜 String + +--- + +## 📜 String ### byteSize @@ -7223,7 +7223,7 @@ Convert a given string to a [`Blob` Object](https://developer.mozilla.org/en-US/ ```js const byteSize = str => new Blob([str]).size; -``` +```
    Examples @@ -7247,7 +7247,7 @@ Omit the `lowerRest` parameter to keep the rest of the string intact, or set it ```js const capitalize = ([first, ...rest], lowerRest = false) => first.toUpperCase() + (lowerRest ? rest.join('').toLowerCase() : rest.join('')); -``` +```
    Examples @@ -7269,7 +7269,7 @@ Use `String.replace()` to match the first character of each word and `String.toU ```js const capitalizeEveryWord = str => str.replace(/\b[a-z]/g, char => char.toUpperCase()); -``` +```
    Examples @@ -7297,7 +7297,7 @@ const CSVToArray = (data, delimiter = ',', omitFirstRow = false) => .slice(omitFirstRow ? data.indexOf('\n') + 1 : 0) .split('\n') .map(v => v.split(delimiter)); -``` +```
    Examples @@ -7333,7 +7333,7 @@ const CSVToJSON = (data, delimiter = ',') => { return titles.reduce((obj, title, index) => ((obj[title] = values[index]), obj), {}); }); }; -``` +```
    Examples @@ -7357,7 +7357,7 @@ Omit the `upperRest` parameter to keep the rest of the string intact, or set it ```js const decapitalize = ([first, ...rest], upperRest = false) => first.toLowerCase() + (upperRest ? rest.join('').toUpperCase() : rest.join('')); -``` +```
    Examples @@ -7390,7 +7390,7 @@ const escapeHTML = str => '"': '"' }[tag] || tag) ); -``` +```
    Examples @@ -7411,7 +7411,7 @@ Use `String.replace()` to escape special characters. ```js const escapeRegExp = str => str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&'); -``` +```
    Examples @@ -7437,7 +7437,7 @@ const fromCamelCase = (str, separator = '_') => .replace(/([a-z\d])([A-Z])/g, '$1' + separator + '$2') .replace(/([A-Z]+)([A-Z][a-z\d]+)/g, '$1' + separator + '$2') .toLowerCase(); -``` +```
    Examples @@ -7460,7 +7460,7 @@ Use a regular expression to test if the string is an absolute URL. ```js const isAbsoluteURL = str => /^[a-z][a-z0-9+.-]*:/.test(str); -``` +```
    Examples @@ -7492,7 +7492,7 @@ const isAnagram = (str1, str2) => { .join(''); return normalize(str1) === normalize(str2); }; -``` +```
    Examples @@ -7513,7 +7513,7 @@ Convert the given string to lower case, using `String.toLowerCase()` and compare ```js const isLowerCase = str => str === str.toLowerCase(); -``` +```
    Examples @@ -7537,7 +7537,7 @@ Convert the given string to upper case, using `String.toUpperCase()` and compare ```js const isUpperCase = str => str === str.toUpperCase(); -``` +```
    Examples @@ -7566,7 +7566,7 @@ const mapString = (str, fn) => .split('') .map((c, i) => fn(c, i, str)) .join(''); -``` +```
    Examples @@ -7591,7 +7591,7 @@ Omit the third argument, `mask`, to use a default character of `'*'` for the mas ```js const mask = (cc, num = 4, mask = '*') => ('' + cc).slice(0, -num).replace(/./g, mask) + ('' + cc).slice(-num); -``` +```
    Examples @@ -7616,7 +7616,7 @@ Omit the third argument, `char`, to use the whitespace character as the default ```js const pad = (str, length, char = ' ') => str.padStart((str.length + length) / 2, char).padEnd(length, char); -``` +```
    Examples @@ -7643,7 +7643,7 @@ const palindrome = str => { const s = str.toLowerCase().replace(/[\W_]/g, ''); return s === [...s].reverse().join(''); }; -``` +```
    Examples @@ -7669,7 +7669,7 @@ const pluralize = (val, word, plural = word + 's') => { if (typeof val === 'object') return (num, word) => _pluralize(num, word, val[word]); return _pluralize(val, word, plural); }; -``` +```
    Examples @@ -7700,7 +7700,7 @@ Use a regular expression to remove non-printable ASCII characters. ```js const removeNonASCII = str => str.replace(/[^\x20-\x7E]/g, ''); -``` +```
    Examples @@ -7722,7 +7722,7 @@ Combine characters to get a string using `String.join('')`. ```js const reverseString = str => [...str].reverse().join(''); -``` +```
    Examples @@ -7743,7 +7743,7 @@ Use the spread operator (`...`), `Array.sort()` and `String.localeCompare()` to ```js const sortCharactersInString = str => [...str].sort((a, b) => a.localeCompare(b)).join(''); -``` +```
    Examples @@ -7764,7 +7764,7 @@ Use `String.split()` and a regular expression to match line breaks and create an ```js const splitLines = str => str.split(/\r?\n/); -``` +```
    Examples @@ -7799,7 +7799,7 @@ const stringPermutations = str => { [] ); }; -``` +```
    Examples @@ -7820,7 +7820,7 @@ Use a regular expression to remove HTML/XML tags from a string. ```js const stripHTMLTags = str => str.replace(/<[^>]*>/g, ''); -``` +```
    Examples @@ -7849,7 +7849,7 @@ const toCamelCase = str => { .join(''); return s.slice(0, 1).toLowerCase() + s.slice(1); }; -``` +```
    Examples @@ -7878,7 +7878,7 @@ const toKebabCase = str => .match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g) .map(x => x.toLowerCase()) .join('-'); -``` +```
    Examples @@ -7908,7 +7908,7 @@ const toSnakeCase = str => .match(/[A-Z]{2,}(?=[A-Z][a-z]+[0-9]*|\b)|[A-Z]?[a-z]+[0-9]*|[A-Z]|[0-9]+/g) .map(x => x.toLowerCase()) .join('_'); -``` +```
    Examples @@ -7935,7 +7935,7 @@ Return the string truncated to the desired length, with `'...'` appended to the ```js const truncateString = (str, num) => str.length > num ? str.slice(0, num > 3 ? num - 3 : num) + '...' : str; -``` +```
    Examples @@ -7967,7 +7967,7 @@ const unescapeHTML = str => '"': '"' }[tag] || tag) ); -``` +```
    Examples @@ -7996,7 +7996,7 @@ const URLJoin = (...args) => .replace(/\/(\?|&|#[^!])/g, '$1') .replace(/\?/g, '&') .replace('&', '?'); -``` +```
    Examples @@ -8018,7 +8018,7 @@ Omit the second argument to use the default regexp. ```js const words = (str, pattern = /[^a-zA-Z-]+/) => str.split(pattern).filter(Boolean); -``` +```
    Examples @@ -8032,10 +8032,10 @@ words('python, javaScript & coffee'); // ["python", "javaScript", "coffee"]
    [⬆ Back to top](#table-of-contents) - ---- - -## 📃 Type + +--- + +## 📃 Type ### getType @@ -8046,7 +8046,7 @@ Returns lowercased constructor name of value, `"undefined"` or `"null"` if value ```js const getType = v => v === undefined ? 'undefined' : v === null ? 'null' : v.constructor.name.toLowerCase(); -``` +```
    Examples @@ -8067,7 +8067,7 @@ Ensure the value is not `undefined` or `null` using `Array.includes()`, and comp ```js const is = (type, val) => ![, null].includes(val) && val.constructor === type; -``` +```
    Examples @@ -8100,7 +8100,7 @@ Check if the provided argument is not `null` and that its `Symbol.iterator` prop ```js const isArrayLike = obj => obj != null && typeof obj[Symbol.iterator] === 'function'; -``` +```
    Examples @@ -8123,7 +8123,7 @@ Use `typeof` to check if a value is classified as a boolean primitive. ```js const isBoolean = val => typeof val === 'boolean'; -``` +```
    Examples @@ -8145,7 +8145,7 @@ Check if the provided value is `null` or if its `length` is equal to `0`. ```js const isEmpty = val => val == null || !(Object.keys(val) || val).length; -``` +```
    Examples @@ -8175,7 +8175,7 @@ Use `typeof` to check if a value is classified as a function primitive. ```js const isFunction = val => typeof val === 'function'; -``` +```
    Examples @@ -8197,7 +8197,7 @@ Use the strict equality operator to check if the value and of `val` are equal to ```js const isNil = val => val === undefined || val === null; -``` +```
    Examples @@ -8219,7 +8219,7 @@ Use the strict equality operator to check if the value and of `val` are equal to ```js const isNull = val => val === null; -``` +```
    Examples @@ -8240,7 +8240,7 @@ Use `typeof` to check if a value is classified as a number primitive. ```js const isNumber = val => typeof val === 'number'; -``` +```
    Examples @@ -8263,7 +8263,7 @@ If the value is `null` or `undefined`, create and return an empty object. Οther ```js const isObject = obj => obj === Object(obj); -``` +```
    Examples @@ -8289,7 +8289,7 @@ Check if the provided value is not `null` and its `typeof` is equal to `'object' ```js const isObjectLike = val => val !== null && typeof val === 'object'; -``` +```
    Examples @@ -8313,7 +8313,7 @@ Check if the provided value is truthy, use `typeof` to check if it is an object ```js const isPlainObject = val => !!val && typeof val === 'object' && val.constructor === Object; -``` +```
    Examples @@ -8337,7 +8337,7 @@ Since `typeof null` evaluates to `'object'`, it needs to be directly compared. ```js const isPrimitive = val => !['object', 'function'].includes(typeof val) || val === null; -``` +```
    Examples @@ -8366,7 +8366,7 @@ const isPromiseLike = obj => obj !== null && (typeof obj === 'object' || typeof obj === 'function') && typeof obj.then === 'function'; -``` +```
    Examples @@ -8393,7 +8393,7 @@ Use `typeof` to check if a value is classified as a string primitive. ```js const isString = val => typeof val === 'string'; -``` +```
    Examples @@ -8414,7 +8414,7 @@ Use `typeof` to check if a value is classified as a symbol primitive. ```js const isSymbol = val => typeof val === 'symbol'; -``` +```
    Examples @@ -8435,7 +8435,7 @@ Use the strict equality operator to check if the value and of `val` are equal to ```js const isUndefined = val => val === undefined; -``` +```
    Examples @@ -8463,7 +8463,7 @@ const isValidJSON = obj => { return false; } }; -``` +```
    Examples @@ -8478,10 +8478,10 @@ isValidJSON(null); // true
    [⬆ Back to top](#table-of-contents) - ---- - -## 🔧 Utility + +--- + +## 🔧 Utility ### castArray @@ -8491,7 +8491,7 @@ Use `Array.isArray()` to determine if `val` is an array and return it as-is or e ```js const castArray = val => (Array.isArray(val) ? val : [val]); -``` +```
    Examples @@ -8513,7 +8513,7 @@ Use `new RegExp()`, `RegExp.source` and `RegExp.flags` to clone the given regula ```js const cloneRegExp = regExp => new RegExp(regExp.source, regExp.flags); -``` +```
    Examples @@ -8535,7 +8535,7 @@ Use `Array.find()` to return the first non `null`/`undefined` argument. ```js const coalesce = (...args) => args.find(_ => ![undefined, null].includes(_)); -``` +```
    Examples @@ -8556,7 +8556,7 @@ Use `Array.find()` to return the first argument that returns `true` from the pro ```js const coalesceFactory = valid => (...args) => args.find(valid); -``` +```
    Examples @@ -8585,7 +8585,7 @@ const extendHex = shortHex => .split('') .map(x => x + x) .join(''); -``` +```
    Examples @@ -8612,7 +8612,7 @@ const getURLParameters = url => (a, v) => ((a[v.slice(0, v.indexOf('='))] = v.slice(v.indexOf('=') + 1)), a), {} ); -``` +```
    Examples @@ -8652,7 +8652,7 @@ const hexToRGB = hex => { ')' ); }; -``` +```
    Examples @@ -8684,7 +8684,7 @@ const httpGet = (url, callback, err = console.error) => { request.onerror = () => err(request); request.send(); }; -``` +```
    Examples @@ -8727,7 +8727,7 @@ const httpPost = (url, data, callback, err = console.error) => { request.onerror = () => err(request); request.send(data); }; -``` +```
    Examples @@ -8777,7 +8777,7 @@ If both of them are not `undefined`, then the current environment is assumed to ```js const isBrowser = () => ![typeof window, typeof document].includes('undefined'); -``` +```
    Examples @@ -8808,7 +8808,7 @@ const mostPerformant = (fns, iterations = 10000) => { }); return times.indexOf(Math.min(...times)); }; -``` +```
    Examples @@ -8838,7 +8838,7 @@ Use `Array.slice()` to get the desired argument at index `n`. ```js const nthArg = n => (...args) => args.slice(n)[0]; -``` +```
    Examples @@ -8872,7 +8872,7 @@ const parseCookie = str => acc[decodeURIComponent(v[0].trim())] = decodeURIComponent(v[1].trim()); return acc; }, {}); -``` +```
    Examples @@ -8903,7 +8903,7 @@ const prettyBytes = (num, precision = 3, addSpace = true) => { const n = Number(((num < 0 ? -num : num) / 1000 ** exponent).toPrecision(precision)); return (num < 0 ? '-' : '') + n + (addSpace ? ' ' : '') + UNITS[exponent]; }; -``` +```
    Examples @@ -8929,7 +8929,7 @@ const randomHexColorCode = () => { let n = (Math.random() * 0xfffff * 1000000).toString(16); return '#' + n.slice(0, 6); }; -``` +```
    Examples @@ -8950,7 +8950,7 @@ Convert given RGB parameters to hexadecimal string using bitwise left-shift oper ```js const RGBToHex = (r, g, b) => ((r << 16) + (g << 8) + b).toString(16).padStart(6, '0'); -``` +```
    Examples @@ -8971,7 +8971,7 @@ Use template literals and `encodeURIComponent()` to create the appropriate strin ```js const serializeCookie = (name, val) => `${encodeURIComponent(name)}=${encodeURIComponent(val)}`; -``` +```
    Examples @@ -8997,7 +8997,7 @@ const timeTaken = callback => { console.timeEnd('timeTaken'); return r; }; -``` +```
    Examples @@ -9019,7 +9019,7 @@ Use `Intl.NumberFormat` to enable country / currency sensitive formatting. ```js const toCurrency = (n, curr, LanguageFormat = undefined) => Intl.NumberFormat(LanguageFormat, { style: 'currency', currency: curr }).format(n); -``` +```
    Examples @@ -9042,7 +9042,7 @@ Use `toLocaleString()` to convert a float-point arithmetic to the [Decimal mark] ```js const toDecimalMark = num => num.toLocaleString('en-US'); -``` +```
    Examples @@ -9074,7 +9074,7 @@ const toOrdinalSuffix = num => { ? int + ordinals[digits[0] - 1] : int + ordinals[3]; }; -``` +```
    Examples @@ -9097,7 +9097,7 @@ Use `Number()` to check if the coercion holds. ```js const validateNumber = n => !isNaN(parseFloat(n)) && isFinite(n) && Number(n) == n; -``` +```
    Examples @@ -9120,7 +9120,7 @@ Omit the second argument, `def` to set the default answer as `no`. ```js const yesNo = (val, def = false) => /^(y|yes)$/i.test(val) ? true : /^(n|no)$/i.test(val) ? false : def; -``` +```
    Examples diff --git a/package-lock.json b/package-lock.json index 6d5bc52e4..94fb5063b 100644 --- a/package-lock.json +++ b/package-lock.json @@ -5729,9 +5729,9 @@ } }, "markdown-builder": { - "version": "0.8.4-hotfix", - "resolved": "https://registry.npmjs.org/markdown-builder/-/markdown-builder-0.8.4-hotfix.tgz", - "integrity": "sha512-hpqPx1i+UPVFeSG3rLgPFPp7/Zb62zNsrPsULGUPNgHo1z8HHnAiwkV+sbtz9N3adn7g4xJUVTN7A2BZ1V0ZLQ==", + "version": "0.8.4", + "resolved": "https://registry.npmjs.org/markdown-builder/-/markdown-builder-0.8.4.tgz", + "integrity": "sha512-zI9O16OxyA7kqBdkCkgqvbDGO8FsCYF7rOV+XoeQ0H6ucZII7Do2p2kTkdiLTuxKWPBo/RFYnmP+To8KOp4jCQ==", "dev": true, "requires": { "husky": "1.0.0-rc.14" diff --git a/package.json b/package.json index 7cbc99549..e1794e610 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "html-minifier": "^3.5.15", "jest": "^23.1.0", "jest-tap-reporter": "^1.9.0", - "markdown-builder": "^0.8.4-hotfix", + "markdown-builder": "^0.8.4", "markdown-it": "^8.4.1", "mini.css": "^2.3.7", "node-sass": "^4.9.0",