From 316fa3de0620ddf1af3e9871a0bba37e89cf7a75 Mon Sep 17 00:00:00 2001 From: Evan King <4539809+evan-king@users.noreply.github.com> Date: Tue, 14 Aug 2018 15:28:53 -0300 Subject: [PATCH 001/111] Expand documentation of `memoize` and `memoizeWith` to clarify their limitations and help users find `memoizeWith(toString)` in lieu of choosing a deprecated function. --- source/memoize.js | 3 +++ source/memoizeWith.js | 7 ++++--- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/source/memoize.js b/source/memoize.js index 14cf91f17d..b02254d417 100644 --- a/source/memoize.js +++ b/source/memoize.js @@ -9,6 +9,9 @@ import toString from './toString'; * call to `fn`; instead, the cached result for that set of arguments will be * returned. * + * Arguments are compared by string representation of values. Behavior when + * handling functions or large data structures as arguments is not guaranteed. + * * @func * @memberOf R * @since v0.1.0 diff --git a/source/memoizeWith.js b/source/memoizeWith.js index 22262efc51..3ec566f28a 100644 --- a/source/memoizeWith.js +++ b/source/memoizeWith.js @@ -7,9 +7,10 @@ import _has from './internal/_has'; * A customisable version of [`R.memoize`](#memoize). `memoizeWith` takes an * additional function that will be applied to a given argument set and used to * create the cache key under which the results of the function to be memoized - * will be stored. Care must be taken when implementing key generation to avoid - * clashes that may overwrite previous entries erroneously. + * will be stored. * + * Care must be taken when implementing key generation to avoid key collision, + * or if tracking references, memory leaks and mutating arguments. * * @func * @memberOf R @@ -19,7 +20,7 @@ import _has from './internal/_has'; * @param {Function} fn The function to generate the cache key. * @param {Function} fn The function to memoize. * @return {Function} Memoized version of `fn`. - * @see R.memoize + * @see R.memoize, R.toString * @example * * let count = 0; From 07a55cba6bb1b4d17a409d72f7014e74dfbab706 Mon Sep 17 00:00:00 2001 From: Scott Sauyet Date: Mon, 27 May 2019 19:22:36 -0400 Subject: [PATCH 002/111] removing files deprecated in previous release --- package-lock.json | 258 ++++++++++----------------------------------- source/composeK.js | 44 -------- source/composeP.js | 45 -------- source/contains.js | 29 ----- source/index.js | 6 -- source/merge.js | 32 ------ source/pipeK.js | 44 -------- source/pipeP.js | 34 ------ test/composeK.js | 48 --------- test/composeP.js | 54 ---------- test/groupBy.js | 2 +- test/merge.js | 35 ------ test/pipeK.js | 48 --------- test/pipeP.js | 54 ---------- test/transduce.js | 2 +- 15 files changed, 58 insertions(+), 677 deletions(-) delete mode 100644 source/composeK.js delete mode 100644 source/composeP.js delete mode 100644 source/contains.js delete mode 100644 source/merge.js delete mode 100644 source/pipeK.js delete mode 100644 source/pipeP.js delete mode 100644 test/composeK.js delete mode 100644 test/composeP.js delete mode 100644 test/merge.js delete mode 100644 test/pipeK.js delete mode 100644 test/pipeP.js diff --git a/package-lock.json b/package-lock.json index 70a15f2f4e..a31f2ab902 100644 --- a/package-lock.json +++ b/package-lock.json @@ -49,22 +49,19 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", "integrity": "sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA=", - "dev": true, - "optional": true + "dev": true }, "array-unique": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=", - "dev": true, - "optional": true + "dev": true }, "braces": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/braces/-/braces-2.3.2.tgz", "integrity": "sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w==", "dev": true, - "optional": true, "requires": { "arr-flatten": "^1.1.0", "array-unique": "^0.3.2", @@ -83,7 +80,6 @@ "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, - "optional": true, "requires": { "is-extendable": "^0.1.0" } @@ -125,7 +121,6 @@ "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz", "integrity": "sha1-t3c14xXOMPa27/D4OwQVGiJEliI=", "dev": true, - "optional": true, "requires": { "debug": "^2.3.3", "define-property": "^0.2.5", @@ -141,7 +136,6 @@ "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", "dev": true, - "optional": true, "requires": { "is-descriptor": "^0.1.0" } @@ -151,7 +145,6 @@ "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, - "optional": true, "requires": { "is-extendable": "^0.1.0" } @@ -161,7 +154,6 @@ "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", "dev": true, - "optional": true, "requires": { "kind-of": "^3.0.2" }, @@ -171,7 +163,6 @@ "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, - "optional": true, "requires": { "is-buffer": "^1.1.5" } @@ -183,7 +174,6 @@ "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", "dev": true, - "optional": true, "requires": { "kind-of": "^3.0.2" }, @@ -193,7 +183,6 @@ "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, - "optional": true, "requires": { "is-buffer": "^1.1.5" } @@ -205,7 +194,6 @@ "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", "dev": true, - "optional": true, "requires": { "is-accessor-descriptor": "^0.1.6", "is-data-descriptor": "^0.1.4", @@ -216,8 +204,7 @@ "version": "5.1.0", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", - "dev": true, - "optional": true + "dev": true } } }, @@ -226,7 +213,6 @@ "resolved": "https://registry.npmjs.org/extglob/-/extglob-2.0.4.tgz", "integrity": "sha512-Nmb6QXkELsuBr24CJSkilo6UHHgbekK5UiZgfE6UHD3Eb27YC6oD+bhcT+tJ6cl8dmsgdQxnWlcry8ksBIBLpw==", "dev": true, - "optional": true, "requires": { "array-unique": "^0.3.2", "define-property": "^1.0.0", @@ -243,7 +229,6 @@ "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", "dev": true, - "optional": true, "requires": { "is-descriptor": "^1.0.0" } @@ -253,7 +238,6 @@ "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, - "optional": true, "requires": { "is-extendable": "^0.1.0" } @@ -265,7 +249,6 @@ "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", "integrity": "sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc=", "dev": true, - "optional": true, "requires": { "extend-shallow": "^2.0.1", "is-number": "^3.0.0", @@ -278,7 +261,6 @@ "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, - "optional": true, "requires": { "is-extendable": "^0.1.0" } @@ -305,8 +287,7 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "aproba": { "version": "1.2.0", @@ -327,14 +308,12 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, - "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -349,20 +328,17 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "core-util-is": { "version": "1.0.2", @@ -479,8 +455,7 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "ini": { "version": "1.3.5", @@ -492,7 +467,6 @@ "version": "1.0.0", "bundled": true, "dev": true, - "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -507,7 +481,6 @@ "version": "3.0.4", "bundled": true, "dev": true, - "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -515,14 +488,12 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "minipass": { "version": "2.3.5", "bundled": true, "dev": true, - "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -541,7 +512,6 @@ "version": "0.5.1", "bundled": true, "dev": true, - "optional": true, "requires": { "minimist": "0.0.8" } @@ -622,8 +592,7 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "object-assign": { "version": "4.1.1", @@ -635,7 +604,6 @@ "version": "1.4.0", "bundled": true, "dev": true, - "optional": true, "requires": { "wrappy": "1" } @@ -721,8 +689,7 @@ "safe-buffer": { "version": "5.1.2", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "safer-buffer": { "version": "2.1.2", @@ -758,7 +725,6 @@ "version": "1.0.2", "bundled": true, "dev": true, - "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -778,7 +744,6 @@ "version": "3.0.1", "bundled": true, "dev": true, - "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -822,14 +787,12 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true, - "optional": true + "dev": true }, "yallist": { "version": "3.0.3", "bundled": true, - "dev": true, - "optional": true + "dev": true } } }, @@ -875,7 +838,6 @@ "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", "dev": true, - "optional": true, "requires": { "kind-of": "^6.0.0" } @@ -885,7 +847,6 @@ "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", "dev": true, - "optional": true, "requires": { "kind-of": "^6.0.0" } @@ -895,7 +856,6 @@ "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", "dev": true, - "optional": true, "requires": { "is-accessor-descriptor": "^1.0.0", "is-data-descriptor": "^1.0.0", @@ -906,8 +866,7 @@ "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", - "dev": true, - "optional": true + "dev": true }, "is-glob": { "version": "4.0.1", @@ -924,7 +883,6 @@ "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", "dev": true, - "optional": true, "requires": { "kind-of": "^3.0.2" }, @@ -934,7 +892,6 @@ "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, - "optional": true, "requires": { "is-buffer": "^1.1.5" } @@ -952,15 +909,13 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true, - "optional": true + "dev": true }, "kind-of": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", - "dev": true, - "optional": true + "dev": true }, "lodash": { "version": "4.17.11", @@ -973,7 +928,6 @@ "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz", "integrity": "sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==", "dev": true, - "optional": true, "requires": { "arr-diff": "^4.0.0", "array-unique": "^0.3.2", @@ -1577,15 +1531,13 @@ "version": "1.1.0", "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", - "dev": true, - "optional": true + "dev": true }, "arr-union": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/arr-union/-/arr-union-3.1.0.tgz", "integrity": "sha1-45sJrqne+Gao8gbiiK9jkZuuOcQ=", - "dev": true, - "optional": true + "dev": true }, "array-flatten": { "version": "1.1.1", @@ -1629,8 +1581,7 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/assign-symbols/-/assign-symbols-1.0.0.tgz", "integrity": "sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c=", - "dev": true, - "optional": true + "dev": true }, "astral-regex": { "version": "1.0.0", @@ -1670,8 +1621,7 @@ "version": "2.1.2", "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz", "integrity": "sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==", - "dev": true, - "optional": true + "dev": true }, "babel-plugin-annotate-pure-calls": { "version": "0.4.0", @@ -1717,7 +1667,6 @@ "resolved": "https://registry.npmjs.org/base/-/base-0.11.2.tgz", "integrity": "sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg==", "dev": true, - "optional": true, "requires": { "cache-base": "^1.0.1", "class-utils": "^0.3.5", @@ -1733,7 +1682,6 @@ "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", "dev": true, - "optional": true, "requires": { "is-descriptor": "^1.0.0" } @@ -1743,7 +1691,6 @@ "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", "dev": true, - "optional": true, "requires": { "kind-of": "^6.0.0" } @@ -1753,7 +1700,6 @@ "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", "dev": true, - "optional": true, "requires": { "kind-of": "^6.0.0" } @@ -1763,7 +1709,6 @@ "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", "dev": true, - "optional": true, "requires": { "is-accessor-descriptor": "^1.0.0", "is-data-descriptor": "^1.0.0", @@ -1774,15 +1719,13 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true, - "optional": true + "dev": true }, "kind-of": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", - "dev": true, - "optional": true + "dev": true } } }, @@ -2152,7 +2095,6 @@ "resolved": "https://registry.npmjs.org/cache-base/-/cache-base-1.0.1.tgz", "integrity": "sha512-AKcdTnFSWATd5/GCPRxr2ChwIJ85CeyrEyjRHlKxQ56d4XJMGym0uAiKn0xbLOGOl3+yRpOTi484dVCEc5AUzQ==", "dev": true, - "optional": true, "requires": { "collection-visit": "^1.0.0", "component-emitter": "^1.2.1", @@ -2169,8 +2111,7 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true, - "optional": true + "dev": true } } }, @@ -2227,7 +2168,6 @@ "resolved": "https://registry.npmjs.org/class-utils/-/class-utils-0.3.6.tgz", "integrity": "sha512-qOhPa/Fj7s6TY8H8esGu5QNpMMQxz79h+urzrNYN6mn+9BnxlDGf5QZ+XeCDsxSjPqsSR56XOZOJmpeurnLMeg==", "dev": true, - "optional": true, "requires": { "arr-union": "^3.1.0", "define-property": "^0.2.5", @@ -2240,7 +2180,6 @@ "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", "dev": true, - "optional": true, "requires": { "is-descriptor": "^0.1.0" } @@ -2249,8 +2188,7 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true, - "optional": true + "dev": true } } }, @@ -2289,7 +2227,6 @@ "resolved": "https://registry.npmjs.org/collection-visit/-/collection-visit-1.0.0.tgz", "integrity": "sha1-S8A3PBZLwykbTTaMgpzxqApZ3KA=", "dev": true, - "optional": true, "requires": { "map-visit": "^1.0.0", "object-visit": "^1.0.0" @@ -2449,8 +2386,7 @@ "version": "0.1.1", "resolved": "https://registry.npmjs.org/copy-descriptor/-/copy-descriptor-0.1.1.tgz", "integrity": "sha1-Z29us8OZl8LuGsOpJP1hJHSPV40=", - "dev": true, - "optional": true + "dev": true }, "core-js": { "version": "3.1.1", @@ -2568,8 +2504,7 @@ "version": "0.2.0", "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz", "integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=", - "dev": true, - "optional": true + "dev": true }, "deep-equal": { "version": "1.0.1", @@ -2597,7 +2532,6 @@ "resolved": "https://registry.npmjs.org/define-property/-/define-property-2.0.2.tgz", "integrity": "sha512-jwK2UV4cnPpbcG7+VRARKTZPUWowwXA8bzH5NP6ud0oeAxyYPuGZUAC7hMugpCdz4BeSZl2Dl9k66CHJ/46ZYQ==", "dev": true, - "optional": true, "requires": { "is-descriptor": "^1.0.2", "isobject": "^3.0.1" @@ -2608,7 +2542,6 @@ "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", "dev": true, - "optional": true, "requires": { "kind-of": "^6.0.0" } @@ -2618,7 +2551,6 @@ "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", "dev": true, - "optional": true, "requires": { "kind-of": "^6.0.0" } @@ -2628,7 +2560,6 @@ "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", "dev": true, - "optional": true, "requires": { "is-accessor-descriptor": "^1.0.0", "is-data-descriptor": "^1.0.0", @@ -2639,15 +2570,13 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true, - "optional": true + "dev": true }, "kind-of": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", - "dev": true, - "optional": true + "dev": true } } }, @@ -3249,7 +3178,6 @@ "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", "integrity": "sha1-Jqcarwc7OfshJxcnRhMcJwQCjbg=", "dev": true, - "optional": true, "requires": { "assign-symbols": "^1.0.0", "is-extendable": "^1.0.1" @@ -3260,7 +3188,6 @@ "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", "dev": true, - "optional": true, "requires": { "is-plain-object": "^2.0.4" } @@ -3434,8 +3361,7 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=", - "dev": true, - "optional": true + "dev": true }, "forwarded": { "version": "0.1.2", @@ -3448,7 +3374,6 @@ "resolved": "https://registry.npmjs.org/fragment-cache/-/fragment-cache-0.2.1.tgz", "integrity": "sha1-QpD60n8T6Jvn8zeZxrxaCr//DRk=", "dev": true, - "optional": true, "requires": { "map-cache": "^0.2.2" } @@ -3555,8 +3480,7 @@ "version": "2.0.6", "resolved": "https://registry.npmjs.org/get-value/-/get-value-2.0.6.tgz", "integrity": "sha1-3BXKHGcjh8p2vTesCjlbogQqLCg=", - "dev": true, - "optional": true + "dev": true }, "glob": { "version": "4.5.3", @@ -3686,7 +3610,6 @@ "resolved": "https://registry.npmjs.org/has-value/-/has-value-1.0.0.tgz", "integrity": "sha1-GLKB2lhbHFxR3vJMkw7SmgvmsXc=", "dev": true, - "optional": true, "requires": { "get-value": "^2.0.6", "has-values": "^1.0.0", @@ -3697,8 +3620,7 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true, - "optional": true + "dev": true } } }, @@ -3707,7 +3629,6 @@ "resolved": "https://registry.npmjs.org/has-values/-/has-values-1.0.0.tgz", "integrity": "sha1-lbC2P+whRmGab+V/51Yo1aOe/k8=", "dev": true, - "optional": true, "requires": { "is-number": "^3.0.0", "kind-of": "^4.0.0" @@ -3718,7 +3639,6 @@ "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", "dev": true, - "optional": true, "requires": { "kind-of": "^3.0.2" }, @@ -3728,7 +3648,6 @@ "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, - "optional": true, "requires": { "is-buffer": "^1.1.5" } @@ -3740,7 +3659,6 @@ "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-4.0.0.tgz", "integrity": "sha1-IIE989cSkosgc3hpGkUGb65y3Vc=", "dev": true, - "optional": true, "requires": { "is-buffer": "^1.1.5" } @@ -4034,7 +3952,6 @@ "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", "dev": true, - "optional": true, "requires": { "kind-of": "^3.0.2" } @@ -4066,7 +3983,6 @@ "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", "dev": true, - "optional": true, "requires": { "kind-of": "^3.0.2" } @@ -4082,7 +3998,6 @@ "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", "dev": true, - "optional": true, "requires": { "is-accessor-descriptor": "^0.1.6", "is-data-descriptor": "^0.1.4", @@ -4093,8 +4008,7 @@ "version": "5.1.0", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", - "dev": true, - "optional": true + "dev": true } } }, @@ -4102,8 +4016,7 @@ "version": "0.1.1", "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=", - "dev": true, - "optional": true + "dev": true }, "is-fullwidth-code-point": { "version": "2.0.0", @@ -4122,7 +4035,6 @@ "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==", "dev": true, - "optional": true, "requires": { "isobject": "^3.0.1" }, @@ -4131,8 +4043,7 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true, - "optional": true + "dev": true } } }, @@ -4471,7 +4382,6 @@ "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, - "optional": true, "requires": { "is-buffer": "^1.1.5" } @@ -4673,15 +4583,13 @@ "version": "0.2.2", "resolved": "https://registry.npmjs.org/map-cache/-/map-cache-0.2.2.tgz", "integrity": "sha1-wyq9C9ZSXZsFFkW7TyasXcmKDb8=", - "dev": true, - "optional": true + "dev": true }, "map-visit": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/map-visit/-/map-visit-1.0.0.tgz", "integrity": "sha1-7Nyo8TFE5mDxtb1B8S80edmN+48=", "dev": true, - "optional": true, "requires": { "object-visit": "^1.0.0" } @@ -4889,7 +4797,6 @@ "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.1.tgz", "integrity": "sha512-8ZItLHeEgaqEvd5lYBXfm4EZSFCX29Jb9K+lAHhDKzReKBQKj3R+7NOF6tjqYi9t4oI8VUfaWITJQm86wnXGNQ==", "dev": true, - "optional": true, "requires": { "for-in": "^1.0.2", "is-extendable": "^1.0.1" @@ -4900,7 +4807,6 @@ "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", "dev": true, - "optional": true, "requires": { "is-plain-object": "^2.0.4" } @@ -5143,7 +5049,6 @@ "resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.13.tgz", "integrity": "sha512-fpoe2T0RbHwBTBUOftAfBPaDEi06ufaUai0mE6Yn1kacc3SnTErfb/h+X94VXzI64rKFHYImXSvdwGGCmwOqCA==", "dev": true, - "optional": true, "requires": { "arr-diff": "^4.0.0", "array-unique": "^0.3.2", @@ -5162,22 +5067,19 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", "integrity": "sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA=", - "dev": true, - "optional": true + "dev": true }, "array-unique": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=", - "dev": true, - "optional": true + "dev": true }, "kind-of": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", - "dev": true, - "optional": true + "dev": true } } }, @@ -5316,7 +5218,6 @@ "resolved": "https://registry.npmjs.org/object-copy/-/object-copy-0.1.0.tgz", "integrity": "sha1-fn2Fi3gb18mRpBupde04EnVOmYw=", "dev": true, - "optional": true, "requires": { "copy-descriptor": "^0.1.0", "define-property": "^0.2.5", @@ -5328,7 +5229,6 @@ "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", "dev": true, - "optional": true, "requires": { "is-descriptor": "^0.1.0" } @@ -5346,7 +5246,6 @@ "resolved": "https://registry.npmjs.org/object-visit/-/object-visit-1.0.1.tgz", "integrity": "sha1-95xEk68MU3e1n+OdOV5BBC3QRbs=", "dev": true, - "optional": true, "requires": { "isobject": "^3.0.0" }, @@ -5355,8 +5254,7 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true, - "optional": true + "dev": true } } }, @@ -5387,7 +5285,6 @@ "resolved": "https://registry.npmjs.org/object.pick/-/object.pick-1.3.0.tgz", "integrity": "sha1-h6EKxMFpS9Lhy/U1kaZhQftd10c=", "dev": true, - "optional": true, "requires": { "isobject": "^3.0.1" }, @@ -5396,8 +5293,7 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true, - "optional": true + "dev": true } } }, @@ -5598,8 +5494,7 @@ "version": "0.1.1", "resolved": "https://registry.npmjs.org/pascalcase/-/pascalcase-0.1.1.tgz", "integrity": "sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ=", - "dev": true, - "optional": true + "dev": true }, "path-browserify": { "version": "0.0.1", @@ -5700,8 +5595,7 @@ "version": "0.1.1", "resolved": "https://registry.npmjs.org/posix-character-classes/-/posix-character-classes-0.1.1.tgz", "integrity": "sha1-AerA/jta9xoqbAL+q7jB/vfgDqs=", - "dev": true, - "optional": true + "dev": true }, "prelude-ls": { "version": "1.1.2", @@ -5874,7 +5768,6 @@ "resolved": "https://registry.npmjs.org/regex-not/-/regex-not-1.0.2.tgz", "integrity": "sha512-J6SDjUgDxQj5NusnOtdFxDwN/+HWykR8GELwctJ7mdqhcyy1xEc4SRFHUXvxTp661YaVKAjfRLZ9cCqS6tn32A==", "dev": true, - "optional": true, "requires": { "extend-shallow": "^3.0.2", "safe-regex": "^1.1.0" @@ -5897,15 +5790,13 @@ "version": "1.1.2", "resolved": "https://registry.npmjs.org/repeat-element/-/repeat-element-1.1.2.tgz", "integrity": "sha1-7wiaF40Ug7quTZPrmLT55OEdmQo=", - "dev": true, - "optional": true + "dev": true }, "repeat-string": { "version": "1.6.1", "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", - "dev": true, - "optional": true + "dev": true }, "require-directory": { "version": "2.1.1", @@ -5944,8 +5835,7 @@ "version": "0.2.1", "resolved": "https://registry.npmjs.org/resolve-url/-/resolve-url-0.2.1.tgz", "integrity": "sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo=", - "dev": true, - "optional": true + "dev": true }, "restore-cursor": { "version": "2.0.0", @@ -5961,8 +5851,7 @@ "version": "0.1.15", "resolved": "https://registry.npmjs.org/ret/-/ret-0.1.15.tgz", "integrity": "sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg==", - "dev": true, - "optional": true + "dev": true }, "rimraf": { "version": "2.6.3", @@ -6050,7 +5939,6 @@ "resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz", "integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=", "dev": true, - "optional": true, "requires": { "ret": "~0.1.10" } @@ -6134,7 +6022,6 @@ "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.0.tgz", "integrity": "sha512-hw0yxk9GT/Hr5yJEYnHNKYXkIA8mVJgd9ditYZCe16ZczcaELYYcfvaXesNACk2O8O0nTiPQcQhGUQj8JLzeeg==", "dev": true, - "optional": true, "requires": { "extend-shallow": "^2.0.1", "is-extendable": "^0.1.1", @@ -6147,7 +6034,6 @@ "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, - "optional": true, "requires": { "is-extendable": "^0.1.0" } @@ -6250,7 +6136,6 @@ "resolved": "https://registry.npmjs.org/snapdragon/-/snapdragon-0.8.2.tgz", "integrity": "sha512-FtyOnWN/wCHTVXOMwvSv26d+ko5vWlIDD6zoUJ7LW8vh+ZBC8QdljveRP+crNrtBwioEUWy/4dMtbBjA4ioNlg==", "dev": true, - "optional": true, "requires": { "base": "^0.11.1", "debug": "^2.2.0", @@ -6267,7 +6152,6 @@ "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", "dev": true, - "optional": true, "requires": { "is-descriptor": "^0.1.0" } @@ -6277,7 +6161,6 @@ "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, - "optional": true, "requires": { "is-extendable": "^0.1.0" } @@ -6286,8 +6169,7 @@ "version": "0.5.7", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", - "dev": true, - "optional": true + "dev": true } } }, @@ -6296,7 +6178,6 @@ "resolved": "https://registry.npmjs.org/snapdragon-node/-/snapdragon-node-2.1.1.tgz", "integrity": "sha512-O27l4xaMYt/RSQ5TR3vpWCAB5Kb/czIcqUFOM/C4fYcLnbZUc1PkjTAMjof2pBWaSTwOUd6qUHcFGVGj7aIwnw==", "dev": true, - "optional": true, "requires": { "define-property": "^1.0.0", "isobject": "^3.0.0", @@ -6308,7 +6189,6 @@ "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", "dev": true, - "optional": true, "requires": { "is-descriptor": "^1.0.0" } @@ -6318,7 +6198,6 @@ "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", "dev": true, - "optional": true, "requires": { "kind-of": "^6.0.0" } @@ -6328,7 +6207,6 @@ "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", "dev": true, - "optional": true, "requires": { "kind-of": "^6.0.0" } @@ -6338,7 +6216,6 @@ "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", "dev": true, - "optional": true, "requires": { "is-accessor-descriptor": "^1.0.0", "is-data-descriptor": "^1.0.0", @@ -6349,15 +6226,13 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true, - "optional": true + "dev": true }, "kind-of": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", - "dev": true, - "optional": true + "dev": true } } }, @@ -6366,7 +6241,6 @@ "resolved": "https://registry.npmjs.org/snapdragon-util/-/snapdragon-util-3.0.1.tgz", "integrity": "sha512-mbKkMdQKsjX4BAL4bRYTj21edOf8cN7XHdYUJEe+Zn99hVEYcMvKPct1IqNe7+AZPirn8BCDOQBHQZknqmKlZQ==", "dev": true, - "optional": true, "requires": { "kind-of": "^3.2.0" } @@ -6483,7 +6357,6 @@ "resolved": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.5.2.tgz", "integrity": "sha512-MjqsvNwyz1s0k81Goz/9vRBe9SZdB09Bdw+/zYyO+3CuPk6fouTaxscHkgtE8jKvf01kVfl8riHzERQ/kefaSA==", "dev": true, - "optional": true, "requires": { "atob": "^2.1.1", "decode-uri-component": "^0.2.0", @@ -6514,8 +6387,7 @@ "version": "0.4.0", "resolved": "https://registry.npmjs.org/source-map-url/-/source-map-url-0.4.0.tgz", "integrity": "sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM=", - "dev": true, - "optional": true + "dev": true }, "spawn-args": { "version": "0.2.0", @@ -6528,7 +6400,6 @@ "resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz", "integrity": "sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw==", "dev": true, - "optional": true, "requires": { "extend-shallow": "^3.0.0" } @@ -6544,7 +6415,6 @@ "resolved": "https://registry.npmjs.org/static-extend/-/static-extend-0.1.2.tgz", "integrity": "sha1-YICcOcv/VTNyJv1eC1IPNB8ftcY=", "dev": true, - "optional": true, "requires": { "define-property": "^0.2.5", "object-copy": "^0.1.0" @@ -6555,7 +6425,6 @@ "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", "dev": true, - "optional": true, "requires": { "is-descriptor": "^0.1.0" } @@ -6878,7 +6747,6 @@ "resolved": "https://registry.npmjs.org/to-object-path/-/to-object-path-0.3.0.tgz", "integrity": "sha1-KXWIt7Dn4KwI4E5nL4XB9JmeF68=", "dev": true, - "optional": true, "requires": { "kind-of": "^3.0.2" } @@ -6888,7 +6756,6 @@ "resolved": "https://registry.npmjs.org/to-regex/-/to-regex-3.0.2.tgz", "integrity": "sha512-FWtleNAtZ/Ki2qtqej2CXTOayOH9bHDQF+Q48VpWyDXjbYxA4Yz8iDB31zXOBUlOHHKidDbqGVrTUvQMPmBGBw==", "dev": true, - "optional": true, "requires": { "define-property": "^2.0.2", "extend-shallow": "^3.0.2", @@ -6901,7 +6768,6 @@ "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-2.1.1.tgz", "integrity": "sha1-fIDBe53+vlmeJzZ+DU3VWQFB2zg=", "dev": true, - "optional": true, "requires": { "is-number": "^3.0.0", "repeat-string": "^1.6.1" @@ -6912,7 +6778,6 @@ "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", "dev": true, - "optional": true, "requires": { "kind-of": "^3.0.2" } @@ -7033,7 +6898,6 @@ "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.0.tgz", "integrity": "sha1-XHHDTLW61dzr4+oM0IIHulqhrqQ=", "dev": true, - "optional": true, "requires": { "arr-union": "^3.1.0", "get-value": "^2.0.6", @@ -7046,7 +6910,6 @@ "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, - "optional": true, "requires": { "is-extendable": "^0.1.0" } @@ -7056,7 +6919,6 @@ "resolved": "https://registry.npmjs.org/set-value/-/set-value-0.4.3.tgz", "integrity": "sha1-fbCPnT0i3H945Trzw79GZuzfzPE=", "dev": true, - "optional": true, "requires": { "extend-shallow": "^2.0.1", "is-extendable": "^0.1.1", @@ -7077,7 +6939,6 @@ "resolved": "https://registry.npmjs.org/unset-value/-/unset-value-1.0.0.tgz", "integrity": "sha1-g3aHP30jNRef+x5vw6jtDfyKtVk=", "dev": true, - "optional": true, "requires": { "has-value": "^0.3.1", "isobject": "^3.0.0" @@ -7088,7 +6949,6 @@ "resolved": "https://registry.npmjs.org/has-value/-/has-value-0.3.1.tgz", "integrity": "sha1-ex9YutpiyoJ+wKIHgCVlSEWZXh8=", "dev": true, - "optional": true, "requires": { "get-value": "^2.0.3", "has-values": "^0.1.4", @@ -7100,7 +6960,6 @@ "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", "integrity": "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=", "dev": true, - "optional": true, "requires": { "isarray": "1.0.0" } @@ -7111,22 +6970,19 @@ "version": "0.1.4", "resolved": "https://registry.npmjs.org/has-values/-/has-values-0.1.4.tgz", "integrity": "sha1-bWHeldkd/Km5oCCJrThL/49it3E=", - "dev": true, - "optional": true + "dev": true }, "isarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "dev": true, - "optional": true + "dev": true }, "isobject": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true, - "optional": true + "dev": true } } }, @@ -7158,8 +7014,7 @@ "version": "0.1.0", "resolved": "https://registry.npmjs.org/urix/-/urix-0.1.0.tgz", "integrity": "sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI=", - "dev": true, - "optional": true + "dev": true }, "url": { "version": "0.10.3", @@ -7183,8 +7038,7 @@ "version": "3.1.1", "resolved": "https://registry.npmjs.org/use/-/use-3.1.1.tgz", "integrity": "sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ==", - "dev": true, - "optional": true + "dev": true }, "util": { "version": "0.10.3", diff --git a/source/composeK.js b/source/composeK.js deleted file mode 100644 index 6ce0caa976..0000000000 --- a/source/composeK.js +++ /dev/null @@ -1,44 +0,0 @@ -import chain from './chain'; -import compose from './compose'; -import map from './map'; - - -/** - * Returns the right-to-left Kleisli composition of the provided functions, - * each of which must return a value of a type supported by [`chain`](#chain). - * - * `R.composeK(h, g, f)` is equivalent to `R.compose(R.chain(h), R.chain(g), f)`. - * - * @func - * @memberOf R - * @since v0.16.0 - * @category Function - * @sig Chain m => ((y -> m z), (x -> m y), ..., (a -> m b)) -> (a -> m z) - * @param {...Function} ...functions The functions to compose - * @return {Function} - * @see R.pipeK - * @deprecated since v0.26.0 - * @example - * - * // get :: String -> Object -> Maybe * - * const get = R.curry((propName, obj) => Maybe(obj[propName])) - * - * // getStateCode :: Maybe String -> Maybe String - * const getStateCode = R.composeK( - * R.compose(Maybe.of, R.toUpper), - * get('state'), - * get('address'), - * get('user'), - * ); - * getStateCode({"user":{"address":{"state":"ny"}}}); //=> Maybe.Just("NY") - * getStateCode({}); //=> Maybe.Nothing() - * @symb R.composeK(f, g, h)(a) = R.chain(f, R.chain(g, h(a))) - */ -export default function composeK() { - if (arguments.length === 0) { - throw new Error('composeK requires at least one argument'); - } - var init = Array.prototype.slice.call(arguments); - var last = init.pop(); - return compose(compose.apply(this, map(chain, init)), last); -} diff --git a/source/composeP.js b/source/composeP.js deleted file mode 100644 index 89c3a53a02..0000000000 --- a/source/composeP.js +++ /dev/null @@ -1,45 +0,0 @@ -import pipeP from './pipeP'; -import reverse from './reverse'; - - -/** - * Performs right-to-left composition of one or more Promise-returning - * functions. The last arguments may have any arity; the remaining - * arguments must be unary. - * - * @func - * @memberOf R - * @since v0.10.0 - * @category Function - * @sig ((y -> Promise z), (x -> Promise y), ..., (a -> Promise b)) -> (a -> Promise z) - * @param {...Function} functions The functions to compose - * @return {Function} - * @see R.pipeP - * @deprecated since v0.26.0 - * @example - * - * const db = { - * users: { - * JOE: { - * name: 'Joe', - * followers: ['STEVE', 'SUZY'] - * } - * } - * } - * - * // We'll pretend to do a db lookup which returns a promise - * const lookupUser = (userId) => Promise.resolve(db.users[userId]) - * const lookupFollowers = (user) => Promise.resolve(user.followers) - * lookupUser('JOE').then(lookupFollowers) - * - * // followersForUser :: String -> Promise [UserId] - * const followersForUser = R.composeP(lookupFollowers, lookupUser); - * followersForUser('JOE').then(followers => console.log('Followers:', followers)) - * // Followers: ["STEVE","SUZY"] - */ -export default function composeP() { - if (arguments.length === 0) { - throw new Error('composeP requires at least one argument'); - } - return pipeP.apply(this, reverse(arguments)); -} diff --git a/source/contains.js b/source/contains.js deleted file mode 100644 index 34aa451797..0000000000 --- a/source/contains.js +++ /dev/null @@ -1,29 +0,0 @@ -import _includes from './internal/_includes'; -import _curry2 from './internal/_curry2'; - - -/** - * Returns `true` if the specified value is equal, in [`R.equals`](#equals) - * terms, to at least one element of the given list; `false` otherwise. - * Works also with strings. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category List - * @sig a -> [a] -> Boolean - * @param {Object} a The item to compare against. - * @param {Array} list The array to consider. - * @return {Boolean} `true` if an equivalent item is in the list, `false` otherwise. - * @see R.includes - * @deprecated since v0.26.0 - * @example - * - * R.contains(3, [1, 2, 3]); //=> true - * R.contains(4, [1, 2, 3]); //=> false - * R.contains({ name: 'Fred' }, [{ name: 'Fred' }]); //=> true - * R.contains([42], [[42]]); //=> true - * R.contains('ba', 'banana'); //=>true - */ -var contains = _curry2(_includes); -export default contains; diff --git a/source/index.js b/source/index.js index 6a440961eb..3245ade70f 100644 --- a/source/index.js +++ b/source/index.js @@ -29,14 +29,11 @@ export { default as clone } from './clone'; export { default as comparator } from './comparator'; export { default as complement } from './complement'; export { default as compose } from './compose'; -export { default as composeK } from './composeK'; -export { default as composeP } from './composeP'; export { default as composeWith } from './composeWith'; export { default as concat } from './concat'; export { default as cond } from './cond'; export { default as construct } from './construct'; export { default as constructN } from './constructN'; -export { default as contains } from './contains'; export { default as converge } from './converge'; export { default as countBy } from './countBy'; export { default as curry } from './curry'; @@ -126,7 +123,6 @@ export { default as maxBy } from './maxBy'; export { default as mean } from './mean'; export { default as median } from './median'; export { default as memoizeWith } from './memoizeWith'; -export { default as merge } from './merge'; export { default as mergeAll } from './mergeAll'; export { default as mergeDeepLeft } from './mergeDeepLeft'; export { default as mergeDeepRight } from './mergeDeepRight'; @@ -168,8 +164,6 @@ export { default as pick } from './pick'; export { default as pickAll } from './pickAll'; export { default as pickBy } from './pickBy'; export { default as pipe } from './pipe'; -export { default as pipeK } from './pipeK'; -export { default as pipeP } from './pipeP'; export { default as pipeWith } from './pipeWith'; export { default as pluck } from './pluck'; export { default as prepend } from './prepend'; diff --git a/source/merge.js b/source/merge.js deleted file mode 100644 index 6059a4c00b..0000000000 --- a/source/merge.js +++ /dev/null @@ -1,32 +0,0 @@ -import _objectAssign from './internal/_objectAssign'; -import _curry2 from './internal/_curry2'; - - -/** - * Create a new object with the own properties of the first object merged with - * the own properties of the second object. If a key exists in both objects, - * the value from the second object will be used. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Object - * @sig {k: v} -> {k: v} -> {k: v} - * @param {Object} l - * @param {Object} r - * @return {Object} - * @see R.mergeRight, R.mergeDeepRight, R.mergeWith, R.mergeWithKey - * @deprecated since v0.26.0 - * @example - * - * R.merge({ 'name': 'fred', 'age': 10 }, { 'age': 40 }); - * //=> { 'name': 'fred', 'age': 40 } - * - * const withDefaults = R.merge({x: 0, y: 0}); - * withDefaults({y: 2}); //=> {x: 0, y: 2} - * @symb R.merge(a, b) = {...a, ...b} - */ -var merge = _curry2(function merge(l, r) { - return _objectAssign({}, l, r); -}); -export default merge; diff --git a/source/pipeK.js b/source/pipeK.js deleted file mode 100644 index 36fc77350f..0000000000 --- a/source/pipeK.js +++ /dev/null @@ -1,44 +0,0 @@ -import composeK from './composeK'; -import reverse from './reverse'; - -/** - * Returns the left-to-right Kleisli composition of the provided functions, - * each of which must return a value of a type supported by [`chain`](#chain). - * - * `R.pipeK(f, g, h)` is equivalent to `R.pipe(f, R.chain(g), R.chain(h))`. - * - * @func - * @memberOf R - * @since v0.16.0 - * @category Function - * @sig Chain m => ((a -> m b), (b -> m c), ..., (y -> m z)) -> (a -> m z) - * @param {...Function} - * @return {Function} - * @see R.composeK - * @deprecated since v0.26.0 - * @example - * - * // parseJson :: String -> Maybe * - * // get :: String -> Object -> Maybe * - * - * // getStateCode :: Maybe String -> Maybe String - * const getStateCode = R.pipeK( - * parseJson, - * get('user'), - * get('address'), - * get('state'), - * R.compose(Maybe.of, R.toUpper) - * ); - * - * getStateCode('{"user":{"address":{"state":"ny"}}}'); - * //=> Just('NY') - * getStateCode('[Invalid JSON]'); - * //=> Nothing() - * @symb R.pipeK(f, g, h)(a) = R.chain(h, R.chain(g, f(a))) - */ -export default function pipeK() { - if (arguments.length === 0) { - throw new Error('pipeK requires at least one argument'); - } - return composeK.apply(this, reverse(arguments)); -} diff --git a/source/pipeP.js b/source/pipeP.js deleted file mode 100644 index b4ee1f2c87..0000000000 --- a/source/pipeP.js +++ /dev/null @@ -1,34 +0,0 @@ -import _arity from './internal/_arity'; -import _pipeP from './internal/_pipeP'; -import reduce from './reduce'; -import tail from './tail'; - - -/** - * Performs left-to-right composition of one or more Promise-returning - * functions. The first argument may have any arity; the remaining arguments - * must be unary. - * - * @func - * @memberOf R - * @since v0.10.0 - * @category Function - * @sig ((a -> Promise b), (b -> Promise c), ..., (y -> Promise z)) -> (a -> Promise z) - * @param {...Function} functions - * @return {Function} - * @see R.composeP - * @deprecated since v0.26.0 - * @example - * - * // followersForUser :: String -> Promise [User] - * const followersForUser = R.pipeP(db.getUserById, db.getFollowers); - */ -export default function pipeP() { - if (arguments.length === 0) { - throw new Error('pipeP requires at least one argument'); - } - return _arity( - arguments[0].length, - reduce(_pipeP, arguments[0], tail(arguments)) - ); -} diff --git a/test/composeK.js b/test/composeK.js deleted file mode 100644 index 2f95001a0f..0000000000 --- a/test/composeK.js +++ /dev/null @@ -1,48 +0,0 @@ -var assert = require('assert'); -var jsv = require('jsverify'); - -var R = require('../source'); -var eq = require('./shared/eq'); - - -var Identity = function(x) { - this.value = x; -}; - -Identity.prototype.chain = function(f) { - return f(this.value); -}; - -function IdentityArb(arb) { - return arb.smap(function(x) { return new Identity(x); }, function(i) { return i.value; }); -} - -describe('composeK', function() { - - it('is a variadic function', function() { - eq(typeof R.composeK, 'function'); - eq(R.composeK.length, 0); - }); - - jsv.property('performs right-to-left Kleisli composition', - jsv.fn(IdentityArb(jsv.number)), - jsv.fn(IdentityArb(jsv.number)), - jsv.fn(IdentityArb(jsv.number)), - jsv.number, - function(f, g, h, x) { - var actual = R.composeK(f, g, h)(x).value; - var expected = R.chain(f, R.chain(g, h(x))).value; - return actual === expected; - } - ); - - it('throws if given no arguments', function() { - assert.throws( - function() { R.composeK(); }, - function(err) { - return err.constructor === Error && - err.message === 'composeK requires at least one argument'; - } - ); - }); -}); diff --git a/test/composeP.js b/test/composeP.js deleted file mode 100644 index 55f1295416..0000000000 --- a/test/composeP.js +++ /dev/null @@ -1,54 +0,0 @@ -var assert = require('assert'); - -var R = require('../source'); -var eq = require('./shared/eq'); - - -describe('composeP', function() { - - it('is a variadic function', function() { - eq(typeof R.composeP, 'function'); - eq(R.composeP.length, 0); - }); - - it('performs right-to-left composition of Promise-returning functions', function(done) { - var f = function(a) { return new Promise(function(res) { res([a]); }); }; - var g = function(a, b) { return new Promise(function(res) { res([a, b]); }); }; - - eq(R.composeP(f).length, 1); - eq(R.composeP(g).length, 2); - eq(R.composeP(f, f).length, 1); - eq(R.composeP(f, g).length, 2); - eq(R.composeP(g, f).length, 1); - eq(R.composeP(g, g).length, 2); - - R.composeP(f, g)(1).then(function(result) { - eq(result, [[1, undefined]]); - - R.composeP(g, f)(1).then(function(result) { - eq(result, [[1], undefined]); - - R.composeP(f, g)(1, 2).then(function(result) { - eq(result, [[1, 2]]); - - R.composeP(g, f)(1, 2).then(function(result) { - eq(result, [[1], undefined]); - - done(); - })['catch'](done); - })['catch'](done); - })['catch'](done); - })['catch'](done); - }); - - it('throws if given no arguments', function() { - assert.throws( - function() { R.composeP(); }, - function(err) { - return err.constructor === Error && - err.message === 'composeP requires at least one argument'; - } - ); - }); - -}); diff --git a/test/groupBy.js b/test/groupBy.js index 709705a8ae..61d224192d 100644 --- a/test/groupBy.js +++ b/test/groupBy.js @@ -39,7 +39,7 @@ describe('groupBy', function() { var xf = { '@@transducer/init': function() { return {}; }, '@@transducer/result': function(x) { return x; }, - '@@transducer/step': R.merge + '@@transducer/step': R.mergeRight }; eq(_isTransformer(R.groupBy(byType, xf)), true); }); diff --git a/test/merge.js b/test/merge.js deleted file mode 100644 index 8949d9a840..0000000000 --- a/test/merge.js +++ /dev/null @@ -1,35 +0,0 @@ -var assert = require('assert'); - -var R = require('../source'); -var eq = require('./shared/eq'); - - -describe('merge', function() { - it('takes two objects, merges their own properties and returns a new object', function() { - var a = {w: 1, x: 2}; - var b = {y: 3, z: 4}; - eq(R.merge(a, b), {w: 1, x: 2, y: 3, z: 4}); - }); - - it('overrides properties in the first object with properties in the second object', function() { - var a = {w: 1, x: 2}; - var b = {w: 100, y: 3, z: 4}; - eq(R.merge(a, b), {w: 100, x: 2, y: 3, z: 4}); - }); - - it('is not destructive', function() { - var a = {w: 1, x: 2}; - var res = R.merge(a, {x: 5}); - assert.notStrictEqual(a, res); - eq(res, {w: 1, x: 5}); - }); - - it('reports only own properties', function() { - var a = {w: 1, x: 2}; - function Cla() {} - Cla.prototype.x = 5; - eq(R.merge(new Cla(), a), {w: 1, x: 2}); - eq(R.merge(a, new Cla()), {w: 1, x: 2}); - }); - -}); diff --git a/test/pipeK.js b/test/pipeK.js deleted file mode 100644 index ce39f20276..0000000000 --- a/test/pipeK.js +++ /dev/null @@ -1,48 +0,0 @@ -var jsv = require('jsverify'); -var assert = require('assert'); - -var R = require('../source'); -var eq = require('./shared/eq'); - - -var Identity = function(x) { - this.value = x; -}; - -Identity.prototype.chain = function(f) { - return f(this.value); -}; - -function IdentityArb(arb) { - return arb.smap(function(x) { return new Identity(x); }, function(i) { return i.value; }); -} - -describe('pipeK', function() { - - it('is a variadic function', function() { - eq(typeof R.pipeK, 'function'); - eq(R.pipeK.length, 0); - }); - - jsv.property('performs left-to-right Kleisli composition', - jsv.fn(IdentityArb(jsv.number)), - jsv.fn(IdentityArb(jsv.number)), - jsv.fn(IdentityArb(jsv.number)), - jsv.number, - function(f, g, h, x) { - var actual = R.pipeK(f, g, h)(x).value; - var expected = R.chain(h, R.chain(g, f(x))).value; - return actual === expected; - } - ); - - it('throws if given no arguments', function() { - assert.throws( - function() { R.pipeK(); }, - function(err) { - return err.constructor === Error && - err.message === 'pipeK requires at least one argument'; - } - ); - }); -}); diff --git a/test/pipeP.js b/test/pipeP.js deleted file mode 100644 index 4815e07ccc..0000000000 --- a/test/pipeP.js +++ /dev/null @@ -1,54 +0,0 @@ -var assert = require('assert'); - -var R = require('../source'); -var eq = require('./shared/eq'); - - -describe('pipeP', function() { - - it('is a variadic function', function() { - eq(typeof R.pipeP, 'function'); - eq(R.pipeP.length, 0); - }); - - it('performs left-to-right composition of Promise-returning functions', function(done) { - var f = function(a) { return new Promise(function(res) { res([a]); }); }; - var g = function(a, b) { return new Promise(function(res) { res([a, b]); }); }; - - eq(R.pipeP(f).length, 1); - eq(R.pipeP(g).length, 2); - eq(R.pipeP(f, f).length, 1); - eq(R.pipeP(f, g).length, 1); - eq(R.pipeP(g, f).length, 2); - eq(R.pipeP(g, g).length, 2); - - R.pipeP(f, g)(1).then(function(result) { - eq(result, [[1], undefined]); - - R.pipeP(g, f)(1).then(function(result) { - eq(result, [[1, undefined]]); - - R.pipeP(f, g)(1, 2).then(function(result) { - eq(result, [[1], undefined]); - - R.pipeP(g, f)(1, 2).then(function(result) { - eq(result, [[1, 2]]); - - done(); - })['catch'](done); - })['catch'](done); - })['catch'](done); - })['catch'](done); - }); - - it('throws if given no arguments', function() { - assert.throws( - function() { R.pipeP(); }, - function(err) { - return err.constructor === Error && - err.message === 'pipeP requires at least one argument'; - } - ); - }); - -}); diff --git a/test/transduce.js b/test/transduce.js index 6668e5b30f..4287a9c782 100644 --- a/test/transduce.js +++ b/test/transduce.js @@ -50,7 +50,7 @@ describe('transduce', function() { }); it('transduces into objects', function() { - eq(R.transduce(R.map(R.identity), R.merge, {}, [{a: 1}, {b: 2, c: 3}]), {a: 1, b: 2, c: 3}); + eq(R.transduce(R.map(R.identity), R.mergeRight, {}, [{a: 1}, {b: 2, c: 3}]), {a: 1, b: 2, c: 3}); }); it('folds transformer objects over a collection with the supplied accumulator', function() { From a31392a55853ef430bd51e7d7f8b81669be0447e Mon Sep 17 00:00:00 2001 From: Evan King <4539809+evan-king@users.noreply.github.com> Date: Tue, 3 Sep 2019 16:41:40 -0300 Subject: [PATCH 003/111] Switch `memoizeWith` exmple to using `Number` as key fuction. --- source/memoizeWith.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/memoizeWith.js b/source/memoizeWith.js index 8b6bd8eac8..ea0188ad93 100644 --- a/source/memoizeWith.js +++ b/source/memoizeWith.js @@ -24,7 +24,7 @@ import _has from './internal/_has'; * @example * * let count = 0; - * const factorial = R.memoizeWith(R.identity, n => { + * const factorial = R.memoizeWith(Number, n => { * count += 1; * return R.product(R.range(1, n + 1)); * }); From a256d1924db18a5dcd5cc6313c836e55da5415d0 Mon Sep 17 00:00:00 2001 From: adispring Date: Fri, 27 Dec 2019 11:37:24 +0800 Subject: [PATCH 004/111] optimize unionWith description: use first element from first list --- source/unionWith.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/unionWith.js b/source/unionWith.js index f1c30d47d5..698ce4cad6 100644 --- a/source/unionWith.js +++ b/source/unionWith.js @@ -6,7 +6,8 @@ import uniqWith from './uniqWith'; /** * Combines two lists into a set (i.e. no duplicates) composed of the elements * of each list. Duplication is determined according to the value returned by - * applying the supplied predicate to two list elements. + * applying the supplied predicate to two list elements. If an element exists + * in both lists, the first element from the first list will be used. * * @func * @memberOf R From bd1172e8bc8f5825cf86cb14de11e8e485aba6e8 Mon Sep 17 00:00:00 2001 From: Scott Sauyet Date: Sun, 29 Dec 2019 14:34:30 -0500 Subject: [PATCH 005/111] chaning like to Randy Coulman's series to HTTPS --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 2a1d8d3216..2259c36354 100644 --- a/README.md +++ b/README.md @@ -47,7 +47,7 @@ Introductions * [Favoring Curry](http://fr.umio.us/favoring-curry/) by Scott Sauyet * [Why Curry Helps](https://hughfdjackson.com/javascript/why-curry-helps/) by Hugh Jackson * [Hey Underscore, You're Doing It Wrong!](https://www.youtube.com/watch?v=m3svKOdZijA&app=desktop) by Brian Lonsdorf -* [Thinking in Ramda](http://randycoulman.com/blog/categories/thinking-in-ramda) by Randy Coulman +* [Thinking in Ramda](https://randycoulman.com/blog/categories/thinking-in-ramda) by Randy Coulman From dab5652a35b195797b6423e3b03567ab3832aed2 Mon Sep 17 00:00:00 2001 From: Josh Byster Date: Wed, 8 Jan 2020 04:25:52 -0600 Subject: [PATCH 006/111] Add clarifying to auto-curry --- source/compose.js | 1 + source/pipe.js | 1 + 2 files changed, 2 insertions(+) diff --git a/source/compose.js b/source/compose.js index 10429cc7ef..b920e82bdd 100644 --- a/source/compose.js +++ b/source/compose.js @@ -25,6 +25,7 @@ import reverse from './reverse'; * R.compose(Math.abs, R.add(1), R.multiply(2))(-4) //=> 7 * * @symb R.compose(f, g, h)(a, b) = f(g(h(a, b))) + * @symb R.compose(f, g, h)(a)(b) = f(g(h(a)))(b) */ export default function compose() { if (arguments.length === 0) { diff --git a/source/pipe.js b/source/pipe.js index ef8945e9a8..91decacc4c 100644 --- a/source/pipe.js +++ b/source/pipe.js @@ -26,6 +26,7 @@ import tail from './tail'; * * f(3, 4); // -(3^4) + 1 * @symb R.pipe(f, g, h)(a, b) = h(g(f(a, b))) + * @symb R.pipe(f, g, h)(a)(b) = h(g(f(a)))(b) */ export default function pipe() { if (arguments.length === 0) { From e91dcce5878361560e2d13e74ed4e38e6ccfb2a9 Mon Sep 17 00:00:00 2001 From: adispring Date: Wed, 22 Jan 2020 07:46:28 +0800 Subject: [PATCH 007/111] optimize call signature & its example's indent --- source/call.js | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/source/call.js b/source/call.js index 2ef23bbc4f..ae6aa1b044 100644 --- a/source/call.js +++ b/source/call.js @@ -12,7 +12,7 @@ import curry from './curry'; * @memberOf R * @since v0.9.0 * @category Function - * @sig (*... -> a),*... -> a + * @sig ((*... -> a), *...) -> a * @param {Function} fn The function to apply to the remaining arguments. * @param {...*} args Any number of positional arguments. * @return {*} @@ -21,14 +21,19 @@ import curry from './curry'; * * R.call(R.add, 1, 2); //=> 3 * - * const indentN = R.pipe(R.repeat(' '), - * R.join(''), - * R.replace(/^(?!$)/gm)); + * const indentN = R.pipe( + * R.repeat(' '), + * R.join(''), + * R.replace(/^(?!$)/gm) + * ); * - * const format = R.converge(R.call, [ - * R.pipe(R.prop('indent'), indentN), - * R.prop('value') - * ]); + * const format = R.converge( + * R.call, + * [ + * R.pipe(R.prop('indent'), indentN), + * R.prop('value') + * ] + * ); * * format({indent: 2, value: 'foo\nbar\nbaz\n'}); //=> ' foo\n bar\n baz\n' * @symb R.call(f, a, b) = f(a, b) From ecba3855382f7aeae0335ae9d7e1dfc9dc67d3ae Mon Sep 17 00:00:00 2001 From: adispring Date: Wed, 22 Jan 2020 16:08:37 +0800 Subject: [PATCH 008/111] wrap R.call with _curry1 instead of curry --- source/call.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/call.js b/source/call.js index ae6aa1b044..d654db5339 100644 --- a/source/call.js +++ b/source/call.js @@ -1,4 +1,4 @@ -import curry from './curry'; +import _curry1 from './internal/_curry1'; /** @@ -38,7 +38,7 @@ import curry from './curry'; * format({indent: 2, value: 'foo\nbar\nbaz\n'}); //=> ' foo\n bar\n baz\n' * @symb R.call(f, a, b) = f(a, b) */ -var call = curry(function call(fn) { +var call = _curry1(function call(fn) { return fn.apply(this, Array.prototype.slice.call(arguments, 1)); }); export default call; From 13ea6c5532d30e8360a732237bf5b6cd977713a8 Mon Sep 17 00:00:00 2001 From: Kuba Juszczyk Date: Sat, 25 Jan 2020 16:56:25 +0100 Subject: [PATCH 009/111] optimize "prop" --- source/prop.js | 10 ++++++++-- source/propOr.js | 5 +++-- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/source/prop.js b/source/prop.js index 7602c94e68..424858accf 100644 --- a/source/prop.js +++ b/source/prop.js @@ -1,5 +1,6 @@ import _curry2 from './internal/_curry2'; -import path from './path'; +import _isInteger from './internal/_isInteger'; +import nth from './nth'; /** @@ -24,5 +25,10 @@ import path from './path'; * R.compose(R.inc, R.prop('x'))({ x: 3 }) //=> 4 */ -var prop = _curry2(function prop(p, obj) { return path([p], obj); }); +var prop = _curry2(function prop(p, obj) { + if (obj == null) { + return; + } + return _isInteger(p) ? nth(p, obj) : obj[p]; +}); export default prop; diff --git a/source/propOr.js b/source/propOr.js index 10413153a5..ce22e62b86 100644 --- a/source/propOr.js +++ b/source/propOr.js @@ -1,5 +1,6 @@ import _curry3 from './internal/_curry3'; -import pathOr from './pathOr'; +import defaultTo from './defaultTo'; +import prop from './prop'; /** @@ -29,6 +30,6 @@ import pathOr from './pathOr'; * favoriteWithDefault(alice); //=> 'Ramda' */ var propOr = _curry3(function propOr(val, p, obj) { - return pathOr(val, [p], obj); + return defaultTo(val, prop(p, obj)); }); export default propOr; From 240797b3150f2619370a5ef481ff02eec7eb82b8 Mon Sep 17 00:00:00 2001 From: adispring Date: Sun, 26 Jan 2020 18:29:20 +0800 Subject: [PATCH 010/111] optimize andThen and otherwise's example --- source/andThen.js | 10 +++++++--- source/otherwise.js | 14 +++++++------- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/source/andThen.js b/source/andThen.js index 2153704ae2..a348b8d353 100644 --- a/source/andThen.js +++ b/source/andThen.js @@ -18,14 +18,18 @@ import _assertPromise from './internal/_assertPromise'; * @see R.otherwise * @example * - * var makeQuery = (email) => ({ query: { email }}); + * const makeQuery = email => ({ query: { email }}); + * const fetchMember = request => + * Promise.resolve({ firstName: 'Bob', lastName: 'Loblaw', id: 42 }); * - * //getMemberName :: String -> Promise ({firstName, lastName}) - * var getMemberName = R.pipe( + * //getMemberName :: String -> Promise ({ firstName, lastName }) + * const getMemberName = R.pipe( * makeQuery, * fetchMember, * R.andThen(R.pick(['firstName', 'lastName'])) * ); + * + * getMemberName('bob@gmail.com').then(console.log); */ var andThen = _curry2(function andThen(f, p) { _assertPromise('andThen', p); diff --git a/source/otherwise.js b/source/otherwise.js index ff67ebc787..d68a1a0d51 100644 --- a/source/otherwise.js +++ b/source/otherwise.js @@ -16,19 +16,19 @@ import _assertPromise from './internal/_assertPromise'; * @param {Function} onFailure The function to apply. Can return a value or a promise of a value. * @param {Promise} p * @return {Promise} The result of calling `p.then(null, onFailure)` - * @see R.then + * @see R.andThen * @example * - * var failedFetch = (id) => Promise.reject('bad ID'); - * var useDefault = () => ({ firstName: 'Bob', lastName: 'Loblaw' }) + * const failedFetch = id => Promise.reject('bad ID'); + * const useDefault = () => ({ firstName: 'Bob', lastName: 'Loblaw' }); * - * //recoverFromFailure :: String -> Promise ({firstName, lastName}) - * var recoverFromFailure = R.pipe( + * //recoverFromFailure :: String -> Promise ({ firstName, lastName }) + * const recoverFromFailure = R.pipe( * failedFetch, * R.otherwise(useDefault), - * R.then(R.pick(['firstName', 'lastName'])), + * R.andThen(R.pick(['firstName', 'lastName'])), * ); - * recoverFromFailure(12345).then(console.log) + * recoverFromFailure(12345).then(console.log); */ var otherwise = _curry2(function otherwise(f, p) { _assertPromise('otherwise', p); From 23f1fa986b164f377f74986f934b5af5edd36337 Mon Sep 17 00:00:00 2001 From: ryanbas21 Date: Sat, 1 Feb 2020 18:07:28 -0700 Subject: [PATCH 011/111] update try catch docs to use caught instead of catched --- source/tryCatch.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/source/tryCatch.js b/source/tryCatch.js index 8164c6471c..5960751dad 100644 --- a/source/tryCatch.js +++ b/source/tryCatch.js @@ -21,7 +21,8 @@ import _curry2 from './internal/_curry2'; * @example * * R.tryCatch(R.prop('x'), R.F)({x: true}); //=> true - * R.tryCatch(() => { throw 'foo'}, R.always('catched'))('bar') // => 'catched' + * R.tryCatch(() => { throw 'foo'}, R.always('caught'))('bar') // => + * 'caught' * R.tryCatch(R.times(R.identity), R.always([]))('s') // => [] */ var tryCatch = _curry2(function _tryCatch(tryer, catcher) { From 51bddb437a272e65a552dcbe54b86892d1af606d Mon Sep 17 00:00:00 2001 From: Kuba Juszczyk Date: Mon, 3 Feb 2020 22:07:25 +0100 Subject: [PATCH 012/111] add tests --- test/prop.js | 30 ++++++++++++++++++++++++++++++ test/propOr.js | 35 +++++++++++++++++++++++++++++++++++ 2 files changed, 65 insertions(+) diff --git a/test/prop.js b/test/prop.js index 1c9e2a58eb..36c30701fc 100644 --- a/test/prop.js +++ b/test/prop.js @@ -11,6 +11,36 @@ describe('prop', function() { eq(nm(fred), 'Fred'); }); + it('shows the same behaviour as path for a nonexistent property', function() { + var propResult = R.prop('incorrect', fred); + var pathResult = R.path(['incorrect'], fred); + eq(propResult, pathResult); + }) + + it('shows the same behaviour as path for an undefined property', function() { + var propResult = R.prop(undefined, fred); + var pathResult = R.path([undefined], fred); + eq(propResult, pathResult); + }) + + it('shows the same behaviour as path for a null property', function() { + var propResult = R.prop(null, fred); + var pathResult = R.path([null], fred); + eq(propResult, pathResult); + }) + + it('shows the same behaviour as path for a valid property and object', function() { + var propResult = R.prop('age', fred); + var pathResult = R.path(['age'], fred); + eq(propResult, pathResult); + }) + + it('shows the same behaviour as path for a null object', function() { + var propResult = R.prop('age', null); + var pathResult = R.path(['age'], null); + eq(propResult, pathResult); + }) + it('shows the same behaviour as path for an undefined object', function() { var propResult, propException, pathResult, pathException; try { diff --git a/test/propOr.js b/test/propOr.js index 7520591718..28a15a2edb 100644 --- a/test/propOr.js +++ b/test/propOr.js @@ -27,4 +27,39 @@ describe('propOr', function() { eq(R.propOr('foo', 'x', {x: undefined}), 'foo'); }); + it('shows the same behaviour as path for a nonexistent property', function() { + var propOrResult = R.propOr('Unknown', 'incorrect', fred); + var pathOrResult = R.pathOr('Unknown', ['incorrect'], fred); + eq(propOrResult, pathOrResult); + }) + + it('shows the same behaviour as path for an undefined property', function() { + var propOrResult = R.propOr('Unknown', undefined, fred); + var pathOrResult = R.pathOr('Unknown', [undefined], fred); + eq(propOrResult, pathOrResult); + }) + + it('shows the same behaviour as path for a null property', function() { + var propOrResult = R.propOr('Unknown', null, fred); + var pathOrResult = R.pathOr('Unknown', [null], fred); + eq(propOrResult, pathOrResult); + }) + + it('shows the same behaviour as path for a valid property and object', function() { + var propOrResult = R.propOr('Unknown', 'age', fred); + var pathOrResult = R.pathOr('Unknown', ['age'], fred); + eq(propOrResult, pathOrResult); + }) + + it('shows the same behaviour as path for a null object', function() { + var propOrResult = R.propOr('Unknown', 'age', null); + var pathOrResult = R.pathOr('Unknown', ['age'], null); + eq(propOrResult, pathOrResult); + }) + + it('shows the same behaviour as path for an undefined object', function() { + var propOrResult = R.propOr('Unknown', 'age', undefined); + var pathOrResult = R.pathOr('Unknown', ['age'], undefined); + eq(propOrResult, pathOrResult); + }); }); From f685ff57e7cfea21f693369db52f01361a13d214 Mon Sep 17 00:00:00 2001 From: Kuba Juszczyk Date: Mon, 3 Feb 2020 22:12:32 +0100 Subject: [PATCH 013/111] fix linter --- test/prop.js | 10 +++++----- test/propOr.js | 22 +++++++++++----------- 2 files changed, 16 insertions(+), 16 deletions(-) diff --git a/test/prop.js b/test/prop.js index 36c30701fc..57acb41365 100644 --- a/test/prop.js +++ b/test/prop.js @@ -15,31 +15,31 @@ describe('prop', function() { var propResult = R.prop('incorrect', fred); var pathResult = R.path(['incorrect'], fred); eq(propResult, pathResult); - }) + }); it('shows the same behaviour as path for an undefined property', function() { var propResult = R.prop(undefined, fred); var pathResult = R.path([undefined], fred); eq(propResult, pathResult); - }) + }); it('shows the same behaviour as path for a null property', function() { var propResult = R.prop(null, fred); var pathResult = R.path([null], fred); eq(propResult, pathResult); - }) + }); it('shows the same behaviour as path for a valid property and object', function() { var propResult = R.prop('age', fred); var pathResult = R.path(['age'], fred); eq(propResult, pathResult); - }) + }); it('shows the same behaviour as path for a null object', function() { var propResult = R.prop('age', null); var pathResult = R.path(['age'], null); eq(propResult, pathResult); - }) + }); it('shows the same behaviour as path for an undefined object', function() { var propResult, propException, pathResult, pathException; diff --git a/test/propOr.js b/test/propOr.js index 28a15a2edb..8cdd1f2eb6 100644 --- a/test/propOr.js +++ b/test/propOr.js @@ -27,37 +27,37 @@ describe('propOr', function() { eq(R.propOr('foo', 'x', {x: undefined}), 'foo'); }); - it('shows the same behaviour as path for a nonexistent property', function() { + it('shows the same behaviour as pathOr for a nonexistent property', function() { var propOrResult = R.propOr('Unknown', 'incorrect', fred); var pathOrResult = R.pathOr('Unknown', ['incorrect'], fred); eq(propOrResult, pathOrResult); - }) + }); - it('shows the same behaviour as path for an undefined property', function() { + it('shows the same behaviour as pathOr for an undefined property', function() { var propOrResult = R.propOr('Unknown', undefined, fred); var pathOrResult = R.pathOr('Unknown', [undefined], fred); eq(propOrResult, pathOrResult); - }) + }); - it('shows the same behaviour as path for a null property', function() { + it('shows the same behaviour as pathOr for a null property', function() { var propOrResult = R.propOr('Unknown', null, fred); var pathOrResult = R.pathOr('Unknown', [null], fred); eq(propOrResult, pathOrResult); - }) + }); - it('shows the same behaviour as path for a valid property and object', function() { + it('shows the same behaviour as pathOr for a valid property and object', function() { var propOrResult = R.propOr('Unknown', 'age', fred); var pathOrResult = R.pathOr('Unknown', ['age'], fred); eq(propOrResult, pathOrResult); - }) + }); - it('shows the same behaviour as path for a null object', function() { + it('shows the same behaviour as pathOr for a null object', function() { var propOrResult = R.propOr('Unknown', 'age', null); var pathOrResult = R.pathOr('Unknown', ['age'], null); eq(propOrResult, pathOrResult); - }) + }); - it('shows the same behaviour as path for an undefined object', function() { + it('shows the same behaviour as pathOr for an undefined object', function() { var propOrResult = R.propOr('Unknown', 'age', undefined); var pathOrResult = R.pathOr('Unknown', ['age'], undefined); eq(propOrResult, pathOrResult); From 59336454d601e6f0f70b6eaa9886bbd3dac76da8 Mon Sep 17 00:00:00 2001 From: adispring Date: Wed, 12 Feb 2020 14:44:46 +0800 Subject: [PATCH 014/111] fix comment typo: compose -> composeWith --- source/composeWith.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/composeWith.js b/source/composeWith.js index ae10ed618d..b1a5e95a74 100644 --- a/source/composeWith.js +++ b/source/composeWith.js @@ -7,8 +7,8 @@ import reverse from './reverse'; * Performs right-to-left function composition using transforming function. The last argument may have * any arity; the remaining arguments must be unary. * - * **Note:** The result of compose is not automatically curried. Transforming function is not used on the - * last argument. + * **Note:** The result of composeWith is not automatically curried. Transforming function is not used + * on the last argument. * * @func * @memberOf R From a7e5e2a67978e4c1dca91991adf197c8a92308b4 Mon Sep 17 00:00:00 2001 From: adispring Date: Thu, 13 Feb 2020 09:34:33 +0800 Subject: [PATCH 015/111] optimize pipeWith and composeWith's description and @param --- source/composeWith.js | 7 ++++--- source/pipeWith.js | 7 ++++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/source/composeWith.js b/source/composeWith.js index b1a5e95a74..817aa6c459 100644 --- a/source/composeWith.js +++ b/source/composeWith.js @@ -4,8 +4,8 @@ import reverse from './reverse'; /** - * Performs right-to-left function composition using transforming function. The last argument may have - * any arity; the remaining arguments must be unary. + * Performs right-to-left function composition using transforming function. The last function may have + * any arity; the remaining functions must be unary. * * **Note:** The result of composeWith is not automatically curried. Transforming function is not used * on the last argument. @@ -15,7 +15,8 @@ import reverse from './reverse'; * @since v0.26.0 * @category Function * @sig ((* -> *), [(y -> z), (x -> y), ..., (o -> p), ((a, b, ..., n) -> o)]) -> ((a, b, ..., n) -> z) - * @param {...Function} ...functions The functions to compose + * @param {Function} transformer The transforming function + * @param {Array} functions The functions to compose * @return {Function} * @see R.compose, R.pipeWith * @example diff --git a/source/pipeWith.js b/source/pipeWith.js index eccee25cdf..beb17d99ce 100644 --- a/source/pipeWith.js +++ b/source/pipeWith.js @@ -7,8 +7,8 @@ import identity from './identity'; /** - * Performs left-to-right function composition using transforming function. The first argument may have - * any arity; the remaining arguments must be unary. + * Performs left-to-right function composition using transforming function. The first function may have + * any arity; the remaining functions must be unary. * * **Note:** The result of pipeWith is not automatically curried. Transforming function is not used on the * first argument. @@ -18,7 +18,8 @@ import identity from './identity'; * @since v0.26.0 * @category Function * @sig ((* -> *), [((a, b, ..., n) -> o), (o -> p), ..., (x -> y), (y -> z)]) -> ((a, b, ..., n) -> z) - * @param {...Function} functions + * @param {Function} transformer The transforming function + * @param {Array} functions The functions to pipe * @return {Function} * @see R.composeWith, R.pipe * @example From d7b335649ffb313987a1592f9b0707ca70499454 Mon Sep 17 00:00:00 2001 From: Kuba Juszczyk Date: Sat, 15 Feb 2020 11:12:59 +0100 Subject: [PATCH 016/111] add number property tests to prop* and fix propIs (when property is number) --- source/propIs.js | 3 ++- test/prop.js | 8 ++++++++ test/propEq.js | 9 +++++++++ test/propIs.js | 9 +++++++++ test/propOr.js | 9 +++++++++ 5 files changed, 37 insertions(+), 1 deletion(-) diff --git a/source/propIs.js b/source/propIs.js index 46f31ae559..236511785d 100644 --- a/source/propIs.js +++ b/source/propIs.js @@ -1,4 +1,5 @@ import _curry3 from './internal/_curry3'; +import prop from './prop'; import is from './is'; @@ -23,6 +24,6 @@ import is from './is'; * R.propIs(Number, 'x', {}); //=> false */ var propIs = _curry3(function propIs(type, name, obj) { - return is(type, obj[name]); + return is(type, prop(name, obj)); }); export default propIs; diff --git a/test/prop.js b/test/prop.js index 57acb41365..b941d70c8d 100644 --- a/test/prop.js +++ b/test/prop.js @@ -11,6 +11,14 @@ describe('prop', function() { eq(nm(fred), 'Fred'); }); + it('handles number as property', function() { + var deities = ['Cthulhu', 'Dagon', 'Yog-Sothoth']; + eq(R.prop(0, deities), 'Cthulhu'); + eq(R.prop(1, deities), 'Dagon'); + eq(R.prop(2, deities), 'Yog-Sothoth'); + eq(R.prop(-1, deities), 'Yog-Sothoth'); + }); + it('shows the same behaviour as path for a nonexistent property', function() { var propResult = R.prop('incorrect', fred); var pathResult = R.path(['incorrect'], fred); diff --git a/test/propEq.js b/test/propEq.js index 8c8c4b367f..de22e267d8 100644 --- a/test/propEq.js +++ b/test/propEq.js @@ -12,6 +12,15 @@ describe('propEq', function() { eq(R.propEq('hair', 'blond', obj2), false); }); + it('handles number as property', function() { + var deities = ['Cthulhu', 'Dagon', 'Yog-Sothoth']; + eq(R.propEq(0, 'Cthulhu', deities), true); + eq(R.propEq(1, 'Dagon', deities), true); + eq(R.propEq(2, 'Yog-Sothoth', deities), true); + eq(R.propEq(-1, 'Yog-Sothoth', deities), true); + eq(R.propEq(3, undefined, deities), true); + }); + it('has R.equals semantics', function() { function Just(x) { this.value = x; } Just.prototype.equals = function(x) { diff --git a/test/propIs.js b/test/propIs.js index c932ea7bba..12c4e15b30 100644 --- a/test/propIs.js +++ b/test/propIs.js @@ -13,4 +13,13 @@ describe('propIs', function() { eq(R.propIs(String, 'value', {}), false); }); + it('handles number as property', function() { + var deities = ['Cthulhu', 'Dagon', 'Yog-Sothoth']; + eq(R.propIs(String, 0, deities), true); + eq(R.propIs(String, 1, deities), true); + eq(R.propIs(String, 2, deities), true); + eq(R.propIs(String, -1, deities), true); + eq(R.propIs(String, 3, deities), false); + }); + }); diff --git a/test/propOr.js b/test/propOr.js index 8cdd1f2eb6..72bf8f367c 100644 --- a/test/propOr.js +++ b/test/propOr.js @@ -27,6 +27,15 @@ describe('propOr', function() { eq(R.propOr('foo', 'x', {x: undefined}), 'foo'); }); + it('handles number as property', function() { + var deities = ['Cthulhu', 'Dagon', 'Yog-Sothoth']; + eq(R.propOr('Unknown', 0, deities), 'Cthulhu'); + eq(R.propOr('Unknown', 1, deities), 'Dagon'); + eq(R.propOr('Unknown', 2, deities), 'Yog-Sothoth'); + eq(R.propOr('Unknown', -1, deities), 'Yog-Sothoth'); + eq(R.propOr('Unknown', 3, deities), 'Unknown'); + }); + it('shows the same behaviour as pathOr for a nonexistent property', function() { var propOrResult = R.propOr('Unknown', 'incorrect', fred); var pathOrResult = R.pathOr('Unknown', ['incorrect'], fred); From db51f107ba080d25a3938ab87a66a9079d908ad7 Mon Sep 17 00:00:00 2001 From: Kuba Juszczyk Date: Wed, 19 Feb 2020 19:51:42 +0100 Subject: [PATCH 017/111] hasIn: added protection against undefined object (#2986) --- source/hasIn.js | 4 ++++ test/hasIn.js | 4 ++++ 2 files changed, 8 insertions(+) diff --git a/source/hasIn.js b/source/hasIn.js index 2286e83aca..1f46a91252 100644 --- a/source/hasIn.js +++ b/source/hasIn.js @@ -1,4 +1,5 @@ import _curry2 from './internal/_curry2'; +import isNil from './isNil'; /** @@ -28,6 +29,9 @@ import _curry2 from './internal/_curry2'; * R.hasIn('area', square); //=> true */ var hasIn = _curry2(function hasIn(prop, obj) { + if (isNil(obj)) { + return false; + } return prop in obj; }); export default hasIn; diff --git a/test/hasIn.js b/test/hasIn.js index 4837f946e4..cb702cfb3b 100644 --- a/test/hasIn.js +++ b/test/hasIn.js @@ -26,4 +26,8 @@ describe('hasIn', function() { eq(R.hasIn('name', anon), false); }); + it('returns false when non-existent object', function() { + eq(R.hasIn('name', null), false); + eq(R.hasIn('name', undefined), false); + }); }); From 17641ec74c7c7f59e6de098604ebd5bfb9f31bdb Mon Sep 17 00:00:00 2001 From: adispring Date: Thu, 20 Feb 2020 22:47:45 +0800 Subject: [PATCH 018/111] add @see: R.view and R.set --- source/set.js | 2 +- source/view.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source/set.js b/source/set.js index 62d2186aac..368607c25d 100644 --- a/source/set.js +++ b/source/set.js @@ -17,7 +17,7 @@ import over from './over'; * @param {*} v * @param {*} x * @return {*} - * @see R.prop, R.lensIndex, R.lensProp + * @see R.view, R.prop, R.lensIndex, R.lensProp * @example * * const xLens = R.lensProp('x'); diff --git a/source/view.js b/source/view.js index e11415a844..76323bfb94 100644 --- a/source/view.js +++ b/source/view.js @@ -19,7 +19,7 @@ var Const = function(x) { * @param {Lens} lens * @param {*} x * @return {*} - * @see R.prop, R.lensIndex, R.lensProp + * @see R.set, R.prop, R.lensIndex, R.lensProp * @example * * const xLens = R.lensProp('x'); From 0eef132d02aaa324588fd7262488cea649b21499 Mon Sep 17 00:00:00 2001 From: adispring Date: Fri, 21 Feb 2020 09:42:13 +0800 Subject: [PATCH 019/111] view, set, over: add @see to each other. --- source/over.js | 2 +- source/set.js | 2 +- source/view.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/source/over.js b/source/over.js index 4e74dbaa6d..ecf036a1d0 100644 --- a/source/over.js +++ b/source/over.js @@ -22,7 +22,7 @@ var Identity = function(x) { * @param {*} v * @param {*} x * @return {*} - * @see R.prop, R.lensIndex, R.lensProp + * @see R.view, R.set, R.lens, R.lensIndex, R.lensProp, R.lensPath * @example * * const headLens = R.lensIndex(0); diff --git a/source/set.js b/source/set.js index 368607c25d..e7c3be5058 100644 --- a/source/set.js +++ b/source/set.js @@ -17,7 +17,7 @@ import over from './over'; * @param {*} v * @param {*} x * @return {*} - * @see R.view, R.prop, R.lensIndex, R.lensProp + * @see R.view, R.over, R.lens, R.lensIndex, R.lensProp, R.lensPath * @example * * const xLens = R.lensProp('x'); diff --git a/source/view.js b/source/view.js index 76323bfb94..7dcfdca6dc 100644 --- a/source/view.js +++ b/source/view.js @@ -19,7 +19,7 @@ var Const = function(x) { * @param {Lens} lens * @param {*} x * @return {*} - * @see R.set, R.prop, R.lensIndex, R.lensProp + * @see R.set, R.over, R.lens, R.lensIndex, R.lensProp, R.lensPath * @example * * const xLens = R.lensProp('x'); From 332195ecf9239459a371d9b4ef8f19f293a0ed0f Mon Sep 17 00:00:00 2001 From: Rafael Calderon <33050889+wirecobweb@users.noreply.github.com> Date: Fri, 28 Feb 2020 15:32:21 +0100 Subject: [PATCH 020/111] update README.md (#2990) translation to Spanish --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index 2259c36354..0e50e1f06f 100644 --- a/README.md +++ b/README.md @@ -239,6 +239,8 @@ Translations - [Ukrainian(Українська)](https://github.com/ivanzusko/ramda) - [Portuguese(BR)](https://github.com/renansj/ramda) - [Russian(Русский)](https://github.com/Guck111/ramda) +- [Spanish(ES)](https://github.com/wirecobweb/ramda) + From 5b0ea82c88f0b50ffd5a013f7d64a4d6822dcf8d Mon Sep 17 00:00:00 2001 From: Scott Sauyet Date: Wed, 4 Mar 2020 20:01:25 -0500 Subject: [PATCH 021/111] Replace defaultTo with undefined check in pathOr (#2888) * Replace defaultTo with undefined check in pathOr * Add errors to handle different undefined cases --- source/path.js | 6 +++++- source/pathOr.js | 10 +++++---- source/paths.js | 26 ++++++++++++++++++++++-- test/path.js | 4 ++-- test/pathOr.js | 4 ++-- test/paths.js | 53 ++++++++++++++++++++++++++++++++++++++++++------ test/propOr.js | 6 +++--- 7 files changed, 89 insertions(+), 20 deletions(-) diff --git a/source/path.js b/source/path.js index 0aee92a4c4..4f289c8bfd 100644 --- a/source/path.js +++ b/source/path.js @@ -23,6 +23,10 @@ import paths from './paths'; */ var path = _curry2(function path(pathAr, obj) { - return paths([pathAr], obj)[0]; + try { + return paths([pathAr], obj)[0]; + } catch (e) { + return undefined; + } }); export default path; diff --git a/source/pathOr.js b/source/pathOr.js index c4b2128fbe..68a96f939c 100644 --- a/source/pathOr.js +++ b/source/pathOr.js @@ -1,7 +1,5 @@ import _curry3 from './internal/_curry3'; -import defaultTo from './defaultTo'; -import path from './path'; - +import paths from './paths'; /** * If the given, non-null object has a value at the given path, returns the @@ -23,6 +21,10 @@ import path from './path'; * R.pathOr('N/A', ['a', 'b'], {c: {b: 2}}); //=> "N/A" */ var pathOr = _curry3(function pathOr(d, p, obj) { - return defaultTo(d, path(p, obj)); + try { + return paths([p], obj)[0]; + } catch (e) { + return d; + } }); export default pathOr; diff --git a/source/paths.js b/source/paths.js index 871233dcbd..c6c779e096 100644 --- a/source/paths.js +++ b/source/paths.js @@ -26,11 +26,33 @@ var paths = _curry2(function paths(pathsArray, obj) { var p; while (idx < paths.length) { if (val == null) { - return; + throw new Error('Specified path not in object2'); } + p = paths[idx]; - val = _isInteger(p) ? nth(p, val) : val[p]; + + if ( + _isInteger(p) && + Array.isArray(val) && + ( + (p < 0 && (val.length >= Math.abs(p))) || + (p >= 0 && p < val.length) + ) + ) { + // nth is only intended to be used on arrays. + // Have to check array bounds because nth returns + // undefined when the value is not in the list + // and when the index is out of the range + val = nth(p, val); + } else if ( + val instanceof Object && + p in val) { + val = val[p]; + } else { + throw new Error('Specified path not in object'); + } idx += 1; + } return val; }); diff --git a/test/path.js b/test/path.js index 49e3a393a8..adf666ee28 100644 --- a/test/path.js +++ b/test/path.js @@ -54,8 +54,8 @@ describe('path', function() { eq(R.path(['a', 'b'], {a: null}), undefined); }); - it('works with falsy items', function() { - eq(R.path(['toString'], false), Boolean.prototype.toString); + it('returns undefined for non-object items', function() { + eq(R.path(['toString'], false), undefined); }); }); diff --git a/test/pathOr.js b/test/pathOr.js index 407e52d969..d70633ef0b 100644 --- a/test/pathOr.js +++ b/test/pathOr.js @@ -44,8 +44,8 @@ describe('pathOr', function() { eq(R.pathOr('Unknown', ['toString'], undefined), 'Unknown'); }); - it('works with falsy items', function() { - eq(R.pathOr('Unknown', ['toString'], false), Boolean.prototype.toString); + it('returns the default for non-object items', function() { + eq(R.pathOr('Unknown', ['toString'], false), 'Unknown'); }); }); diff --git a/test/paths.js b/test/paths.js index f0fc7962c2..b35c543492 100644 --- a/test/paths.js +++ b/test/paths.js @@ -1,3 +1,5 @@ +var assert = require('assert'); + var R = require('../source'); var eq = require('./shared/eq'); @@ -17,17 +19,20 @@ describe('paths', function() { }; it('takes paths and returns values at those paths', function() { eq(R.paths([['a', 'b', 'c'], ['x', 'y']], obj), [1, 'Alice']); - eq(R.paths([['a', 'b', 'd'], ['p', 'q']], obj), [2, undefined]); + assert.throws(function() { + R.paths([['a', 'b', 'd'], ['p', 'q']], obj); + }, function(err) { + return (err instanceof Error && + err.message === 'Specified path not in object'); + }); }); it('takes a paths that contains indices into arrays', function() { eq(R.paths([['p', 0, 'q'], ['x', 'z', 0, 0]], obj), [3, {}]); - eq(R.paths([['p', 0, 'q'], ['x', 'z', 2, 1]], obj), [3, undefined]); }); it('takes a path that contains negative indices into arrays', function() { eq(R.paths([['p', -2, 'q'], ['p', -1]], obj), [3, 'Hi']); - eq(R.paths([['p', -4, 'q'], ['x', 'z', -1, 0]], obj), [undefined, {}]); }); it("gets a deep property's value from objects", function() { @@ -35,9 +40,45 @@ describe('paths', function() { eq(R.paths([['p', 0]], obj), [obj.p[0]]); }); - it('returns undefined for items not found', function() { - eq(R.paths([['a', 'x', 'y']], obj), [undefined]); - eq(R.paths([['p', 2]], obj), [undefined]); + it('throws an error for items not found in an object', function() { + assert.throws(function() { + R.paths([['a', 'x', 'y']], obj); + }, function(err) { + return (err instanceof Error && + err.message === 'Specified path not in object'); + }); + + assert.throws(function() { + R.paths([['p', 0, 'q'], ['x', 'z', 2, 1]], obj); + }, function(err) { + return (err instanceof Error && + err.message === 'Specified path not in object'); + }); + + assert.throws(function() { + R.paths([['p', -4, 'q'], ['x', 'z', -1, 0]], obj); + }, function(err) { + return (err instanceof Error && + err.message === 'Specified path not in object'); + }); + }); + + it('does not index into strings values', function() { + assert.throws(function() { + R.paths([['x', 'y', 1]], obj); + }, function(err) { + return (err instanceof Error && + err.message === 'Specified path not in object'); + }); + }); + + it('raises an error for items not found in a list', function() { + assert.throws(function() { + eq(R.paths([['p', 2]], obj), [undefined]); + }, function(err) { + return (err instanceof Error && + err.message === 'Specified path not in object'); + }); }); }); diff --git a/test/propOr.js b/test/propOr.js index 72bf8f367c..89acaf89b8 100644 --- a/test/propOr.js +++ b/test/propOr.js @@ -22,9 +22,9 @@ describe('propOr', function() { eq(nm(void 0), 'Unknown'); }); - it('uses the default when supplied an object with a nil value', function() { - eq(R.propOr('foo', 'x', {x: null}), 'foo'); - eq(R.propOr('foo', 'x', {x: undefined}), 'foo'); + it('returns the value when supplied an object with a nil value', function() { + eq(R.propOr('foo', 'x', {x: null}), null); + eq(R.propOr('foo', 'x', {x: undefined}), undefined); }); it('handles number as property', function() { From db109735aa70fb76f8eae7153466d416d1b8663d Mon Sep 17 00:00:00 2001 From: "Brad Compton (he/him)" Date: Sun, 8 Mar 2020 11:42:08 -0700 Subject: [PATCH 022/111] Revert "Replace defaultTo with undefined check in pathOr (#2888)" This reverts commit 5b0ea82c88f0b50ffd5a013f7d64a4d6822dcf8d. --- source/path.js | 6 +----- source/pathOr.js | 10 ++++----- source/paths.js | 26 ++---------------------- test/path.js | 4 ++-- test/pathOr.js | 4 ++-- test/paths.js | 53 ++++++------------------------------------------ test/propOr.js | 6 +++--- 7 files changed, 20 insertions(+), 89 deletions(-) diff --git a/source/path.js b/source/path.js index 4f289c8bfd..0aee92a4c4 100644 --- a/source/path.js +++ b/source/path.js @@ -23,10 +23,6 @@ import paths from './paths'; */ var path = _curry2(function path(pathAr, obj) { - try { - return paths([pathAr], obj)[0]; - } catch (e) { - return undefined; - } + return paths([pathAr], obj)[0]; }); export default path; diff --git a/source/pathOr.js b/source/pathOr.js index 68a96f939c..c4b2128fbe 100644 --- a/source/pathOr.js +++ b/source/pathOr.js @@ -1,5 +1,7 @@ import _curry3 from './internal/_curry3'; -import paths from './paths'; +import defaultTo from './defaultTo'; +import path from './path'; + /** * If the given, non-null object has a value at the given path, returns the @@ -21,10 +23,6 @@ import paths from './paths'; * R.pathOr('N/A', ['a', 'b'], {c: {b: 2}}); //=> "N/A" */ var pathOr = _curry3(function pathOr(d, p, obj) { - try { - return paths([p], obj)[0]; - } catch (e) { - return d; - } + return defaultTo(d, path(p, obj)); }); export default pathOr; diff --git a/source/paths.js b/source/paths.js index c6c779e096..871233dcbd 100644 --- a/source/paths.js +++ b/source/paths.js @@ -26,33 +26,11 @@ var paths = _curry2(function paths(pathsArray, obj) { var p; while (idx < paths.length) { if (val == null) { - throw new Error('Specified path not in object2'); + return; } - p = paths[idx]; - - if ( - _isInteger(p) && - Array.isArray(val) && - ( - (p < 0 && (val.length >= Math.abs(p))) || - (p >= 0 && p < val.length) - ) - ) { - // nth is only intended to be used on arrays. - // Have to check array bounds because nth returns - // undefined when the value is not in the list - // and when the index is out of the range - val = nth(p, val); - } else if ( - val instanceof Object && - p in val) { - val = val[p]; - } else { - throw new Error('Specified path not in object'); - } + val = _isInteger(p) ? nth(p, val) : val[p]; idx += 1; - } return val; }); diff --git a/test/path.js b/test/path.js index adf666ee28..49e3a393a8 100644 --- a/test/path.js +++ b/test/path.js @@ -54,8 +54,8 @@ describe('path', function() { eq(R.path(['a', 'b'], {a: null}), undefined); }); - it('returns undefined for non-object items', function() { - eq(R.path(['toString'], false), undefined); + it('works with falsy items', function() { + eq(R.path(['toString'], false), Boolean.prototype.toString); }); }); diff --git a/test/pathOr.js b/test/pathOr.js index d70633ef0b..407e52d969 100644 --- a/test/pathOr.js +++ b/test/pathOr.js @@ -44,8 +44,8 @@ describe('pathOr', function() { eq(R.pathOr('Unknown', ['toString'], undefined), 'Unknown'); }); - it('returns the default for non-object items', function() { - eq(R.pathOr('Unknown', ['toString'], false), 'Unknown'); + it('works with falsy items', function() { + eq(R.pathOr('Unknown', ['toString'], false), Boolean.prototype.toString); }); }); diff --git a/test/paths.js b/test/paths.js index b35c543492..f0fc7962c2 100644 --- a/test/paths.js +++ b/test/paths.js @@ -1,5 +1,3 @@ -var assert = require('assert'); - var R = require('../source'); var eq = require('./shared/eq'); @@ -19,20 +17,17 @@ describe('paths', function() { }; it('takes paths and returns values at those paths', function() { eq(R.paths([['a', 'b', 'c'], ['x', 'y']], obj), [1, 'Alice']); - assert.throws(function() { - R.paths([['a', 'b', 'd'], ['p', 'q']], obj); - }, function(err) { - return (err instanceof Error && - err.message === 'Specified path not in object'); - }); + eq(R.paths([['a', 'b', 'd'], ['p', 'q']], obj), [2, undefined]); }); it('takes a paths that contains indices into arrays', function() { eq(R.paths([['p', 0, 'q'], ['x', 'z', 0, 0]], obj), [3, {}]); + eq(R.paths([['p', 0, 'q'], ['x', 'z', 2, 1]], obj), [3, undefined]); }); it('takes a path that contains negative indices into arrays', function() { eq(R.paths([['p', -2, 'q'], ['p', -1]], obj), [3, 'Hi']); + eq(R.paths([['p', -4, 'q'], ['x', 'z', -1, 0]], obj), [undefined, {}]); }); it("gets a deep property's value from objects", function() { @@ -40,45 +35,9 @@ describe('paths', function() { eq(R.paths([['p', 0]], obj), [obj.p[0]]); }); - it('throws an error for items not found in an object', function() { - assert.throws(function() { - R.paths([['a', 'x', 'y']], obj); - }, function(err) { - return (err instanceof Error && - err.message === 'Specified path not in object'); - }); - - assert.throws(function() { - R.paths([['p', 0, 'q'], ['x', 'z', 2, 1]], obj); - }, function(err) { - return (err instanceof Error && - err.message === 'Specified path not in object'); - }); - - assert.throws(function() { - R.paths([['p', -4, 'q'], ['x', 'z', -1, 0]], obj); - }, function(err) { - return (err instanceof Error && - err.message === 'Specified path not in object'); - }); - }); - - it('does not index into strings values', function() { - assert.throws(function() { - R.paths([['x', 'y', 1]], obj); - }, function(err) { - return (err instanceof Error && - err.message === 'Specified path not in object'); - }); - }); - - it('raises an error for items not found in a list', function() { - assert.throws(function() { - eq(R.paths([['p', 2]], obj), [undefined]); - }, function(err) { - return (err instanceof Error && - err.message === 'Specified path not in object'); - }); + it('returns undefined for items not found', function() { + eq(R.paths([['a', 'x', 'y']], obj), [undefined]); + eq(R.paths([['p', 2]], obj), [undefined]); }); }); diff --git a/test/propOr.js b/test/propOr.js index 89acaf89b8..72bf8f367c 100644 --- a/test/propOr.js +++ b/test/propOr.js @@ -22,9 +22,9 @@ describe('propOr', function() { eq(nm(void 0), 'Unknown'); }); - it('returns the value when supplied an object with a nil value', function() { - eq(R.propOr('foo', 'x', {x: null}), null); - eq(R.propOr('foo', 'x', {x: undefined}), undefined); + it('uses the default when supplied an object with a nil value', function() { + eq(R.propOr('foo', 'x', {x: null}), 'foo'); + eq(R.propOr('foo', 'x', {x: undefined}), 'foo'); }); it('handles number as property', function() { From a09581f9b196352b58e89b5ec29e29ae932605c7 Mon Sep 17 00:00:00 2001 From: krzysztofpniak Date: Sun, 29 Mar 2020 19:10:57 +0200 Subject: [PATCH 023/111] Filter fix (#3002) * fixes filter in Maybe * adds fantasy-land/filter test * fix fantasy-land implementation in filter --- source/filter.js | 2 +- test/filter.js | 8 ++++++++ test/shared/Maybe.js | 2 +- 3 files changed, 10 insertions(+), 2 deletions(-) diff --git a/source/filter.js b/source/filter.js index a759d20dd1..bc8b42244c 100644 --- a/source/filter.js +++ b/source/filter.js @@ -34,7 +34,7 @@ import keys from './keys'; * * R.filter(isEven, {a: 1, b: 2, c: 3, d: 4}); //=> {b: 2, d: 4} */ -var filter = _curry2(_dispatchable(['filter'], _xfilter, function(pred, filterable) { +var filter = _curry2(_dispatchable(['fantasy-land/filter', 'filter'], _xfilter, function(pred, filterable) { return ( _isObject(filterable) ? _reduce(function(acc, key) { diff --git a/test/filter.js b/test/filter.js index dd64a93bac..dcc80d7abc 100644 --- a/test/filter.js +++ b/test/filter.js @@ -1,5 +1,6 @@ var R = require('../source'); var eq = require('./shared/eq'); +var Maybe = require('./shared/Maybe'); describe('filter', function() { @@ -31,4 +32,11 @@ describe('filter', function() { eq(R.filter(function(s) { return s; }, f), 'called f.filter'); }); + it('correctly uses fantasy-land implementations', function() { + var m1 = Maybe.Just(-1); + var m2 = R.filter(function(x) { return x > 0; } , m1); + + eq(m2.isNothing, true); + }); + }); diff --git a/test/shared/Maybe.js b/test/shared/Maybe.js index c47cfda12a..7fc89fe3b7 100644 --- a/test/shared/Maybe.js +++ b/test/shared/Maybe.js @@ -49,7 +49,7 @@ Maybe.prototype['fantasy-land/chain'] = function(f) { }; // Maybe#filter :: Maybe a ~> (a -> Boolean) -> Maybe a -Maybe.prototype.filter = function(pred) { +Maybe.prototype['fantasy-land/filter'] = function(pred) { return this.isJust && pred(this.value) ? this : Nothing; }; From 87d90ba3c0e116a49718cc5cb7a181d5acf8bee2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mateusz=20Burzy=C5=84ski?= Date: Tue, 31 Mar 2020 17:19:32 +0200 Subject: [PATCH 024/111] Fix for importing Ramda in ESM-compatible nodes (#2999) --- package.json | 19 ++++++++++++++----- scripts/addModulePackageScope.js | 6 ++++++ 2 files changed, 20 insertions(+), 5 deletions(-) create mode 100644 scripts/addModulePackageScope.js diff --git a/package.json b/package.json index 465c3135c6..97212cfabf 100644 --- a/package.json +++ b/package.json @@ -45,8 +45,18 @@ "type": "git", "url": "git://github.com/ramda/ramda.git" }, - "module": "es/index.js", - "main": "src/index", + "main": "./src/index.js", + "exports": { + ".": { + "require": "./src/index.js", + "import": "./es/index.js", + "default": "./src/index.js" + }, + "./es/": "./es/", + "./src/": "./src/", + "./dist/": "./dist/" + }, + "module": "./es/index.js", "unpkg": "dist/ramda.min.js", "jsdelivr": "dist/ramda.min.js", "files": [ @@ -58,12 +68,11 @@ "prebench": "npm run --silent build:cjs", "bench": "node scripts/benchRunner", "bookmarklet": "node scripts/bookmarklet", - "build:es": "cross-env BABEL_ENV=es babel source --out-dir es", + "build:es": "cross-env BABEL_ENV=es babel source --out-dir es && node ./scripts/addModulePackageScope.js", "build:cjs": "cross-env BABEL_ENV=cjs babel source --out-dir src", - "build:mjs": "cross-env BABEL_ENV=es babel source/index.js --out-file src/index.mjs", "build:umd": "cross-env NODE_ENV=development rollup -c -o dist/ramda.js", "build:umd:min": "cross-env NODE_ENV=production rollup -c -o dist/ramda.min.js", - "build": "npm run build:es && npm run build:cjs && npm run build:umd && npm run build:umd:min && npm run build:mjs", + "build": "npm run build:es && npm run build:cjs && npm run build:umd && npm run build:umd:min", "partial-build": "node ./scripts/partialBuild", "clean": "rimraf es/* src/* dist/* coverage/*", "prepare": "npm run clean && npm run build", diff --git a/scripts/addModulePackageScope.js b/scripts/addModulePackageScope.js new file mode 100644 index 0000000000..bbfef22e9f --- /dev/null +++ b/scripts/addModulePackageScope.js @@ -0,0 +1,6 @@ +const fs = require('fs'); +const path = require('path'); + +const PACKAGE_SCOPE_PATH = path.join(__dirname, '..', 'es', 'package.json'); + +fs.writeFileSync(PACKAGE_SCOPE_PATH, JSON.stringify({ type: 'module' })); From 42d5243f624714eadf65ae6cd68d28c8995dd89a Mon Sep 17 00:00:00 2001 From: adispring Date: Mon, 6 Apr 2020 17:28:40 +0800 Subject: [PATCH 025/111] optimize binary signature --- source/binary.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/binary.js b/source/binary.js index 35361a48a4..69b69a52f7 100644 --- a/source/binary.js +++ b/source/binary.js @@ -11,7 +11,7 @@ import nAry from './nAry'; * @memberOf R * @since v0.2.0 * @category Function - * @sig (* -> c) -> (a, b -> c) + * @sig (* -> c) -> ((a, b) -> c) * @param {Function} fn The function to wrap. * @return {Function} A new function wrapping `fn`. The new function is guaranteed to be of * arity 2. From 10c1d876e70b519fec5df2ae093be84c665c3ba8 Mon Sep 17 00:00:00 2001 From: adispring Date: Tue, 7 Apr 2020 08:58:51 +0800 Subject: [PATCH 026/111] optimize unary & binary signatures --- source/binary.js | 2 +- source/unary.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source/binary.js b/source/binary.js index 69b69a52f7..bf5f5af823 100644 --- a/source/binary.js +++ b/source/binary.js @@ -11,7 +11,7 @@ import nAry from './nAry'; * @memberOf R * @since v0.2.0 * @category Function - * @sig (* -> c) -> ((a, b) -> c) + * @sig (a -> b -> c -> ... -> z) -> ((a, b) -> z) * @param {Function} fn The function to wrap. * @return {Function} A new function wrapping `fn`. The new function is guaranteed to be of * arity 2. diff --git a/source/unary.js b/source/unary.js index 40dd541040..74d5f37f76 100644 --- a/source/unary.js +++ b/source/unary.js @@ -11,7 +11,7 @@ import nAry from './nAry'; * @memberOf R * @since v0.2.0 * @category Function - * @sig (* -> b) -> (a -> b) + * @sig (a -> b -> c -> ... -> z) -> (a -> z) * @param {Function} fn The function to wrap. * @return {Function} A new function wrapping `fn`. The new function is guaranteed to be of * arity 1. From e649d4a5fcdd3dbac371c6f6db4eb0e956233f5e Mon Sep 17 00:00:00 2001 From: Sergei Orlov Date: Tue, 14 Apr 2020 22:42:34 +0300 Subject: [PATCH 027/111] Fix typo in the @return message (#3011) --- source/tryCatch.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/tryCatch.js b/source/tryCatch.js index 4182c411ee..886728eb28 100644 --- a/source/tryCatch.js +++ b/source/tryCatch.js @@ -17,7 +17,7 @@ import _curry2 from './internal/_curry2'; * @sig (...x -> a) -> ((e, ...x) -> a) -> (...x -> a) * @param {Function} tryer The function that may throw. * @param {Function} catcher The function that will be evaluated if `tryer` throws. - * @return {Function} A new function that will catch exceptions and send then to the catcher. + * @return {Function} A new function that will catch exceptions and send them to the catcher. * @example * * R.tryCatch(R.prop('x'), R.F)({x: true}); //=> true From ccc669959fe24dc36507be159d45f1db361e8fcc Mon Sep 17 00:00:00 2001 From: Richard Date: Wed, 15 Apr 2020 14:56:27 +0200 Subject: [PATCH 028/111] Update includes.js (#3013) --- source/includes.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/includes.js b/source/includes.js index 1404e9d780..784be5df6c 100644 --- a/source/includes.js +++ b/source/includes.js @@ -4,7 +4,7 @@ import _curry2 from './internal/_curry2'; /** * Returns `true` if the specified value is equal, in [`R.equals`](#equals) * terms, to at least one element of the given list; `false` otherwise. - * Works also with strings. + * Also works with strings. * * @func * @memberOf R From 1a4d8e1354c4bab732664d075bc12cbd1db391c8 Mon Sep 17 00:00:00 2001 From: Tim Gates Date: Sun, 19 Apr 2020 07:03:26 +1000 Subject: [PATCH 029/111] docs: Fix simple typo, implemtation -> implementation There is a small typo in dist/ramda.js, source/internal/_checkForMethod.js. Should read `implementation` rather than `implemtation`. --- dist/ramda.js | 2 +- source/internal/_checkForMethod.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/dist/ramda.js b/dist/ramda.js index 02918c6ded..b1daa4fe34 100644 --- a/dist/ramda.js +++ b/dist/ramda.js @@ -2097,7 +2097,7 @@ function _pipe(f, g) { * implementation. * * @private - * @param {Function} fn ramda implemtation + * @param {Function} fn ramda implementation * @param {String} methodname property to check for a custom implementation * @return {Object} Whatever the return value of the method is. */ diff --git a/source/internal/_checkForMethod.js b/source/internal/_checkForMethod.js index 7eb9ef6d96..f2d1307a3c 100644 --- a/source/internal/_checkForMethod.js +++ b/source/internal/_checkForMethod.js @@ -7,7 +7,7 @@ import _isArray from './_isArray'; * implementation. * * @private - * @param {Function} fn ramda implemtation + * @param {Function} fn ramda implementation * @param {String} methodname property to check for a custom implementation * @return {Object} Whatever the return value of the method is. */ From 7c78ed2a28f767bb962bdc5cf15a2e1c3cbb0e5c Mon Sep 17 00:00:00 2001 From: Tim Gates Date: Tue, 21 Apr 2020 06:36:14 +1000 Subject: [PATCH 030/111] Restore original file on request --- dist/ramda.js | 9568 ------------------------------------------------- 1 file changed, 9568 deletions(-) diff --git a/dist/ramda.js b/dist/ramda.js index b1daa4fe34..e69de29bb2 100644 --- a/dist/ramda.js +++ b/dist/ramda.js @@ -1,9568 +0,0 @@ -// Ramda v0.25.0 -// https://github.com/ramda/ramda -// (c) 2013-2018 Scott Sauyet, Michael Hurley, and David Chambers -// Ramda may be freely distributed under the MIT license. - -(function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : - typeof define === 'function' && define.amd ? define(['exports'], factory) : - (factory((global.R = {}))); -}(this, (function (exports) { 'use strict'; - -/** - * A function that always returns `false`. Any passed in parameters are ignored. - * - * @func - * @memberOf R - * @since v0.9.0 - * @category Function - * @sig * -> Boolean - * @param {*} - * @return {Boolean} - * @see R.T - * @example - * - * R.F(); //=> false - */ -var F = function() {return false;}; - -/** - * A function that always returns `true`. Any passed in parameters are ignored. - * - * @func - * @memberOf R - * @since v0.9.0 - * @category Function - * @sig * -> Boolean - * @param {*} - * @return {Boolean} - * @see R.F - * @example - * - * R.T(); //=> true - */ -var T = function() {return true;}; - -/** - * A special placeholder value used to specify "gaps" within curried functions, - * allowing partial application of any combination of arguments, regardless of - * their positions. - * - * If `g` is a curried ternary function and `_` is `R.__`, the following are - * equivalent: - * - * - `g(1, 2, 3)` - * - `g(_, 2, 3)(1)` - * - `g(_, _, 3)(1)(2)` - * - `g(_, _, 3)(1, 2)` - * - `g(_, 2, _)(1, 3)` - * - `g(_, 2)(1)(3)` - * - `g(_, 2)(1, 3)` - * - `g(_, 2)(_, 3)(1)` - * - * @name __ - * @constant - * @memberOf R - * @since v0.6.0 - * @category Function - * @example - * - * const greet = R.replace('{name}', R.__, 'Hello, {name}!'); - * greet('Alice'); //=> 'Hello, Alice!' - */ -var __ = {'@@functional/placeholder': true}; - -function _isPlaceholder(a) { - return a != null && - typeof a === 'object' && - a['@@functional/placeholder'] === true; -} - -/** - * Optimized internal one-arity curry function. - * - * @private - * @category Function - * @param {Function} fn The function to curry. - * @return {Function} The curried function. - */ -function _curry1(fn) { - return function f1(a) { - if (arguments.length === 0 || _isPlaceholder(a)) { - return f1; - } else { - return fn.apply(this, arguments); - } - }; -} - -/** - * Optimized internal two-arity curry function. - * - * @private - * @category Function - * @param {Function} fn The function to curry. - * @return {Function} The curried function. - */ -function _curry2(fn) { - return function f2(a, b) { - switch (arguments.length) { - case 0: - return f2; - case 1: - return _isPlaceholder(a) ? f2 - : _curry1(function(_b) { return fn(a, _b); }); - default: - return _isPlaceholder(a) && _isPlaceholder(b) ? f2 - : _isPlaceholder(a) ? _curry1(function(_a) { return fn(_a, b); }) - : _isPlaceholder(b) ? _curry1(function(_b) { return fn(a, _b); }) - : fn(a, b); - } - }; -} - -/** - * Adds two values. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Math - * @sig Number -> Number -> Number - * @param {Number} a - * @param {Number} b - * @return {Number} - * @see R.subtract - * @example - * - * R.add(2, 3); //=> 5 - * R.add(7)(10); //=> 17 - */ -var add = _curry2(function add(a, b) { - return Number(a) + Number(b); -}); - -/** - * Private `concat` function to merge two array-like objects. - * - * @private - * @param {Array|Arguments} [set1=[]] An array-like object. - * @param {Array|Arguments} [set2=[]] An array-like object. - * @return {Array} A new, merged array. - * @example - * - * _concat([4, 5, 6], [1, 2, 3]); //=> [4, 5, 6, 1, 2, 3] - */ -function _concat(set1, set2) { - set1 = set1 || []; - set2 = set2 || []; - var idx; - var len1 = set1.length; - var len2 = set2.length; - var result = []; - - idx = 0; - while (idx < len1) { - result[result.length] = set1[idx]; - idx += 1; - } - idx = 0; - while (idx < len2) { - result[result.length] = set2[idx]; - idx += 1; - } - return result; -} - -function _arity(n, fn) { - /* eslint-disable no-unused-vars */ - switch (n) { - case 0: return function() { return fn.apply(this, arguments); }; - case 1: return function(a0) { return fn.apply(this, arguments); }; - case 2: return function(a0, a1) { return fn.apply(this, arguments); }; - case 3: return function(a0, a1, a2) { return fn.apply(this, arguments); }; - case 4: return function(a0, a1, a2, a3) { return fn.apply(this, arguments); }; - case 5: return function(a0, a1, a2, a3, a4) { return fn.apply(this, arguments); }; - case 6: return function(a0, a1, a2, a3, a4, a5) { return fn.apply(this, arguments); }; - case 7: return function(a0, a1, a2, a3, a4, a5, a6) { return fn.apply(this, arguments); }; - case 8: return function(a0, a1, a2, a3, a4, a5, a6, a7) { return fn.apply(this, arguments); }; - case 9: return function(a0, a1, a2, a3, a4, a5, a6, a7, a8) { return fn.apply(this, arguments); }; - case 10: return function(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9) { return fn.apply(this, arguments); }; - default: throw new Error('First argument to _arity must be a non-negative integer no greater than ten'); - } -} - -/** - * Internal curryN function. - * - * @private - * @category Function - * @param {Number} length The arity of the curried function. - * @param {Array} received An array of arguments received thus far. - * @param {Function} fn The function to curry. - * @return {Function} The curried function. - */ -function _curryN(length, received, fn) { - return function() { - var combined = []; - var argsIdx = 0; - var left = length; - var combinedIdx = 0; - while (combinedIdx < received.length || argsIdx < arguments.length) { - var result; - if (combinedIdx < received.length && - (!_isPlaceholder(received[combinedIdx]) || - argsIdx >= arguments.length)) { - result = received[combinedIdx]; - } else { - result = arguments[argsIdx]; - argsIdx += 1; - } - combined[combinedIdx] = result; - if (!_isPlaceholder(result)) { - left -= 1; - } - combinedIdx += 1; - } - return left <= 0 ? fn.apply(this, combined) - : _arity(left, _curryN(length, combined, fn)); - }; -} - -/** - * Returns a curried equivalent of the provided function, with the specified - * arity. The curried function has two unusual capabilities. First, its - * arguments needn't be provided one at a time. If `g` is `R.curryN(3, f)`, the - * following are equivalent: - * - * - `g(1)(2)(3)` - * - `g(1)(2, 3)` - * - `g(1, 2)(3)` - * - `g(1, 2, 3)` - * - * Secondly, the special placeholder value [`R.__`](#__) may be used to specify - * "gaps", allowing partial application of any combination of arguments, - * regardless of their positions. If `g` is as above and `_` is [`R.__`](#__), - * the following are equivalent: - * - * - `g(1, 2, 3)` - * - `g(_, 2, 3)(1)` - * - `g(_, _, 3)(1)(2)` - * - `g(_, _, 3)(1, 2)` - * - `g(_, 2)(1)(3)` - * - `g(_, 2)(1, 3)` - * - `g(_, 2)(_, 3)(1)` - * - * @func - * @memberOf R - * @since v0.5.0 - * @category Function - * @sig Number -> (* -> a) -> (* -> a) - * @param {Number} length The arity for the returned function. - * @param {Function} fn The function to curry. - * @return {Function} A new, curried function. - * @see R.curry - * @example - * - * const sumArgs = (...args) => R.sum(args); - * - * const curriedAddFourNumbers = R.curryN(4, sumArgs); - * const f = curriedAddFourNumbers(1, 2); - * const g = f(3); - * g(4); //=> 10 - */ -var curryN = _curry2(function curryN(length, fn) { - if (length === 1) { - return _curry1(fn); - } - return _arity(length, _curryN(length, [], fn)); -}); - -/** - * Creates a new list iteration function from an existing one by adding two new - * parameters to its callback function: the current index, and the entire list. - * - * This would turn, for instance, [`R.map`](#map) function into one that - * more closely resembles `Array.prototype.map`. Note that this will only work - * for functions in which the iteration callback function is the first - * parameter, and where the list is the last parameter. (This latter might be - * unimportant if the list parameter is not used.) - * - * @func - * @memberOf R - * @since v0.15.0 - * @category Function - * @category List - * @sig ((a ... -> b) ... -> [a] -> *) -> ((a ..., Int, [a] -> b) ... -> [a] -> *) - * @param {Function} fn A list iteration function that does not pass index or list to its callback - * @return {Function} An altered list iteration function that passes (item, index, list) to its callback - * @example - * - * const mapIndexed = R.addIndex(R.map); - * mapIndexed((val, idx) => idx + '-' + val, ['f', 'o', 'o', 'b', 'a', 'r']); - * //=> ['0-f', '1-o', '2-o', '3-b', '4-a', '5-r'] - */ -var addIndex = _curry1(function addIndex(fn) { - return curryN(fn.length, function() { - var idx = 0; - var origFn = arguments[0]; - var list = arguments[arguments.length - 1]; - var args = Array.prototype.slice.call(arguments, 0); - args[0] = function() { - var result = origFn.apply(this, _concat(arguments, [idx, list])); - idx += 1; - return result; - }; - return fn.apply(this, args); - }); -}); - -/** - * Optimized internal three-arity curry function. - * - * @private - * @category Function - * @param {Function} fn The function to curry. - * @return {Function} The curried function. - */ -function _curry3(fn) { - return function f3(a, b, c) { - switch (arguments.length) { - case 0: - return f3; - case 1: - return _isPlaceholder(a) ? f3 - : _curry2(function(_b, _c) { return fn(a, _b, _c); }); - case 2: - return _isPlaceholder(a) && _isPlaceholder(b) ? f3 - : _isPlaceholder(a) ? _curry2(function(_a, _c) { return fn(_a, b, _c); }) - : _isPlaceholder(b) ? _curry2(function(_b, _c) { return fn(a, _b, _c); }) - : _curry1(function(_c) { return fn(a, b, _c); }); - default: - return _isPlaceholder(a) && _isPlaceholder(b) && _isPlaceholder(c) ? f3 - : _isPlaceholder(a) && _isPlaceholder(b) ? _curry2(function(_a, _b) { return fn(_a, _b, c); }) - : _isPlaceholder(a) && _isPlaceholder(c) ? _curry2(function(_a, _c) { return fn(_a, b, _c); }) - : _isPlaceholder(b) && _isPlaceholder(c) ? _curry2(function(_b, _c) { return fn(a, _b, _c); }) - : _isPlaceholder(a) ? _curry1(function(_a) { return fn(_a, b, c); }) - : _isPlaceholder(b) ? _curry1(function(_b) { return fn(a, _b, c); }) - : _isPlaceholder(c) ? _curry1(function(_c) { return fn(a, b, _c); }) - : fn(a, b, c); - } - }; -} - -/** - * Applies a function to the value at the given index of an array, returning a - * new copy of the array with the element at the given index replaced with the - * result of the function application. - * - * @func - * @memberOf R - * @since v0.14.0 - * @category List - * @sig Number -> (a -> a) -> [a] -> [a] - * @param {Number} idx The index. - * @param {Function} fn The function to apply. - * @param {Array|Arguments} list An array-like object whose value - * at the supplied index will be replaced. - * @return {Array} A copy of the supplied array-like object with - * the element at index `idx` replaced with the value - * returned by applying `fn` to the existing element. - * @see R.update - * @example - * - * R.adjust(1, R.toUpper, ['a', 'b', 'c', 'd']); //=> ['a', 'B', 'c', 'd'] - * R.adjust(-1, R.toUpper, ['a', 'b', 'c', 'd']); //=> ['a', 'b', 'c', 'D'] - * @symb R.adjust(-1, f, [a, b]) = [a, f(b)] - * @symb R.adjust(0, f, [a, b]) = [f(a), b] - */ -var adjust = _curry3(function adjust(idx, fn, list) { - if (idx >= list.length || idx < -list.length) { - return list; - } - var start = idx < 0 ? list.length : 0; - var _idx = start + idx; - var _list = _concat(list); - _list[_idx] = fn(list[_idx]); - return _list; -}); - -/** - * Tests whether or not an object is an array. - * - * @private - * @param {*} val The object to test. - * @return {Boolean} `true` if `val` is an array, `false` otherwise. - * @example - * - * _isArray([]); //=> true - * _isArray(null); //=> false - * _isArray({}); //=> false - */ -var _isArray = Array.isArray || function _isArray(val) { - return (val != null && - val.length >= 0 && - Object.prototype.toString.call(val) === '[object Array]'); -}; - -function _isTransformer(obj) { - return obj != null && typeof obj['@@transducer/step'] === 'function'; -} - -/** - * Returns a function that dispatches with different strategies based on the - * object in list position (last argument). If it is an array, executes [fn]. - * Otherwise, if it has a function with one of the given method names, it will - * execute that function (functor case). Otherwise, if it is a transformer, - * uses transducer [xf] to return a new transformer (transducer case). - * Otherwise, it will default to executing [fn]. - * - * @private - * @param {Array} methodNames properties to check for a custom implementation - * @param {Function} xf transducer to initialize if object is transformer - * @param {Function} fn default ramda implementation - * @return {Function} A function that dispatches on object in list position - */ -function _dispatchable(methodNames, xf, fn) { - return function() { - if (arguments.length === 0) { - return fn(); - } - var args = Array.prototype.slice.call(arguments, 0); - var obj = args.pop(); - if (!_isArray(obj)) { - var idx = 0; - while (idx < methodNames.length) { - if (typeof obj[methodNames[idx]] === 'function') { - return obj[methodNames[idx]].apply(obj, args); - } - idx += 1; - } - if (_isTransformer(obj)) { - var transducer = xf.apply(null, args); - return transducer(obj); - } - } - return fn.apply(this, arguments); - }; -} - -function _reduced(x) { - return x && x['@@transducer/reduced'] ? x : - { - '@@transducer/value': x, - '@@transducer/reduced': true - }; -} - -var _xfBase = { - init: function() { - return this.xf['@@transducer/init'](); - }, - result: function(result) { - return this.xf['@@transducer/result'](result); - } -}; - -function XAll(f, xf) { - this.xf = xf; - this.f = f; - this.all = true; -} -XAll.prototype['@@transducer/init'] = _xfBase.init; -XAll.prototype['@@transducer/result'] = function(result) { - if (this.all) { - result = this.xf['@@transducer/step'](result, true); - } - return this.xf['@@transducer/result'](result); -}; -XAll.prototype['@@transducer/step'] = function(result, input) { - if (!this.f(input)) { - this.all = false; - result = _reduced(this.xf['@@transducer/step'](result, false)); - } - return result; -}; - -var _xall = _curry2(function _xall(f, xf) { return new XAll(f, xf); }); - -/** - * Returns `true` if all elements of the list match the predicate, `false` if - * there are any that don't. - * - * Dispatches to the `all` method of the second argument, if present. - * - * Acts as a transducer if a transformer is given in list position. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category List - * @sig (a -> Boolean) -> [a] -> Boolean - * @param {Function} fn The predicate function. - * @param {Array} list The array to consider. - * @return {Boolean} `true` if the predicate is satisfied by every element, `false` - * otherwise. - * @see R.any, R.none, R.transduce - * @example - * - * const equals3 = R.equals(3); - * R.all(equals3)([3, 3, 3, 3]); //=> true - * R.all(equals3)([3, 3, 1, 3]); //=> false - */ -var all = _curry2(_dispatchable(['all'], _xall, function all(fn, list) { - var idx = 0; - while (idx < list.length) { - if (!fn(list[idx])) { - return false; - } - idx += 1; - } - return true; -})); - -/** - * Returns the larger of its two arguments. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Relation - * @sig Ord a => a -> a -> a - * @param {*} a - * @param {*} b - * @return {*} - * @see R.maxBy, R.min - * @example - * - * R.max(789, 123); //=> 789 - * R.max('a', 'b'); //=> 'b' - */ -var max = _curry2(function max(a, b) { return b > a ? b : a; }); - -function _map(fn, functor) { - var idx = 0; - var len = functor.length; - var result = Array(len); - while (idx < len) { - result[idx] = fn(functor[idx]); - idx += 1; - } - return result; -} - -function _isString(x) { - return Object.prototype.toString.call(x) === '[object String]'; -} - -/** - * Tests whether or not an object is similar to an array. - * - * @private - * @category Type - * @category List - * @sig * -> Boolean - * @param {*} x The object to test. - * @return {Boolean} `true` if `x` has a numeric length property and extreme indices defined; `false` otherwise. - * @example - * - * _isArrayLike([]); //=> true - * _isArrayLike(true); //=> false - * _isArrayLike({}); //=> false - * _isArrayLike({length: 10}); //=> false - * _isArrayLike({0: 'zero', 9: 'nine', length: 10}); //=> true - */ -var _isArrayLike = _curry1(function isArrayLike(x) { - if (_isArray(x)) { return true; } - if (!x) { return false; } - if (typeof x !== 'object') { return false; } - if (_isString(x)) { return false; } - if (x.nodeType === 1) { return !!x.length; } - if (x.length === 0) { return true; } - if (x.length > 0) { - return x.hasOwnProperty(0) && x.hasOwnProperty(x.length - 1); - } - return false; -}); - -function XWrap(fn) { - this.f = fn; -} -XWrap.prototype['@@transducer/init'] = function() { - throw new Error('init not implemented on XWrap'); -}; -XWrap.prototype['@@transducer/result'] = function(acc) { return acc; }; -XWrap.prototype['@@transducer/step'] = function(acc, x) { - return this.f(acc, x); -}; - -function _xwrap(fn) { return new XWrap(fn); } - -/** - * Creates a function that is bound to a context. - * Note: `R.bind` does not provide the additional argument-binding capabilities of - * [Function.prototype.bind](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind). - * - * @func - * @memberOf R - * @since v0.6.0 - * @category Function - * @category Object - * @sig (* -> *) -> {*} -> (* -> *) - * @param {Function} fn The function to bind to context - * @param {Object} thisObj The context to bind `fn` to - * @return {Function} A function that will execute in the context of `thisObj`. - * @see R.partial - * @example - * - * const log = R.bind(console.log, console); - * R.pipe(R.assoc('a', 2), R.tap(log), R.assoc('a', 3))({a: 1}); //=> {a: 3} - * // logs {a: 2} - * @symb R.bind(f, o)(a, b) = f.call(o, a, b) - */ -var bind = _curry2(function bind(fn, thisObj) { - return _arity(fn.length, function() { - return fn.apply(thisObj, arguments); - }); -}); - -function _arrayReduce(xf, acc, list) { - var idx = 0; - var len = list.length; - while (idx < len) { - acc = xf['@@transducer/step'](acc, list[idx]); - if (acc && acc['@@transducer/reduced']) { - acc = acc['@@transducer/value']; - break; - } - idx += 1; - } - return xf['@@transducer/result'](acc); -} - -function _iterableReduce(xf, acc, iter) { - var step = iter.next(); - while (!step.done) { - acc = xf['@@transducer/step'](acc, step.value); - if (acc && acc['@@transducer/reduced']) { - acc = acc['@@transducer/value']; - break; - } - step = iter.next(); - } - return xf['@@transducer/result'](acc); -} - -function _methodReduce(xf, acc, obj, methodName) { - return xf['@@transducer/result'](obj[methodName](bind(xf['@@transducer/step'], xf), acc)); -} - -var symIterator = (typeof Symbol !== 'undefined') ? Symbol.iterator : '@@iterator'; - -function _reduce(fn, acc, list) { - if (typeof fn === 'function') { - fn = _xwrap(fn); - } - if (_isArrayLike(list)) { - return _arrayReduce(fn, acc, list); - } - if (typeof list['fantasy-land/reduce'] === 'function') { - return _methodReduce(fn, acc, list, 'fantasy-land/reduce'); - } - if (list[symIterator] != null) { - return _iterableReduce(fn, acc, list[symIterator]()); - } - if (typeof list.next === 'function') { - return _iterableReduce(fn, acc, list); - } - if (typeof list.reduce === 'function') { - return _methodReduce(fn, acc, list, 'reduce'); - } - - throw new TypeError('reduce: list must be array or iterable'); -} - -function XMap(f, xf) { - this.xf = xf; - this.f = f; -} -XMap.prototype['@@transducer/init'] = _xfBase.init; -XMap.prototype['@@transducer/result'] = _xfBase.result; -XMap.prototype['@@transducer/step'] = function(result, input) { - return this.xf['@@transducer/step'](result, this.f(input)); -}; - -var _xmap = _curry2(function _xmap(f, xf) { return new XMap(f, xf); }); - -function _has(prop, obj) { - return Object.prototype.hasOwnProperty.call(obj, prop); -} - -var toString = Object.prototype.toString; -var _isArguments = (function() { - return toString.call(arguments) === '[object Arguments]' ? - function _isArguments(x) { return toString.call(x) === '[object Arguments]'; } : - function _isArguments(x) { return _has('callee', x); }; -}()); - -// cover IE < 9 keys issues -var hasEnumBug = !({toString: null}).propertyIsEnumerable('toString'); -var nonEnumerableProps = ['constructor', 'valueOf', 'isPrototypeOf', 'toString', - 'propertyIsEnumerable', 'hasOwnProperty', 'toLocaleString']; -// Safari bug -var hasArgsEnumBug = (function() { - 'use strict'; - return arguments.propertyIsEnumerable('length'); -}()); - -var contains = function contains(list, item) { - var idx = 0; - while (idx < list.length) { - if (list[idx] === item) { - return true; - } - idx += 1; - } - return false; -}; - -/** - * Returns a list containing the names of all the enumerable own properties of - * the supplied object. - * Note that the order of the output array is not guaranteed to be consistent - * across different JS platforms. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Object - * @sig {k: v} -> [k] - * @param {Object} obj The object to extract properties from - * @return {Array} An array of the object's own properties. - * @see R.keysIn, R.values - * @example - * - * R.keys({a: 1, b: 2, c: 3}); //=> ['a', 'b', 'c'] - */ -var keys = typeof Object.keys === 'function' && !hasArgsEnumBug ? - _curry1(function keys(obj) { - return Object(obj) !== obj ? [] : Object.keys(obj); - }) : - _curry1(function keys(obj) { - if (Object(obj) !== obj) { - return []; - } - var prop, nIdx; - var ks = []; - var checkArgsLength = hasArgsEnumBug && _isArguments(obj); - for (prop in obj) { - if (_has(prop, obj) && (!checkArgsLength || prop !== 'length')) { - ks[ks.length] = prop; - } - } - if (hasEnumBug) { - nIdx = nonEnumerableProps.length - 1; - while (nIdx >= 0) { - prop = nonEnumerableProps[nIdx]; - if (_has(prop, obj) && !contains(ks, prop)) { - ks[ks.length] = prop; - } - nIdx -= 1; - } - } - return ks; - }); - -/** - * Takes a function and - * a [functor](https://github.com/fantasyland/fantasy-land#functor), - * applies the function to each of the functor's values, and returns - * a functor of the same shape. - * - * Ramda provides suitable `map` implementations for `Array` and `Object`, - * so this function may be applied to `[1, 2, 3]` or `{x: 1, y: 2, z: 3}`. - * - * Dispatches to the `map` method of the second argument, if present. - * - * Acts as a transducer if a transformer is given in list position. - * - * Also treats functions as functors and will compose them together. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category List - * @sig Functor f => (a -> b) -> f a -> f b - * @param {Function} fn The function to be called on every element of the input `list`. - * @param {Array} list The list to be iterated over. - * @return {Array} The new list. - * @see R.transduce, R.addIndex - * @example - * - * const double = x => x * 2; - * - * R.map(double, [1, 2, 3]); //=> [2, 4, 6] - * - * R.map(double, {x: 1, y: 2, z: 3}); //=> {x: 2, y: 4, z: 6} - * @symb R.map(f, [a, b]) = [f(a), f(b)] - * @symb R.map(f, { x: a, y: b }) = { x: f(a), y: f(b) } - * @symb R.map(f, functor_o) = functor_o.map(f) - */ -var map = _curry2(_dispatchable(['fantasy-land/map', 'map'], _xmap, function map(fn, functor) { - switch (Object.prototype.toString.call(functor)) { - case '[object Function]': - return curryN(functor.length, function() { - return fn.call(this, functor.apply(this, arguments)); - }); - case '[object Object]': - return _reduce(function(acc, key) { - acc[key] = fn(functor[key]); - return acc; - }, {}, keys(functor)); - default: - return _map(fn, functor); - } -})); - -/** - * Retrieve the value at a given path. - * - * @func - * @memberOf R - * @since v0.2.0 - * @category Object - * @typedefn Idx = String | Int - * @sig [Idx] -> {a} -> a | Undefined - * @param {Array} path The path to use. - * @param {Object} obj The object to retrieve the nested property from. - * @return {*} The data at `path`. - * @see R.prop - * @example - * - * R.path(['a', 'b'], {a: {b: 2}}); //=> 2 - * R.path(['a', 'b'], {c: {b: 2}}); //=> undefined - */ -var path = _curry2(function path(paths, obj) { - var val = obj; - var idx = 0; - while (idx < paths.length) { - if (val == null) { - return; - } - val = val[paths[idx]]; - idx += 1; - } - return val; -}); - -/** - * Returns a function that when supplied an object returns the indicated - * property of that object, if it exists. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Object - * @sig s -> {s: a} -> a | Undefined - * @param {String} p The property name - * @param {Object} obj The object to query - * @return {*} The value at `obj.p`. - * @see R.path - * @example - * - * R.prop('x', {x: 100}); //=> 100 - * R.prop('x', {}); //=> undefined - * R.compose(R.inc, R.prop('x'))({ x: 3 }) //=> 4 - */ - -var prop = _curry2(function prop(p, obj) { return path([p], obj); }); - -/** - * Returns a new list by plucking the same named property off all objects in - * the list supplied. - * - * `pluck` will work on - * any [functor](https://github.com/fantasyland/fantasy-land#functor) in - * addition to arrays, as it is equivalent to `R.map(R.prop(k), f)`. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category List - * @sig Functor f => k -> f {k: v} -> f v - * @param {Number|String} key The key name to pluck off of each object. - * @param {Array} f The array or functor to consider. - * @return {Array} The list of values for the given key. - * @see R.props - * @example - * - * var getAges = R.pluck('age'); - * getAges([{name: 'fred', age: 29}, {name: 'wilma', age: 27}]); //=> [29, 27] - * - * R.pluck(0, [[1, 2], [3, 4]]); //=> [1, 3] - * R.pluck('val', {a: {val: 3}, b: {val: 5}}); //=> {a: 3, b: 5} - * @symb R.pluck('x', [{x: 1, y: 2}, {x: 3, y: 4}, {x: 5, y: 6}]) = [1, 3, 5] - * @symb R.pluck(0, [[1, 2], [3, 4], [5, 6]]) = [1, 3, 5] - */ -var pluck = _curry2(function pluck(p, list) { - return map(prop(p), list); -}); - -/** - * Returns a single item by iterating through the list, successively calling - * the iterator function and passing it an accumulator value and the current - * value from the array, and then passing the result to the next call. - * - * The iterator function receives two values: *(acc, value)*. It may use - * [`R.reduced`](#reduced) to shortcut the iteration. - * - * The arguments' order of [`reduceRight`](#reduceRight)'s iterator function - * is *(value, acc)*. - * - * Note: `R.reduce` does not skip deleted or unassigned indices (sparse - * arrays), unlike the native `Array.prototype.reduce` method. For more details - * on this behavior, see: - * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce#Description - * - * Dispatches to the `reduce` method of the third argument, if present. When - * doing so, it is up to the user to handle the [`R.reduced`](#reduced) - * shortcuting, as this is not implemented by `reduce`. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category List - * @sig ((a, b) -> a) -> a -> [b] -> a - * @param {Function} fn The iterator function. Receives two values, the accumulator and the - * current element from the array. - * @param {*} acc The accumulator value. - * @param {Array} list The list to iterate over. - * @return {*} The final, accumulated value. - * @see R.reduced, R.addIndex, R.reduceRight - * @example - * - * R.reduce(R.subtract, 0, [1, 2, 3, 4]) // => ((((0 - 1) - 2) - 3) - 4) = -10 - * // - -10 - * // / \ / \ - * // - 4 -6 4 - * // / \ / \ - * // - 3 ==> -3 3 - * // / \ / \ - * // - 2 -1 2 - * // / \ / \ - * // 0 1 0 1 - * - * @symb R.reduce(f, a, [b, c, d]) = f(f(f(a, b), c), d) - */ -var reduce = _curry3(_reduce); - -/** - * Takes a list of predicates and returns a predicate that returns true for a - * given list of arguments if every one of the provided predicates is satisfied - * by those arguments. - * - * The function returned is a curried function whose arity matches that of the - * highest-arity predicate. - * - * @func - * @memberOf R - * @since v0.9.0 - * @category Logic - * @sig [(*... -> Boolean)] -> (*... -> Boolean) - * @param {Array} predicates An array of predicates to check - * @return {Function} The combined predicate - * @see R.anyPass - * @example - * - * const isQueen = R.propEq('rank', 'Q'); - * const isSpade = R.propEq('suit', '♠︎'); - * const isQueenOfSpades = R.allPass([isQueen, isSpade]); - * - * isQueenOfSpades({rank: 'Q', suit: '♣︎'}); //=> false - * isQueenOfSpades({rank: 'Q', suit: '♠︎'}); //=> true - */ -var allPass = _curry1(function allPass(preds) { - return curryN(reduce(max, 0, pluck('length', preds)), function() { - var idx = 0; - var len = preds.length; - while (idx < len) { - if (!preds[idx].apply(this, arguments)) { - return false; - } - idx += 1; - } - return true; - }); -}); - -/** - * Returns a function that always returns the given value. Note that for - * non-primitives the value returned is a reference to the original value. - * - * This function is known as `const`, `constant`, or `K` (for K combinator) in - * other languages and libraries. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Function - * @sig a -> (* -> a) - * @param {*} val The value to wrap in a function - * @return {Function} A Function :: * -> val. - * @example - * - * const t = R.always('Tee'); - * t(); //=> 'Tee' - */ -var always = _curry1(function always(val) { - return function() { - return val; - }; -}); - -/** - * Returns `true` if both arguments are `true`; `false` otherwise. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Logic - * @sig a -> b -> a | b - * @param {Any} a - * @param {Any} b - * @return {Any} the first argument if it is falsy, otherwise the second argument. - * @see R.both - * @example - * - * R.and(true, true); //=> true - * R.and(true, false); //=> false - * R.and(false, true); //=> false - * R.and(false, false); //=> false - */ -var and = _curry2(function and(a, b) { - return a && b; -}); - -function XAny(f, xf) { - this.xf = xf; - this.f = f; - this.any = false; -} -XAny.prototype['@@transducer/init'] = _xfBase.init; -XAny.prototype['@@transducer/result'] = function(result) { - if (!this.any) { - result = this.xf['@@transducer/step'](result, false); - } - return this.xf['@@transducer/result'](result); -}; -XAny.prototype['@@transducer/step'] = function(result, input) { - if (this.f(input)) { - this.any = true; - result = _reduced(this.xf['@@transducer/step'](result, true)); - } - return result; -}; - -var _xany = _curry2(function _xany(f, xf) { return new XAny(f, xf); }); - -/** - * Returns `true` if at least one of the elements of the list match the predicate, - * `false` otherwise. - * - * Dispatches to the `any` method of the second argument, if present. - * - * Acts as a transducer if a transformer is given in list position. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category List - * @sig (a -> Boolean) -> [a] -> Boolean - * @param {Function} fn The predicate function. - * @param {Array} list The array to consider. - * @return {Boolean} `true` if the predicate is satisfied by at least one element, `false` - * otherwise. - * @see R.all, R.none, R.transduce - * @example - * - * const lessThan0 = R.flip(R.lt)(0); - * const lessThan2 = R.flip(R.lt)(2); - * R.any(lessThan0)([1, 2]); //=> false - * R.any(lessThan2)([1, 2]); //=> true - */ -var any = _curry2(_dispatchable(['any'], _xany, function any(fn, list) { - var idx = 0; - while (idx < list.length) { - if (fn(list[idx])) { - return true; - } - idx += 1; - } - return false; -})); - -/** - * Takes a list of predicates and returns a predicate that returns true for a - * given list of arguments if at least one of the provided predicates is - * satisfied by those arguments. - * - * The function returned is a curried function whose arity matches that of the - * highest-arity predicate. - * - * @func - * @memberOf R - * @since v0.9.0 - * @category Logic - * @sig [(*... -> Boolean)] -> (*... -> Boolean) - * @param {Array} predicates An array of predicates to check - * @return {Function} The combined predicate - * @see R.allPass - * @example - * - * const isClub = R.propEq('suit', '♣'); - * const isSpade = R.propEq('suit', '♠'); - * const isBlackCard = R.anyPass([isClub, isSpade]); - * - * isBlackCard({rank: '10', suit: '♣'}); //=> true - * isBlackCard({rank: 'Q', suit: '♠'}); //=> true - * isBlackCard({rank: 'Q', suit: '♦'}); //=> false - */ -var anyPass = _curry1(function anyPass(preds) { - return curryN(reduce(max, 0, pluck('length', preds)), function() { - var idx = 0; - var len = preds.length; - while (idx < len) { - if (preds[idx].apply(this, arguments)) { - return true; - } - idx += 1; - } - return false; - }); -}); - -/** - * ap applies a list of functions to a list of values. - * - * Dispatches to the `ap` method of the second argument, if present. Also - * treats curried functions as applicatives. - * - * @func - * @memberOf R - * @since v0.3.0 - * @category Function - * @sig [a -> b] -> [a] -> [b] - * @sig Apply f => f (a -> b) -> f a -> f b - * @sig (r -> a -> b) -> (r -> a) -> (r -> b) - * @param {*} applyF - * @param {*} applyX - * @return {*} - * @example - * - * R.ap([R.multiply(2), R.add(3)], [1,2,3]); //=> [2, 4, 6, 4, 5, 6] - * R.ap([R.concat('tasty '), R.toUpper], ['pizza', 'salad']); //=> ["tasty pizza", "tasty salad", "PIZZA", "SALAD"] - * - * // R.ap can also be used as S combinator - * // when only two functions are passed - * R.ap(R.concat, R.toUpper)('Ramda') //=> 'RamdaRAMDA' - * @symb R.ap([f, g], [a, b]) = [f(a), f(b), g(a), g(b)] - */ -var ap = _curry2(function ap(applyF, applyX) { - return ( - typeof applyX['fantasy-land/ap'] === 'function' ? - applyX['fantasy-land/ap'](applyF) : - typeof applyF.ap === 'function' ? - applyF.ap(applyX) : - typeof applyF === 'function' ? - function(x) { return applyF(x)(applyX(x)); } : - // else - _reduce(function(acc, f) { return _concat(acc, map(f, applyX)); }, [], applyF) - ); -}); - -function _aperture(n, list) { - var idx = 0; - var limit = list.length - (n - 1); - var acc = new Array(limit >= 0 ? limit : 0); - while (idx < limit) { - acc[idx] = Array.prototype.slice.call(list, idx, idx + n); - idx += 1; - } - return acc; -} - -function XAperture(n, xf) { - this.xf = xf; - this.pos = 0; - this.full = false; - this.acc = new Array(n); -} -XAperture.prototype['@@transducer/init'] = _xfBase.init; -XAperture.prototype['@@transducer/result'] = function(result) { - this.acc = null; - return this.xf['@@transducer/result'](result); -}; -XAperture.prototype['@@transducer/step'] = function(result, input) { - this.store(input); - return this.full ? this.xf['@@transducer/step'](result, this.getCopy()) : result; -}; -XAperture.prototype.store = function(input) { - this.acc[this.pos] = input; - this.pos += 1; - if (this.pos === this.acc.length) { - this.pos = 0; - this.full = true; - } -}; -XAperture.prototype.getCopy = function() { - return _concat(Array.prototype.slice.call(this.acc, this.pos), - Array.prototype.slice.call(this.acc, 0, this.pos)); -}; - -var _xaperture = _curry2(function _xaperture(n, xf) { return new XAperture(n, xf); }); - -/** - * Returns a new list, composed of n-tuples of consecutive elements. If `n` is - * greater than the length of the list, an empty list is returned. - * - * Acts as a transducer if a transformer is given in list position. - * - * @func - * @memberOf R - * @since v0.12.0 - * @category List - * @sig Number -> [a] -> [[a]] - * @param {Number} n The size of the tuples to create - * @param {Array} list The list to split into `n`-length tuples - * @return {Array} The resulting list of `n`-length tuples - * @see R.transduce - * @example - * - * R.aperture(2, [1, 2, 3, 4, 5]); //=> [[1, 2], [2, 3], [3, 4], [4, 5]] - * R.aperture(3, [1, 2, 3, 4, 5]); //=> [[1, 2, 3], [2, 3, 4], [3, 4, 5]] - * R.aperture(7, [1, 2, 3, 4, 5]); //=> [] - */ -var aperture = _curry2(_dispatchable([], _xaperture, _aperture)); - -/** - * Returns a new list containing the contents of the given list, followed by - * the given element. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category List - * @sig a -> [a] -> [a] - * @param {*} el The element to add to the end of the new list. - * @param {Array} list The list of elements to add a new item to. - * list. - * @return {Array} A new list containing the elements of the old list followed by `el`. - * @see R.prepend - * @example - * - * R.append('tests', ['write', 'more']); //=> ['write', 'more', 'tests'] - * R.append('tests', []); //=> ['tests'] - * R.append(['tests'], ['write', 'more']); //=> ['write', 'more', ['tests']] - */ -var append = _curry2(function append(el, list) { - return _concat(list, [el]); -}); - -/** - * Applies function `fn` to the argument list `args`. This is useful for - * creating a fixed-arity function from a variadic function. `fn` should be a - * bound function if context is significant. - * - * @func - * @memberOf R - * @since v0.7.0 - * @category Function - * @sig (*... -> a) -> [*] -> a - * @param {Function} fn The function which will be called with `args` - * @param {Array} args The arguments to call `fn` with - * @return {*} result The result, equivalent to `fn(...args)` - * @see R.call, R.unapply - * @example - * - * const nums = [1, 2, 3, -99, 42, 6, 7]; - * R.apply(Math.max, nums); //=> 42 - * @symb R.apply(f, [a, b, c]) = f(a, b, c) - */ -var apply = _curry2(function apply(fn, args) { - return fn.apply(this, args); -}); - -/** - * Returns a list of all the enumerable own properties of the supplied object. - * Note that the order of the output array is not guaranteed across different - * JS platforms. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Object - * @sig {k: v} -> [v] - * @param {Object} obj The object to extract values from - * @return {Array} An array of the values of the object's own properties. - * @see R.valuesIn, R.keys - * @example - * - * R.values({a: 1, b: 2, c: 3}); //=> [1, 2, 3] - */ -var values = _curry1(function values(obj) { - var props = keys(obj); - var len = props.length; - var vals = []; - var idx = 0; - while (idx < len) { - vals[idx] = obj[props[idx]]; - idx += 1; - } - return vals; -}); - -// Use custom mapValues function to avoid issues with specs that include a "map" key and R.map -// delegating calls to .map -function mapValues(fn, obj) { - return keys(obj).reduce(function(acc, key) { - acc[key] = fn(obj[key]); - return acc; - }, {}); -} - -/** - * Given a spec object recursively mapping properties to functions, creates a - * function producing an object of the same structure, by mapping each property - * to the result of calling its associated function with the supplied arguments. - * - * @func - * @memberOf R - * @since v0.20.0 - * @category Function - * @sig {k: ((a, b, ..., m) -> v)} -> ((a, b, ..., m) -> {k: v}) - * @param {Object} spec an object recursively mapping properties to functions for - * producing the values for these properties. - * @return {Function} A function that returns an object of the same structure - * as `spec', with each property set to the value returned by calling its - * associated function with the supplied arguments. - * @see R.converge, R.juxt - * @example - * - * const getMetrics = R.applySpec({ - * sum: R.add, - * nested: { mul: R.multiply } - * }); - * getMetrics(2, 4); // => { sum: 6, nested: { mul: 8 } } - * @symb R.applySpec({ x: f, y: { z: g } })(a, b) = { x: f(a, b), y: { z: g(a, b) } } - */ -var applySpec = _curry1(function applySpec(spec) { - spec = mapValues( - function(v) { return typeof v == 'function' ? v : applySpec(v); }, - spec - ); - - return curryN( - reduce(max, 0, pluck('length', values(spec))), - function() { - var args = arguments; - return mapValues(function(f) { return apply(f, args); }, spec); - }); -}); - -/** - * Takes a value and applies a function to it. - * - * This function is also known as the `thrush` combinator. - * - * @func - * @memberOf R - * @since v0.25.0 - * @category Function - * @sig a -> (a -> b) -> b - * @param {*} x The value - * @param {Function} f The function to apply - * @return {*} The result of applying `f` to `x` - * @example - * - * const t42 = R.applyTo(42); - * t42(R.identity); //=> 42 - * t42(R.add(1)); //=> 43 - */ -var applyTo = _curry2(function applyTo(x, f) { return f(x); }); - -/** - * Makes an ascending comparator function out of a function that returns a value - * that can be compared with `<` and `>`. - * - * @func - * @memberOf R - * @since v0.23.0 - * @category Function - * @sig Ord b => (a -> b) -> a -> a -> Number - * @param {Function} fn A function of arity one that returns a value that can be compared - * @param {*} a The first item to be compared. - * @param {*} b The second item to be compared. - * @return {Number} `-1` if fn(a) < fn(b), `1` if fn(b) < fn(a), otherwise `0` - * @see R.descend - * @example - * - * const byAge = R.ascend(R.prop('age')); - * const people = [ - * { name: 'Emma', age: 70 }, - * { name: 'Peter', age: 78 }, - * { name: 'Mikhail', age: 62 }, - * ]; - * const peopleByYoungestFirst = R.sort(byAge, people); - * //=> [{ name: 'Mikhail', age: 62 },{ name: 'Emma', age: 70 }, { name: 'Peter', age: 78 }] - */ -var ascend = _curry3(function ascend(fn, a, b) { - var aa = fn(a); - var bb = fn(b); - return aa < bb ? -1 : aa > bb ? 1 : 0; -}); - -/** - * Makes a shallow clone of an object, setting or overriding the specified - * property with the given value. Note that this copies and flattens prototype - * properties onto the new object as well. All non-primitive properties are - * copied by reference. - * - * @func - * @memberOf R - * @since v0.8.0 - * @category Object - * @sig String -> a -> {k: v} -> {k: v} - * @param {String} prop The property name to set - * @param {*} val The new value - * @param {Object} obj The object to clone - * @return {Object} A new object equivalent to the original except for the changed property. - * @see R.dissoc, R.pick - * @example - * - * R.assoc('c', 3, {a: 1, b: 2}); //=> {a: 1, b: 2, c: 3} - */ -var assoc = _curry3(function assoc(prop, val, obj) { - var result = {}; - for (var p in obj) { - result[p] = obj[p]; - } - result[prop] = val; - return result; -}); - -/** - * Determine if the passed argument is an integer. - * - * @private - * @param {*} n - * @category Type - * @return {Boolean} - */ -var _isInteger = Number.isInteger || function _isInteger(n) { - return (n << 0) === n; -}; - -/** - * Checks if the input value is `null` or `undefined`. - * - * @func - * @memberOf R - * @since v0.9.0 - * @category Type - * @sig * -> Boolean - * @param {*} x The value to test. - * @return {Boolean} `true` if `x` is `undefined` or `null`, otherwise `false`. - * @example - * - * R.isNil(null); //=> true - * R.isNil(undefined); //=> true - * R.isNil(0); //=> false - * R.isNil([]); //=> false - */ -var isNil = _curry1(function isNil(x) { return x == null; }); - -/** - * Makes a shallow clone of an object, setting or overriding the nodes required - * to create the given path, and placing the specific value at the tail end of - * that path. Note that this copies and flattens prototype properties onto the - * new object as well. All non-primitive properties are copied by reference. - * - * @func - * @memberOf R - * @since v0.8.0 - * @category Object - * @typedefn Idx = String | Int - * @sig [Idx] -> a -> {a} -> {a} - * @param {Array} path the path to set - * @param {*} val The new value - * @param {Object} obj The object to clone - * @return {Object} A new object equivalent to the original except along the specified path. - * @see R.dissocPath - * @example - * - * R.assocPath(['a', 'b', 'c'], 42, {a: {b: {c: 0}}}); //=> {a: {b: {c: 42}}} - * - * // Any missing or non-object keys in path will be overridden - * R.assocPath(['a', 'b', 'c'], 42, {a: 5}); //=> {a: {b: {c: 42}}} - */ -var assocPath = _curry3(function assocPath(path, val, obj) { - if (path.length === 0) { - return val; - } - var idx = path[0]; - if (path.length > 1) { - var nextObj = (!isNil(obj) && _has(idx, obj)) ? obj[idx] : _isInteger(path[1]) ? [] : {}; - val = assocPath(Array.prototype.slice.call(path, 1), val, nextObj); - } - if (_isInteger(idx) && _isArray(obj)) { - var arr = [].concat(obj); - arr[idx] = val; - return arr; - } else { - return assoc(idx, val, obj); - } -}); - -/** - * Wraps a function of any arity (including nullary) in a function that accepts - * exactly `n` parameters. Any extraneous parameters will not be passed to the - * supplied function. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Function - * @sig Number -> (* -> a) -> (* -> a) - * @param {Number} n The desired arity of the new function. - * @param {Function} fn The function to wrap. - * @return {Function} A new function wrapping `fn`. The new function is guaranteed to be of - * arity `n`. - * @see R.binary, R.unary - * @example - * - * const takesTwoArgs = (a, b) => [a, b]; - * - * takesTwoArgs.length; //=> 2 - * takesTwoArgs(1, 2); //=> [1, 2] - * - * const takesOneArg = R.nAry(1, takesTwoArgs); - * takesOneArg.length; //=> 1 - * // Only `n` arguments are passed to the wrapped function - * takesOneArg(1, 2); //=> [1, undefined] - * @symb R.nAry(0, f)(a, b) = f() - * @symb R.nAry(1, f)(a, b) = f(a) - * @symb R.nAry(2, f)(a, b) = f(a, b) - */ -var nAry = _curry2(function nAry(n, fn) { - switch (n) { - case 0: return function() {return fn.call(this);}; - case 1: return function(a0) {return fn.call(this, a0);}; - case 2: return function(a0, a1) {return fn.call(this, a0, a1);}; - case 3: return function(a0, a1, a2) {return fn.call(this, a0, a1, a2);}; - case 4: return function(a0, a1, a2, a3) {return fn.call(this, a0, a1, a2, a3);}; - case 5: return function(a0, a1, a2, a3, a4) {return fn.call(this, a0, a1, a2, a3, a4);}; - case 6: return function(a0, a1, a2, a3, a4, a5) {return fn.call(this, a0, a1, a2, a3, a4, a5);}; - case 7: return function(a0, a1, a2, a3, a4, a5, a6) {return fn.call(this, a0, a1, a2, a3, a4, a5, a6);}; - case 8: return function(a0, a1, a2, a3, a4, a5, a6, a7) {return fn.call(this, a0, a1, a2, a3, a4, a5, a6, a7);}; - case 9: return function(a0, a1, a2, a3, a4, a5, a6, a7, a8) {return fn.call(this, a0, a1, a2, a3, a4, a5, a6, a7, a8);}; - case 10: return function(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9) {return fn.call(this, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9);}; - default: throw new Error('First argument to nAry must be a non-negative integer no greater than ten'); - } -}); - -/** - * Wraps a function of any arity (including nullary) in a function that accepts - * exactly 2 parameters. Any extraneous parameters will not be passed to the - * supplied function. - * - * @func - * @memberOf R - * @since v0.2.0 - * @category Function - * @sig (* -> c) -> (a, b -> c) - * @param {Function} fn The function to wrap. - * @return {Function} A new function wrapping `fn`. The new function is guaranteed to be of - * arity 2. - * @see R.nAry, R.unary - * @example - * - * const takesThreeArgs = function(a, b, c) { - * return [a, b, c]; - * }; - * takesThreeArgs.length; //=> 3 - * takesThreeArgs(1, 2, 3); //=> [1, 2, 3] - * - * const takesTwoArgs = R.binary(takesThreeArgs); - * takesTwoArgs.length; //=> 2 - * // Only 2 arguments are passed to the wrapped function - * takesTwoArgs(1, 2, 3); //=> [1, 2, undefined] - * @symb R.binary(f)(a, b, c) = f(a, b) - */ -var binary = _curry1(function binary(fn) { - return nAry(2, fn); -}); - -function _isFunction(x) { - return Object.prototype.toString.call(x) === '[object Function]'; -} - -/** - * "lifts" a function to be the specified arity, so that it may "map over" that - * many lists, Functions or other objects that satisfy the [FantasyLand Apply spec](https://github.com/fantasyland/fantasy-land#apply). - * - * @func - * @memberOf R - * @since v0.7.0 - * @category Function - * @sig Number -> (*... -> *) -> ([*]... -> [*]) - * @param {Function} fn The function to lift into higher context - * @return {Function} The lifted function. - * @see R.lift, R.ap - * @example - * - * const madd3 = R.liftN(3, (...args) => R.sum(args)); - * madd3([1,2,3], [1,2,3], [1]); //=> [3, 4, 5, 4, 5, 6, 5, 6, 7] - */ -var liftN = _curry2(function liftN(arity, fn) { - var lifted = curryN(arity, fn); - return curryN(arity, function() { - return _reduce(ap, map(lifted, arguments[0]), Array.prototype.slice.call(arguments, 1)); - }); -}); - -/** - * "lifts" a function of arity > 1 so that it may "map over" a list, Function or other - * object that satisfies the [FantasyLand Apply spec](https://github.com/fantasyland/fantasy-land#apply). - * - * @func - * @memberOf R - * @since v0.7.0 - * @category Function - * @sig (*... -> *) -> ([*]... -> [*]) - * @param {Function} fn The function to lift into higher context - * @return {Function} The lifted function. - * @see R.liftN - * @example - * - * const madd3 = R.lift((a, b, c) => a + b + c); - * - * madd3([1,2,3], [1,2,3], [1]); //=> [3, 4, 5, 4, 5, 6, 5, 6, 7] - * - * const madd5 = R.lift((a, b, c, d, e) => a + b + c + d + e); - * - * madd5([1,2], [3], [4, 5], [6], [7, 8]); //=> [21, 22, 22, 23, 22, 23, 23, 24] - */ -var lift = _curry1(function lift(fn) { - return liftN(fn.length, fn); -}); - -/** - * A function which calls the two provided functions and returns the `&&` - * of the results. - * It returns the result of the first function if it is false-y and the result - * of the second function otherwise. Note that this is short-circuited, - * meaning that the second function will not be invoked if the first returns a - * false-y value. - * - * In addition to functions, `R.both` also accepts any fantasy-land compatible - * applicative functor. - * - * @func - * @memberOf R - * @since v0.12.0 - * @category Logic - * @sig (*... -> Boolean) -> (*... -> Boolean) -> (*... -> Boolean) - * @param {Function} f A predicate - * @param {Function} g Another predicate - * @return {Function} a function that applies its arguments to `f` and `g` and `&&`s their outputs together. - * @see R.and - * @example - * - * const gt10 = R.gt(R.__, 10) - * const lt20 = R.lt(R.__, 20) - * const f = R.both(gt10, lt20); - * f(15); //=> true - * f(30); //=> false - * - * R.both(Maybe.Just(false), Maybe.Just(55)); // => Maybe.Just(false) - * R.both([false, false, 'a'], [11]); //=> [false, false, 11] - */ -var both = _curry2(function both(f, g) { - return _isFunction(f) ? - function _both() { - return f.apply(this, arguments) && g.apply(this, arguments); - } : - lift(and)(f, g); -}); - -/** - * Returns a curried equivalent of the provided function. The curried function - * has two unusual capabilities. First, its arguments needn't be provided one - * at a time. If `f` is a ternary function and `g` is `R.curry(f)`, the - * following are equivalent: - * - * - `g(1)(2)(3)` - * - `g(1)(2, 3)` - * - `g(1, 2)(3)` - * - `g(1, 2, 3)` - * - * Secondly, the special placeholder value [`R.__`](#__) may be used to specify - * "gaps", allowing partial application of any combination of arguments, - * regardless of their positions. If `g` is as above and `_` is [`R.__`](#__), - * the following are equivalent: - * - * - `g(1, 2, 3)` - * - `g(_, 2, 3)(1)` - * - `g(_, _, 3)(1)(2)` - * - `g(_, _, 3)(1, 2)` - * - `g(_, 2)(1)(3)` - * - `g(_, 2)(1, 3)` - * - `g(_, 2)(_, 3)(1)` - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Function - * @sig (* -> a) -> (* -> a) - * @param {Function} fn The function to curry. - * @return {Function} A new, curried function. - * @see R.curryN, R.partial - * @example - * - * const addFourNumbers = (a, b, c, d) => a + b + c + d; - * - * const curriedAddFourNumbers = R.curry(addFourNumbers); - * const f = curriedAddFourNumbers(1, 2); - * const g = f(3); - * g(4); //=> 10 - */ -var curry = _curry1(function curry(fn) { - return curryN(fn.length, fn); -}); - -/** - * Returns the result of calling its first argument with the remaining - * arguments. This is occasionally useful as a converging function for - * [`R.converge`](#converge): the first branch can produce a function while the - * remaining branches produce values to be passed to that function as its - * arguments. - * - * @func - * @memberOf R - * @since v0.9.0 - * @category Function - * @sig (*... -> a),*... -> a - * @param {Function} fn The function to apply to the remaining arguments. - * @param {...*} args Any number of positional arguments. - * @return {*} - * @see R.apply - * @example - * - * R.call(R.add, 1, 2); //=> 3 - * - * const indentN = R.pipe(R.repeat(' '), - * R.join(''), - * R.replace(/^(?!$)/gm)); - * - * const format = R.converge(R.call, [ - * R.pipe(R.prop('indent'), indentN), - * R.prop('value') - * ]); - * - * format({indent: 2, value: 'foo\nbar\nbaz\n'}); //=> ' foo\n bar\n baz\n' - * @symb R.call(f, a, b) = f(a, b) - */ -var call = curry(function call(fn) { - return fn.apply(this, Array.prototype.slice.call(arguments, 1)); -}); - -/** - * `_makeFlat` is a helper function that returns a one-level or fully recursive - * function based on the flag passed in. - * - * @private - */ -function _makeFlat(recursive) { - return function flatt(list) { - var value, jlen, j; - var result = []; - var idx = 0; - var ilen = list.length; - - while (idx < ilen) { - if (_isArrayLike(list[idx])) { - value = recursive ? flatt(list[idx]) : list[idx]; - j = 0; - jlen = value.length; - while (j < jlen) { - result[result.length] = value[j]; - j += 1; - } - } else { - result[result.length] = list[idx]; - } - idx += 1; - } - return result; - }; -} - -function _forceReduced(x) { - return { - '@@transducer/value': x, - '@@transducer/reduced': true - }; -} - -var preservingReduced = function(xf) { - return { - '@@transducer/init': _xfBase.init, - '@@transducer/result': function(result) { - return xf['@@transducer/result'](result); - }, - '@@transducer/step': function(result, input) { - var ret = xf['@@transducer/step'](result, input); - return ret['@@transducer/reduced'] ? _forceReduced(ret) : ret; - } - }; -}; - -var _flatCat = function _xcat(xf) { - var rxf = preservingReduced(xf); - return { - '@@transducer/init': _xfBase.init, - '@@transducer/result': function(result) { - return rxf['@@transducer/result'](result); - }, - '@@transducer/step': function(result, input) { - return !_isArrayLike(input) ? _reduce(rxf, result, [input]) : _reduce(rxf, result, input); - } - }; -}; - -var _xchain = _curry2(function _xchain(f, xf) { - return map(f, _flatCat(xf)); -}); - -/** - * `chain` maps a function over a list and concatenates the results. `chain` - * is also known as `flatMap` in some libraries. - * - * Dispatches to the `chain` method of the second argument, if present, - * according to the [FantasyLand Chain spec](https://github.com/fantasyland/fantasy-land#chain). - * - * If second argument is a function, `chain(f, g)(x)` is equivalent to `f(g(x), x)`. - * - * Acts as a transducer if a transformer is given in list position. - * - * @func - * @memberOf R - * @since v0.3.0 - * @category List - * @sig Chain m => (a -> m b) -> m a -> m b - * @param {Function} fn The function to map with - * @param {Array} list The list to map over - * @return {Array} The result of flat-mapping `list` with `fn` - * @example - * - * const duplicate = n => [n, n]; - * R.chain(duplicate, [1, 2, 3]); //=> [1, 1, 2, 2, 3, 3] - * - * R.chain(R.append, R.head)([1, 2, 3]); //=> [1, 2, 3, 1] - */ -var chain = _curry2(_dispatchable(['fantasy-land/chain', 'chain'], _xchain, function chain(fn, monad) { - if (typeof monad === 'function') { - return function(x) { return fn(monad(x))(x); }; - } - return _makeFlat(false)(map(fn, monad)); -})); - -/** - * Restricts a number to be within a range. - * - * Also works for other ordered types such as Strings and Dates. - * - * @func - * @memberOf R - * @since v0.20.0 - * @category Relation - * @sig Ord a => a -> a -> a -> a - * @param {Number} minimum The lower limit of the clamp (inclusive) - * @param {Number} maximum The upper limit of the clamp (inclusive) - * @param {Number} value Value to be clamped - * @return {Number} Returns `minimum` when `val < minimum`, `maximum` when `val > maximum`, returns `val` otherwise - * @example - * - * R.clamp(1, 10, -5) // => 1 - * R.clamp(1, 10, 15) // => 10 - * R.clamp(1, 10, 4) // => 4 - */ -var clamp = _curry3(function clamp(min, max, value) { - if (min > max) { - throw new Error('min must not be greater than max in clamp(min, max, value)'); - } - return value < min ? min : - value > max ? max : - value; -}); - -function _cloneRegExp(pattern) { - return new RegExp(pattern.source, (pattern.global ? 'g' : '') + - (pattern.ignoreCase ? 'i' : '') + - (pattern.multiline ? 'm' : '') + - (pattern.sticky ? 'y' : '') + - (pattern.unicode ? 'u' : '')); -} - -/** - * Gives a single-word string description of the (native) type of a value, - * returning such answers as 'Object', 'Number', 'Array', or 'Null'. Does not - * attempt to distinguish user Object types any further, reporting them all as - * 'Object'. - * - * @func - * @memberOf R - * @since v0.8.0 - * @category Type - * @sig (* -> {*}) -> String - * @param {*} val The value to test - * @return {String} - * @example - * - * R.type({}); //=> "Object" - * R.type(1); //=> "Number" - * R.type(false); //=> "Boolean" - * R.type('s'); //=> "String" - * R.type(null); //=> "Null" - * R.type([]); //=> "Array" - * R.type(/[A-z]/); //=> "RegExp" - * R.type(() => {}); //=> "Function" - * R.type(undefined); //=> "Undefined" - */ -var type = _curry1(function type(val) { - return val === null ? 'Null' : - val === undefined ? 'Undefined' : - Object.prototype.toString.call(val).slice(8, -1); -}); - -/** - * Copies an object. - * - * @private - * @param {*} value The value to be copied - * @param {Array} refFrom Array containing the source references - * @param {Array} refTo Array containing the copied source references - * @param {Boolean} deep Whether or not to perform deep cloning. - * @return {*} The copied value. - */ -function _clone(value, refFrom, refTo, deep) { - var copy = function copy(copiedValue) { - var len = refFrom.length; - var idx = 0; - while (idx < len) { - if (value === refFrom[idx]) { - return refTo[idx]; - } - idx += 1; - } - refFrom[idx + 1] = value; - refTo[idx + 1] = copiedValue; - for (var key in value) { - copiedValue[key] = deep ? - _clone(value[key], refFrom, refTo, true) : value[key]; - } - return copiedValue; - }; - switch (type(value)) { - case 'Object': return copy({}); - case 'Array': return copy([]); - case 'Date': return new Date(value.valueOf()); - case 'RegExp': return _cloneRegExp(value); - default: return value; - } -} - -/** - * Creates a deep copy of the value which may contain (nested) `Array`s and - * `Object`s, `Number`s, `String`s, `Boolean`s and `Date`s. `Function`s are - * assigned by reference rather than copied - * - * Dispatches to a `clone` method if present. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Object - * @sig {*} -> {*} - * @param {*} value The object or array to clone - * @return {*} A deeply cloned copy of `val` - * @example - * - * const objects = [{}, {}, {}]; - * const objectsClone = R.clone(objects); - * objects === objectsClone; //=> false - * objects[0] === objectsClone[0]; //=> false - */ -var clone = _curry1(function clone(value) { - return value != null && typeof value.clone === 'function' ? - value.clone() : - _clone(value, [], [], true); -}); - -/** - * Makes a comparator function out of a function that reports whether the first - * element is less than the second. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Function - * @sig ((a, b) -> Boolean) -> ((a, b) -> Number) - * @param {Function} pred A predicate function of arity two which will return `true` if the first argument - * is less than the second, `false` otherwise - * @return {Function} A Function :: a -> b -> Int that returns `-1` if a < b, `1` if b < a, otherwise `0` - * @example - * - * const byAge = R.comparator((a, b) => a.age < b.age); - * const people = [ - * { name: 'Emma', age: 70 }, - * { name: 'Peter', age: 78 }, - * { name: 'Mikhail', age: 62 }, - * ]; - * const peopleByIncreasingAge = R.sort(byAge, people); - * //=> [{ name: 'Mikhail', age: 62 },{ name: 'Emma', age: 70 }, { name: 'Peter', age: 78 }] - */ -var comparator = _curry1(function comparator(pred) { - return function(a, b) { - return pred(a, b) ? -1 : pred(b, a) ? 1 : 0; - }; -}); - -/** - * A function that returns the `!` of its argument. It will return `true` when - * passed false-y value, and `false` when passed a truth-y one. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Logic - * @sig * -> Boolean - * @param {*} a any value - * @return {Boolean} the logical inverse of passed argument. - * @see R.complement - * @example - * - * R.not(true); //=> false - * R.not(false); //=> true - * R.not(0); //=> true - * R.not(1); //=> false - */ -var not = _curry1(function not(a) { - return !a; -}); - -/** - * Takes a function `f` and returns a function `g` such that if called with the same arguments - * when `f` returns a "truthy" value, `g` returns `false` and when `f` returns a "falsy" value `g` returns `true`. - * - * `R.complement` may be applied to any functor - * - * @func - * @memberOf R - * @since v0.12.0 - * @category Logic - * @sig (*... -> *) -> (*... -> Boolean) - * @param {Function} f - * @return {Function} - * @see R.not - * @example - * - * const isNotNil = R.complement(R.isNil); - * isNil(null); //=> true - * isNotNil(null); //=> false - * isNil(7); //=> false - * isNotNil(7); //=> true - */ -var complement = lift(not); - -function _pipe(f, g) { - return function() { - return g.call(this, f.apply(this, arguments)); - }; -} - -/** - * This checks whether a function has a [methodname] function. If it isn't an - * array it will execute that function otherwise it will default to the ramda - * implementation. - * - * @private - * @param {Function} fn ramda implementation - * @param {String} methodname property to check for a custom implementation - * @return {Object} Whatever the return value of the method is. - */ -function _checkForMethod(methodname, fn) { - return function() { - var length = arguments.length; - if (length === 0) { - return fn(); - } - var obj = arguments[length - 1]; - return (_isArray(obj) || typeof obj[methodname] !== 'function') ? - fn.apply(this, arguments) : - obj[methodname].apply(obj, Array.prototype.slice.call(arguments, 0, length - 1)); - }; -} - -/** - * Returns the elements of the given list or string (or object with a `slice` - * method) from `fromIndex` (inclusive) to `toIndex` (exclusive). - * - * Dispatches to the `slice` method of the third argument, if present. - * - * @func - * @memberOf R - * @since v0.1.4 - * @category List - * @sig Number -> Number -> [a] -> [a] - * @sig Number -> Number -> String -> String - * @param {Number} fromIndex The start index (inclusive). - * @param {Number} toIndex The end index (exclusive). - * @param {*} list - * @return {*} - * @example - * - * R.slice(1, 3, ['a', 'b', 'c', 'd']); //=> ['b', 'c'] - * R.slice(1, Infinity, ['a', 'b', 'c', 'd']); //=> ['b', 'c', 'd'] - * R.slice(0, -1, ['a', 'b', 'c', 'd']); //=> ['a', 'b', 'c'] - * R.slice(-3, -1, ['a', 'b', 'c', 'd']); //=> ['b', 'c'] - * R.slice(0, 3, 'ramda'); //=> 'ram' - */ -var slice = _curry3(_checkForMethod('slice', function slice(fromIndex, toIndex, list) { - return Array.prototype.slice.call(list, fromIndex, toIndex); -})); - -/** - * Returns all but the first element of the given list or string (or object - * with a `tail` method). - * - * Dispatches to the `slice` method of the first argument, if present. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category List - * @sig [a] -> [a] - * @sig String -> String - * @param {*} list - * @return {*} - * @see R.head, R.init, R.last - * @example - * - * R.tail([1, 2, 3]); //=> [2, 3] - * R.tail([1, 2]); //=> [2] - * R.tail([1]); //=> [] - * R.tail([]); //=> [] - * - * R.tail('abc'); //=> 'bc' - * R.tail('ab'); //=> 'b' - * R.tail('a'); //=> '' - * R.tail(''); //=> '' - */ -var tail = _curry1(_checkForMethod('tail', slice(1, Infinity))); - -/** - * Performs left-to-right function composition. The leftmost function may have - * any arity; the remaining functions must be unary. - * - * In some libraries this function is named `sequence`. - * - * **Note:** The result of pipe is not automatically curried. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Function - * @sig (((a, b, ..., n) -> o), (o -> p), ..., (x -> y), (y -> z)) -> ((a, b, ..., n) -> z) - * @param {...Function} functions - * @return {Function} - * @see R.compose - * @example - * - * const f = R.pipe(Math.pow, R.negate, R.inc); - * - * f(3, 4); // -(3^4) + 1 - * @symb R.pipe(f, g, h)(a, b) = h(g(f(a, b))) - */ -function pipe() { - if (arguments.length === 0) { - throw new Error('pipe requires at least one argument'); - } - return _arity(arguments[0].length, - reduce(_pipe, arguments[0], tail(arguments))); -} - -/** - * Returns a new list or string with the elements or characters in reverse - * order. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category List - * @sig [a] -> [a] - * @sig String -> String - * @param {Array|String} list - * @return {Array|String} - * @example - * - * R.reverse([1, 2, 3]); //=> [3, 2, 1] - * R.reverse([1, 2]); //=> [2, 1] - * R.reverse([1]); //=> [1] - * R.reverse([]); //=> [] - * - * R.reverse('abc'); //=> 'cba' - * R.reverse('ab'); //=> 'ba' - * R.reverse('a'); //=> 'a' - * R.reverse(''); //=> '' - */ -var reverse = _curry1(function reverse(list) { - return _isString(list) ? list.split('').reverse().join('') : - Array.prototype.slice.call(list, 0).reverse(); -}); - -/** - * Performs right-to-left function composition. The rightmost function may have - * any arity; the remaining functions must be unary. - * - * **Note:** The result of compose is not automatically curried. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Function - * @sig ((y -> z), (x -> y), ..., (o -> p), ((a, b, ..., n) -> o)) -> ((a, b, ..., n) -> z) - * @param {...Function} ...functions The functions to compose - * @return {Function} - * @see R.pipe - * @example - * - * const classyGreeting = (firstName, lastName) => "The name's " + lastName + ", " + firstName + " " + lastName - * const yellGreeting = R.compose(R.toUpper, classyGreeting); - * yellGreeting('James', 'Bond'); //=> "THE NAME'S BOND, JAMES BOND" - * - * R.compose(Math.abs, R.add(1), R.multiply(2))(-4) //=> 7 - * - * @symb R.compose(f, g, h)(a, b) = f(g(h(a, b))) - */ -function compose() { - if (arguments.length === 0) { - throw new Error('compose requires at least one argument'); - } - return pipe.apply(this, reverse(arguments)); -} - -/** - * Returns the right-to-left Kleisli composition of the provided functions, - * each of which must return a value of a type supported by [`chain`](#chain). - * - * `R.composeK(h, g, f)` is equivalent to `R.compose(R.chain(h), R.chain(g), f)`. - * - * @func - * @memberOf R - * @since v0.16.0 - * @category Function - * @sig Chain m => ((y -> m z), (x -> m y), ..., (a -> m b)) -> (a -> m z) - * @param {...Function} ...functions The functions to compose - * @return {Function} - * @see R.pipeK - * @example - * - * // get :: String -> Object -> Maybe * - * const get = R.curry((propName, obj) => Maybe(obj[propName])) - * - * // getStateCode :: Maybe String -> Maybe String - * const getStateCode = R.composeK( - * R.compose(Maybe.of, R.toUpper), - * get('state'), - * get('address'), - * get('user'), - * ); - * getStateCode({"user":{"address":{"state":"ny"}}}); //=> Maybe.Just("NY") - * getStateCode({}); //=> Maybe.Nothing() - * @symb R.composeK(f, g, h)(a) = R.chain(f, R.chain(g, h(a))) - */ -function composeK() { - if (arguments.length === 0) { - throw new Error('composeK requires at least one argument'); - } - var init = Array.prototype.slice.call(arguments); - var last = init.pop(); - return compose(compose.apply(this, map(chain, init)), last); -} - -function _pipeP(f, g) { - return function() { - var ctx = this; - return f.apply(ctx, arguments).then(function(x) { - return g.call(ctx, x); - }); - }; -} - -/** - * Performs left-to-right composition of one or more Promise-returning - * functions. The leftmost function may have any arity; the remaining functions - * must be unary. - * - * @func - * @memberOf R - * @since v0.10.0 - * @category Function - * @sig ((a -> Promise b), (b -> Promise c), ..., (y -> Promise z)) -> (a -> Promise z) - * @param {...Function} functions - * @return {Function} - * @see R.composeP - * @example - * - * // followersForUser :: String -> Promise [User] - * const followersForUser = R.pipeP(db.getUserById, db.getFollowers); - */ -function pipeP() { - if (arguments.length === 0) { - throw new Error('pipeP requires at least one argument'); - } - return _arity(arguments[0].length, - reduce(_pipeP, arguments[0], tail(arguments))); -} - -/** - * Performs right-to-left composition of one or more Promise-returning - * functions. The rightmost function may have any arity; the remaining - * functions must be unary. - * - * @func - * @memberOf R - * @since v0.10.0 - * @category Function - * @sig ((y -> Promise z), (x -> Promise y), ..., (a -> Promise b)) -> (a -> Promise z) - * @param {...Function} functions The functions to compose - * @return {Function} - * @see R.pipeP - * @example - * - * const db = { - * users: { - * JOE: { - * name: 'Joe', - * followers: ['STEVE', 'SUZY'] - * } - * } - * } - * - * // We'll pretend to do a db lookup which returns a promise - * const lookupUser = (userId) => Promise.resolve(db.users[userId]) - * const lookupFollowers = (user) => Promise.resolve(user.followers) - * lookupUser('JOE').then(lookupFollowers) - * - * // followersForUser :: String -> Promise [UserId] - * const followersForUser = R.composeP(lookupFollowers, lookupUser); - * followersForUser('JOE').then(followers => console.log('Followers:', followers)) - * // Followers: ["STEVE","SUZY"] - */ -function composeP() { - if (arguments.length === 0) { - throw new Error('composeP requires at least one argument'); - } - return pipeP.apply(this, reverse(arguments)); -} - -/** - * Returns the nth element of the given list or string. If n is negative the - * element at index length + n is returned. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category List - * @sig Number -> [a] -> a | Undefined - * @sig Number -> String -> String - * @param {Number} offset - * @param {*} list - * @return {*} - * @example - * - * const list = ['foo', 'bar', 'baz', 'quux']; - * R.nth(1, list); //=> 'bar' - * R.nth(-1, list); //=> 'quux' - * R.nth(-99, list); //=> undefined - * - * R.nth(2, 'abc'); //=> 'c' - * R.nth(3, 'abc'); //=> '' - * @symb R.nth(-1, [a, b, c]) = c - * @symb R.nth(0, [a, b, c]) = a - * @symb R.nth(1, [a, b, c]) = b - */ -var nth = _curry2(function nth(offset, list) { - var idx = offset < 0 ? list.length + offset : offset; - return _isString(list) ? list.charAt(idx) : list[idx]; -}); - -/** - * Returns the first element of the given list or string. In some libraries - * this function is named `first`. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category List - * @sig [a] -> a | Undefined - * @sig String -> String - * @param {Array|String} list - * @return {*} - * @see R.tail, R.init, R.last - * @example - * - * R.head(['fi', 'fo', 'fum']); //=> 'fi' - * R.head([]); //=> undefined - * - * R.head('abc'); //=> 'a' - * R.head(''); //=> '' - */ -var head = nth(0); - -function _identity(x) { return x; } - -/** - * A function that does nothing but return the parameter supplied to it. Good - * as a default or placeholder function. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Function - * @sig a -> a - * @param {*} x The value to return. - * @return {*} The input value, `x`. - * @example - * - * R.identity(1); //=> 1 - * - * const obj = {}; - * R.identity(obj) === obj; //=> true - * @symb R.identity(a) = a - */ -var identity = _curry1(_identity); - -/** - * Performs left-to-right function composition using transforming function. The leftmost function may have - * any arity; the remaining functions must be unary. - * - * **Note:** The result of pipeWith is not automatically curried. - * - * @func - * @memberOf R - * @category Function - * @sig ((* -> *), [((a, b, ..., n) -> o), (o -> p), ..., (x -> y), (y -> z)]) -> ((a, b, ..., n) -> z) - * @param {...Function} functions - * @return {Function} - * @see R.composeWith, R.pipe - * @example - * - * const pipeWhileNotNil = R.pipeWith((f, res) => R.isNil(res) ? res : f(res)); - * const f = pipeWhileNotNil([Math.pow, R.negate, R.inc]) - * - * f(3, 4); // -(3^4) + 1 - * @symb R.pipeWith(f)([g, h, i])(...args) = f(i, f(h, f(g, ...args))) - */ -var pipeWith = _curry2(function pipeWith(xf, list) { - if (list.length <= 0) { - return identity; - } - - const headList = head(list); - const tailList = tail(list); - - return _arity(headList.length, function() { - return _reduce( - function(result, f) { - return xf.call(this, f, result); - }, - headList.apply(this, arguments), - tailList - ); - }); -}); - -/** - * Performs right-to-left function composition using transforming function. The rightmost function may have - * any arity; the remaining functions must be unary. - * - * **Note:** The result of compose is not automatically curried. - * - * @func - * @memberOf R - * @category Function - * @sig ((* -> *), [(y -> z), (x -> y), ..., (o -> p), ((a, b, ..., n) -> o)]) -> ((a, b, ..., n) -> z) - * @param {...Function} ...functions The functions to compose - * @return {Function} - * @see R.compose, R.pipeWith - * @example - * - * const composeWhileNotNil = R.composeWith((f, res) => R.isNil(res) ? res : f(res)); - * - * composeWhileNotNil([R.inc, R.prop('age')])({age: 1}) //=> 2 - * composeWhileNotNil([R.inc, R.prop('age')])({}) //=> null - * - * @symb R.composeWith(f)([g, h, i])(...args) = f(g, f(h, f(i, ...args))) - */ -var composeWith = _curry2(function composeWith(xf, list) { - return pipeWith.apply(this, [xf, reverse(list)]); -}); - -function _arrayFromIterator(iter) { - var list = []; - var next; - while (!(next = iter.next()).done) { - list.push(next.value); - } - return list; -} - -function _includesWith(pred, x, list) { - var idx = 0; - var len = list.length; - - while (idx < len) { - if (pred(x, list[idx])) { - return true; - } - idx += 1; - } - return false; -} - -function _functionName(f) { - // String(x => x) evaluates to "x => x", so the pattern may not match. - var match = String(f).match(/^function (\w*)/); - return match == null ? '' : match[1]; -} - -// Based on https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is -function _objectIs(a, b) { - // SameValue algorithm - if (a === b) { // Steps 1-5, 7-10 - // Steps 6.b-6.e: +0 != -0 - return a !== 0 || 1 / a === 1 / b; - } else { - // Step 6.a: NaN == NaN - return a !== a && b !== b; - } -} - -var _objectIs$1 = typeof Object.is === 'function' ? Object.is : _objectIs; - -/** - * private _uniqContentEquals function. - * That function is checking equality of 2 iterator contents with 2 assumptions - * - iterators lengths are the same - * - iterators values are unique - * - * false-positive result will be returned for comparision of, e.g. - * - [1,2,3] and [1,2,3,4] - * - [1,1,1] and [1,2,3] - * */ - -function _uniqContentEquals(aIterator, bIterator, stackA, stackB) { - var a = _arrayFromIterator(aIterator); - var b = _arrayFromIterator(bIterator); - - function eq(_a, _b) { - return _equals(_a, _b, stackA.slice(), stackB.slice()); - } - - // if *a* array contains any element that is not included in *b* - return !_includesWith(function(b, aItem) { - return !_includesWith(eq, aItem, b); - }, b, a); -} - -function _equals(a, b, stackA, stackB) { - if (_objectIs$1(a, b)) { - return true; - } - - var typeA = type(a); - - if (typeA !== type(b)) { - return false; - } - - if (a == null || b == null) { - return false; - } - - if (typeof a['fantasy-land/equals'] === 'function' || typeof b['fantasy-land/equals'] === 'function') { - return typeof a['fantasy-land/equals'] === 'function' && a['fantasy-land/equals'](b) && - typeof b['fantasy-land/equals'] === 'function' && b['fantasy-land/equals'](a); - } - - if (typeof a.equals === 'function' || typeof b.equals === 'function') { - return typeof a.equals === 'function' && a.equals(b) && - typeof b.equals === 'function' && b.equals(a); - } - - switch (typeA) { - case 'Arguments': - case 'Array': - case 'Object': - if (typeof a.constructor === 'function' && - _functionName(a.constructor) === 'Promise') { - return a === b; - } - break; - case 'Boolean': - case 'Number': - case 'String': - if (!(typeof a === typeof b && _objectIs$1(a.valueOf(), b.valueOf()))) { - return false; - } - break; - case 'Date': - if (!_objectIs$1(a.valueOf(), b.valueOf())) { - return false; - } - break; - case 'Error': - return a.name === b.name && a.message === b.message; - case 'RegExp': - if (!(a.source === b.source && - a.global === b.global && - a.ignoreCase === b.ignoreCase && - a.multiline === b.multiline && - a.sticky === b.sticky && - a.unicode === b.unicode)) { - return false; - } - break; - } - - var idx = stackA.length - 1; - while (idx >= 0) { - if (stackA[idx] === a) { - return stackB[idx] === b; - } - idx -= 1; - } - - switch (typeA) { - case 'Map': - if (a.size !== b.size) { - return false; - } - - return _uniqContentEquals(a.entries(), b.entries(), stackA.concat([a]), stackB.concat([b])); - case 'Set': - if (a.size !== b.size) { - return false; - } - - return _uniqContentEquals(a.values(), b.values(), stackA.concat([a]), stackB.concat([b])); - case 'Arguments': - case 'Array': - case 'Object': - case 'Boolean': - case 'Number': - case 'String': - case 'Date': - case 'Error': - case 'RegExp': - case 'Int8Array': - case 'Uint8Array': - case 'Uint8ClampedArray': - case 'Int16Array': - case 'Uint16Array': - case 'Int32Array': - case 'Uint32Array': - case 'Float32Array': - case 'Float64Array': - case 'ArrayBuffer': - break; - default: - // Values of other types are only equal if identical. - return false; - } - - var keysA = keys(a); - if (keysA.length !== keys(b).length) { - return false; - } - - var extendedStackA = stackA.concat([a]); - var extendedStackB = stackB.concat([b]); - - idx = keysA.length - 1; - while (idx >= 0) { - var key = keysA[idx]; - if (!(_has(key, b) && _equals(b[key], a[key], extendedStackA, extendedStackB))) { - return false; - } - idx -= 1; - } - return true; -} - -/** - * Returns `true` if its arguments are equivalent, `false` otherwise. Handles - * cyclical data structures. - * - * Dispatches symmetrically to the `equals` methods of both arguments, if - * present. - * - * @func - * @memberOf R - * @since v0.15.0 - * @category Relation - * @sig a -> b -> Boolean - * @param {*} a - * @param {*} b - * @return {Boolean} - * @example - * - * R.equals(1, 1); //=> true - * R.equals(1, '1'); //=> false - * R.equals([1, 2, 3], [1, 2, 3]); //=> true - * - * const a = {}; a.v = a; - * const b = {}; b.v = b; - * R.equals(a, b); //=> true - */ -var equals = _curry2(function equals(a, b) { - return _equals(a, b, [], []); -}); - -function _indexOf(list, a, idx) { - var inf, item; - // Array.prototype.indexOf doesn't exist below IE9 - if (typeof list.indexOf === 'function') { - switch (typeof a) { - case 'number': - if (a === 0) { - // manually crawl the list to distinguish between +0 and -0 - inf = 1 / a; - while (idx < list.length) { - item = list[idx]; - if (item === 0 && 1 / item === inf) { - return idx; - } - idx += 1; - } - return -1; - } else if (a !== a) { - // NaN - while (idx < list.length) { - item = list[idx]; - if (typeof item === 'number' && item !== item) { - return idx; - } - idx += 1; - } - return -1; - } - // non-zero numbers can utilise Set - return list.indexOf(a, idx); - - // all these types can utilise Set - case 'string': - case 'boolean': - case 'function': - case 'undefined': - return list.indexOf(a, idx); - - case 'object': - if (a === null) { - // null can utilise Set - return list.indexOf(a, idx); - } - } - } - // anything else not covered above, defer to R.equals - while (idx < list.length) { - if (equals(list[idx], a)) { - return idx; - } - idx += 1; - } - return -1; -} - -function _includes(a, list) { - return _indexOf(list, a, 0) >= 0; -} - -function _quote(s) { - var escaped = s - .replace(/\\/g, '\\\\') - .replace(/[\b]/g, '\\b') // \b matches word boundary; [\b] matches backspace - .replace(/\f/g, '\\f') - .replace(/\n/g, '\\n') - .replace(/\r/g, '\\r') - .replace(/\t/g, '\\t') - .replace(/\v/g, '\\v') - .replace(/\0/g, '\\0'); - - return '"' + escaped.replace(/"/g, '\\"') + '"'; -} - -/** - * Polyfill from . - */ -var pad = function pad(n) { return (n < 10 ? '0' : '') + n; }; - -var _toISOString = typeof Date.prototype.toISOString === 'function' ? - function _toISOString(d) { - return d.toISOString(); - } : - function _toISOString(d) { - return ( - d.getUTCFullYear() + '-' + - pad(d.getUTCMonth() + 1) + '-' + - pad(d.getUTCDate()) + 'T' + - pad(d.getUTCHours()) + ':' + - pad(d.getUTCMinutes()) + ':' + - pad(d.getUTCSeconds()) + '.' + - (d.getUTCMilliseconds() / 1000).toFixed(3).slice(2, 5) + 'Z' - ); - }; - -function _complement(f) { - return function() { - return !f.apply(this, arguments); - }; -} - -function _filter(fn, list) { - var idx = 0; - var len = list.length; - var result = []; - - while (idx < len) { - if (fn(list[idx])) { - result[result.length] = list[idx]; - } - idx += 1; - } - return result; -} - -function _isObject(x) { - return Object.prototype.toString.call(x) === '[object Object]'; -} - -function XFilter(f, xf) { - this.xf = xf; - this.f = f; -} -XFilter.prototype['@@transducer/init'] = _xfBase.init; -XFilter.prototype['@@transducer/result'] = _xfBase.result; -XFilter.prototype['@@transducer/step'] = function(result, input) { - return this.f(input) ? this.xf['@@transducer/step'](result, input) : result; -}; - -var _xfilter = _curry2(function _xfilter(f, xf) { return new XFilter(f, xf); }); - -/** - * Takes a predicate and a `Filterable`, and returns a new filterable of the - * same type containing the members of the given filterable which satisfy the - * given predicate. Filterable objects include plain objects or any object - * that has a filter method such as `Array`. - * - * Dispatches to the `filter` method of the second argument, if present. - * - * Acts as a transducer if a transformer is given in list position. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category List - * @sig Filterable f => (a -> Boolean) -> f a -> f a - * @param {Function} pred - * @param {Array} filterable - * @return {Array} Filterable - * @see R.reject, R.transduce, R.addIndex - * @example - * - * const isEven = n => n % 2 === 0; - * - * R.filter(isEven, [1, 2, 3, 4]); //=> [2, 4] - * - * R.filter(isEven, {a: 1, b: 2, c: 3, d: 4}); //=> {b: 2, d: 4} - */ -var filter = _curry2(_dispatchable(['filter'], _xfilter, function(pred, filterable) { - return ( - _isObject(filterable) ? - _reduce(function(acc, key) { - if (pred(filterable[key])) { - acc[key] = filterable[key]; - } - return acc; - }, {}, keys(filterable)) : - // else - _filter(pred, filterable) - ); -})); - -/** - * The complement of [`filter`](#filter). - * - * Acts as a transducer if a transformer is given in list position. Filterable - * objects include plain objects or any object that has a filter method such - * as `Array`. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category List - * @sig Filterable f => (a -> Boolean) -> f a -> f a - * @param {Function} pred - * @param {Array} filterable - * @return {Array} - * @see R.filter, R.transduce, R.addIndex - * @example - * - * const isOdd = (n) => n % 2 === 1; - * - * R.reject(isOdd, [1, 2, 3, 4]); //=> [2, 4] - * - * R.reject(isOdd, {a: 1, b: 2, c: 3, d: 4}); //=> {b: 2, d: 4} - */ -var reject = _curry2(function reject(pred, filterable) { - return filter(_complement(pred), filterable); -}); - -function _toString(x, seen) { - var recur = function recur(y) { - var xs = seen.concat([x]); - return _includes(y, xs) ? '' : _toString(y, xs); - }; - - // mapPairs :: (Object, [String]) -> [String] - var mapPairs = function(obj, keys$$1) { - return _map(function(k) { return _quote(k) + ': ' + recur(obj[k]); }, keys$$1.slice().sort()); - }; - - switch (Object.prototype.toString.call(x)) { - case '[object Arguments]': - return '(function() { return arguments; }(' + _map(recur, x).join(', ') + '))'; - case '[object Array]': - return '[' + _map(recur, x).concat(mapPairs(x, reject(function(k) { return /^\d+$/.test(k); }, keys(x)))).join(', ') + ']'; - case '[object Boolean]': - return typeof x === 'object' ? 'new Boolean(' + recur(x.valueOf()) + ')' : x.toString(); - case '[object Date]': - return 'new Date(' + (isNaN(x.valueOf()) ? recur(NaN) : _quote(_toISOString(x))) + ')'; - case '[object Null]': - return 'null'; - case '[object Number]': - return typeof x === 'object' ? 'new Number(' + recur(x.valueOf()) + ')' : 1 / x === -Infinity ? '-0' : x.toString(10); - case '[object String]': - return typeof x === 'object' ? 'new String(' + recur(x.valueOf()) + ')' : _quote(x); - case '[object Undefined]': - return 'undefined'; - default: - if (typeof x.toString === 'function') { - var repr = x.toString(); - if (repr !== '[object Object]') { - return repr; - } - } - return '{' + mapPairs(x, keys(x)).join(', ') + '}'; - } -} - -/** - * Returns the string representation of the given value. `eval`'ing the output - * should result in a value equivalent to the input value. Many of the built-in - * `toString` methods do not satisfy this requirement. - * - * If the given value is an `[object Object]` with a `toString` method other - * than `Object.prototype.toString`, this method is invoked with no arguments - * to produce the return value. This means user-defined constructor functions - * can provide a suitable `toString` method. For example: - * - * function Point(x, y) { - * this.x = x; - * this.y = y; - * } - * - * Point.prototype.toString = function() { - * return 'new Point(' + this.x + ', ' + this.y + ')'; - * }; - * - * R.toString(new Point(1, 2)); //=> 'new Point(1, 2)' - * - * @func - * @memberOf R - * @since v0.14.0 - * @category String - * @sig * -> String - * @param {*} val - * @return {String} - * @example - * - * R.toString(42); //=> '42' - * R.toString('abc'); //=> '"abc"' - * R.toString([1, 2, 3]); //=> '[1, 2, 3]' - * R.toString({foo: 1, bar: 2, baz: 3}); //=> '{"bar": 2, "baz": 3, "foo": 1}' - * R.toString(new Date('2001-02-03T04:05:06Z')); //=> 'new Date("2001-02-03T04:05:06.000Z")' - */ -var toString$1 = _curry1(function toString(val) { return _toString(val, []); }); - -/** - * Returns the result of concatenating the given lists or strings. - * - * Note: `R.concat` expects both arguments to be of the same type, - * unlike the native `Array.prototype.concat` method. It will throw - * an error if you `concat` an Array with a non-Array value. - * - * Dispatches to the `concat` method of the first argument, if present. - * Can also concatenate two members of a [fantasy-land - * compatible semigroup](https://github.com/fantasyland/fantasy-land#semigroup). - * - * @func - * @memberOf R - * @since v0.1.0 - * @category List - * @sig [a] -> [a] -> [a] - * @sig String -> String -> String - * @param {Array|String} firstList The first list - * @param {Array|String} secondList The second list - * @return {Array|String} A list consisting of the elements of `firstList` followed by the elements of - * `secondList`. - * - * @example - * - * R.concat('ABC', 'DEF'); // 'ABCDEF' - * R.concat([4, 5, 6], [1, 2, 3]); //=> [4, 5, 6, 1, 2, 3] - * R.concat([], []); //=> [] - */ -var concat = _curry2(function concat(a, b) { - if (_isArray(a)) { - if (_isArray(b)) { - return a.concat(b); - } - throw new TypeError(toString$1(b) + ' is not an array'); - } - if (_isString(a)) { - if (_isString(b)) { - return a + b; - } - throw new TypeError(toString$1(b) + ' is not a string'); - } - if (a != null && _isFunction(a['fantasy-land/concat'])) { - return a['fantasy-land/concat'](b); - } - if (a != null && _isFunction(a.concat)) { - return a.concat(b); - } - throw new TypeError(toString$1(a) + ' does not have a method named "concat" or "fantasy-land/concat"'); -}); - -/** - * Returns a function, `fn`, which encapsulates `if/else, if/else, ...` logic. - * `R.cond` takes a list of [predicate, transformer] pairs. All of the arguments - * to `fn` are applied to each of the predicates in turn until one returns a - * "truthy" value, at which point `fn` returns the result of applying its - * arguments to the corresponding transformer. If none of the predicates - * matches, `fn` returns undefined. - * - * @func - * @memberOf R - * @since v0.6.0 - * @category Logic - * @sig [[(*... -> Boolean),(*... -> *)]] -> (*... -> *) - * @param {Array} pairs A list of [predicate, transformer] - * @return {Function} - * @see R.ifElse, R.unless, R.when - * @example - * - * const fn = R.cond([ - * [R.equals(0), R.always('water freezes at 0°C')], - * [R.equals(100), R.always('water boils at 100°C')], - * [R.T, temp => 'nothing special happens at ' + temp + '°C'] - * ]); - * fn(0); //=> 'water freezes at 0°C' - * fn(50); //=> 'nothing special happens at 50°C' - * fn(100); //=> 'water boils at 100°C' - */ -var cond = _curry1(function cond(pairs) { - var arity = reduce(max, - 0, - map(function(pair) { return pair[0].length; }, pairs)); - return _arity(arity, function() { - var idx = 0; - while (idx < pairs.length) { - if (pairs[idx][0].apply(this, arguments)) { - return pairs[idx][1].apply(this, arguments); - } - idx += 1; - } - }); -}); - -/** - * Wraps a constructor function inside a curried function that can be called - * with the same arguments and returns the same type. The arity of the function - * returned is specified to allow using variadic constructor functions. - * - * @func - * @memberOf R - * @since v0.4.0 - * @category Function - * @sig Number -> (* -> {*}) -> (* -> {*}) - * @param {Number} n The arity of the constructor function. - * @param {Function} Fn The constructor function to wrap. - * @return {Function} A wrapped, curried constructor function. - * @example - * - * // Variadic Constructor function - * function Salad() { - * this.ingredients = arguments; - * } - * - * Salad.prototype.recipe = function() { - * const instructions = R.map(ingredient => 'Add a dollop of ' + ingredient, this.ingredients); - * return R.join('\n', instructions); - * }; - * - * const ThreeLayerSalad = R.constructN(3, Salad); - * - * // Notice we no longer need the 'new' keyword, and the constructor is curried for 3 arguments. - * const salad = ThreeLayerSalad('Mayonnaise')('Potato Chips')('Ketchup'); - * - * console.log(salad.recipe()); - * // Add a dollop of Mayonnaise - * // Add a dollop of Potato Chips - * // Add a dollop of Ketchup - */ -var constructN = _curry2(function constructN(n, Fn) { - if (n > 10) { - throw new Error('Constructor with greater than ten arguments'); - } - if (n === 0) { - return function() { return new Fn(); }; - } - return curry(nAry(n, function($0, $1, $2, $3, $4, $5, $6, $7, $8, $9) { - switch (arguments.length) { - case 1: return new Fn($0); - case 2: return new Fn($0, $1); - case 3: return new Fn($0, $1, $2); - case 4: return new Fn($0, $1, $2, $3); - case 5: return new Fn($0, $1, $2, $3, $4); - case 6: return new Fn($0, $1, $2, $3, $4, $5); - case 7: return new Fn($0, $1, $2, $3, $4, $5, $6); - case 8: return new Fn($0, $1, $2, $3, $4, $5, $6, $7); - case 9: return new Fn($0, $1, $2, $3, $4, $5, $6, $7, $8); - case 10: return new Fn($0, $1, $2, $3, $4, $5, $6, $7, $8, $9); - } - })); -}); - -/** - * Wraps a constructor function inside a curried function that can be called - * with the same arguments and returns the same type. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Function - * @sig (* -> {*}) -> (* -> {*}) - * @param {Function} fn The constructor function to wrap. - * @return {Function} A wrapped, curried constructor function. - * @see R.invoker - * @example - * - * // Constructor function - * function Animal(kind) { - * this.kind = kind; - * }; - * Animal.prototype.sighting = function() { - * return "It's a " + this.kind + "!"; - * } - * - * const AnimalConstructor = R.construct(Animal) - * - * // Notice we no longer need the 'new' keyword: - * AnimalConstructor('Pig'); //=> {"kind": "Pig", "sighting": function (){...}}; - * - * const animalTypes = ["Lion", "Tiger", "Bear"]; - * const animalSighting = R.invoker(0, 'sighting'); - * const sightNewAnimal = R.compose(animalSighting, AnimalConstructor); - * R.map(sightNewAnimal, animalTypes); //=> ["It's a Lion!", "It's a Tiger!", "It's a Bear!"] - */ -var construct = _curry1(function construct(Fn) { - return constructN(Fn.length, Fn); -}); - -/** - * Returns `true` if the specified value is equal, in [`R.equals`](#equals) - * terms, to at least one element of the given list; `false` otherwise. - * Works also with strings. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category List - * @sig a -> [a] -> Boolean - * @param {Object} a The item to compare against. - * @param {Array} list The array to consider. - * @return {Boolean} `true` if an equivalent item is in the list, `false` otherwise. - * @see R.includes - * @deprecated since v0.26.0 - * @example - * - * R.contains(3, [1, 2, 3]); //=> true - * R.contains(4, [1, 2, 3]); //=> false - * R.contains({ name: 'Fred' }, [{ name: 'Fred' }]); //=> true - * R.contains([42], [[42]]); //=> true - * R.contains('ba', 'banana'); //=>true - */ -var contains$1 = _curry2(_includes); - -/** - * Accepts a converging function and a list of branching functions and returns - * a new function. The arity of the new function is the same as the arity of - * the longest branching function. When invoked, this new function is applied - * to some arguments, and each branching function is applied to those same - * arguments. The results of each branching function are passed as arguments - * to the converging function to produce the return value. - * - * @func - * @memberOf R - * @since v0.4.2 - * @category Function - * @sig ((x1, x2, ...) -> z) -> [((a, b, ...) -> x1), ((a, b, ...) -> x2), ...] -> (a -> b -> ... -> z) - * @param {Function} after A function. `after` will be invoked with the return values of - * `fn1` and `fn2` as its arguments. - * @param {Array} functions A list of functions. - * @return {Function} A new function. - * @see R.useWith - * @example - * - * const average = R.converge(R.divide, [R.sum, R.length]) - * average([1, 2, 3, 4, 5, 6, 7]) //=> 4 - * - * const strangeConcat = R.converge(R.concat, [R.toUpper, R.toLower]) - * strangeConcat("Yodel") //=> "YODELyodel" - * - * @symb R.converge(f, [g, h])(a, b) = f(g(a, b), h(a, b)) - */ -var converge = _curry2(function converge(after, fns) { - return curryN(reduce(max, 0, pluck('length', fns)), function() { - var args = arguments; - var context = this; - return after.apply(context, _map(function(fn) { - return fn.apply(context, args); - }, fns)); - }); -}); - -function XReduceBy(valueFn, valueAcc, keyFn, xf) { - this.valueFn = valueFn; - this.valueAcc = valueAcc; - this.keyFn = keyFn; - this.xf = xf; - this.inputs = {}; -} -XReduceBy.prototype['@@transducer/init'] = _xfBase.init; -XReduceBy.prototype['@@transducer/result'] = function(result) { - var key; - for (key in this.inputs) { - if (_has(key, this.inputs)) { - result = this.xf['@@transducer/step'](result, this.inputs[key]); - if (result['@@transducer/reduced']) { - result = result['@@transducer/value']; - break; - } - } - } - this.inputs = null; - return this.xf['@@transducer/result'](result); -}; -XReduceBy.prototype['@@transducer/step'] = function(result, input) { - var key = this.keyFn(input); - this.inputs[key] = this.inputs[key] || [key, this.valueAcc]; - this.inputs[key][1] = this.valueFn(this.inputs[key][1], input); - return result; -}; - -var _xreduceBy = _curryN(4, [], - function _xreduceBy(valueFn, valueAcc, keyFn, xf) { - return new XReduceBy(valueFn, valueAcc, keyFn, xf); - }); - -/** - * Groups the elements of the list according to the result of calling - * the String-returning function `keyFn` on each element and reduces the elements - * of each group to a single value via the reducer function `valueFn`. - * - * This function is basically a more general [`groupBy`](#groupBy) function. - * - * Acts as a transducer if a transformer is given in list position. - * - * @func - * @memberOf R - * @since v0.20.0 - * @category List - * @sig ((a, b) -> a) -> a -> (b -> String) -> [b] -> {String: a} - * @param {Function} valueFn The function that reduces the elements of each group to a single - * value. Receives two values, accumulator for a particular group and the current element. - * @param {*} acc The (initial) accumulator value for each group. - * @param {Function} keyFn The function that maps the list's element into a key. - * @param {Array} list The array to group. - * @return {Object} An object with the output of `keyFn` for keys, mapped to the output of - * `valueFn` for elements which produced that key when passed to `keyFn`. - * @see R.groupBy, R.reduce - * @example - * - * const groupNames = (acc, {name}) => acc.concat(name) - * const toGrade = ({score}) => - * score < 65 ? 'F' : - * score < 70 ? 'D' : - * score < 80 ? 'C' : - * score < 90 ? 'B' : 'A' - * - * var students = [ - * {name: 'Abby', score: 83}, - * {name: 'Bart', score: 62}, - * {name: 'Curt', score: 88}, - * {name: 'Dora', score: 92}, - * ] - * - * reduceBy(groupNames, [], toGrade, students) - * //=> {"A": ["Dora"], "B": ["Abby", "Curt"], "F": ["Bart"]} - */ -var reduceBy = _curryN(4, [], _dispatchable([], _xreduceBy, - function reduceBy(valueFn, valueAcc, keyFn, list) { - return _reduce(function(acc, elt) { - var key = keyFn(elt); - acc[key] = valueFn(_has(key, acc) ? acc[key] : valueAcc, elt); - return acc; - }, {}, list); - })); - -/** - * Counts the elements of a list according to how many match each value of a - * key generated by the supplied function. Returns an object mapping the keys - * produced by `fn` to the number of occurrences in the list. Note that all - * keys are coerced to strings because of how JavaScript objects work. - * - * Acts as a transducer if a transformer is given in list position. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Relation - * @sig (a -> String) -> [a] -> {*} - * @param {Function} fn The function used to map values to keys. - * @param {Array} list The list to count elements from. - * @return {Object} An object mapping keys to number of occurrences in the list. - * @example - * - * const numbers = [1.0, 1.1, 1.2, 2.0, 3.0, 2.2]; - * R.countBy(Math.floor)(numbers); //=> {'1': 3, '2': 2, '3': 1} - * - * const letters = ['a', 'b', 'A', 'a', 'B', 'c']; - * R.countBy(R.toLower)(letters); //=> {'a': 3, 'b': 2, 'c': 1} - */ -var countBy = reduceBy(function(acc, elem) { return acc + 1; }, 0); - -/** - * Decrements its argument. - * - * @func - * @memberOf R - * @since v0.9.0 - * @category Math - * @sig Number -> Number - * @param {Number} n - * @return {Number} n - 1 - * @see R.inc - * @example - * - * R.dec(42); //=> 41 - */ -var dec = add(-1); - -/** - * Returns the second argument if it is not `null`, `undefined` or `NaN`; - * otherwise the first argument is returned. - * - * @func - * @memberOf R - * @since v0.10.0 - * @category Logic - * @sig a -> b -> a | b - * @param {a} default The default value. - * @param {b} val `val` will be returned instead of `default` unless `val` is `null`, `undefined` or `NaN`. - * @return {*} The second value if it is not `null`, `undefined` or `NaN`, otherwise the default value - * @example - * - * const defaultTo42 = R.defaultTo(42); - * - * defaultTo42(null); //=> 42 - * defaultTo42(undefined); //=> 42 - * defaultTo42(false); //=> false - * defaultTo42('Ramda'); //=> 'Ramda' - * // parseInt('string') results in NaN - * defaultTo42(parseInt('string')); //=> 42 - */ -var defaultTo = _curry2(function defaultTo(d, v) { - return v == null || v !== v ? d : v; -}); - -/** - * Makes a descending comparator function out of a function that returns a value - * that can be compared with `<` and `>`. - * - * @func - * @memberOf R - * @since v0.23.0 - * @category Function - * @sig Ord b => (a -> b) -> a -> a -> Number - * @param {Function} fn A function of arity one that returns a value that can be compared - * @param {*} a The first item to be compared. - * @param {*} b The second item to be compared. - * @return {Number} `-1` if fn(a) > fn(b), `1` if fn(b) > fn(a), otherwise `0` - * @see R.ascend - * @example - * - * const byAge = R.descend(R.prop('age')); - * const people = [ - * { name: 'Emma', age: 70 }, - * { name: 'Peter', age: 78 }, - * { name: 'Mikhail', age: 62 }, - * ]; - * const peopleByOldestFirst = R.sort(byAge, people); - * //=> [{ name: 'Peter', age: 78 }, { name: 'Emma', age: 70 }, { name: 'Mikhail', age: 62 }] - */ -var descend = _curry3(function descend(fn, a, b) { - var aa = fn(a); - var bb = fn(b); - return aa > bb ? -1 : aa < bb ? 1 : 0; -}); - -function _Set() { - /* globals Set */ - this._nativeSet = typeof Set === 'function' ? new Set() : null; - this._items = {}; -} - -// until we figure out why jsdoc chokes on this -// @param item The item to add to the Set -// @returns {boolean} true if the item did not exist prior, otherwise false -// -_Set.prototype.add = function(item) { - return !hasOrAdd(item, true, this); -}; - -// -// @param item The item to check for existence in the Set -// @returns {boolean} true if the item exists in the Set, otherwise false -// -_Set.prototype.has = function(item) { - return hasOrAdd(item, false, this); -}; - -// -// Combines the logic for checking whether an item is a member of the set and -// for adding a new item to the set. -// -// @param item The item to check or add to the Set instance. -// @param shouldAdd If true, the item will be added to the set if it doesn't -// already exist. -// @param set The set instance to check or add to. -// @return {boolean} true if the item already existed, otherwise false. -// -function hasOrAdd(item, shouldAdd, set) { - var type = typeof item; - var prevSize, newSize; - switch (type) { - case 'string': - case 'number': - // distinguish between +0 and -0 - if (item === 0 && 1 / item === -Infinity) { - if (set._items['-0']) { - return true; - } else { - if (shouldAdd) { - set._items['-0'] = true; - } - return false; - } - } - // these types can all utilise the native Set - if (set._nativeSet !== null) { - if (shouldAdd) { - prevSize = set._nativeSet.size; - set._nativeSet.add(item); - newSize = set._nativeSet.size; - return newSize === prevSize; - } else { - return set._nativeSet.has(item); - } - } else { - if (!(type in set._items)) { - if (shouldAdd) { - set._items[type] = {}; - set._items[type][item] = true; - } - return false; - } else if (item in set._items[type]) { - return true; - } else { - if (shouldAdd) { - set._items[type][item] = true; - } - return false; - } - } - - case 'boolean': - // set._items['boolean'] holds a two element array - // representing [ falseExists, trueExists ] - if (type in set._items) { - var bIdx = item ? 1 : 0; - if (set._items[type][bIdx]) { - return true; - } else { - if (shouldAdd) { - set._items[type][bIdx] = true; - } - return false; - } - } else { - if (shouldAdd) { - set._items[type] = item ? [false, true] : [true, false]; - } - return false; - } - - case 'function': - // compare functions for reference equality - if (set._nativeSet !== null) { - if (shouldAdd) { - prevSize = set._nativeSet.size; - set._nativeSet.add(item); - newSize = set._nativeSet.size; - return newSize === prevSize; - } else { - return set._nativeSet.has(item); - } - } else { - if (!(type in set._items)) { - if (shouldAdd) { - set._items[type] = [item]; - } - return false; - } - if (!_includes(item, set._items[type])) { - if (shouldAdd) { - set._items[type].push(item); - } - return false; - } - return true; - } - - case 'undefined': - if (set._items[type]) { - return true; - } else { - if (shouldAdd) { - set._items[type] = true; - } - return false; - } - - case 'object': - if (item === null) { - if (!set._items['null']) { - if (shouldAdd) { - set._items['null'] = true; - } - return false; - } - return true; - } - /* falls through */ - default: - // reduce the search size of heterogeneous sets by creating buckets - // for each type. - type = Object.prototype.toString.call(item); - if (!(type in set._items)) { - if (shouldAdd) { - set._items[type] = [item]; - } - return false; - } - // scan through all previously applied items - if (!_includes(item, set._items[type])) { - if (shouldAdd) { - set._items[type].push(item); - } - return false; - } - return true; - } -} - -/** - * Finds the set (i.e. no duplicates) of all elements in the first list not - * contained in the second list. Objects and Arrays are compared in terms of - * value equality, not reference equality. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Relation - * @sig [*] -> [*] -> [*] - * @param {Array} list1 The first list. - * @param {Array} list2 The second list. - * @return {Array} The elements in `list1` that are not in `list2`. - * @see R.differenceWith, R.symmetricDifference, R.symmetricDifferenceWith, R.without - * @example - * - * R.difference([1,2,3,4], [7,6,5,4,3]); //=> [1,2] - * R.difference([7,6,5,4,3], [1,2,3,4]); //=> [7,6,5] - * R.difference([{a: 1}, {b: 2}], [{a: 1}, {c: 3}]) //=> [{b: 2}] - */ -var difference = _curry2(function difference(first, second) { - var out = []; - var idx = 0; - var firstLen = first.length; - var secondLen = second.length; - var toFilterOut = new _Set(); - - for (var i = 0; i < secondLen; i += 1) { - toFilterOut.add(second[i]); - } - - while (idx < firstLen) { - if (toFilterOut.add(first[idx])) { - out[out.length] = first[idx]; - } - idx += 1; - } - return out; -}); - -/** - * Finds the set (i.e. no duplicates) of all elements in the first list not - * contained in the second list. Duplication is determined according to the - * value returned by applying the supplied predicate to two list elements. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Relation - * @sig ((a, a) -> Boolean) -> [a] -> [a] -> [a] - * @param {Function} pred A predicate used to test whether two items are equal. - * @param {Array} list1 The first list. - * @param {Array} list2 The second list. - * @return {Array} The elements in `list1` that are not in `list2`. - * @see R.difference, R.symmetricDifference, R.symmetricDifferenceWith - * @example - * - * const cmp = (x, y) => x.a === y.a; - * const l1 = [{a: 1}, {a: 2}, {a: 3}]; - * const l2 = [{a: 3}, {a: 4}]; - * R.differenceWith(cmp, l1, l2); //=> [{a: 1}, {a: 2}] - */ -var differenceWith = _curry3(function differenceWith(pred, first, second) { - var out = []; - var idx = 0; - var firstLen = first.length; - while (idx < firstLen) { - if (!_includesWith(pred, first[idx], second) && - !_includesWith(pred, first[idx], out)) { - out.push(first[idx]); - } - idx += 1; - } - return out; -}); - -/** - * Returns a new object that does not contain a `prop` property. - * - * @func - * @memberOf R - * @since v0.10.0 - * @category Object - * @sig String -> {k: v} -> {k: v} - * @param {String} prop The name of the property to dissociate - * @param {Object} obj The object to clone - * @return {Object} A new object equivalent to the original but without the specified property - * @see R.assoc, R.omit - * @example - * - * R.dissoc('b', {a: 1, b: 2, c: 3}); //=> {a: 1, c: 3} - */ -var dissoc = _curry2(function dissoc(prop, obj) { - var result = {}; - for (var p in obj) { - result[p] = obj[p]; - } - delete result[prop]; - return result; -}); - -/** - * Removes the sub-list of `list` starting at index `start` and containing - * `count` elements. _Note that this is not destructive_: it returns a copy of - * the list with the changes. - * No lists have been harmed in the application of this function. - * - * @func - * @memberOf R - * @since v0.2.2 - * @category List - * @sig Number -> Number -> [a] -> [a] - * @param {Number} start The position to start removing elements - * @param {Number} count The number of elements to remove - * @param {Array} list The list to remove from - * @return {Array} A new Array with `count` elements from `start` removed. - * @see R.without - * @example - * - * R.remove(2, 3, [1,2,3,4,5,6,7,8]); //=> [1,2,6,7,8] - */ -var remove = _curry3(function remove(start, count, list) { - var result = Array.prototype.slice.call(list, 0); - result.splice(start, count); - return result; -}); - -/** - * Returns a new copy of the array with the element at the provided index - * replaced with the given value. - * - * @func - * @memberOf R - * @since v0.14.0 - * @category List - * @sig Number -> a -> [a] -> [a] - * @param {Number} idx The index to update. - * @param {*} x The value to exist at the given index of the returned array. - * @param {Array|Arguments} list The source array-like object to be updated. - * @return {Array} A copy of `list` with the value at index `idx` replaced with `x`. - * @see R.adjust - * @example - * - * R.update(1, '_', ['a', 'b', 'c']); //=> ['a', '_', 'c'] - * R.update(-1, '_', ['a', 'b', 'c']); //=> ['a', 'b', '_'] - * @symb R.update(-1, a, [b, c]) = [b, a] - * @symb R.update(0, a, [b, c]) = [a, c] - * @symb R.update(1, a, [b, c]) = [b, a] - */ -var update = _curry3(function update(idx, x, list) { - return adjust(idx, always(x), list); -}); - -/** - * Makes a shallow clone of an object, omitting the property at the given path. - * Note that this copies and flattens prototype properties onto the new object - * as well. All non-primitive properties are copied by reference. - * - * @func - * @memberOf R - * @since v0.11.0 - * @category Object - * @typedefn Idx = String | Int - * @sig [Idx] -> {k: v} -> {k: v} - * @param {Array} path The path to the value to omit - * @param {Object} obj The object to clone - * @return {Object} A new object without the property at path - * @see R.assocPath - * @example - * - * R.dissocPath(['a', 'b', 'c'], {a: {b: {c: 42}}}); //=> {a: {b: {}}} - */ -var dissocPath = _curry2(function dissocPath(path, obj) { - switch (path.length) { - case 0: - return obj; - case 1: - return _isInteger(path[0]) && _isArray(obj) ? remove(path[0], 1, obj) : dissoc(path[0], obj); - default: - var head = path[0]; - var tail = Array.prototype.slice.call(path, 1); - if (obj[head] == null) { - return obj; - } else if (_isInteger(head) && _isArray(obj)) { - return update(head, dissocPath(tail, obj[head]), obj); - } else { - return assoc(head, dissocPath(tail, obj[head]), obj); - } - } -}); - -/** - * Divides two numbers. Equivalent to `a / b`. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Math - * @sig Number -> Number -> Number - * @param {Number} a The first value. - * @param {Number} b The second value. - * @return {Number} The result of `a / b`. - * @see R.multiply - * @example - * - * R.divide(71, 100); //=> 0.71 - * - * const half = R.divide(R.__, 2); - * half(42); //=> 21 - * - * const reciprocal = R.divide(1); - * reciprocal(4); //=> 0.25 - */ -var divide = _curry2(function divide(a, b) { return a / b; }); - -function XDrop(n, xf) { - this.xf = xf; - this.n = n; -} -XDrop.prototype['@@transducer/init'] = _xfBase.init; -XDrop.prototype['@@transducer/result'] = _xfBase.result; -XDrop.prototype['@@transducer/step'] = function(result, input) { - if (this.n > 0) { - this.n -= 1; - return result; - } - return this.xf['@@transducer/step'](result, input); -}; - -var _xdrop = _curry2(function _xdrop(n, xf) { return new XDrop(n, xf); }); - -/** - * Returns all but the first `n` elements of the given list, string, or - * transducer/transformer (or object with a `drop` method). - * - * Dispatches to the `drop` method of the second argument, if present. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category List - * @sig Number -> [a] -> [a] - * @sig Number -> String -> String - * @param {Number} n - * @param {*} list - * @return {*} A copy of list without the first `n` elements - * @see R.take, R.transduce, R.dropLast, R.dropWhile - * @example - * - * R.drop(1, ['foo', 'bar', 'baz']); //=> ['bar', 'baz'] - * R.drop(2, ['foo', 'bar', 'baz']); //=> ['baz'] - * R.drop(3, ['foo', 'bar', 'baz']); //=> [] - * R.drop(4, ['foo', 'bar', 'baz']); //=> [] - * R.drop(3, 'ramda'); //=> 'da' - */ -var drop = _curry2(_dispatchable(['drop'], _xdrop, function drop(n, xs) { - return slice(Math.max(0, n), Infinity, xs); -})); - -function XTake(n, xf) { - this.xf = xf; - this.n = n; - this.i = 0; -} -XTake.prototype['@@transducer/init'] = _xfBase.init; -XTake.prototype['@@transducer/result'] = _xfBase.result; -XTake.prototype['@@transducer/step'] = function(result, input) { - this.i += 1; - var ret = this.n === 0 ? result : this.xf['@@transducer/step'](result, input); - return this.n >= 0 && this.i >= this.n ? _reduced(ret) : ret; -}; - -var _xtake = _curry2(function _xtake(n, xf) { return new XTake(n, xf); }); - -/** - * Returns the first `n` elements of the given list, string, or - * transducer/transformer (or object with a `take` method). - * - * Dispatches to the `take` method of the second argument, if present. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category List - * @sig Number -> [a] -> [a] - * @sig Number -> String -> String - * @param {Number} n - * @param {*} list - * @return {*} - * @see R.drop - * @example - * - * R.take(1, ['foo', 'bar', 'baz']); //=> ['foo'] - * R.take(2, ['foo', 'bar', 'baz']); //=> ['foo', 'bar'] - * R.take(3, ['foo', 'bar', 'baz']); //=> ['foo', 'bar', 'baz'] - * R.take(4, ['foo', 'bar', 'baz']); //=> ['foo', 'bar', 'baz'] - * R.take(3, 'ramda'); //=> 'ram' - * - * const personnel = [ - * 'Dave Brubeck', - * 'Paul Desmond', - * 'Eugene Wright', - * 'Joe Morello', - * 'Gerry Mulligan', - * 'Bob Bates', - * 'Joe Dodge', - * 'Ron Crotty' - * ]; - * - * const takeFive = R.take(5); - * takeFive(personnel); - * //=> ['Dave Brubeck', 'Paul Desmond', 'Eugene Wright', 'Joe Morello', 'Gerry Mulligan'] - * @symb R.take(-1, [a, b]) = [a, b] - * @symb R.take(0, [a, b]) = [] - * @symb R.take(1, [a, b]) = [a] - * @symb R.take(2, [a, b]) = [a, b] - */ -var take = _curry2(_dispatchable(['take'], _xtake, function take(n, xs) { - return slice(0, n < 0 ? Infinity : n, xs); -})); - -function dropLast$2(n, xs) { - return take(n < xs.length ? xs.length - n : 0, xs); -} - -function XDropLast(n, xf) { - this.xf = xf; - this.pos = 0; - this.full = false; - this.acc = new Array(n); -} -XDropLast.prototype['@@transducer/init'] = _xfBase.init; -XDropLast.prototype['@@transducer/result'] = function(result) { - this.acc = null; - return this.xf['@@transducer/result'](result); -}; -XDropLast.prototype['@@transducer/step'] = function(result, input) { - if (this.full) { - result = this.xf['@@transducer/step'](result, this.acc[this.pos]); - } - this.store(input); - return result; -}; -XDropLast.prototype.store = function(input) { - this.acc[this.pos] = input; - this.pos += 1; - if (this.pos === this.acc.length) { - this.pos = 0; - this.full = true; - } -}; - -var _xdropLast = _curry2(function _xdropLast(n, xf) { return new XDropLast(n, xf); }); - -/** - * Returns a list containing all but the last `n` elements of the given `list`. - * - * Acts as a transducer if a transformer is given in list position. - * - * @func - * @memberOf R - * @since v0.16.0 - * @category List - * @sig Number -> [a] -> [a] - * @sig Number -> String -> String - * @param {Number} n The number of elements of `list` to skip. - * @param {Array} list The list of elements to consider. - * @return {Array} A copy of the list with only the first `list.length - n` elements - * @see R.takeLast, R.drop, R.dropWhile, R.dropLastWhile - * @example - * - * R.dropLast(1, ['foo', 'bar', 'baz']); //=> ['foo', 'bar'] - * R.dropLast(2, ['foo', 'bar', 'baz']); //=> ['foo'] - * R.dropLast(3, ['foo', 'bar', 'baz']); //=> [] - * R.dropLast(4, ['foo', 'bar', 'baz']); //=> [] - * R.dropLast(3, 'ramda'); //=> 'ra' - */ -var dropLast = _curry2(_dispatchable([], _xdropLast, dropLast$2)); - -function dropLastWhile$2(pred, xs) { - var idx = xs.length - 1; - while (idx >= 0 && pred(xs[idx])) { - idx -= 1; - } - return slice(0, idx + 1, xs); -} - -function XDropLastWhile(fn, xf) { - this.f = fn; - this.retained = []; - this.xf = xf; -} -XDropLastWhile.prototype['@@transducer/init'] = _xfBase.init; -XDropLastWhile.prototype['@@transducer/result'] = function(result) { - this.retained = null; - return this.xf['@@transducer/result'](result); -}; -XDropLastWhile.prototype['@@transducer/step'] = function(result, input) { - return this.f(input) ? this.retain(result, input) - : this.flush(result, input); -}; -XDropLastWhile.prototype.flush = function(result, input) { - result = _reduce( - this.xf['@@transducer/step'], - result, - this.retained - ); - this.retained = []; - return this.xf['@@transducer/step'](result, input); -}; -XDropLastWhile.prototype.retain = function(result, input) { - this.retained.push(input); - return result; -}; - -var _xdropLastWhile = _curry2(function _xdropLastWhile(fn, xf) { return new XDropLastWhile(fn, xf); }); - -/** - * Returns a new list excluding all the tailing elements of a given list which - * satisfy the supplied predicate function. It passes each value from the right - * to the supplied predicate function, skipping elements until the predicate - * function returns a `falsy` value. The predicate function is applied to one argument: - * *(value)*. - * - * Acts as a transducer if a transformer is given in list position. - * - * @func - * @memberOf R - * @since v0.16.0 - * @category List - * @sig (a -> Boolean) -> [a] -> [a] - * @sig (a -> Boolean) -> String -> String - * @param {Function} predicate The function to be called on each element - * @param {Array} xs The collection to iterate over. - * @return {Array} A new array without any trailing elements that return `falsy` values from the `predicate`. - * @see R.takeLastWhile, R.addIndex, R.drop, R.dropWhile - * @example - * - * const lteThree = x => x <= 3; - * - * R.dropLastWhile(lteThree, [1, 2, 3, 4, 3, 2, 1]); //=> [1, 2, 3, 4] - * - * R.dropLastWhile(x => x !== 'd' , 'Ramda'); //=> 'Ramd' - */ -var dropLastWhile = _curry2(_dispatchable([], _xdropLastWhile, dropLastWhile$2)); - -function XDropRepeatsWith(pred, xf) { - this.xf = xf; - this.pred = pred; - this.lastValue = undefined; - this.seenFirstValue = false; -} - -XDropRepeatsWith.prototype['@@transducer/init'] = _xfBase.init; -XDropRepeatsWith.prototype['@@transducer/result'] = _xfBase.result; -XDropRepeatsWith.prototype['@@transducer/step'] = function(result, input) { - var sameAsLast = false; - if (!this.seenFirstValue) { - this.seenFirstValue = true; - } else if (this.pred(this.lastValue, input)) { - sameAsLast = true; - } - this.lastValue = input; - return sameAsLast ? result : this.xf['@@transducer/step'](result, input); -}; - -var _xdropRepeatsWith = _curry2(function _xdropRepeatsWith(pred, xf) { return new XDropRepeatsWith(pred, xf); }); - -/** - * Returns the last element of the given list or string. - * - * @func - * @memberOf R - * @since v0.1.4 - * @category List - * @sig [a] -> a | Undefined - * @sig String -> String - * @param {*} list - * @return {*} - * @see R.init, R.head, R.tail - * @example - * - * R.last(['fi', 'fo', 'fum']); //=> 'fum' - * R.last([]); //=> undefined - * - * R.last('abc'); //=> 'c' - * R.last(''); //=> '' - */ -var last = nth(-1); - -/** - * Returns a new list without any consecutively repeating elements. Equality is - * determined by applying the supplied predicate to each pair of consecutive elements. The - * first element in a series of equal elements will be preserved. - * - * Acts as a transducer if a transformer is given in list position. - * - * @func - * @memberOf R - * @since v0.14.0 - * @category List - * @sig ((a, a) -> Boolean) -> [a] -> [a] - * @param {Function} pred A predicate used to test whether two items are equal. - * @param {Array} list The array to consider. - * @return {Array} `list` without repeating elements. - * @see R.transduce - * @example - * - * const l = [1, -1, 1, 3, 4, -4, -4, -5, 5, 3, 3]; - * R.dropRepeatsWith(R.eqBy(Math.abs), l); //=> [1, 3, 4, -5, 3] - */ -var dropRepeatsWith = _curry2(_dispatchable([], _xdropRepeatsWith, function dropRepeatsWith(pred, list) { - var result = []; - var idx = 1; - var len = list.length; - if (len !== 0) { - result[0] = list[0]; - while (idx < len) { - if (!pred(last(result), list[idx])) { - result[result.length] = list[idx]; - } - idx += 1; - } - } - return result; -})); - -/** - * Returns a new list without any consecutively repeating elements. - * [`R.equals`](#equals) is used to determine equality. - * - * Acts as a transducer if a transformer is given in list position. - * - * @func - * @memberOf R - * @since v0.14.0 - * @category List - * @sig [a] -> [a] - * @param {Array} list The array to consider. - * @return {Array} `list` without repeating elements. - * @see R.transduce - * @example - * - * R.dropRepeats([1, 1, 1, 2, 3, 4, 4, 2, 2]); //=> [1, 2, 3, 4, 2] - */ -var dropRepeats = _curry1(_dispatchable([], - _xdropRepeatsWith(equals), - dropRepeatsWith(equals))); - -function XDropWhile(f, xf) { - this.xf = xf; - this.f = f; -} -XDropWhile.prototype['@@transducer/init'] = _xfBase.init; -XDropWhile.prototype['@@transducer/result'] = _xfBase.result; -XDropWhile.prototype['@@transducer/step'] = function(result, input) { - if (this.f) { - if (this.f(input)) { - return result; - } - this.f = null; - } - return this.xf['@@transducer/step'](result, input); -}; - -var _xdropWhile = _curry2(function _xdropWhile(f, xf) { return new XDropWhile(f, xf); }); - -/** - * Returns a new list excluding the leading elements of a given list which - * satisfy the supplied predicate function. It passes each value to the supplied - * predicate function, skipping elements while the predicate function returns - * `true`. The predicate function is applied to one argument: *(value)*. - * - * Dispatches to the `dropWhile` method of the second argument, if present. - * - * Acts as a transducer if a transformer is given in list position. - * - * @func - * @memberOf R - * @since v0.9.0 - * @category List - * @sig (a -> Boolean) -> [a] -> [a] - * @sig (a -> Boolean) -> String -> String - * @param {Function} fn The function called per iteration. - * @param {Array} xs The collection to iterate over. - * @return {Array} A new array. - * @see R.takeWhile, R.transduce, R.addIndex - * @example - * - * const lteTwo = x => x <= 2; - * - * R.dropWhile(lteTwo, [1, 2, 3, 4, 3, 2, 1]); //=> [3, 4, 3, 2, 1] - * - * R.dropWhile(x => x !== 'd' , 'Ramda'); //=> 'da' - */ -var dropWhile = _curry2(_dispatchable(['dropWhile'], _xdropWhile, function dropWhile(pred, xs) { - var idx = 0; - var len = xs.length; - while (idx < len && pred(xs[idx])) { - idx += 1; - } - return slice(idx, Infinity, xs); -})); - -/** - * Returns `true` if one or both of its arguments are `true`. Returns `false` - * if both arguments are `false`. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Logic - * @sig a -> b -> a | b - * @param {Any} a - * @param {Any} b - * @return {Any} the first argument if truthy, otherwise the second argument. - * @see R.either - * @example - * - * R.or(true, true); //=> true - * R.or(true, false); //=> true - * R.or(false, true); //=> true - * R.or(false, false); //=> false - */ -var or = _curry2(function or(a, b) { - return a || b; -}); - -/** - * A function wrapping calls to the two functions in an `||` operation, - * returning the result of the first function if it is truth-y and the result - * of the second function otherwise. Note that this is short-circuited, - * meaning that the second function will not be invoked if the first returns a - * truth-y value. - * - * In addition to functions, `R.either` also accepts any fantasy-land compatible - * applicative functor. - * - * @func - * @memberOf R - * @since v0.12.0 - * @category Logic - * @sig (*... -> Boolean) -> (*... -> Boolean) -> (*... -> Boolean) - * @param {Function} f a predicate - * @param {Function} g another predicate - * @return {Function} a function that applies its arguments to `f` and `g` and `||`s their outputs together. - * @see R.or - * @example - * - * const gt10 = x => x > 10; - * const even = x => x % 2 === 0; - * const f = R.either(gt10, even); - * f(101); //=> true - * f(8); //=> true - * - * R.either(Maybe.Just(false), Maybe.Just(55)); // => Maybe.Just(55) - * R.either([false, false, 'a'], [11]) // => [11, 11, "a"] - */ -var either = _curry2(function either(f, g) { - return _isFunction(f) ? - function _either() { - return f.apply(this, arguments) || g.apply(this, arguments); - } : - lift(or)(f, g); -}); - -/** - * Returns the empty value of its argument's type. Ramda defines the empty - * value of Array (`[]`), Object (`{}`), String (`''`), and Arguments. Other - * types are supported if they define `.empty`, - * `.prototype.empty` or implement the - * [FantasyLand Monoid spec](https://github.com/fantasyland/fantasy-land#monoid). - * - * Dispatches to the `empty` method of the first argument, if present. - * - * @func - * @memberOf R - * @since v0.3.0 - * @category Function - * @sig a -> a - * @param {*} x - * @return {*} - * @example - * - * R.empty(Just(42)); //=> Nothing() - * R.empty([1, 2, 3]); //=> [] - * R.empty('unicorns'); //=> '' - * R.empty({x: 1, y: 2}); //=> {} - */ -var empty = _curry1(function empty(x) { - return ( - (x != null && typeof x['fantasy-land/empty'] === 'function') ? - x['fantasy-land/empty']() : - (x != null && x.constructor != null && typeof x.constructor['fantasy-land/empty'] === 'function') ? - x.constructor['fantasy-land/empty']() : - (x != null && typeof x.empty === 'function') ? - x.empty() : - (x != null && x.constructor != null && typeof x.constructor.empty === 'function') ? - x.constructor.empty() : - _isArray(x) ? - [] : - _isString(x) ? - '' : - _isObject(x) ? - {} : - _isArguments(x) ? - (function() { return arguments; }()) : - // else - void 0 - ); -}); - -/** - * Returns a new list containing the last `n` elements of the given list. - * If `n > list.length`, returns a list of `list.length` elements. - * - * @func - * @memberOf R - * @since v0.16.0 - * @category List - * @sig Number -> [a] -> [a] - * @sig Number -> String -> String - * @param {Number} n The number of elements to return. - * @param {Array} xs The collection to consider. - * @return {Array} - * @see R.dropLast - * @example - * - * R.takeLast(1, ['foo', 'bar', 'baz']); //=> ['baz'] - * R.takeLast(2, ['foo', 'bar', 'baz']); //=> ['bar', 'baz'] - * R.takeLast(3, ['foo', 'bar', 'baz']); //=> ['foo', 'bar', 'baz'] - * R.takeLast(4, ['foo', 'bar', 'baz']); //=> ['foo', 'bar', 'baz'] - * R.takeLast(3, 'ramda'); //=> 'mda' - */ -var takeLast = _curry2(function takeLast(n, xs) { - return drop(n >= 0 ? xs.length - n : 0, xs); -}); - -/** - * Checks if a list ends with the provided sublist. - * - * Similarly, checks if a string ends with the provided substring. - * - * @func - * @memberOf R - * @since v0.24.0 - * @category List - * @sig [a] -> [a] -> Boolean - * @sig String -> String -> Boolean - * @param {*} suffix - * @param {*} list - * @return {Boolean} - * @see R.startsWith - * @example - * - * R.endsWith('c', 'abc') //=> true - * R.endsWith('b', 'abc') //=> false - * R.endsWith(['c'], ['a', 'b', 'c']) //=> true - * R.endsWith(['b'], ['a', 'b', 'c']) //=> false - */ -var endsWith = _curry2(function(suffix, list) { - return equals(takeLast(suffix.length, list), suffix); -}); - -/** - * Takes a function and two values in its domain and returns `true` if the - * values map to the same value in the codomain; `false` otherwise. - * - * @func - * @memberOf R - * @since v0.18.0 - * @category Relation - * @sig (a -> b) -> a -> a -> Boolean - * @param {Function} f - * @param {*} x - * @param {*} y - * @return {Boolean} - * @example - * - * R.eqBy(Math.abs, 5, -5); //=> true - */ -var eqBy = _curry3(function eqBy(f, x, y) { - return equals(f(x), f(y)); -}); - -/** - * Reports whether two objects have the same value, in [`R.equals`](#equals) - * terms, for the specified property. Useful as a curried predicate. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Object - * @sig k -> {k: v} -> {k: v} -> Boolean - * @param {String} prop The name of the property to compare - * @param {Object} obj1 - * @param {Object} obj2 - * @return {Boolean} - * - * @example - * - * const o1 = { a: 1, b: 2, c: 3, d: 4 }; - * const o2 = { a: 10, b: 20, c: 3, d: 40 }; - * R.eqProps('a', o1, o2); //=> false - * R.eqProps('c', o1, o2); //=> true - */ -var eqProps = _curry3(function eqProps(prop, obj1, obj2) { - return equals(obj1[prop], obj2[prop]); -}); - -/** - * Creates a new object by recursively evolving a shallow copy of `object`, - * according to the `transformation` functions. All non-primitive properties - * are copied by reference. - * - * A `transformation` function will not be invoked if its corresponding key - * does not exist in the evolved object. - * - * @func - * @memberOf R - * @since v0.9.0 - * @category Object - * @sig {k: (v -> v)} -> {k: v} -> {k: v} - * @param {Object} transformations The object specifying transformation functions to apply - * to the object. - * @param {Object} object The object to be transformed. - * @return {Object} The transformed object. - * @example - * - * const tomato = {firstName: ' Tomato ', data: {elapsed: 100, remaining: 1400}, id:123}; - * const transformations = { - * firstName: R.trim, - * lastName: R.trim, // Will not get invoked. - * data: {elapsed: R.add(1), remaining: R.add(-1)} - * }; - * R.evolve(transformations, tomato); //=> {firstName: 'Tomato', data: {elapsed: 101, remaining: 1399}, id:123} - */ -var evolve = _curry2(function evolve(transformations, object) { - var result = object instanceof Array ? [] : {}; - var transformation, key, type; - for (key in object) { - transformation = transformations[key]; - type = typeof transformation; - result[key] = type === 'function' ? transformation(object[key]) - : transformation && type === 'object' ? evolve(transformation, object[key]) - : object[key]; - } - return result; -}); - -function XFind(f, xf) { - this.xf = xf; - this.f = f; - this.found = false; -} -XFind.prototype['@@transducer/init'] = _xfBase.init; -XFind.prototype['@@transducer/result'] = function(result) { - if (!this.found) { - result = this.xf['@@transducer/step'](result, void 0); - } - return this.xf['@@transducer/result'](result); -}; -XFind.prototype['@@transducer/step'] = function(result, input) { - if (this.f(input)) { - this.found = true; - result = _reduced(this.xf['@@transducer/step'](result, input)); - } - return result; -}; - -var _xfind = _curry2(function _xfind(f, xf) { return new XFind(f, xf); }); - -/** - * Returns the first element of the list which matches the predicate, or - * `undefined` if no element matches. - * - * Dispatches to the `find` method of the second argument, if present. - * - * Acts as a transducer if a transformer is given in list position. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category List - * @sig (a -> Boolean) -> [a] -> a | undefined - * @param {Function} fn The predicate function used to determine if the element is the - * desired one. - * @param {Array} list The array to consider. - * @return {Object} The element found, or `undefined`. - * @see R.transduce - * @example - * - * const xs = [{a: 1}, {a: 2}, {a: 3}]; - * R.find(R.propEq('a', 2))(xs); //=> {a: 2} - * R.find(R.propEq('a', 4))(xs); //=> undefined - */ -var find = _curry2(_dispatchable(['find'], _xfind, function find(fn, list) { - var idx = 0; - var len = list.length; - while (idx < len) { - if (fn(list[idx])) { - return list[idx]; - } - idx += 1; - } -})); - -function XFindIndex(f, xf) { - this.xf = xf; - this.f = f; - this.idx = -1; - this.found = false; -} -XFindIndex.prototype['@@transducer/init'] = _xfBase.init; -XFindIndex.prototype['@@transducer/result'] = function(result) { - if (!this.found) { - result = this.xf['@@transducer/step'](result, -1); - } - return this.xf['@@transducer/result'](result); -}; -XFindIndex.prototype['@@transducer/step'] = function(result, input) { - this.idx += 1; - if (this.f(input)) { - this.found = true; - result = _reduced(this.xf['@@transducer/step'](result, this.idx)); - } - return result; -}; - -var _xfindIndex = _curry2(function _xfindIndex(f, xf) { return new XFindIndex(f, xf); }); - -/** - * Returns the index of the first element of the list which matches the - * predicate, or `-1` if no element matches. - * - * Acts as a transducer if a transformer is given in list position. - * - * @func - * @memberOf R - * @since v0.1.1 - * @category List - * @sig (a -> Boolean) -> [a] -> Number - * @param {Function} fn The predicate function used to determine if the element is the - * desired one. - * @param {Array} list The array to consider. - * @return {Number} The index of the element found, or `-1`. - * @see R.transduce - * @example - * - * const xs = [{a: 1}, {a: 2}, {a: 3}]; - * R.findIndex(R.propEq('a', 2))(xs); //=> 1 - * R.findIndex(R.propEq('a', 4))(xs); //=> -1 - */ -var findIndex = _curry2(_dispatchable([], _xfindIndex, function findIndex(fn, list) { - var idx = 0; - var len = list.length; - while (idx < len) { - if (fn(list[idx])) { - return idx; - } - idx += 1; - } - return -1; -})); - -function XFindLast(f, xf) { - this.xf = xf; - this.f = f; -} -XFindLast.prototype['@@transducer/init'] = _xfBase.init; -XFindLast.prototype['@@transducer/result'] = function(result) { - return this.xf['@@transducer/result'](this.xf['@@transducer/step'](result, this.last)); -}; -XFindLast.prototype['@@transducer/step'] = function(result, input) { - if (this.f(input)) { - this.last = input; - } - return result; -}; - -var _xfindLast = _curry2(function _xfindLast(f, xf) { return new XFindLast(f, xf); }); - -/** - * Returns the last element of the list which matches the predicate, or - * `undefined` if no element matches. - * - * Acts as a transducer if a transformer is given in list position. - * - * @func - * @memberOf R - * @since v0.1.1 - * @category List - * @sig (a -> Boolean) -> [a] -> a | undefined - * @param {Function} fn The predicate function used to determine if the element is the - * desired one. - * @param {Array} list The array to consider. - * @return {Object} The element found, or `undefined`. - * @see R.transduce - * @example - * - * const xs = [{a: 1, b: 0}, {a:1, b: 1}]; - * R.findLast(R.propEq('a', 1))(xs); //=> {a: 1, b: 1} - * R.findLast(R.propEq('a', 4))(xs); //=> undefined - */ -var findLast = _curry2(_dispatchable([], _xfindLast, function findLast(fn, list) { - var idx = list.length - 1; - while (idx >= 0) { - if (fn(list[idx])) { - return list[idx]; - } - idx -= 1; - } -})); - -function XFindLastIndex(f, xf) { - this.xf = xf; - this.f = f; - this.idx = -1; - this.lastIdx = -1; -} -XFindLastIndex.prototype['@@transducer/init'] = _xfBase.init; -XFindLastIndex.prototype['@@transducer/result'] = function(result) { - return this.xf['@@transducer/result'](this.xf['@@transducer/step'](result, this.lastIdx)); -}; -XFindLastIndex.prototype['@@transducer/step'] = function(result, input) { - this.idx += 1; - if (this.f(input)) { - this.lastIdx = this.idx; - } - return result; -}; - -var _xfindLastIndex = _curry2(function _xfindLastIndex(f, xf) { return new XFindLastIndex(f, xf); }); - -/** - * Returns the index of the last element of the list which matches the - * predicate, or `-1` if no element matches. - * - * Acts as a transducer if a transformer is given in list position. - * - * @func - * @memberOf R - * @since v0.1.1 - * @category List - * @sig (a -> Boolean) -> [a] -> Number - * @param {Function} fn The predicate function used to determine if the element is the - * desired one. - * @param {Array} list The array to consider. - * @return {Number} The index of the element found, or `-1`. - * @see R.transduce - * @example - * - * const xs = [{a: 1, b: 0}, {a:1, b: 1}]; - * R.findLastIndex(R.propEq('a', 1))(xs); //=> 1 - * R.findLastIndex(R.propEq('a', 4))(xs); //=> -1 - */ -var findLastIndex = _curry2(_dispatchable([], _xfindLastIndex, function findLastIndex(fn, list) { - var idx = list.length - 1; - while (idx >= 0) { - if (fn(list[idx])) { - return idx; - } - idx -= 1; - } - return -1; -})); - -/** - * Returns a new list by pulling every item out of it (and all its sub-arrays) - * and putting them in a new array, depth-first. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category List - * @sig [a] -> [b] - * @param {Array} list The array to consider. - * @return {Array} The flattened list. - * @see R.unnest - * @example - * - * R.flatten([1, 2, [3, 4], 5, [6, [7, 8, [9, [10, 11], 12]]]]); - * //=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] - */ -var flatten = _curry1(_makeFlat(true)); - -/** - * Returns a new function much like the supplied one, except that the first two - * arguments' order is reversed. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Function - * @sig ((a, b, c, ...) -> z) -> (b -> a -> c -> ... -> z) - * @param {Function} fn The function to invoke with its first two parameters reversed. - * @return {*} The result of invoking `fn` with its first two parameters' order reversed. - * @example - * - * const mergeThree = (a, b, c) => [].concat(a, b, c); - * - * mergeThree(1, 2, 3); //=> [1, 2, 3] - * - * R.flip(mergeThree)(1, 2, 3); //=> [2, 1, 3] - * @symb R.flip(f)(a, b, c) = f(b, a, c) - */ -var flip = _curry1(function flip(fn) { - return curryN(fn.length, function(a, b) { - var args = Array.prototype.slice.call(arguments, 0); - args[0] = b; - args[1] = a; - return fn.apply(this, args); - }); -}); - -/** - * Iterate over an input `list`, calling a provided function `fn` for each - * element in the list. - * - * `fn` receives one argument: *(value)*. - * - * Note: `R.forEach` does not skip deleted or unassigned indices (sparse - * arrays), unlike the native `Array.prototype.forEach` method. For more - * details on this behavior, see: - * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach#Description - * - * Also note that, unlike `Array.prototype.forEach`, Ramda's `forEach` returns - * the original array. In some libraries this function is named `each`. - * - * Dispatches to the `forEach` method of the second argument, if present. - * - * @func - * @memberOf R - * @since v0.1.1 - * @category List - * @sig (a -> *) -> [a] -> [a] - * @param {Function} fn The function to invoke. Receives one argument, `value`. - * @param {Array} list The list to iterate over. - * @return {Array} The original list. - * @see R.addIndex - * @example - * - * const printXPlusFive = x => console.log(x + 5); - * R.forEach(printXPlusFive, [1, 2, 3]); //=> [1, 2, 3] - * // logs 6 - * // logs 7 - * // logs 8 - * @symb R.forEach(f, [a, b, c]) = [a, b, c] - */ -var forEach = _curry2(_checkForMethod('forEach', function forEach(fn, list) { - var len = list.length; - var idx = 0; - while (idx < len) { - fn(list[idx]); - idx += 1; - } - return list; -})); - -/** - * Iterate over an input `object`, calling a provided function `fn` for each - * key and value in the object. - * - * `fn` receives three argument: *(value, key, obj)*. - * - * @func - * @memberOf R - * @since v0.23.0 - * @category Object - * @sig ((a, String, StrMap a) -> Any) -> StrMap a -> StrMap a - * @param {Function} fn The function to invoke. Receives three argument, `value`, `key`, `obj`. - * @param {Object} obj The object to iterate over. - * @return {Object} The original object. - * @example - * - * const printKeyConcatValue = (value, key) => console.log(key + ':' + value); - * R.forEachObjIndexed(printKeyConcatValue, {x: 1, y: 2}); //=> {x: 1, y: 2} - * // logs x:1 - * // logs y:2 - * @symb R.forEachObjIndexed(f, {x: a, y: b}) = {x: a, y: b} - */ -var forEachObjIndexed = _curry2(function forEachObjIndexed(fn, obj) { - var keyList = keys(obj); - var idx = 0; - while (idx < keyList.length) { - var key = keyList[idx]; - fn(obj[key], key, obj); - idx += 1; - } - return obj; -}); - -/** - * Creates a new object from a list key-value pairs. If a key appears in - * multiple pairs, the rightmost pair is included in the object. - * - * @func - * @memberOf R - * @since v0.3.0 - * @category List - * @sig [[k,v]] -> {k: v} - * @param {Array} pairs An array of two-element arrays that will be the keys and values of the output object. - * @return {Object} The object made by pairing up `keys` and `values`. - * @see R.toPairs, R.pair - * @example - * - * R.fromPairs([['a', 1], ['b', 2], ['c', 3]]); //=> {a: 1, b: 2, c: 3} - */ -var fromPairs = _curry1(function fromPairs(pairs) { - var result = {}; - var idx = 0; - while (idx < pairs.length) { - result[pairs[idx][0]] = pairs[idx][1]; - idx += 1; - } - return result; -}); - -/** - * Splits a list into sub-lists stored in an object, based on the result of - * calling a String-returning function on each element, and grouping the - * results according to values returned. - * - * Dispatches to the `groupBy` method of the second argument, if present. - * - * Acts as a transducer if a transformer is given in list position. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category List - * @sig (a -> String) -> [a] -> {String: [a]} - * @param {Function} fn Function :: a -> String - * @param {Array} list The array to group - * @return {Object} An object with the output of `fn` for keys, mapped to arrays of elements - * that produced that key when passed to `fn`. - * @see R.reduceBy, R.transduce - * @example - * - * const byGrade = R.groupBy(function(student) { - * const score = student.score; - * return score < 65 ? 'F' : - * score < 70 ? 'D' : - * score < 80 ? 'C' : - * score < 90 ? 'B' : 'A'; - * }); - * const students = [{name: 'Abby', score: 84}, - * {name: 'Eddy', score: 58}, - * // ... - * {name: 'Jack', score: 69}]; - * byGrade(students); - * // { - * // 'A': [{name: 'Dianne', score: 99}], - * // 'B': [{name: 'Abby', score: 84}] - * // // ..., - * // 'F': [{name: 'Eddy', score: 58}] - * // } - */ -var groupBy = _curry2(_checkForMethod('groupBy', reduceBy(function(acc, item) { - if (acc == null) { - acc = []; - } - acc.push(item); - return acc; -}, null))); - -/** - * Takes a list and returns a list of lists where each sublist's elements are - * all satisfied pairwise comparison according to the provided function. - * Only adjacent elements are passed to the comparison function. - * - * @func - * @memberOf R - * @since v0.21.0 - * @category List - * @sig ((a, a) → Boolean) → [a] → [[a]] - * @param {Function} fn Function for determining whether two given (adjacent) - * elements should be in the same group - * @param {Array} list The array to group. Also accepts a string, which will be - * treated as a list of characters. - * @return {List} A list that contains sublists of elements, - * whose concatenations are equal to the original list. - * @example - * - * R.groupWith(R.equals, [0, 1, 1, 2, 3, 5, 8, 13, 21]) - * //=> [[0], [1, 1], [2], [3], [5], [8], [13], [21]] - * - * R.groupWith((a, b) => a + 1 === b, [0, 1, 1, 2, 3, 5, 8, 13, 21]) - * //=> [[0, 1], [1, 2, 3], [5], [8], [13], [21]] - * - * R.groupWith((a, b) => a % 2 === b % 2, [0, 1, 1, 2, 3, 5, 8, 13, 21]) - * //=> [[0], [1, 1], [2], [3, 5], [8], [13, 21]] - * - * R.groupWith(R.eqBy(isVowel), 'aestiou') - * //=> ['ae', 'st', 'iou'] - */ -var groupWith = _curry2(function(fn, list) { - var res = []; - var idx = 0; - var len = list.length; - while (idx < len) { - var nextidx = idx + 1; - while (nextidx < len && fn(list[nextidx - 1], list[nextidx])) { - nextidx += 1; - } - res.push(list.slice(idx, nextidx)); - idx = nextidx; - } - return res; -}); - -/** - * Returns `true` if the first argument is greater than the second; `false` - * otherwise. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Relation - * @sig Ord a => a -> a -> Boolean - * @param {*} a - * @param {*} b - * @return {Boolean} - * @see R.lt - * @example - * - * R.gt(2, 1); //=> true - * R.gt(2, 2); //=> false - * R.gt(2, 3); //=> false - * R.gt('a', 'z'); //=> false - * R.gt('z', 'a'); //=> true - */ -var gt = _curry2(function gt(a, b) { return a > b; }); - -/** - * Returns `true` if the first argument is greater than or equal to the second; - * `false` otherwise. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Relation - * @sig Ord a => a -> a -> Boolean - * @param {Number} a - * @param {Number} b - * @return {Boolean} - * @see R.lte - * @example - * - * R.gte(2, 1); //=> true - * R.gte(2, 2); //=> true - * R.gte(2, 3); //=> false - * R.gte('a', 'z'); //=> false - * R.gte('z', 'a'); //=> true - */ -var gte = _curry2(function gte(a, b) { return a >= b; }); - -/** - * Returns whether or not a path exists in an object. Only the object's - * own properties are checked. - * - * @func - * @memberOf R - * @since v0.26.0 - * @category Object - * @typedefn Idx = String | Int - * @sig [Idx] -> {a} -> Boolean - * @param {Array} path The path to use. - * @param {Object} obj The object to check the path in. - * @return {Boolean} Whether the path exists. - * @see R.has - * @example - * - * R.hasPath(['a', 'b'], {a: {b: 2}}); // => true - * R.hasPath(['a', 'b'], {a: {b: undefined}}); // => true - * R.hasPath(['a', 'b'], {a: {c: 2}}); // => false - * R.hasPath(['a', 'b'], {}); // => false - */ -var hasPath = _curry2(function hasPath(_path, obj) { - if (_path.length === 0) { - return false; - } - var val = obj; - var idx = 0; - while (idx < _path.length) { - if (_has(_path[idx], val)) { - val = val[_path[idx]]; - idx += 1; - } else { - return false; - } - } - return true; -}); - -/** - * Returns whether or not an object has an own property with the specified name - * - * @func - * @memberOf R - * @since v0.7.0 - * @category Object - * @sig s -> {s: x} -> Boolean - * @param {String} prop The name of the property to check for. - * @param {Object} obj The object to query. - * @return {Boolean} Whether the property exists. - * @example - * - * const hasName = R.has('name'); - * hasName({name: 'alice'}); //=> true - * hasName({name: 'bob'}); //=> true - * hasName({}); //=> false - * - * const point = {x: 0, y: 0}; - * const pointHas = R.has(R.__, point); - * pointHas('x'); //=> true - * pointHas('y'); //=> true - * pointHas('z'); //=> false - */ -var has = _curry2(function has(prop, obj) { - return hasPath([prop], obj); -}); - -/** - * Returns whether or not an object or its prototype chain has a property with - * the specified name - * - * @func - * @memberOf R - * @since v0.7.0 - * @category Object - * @sig s -> {s: x} -> Boolean - * @param {String} prop The name of the property to check for. - * @param {Object} obj The object to query. - * @return {Boolean} Whether the property exists. - * @example - * - * function Rectangle(width, height) { - * this.width = width; - * this.height = height; - * } - * Rectangle.prototype.area = function() { - * return this.width * this.height; - * }; - * - * const square = new Rectangle(2, 2); - * R.hasIn('width', square); //=> true - * R.hasIn('area', square); //=> true - */ -var hasIn = _curry2(function hasIn(prop, obj) { - return prop in obj; -}); - -/** - * Returns true if its arguments are identical, false otherwise. Values are - * identical if they reference the same memory. `NaN` is identical to `NaN`; - * `0` and `-0` are not identical. - * - * Note this is merely a curried version of ES6 `Object.is`. - * - * @func - * @memberOf R - * @since v0.15.0 - * @category Relation - * @sig a -> a -> Boolean - * @param {*} a - * @param {*} b - * @return {Boolean} - * @example - * - * const o = {}; - * R.identical(o, o); //=> true - * R.identical(1, 1); //=> true - * R.identical(1, '1'); //=> false - * R.identical([], []); //=> false - * R.identical(0, -0); //=> false - * R.identical(NaN, NaN); //=> true - */ -var identical = _curry2(_objectIs$1); - -/** - * Creates a function that will process either the `onTrue` or the `onFalse` - * function depending upon the result of the `condition` predicate. - * - * @func - * @memberOf R - * @since v0.8.0 - * @category Logic - * @sig (*... -> Boolean) -> (*... -> *) -> (*... -> *) -> (*... -> *) - * @param {Function} condition A predicate function - * @param {Function} onTrue A function to invoke when the `condition` evaluates to a truthy value. - * @param {Function} onFalse A function to invoke when the `condition` evaluates to a falsy value. - * @return {Function} A new function that will process either the `onTrue` or the `onFalse` - * function depending upon the result of the `condition` predicate. - * @see R.unless, R.when, R.cond - * @example - * - * const incCount = R.ifElse( - * R.has('count'), - * R.over(R.lensProp('count'), R.inc), - * R.assoc('count', 1) - * ); - * incCount({}); //=> { count: 1 } - * incCount({ count: 1 }); //=> { count: 2 } - */ -var ifElse = _curry3(function ifElse(condition, onTrue, onFalse) { - return curryN(Math.max(condition.length, onTrue.length, onFalse.length), - function _ifElse() { - return condition.apply(this, arguments) ? onTrue.apply(this, arguments) : onFalse.apply(this, arguments); - } - ); -}); - -/** - * Increments its argument. - * - * @func - * @memberOf R - * @since v0.9.0 - * @category Math - * @sig Number -> Number - * @param {Number} n - * @return {Number} n + 1 - * @see R.dec - * @example - * - * R.inc(42); //=> 43 - */ -var inc = add(1); - -/** - * Returns `true` if the specified value is equal, in [`R.equals`](#equals) - * terms, to at least one element of the given list; `false` otherwise. - * Works also with strings. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category List - * @sig a -> [a] -> Boolean - * @param {Object} a The item to compare against. - * @param {Array} list The array to consider. - * @return {Boolean} `true` if an equivalent item is in the list, `false` otherwise. - * @see R.any - * @example - * - * R.includes(3, [1, 2, 3]); //=> true - * R.includes(4, [1, 2, 3]); //=> false - * R.includes({ name: 'Fred' }, [{ name: 'Fred' }]); //=> true - * R.includes([42], [[42]]); //=> true - * R.includes('ba', 'banana'); //=>true - */ -var includes = _curry2(_includes); - -/** - * Given a function that generates a key, turns a list of objects into an - * object indexing the objects by the given key. Note that if multiple - * objects generate the same value for the indexing key only the last value - * will be included in the generated object. - * - * Acts as a transducer if a transformer is given in list position. - * - * @func - * @memberOf R - * @since v0.19.0 - * @category List - * @sig (a -> String) -> [{k: v}] -> {k: {k: v}} - * @param {Function} fn Function :: a -> String - * @param {Array} array The array of objects to index - * @return {Object} An object indexing each array element by the given property. - * @example - * - * const list = [{id: 'xyz', title: 'A'}, {id: 'abc', title: 'B'}]; - * R.indexBy(R.prop('id'), list); - * //=> {abc: {id: 'abc', title: 'B'}, xyz: {id: 'xyz', title: 'A'}} - */ -var indexBy = reduceBy(function(acc, elem) { return elem; }, null); - -/** - * Returns the position of the first occurrence of an item in an array, or -1 - * if the item is not included in the array. [`R.equals`](#equals) is used to - * determine equality. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category List - * @sig a -> [a] -> Number - * @param {*} target The item to find. - * @param {Array} xs The array to search in. - * @return {Number} the index of the target, or -1 if the target is not found. - * @see R.lastIndexOf - * @example - * - * R.indexOf(3, [1,2,3,4]); //=> 2 - * R.indexOf(10, [1,2,3,4]); //=> -1 - */ -var indexOf = _curry2(function indexOf(target, xs) { - return typeof xs.indexOf === 'function' && !_isArray(xs) ? - xs.indexOf(target) : - _indexOf(xs, target, 0); -}); - -/** - * Returns all but the last element of the given list or string. - * - * @func - * @memberOf R - * @since v0.9.0 - * @category List - * @sig [a] -> [a] - * @sig String -> String - * @param {*} list - * @return {*} - * @see R.last, R.head, R.tail - * @example - * - * R.init([1, 2, 3]); //=> [1, 2] - * R.init([1, 2]); //=> [1] - * R.init([1]); //=> [] - * R.init([]); //=> [] - * - * R.init('abc'); //=> 'ab' - * R.init('ab'); //=> 'a' - * R.init('a'); //=> '' - * R.init(''); //=> '' - */ -var init = slice(0, -1); - -/** - * Takes a predicate `pred`, a list `xs`, and a list `ys`, and returns a list - * `xs'` comprising each of the elements of `xs` which is equal to one or more - * elements of `ys` according to `pred`. - * - * `pred` must be a binary function expecting an element from each list. - * - * `xs`, `ys`, and `xs'` are treated as sets, semantically, so ordering should - * not be significant, but since `xs'` is ordered the implementation guarantees - * that its values are in the same order as they appear in `xs`. Duplicates are - * not removed, so `xs'` may contain duplicates if `xs` contains duplicates. - * - * @func - * @memberOf R - * @since v0.24.0 - * @category Relation - * @sig ((a, b) -> Boolean) -> [a] -> [b] -> [a] - * @param {Function} pred - * @param {Array} xs - * @param {Array} ys - * @return {Array} - * @see R.intersection - * @example - * - * R.innerJoin( - * (record, id) => record.id === id, - * [{id: 824, name: 'Richie Furay'}, - * {id: 956, name: 'Dewey Martin'}, - * {id: 313, name: 'Bruce Palmer'}, - * {id: 456, name: 'Stephen Stills'}, - * {id: 177, name: 'Neil Young'}], - * [177, 456, 999] - * ); - * //=> [{id: 456, name: 'Stephen Stills'}, {id: 177, name: 'Neil Young'}] - */ -var innerJoin = _curry3(function innerJoin(pred, xs, ys) { - return _filter(function(x) { return _includesWith(pred, x, ys); }, xs); -}); - -/** - * Inserts the supplied element into the list, at the specified `index`. _Note that - - * this is not destructive_: it returns a copy of the list with the changes. - * No lists have been harmed in the application of this function. - * - * @func - * @memberOf R - * @since v0.2.2 - * @category List - * @sig Number -> a -> [a] -> [a] - * @param {Number} index The position to insert the element - * @param {*} elt The element to insert into the Array - * @param {Array} list The list to insert into - * @return {Array} A new Array with `elt` inserted at `index`. - * @example - * - * R.insert(2, 'x', [1,2,3,4]); //=> [1,2,'x',3,4] - */ -var insert = _curry3(function insert(idx, elt, list) { - idx = idx < list.length && idx >= 0 ? idx : list.length; - var result = Array.prototype.slice.call(list, 0); - result.splice(idx, 0, elt); - return result; -}); - -/** - * Inserts the sub-list into the list, at the specified `index`. _Note that this is not - * destructive_: it returns a copy of the list with the changes. - * No lists have been harmed in the application of this function. - * - * @func - * @memberOf R - * @since v0.9.0 - * @category List - * @sig Number -> [a] -> [a] -> [a] - * @param {Number} index The position to insert the sub-list - * @param {Array} elts The sub-list to insert into the Array - * @param {Array} list The list to insert the sub-list into - * @return {Array} A new Array with `elts` inserted starting at `index`. - * @example - * - * R.insertAll(2, ['x','y','z'], [1,2,3,4]); //=> [1,2,'x','y','z',3,4] - */ -var insertAll = _curry3(function insertAll(idx, elts, list) { - idx = idx < list.length && idx >= 0 ? idx : list.length; - return [].concat(Array.prototype.slice.call(list, 0, idx), - elts, - Array.prototype.slice.call(list, idx)); -}); - -/** - * Returns a new list containing only one copy of each element in the original - * list, based upon the value returned by applying the supplied function to - * each list element. Prefers the first item if the supplied function produces - * the same value on two items. [`R.equals`](#equals) is used for comparison. - * - * @func - * @memberOf R - * @since v0.16.0 - * @category List - * @sig (a -> b) -> [a] -> [a] - * @param {Function} fn A function used to produce a value to use during comparisons. - * @param {Array} list The array to consider. - * @return {Array} The list of unique items. - * @example - * - * R.uniqBy(Math.abs, [-1, -5, 2, 10, 1, 2]); //=> [-1, -5, 2, 10] - */ -var uniqBy = _curry2(function uniqBy(fn, list) { - var set = new _Set(); - var result = []; - var idx = 0; - var appliedItem, item; - - while (idx < list.length) { - item = list[idx]; - appliedItem = fn(item); - if (set.add(appliedItem)) { - result.push(item); - } - idx += 1; - } - return result; -}); - -/** - * Returns a new list containing only one copy of each element in the original - * list. [`R.equals`](#equals) is used to determine equality. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category List - * @sig [a] -> [a] - * @param {Array} list The array to consider. - * @return {Array} The list of unique items. - * @example - * - * R.uniq([1, 1, 2, 1]); //=> [1, 2] - * R.uniq([1, '1']); //=> [1, '1'] - * R.uniq([[42], [42]]); //=> [[42]] - */ -var uniq = uniqBy(identity); - -/** - * Combines two lists into a set (i.e. no duplicates) composed of those - * elements common to both lists. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Relation - * @sig [*] -> [*] -> [*] - * @param {Array} list1 The first list. - * @param {Array} list2 The second list. - * @return {Array} The list of elements found in both `list1` and `list2`. - * @see R.innerJoin - * @example - * - * R.intersection([1,2,3,4], [7,6,5,4,3]); //=> [4, 3] - */ -var intersection = _curry2(function intersection(list1, list2) { - var lookupList, filteredList; - if (list1.length > list2.length) { - lookupList = list1; - filteredList = list2; - } else { - lookupList = list2; - filteredList = list1; - } - return uniq(_filter(flip(_includes)(lookupList), filteredList)); -}); - -/** - * Creates a new list with the separator interposed between elements. - * - * Dispatches to the `intersperse` method of the second argument, if present. - * - * @func - * @memberOf R - * @since v0.14.0 - * @category List - * @sig a -> [a] -> [a] - * @param {*} separator The element to add to the list. - * @param {Array} list The list to be interposed. - * @return {Array} The new list. - * @example - * - * R.intersperse('a', ['b', 'n', 'n', 's']); //=> ['b', 'a', 'n', 'a', 'n', 'a', 's'] - */ -var intersperse = _curry2(_checkForMethod('intersperse', function intersperse(separator, list) { - var out = []; - var idx = 0; - var length = list.length; - while (idx < length) { - if (idx === length - 1) { - out.push(list[idx]); - } else { - out.push(list[idx], separator); - } - idx += 1; - } - return out; -})); - -// Based on https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/assign -function _objectAssign(target) { - if (target == null) { - throw new TypeError('Cannot convert undefined or null to object'); - } - - var output = Object(target); - var idx = 1; - var length = arguments.length; - while (idx < length) { - var source = arguments[idx]; - if (source != null) { - for (var nextKey in source) { - if (_has(nextKey, source)) { - output[nextKey] = source[nextKey]; - } - } - } - idx += 1; - } - return output; -} - -var _objectAssign$1 = typeof Object.assign === 'function' ? Object.assign : _objectAssign; - -/** - * Creates an object containing a single key:value pair. - * - * @func - * @memberOf R - * @since v0.18.0 - * @category Object - * @sig String -> a -> {String:a} - * @param {String} key - * @param {*} val - * @return {Object} - * @see R.pair - * @example - * - * const matchPhrases = R.compose( - * R.objOf('must'), - * R.map(R.objOf('match_phrase')) - * ); - * matchPhrases(['foo', 'bar', 'baz']); //=> {must: [{match_phrase: 'foo'}, {match_phrase: 'bar'}, {match_phrase: 'baz'}]} - */ -var objOf = _curry2(function objOf(key, val) { - var obj = {}; - obj[key] = val; - return obj; -}); - -var _stepCatArray = { - '@@transducer/init': Array, - '@@transducer/step': function(xs, x) { - xs.push(x); - return xs; - }, - '@@transducer/result': _identity -}; -var _stepCatString = { - '@@transducer/init': String, - '@@transducer/step': function(a, b) { return a + b; }, - '@@transducer/result': _identity -}; -var _stepCatObject = { - '@@transducer/init': Object, - '@@transducer/step': function(result, input) { - return _objectAssign$1( - result, - _isArrayLike(input) ? objOf(input[0], input[1]) : input - ); - }, - '@@transducer/result': _identity -}; - -function _stepCat(obj) { - if (_isTransformer(obj)) { - return obj; - } - if (_isArrayLike(obj)) { - return _stepCatArray; - } - if (typeof obj === 'string') { - return _stepCatString; - } - if (typeof obj === 'object') { - return _stepCatObject; - } - throw new Error('Cannot create transformer for ' + obj); -} - -/** - * Transforms the items of the list with the transducer and appends the - * transformed items to the accumulator using an appropriate iterator function - * based on the accumulator type. - * - * The accumulator can be an array, string, object or a transformer. Iterated - * items will be appended to arrays and concatenated to strings. Objects will - * be merged directly or 2-item arrays will be merged as key, value pairs. - * - * The accumulator can also be a transformer object that provides a 2-arity - * reducing iterator function, step, 0-arity initial value function, init, and - * 1-arity result extraction function result. The step function is used as the - * iterator function in reduce. The result function is used to convert the - * final accumulator into the return type and in most cases is R.identity. The - * init function is used to provide the initial accumulator. - * - * The iteration is performed with [`R.reduce`](#reduce) after initializing the - * transducer. - * - * @func - * @memberOf R - * @since v0.12.0 - * @category List - * @sig a -> (b -> b) -> [c] -> a - * @param {*} acc The initial accumulator value. - * @param {Function} xf The transducer function. Receives a transformer and returns a transformer. - * @param {Array} list The list to iterate over. - * @return {*} The final, accumulated value. - * @see R.transduce - * @example - * - * const numbers = [1, 2, 3, 4]; - * const transducer = R.compose(R.map(R.add(1)), R.take(2)); - * - * R.into([], transducer, numbers); //=> [2, 3] - * - * const intoArray = R.into([]); - * intoArray(transducer, numbers); //=> [2, 3] - */ -var into = _curry3(function into(acc, xf, list) { - return _isTransformer(acc) ? - _reduce(xf(acc), acc['@@transducer/init'](), list) : - _reduce(xf(_stepCat(acc)), _clone(acc, [], [], false), list); -}); - -/** - * Same as [`R.invertObj`](#invertObj), however this accounts for objects with - * duplicate values by putting the values into an array. - * - * @func - * @memberOf R - * @since v0.9.0 - * @category Object - * @sig {s: x} -> {x: [ s, ... ]} - * @param {Object} obj The object or array to invert - * @return {Object} out A new object with keys in an array. - * @see R.invertObj - * @example - * - * const raceResultsByFirstName = { - * first: 'alice', - * second: 'jake', - * third: 'alice', - * }; - * R.invert(raceResultsByFirstName); - * //=> { 'alice': ['first', 'third'], 'jake':['second'] } - */ -var invert = _curry1(function invert(obj) { - var props = keys(obj); - var len = props.length; - var idx = 0; - var out = {}; - - while (idx < len) { - var key = props[idx]; - var val = obj[key]; - var list = _has(val, out) ? out[val] : (out[val] = []); - list[list.length] = key; - idx += 1; - } - return out; -}); - -/** - * Returns a new object with the keys of the given object as values, and the - * values of the given object, which are coerced to strings, as keys. Note - * that the last key found is preferred when handling the same value. - * - * @func - * @memberOf R - * @since v0.9.0 - * @category Object - * @sig {s: x} -> {x: s} - * @param {Object} obj The object or array to invert - * @return {Object} out A new object - * @see R.invert - * @example - * - * const raceResults = { - * first: 'alice', - * second: 'jake' - * }; - * R.invertObj(raceResults); - * //=> { 'alice': 'first', 'jake':'second' } - * - * // Alternatively: - * const raceResults = ['alice', 'jake']; - * R.invertObj(raceResults); - * //=> { 'alice': '0', 'jake':'1' } - */ -var invertObj = _curry1(function invertObj(obj) { - var props = keys(obj); - var len = props.length; - var idx = 0; - var out = {}; - - while (idx < len) { - var key = props[idx]; - out[obj[key]] = key; - idx += 1; - } - return out; -}); - -/** - * Turns a named method with a specified arity into a function that can be - * called directly supplied with arguments and a target object. - * - * The returned function is curried and accepts `arity + 1` parameters where - * the final parameter is the target object. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Function - * @sig Number -> String -> (a -> b -> ... -> n -> Object -> *) - * @param {Number} arity Number of arguments the returned function should take - * before the target object. - * @param {String} method Name of the method to call. - * @return {Function} A new curried function. - * @see R.construct - * @example - * - * const sliceFrom = R.invoker(1, 'slice'); - * sliceFrom(6, 'abcdefghijklm'); //=> 'ghijklm' - * const sliceFrom6 = R.invoker(2, 'slice')(6); - * sliceFrom6(8, 'abcdefghijklm'); //=> 'gh' - * @symb R.invoker(0, 'method')(o) = o['method']() - * @symb R.invoker(1, 'method')(a, o) = o['method'](a) - * @symb R.invoker(2, 'method')(a, b, o) = o['method'](a, b) - */ -var invoker = _curry2(function invoker(arity, method) { - return curryN(arity + 1, function() { - var target = arguments[arity]; - if (target != null && _isFunction(target[method])) { - return target[method].apply(target, Array.prototype.slice.call(arguments, 0, arity)); - } - throw new TypeError(toString$1(target) + ' does not have a method named "' + method + '"'); - }); -}); - -/** - * See if an object (`val`) is an instance of the supplied constructor. This - * function will check up the inheritance chain, if any. - * - * @func - * @memberOf R - * @since v0.3.0 - * @category Type - * @sig (* -> {*}) -> a -> Boolean - * @param {Object} ctor A constructor - * @param {*} val The value to test - * @return {Boolean} - * @example - * - * R.is(Object, {}); //=> true - * R.is(Number, 1); //=> true - * R.is(Object, 1); //=> false - * R.is(String, 's'); //=> true - * R.is(String, new String('')); //=> true - * R.is(Object, new String('')); //=> true - * R.is(Object, 's'); //=> false - * R.is(Number, {}); //=> false - */ -var is = _curry2(function is(Ctor, val) { - return val != null && val.constructor === Ctor || val instanceof Ctor; -}); - -/** - * Returns `true` if the given value is its type's empty value; `false` - * otherwise. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Logic - * @sig a -> Boolean - * @param {*} x - * @return {Boolean} - * @see R.empty - * @example - * - * R.isEmpty([1, 2, 3]); //=> false - * R.isEmpty([]); //=> true - * R.isEmpty(''); //=> true - * R.isEmpty(null); //=> false - * R.isEmpty({}); //=> true - * R.isEmpty({length: 0}); //=> false - */ -var isEmpty = _curry1(function isEmpty(x) { - return x != null && equals(x, empty(x)); -}); - -/** - * Returns a string made by inserting the `separator` between each element and - * concatenating all the elements into a single string. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category List - * @sig String -> [a] -> String - * @param {Number|String} separator The string used to separate the elements. - * @param {Array} xs The elements to join into a string. - * @return {String} str The string made by concatenating `xs` with `separator`. - * @see R.split - * @example - * - * const spacer = R.join(' '); - * spacer(['a', 2, 3.4]); //=> 'a 2 3.4' - * R.join('|', [1, 2, 3]); //=> '1|2|3' - */ -var join = invoker(1, 'join'); - -/** - * juxt applies a list of functions to a list of values. - * - * @func - * @memberOf R - * @since v0.19.0 - * @category Function - * @sig [(a, b, ..., m) -> n] -> ((a, b, ..., m) -> [n]) - * @param {Array} fns An array of functions - * @return {Function} A function that returns a list of values after applying each of the original `fns` to its parameters. - * @see R.applySpec - * @example - * - * const getRange = R.juxt([Math.min, Math.max]); - * getRange(3, 4, 9, -3); //=> [-3, 9] - * @symb R.juxt([f, g, h])(a, b) = [f(a, b), g(a, b), h(a, b)] - */ -var juxt = _curry1(function juxt(fns) { - return converge(function() { return Array.prototype.slice.call(arguments, 0); }, fns); -}); - -/** - * Returns a list containing the names of all the properties of the supplied - * object, including prototype properties. - * Note that the order of the output array is not guaranteed to be consistent - * across different JS platforms. - * - * @func - * @memberOf R - * @since v0.2.0 - * @category Object - * @sig {k: v} -> [k] - * @param {Object} obj The object to extract properties from - * @return {Array} An array of the object's own and prototype properties. - * @see R.keys, R.valuesIn - * @example - * - * const F = function() { this.x = 'X'; }; - * F.prototype.y = 'Y'; - * const f = new F(); - * R.keysIn(f); //=> ['x', 'y'] - */ -var keysIn = _curry1(function keysIn(obj) { - var prop; - var ks = []; - for (prop in obj) { - ks[ks.length] = prop; - } - return ks; -}); - -/** - * Returns the position of the last occurrence of an item in an array, or -1 if - * the item is not included in the array. [`R.equals`](#equals) is used to - * determine equality. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category List - * @sig a -> [a] -> Number - * @param {*} target The item to find. - * @param {Array} xs The array to search in. - * @return {Number} the index of the target, or -1 if the target is not found. - * @see R.indexOf - * @example - * - * R.lastIndexOf(3, [-1,3,3,0,1,2,3,4]); //=> 6 - * R.lastIndexOf(10, [1,2,3,4]); //=> -1 - */ -var lastIndexOf = _curry2(function lastIndexOf(target, xs) { - if (typeof xs.lastIndexOf === 'function' && !_isArray(xs)) { - return xs.lastIndexOf(target); - } else { - var idx = xs.length - 1; - while (idx >= 0) { - if (equals(xs[idx], target)) { - return idx; - } - idx -= 1; - } - return -1; - } -}); - -function _isNumber(x) { - return Object.prototype.toString.call(x) === '[object Number]'; -} - -/** - * Returns the number of elements in the array by returning `list.length`. - * - * @func - * @memberOf R - * @since v0.3.0 - * @category List - * @sig [a] -> Number - * @param {Array} list The array to inspect. - * @return {Number} The length of the array. - * @example - * - * R.length([]); //=> 0 - * R.length([1, 2, 3]); //=> 3 - */ -var length = _curry1(function length(list) { - return list != null && _isNumber(list.length) ? list.length : NaN; -}); - -/** - * Returns a lens for the given getter and setter functions. The getter "gets" - * the value of the focus; the setter "sets" the value of the focus. The setter - * should not mutate the data structure. - * - * @func - * @memberOf R - * @since v0.8.0 - * @category Object - * @typedefn Lens s a = Functor f => (a -> f a) -> s -> f s - * @sig (s -> a) -> ((a, s) -> s) -> Lens s a - * @param {Function} getter - * @param {Function} setter - * @return {Lens} - * @see R.view, R.set, R.over, R.lensIndex, R.lensProp - * @example - * - * const xLens = R.lens(R.prop('x'), R.assoc('x')); - * - * R.view(xLens, {x: 1, y: 2}); //=> 1 - * R.set(xLens, 4, {x: 1, y: 2}); //=> {x: 4, y: 2} - * R.over(xLens, R.negate, {x: 1, y: 2}); //=> {x: -1, y: 2} - */ -var lens = _curry2(function lens(getter, setter) { - return function(toFunctorFn) { - return function(target) { - return map( - function(focus) { - return setter(focus, target); - }, - toFunctorFn(getter(target)) - ); - }; - }; -}); - -/** - * Returns a lens whose focus is the specified index. - * - * @func - * @memberOf R - * @since v0.14.0 - * @category Object - * @typedefn Lens s a = Functor f => (a -> f a) -> s -> f s - * @sig Number -> Lens s a - * @param {Number} n - * @return {Lens} - * @see R.view, R.set, R.over - * @example - * - * const headLens = R.lensIndex(0); - * - * R.view(headLens, ['a', 'b', 'c']); //=> 'a' - * R.set(headLens, 'x', ['a', 'b', 'c']); //=> ['x', 'b', 'c'] - * R.over(headLens, R.toUpper, ['a', 'b', 'c']); //=> ['A', 'b', 'c'] - */ -var lensIndex = _curry1(function lensIndex(n) { - return lens(nth(n), update(n)); -}); - -/** - * Returns a lens whose focus is the specified path. - * - * @func - * @memberOf R - * @since v0.19.0 - * @category Object - * @typedefn Idx = String | Int - * @typedefn Lens s a = Functor f => (a -> f a) -> s -> f s - * @sig [Idx] -> Lens s a - * @param {Array} path The path to use. - * @return {Lens} - * @see R.view, R.set, R.over - * @example - * - * const xHeadYLens = R.lensPath(['x', 0, 'y']); - * - * R.view(xHeadYLens, {x: [{y: 2, z: 3}, {y: 4, z: 5}]}); - * //=> 2 - * R.set(xHeadYLens, 1, {x: [{y: 2, z: 3}, {y: 4, z: 5}]}); - * //=> {x: [{y: 1, z: 3}, {y: 4, z: 5}]} - * R.over(xHeadYLens, R.negate, {x: [{y: 2, z: 3}, {y: 4, z: 5}]}); - * //=> {x: [{y: -2, z: 3}, {y: 4, z: 5}]} - */ -var lensPath = _curry1(function lensPath(p) { - return lens(path(p), assocPath(p)); -}); - -/** - * Returns a lens whose focus is the specified property. - * - * @func - * @memberOf R - * @since v0.14.0 - * @category Object - * @typedefn Lens s a = Functor f => (a -> f a) -> s -> f s - * @sig String -> Lens s a - * @param {String} k - * @return {Lens} - * @see R.view, R.set, R.over - * @example - * - * const xLens = R.lensProp('x'); - * - * R.view(xLens, {x: 1, y: 2}); //=> 1 - * R.set(xLens, 4, {x: 1, y: 2}); //=> {x: 4, y: 2} - * R.over(xLens, R.negate, {x: 1, y: 2}); //=> {x: -1, y: 2} - */ -var lensProp = _curry1(function lensProp(k) { - return lens(prop(k), assoc(k)); -}); - -/** - * Returns `true` if the first argument is less than the second; `false` - * otherwise. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Relation - * @sig Ord a => a -> a -> Boolean - * @param {*} a - * @param {*} b - * @return {Boolean} - * @see R.gt - * @example - * - * R.lt(2, 1); //=> false - * R.lt(2, 2); //=> false - * R.lt(2, 3); //=> true - * R.lt('a', 'z'); //=> true - * R.lt('z', 'a'); //=> false - */ -var lt = _curry2(function lt(a, b) { return a < b; }); - -/** - * Returns `true` if the first argument is less than or equal to the second; - * `false` otherwise. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Relation - * @sig Ord a => a -> a -> Boolean - * @param {Number} a - * @param {Number} b - * @return {Boolean} - * @see R.gte - * @example - * - * R.lte(2, 1); //=> false - * R.lte(2, 2); //=> true - * R.lte(2, 3); //=> true - * R.lte('a', 'z'); //=> true - * R.lte('z', 'a'); //=> false - */ -var lte = _curry2(function lte(a, b) { return a <= b; }); - -/** - * The `mapAccum` function behaves like a combination of map and reduce; it - * applies a function to each element of a list, passing an accumulating - * parameter from left to right, and returning a final value of this - * accumulator together with the new list. - * - * The iterator function receives two arguments, *acc* and *value*, and should - * return a tuple *[acc, value]*. - * - * @func - * @memberOf R - * @since v0.10.0 - * @category List - * @sig ((acc, x) -> (acc, y)) -> acc -> [x] -> (acc, [y]) - * @param {Function} fn The function to be called on every element of the input `list`. - * @param {*} acc The accumulator value. - * @param {Array} list The list to iterate over. - * @return {*} The final, accumulated value. - * @see R.scan, R.addIndex, R.mapAccumRight - * @example - * - * const digits = ['1', '2', '3', '4']; - * const appender = (a, b) => [a + b, a + b]; - * - * R.mapAccum(appender, 0, digits); //=> ['01234', ['01', '012', '0123', '01234']] - * @symb R.mapAccum(f, a, [b, c, d]) = [ - * f(f(f(a, b)[0], c)[0], d)[0], - * [ - * f(a, b)[1], - * f(f(a, b)[0], c)[1], - * f(f(f(a, b)[0], c)[0], d)[1] - * ] - * ] - */ -var mapAccum = _curry3(function mapAccum(fn, acc, list) { - var idx = 0; - var len = list.length; - var result = []; - var tuple = [acc]; - while (idx < len) { - tuple = fn(tuple[0], list[idx]); - result[idx] = tuple[1]; - idx += 1; - } - return [tuple[0], result]; -}); - -/** - * The `mapAccumRight` function behaves like a combination of map and reduce; it - * applies a function to each element of a list, passing an accumulating - * parameter from right to left, and returning a final value of this - * accumulator together with the new list. - * - * Similar to [`mapAccum`](#mapAccum), except moves through the input list from - * the right to the left. - * - * The iterator function receives two arguments, *acc* and *value*, and should - * return a tuple *[acc, value]*. - * - * @func - * @memberOf R - * @since v0.10.0 - * @category List - * @sig ((acc, x) -> (acc, y)) -> acc -> [x] -> (acc, [y]) - * @param {Function} fn The function to be called on every element of the input `list`. - * @param {*} acc The accumulator value. - * @param {Array} list The list to iterate over. - * @return {*} The final, accumulated value. - * @see R.addIndex, R.mapAccum - * @example - * - * const digits = ['1', '2', '3', '4']; - * const appender = (a, b) => [b + a, b + a]; - * - * R.mapAccumRight(appender, 5, digits); //=> ['12345', ['12345', '2345', '345', '45']] - * @symb R.mapAccumRight(f, a, [b, c, d]) = [ - * f(f(f(a, d)[0], c)[0], b)[0], - * [ - * f(a, d)[1], - * f(f(a, d)[0], c)[1], - * f(f(f(a, d)[0], c)[0], b)[1] - * ] - * ] - */ -var mapAccumRight = _curry3(function mapAccumRight(fn, acc, list) { - var idx = list.length - 1; - var result = []; - var tuple = [acc]; - while (idx >= 0) { - tuple = fn(tuple[0], list[idx]); - result[idx] = tuple[1]; - idx -= 1; - } - return [tuple[0], result]; -}); - -/** - * An Object-specific version of [`map`](#map). The function is applied to three - * arguments: *(value, key, obj)*. If only the value is significant, use - * [`map`](#map) instead. - * - * @func - * @memberOf R - * @since v0.9.0 - * @category Object - * @sig ((*, String, Object) -> *) -> Object -> Object - * @param {Function} fn - * @param {Object} obj - * @return {Object} - * @see R.map - * @example - * - * const xyz = { x: 1, y: 2, z: 3 }; - * const prependKeyAndDouble = (num, key, obj) => key + (num * 2); - * - * R.mapObjIndexed(prependKeyAndDouble, xyz); //=> { x: 'x2', y: 'y4', z: 'z6' } - */ -var mapObjIndexed = _curry2(function mapObjIndexed(fn, obj) { - return _reduce(function(acc, key) { - acc[key] = fn(obj[key], key, obj); - return acc; - }, {}, keys(obj)); -}); - -/** - * Tests a regular expression against a String. Note that this function will - * return an empty array when there are no matches. This differs from - * [`String.prototype.match`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/match) - * which returns `null` when there are no matches. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category String - * @sig RegExp -> String -> [String | Undefined] - * @param {RegExp} rx A regular expression. - * @param {String} str The string to match against - * @return {Array} The list of matches or empty array. - * @see R.test - * @example - * - * R.match(/([a-z]a)/g, 'bananas'); //=> ['ba', 'na', 'na'] - * R.match(/a/, 'b'); //=> [] - * R.match(/a/, null); //=> TypeError: null does not have a method named "match" - */ -var match = _curry2(function match(rx, str) { - return str.match(rx) || []; -}); - -/** - * `mathMod` behaves like the modulo operator should mathematically, unlike the - * `%` operator (and by extension, [`R.modulo`](#modulo)). So while - * `-17 % 5` is `-2`, `mathMod(-17, 5)` is `3`. `mathMod` requires Integer - * arguments, and returns NaN when the modulus is zero or negative. - * - * @func - * @memberOf R - * @since v0.3.0 - * @category Math - * @sig Number -> Number -> Number - * @param {Number} m The dividend. - * @param {Number} p the modulus. - * @return {Number} The result of `b mod a`. - * @see R.modulo - * @example - * - * R.mathMod(-17, 5); //=> 3 - * R.mathMod(17, 5); //=> 2 - * R.mathMod(17, -5); //=> NaN - * R.mathMod(17, 0); //=> NaN - * R.mathMod(17.2, 5); //=> NaN - * R.mathMod(17, 5.3); //=> NaN - * - * const clock = R.mathMod(R.__, 12); - * clock(15); //=> 3 - * clock(24); //=> 0 - * - * const seventeenMod = R.mathMod(17); - * seventeenMod(3); //=> 2 - * seventeenMod(4); //=> 1 - * seventeenMod(10); //=> 7 - */ -var mathMod = _curry2(function mathMod(m, p) { - if (!_isInteger(m)) { return NaN; } - if (!_isInteger(p) || p < 1) { return NaN; } - return ((m % p) + p) % p; -}); - -/** - * Takes a function and two values, and returns whichever value produces the - * larger result when passed to the provided function. - * - * @func - * @memberOf R - * @since v0.8.0 - * @category Relation - * @sig Ord b => (a -> b) -> a -> a -> a - * @param {Function} f - * @param {*} a - * @param {*} b - * @return {*} - * @see R.max, R.minBy - * @example - * - * // square :: Number -> Number - * const square = n => n * n; - * - * R.maxBy(square, -3, 2); //=> -3 - * - * R.reduce(R.maxBy(square), 0, [3, -5, 4, 1, -2]); //=> -5 - * R.reduce(R.maxBy(square), 0, []); //=> 0 - */ -var maxBy = _curry3(function maxBy(f, a, b) { - return f(b) > f(a) ? b : a; -}); - -/** - * Adds together all the elements of a list. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Math - * @sig [Number] -> Number - * @param {Array} list An array of numbers - * @return {Number} The sum of all the numbers in the list. - * @see R.reduce - * @example - * - * R.sum([2,4,6,8,100,1]); //=> 121 - */ -var sum = reduce(add, 0); - -/** - * Returns the mean of the given list of numbers. - * - * @func - * @memberOf R - * @since v0.14.0 - * @category Math - * @sig [Number] -> Number - * @param {Array} list - * @return {Number} - * @see R.median - * @example - * - * R.mean([2, 7, 9]); //=> 6 - * R.mean([]); //=> NaN - */ -var mean = _curry1(function mean(list) { - return sum(list) / list.length; -}); - -/** - * Returns the median of the given list of numbers. - * - * @func - * @memberOf R - * @since v0.14.0 - * @category Math - * @sig [Number] -> Number - * @param {Array} list - * @return {Number} - * @see R.mean - * @example - * - * R.median([2, 9, 7]); //=> 7 - * R.median([7, 2, 10, 9]); //=> 8 - * R.median([]); //=> NaN - */ -var median = _curry1(function median(list) { - var len = list.length; - if (len === 0) { - return NaN; - } - var width = 2 - len % 2; - var idx = (len - width) / 2; - return mean(Array.prototype.slice.call(list, 0).sort(function(a, b) { - return a < b ? -1 : a > b ? 1 : 0; - }).slice(idx, idx + width)); -}); - -/** - * A customisable version of [`R.memoize`](#memoize). `memoizeWith` takes an - * additional function that will be applied to a given argument set and used to - * create the cache key under which the results of the function to be memoized - * will be stored. Care must be taken when implementing key generation to avoid - * clashes that may overwrite previous entries erroneously. - * - * - * @func - * @memberOf R - * @since v0.24.0 - * @category Function - * @sig (*... -> String) -> (*... -> a) -> (*... -> a) - * @param {Function} fn The function to generate the cache key. - * @param {Function} fn The function to memoize. - * @return {Function} Memoized version of `fn`. - * @example - * - * let count = 0; - * const factorial = R.memoizeWith(R.identity, n => { - * count += 1; - * return R.product(R.range(1, n + 1)); - * }); - * factorial(5); //=> 120 - * factorial(5); //=> 120 - * factorial(5); //=> 120 - * count; //=> 1 - */ -var memoizeWith = _curry2(function memoizeWith(mFn, fn) { - var cache = {}; - return _arity(fn.length, function() { - var key = mFn.apply(this, arguments); - if (!_has(key, cache)) { - cache[key] = fn.apply(this, arguments); - } - return cache[key]; - }); -}); - -/** - * Create a new object with the own properties of the first object merged with - * the own properties of the second object. If a key exists in both objects, - * the value from the second object will be used. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Object - * @sig {k: v} -> {k: v} -> {k: v} - * @param {Object} l - * @param {Object} r - * @return {Object} - * @see R.mergeRight, R.mergeDeepRight, R.mergeWith, R.mergeWithKey - * @deprecated - * @example - * - * R.merge({ 'name': 'fred', 'age': 10 }, { 'age': 40 }); - * //=> { 'name': 'fred', 'age': 40 } - * - * const withDefaults = R.merge({x: 0, y: 0}); - * withDefaults({y: 2}); //=> {x: 0, y: 2} - * @symb R.merge(a, b) = {...a, ...b} - */ -var merge = _curry2(function merge(l, r) { - return _objectAssign$1({}, l, r); -}); - -/** - * Merges a list of objects together into one object. - * - * @func - * @memberOf R - * @since v0.10.0 - * @category List - * @sig [{k: v}] -> {k: v} - * @param {Array} list An array of objects - * @return {Object} A merged object. - * @see R.reduce - * @example - * - * R.mergeAll([{foo:1},{bar:2},{baz:3}]); //=> {foo:1,bar:2,baz:3} - * R.mergeAll([{foo:1},{foo:2},{bar:2}]); //=> {foo:2,bar:2} - * @symb R.mergeAll([{ x: 1 }, { y: 2 }, { z: 3 }]) = { x: 1, y: 2, z: 3 } - */ -var mergeAll = _curry1(function mergeAll(list) { - return _objectAssign$1.apply(null, [{}].concat(list)); -}); - -/** - * Creates a new object with the own properties of the two provided objects. If - * a key exists in both objects, the provided function is applied to the key - * and the values associated with the key in each object, with the result being - * used as the value associated with the key in the returned object. - * - * @func - * @memberOf R - * @since v0.19.0 - * @category Object - * @sig ((String, a, a) -> a) -> {a} -> {a} -> {a} - * @param {Function} fn - * @param {Object} l - * @param {Object} r - * @return {Object} - * @see R.mergeDeepWithKey, R.merge, R.mergeWith - * @example - * - * let concatValues = (k, l, r) => k == 'values' ? R.concat(l, r) : r - * R.mergeWithKey(concatValues, - * { a: true, thing: 'foo', values: [10, 20] }, - * { b: true, thing: 'bar', values: [15, 35] }); - * //=> { a: true, b: true, thing: 'bar', values: [10, 20, 15, 35] } - * @symb R.mergeWithKey(f, { x: 1, y: 2 }, { y: 5, z: 3 }) = { x: 1, y: f('y', 2, 5), z: 3 } - */ -var mergeWithKey = _curry3(function mergeWithKey(fn, l, r) { - var result = {}; - var k; - - for (k in l) { - if (_has(k, l)) { - result[k] = _has(k, r) ? fn(k, l[k], r[k]) : l[k]; - } - } - - for (k in r) { - if (_has(k, r) && !(_has(k, result))) { - result[k] = r[k]; - } - } - - return result; -}); - -/** - * Creates a new object with the own properties of the two provided objects. - * If a key exists in both objects: - * - and both associated values are also objects then the values will be - * recursively merged. - * - otherwise the provided function is applied to the key and associated values - * using the resulting value as the new value associated with the key. - * If a key only exists in one object, the value will be associated with the key - * of the resulting object. - * - * @func - * @memberOf R - * @since v0.24.0 - * @category Object - * @sig ((String, a, a) -> a) -> {a} -> {a} -> {a} - * @param {Function} fn - * @param {Object} lObj - * @param {Object} rObj - * @return {Object} - * @see R.mergeWithKey, R.mergeDeepWith - * @example - * - * let concatValues = (k, l, r) => k == 'values' ? R.concat(l, r) : r - * R.mergeDeepWithKey(concatValues, - * { a: true, c: { thing: 'foo', values: [10, 20] }}, - * { b: true, c: { thing: 'bar', values: [15, 35] }}); - * //=> { a: true, b: true, c: { thing: 'bar', values: [10, 20, 15, 35] }} - */ -var mergeDeepWithKey = _curry3(function mergeDeepWithKey(fn, lObj, rObj) { - return mergeWithKey(function(k, lVal, rVal) { - if (_isObject(lVal) && _isObject(rVal)) { - return mergeDeepWithKey(fn, lVal, rVal); - } else { - return fn(k, lVal, rVal); - } - }, lObj, rObj); -}); - -/** - * Creates a new object with the own properties of the first object merged with - * the own properties of the second object. If a key exists in both objects: - * - and both values are objects, the two values will be recursively merged - * - otherwise the value from the first object will be used. - * - * @func - * @memberOf R - * @since v0.24.0 - * @category Object - * @sig {a} -> {a} -> {a} - * @param {Object} lObj - * @param {Object} rObj - * @return {Object} - * @see R.merge, R.mergeDeepRight, R.mergeDeepWith, R.mergeDeepWithKey - * @example - * - * R.mergeDeepLeft({ name: 'fred', age: 10, contact: { email: 'moo@example.com' }}, - * { age: 40, contact: { email: 'baa@example.com' }}); - * //=> { name: 'fred', age: 10, contact: { email: 'moo@example.com' }} - */ -var mergeDeepLeft = _curry2(function mergeDeepLeft(lObj, rObj) { - return mergeDeepWithKey(function(k, lVal, rVal) { - return lVal; - }, lObj, rObj); -}); - -/** - * Creates a new object with the own properties of the first object merged with - * the own properties of the second object. If a key exists in both objects: - * - and both values are objects, the two values will be recursively merged - * - otherwise the value from the second object will be used. - * - * @func - * @memberOf R - * @since v0.24.0 - * @category Object - * @sig {a} -> {a} -> {a} - * @param {Object} lObj - * @param {Object} rObj - * @return {Object} - * @see R.merge, R.mergeDeepLeft, R.mergeDeepWith, R.mergeDeepWithKey - * @example - * - * R.mergeDeepRight({ name: 'fred', age: 10, contact: { email: 'moo@example.com' }}, - * { age: 40, contact: { email: 'baa@example.com' }}); - * //=> { name: 'fred', age: 40, contact: { email: 'baa@example.com' }} - */ -var mergeDeepRight = _curry2(function mergeDeepRight(lObj, rObj) { - return mergeDeepWithKey(function(k, lVal, rVal) { - return rVal; - }, lObj, rObj); -}); - -/** - * Creates a new object with the own properties of the two provided objects. - * If a key exists in both objects: - * - and both associated values are also objects then the values will be - * recursively merged. - * - otherwise the provided function is applied to associated values using the - * resulting value as the new value associated with the key. - * If a key only exists in one object, the value will be associated with the key - * of the resulting object. - * - * @func - * @memberOf R - * @since v0.24.0 - * @category Object - * @sig ((a, a) -> a) -> {a} -> {a} -> {a} - * @param {Function} fn - * @param {Object} lObj - * @param {Object} rObj - * @return {Object} - * @see R.mergeWith, R.mergeDeepWithKey - * @example - * - * R.mergeDeepWith(R.concat, - * { a: true, c: { values: [10, 20] }}, - * { b: true, c: { values: [15, 35] }}); - * //=> { a: true, b: true, c: { values: [10, 20, 15, 35] }} - */ -var mergeDeepWith = _curry3(function mergeDeepWith(fn, lObj, rObj) { - return mergeDeepWithKey(function(k, lVal, rVal) { - return fn(lVal, rVal); - }, lObj, rObj); -}); - -/** - * Create a new object with the own properties of the first object merged with - * the own properties of the second object. If a key exists in both objects, - * the value from the first object will be used. - * - * @func - * @memberOf R - * @category Object - * @sig {k: v} -> {k: v} -> {k: v} - * @param {Object} l - * @param {Object} r - * @return {Object} - * @see R.mergeRight, R.mergeDeepLeft, R.mergeWith, R.mergeWithKey - * @example - * - * R.mergeLeft({ 'age': 40 }, { 'name': 'fred', 'age': 10 }); - * //=> { 'name': 'fred', 'age': 40 } - * - * const resetToDefault = R.mergeLeft({x: 0}); - * resetToDefault({x: 5, y: 2}); //=> {x: 0, y: 2} - * @symb R.mergeLeft(a, b) = {...b, ...a} - */ -var mergeLeft = _curry2(function mergeLeft(l, r) { - return _objectAssign$1({}, r, l); -}); - -/** - * Create a new object with the own properties of the first object merged with - * the own properties of the second object. If a key exists in both objects, - * the value from the second object will be used. - * - * @func - * @memberOf R - * @category Object - * @sig {k: v} -> {k: v} -> {k: v} - * @param {Object} l - * @param {Object} r - * @return {Object} - * @see R.mergeLeft, R.mergeDeepRight, R.mergeWith, R.mergeWithKey - * @example - * - * R.mergeRight({ 'name': 'fred', 'age': 10 }, { 'age': 40 }); - * //=> { 'name': 'fred', 'age': 40 } - * - * const withDefaults = R.mergeRight({x: 0, y: 0}); - * withDefaults({y: 2}); //=> {x: 0, y: 2} - * @symb R.mergeRight(a, b) = {...a, ...b} - */ -var mergeRight = _curry2(function mergeRight(l, r) { - return _objectAssign$1({}, l, r); -}); - -/** - * Creates a new object with the own properties of the two provided objects. If - * a key exists in both objects, the provided function is applied to the values - * associated with the key in each object, with the result being used as the - * value associated with the key in the returned object. - * - * @func - * @memberOf R - * @since v0.19.0 - * @category Object - * @sig ((a, a) -> a) -> {a} -> {a} -> {a} - * @param {Function} fn - * @param {Object} l - * @param {Object} r - * @return {Object} - * @see R.mergeDeepWith, R.merge, R.mergeWithKey - * @example - * - * R.mergeWith(R.concat, - * { a: true, values: [10, 20] }, - * { b: true, values: [15, 35] }); - * //=> { a: true, b: true, values: [10, 20, 15, 35] } - */ -var mergeWith = _curry3(function mergeWith(fn, l, r) { - return mergeWithKey(function(_, _l, _r) { - return fn(_l, _r); - }, l, r); -}); - -/** - * Returns the smaller of its two arguments. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Relation - * @sig Ord a => a -> a -> a - * @param {*} a - * @param {*} b - * @return {*} - * @see R.minBy, R.max - * @example - * - * R.min(789, 123); //=> 123 - * R.min('a', 'b'); //=> 'a' - */ -var min = _curry2(function min(a, b) { return b < a ? b : a; }); - -/** - * Takes a function and two values, and returns whichever value produces the - * smaller result when passed to the provided function. - * - * @func - * @memberOf R - * @since v0.8.0 - * @category Relation - * @sig Ord b => (a -> b) -> a -> a -> a - * @param {Function} f - * @param {*} a - * @param {*} b - * @return {*} - * @see R.min, R.maxBy - * @example - * - * // square :: Number -> Number - * const square = n => n * n; - * - * R.minBy(square, -3, 2); //=> 2 - * - * R.reduce(R.minBy(square), Infinity, [3, -5, 4, 1, -2]); //=> 1 - * R.reduce(R.minBy(square), Infinity, []); //=> Infinity - */ -var minBy = _curry3(function minBy(f, a, b) { - return f(b) < f(a) ? b : a; -}); - -/** - * Divides the first parameter by the second and returns the remainder. Note - * that this function preserves the JavaScript-style behavior for modulo. For - * mathematical modulo see [`mathMod`](#mathMod). - * - * @func - * @memberOf R - * @since v0.1.1 - * @category Math - * @sig Number -> Number -> Number - * @param {Number} a The value to the divide. - * @param {Number} b The pseudo-modulus - * @return {Number} The result of `b % a`. - * @see R.mathMod - * @example - * - * R.modulo(17, 3); //=> 2 - * // JS behavior: - * R.modulo(-17, 3); //=> -2 - * R.modulo(17, -3); //=> 2 - * - * const isOdd = R.modulo(R.__, 2); - * isOdd(42); //=> 0 - * isOdd(21); //=> 1 - */ -var modulo = _curry2(function modulo(a, b) { return a % b; }); - -/** - * Multiplies two numbers. Equivalent to `a * b` but curried. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Math - * @sig Number -> Number -> Number - * @param {Number} a The first value. - * @param {Number} b The second value. - * @return {Number} The result of `a * b`. - * @see R.divide - * @example - * - * const double = R.multiply(2); - * const triple = R.multiply(3); - * double(3); //=> 6 - * triple(4); //=> 12 - * R.multiply(2, 5); //=> 10 - */ -var multiply = _curry2(function multiply(a, b) { return a * b; }); - -/** - * Negates its argument. - * - * @func - * @memberOf R - * @since v0.9.0 - * @category Math - * @sig Number -> Number - * @param {Number} n - * @return {Number} - * @example - * - * R.negate(42); //=> -42 - */ -var negate = _curry1(function negate(n) { return -n; }); - -/** - * Returns `true` if no elements of the list match the predicate, `false` - * otherwise. - * - * Dispatches to the `all` method of the second argument, if present. - * - * Acts as a transducer if a transformer is given in list position. - * - * @func - * @memberOf R - * @since v0.12.0 - * @category List - * @sig (a -> Boolean) -> [a] -> Boolean - * @param {Function} fn The predicate function. - * @param {Array} list The array to consider. - * @return {Boolean} `true` if the predicate is not satisfied by every element, `false` otherwise. - * @see R.all, R.any - * @example - * - * const isEven = n => n % 2 === 0; - * const isOdd = n => n % 2 === 1; - * - * R.none(isEven, [1, 3, 5, 7, 9, 11]); //=> true - * R.none(isOdd, [1, 3, 5, 7, 8, 11]); //=> false - */ -const none = _curry2(function none(fn, input) { - return all(_complement(fn), input); -}); - -/** - * Returns a function which returns its nth argument. - * - * @func - * @memberOf R - * @since v0.9.0 - * @category Function - * @sig Number -> *... -> * - * @param {Number} n - * @return {Function} - * @example - * - * R.nthArg(1)('a', 'b', 'c'); //=> 'b' - * R.nthArg(-1)('a', 'b', 'c'); //=> 'c' - * @symb R.nthArg(-1)(a, b, c) = c - * @symb R.nthArg(0)(a, b, c) = a - * @symb R.nthArg(1)(a, b, c) = b - */ -var nthArg = _curry1(function nthArg(n) { - var arity = n < 0 ? 1 : n + 1; - return curryN(arity, function() { - return nth(n, arguments); - }); -}); - -/** - * `o` is a curried composition function that returns a unary function. - * Like [`compose`](#compose), `o` performs right-to-left function composition. - * Unlike [`compose`](#compose), the rightmost function passed to `o` will be - * invoked with only one argument. Also, unlike [`compose`](#compose), `o` is - * limited to accepting only 2 unary functions. The name o was chosen because - * of its similarity to the mathematical composition operator ∘. - * - * @func - * @memberOf R - * @since v0.24.0 - * @category Function - * @sig (b -> c) -> (a -> b) -> a -> c - * @param {Function} f - * @param {Function} g - * @return {Function} - * @see R.compose, R.pipe - * @example - * - * const classyGreeting = name => "The name's " + name.last + ", " + name.first + " " + name.last - * const yellGreeting = R.o(R.toUpper, classyGreeting); - * yellGreeting({first: 'James', last: 'Bond'}); //=> "THE NAME'S BOND, JAMES BOND" - * - * R.o(R.multiply(10), R.add(10))(-4) //=> 60 - * - * @symb R.o(f, g, x) = f(g(x)) - */ -var o = _curry3(function o(f, g, x) { - return f(g(x)); -}); - -function _of(x) { return [x]; } - -/** - * Returns a singleton array containing the value provided. - * - * Note this `of` is different from the ES6 `of`; See - * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/of - * - * @func - * @memberOf R - * @since v0.3.0 - * @category Function - * @sig a -> [a] - * @param {*} x any value - * @return {Array} An array wrapping `x`. - * @example - * - * R.of(null); //=> [null] - * R.of([42]); //=> [[42]] - */ -var of = _curry1(_of); - -/** - * Returns a partial copy of an object omitting the keys specified. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Object - * @sig [String] -> {String: *} -> {String: *} - * @param {Array} names an array of String property names to omit from the new object - * @param {Object} obj The object to copy from - * @return {Object} A new object with properties from `names` not on it. - * @see R.pick - * @example - * - * R.omit(['a', 'd'], {a: 1, b: 2, c: 3, d: 4}); //=> {b: 2, c: 3} - */ -var omit = _curry2(function omit(names, obj) { - var result = {}; - var index = {}; - var idx = 0; - var len = names.length; - - while (idx < len) { - index[names[idx]] = 1; - idx += 1; - } - - for (var prop in obj) { - if (!index.hasOwnProperty(prop)) { - result[prop] = obj[prop]; - } - } - return result; -}); - -/** - * Accepts a function `fn` and returns a function that guards invocation of - * `fn` such that `fn` can only ever be called once, no matter how many times - * the returned function is invoked. The first value calculated is returned in - * subsequent invocations. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Function - * @sig (a... -> b) -> (a... -> b) - * @param {Function} fn The function to wrap in a call-only-once wrapper. - * @return {Function} The wrapped function. - * @example - * - * const addOneOnce = R.once(x => x + 1); - * addOneOnce(10); //=> 11 - * addOneOnce(addOneOnce(50)); //=> 11 - */ -var once = _curry1(function once(fn) { - var called = false; - var result; - return _arity(fn.length, function() { - if (called) { - return result; - } - called = true; - result = fn.apply(this, arguments); - return result; - }); -}); - -function _assertPromise(name, p) { - if (p == null || !_isFunction(p.then)) { - throw new TypeError('`' + name + '` expected a Promise, received ' + _toString(p, [])); - } -} - -/** - * Returns the result of applying the onFailure function to the value inside - * a failed promise. This is useful for handling rejected promises - * inside function compositions. - * - * @func - * @memberOf R - * @category Function - * @sig (e -> b) -> (Promise e a) -> (Promise e b) - * @sig (e -> (Promise f b)) -> (Promise e a) -> (Promise f b) - * @param {Function} onFailure The function to apply. Can return a value or a promise of a value. - * @param {Promise} p - * @return {Promise} The result of calling `p.then(null, onFailure)` - * @see R.then - * @example - * - * var failedFetch = (id) => Promise.reject('bad ID'); - * var useDefault = () => ({ firstName: 'Bob', lastName: 'Loblaw' }) - * - * //recoverFromFailure :: String -> Promise ({firstName, lastName}) - * var recoverFromFailure = R.pipe( - * failedFetch(12345), - * R.otherwise(useDefault), - * R.then(R.pick(['firstName', 'lastName'])) - * ); - */ -const otherwise = _curry2(function otherwise(f, p) { - _assertPromise('otherwise', p); - - return p.then(null, f); -}); - -// `Identity` is a functor that holds a single value, where `map` simply -// transforms the held value with the provided function. -var Identity = function(x) { - return {value: x, map: function(f) { return Identity(f(x)); }}; -}; - - -/** - * Returns the result of "setting" the portion of the given data structure - * focused by the given lens to the result of applying the given function to - * the focused value. - * - * @func - * @memberOf R - * @since v0.16.0 - * @category Object - * @typedefn Lens s a = Functor f => (a -> f a) -> s -> f s - * @sig Lens s a -> (a -> a) -> s -> s - * @param {Lens} lens - * @param {*} v - * @param {*} x - * @return {*} - * @see R.prop, R.lensIndex, R.lensProp - * @example - * - * const headLens = R.lensIndex(0); - * - * R.over(headLens, R.toUpper, ['foo', 'bar', 'baz']); //=> ['FOO', 'bar', 'baz'] - */ -var over = _curry3(function over(lens, f, x) { - // The value returned by the getter function is first transformed with `f`, - // then set as the value of an `Identity`. This is then mapped over with the - // setter function of the lens. - return lens(function(y) { return Identity(f(y)); })(x).value; -}); - -/** - * Takes two arguments, `fst` and `snd`, and returns `[fst, snd]`. - * - * @func - * @memberOf R - * @since v0.18.0 - * @category List - * @sig a -> b -> (a,b) - * @param {*} fst - * @param {*} snd - * @return {Array} - * @see R.objOf, R.of - * @example - * - * R.pair('foo', 'bar'); //=> ['foo', 'bar'] - */ -var pair = _curry2(function pair(fst, snd) { return [fst, snd]; }); - -function _createPartialApplicator(concat) { - return _curry2(function(fn, args) { - return _arity(Math.max(0, fn.length - args.length), function() { - return fn.apply(this, concat(args, arguments)); - }); - }); -} - -/** - * Takes a function `f` and a list of arguments, and returns a function `g`. - * When applied, `g` returns the result of applying `f` to the arguments - * provided initially followed by the arguments provided to `g`. - * - * @func - * @memberOf R - * @since v0.10.0 - * @category Function - * @sig ((a, b, c, ..., n) -> x) -> [a, b, c, ...] -> ((d, e, f, ..., n) -> x) - * @param {Function} f - * @param {Array} args - * @return {Function} - * @see R.partialRight, R.curry - * @example - * - * const multiply2 = (a, b) => a * b; - * const double = R.partial(multiply2, [2]); - * double(2); //=> 4 - * - * const greet = (salutation, title, firstName, lastName) => - * salutation + ', ' + title + ' ' + firstName + ' ' + lastName + '!'; - * - * const sayHello = R.partial(greet, ['Hello']); - * const sayHelloToMs = R.partial(sayHello, ['Ms.']); - * sayHelloToMs('Jane', 'Jones'); //=> 'Hello, Ms. Jane Jones!' - * @symb R.partial(f, [a, b])(c, d) = f(a, b, c, d) - */ -var partial = _createPartialApplicator(_concat); - -/** - * Takes a function `f` and a list of arguments, and returns a function `g`. - * When applied, `g` returns the result of applying `f` to the arguments - * provided to `g` followed by the arguments provided initially. - * - * @func - * @memberOf R - * @since v0.10.0 - * @category Function - * @sig ((a, b, c, ..., n) -> x) -> [d, e, f, ..., n] -> ((a, b, c, ...) -> x) - * @param {Function} f - * @param {Array} args - * @return {Function} - * @see R.partial - * @example - * - * const greet = (salutation, title, firstName, lastName) => - * salutation + ', ' + title + ' ' + firstName + ' ' + lastName + '!'; - * - * const greetMsJaneJones = R.partialRight(greet, ['Ms.', 'Jane', 'Jones']); - * - * greetMsJaneJones('Hello'); //=> 'Hello, Ms. Jane Jones!' - * @symb R.partialRight(f, [a, b])(c, d) = f(c, d, a, b) - */ -var partialRight = _createPartialApplicator(flip(_concat)); - -/** - * Takes a predicate and a list or other `Filterable` object and returns the - * pair of filterable objects of the same type of elements which do and do not - * satisfy, the predicate, respectively. Filterable objects include plain objects or any object - * that has a filter method such as `Array`. - * - * @func - * @memberOf R - * @since v0.1.4 - * @category List - * @sig Filterable f => (a -> Boolean) -> f a -> [f a, f a] - * @param {Function} pred A predicate to determine which side the element belongs to. - * @param {Array} filterable the list (or other filterable) to partition. - * @return {Array} An array, containing first the subset of elements that satisfy the - * predicate, and second the subset of elements that do not satisfy. - * @see R.filter, R.reject - * @example - * - * R.partition(R.includes('s'), ['sss', 'ttt', 'foo', 'bars']); - * // => [ [ 'sss', 'bars' ], [ 'ttt', 'foo' ] ] - * - * R.partition(R.includes('s'), { a: 'sss', b: 'ttt', foo: 'bars' }); - * // => [ { a: 'sss', foo: 'bars' }, { b: 'ttt' } ] - */ -var partition = juxt([filter, reject]); - -/** - * Determines whether a nested path on an object has a specific value, in - * [`R.equals`](#equals) terms. Most likely used to filter a list. - * - * @func - * @memberOf R - * @since v0.7.0 - * @category Relation - * @typedefn Idx = String | Int - * @sig [Idx] -> a -> {a} -> Boolean - * @param {Array} path The path of the nested property to use - * @param {*} val The value to compare the nested property with - * @param {Object} obj The object to check the nested property in - * @return {Boolean} `true` if the value equals the nested object property, - * `false` otherwise. - * @example - * - * const user1 = { address: { zipCode: 90210 } }; - * const user2 = { address: { zipCode: 55555 } }; - * const user3 = { name: 'Bob' }; - * const users = [ user1, user2, user3 ]; - * const isFamous = R.pathEq(['address', 'zipCode'], 90210); - * R.filter(isFamous, users); //=> [ user1 ] - */ -var pathEq = _curry3(function pathEq(_path, val, obj) { - return equals(path(_path, obj), val); -}); - -/** - * If the given, non-null object has a value at the given path, returns the - * value at that path. Otherwise returns the provided default value. - * - * @func - * @memberOf R - * @since v0.18.0 - * @category Object - * @typedefn Idx = String | Int - * @sig a -> [Idx] -> {a} -> a - * @param {*} d The default value. - * @param {Array} p The path to use. - * @param {Object} obj The object to retrieve the nested property from. - * @return {*} The data at `path` of the supplied object or the default value. - * @example - * - * R.pathOr('N/A', ['a', 'b'], {a: {b: 2}}); //=> 2 - * R.pathOr('N/A', ['a', 'b'], {c: {b: 2}}); //=> "N/A" - */ -var pathOr = _curry3(function pathOr(d, p, obj) { - return defaultTo(d, path(p, obj)); -}); - -/** - * Returns `true` if the specified object property at given path satisfies the - * given predicate; `false` otherwise. - * - * @func - * @memberOf R - * @since v0.19.0 - * @category Logic - * @typedefn Idx = String | Int - * @sig (a -> Boolean) -> [Idx] -> {a} -> Boolean - * @param {Function} pred - * @param {Array} propPath - * @param {*} obj - * @return {Boolean} - * @see R.propSatisfies, R.path - * @example - * - * R.pathSatisfies(y => y > 0, ['x', 'y'], {x: {y: 2}}); //=> true - */ -var pathSatisfies = _curry3(function pathSatisfies(pred, propPath, obj) { - return propPath.length > 0 && pred(path(propPath, obj)); -}); - -/** - * Returns a partial copy of an object containing only the keys specified. If - * the key does not exist, the property is ignored. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Object - * @sig [k] -> {k: v} -> {k: v} - * @param {Array} names an array of String property names to copy onto a new object - * @param {Object} obj The object to copy from - * @return {Object} A new object with only properties from `names` on it. - * @see R.omit, R.props - * @example - * - * R.pick(['a', 'd'], {a: 1, b: 2, c: 3, d: 4}); //=> {a: 1, d: 4} - * R.pick(['a', 'e', 'f'], {a: 1, b: 2, c: 3, d: 4}); //=> {a: 1} - */ -var pick = _curry2(function pick(names, obj) { - var result = {}; - var idx = 0; - while (idx < names.length) { - if (names[idx] in obj) { - result[names[idx]] = obj[names[idx]]; - } - idx += 1; - } - return result; -}); - -/** - * Similar to `pick` except that this one includes a `key: undefined` pair for - * properties that don't exist. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Object - * @sig [k] -> {k: v} -> {k: v} - * @param {Array} names an array of String property names to copy onto a new object - * @param {Object} obj The object to copy from - * @return {Object} A new object with only properties from `names` on it. - * @see R.pick - * @example - * - * R.pickAll(['a', 'd'], {a: 1, b: 2, c: 3, d: 4}); //=> {a: 1, d: 4} - * R.pickAll(['a', 'e', 'f'], {a: 1, b: 2, c: 3, d: 4}); //=> {a: 1, e: undefined, f: undefined} - */ -var pickAll = _curry2(function pickAll(names, obj) { - var result = {}; - var idx = 0; - var len = names.length; - while (idx < len) { - var name = names[idx]; - result[name] = obj[name]; - idx += 1; - } - return result; -}); - -/** - * Returns a partial copy of an object containing only the keys that satisfy - * the supplied predicate. - * - * @func - * @memberOf R - * @since v0.8.0 - * @category Object - * @sig ((v, k) -> Boolean) -> {k: v} -> {k: v} - * @param {Function} pred A predicate to determine whether or not a key - * should be included on the output object. - * @param {Object} obj The object to copy from - * @return {Object} A new object with only properties that satisfy `pred` - * on it. - * @see R.pick, R.filter - * @example - * - * const isUpperCase = (val, key) => key.toUpperCase() === key; - * R.pickBy(isUpperCase, {a: 1, b: 2, A: 3, B: 4}); //=> {A: 3, B: 4} - */ -var pickBy = _curry2(function pickBy(test, obj) { - var result = {}; - for (var prop in obj) { - if (test(obj[prop], prop, obj)) { - result[prop] = obj[prop]; - } - } - return result; -}); - -/** - * Returns the left-to-right Kleisli composition of the provided functions, - * each of which must return a value of a type supported by [`chain`](#chain). - * - * `R.pipeK(f, g, h)` is equivalent to `R.pipe(f, R.chain(g), R.chain(h))`. - * - * @func - * @memberOf R - * @since v0.16.0 - * @category Function - * @sig Chain m => ((a -> m b), (b -> m c), ..., (y -> m z)) -> (a -> m z) - * @param {...Function} - * @return {Function} - * @see R.composeK - * @example - * - * // parseJson :: String -> Maybe * - * // get :: String -> Object -> Maybe * - * - * // getStateCode :: Maybe String -> Maybe String - * const getStateCode = R.pipeK( - * parseJson, - * get('user'), - * get('address'), - * get('state'), - * R.compose(Maybe.of, R.toUpper) - * ); - * - * getStateCode('{"user":{"address":{"state":"ny"}}}'); - * //=> Just('NY') - * getStateCode('[Invalid JSON]'); - * //=> Nothing() - * @symb R.pipeK(f, g, h)(a) = R.chain(h, R.chain(g, f(a))) - */ -function pipeK() { - if (arguments.length === 0) { - throw new Error('pipeK requires at least one argument'); - } - return composeK.apply(this, reverse(arguments)); -} - -/** - * Returns a new list with the given element at the front, followed by the - * contents of the list. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category List - * @sig a -> [a] -> [a] - * @param {*} el The item to add to the head of the output list. - * @param {Array} list The array to add to the tail of the output list. - * @return {Array} A new array. - * @see R.append - * @example - * - * R.prepend('fee', ['fi', 'fo', 'fum']); //=> ['fee', 'fi', 'fo', 'fum'] - */ -var prepend = _curry2(function prepend(el, list) { - return _concat([el], list); -}); - -/** - * Multiplies together all the elements of a list. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Math - * @sig [Number] -> Number - * @param {Array} list An array of numbers - * @return {Number} The product of all the numbers in the list. - * @see R.reduce - * @example - * - * R.product([2,4,6,8,100,1]); //=> 38400 - */ -var product = reduce(multiply, 1); - -/** - * Accepts a function `fn` and a list of transformer functions and returns a - * new curried function. When the new function is invoked, it calls the - * function `fn` with parameters consisting of the result of calling each - * supplied handler on successive arguments to the new function. - * - * If more arguments are passed to the returned function than transformer - * functions, those arguments are passed directly to `fn` as additional - * parameters. If you expect additional arguments that don't need to be - * transformed, although you can ignore them, it's best to pass an identity - * function so that the new function reports the correct arity. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Function - * @sig ((x1, x2, ...) -> z) -> [(a -> x1), (b -> x2), ...] -> (a -> b -> ... -> z) - * @param {Function} fn The function to wrap. - * @param {Array} transformers A list of transformer functions - * @return {Function} The wrapped function. - * @see R.converge - * @example - * - * R.useWith(Math.pow, [R.identity, R.identity])(3, 4); //=> 81 - * R.useWith(Math.pow, [R.identity, R.identity])(3)(4); //=> 81 - * R.useWith(Math.pow, [R.dec, R.inc])(3, 4); //=> 32 - * R.useWith(Math.pow, [R.dec, R.inc])(3)(4); //=> 32 - * @symb R.useWith(f, [g, h])(a, b) = f(g(a), h(b)) - */ -var useWith = _curry2(function useWith(fn, transformers) { - return curryN(transformers.length, function() { - var args = []; - var idx = 0; - while (idx < transformers.length) { - args.push(transformers[idx].call(this, arguments[idx])); - idx += 1; - } - return fn.apply(this, args.concat(Array.prototype.slice.call(arguments, transformers.length))); - }); -}); - -/** - * Reasonable analog to SQL `select` statement. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Object - * @category Relation - * @sig [k] -> [{k: v}] -> [{k: v}] - * @param {Array} props The property names to project - * @param {Array} objs The objects to query - * @return {Array} An array of objects with just the `props` properties. - * @example - * - * const abby = {name: 'Abby', age: 7, hair: 'blond', grade: 2}; - * const fred = {name: 'Fred', age: 12, hair: 'brown', grade: 7}; - * const kids = [abby, fred]; - * R.project(['name', 'grade'], kids); //=> [{name: 'Abby', grade: 2}, {name: 'Fred', grade: 7}] - */ -var project = useWith(_map, [pickAll, identity]); // passing `identity` gives correct arity - -/** - * Returns `true` if the specified object property is equal, in - * [`R.equals`](#equals) terms, to the given value; `false` otherwise. - * You can test multiple properties with [`R.whereEq`](#whereEq). - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Relation - * @sig String -> a -> Object -> Boolean - * @param {String} name - * @param {*} val - * @param {*} obj - * @return {Boolean} - * @see R.whereEq, R.propSatisfies, R.equals - * @example - * - * const abby = {name: 'Abby', age: 7, hair: 'blond'}; - * const fred = {name: 'Fred', age: 12, hair: 'brown'}; - * const rusty = {name: 'Rusty', age: 10, hair: 'brown'}; - * const alois = {name: 'Alois', age: 15, disposition: 'surly'}; - * const kids = [abby, fred, rusty, alois]; - * const hasBrownHair = R.propEq('hair', 'brown'); - * R.filter(hasBrownHair, kids); //=> [fred, rusty] - */ -var propEq = _curry3(function propEq(name, val, obj) { - return equals(val, obj[name]); -}); - -/** - * Returns `true` if the specified object property is of the given type; - * `false` otherwise. - * - * @func - * @memberOf R - * @since v0.16.0 - * @category Type - * @sig Type -> String -> Object -> Boolean - * @param {Function} type - * @param {String} name - * @param {*} obj - * @return {Boolean} - * @see R.is, R.propSatisfies - * @example - * - * R.propIs(Number, 'x', {x: 1, y: 2}); //=> true - * R.propIs(Number, 'x', {x: 'foo'}); //=> false - * R.propIs(Number, 'x', {}); //=> false - */ -var propIs = _curry3(function propIs(type, name, obj) { - return is(type, obj[name]); -}); - -/** - * If the given, non-null object has an own property with the specified name, - * returns the value of that property. Otherwise returns the provided default - * value. - * - * @func - * @memberOf R - * @since v0.6.0 - * @category Object - * @sig a -> String -> Object -> a - * @param {*} val The default value. - * @param {String} p The name of the property to return. - * @param {Object} obj The object to query. - * @return {*} The value of given property of the supplied object or the default value. - * @example - * - * const alice = { - * name: 'ALICE', - * age: 101 - * }; - * const favorite = R.prop('favoriteLibrary'); - * const favoriteWithDefault = R.propOr('Ramda', 'favoriteLibrary'); - * - * favorite(alice); //=> undefined - * favoriteWithDefault(alice); //=> 'Ramda' - */ -var propOr = _curry3(function propOr(val, p, obj) { - return pathOr(val, [p], obj); -}); - -/** - * Returns `true` if the specified object property satisfies the given - * predicate; `false` otherwise. You can test multiple properties with - * [`R.where`](#where). - * - * @func - * @memberOf R - * @since v0.16.0 - * @category Logic - * @sig (a -> Boolean) -> String -> {String: a} -> Boolean - * @param {Function} pred - * @param {String} name - * @param {*} obj - * @return {Boolean} - * @see R.where, R.propEq, R.propIs - * @example - * - * R.propSatisfies(x => x > 0, 'x', {x: 1, y: 2}); //=> true - */ -var propSatisfies = _curry3(function propSatisfies(pred, name, obj) { - return pred(obj[name]); -}); - -/** - * Acts as multiple `prop`: array of keys in, array of values out. Preserves - * order. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Object - * @sig [k] -> {k: v} -> [v] - * @param {Array} ps The property names to fetch - * @param {Object} obj The object to query - * @return {Array} The corresponding values or partially applied function. - * @example - * - * R.props(['x', 'y'], {x: 1, y: 2}); //=> [1, 2] - * R.props(['c', 'a', 'b'], {b: 2, a: 1}); //=> [undefined, 1, 2] - * - * const fullName = R.compose(R.join(' '), R.props(['first', 'last'])); - * fullName({last: 'Bullet-Tooth', age: 33, first: 'Tony'}); //=> 'Tony Bullet-Tooth' - */ -var props = _curry2(function props(ps, obj) { - var len = ps.length; - var out = []; - var idx = 0; - - while (idx < len) { - out[idx] = obj[ps[idx]]; - idx += 1; - } - - return out; -}); - -/** - * Returns a list of numbers from `from` (inclusive) to `to` (exclusive). - * - * @func - * @memberOf R - * @since v0.1.0 - * @category List - * @sig Number -> Number -> [Number] - * @param {Number} from The first number in the list. - * @param {Number} to One more than the last number in the list. - * @return {Array} The list of numbers in the set `[a, b)`. - * @example - * - * R.range(1, 5); //=> [1, 2, 3, 4] - * R.range(50, 53); //=> [50, 51, 52] - */ -var range = _curry2(function range(from, to) { - if (!(_isNumber(from) && _isNumber(to))) { - throw new TypeError('Both arguments to range must be numbers'); - } - var result = []; - var n = from; - while (n < to) { - result.push(n); - n += 1; - } - return result; -}); - -/** - * Returns a single item by iterating through the list, successively calling - * the iterator function and passing it an accumulator value and the current - * value from the array, and then passing the result to the next call. - * - * Similar to [`reduce`](#reduce), except moves through the input list from the - * right to the left. - * - * The iterator function receives two values: *(value, acc)*, while the arguments' - * order of `reduce`'s iterator function is *(acc, value)*. - * - * Note: `R.reduceRight` does not skip deleted or unassigned indices (sparse - * arrays), unlike the native `Array.prototype.reduceRight` method. For more details - * on this behavior, see: - * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduceRight#Description - * - * @func - * @memberOf R - * @since v0.1.0 - * @category List - * @sig ((a, b) -> b) -> b -> [a] -> b - * @param {Function} fn The iterator function. Receives two values, the current element from the array - * and the accumulator. - * @param {*} acc The accumulator value. - * @param {Array} list The list to iterate over. - * @return {*} The final, accumulated value. - * @see R.reduce, R.addIndex - * @example - * - * R.reduceRight(R.subtract, 0, [1, 2, 3, 4]) // => (1 - (2 - (3 - (4 - 0)))) = -2 - * // - -2 - * // / \ / \ - * // 1 - 1 3 - * // / \ / \ - * // 2 - ==> 2 -1 - * // / \ / \ - * // 3 - 3 4 - * // / \ / \ - * // 4 0 4 0 - * - * @symb R.reduceRight(f, a, [b, c, d]) = f(b, f(c, f(d, a))) - */ -var reduceRight = _curry3(function reduceRight(fn, acc, list) { - var idx = list.length - 1; - while (idx >= 0) { - acc = fn(list[idx], acc); - idx -= 1; - } - return acc; -}); - -/** - * Like [`reduce`](#reduce), `reduceWhile` returns a single item by iterating - * through the list, successively calling the iterator function. `reduceWhile` - * also takes a predicate that is evaluated before each step. If the predicate - * returns `false`, it "short-circuits" the iteration and returns the current - * value of the accumulator. - * - * @func - * @memberOf R - * @since v0.22.0 - * @category List - * @sig ((a, b) -> Boolean) -> ((a, b) -> a) -> a -> [b] -> a - * @param {Function} pred The predicate. It is passed the accumulator and the - * current element. - * @param {Function} fn The iterator function. Receives two values, the - * accumulator and the current element. - * @param {*} a The accumulator value. - * @param {Array} list The list to iterate over. - * @return {*} The final, accumulated value. - * @see R.reduce, R.reduced - * @example - * - * const isOdd = (acc, x) => x % 2 === 1; - * const xs = [1, 3, 5, 60, 777, 800]; - * R.reduceWhile(isOdd, R.add, 0, xs); //=> 9 - * - * const ys = [2, 4, 6] - * R.reduceWhile(isOdd, R.add, 111, ys); //=> 111 - */ -var reduceWhile = _curryN(4, [], function _reduceWhile(pred, fn, a, list) { - return _reduce(function(acc, x) { - return pred(acc, x) ? fn(acc, x) : _reduced(acc); - }, a, list); -}); - -/** - * Returns a value wrapped to indicate that it is the final value of the reduce - * and transduce functions. The returned value should be considered a black - * box: the internal structure is not guaranteed to be stable. - * - * Note: this optimization is only available to the below functions: - * - [`reduce`](#reduce) - * - [`reduceWhile`](#reduceWhile) - * - [`transduce`](#transduce) - * - * @func - * @memberOf R - * @since v0.15.0 - * @category List - * @sig a -> * - * @param {*} x The final value of the reduce. - * @return {*} The wrapped value. - * @see R.reduce, R.reduceWhile, R.transduce - * @example - * - * R.reduce( - * (acc, item) => item > 3 ? R.reduced(acc) : acc.concat(item), - * [], - * [1, 2, 3, 4, 5]) // [1, 2, 3] - */ -var reduced = _curry1(_reduced); - -/** - * Calls an input function `n` times, returning an array containing the results - * of those function calls. - * - * `fn` is passed one argument: The current value of `n`, which begins at `0` - * and is gradually incremented to `n - 1`. - * - * @func - * @memberOf R - * @since v0.2.3 - * @category List - * @sig (Number -> a) -> Number -> [a] - * @param {Function} fn The function to invoke. Passed one argument, the current value of `n`. - * @param {Number} n A value between `0` and `n - 1`. Increments after each function call. - * @return {Array} An array containing the return values of all calls to `fn`. - * @see R.repeat - * @example - * - * R.times(R.identity, 5); //=> [0, 1, 2, 3, 4] - * @symb R.times(f, 0) = [] - * @symb R.times(f, 1) = [f(0)] - * @symb R.times(f, 2) = [f(0), f(1)] - */ -var times = _curry2(function times(fn, n) { - var len = Number(n); - var idx = 0; - var list; - - if (len < 0 || isNaN(len)) { - throw new RangeError('n must be a non-negative number'); - } - list = new Array(len); - while (idx < len) { - list[idx] = fn(idx); - idx += 1; - } - return list; -}); - -/** - * Returns a fixed list of size `n` containing a specified identical value. - * - * @func - * @memberOf R - * @since v0.1.1 - * @category List - * @sig a -> n -> [a] - * @param {*} value The value to repeat. - * @param {Number} n The desired size of the output list. - * @return {Array} A new array containing `n` `value`s. - * @see R.times - * @example - * - * R.repeat('hi', 5); //=> ['hi', 'hi', 'hi', 'hi', 'hi'] - * - * const obj = {}; - * const repeatedObjs = R.repeat(obj, 5); //=> [{}, {}, {}, {}, {}] - * repeatedObjs[0] === repeatedObjs[1]; //=> true - * @symb R.repeat(a, 0) = [] - * @symb R.repeat(a, 1) = [a] - * @symb R.repeat(a, 2) = [a, a] - */ -var repeat = _curry2(function repeat(value, n) { - return times(always(value), n); -}); - -/** - * Replace a substring or regex match in a string with a replacement. - * - * The first two parameters correspond to the parameters of the - * `String.prototype.replace()` function, so the second parameter can also be a - * function. - * - * @func - * @memberOf R - * @since v0.7.0 - * @category String - * @sig RegExp|String -> String -> String -> String - * @param {RegExp|String} pattern A regular expression or a substring to match. - * @param {String} replacement The string to replace the matches with. - * @param {String} str The String to do the search and replacement in. - * @return {String} The result. - * @example - * - * R.replace('foo', 'bar', 'foo foo foo'); //=> 'bar foo foo' - * R.replace(/foo/, 'bar', 'foo foo foo'); //=> 'bar foo foo' - * - * // Use the "g" (global) flag to replace all occurrences: - * R.replace(/foo/g, 'bar', 'foo foo foo'); //=> 'bar bar bar' - */ -var replace = _curry3(function replace(regex, replacement, str) { - return str.replace(regex, replacement); -}); - -/** - * Scan is similar to [`reduce`](#reduce), but returns a list of successively - * reduced values from the left - * - * @func - * @memberOf R - * @since v0.10.0 - * @category List - * @sig ((a, b) -> a) -> a -> [b] -> [a] - * @param {Function} fn The iterator function. Receives two values, the accumulator and the - * current element from the array - * @param {*} acc The accumulator value. - * @param {Array} list The list to iterate over. - * @return {Array} A list of all intermediately reduced values. - * @see R.reduce, R.mapAccum - * @example - * - * const numbers = [1, 2, 3, 4]; - * const factorials = R.scan(R.multiply, 1, numbers); //=> [1, 1, 2, 6, 24] - * @symb R.scan(f, a, [b, c]) = [a, f(a, b), f(f(a, b), c)] - */ -var scan = _curry3(function scan(fn, acc, list) { - var idx = 0; - var len = list.length; - var result = [acc]; - while (idx < len) { - acc = fn(acc, list[idx]); - result[idx + 1] = acc; - idx += 1; - } - return result; -}); - -/** - * Transforms a [Traversable](https://github.com/fantasyland/fantasy-land#traversable) - * of [Applicative](https://github.com/fantasyland/fantasy-land#applicative) into an - * Applicative of Traversable. - * - * Dispatches to the `sequence` method of the second argument, if present. - * - * @func - * @memberOf R - * @since v0.19.0 - * @category List - * @sig (Applicative f, Traversable t) => (a -> f a) -> t (f a) -> f (t a) - * @param {Function} of - * @param {*} traversable - * @return {*} - * @see R.traverse - * @example - * - * R.sequence(Maybe.of, [Just(1), Just(2), Just(3)]); //=> Just([1, 2, 3]) - * R.sequence(Maybe.of, [Just(1), Just(2), Nothing()]); //=> Nothing() - * - * R.sequence(R.of, Just([1, 2, 3])); //=> [Just(1), Just(2), Just(3)] - * R.sequence(R.of, Nothing()); //=> [Nothing()] - */ -var sequence = _curry2(function sequence(of, traversable) { - return typeof traversable.sequence === 'function' ? - traversable.sequence(of) : - reduceRight(function(x, acc) { return ap(map(prepend, x), acc); }, - of([]), - traversable); -}); - -/** - * Returns the result of "setting" the portion of the given data structure - * focused by the given lens to the given value. - * - * @func - * @memberOf R - * @since v0.16.0 - * @category Object - * @typedefn Lens s a = Functor f => (a -> f a) -> s -> f s - * @sig Lens s a -> a -> s -> s - * @param {Lens} lens - * @param {*} v - * @param {*} x - * @return {*} - * @see R.prop, R.lensIndex, R.lensProp - * @example - * - * const xLens = R.lensProp('x'); - * - * R.set(xLens, 4, {x: 1, y: 2}); //=> {x: 4, y: 2} - * R.set(xLens, 8, {x: 1, y: 2}); //=> {x: 8, y: 2} - */ -var set = _curry3(function set(lens, v, x) { - return over(lens, always(v), x); -}); - -/** - * Returns a copy of the list, sorted according to the comparator function, - * which should accept two values at a time and return a negative number if the - * first value is smaller, a positive number if it's larger, and zero if they - * are equal. Please note that this is a **copy** of the list. It does not - * modify the original. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category List - * @sig ((a, a) -> Number) -> [a] -> [a] - * @param {Function} comparator A sorting function :: a -> b -> Int - * @param {Array} list The list to sort - * @return {Array} a new array with its elements sorted by the comparator function. - * @example - * - * const diff = function(a, b) { return a - b; }; - * R.sort(diff, [4,2,7,5]); //=> [2, 4, 5, 7] - */ -var sort = _curry2(function sort(comparator, list) { - return Array.prototype.slice.call(list, 0).sort(comparator); -}); - -/** - * Sorts the list according to the supplied function. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Relation - * @sig Ord b => (a -> b) -> [a] -> [a] - * @param {Function} fn - * @param {Array} list The list to sort. - * @return {Array} A new list sorted by the keys generated by `fn`. - * @example - * - * const sortByFirstItem = R.sortBy(R.prop(0)); - * const pairs = [[-1, 1], [-2, 2], [-3, 3]]; - * sortByFirstItem(pairs); //=> [[-3, 3], [-2, 2], [-1, 1]] - * - * const sortByNameCaseInsensitive = R.sortBy(R.compose(R.toLower, R.prop('name'))); - * const alice = { - * name: 'ALICE', - * age: 101 - * }; - * const bob = { - * name: 'Bob', - * age: -10 - * }; - * const clara = { - * name: 'clara', - * age: 314.159 - * }; - * const people = [clara, bob, alice]; - * sortByNameCaseInsensitive(people); //=> [alice, bob, clara] - */ -var sortBy = _curry2(function sortBy(fn, list) { - return Array.prototype.slice.call(list, 0).sort(function(a, b) { - var aa = fn(a); - var bb = fn(b); - return aa < bb ? -1 : aa > bb ? 1 : 0; - }); -}); - -/** - * Sorts a list according to a list of comparators. - * - * @func - * @memberOf R - * @since v0.23.0 - * @category Relation - * @sig [(a, a) -> Number] -> [a] -> [a] - * @param {Array} functions A list of comparator functions. - * @param {Array} list The list to sort. - * @return {Array} A new list sorted according to the comarator functions. - * @example - * - * const alice = { - * name: 'alice', - * age: 40 - * }; - * const bob = { - * name: 'bob', - * age: 30 - * }; - * const clara = { - * name: 'clara', - * age: 40 - * }; - * const people = [clara, bob, alice]; - * const ageNameSort = R.sortWith([ - * R.descend(R.prop('age')), - * R.ascend(R.prop('name')) - * ]); - * ageNameSort(people); //=> [alice, clara, bob] - */ -var sortWith = _curry2(function sortWith(fns, list) { - return Array.prototype.slice.call(list, 0).sort(function(a, b) { - var result = 0; - var i = 0; - while (result === 0 && i < fns.length) { - result = fns[i](a, b); - i += 1; - } - return result; - }); -}); - -/** - * Splits a string into an array of strings based on the given - * separator. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category String - * @sig (String | RegExp) -> String -> [String] - * @param {String|RegExp} sep The pattern. - * @param {String} str The string to separate into an array. - * @return {Array} The array of strings from `str` separated by `str`. - * @see R.join - * @example - * - * const pathComponents = R.split('/'); - * R.tail(pathComponents('/usr/local/bin/node')); //=> ['usr', 'local', 'bin', 'node'] - * - * R.split('.', 'a.b.c.xyz.d'); //=> ['a', 'b', 'c', 'xyz', 'd'] - */ -var split = invoker(1, 'split'); - -/** - * Splits a given list or string at a given index. - * - * @func - * @memberOf R - * @since v0.19.0 - * @category List - * @sig Number -> [a] -> [[a], [a]] - * @sig Number -> String -> [String, String] - * @param {Number} index The index where the array/string is split. - * @param {Array|String} array The array/string to be split. - * @return {Array} - * @example - * - * R.splitAt(1, [1, 2, 3]); //=> [[1], [2, 3]] - * R.splitAt(5, 'hello world'); //=> ['hello', ' world'] - * R.splitAt(-1, 'foobar'); //=> ['fooba', 'r'] - */ -var splitAt = _curry2(function splitAt(index, array) { - return [slice(0, index, array), slice(index, length(array), array)]; -}); - -/** - * Splits a collection into slices of the specified length. - * - * @func - * @memberOf R - * @since v0.16.0 - * @category List - * @sig Number -> [a] -> [[a]] - * @sig Number -> String -> [String] - * @param {Number} n - * @param {Array} list - * @return {Array} - * @example - * - * R.splitEvery(3, [1, 2, 3, 4, 5, 6, 7]); //=> [[1, 2, 3], [4, 5, 6], [7]] - * R.splitEvery(3, 'foobarbaz'); //=> ['foo', 'bar', 'baz'] - */ -var splitEvery = _curry2(function splitEvery(n, list) { - if (n <= 0) { - throw new Error('First argument to splitEvery must be a positive integer'); - } - var result = []; - var idx = 0; - while (idx < list.length) { - result.push(slice(idx, idx += n, list)); - } - return result; -}); - -/** - * Takes a list and a predicate and returns a pair of lists with the following properties: - * - * - the result of concatenating the two output lists is equivalent to the input list; - * - none of the elements of the first output list satisfies the predicate; and - * - if the second output list is non-empty, its first element satisfies the predicate. - * - * @func - * @memberOf R - * @since v0.19.0 - * @category List - * @sig (a -> Boolean) -> [a] -> [[a], [a]] - * @param {Function} pred The predicate that determines where the array is split. - * @param {Array} list The array to be split. - * @return {Array} - * @example - * - * R.splitWhen(R.equals(2), [1, 2, 3, 1, 2, 3]); //=> [[1], [2, 3, 1, 2, 3]] - */ -var splitWhen = _curry2(function splitWhen(pred, list) { - var idx = 0; - var len = list.length; - var prefix = []; - - while (idx < len && !pred(list[idx])) { - prefix.push(list[idx]); - idx += 1; - } - - return [prefix, Array.prototype.slice.call(list, idx)]; -}); - -/** - * Checks if a list starts with the provided sublist. - * - * Similarly, checks if a string starts with the provided substring. - * - * @func - * @memberOf R - * @since v0.24.0 - * @category List - * @sig [a] -> [a] -> Boolean - * @sig String -> String -> Boolean - * @param {*} prefix - * @param {*} list - * @return {Boolean} - * @see R.endsWith - * @example - * - * R.startsWith('a', 'abc') //=> true - * R.startsWith('b', 'abc') //=> false - * R.startsWith(['a'], ['a', 'b', 'c']) //=> true - * R.startsWith(['b'], ['a', 'b', 'c']) //=> false - */ -var startsWith = _curry2(function(prefix, list) { - return equals(take(prefix.length, list), prefix); -}); - -/** - * Subtracts its second argument from its first argument. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Math - * @sig Number -> Number -> Number - * @param {Number} a The first value. - * @param {Number} b The second value. - * @return {Number} The result of `a - b`. - * @see R.add - * @example - * - * R.subtract(10, 8); //=> 2 - * - * const minus5 = R.subtract(R.__, 5); - * minus5(17); //=> 12 - * - * const complementaryAngle = R.subtract(90); - * complementaryAngle(30); //=> 60 - * complementaryAngle(72); //=> 18 - */ -var subtract = _curry2(function subtract(a, b) { - return Number(a) - Number(b); -}); - -/** - * Finds the set (i.e. no duplicates) of all elements contained in the first or - * second list, but not both. - * - * @func - * @memberOf R - * @since v0.19.0 - * @category Relation - * @sig [*] -> [*] -> [*] - * @param {Array} list1 The first list. - * @param {Array} list2 The second list. - * @return {Array} The elements in `list1` or `list2`, but not both. - * @see R.symmetricDifferenceWith, R.difference, R.differenceWith - * @example - * - * R.symmetricDifference([1,2,3,4], [7,6,5,4,3]); //=> [1,2,7,6,5] - * R.symmetricDifference([7,6,5,4,3], [1,2,3,4]); //=> [7,6,5,1,2] - */ -var symmetricDifference = _curry2(function symmetricDifference(list1, list2) { - return concat(difference(list1, list2), difference(list2, list1)); -}); - -/** - * Finds the set (i.e. no duplicates) of all elements contained in the first or - * second list, but not both. Duplication is determined according to the value - * returned by applying the supplied predicate to two list elements. - * - * @func - * @memberOf R - * @since v0.19.0 - * @category Relation - * @sig ((a, a) -> Boolean) -> [a] -> [a] -> [a] - * @param {Function} pred A predicate used to test whether two items are equal. - * @param {Array} list1 The first list. - * @param {Array} list2 The second list. - * @return {Array} The elements in `list1` or `list2`, but not both. - * @see R.symmetricDifference, R.difference, R.differenceWith - * @example - * - * const eqA = R.eqBy(R.prop('a')); - * const l1 = [{a: 1}, {a: 2}, {a: 3}, {a: 4}]; - * const l2 = [{a: 3}, {a: 4}, {a: 5}, {a: 6}]; - * R.symmetricDifferenceWith(eqA, l1, l2); //=> [{a: 1}, {a: 2}, {a: 5}, {a: 6}] - */ -var symmetricDifferenceWith = _curry3(function symmetricDifferenceWith(pred, list1, list2) { - return concat(differenceWith(pred, list1, list2), differenceWith(pred, list2, list1)); -}); - -/** - * Returns a new list containing the last `n` elements of a given list, passing - * each value to the supplied predicate function, and terminating when the - * predicate function returns `false`. Excludes the element that caused the - * predicate function to fail. The predicate function is passed one argument: - * *(value)*. - * - * @func - * @memberOf R - * @since v0.16.0 - * @category List - * @sig (a -> Boolean) -> [a] -> [a] - * @sig (a -> Boolean) -> String -> String - * @param {Function} fn The function called per iteration. - * @param {Array} xs The collection to iterate over. - * @return {Array} A new array. - * @see R.dropLastWhile, R.addIndex - * @example - * - * const isNotOne = x => x !== 1; - * - * R.takeLastWhile(isNotOne, [1, 2, 3, 4]); //=> [2, 3, 4] - * - * R.takeLastWhile(x => x !== 'R' , 'Ramda'); //=> 'amda' - */ -var takeLastWhile = _curry2(function takeLastWhile(fn, xs) { - var idx = xs.length - 1; - while (idx >= 0 && fn(xs[idx])) { - idx -= 1; - } - return slice(idx + 1, Infinity, xs); -}); - -function XTakeWhile(f, xf) { - this.xf = xf; - this.f = f; -} -XTakeWhile.prototype['@@transducer/init'] = _xfBase.init; -XTakeWhile.prototype['@@transducer/result'] = _xfBase.result; -XTakeWhile.prototype['@@transducer/step'] = function(result, input) { - return this.f(input) ? this.xf['@@transducer/step'](result, input) : _reduced(result); -}; - -var _xtakeWhile = _curry2(function _xtakeWhile(f, xf) { return new XTakeWhile(f, xf); }); - -/** - * Returns a new list containing the first `n` elements of a given list, - * passing each value to the supplied predicate function, and terminating when - * the predicate function returns `false`. Excludes the element that caused the - * predicate function to fail. The predicate function is passed one argument: - * *(value)*. - * - * Dispatches to the `takeWhile` method of the second argument, if present. - * - * Acts as a transducer if a transformer is given in list position. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category List - * @sig (a -> Boolean) -> [a] -> [a] - * @sig (a -> Boolean) -> String -> String - * @param {Function} fn The function called per iteration. - * @param {Array} xs The collection to iterate over. - * @return {Array} A new array. - * @see R.dropWhile, R.transduce, R.addIndex - * @example - * - * const isNotFour = x => x !== 4; - * - * R.takeWhile(isNotFour, [1, 2, 3, 4, 3, 2, 1]); //=> [1, 2, 3] - * - * R.takeWhile(x => x !== 'd' , 'Ramda'); //=> 'Ram' - */ -var takeWhile = _curry2(_dispatchable(['takeWhile'], _xtakeWhile, function takeWhile(fn, xs) { - var idx = 0; - var len = xs.length; - while (idx < len && fn(xs[idx])) { - idx += 1; - } - return slice(0, idx, xs); -})); - -function XTap(f, xf) { - this.xf = xf; - this.f = f; -} -XTap.prototype['@@transducer/init'] = _xfBase.init; -XTap.prototype['@@transducer/result'] = _xfBase.result; -XTap.prototype['@@transducer/step'] = function(result, input) { - this.f(input); - return this.xf['@@transducer/step'](result, input); -}; - -var _xtap = _curry2(function _xtap(f, xf) { return new XTap(f, xf); }); - -/** - * Runs the given function with the supplied object, then returns the object. - * - * Acts as a transducer if a transformer is given as second parameter. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Function - * @sig (a -> *) -> a -> a - * @param {Function} fn The function to call with `x`. The return value of `fn` will be thrown away. - * @param {*} x - * @return {*} `x`. - * @example - * - * const sayX = x => console.log('x is ' + x); - * R.tap(sayX, 100); //=> 100 - * // logs 'x is 100' - * @symb R.tap(f, a) = a - */ -var tap = _curry2(_dispatchable([], _xtap, function tap(fn, x) { - fn(x); - return x; -})); - -function _isRegExp(x) { - return Object.prototype.toString.call(x) === '[object RegExp]'; -} - -/** - * Determines whether a given string matches a given regular expression. - * - * @func - * @memberOf R - * @since v0.12.0 - * @category String - * @sig RegExp -> String -> Boolean - * @param {RegExp} pattern - * @param {String} str - * @return {Boolean} - * @see R.match - * @example - * - * R.test(/^x/, 'xyz'); //=> true - * R.test(/^y/, 'xyz'); //=> false - */ -var test = _curry2(function test(pattern, str) { - if (!_isRegExp(pattern)) { - throw new TypeError('‘test’ requires a value of type RegExp as its first argument; received ' + toString$1(pattern)); - } - return _cloneRegExp(pattern).test(str); -}); - -/** - * Returns the result of applying the onSuccess function to the value inside - * a successfully resolved promise. This is useful for working with promises - * inside function compositions. - * - * @func - * @memberOf R - * @category Function - * @sig (a -> b) -> (Promise e a) -> (Promise e b) - * @sig (a -> (Promise e b)) -> (Promise e a) -> (Promise e b) - * @param {Function} onSuccess The function to apply. Can return a value or a promise of a value. - * @param {Promise} p - * @return {Promise} The result of calling `p.then(onSuccess)` - * @see R.otherwise - * @example - * - * var makeQuery = (email) => ({ query: { email }}); - * - * //getMemberName :: String -> Promise ({firstName, lastName}) - * var getMemberName = R.pipe( - * makeQuery, - * fetchMember, - * R.then(R.pick(['firstName', 'lastName'])) - * ); - */ -const then = _curry2(function then(f, p) { - _assertPromise('then', p); - - return p.then(f); -}); - -/** - * The lower case version of a string. - * - * @func - * @memberOf R - * @since v0.9.0 - * @category String - * @sig String -> String - * @param {String} str The string to lower case. - * @return {String} The lower case version of `str`. - * @see R.toUpper - * @example - * - * R.toLower('XYZ'); //=> 'xyz' - */ -var toLower = invoker(0, 'toLowerCase'); - -/** - * Converts an object into an array of key, value arrays. Only the object's - * own properties are used. - * Note that the order of the output array is not guaranteed to be consistent - * across different JS platforms. - * - * @func - * @memberOf R - * @since v0.4.0 - * @category Object - * @sig {String: *} -> [[String,*]] - * @param {Object} obj The object to extract from - * @return {Array} An array of key, value arrays from the object's own properties. - * @see R.fromPairs - * @example - * - * R.toPairs({a: 1, b: 2, c: 3}); //=> [['a', 1], ['b', 2], ['c', 3]] - */ -var toPairs = _curry1(function toPairs(obj) { - var pairs = []; - for (var prop in obj) { - if (_has(prop, obj)) { - pairs[pairs.length] = [prop, obj[prop]]; - } - } - return pairs; -}); - -/** - * Converts an object into an array of key, value arrays. The object's own - * properties and prototype properties are used. Note that the order of the - * output array is not guaranteed to be consistent across different JS - * platforms. - * - * @func - * @memberOf R - * @since v0.4.0 - * @category Object - * @sig {String: *} -> [[String,*]] - * @param {Object} obj The object to extract from - * @return {Array} An array of key, value arrays from the object's own - * and prototype properties. - * @example - * - * const F = function() { this.x = 'X'; }; - * F.prototype.y = 'Y'; - * const f = new F(); - * R.toPairsIn(f); //=> [['x','X'], ['y','Y']] - */ -var toPairsIn = _curry1(function toPairsIn(obj) { - var pairs = []; - for (var prop in obj) { - pairs[pairs.length] = [prop, obj[prop]]; - } - return pairs; -}); - -/** - * The upper case version of a string. - * - * @func - * @memberOf R - * @since v0.9.0 - * @category String - * @sig String -> String - * @param {String} str The string to upper case. - * @return {String} The upper case version of `str`. - * @see R.toLower - * @example - * - * R.toUpper('abc'); //=> 'ABC' - */ -var toUpper = invoker(0, 'toUpperCase'); - -/** - * Initializes a transducer using supplied iterator function. Returns a single - * item by iterating through the list, successively calling the transformed - * iterator function and passing it an accumulator value and the current value - * from the array, and then passing the result to the next call. - * - * The iterator function receives two values: *(acc, value)*. It will be - * wrapped as a transformer to initialize the transducer. A transformer can be - * passed directly in place of an iterator function. In both cases, iteration - * may be stopped early with the [`R.reduced`](#reduced) function. - * - * A transducer is a function that accepts a transformer and returns a - * transformer and can be composed directly. - * - * A transformer is an an object that provides a 2-arity reducing iterator - * function, step, 0-arity initial value function, init, and 1-arity result - * extraction function, result. The step function is used as the iterator - * function in reduce. The result function is used to convert the final - * accumulator into the return type and in most cases is - * [`R.identity`](#identity). The init function can be used to provide an - * initial accumulator, but is ignored by transduce. - * - * The iteration is performed with [`R.reduce`](#reduce) after initializing the transducer. - * - * @func - * @memberOf R - * @since v0.12.0 - * @category List - * @sig (c -> c) -> ((a, b) -> a) -> a -> [b] -> a - * @param {Function} xf The transducer function. Receives a transformer and returns a transformer. - * @param {Function} fn The iterator function. Receives two values, the accumulator and the - * current element from the array. Wrapped as transformer, if necessary, and used to - * initialize the transducer - * @param {*} acc The initial accumulator value. - * @param {Array} list The list to iterate over. - * @return {*} The final, accumulated value. - * @see R.reduce, R.reduced, R.into - * @example - * - * const numbers = [1, 2, 3, 4]; - * const transducer = R.compose(R.map(R.add(1)), R.take(2)); - * R.transduce(transducer, R.flip(R.append), [], numbers); //=> [2, 3] - * - * const isOdd = (x) => x % 2 === 1; - * const firstOddTransducer = R.compose(R.filter(isOdd), R.take(1)); - * R.transduce(firstOddTransducer, R.flip(R.append), [], R.range(0, 100)); //=> [1] - */ -var transduce = curryN(4, function transduce(xf, fn, acc, list) { - return _reduce(xf(typeof fn === 'function' ? _xwrap(fn) : fn), acc, list); -}); - -/** - * Transposes the rows and columns of a 2D list. - * When passed a list of `n` lists of length `x`, - * returns a list of `x` lists of length `n`. - * - * - * @func - * @memberOf R - * @since v0.19.0 - * @category List - * @sig [[a]] -> [[a]] - * @param {Array} list A 2D list - * @return {Array} A 2D list - * @example - * - * R.transpose([[1, 'a'], [2, 'b'], [3, 'c']]) //=> [[1, 2, 3], ['a', 'b', 'c']] - * R.transpose([[1, 2, 3], ['a', 'b', 'c']]) //=> [[1, 'a'], [2, 'b'], [3, 'c']] - * - * // If some of the rows are shorter than the following rows, their elements are skipped: - * R.transpose([[10, 11], [20], [], [30, 31, 32]]) //=> [[10, 20, 30], [11, 31], [32]] - * @symb R.transpose([[a], [b], [c]]) = [a, b, c] - * @symb R.transpose([[a, b], [c, d]]) = [[a, c], [b, d]] - * @symb R.transpose([[a, b], [c]]) = [[a, c], [b]] - */ -var transpose = _curry1(function transpose(outerlist) { - var i = 0; - var result = []; - while (i < outerlist.length) { - var innerlist = outerlist[i]; - var j = 0; - while (j < innerlist.length) { - if (typeof result[j] === 'undefined') { - result[j] = []; - } - result[j].push(innerlist[j]); - j += 1; - } - i += 1; - } - return result; -}); - -/** - * Maps an [Applicative](https://github.com/fantasyland/fantasy-land#applicative)-returning - * function over a [Traversable](https://github.com/fantasyland/fantasy-land#traversable), - * then uses [`sequence`](#sequence) to transform the resulting Traversable of Applicative - * into an Applicative of Traversable. - * - * Dispatches to the `traverse` method of the third argument, if present. - * - * @func - * @memberOf R - * @since v0.19.0 - * @category List - * @sig (Applicative f, Traversable t) => (a -> f a) -> (a -> f b) -> t a -> f (t b) - * @param {Function} of - * @param {Function} f - * @param {*} traversable - * @return {*} - * @see R.sequence - * @example - * - * // Returns `Maybe.Nothing` if the given divisor is `0` - * const safeDiv = n => d => d === 0 ? Maybe.Nothing() : Maybe.Just(n / d) - * - * R.traverse(Maybe.of, safeDiv(10), [2, 4, 5]); //=> Maybe.Just([5, 2.5, 2]) - * R.traverse(Maybe.of, safeDiv(10), [2, 0, 5]); //=> Maybe.Nothing - */ -var traverse = _curry3(function traverse(of, f, traversable) { - return typeof traversable['fantasy-land/traverse'] === 'function' ? - traversable['fantasy-land/traverse'](f, of) : - sequence(of, map(f, traversable)); -}); - -var ws = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003' + - '\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028' + - '\u2029\uFEFF'; -var zeroWidth = '\u200b'; -var hasProtoTrim = (typeof String.prototype.trim === 'function'); -/** - * Removes (strips) whitespace from both ends of the string. - * - * @func - * @memberOf R - * @since v0.6.0 - * @category String - * @sig String -> String - * @param {String} str The string to trim. - * @return {String} Trimmed version of `str`. - * @example - * - * R.trim(' xyz '); //=> 'xyz' - * R.map(R.trim, R.split(',', 'x, y, z')); //=> ['x', 'y', 'z'] - */ -var trim = !hasProtoTrim || (ws.trim() || !zeroWidth.trim()) ? - _curry1(function trim(str) { - var beginRx = new RegExp('^[' + ws + '][' + ws + ']*'); - var endRx = new RegExp('[' + ws + '][' + ws + ']*$'); - return str.replace(beginRx, '').replace(endRx, ''); - }) : - _curry1(function trim(str) { - return str.trim(); - }); - -/** - * `tryCatch` takes two functions, a `tryer` and a `catcher`. The returned - * function evaluates the `tryer`; if it does not throw, it simply returns the - * result. If the `tryer` *does* throw, the returned function evaluates the - * `catcher` function and returns its result. Note that for effective - * composition with this function, both the `tryer` and `catcher` functions - * must return the same type of results. - * - * @func - * @memberOf R - * @since v0.20.0 - * @category Function - * @sig (...x -> a) -> ((e, ...x) -> a) -> (...x -> a) - * @param {Function} tryer The function that may throw. - * @param {Function} catcher The function that will be evaluated if `tryer` throws. - * @return {Function} A new function that will catch exceptions and send then to the catcher. - * @example - * - * R.tryCatch(R.prop('x'), R.F)({x: true}); //=> true - * R.tryCatch(() => { throw 'foo'}, R.always('catched'))('bar') // => 'catched' - * R.tryCatch(R.times(R.identity), R.always([]))('s') // => [] - `` */ -var tryCatch = _curry2(function _tryCatch(tryer, catcher) { - return _arity(tryer.length, function() { - try { - return tryer.apply(this, arguments); - } catch (e) { - return catcher.apply(this, _concat([e], arguments)); - } - }); -}); - -/** - * Takes a function `fn`, which takes a single array argument, and returns a - * function which: - * - * - takes any number of positional arguments; - * - passes these arguments to `fn` as an array; and - * - returns the result. - * - * In other words, `R.unapply` derives a variadic function from a function which - * takes an array. `R.unapply` is the inverse of [`R.apply`](#apply). - * - * @func - * @memberOf R - * @since v0.8.0 - * @category Function - * @sig ([*...] -> a) -> (*... -> a) - * @param {Function} fn - * @return {Function} - * @see R.apply - * @example - * - * R.unapply(JSON.stringify)(1, 2, 3); //=> '[1,2,3]' - * @symb R.unapply(f)(a, b) = f([a, b]) - */ -var unapply = _curry1(function unapply(fn) { - return function() { - return fn(Array.prototype.slice.call(arguments, 0)); - }; -}); - -/** - * Wraps a function of any arity (including nullary) in a function that accepts - * exactly 1 parameter. Any extraneous parameters will not be passed to the - * supplied function. - * - * @func - * @memberOf R - * @since v0.2.0 - * @category Function - * @sig (* -> b) -> (a -> b) - * @param {Function} fn The function to wrap. - * @return {Function} A new function wrapping `fn`. The new function is guaranteed to be of - * arity 1. - * @see R.binary, R.nAry - * @example - * - * const takesTwoArgs = function(a, b) { - * return [a, b]; - * }; - * takesTwoArgs.length; //=> 2 - * takesTwoArgs(1, 2); //=> [1, 2] - * - * const takesOneArg = R.unary(takesTwoArgs); - * takesOneArg.length; //=> 1 - * // Only 1 argument is passed to the wrapped function - * takesOneArg(1, 2); //=> [1, undefined] - * @symb R.unary(f)(a, b, c) = f(a) - */ -var unary = _curry1(function unary(fn) { - return nAry(1, fn); -}); - -/** - * Returns a function of arity `n` from a (manually) curried function. - * - * @func - * @memberOf R - * @since v0.14.0 - * @category Function - * @sig Number -> (a -> b) -> (a -> c) - * @param {Number} length The arity for the returned function. - * @param {Function} fn The function to uncurry. - * @return {Function} A new function. - * @see R.curry - * @example - * - * const addFour = a => b => c => d => a + b + c + d; - * - * const uncurriedAddFour = R.uncurryN(4, addFour); - * uncurriedAddFour(1, 2, 3, 4); //=> 10 - */ -var uncurryN = _curry2(function uncurryN(depth, fn) { - return curryN(depth, function() { - var currentDepth = 1; - var value = fn; - var idx = 0; - var endIdx; - while (currentDepth <= depth && typeof value === 'function') { - endIdx = currentDepth === depth ? arguments.length : idx + value.length; - value = value.apply(this, Array.prototype.slice.call(arguments, idx, endIdx)); - currentDepth += 1; - idx = endIdx; - } - return value; - }); -}); - -/** - * Builds a list from a seed value. Accepts an iterator function, which returns - * either false to stop iteration or an array of length 2 containing the value - * to add to the resulting list and the seed to be used in the next call to the - * iterator function. - * - * The iterator function receives one argument: *(seed)*. - * - * @func - * @memberOf R - * @since v0.10.0 - * @category List - * @sig (a -> [b]) -> * -> [b] - * @param {Function} fn The iterator function. receives one argument, `seed`, and returns - * either false to quit iteration or an array of length two to proceed. The element - * at index 0 of this array will be added to the resulting array, and the element - * at index 1 will be passed to the next call to `fn`. - * @param {*} seed The seed value. - * @return {Array} The final list. - * @example - * - * const f = n => n > 50 ? false : [-n, n + 10]; - * R.unfold(f, 10); //=> [-10, -20, -30, -40, -50] - * @symb R.unfold(f, x) = [f(x)[0], f(f(x)[1])[0], f(f(f(x)[1])[1])[0], ...] - */ -var unfold = _curry2(function unfold(fn, seed) { - var pair = fn(seed); - var result = []; - while (pair && pair.length) { - result[result.length] = pair[0]; - pair = fn(pair[1]); - } - return result; -}); - -/** - * Combines two lists into a set (i.e. no duplicates) composed of the elements - * of each list. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Relation - * @sig [*] -> [*] -> [*] - * @param {Array} as The first list. - * @param {Array} bs The second list. - * @return {Array} The first and second lists concatenated, with - * duplicates removed. - * @example - * - * R.union([1, 2, 3], [2, 3, 4]); //=> [1, 2, 3, 4] - */ -var union = _curry2(compose(uniq, _concat)); - -/** - * Returns a new list containing only one copy of each element in the original - * list, based upon the value returned by applying the supplied predicate to - * two list elements. Prefers the first item if two items compare equal based - * on the predicate. - * - * @func - * @memberOf R - * @since v0.2.0 - * @category List - * @sig ((a, a) -> Boolean) -> [a] -> [a] - * @param {Function} pred A predicate used to test whether two items are equal. - * @param {Array} list The array to consider. - * @return {Array} The list of unique items. - * @example - * - * const strEq = R.eqBy(String); - * R.uniqWith(strEq)([1, '1', 2, 1]); //=> [1, 2] - * R.uniqWith(strEq)([{}, {}]); //=> [{}] - * R.uniqWith(strEq)([1, '1', 1]); //=> [1] - * R.uniqWith(strEq)(['1', 1, 1]); //=> ['1'] - */ -var uniqWith = _curry2(function uniqWith(pred, list) { - var idx = 0; - var len = list.length; - var result = []; - var item; - while (idx < len) { - item = list[idx]; - if (!_includesWith(pred, item, result)) { - result[result.length] = item; - } - idx += 1; - } - return result; -}); - -/** - * Combines two lists into a set (i.e. no duplicates) composed of the elements - * of each list. Duplication is determined according to the value returned by - * applying the supplied predicate to two list elements. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Relation - * @sig ((a, a) -> Boolean) -> [*] -> [*] -> [*] - * @param {Function} pred A predicate used to test whether two items are equal. - * @param {Array} list1 The first list. - * @param {Array} list2 The second list. - * @return {Array} The first and second lists concatenated, with - * duplicates removed. - * @see R.union - * @example - * - * const l1 = [{a: 1}, {a: 2}]; - * const l2 = [{a: 1}, {a: 4}]; - * R.unionWith(R.eqBy(R.prop('a')), l1, l2); //=> [{a: 1}, {a: 2}, {a: 4}] - */ -var unionWith = _curry3(function unionWith(pred, list1, list2) { - return uniqWith(pred, _concat(list1, list2)); -}); - -/** - * Tests the final argument by passing it to the given predicate function. If - * the predicate is not satisfied, the function will return the result of - * calling the `whenFalseFn` function with the same argument. If the predicate - * is satisfied, the argument is returned as is. - * - * @func - * @memberOf R - * @since v0.18.0 - * @category Logic - * @sig (a -> Boolean) -> (a -> a) -> a -> a - * @param {Function} pred A predicate function - * @param {Function} whenFalseFn A function to invoke when the `pred` evaluates - * to a falsy value. - * @param {*} x An object to test with the `pred` function and - * pass to `whenFalseFn` if necessary. - * @return {*} Either `x` or the result of applying `x` to `whenFalseFn`. - * @see R.ifElse, R.when, R.cond - * @example - * - * let safeInc = R.unless(R.isNil, R.inc); - * safeInc(null); //=> null - * safeInc(1); //=> 2 - */ -var unless = _curry3(function unless(pred, whenFalseFn, x) { - return pred(x) ? x : whenFalseFn(x); -}); - -/** - * Shorthand for `R.chain(R.identity)`, which removes one level of nesting from - * any [Chain](https://github.com/fantasyland/fantasy-land#chain). - * - * @func - * @memberOf R - * @since v0.3.0 - * @category List - * @sig Chain c => c (c a) -> c a - * @param {*} list - * @return {*} - * @see R.flatten, R.chain - * @example - * - * R.unnest([1, [2], [[3]]]); //=> [1, 2, [3]] - * R.unnest([[1, 2], [3, 4], [5, 6]]); //=> [1, 2, 3, 4, 5, 6] - */ -var unnest = chain(_identity); - -/** - * Takes a predicate, a transformation function, and an initial value, - * and returns a value of the same type as the initial value. - * It does so by applying the transformation until the predicate is satisfied, - * at which point it returns the satisfactory value. - * - * @func - * @memberOf R - * @since v0.20.0 - * @category Logic - * @sig (a -> Boolean) -> (a -> a) -> a -> a - * @param {Function} pred A predicate function - * @param {Function} fn The iterator function - * @param {*} init Initial value - * @return {*} Final value that satisfies predicate - * @example - * - * R.until(R.gt(R.__, 100), R.multiply(2))(1) // => 128 - */ -var until = _curry3(function until(pred, fn, init) { - var val = init; - while (!pred(val)) { - val = fn(val); - } - return val; -}); - -/** - * Returns a list of all the properties, including prototype properties, of the - * supplied object. - * Note that the order of the output array is not guaranteed to be consistent - * across different JS platforms. - * - * @func - * @memberOf R - * @since v0.2.0 - * @category Object - * @sig {k: v} -> [v] - * @param {Object} obj The object to extract values from - * @return {Array} An array of the values of the object's own and prototype properties. - * @see R.values, R.keysIn - * @example - * - * const F = function() { this.x = 'X'; }; - * F.prototype.y = 'Y'; - * const f = new F(); - * R.valuesIn(f); //=> ['X', 'Y'] - */ -var valuesIn = _curry1(function valuesIn(obj) { - var prop; - var vs = []; - for (prop in obj) { - vs[vs.length] = obj[prop]; - } - return vs; -}); - -// `Const` is a functor that effectively ignores the function given to `map`. -var Const = function(x) { - return {value: x, 'fantasy-land/map': function() { return this; }}; -}; - -/** - * Returns a "view" of the given data structure, determined by the given lens. - * The lens's focus determines which portion of the data structure is visible. - * - * @func - * @memberOf R - * @since v0.16.0 - * @category Object - * @typedefn Lens s a = Functor f => (a -> f a) -> s -> f s - * @sig Lens s a -> s -> a - * @param {Lens} lens - * @param {*} x - * @return {*} - * @see R.prop, R.lensIndex, R.lensProp - * @example - * - * const xLens = R.lensProp('x'); - * - * R.view(xLens, {x: 1, y: 2}); //=> 1 - * R.view(xLens, {x: 4, y: 2}); //=> 4 - */ -var view = _curry2(function view(lens, x) { - // Using `Const` effectively ignores the setter function of the `lens`, - // leaving the value returned by the getter function unmodified. - return lens(Const)(x).value; -}); - -/** - * Tests the final argument by passing it to the given predicate function. If - * the predicate is satisfied, the function will return the result of calling - * the `whenTrueFn` function with the same argument. If the predicate is not - * satisfied, the argument is returned as is. - * - * @func - * @memberOf R - * @since v0.18.0 - * @category Logic - * @sig (a -> Boolean) -> (a -> a) -> a -> a - * @param {Function} pred A predicate function - * @param {Function} whenTrueFn A function to invoke when the `condition` - * evaluates to a truthy value. - * @param {*} x An object to test with the `pred` function and - * pass to `whenTrueFn` if necessary. - * @return {*} Either `x` or the result of applying `x` to `whenTrueFn`. - * @see R.ifElse, R.unless, R.cond - * @example - * - * // truncate :: String -> String - * const truncate = R.when( - * R.propSatisfies(R.gt(R.__, 10), 'length'), - * R.pipe(R.take(10), R.append('…'), R.join('')) - * ); - * truncate('12345'); //=> '12345' - * truncate('0123456789ABC'); //=> '0123456789…' - */ -var when = _curry3(function when(pred, whenTrueFn, x) { - return pred(x) ? whenTrueFn(x) : x; -}); - -/** - * Takes a spec object and a test object; returns true if the test satisfies - * the spec. Each of the spec's own properties must be a predicate function. - * Each predicate is applied to the value of the corresponding property of the - * test object. `where` returns true if all the predicates return true, false - * otherwise. - * - * `where` is well suited to declaratively expressing constraints for other - * functions such as [`filter`](#filter) and [`find`](#find). - * - * @func - * @memberOf R - * @since v0.1.1 - * @category Object - * @sig {String: (* -> Boolean)} -> {String: *} -> Boolean - * @param {Object} spec - * @param {Object} testObj - * @return {Boolean} - * @see R.propSatisfies, R.whereEq - * @example - * - * // pred :: Object -> Boolean - * const pred = R.where({ - * a: R.equals('foo'), - * b: R.complement(R.equals('bar')), - * x: R.gt(R.__, 10), - * y: R.lt(R.__, 20) - * }); - * - * pred({a: 'foo', b: 'xxx', x: 11, y: 19}); //=> true - * pred({a: 'xxx', b: 'xxx', x: 11, y: 19}); //=> false - * pred({a: 'foo', b: 'bar', x: 11, y: 19}); //=> false - * pred({a: 'foo', b: 'xxx', x: 10, y: 19}); //=> false - * pred({a: 'foo', b: 'xxx', x: 11, y: 20}); //=> false - */ -var where = _curry2(function where(spec, testObj) { - for (var prop in spec) { - if (_has(prop, spec) && !spec[prop](testObj[prop])) { - return false; - } - } - return true; -}); - -/** - * Takes a spec object and a test object; returns true if the test satisfies - * the spec, false otherwise. An object satisfies the spec if, for each of the - * spec's own properties, accessing that property of the object gives the same - * value (in [`R.equals`](#equals) terms) as accessing that property of the - * spec. - * - * `whereEq` is a specialization of [`where`](#where). - * - * @func - * @memberOf R - * @since v0.14.0 - * @category Object - * @sig {String: *} -> {String: *} -> Boolean - * @param {Object} spec - * @param {Object} testObj - * @return {Boolean} - * @see R.propEq, R.where - * @example - * - * // pred :: Object -> Boolean - * const pred = R.whereEq({a: 1, b: 2}); - * - * pred({a: 1}); //=> false - * pred({a: 1, b: 2}); //=> true - * pred({a: 1, b: 2, c: 3}); //=> true - * pred({a: 1, b: 1}); //=> false - */ -var whereEq = _curry2(function whereEq(spec, testObj) { - return where(map(equals, spec), testObj); -}); - -/** - * Returns a new list without values in the first argument. - * [`R.equals`](#equals) is used to determine equality. - * - * Acts as a transducer if a transformer is given in list position. - * - * @func - * @memberOf R - * @since v0.19.0 - * @category List - * @sig [a] -> [a] -> [a] - * @param {Array} list1 The values to be removed from `list2`. - * @param {Array} list2 The array to remove values from. - * @return {Array} The new array without values in `list1`. - * @see R.transduce, R.difference, R.remove - * @example - * - * R.without([1, 2], [1, 2, 1, 3, 4]); //=> [3, 4] - */ -var without = _curry2(function(xs, list) { - return reject(flip(_includes)(xs), list); -}); - -/** - * Creates a new list out of the two supplied by creating each possible pair - * from the lists. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category List - * @sig [a] -> [b] -> [[a,b]] - * @param {Array} as The first list. - * @param {Array} bs The second list. - * @return {Array} The list made by combining each possible pair from - * `as` and `bs` into pairs (`[a, b]`). - * @example - * - * R.xprod([1, 2], ['a', 'b']); //=> [[1, 'a'], [1, 'b'], [2, 'a'], [2, 'b']] - * @symb R.xprod([a, b], [c, d]) = [[a, c], [a, d], [b, c], [b, d]] - */ -var xprod = _curry2(function xprod(a, b) { // = xprodWith(prepend); (takes about 3 times as long...) - var idx = 0; - var ilen = a.length; - var j; - var jlen = b.length; - var result = []; - while (idx < ilen) { - j = 0; - while (j < jlen) { - result[result.length] = [a[idx], b[j]]; - j += 1; - } - idx += 1; - } - return result; -}); - -/** - * Creates a new list out of the two supplied by pairing up equally-positioned - * items from both lists. The returned list is truncated to the length of the - * shorter of the two input lists. - * Note: `zip` is equivalent to `zipWith(function(a, b) { return [a, b] })`. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category List - * @sig [a] -> [b] -> [[a,b]] - * @param {Array} list1 The first array to consider. - * @param {Array} list2 The second array to consider. - * @return {Array} The list made by pairing up same-indexed elements of `list1` and `list2`. - * @example - * - * R.zip([1, 2, 3], ['a', 'b', 'c']); //=> [[1, 'a'], [2, 'b'], [3, 'c']] - * @symb R.zip([a, b, c], [d, e, f]) = [[a, d], [b, e], [c, f]] - */ -var zip = _curry2(function zip(a, b) { - var rv = []; - var idx = 0; - var len = Math.min(a.length, b.length); - while (idx < len) { - rv[idx] = [a[idx], b[idx]]; - idx += 1; - } - return rv; -}); - -/** - * Creates a new object out of a list of keys and a list of values. - * Key/value pairing is truncated to the length of the shorter of the two lists. - * Note: `zipObj` is equivalent to `pipe(zip, fromPairs)`. - * - * @func - * @memberOf R - * @since v0.3.0 - * @category List - * @sig [String] -> [*] -> {String: *} - * @param {Array} keys The array that will be properties on the output object. - * @param {Array} values The list of values on the output object. - * @return {Object} The object made by pairing up same-indexed elements of `keys` and `values`. - * @example - * - * R.zipObj(['a', 'b', 'c'], [1, 2, 3]); //=> {a: 1, b: 2, c: 3} - */ -var zipObj = _curry2(function zipObj(keys, values) { - var idx = 0; - var len = Math.min(keys.length, values.length); - var out = {}; - while (idx < len) { - out[keys[idx]] = values[idx]; - idx += 1; - } - return out; -}); - -/** - * Creates a new list out of the two supplied by applying the function to each - * equally-positioned pair in the lists. The returned list is truncated to the - * length of the shorter of the two input lists. - * - * @function - * @memberOf R - * @since v0.1.0 - * @category List - * @sig ((a, b) -> c) -> [a] -> [b] -> [c] - * @param {Function} fn The function used to combine the two elements into one value. - * @param {Array} list1 The first array to consider. - * @param {Array} list2 The second array to consider. - * @return {Array} The list made by combining same-indexed elements of `list1` and `list2` - * using `fn`. - * @example - * - * const f = (x, y) => { - * // ... - * }; - * R.zipWith(f, [1, 2, 3], ['a', 'b', 'c']); - * //=> [f(1, 'a'), f(2, 'b'), f(3, 'c')] - * @symb R.zipWith(fn, [a, b, c], [d, e, f]) = [fn(a, d), fn(b, e), fn(c, f)] - */ -var zipWith = _curry3(function zipWith(fn, a, b) { - var rv = []; - var idx = 0; - var len = Math.min(a.length, b.length); - while (idx < len) { - rv[idx] = fn(a[idx], b[idx]); - idx += 1; - } - return rv; -}); - -/** - * Creates a thunk out of a function. A thunk delays a calculation until - * its result is needed, providing lazy evaluation of arguments. - * - * @func - * @memberOf R - * @category Function - * @sig ((a, b, ..., j) -> k) -> (a, b, ..., j) -> (() -> k) - * @param {Function} fn A function to wrap in a thunk - * @return {Function} Expects arguments for `fn` and returns a new function - * that, when called, applies those arguments to `fn`. - * @see R.partial, R.partialRight - * @example - * - * R.thunkify(R.identity)(42)(); //=> 42 - * R.thunkify((a, b) => a + b)(25, 17)(); //=> 42 - */ -var thunkify = _curry1(function thunkify(fn) { - return curryN(fn.length, function createThunk() { - const fnArgs = arguments; - return function invokeThunk() { - return fn.apply(this, fnArgs); - }; - }); -}); - -exports.F = F; -exports.T = T; -exports.__ = __; -exports.add = add; -exports.addIndex = addIndex; -exports.adjust = adjust; -exports.all = all; -exports.allPass = allPass; -exports.always = always; -exports.and = and; -exports.any = any; -exports.anyPass = anyPass; -exports.ap = ap; -exports.aperture = aperture; -exports.append = append; -exports.apply = apply; -exports.applySpec = applySpec; -exports.applyTo = applyTo; -exports.ascend = ascend; -exports.assoc = assoc; -exports.assocPath = assocPath; -exports.binary = binary; -exports.bind = bind; -exports.both = both; -exports.call = call; -exports.chain = chain; -exports.clamp = clamp; -exports.clone = clone; -exports.comparator = comparator; -exports.complement = complement; -exports.compose = compose; -exports.composeK = composeK; -exports.composeP = composeP; -exports.composeWith = composeWith; -exports.concat = concat; -exports.cond = cond; -exports.construct = construct; -exports.constructN = constructN; -exports.contains = contains$1; -exports.converge = converge; -exports.countBy = countBy; -exports.curry = curry; -exports.curryN = curryN; -exports.dec = dec; -exports.defaultTo = defaultTo; -exports.descend = descend; -exports.difference = difference; -exports.differenceWith = differenceWith; -exports.dissoc = dissoc; -exports.dissocPath = dissocPath; -exports.divide = divide; -exports.drop = drop; -exports.dropLast = dropLast; -exports.dropLastWhile = dropLastWhile; -exports.dropRepeats = dropRepeats; -exports.dropRepeatsWith = dropRepeatsWith; -exports.dropWhile = dropWhile; -exports.either = either; -exports.empty = empty; -exports.endsWith = endsWith; -exports.eqBy = eqBy; -exports.eqProps = eqProps; -exports.equals = equals; -exports.evolve = evolve; -exports.filter = filter; -exports.find = find; -exports.findIndex = findIndex; -exports.findLast = findLast; -exports.findLastIndex = findLastIndex; -exports.flatten = flatten; -exports.flip = flip; -exports.forEach = forEach; -exports.forEachObjIndexed = forEachObjIndexed; -exports.fromPairs = fromPairs; -exports.groupBy = groupBy; -exports.groupWith = groupWith; -exports.gt = gt; -exports.gte = gte; -exports.has = has; -exports.hasIn = hasIn; -exports.hasPath = hasPath; -exports.head = head; -exports.identical = identical; -exports.identity = identity; -exports.ifElse = ifElse; -exports.inc = inc; -exports.includes = includes; -exports.indexBy = indexBy; -exports.indexOf = indexOf; -exports.init = init; -exports.innerJoin = innerJoin; -exports.insert = insert; -exports.insertAll = insertAll; -exports.intersection = intersection; -exports.intersperse = intersperse; -exports.into = into; -exports.invert = invert; -exports.invertObj = invertObj; -exports.invoker = invoker; -exports.is = is; -exports.isEmpty = isEmpty; -exports.isNil = isNil; -exports.join = join; -exports.juxt = juxt; -exports.keys = keys; -exports.keysIn = keysIn; -exports.last = last; -exports.lastIndexOf = lastIndexOf; -exports.length = length; -exports.lens = lens; -exports.lensIndex = lensIndex; -exports.lensPath = lensPath; -exports.lensProp = lensProp; -exports.lift = lift; -exports.liftN = liftN; -exports.lt = lt; -exports.lte = lte; -exports.map = map; -exports.mapAccum = mapAccum; -exports.mapAccumRight = mapAccumRight; -exports.mapObjIndexed = mapObjIndexed; -exports.match = match; -exports.mathMod = mathMod; -exports.max = max; -exports.maxBy = maxBy; -exports.mean = mean; -exports.median = median; -exports.memoizeWith = memoizeWith; -exports.merge = merge; -exports.mergeAll = mergeAll; -exports.mergeDeepLeft = mergeDeepLeft; -exports.mergeDeepRight = mergeDeepRight; -exports.mergeDeepWith = mergeDeepWith; -exports.mergeDeepWithKey = mergeDeepWithKey; -exports.mergeLeft = mergeLeft; -exports.mergeRight = mergeRight; -exports.mergeWith = mergeWith; -exports.mergeWithKey = mergeWithKey; -exports.min = min; -exports.minBy = minBy; -exports.modulo = modulo; -exports.multiply = multiply; -exports.nAry = nAry; -exports.negate = negate; -exports.none = none; -exports.not = not; -exports.nth = nth; -exports.nthArg = nthArg; -exports.o = o; -exports.objOf = objOf; -exports.of = of; -exports.omit = omit; -exports.once = once; -exports.or = or; -exports.otherwise = otherwise; -exports.over = over; -exports.pair = pair; -exports.partial = partial; -exports.partialRight = partialRight; -exports.partition = partition; -exports.path = path; -exports.pathEq = pathEq; -exports.pathOr = pathOr; -exports.pathSatisfies = pathSatisfies; -exports.pick = pick; -exports.pickAll = pickAll; -exports.pickBy = pickBy; -exports.pipe = pipe; -exports.pipeK = pipeK; -exports.pipeP = pipeP; -exports.pipeWith = pipeWith; -exports.pluck = pluck; -exports.prepend = prepend; -exports.product = product; -exports.project = project; -exports.prop = prop; -exports.propEq = propEq; -exports.propIs = propIs; -exports.propOr = propOr; -exports.propSatisfies = propSatisfies; -exports.props = props; -exports.range = range; -exports.reduce = reduce; -exports.reduceBy = reduceBy; -exports.reduceRight = reduceRight; -exports.reduceWhile = reduceWhile; -exports.reduced = reduced; -exports.reject = reject; -exports.remove = remove; -exports.repeat = repeat; -exports.replace = replace; -exports.reverse = reverse; -exports.scan = scan; -exports.sequence = sequence; -exports.set = set; -exports.slice = slice; -exports.sort = sort; -exports.sortBy = sortBy; -exports.sortWith = sortWith; -exports.split = split; -exports.splitAt = splitAt; -exports.splitEvery = splitEvery; -exports.splitWhen = splitWhen; -exports.startsWith = startsWith; -exports.subtract = subtract; -exports.sum = sum; -exports.symmetricDifference = symmetricDifference; -exports.symmetricDifferenceWith = symmetricDifferenceWith; -exports.tail = tail; -exports.take = take; -exports.takeLast = takeLast; -exports.takeLastWhile = takeLastWhile; -exports.takeWhile = takeWhile; -exports.tap = tap; -exports.test = test; -exports.then = then; -exports.times = times; -exports.toLower = toLower; -exports.toPairs = toPairs; -exports.toPairsIn = toPairsIn; -exports.toString = toString$1; -exports.toUpper = toUpper; -exports.transduce = transduce; -exports.transpose = transpose; -exports.traverse = traverse; -exports.trim = trim; -exports.tryCatch = tryCatch; -exports.type = type; -exports.unapply = unapply; -exports.unary = unary; -exports.uncurryN = uncurryN; -exports.unfold = unfold; -exports.union = union; -exports.unionWith = unionWith; -exports.uniq = uniq; -exports.uniqBy = uniqBy; -exports.uniqWith = uniqWith; -exports.unless = unless; -exports.unnest = unnest; -exports.until = until; -exports.update = update; -exports.useWith = useWith; -exports.values = values; -exports.valuesIn = valuesIn; -exports.view = view; -exports.when = when; -exports.where = where; -exports.whereEq = whereEq; -exports.without = without; -exports.xprod = xprod; -exports.zip = zip; -exports.zipObj = zipObj; -exports.zipWith = zipWith; -exports.thunkify = thunkify; - -Object.defineProperty(exports, '__esModule', { value: true }); - -}))); From 98d6b76827ee437fc1cef7c14e0573aef41fdfab Mon Sep 17 00:00:00 2001 From: Tim Gates Date: Tue, 21 Apr 2020 06:37:18 +1000 Subject: [PATCH 031/111] Restore original file on request --- dist/ramda.js | 9568 +++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 9568 insertions(+) diff --git a/dist/ramda.js b/dist/ramda.js index e69de29bb2..02918c6ded 100644 --- a/dist/ramda.js +++ b/dist/ramda.js @@ -0,0 +1,9568 @@ +// Ramda v0.25.0 +// https://github.com/ramda/ramda +// (c) 2013-2018 Scott Sauyet, Michael Hurley, and David Chambers +// Ramda may be freely distributed under the MIT license. + +(function (global, factory) { + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : + typeof define === 'function' && define.amd ? define(['exports'], factory) : + (factory((global.R = {}))); +}(this, (function (exports) { 'use strict'; + +/** + * A function that always returns `false`. Any passed in parameters are ignored. + * + * @func + * @memberOf R + * @since v0.9.0 + * @category Function + * @sig * -> Boolean + * @param {*} + * @return {Boolean} + * @see R.T + * @example + * + * R.F(); //=> false + */ +var F = function() {return false;}; + +/** + * A function that always returns `true`. Any passed in parameters are ignored. + * + * @func + * @memberOf R + * @since v0.9.0 + * @category Function + * @sig * -> Boolean + * @param {*} + * @return {Boolean} + * @see R.F + * @example + * + * R.T(); //=> true + */ +var T = function() {return true;}; + +/** + * A special placeholder value used to specify "gaps" within curried functions, + * allowing partial application of any combination of arguments, regardless of + * their positions. + * + * If `g` is a curried ternary function and `_` is `R.__`, the following are + * equivalent: + * + * - `g(1, 2, 3)` + * - `g(_, 2, 3)(1)` + * - `g(_, _, 3)(1)(2)` + * - `g(_, _, 3)(1, 2)` + * - `g(_, 2, _)(1, 3)` + * - `g(_, 2)(1)(3)` + * - `g(_, 2)(1, 3)` + * - `g(_, 2)(_, 3)(1)` + * + * @name __ + * @constant + * @memberOf R + * @since v0.6.0 + * @category Function + * @example + * + * const greet = R.replace('{name}', R.__, 'Hello, {name}!'); + * greet('Alice'); //=> 'Hello, Alice!' + */ +var __ = {'@@functional/placeholder': true}; + +function _isPlaceholder(a) { + return a != null && + typeof a === 'object' && + a['@@functional/placeholder'] === true; +} + +/** + * Optimized internal one-arity curry function. + * + * @private + * @category Function + * @param {Function} fn The function to curry. + * @return {Function} The curried function. + */ +function _curry1(fn) { + return function f1(a) { + if (arguments.length === 0 || _isPlaceholder(a)) { + return f1; + } else { + return fn.apply(this, arguments); + } + }; +} + +/** + * Optimized internal two-arity curry function. + * + * @private + * @category Function + * @param {Function} fn The function to curry. + * @return {Function} The curried function. + */ +function _curry2(fn) { + return function f2(a, b) { + switch (arguments.length) { + case 0: + return f2; + case 1: + return _isPlaceholder(a) ? f2 + : _curry1(function(_b) { return fn(a, _b); }); + default: + return _isPlaceholder(a) && _isPlaceholder(b) ? f2 + : _isPlaceholder(a) ? _curry1(function(_a) { return fn(_a, b); }) + : _isPlaceholder(b) ? _curry1(function(_b) { return fn(a, _b); }) + : fn(a, b); + } + }; +} + +/** + * Adds two values. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Math + * @sig Number -> Number -> Number + * @param {Number} a + * @param {Number} b + * @return {Number} + * @see R.subtract + * @example + * + * R.add(2, 3); //=> 5 + * R.add(7)(10); //=> 17 + */ +var add = _curry2(function add(a, b) { + return Number(a) + Number(b); +}); + +/** + * Private `concat` function to merge two array-like objects. + * + * @private + * @param {Array|Arguments} [set1=[]] An array-like object. + * @param {Array|Arguments} [set2=[]] An array-like object. + * @return {Array} A new, merged array. + * @example + * + * _concat([4, 5, 6], [1, 2, 3]); //=> [4, 5, 6, 1, 2, 3] + */ +function _concat(set1, set2) { + set1 = set1 || []; + set2 = set2 || []; + var idx; + var len1 = set1.length; + var len2 = set2.length; + var result = []; + + idx = 0; + while (idx < len1) { + result[result.length] = set1[idx]; + idx += 1; + } + idx = 0; + while (idx < len2) { + result[result.length] = set2[idx]; + idx += 1; + } + return result; +} + +function _arity(n, fn) { + /* eslint-disable no-unused-vars */ + switch (n) { + case 0: return function() { return fn.apply(this, arguments); }; + case 1: return function(a0) { return fn.apply(this, arguments); }; + case 2: return function(a0, a1) { return fn.apply(this, arguments); }; + case 3: return function(a0, a1, a2) { return fn.apply(this, arguments); }; + case 4: return function(a0, a1, a2, a3) { return fn.apply(this, arguments); }; + case 5: return function(a0, a1, a2, a3, a4) { return fn.apply(this, arguments); }; + case 6: return function(a0, a1, a2, a3, a4, a5) { return fn.apply(this, arguments); }; + case 7: return function(a0, a1, a2, a3, a4, a5, a6) { return fn.apply(this, arguments); }; + case 8: return function(a0, a1, a2, a3, a4, a5, a6, a7) { return fn.apply(this, arguments); }; + case 9: return function(a0, a1, a2, a3, a4, a5, a6, a7, a8) { return fn.apply(this, arguments); }; + case 10: return function(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9) { return fn.apply(this, arguments); }; + default: throw new Error('First argument to _arity must be a non-negative integer no greater than ten'); + } +} + +/** + * Internal curryN function. + * + * @private + * @category Function + * @param {Number} length The arity of the curried function. + * @param {Array} received An array of arguments received thus far. + * @param {Function} fn The function to curry. + * @return {Function} The curried function. + */ +function _curryN(length, received, fn) { + return function() { + var combined = []; + var argsIdx = 0; + var left = length; + var combinedIdx = 0; + while (combinedIdx < received.length || argsIdx < arguments.length) { + var result; + if (combinedIdx < received.length && + (!_isPlaceholder(received[combinedIdx]) || + argsIdx >= arguments.length)) { + result = received[combinedIdx]; + } else { + result = arguments[argsIdx]; + argsIdx += 1; + } + combined[combinedIdx] = result; + if (!_isPlaceholder(result)) { + left -= 1; + } + combinedIdx += 1; + } + return left <= 0 ? fn.apply(this, combined) + : _arity(left, _curryN(length, combined, fn)); + }; +} + +/** + * Returns a curried equivalent of the provided function, with the specified + * arity. The curried function has two unusual capabilities. First, its + * arguments needn't be provided one at a time. If `g` is `R.curryN(3, f)`, the + * following are equivalent: + * + * - `g(1)(2)(3)` + * - `g(1)(2, 3)` + * - `g(1, 2)(3)` + * - `g(1, 2, 3)` + * + * Secondly, the special placeholder value [`R.__`](#__) may be used to specify + * "gaps", allowing partial application of any combination of arguments, + * regardless of their positions. If `g` is as above and `_` is [`R.__`](#__), + * the following are equivalent: + * + * - `g(1, 2, 3)` + * - `g(_, 2, 3)(1)` + * - `g(_, _, 3)(1)(2)` + * - `g(_, _, 3)(1, 2)` + * - `g(_, 2)(1)(3)` + * - `g(_, 2)(1, 3)` + * - `g(_, 2)(_, 3)(1)` + * + * @func + * @memberOf R + * @since v0.5.0 + * @category Function + * @sig Number -> (* -> a) -> (* -> a) + * @param {Number} length The arity for the returned function. + * @param {Function} fn The function to curry. + * @return {Function} A new, curried function. + * @see R.curry + * @example + * + * const sumArgs = (...args) => R.sum(args); + * + * const curriedAddFourNumbers = R.curryN(4, sumArgs); + * const f = curriedAddFourNumbers(1, 2); + * const g = f(3); + * g(4); //=> 10 + */ +var curryN = _curry2(function curryN(length, fn) { + if (length === 1) { + return _curry1(fn); + } + return _arity(length, _curryN(length, [], fn)); +}); + +/** + * Creates a new list iteration function from an existing one by adding two new + * parameters to its callback function: the current index, and the entire list. + * + * This would turn, for instance, [`R.map`](#map) function into one that + * more closely resembles `Array.prototype.map`. Note that this will only work + * for functions in which the iteration callback function is the first + * parameter, and where the list is the last parameter. (This latter might be + * unimportant if the list parameter is not used.) + * + * @func + * @memberOf R + * @since v0.15.0 + * @category Function + * @category List + * @sig ((a ... -> b) ... -> [a] -> *) -> ((a ..., Int, [a] -> b) ... -> [a] -> *) + * @param {Function} fn A list iteration function that does not pass index or list to its callback + * @return {Function} An altered list iteration function that passes (item, index, list) to its callback + * @example + * + * const mapIndexed = R.addIndex(R.map); + * mapIndexed((val, idx) => idx + '-' + val, ['f', 'o', 'o', 'b', 'a', 'r']); + * //=> ['0-f', '1-o', '2-o', '3-b', '4-a', '5-r'] + */ +var addIndex = _curry1(function addIndex(fn) { + return curryN(fn.length, function() { + var idx = 0; + var origFn = arguments[0]; + var list = arguments[arguments.length - 1]; + var args = Array.prototype.slice.call(arguments, 0); + args[0] = function() { + var result = origFn.apply(this, _concat(arguments, [idx, list])); + idx += 1; + return result; + }; + return fn.apply(this, args); + }); +}); + +/** + * Optimized internal three-arity curry function. + * + * @private + * @category Function + * @param {Function} fn The function to curry. + * @return {Function} The curried function. + */ +function _curry3(fn) { + return function f3(a, b, c) { + switch (arguments.length) { + case 0: + return f3; + case 1: + return _isPlaceholder(a) ? f3 + : _curry2(function(_b, _c) { return fn(a, _b, _c); }); + case 2: + return _isPlaceholder(a) && _isPlaceholder(b) ? f3 + : _isPlaceholder(a) ? _curry2(function(_a, _c) { return fn(_a, b, _c); }) + : _isPlaceholder(b) ? _curry2(function(_b, _c) { return fn(a, _b, _c); }) + : _curry1(function(_c) { return fn(a, b, _c); }); + default: + return _isPlaceholder(a) && _isPlaceholder(b) && _isPlaceholder(c) ? f3 + : _isPlaceholder(a) && _isPlaceholder(b) ? _curry2(function(_a, _b) { return fn(_a, _b, c); }) + : _isPlaceholder(a) && _isPlaceholder(c) ? _curry2(function(_a, _c) { return fn(_a, b, _c); }) + : _isPlaceholder(b) && _isPlaceholder(c) ? _curry2(function(_b, _c) { return fn(a, _b, _c); }) + : _isPlaceholder(a) ? _curry1(function(_a) { return fn(_a, b, c); }) + : _isPlaceholder(b) ? _curry1(function(_b) { return fn(a, _b, c); }) + : _isPlaceholder(c) ? _curry1(function(_c) { return fn(a, b, _c); }) + : fn(a, b, c); + } + }; +} + +/** + * Applies a function to the value at the given index of an array, returning a + * new copy of the array with the element at the given index replaced with the + * result of the function application. + * + * @func + * @memberOf R + * @since v0.14.0 + * @category List + * @sig Number -> (a -> a) -> [a] -> [a] + * @param {Number} idx The index. + * @param {Function} fn The function to apply. + * @param {Array|Arguments} list An array-like object whose value + * at the supplied index will be replaced. + * @return {Array} A copy of the supplied array-like object with + * the element at index `idx` replaced with the value + * returned by applying `fn` to the existing element. + * @see R.update + * @example + * + * R.adjust(1, R.toUpper, ['a', 'b', 'c', 'd']); //=> ['a', 'B', 'c', 'd'] + * R.adjust(-1, R.toUpper, ['a', 'b', 'c', 'd']); //=> ['a', 'b', 'c', 'D'] + * @symb R.adjust(-1, f, [a, b]) = [a, f(b)] + * @symb R.adjust(0, f, [a, b]) = [f(a), b] + */ +var adjust = _curry3(function adjust(idx, fn, list) { + if (idx >= list.length || idx < -list.length) { + return list; + } + var start = idx < 0 ? list.length : 0; + var _idx = start + idx; + var _list = _concat(list); + _list[_idx] = fn(list[_idx]); + return _list; +}); + +/** + * Tests whether or not an object is an array. + * + * @private + * @param {*} val The object to test. + * @return {Boolean} `true` if `val` is an array, `false` otherwise. + * @example + * + * _isArray([]); //=> true + * _isArray(null); //=> false + * _isArray({}); //=> false + */ +var _isArray = Array.isArray || function _isArray(val) { + return (val != null && + val.length >= 0 && + Object.prototype.toString.call(val) === '[object Array]'); +}; + +function _isTransformer(obj) { + return obj != null && typeof obj['@@transducer/step'] === 'function'; +} + +/** + * Returns a function that dispatches with different strategies based on the + * object in list position (last argument). If it is an array, executes [fn]. + * Otherwise, if it has a function with one of the given method names, it will + * execute that function (functor case). Otherwise, if it is a transformer, + * uses transducer [xf] to return a new transformer (transducer case). + * Otherwise, it will default to executing [fn]. + * + * @private + * @param {Array} methodNames properties to check for a custom implementation + * @param {Function} xf transducer to initialize if object is transformer + * @param {Function} fn default ramda implementation + * @return {Function} A function that dispatches on object in list position + */ +function _dispatchable(methodNames, xf, fn) { + return function() { + if (arguments.length === 0) { + return fn(); + } + var args = Array.prototype.slice.call(arguments, 0); + var obj = args.pop(); + if (!_isArray(obj)) { + var idx = 0; + while (idx < methodNames.length) { + if (typeof obj[methodNames[idx]] === 'function') { + return obj[methodNames[idx]].apply(obj, args); + } + idx += 1; + } + if (_isTransformer(obj)) { + var transducer = xf.apply(null, args); + return transducer(obj); + } + } + return fn.apply(this, arguments); + }; +} + +function _reduced(x) { + return x && x['@@transducer/reduced'] ? x : + { + '@@transducer/value': x, + '@@transducer/reduced': true + }; +} + +var _xfBase = { + init: function() { + return this.xf['@@transducer/init'](); + }, + result: function(result) { + return this.xf['@@transducer/result'](result); + } +}; + +function XAll(f, xf) { + this.xf = xf; + this.f = f; + this.all = true; +} +XAll.prototype['@@transducer/init'] = _xfBase.init; +XAll.prototype['@@transducer/result'] = function(result) { + if (this.all) { + result = this.xf['@@transducer/step'](result, true); + } + return this.xf['@@transducer/result'](result); +}; +XAll.prototype['@@transducer/step'] = function(result, input) { + if (!this.f(input)) { + this.all = false; + result = _reduced(this.xf['@@transducer/step'](result, false)); + } + return result; +}; + +var _xall = _curry2(function _xall(f, xf) { return new XAll(f, xf); }); + +/** + * Returns `true` if all elements of the list match the predicate, `false` if + * there are any that don't. + * + * Dispatches to the `all` method of the second argument, if present. + * + * Acts as a transducer if a transformer is given in list position. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category List + * @sig (a -> Boolean) -> [a] -> Boolean + * @param {Function} fn The predicate function. + * @param {Array} list The array to consider. + * @return {Boolean} `true` if the predicate is satisfied by every element, `false` + * otherwise. + * @see R.any, R.none, R.transduce + * @example + * + * const equals3 = R.equals(3); + * R.all(equals3)([3, 3, 3, 3]); //=> true + * R.all(equals3)([3, 3, 1, 3]); //=> false + */ +var all = _curry2(_dispatchable(['all'], _xall, function all(fn, list) { + var idx = 0; + while (idx < list.length) { + if (!fn(list[idx])) { + return false; + } + idx += 1; + } + return true; +})); + +/** + * Returns the larger of its two arguments. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Relation + * @sig Ord a => a -> a -> a + * @param {*} a + * @param {*} b + * @return {*} + * @see R.maxBy, R.min + * @example + * + * R.max(789, 123); //=> 789 + * R.max('a', 'b'); //=> 'b' + */ +var max = _curry2(function max(a, b) { return b > a ? b : a; }); + +function _map(fn, functor) { + var idx = 0; + var len = functor.length; + var result = Array(len); + while (idx < len) { + result[idx] = fn(functor[idx]); + idx += 1; + } + return result; +} + +function _isString(x) { + return Object.prototype.toString.call(x) === '[object String]'; +} + +/** + * Tests whether or not an object is similar to an array. + * + * @private + * @category Type + * @category List + * @sig * -> Boolean + * @param {*} x The object to test. + * @return {Boolean} `true` if `x` has a numeric length property and extreme indices defined; `false` otherwise. + * @example + * + * _isArrayLike([]); //=> true + * _isArrayLike(true); //=> false + * _isArrayLike({}); //=> false + * _isArrayLike({length: 10}); //=> false + * _isArrayLike({0: 'zero', 9: 'nine', length: 10}); //=> true + */ +var _isArrayLike = _curry1(function isArrayLike(x) { + if (_isArray(x)) { return true; } + if (!x) { return false; } + if (typeof x !== 'object') { return false; } + if (_isString(x)) { return false; } + if (x.nodeType === 1) { return !!x.length; } + if (x.length === 0) { return true; } + if (x.length > 0) { + return x.hasOwnProperty(0) && x.hasOwnProperty(x.length - 1); + } + return false; +}); + +function XWrap(fn) { + this.f = fn; +} +XWrap.prototype['@@transducer/init'] = function() { + throw new Error('init not implemented on XWrap'); +}; +XWrap.prototype['@@transducer/result'] = function(acc) { return acc; }; +XWrap.prototype['@@transducer/step'] = function(acc, x) { + return this.f(acc, x); +}; + +function _xwrap(fn) { return new XWrap(fn); } + +/** + * Creates a function that is bound to a context. + * Note: `R.bind` does not provide the additional argument-binding capabilities of + * [Function.prototype.bind](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind). + * + * @func + * @memberOf R + * @since v0.6.0 + * @category Function + * @category Object + * @sig (* -> *) -> {*} -> (* -> *) + * @param {Function} fn The function to bind to context + * @param {Object} thisObj The context to bind `fn` to + * @return {Function} A function that will execute in the context of `thisObj`. + * @see R.partial + * @example + * + * const log = R.bind(console.log, console); + * R.pipe(R.assoc('a', 2), R.tap(log), R.assoc('a', 3))({a: 1}); //=> {a: 3} + * // logs {a: 2} + * @symb R.bind(f, o)(a, b) = f.call(o, a, b) + */ +var bind = _curry2(function bind(fn, thisObj) { + return _arity(fn.length, function() { + return fn.apply(thisObj, arguments); + }); +}); + +function _arrayReduce(xf, acc, list) { + var idx = 0; + var len = list.length; + while (idx < len) { + acc = xf['@@transducer/step'](acc, list[idx]); + if (acc && acc['@@transducer/reduced']) { + acc = acc['@@transducer/value']; + break; + } + idx += 1; + } + return xf['@@transducer/result'](acc); +} + +function _iterableReduce(xf, acc, iter) { + var step = iter.next(); + while (!step.done) { + acc = xf['@@transducer/step'](acc, step.value); + if (acc && acc['@@transducer/reduced']) { + acc = acc['@@transducer/value']; + break; + } + step = iter.next(); + } + return xf['@@transducer/result'](acc); +} + +function _methodReduce(xf, acc, obj, methodName) { + return xf['@@transducer/result'](obj[methodName](bind(xf['@@transducer/step'], xf), acc)); +} + +var symIterator = (typeof Symbol !== 'undefined') ? Symbol.iterator : '@@iterator'; + +function _reduce(fn, acc, list) { + if (typeof fn === 'function') { + fn = _xwrap(fn); + } + if (_isArrayLike(list)) { + return _arrayReduce(fn, acc, list); + } + if (typeof list['fantasy-land/reduce'] === 'function') { + return _methodReduce(fn, acc, list, 'fantasy-land/reduce'); + } + if (list[symIterator] != null) { + return _iterableReduce(fn, acc, list[symIterator]()); + } + if (typeof list.next === 'function') { + return _iterableReduce(fn, acc, list); + } + if (typeof list.reduce === 'function') { + return _methodReduce(fn, acc, list, 'reduce'); + } + + throw new TypeError('reduce: list must be array or iterable'); +} + +function XMap(f, xf) { + this.xf = xf; + this.f = f; +} +XMap.prototype['@@transducer/init'] = _xfBase.init; +XMap.prototype['@@transducer/result'] = _xfBase.result; +XMap.prototype['@@transducer/step'] = function(result, input) { + return this.xf['@@transducer/step'](result, this.f(input)); +}; + +var _xmap = _curry2(function _xmap(f, xf) { return new XMap(f, xf); }); + +function _has(prop, obj) { + return Object.prototype.hasOwnProperty.call(obj, prop); +} + +var toString = Object.prototype.toString; +var _isArguments = (function() { + return toString.call(arguments) === '[object Arguments]' ? + function _isArguments(x) { return toString.call(x) === '[object Arguments]'; } : + function _isArguments(x) { return _has('callee', x); }; +}()); + +// cover IE < 9 keys issues +var hasEnumBug = !({toString: null}).propertyIsEnumerable('toString'); +var nonEnumerableProps = ['constructor', 'valueOf', 'isPrototypeOf', 'toString', + 'propertyIsEnumerable', 'hasOwnProperty', 'toLocaleString']; +// Safari bug +var hasArgsEnumBug = (function() { + 'use strict'; + return arguments.propertyIsEnumerable('length'); +}()); + +var contains = function contains(list, item) { + var idx = 0; + while (idx < list.length) { + if (list[idx] === item) { + return true; + } + idx += 1; + } + return false; +}; + +/** + * Returns a list containing the names of all the enumerable own properties of + * the supplied object. + * Note that the order of the output array is not guaranteed to be consistent + * across different JS platforms. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Object + * @sig {k: v} -> [k] + * @param {Object} obj The object to extract properties from + * @return {Array} An array of the object's own properties. + * @see R.keysIn, R.values + * @example + * + * R.keys({a: 1, b: 2, c: 3}); //=> ['a', 'b', 'c'] + */ +var keys = typeof Object.keys === 'function' && !hasArgsEnumBug ? + _curry1(function keys(obj) { + return Object(obj) !== obj ? [] : Object.keys(obj); + }) : + _curry1(function keys(obj) { + if (Object(obj) !== obj) { + return []; + } + var prop, nIdx; + var ks = []; + var checkArgsLength = hasArgsEnumBug && _isArguments(obj); + for (prop in obj) { + if (_has(prop, obj) && (!checkArgsLength || prop !== 'length')) { + ks[ks.length] = prop; + } + } + if (hasEnumBug) { + nIdx = nonEnumerableProps.length - 1; + while (nIdx >= 0) { + prop = nonEnumerableProps[nIdx]; + if (_has(prop, obj) && !contains(ks, prop)) { + ks[ks.length] = prop; + } + nIdx -= 1; + } + } + return ks; + }); + +/** + * Takes a function and + * a [functor](https://github.com/fantasyland/fantasy-land#functor), + * applies the function to each of the functor's values, and returns + * a functor of the same shape. + * + * Ramda provides suitable `map` implementations for `Array` and `Object`, + * so this function may be applied to `[1, 2, 3]` or `{x: 1, y: 2, z: 3}`. + * + * Dispatches to the `map` method of the second argument, if present. + * + * Acts as a transducer if a transformer is given in list position. + * + * Also treats functions as functors and will compose them together. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category List + * @sig Functor f => (a -> b) -> f a -> f b + * @param {Function} fn The function to be called on every element of the input `list`. + * @param {Array} list The list to be iterated over. + * @return {Array} The new list. + * @see R.transduce, R.addIndex + * @example + * + * const double = x => x * 2; + * + * R.map(double, [1, 2, 3]); //=> [2, 4, 6] + * + * R.map(double, {x: 1, y: 2, z: 3}); //=> {x: 2, y: 4, z: 6} + * @symb R.map(f, [a, b]) = [f(a), f(b)] + * @symb R.map(f, { x: a, y: b }) = { x: f(a), y: f(b) } + * @symb R.map(f, functor_o) = functor_o.map(f) + */ +var map = _curry2(_dispatchable(['fantasy-land/map', 'map'], _xmap, function map(fn, functor) { + switch (Object.prototype.toString.call(functor)) { + case '[object Function]': + return curryN(functor.length, function() { + return fn.call(this, functor.apply(this, arguments)); + }); + case '[object Object]': + return _reduce(function(acc, key) { + acc[key] = fn(functor[key]); + return acc; + }, {}, keys(functor)); + default: + return _map(fn, functor); + } +})); + +/** + * Retrieve the value at a given path. + * + * @func + * @memberOf R + * @since v0.2.0 + * @category Object + * @typedefn Idx = String | Int + * @sig [Idx] -> {a} -> a | Undefined + * @param {Array} path The path to use. + * @param {Object} obj The object to retrieve the nested property from. + * @return {*} The data at `path`. + * @see R.prop + * @example + * + * R.path(['a', 'b'], {a: {b: 2}}); //=> 2 + * R.path(['a', 'b'], {c: {b: 2}}); //=> undefined + */ +var path = _curry2(function path(paths, obj) { + var val = obj; + var idx = 0; + while (idx < paths.length) { + if (val == null) { + return; + } + val = val[paths[idx]]; + idx += 1; + } + return val; +}); + +/** + * Returns a function that when supplied an object returns the indicated + * property of that object, if it exists. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Object + * @sig s -> {s: a} -> a | Undefined + * @param {String} p The property name + * @param {Object} obj The object to query + * @return {*} The value at `obj.p`. + * @see R.path + * @example + * + * R.prop('x', {x: 100}); //=> 100 + * R.prop('x', {}); //=> undefined + * R.compose(R.inc, R.prop('x'))({ x: 3 }) //=> 4 + */ + +var prop = _curry2(function prop(p, obj) { return path([p], obj); }); + +/** + * Returns a new list by plucking the same named property off all objects in + * the list supplied. + * + * `pluck` will work on + * any [functor](https://github.com/fantasyland/fantasy-land#functor) in + * addition to arrays, as it is equivalent to `R.map(R.prop(k), f)`. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category List + * @sig Functor f => k -> f {k: v} -> f v + * @param {Number|String} key The key name to pluck off of each object. + * @param {Array} f The array or functor to consider. + * @return {Array} The list of values for the given key. + * @see R.props + * @example + * + * var getAges = R.pluck('age'); + * getAges([{name: 'fred', age: 29}, {name: 'wilma', age: 27}]); //=> [29, 27] + * + * R.pluck(0, [[1, 2], [3, 4]]); //=> [1, 3] + * R.pluck('val', {a: {val: 3}, b: {val: 5}}); //=> {a: 3, b: 5} + * @symb R.pluck('x', [{x: 1, y: 2}, {x: 3, y: 4}, {x: 5, y: 6}]) = [1, 3, 5] + * @symb R.pluck(0, [[1, 2], [3, 4], [5, 6]]) = [1, 3, 5] + */ +var pluck = _curry2(function pluck(p, list) { + return map(prop(p), list); +}); + +/** + * Returns a single item by iterating through the list, successively calling + * the iterator function and passing it an accumulator value and the current + * value from the array, and then passing the result to the next call. + * + * The iterator function receives two values: *(acc, value)*. It may use + * [`R.reduced`](#reduced) to shortcut the iteration. + * + * The arguments' order of [`reduceRight`](#reduceRight)'s iterator function + * is *(value, acc)*. + * + * Note: `R.reduce` does not skip deleted or unassigned indices (sparse + * arrays), unlike the native `Array.prototype.reduce` method. For more details + * on this behavior, see: + * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce#Description + * + * Dispatches to the `reduce` method of the third argument, if present. When + * doing so, it is up to the user to handle the [`R.reduced`](#reduced) + * shortcuting, as this is not implemented by `reduce`. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category List + * @sig ((a, b) -> a) -> a -> [b] -> a + * @param {Function} fn The iterator function. Receives two values, the accumulator and the + * current element from the array. + * @param {*} acc The accumulator value. + * @param {Array} list The list to iterate over. + * @return {*} The final, accumulated value. + * @see R.reduced, R.addIndex, R.reduceRight + * @example + * + * R.reduce(R.subtract, 0, [1, 2, 3, 4]) // => ((((0 - 1) - 2) - 3) - 4) = -10 + * // - -10 + * // / \ / \ + * // - 4 -6 4 + * // / \ / \ + * // - 3 ==> -3 3 + * // / \ / \ + * // - 2 -1 2 + * // / \ / \ + * // 0 1 0 1 + * + * @symb R.reduce(f, a, [b, c, d]) = f(f(f(a, b), c), d) + */ +var reduce = _curry3(_reduce); + +/** + * Takes a list of predicates and returns a predicate that returns true for a + * given list of arguments if every one of the provided predicates is satisfied + * by those arguments. + * + * The function returned is a curried function whose arity matches that of the + * highest-arity predicate. + * + * @func + * @memberOf R + * @since v0.9.0 + * @category Logic + * @sig [(*... -> Boolean)] -> (*... -> Boolean) + * @param {Array} predicates An array of predicates to check + * @return {Function} The combined predicate + * @see R.anyPass + * @example + * + * const isQueen = R.propEq('rank', 'Q'); + * const isSpade = R.propEq('suit', '♠︎'); + * const isQueenOfSpades = R.allPass([isQueen, isSpade]); + * + * isQueenOfSpades({rank: 'Q', suit: '♣︎'}); //=> false + * isQueenOfSpades({rank: 'Q', suit: '♠︎'}); //=> true + */ +var allPass = _curry1(function allPass(preds) { + return curryN(reduce(max, 0, pluck('length', preds)), function() { + var idx = 0; + var len = preds.length; + while (idx < len) { + if (!preds[idx].apply(this, arguments)) { + return false; + } + idx += 1; + } + return true; + }); +}); + +/** + * Returns a function that always returns the given value. Note that for + * non-primitives the value returned is a reference to the original value. + * + * This function is known as `const`, `constant`, or `K` (for K combinator) in + * other languages and libraries. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Function + * @sig a -> (* -> a) + * @param {*} val The value to wrap in a function + * @return {Function} A Function :: * -> val. + * @example + * + * const t = R.always('Tee'); + * t(); //=> 'Tee' + */ +var always = _curry1(function always(val) { + return function() { + return val; + }; +}); + +/** + * Returns `true` if both arguments are `true`; `false` otherwise. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Logic + * @sig a -> b -> a | b + * @param {Any} a + * @param {Any} b + * @return {Any} the first argument if it is falsy, otherwise the second argument. + * @see R.both + * @example + * + * R.and(true, true); //=> true + * R.and(true, false); //=> false + * R.and(false, true); //=> false + * R.and(false, false); //=> false + */ +var and = _curry2(function and(a, b) { + return a && b; +}); + +function XAny(f, xf) { + this.xf = xf; + this.f = f; + this.any = false; +} +XAny.prototype['@@transducer/init'] = _xfBase.init; +XAny.prototype['@@transducer/result'] = function(result) { + if (!this.any) { + result = this.xf['@@transducer/step'](result, false); + } + return this.xf['@@transducer/result'](result); +}; +XAny.prototype['@@transducer/step'] = function(result, input) { + if (this.f(input)) { + this.any = true; + result = _reduced(this.xf['@@transducer/step'](result, true)); + } + return result; +}; + +var _xany = _curry2(function _xany(f, xf) { return new XAny(f, xf); }); + +/** + * Returns `true` if at least one of the elements of the list match the predicate, + * `false` otherwise. + * + * Dispatches to the `any` method of the second argument, if present. + * + * Acts as a transducer if a transformer is given in list position. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category List + * @sig (a -> Boolean) -> [a] -> Boolean + * @param {Function} fn The predicate function. + * @param {Array} list The array to consider. + * @return {Boolean} `true` if the predicate is satisfied by at least one element, `false` + * otherwise. + * @see R.all, R.none, R.transduce + * @example + * + * const lessThan0 = R.flip(R.lt)(0); + * const lessThan2 = R.flip(R.lt)(2); + * R.any(lessThan0)([1, 2]); //=> false + * R.any(lessThan2)([1, 2]); //=> true + */ +var any = _curry2(_dispatchable(['any'], _xany, function any(fn, list) { + var idx = 0; + while (idx < list.length) { + if (fn(list[idx])) { + return true; + } + idx += 1; + } + return false; +})); + +/** + * Takes a list of predicates and returns a predicate that returns true for a + * given list of arguments if at least one of the provided predicates is + * satisfied by those arguments. + * + * The function returned is a curried function whose arity matches that of the + * highest-arity predicate. + * + * @func + * @memberOf R + * @since v0.9.0 + * @category Logic + * @sig [(*... -> Boolean)] -> (*... -> Boolean) + * @param {Array} predicates An array of predicates to check + * @return {Function} The combined predicate + * @see R.allPass + * @example + * + * const isClub = R.propEq('suit', '♣'); + * const isSpade = R.propEq('suit', '♠'); + * const isBlackCard = R.anyPass([isClub, isSpade]); + * + * isBlackCard({rank: '10', suit: '♣'}); //=> true + * isBlackCard({rank: 'Q', suit: '♠'}); //=> true + * isBlackCard({rank: 'Q', suit: '♦'}); //=> false + */ +var anyPass = _curry1(function anyPass(preds) { + return curryN(reduce(max, 0, pluck('length', preds)), function() { + var idx = 0; + var len = preds.length; + while (idx < len) { + if (preds[idx].apply(this, arguments)) { + return true; + } + idx += 1; + } + return false; + }); +}); + +/** + * ap applies a list of functions to a list of values. + * + * Dispatches to the `ap` method of the second argument, if present. Also + * treats curried functions as applicatives. + * + * @func + * @memberOf R + * @since v0.3.0 + * @category Function + * @sig [a -> b] -> [a] -> [b] + * @sig Apply f => f (a -> b) -> f a -> f b + * @sig (r -> a -> b) -> (r -> a) -> (r -> b) + * @param {*} applyF + * @param {*} applyX + * @return {*} + * @example + * + * R.ap([R.multiply(2), R.add(3)], [1,2,3]); //=> [2, 4, 6, 4, 5, 6] + * R.ap([R.concat('tasty '), R.toUpper], ['pizza', 'salad']); //=> ["tasty pizza", "tasty salad", "PIZZA", "SALAD"] + * + * // R.ap can also be used as S combinator + * // when only two functions are passed + * R.ap(R.concat, R.toUpper)('Ramda') //=> 'RamdaRAMDA' + * @symb R.ap([f, g], [a, b]) = [f(a), f(b), g(a), g(b)] + */ +var ap = _curry2(function ap(applyF, applyX) { + return ( + typeof applyX['fantasy-land/ap'] === 'function' ? + applyX['fantasy-land/ap'](applyF) : + typeof applyF.ap === 'function' ? + applyF.ap(applyX) : + typeof applyF === 'function' ? + function(x) { return applyF(x)(applyX(x)); } : + // else + _reduce(function(acc, f) { return _concat(acc, map(f, applyX)); }, [], applyF) + ); +}); + +function _aperture(n, list) { + var idx = 0; + var limit = list.length - (n - 1); + var acc = new Array(limit >= 0 ? limit : 0); + while (idx < limit) { + acc[idx] = Array.prototype.slice.call(list, idx, idx + n); + idx += 1; + } + return acc; +} + +function XAperture(n, xf) { + this.xf = xf; + this.pos = 0; + this.full = false; + this.acc = new Array(n); +} +XAperture.prototype['@@transducer/init'] = _xfBase.init; +XAperture.prototype['@@transducer/result'] = function(result) { + this.acc = null; + return this.xf['@@transducer/result'](result); +}; +XAperture.prototype['@@transducer/step'] = function(result, input) { + this.store(input); + return this.full ? this.xf['@@transducer/step'](result, this.getCopy()) : result; +}; +XAperture.prototype.store = function(input) { + this.acc[this.pos] = input; + this.pos += 1; + if (this.pos === this.acc.length) { + this.pos = 0; + this.full = true; + } +}; +XAperture.prototype.getCopy = function() { + return _concat(Array.prototype.slice.call(this.acc, this.pos), + Array.prototype.slice.call(this.acc, 0, this.pos)); +}; + +var _xaperture = _curry2(function _xaperture(n, xf) { return new XAperture(n, xf); }); + +/** + * Returns a new list, composed of n-tuples of consecutive elements. If `n` is + * greater than the length of the list, an empty list is returned. + * + * Acts as a transducer if a transformer is given in list position. + * + * @func + * @memberOf R + * @since v0.12.0 + * @category List + * @sig Number -> [a] -> [[a]] + * @param {Number} n The size of the tuples to create + * @param {Array} list The list to split into `n`-length tuples + * @return {Array} The resulting list of `n`-length tuples + * @see R.transduce + * @example + * + * R.aperture(2, [1, 2, 3, 4, 5]); //=> [[1, 2], [2, 3], [3, 4], [4, 5]] + * R.aperture(3, [1, 2, 3, 4, 5]); //=> [[1, 2, 3], [2, 3, 4], [3, 4, 5]] + * R.aperture(7, [1, 2, 3, 4, 5]); //=> [] + */ +var aperture = _curry2(_dispatchable([], _xaperture, _aperture)); + +/** + * Returns a new list containing the contents of the given list, followed by + * the given element. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category List + * @sig a -> [a] -> [a] + * @param {*} el The element to add to the end of the new list. + * @param {Array} list The list of elements to add a new item to. + * list. + * @return {Array} A new list containing the elements of the old list followed by `el`. + * @see R.prepend + * @example + * + * R.append('tests', ['write', 'more']); //=> ['write', 'more', 'tests'] + * R.append('tests', []); //=> ['tests'] + * R.append(['tests'], ['write', 'more']); //=> ['write', 'more', ['tests']] + */ +var append = _curry2(function append(el, list) { + return _concat(list, [el]); +}); + +/** + * Applies function `fn` to the argument list `args`. This is useful for + * creating a fixed-arity function from a variadic function. `fn` should be a + * bound function if context is significant. + * + * @func + * @memberOf R + * @since v0.7.0 + * @category Function + * @sig (*... -> a) -> [*] -> a + * @param {Function} fn The function which will be called with `args` + * @param {Array} args The arguments to call `fn` with + * @return {*} result The result, equivalent to `fn(...args)` + * @see R.call, R.unapply + * @example + * + * const nums = [1, 2, 3, -99, 42, 6, 7]; + * R.apply(Math.max, nums); //=> 42 + * @symb R.apply(f, [a, b, c]) = f(a, b, c) + */ +var apply = _curry2(function apply(fn, args) { + return fn.apply(this, args); +}); + +/** + * Returns a list of all the enumerable own properties of the supplied object. + * Note that the order of the output array is not guaranteed across different + * JS platforms. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Object + * @sig {k: v} -> [v] + * @param {Object} obj The object to extract values from + * @return {Array} An array of the values of the object's own properties. + * @see R.valuesIn, R.keys + * @example + * + * R.values({a: 1, b: 2, c: 3}); //=> [1, 2, 3] + */ +var values = _curry1(function values(obj) { + var props = keys(obj); + var len = props.length; + var vals = []; + var idx = 0; + while (idx < len) { + vals[idx] = obj[props[idx]]; + idx += 1; + } + return vals; +}); + +// Use custom mapValues function to avoid issues with specs that include a "map" key and R.map +// delegating calls to .map +function mapValues(fn, obj) { + return keys(obj).reduce(function(acc, key) { + acc[key] = fn(obj[key]); + return acc; + }, {}); +} + +/** + * Given a spec object recursively mapping properties to functions, creates a + * function producing an object of the same structure, by mapping each property + * to the result of calling its associated function with the supplied arguments. + * + * @func + * @memberOf R + * @since v0.20.0 + * @category Function + * @sig {k: ((a, b, ..., m) -> v)} -> ((a, b, ..., m) -> {k: v}) + * @param {Object} spec an object recursively mapping properties to functions for + * producing the values for these properties. + * @return {Function} A function that returns an object of the same structure + * as `spec', with each property set to the value returned by calling its + * associated function with the supplied arguments. + * @see R.converge, R.juxt + * @example + * + * const getMetrics = R.applySpec({ + * sum: R.add, + * nested: { mul: R.multiply } + * }); + * getMetrics(2, 4); // => { sum: 6, nested: { mul: 8 } } + * @symb R.applySpec({ x: f, y: { z: g } })(a, b) = { x: f(a, b), y: { z: g(a, b) } } + */ +var applySpec = _curry1(function applySpec(spec) { + spec = mapValues( + function(v) { return typeof v == 'function' ? v : applySpec(v); }, + spec + ); + + return curryN( + reduce(max, 0, pluck('length', values(spec))), + function() { + var args = arguments; + return mapValues(function(f) { return apply(f, args); }, spec); + }); +}); + +/** + * Takes a value and applies a function to it. + * + * This function is also known as the `thrush` combinator. + * + * @func + * @memberOf R + * @since v0.25.0 + * @category Function + * @sig a -> (a -> b) -> b + * @param {*} x The value + * @param {Function} f The function to apply + * @return {*} The result of applying `f` to `x` + * @example + * + * const t42 = R.applyTo(42); + * t42(R.identity); //=> 42 + * t42(R.add(1)); //=> 43 + */ +var applyTo = _curry2(function applyTo(x, f) { return f(x); }); + +/** + * Makes an ascending comparator function out of a function that returns a value + * that can be compared with `<` and `>`. + * + * @func + * @memberOf R + * @since v0.23.0 + * @category Function + * @sig Ord b => (a -> b) -> a -> a -> Number + * @param {Function} fn A function of arity one that returns a value that can be compared + * @param {*} a The first item to be compared. + * @param {*} b The second item to be compared. + * @return {Number} `-1` if fn(a) < fn(b), `1` if fn(b) < fn(a), otherwise `0` + * @see R.descend + * @example + * + * const byAge = R.ascend(R.prop('age')); + * const people = [ + * { name: 'Emma', age: 70 }, + * { name: 'Peter', age: 78 }, + * { name: 'Mikhail', age: 62 }, + * ]; + * const peopleByYoungestFirst = R.sort(byAge, people); + * //=> [{ name: 'Mikhail', age: 62 },{ name: 'Emma', age: 70 }, { name: 'Peter', age: 78 }] + */ +var ascend = _curry3(function ascend(fn, a, b) { + var aa = fn(a); + var bb = fn(b); + return aa < bb ? -1 : aa > bb ? 1 : 0; +}); + +/** + * Makes a shallow clone of an object, setting or overriding the specified + * property with the given value. Note that this copies and flattens prototype + * properties onto the new object as well. All non-primitive properties are + * copied by reference. + * + * @func + * @memberOf R + * @since v0.8.0 + * @category Object + * @sig String -> a -> {k: v} -> {k: v} + * @param {String} prop The property name to set + * @param {*} val The new value + * @param {Object} obj The object to clone + * @return {Object} A new object equivalent to the original except for the changed property. + * @see R.dissoc, R.pick + * @example + * + * R.assoc('c', 3, {a: 1, b: 2}); //=> {a: 1, b: 2, c: 3} + */ +var assoc = _curry3(function assoc(prop, val, obj) { + var result = {}; + for (var p in obj) { + result[p] = obj[p]; + } + result[prop] = val; + return result; +}); + +/** + * Determine if the passed argument is an integer. + * + * @private + * @param {*} n + * @category Type + * @return {Boolean} + */ +var _isInteger = Number.isInteger || function _isInteger(n) { + return (n << 0) === n; +}; + +/** + * Checks if the input value is `null` or `undefined`. + * + * @func + * @memberOf R + * @since v0.9.0 + * @category Type + * @sig * -> Boolean + * @param {*} x The value to test. + * @return {Boolean} `true` if `x` is `undefined` or `null`, otherwise `false`. + * @example + * + * R.isNil(null); //=> true + * R.isNil(undefined); //=> true + * R.isNil(0); //=> false + * R.isNil([]); //=> false + */ +var isNil = _curry1(function isNil(x) { return x == null; }); + +/** + * Makes a shallow clone of an object, setting or overriding the nodes required + * to create the given path, and placing the specific value at the tail end of + * that path. Note that this copies and flattens prototype properties onto the + * new object as well. All non-primitive properties are copied by reference. + * + * @func + * @memberOf R + * @since v0.8.0 + * @category Object + * @typedefn Idx = String | Int + * @sig [Idx] -> a -> {a} -> {a} + * @param {Array} path the path to set + * @param {*} val The new value + * @param {Object} obj The object to clone + * @return {Object} A new object equivalent to the original except along the specified path. + * @see R.dissocPath + * @example + * + * R.assocPath(['a', 'b', 'c'], 42, {a: {b: {c: 0}}}); //=> {a: {b: {c: 42}}} + * + * // Any missing or non-object keys in path will be overridden + * R.assocPath(['a', 'b', 'c'], 42, {a: 5}); //=> {a: {b: {c: 42}}} + */ +var assocPath = _curry3(function assocPath(path, val, obj) { + if (path.length === 0) { + return val; + } + var idx = path[0]; + if (path.length > 1) { + var nextObj = (!isNil(obj) && _has(idx, obj)) ? obj[idx] : _isInteger(path[1]) ? [] : {}; + val = assocPath(Array.prototype.slice.call(path, 1), val, nextObj); + } + if (_isInteger(idx) && _isArray(obj)) { + var arr = [].concat(obj); + arr[idx] = val; + return arr; + } else { + return assoc(idx, val, obj); + } +}); + +/** + * Wraps a function of any arity (including nullary) in a function that accepts + * exactly `n` parameters. Any extraneous parameters will not be passed to the + * supplied function. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Function + * @sig Number -> (* -> a) -> (* -> a) + * @param {Number} n The desired arity of the new function. + * @param {Function} fn The function to wrap. + * @return {Function} A new function wrapping `fn`. The new function is guaranteed to be of + * arity `n`. + * @see R.binary, R.unary + * @example + * + * const takesTwoArgs = (a, b) => [a, b]; + * + * takesTwoArgs.length; //=> 2 + * takesTwoArgs(1, 2); //=> [1, 2] + * + * const takesOneArg = R.nAry(1, takesTwoArgs); + * takesOneArg.length; //=> 1 + * // Only `n` arguments are passed to the wrapped function + * takesOneArg(1, 2); //=> [1, undefined] + * @symb R.nAry(0, f)(a, b) = f() + * @symb R.nAry(1, f)(a, b) = f(a) + * @symb R.nAry(2, f)(a, b) = f(a, b) + */ +var nAry = _curry2(function nAry(n, fn) { + switch (n) { + case 0: return function() {return fn.call(this);}; + case 1: return function(a0) {return fn.call(this, a0);}; + case 2: return function(a0, a1) {return fn.call(this, a0, a1);}; + case 3: return function(a0, a1, a2) {return fn.call(this, a0, a1, a2);}; + case 4: return function(a0, a1, a2, a3) {return fn.call(this, a0, a1, a2, a3);}; + case 5: return function(a0, a1, a2, a3, a4) {return fn.call(this, a0, a1, a2, a3, a4);}; + case 6: return function(a0, a1, a2, a3, a4, a5) {return fn.call(this, a0, a1, a2, a3, a4, a5);}; + case 7: return function(a0, a1, a2, a3, a4, a5, a6) {return fn.call(this, a0, a1, a2, a3, a4, a5, a6);}; + case 8: return function(a0, a1, a2, a3, a4, a5, a6, a7) {return fn.call(this, a0, a1, a2, a3, a4, a5, a6, a7);}; + case 9: return function(a0, a1, a2, a3, a4, a5, a6, a7, a8) {return fn.call(this, a0, a1, a2, a3, a4, a5, a6, a7, a8);}; + case 10: return function(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9) {return fn.call(this, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9);}; + default: throw new Error('First argument to nAry must be a non-negative integer no greater than ten'); + } +}); + +/** + * Wraps a function of any arity (including nullary) in a function that accepts + * exactly 2 parameters. Any extraneous parameters will not be passed to the + * supplied function. + * + * @func + * @memberOf R + * @since v0.2.0 + * @category Function + * @sig (* -> c) -> (a, b -> c) + * @param {Function} fn The function to wrap. + * @return {Function} A new function wrapping `fn`. The new function is guaranteed to be of + * arity 2. + * @see R.nAry, R.unary + * @example + * + * const takesThreeArgs = function(a, b, c) { + * return [a, b, c]; + * }; + * takesThreeArgs.length; //=> 3 + * takesThreeArgs(1, 2, 3); //=> [1, 2, 3] + * + * const takesTwoArgs = R.binary(takesThreeArgs); + * takesTwoArgs.length; //=> 2 + * // Only 2 arguments are passed to the wrapped function + * takesTwoArgs(1, 2, 3); //=> [1, 2, undefined] + * @symb R.binary(f)(a, b, c) = f(a, b) + */ +var binary = _curry1(function binary(fn) { + return nAry(2, fn); +}); + +function _isFunction(x) { + return Object.prototype.toString.call(x) === '[object Function]'; +} + +/** + * "lifts" a function to be the specified arity, so that it may "map over" that + * many lists, Functions or other objects that satisfy the [FantasyLand Apply spec](https://github.com/fantasyland/fantasy-land#apply). + * + * @func + * @memberOf R + * @since v0.7.0 + * @category Function + * @sig Number -> (*... -> *) -> ([*]... -> [*]) + * @param {Function} fn The function to lift into higher context + * @return {Function} The lifted function. + * @see R.lift, R.ap + * @example + * + * const madd3 = R.liftN(3, (...args) => R.sum(args)); + * madd3([1,2,3], [1,2,3], [1]); //=> [3, 4, 5, 4, 5, 6, 5, 6, 7] + */ +var liftN = _curry2(function liftN(arity, fn) { + var lifted = curryN(arity, fn); + return curryN(arity, function() { + return _reduce(ap, map(lifted, arguments[0]), Array.prototype.slice.call(arguments, 1)); + }); +}); + +/** + * "lifts" a function of arity > 1 so that it may "map over" a list, Function or other + * object that satisfies the [FantasyLand Apply spec](https://github.com/fantasyland/fantasy-land#apply). + * + * @func + * @memberOf R + * @since v0.7.0 + * @category Function + * @sig (*... -> *) -> ([*]... -> [*]) + * @param {Function} fn The function to lift into higher context + * @return {Function} The lifted function. + * @see R.liftN + * @example + * + * const madd3 = R.lift((a, b, c) => a + b + c); + * + * madd3([1,2,3], [1,2,3], [1]); //=> [3, 4, 5, 4, 5, 6, 5, 6, 7] + * + * const madd5 = R.lift((a, b, c, d, e) => a + b + c + d + e); + * + * madd5([1,2], [3], [4, 5], [6], [7, 8]); //=> [21, 22, 22, 23, 22, 23, 23, 24] + */ +var lift = _curry1(function lift(fn) { + return liftN(fn.length, fn); +}); + +/** + * A function which calls the two provided functions and returns the `&&` + * of the results. + * It returns the result of the first function if it is false-y and the result + * of the second function otherwise. Note that this is short-circuited, + * meaning that the second function will not be invoked if the first returns a + * false-y value. + * + * In addition to functions, `R.both` also accepts any fantasy-land compatible + * applicative functor. + * + * @func + * @memberOf R + * @since v0.12.0 + * @category Logic + * @sig (*... -> Boolean) -> (*... -> Boolean) -> (*... -> Boolean) + * @param {Function} f A predicate + * @param {Function} g Another predicate + * @return {Function} a function that applies its arguments to `f` and `g` and `&&`s their outputs together. + * @see R.and + * @example + * + * const gt10 = R.gt(R.__, 10) + * const lt20 = R.lt(R.__, 20) + * const f = R.both(gt10, lt20); + * f(15); //=> true + * f(30); //=> false + * + * R.both(Maybe.Just(false), Maybe.Just(55)); // => Maybe.Just(false) + * R.both([false, false, 'a'], [11]); //=> [false, false, 11] + */ +var both = _curry2(function both(f, g) { + return _isFunction(f) ? + function _both() { + return f.apply(this, arguments) && g.apply(this, arguments); + } : + lift(and)(f, g); +}); + +/** + * Returns a curried equivalent of the provided function. The curried function + * has two unusual capabilities. First, its arguments needn't be provided one + * at a time. If `f` is a ternary function and `g` is `R.curry(f)`, the + * following are equivalent: + * + * - `g(1)(2)(3)` + * - `g(1)(2, 3)` + * - `g(1, 2)(3)` + * - `g(1, 2, 3)` + * + * Secondly, the special placeholder value [`R.__`](#__) may be used to specify + * "gaps", allowing partial application of any combination of arguments, + * regardless of their positions. If `g` is as above and `_` is [`R.__`](#__), + * the following are equivalent: + * + * - `g(1, 2, 3)` + * - `g(_, 2, 3)(1)` + * - `g(_, _, 3)(1)(2)` + * - `g(_, _, 3)(1, 2)` + * - `g(_, 2)(1)(3)` + * - `g(_, 2)(1, 3)` + * - `g(_, 2)(_, 3)(1)` + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Function + * @sig (* -> a) -> (* -> a) + * @param {Function} fn The function to curry. + * @return {Function} A new, curried function. + * @see R.curryN, R.partial + * @example + * + * const addFourNumbers = (a, b, c, d) => a + b + c + d; + * + * const curriedAddFourNumbers = R.curry(addFourNumbers); + * const f = curriedAddFourNumbers(1, 2); + * const g = f(3); + * g(4); //=> 10 + */ +var curry = _curry1(function curry(fn) { + return curryN(fn.length, fn); +}); + +/** + * Returns the result of calling its first argument with the remaining + * arguments. This is occasionally useful as a converging function for + * [`R.converge`](#converge): the first branch can produce a function while the + * remaining branches produce values to be passed to that function as its + * arguments. + * + * @func + * @memberOf R + * @since v0.9.0 + * @category Function + * @sig (*... -> a),*... -> a + * @param {Function} fn The function to apply to the remaining arguments. + * @param {...*} args Any number of positional arguments. + * @return {*} + * @see R.apply + * @example + * + * R.call(R.add, 1, 2); //=> 3 + * + * const indentN = R.pipe(R.repeat(' '), + * R.join(''), + * R.replace(/^(?!$)/gm)); + * + * const format = R.converge(R.call, [ + * R.pipe(R.prop('indent'), indentN), + * R.prop('value') + * ]); + * + * format({indent: 2, value: 'foo\nbar\nbaz\n'}); //=> ' foo\n bar\n baz\n' + * @symb R.call(f, a, b) = f(a, b) + */ +var call = curry(function call(fn) { + return fn.apply(this, Array.prototype.slice.call(arguments, 1)); +}); + +/** + * `_makeFlat` is a helper function that returns a one-level or fully recursive + * function based on the flag passed in. + * + * @private + */ +function _makeFlat(recursive) { + return function flatt(list) { + var value, jlen, j; + var result = []; + var idx = 0; + var ilen = list.length; + + while (idx < ilen) { + if (_isArrayLike(list[idx])) { + value = recursive ? flatt(list[idx]) : list[idx]; + j = 0; + jlen = value.length; + while (j < jlen) { + result[result.length] = value[j]; + j += 1; + } + } else { + result[result.length] = list[idx]; + } + idx += 1; + } + return result; + }; +} + +function _forceReduced(x) { + return { + '@@transducer/value': x, + '@@transducer/reduced': true + }; +} + +var preservingReduced = function(xf) { + return { + '@@transducer/init': _xfBase.init, + '@@transducer/result': function(result) { + return xf['@@transducer/result'](result); + }, + '@@transducer/step': function(result, input) { + var ret = xf['@@transducer/step'](result, input); + return ret['@@transducer/reduced'] ? _forceReduced(ret) : ret; + } + }; +}; + +var _flatCat = function _xcat(xf) { + var rxf = preservingReduced(xf); + return { + '@@transducer/init': _xfBase.init, + '@@transducer/result': function(result) { + return rxf['@@transducer/result'](result); + }, + '@@transducer/step': function(result, input) { + return !_isArrayLike(input) ? _reduce(rxf, result, [input]) : _reduce(rxf, result, input); + } + }; +}; + +var _xchain = _curry2(function _xchain(f, xf) { + return map(f, _flatCat(xf)); +}); + +/** + * `chain` maps a function over a list and concatenates the results. `chain` + * is also known as `flatMap` in some libraries. + * + * Dispatches to the `chain` method of the second argument, if present, + * according to the [FantasyLand Chain spec](https://github.com/fantasyland/fantasy-land#chain). + * + * If second argument is a function, `chain(f, g)(x)` is equivalent to `f(g(x), x)`. + * + * Acts as a transducer if a transformer is given in list position. + * + * @func + * @memberOf R + * @since v0.3.0 + * @category List + * @sig Chain m => (a -> m b) -> m a -> m b + * @param {Function} fn The function to map with + * @param {Array} list The list to map over + * @return {Array} The result of flat-mapping `list` with `fn` + * @example + * + * const duplicate = n => [n, n]; + * R.chain(duplicate, [1, 2, 3]); //=> [1, 1, 2, 2, 3, 3] + * + * R.chain(R.append, R.head)([1, 2, 3]); //=> [1, 2, 3, 1] + */ +var chain = _curry2(_dispatchable(['fantasy-land/chain', 'chain'], _xchain, function chain(fn, monad) { + if (typeof monad === 'function') { + return function(x) { return fn(monad(x))(x); }; + } + return _makeFlat(false)(map(fn, monad)); +})); + +/** + * Restricts a number to be within a range. + * + * Also works for other ordered types such as Strings and Dates. + * + * @func + * @memberOf R + * @since v0.20.0 + * @category Relation + * @sig Ord a => a -> a -> a -> a + * @param {Number} minimum The lower limit of the clamp (inclusive) + * @param {Number} maximum The upper limit of the clamp (inclusive) + * @param {Number} value Value to be clamped + * @return {Number} Returns `minimum` when `val < minimum`, `maximum` when `val > maximum`, returns `val` otherwise + * @example + * + * R.clamp(1, 10, -5) // => 1 + * R.clamp(1, 10, 15) // => 10 + * R.clamp(1, 10, 4) // => 4 + */ +var clamp = _curry3(function clamp(min, max, value) { + if (min > max) { + throw new Error('min must not be greater than max in clamp(min, max, value)'); + } + return value < min ? min : + value > max ? max : + value; +}); + +function _cloneRegExp(pattern) { + return new RegExp(pattern.source, (pattern.global ? 'g' : '') + + (pattern.ignoreCase ? 'i' : '') + + (pattern.multiline ? 'm' : '') + + (pattern.sticky ? 'y' : '') + + (pattern.unicode ? 'u' : '')); +} + +/** + * Gives a single-word string description of the (native) type of a value, + * returning such answers as 'Object', 'Number', 'Array', or 'Null'. Does not + * attempt to distinguish user Object types any further, reporting them all as + * 'Object'. + * + * @func + * @memberOf R + * @since v0.8.0 + * @category Type + * @sig (* -> {*}) -> String + * @param {*} val The value to test + * @return {String} + * @example + * + * R.type({}); //=> "Object" + * R.type(1); //=> "Number" + * R.type(false); //=> "Boolean" + * R.type('s'); //=> "String" + * R.type(null); //=> "Null" + * R.type([]); //=> "Array" + * R.type(/[A-z]/); //=> "RegExp" + * R.type(() => {}); //=> "Function" + * R.type(undefined); //=> "Undefined" + */ +var type = _curry1(function type(val) { + return val === null ? 'Null' : + val === undefined ? 'Undefined' : + Object.prototype.toString.call(val).slice(8, -1); +}); + +/** + * Copies an object. + * + * @private + * @param {*} value The value to be copied + * @param {Array} refFrom Array containing the source references + * @param {Array} refTo Array containing the copied source references + * @param {Boolean} deep Whether or not to perform deep cloning. + * @return {*} The copied value. + */ +function _clone(value, refFrom, refTo, deep) { + var copy = function copy(copiedValue) { + var len = refFrom.length; + var idx = 0; + while (idx < len) { + if (value === refFrom[idx]) { + return refTo[idx]; + } + idx += 1; + } + refFrom[idx + 1] = value; + refTo[idx + 1] = copiedValue; + for (var key in value) { + copiedValue[key] = deep ? + _clone(value[key], refFrom, refTo, true) : value[key]; + } + return copiedValue; + }; + switch (type(value)) { + case 'Object': return copy({}); + case 'Array': return copy([]); + case 'Date': return new Date(value.valueOf()); + case 'RegExp': return _cloneRegExp(value); + default: return value; + } +} + +/** + * Creates a deep copy of the value which may contain (nested) `Array`s and + * `Object`s, `Number`s, `String`s, `Boolean`s and `Date`s. `Function`s are + * assigned by reference rather than copied + * + * Dispatches to a `clone` method if present. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Object + * @sig {*} -> {*} + * @param {*} value The object or array to clone + * @return {*} A deeply cloned copy of `val` + * @example + * + * const objects = [{}, {}, {}]; + * const objectsClone = R.clone(objects); + * objects === objectsClone; //=> false + * objects[0] === objectsClone[0]; //=> false + */ +var clone = _curry1(function clone(value) { + return value != null && typeof value.clone === 'function' ? + value.clone() : + _clone(value, [], [], true); +}); + +/** + * Makes a comparator function out of a function that reports whether the first + * element is less than the second. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Function + * @sig ((a, b) -> Boolean) -> ((a, b) -> Number) + * @param {Function} pred A predicate function of arity two which will return `true` if the first argument + * is less than the second, `false` otherwise + * @return {Function} A Function :: a -> b -> Int that returns `-1` if a < b, `1` if b < a, otherwise `0` + * @example + * + * const byAge = R.comparator((a, b) => a.age < b.age); + * const people = [ + * { name: 'Emma', age: 70 }, + * { name: 'Peter', age: 78 }, + * { name: 'Mikhail', age: 62 }, + * ]; + * const peopleByIncreasingAge = R.sort(byAge, people); + * //=> [{ name: 'Mikhail', age: 62 },{ name: 'Emma', age: 70 }, { name: 'Peter', age: 78 }] + */ +var comparator = _curry1(function comparator(pred) { + return function(a, b) { + return pred(a, b) ? -1 : pred(b, a) ? 1 : 0; + }; +}); + +/** + * A function that returns the `!` of its argument. It will return `true` when + * passed false-y value, and `false` when passed a truth-y one. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Logic + * @sig * -> Boolean + * @param {*} a any value + * @return {Boolean} the logical inverse of passed argument. + * @see R.complement + * @example + * + * R.not(true); //=> false + * R.not(false); //=> true + * R.not(0); //=> true + * R.not(1); //=> false + */ +var not = _curry1(function not(a) { + return !a; +}); + +/** + * Takes a function `f` and returns a function `g` such that if called with the same arguments + * when `f` returns a "truthy" value, `g` returns `false` and when `f` returns a "falsy" value `g` returns `true`. + * + * `R.complement` may be applied to any functor + * + * @func + * @memberOf R + * @since v0.12.0 + * @category Logic + * @sig (*... -> *) -> (*... -> Boolean) + * @param {Function} f + * @return {Function} + * @see R.not + * @example + * + * const isNotNil = R.complement(R.isNil); + * isNil(null); //=> true + * isNotNil(null); //=> false + * isNil(7); //=> false + * isNotNil(7); //=> true + */ +var complement = lift(not); + +function _pipe(f, g) { + return function() { + return g.call(this, f.apply(this, arguments)); + }; +} + +/** + * This checks whether a function has a [methodname] function. If it isn't an + * array it will execute that function otherwise it will default to the ramda + * implementation. + * + * @private + * @param {Function} fn ramda implemtation + * @param {String} methodname property to check for a custom implementation + * @return {Object} Whatever the return value of the method is. + */ +function _checkForMethod(methodname, fn) { + return function() { + var length = arguments.length; + if (length === 0) { + return fn(); + } + var obj = arguments[length - 1]; + return (_isArray(obj) || typeof obj[methodname] !== 'function') ? + fn.apply(this, arguments) : + obj[methodname].apply(obj, Array.prototype.slice.call(arguments, 0, length - 1)); + }; +} + +/** + * Returns the elements of the given list or string (or object with a `slice` + * method) from `fromIndex` (inclusive) to `toIndex` (exclusive). + * + * Dispatches to the `slice` method of the third argument, if present. + * + * @func + * @memberOf R + * @since v0.1.4 + * @category List + * @sig Number -> Number -> [a] -> [a] + * @sig Number -> Number -> String -> String + * @param {Number} fromIndex The start index (inclusive). + * @param {Number} toIndex The end index (exclusive). + * @param {*} list + * @return {*} + * @example + * + * R.slice(1, 3, ['a', 'b', 'c', 'd']); //=> ['b', 'c'] + * R.slice(1, Infinity, ['a', 'b', 'c', 'd']); //=> ['b', 'c', 'd'] + * R.slice(0, -1, ['a', 'b', 'c', 'd']); //=> ['a', 'b', 'c'] + * R.slice(-3, -1, ['a', 'b', 'c', 'd']); //=> ['b', 'c'] + * R.slice(0, 3, 'ramda'); //=> 'ram' + */ +var slice = _curry3(_checkForMethod('slice', function slice(fromIndex, toIndex, list) { + return Array.prototype.slice.call(list, fromIndex, toIndex); +})); + +/** + * Returns all but the first element of the given list or string (or object + * with a `tail` method). + * + * Dispatches to the `slice` method of the first argument, if present. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category List + * @sig [a] -> [a] + * @sig String -> String + * @param {*} list + * @return {*} + * @see R.head, R.init, R.last + * @example + * + * R.tail([1, 2, 3]); //=> [2, 3] + * R.tail([1, 2]); //=> [2] + * R.tail([1]); //=> [] + * R.tail([]); //=> [] + * + * R.tail('abc'); //=> 'bc' + * R.tail('ab'); //=> 'b' + * R.tail('a'); //=> '' + * R.tail(''); //=> '' + */ +var tail = _curry1(_checkForMethod('tail', slice(1, Infinity))); + +/** + * Performs left-to-right function composition. The leftmost function may have + * any arity; the remaining functions must be unary. + * + * In some libraries this function is named `sequence`. + * + * **Note:** The result of pipe is not automatically curried. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Function + * @sig (((a, b, ..., n) -> o), (o -> p), ..., (x -> y), (y -> z)) -> ((a, b, ..., n) -> z) + * @param {...Function} functions + * @return {Function} + * @see R.compose + * @example + * + * const f = R.pipe(Math.pow, R.negate, R.inc); + * + * f(3, 4); // -(3^4) + 1 + * @symb R.pipe(f, g, h)(a, b) = h(g(f(a, b))) + */ +function pipe() { + if (arguments.length === 0) { + throw new Error('pipe requires at least one argument'); + } + return _arity(arguments[0].length, + reduce(_pipe, arguments[0], tail(arguments))); +} + +/** + * Returns a new list or string with the elements or characters in reverse + * order. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category List + * @sig [a] -> [a] + * @sig String -> String + * @param {Array|String} list + * @return {Array|String} + * @example + * + * R.reverse([1, 2, 3]); //=> [3, 2, 1] + * R.reverse([1, 2]); //=> [2, 1] + * R.reverse([1]); //=> [1] + * R.reverse([]); //=> [] + * + * R.reverse('abc'); //=> 'cba' + * R.reverse('ab'); //=> 'ba' + * R.reverse('a'); //=> 'a' + * R.reverse(''); //=> '' + */ +var reverse = _curry1(function reverse(list) { + return _isString(list) ? list.split('').reverse().join('') : + Array.prototype.slice.call(list, 0).reverse(); +}); + +/** + * Performs right-to-left function composition. The rightmost function may have + * any arity; the remaining functions must be unary. + * + * **Note:** The result of compose is not automatically curried. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Function + * @sig ((y -> z), (x -> y), ..., (o -> p), ((a, b, ..., n) -> o)) -> ((a, b, ..., n) -> z) + * @param {...Function} ...functions The functions to compose + * @return {Function} + * @see R.pipe + * @example + * + * const classyGreeting = (firstName, lastName) => "The name's " + lastName + ", " + firstName + " " + lastName + * const yellGreeting = R.compose(R.toUpper, classyGreeting); + * yellGreeting('James', 'Bond'); //=> "THE NAME'S BOND, JAMES BOND" + * + * R.compose(Math.abs, R.add(1), R.multiply(2))(-4) //=> 7 + * + * @symb R.compose(f, g, h)(a, b) = f(g(h(a, b))) + */ +function compose() { + if (arguments.length === 0) { + throw new Error('compose requires at least one argument'); + } + return pipe.apply(this, reverse(arguments)); +} + +/** + * Returns the right-to-left Kleisli composition of the provided functions, + * each of which must return a value of a type supported by [`chain`](#chain). + * + * `R.composeK(h, g, f)` is equivalent to `R.compose(R.chain(h), R.chain(g), f)`. + * + * @func + * @memberOf R + * @since v0.16.0 + * @category Function + * @sig Chain m => ((y -> m z), (x -> m y), ..., (a -> m b)) -> (a -> m z) + * @param {...Function} ...functions The functions to compose + * @return {Function} + * @see R.pipeK + * @example + * + * // get :: String -> Object -> Maybe * + * const get = R.curry((propName, obj) => Maybe(obj[propName])) + * + * // getStateCode :: Maybe String -> Maybe String + * const getStateCode = R.composeK( + * R.compose(Maybe.of, R.toUpper), + * get('state'), + * get('address'), + * get('user'), + * ); + * getStateCode({"user":{"address":{"state":"ny"}}}); //=> Maybe.Just("NY") + * getStateCode({}); //=> Maybe.Nothing() + * @symb R.composeK(f, g, h)(a) = R.chain(f, R.chain(g, h(a))) + */ +function composeK() { + if (arguments.length === 0) { + throw new Error('composeK requires at least one argument'); + } + var init = Array.prototype.slice.call(arguments); + var last = init.pop(); + return compose(compose.apply(this, map(chain, init)), last); +} + +function _pipeP(f, g) { + return function() { + var ctx = this; + return f.apply(ctx, arguments).then(function(x) { + return g.call(ctx, x); + }); + }; +} + +/** + * Performs left-to-right composition of one or more Promise-returning + * functions. The leftmost function may have any arity; the remaining functions + * must be unary. + * + * @func + * @memberOf R + * @since v0.10.0 + * @category Function + * @sig ((a -> Promise b), (b -> Promise c), ..., (y -> Promise z)) -> (a -> Promise z) + * @param {...Function} functions + * @return {Function} + * @see R.composeP + * @example + * + * // followersForUser :: String -> Promise [User] + * const followersForUser = R.pipeP(db.getUserById, db.getFollowers); + */ +function pipeP() { + if (arguments.length === 0) { + throw new Error('pipeP requires at least one argument'); + } + return _arity(arguments[0].length, + reduce(_pipeP, arguments[0], tail(arguments))); +} + +/** + * Performs right-to-left composition of one or more Promise-returning + * functions. The rightmost function may have any arity; the remaining + * functions must be unary. + * + * @func + * @memberOf R + * @since v0.10.0 + * @category Function + * @sig ((y -> Promise z), (x -> Promise y), ..., (a -> Promise b)) -> (a -> Promise z) + * @param {...Function} functions The functions to compose + * @return {Function} + * @see R.pipeP + * @example + * + * const db = { + * users: { + * JOE: { + * name: 'Joe', + * followers: ['STEVE', 'SUZY'] + * } + * } + * } + * + * // We'll pretend to do a db lookup which returns a promise + * const lookupUser = (userId) => Promise.resolve(db.users[userId]) + * const lookupFollowers = (user) => Promise.resolve(user.followers) + * lookupUser('JOE').then(lookupFollowers) + * + * // followersForUser :: String -> Promise [UserId] + * const followersForUser = R.composeP(lookupFollowers, lookupUser); + * followersForUser('JOE').then(followers => console.log('Followers:', followers)) + * // Followers: ["STEVE","SUZY"] + */ +function composeP() { + if (arguments.length === 0) { + throw new Error('composeP requires at least one argument'); + } + return pipeP.apply(this, reverse(arguments)); +} + +/** + * Returns the nth element of the given list or string. If n is negative the + * element at index length + n is returned. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category List + * @sig Number -> [a] -> a | Undefined + * @sig Number -> String -> String + * @param {Number} offset + * @param {*} list + * @return {*} + * @example + * + * const list = ['foo', 'bar', 'baz', 'quux']; + * R.nth(1, list); //=> 'bar' + * R.nth(-1, list); //=> 'quux' + * R.nth(-99, list); //=> undefined + * + * R.nth(2, 'abc'); //=> 'c' + * R.nth(3, 'abc'); //=> '' + * @symb R.nth(-1, [a, b, c]) = c + * @symb R.nth(0, [a, b, c]) = a + * @symb R.nth(1, [a, b, c]) = b + */ +var nth = _curry2(function nth(offset, list) { + var idx = offset < 0 ? list.length + offset : offset; + return _isString(list) ? list.charAt(idx) : list[idx]; +}); + +/** + * Returns the first element of the given list or string. In some libraries + * this function is named `first`. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category List + * @sig [a] -> a | Undefined + * @sig String -> String + * @param {Array|String} list + * @return {*} + * @see R.tail, R.init, R.last + * @example + * + * R.head(['fi', 'fo', 'fum']); //=> 'fi' + * R.head([]); //=> undefined + * + * R.head('abc'); //=> 'a' + * R.head(''); //=> '' + */ +var head = nth(0); + +function _identity(x) { return x; } + +/** + * A function that does nothing but return the parameter supplied to it. Good + * as a default or placeholder function. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Function + * @sig a -> a + * @param {*} x The value to return. + * @return {*} The input value, `x`. + * @example + * + * R.identity(1); //=> 1 + * + * const obj = {}; + * R.identity(obj) === obj; //=> true + * @symb R.identity(a) = a + */ +var identity = _curry1(_identity); + +/** + * Performs left-to-right function composition using transforming function. The leftmost function may have + * any arity; the remaining functions must be unary. + * + * **Note:** The result of pipeWith is not automatically curried. + * + * @func + * @memberOf R + * @category Function + * @sig ((* -> *), [((a, b, ..., n) -> o), (o -> p), ..., (x -> y), (y -> z)]) -> ((a, b, ..., n) -> z) + * @param {...Function} functions + * @return {Function} + * @see R.composeWith, R.pipe + * @example + * + * const pipeWhileNotNil = R.pipeWith((f, res) => R.isNil(res) ? res : f(res)); + * const f = pipeWhileNotNil([Math.pow, R.negate, R.inc]) + * + * f(3, 4); // -(3^4) + 1 + * @symb R.pipeWith(f)([g, h, i])(...args) = f(i, f(h, f(g, ...args))) + */ +var pipeWith = _curry2(function pipeWith(xf, list) { + if (list.length <= 0) { + return identity; + } + + const headList = head(list); + const tailList = tail(list); + + return _arity(headList.length, function() { + return _reduce( + function(result, f) { + return xf.call(this, f, result); + }, + headList.apply(this, arguments), + tailList + ); + }); +}); + +/** + * Performs right-to-left function composition using transforming function. The rightmost function may have + * any arity; the remaining functions must be unary. + * + * **Note:** The result of compose is not automatically curried. + * + * @func + * @memberOf R + * @category Function + * @sig ((* -> *), [(y -> z), (x -> y), ..., (o -> p), ((a, b, ..., n) -> o)]) -> ((a, b, ..., n) -> z) + * @param {...Function} ...functions The functions to compose + * @return {Function} + * @see R.compose, R.pipeWith + * @example + * + * const composeWhileNotNil = R.composeWith((f, res) => R.isNil(res) ? res : f(res)); + * + * composeWhileNotNil([R.inc, R.prop('age')])({age: 1}) //=> 2 + * composeWhileNotNil([R.inc, R.prop('age')])({}) //=> null + * + * @symb R.composeWith(f)([g, h, i])(...args) = f(g, f(h, f(i, ...args))) + */ +var composeWith = _curry2(function composeWith(xf, list) { + return pipeWith.apply(this, [xf, reverse(list)]); +}); + +function _arrayFromIterator(iter) { + var list = []; + var next; + while (!(next = iter.next()).done) { + list.push(next.value); + } + return list; +} + +function _includesWith(pred, x, list) { + var idx = 0; + var len = list.length; + + while (idx < len) { + if (pred(x, list[idx])) { + return true; + } + idx += 1; + } + return false; +} + +function _functionName(f) { + // String(x => x) evaluates to "x => x", so the pattern may not match. + var match = String(f).match(/^function (\w*)/); + return match == null ? '' : match[1]; +} + +// Based on https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is +function _objectIs(a, b) { + // SameValue algorithm + if (a === b) { // Steps 1-5, 7-10 + // Steps 6.b-6.e: +0 != -0 + return a !== 0 || 1 / a === 1 / b; + } else { + // Step 6.a: NaN == NaN + return a !== a && b !== b; + } +} + +var _objectIs$1 = typeof Object.is === 'function' ? Object.is : _objectIs; + +/** + * private _uniqContentEquals function. + * That function is checking equality of 2 iterator contents with 2 assumptions + * - iterators lengths are the same + * - iterators values are unique + * + * false-positive result will be returned for comparision of, e.g. + * - [1,2,3] and [1,2,3,4] + * - [1,1,1] and [1,2,3] + * */ + +function _uniqContentEquals(aIterator, bIterator, stackA, stackB) { + var a = _arrayFromIterator(aIterator); + var b = _arrayFromIterator(bIterator); + + function eq(_a, _b) { + return _equals(_a, _b, stackA.slice(), stackB.slice()); + } + + // if *a* array contains any element that is not included in *b* + return !_includesWith(function(b, aItem) { + return !_includesWith(eq, aItem, b); + }, b, a); +} + +function _equals(a, b, stackA, stackB) { + if (_objectIs$1(a, b)) { + return true; + } + + var typeA = type(a); + + if (typeA !== type(b)) { + return false; + } + + if (a == null || b == null) { + return false; + } + + if (typeof a['fantasy-land/equals'] === 'function' || typeof b['fantasy-land/equals'] === 'function') { + return typeof a['fantasy-land/equals'] === 'function' && a['fantasy-land/equals'](b) && + typeof b['fantasy-land/equals'] === 'function' && b['fantasy-land/equals'](a); + } + + if (typeof a.equals === 'function' || typeof b.equals === 'function') { + return typeof a.equals === 'function' && a.equals(b) && + typeof b.equals === 'function' && b.equals(a); + } + + switch (typeA) { + case 'Arguments': + case 'Array': + case 'Object': + if (typeof a.constructor === 'function' && + _functionName(a.constructor) === 'Promise') { + return a === b; + } + break; + case 'Boolean': + case 'Number': + case 'String': + if (!(typeof a === typeof b && _objectIs$1(a.valueOf(), b.valueOf()))) { + return false; + } + break; + case 'Date': + if (!_objectIs$1(a.valueOf(), b.valueOf())) { + return false; + } + break; + case 'Error': + return a.name === b.name && a.message === b.message; + case 'RegExp': + if (!(a.source === b.source && + a.global === b.global && + a.ignoreCase === b.ignoreCase && + a.multiline === b.multiline && + a.sticky === b.sticky && + a.unicode === b.unicode)) { + return false; + } + break; + } + + var idx = stackA.length - 1; + while (idx >= 0) { + if (stackA[idx] === a) { + return stackB[idx] === b; + } + idx -= 1; + } + + switch (typeA) { + case 'Map': + if (a.size !== b.size) { + return false; + } + + return _uniqContentEquals(a.entries(), b.entries(), stackA.concat([a]), stackB.concat([b])); + case 'Set': + if (a.size !== b.size) { + return false; + } + + return _uniqContentEquals(a.values(), b.values(), stackA.concat([a]), stackB.concat([b])); + case 'Arguments': + case 'Array': + case 'Object': + case 'Boolean': + case 'Number': + case 'String': + case 'Date': + case 'Error': + case 'RegExp': + case 'Int8Array': + case 'Uint8Array': + case 'Uint8ClampedArray': + case 'Int16Array': + case 'Uint16Array': + case 'Int32Array': + case 'Uint32Array': + case 'Float32Array': + case 'Float64Array': + case 'ArrayBuffer': + break; + default: + // Values of other types are only equal if identical. + return false; + } + + var keysA = keys(a); + if (keysA.length !== keys(b).length) { + return false; + } + + var extendedStackA = stackA.concat([a]); + var extendedStackB = stackB.concat([b]); + + idx = keysA.length - 1; + while (idx >= 0) { + var key = keysA[idx]; + if (!(_has(key, b) && _equals(b[key], a[key], extendedStackA, extendedStackB))) { + return false; + } + idx -= 1; + } + return true; +} + +/** + * Returns `true` if its arguments are equivalent, `false` otherwise. Handles + * cyclical data structures. + * + * Dispatches symmetrically to the `equals` methods of both arguments, if + * present. + * + * @func + * @memberOf R + * @since v0.15.0 + * @category Relation + * @sig a -> b -> Boolean + * @param {*} a + * @param {*} b + * @return {Boolean} + * @example + * + * R.equals(1, 1); //=> true + * R.equals(1, '1'); //=> false + * R.equals([1, 2, 3], [1, 2, 3]); //=> true + * + * const a = {}; a.v = a; + * const b = {}; b.v = b; + * R.equals(a, b); //=> true + */ +var equals = _curry2(function equals(a, b) { + return _equals(a, b, [], []); +}); + +function _indexOf(list, a, idx) { + var inf, item; + // Array.prototype.indexOf doesn't exist below IE9 + if (typeof list.indexOf === 'function') { + switch (typeof a) { + case 'number': + if (a === 0) { + // manually crawl the list to distinguish between +0 and -0 + inf = 1 / a; + while (idx < list.length) { + item = list[idx]; + if (item === 0 && 1 / item === inf) { + return idx; + } + idx += 1; + } + return -1; + } else if (a !== a) { + // NaN + while (idx < list.length) { + item = list[idx]; + if (typeof item === 'number' && item !== item) { + return idx; + } + idx += 1; + } + return -1; + } + // non-zero numbers can utilise Set + return list.indexOf(a, idx); + + // all these types can utilise Set + case 'string': + case 'boolean': + case 'function': + case 'undefined': + return list.indexOf(a, idx); + + case 'object': + if (a === null) { + // null can utilise Set + return list.indexOf(a, idx); + } + } + } + // anything else not covered above, defer to R.equals + while (idx < list.length) { + if (equals(list[idx], a)) { + return idx; + } + idx += 1; + } + return -1; +} + +function _includes(a, list) { + return _indexOf(list, a, 0) >= 0; +} + +function _quote(s) { + var escaped = s + .replace(/\\/g, '\\\\') + .replace(/[\b]/g, '\\b') // \b matches word boundary; [\b] matches backspace + .replace(/\f/g, '\\f') + .replace(/\n/g, '\\n') + .replace(/\r/g, '\\r') + .replace(/\t/g, '\\t') + .replace(/\v/g, '\\v') + .replace(/\0/g, '\\0'); + + return '"' + escaped.replace(/"/g, '\\"') + '"'; +} + +/** + * Polyfill from . + */ +var pad = function pad(n) { return (n < 10 ? '0' : '') + n; }; + +var _toISOString = typeof Date.prototype.toISOString === 'function' ? + function _toISOString(d) { + return d.toISOString(); + } : + function _toISOString(d) { + return ( + d.getUTCFullYear() + '-' + + pad(d.getUTCMonth() + 1) + '-' + + pad(d.getUTCDate()) + 'T' + + pad(d.getUTCHours()) + ':' + + pad(d.getUTCMinutes()) + ':' + + pad(d.getUTCSeconds()) + '.' + + (d.getUTCMilliseconds() / 1000).toFixed(3).slice(2, 5) + 'Z' + ); + }; + +function _complement(f) { + return function() { + return !f.apply(this, arguments); + }; +} + +function _filter(fn, list) { + var idx = 0; + var len = list.length; + var result = []; + + while (idx < len) { + if (fn(list[idx])) { + result[result.length] = list[idx]; + } + idx += 1; + } + return result; +} + +function _isObject(x) { + return Object.prototype.toString.call(x) === '[object Object]'; +} + +function XFilter(f, xf) { + this.xf = xf; + this.f = f; +} +XFilter.prototype['@@transducer/init'] = _xfBase.init; +XFilter.prototype['@@transducer/result'] = _xfBase.result; +XFilter.prototype['@@transducer/step'] = function(result, input) { + return this.f(input) ? this.xf['@@transducer/step'](result, input) : result; +}; + +var _xfilter = _curry2(function _xfilter(f, xf) { return new XFilter(f, xf); }); + +/** + * Takes a predicate and a `Filterable`, and returns a new filterable of the + * same type containing the members of the given filterable which satisfy the + * given predicate. Filterable objects include plain objects or any object + * that has a filter method such as `Array`. + * + * Dispatches to the `filter` method of the second argument, if present. + * + * Acts as a transducer if a transformer is given in list position. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category List + * @sig Filterable f => (a -> Boolean) -> f a -> f a + * @param {Function} pred + * @param {Array} filterable + * @return {Array} Filterable + * @see R.reject, R.transduce, R.addIndex + * @example + * + * const isEven = n => n % 2 === 0; + * + * R.filter(isEven, [1, 2, 3, 4]); //=> [2, 4] + * + * R.filter(isEven, {a: 1, b: 2, c: 3, d: 4}); //=> {b: 2, d: 4} + */ +var filter = _curry2(_dispatchable(['filter'], _xfilter, function(pred, filterable) { + return ( + _isObject(filterable) ? + _reduce(function(acc, key) { + if (pred(filterable[key])) { + acc[key] = filterable[key]; + } + return acc; + }, {}, keys(filterable)) : + // else + _filter(pred, filterable) + ); +})); + +/** + * The complement of [`filter`](#filter). + * + * Acts as a transducer if a transformer is given in list position. Filterable + * objects include plain objects or any object that has a filter method such + * as `Array`. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category List + * @sig Filterable f => (a -> Boolean) -> f a -> f a + * @param {Function} pred + * @param {Array} filterable + * @return {Array} + * @see R.filter, R.transduce, R.addIndex + * @example + * + * const isOdd = (n) => n % 2 === 1; + * + * R.reject(isOdd, [1, 2, 3, 4]); //=> [2, 4] + * + * R.reject(isOdd, {a: 1, b: 2, c: 3, d: 4}); //=> {b: 2, d: 4} + */ +var reject = _curry2(function reject(pred, filterable) { + return filter(_complement(pred), filterable); +}); + +function _toString(x, seen) { + var recur = function recur(y) { + var xs = seen.concat([x]); + return _includes(y, xs) ? '' : _toString(y, xs); + }; + + // mapPairs :: (Object, [String]) -> [String] + var mapPairs = function(obj, keys$$1) { + return _map(function(k) { return _quote(k) + ': ' + recur(obj[k]); }, keys$$1.slice().sort()); + }; + + switch (Object.prototype.toString.call(x)) { + case '[object Arguments]': + return '(function() { return arguments; }(' + _map(recur, x).join(', ') + '))'; + case '[object Array]': + return '[' + _map(recur, x).concat(mapPairs(x, reject(function(k) { return /^\d+$/.test(k); }, keys(x)))).join(', ') + ']'; + case '[object Boolean]': + return typeof x === 'object' ? 'new Boolean(' + recur(x.valueOf()) + ')' : x.toString(); + case '[object Date]': + return 'new Date(' + (isNaN(x.valueOf()) ? recur(NaN) : _quote(_toISOString(x))) + ')'; + case '[object Null]': + return 'null'; + case '[object Number]': + return typeof x === 'object' ? 'new Number(' + recur(x.valueOf()) + ')' : 1 / x === -Infinity ? '-0' : x.toString(10); + case '[object String]': + return typeof x === 'object' ? 'new String(' + recur(x.valueOf()) + ')' : _quote(x); + case '[object Undefined]': + return 'undefined'; + default: + if (typeof x.toString === 'function') { + var repr = x.toString(); + if (repr !== '[object Object]') { + return repr; + } + } + return '{' + mapPairs(x, keys(x)).join(', ') + '}'; + } +} + +/** + * Returns the string representation of the given value. `eval`'ing the output + * should result in a value equivalent to the input value. Many of the built-in + * `toString` methods do not satisfy this requirement. + * + * If the given value is an `[object Object]` with a `toString` method other + * than `Object.prototype.toString`, this method is invoked with no arguments + * to produce the return value. This means user-defined constructor functions + * can provide a suitable `toString` method. For example: + * + * function Point(x, y) { + * this.x = x; + * this.y = y; + * } + * + * Point.prototype.toString = function() { + * return 'new Point(' + this.x + ', ' + this.y + ')'; + * }; + * + * R.toString(new Point(1, 2)); //=> 'new Point(1, 2)' + * + * @func + * @memberOf R + * @since v0.14.0 + * @category String + * @sig * -> String + * @param {*} val + * @return {String} + * @example + * + * R.toString(42); //=> '42' + * R.toString('abc'); //=> '"abc"' + * R.toString([1, 2, 3]); //=> '[1, 2, 3]' + * R.toString({foo: 1, bar: 2, baz: 3}); //=> '{"bar": 2, "baz": 3, "foo": 1}' + * R.toString(new Date('2001-02-03T04:05:06Z')); //=> 'new Date("2001-02-03T04:05:06.000Z")' + */ +var toString$1 = _curry1(function toString(val) { return _toString(val, []); }); + +/** + * Returns the result of concatenating the given lists or strings. + * + * Note: `R.concat` expects both arguments to be of the same type, + * unlike the native `Array.prototype.concat` method. It will throw + * an error if you `concat` an Array with a non-Array value. + * + * Dispatches to the `concat` method of the first argument, if present. + * Can also concatenate two members of a [fantasy-land + * compatible semigroup](https://github.com/fantasyland/fantasy-land#semigroup). + * + * @func + * @memberOf R + * @since v0.1.0 + * @category List + * @sig [a] -> [a] -> [a] + * @sig String -> String -> String + * @param {Array|String} firstList The first list + * @param {Array|String} secondList The second list + * @return {Array|String} A list consisting of the elements of `firstList` followed by the elements of + * `secondList`. + * + * @example + * + * R.concat('ABC', 'DEF'); // 'ABCDEF' + * R.concat([4, 5, 6], [1, 2, 3]); //=> [4, 5, 6, 1, 2, 3] + * R.concat([], []); //=> [] + */ +var concat = _curry2(function concat(a, b) { + if (_isArray(a)) { + if (_isArray(b)) { + return a.concat(b); + } + throw new TypeError(toString$1(b) + ' is not an array'); + } + if (_isString(a)) { + if (_isString(b)) { + return a + b; + } + throw new TypeError(toString$1(b) + ' is not a string'); + } + if (a != null && _isFunction(a['fantasy-land/concat'])) { + return a['fantasy-land/concat'](b); + } + if (a != null && _isFunction(a.concat)) { + return a.concat(b); + } + throw new TypeError(toString$1(a) + ' does not have a method named "concat" or "fantasy-land/concat"'); +}); + +/** + * Returns a function, `fn`, which encapsulates `if/else, if/else, ...` logic. + * `R.cond` takes a list of [predicate, transformer] pairs. All of the arguments + * to `fn` are applied to each of the predicates in turn until one returns a + * "truthy" value, at which point `fn` returns the result of applying its + * arguments to the corresponding transformer. If none of the predicates + * matches, `fn` returns undefined. + * + * @func + * @memberOf R + * @since v0.6.0 + * @category Logic + * @sig [[(*... -> Boolean),(*... -> *)]] -> (*... -> *) + * @param {Array} pairs A list of [predicate, transformer] + * @return {Function} + * @see R.ifElse, R.unless, R.when + * @example + * + * const fn = R.cond([ + * [R.equals(0), R.always('water freezes at 0°C')], + * [R.equals(100), R.always('water boils at 100°C')], + * [R.T, temp => 'nothing special happens at ' + temp + '°C'] + * ]); + * fn(0); //=> 'water freezes at 0°C' + * fn(50); //=> 'nothing special happens at 50°C' + * fn(100); //=> 'water boils at 100°C' + */ +var cond = _curry1(function cond(pairs) { + var arity = reduce(max, + 0, + map(function(pair) { return pair[0].length; }, pairs)); + return _arity(arity, function() { + var idx = 0; + while (idx < pairs.length) { + if (pairs[idx][0].apply(this, arguments)) { + return pairs[idx][1].apply(this, arguments); + } + idx += 1; + } + }); +}); + +/** + * Wraps a constructor function inside a curried function that can be called + * with the same arguments and returns the same type. The arity of the function + * returned is specified to allow using variadic constructor functions. + * + * @func + * @memberOf R + * @since v0.4.0 + * @category Function + * @sig Number -> (* -> {*}) -> (* -> {*}) + * @param {Number} n The arity of the constructor function. + * @param {Function} Fn The constructor function to wrap. + * @return {Function} A wrapped, curried constructor function. + * @example + * + * // Variadic Constructor function + * function Salad() { + * this.ingredients = arguments; + * } + * + * Salad.prototype.recipe = function() { + * const instructions = R.map(ingredient => 'Add a dollop of ' + ingredient, this.ingredients); + * return R.join('\n', instructions); + * }; + * + * const ThreeLayerSalad = R.constructN(3, Salad); + * + * // Notice we no longer need the 'new' keyword, and the constructor is curried for 3 arguments. + * const salad = ThreeLayerSalad('Mayonnaise')('Potato Chips')('Ketchup'); + * + * console.log(salad.recipe()); + * // Add a dollop of Mayonnaise + * // Add a dollop of Potato Chips + * // Add a dollop of Ketchup + */ +var constructN = _curry2(function constructN(n, Fn) { + if (n > 10) { + throw new Error('Constructor with greater than ten arguments'); + } + if (n === 0) { + return function() { return new Fn(); }; + } + return curry(nAry(n, function($0, $1, $2, $3, $4, $5, $6, $7, $8, $9) { + switch (arguments.length) { + case 1: return new Fn($0); + case 2: return new Fn($0, $1); + case 3: return new Fn($0, $1, $2); + case 4: return new Fn($0, $1, $2, $3); + case 5: return new Fn($0, $1, $2, $3, $4); + case 6: return new Fn($0, $1, $2, $3, $4, $5); + case 7: return new Fn($0, $1, $2, $3, $4, $5, $6); + case 8: return new Fn($0, $1, $2, $3, $4, $5, $6, $7); + case 9: return new Fn($0, $1, $2, $3, $4, $5, $6, $7, $8); + case 10: return new Fn($0, $1, $2, $3, $4, $5, $6, $7, $8, $9); + } + })); +}); + +/** + * Wraps a constructor function inside a curried function that can be called + * with the same arguments and returns the same type. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Function + * @sig (* -> {*}) -> (* -> {*}) + * @param {Function} fn The constructor function to wrap. + * @return {Function} A wrapped, curried constructor function. + * @see R.invoker + * @example + * + * // Constructor function + * function Animal(kind) { + * this.kind = kind; + * }; + * Animal.prototype.sighting = function() { + * return "It's a " + this.kind + "!"; + * } + * + * const AnimalConstructor = R.construct(Animal) + * + * // Notice we no longer need the 'new' keyword: + * AnimalConstructor('Pig'); //=> {"kind": "Pig", "sighting": function (){...}}; + * + * const animalTypes = ["Lion", "Tiger", "Bear"]; + * const animalSighting = R.invoker(0, 'sighting'); + * const sightNewAnimal = R.compose(animalSighting, AnimalConstructor); + * R.map(sightNewAnimal, animalTypes); //=> ["It's a Lion!", "It's a Tiger!", "It's a Bear!"] + */ +var construct = _curry1(function construct(Fn) { + return constructN(Fn.length, Fn); +}); + +/** + * Returns `true` if the specified value is equal, in [`R.equals`](#equals) + * terms, to at least one element of the given list; `false` otherwise. + * Works also with strings. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category List + * @sig a -> [a] -> Boolean + * @param {Object} a The item to compare against. + * @param {Array} list The array to consider. + * @return {Boolean} `true` if an equivalent item is in the list, `false` otherwise. + * @see R.includes + * @deprecated since v0.26.0 + * @example + * + * R.contains(3, [1, 2, 3]); //=> true + * R.contains(4, [1, 2, 3]); //=> false + * R.contains({ name: 'Fred' }, [{ name: 'Fred' }]); //=> true + * R.contains([42], [[42]]); //=> true + * R.contains('ba', 'banana'); //=>true + */ +var contains$1 = _curry2(_includes); + +/** + * Accepts a converging function and a list of branching functions and returns + * a new function. The arity of the new function is the same as the arity of + * the longest branching function. When invoked, this new function is applied + * to some arguments, and each branching function is applied to those same + * arguments. The results of each branching function are passed as arguments + * to the converging function to produce the return value. + * + * @func + * @memberOf R + * @since v0.4.2 + * @category Function + * @sig ((x1, x2, ...) -> z) -> [((a, b, ...) -> x1), ((a, b, ...) -> x2), ...] -> (a -> b -> ... -> z) + * @param {Function} after A function. `after` will be invoked with the return values of + * `fn1` and `fn2` as its arguments. + * @param {Array} functions A list of functions. + * @return {Function} A new function. + * @see R.useWith + * @example + * + * const average = R.converge(R.divide, [R.sum, R.length]) + * average([1, 2, 3, 4, 5, 6, 7]) //=> 4 + * + * const strangeConcat = R.converge(R.concat, [R.toUpper, R.toLower]) + * strangeConcat("Yodel") //=> "YODELyodel" + * + * @symb R.converge(f, [g, h])(a, b) = f(g(a, b), h(a, b)) + */ +var converge = _curry2(function converge(after, fns) { + return curryN(reduce(max, 0, pluck('length', fns)), function() { + var args = arguments; + var context = this; + return after.apply(context, _map(function(fn) { + return fn.apply(context, args); + }, fns)); + }); +}); + +function XReduceBy(valueFn, valueAcc, keyFn, xf) { + this.valueFn = valueFn; + this.valueAcc = valueAcc; + this.keyFn = keyFn; + this.xf = xf; + this.inputs = {}; +} +XReduceBy.prototype['@@transducer/init'] = _xfBase.init; +XReduceBy.prototype['@@transducer/result'] = function(result) { + var key; + for (key in this.inputs) { + if (_has(key, this.inputs)) { + result = this.xf['@@transducer/step'](result, this.inputs[key]); + if (result['@@transducer/reduced']) { + result = result['@@transducer/value']; + break; + } + } + } + this.inputs = null; + return this.xf['@@transducer/result'](result); +}; +XReduceBy.prototype['@@transducer/step'] = function(result, input) { + var key = this.keyFn(input); + this.inputs[key] = this.inputs[key] || [key, this.valueAcc]; + this.inputs[key][1] = this.valueFn(this.inputs[key][1], input); + return result; +}; + +var _xreduceBy = _curryN(4, [], + function _xreduceBy(valueFn, valueAcc, keyFn, xf) { + return new XReduceBy(valueFn, valueAcc, keyFn, xf); + }); + +/** + * Groups the elements of the list according to the result of calling + * the String-returning function `keyFn` on each element and reduces the elements + * of each group to a single value via the reducer function `valueFn`. + * + * This function is basically a more general [`groupBy`](#groupBy) function. + * + * Acts as a transducer if a transformer is given in list position. + * + * @func + * @memberOf R + * @since v0.20.0 + * @category List + * @sig ((a, b) -> a) -> a -> (b -> String) -> [b] -> {String: a} + * @param {Function} valueFn The function that reduces the elements of each group to a single + * value. Receives two values, accumulator for a particular group and the current element. + * @param {*} acc The (initial) accumulator value for each group. + * @param {Function} keyFn The function that maps the list's element into a key. + * @param {Array} list The array to group. + * @return {Object} An object with the output of `keyFn` for keys, mapped to the output of + * `valueFn` for elements which produced that key when passed to `keyFn`. + * @see R.groupBy, R.reduce + * @example + * + * const groupNames = (acc, {name}) => acc.concat(name) + * const toGrade = ({score}) => + * score < 65 ? 'F' : + * score < 70 ? 'D' : + * score < 80 ? 'C' : + * score < 90 ? 'B' : 'A' + * + * var students = [ + * {name: 'Abby', score: 83}, + * {name: 'Bart', score: 62}, + * {name: 'Curt', score: 88}, + * {name: 'Dora', score: 92}, + * ] + * + * reduceBy(groupNames, [], toGrade, students) + * //=> {"A": ["Dora"], "B": ["Abby", "Curt"], "F": ["Bart"]} + */ +var reduceBy = _curryN(4, [], _dispatchable([], _xreduceBy, + function reduceBy(valueFn, valueAcc, keyFn, list) { + return _reduce(function(acc, elt) { + var key = keyFn(elt); + acc[key] = valueFn(_has(key, acc) ? acc[key] : valueAcc, elt); + return acc; + }, {}, list); + })); + +/** + * Counts the elements of a list according to how many match each value of a + * key generated by the supplied function. Returns an object mapping the keys + * produced by `fn` to the number of occurrences in the list. Note that all + * keys are coerced to strings because of how JavaScript objects work. + * + * Acts as a transducer if a transformer is given in list position. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Relation + * @sig (a -> String) -> [a] -> {*} + * @param {Function} fn The function used to map values to keys. + * @param {Array} list The list to count elements from. + * @return {Object} An object mapping keys to number of occurrences in the list. + * @example + * + * const numbers = [1.0, 1.1, 1.2, 2.0, 3.0, 2.2]; + * R.countBy(Math.floor)(numbers); //=> {'1': 3, '2': 2, '3': 1} + * + * const letters = ['a', 'b', 'A', 'a', 'B', 'c']; + * R.countBy(R.toLower)(letters); //=> {'a': 3, 'b': 2, 'c': 1} + */ +var countBy = reduceBy(function(acc, elem) { return acc + 1; }, 0); + +/** + * Decrements its argument. + * + * @func + * @memberOf R + * @since v0.9.0 + * @category Math + * @sig Number -> Number + * @param {Number} n + * @return {Number} n - 1 + * @see R.inc + * @example + * + * R.dec(42); //=> 41 + */ +var dec = add(-1); + +/** + * Returns the second argument if it is not `null`, `undefined` or `NaN`; + * otherwise the first argument is returned. + * + * @func + * @memberOf R + * @since v0.10.0 + * @category Logic + * @sig a -> b -> a | b + * @param {a} default The default value. + * @param {b} val `val` will be returned instead of `default` unless `val` is `null`, `undefined` or `NaN`. + * @return {*} The second value if it is not `null`, `undefined` or `NaN`, otherwise the default value + * @example + * + * const defaultTo42 = R.defaultTo(42); + * + * defaultTo42(null); //=> 42 + * defaultTo42(undefined); //=> 42 + * defaultTo42(false); //=> false + * defaultTo42('Ramda'); //=> 'Ramda' + * // parseInt('string') results in NaN + * defaultTo42(parseInt('string')); //=> 42 + */ +var defaultTo = _curry2(function defaultTo(d, v) { + return v == null || v !== v ? d : v; +}); + +/** + * Makes a descending comparator function out of a function that returns a value + * that can be compared with `<` and `>`. + * + * @func + * @memberOf R + * @since v0.23.0 + * @category Function + * @sig Ord b => (a -> b) -> a -> a -> Number + * @param {Function} fn A function of arity one that returns a value that can be compared + * @param {*} a The first item to be compared. + * @param {*} b The second item to be compared. + * @return {Number} `-1` if fn(a) > fn(b), `1` if fn(b) > fn(a), otherwise `0` + * @see R.ascend + * @example + * + * const byAge = R.descend(R.prop('age')); + * const people = [ + * { name: 'Emma', age: 70 }, + * { name: 'Peter', age: 78 }, + * { name: 'Mikhail', age: 62 }, + * ]; + * const peopleByOldestFirst = R.sort(byAge, people); + * //=> [{ name: 'Peter', age: 78 }, { name: 'Emma', age: 70 }, { name: 'Mikhail', age: 62 }] + */ +var descend = _curry3(function descend(fn, a, b) { + var aa = fn(a); + var bb = fn(b); + return aa > bb ? -1 : aa < bb ? 1 : 0; +}); + +function _Set() { + /* globals Set */ + this._nativeSet = typeof Set === 'function' ? new Set() : null; + this._items = {}; +} + +// until we figure out why jsdoc chokes on this +// @param item The item to add to the Set +// @returns {boolean} true if the item did not exist prior, otherwise false +// +_Set.prototype.add = function(item) { + return !hasOrAdd(item, true, this); +}; + +// +// @param item The item to check for existence in the Set +// @returns {boolean} true if the item exists in the Set, otherwise false +// +_Set.prototype.has = function(item) { + return hasOrAdd(item, false, this); +}; + +// +// Combines the logic for checking whether an item is a member of the set and +// for adding a new item to the set. +// +// @param item The item to check or add to the Set instance. +// @param shouldAdd If true, the item will be added to the set if it doesn't +// already exist. +// @param set The set instance to check or add to. +// @return {boolean} true if the item already existed, otherwise false. +// +function hasOrAdd(item, shouldAdd, set) { + var type = typeof item; + var prevSize, newSize; + switch (type) { + case 'string': + case 'number': + // distinguish between +0 and -0 + if (item === 0 && 1 / item === -Infinity) { + if (set._items['-0']) { + return true; + } else { + if (shouldAdd) { + set._items['-0'] = true; + } + return false; + } + } + // these types can all utilise the native Set + if (set._nativeSet !== null) { + if (shouldAdd) { + prevSize = set._nativeSet.size; + set._nativeSet.add(item); + newSize = set._nativeSet.size; + return newSize === prevSize; + } else { + return set._nativeSet.has(item); + } + } else { + if (!(type in set._items)) { + if (shouldAdd) { + set._items[type] = {}; + set._items[type][item] = true; + } + return false; + } else if (item in set._items[type]) { + return true; + } else { + if (shouldAdd) { + set._items[type][item] = true; + } + return false; + } + } + + case 'boolean': + // set._items['boolean'] holds a two element array + // representing [ falseExists, trueExists ] + if (type in set._items) { + var bIdx = item ? 1 : 0; + if (set._items[type][bIdx]) { + return true; + } else { + if (shouldAdd) { + set._items[type][bIdx] = true; + } + return false; + } + } else { + if (shouldAdd) { + set._items[type] = item ? [false, true] : [true, false]; + } + return false; + } + + case 'function': + // compare functions for reference equality + if (set._nativeSet !== null) { + if (shouldAdd) { + prevSize = set._nativeSet.size; + set._nativeSet.add(item); + newSize = set._nativeSet.size; + return newSize === prevSize; + } else { + return set._nativeSet.has(item); + } + } else { + if (!(type in set._items)) { + if (shouldAdd) { + set._items[type] = [item]; + } + return false; + } + if (!_includes(item, set._items[type])) { + if (shouldAdd) { + set._items[type].push(item); + } + return false; + } + return true; + } + + case 'undefined': + if (set._items[type]) { + return true; + } else { + if (shouldAdd) { + set._items[type] = true; + } + return false; + } + + case 'object': + if (item === null) { + if (!set._items['null']) { + if (shouldAdd) { + set._items['null'] = true; + } + return false; + } + return true; + } + /* falls through */ + default: + // reduce the search size of heterogeneous sets by creating buckets + // for each type. + type = Object.prototype.toString.call(item); + if (!(type in set._items)) { + if (shouldAdd) { + set._items[type] = [item]; + } + return false; + } + // scan through all previously applied items + if (!_includes(item, set._items[type])) { + if (shouldAdd) { + set._items[type].push(item); + } + return false; + } + return true; + } +} + +/** + * Finds the set (i.e. no duplicates) of all elements in the first list not + * contained in the second list. Objects and Arrays are compared in terms of + * value equality, not reference equality. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Relation + * @sig [*] -> [*] -> [*] + * @param {Array} list1 The first list. + * @param {Array} list2 The second list. + * @return {Array} The elements in `list1` that are not in `list2`. + * @see R.differenceWith, R.symmetricDifference, R.symmetricDifferenceWith, R.without + * @example + * + * R.difference([1,2,3,4], [7,6,5,4,3]); //=> [1,2] + * R.difference([7,6,5,4,3], [1,2,3,4]); //=> [7,6,5] + * R.difference([{a: 1}, {b: 2}], [{a: 1}, {c: 3}]) //=> [{b: 2}] + */ +var difference = _curry2(function difference(first, second) { + var out = []; + var idx = 0; + var firstLen = first.length; + var secondLen = second.length; + var toFilterOut = new _Set(); + + for (var i = 0; i < secondLen; i += 1) { + toFilterOut.add(second[i]); + } + + while (idx < firstLen) { + if (toFilterOut.add(first[idx])) { + out[out.length] = first[idx]; + } + idx += 1; + } + return out; +}); + +/** + * Finds the set (i.e. no duplicates) of all elements in the first list not + * contained in the second list. Duplication is determined according to the + * value returned by applying the supplied predicate to two list elements. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Relation + * @sig ((a, a) -> Boolean) -> [a] -> [a] -> [a] + * @param {Function} pred A predicate used to test whether two items are equal. + * @param {Array} list1 The first list. + * @param {Array} list2 The second list. + * @return {Array} The elements in `list1` that are not in `list2`. + * @see R.difference, R.symmetricDifference, R.symmetricDifferenceWith + * @example + * + * const cmp = (x, y) => x.a === y.a; + * const l1 = [{a: 1}, {a: 2}, {a: 3}]; + * const l2 = [{a: 3}, {a: 4}]; + * R.differenceWith(cmp, l1, l2); //=> [{a: 1}, {a: 2}] + */ +var differenceWith = _curry3(function differenceWith(pred, first, second) { + var out = []; + var idx = 0; + var firstLen = first.length; + while (idx < firstLen) { + if (!_includesWith(pred, first[idx], second) && + !_includesWith(pred, first[idx], out)) { + out.push(first[idx]); + } + idx += 1; + } + return out; +}); + +/** + * Returns a new object that does not contain a `prop` property. + * + * @func + * @memberOf R + * @since v0.10.0 + * @category Object + * @sig String -> {k: v} -> {k: v} + * @param {String} prop The name of the property to dissociate + * @param {Object} obj The object to clone + * @return {Object} A new object equivalent to the original but without the specified property + * @see R.assoc, R.omit + * @example + * + * R.dissoc('b', {a: 1, b: 2, c: 3}); //=> {a: 1, c: 3} + */ +var dissoc = _curry2(function dissoc(prop, obj) { + var result = {}; + for (var p in obj) { + result[p] = obj[p]; + } + delete result[prop]; + return result; +}); + +/** + * Removes the sub-list of `list` starting at index `start` and containing + * `count` elements. _Note that this is not destructive_: it returns a copy of + * the list with the changes. + * No lists have been harmed in the application of this function. + * + * @func + * @memberOf R + * @since v0.2.2 + * @category List + * @sig Number -> Number -> [a] -> [a] + * @param {Number} start The position to start removing elements + * @param {Number} count The number of elements to remove + * @param {Array} list The list to remove from + * @return {Array} A new Array with `count` elements from `start` removed. + * @see R.without + * @example + * + * R.remove(2, 3, [1,2,3,4,5,6,7,8]); //=> [1,2,6,7,8] + */ +var remove = _curry3(function remove(start, count, list) { + var result = Array.prototype.slice.call(list, 0); + result.splice(start, count); + return result; +}); + +/** + * Returns a new copy of the array with the element at the provided index + * replaced with the given value. + * + * @func + * @memberOf R + * @since v0.14.0 + * @category List + * @sig Number -> a -> [a] -> [a] + * @param {Number} idx The index to update. + * @param {*} x The value to exist at the given index of the returned array. + * @param {Array|Arguments} list The source array-like object to be updated. + * @return {Array} A copy of `list` with the value at index `idx` replaced with `x`. + * @see R.adjust + * @example + * + * R.update(1, '_', ['a', 'b', 'c']); //=> ['a', '_', 'c'] + * R.update(-1, '_', ['a', 'b', 'c']); //=> ['a', 'b', '_'] + * @symb R.update(-1, a, [b, c]) = [b, a] + * @symb R.update(0, a, [b, c]) = [a, c] + * @symb R.update(1, a, [b, c]) = [b, a] + */ +var update = _curry3(function update(idx, x, list) { + return adjust(idx, always(x), list); +}); + +/** + * Makes a shallow clone of an object, omitting the property at the given path. + * Note that this copies and flattens prototype properties onto the new object + * as well. All non-primitive properties are copied by reference. + * + * @func + * @memberOf R + * @since v0.11.0 + * @category Object + * @typedefn Idx = String | Int + * @sig [Idx] -> {k: v} -> {k: v} + * @param {Array} path The path to the value to omit + * @param {Object} obj The object to clone + * @return {Object} A new object without the property at path + * @see R.assocPath + * @example + * + * R.dissocPath(['a', 'b', 'c'], {a: {b: {c: 42}}}); //=> {a: {b: {}}} + */ +var dissocPath = _curry2(function dissocPath(path, obj) { + switch (path.length) { + case 0: + return obj; + case 1: + return _isInteger(path[0]) && _isArray(obj) ? remove(path[0], 1, obj) : dissoc(path[0], obj); + default: + var head = path[0]; + var tail = Array.prototype.slice.call(path, 1); + if (obj[head] == null) { + return obj; + } else if (_isInteger(head) && _isArray(obj)) { + return update(head, dissocPath(tail, obj[head]), obj); + } else { + return assoc(head, dissocPath(tail, obj[head]), obj); + } + } +}); + +/** + * Divides two numbers. Equivalent to `a / b`. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Math + * @sig Number -> Number -> Number + * @param {Number} a The first value. + * @param {Number} b The second value. + * @return {Number} The result of `a / b`. + * @see R.multiply + * @example + * + * R.divide(71, 100); //=> 0.71 + * + * const half = R.divide(R.__, 2); + * half(42); //=> 21 + * + * const reciprocal = R.divide(1); + * reciprocal(4); //=> 0.25 + */ +var divide = _curry2(function divide(a, b) { return a / b; }); + +function XDrop(n, xf) { + this.xf = xf; + this.n = n; +} +XDrop.prototype['@@transducer/init'] = _xfBase.init; +XDrop.prototype['@@transducer/result'] = _xfBase.result; +XDrop.prototype['@@transducer/step'] = function(result, input) { + if (this.n > 0) { + this.n -= 1; + return result; + } + return this.xf['@@transducer/step'](result, input); +}; + +var _xdrop = _curry2(function _xdrop(n, xf) { return new XDrop(n, xf); }); + +/** + * Returns all but the first `n` elements of the given list, string, or + * transducer/transformer (or object with a `drop` method). + * + * Dispatches to the `drop` method of the second argument, if present. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category List + * @sig Number -> [a] -> [a] + * @sig Number -> String -> String + * @param {Number} n + * @param {*} list + * @return {*} A copy of list without the first `n` elements + * @see R.take, R.transduce, R.dropLast, R.dropWhile + * @example + * + * R.drop(1, ['foo', 'bar', 'baz']); //=> ['bar', 'baz'] + * R.drop(2, ['foo', 'bar', 'baz']); //=> ['baz'] + * R.drop(3, ['foo', 'bar', 'baz']); //=> [] + * R.drop(4, ['foo', 'bar', 'baz']); //=> [] + * R.drop(3, 'ramda'); //=> 'da' + */ +var drop = _curry2(_dispatchable(['drop'], _xdrop, function drop(n, xs) { + return slice(Math.max(0, n), Infinity, xs); +})); + +function XTake(n, xf) { + this.xf = xf; + this.n = n; + this.i = 0; +} +XTake.prototype['@@transducer/init'] = _xfBase.init; +XTake.prototype['@@transducer/result'] = _xfBase.result; +XTake.prototype['@@transducer/step'] = function(result, input) { + this.i += 1; + var ret = this.n === 0 ? result : this.xf['@@transducer/step'](result, input); + return this.n >= 0 && this.i >= this.n ? _reduced(ret) : ret; +}; + +var _xtake = _curry2(function _xtake(n, xf) { return new XTake(n, xf); }); + +/** + * Returns the first `n` elements of the given list, string, or + * transducer/transformer (or object with a `take` method). + * + * Dispatches to the `take` method of the second argument, if present. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category List + * @sig Number -> [a] -> [a] + * @sig Number -> String -> String + * @param {Number} n + * @param {*} list + * @return {*} + * @see R.drop + * @example + * + * R.take(1, ['foo', 'bar', 'baz']); //=> ['foo'] + * R.take(2, ['foo', 'bar', 'baz']); //=> ['foo', 'bar'] + * R.take(3, ['foo', 'bar', 'baz']); //=> ['foo', 'bar', 'baz'] + * R.take(4, ['foo', 'bar', 'baz']); //=> ['foo', 'bar', 'baz'] + * R.take(3, 'ramda'); //=> 'ram' + * + * const personnel = [ + * 'Dave Brubeck', + * 'Paul Desmond', + * 'Eugene Wright', + * 'Joe Morello', + * 'Gerry Mulligan', + * 'Bob Bates', + * 'Joe Dodge', + * 'Ron Crotty' + * ]; + * + * const takeFive = R.take(5); + * takeFive(personnel); + * //=> ['Dave Brubeck', 'Paul Desmond', 'Eugene Wright', 'Joe Morello', 'Gerry Mulligan'] + * @symb R.take(-1, [a, b]) = [a, b] + * @symb R.take(0, [a, b]) = [] + * @symb R.take(1, [a, b]) = [a] + * @symb R.take(2, [a, b]) = [a, b] + */ +var take = _curry2(_dispatchable(['take'], _xtake, function take(n, xs) { + return slice(0, n < 0 ? Infinity : n, xs); +})); + +function dropLast$2(n, xs) { + return take(n < xs.length ? xs.length - n : 0, xs); +} + +function XDropLast(n, xf) { + this.xf = xf; + this.pos = 0; + this.full = false; + this.acc = new Array(n); +} +XDropLast.prototype['@@transducer/init'] = _xfBase.init; +XDropLast.prototype['@@transducer/result'] = function(result) { + this.acc = null; + return this.xf['@@transducer/result'](result); +}; +XDropLast.prototype['@@transducer/step'] = function(result, input) { + if (this.full) { + result = this.xf['@@transducer/step'](result, this.acc[this.pos]); + } + this.store(input); + return result; +}; +XDropLast.prototype.store = function(input) { + this.acc[this.pos] = input; + this.pos += 1; + if (this.pos === this.acc.length) { + this.pos = 0; + this.full = true; + } +}; + +var _xdropLast = _curry2(function _xdropLast(n, xf) { return new XDropLast(n, xf); }); + +/** + * Returns a list containing all but the last `n` elements of the given `list`. + * + * Acts as a transducer if a transformer is given in list position. + * + * @func + * @memberOf R + * @since v0.16.0 + * @category List + * @sig Number -> [a] -> [a] + * @sig Number -> String -> String + * @param {Number} n The number of elements of `list` to skip. + * @param {Array} list The list of elements to consider. + * @return {Array} A copy of the list with only the first `list.length - n` elements + * @see R.takeLast, R.drop, R.dropWhile, R.dropLastWhile + * @example + * + * R.dropLast(1, ['foo', 'bar', 'baz']); //=> ['foo', 'bar'] + * R.dropLast(2, ['foo', 'bar', 'baz']); //=> ['foo'] + * R.dropLast(3, ['foo', 'bar', 'baz']); //=> [] + * R.dropLast(4, ['foo', 'bar', 'baz']); //=> [] + * R.dropLast(3, 'ramda'); //=> 'ra' + */ +var dropLast = _curry2(_dispatchable([], _xdropLast, dropLast$2)); + +function dropLastWhile$2(pred, xs) { + var idx = xs.length - 1; + while (idx >= 0 && pred(xs[idx])) { + idx -= 1; + } + return slice(0, idx + 1, xs); +} + +function XDropLastWhile(fn, xf) { + this.f = fn; + this.retained = []; + this.xf = xf; +} +XDropLastWhile.prototype['@@transducer/init'] = _xfBase.init; +XDropLastWhile.prototype['@@transducer/result'] = function(result) { + this.retained = null; + return this.xf['@@transducer/result'](result); +}; +XDropLastWhile.prototype['@@transducer/step'] = function(result, input) { + return this.f(input) ? this.retain(result, input) + : this.flush(result, input); +}; +XDropLastWhile.prototype.flush = function(result, input) { + result = _reduce( + this.xf['@@transducer/step'], + result, + this.retained + ); + this.retained = []; + return this.xf['@@transducer/step'](result, input); +}; +XDropLastWhile.prototype.retain = function(result, input) { + this.retained.push(input); + return result; +}; + +var _xdropLastWhile = _curry2(function _xdropLastWhile(fn, xf) { return new XDropLastWhile(fn, xf); }); + +/** + * Returns a new list excluding all the tailing elements of a given list which + * satisfy the supplied predicate function. It passes each value from the right + * to the supplied predicate function, skipping elements until the predicate + * function returns a `falsy` value. The predicate function is applied to one argument: + * *(value)*. + * + * Acts as a transducer if a transformer is given in list position. + * + * @func + * @memberOf R + * @since v0.16.0 + * @category List + * @sig (a -> Boolean) -> [a] -> [a] + * @sig (a -> Boolean) -> String -> String + * @param {Function} predicate The function to be called on each element + * @param {Array} xs The collection to iterate over. + * @return {Array} A new array without any trailing elements that return `falsy` values from the `predicate`. + * @see R.takeLastWhile, R.addIndex, R.drop, R.dropWhile + * @example + * + * const lteThree = x => x <= 3; + * + * R.dropLastWhile(lteThree, [1, 2, 3, 4, 3, 2, 1]); //=> [1, 2, 3, 4] + * + * R.dropLastWhile(x => x !== 'd' , 'Ramda'); //=> 'Ramd' + */ +var dropLastWhile = _curry2(_dispatchable([], _xdropLastWhile, dropLastWhile$2)); + +function XDropRepeatsWith(pred, xf) { + this.xf = xf; + this.pred = pred; + this.lastValue = undefined; + this.seenFirstValue = false; +} + +XDropRepeatsWith.prototype['@@transducer/init'] = _xfBase.init; +XDropRepeatsWith.prototype['@@transducer/result'] = _xfBase.result; +XDropRepeatsWith.prototype['@@transducer/step'] = function(result, input) { + var sameAsLast = false; + if (!this.seenFirstValue) { + this.seenFirstValue = true; + } else if (this.pred(this.lastValue, input)) { + sameAsLast = true; + } + this.lastValue = input; + return sameAsLast ? result : this.xf['@@transducer/step'](result, input); +}; + +var _xdropRepeatsWith = _curry2(function _xdropRepeatsWith(pred, xf) { return new XDropRepeatsWith(pred, xf); }); + +/** + * Returns the last element of the given list or string. + * + * @func + * @memberOf R + * @since v0.1.4 + * @category List + * @sig [a] -> a | Undefined + * @sig String -> String + * @param {*} list + * @return {*} + * @see R.init, R.head, R.tail + * @example + * + * R.last(['fi', 'fo', 'fum']); //=> 'fum' + * R.last([]); //=> undefined + * + * R.last('abc'); //=> 'c' + * R.last(''); //=> '' + */ +var last = nth(-1); + +/** + * Returns a new list without any consecutively repeating elements. Equality is + * determined by applying the supplied predicate to each pair of consecutive elements. The + * first element in a series of equal elements will be preserved. + * + * Acts as a transducer if a transformer is given in list position. + * + * @func + * @memberOf R + * @since v0.14.0 + * @category List + * @sig ((a, a) -> Boolean) -> [a] -> [a] + * @param {Function} pred A predicate used to test whether two items are equal. + * @param {Array} list The array to consider. + * @return {Array} `list` without repeating elements. + * @see R.transduce + * @example + * + * const l = [1, -1, 1, 3, 4, -4, -4, -5, 5, 3, 3]; + * R.dropRepeatsWith(R.eqBy(Math.abs), l); //=> [1, 3, 4, -5, 3] + */ +var dropRepeatsWith = _curry2(_dispatchable([], _xdropRepeatsWith, function dropRepeatsWith(pred, list) { + var result = []; + var idx = 1; + var len = list.length; + if (len !== 0) { + result[0] = list[0]; + while (idx < len) { + if (!pred(last(result), list[idx])) { + result[result.length] = list[idx]; + } + idx += 1; + } + } + return result; +})); + +/** + * Returns a new list without any consecutively repeating elements. + * [`R.equals`](#equals) is used to determine equality. + * + * Acts as a transducer if a transformer is given in list position. + * + * @func + * @memberOf R + * @since v0.14.0 + * @category List + * @sig [a] -> [a] + * @param {Array} list The array to consider. + * @return {Array} `list` without repeating elements. + * @see R.transduce + * @example + * + * R.dropRepeats([1, 1, 1, 2, 3, 4, 4, 2, 2]); //=> [1, 2, 3, 4, 2] + */ +var dropRepeats = _curry1(_dispatchable([], + _xdropRepeatsWith(equals), + dropRepeatsWith(equals))); + +function XDropWhile(f, xf) { + this.xf = xf; + this.f = f; +} +XDropWhile.prototype['@@transducer/init'] = _xfBase.init; +XDropWhile.prototype['@@transducer/result'] = _xfBase.result; +XDropWhile.prototype['@@transducer/step'] = function(result, input) { + if (this.f) { + if (this.f(input)) { + return result; + } + this.f = null; + } + return this.xf['@@transducer/step'](result, input); +}; + +var _xdropWhile = _curry2(function _xdropWhile(f, xf) { return new XDropWhile(f, xf); }); + +/** + * Returns a new list excluding the leading elements of a given list which + * satisfy the supplied predicate function. It passes each value to the supplied + * predicate function, skipping elements while the predicate function returns + * `true`. The predicate function is applied to one argument: *(value)*. + * + * Dispatches to the `dropWhile` method of the second argument, if present. + * + * Acts as a transducer if a transformer is given in list position. + * + * @func + * @memberOf R + * @since v0.9.0 + * @category List + * @sig (a -> Boolean) -> [a] -> [a] + * @sig (a -> Boolean) -> String -> String + * @param {Function} fn The function called per iteration. + * @param {Array} xs The collection to iterate over. + * @return {Array} A new array. + * @see R.takeWhile, R.transduce, R.addIndex + * @example + * + * const lteTwo = x => x <= 2; + * + * R.dropWhile(lteTwo, [1, 2, 3, 4, 3, 2, 1]); //=> [3, 4, 3, 2, 1] + * + * R.dropWhile(x => x !== 'd' , 'Ramda'); //=> 'da' + */ +var dropWhile = _curry2(_dispatchable(['dropWhile'], _xdropWhile, function dropWhile(pred, xs) { + var idx = 0; + var len = xs.length; + while (idx < len && pred(xs[idx])) { + idx += 1; + } + return slice(idx, Infinity, xs); +})); + +/** + * Returns `true` if one or both of its arguments are `true`. Returns `false` + * if both arguments are `false`. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Logic + * @sig a -> b -> a | b + * @param {Any} a + * @param {Any} b + * @return {Any} the first argument if truthy, otherwise the second argument. + * @see R.either + * @example + * + * R.or(true, true); //=> true + * R.or(true, false); //=> true + * R.or(false, true); //=> true + * R.or(false, false); //=> false + */ +var or = _curry2(function or(a, b) { + return a || b; +}); + +/** + * A function wrapping calls to the two functions in an `||` operation, + * returning the result of the first function if it is truth-y and the result + * of the second function otherwise. Note that this is short-circuited, + * meaning that the second function will not be invoked if the first returns a + * truth-y value. + * + * In addition to functions, `R.either` also accepts any fantasy-land compatible + * applicative functor. + * + * @func + * @memberOf R + * @since v0.12.0 + * @category Logic + * @sig (*... -> Boolean) -> (*... -> Boolean) -> (*... -> Boolean) + * @param {Function} f a predicate + * @param {Function} g another predicate + * @return {Function} a function that applies its arguments to `f` and `g` and `||`s their outputs together. + * @see R.or + * @example + * + * const gt10 = x => x > 10; + * const even = x => x % 2 === 0; + * const f = R.either(gt10, even); + * f(101); //=> true + * f(8); //=> true + * + * R.either(Maybe.Just(false), Maybe.Just(55)); // => Maybe.Just(55) + * R.either([false, false, 'a'], [11]) // => [11, 11, "a"] + */ +var either = _curry2(function either(f, g) { + return _isFunction(f) ? + function _either() { + return f.apply(this, arguments) || g.apply(this, arguments); + } : + lift(or)(f, g); +}); + +/** + * Returns the empty value of its argument's type. Ramda defines the empty + * value of Array (`[]`), Object (`{}`), String (`''`), and Arguments. Other + * types are supported if they define `.empty`, + * `.prototype.empty` or implement the + * [FantasyLand Monoid spec](https://github.com/fantasyland/fantasy-land#monoid). + * + * Dispatches to the `empty` method of the first argument, if present. + * + * @func + * @memberOf R + * @since v0.3.0 + * @category Function + * @sig a -> a + * @param {*} x + * @return {*} + * @example + * + * R.empty(Just(42)); //=> Nothing() + * R.empty([1, 2, 3]); //=> [] + * R.empty('unicorns'); //=> '' + * R.empty({x: 1, y: 2}); //=> {} + */ +var empty = _curry1(function empty(x) { + return ( + (x != null && typeof x['fantasy-land/empty'] === 'function') ? + x['fantasy-land/empty']() : + (x != null && x.constructor != null && typeof x.constructor['fantasy-land/empty'] === 'function') ? + x.constructor['fantasy-land/empty']() : + (x != null && typeof x.empty === 'function') ? + x.empty() : + (x != null && x.constructor != null && typeof x.constructor.empty === 'function') ? + x.constructor.empty() : + _isArray(x) ? + [] : + _isString(x) ? + '' : + _isObject(x) ? + {} : + _isArguments(x) ? + (function() { return arguments; }()) : + // else + void 0 + ); +}); + +/** + * Returns a new list containing the last `n` elements of the given list. + * If `n > list.length`, returns a list of `list.length` elements. + * + * @func + * @memberOf R + * @since v0.16.0 + * @category List + * @sig Number -> [a] -> [a] + * @sig Number -> String -> String + * @param {Number} n The number of elements to return. + * @param {Array} xs The collection to consider. + * @return {Array} + * @see R.dropLast + * @example + * + * R.takeLast(1, ['foo', 'bar', 'baz']); //=> ['baz'] + * R.takeLast(2, ['foo', 'bar', 'baz']); //=> ['bar', 'baz'] + * R.takeLast(3, ['foo', 'bar', 'baz']); //=> ['foo', 'bar', 'baz'] + * R.takeLast(4, ['foo', 'bar', 'baz']); //=> ['foo', 'bar', 'baz'] + * R.takeLast(3, 'ramda'); //=> 'mda' + */ +var takeLast = _curry2(function takeLast(n, xs) { + return drop(n >= 0 ? xs.length - n : 0, xs); +}); + +/** + * Checks if a list ends with the provided sublist. + * + * Similarly, checks if a string ends with the provided substring. + * + * @func + * @memberOf R + * @since v0.24.0 + * @category List + * @sig [a] -> [a] -> Boolean + * @sig String -> String -> Boolean + * @param {*} suffix + * @param {*} list + * @return {Boolean} + * @see R.startsWith + * @example + * + * R.endsWith('c', 'abc') //=> true + * R.endsWith('b', 'abc') //=> false + * R.endsWith(['c'], ['a', 'b', 'c']) //=> true + * R.endsWith(['b'], ['a', 'b', 'c']) //=> false + */ +var endsWith = _curry2(function(suffix, list) { + return equals(takeLast(suffix.length, list), suffix); +}); + +/** + * Takes a function and two values in its domain and returns `true` if the + * values map to the same value in the codomain; `false` otherwise. + * + * @func + * @memberOf R + * @since v0.18.0 + * @category Relation + * @sig (a -> b) -> a -> a -> Boolean + * @param {Function} f + * @param {*} x + * @param {*} y + * @return {Boolean} + * @example + * + * R.eqBy(Math.abs, 5, -5); //=> true + */ +var eqBy = _curry3(function eqBy(f, x, y) { + return equals(f(x), f(y)); +}); + +/** + * Reports whether two objects have the same value, in [`R.equals`](#equals) + * terms, for the specified property. Useful as a curried predicate. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Object + * @sig k -> {k: v} -> {k: v} -> Boolean + * @param {String} prop The name of the property to compare + * @param {Object} obj1 + * @param {Object} obj2 + * @return {Boolean} + * + * @example + * + * const o1 = { a: 1, b: 2, c: 3, d: 4 }; + * const o2 = { a: 10, b: 20, c: 3, d: 40 }; + * R.eqProps('a', o1, o2); //=> false + * R.eqProps('c', o1, o2); //=> true + */ +var eqProps = _curry3(function eqProps(prop, obj1, obj2) { + return equals(obj1[prop], obj2[prop]); +}); + +/** + * Creates a new object by recursively evolving a shallow copy of `object`, + * according to the `transformation` functions. All non-primitive properties + * are copied by reference. + * + * A `transformation` function will not be invoked if its corresponding key + * does not exist in the evolved object. + * + * @func + * @memberOf R + * @since v0.9.0 + * @category Object + * @sig {k: (v -> v)} -> {k: v} -> {k: v} + * @param {Object} transformations The object specifying transformation functions to apply + * to the object. + * @param {Object} object The object to be transformed. + * @return {Object} The transformed object. + * @example + * + * const tomato = {firstName: ' Tomato ', data: {elapsed: 100, remaining: 1400}, id:123}; + * const transformations = { + * firstName: R.trim, + * lastName: R.trim, // Will not get invoked. + * data: {elapsed: R.add(1), remaining: R.add(-1)} + * }; + * R.evolve(transformations, tomato); //=> {firstName: 'Tomato', data: {elapsed: 101, remaining: 1399}, id:123} + */ +var evolve = _curry2(function evolve(transformations, object) { + var result = object instanceof Array ? [] : {}; + var transformation, key, type; + for (key in object) { + transformation = transformations[key]; + type = typeof transformation; + result[key] = type === 'function' ? transformation(object[key]) + : transformation && type === 'object' ? evolve(transformation, object[key]) + : object[key]; + } + return result; +}); + +function XFind(f, xf) { + this.xf = xf; + this.f = f; + this.found = false; +} +XFind.prototype['@@transducer/init'] = _xfBase.init; +XFind.prototype['@@transducer/result'] = function(result) { + if (!this.found) { + result = this.xf['@@transducer/step'](result, void 0); + } + return this.xf['@@transducer/result'](result); +}; +XFind.prototype['@@transducer/step'] = function(result, input) { + if (this.f(input)) { + this.found = true; + result = _reduced(this.xf['@@transducer/step'](result, input)); + } + return result; +}; + +var _xfind = _curry2(function _xfind(f, xf) { return new XFind(f, xf); }); + +/** + * Returns the first element of the list which matches the predicate, or + * `undefined` if no element matches. + * + * Dispatches to the `find` method of the second argument, if present. + * + * Acts as a transducer if a transformer is given in list position. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category List + * @sig (a -> Boolean) -> [a] -> a | undefined + * @param {Function} fn The predicate function used to determine if the element is the + * desired one. + * @param {Array} list The array to consider. + * @return {Object} The element found, or `undefined`. + * @see R.transduce + * @example + * + * const xs = [{a: 1}, {a: 2}, {a: 3}]; + * R.find(R.propEq('a', 2))(xs); //=> {a: 2} + * R.find(R.propEq('a', 4))(xs); //=> undefined + */ +var find = _curry2(_dispatchable(['find'], _xfind, function find(fn, list) { + var idx = 0; + var len = list.length; + while (idx < len) { + if (fn(list[idx])) { + return list[idx]; + } + idx += 1; + } +})); + +function XFindIndex(f, xf) { + this.xf = xf; + this.f = f; + this.idx = -1; + this.found = false; +} +XFindIndex.prototype['@@transducer/init'] = _xfBase.init; +XFindIndex.prototype['@@transducer/result'] = function(result) { + if (!this.found) { + result = this.xf['@@transducer/step'](result, -1); + } + return this.xf['@@transducer/result'](result); +}; +XFindIndex.prototype['@@transducer/step'] = function(result, input) { + this.idx += 1; + if (this.f(input)) { + this.found = true; + result = _reduced(this.xf['@@transducer/step'](result, this.idx)); + } + return result; +}; + +var _xfindIndex = _curry2(function _xfindIndex(f, xf) { return new XFindIndex(f, xf); }); + +/** + * Returns the index of the first element of the list which matches the + * predicate, or `-1` if no element matches. + * + * Acts as a transducer if a transformer is given in list position. + * + * @func + * @memberOf R + * @since v0.1.1 + * @category List + * @sig (a -> Boolean) -> [a] -> Number + * @param {Function} fn The predicate function used to determine if the element is the + * desired one. + * @param {Array} list The array to consider. + * @return {Number} The index of the element found, or `-1`. + * @see R.transduce + * @example + * + * const xs = [{a: 1}, {a: 2}, {a: 3}]; + * R.findIndex(R.propEq('a', 2))(xs); //=> 1 + * R.findIndex(R.propEq('a', 4))(xs); //=> -1 + */ +var findIndex = _curry2(_dispatchable([], _xfindIndex, function findIndex(fn, list) { + var idx = 0; + var len = list.length; + while (idx < len) { + if (fn(list[idx])) { + return idx; + } + idx += 1; + } + return -1; +})); + +function XFindLast(f, xf) { + this.xf = xf; + this.f = f; +} +XFindLast.prototype['@@transducer/init'] = _xfBase.init; +XFindLast.prototype['@@transducer/result'] = function(result) { + return this.xf['@@transducer/result'](this.xf['@@transducer/step'](result, this.last)); +}; +XFindLast.prototype['@@transducer/step'] = function(result, input) { + if (this.f(input)) { + this.last = input; + } + return result; +}; + +var _xfindLast = _curry2(function _xfindLast(f, xf) { return new XFindLast(f, xf); }); + +/** + * Returns the last element of the list which matches the predicate, or + * `undefined` if no element matches. + * + * Acts as a transducer if a transformer is given in list position. + * + * @func + * @memberOf R + * @since v0.1.1 + * @category List + * @sig (a -> Boolean) -> [a] -> a | undefined + * @param {Function} fn The predicate function used to determine if the element is the + * desired one. + * @param {Array} list The array to consider. + * @return {Object} The element found, or `undefined`. + * @see R.transduce + * @example + * + * const xs = [{a: 1, b: 0}, {a:1, b: 1}]; + * R.findLast(R.propEq('a', 1))(xs); //=> {a: 1, b: 1} + * R.findLast(R.propEq('a', 4))(xs); //=> undefined + */ +var findLast = _curry2(_dispatchable([], _xfindLast, function findLast(fn, list) { + var idx = list.length - 1; + while (idx >= 0) { + if (fn(list[idx])) { + return list[idx]; + } + idx -= 1; + } +})); + +function XFindLastIndex(f, xf) { + this.xf = xf; + this.f = f; + this.idx = -1; + this.lastIdx = -1; +} +XFindLastIndex.prototype['@@transducer/init'] = _xfBase.init; +XFindLastIndex.prototype['@@transducer/result'] = function(result) { + return this.xf['@@transducer/result'](this.xf['@@transducer/step'](result, this.lastIdx)); +}; +XFindLastIndex.prototype['@@transducer/step'] = function(result, input) { + this.idx += 1; + if (this.f(input)) { + this.lastIdx = this.idx; + } + return result; +}; + +var _xfindLastIndex = _curry2(function _xfindLastIndex(f, xf) { return new XFindLastIndex(f, xf); }); + +/** + * Returns the index of the last element of the list which matches the + * predicate, or `-1` if no element matches. + * + * Acts as a transducer if a transformer is given in list position. + * + * @func + * @memberOf R + * @since v0.1.1 + * @category List + * @sig (a -> Boolean) -> [a] -> Number + * @param {Function} fn The predicate function used to determine if the element is the + * desired one. + * @param {Array} list The array to consider. + * @return {Number} The index of the element found, or `-1`. + * @see R.transduce + * @example + * + * const xs = [{a: 1, b: 0}, {a:1, b: 1}]; + * R.findLastIndex(R.propEq('a', 1))(xs); //=> 1 + * R.findLastIndex(R.propEq('a', 4))(xs); //=> -1 + */ +var findLastIndex = _curry2(_dispatchable([], _xfindLastIndex, function findLastIndex(fn, list) { + var idx = list.length - 1; + while (idx >= 0) { + if (fn(list[idx])) { + return idx; + } + idx -= 1; + } + return -1; +})); + +/** + * Returns a new list by pulling every item out of it (and all its sub-arrays) + * and putting them in a new array, depth-first. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category List + * @sig [a] -> [b] + * @param {Array} list The array to consider. + * @return {Array} The flattened list. + * @see R.unnest + * @example + * + * R.flatten([1, 2, [3, 4], 5, [6, [7, 8, [9, [10, 11], 12]]]]); + * //=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] + */ +var flatten = _curry1(_makeFlat(true)); + +/** + * Returns a new function much like the supplied one, except that the first two + * arguments' order is reversed. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Function + * @sig ((a, b, c, ...) -> z) -> (b -> a -> c -> ... -> z) + * @param {Function} fn The function to invoke with its first two parameters reversed. + * @return {*} The result of invoking `fn` with its first two parameters' order reversed. + * @example + * + * const mergeThree = (a, b, c) => [].concat(a, b, c); + * + * mergeThree(1, 2, 3); //=> [1, 2, 3] + * + * R.flip(mergeThree)(1, 2, 3); //=> [2, 1, 3] + * @symb R.flip(f)(a, b, c) = f(b, a, c) + */ +var flip = _curry1(function flip(fn) { + return curryN(fn.length, function(a, b) { + var args = Array.prototype.slice.call(arguments, 0); + args[0] = b; + args[1] = a; + return fn.apply(this, args); + }); +}); + +/** + * Iterate over an input `list`, calling a provided function `fn` for each + * element in the list. + * + * `fn` receives one argument: *(value)*. + * + * Note: `R.forEach` does not skip deleted or unassigned indices (sparse + * arrays), unlike the native `Array.prototype.forEach` method. For more + * details on this behavior, see: + * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach#Description + * + * Also note that, unlike `Array.prototype.forEach`, Ramda's `forEach` returns + * the original array. In some libraries this function is named `each`. + * + * Dispatches to the `forEach` method of the second argument, if present. + * + * @func + * @memberOf R + * @since v0.1.1 + * @category List + * @sig (a -> *) -> [a] -> [a] + * @param {Function} fn The function to invoke. Receives one argument, `value`. + * @param {Array} list The list to iterate over. + * @return {Array} The original list. + * @see R.addIndex + * @example + * + * const printXPlusFive = x => console.log(x + 5); + * R.forEach(printXPlusFive, [1, 2, 3]); //=> [1, 2, 3] + * // logs 6 + * // logs 7 + * // logs 8 + * @symb R.forEach(f, [a, b, c]) = [a, b, c] + */ +var forEach = _curry2(_checkForMethod('forEach', function forEach(fn, list) { + var len = list.length; + var idx = 0; + while (idx < len) { + fn(list[idx]); + idx += 1; + } + return list; +})); + +/** + * Iterate over an input `object`, calling a provided function `fn` for each + * key and value in the object. + * + * `fn` receives three argument: *(value, key, obj)*. + * + * @func + * @memberOf R + * @since v0.23.0 + * @category Object + * @sig ((a, String, StrMap a) -> Any) -> StrMap a -> StrMap a + * @param {Function} fn The function to invoke. Receives three argument, `value`, `key`, `obj`. + * @param {Object} obj The object to iterate over. + * @return {Object} The original object. + * @example + * + * const printKeyConcatValue = (value, key) => console.log(key + ':' + value); + * R.forEachObjIndexed(printKeyConcatValue, {x: 1, y: 2}); //=> {x: 1, y: 2} + * // logs x:1 + * // logs y:2 + * @symb R.forEachObjIndexed(f, {x: a, y: b}) = {x: a, y: b} + */ +var forEachObjIndexed = _curry2(function forEachObjIndexed(fn, obj) { + var keyList = keys(obj); + var idx = 0; + while (idx < keyList.length) { + var key = keyList[idx]; + fn(obj[key], key, obj); + idx += 1; + } + return obj; +}); + +/** + * Creates a new object from a list key-value pairs. If a key appears in + * multiple pairs, the rightmost pair is included in the object. + * + * @func + * @memberOf R + * @since v0.3.0 + * @category List + * @sig [[k,v]] -> {k: v} + * @param {Array} pairs An array of two-element arrays that will be the keys and values of the output object. + * @return {Object} The object made by pairing up `keys` and `values`. + * @see R.toPairs, R.pair + * @example + * + * R.fromPairs([['a', 1], ['b', 2], ['c', 3]]); //=> {a: 1, b: 2, c: 3} + */ +var fromPairs = _curry1(function fromPairs(pairs) { + var result = {}; + var idx = 0; + while (idx < pairs.length) { + result[pairs[idx][0]] = pairs[idx][1]; + idx += 1; + } + return result; +}); + +/** + * Splits a list into sub-lists stored in an object, based on the result of + * calling a String-returning function on each element, and grouping the + * results according to values returned. + * + * Dispatches to the `groupBy` method of the second argument, if present. + * + * Acts as a transducer if a transformer is given in list position. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category List + * @sig (a -> String) -> [a] -> {String: [a]} + * @param {Function} fn Function :: a -> String + * @param {Array} list The array to group + * @return {Object} An object with the output of `fn` for keys, mapped to arrays of elements + * that produced that key when passed to `fn`. + * @see R.reduceBy, R.transduce + * @example + * + * const byGrade = R.groupBy(function(student) { + * const score = student.score; + * return score < 65 ? 'F' : + * score < 70 ? 'D' : + * score < 80 ? 'C' : + * score < 90 ? 'B' : 'A'; + * }); + * const students = [{name: 'Abby', score: 84}, + * {name: 'Eddy', score: 58}, + * // ... + * {name: 'Jack', score: 69}]; + * byGrade(students); + * // { + * // 'A': [{name: 'Dianne', score: 99}], + * // 'B': [{name: 'Abby', score: 84}] + * // // ..., + * // 'F': [{name: 'Eddy', score: 58}] + * // } + */ +var groupBy = _curry2(_checkForMethod('groupBy', reduceBy(function(acc, item) { + if (acc == null) { + acc = []; + } + acc.push(item); + return acc; +}, null))); + +/** + * Takes a list and returns a list of lists where each sublist's elements are + * all satisfied pairwise comparison according to the provided function. + * Only adjacent elements are passed to the comparison function. + * + * @func + * @memberOf R + * @since v0.21.0 + * @category List + * @sig ((a, a) → Boolean) → [a] → [[a]] + * @param {Function} fn Function for determining whether two given (adjacent) + * elements should be in the same group + * @param {Array} list The array to group. Also accepts a string, which will be + * treated as a list of characters. + * @return {List} A list that contains sublists of elements, + * whose concatenations are equal to the original list. + * @example + * + * R.groupWith(R.equals, [0, 1, 1, 2, 3, 5, 8, 13, 21]) + * //=> [[0], [1, 1], [2], [3], [5], [8], [13], [21]] + * + * R.groupWith((a, b) => a + 1 === b, [0, 1, 1, 2, 3, 5, 8, 13, 21]) + * //=> [[0, 1], [1, 2, 3], [5], [8], [13], [21]] + * + * R.groupWith((a, b) => a % 2 === b % 2, [0, 1, 1, 2, 3, 5, 8, 13, 21]) + * //=> [[0], [1, 1], [2], [3, 5], [8], [13, 21]] + * + * R.groupWith(R.eqBy(isVowel), 'aestiou') + * //=> ['ae', 'st', 'iou'] + */ +var groupWith = _curry2(function(fn, list) { + var res = []; + var idx = 0; + var len = list.length; + while (idx < len) { + var nextidx = idx + 1; + while (nextidx < len && fn(list[nextidx - 1], list[nextidx])) { + nextidx += 1; + } + res.push(list.slice(idx, nextidx)); + idx = nextidx; + } + return res; +}); + +/** + * Returns `true` if the first argument is greater than the second; `false` + * otherwise. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Relation + * @sig Ord a => a -> a -> Boolean + * @param {*} a + * @param {*} b + * @return {Boolean} + * @see R.lt + * @example + * + * R.gt(2, 1); //=> true + * R.gt(2, 2); //=> false + * R.gt(2, 3); //=> false + * R.gt('a', 'z'); //=> false + * R.gt('z', 'a'); //=> true + */ +var gt = _curry2(function gt(a, b) { return a > b; }); + +/** + * Returns `true` if the first argument is greater than or equal to the second; + * `false` otherwise. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Relation + * @sig Ord a => a -> a -> Boolean + * @param {Number} a + * @param {Number} b + * @return {Boolean} + * @see R.lte + * @example + * + * R.gte(2, 1); //=> true + * R.gte(2, 2); //=> true + * R.gte(2, 3); //=> false + * R.gte('a', 'z'); //=> false + * R.gte('z', 'a'); //=> true + */ +var gte = _curry2(function gte(a, b) { return a >= b; }); + +/** + * Returns whether or not a path exists in an object. Only the object's + * own properties are checked. + * + * @func + * @memberOf R + * @since v0.26.0 + * @category Object + * @typedefn Idx = String | Int + * @sig [Idx] -> {a} -> Boolean + * @param {Array} path The path to use. + * @param {Object} obj The object to check the path in. + * @return {Boolean} Whether the path exists. + * @see R.has + * @example + * + * R.hasPath(['a', 'b'], {a: {b: 2}}); // => true + * R.hasPath(['a', 'b'], {a: {b: undefined}}); // => true + * R.hasPath(['a', 'b'], {a: {c: 2}}); // => false + * R.hasPath(['a', 'b'], {}); // => false + */ +var hasPath = _curry2(function hasPath(_path, obj) { + if (_path.length === 0) { + return false; + } + var val = obj; + var idx = 0; + while (idx < _path.length) { + if (_has(_path[idx], val)) { + val = val[_path[idx]]; + idx += 1; + } else { + return false; + } + } + return true; +}); + +/** + * Returns whether or not an object has an own property with the specified name + * + * @func + * @memberOf R + * @since v0.7.0 + * @category Object + * @sig s -> {s: x} -> Boolean + * @param {String} prop The name of the property to check for. + * @param {Object} obj The object to query. + * @return {Boolean} Whether the property exists. + * @example + * + * const hasName = R.has('name'); + * hasName({name: 'alice'}); //=> true + * hasName({name: 'bob'}); //=> true + * hasName({}); //=> false + * + * const point = {x: 0, y: 0}; + * const pointHas = R.has(R.__, point); + * pointHas('x'); //=> true + * pointHas('y'); //=> true + * pointHas('z'); //=> false + */ +var has = _curry2(function has(prop, obj) { + return hasPath([prop], obj); +}); + +/** + * Returns whether or not an object or its prototype chain has a property with + * the specified name + * + * @func + * @memberOf R + * @since v0.7.0 + * @category Object + * @sig s -> {s: x} -> Boolean + * @param {String} prop The name of the property to check for. + * @param {Object} obj The object to query. + * @return {Boolean} Whether the property exists. + * @example + * + * function Rectangle(width, height) { + * this.width = width; + * this.height = height; + * } + * Rectangle.prototype.area = function() { + * return this.width * this.height; + * }; + * + * const square = new Rectangle(2, 2); + * R.hasIn('width', square); //=> true + * R.hasIn('area', square); //=> true + */ +var hasIn = _curry2(function hasIn(prop, obj) { + return prop in obj; +}); + +/** + * Returns true if its arguments are identical, false otherwise. Values are + * identical if they reference the same memory. `NaN` is identical to `NaN`; + * `0` and `-0` are not identical. + * + * Note this is merely a curried version of ES6 `Object.is`. + * + * @func + * @memberOf R + * @since v0.15.0 + * @category Relation + * @sig a -> a -> Boolean + * @param {*} a + * @param {*} b + * @return {Boolean} + * @example + * + * const o = {}; + * R.identical(o, o); //=> true + * R.identical(1, 1); //=> true + * R.identical(1, '1'); //=> false + * R.identical([], []); //=> false + * R.identical(0, -0); //=> false + * R.identical(NaN, NaN); //=> true + */ +var identical = _curry2(_objectIs$1); + +/** + * Creates a function that will process either the `onTrue` or the `onFalse` + * function depending upon the result of the `condition` predicate. + * + * @func + * @memberOf R + * @since v0.8.0 + * @category Logic + * @sig (*... -> Boolean) -> (*... -> *) -> (*... -> *) -> (*... -> *) + * @param {Function} condition A predicate function + * @param {Function} onTrue A function to invoke when the `condition` evaluates to a truthy value. + * @param {Function} onFalse A function to invoke when the `condition` evaluates to a falsy value. + * @return {Function} A new function that will process either the `onTrue` or the `onFalse` + * function depending upon the result of the `condition` predicate. + * @see R.unless, R.when, R.cond + * @example + * + * const incCount = R.ifElse( + * R.has('count'), + * R.over(R.lensProp('count'), R.inc), + * R.assoc('count', 1) + * ); + * incCount({}); //=> { count: 1 } + * incCount({ count: 1 }); //=> { count: 2 } + */ +var ifElse = _curry3(function ifElse(condition, onTrue, onFalse) { + return curryN(Math.max(condition.length, onTrue.length, onFalse.length), + function _ifElse() { + return condition.apply(this, arguments) ? onTrue.apply(this, arguments) : onFalse.apply(this, arguments); + } + ); +}); + +/** + * Increments its argument. + * + * @func + * @memberOf R + * @since v0.9.0 + * @category Math + * @sig Number -> Number + * @param {Number} n + * @return {Number} n + 1 + * @see R.dec + * @example + * + * R.inc(42); //=> 43 + */ +var inc = add(1); + +/** + * Returns `true` if the specified value is equal, in [`R.equals`](#equals) + * terms, to at least one element of the given list; `false` otherwise. + * Works also with strings. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category List + * @sig a -> [a] -> Boolean + * @param {Object} a The item to compare against. + * @param {Array} list The array to consider. + * @return {Boolean} `true` if an equivalent item is in the list, `false` otherwise. + * @see R.any + * @example + * + * R.includes(3, [1, 2, 3]); //=> true + * R.includes(4, [1, 2, 3]); //=> false + * R.includes({ name: 'Fred' }, [{ name: 'Fred' }]); //=> true + * R.includes([42], [[42]]); //=> true + * R.includes('ba', 'banana'); //=>true + */ +var includes = _curry2(_includes); + +/** + * Given a function that generates a key, turns a list of objects into an + * object indexing the objects by the given key. Note that if multiple + * objects generate the same value for the indexing key only the last value + * will be included in the generated object. + * + * Acts as a transducer if a transformer is given in list position. + * + * @func + * @memberOf R + * @since v0.19.0 + * @category List + * @sig (a -> String) -> [{k: v}] -> {k: {k: v}} + * @param {Function} fn Function :: a -> String + * @param {Array} array The array of objects to index + * @return {Object} An object indexing each array element by the given property. + * @example + * + * const list = [{id: 'xyz', title: 'A'}, {id: 'abc', title: 'B'}]; + * R.indexBy(R.prop('id'), list); + * //=> {abc: {id: 'abc', title: 'B'}, xyz: {id: 'xyz', title: 'A'}} + */ +var indexBy = reduceBy(function(acc, elem) { return elem; }, null); + +/** + * Returns the position of the first occurrence of an item in an array, or -1 + * if the item is not included in the array. [`R.equals`](#equals) is used to + * determine equality. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category List + * @sig a -> [a] -> Number + * @param {*} target The item to find. + * @param {Array} xs The array to search in. + * @return {Number} the index of the target, or -1 if the target is not found. + * @see R.lastIndexOf + * @example + * + * R.indexOf(3, [1,2,3,4]); //=> 2 + * R.indexOf(10, [1,2,3,4]); //=> -1 + */ +var indexOf = _curry2(function indexOf(target, xs) { + return typeof xs.indexOf === 'function' && !_isArray(xs) ? + xs.indexOf(target) : + _indexOf(xs, target, 0); +}); + +/** + * Returns all but the last element of the given list or string. + * + * @func + * @memberOf R + * @since v0.9.0 + * @category List + * @sig [a] -> [a] + * @sig String -> String + * @param {*} list + * @return {*} + * @see R.last, R.head, R.tail + * @example + * + * R.init([1, 2, 3]); //=> [1, 2] + * R.init([1, 2]); //=> [1] + * R.init([1]); //=> [] + * R.init([]); //=> [] + * + * R.init('abc'); //=> 'ab' + * R.init('ab'); //=> 'a' + * R.init('a'); //=> '' + * R.init(''); //=> '' + */ +var init = slice(0, -1); + +/** + * Takes a predicate `pred`, a list `xs`, and a list `ys`, and returns a list + * `xs'` comprising each of the elements of `xs` which is equal to one or more + * elements of `ys` according to `pred`. + * + * `pred` must be a binary function expecting an element from each list. + * + * `xs`, `ys`, and `xs'` are treated as sets, semantically, so ordering should + * not be significant, but since `xs'` is ordered the implementation guarantees + * that its values are in the same order as they appear in `xs`. Duplicates are + * not removed, so `xs'` may contain duplicates if `xs` contains duplicates. + * + * @func + * @memberOf R + * @since v0.24.0 + * @category Relation + * @sig ((a, b) -> Boolean) -> [a] -> [b] -> [a] + * @param {Function} pred + * @param {Array} xs + * @param {Array} ys + * @return {Array} + * @see R.intersection + * @example + * + * R.innerJoin( + * (record, id) => record.id === id, + * [{id: 824, name: 'Richie Furay'}, + * {id: 956, name: 'Dewey Martin'}, + * {id: 313, name: 'Bruce Palmer'}, + * {id: 456, name: 'Stephen Stills'}, + * {id: 177, name: 'Neil Young'}], + * [177, 456, 999] + * ); + * //=> [{id: 456, name: 'Stephen Stills'}, {id: 177, name: 'Neil Young'}] + */ +var innerJoin = _curry3(function innerJoin(pred, xs, ys) { + return _filter(function(x) { return _includesWith(pred, x, ys); }, xs); +}); + +/** + * Inserts the supplied element into the list, at the specified `index`. _Note that + + * this is not destructive_: it returns a copy of the list with the changes. + * No lists have been harmed in the application of this function. + * + * @func + * @memberOf R + * @since v0.2.2 + * @category List + * @sig Number -> a -> [a] -> [a] + * @param {Number} index The position to insert the element + * @param {*} elt The element to insert into the Array + * @param {Array} list The list to insert into + * @return {Array} A new Array with `elt` inserted at `index`. + * @example + * + * R.insert(2, 'x', [1,2,3,4]); //=> [1,2,'x',3,4] + */ +var insert = _curry3(function insert(idx, elt, list) { + idx = idx < list.length && idx >= 0 ? idx : list.length; + var result = Array.prototype.slice.call(list, 0); + result.splice(idx, 0, elt); + return result; +}); + +/** + * Inserts the sub-list into the list, at the specified `index`. _Note that this is not + * destructive_: it returns a copy of the list with the changes. + * No lists have been harmed in the application of this function. + * + * @func + * @memberOf R + * @since v0.9.0 + * @category List + * @sig Number -> [a] -> [a] -> [a] + * @param {Number} index The position to insert the sub-list + * @param {Array} elts The sub-list to insert into the Array + * @param {Array} list The list to insert the sub-list into + * @return {Array} A new Array with `elts` inserted starting at `index`. + * @example + * + * R.insertAll(2, ['x','y','z'], [1,2,3,4]); //=> [1,2,'x','y','z',3,4] + */ +var insertAll = _curry3(function insertAll(idx, elts, list) { + idx = idx < list.length && idx >= 0 ? idx : list.length; + return [].concat(Array.prototype.slice.call(list, 0, idx), + elts, + Array.prototype.slice.call(list, idx)); +}); + +/** + * Returns a new list containing only one copy of each element in the original + * list, based upon the value returned by applying the supplied function to + * each list element. Prefers the first item if the supplied function produces + * the same value on two items. [`R.equals`](#equals) is used for comparison. + * + * @func + * @memberOf R + * @since v0.16.0 + * @category List + * @sig (a -> b) -> [a] -> [a] + * @param {Function} fn A function used to produce a value to use during comparisons. + * @param {Array} list The array to consider. + * @return {Array} The list of unique items. + * @example + * + * R.uniqBy(Math.abs, [-1, -5, 2, 10, 1, 2]); //=> [-1, -5, 2, 10] + */ +var uniqBy = _curry2(function uniqBy(fn, list) { + var set = new _Set(); + var result = []; + var idx = 0; + var appliedItem, item; + + while (idx < list.length) { + item = list[idx]; + appliedItem = fn(item); + if (set.add(appliedItem)) { + result.push(item); + } + idx += 1; + } + return result; +}); + +/** + * Returns a new list containing only one copy of each element in the original + * list. [`R.equals`](#equals) is used to determine equality. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category List + * @sig [a] -> [a] + * @param {Array} list The array to consider. + * @return {Array} The list of unique items. + * @example + * + * R.uniq([1, 1, 2, 1]); //=> [1, 2] + * R.uniq([1, '1']); //=> [1, '1'] + * R.uniq([[42], [42]]); //=> [[42]] + */ +var uniq = uniqBy(identity); + +/** + * Combines two lists into a set (i.e. no duplicates) composed of those + * elements common to both lists. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Relation + * @sig [*] -> [*] -> [*] + * @param {Array} list1 The first list. + * @param {Array} list2 The second list. + * @return {Array} The list of elements found in both `list1` and `list2`. + * @see R.innerJoin + * @example + * + * R.intersection([1,2,3,4], [7,6,5,4,3]); //=> [4, 3] + */ +var intersection = _curry2(function intersection(list1, list2) { + var lookupList, filteredList; + if (list1.length > list2.length) { + lookupList = list1; + filteredList = list2; + } else { + lookupList = list2; + filteredList = list1; + } + return uniq(_filter(flip(_includes)(lookupList), filteredList)); +}); + +/** + * Creates a new list with the separator interposed between elements. + * + * Dispatches to the `intersperse` method of the second argument, if present. + * + * @func + * @memberOf R + * @since v0.14.0 + * @category List + * @sig a -> [a] -> [a] + * @param {*} separator The element to add to the list. + * @param {Array} list The list to be interposed. + * @return {Array} The new list. + * @example + * + * R.intersperse('a', ['b', 'n', 'n', 's']); //=> ['b', 'a', 'n', 'a', 'n', 'a', 's'] + */ +var intersperse = _curry2(_checkForMethod('intersperse', function intersperse(separator, list) { + var out = []; + var idx = 0; + var length = list.length; + while (idx < length) { + if (idx === length - 1) { + out.push(list[idx]); + } else { + out.push(list[idx], separator); + } + idx += 1; + } + return out; +})); + +// Based on https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/assign +function _objectAssign(target) { + if (target == null) { + throw new TypeError('Cannot convert undefined or null to object'); + } + + var output = Object(target); + var idx = 1; + var length = arguments.length; + while (idx < length) { + var source = arguments[idx]; + if (source != null) { + for (var nextKey in source) { + if (_has(nextKey, source)) { + output[nextKey] = source[nextKey]; + } + } + } + idx += 1; + } + return output; +} + +var _objectAssign$1 = typeof Object.assign === 'function' ? Object.assign : _objectAssign; + +/** + * Creates an object containing a single key:value pair. + * + * @func + * @memberOf R + * @since v0.18.0 + * @category Object + * @sig String -> a -> {String:a} + * @param {String} key + * @param {*} val + * @return {Object} + * @see R.pair + * @example + * + * const matchPhrases = R.compose( + * R.objOf('must'), + * R.map(R.objOf('match_phrase')) + * ); + * matchPhrases(['foo', 'bar', 'baz']); //=> {must: [{match_phrase: 'foo'}, {match_phrase: 'bar'}, {match_phrase: 'baz'}]} + */ +var objOf = _curry2(function objOf(key, val) { + var obj = {}; + obj[key] = val; + return obj; +}); + +var _stepCatArray = { + '@@transducer/init': Array, + '@@transducer/step': function(xs, x) { + xs.push(x); + return xs; + }, + '@@transducer/result': _identity +}; +var _stepCatString = { + '@@transducer/init': String, + '@@transducer/step': function(a, b) { return a + b; }, + '@@transducer/result': _identity +}; +var _stepCatObject = { + '@@transducer/init': Object, + '@@transducer/step': function(result, input) { + return _objectAssign$1( + result, + _isArrayLike(input) ? objOf(input[0], input[1]) : input + ); + }, + '@@transducer/result': _identity +}; + +function _stepCat(obj) { + if (_isTransformer(obj)) { + return obj; + } + if (_isArrayLike(obj)) { + return _stepCatArray; + } + if (typeof obj === 'string') { + return _stepCatString; + } + if (typeof obj === 'object') { + return _stepCatObject; + } + throw new Error('Cannot create transformer for ' + obj); +} + +/** + * Transforms the items of the list with the transducer and appends the + * transformed items to the accumulator using an appropriate iterator function + * based on the accumulator type. + * + * The accumulator can be an array, string, object or a transformer. Iterated + * items will be appended to arrays and concatenated to strings. Objects will + * be merged directly or 2-item arrays will be merged as key, value pairs. + * + * The accumulator can also be a transformer object that provides a 2-arity + * reducing iterator function, step, 0-arity initial value function, init, and + * 1-arity result extraction function result. The step function is used as the + * iterator function in reduce. The result function is used to convert the + * final accumulator into the return type and in most cases is R.identity. The + * init function is used to provide the initial accumulator. + * + * The iteration is performed with [`R.reduce`](#reduce) after initializing the + * transducer. + * + * @func + * @memberOf R + * @since v0.12.0 + * @category List + * @sig a -> (b -> b) -> [c] -> a + * @param {*} acc The initial accumulator value. + * @param {Function} xf The transducer function. Receives a transformer and returns a transformer. + * @param {Array} list The list to iterate over. + * @return {*} The final, accumulated value. + * @see R.transduce + * @example + * + * const numbers = [1, 2, 3, 4]; + * const transducer = R.compose(R.map(R.add(1)), R.take(2)); + * + * R.into([], transducer, numbers); //=> [2, 3] + * + * const intoArray = R.into([]); + * intoArray(transducer, numbers); //=> [2, 3] + */ +var into = _curry3(function into(acc, xf, list) { + return _isTransformer(acc) ? + _reduce(xf(acc), acc['@@transducer/init'](), list) : + _reduce(xf(_stepCat(acc)), _clone(acc, [], [], false), list); +}); + +/** + * Same as [`R.invertObj`](#invertObj), however this accounts for objects with + * duplicate values by putting the values into an array. + * + * @func + * @memberOf R + * @since v0.9.0 + * @category Object + * @sig {s: x} -> {x: [ s, ... ]} + * @param {Object} obj The object or array to invert + * @return {Object} out A new object with keys in an array. + * @see R.invertObj + * @example + * + * const raceResultsByFirstName = { + * first: 'alice', + * second: 'jake', + * third: 'alice', + * }; + * R.invert(raceResultsByFirstName); + * //=> { 'alice': ['first', 'third'], 'jake':['second'] } + */ +var invert = _curry1(function invert(obj) { + var props = keys(obj); + var len = props.length; + var idx = 0; + var out = {}; + + while (idx < len) { + var key = props[idx]; + var val = obj[key]; + var list = _has(val, out) ? out[val] : (out[val] = []); + list[list.length] = key; + idx += 1; + } + return out; +}); + +/** + * Returns a new object with the keys of the given object as values, and the + * values of the given object, which are coerced to strings, as keys. Note + * that the last key found is preferred when handling the same value. + * + * @func + * @memberOf R + * @since v0.9.0 + * @category Object + * @sig {s: x} -> {x: s} + * @param {Object} obj The object or array to invert + * @return {Object} out A new object + * @see R.invert + * @example + * + * const raceResults = { + * first: 'alice', + * second: 'jake' + * }; + * R.invertObj(raceResults); + * //=> { 'alice': 'first', 'jake':'second' } + * + * // Alternatively: + * const raceResults = ['alice', 'jake']; + * R.invertObj(raceResults); + * //=> { 'alice': '0', 'jake':'1' } + */ +var invertObj = _curry1(function invertObj(obj) { + var props = keys(obj); + var len = props.length; + var idx = 0; + var out = {}; + + while (idx < len) { + var key = props[idx]; + out[obj[key]] = key; + idx += 1; + } + return out; +}); + +/** + * Turns a named method with a specified arity into a function that can be + * called directly supplied with arguments and a target object. + * + * The returned function is curried and accepts `arity + 1` parameters where + * the final parameter is the target object. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Function + * @sig Number -> String -> (a -> b -> ... -> n -> Object -> *) + * @param {Number} arity Number of arguments the returned function should take + * before the target object. + * @param {String} method Name of the method to call. + * @return {Function} A new curried function. + * @see R.construct + * @example + * + * const sliceFrom = R.invoker(1, 'slice'); + * sliceFrom(6, 'abcdefghijklm'); //=> 'ghijklm' + * const sliceFrom6 = R.invoker(2, 'slice')(6); + * sliceFrom6(8, 'abcdefghijklm'); //=> 'gh' + * @symb R.invoker(0, 'method')(o) = o['method']() + * @symb R.invoker(1, 'method')(a, o) = o['method'](a) + * @symb R.invoker(2, 'method')(a, b, o) = o['method'](a, b) + */ +var invoker = _curry2(function invoker(arity, method) { + return curryN(arity + 1, function() { + var target = arguments[arity]; + if (target != null && _isFunction(target[method])) { + return target[method].apply(target, Array.prototype.slice.call(arguments, 0, arity)); + } + throw new TypeError(toString$1(target) + ' does not have a method named "' + method + '"'); + }); +}); + +/** + * See if an object (`val`) is an instance of the supplied constructor. This + * function will check up the inheritance chain, if any. + * + * @func + * @memberOf R + * @since v0.3.0 + * @category Type + * @sig (* -> {*}) -> a -> Boolean + * @param {Object} ctor A constructor + * @param {*} val The value to test + * @return {Boolean} + * @example + * + * R.is(Object, {}); //=> true + * R.is(Number, 1); //=> true + * R.is(Object, 1); //=> false + * R.is(String, 's'); //=> true + * R.is(String, new String('')); //=> true + * R.is(Object, new String('')); //=> true + * R.is(Object, 's'); //=> false + * R.is(Number, {}); //=> false + */ +var is = _curry2(function is(Ctor, val) { + return val != null && val.constructor === Ctor || val instanceof Ctor; +}); + +/** + * Returns `true` if the given value is its type's empty value; `false` + * otherwise. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Logic + * @sig a -> Boolean + * @param {*} x + * @return {Boolean} + * @see R.empty + * @example + * + * R.isEmpty([1, 2, 3]); //=> false + * R.isEmpty([]); //=> true + * R.isEmpty(''); //=> true + * R.isEmpty(null); //=> false + * R.isEmpty({}); //=> true + * R.isEmpty({length: 0}); //=> false + */ +var isEmpty = _curry1(function isEmpty(x) { + return x != null && equals(x, empty(x)); +}); + +/** + * Returns a string made by inserting the `separator` between each element and + * concatenating all the elements into a single string. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category List + * @sig String -> [a] -> String + * @param {Number|String} separator The string used to separate the elements. + * @param {Array} xs The elements to join into a string. + * @return {String} str The string made by concatenating `xs` with `separator`. + * @see R.split + * @example + * + * const spacer = R.join(' '); + * spacer(['a', 2, 3.4]); //=> 'a 2 3.4' + * R.join('|', [1, 2, 3]); //=> '1|2|3' + */ +var join = invoker(1, 'join'); + +/** + * juxt applies a list of functions to a list of values. + * + * @func + * @memberOf R + * @since v0.19.0 + * @category Function + * @sig [(a, b, ..., m) -> n] -> ((a, b, ..., m) -> [n]) + * @param {Array} fns An array of functions + * @return {Function} A function that returns a list of values after applying each of the original `fns` to its parameters. + * @see R.applySpec + * @example + * + * const getRange = R.juxt([Math.min, Math.max]); + * getRange(3, 4, 9, -3); //=> [-3, 9] + * @symb R.juxt([f, g, h])(a, b) = [f(a, b), g(a, b), h(a, b)] + */ +var juxt = _curry1(function juxt(fns) { + return converge(function() { return Array.prototype.slice.call(arguments, 0); }, fns); +}); + +/** + * Returns a list containing the names of all the properties of the supplied + * object, including prototype properties. + * Note that the order of the output array is not guaranteed to be consistent + * across different JS platforms. + * + * @func + * @memberOf R + * @since v0.2.0 + * @category Object + * @sig {k: v} -> [k] + * @param {Object} obj The object to extract properties from + * @return {Array} An array of the object's own and prototype properties. + * @see R.keys, R.valuesIn + * @example + * + * const F = function() { this.x = 'X'; }; + * F.prototype.y = 'Y'; + * const f = new F(); + * R.keysIn(f); //=> ['x', 'y'] + */ +var keysIn = _curry1(function keysIn(obj) { + var prop; + var ks = []; + for (prop in obj) { + ks[ks.length] = prop; + } + return ks; +}); + +/** + * Returns the position of the last occurrence of an item in an array, or -1 if + * the item is not included in the array. [`R.equals`](#equals) is used to + * determine equality. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category List + * @sig a -> [a] -> Number + * @param {*} target The item to find. + * @param {Array} xs The array to search in. + * @return {Number} the index of the target, or -1 if the target is not found. + * @see R.indexOf + * @example + * + * R.lastIndexOf(3, [-1,3,3,0,1,2,3,4]); //=> 6 + * R.lastIndexOf(10, [1,2,3,4]); //=> -1 + */ +var lastIndexOf = _curry2(function lastIndexOf(target, xs) { + if (typeof xs.lastIndexOf === 'function' && !_isArray(xs)) { + return xs.lastIndexOf(target); + } else { + var idx = xs.length - 1; + while (idx >= 0) { + if (equals(xs[idx], target)) { + return idx; + } + idx -= 1; + } + return -1; + } +}); + +function _isNumber(x) { + return Object.prototype.toString.call(x) === '[object Number]'; +} + +/** + * Returns the number of elements in the array by returning `list.length`. + * + * @func + * @memberOf R + * @since v0.3.0 + * @category List + * @sig [a] -> Number + * @param {Array} list The array to inspect. + * @return {Number} The length of the array. + * @example + * + * R.length([]); //=> 0 + * R.length([1, 2, 3]); //=> 3 + */ +var length = _curry1(function length(list) { + return list != null && _isNumber(list.length) ? list.length : NaN; +}); + +/** + * Returns a lens for the given getter and setter functions. The getter "gets" + * the value of the focus; the setter "sets" the value of the focus. The setter + * should not mutate the data structure. + * + * @func + * @memberOf R + * @since v0.8.0 + * @category Object + * @typedefn Lens s a = Functor f => (a -> f a) -> s -> f s + * @sig (s -> a) -> ((a, s) -> s) -> Lens s a + * @param {Function} getter + * @param {Function} setter + * @return {Lens} + * @see R.view, R.set, R.over, R.lensIndex, R.lensProp + * @example + * + * const xLens = R.lens(R.prop('x'), R.assoc('x')); + * + * R.view(xLens, {x: 1, y: 2}); //=> 1 + * R.set(xLens, 4, {x: 1, y: 2}); //=> {x: 4, y: 2} + * R.over(xLens, R.negate, {x: 1, y: 2}); //=> {x: -1, y: 2} + */ +var lens = _curry2(function lens(getter, setter) { + return function(toFunctorFn) { + return function(target) { + return map( + function(focus) { + return setter(focus, target); + }, + toFunctorFn(getter(target)) + ); + }; + }; +}); + +/** + * Returns a lens whose focus is the specified index. + * + * @func + * @memberOf R + * @since v0.14.0 + * @category Object + * @typedefn Lens s a = Functor f => (a -> f a) -> s -> f s + * @sig Number -> Lens s a + * @param {Number} n + * @return {Lens} + * @see R.view, R.set, R.over + * @example + * + * const headLens = R.lensIndex(0); + * + * R.view(headLens, ['a', 'b', 'c']); //=> 'a' + * R.set(headLens, 'x', ['a', 'b', 'c']); //=> ['x', 'b', 'c'] + * R.over(headLens, R.toUpper, ['a', 'b', 'c']); //=> ['A', 'b', 'c'] + */ +var lensIndex = _curry1(function lensIndex(n) { + return lens(nth(n), update(n)); +}); + +/** + * Returns a lens whose focus is the specified path. + * + * @func + * @memberOf R + * @since v0.19.0 + * @category Object + * @typedefn Idx = String | Int + * @typedefn Lens s a = Functor f => (a -> f a) -> s -> f s + * @sig [Idx] -> Lens s a + * @param {Array} path The path to use. + * @return {Lens} + * @see R.view, R.set, R.over + * @example + * + * const xHeadYLens = R.lensPath(['x', 0, 'y']); + * + * R.view(xHeadYLens, {x: [{y: 2, z: 3}, {y: 4, z: 5}]}); + * //=> 2 + * R.set(xHeadYLens, 1, {x: [{y: 2, z: 3}, {y: 4, z: 5}]}); + * //=> {x: [{y: 1, z: 3}, {y: 4, z: 5}]} + * R.over(xHeadYLens, R.negate, {x: [{y: 2, z: 3}, {y: 4, z: 5}]}); + * //=> {x: [{y: -2, z: 3}, {y: 4, z: 5}]} + */ +var lensPath = _curry1(function lensPath(p) { + return lens(path(p), assocPath(p)); +}); + +/** + * Returns a lens whose focus is the specified property. + * + * @func + * @memberOf R + * @since v0.14.0 + * @category Object + * @typedefn Lens s a = Functor f => (a -> f a) -> s -> f s + * @sig String -> Lens s a + * @param {String} k + * @return {Lens} + * @see R.view, R.set, R.over + * @example + * + * const xLens = R.lensProp('x'); + * + * R.view(xLens, {x: 1, y: 2}); //=> 1 + * R.set(xLens, 4, {x: 1, y: 2}); //=> {x: 4, y: 2} + * R.over(xLens, R.negate, {x: 1, y: 2}); //=> {x: -1, y: 2} + */ +var lensProp = _curry1(function lensProp(k) { + return lens(prop(k), assoc(k)); +}); + +/** + * Returns `true` if the first argument is less than the second; `false` + * otherwise. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Relation + * @sig Ord a => a -> a -> Boolean + * @param {*} a + * @param {*} b + * @return {Boolean} + * @see R.gt + * @example + * + * R.lt(2, 1); //=> false + * R.lt(2, 2); //=> false + * R.lt(2, 3); //=> true + * R.lt('a', 'z'); //=> true + * R.lt('z', 'a'); //=> false + */ +var lt = _curry2(function lt(a, b) { return a < b; }); + +/** + * Returns `true` if the first argument is less than or equal to the second; + * `false` otherwise. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Relation + * @sig Ord a => a -> a -> Boolean + * @param {Number} a + * @param {Number} b + * @return {Boolean} + * @see R.gte + * @example + * + * R.lte(2, 1); //=> false + * R.lte(2, 2); //=> true + * R.lte(2, 3); //=> true + * R.lte('a', 'z'); //=> true + * R.lte('z', 'a'); //=> false + */ +var lte = _curry2(function lte(a, b) { return a <= b; }); + +/** + * The `mapAccum` function behaves like a combination of map and reduce; it + * applies a function to each element of a list, passing an accumulating + * parameter from left to right, and returning a final value of this + * accumulator together with the new list. + * + * The iterator function receives two arguments, *acc* and *value*, and should + * return a tuple *[acc, value]*. + * + * @func + * @memberOf R + * @since v0.10.0 + * @category List + * @sig ((acc, x) -> (acc, y)) -> acc -> [x] -> (acc, [y]) + * @param {Function} fn The function to be called on every element of the input `list`. + * @param {*} acc The accumulator value. + * @param {Array} list The list to iterate over. + * @return {*} The final, accumulated value. + * @see R.scan, R.addIndex, R.mapAccumRight + * @example + * + * const digits = ['1', '2', '3', '4']; + * const appender = (a, b) => [a + b, a + b]; + * + * R.mapAccum(appender, 0, digits); //=> ['01234', ['01', '012', '0123', '01234']] + * @symb R.mapAccum(f, a, [b, c, d]) = [ + * f(f(f(a, b)[0], c)[0], d)[0], + * [ + * f(a, b)[1], + * f(f(a, b)[0], c)[1], + * f(f(f(a, b)[0], c)[0], d)[1] + * ] + * ] + */ +var mapAccum = _curry3(function mapAccum(fn, acc, list) { + var idx = 0; + var len = list.length; + var result = []; + var tuple = [acc]; + while (idx < len) { + tuple = fn(tuple[0], list[idx]); + result[idx] = tuple[1]; + idx += 1; + } + return [tuple[0], result]; +}); + +/** + * The `mapAccumRight` function behaves like a combination of map and reduce; it + * applies a function to each element of a list, passing an accumulating + * parameter from right to left, and returning a final value of this + * accumulator together with the new list. + * + * Similar to [`mapAccum`](#mapAccum), except moves through the input list from + * the right to the left. + * + * The iterator function receives two arguments, *acc* and *value*, and should + * return a tuple *[acc, value]*. + * + * @func + * @memberOf R + * @since v0.10.0 + * @category List + * @sig ((acc, x) -> (acc, y)) -> acc -> [x] -> (acc, [y]) + * @param {Function} fn The function to be called on every element of the input `list`. + * @param {*} acc The accumulator value. + * @param {Array} list The list to iterate over. + * @return {*} The final, accumulated value. + * @see R.addIndex, R.mapAccum + * @example + * + * const digits = ['1', '2', '3', '4']; + * const appender = (a, b) => [b + a, b + a]; + * + * R.mapAccumRight(appender, 5, digits); //=> ['12345', ['12345', '2345', '345', '45']] + * @symb R.mapAccumRight(f, a, [b, c, d]) = [ + * f(f(f(a, d)[0], c)[0], b)[0], + * [ + * f(a, d)[1], + * f(f(a, d)[0], c)[1], + * f(f(f(a, d)[0], c)[0], b)[1] + * ] + * ] + */ +var mapAccumRight = _curry3(function mapAccumRight(fn, acc, list) { + var idx = list.length - 1; + var result = []; + var tuple = [acc]; + while (idx >= 0) { + tuple = fn(tuple[0], list[idx]); + result[idx] = tuple[1]; + idx -= 1; + } + return [tuple[0], result]; +}); + +/** + * An Object-specific version of [`map`](#map). The function is applied to three + * arguments: *(value, key, obj)*. If only the value is significant, use + * [`map`](#map) instead. + * + * @func + * @memberOf R + * @since v0.9.0 + * @category Object + * @sig ((*, String, Object) -> *) -> Object -> Object + * @param {Function} fn + * @param {Object} obj + * @return {Object} + * @see R.map + * @example + * + * const xyz = { x: 1, y: 2, z: 3 }; + * const prependKeyAndDouble = (num, key, obj) => key + (num * 2); + * + * R.mapObjIndexed(prependKeyAndDouble, xyz); //=> { x: 'x2', y: 'y4', z: 'z6' } + */ +var mapObjIndexed = _curry2(function mapObjIndexed(fn, obj) { + return _reduce(function(acc, key) { + acc[key] = fn(obj[key], key, obj); + return acc; + }, {}, keys(obj)); +}); + +/** + * Tests a regular expression against a String. Note that this function will + * return an empty array when there are no matches. This differs from + * [`String.prototype.match`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/match) + * which returns `null` when there are no matches. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category String + * @sig RegExp -> String -> [String | Undefined] + * @param {RegExp} rx A regular expression. + * @param {String} str The string to match against + * @return {Array} The list of matches or empty array. + * @see R.test + * @example + * + * R.match(/([a-z]a)/g, 'bananas'); //=> ['ba', 'na', 'na'] + * R.match(/a/, 'b'); //=> [] + * R.match(/a/, null); //=> TypeError: null does not have a method named "match" + */ +var match = _curry2(function match(rx, str) { + return str.match(rx) || []; +}); + +/** + * `mathMod` behaves like the modulo operator should mathematically, unlike the + * `%` operator (and by extension, [`R.modulo`](#modulo)). So while + * `-17 % 5` is `-2`, `mathMod(-17, 5)` is `3`. `mathMod` requires Integer + * arguments, and returns NaN when the modulus is zero or negative. + * + * @func + * @memberOf R + * @since v0.3.0 + * @category Math + * @sig Number -> Number -> Number + * @param {Number} m The dividend. + * @param {Number} p the modulus. + * @return {Number} The result of `b mod a`. + * @see R.modulo + * @example + * + * R.mathMod(-17, 5); //=> 3 + * R.mathMod(17, 5); //=> 2 + * R.mathMod(17, -5); //=> NaN + * R.mathMod(17, 0); //=> NaN + * R.mathMod(17.2, 5); //=> NaN + * R.mathMod(17, 5.3); //=> NaN + * + * const clock = R.mathMod(R.__, 12); + * clock(15); //=> 3 + * clock(24); //=> 0 + * + * const seventeenMod = R.mathMod(17); + * seventeenMod(3); //=> 2 + * seventeenMod(4); //=> 1 + * seventeenMod(10); //=> 7 + */ +var mathMod = _curry2(function mathMod(m, p) { + if (!_isInteger(m)) { return NaN; } + if (!_isInteger(p) || p < 1) { return NaN; } + return ((m % p) + p) % p; +}); + +/** + * Takes a function and two values, and returns whichever value produces the + * larger result when passed to the provided function. + * + * @func + * @memberOf R + * @since v0.8.0 + * @category Relation + * @sig Ord b => (a -> b) -> a -> a -> a + * @param {Function} f + * @param {*} a + * @param {*} b + * @return {*} + * @see R.max, R.minBy + * @example + * + * // square :: Number -> Number + * const square = n => n * n; + * + * R.maxBy(square, -3, 2); //=> -3 + * + * R.reduce(R.maxBy(square), 0, [3, -5, 4, 1, -2]); //=> -5 + * R.reduce(R.maxBy(square), 0, []); //=> 0 + */ +var maxBy = _curry3(function maxBy(f, a, b) { + return f(b) > f(a) ? b : a; +}); + +/** + * Adds together all the elements of a list. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Math + * @sig [Number] -> Number + * @param {Array} list An array of numbers + * @return {Number} The sum of all the numbers in the list. + * @see R.reduce + * @example + * + * R.sum([2,4,6,8,100,1]); //=> 121 + */ +var sum = reduce(add, 0); + +/** + * Returns the mean of the given list of numbers. + * + * @func + * @memberOf R + * @since v0.14.0 + * @category Math + * @sig [Number] -> Number + * @param {Array} list + * @return {Number} + * @see R.median + * @example + * + * R.mean([2, 7, 9]); //=> 6 + * R.mean([]); //=> NaN + */ +var mean = _curry1(function mean(list) { + return sum(list) / list.length; +}); + +/** + * Returns the median of the given list of numbers. + * + * @func + * @memberOf R + * @since v0.14.0 + * @category Math + * @sig [Number] -> Number + * @param {Array} list + * @return {Number} + * @see R.mean + * @example + * + * R.median([2, 9, 7]); //=> 7 + * R.median([7, 2, 10, 9]); //=> 8 + * R.median([]); //=> NaN + */ +var median = _curry1(function median(list) { + var len = list.length; + if (len === 0) { + return NaN; + } + var width = 2 - len % 2; + var idx = (len - width) / 2; + return mean(Array.prototype.slice.call(list, 0).sort(function(a, b) { + return a < b ? -1 : a > b ? 1 : 0; + }).slice(idx, idx + width)); +}); + +/** + * A customisable version of [`R.memoize`](#memoize). `memoizeWith` takes an + * additional function that will be applied to a given argument set and used to + * create the cache key under which the results of the function to be memoized + * will be stored. Care must be taken when implementing key generation to avoid + * clashes that may overwrite previous entries erroneously. + * + * + * @func + * @memberOf R + * @since v0.24.0 + * @category Function + * @sig (*... -> String) -> (*... -> a) -> (*... -> a) + * @param {Function} fn The function to generate the cache key. + * @param {Function} fn The function to memoize. + * @return {Function} Memoized version of `fn`. + * @example + * + * let count = 0; + * const factorial = R.memoizeWith(R.identity, n => { + * count += 1; + * return R.product(R.range(1, n + 1)); + * }); + * factorial(5); //=> 120 + * factorial(5); //=> 120 + * factorial(5); //=> 120 + * count; //=> 1 + */ +var memoizeWith = _curry2(function memoizeWith(mFn, fn) { + var cache = {}; + return _arity(fn.length, function() { + var key = mFn.apply(this, arguments); + if (!_has(key, cache)) { + cache[key] = fn.apply(this, arguments); + } + return cache[key]; + }); +}); + +/** + * Create a new object with the own properties of the first object merged with + * the own properties of the second object. If a key exists in both objects, + * the value from the second object will be used. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Object + * @sig {k: v} -> {k: v} -> {k: v} + * @param {Object} l + * @param {Object} r + * @return {Object} + * @see R.mergeRight, R.mergeDeepRight, R.mergeWith, R.mergeWithKey + * @deprecated + * @example + * + * R.merge({ 'name': 'fred', 'age': 10 }, { 'age': 40 }); + * //=> { 'name': 'fred', 'age': 40 } + * + * const withDefaults = R.merge({x: 0, y: 0}); + * withDefaults({y: 2}); //=> {x: 0, y: 2} + * @symb R.merge(a, b) = {...a, ...b} + */ +var merge = _curry2(function merge(l, r) { + return _objectAssign$1({}, l, r); +}); + +/** + * Merges a list of objects together into one object. + * + * @func + * @memberOf R + * @since v0.10.0 + * @category List + * @sig [{k: v}] -> {k: v} + * @param {Array} list An array of objects + * @return {Object} A merged object. + * @see R.reduce + * @example + * + * R.mergeAll([{foo:1},{bar:2},{baz:3}]); //=> {foo:1,bar:2,baz:3} + * R.mergeAll([{foo:1},{foo:2},{bar:2}]); //=> {foo:2,bar:2} + * @symb R.mergeAll([{ x: 1 }, { y: 2 }, { z: 3 }]) = { x: 1, y: 2, z: 3 } + */ +var mergeAll = _curry1(function mergeAll(list) { + return _objectAssign$1.apply(null, [{}].concat(list)); +}); + +/** + * Creates a new object with the own properties of the two provided objects. If + * a key exists in both objects, the provided function is applied to the key + * and the values associated with the key in each object, with the result being + * used as the value associated with the key in the returned object. + * + * @func + * @memberOf R + * @since v0.19.0 + * @category Object + * @sig ((String, a, a) -> a) -> {a} -> {a} -> {a} + * @param {Function} fn + * @param {Object} l + * @param {Object} r + * @return {Object} + * @see R.mergeDeepWithKey, R.merge, R.mergeWith + * @example + * + * let concatValues = (k, l, r) => k == 'values' ? R.concat(l, r) : r + * R.mergeWithKey(concatValues, + * { a: true, thing: 'foo', values: [10, 20] }, + * { b: true, thing: 'bar', values: [15, 35] }); + * //=> { a: true, b: true, thing: 'bar', values: [10, 20, 15, 35] } + * @symb R.mergeWithKey(f, { x: 1, y: 2 }, { y: 5, z: 3 }) = { x: 1, y: f('y', 2, 5), z: 3 } + */ +var mergeWithKey = _curry3(function mergeWithKey(fn, l, r) { + var result = {}; + var k; + + for (k in l) { + if (_has(k, l)) { + result[k] = _has(k, r) ? fn(k, l[k], r[k]) : l[k]; + } + } + + for (k in r) { + if (_has(k, r) && !(_has(k, result))) { + result[k] = r[k]; + } + } + + return result; +}); + +/** + * Creates a new object with the own properties of the two provided objects. + * If a key exists in both objects: + * - and both associated values are also objects then the values will be + * recursively merged. + * - otherwise the provided function is applied to the key and associated values + * using the resulting value as the new value associated with the key. + * If a key only exists in one object, the value will be associated with the key + * of the resulting object. + * + * @func + * @memberOf R + * @since v0.24.0 + * @category Object + * @sig ((String, a, a) -> a) -> {a} -> {a} -> {a} + * @param {Function} fn + * @param {Object} lObj + * @param {Object} rObj + * @return {Object} + * @see R.mergeWithKey, R.mergeDeepWith + * @example + * + * let concatValues = (k, l, r) => k == 'values' ? R.concat(l, r) : r + * R.mergeDeepWithKey(concatValues, + * { a: true, c: { thing: 'foo', values: [10, 20] }}, + * { b: true, c: { thing: 'bar', values: [15, 35] }}); + * //=> { a: true, b: true, c: { thing: 'bar', values: [10, 20, 15, 35] }} + */ +var mergeDeepWithKey = _curry3(function mergeDeepWithKey(fn, lObj, rObj) { + return mergeWithKey(function(k, lVal, rVal) { + if (_isObject(lVal) && _isObject(rVal)) { + return mergeDeepWithKey(fn, lVal, rVal); + } else { + return fn(k, lVal, rVal); + } + }, lObj, rObj); +}); + +/** + * Creates a new object with the own properties of the first object merged with + * the own properties of the second object. If a key exists in both objects: + * - and both values are objects, the two values will be recursively merged + * - otherwise the value from the first object will be used. + * + * @func + * @memberOf R + * @since v0.24.0 + * @category Object + * @sig {a} -> {a} -> {a} + * @param {Object} lObj + * @param {Object} rObj + * @return {Object} + * @see R.merge, R.mergeDeepRight, R.mergeDeepWith, R.mergeDeepWithKey + * @example + * + * R.mergeDeepLeft({ name: 'fred', age: 10, contact: { email: 'moo@example.com' }}, + * { age: 40, contact: { email: 'baa@example.com' }}); + * //=> { name: 'fred', age: 10, contact: { email: 'moo@example.com' }} + */ +var mergeDeepLeft = _curry2(function mergeDeepLeft(lObj, rObj) { + return mergeDeepWithKey(function(k, lVal, rVal) { + return lVal; + }, lObj, rObj); +}); + +/** + * Creates a new object with the own properties of the first object merged with + * the own properties of the second object. If a key exists in both objects: + * - and both values are objects, the two values will be recursively merged + * - otherwise the value from the second object will be used. + * + * @func + * @memberOf R + * @since v0.24.0 + * @category Object + * @sig {a} -> {a} -> {a} + * @param {Object} lObj + * @param {Object} rObj + * @return {Object} + * @see R.merge, R.mergeDeepLeft, R.mergeDeepWith, R.mergeDeepWithKey + * @example + * + * R.mergeDeepRight({ name: 'fred', age: 10, contact: { email: 'moo@example.com' }}, + * { age: 40, contact: { email: 'baa@example.com' }}); + * //=> { name: 'fred', age: 40, contact: { email: 'baa@example.com' }} + */ +var mergeDeepRight = _curry2(function mergeDeepRight(lObj, rObj) { + return mergeDeepWithKey(function(k, lVal, rVal) { + return rVal; + }, lObj, rObj); +}); + +/** + * Creates a new object with the own properties of the two provided objects. + * If a key exists in both objects: + * - and both associated values are also objects then the values will be + * recursively merged. + * - otherwise the provided function is applied to associated values using the + * resulting value as the new value associated with the key. + * If a key only exists in one object, the value will be associated with the key + * of the resulting object. + * + * @func + * @memberOf R + * @since v0.24.0 + * @category Object + * @sig ((a, a) -> a) -> {a} -> {a} -> {a} + * @param {Function} fn + * @param {Object} lObj + * @param {Object} rObj + * @return {Object} + * @see R.mergeWith, R.mergeDeepWithKey + * @example + * + * R.mergeDeepWith(R.concat, + * { a: true, c: { values: [10, 20] }}, + * { b: true, c: { values: [15, 35] }}); + * //=> { a: true, b: true, c: { values: [10, 20, 15, 35] }} + */ +var mergeDeepWith = _curry3(function mergeDeepWith(fn, lObj, rObj) { + return mergeDeepWithKey(function(k, lVal, rVal) { + return fn(lVal, rVal); + }, lObj, rObj); +}); + +/** + * Create a new object with the own properties of the first object merged with + * the own properties of the second object. If a key exists in both objects, + * the value from the first object will be used. + * + * @func + * @memberOf R + * @category Object + * @sig {k: v} -> {k: v} -> {k: v} + * @param {Object} l + * @param {Object} r + * @return {Object} + * @see R.mergeRight, R.mergeDeepLeft, R.mergeWith, R.mergeWithKey + * @example + * + * R.mergeLeft({ 'age': 40 }, { 'name': 'fred', 'age': 10 }); + * //=> { 'name': 'fred', 'age': 40 } + * + * const resetToDefault = R.mergeLeft({x: 0}); + * resetToDefault({x: 5, y: 2}); //=> {x: 0, y: 2} + * @symb R.mergeLeft(a, b) = {...b, ...a} + */ +var mergeLeft = _curry2(function mergeLeft(l, r) { + return _objectAssign$1({}, r, l); +}); + +/** + * Create a new object with the own properties of the first object merged with + * the own properties of the second object. If a key exists in both objects, + * the value from the second object will be used. + * + * @func + * @memberOf R + * @category Object + * @sig {k: v} -> {k: v} -> {k: v} + * @param {Object} l + * @param {Object} r + * @return {Object} + * @see R.mergeLeft, R.mergeDeepRight, R.mergeWith, R.mergeWithKey + * @example + * + * R.mergeRight({ 'name': 'fred', 'age': 10 }, { 'age': 40 }); + * //=> { 'name': 'fred', 'age': 40 } + * + * const withDefaults = R.mergeRight({x: 0, y: 0}); + * withDefaults({y: 2}); //=> {x: 0, y: 2} + * @symb R.mergeRight(a, b) = {...a, ...b} + */ +var mergeRight = _curry2(function mergeRight(l, r) { + return _objectAssign$1({}, l, r); +}); + +/** + * Creates a new object with the own properties of the two provided objects. If + * a key exists in both objects, the provided function is applied to the values + * associated with the key in each object, with the result being used as the + * value associated with the key in the returned object. + * + * @func + * @memberOf R + * @since v0.19.0 + * @category Object + * @sig ((a, a) -> a) -> {a} -> {a} -> {a} + * @param {Function} fn + * @param {Object} l + * @param {Object} r + * @return {Object} + * @see R.mergeDeepWith, R.merge, R.mergeWithKey + * @example + * + * R.mergeWith(R.concat, + * { a: true, values: [10, 20] }, + * { b: true, values: [15, 35] }); + * //=> { a: true, b: true, values: [10, 20, 15, 35] } + */ +var mergeWith = _curry3(function mergeWith(fn, l, r) { + return mergeWithKey(function(_, _l, _r) { + return fn(_l, _r); + }, l, r); +}); + +/** + * Returns the smaller of its two arguments. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Relation + * @sig Ord a => a -> a -> a + * @param {*} a + * @param {*} b + * @return {*} + * @see R.minBy, R.max + * @example + * + * R.min(789, 123); //=> 123 + * R.min('a', 'b'); //=> 'a' + */ +var min = _curry2(function min(a, b) { return b < a ? b : a; }); + +/** + * Takes a function and two values, and returns whichever value produces the + * smaller result when passed to the provided function. + * + * @func + * @memberOf R + * @since v0.8.0 + * @category Relation + * @sig Ord b => (a -> b) -> a -> a -> a + * @param {Function} f + * @param {*} a + * @param {*} b + * @return {*} + * @see R.min, R.maxBy + * @example + * + * // square :: Number -> Number + * const square = n => n * n; + * + * R.minBy(square, -3, 2); //=> 2 + * + * R.reduce(R.minBy(square), Infinity, [3, -5, 4, 1, -2]); //=> 1 + * R.reduce(R.minBy(square), Infinity, []); //=> Infinity + */ +var minBy = _curry3(function minBy(f, a, b) { + return f(b) < f(a) ? b : a; +}); + +/** + * Divides the first parameter by the second and returns the remainder. Note + * that this function preserves the JavaScript-style behavior for modulo. For + * mathematical modulo see [`mathMod`](#mathMod). + * + * @func + * @memberOf R + * @since v0.1.1 + * @category Math + * @sig Number -> Number -> Number + * @param {Number} a The value to the divide. + * @param {Number} b The pseudo-modulus + * @return {Number} The result of `b % a`. + * @see R.mathMod + * @example + * + * R.modulo(17, 3); //=> 2 + * // JS behavior: + * R.modulo(-17, 3); //=> -2 + * R.modulo(17, -3); //=> 2 + * + * const isOdd = R.modulo(R.__, 2); + * isOdd(42); //=> 0 + * isOdd(21); //=> 1 + */ +var modulo = _curry2(function modulo(a, b) { return a % b; }); + +/** + * Multiplies two numbers. Equivalent to `a * b` but curried. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Math + * @sig Number -> Number -> Number + * @param {Number} a The first value. + * @param {Number} b The second value. + * @return {Number} The result of `a * b`. + * @see R.divide + * @example + * + * const double = R.multiply(2); + * const triple = R.multiply(3); + * double(3); //=> 6 + * triple(4); //=> 12 + * R.multiply(2, 5); //=> 10 + */ +var multiply = _curry2(function multiply(a, b) { return a * b; }); + +/** + * Negates its argument. + * + * @func + * @memberOf R + * @since v0.9.0 + * @category Math + * @sig Number -> Number + * @param {Number} n + * @return {Number} + * @example + * + * R.negate(42); //=> -42 + */ +var negate = _curry1(function negate(n) { return -n; }); + +/** + * Returns `true` if no elements of the list match the predicate, `false` + * otherwise. + * + * Dispatches to the `all` method of the second argument, if present. + * + * Acts as a transducer if a transformer is given in list position. + * + * @func + * @memberOf R + * @since v0.12.0 + * @category List + * @sig (a -> Boolean) -> [a] -> Boolean + * @param {Function} fn The predicate function. + * @param {Array} list The array to consider. + * @return {Boolean} `true` if the predicate is not satisfied by every element, `false` otherwise. + * @see R.all, R.any + * @example + * + * const isEven = n => n % 2 === 0; + * const isOdd = n => n % 2 === 1; + * + * R.none(isEven, [1, 3, 5, 7, 9, 11]); //=> true + * R.none(isOdd, [1, 3, 5, 7, 8, 11]); //=> false + */ +const none = _curry2(function none(fn, input) { + return all(_complement(fn), input); +}); + +/** + * Returns a function which returns its nth argument. + * + * @func + * @memberOf R + * @since v0.9.0 + * @category Function + * @sig Number -> *... -> * + * @param {Number} n + * @return {Function} + * @example + * + * R.nthArg(1)('a', 'b', 'c'); //=> 'b' + * R.nthArg(-1)('a', 'b', 'c'); //=> 'c' + * @symb R.nthArg(-1)(a, b, c) = c + * @symb R.nthArg(0)(a, b, c) = a + * @symb R.nthArg(1)(a, b, c) = b + */ +var nthArg = _curry1(function nthArg(n) { + var arity = n < 0 ? 1 : n + 1; + return curryN(arity, function() { + return nth(n, arguments); + }); +}); + +/** + * `o` is a curried composition function that returns a unary function. + * Like [`compose`](#compose), `o` performs right-to-left function composition. + * Unlike [`compose`](#compose), the rightmost function passed to `o` will be + * invoked with only one argument. Also, unlike [`compose`](#compose), `o` is + * limited to accepting only 2 unary functions. The name o was chosen because + * of its similarity to the mathematical composition operator ∘. + * + * @func + * @memberOf R + * @since v0.24.0 + * @category Function + * @sig (b -> c) -> (a -> b) -> a -> c + * @param {Function} f + * @param {Function} g + * @return {Function} + * @see R.compose, R.pipe + * @example + * + * const classyGreeting = name => "The name's " + name.last + ", " + name.first + " " + name.last + * const yellGreeting = R.o(R.toUpper, classyGreeting); + * yellGreeting({first: 'James', last: 'Bond'}); //=> "THE NAME'S BOND, JAMES BOND" + * + * R.o(R.multiply(10), R.add(10))(-4) //=> 60 + * + * @symb R.o(f, g, x) = f(g(x)) + */ +var o = _curry3(function o(f, g, x) { + return f(g(x)); +}); + +function _of(x) { return [x]; } + +/** + * Returns a singleton array containing the value provided. + * + * Note this `of` is different from the ES6 `of`; See + * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/of + * + * @func + * @memberOf R + * @since v0.3.0 + * @category Function + * @sig a -> [a] + * @param {*} x any value + * @return {Array} An array wrapping `x`. + * @example + * + * R.of(null); //=> [null] + * R.of([42]); //=> [[42]] + */ +var of = _curry1(_of); + +/** + * Returns a partial copy of an object omitting the keys specified. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Object + * @sig [String] -> {String: *} -> {String: *} + * @param {Array} names an array of String property names to omit from the new object + * @param {Object} obj The object to copy from + * @return {Object} A new object with properties from `names` not on it. + * @see R.pick + * @example + * + * R.omit(['a', 'd'], {a: 1, b: 2, c: 3, d: 4}); //=> {b: 2, c: 3} + */ +var omit = _curry2(function omit(names, obj) { + var result = {}; + var index = {}; + var idx = 0; + var len = names.length; + + while (idx < len) { + index[names[idx]] = 1; + idx += 1; + } + + for (var prop in obj) { + if (!index.hasOwnProperty(prop)) { + result[prop] = obj[prop]; + } + } + return result; +}); + +/** + * Accepts a function `fn` and returns a function that guards invocation of + * `fn` such that `fn` can only ever be called once, no matter how many times + * the returned function is invoked. The first value calculated is returned in + * subsequent invocations. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Function + * @sig (a... -> b) -> (a... -> b) + * @param {Function} fn The function to wrap in a call-only-once wrapper. + * @return {Function} The wrapped function. + * @example + * + * const addOneOnce = R.once(x => x + 1); + * addOneOnce(10); //=> 11 + * addOneOnce(addOneOnce(50)); //=> 11 + */ +var once = _curry1(function once(fn) { + var called = false; + var result; + return _arity(fn.length, function() { + if (called) { + return result; + } + called = true; + result = fn.apply(this, arguments); + return result; + }); +}); + +function _assertPromise(name, p) { + if (p == null || !_isFunction(p.then)) { + throw new TypeError('`' + name + '` expected a Promise, received ' + _toString(p, [])); + } +} + +/** + * Returns the result of applying the onFailure function to the value inside + * a failed promise. This is useful for handling rejected promises + * inside function compositions. + * + * @func + * @memberOf R + * @category Function + * @sig (e -> b) -> (Promise e a) -> (Promise e b) + * @sig (e -> (Promise f b)) -> (Promise e a) -> (Promise f b) + * @param {Function} onFailure The function to apply. Can return a value or a promise of a value. + * @param {Promise} p + * @return {Promise} The result of calling `p.then(null, onFailure)` + * @see R.then + * @example + * + * var failedFetch = (id) => Promise.reject('bad ID'); + * var useDefault = () => ({ firstName: 'Bob', lastName: 'Loblaw' }) + * + * //recoverFromFailure :: String -> Promise ({firstName, lastName}) + * var recoverFromFailure = R.pipe( + * failedFetch(12345), + * R.otherwise(useDefault), + * R.then(R.pick(['firstName', 'lastName'])) + * ); + */ +const otherwise = _curry2(function otherwise(f, p) { + _assertPromise('otherwise', p); + + return p.then(null, f); +}); + +// `Identity` is a functor that holds a single value, where `map` simply +// transforms the held value with the provided function. +var Identity = function(x) { + return {value: x, map: function(f) { return Identity(f(x)); }}; +}; + + +/** + * Returns the result of "setting" the portion of the given data structure + * focused by the given lens to the result of applying the given function to + * the focused value. + * + * @func + * @memberOf R + * @since v0.16.0 + * @category Object + * @typedefn Lens s a = Functor f => (a -> f a) -> s -> f s + * @sig Lens s a -> (a -> a) -> s -> s + * @param {Lens} lens + * @param {*} v + * @param {*} x + * @return {*} + * @see R.prop, R.lensIndex, R.lensProp + * @example + * + * const headLens = R.lensIndex(0); + * + * R.over(headLens, R.toUpper, ['foo', 'bar', 'baz']); //=> ['FOO', 'bar', 'baz'] + */ +var over = _curry3(function over(lens, f, x) { + // The value returned by the getter function is first transformed with `f`, + // then set as the value of an `Identity`. This is then mapped over with the + // setter function of the lens. + return lens(function(y) { return Identity(f(y)); })(x).value; +}); + +/** + * Takes two arguments, `fst` and `snd`, and returns `[fst, snd]`. + * + * @func + * @memberOf R + * @since v0.18.0 + * @category List + * @sig a -> b -> (a,b) + * @param {*} fst + * @param {*} snd + * @return {Array} + * @see R.objOf, R.of + * @example + * + * R.pair('foo', 'bar'); //=> ['foo', 'bar'] + */ +var pair = _curry2(function pair(fst, snd) { return [fst, snd]; }); + +function _createPartialApplicator(concat) { + return _curry2(function(fn, args) { + return _arity(Math.max(0, fn.length - args.length), function() { + return fn.apply(this, concat(args, arguments)); + }); + }); +} + +/** + * Takes a function `f` and a list of arguments, and returns a function `g`. + * When applied, `g` returns the result of applying `f` to the arguments + * provided initially followed by the arguments provided to `g`. + * + * @func + * @memberOf R + * @since v0.10.0 + * @category Function + * @sig ((a, b, c, ..., n) -> x) -> [a, b, c, ...] -> ((d, e, f, ..., n) -> x) + * @param {Function} f + * @param {Array} args + * @return {Function} + * @see R.partialRight, R.curry + * @example + * + * const multiply2 = (a, b) => a * b; + * const double = R.partial(multiply2, [2]); + * double(2); //=> 4 + * + * const greet = (salutation, title, firstName, lastName) => + * salutation + ', ' + title + ' ' + firstName + ' ' + lastName + '!'; + * + * const sayHello = R.partial(greet, ['Hello']); + * const sayHelloToMs = R.partial(sayHello, ['Ms.']); + * sayHelloToMs('Jane', 'Jones'); //=> 'Hello, Ms. Jane Jones!' + * @symb R.partial(f, [a, b])(c, d) = f(a, b, c, d) + */ +var partial = _createPartialApplicator(_concat); + +/** + * Takes a function `f` and a list of arguments, and returns a function `g`. + * When applied, `g` returns the result of applying `f` to the arguments + * provided to `g` followed by the arguments provided initially. + * + * @func + * @memberOf R + * @since v0.10.0 + * @category Function + * @sig ((a, b, c, ..., n) -> x) -> [d, e, f, ..., n] -> ((a, b, c, ...) -> x) + * @param {Function} f + * @param {Array} args + * @return {Function} + * @see R.partial + * @example + * + * const greet = (salutation, title, firstName, lastName) => + * salutation + ', ' + title + ' ' + firstName + ' ' + lastName + '!'; + * + * const greetMsJaneJones = R.partialRight(greet, ['Ms.', 'Jane', 'Jones']); + * + * greetMsJaneJones('Hello'); //=> 'Hello, Ms. Jane Jones!' + * @symb R.partialRight(f, [a, b])(c, d) = f(c, d, a, b) + */ +var partialRight = _createPartialApplicator(flip(_concat)); + +/** + * Takes a predicate and a list or other `Filterable` object and returns the + * pair of filterable objects of the same type of elements which do and do not + * satisfy, the predicate, respectively. Filterable objects include plain objects or any object + * that has a filter method such as `Array`. + * + * @func + * @memberOf R + * @since v0.1.4 + * @category List + * @sig Filterable f => (a -> Boolean) -> f a -> [f a, f a] + * @param {Function} pred A predicate to determine which side the element belongs to. + * @param {Array} filterable the list (or other filterable) to partition. + * @return {Array} An array, containing first the subset of elements that satisfy the + * predicate, and second the subset of elements that do not satisfy. + * @see R.filter, R.reject + * @example + * + * R.partition(R.includes('s'), ['sss', 'ttt', 'foo', 'bars']); + * // => [ [ 'sss', 'bars' ], [ 'ttt', 'foo' ] ] + * + * R.partition(R.includes('s'), { a: 'sss', b: 'ttt', foo: 'bars' }); + * // => [ { a: 'sss', foo: 'bars' }, { b: 'ttt' } ] + */ +var partition = juxt([filter, reject]); + +/** + * Determines whether a nested path on an object has a specific value, in + * [`R.equals`](#equals) terms. Most likely used to filter a list. + * + * @func + * @memberOf R + * @since v0.7.0 + * @category Relation + * @typedefn Idx = String | Int + * @sig [Idx] -> a -> {a} -> Boolean + * @param {Array} path The path of the nested property to use + * @param {*} val The value to compare the nested property with + * @param {Object} obj The object to check the nested property in + * @return {Boolean} `true` if the value equals the nested object property, + * `false` otherwise. + * @example + * + * const user1 = { address: { zipCode: 90210 } }; + * const user2 = { address: { zipCode: 55555 } }; + * const user3 = { name: 'Bob' }; + * const users = [ user1, user2, user3 ]; + * const isFamous = R.pathEq(['address', 'zipCode'], 90210); + * R.filter(isFamous, users); //=> [ user1 ] + */ +var pathEq = _curry3(function pathEq(_path, val, obj) { + return equals(path(_path, obj), val); +}); + +/** + * If the given, non-null object has a value at the given path, returns the + * value at that path. Otherwise returns the provided default value. + * + * @func + * @memberOf R + * @since v0.18.0 + * @category Object + * @typedefn Idx = String | Int + * @sig a -> [Idx] -> {a} -> a + * @param {*} d The default value. + * @param {Array} p The path to use. + * @param {Object} obj The object to retrieve the nested property from. + * @return {*} The data at `path` of the supplied object or the default value. + * @example + * + * R.pathOr('N/A', ['a', 'b'], {a: {b: 2}}); //=> 2 + * R.pathOr('N/A', ['a', 'b'], {c: {b: 2}}); //=> "N/A" + */ +var pathOr = _curry3(function pathOr(d, p, obj) { + return defaultTo(d, path(p, obj)); +}); + +/** + * Returns `true` if the specified object property at given path satisfies the + * given predicate; `false` otherwise. + * + * @func + * @memberOf R + * @since v0.19.0 + * @category Logic + * @typedefn Idx = String | Int + * @sig (a -> Boolean) -> [Idx] -> {a} -> Boolean + * @param {Function} pred + * @param {Array} propPath + * @param {*} obj + * @return {Boolean} + * @see R.propSatisfies, R.path + * @example + * + * R.pathSatisfies(y => y > 0, ['x', 'y'], {x: {y: 2}}); //=> true + */ +var pathSatisfies = _curry3(function pathSatisfies(pred, propPath, obj) { + return propPath.length > 0 && pred(path(propPath, obj)); +}); + +/** + * Returns a partial copy of an object containing only the keys specified. If + * the key does not exist, the property is ignored. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Object + * @sig [k] -> {k: v} -> {k: v} + * @param {Array} names an array of String property names to copy onto a new object + * @param {Object} obj The object to copy from + * @return {Object} A new object with only properties from `names` on it. + * @see R.omit, R.props + * @example + * + * R.pick(['a', 'd'], {a: 1, b: 2, c: 3, d: 4}); //=> {a: 1, d: 4} + * R.pick(['a', 'e', 'f'], {a: 1, b: 2, c: 3, d: 4}); //=> {a: 1} + */ +var pick = _curry2(function pick(names, obj) { + var result = {}; + var idx = 0; + while (idx < names.length) { + if (names[idx] in obj) { + result[names[idx]] = obj[names[idx]]; + } + idx += 1; + } + return result; +}); + +/** + * Similar to `pick` except that this one includes a `key: undefined` pair for + * properties that don't exist. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Object + * @sig [k] -> {k: v} -> {k: v} + * @param {Array} names an array of String property names to copy onto a new object + * @param {Object} obj The object to copy from + * @return {Object} A new object with only properties from `names` on it. + * @see R.pick + * @example + * + * R.pickAll(['a', 'd'], {a: 1, b: 2, c: 3, d: 4}); //=> {a: 1, d: 4} + * R.pickAll(['a', 'e', 'f'], {a: 1, b: 2, c: 3, d: 4}); //=> {a: 1, e: undefined, f: undefined} + */ +var pickAll = _curry2(function pickAll(names, obj) { + var result = {}; + var idx = 0; + var len = names.length; + while (idx < len) { + var name = names[idx]; + result[name] = obj[name]; + idx += 1; + } + return result; +}); + +/** + * Returns a partial copy of an object containing only the keys that satisfy + * the supplied predicate. + * + * @func + * @memberOf R + * @since v0.8.0 + * @category Object + * @sig ((v, k) -> Boolean) -> {k: v} -> {k: v} + * @param {Function} pred A predicate to determine whether or not a key + * should be included on the output object. + * @param {Object} obj The object to copy from + * @return {Object} A new object with only properties that satisfy `pred` + * on it. + * @see R.pick, R.filter + * @example + * + * const isUpperCase = (val, key) => key.toUpperCase() === key; + * R.pickBy(isUpperCase, {a: 1, b: 2, A: 3, B: 4}); //=> {A: 3, B: 4} + */ +var pickBy = _curry2(function pickBy(test, obj) { + var result = {}; + for (var prop in obj) { + if (test(obj[prop], prop, obj)) { + result[prop] = obj[prop]; + } + } + return result; +}); + +/** + * Returns the left-to-right Kleisli composition of the provided functions, + * each of which must return a value of a type supported by [`chain`](#chain). + * + * `R.pipeK(f, g, h)` is equivalent to `R.pipe(f, R.chain(g), R.chain(h))`. + * + * @func + * @memberOf R + * @since v0.16.0 + * @category Function + * @sig Chain m => ((a -> m b), (b -> m c), ..., (y -> m z)) -> (a -> m z) + * @param {...Function} + * @return {Function} + * @see R.composeK + * @example + * + * // parseJson :: String -> Maybe * + * // get :: String -> Object -> Maybe * + * + * // getStateCode :: Maybe String -> Maybe String + * const getStateCode = R.pipeK( + * parseJson, + * get('user'), + * get('address'), + * get('state'), + * R.compose(Maybe.of, R.toUpper) + * ); + * + * getStateCode('{"user":{"address":{"state":"ny"}}}'); + * //=> Just('NY') + * getStateCode('[Invalid JSON]'); + * //=> Nothing() + * @symb R.pipeK(f, g, h)(a) = R.chain(h, R.chain(g, f(a))) + */ +function pipeK() { + if (arguments.length === 0) { + throw new Error('pipeK requires at least one argument'); + } + return composeK.apply(this, reverse(arguments)); +} + +/** + * Returns a new list with the given element at the front, followed by the + * contents of the list. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category List + * @sig a -> [a] -> [a] + * @param {*} el The item to add to the head of the output list. + * @param {Array} list The array to add to the tail of the output list. + * @return {Array} A new array. + * @see R.append + * @example + * + * R.prepend('fee', ['fi', 'fo', 'fum']); //=> ['fee', 'fi', 'fo', 'fum'] + */ +var prepend = _curry2(function prepend(el, list) { + return _concat([el], list); +}); + +/** + * Multiplies together all the elements of a list. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Math + * @sig [Number] -> Number + * @param {Array} list An array of numbers + * @return {Number} The product of all the numbers in the list. + * @see R.reduce + * @example + * + * R.product([2,4,6,8,100,1]); //=> 38400 + */ +var product = reduce(multiply, 1); + +/** + * Accepts a function `fn` and a list of transformer functions and returns a + * new curried function. When the new function is invoked, it calls the + * function `fn` with parameters consisting of the result of calling each + * supplied handler on successive arguments to the new function. + * + * If more arguments are passed to the returned function than transformer + * functions, those arguments are passed directly to `fn` as additional + * parameters. If you expect additional arguments that don't need to be + * transformed, although you can ignore them, it's best to pass an identity + * function so that the new function reports the correct arity. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Function + * @sig ((x1, x2, ...) -> z) -> [(a -> x1), (b -> x2), ...] -> (a -> b -> ... -> z) + * @param {Function} fn The function to wrap. + * @param {Array} transformers A list of transformer functions + * @return {Function} The wrapped function. + * @see R.converge + * @example + * + * R.useWith(Math.pow, [R.identity, R.identity])(3, 4); //=> 81 + * R.useWith(Math.pow, [R.identity, R.identity])(3)(4); //=> 81 + * R.useWith(Math.pow, [R.dec, R.inc])(3, 4); //=> 32 + * R.useWith(Math.pow, [R.dec, R.inc])(3)(4); //=> 32 + * @symb R.useWith(f, [g, h])(a, b) = f(g(a), h(b)) + */ +var useWith = _curry2(function useWith(fn, transformers) { + return curryN(transformers.length, function() { + var args = []; + var idx = 0; + while (idx < transformers.length) { + args.push(transformers[idx].call(this, arguments[idx])); + idx += 1; + } + return fn.apply(this, args.concat(Array.prototype.slice.call(arguments, transformers.length))); + }); +}); + +/** + * Reasonable analog to SQL `select` statement. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Object + * @category Relation + * @sig [k] -> [{k: v}] -> [{k: v}] + * @param {Array} props The property names to project + * @param {Array} objs The objects to query + * @return {Array} An array of objects with just the `props` properties. + * @example + * + * const abby = {name: 'Abby', age: 7, hair: 'blond', grade: 2}; + * const fred = {name: 'Fred', age: 12, hair: 'brown', grade: 7}; + * const kids = [abby, fred]; + * R.project(['name', 'grade'], kids); //=> [{name: 'Abby', grade: 2}, {name: 'Fred', grade: 7}] + */ +var project = useWith(_map, [pickAll, identity]); // passing `identity` gives correct arity + +/** + * Returns `true` if the specified object property is equal, in + * [`R.equals`](#equals) terms, to the given value; `false` otherwise. + * You can test multiple properties with [`R.whereEq`](#whereEq). + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Relation + * @sig String -> a -> Object -> Boolean + * @param {String} name + * @param {*} val + * @param {*} obj + * @return {Boolean} + * @see R.whereEq, R.propSatisfies, R.equals + * @example + * + * const abby = {name: 'Abby', age: 7, hair: 'blond'}; + * const fred = {name: 'Fred', age: 12, hair: 'brown'}; + * const rusty = {name: 'Rusty', age: 10, hair: 'brown'}; + * const alois = {name: 'Alois', age: 15, disposition: 'surly'}; + * const kids = [abby, fred, rusty, alois]; + * const hasBrownHair = R.propEq('hair', 'brown'); + * R.filter(hasBrownHair, kids); //=> [fred, rusty] + */ +var propEq = _curry3(function propEq(name, val, obj) { + return equals(val, obj[name]); +}); + +/** + * Returns `true` if the specified object property is of the given type; + * `false` otherwise. + * + * @func + * @memberOf R + * @since v0.16.0 + * @category Type + * @sig Type -> String -> Object -> Boolean + * @param {Function} type + * @param {String} name + * @param {*} obj + * @return {Boolean} + * @see R.is, R.propSatisfies + * @example + * + * R.propIs(Number, 'x', {x: 1, y: 2}); //=> true + * R.propIs(Number, 'x', {x: 'foo'}); //=> false + * R.propIs(Number, 'x', {}); //=> false + */ +var propIs = _curry3(function propIs(type, name, obj) { + return is(type, obj[name]); +}); + +/** + * If the given, non-null object has an own property with the specified name, + * returns the value of that property. Otherwise returns the provided default + * value. + * + * @func + * @memberOf R + * @since v0.6.0 + * @category Object + * @sig a -> String -> Object -> a + * @param {*} val The default value. + * @param {String} p The name of the property to return. + * @param {Object} obj The object to query. + * @return {*} The value of given property of the supplied object or the default value. + * @example + * + * const alice = { + * name: 'ALICE', + * age: 101 + * }; + * const favorite = R.prop('favoriteLibrary'); + * const favoriteWithDefault = R.propOr('Ramda', 'favoriteLibrary'); + * + * favorite(alice); //=> undefined + * favoriteWithDefault(alice); //=> 'Ramda' + */ +var propOr = _curry3(function propOr(val, p, obj) { + return pathOr(val, [p], obj); +}); + +/** + * Returns `true` if the specified object property satisfies the given + * predicate; `false` otherwise. You can test multiple properties with + * [`R.where`](#where). + * + * @func + * @memberOf R + * @since v0.16.0 + * @category Logic + * @sig (a -> Boolean) -> String -> {String: a} -> Boolean + * @param {Function} pred + * @param {String} name + * @param {*} obj + * @return {Boolean} + * @see R.where, R.propEq, R.propIs + * @example + * + * R.propSatisfies(x => x > 0, 'x', {x: 1, y: 2}); //=> true + */ +var propSatisfies = _curry3(function propSatisfies(pred, name, obj) { + return pred(obj[name]); +}); + +/** + * Acts as multiple `prop`: array of keys in, array of values out. Preserves + * order. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Object + * @sig [k] -> {k: v} -> [v] + * @param {Array} ps The property names to fetch + * @param {Object} obj The object to query + * @return {Array} The corresponding values or partially applied function. + * @example + * + * R.props(['x', 'y'], {x: 1, y: 2}); //=> [1, 2] + * R.props(['c', 'a', 'b'], {b: 2, a: 1}); //=> [undefined, 1, 2] + * + * const fullName = R.compose(R.join(' '), R.props(['first', 'last'])); + * fullName({last: 'Bullet-Tooth', age: 33, first: 'Tony'}); //=> 'Tony Bullet-Tooth' + */ +var props = _curry2(function props(ps, obj) { + var len = ps.length; + var out = []; + var idx = 0; + + while (idx < len) { + out[idx] = obj[ps[idx]]; + idx += 1; + } + + return out; +}); + +/** + * Returns a list of numbers from `from` (inclusive) to `to` (exclusive). + * + * @func + * @memberOf R + * @since v0.1.0 + * @category List + * @sig Number -> Number -> [Number] + * @param {Number} from The first number in the list. + * @param {Number} to One more than the last number in the list. + * @return {Array} The list of numbers in the set `[a, b)`. + * @example + * + * R.range(1, 5); //=> [1, 2, 3, 4] + * R.range(50, 53); //=> [50, 51, 52] + */ +var range = _curry2(function range(from, to) { + if (!(_isNumber(from) && _isNumber(to))) { + throw new TypeError('Both arguments to range must be numbers'); + } + var result = []; + var n = from; + while (n < to) { + result.push(n); + n += 1; + } + return result; +}); + +/** + * Returns a single item by iterating through the list, successively calling + * the iterator function and passing it an accumulator value and the current + * value from the array, and then passing the result to the next call. + * + * Similar to [`reduce`](#reduce), except moves through the input list from the + * right to the left. + * + * The iterator function receives two values: *(value, acc)*, while the arguments' + * order of `reduce`'s iterator function is *(acc, value)*. + * + * Note: `R.reduceRight` does not skip deleted or unassigned indices (sparse + * arrays), unlike the native `Array.prototype.reduceRight` method. For more details + * on this behavior, see: + * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduceRight#Description + * + * @func + * @memberOf R + * @since v0.1.0 + * @category List + * @sig ((a, b) -> b) -> b -> [a] -> b + * @param {Function} fn The iterator function. Receives two values, the current element from the array + * and the accumulator. + * @param {*} acc The accumulator value. + * @param {Array} list The list to iterate over. + * @return {*} The final, accumulated value. + * @see R.reduce, R.addIndex + * @example + * + * R.reduceRight(R.subtract, 0, [1, 2, 3, 4]) // => (1 - (2 - (3 - (4 - 0)))) = -2 + * // - -2 + * // / \ / \ + * // 1 - 1 3 + * // / \ / \ + * // 2 - ==> 2 -1 + * // / \ / \ + * // 3 - 3 4 + * // / \ / \ + * // 4 0 4 0 + * + * @symb R.reduceRight(f, a, [b, c, d]) = f(b, f(c, f(d, a))) + */ +var reduceRight = _curry3(function reduceRight(fn, acc, list) { + var idx = list.length - 1; + while (idx >= 0) { + acc = fn(list[idx], acc); + idx -= 1; + } + return acc; +}); + +/** + * Like [`reduce`](#reduce), `reduceWhile` returns a single item by iterating + * through the list, successively calling the iterator function. `reduceWhile` + * also takes a predicate that is evaluated before each step. If the predicate + * returns `false`, it "short-circuits" the iteration and returns the current + * value of the accumulator. + * + * @func + * @memberOf R + * @since v0.22.0 + * @category List + * @sig ((a, b) -> Boolean) -> ((a, b) -> a) -> a -> [b] -> a + * @param {Function} pred The predicate. It is passed the accumulator and the + * current element. + * @param {Function} fn The iterator function. Receives two values, the + * accumulator and the current element. + * @param {*} a The accumulator value. + * @param {Array} list The list to iterate over. + * @return {*} The final, accumulated value. + * @see R.reduce, R.reduced + * @example + * + * const isOdd = (acc, x) => x % 2 === 1; + * const xs = [1, 3, 5, 60, 777, 800]; + * R.reduceWhile(isOdd, R.add, 0, xs); //=> 9 + * + * const ys = [2, 4, 6] + * R.reduceWhile(isOdd, R.add, 111, ys); //=> 111 + */ +var reduceWhile = _curryN(4, [], function _reduceWhile(pred, fn, a, list) { + return _reduce(function(acc, x) { + return pred(acc, x) ? fn(acc, x) : _reduced(acc); + }, a, list); +}); + +/** + * Returns a value wrapped to indicate that it is the final value of the reduce + * and transduce functions. The returned value should be considered a black + * box: the internal structure is not guaranteed to be stable. + * + * Note: this optimization is only available to the below functions: + * - [`reduce`](#reduce) + * - [`reduceWhile`](#reduceWhile) + * - [`transduce`](#transduce) + * + * @func + * @memberOf R + * @since v0.15.0 + * @category List + * @sig a -> * + * @param {*} x The final value of the reduce. + * @return {*} The wrapped value. + * @see R.reduce, R.reduceWhile, R.transduce + * @example + * + * R.reduce( + * (acc, item) => item > 3 ? R.reduced(acc) : acc.concat(item), + * [], + * [1, 2, 3, 4, 5]) // [1, 2, 3] + */ +var reduced = _curry1(_reduced); + +/** + * Calls an input function `n` times, returning an array containing the results + * of those function calls. + * + * `fn` is passed one argument: The current value of `n`, which begins at `0` + * and is gradually incremented to `n - 1`. + * + * @func + * @memberOf R + * @since v0.2.3 + * @category List + * @sig (Number -> a) -> Number -> [a] + * @param {Function} fn The function to invoke. Passed one argument, the current value of `n`. + * @param {Number} n A value between `0` and `n - 1`. Increments after each function call. + * @return {Array} An array containing the return values of all calls to `fn`. + * @see R.repeat + * @example + * + * R.times(R.identity, 5); //=> [0, 1, 2, 3, 4] + * @symb R.times(f, 0) = [] + * @symb R.times(f, 1) = [f(0)] + * @symb R.times(f, 2) = [f(0), f(1)] + */ +var times = _curry2(function times(fn, n) { + var len = Number(n); + var idx = 0; + var list; + + if (len < 0 || isNaN(len)) { + throw new RangeError('n must be a non-negative number'); + } + list = new Array(len); + while (idx < len) { + list[idx] = fn(idx); + idx += 1; + } + return list; +}); + +/** + * Returns a fixed list of size `n` containing a specified identical value. + * + * @func + * @memberOf R + * @since v0.1.1 + * @category List + * @sig a -> n -> [a] + * @param {*} value The value to repeat. + * @param {Number} n The desired size of the output list. + * @return {Array} A new array containing `n` `value`s. + * @see R.times + * @example + * + * R.repeat('hi', 5); //=> ['hi', 'hi', 'hi', 'hi', 'hi'] + * + * const obj = {}; + * const repeatedObjs = R.repeat(obj, 5); //=> [{}, {}, {}, {}, {}] + * repeatedObjs[0] === repeatedObjs[1]; //=> true + * @symb R.repeat(a, 0) = [] + * @symb R.repeat(a, 1) = [a] + * @symb R.repeat(a, 2) = [a, a] + */ +var repeat = _curry2(function repeat(value, n) { + return times(always(value), n); +}); + +/** + * Replace a substring or regex match in a string with a replacement. + * + * The first two parameters correspond to the parameters of the + * `String.prototype.replace()` function, so the second parameter can also be a + * function. + * + * @func + * @memberOf R + * @since v0.7.0 + * @category String + * @sig RegExp|String -> String -> String -> String + * @param {RegExp|String} pattern A regular expression or a substring to match. + * @param {String} replacement The string to replace the matches with. + * @param {String} str The String to do the search and replacement in. + * @return {String} The result. + * @example + * + * R.replace('foo', 'bar', 'foo foo foo'); //=> 'bar foo foo' + * R.replace(/foo/, 'bar', 'foo foo foo'); //=> 'bar foo foo' + * + * // Use the "g" (global) flag to replace all occurrences: + * R.replace(/foo/g, 'bar', 'foo foo foo'); //=> 'bar bar bar' + */ +var replace = _curry3(function replace(regex, replacement, str) { + return str.replace(regex, replacement); +}); + +/** + * Scan is similar to [`reduce`](#reduce), but returns a list of successively + * reduced values from the left + * + * @func + * @memberOf R + * @since v0.10.0 + * @category List + * @sig ((a, b) -> a) -> a -> [b] -> [a] + * @param {Function} fn The iterator function. Receives two values, the accumulator and the + * current element from the array + * @param {*} acc The accumulator value. + * @param {Array} list The list to iterate over. + * @return {Array} A list of all intermediately reduced values. + * @see R.reduce, R.mapAccum + * @example + * + * const numbers = [1, 2, 3, 4]; + * const factorials = R.scan(R.multiply, 1, numbers); //=> [1, 1, 2, 6, 24] + * @symb R.scan(f, a, [b, c]) = [a, f(a, b), f(f(a, b), c)] + */ +var scan = _curry3(function scan(fn, acc, list) { + var idx = 0; + var len = list.length; + var result = [acc]; + while (idx < len) { + acc = fn(acc, list[idx]); + result[idx + 1] = acc; + idx += 1; + } + return result; +}); + +/** + * Transforms a [Traversable](https://github.com/fantasyland/fantasy-land#traversable) + * of [Applicative](https://github.com/fantasyland/fantasy-land#applicative) into an + * Applicative of Traversable. + * + * Dispatches to the `sequence` method of the second argument, if present. + * + * @func + * @memberOf R + * @since v0.19.0 + * @category List + * @sig (Applicative f, Traversable t) => (a -> f a) -> t (f a) -> f (t a) + * @param {Function} of + * @param {*} traversable + * @return {*} + * @see R.traverse + * @example + * + * R.sequence(Maybe.of, [Just(1), Just(2), Just(3)]); //=> Just([1, 2, 3]) + * R.sequence(Maybe.of, [Just(1), Just(2), Nothing()]); //=> Nothing() + * + * R.sequence(R.of, Just([1, 2, 3])); //=> [Just(1), Just(2), Just(3)] + * R.sequence(R.of, Nothing()); //=> [Nothing()] + */ +var sequence = _curry2(function sequence(of, traversable) { + return typeof traversable.sequence === 'function' ? + traversable.sequence(of) : + reduceRight(function(x, acc) { return ap(map(prepend, x), acc); }, + of([]), + traversable); +}); + +/** + * Returns the result of "setting" the portion of the given data structure + * focused by the given lens to the given value. + * + * @func + * @memberOf R + * @since v0.16.0 + * @category Object + * @typedefn Lens s a = Functor f => (a -> f a) -> s -> f s + * @sig Lens s a -> a -> s -> s + * @param {Lens} lens + * @param {*} v + * @param {*} x + * @return {*} + * @see R.prop, R.lensIndex, R.lensProp + * @example + * + * const xLens = R.lensProp('x'); + * + * R.set(xLens, 4, {x: 1, y: 2}); //=> {x: 4, y: 2} + * R.set(xLens, 8, {x: 1, y: 2}); //=> {x: 8, y: 2} + */ +var set = _curry3(function set(lens, v, x) { + return over(lens, always(v), x); +}); + +/** + * Returns a copy of the list, sorted according to the comparator function, + * which should accept two values at a time and return a negative number if the + * first value is smaller, a positive number if it's larger, and zero if they + * are equal. Please note that this is a **copy** of the list. It does not + * modify the original. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category List + * @sig ((a, a) -> Number) -> [a] -> [a] + * @param {Function} comparator A sorting function :: a -> b -> Int + * @param {Array} list The list to sort + * @return {Array} a new array with its elements sorted by the comparator function. + * @example + * + * const diff = function(a, b) { return a - b; }; + * R.sort(diff, [4,2,7,5]); //=> [2, 4, 5, 7] + */ +var sort = _curry2(function sort(comparator, list) { + return Array.prototype.slice.call(list, 0).sort(comparator); +}); + +/** + * Sorts the list according to the supplied function. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Relation + * @sig Ord b => (a -> b) -> [a] -> [a] + * @param {Function} fn + * @param {Array} list The list to sort. + * @return {Array} A new list sorted by the keys generated by `fn`. + * @example + * + * const sortByFirstItem = R.sortBy(R.prop(0)); + * const pairs = [[-1, 1], [-2, 2], [-3, 3]]; + * sortByFirstItem(pairs); //=> [[-3, 3], [-2, 2], [-1, 1]] + * + * const sortByNameCaseInsensitive = R.sortBy(R.compose(R.toLower, R.prop('name'))); + * const alice = { + * name: 'ALICE', + * age: 101 + * }; + * const bob = { + * name: 'Bob', + * age: -10 + * }; + * const clara = { + * name: 'clara', + * age: 314.159 + * }; + * const people = [clara, bob, alice]; + * sortByNameCaseInsensitive(people); //=> [alice, bob, clara] + */ +var sortBy = _curry2(function sortBy(fn, list) { + return Array.prototype.slice.call(list, 0).sort(function(a, b) { + var aa = fn(a); + var bb = fn(b); + return aa < bb ? -1 : aa > bb ? 1 : 0; + }); +}); + +/** + * Sorts a list according to a list of comparators. + * + * @func + * @memberOf R + * @since v0.23.0 + * @category Relation + * @sig [(a, a) -> Number] -> [a] -> [a] + * @param {Array} functions A list of comparator functions. + * @param {Array} list The list to sort. + * @return {Array} A new list sorted according to the comarator functions. + * @example + * + * const alice = { + * name: 'alice', + * age: 40 + * }; + * const bob = { + * name: 'bob', + * age: 30 + * }; + * const clara = { + * name: 'clara', + * age: 40 + * }; + * const people = [clara, bob, alice]; + * const ageNameSort = R.sortWith([ + * R.descend(R.prop('age')), + * R.ascend(R.prop('name')) + * ]); + * ageNameSort(people); //=> [alice, clara, bob] + */ +var sortWith = _curry2(function sortWith(fns, list) { + return Array.prototype.slice.call(list, 0).sort(function(a, b) { + var result = 0; + var i = 0; + while (result === 0 && i < fns.length) { + result = fns[i](a, b); + i += 1; + } + return result; + }); +}); + +/** + * Splits a string into an array of strings based on the given + * separator. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category String + * @sig (String | RegExp) -> String -> [String] + * @param {String|RegExp} sep The pattern. + * @param {String} str The string to separate into an array. + * @return {Array} The array of strings from `str` separated by `str`. + * @see R.join + * @example + * + * const pathComponents = R.split('/'); + * R.tail(pathComponents('/usr/local/bin/node')); //=> ['usr', 'local', 'bin', 'node'] + * + * R.split('.', 'a.b.c.xyz.d'); //=> ['a', 'b', 'c', 'xyz', 'd'] + */ +var split = invoker(1, 'split'); + +/** + * Splits a given list or string at a given index. + * + * @func + * @memberOf R + * @since v0.19.0 + * @category List + * @sig Number -> [a] -> [[a], [a]] + * @sig Number -> String -> [String, String] + * @param {Number} index The index where the array/string is split. + * @param {Array|String} array The array/string to be split. + * @return {Array} + * @example + * + * R.splitAt(1, [1, 2, 3]); //=> [[1], [2, 3]] + * R.splitAt(5, 'hello world'); //=> ['hello', ' world'] + * R.splitAt(-1, 'foobar'); //=> ['fooba', 'r'] + */ +var splitAt = _curry2(function splitAt(index, array) { + return [slice(0, index, array), slice(index, length(array), array)]; +}); + +/** + * Splits a collection into slices of the specified length. + * + * @func + * @memberOf R + * @since v0.16.0 + * @category List + * @sig Number -> [a] -> [[a]] + * @sig Number -> String -> [String] + * @param {Number} n + * @param {Array} list + * @return {Array} + * @example + * + * R.splitEvery(3, [1, 2, 3, 4, 5, 6, 7]); //=> [[1, 2, 3], [4, 5, 6], [7]] + * R.splitEvery(3, 'foobarbaz'); //=> ['foo', 'bar', 'baz'] + */ +var splitEvery = _curry2(function splitEvery(n, list) { + if (n <= 0) { + throw new Error('First argument to splitEvery must be a positive integer'); + } + var result = []; + var idx = 0; + while (idx < list.length) { + result.push(slice(idx, idx += n, list)); + } + return result; +}); + +/** + * Takes a list and a predicate and returns a pair of lists with the following properties: + * + * - the result of concatenating the two output lists is equivalent to the input list; + * - none of the elements of the first output list satisfies the predicate; and + * - if the second output list is non-empty, its first element satisfies the predicate. + * + * @func + * @memberOf R + * @since v0.19.0 + * @category List + * @sig (a -> Boolean) -> [a] -> [[a], [a]] + * @param {Function} pred The predicate that determines where the array is split. + * @param {Array} list The array to be split. + * @return {Array} + * @example + * + * R.splitWhen(R.equals(2), [1, 2, 3, 1, 2, 3]); //=> [[1], [2, 3, 1, 2, 3]] + */ +var splitWhen = _curry2(function splitWhen(pred, list) { + var idx = 0; + var len = list.length; + var prefix = []; + + while (idx < len && !pred(list[idx])) { + prefix.push(list[idx]); + idx += 1; + } + + return [prefix, Array.prototype.slice.call(list, idx)]; +}); + +/** + * Checks if a list starts with the provided sublist. + * + * Similarly, checks if a string starts with the provided substring. + * + * @func + * @memberOf R + * @since v0.24.0 + * @category List + * @sig [a] -> [a] -> Boolean + * @sig String -> String -> Boolean + * @param {*} prefix + * @param {*} list + * @return {Boolean} + * @see R.endsWith + * @example + * + * R.startsWith('a', 'abc') //=> true + * R.startsWith('b', 'abc') //=> false + * R.startsWith(['a'], ['a', 'b', 'c']) //=> true + * R.startsWith(['b'], ['a', 'b', 'c']) //=> false + */ +var startsWith = _curry2(function(prefix, list) { + return equals(take(prefix.length, list), prefix); +}); + +/** + * Subtracts its second argument from its first argument. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Math + * @sig Number -> Number -> Number + * @param {Number} a The first value. + * @param {Number} b The second value. + * @return {Number} The result of `a - b`. + * @see R.add + * @example + * + * R.subtract(10, 8); //=> 2 + * + * const minus5 = R.subtract(R.__, 5); + * minus5(17); //=> 12 + * + * const complementaryAngle = R.subtract(90); + * complementaryAngle(30); //=> 60 + * complementaryAngle(72); //=> 18 + */ +var subtract = _curry2(function subtract(a, b) { + return Number(a) - Number(b); +}); + +/** + * Finds the set (i.e. no duplicates) of all elements contained in the first or + * second list, but not both. + * + * @func + * @memberOf R + * @since v0.19.0 + * @category Relation + * @sig [*] -> [*] -> [*] + * @param {Array} list1 The first list. + * @param {Array} list2 The second list. + * @return {Array} The elements in `list1` or `list2`, but not both. + * @see R.symmetricDifferenceWith, R.difference, R.differenceWith + * @example + * + * R.symmetricDifference([1,2,3,4], [7,6,5,4,3]); //=> [1,2,7,6,5] + * R.symmetricDifference([7,6,5,4,3], [1,2,3,4]); //=> [7,6,5,1,2] + */ +var symmetricDifference = _curry2(function symmetricDifference(list1, list2) { + return concat(difference(list1, list2), difference(list2, list1)); +}); + +/** + * Finds the set (i.e. no duplicates) of all elements contained in the first or + * second list, but not both. Duplication is determined according to the value + * returned by applying the supplied predicate to two list elements. + * + * @func + * @memberOf R + * @since v0.19.0 + * @category Relation + * @sig ((a, a) -> Boolean) -> [a] -> [a] -> [a] + * @param {Function} pred A predicate used to test whether two items are equal. + * @param {Array} list1 The first list. + * @param {Array} list2 The second list. + * @return {Array} The elements in `list1` or `list2`, but not both. + * @see R.symmetricDifference, R.difference, R.differenceWith + * @example + * + * const eqA = R.eqBy(R.prop('a')); + * const l1 = [{a: 1}, {a: 2}, {a: 3}, {a: 4}]; + * const l2 = [{a: 3}, {a: 4}, {a: 5}, {a: 6}]; + * R.symmetricDifferenceWith(eqA, l1, l2); //=> [{a: 1}, {a: 2}, {a: 5}, {a: 6}] + */ +var symmetricDifferenceWith = _curry3(function symmetricDifferenceWith(pred, list1, list2) { + return concat(differenceWith(pred, list1, list2), differenceWith(pred, list2, list1)); +}); + +/** + * Returns a new list containing the last `n` elements of a given list, passing + * each value to the supplied predicate function, and terminating when the + * predicate function returns `false`. Excludes the element that caused the + * predicate function to fail. The predicate function is passed one argument: + * *(value)*. + * + * @func + * @memberOf R + * @since v0.16.0 + * @category List + * @sig (a -> Boolean) -> [a] -> [a] + * @sig (a -> Boolean) -> String -> String + * @param {Function} fn The function called per iteration. + * @param {Array} xs The collection to iterate over. + * @return {Array} A new array. + * @see R.dropLastWhile, R.addIndex + * @example + * + * const isNotOne = x => x !== 1; + * + * R.takeLastWhile(isNotOne, [1, 2, 3, 4]); //=> [2, 3, 4] + * + * R.takeLastWhile(x => x !== 'R' , 'Ramda'); //=> 'amda' + */ +var takeLastWhile = _curry2(function takeLastWhile(fn, xs) { + var idx = xs.length - 1; + while (idx >= 0 && fn(xs[idx])) { + idx -= 1; + } + return slice(idx + 1, Infinity, xs); +}); + +function XTakeWhile(f, xf) { + this.xf = xf; + this.f = f; +} +XTakeWhile.prototype['@@transducer/init'] = _xfBase.init; +XTakeWhile.prototype['@@transducer/result'] = _xfBase.result; +XTakeWhile.prototype['@@transducer/step'] = function(result, input) { + return this.f(input) ? this.xf['@@transducer/step'](result, input) : _reduced(result); +}; + +var _xtakeWhile = _curry2(function _xtakeWhile(f, xf) { return new XTakeWhile(f, xf); }); + +/** + * Returns a new list containing the first `n` elements of a given list, + * passing each value to the supplied predicate function, and terminating when + * the predicate function returns `false`. Excludes the element that caused the + * predicate function to fail. The predicate function is passed one argument: + * *(value)*. + * + * Dispatches to the `takeWhile` method of the second argument, if present. + * + * Acts as a transducer if a transformer is given in list position. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category List + * @sig (a -> Boolean) -> [a] -> [a] + * @sig (a -> Boolean) -> String -> String + * @param {Function} fn The function called per iteration. + * @param {Array} xs The collection to iterate over. + * @return {Array} A new array. + * @see R.dropWhile, R.transduce, R.addIndex + * @example + * + * const isNotFour = x => x !== 4; + * + * R.takeWhile(isNotFour, [1, 2, 3, 4, 3, 2, 1]); //=> [1, 2, 3] + * + * R.takeWhile(x => x !== 'd' , 'Ramda'); //=> 'Ram' + */ +var takeWhile = _curry2(_dispatchable(['takeWhile'], _xtakeWhile, function takeWhile(fn, xs) { + var idx = 0; + var len = xs.length; + while (idx < len && fn(xs[idx])) { + idx += 1; + } + return slice(0, idx, xs); +})); + +function XTap(f, xf) { + this.xf = xf; + this.f = f; +} +XTap.prototype['@@transducer/init'] = _xfBase.init; +XTap.prototype['@@transducer/result'] = _xfBase.result; +XTap.prototype['@@transducer/step'] = function(result, input) { + this.f(input); + return this.xf['@@transducer/step'](result, input); +}; + +var _xtap = _curry2(function _xtap(f, xf) { return new XTap(f, xf); }); + +/** + * Runs the given function with the supplied object, then returns the object. + * + * Acts as a transducer if a transformer is given as second parameter. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Function + * @sig (a -> *) -> a -> a + * @param {Function} fn The function to call with `x`. The return value of `fn` will be thrown away. + * @param {*} x + * @return {*} `x`. + * @example + * + * const sayX = x => console.log('x is ' + x); + * R.tap(sayX, 100); //=> 100 + * // logs 'x is 100' + * @symb R.tap(f, a) = a + */ +var tap = _curry2(_dispatchable([], _xtap, function tap(fn, x) { + fn(x); + return x; +})); + +function _isRegExp(x) { + return Object.prototype.toString.call(x) === '[object RegExp]'; +} + +/** + * Determines whether a given string matches a given regular expression. + * + * @func + * @memberOf R + * @since v0.12.0 + * @category String + * @sig RegExp -> String -> Boolean + * @param {RegExp} pattern + * @param {String} str + * @return {Boolean} + * @see R.match + * @example + * + * R.test(/^x/, 'xyz'); //=> true + * R.test(/^y/, 'xyz'); //=> false + */ +var test = _curry2(function test(pattern, str) { + if (!_isRegExp(pattern)) { + throw new TypeError('‘test’ requires a value of type RegExp as its first argument; received ' + toString$1(pattern)); + } + return _cloneRegExp(pattern).test(str); +}); + +/** + * Returns the result of applying the onSuccess function to the value inside + * a successfully resolved promise. This is useful for working with promises + * inside function compositions. + * + * @func + * @memberOf R + * @category Function + * @sig (a -> b) -> (Promise e a) -> (Promise e b) + * @sig (a -> (Promise e b)) -> (Promise e a) -> (Promise e b) + * @param {Function} onSuccess The function to apply. Can return a value or a promise of a value. + * @param {Promise} p + * @return {Promise} The result of calling `p.then(onSuccess)` + * @see R.otherwise + * @example + * + * var makeQuery = (email) => ({ query: { email }}); + * + * //getMemberName :: String -> Promise ({firstName, lastName}) + * var getMemberName = R.pipe( + * makeQuery, + * fetchMember, + * R.then(R.pick(['firstName', 'lastName'])) + * ); + */ +const then = _curry2(function then(f, p) { + _assertPromise('then', p); + + return p.then(f); +}); + +/** + * The lower case version of a string. + * + * @func + * @memberOf R + * @since v0.9.0 + * @category String + * @sig String -> String + * @param {String} str The string to lower case. + * @return {String} The lower case version of `str`. + * @see R.toUpper + * @example + * + * R.toLower('XYZ'); //=> 'xyz' + */ +var toLower = invoker(0, 'toLowerCase'); + +/** + * Converts an object into an array of key, value arrays. Only the object's + * own properties are used. + * Note that the order of the output array is not guaranteed to be consistent + * across different JS platforms. + * + * @func + * @memberOf R + * @since v0.4.0 + * @category Object + * @sig {String: *} -> [[String,*]] + * @param {Object} obj The object to extract from + * @return {Array} An array of key, value arrays from the object's own properties. + * @see R.fromPairs + * @example + * + * R.toPairs({a: 1, b: 2, c: 3}); //=> [['a', 1], ['b', 2], ['c', 3]] + */ +var toPairs = _curry1(function toPairs(obj) { + var pairs = []; + for (var prop in obj) { + if (_has(prop, obj)) { + pairs[pairs.length] = [prop, obj[prop]]; + } + } + return pairs; +}); + +/** + * Converts an object into an array of key, value arrays. The object's own + * properties and prototype properties are used. Note that the order of the + * output array is not guaranteed to be consistent across different JS + * platforms. + * + * @func + * @memberOf R + * @since v0.4.0 + * @category Object + * @sig {String: *} -> [[String,*]] + * @param {Object} obj The object to extract from + * @return {Array} An array of key, value arrays from the object's own + * and prototype properties. + * @example + * + * const F = function() { this.x = 'X'; }; + * F.prototype.y = 'Y'; + * const f = new F(); + * R.toPairsIn(f); //=> [['x','X'], ['y','Y']] + */ +var toPairsIn = _curry1(function toPairsIn(obj) { + var pairs = []; + for (var prop in obj) { + pairs[pairs.length] = [prop, obj[prop]]; + } + return pairs; +}); + +/** + * The upper case version of a string. + * + * @func + * @memberOf R + * @since v0.9.0 + * @category String + * @sig String -> String + * @param {String} str The string to upper case. + * @return {String} The upper case version of `str`. + * @see R.toLower + * @example + * + * R.toUpper('abc'); //=> 'ABC' + */ +var toUpper = invoker(0, 'toUpperCase'); + +/** + * Initializes a transducer using supplied iterator function. Returns a single + * item by iterating through the list, successively calling the transformed + * iterator function and passing it an accumulator value and the current value + * from the array, and then passing the result to the next call. + * + * The iterator function receives two values: *(acc, value)*. It will be + * wrapped as a transformer to initialize the transducer. A transformer can be + * passed directly in place of an iterator function. In both cases, iteration + * may be stopped early with the [`R.reduced`](#reduced) function. + * + * A transducer is a function that accepts a transformer and returns a + * transformer and can be composed directly. + * + * A transformer is an an object that provides a 2-arity reducing iterator + * function, step, 0-arity initial value function, init, and 1-arity result + * extraction function, result. The step function is used as the iterator + * function in reduce. The result function is used to convert the final + * accumulator into the return type and in most cases is + * [`R.identity`](#identity). The init function can be used to provide an + * initial accumulator, but is ignored by transduce. + * + * The iteration is performed with [`R.reduce`](#reduce) after initializing the transducer. + * + * @func + * @memberOf R + * @since v0.12.0 + * @category List + * @sig (c -> c) -> ((a, b) -> a) -> a -> [b] -> a + * @param {Function} xf The transducer function. Receives a transformer and returns a transformer. + * @param {Function} fn The iterator function. Receives two values, the accumulator and the + * current element from the array. Wrapped as transformer, if necessary, and used to + * initialize the transducer + * @param {*} acc The initial accumulator value. + * @param {Array} list The list to iterate over. + * @return {*} The final, accumulated value. + * @see R.reduce, R.reduced, R.into + * @example + * + * const numbers = [1, 2, 3, 4]; + * const transducer = R.compose(R.map(R.add(1)), R.take(2)); + * R.transduce(transducer, R.flip(R.append), [], numbers); //=> [2, 3] + * + * const isOdd = (x) => x % 2 === 1; + * const firstOddTransducer = R.compose(R.filter(isOdd), R.take(1)); + * R.transduce(firstOddTransducer, R.flip(R.append), [], R.range(0, 100)); //=> [1] + */ +var transduce = curryN(4, function transduce(xf, fn, acc, list) { + return _reduce(xf(typeof fn === 'function' ? _xwrap(fn) : fn), acc, list); +}); + +/** + * Transposes the rows and columns of a 2D list. + * When passed a list of `n` lists of length `x`, + * returns a list of `x` lists of length `n`. + * + * + * @func + * @memberOf R + * @since v0.19.0 + * @category List + * @sig [[a]] -> [[a]] + * @param {Array} list A 2D list + * @return {Array} A 2D list + * @example + * + * R.transpose([[1, 'a'], [2, 'b'], [3, 'c']]) //=> [[1, 2, 3], ['a', 'b', 'c']] + * R.transpose([[1, 2, 3], ['a', 'b', 'c']]) //=> [[1, 'a'], [2, 'b'], [3, 'c']] + * + * // If some of the rows are shorter than the following rows, their elements are skipped: + * R.transpose([[10, 11], [20], [], [30, 31, 32]]) //=> [[10, 20, 30], [11, 31], [32]] + * @symb R.transpose([[a], [b], [c]]) = [a, b, c] + * @symb R.transpose([[a, b], [c, d]]) = [[a, c], [b, d]] + * @symb R.transpose([[a, b], [c]]) = [[a, c], [b]] + */ +var transpose = _curry1(function transpose(outerlist) { + var i = 0; + var result = []; + while (i < outerlist.length) { + var innerlist = outerlist[i]; + var j = 0; + while (j < innerlist.length) { + if (typeof result[j] === 'undefined') { + result[j] = []; + } + result[j].push(innerlist[j]); + j += 1; + } + i += 1; + } + return result; +}); + +/** + * Maps an [Applicative](https://github.com/fantasyland/fantasy-land#applicative)-returning + * function over a [Traversable](https://github.com/fantasyland/fantasy-land#traversable), + * then uses [`sequence`](#sequence) to transform the resulting Traversable of Applicative + * into an Applicative of Traversable. + * + * Dispatches to the `traverse` method of the third argument, if present. + * + * @func + * @memberOf R + * @since v0.19.0 + * @category List + * @sig (Applicative f, Traversable t) => (a -> f a) -> (a -> f b) -> t a -> f (t b) + * @param {Function} of + * @param {Function} f + * @param {*} traversable + * @return {*} + * @see R.sequence + * @example + * + * // Returns `Maybe.Nothing` if the given divisor is `0` + * const safeDiv = n => d => d === 0 ? Maybe.Nothing() : Maybe.Just(n / d) + * + * R.traverse(Maybe.of, safeDiv(10), [2, 4, 5]); //=> Maybe.Just([5, 2.5, 2]) + * R.traverse(Maybe.of, safeDiv(10), [2, 0, 5]); //=> Maybe.Nothing + */ +var traverse = _curry3(function traverse(of, f, traversable) { + return typeof traversable['fantasy-land/traverse'] === 'function' ? + traversable['fantasy-land/traverse'](f, of) : + sequence(of, map(f, traversable)); +}); + +var ws = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003' + + '\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028' + + '\u2029\uFEFF'; +var zeroWidth = '\u200b'; +var hasProtoTrim = (typeof String.prototype.trim === 'function'); +/** + * Removes (strips) whitespace from both ends of the string. + * + * @func + * @memberOf R + * @since v0.6.0 + * @category String + * @sig String -> String + * @param {String} str The string to trim. + * @return {String} Trimmed version of `str`. + * @example + * + * R.trim(' xyz '); //=> 'xyz' + * R.map(R.trim, R.split(',', 'x, y, z')); //=> ['x', 'y', 'z'] + */ +var trim = !hasProtoTrim || (ws.trim() || !zeroWidth.trim()) ? + _curry1(function trim(str) { + var beginRx = new RegExp('^[' + ws + '][' + ws + ']*'); + var endRx = new RegExp('[' + ws + '][' + ws + ']*$'); + return str.replace(beginRx, '').replace(endRx, ''); + }) : + _curry1(function trim(str) { + return str.trim(); + }); + +/** + * `tryCatch` takes two functions, a `tryer` and a `catcher`. The returned + * function evaluates the `tryer`; if it does not throw, it simply returns the + * result. If the `tryer` *does* throw, the returned function evaluates the + * `catcher` function and returns its result. Note that for effective + * composition with this function, both the `tryer` and `catcher` functions + * must return the same type of results. + * + * @func + * @memberOf R + * @since v0.20.0 + * @category Function + * @sig (...x -> a) -> ((e, ...x) -> a) -> (...x -> a) + * @param {Function} tryer The function that may throw. + * @param {Function} catcher The function that will be evaluated if `tryer` throws. + * @return {Function} A new function that will catch exceptions and send then to the catcher. + * @example + * + * R.tryCatch(R.prop('x'), R.F)({x: true}); //=> true + * R.tryCatch(() => { throw 'foo'}, R.always('catched'))('bar') // => 'catched' + * R.tryCatch(R.times(R.identity), R.always([]))('s') // => [] + `` */ +var tryCatch = _curry2(function _tryCatch(tryer, catcher) { + return _arity(tryer.length, function() { + try { + return tryer.apply(this, arguments); + } catch (e) { + return catcher.apply(this, _concat([e], arguments)); + } + }); +}); + +/** + * Takes a function `fn`, which takes a single array argument, and returns a + * function which: + * + * - takes any number of positional arguments; + * - passes these arguments to `fn` as an array; and + * - returns the result. + * + * In other words, `R.unapply` derives a variadic function from a function which + * takes an array. `R.unapply` is the inverse of [`R.apply`](#apply). + * + * @func + * @memberOf R + * @since v0.8.0 + * @category Function + * @sig ([*...] -> a) -> (*... -> a) + * @param {Function} fn + * @return {Function} + * @see R.apply + * @example + * + * R.unapply(JSON.stringify)(1, 2, 3); //=> '[1,2,3]' + * @symb R.unapply(f)(a, b) = f([a, b]) + */ +var unapply = _curry1(function unapply(fn) { + return function() { + return fn(Array.prototype.slice.call(arguments, 0)); + }; +}); + +/** + * Wraps a function of any arity (including nullary) in a function that accepts + * exactly 1 parameter. Any extraneous parameters will not be passed to the + * supplied function. + * + * @func + * @memberOf R + * @since v0.2.0 + * @category Function + * @sig (* -> b) -> (a -> b) + * @param {Function} fn The function to wrap. + * @return {Function} A new function wrapping `fn`. The new function is guaranteed to be of + * arity 1. + * @see R.binary, R.nAry + * @example + * + * const takesTwoArgs = function(a, b) { + * return [a, b]; + * }; + * takesTwoArgs.length; //=> 2 + * takesTwoArgs(1, 2); //=> [1, 2] + * + * const takesOneArg = R.unary(takesTwoArgs); + * takesOneArg.length; //=> 1 + * // Only 1 argument is passed to the wrapped function + * takesOneArg(1, 2); //=> [1, undefined] + * @symb R.unary(f)(a, b, c) = f(a) + */ +var unary = _curry1(function unary(fn) { + return nAry(1, fn); +}); + +/** + * Returns a function of arity `n` from a (manually) curried function. + * + * @func + * @memberOf R + * @since v0.14.0 + * @category Function + * @sig Number -> (a -> b) -> (a -> c) + * @param {Number} length The arity for the returned function. + * @param {Function} fn The function to uncurry. + * @return {Function} A new function. + * @see R.curry + * @example + * + * const addFour = a => b => c => d => a + b + c + d; + * + * const uncurriedAddFour = R.uncurryN(4, addFour); + * uncurriedAddFour(1, 2, 3, 4); //=> 10 + */ +var uncurryN = _curry2(function uncurryN(depth, fn) { + return curryN(depth, function() { + var currentDepth = 1; + var value = fn; + var idx = 0; + var endIdx; + while (currentDepth <= depth && typeof value === 'function') { + endIdx = currentDepth === depth ? arguments.length : idx + value.length; + value = value.apply(this, Array.prototype.slice.call(arguments, idx, endIdx)); + currentDepth += 1; + idx = endIdx; + } + return value; + }); +}); + +/** + * Builds a list from a seed value. Accepts an iterator function, which returns + * either false to stop iteration or an array of length 2 containing the value + * to add to the resulting list and the seed to be used in the next call to the + * iterator function. + * + * The iterator function receives one argument: *(seed)*. + * + * @func + * @memberOf R + * @since v0.10.0 + * @category List + * @sig (a -> [b]) -> * -> [b] + * @param {Function} fn The iterator function. receives one argument, `seed`, and returns + * either false to quit iteration or an array of length two to proceed. The element + * at index 0 of this array will be added to the resulting array, and the element + * at index 1 will be passed to the next call to `fn`. + * @param {*} seed The seed value. + * @return {Array} The final list. + * @example + * + * const f = n => n > 50 ? false : [-n, n + 10]; + * R.unfold(f, 10); //=> [-10, -20, -30, -40, -50] + * @symb R.unfold(f, x) = [f(x)[0], f(f(x)[1])[0], f(f(f(x)[1])[1])[0], ...] + */ +var unfold = _curry2(function unfold(fn, seed) { + var pair = fn(seed); + var result = []; + while (pair && pair.length) { + result[result.length] = pair[0]; + pair = fn(pair[1]); + } + return result; +}); + +/** + * Combines two lists into a set (i.e. no duplicates) composed of the elements + * of each list. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Relation + * @sig [*] -> [*] -> [*] + * @param {Array} as The first list. + * @param {Array} bs The second list. + * @return {Array} The first and second lists concatenated, with + * duplicates removed. + * @example + * + * R.union([1, 2, 3], [2, 3, 4]); //=> [1, 2, 3, 4] + */ +var union = _curry2(compose(uniq, _concat)); + +/** + * Returns a new list containing only one copy of each element in the original + * list, based upon the value returned by applying the supplied predicate to + * two list elements. Prefers the first item if two items compare equal based + * on the predicate. + * + * @func + * @memberOf R + * @since v0.2.0 + * @category List + * @sig ((a, a) -> Boolean) -> [a] -> [a] + * @param {Function} pred A predicate used to test whether two items are equal. + * @param {Array} list The array to consider. + * @return {Array} The list of unique items. + * @example + * + * const strEq = R.eqBy(String); + * R.uniqWith(strEq)([1, '1', 2, 1]); //=> [1, 2] + * R.uniqWith(strEq)([{}, {}]); //=> [{}] + * R.uniqWith(strEq)([1, '1', 1]); //=> [1] + * R.uniqWith(strEq)(['1', 1, 1]); //=> ['1'] + */ +var uniqWith = _curry2(function uniqWith(pred, list) { + var idx = 0; + var len = list.length; + var result = []; + var item; + while (idx < len) { + item = list[idx]; + if (!_includesWith(pred, item, result)) { + result[result.length] = item; + } + idx += 1; + } + return result; +}); + +/** + * Combines two lists into a set (i.e. no duplicates) composed of the elements + * of each list. Duplication is determined according to the value returned by + * applying the supplied predicate to two list elements. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Relation + * @sig ((a, a) -> Boolean) -> [*] -> [*] -> [*] + * @param {Function} pred A predicate used to test whether two items are equal. + * @param {Array} list1 The first list. + * @param {Array} list2 The second list. + * @return {Array} The first and second lists concatenated, with + * duplicates removed. + * @see R.union + * @example + * + * const l1 = [{a: 1}, {a: 2}]; + * const l2 = [{a: 1}, {a: 4}]; + * R.unionWith(R.eqBy(R.prop('a')), l1, l2); //=> [{a: 1}, {a: 2}, {a: 4}] + */ +var unionWith = _curry3(function unionWith(pred, list1, list2) { + return uniqWith(pred, _concat(list1, list2)); +}); + +/** + * Tests the final argument by passing it to the given predicate function. If + * the predicate is not satisfied, the function will return the result of + * calling the `whenFalseFn` function with the same argument. If the predicate + * is satisfied, the argument is returned as is. + * + * @func + * @memberOf R + * @since v0.18.0 + * @category Logic + * @sig (a -> Boolean) -> (a -> a) -> a -> a + * @param {Function} pred A predicate function + * @param {Function} whenFalseFn A function to invoke when the `pred` evaluates + * to a falsy value. + * @param {*} x An object to test with the `pred` function and + * pass to `whenFalseFn` if necessary. + * @return {*} Either `x` or the result of applying `x` to `whenFalseFn`. + * @see R.ifElse, R.when, R.cond + * @example + * + * let safeInc = R.unless(R.isNil, R.inc); + * safeInc(null); //=> null + * safeInc(1); //=> 2 + */ +var unless = _curry3(function unless(pred, whenFalseFn, x) { + return pred(x) ? x : whenFalseFn(x); +}); + +/** + * Shorthand for `R.chain(R.identity)`, which removes one level of nesting from + * any [Chain](https://github.com/fantasyland/fantasy-land#chain). + * + * @func + * @memberOf R + * @since v0.3.0 + * @category List + * @sig Chain c => c (c a) -> c a + * @param {*} list + * @return {*} + * @see R.flatten, R.chain + * @example + * + * R.unnest([1, [2], [[3]]]); //=> [1, 2, [3]] + * R.unnest([[1, 2], [3, 4], [5, 6]]); //=> [1, 2, 3, 4, 5, 6] + */ +var unnest = chain(_identity); + +/** + * Takes a predicate, a transformation function, and an initial value, + * and returns a value of the same type as the initial value. + * It does so by applying the transformation until the predicate is satisfied, + * at which point it returns the satisfactory value. + * + * @func + * @memberOf R + * @since v0.20.0 + * @category Logic + * @sig (a -> Boolean) -> (a -> a) -> a -> a + * @param {Function} pred A predicate function + * @param {Function} fn The iterator function + * @param {*} init Initial value + * @return {*} Final value that satisfies predicate + * @example + * + * R.until(R.gt(R.__, 100), R.multiply(2))(1) // => 128 + */ +var until = _curry3(function until(pred, fn, init) { + var val = init; + while (!pred(val)) { + val = fn(val); + } + return val; +}); + +/** + * Returns a list of all the properties, including prototype properties, of the + * supplied object. + * Note that the order of the output array is not guaranteed to be consistent + * across different JS platforms. + * + * @func + * @memberOf R + * @since v0.2.0 + * @category Object + * @sig {k: v} -> [v] + * @param {Object} obj The object to extract values from + * @return {Array} An array of the values of the object's own and prototype properties. + * @see R.values, R.keysIn + * @example + * + * const F = function() { this.x = 'X'; }; + * F.prototype.y = 'Y'; + * const f = new F(); + * R.valuesIn(f); //=> ['X', 'Y'] + */ +var valuesIn = _curry1(function valuesIn(obj) { + var prop; + var vs = []; + for (prop in obj) { + vs[vs.length] = obj[prop]; + } + return vs; +}); + +// `Const` is a functor that effectively ignores the function given to `map`. +var Const = function(x) { + return {value: x, 'fantasy-land/map': function() { return this; }}; +}; + +/** + * Returns a "view" of the given data structure, determined by the given lens. + * The lens's focus determines which portion of the data structure is visible. + * + * @func + * @memberOf R + * @since v0.16.0 + * @category Object + * @typedefn Lens s a = Functor f => (a -> f a) -> s -> f s + * @sig Lens s a -> s -> a + * @param {Lens} lens + * @param {*} x + * @return {*} + * @see R.prop, R.lensIndex, R.lensProp + * @example + * + * const xLens = R.lensProp('x'); + * + * R.view(xLens, {x: 1, y: 2}); //=> 1 + * R.view(xLens, {x: 4, y: 2}); //=> 4 + */ +var view = _curry2(function view(lens, x) { + // Using `Const` effectively ignores the setter function of the `lens`, + // leaving the value returned by the getter function unmodified. + return lens(Const)(x).value; +}); + +/** + * Tests the final argument by passing it to the given predicate function. If + * the predicate is satisfied, the function will return the result of calling + * the `whenTrueFn` function with the same argument. If the predicate is not + * satisfied, the argument is returned as is. + * + * @func + * @memberOf R + * @since v0.18.0 + * @category Logic + * @sig (a -> Boolean) -> (a -> a) -> a -> a + * @param {Function} pred A predicate function + * @param {Function} whenTrueFn A function to invoke when the `condition` + * evaluates to a truthy value. + * @param {*} x An object to test with the `pred` function and + * pass to `whenTrueFn` if necessary. + * @return {*} Either `x` or the result of applying `x` to `whenTrueFn`. + * @see R.ifElse, R.unless, R.cond + * @example + * + * // truncate :: String -> String + * const truncate = R.when( + * R.propSatisfies(R.gt(R.__, 10), 'length'), + * R.pipe(R.take(10), R.append('…'), R.join('')) + * ); + * truncate('12345'); //=> '12345' + * truncate('0123456789ABC'); //=> '0123456789…' + */ +var when = _curry3(function when(pred, whenTrueFn, x) { + return pred(x) ? whenTrueFn(x) : x; +}); + +/** + * Takes a spec object and a test object; returns true if the test satisfies + * the spec. Each of the spec's own properties must be a predicate function. + * Each predicate is applied to the value of the corresponding property of the + * test object. `where` returns true if all the predicates return true, false + * otherwise. + * + * `where` is well suited to declaratively expressing constraints for other + * functions such as [`filter`](#filter) and [`find`](#find). + * + * @func + * @memberOf R + * @since v0.1.1 + * @category Object + * @sig {String: (* -> Boolean)} -> {String: *} -> Boolean + * @param {Object} spec + * @param {Object} testObj + * @return {Boolean} + * @see R.propSatisfies, R.whereEq + * @example + * + * // pred :: Object -> Boolean + * const pred = R.where({ + * a: R.equals('foo'), + * b: R.complement(R.equals('bar')), + * x: R.gt(R.__, 10), + * y: R.lt(R.__, 20) + * }); + * + * pred({a: 'foo', b: 'xxx', x: 11, y: 19}); //=> true + * pred({a: 'xxx', b: 'xxx', x: 11, y: 19}); //=> false + * pred({a: 'foo', b: 'bar', x: 11, y: 19}); //=> false + * pred({a: 'foo', b: 'xxx', x: 10, y: 19}); //=> false + * pred({a: 'foo', b: 'xxx', x: 11, y: 20}); //=> false + */ +var where = _curry2(function where(spec, testObj) { + for (var prop in spec) { + if (_has(prop, spec) && !spec[prop](testObj[prop])) { + return false; + } + } + return true; +}); + +/** + * Takes a spec object and a test object; returns true if the test satisfies + * the spec, false otherwise. An object satisfies the spec if, for each of the + * spec's own properties, accessing that property of the object gives the same + * value (in [`R.equals`](#equals) terms) as accessing that property of the + * spec. + * + * `whereEq` is a specialization of [`where`](#where). + * + * @func + * @memberOf R + * @since v0.14.0 + * @category Object + * @sig {String: *} -> {String: *} -> Boolean + * @param {Object} spec + * @param {Object} testObj + * @return {Boolean} + * @see R.propEq, R.where + * @example + * + * // pred :: Object -> Boolean + * const pred = R.whereEq({a: 1, b: 2}); + * + * pred({a: 1}); //=> false + * pred({a: 1, b: 2}); //=> true + * pred({a: 1, b: 2, c: 3}); //=> true + * pred({a: 1, b: 1}); //=> false + */ +var whereEq = _curry2(function whereEq(spec, testObj) { + return where(map(equals, spec), testObj); +}); + +/** + * Returns a new list without values in the first argument. + * [`R.equals`](#equals) is used to determine equality. + * + * Acts as a transducer if a transformer is given in list position. + * + * @func + * @memberOf R + * @since v0.19.0 + * @category List + * @sig [a] -> [a] -> [a] + * @param {Array} list1 The values to be removed from `list2`. + * @param {Array} list2 The array to remove values from. + * @return {Array} The new array without values in `list1`. + * @see R.transduce, R.difference, R.remove + * @example + * + * R.without([1, 2], [1, 2, 1, 3, 4]); //=> [3, 4] + */ +var without = _curry2(function(xs, list) { + return reject(flip(_includes)(xs), list); +}); + +/** + * Creates a new list out of the two supplied by creating each possible pair + * from the lists. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category List + * @sig [a] -> [b] -> [[a,b]] + * @param {Array} as The first list. + * @param {Array} bs The second list. + * @return {Array} The list made by combining each possible pair from + * `as` and `bs` into pairs (`[a, b]`). + * @example + * + * R.xprod([1, 2], ['a', 'b']); //=> [[1, 'a'], [1, 'b'], [2, 'a'], [2, 'b']] + * @symb R.xprod([a, b], [c, d]) = [[a, c], [a, d], [b, c], [b, d]] + */ +var xprod = _curry2(function xprod(a, b) { // = xprodWith(prepend); (takes about 3 times as long...) + var idx = 0; + var ilen = a.length; + var j; + var jlen = b.length; + var result = []; + while (idx < ilen) { + j = 0; + while (j < jlen) { + result[result.length] = [a[idx], b[j]]; + j += 1; + } + idx += 1; + } + return result; +}); + +/** + * Creates a new list out of the two supplied by pairing up equally-positioned + * items from both lists. The returned list is truncated to the length of the + * shorter of the two input lists. + * Note: `zip` is equivalent to `zipWith(function(a, b) { return [a, b] })`. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category List + * @sig [a] -> [b] -> [[a,b]] + * @param {Array} list1 The first array to consider. + * @param {Array} list2 The second array to consider. + * @return {Array} The list made by pairing up same-indexed elements of `list1` and `list2`. + * @example + * + * R.zip([1, 2, 3], ['a', 'b', 'c']); //=> [[1, 'a'], [2, 'b'], [3, 'c']] + * @symb R.zip([a, b, c], [d, e, f]) = [[a, d], [b, e], [c, f]] + */ +var zip = _curry2(function zip(a, b) { + var rv = []; + var idx = 0; + var len = Math.min(a.length, b.length); + while (idx < len) { + rv[idx] = [a[idx], b[idx]]; + idx += 1; + } + return rv; +}); + +/** + * Creates a new object out of a list of keys and a list of values. + * Key/value pairing is truncated to the length of the shorter of the two lists. + * Note: `zipObj` is equivalent to `pipe(zip, fromPairs)`. + * + * @func + * @memberOf R + * @since v0.3.0 + * @category List + * @sig [String] -> [*] -> {String: *} + * @param {Array} keys The array that will be properties on the output object. + * @param {Array} values The list of values on the output object. + * @return {Object} The object made by pairing up same-indexed elements of `keys` and `values`. + * @example + * + * R.zipObj(['a', 'b', 'c'], [1, 2, 3]); //=> {a: 1, b: 2, c: 3} + */ +var zipObj = _curry2(function zipObj(keys, values) { + var idx = 0; + var len = Math.min(keys.length, values.length); + var out = {}; + while (idx < len) { + out[keys[idx]] = values[idx]; + idx += 1; + } + return out; +}); + +/** + * Creates a new list out of the two supplied by applying the function to each + * equally-positioned pair in the lists. The returned list is truncated to the + * length of the shorter of the two input lists. + * + * @function + * @memberOf R + * @since v0.1.0 + * @category List + * @sig ((a, b) -> c) -> [a] -> [b] -> [c] + * @param {Function} fn The function used to combine the two elements into one value. + * @param {Array} list1 The first array to consider. + * @param {Array} list2 The second array to consider. + * @return {Array} The list made by combining same-indexed elements of `list1` and `list2` + * using `fn`. + * @example + * + * const f = (x, y) => { + * // ... + * }; + * R.zipWith(f, [1, 2, 3], ['a', 'b', 'c']); + * //=> [f(1, 'a'), f(2, 'b'), f(3, 'c')] + * @symb R.zipWith(fn, [a, b, c], [d, e, f]) = [fn(a, d), fn(b, e), fn(c, f)] + */ +var zipWith = _curry3(function zipWith(fn, a, b) { + var rv = []; + var idx = 0; + var len = Math.min(a.length, b.length); + while (idx < len) { + rv[idx] = fn(a[idx], b[idx]); + idx += 1; + } + return rv; +}); + +/** + * Creates a thunk out of a function. A thunk delays a calculation until + * its result is needed, providing lazy evaluation of arguments. + * + * @func + * @memberOf R + * @category Function + * @sig ((a, b, ..., j) -> k) -> (a, b, ..., j) -> (() -> k) + * @param {Function} fn A function to wrap in a thunk + * @return {Function} Expects arguments for `fn` and returns a new function + * that, when called, applies those arguments to `fn`. + * @see R.partial, R.partialRight + * @example + * + * R.thunkify(R.identity)(42)(); //=> 42 + * R.thunkify((a, b) => a + b)(25, 17)(); //=> 42 + */ +var thunkify = _curry1(function thunkify(fn) { + return curryN(fn.length, function createThunk() { + const fnArgs = arguments; + return function invokeThunk() { + return fn.apply(this, fnArgs); + }; + }); +}); + +exports.F = F; +exports.T = T; +exports.__ = __; +exports.add = add; +exports.addIndex = addIndex; +exports.adjust = adjust; +exports.all = all; +exports.allPass = allPass; +exports.always = always; +exports.and = and; +exports.any = any; +exports.anyPass = anyPass; +exports.ap = ap; +exports.aperture = aperture; +exports.append = append; +exports.apply = apply; +exports.applySpec = applySpec; +exports.applyTo = applyTo; +exports.ascend = ascend; +exports.assoc = assoc; +exports.assocPath = assocPath; +exports.binary = binary; +exports.bind = bind; +exports.both = both; +exports.call = call; +exports.chain = chain; +exports.clamp = clamp; +exports.clone = clone; +exports.comparator = comparator; +exports.complement = complement; +exports.compose = compose; +exports.composeK = composeK; +exports.composeP = composeP; +exports.composeWith = composeWith; +exports.concat = concat; +exports.cond = cond; +exports.construct = construct; +exports.constructN = constructN; +exports.contains = contains$1; +exports.converge = converge; +exports.countBy = countBy; +exports.curry = curry; +exports.curryN = curryN; +exports.dec = dec; +exports.defaultTo = defaultTo; +exports.descend = descend; +exports.difference = difference; +exports.differenceWith = differenceWith; +exports.dissoc = dissoc; +exports.dissocPath = dissocPath; +exports.divide = divide; +exports.drop = drop; +exports.dropLast = dropLast; +exports.dropLastWhile = dropLastWhile; +exports.dropRepeats = dropRepeats; +exports.dropRepeatsWith = dropRepeatsWith; +exports.dropWhile = dropWhile; +exports.either = either; +exports.empty = empty; +exports.endsWith = endsWith; +exports.eqBy = eqBy; +exports.eqProps = eqProps; +exports.equals = equals; +exports.evolve = evolve; +exports.filter = filter; +exports.find = find; +exports.findIndex = findIndex; +exports.findLast = findLast; +exports.findLastIndex = findLastIndex; +exports.flatten = flatten; +exports.flip = flip; +exports.forEach = forEach; +exports.forEachObjIndexed = forEachObjIndexed; +exports.fromPairs = fromPairs; +exports.groupBy = groupBy; +exports.groupWith = groupWith; +exports.gt = gt; +exports.gte = gte; +exports.has = has; +exports.hasIn = hasIn; +exports.hasPath = hasPath; +exports.head = head; +exports.identical = identical; +exports.identity = identity; +exports.ifElse = ifElse; +exports.inc = inc; +exports.includes = includes; +exports.indexBy = indexBy; +exports.indexOf = indexOf; +exports.init = init; +exports.innerJoin = innerJoin; +exports.insert = insert; +exports.insertAll = insertAll; +exports.intersection = intersection; +exports.intersperse = intersperse; +exports.into = into; +exports.invert = invert; +exports.invertObj = invertObj; +exports.invoker = invoker; +exports.is = is; +exports.isEmpty = isEmpty; +exports.isNil = isNil; +exports.join = join; +exports.juxt = juxt; +exports.keys = keys; +exports.keysIn = keysIn; +exports.last = last; +exports.lastIndexOf = lastIndexOf; +exports.length = length; +exports.lens = lens; +exports.lensIndex = lensIndex; +exports.lensPath = lensPath; +exports.lensProp = lensProp; +exports.lift = lift; +exports.liftN = liftN; +exports.lt = lt; +exports.lte = lte; +exports.map = map; +exports.mapAccum = mapAccum; +exports.mapAccumRight = mapAccumRight; +exports.mapObjIndexed = mapObjIndexed; +exports.match = match; +exports.mathMod = mathMod; +exports.max = max; +exports.maxBy = maxBy; +exports.mean = mean; +exports.median = median; +exports.memoizeWith = memoizeWith; +exports.merge = merge; +exports.mergeAll = mergeAll; +exports.mergeDeepLeft = mergeDeepLeft; +exports.mergeDeepRight = mergeDeepRight; +exports.mergeDeepWith = mergeDeepWith; +exports.mergeDeepWithKey = mergeDeepWithKey; +exports.mergeLeft = mergeLeft; +exports.mergeRight = mergeRight; +exports.mergeWith = mergeWith; +exports.mergeWithKey = mergeWithKey; +exports.min = min; +exports.minBy = minBy; +exports.modulo = modulo; +exports.multiply = multiply; +exports.nAry = nAry; +exports.negate = negate; +exports.none = none; +exports.not = not; +exports.nth = nth; +exports.nthArg = nthArg; +exports.o = o; +exports.objOf = objOf; +exports.of = of; +exports.omit = omit; +exports.once = once; +exports.or = or; +exports.otherwise = otherwise; +exports.over = over; +exports.pair = pair; +exports.partial = partial; +exports.partialRight = partialRight; +exports.partition = partition; +exports.path = path; +exports.pathEq = pathEq; +exports.pathOr = pathOr; +exports.pathSatisfies = pathSatisfies; +exports.pick = pick; +exports.pickAll = pickAll; +exports.pickBy = pickBy; +exports.pipe = pipe; +exports.pipeK = pipeK; +exports.pipeP = pipeP; +exports.pipeWith = pipeWith; +exports.pluck = pluck; +exports.prepend = prepend; +exports.product = product; +exports.project = project; +exports.prop = prop; +exports.propEq = propEq; +exports.propIs = propIs; +exports.propOr = propOr; +exports.propSatisfies = propSatisfies; +exports.props = props; +exports.range = range; +exports.reduce = reduce; +exports.reduceBy = reduceBy; +exports.reduceRight = reduceRight; +exports.reduceWhile = reduceWhile; +exports.reduced = reduced; +exports.reject = reject; +exports.remove = remove; +exports.repeat = repeat; +exports.replace = replace; +exports.reverse = reverse; +exports.scan = scan; +exports.sequence = sequence; +exports.set = set; +exports.slice = slice; +exports.sort = sort; +exports.sortBy = sortBy; +exports.sortWith = sortWith; +exports.split = split; +exports.splitAt = splitAt; +exports.splitEvery = splitEvery; +exports.splitWhen = splitWhen; +exports.startsWith = startsWith; +exports.subtract = subtract; +exports.sum = sum; +exports.symmetricDifference = symmetricDifference; +exports.symmetricDifferenceWith = symmetricDifferenceWith; +exports.tail = tail; +exports.take = take; +exports.takeLast = takeLast; +exports.takeLastWhile = takeLastWhile; +exports.takeWhile = takeWhile; +exports.tap = tap; +exports.test = test; +exports.then = then; +exports.times = times; +exports.toLower = toLower; +exports.toPairs = toPairs; +exports.toPairsIn = toPairsIn; +exports.toString = toString$1; +exports.toUpper = toUpper; +exports.transduce = transduce; +exports.transpose = transpose; +exports.traverse = traverse; +exports.trim = trim; +exports.tryCatch = tryCatch; +exports.type = type; +exports.unapply = unapply; +exports.unary = unary; +exports.uncurryN = uncurryN; +exports.unfold = unfold; +exports.union = union; +exports.unionWith = unionWith; +exports.uniq = uniq; +exports.uniqBy = uniqBy; +exports.uniqWith = uniqWith; +exports.unless = unless; +exports.unnest = unnest; +exports.until = until; +exports.update = update; +exports.useWith = useWith; +exports.values = values; +exports.valuesIn = valuesIn; +exports.view = view; +exports.when = when; +exports.where = where; +exports.whereEq = whereEq; +exports.without = without; +exports.xprod = xprod; +exports.zip = zip; +exports.zipObj = zipObj; +exports.zipWith = zipWith; +exports.thunkify = thunkify; + +Object.defineProperty(exports, '__esModule', { value: true }); + +}))); From 9aa12b4db06855e6bd55a498479d666dd973e31a Mon Sep 17 00:00:00 2001 From: klequis Date: Mon, 11 May 2020 16:04:54 -0700 Subject: [PATCH 032/111] updated mergeAll description per issue #3024 (#3025) --- source/mergeAll.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/source/mergeAll.js b/source/mergeAll.js index e6ea8a6cb3..b9951f855d 100644 --- a/source/mergeAll.js +++ b/source/mergeAll.js @@ -3,7 +3,9 @@ import _curry1 from './internal/_curry1'; /** - * Merges a list of objects together into one object. + * Creates one new object with the own properties from a list of objects. + * If a key exists in more than one object, the value from the last + * object it exists in will be used. * * @func * @memberOf R From a725c1760db0f137ff1fecd3bc31174d12fd26fa Mon Sep 17 00:00:00 2001 From: Giuseppe Mandato Date: Sun, 31 May 2020 20:30:02 +0100 Subject: [PATCH 033/111] chore(ci): add github workflows and code climate --- .codeclimate.yml | 28 + .github/workflows/build.yml | 45 + .gitignore | 2 + .travis.yml | 8 - README.md | 3 +- package-lock.json | 1621 +++++++++++++++++++++++++++++++---- package.json | 4 +- 7 files changed, 1510 insertions(+), 201 deletions(-) create mode 100644 .codeclimate.yml create mode 100644 .github/workflows/build.yml delete mode 100644 .travis.yml diff --git a/.codeclimate.yml b/.codeclimate.yml new file mode 100644 index 0000000000..0be9d672f9 --- /dev/null +++ b/.codeclimate.yml @@ -0,0 +1,28 @@ +version: '2' + +plugins: + nodesecurity: + enabled: true + + editorconfig: + enabled: true + + markdownlint: + enabled: true + + duplication: + enabled: true + config: + languages: + - javascript + + eslint: + enabled: true + + fixme: + enabled: true + +exclude_patterns: + - '.*' + - '**/*.*' + - '!source/**/*.js' diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml new file mode 100644 index 0000000000..793ef92009 --- /dev/null +++ b/.github/workflows/build.yml @@ -0,0 +1,45 @@ +name: Build + +on: [push] + +jobs: + coverage: + runs-on: ubuntu-latest + name: Code Climate Coverage + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Installing Dependencies + run: npm ci + + - name: Collecting Coverage + uses: paambaati/codeclimate-action@v2.6.0 + env: + CC_TEST_REPORTER_ID: ${{ secrets.CODE_CLIMATE_TOKEN }} + with: + coverageCommand: npm run coverage + coverageLocations: | + ${{github.workspace}}/coverage/lcov.info:lcov + + build: + runs-on: ubuntu-latest + strategy: + matrix: + node: ['14', '12', '10', '8'] + name: Node ${{ matrix.node }} + steps: + - name: Checkout repository + uses: actions/checkout@v2 + + - name: Installing Dependencies + run: npm ci + + - name: Linting Codebase + run: npm run lint + + - name: Unit Testing + run: npm run test + + - name: Building Artefacts + run: npm run build diff --git a/.gitignore b/.gitignore index fd86398093..b19ff30dff 100644 --- a/.gitignore +++ b/.gitignore @@ -10,3 +10,5 @@ /dist/gh-pages/ /tmp-test-bundle.js /coverage/ +/.idea +/.nyc_output diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index d27fcc9ff0..0000000000 --- a/.travis.yml +++ /dev/null @@ -1,8 +0,0 @@ -sudo: false -language: node_js -node_js: -- 8 -- 10 -- 12 -before_script: -- npm run lint diff --git a/README.md b/README.md index 0e50e1f06f..1ffd653a88 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,8 @@ Ramda A practical functional library for JavaScript programmers. -[![Build Status](https://travis-ci.org/ramda/ramda.svg?branch=master)](https://travis-ci.org/ramda/ramda) +[![Build Status](https://github.com/ramda/ramda/workflows/Build/badge.svg)](https://github.com/ramda/ramda/actions?query=workflow%3ABuild) +[![Test Coverage](https://api.codeclimate.com/v1/badges/953a3c5ee423e5301d18/test_coverage)](https://codeclimate.com/github/ramda/ramda/test_coverage) [![npm module](https://badge.fury.io/js/ramda.svg)](https://www.npmjs.org/package/ramda) [![dependencies](https://david-dm.org/ramda/ramda.svg)](https://david-dm.org/ramda/ramda) [![Gitter](https://badges.gitter.im/Join_Chat.svg)](https://gitter.im/ramda/ramda?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) diff --git a/package-lock.json b/package-lock.json index 5cf6e37fcd..884ddaed0d 100644 --- a/package-lock.json +++ b/package-lock.json @@ -49,19 +49,22 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", "integrity": "sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA=", - "dev": true + "dev": true, + "optional": true }, "array-unique": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=", - "dev": true + "dev": true, + "optional": true }, "braces": { "version": "2.3.2", "resolved": "https://registry.npmjs.org/braces/-/braces-2.3.2.tgz", "integrity": "sha512-aNdbnj9P8PjdXU4ybaWLK2IF3jc/EoDYbC7AazW6to3TRsfXxscC9UXOB5iDiEQrkyIbWp2SLQda4+QAa7nc3w==", "dev": true, + "optional": true, "requires": { "arr-flatten": "^1.1.0", "array-unique": "^0.3.2", @@ -80,6 +83,7 @@ "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, + "optional": true, "requires": { "is-extendable": "^0.1.0" } @@ -121,6 +125,7 @@ "resolved": "https://registry.npmjs.org/expand-brackets/-/expand-brackets-2.1.4.tgz", "integrity": "sha1-t3c14xXOMPa27/D4OwQVGiJEliI=", "dev": true, + "optional": true, "requires": { "debug": "^2.3.3", "define-property": "^0.2.5", @@ -136,6 +141,7 @@ "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", "dev": true, + "optional": true, "requires": { "is-descriptor": "^0.1.0" } @@ -145,6 +151,7 @@ "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, + "optional": true, "requires": { "is-extendable": "^0.1.0" } @@ -154,6 +161,7 @@ "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", "dev": true, + "optional": true, "requires": { "kind-of": "^3.0.2" }, @@ -163,6 +171,7 @@ "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, + "optional": true, "requires": { "is-buffer": "^1.1.5" } @@ -174,6 +183,7 @@ "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", "dev": true, + "optional": true, "requires": { "kind-of": "^3.0.2" }, @@ -183,6 +193,7 @@ "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, + "optional": true, "requires": { "is-buffer": "^1.1.5" } @@ -194,6 +205,7 @@ "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", "dev": true, + "optional": true, "requires": { "is-accessor-descriptor": "^0.1.6", "is-data-descriptor": "^0.1.4", @@ -204,7 +216,8 @@ "version": "5.1.0", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", - "dev": true + "dev": true, + "optional": true } } }, @@ -213,6 +226,7 @@ "resolved": "https://registry.npmjs.org/extglob/-/extglob-2.0.4.tgz", "integrity": "sha512-Nmb6QXkELsuBr24CJSkilo6UHHgbekK5UiZgfE6UHD3Eb27YC6oD+bhcT+tJ6cl8dmsgdQxnWlcry8ksBIBLpw==", "dev": true, + "optional": true, "requires": { "array-unique": "^0.3.2", "define-property": "^1.0.0", @@ -229,6 +243,7 @@ "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", "dev": true, + "optional": true, "requires": { "is-descriptor": "^1.0.0" } @@ -238,6 +253,7 @@ "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, + "optional": true, "requires": { "is-extendable": "^0.1.0" } @@ -249,6 +265,7 @@ "resolved": "https://registry.npmjs.org/fill-range/-/fill-range-4.0.0.tgz", "integrity": "sha1-1USBHUKPmOsGpj3EAtJAPDKMOPc=", "dev": true, + "optional": true, "requires": { "extend-shallow": "^2.0.1", "is-number": "^3.0.0", @@ -261,6 +278,7 @@ "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, + "optional": true, "requires": { "is-extendable": "^0.1.0" } @@ -287,7 +305,8 @@ "ansi-regex": { "version": "2.1.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "aproba": { "version": "1.2.0", @@ -308,12 +327,14 @@ "balanced-match": { "version": "1.0.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "brace-expansion": { "version": "1.1.11", "bundled": true, "dev": true, + "optional": true, "requires": { "balanced-match": "^1.0.0", "concat-map": "0.0.1" @@ -328,17 +349,20 @@ "code-point-at": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "concat-map": { "version": "0.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "console-control-strings": { "version": "1.1.0", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "core-util-is": { "version": "1.0.2", @@ -455,7 +479,8 @@ "inherits": { "version": "2.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "ini": { "version": "1.3.5", @@ -467,6 +492,7 @@ "version": "1.0.0", "bundled": true, "dev": true, + "optional": true, "requires": { "number-is-nan": "^1.0.0" } @@ -481,6 +507,7 @@ "version": "3.0.4", "bundled": true, "dev": true, + "optional": true, "requires": { "brace-expansion": "^1.1.7" } @@ -488,12 +515,14 @@ "minimist": { "version": "0.0.8", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "minipass": { "version": "2.3.5", "bundled": true, "dev": true, + "optional": true, "requires": { "safe-buffer": "^5.1.2", "yallist": "^3.0.0" @@ -512,6 +541,7 @@ "version": "0.5.1", "bundled": true, "dev": true, + "optional": true, "requires": { "minimist": "0.0.8" } @@ -592,7 +622,8 @@ "number-is-nan": { "version": "1.0.1", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "object-assign": { "version": "4.1.1", @@ -604,6 +635,7 @@ "version": "1.4.0", "bundled": true, "dev": true, + "optional": true, "requires": { "wrappy": "1" } @@ -689,7 +721,8 @@ "safe-buffer": { "version": "5.1.2", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "safer-buffer": { "version": "2.1.2", @@ -725,6 +758,7 @@ "version": "1.0.2", "bundled": true, "dev": true, + "optional": true, "requires": { "code-point-at": "^1.0.0", "is-fullwidth-code-point": "^1.0.0", @@ -744,6 +778,7 @@ "version": "3.0.1", "bundled": true, "dev": true, + "optional": true, "requires": { "ansi-regex": "^2.0.0" } @@ -787,12 +822,14 @@ "wrappy": { "version": "1.0.2", "bundled": true, - "dev": true + "dev": true, + "optional": true }, "yallist": { "version": "3.0.3", "bundled": true, - "dev": true + "dev": true, + "optional": true } } }, @@ -838,6 +875,7 @@ "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", "dev": true, + "optional": true, "requires": { "kind-of": "^6.0.0" } @@ -847,6 +885,7 @@ "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", "dev": true, + "optional": true, "requires": { "kind-of": "^6.0.0" } @@ -856,6 +895,7 @@ "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", "dev": true, + "optional": true, "requires": { "is-accessor-descriptor": "^1.0.0", "is-data-descriptor": "^1.0.0", @@ -866,7 +906,8 @@ "version": "2.1.1", "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", - "dev": true + "dev": true, + "optional": true }, "is-glob": { "version": "4.0.1", @@ -883,6 +924,7 @@ "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", "dev": true, + "optional": true, "requires": { "kind-of": "^3.0.2" }, @@ -892,6 +934,7 @@ "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, + "optional": true, "requires": { "is-buffer": "^1.1.5" } @@ -909,13 +952,15 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true + "dev": true, + "optional": true }, "kind-of": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", - "dev": true + "dev": true, + "optional": true }, "lodash": { "version": "4.17.14", @@ -928,6 +973,7 @@ "resolved": "https://registry.npmjs.org/micromatch/-/micromatch-3.1.10.tgz", "integrity": "sha512-MWikgl9n9M3w+bpsY3He8L+w9eF9338xRl8IAO5viDizwSzziFEyUzo2xrrloB64ADbTf8uA8vRqqttDTOmccg==", "dev": true, + "optional": true, "requires": { "arr-diff": "^4.0.0", "array-unique": "^0.3.2", @@ -2071,6 +2117,12 @@ "@babel/types": "^7.4.4" } }, + "@babel/helper-validator-identifier": { + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/helper-validator-identifier/-/helper-validator-identifier-7.10.1.tgz", + "integrity": "sha512-5vW/JXLALhczRCWP0PnFDMCJAchlBvM7f4uk/jXritBnIa6E1KmqmtrS3yn1LAnxFBypQ3eneLuXjsnfQsgILw==", + "dev": true + }, "@babel/helper-wrap-function": { "version": "7.7.4", "resolved": "https://registry.npmjs.org/@babel/helper-wrap-function/-/helper-wrap-function-7.7.4.tgz", @@ -2991,6 +3043,67 @@ } } }, + "@istanbuljs/load-nyc-config": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/@istanbuljs/load-nyc-config/-/load-nyc-config-1.1.0.tgz", + "integrity": "sha512-VjeHSlIzpv/NyD3N0YuHfXOPDIixcA1q2ZV98wsMqcYlPmv2n3Yb2lYP9XMElnaFVXg5A7YLTeLu6V84uQDjmQ==", + "dev": true, + "requires": { + "camelcase": "^5.3.1", + "find-up": "^4.1.0", + "get-package-type": "^0.1.0", + "js-yaml": "^3.13.1", + "resolve-from": "^5.0.0" + }, + "dependencies": { + "find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "dev": true, + "requires": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + } + }, + "locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "dev": true, + "requires": { + "p-locate": "^4.1.0" + } + }, + "p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "dev": true, + "requires": { + "p-limit": "^2.2.0" + } + }, + "path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true + }, + "resolve-from": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", + "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==", + "dev": true + } + } + }, + "@istanbuljs/schema": { + "version": "0.1.2", + "resolved": "https://registry.npmjs.org/@istanbuljs/schema/-/schema-0.1.2.tgz", + "integrity": "sha512-tsAQNx32a8CoFhjhijUIhI4kccIAgmGhy8LZMZgGfmXcpMbPRUqn5LWmgRttILi6yeGmBJd2xsPkFMs0PzgPCw==", + "dev": true + }, "@sinonjs/commons": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.4.0.tgz", @@ -3035,6 +3148,12 @@ "integrity": "sha512-+iTbntw2IZPb/anVDbypzfQa+ay64MW0Zo8aJ8gZPWMMK6/OubMVb6lUPMagqjOPnmtauXnFCACVl3O7ogjeqQ==", "dev": true }, + "@types/color-name": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/@types/color-name/-/color-name-1.1.1.tgz", + "integrity": "sha512-rr+OQyAjxze7GgWrSaJwydHStIhHq2lvY3BOC2Mj7KnzI7XK0Uw1TOOdI9lDoajEbSWLiYgoo4f1R51erQfhPQ==", + "dev": true + }, "@types/estree": { "version": "0.0.39", "resolved": "https://registry.npmjs.org/@types/estree/-/estree-0.0.39.tgz", @@ -3071,12 +3190,6 @@ } } }, - "abbrev": { - "version": "1.0.9", - "resolved": "https://registry.npmjs.org/abbrev/-/abbrev-1.0.9.tgz", - "integrity": "sha1-kbR5JYinc4wl813W9jdSovh3YTU=", - "dev": true - }, "accepts": { "version": "1.3.7", "resolved": "https://registry.npmjs.org/accepts/-/accepts-1.3.7.tgz", @@ -3137,6 +3250,16 @@ "integrity": "sha1-/ts5T58OAqqXaOcCvaI7UF+ufh8=", "dev": true }, + "aggregate-error": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/aggregate-error/-/aggregate-error-3.0.1.tgz", + "integrity": "sha512-quoaXsZ9/BLNae5yiNoUz+Nhkwz83GhWwtYFglcjEQB2NDHCIpApbqXxIFnm4Pq/Nvhrsq5sYJFyohrrxnTGAA==", + "dev": true, + "requires": { + "clean-stack": "^2.0.0", + "indent-string": "^4.0.0" + } + }, "ajv": { "version": "6.10.0", "resolved": "https://registry.npmjs.org/ajv/-/ajv-6.10.0.tgz", @@ -3182,12 +3305,27 @@ "color-convert": "^1.9.0" } }, + "append-transform": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/append-transform/-/append-transform-2.0.0.tgz", + "integrity": "sha512-7yeyCEurROLQJFv5Xj4lEGTy0borxepjFv1g22oAdqFu//SrAlDl1O1Nxx15SH1RoliUml6p8dwJW9jvZughhg==", + "dev": true, + "requires": { + "default-require-extensions": "^3.0.0" + } + }, "aproba": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/aproba/-/aproba-1.2.0.tgz", "integrity": "sha512-Y9J6ZjXtoYh8RnXVCMOU/ttDmk1aBjunq9vO0ta5x85WDQiQfUF9sIPBITdbiiIVcBo03Hi3jMxigBtsddlXRw==", "dev": true }, + "archy": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/archy/-/archy-1.0.0.tgz", + "integrity": "sha1-+cjBN1fMHde8N5rHeyxipcKGjEA=", + "dev": true + }, "are-we-there-yet": { "version": "1.1.5", "resolved": "https://registry.npmjs.org/are-we-there-yet/-/are-we-there-yet-1.1.5.tgz", @@ -3243,13 +3381,15 @@ "version": "1.1.0", "resolved": "https://registry.npmjs.org/arr-flatten/-/arr-flatten-1.1.0.tgz", "integrity": "sha512-L3hKV5R/p5o81R7O02IGnwpDmkp6E982XhtbuwSe3O4qOtMMMtodicASA1Cny2U+aCXcNpml+m4dPsvsJ3jatg==", - "dev": true + "dev": true, + "optional": true }, "arr-union": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/arr-union/-/arr-union-3.1.0.tgz", "integrity": "sha1-45sJrqne+Gao8gbiiK9jkZuuOcQ=", - "dev": true + "dev": true, + "optional": true }, "array-flatten": { "version": "1.1.1", @@ -3293,7 +3433,8 @@ "version": "1.0.0", "resolved": "https://registry.npmjs.org/assign-symbols/-/assign-symbols-1.0.0.tgz", "integrity": "sha1-WWZ/QfrdTyDMvCu5a41Pf3jsA2c=", - "dev": true + "dev": true, + "optional": true }, "astral-regex": { "version": "1.0.0", @@ -3333,7 +3474,8 @@ "version": "2.1.2", "resolved": "https://registry.npmjs.org/atob/-/atob-2.1.2.tgz", "integrity": "sha512-Wm6ukoaOGJi/73p/cl2GvLjTI5JM1k/O14isD73YML8StrH/7/lRFgmg8nICZgD3bZZvjwCGxtMOD3wWNAu8cg==", - "dev": true + "dev": true, + "optional": true }, "babel-plugin-annotate-pure-calls": { "version": "0.4.0", @@ -3388,6 +3530,7 @@ "resolved": "https://registry.npmjs.org/base/-/base-0.11.2.tgz", "integrity": "sha512-5T6P4xPgpp0YDFvSWwEZ4NoE3aM4QBQXDzmVbraCkFj8zHM+mba8SyqB5DbZWyR7mYHo6Y7BdQo3MoA4m0TeQg==", "dev": true, + "optional": true, "requires": { "cache-base": "^1.0.1", "class-utils": "^0.3.5", @@ -3403,6 +3546,7 @@ "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", "dev": true, + "optional": true, "requires": { "is-descriptor": "^1.0.0" } @@ -3412,6 +3556,7 @@ "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", "dev": true, + "optional": true, "requires": { "kind-of": "^6.0.0" } @@ -3421,6 +3566,7 @@ "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", "dev": true, + "optional": true, "requires": { "kind-of": "^6.0.0" } @@ -3430,6 +3576,7 @@ "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", "dev": true, + "optional": true, "requires": { "is-accessor-descriptor": "^1.0.0", "is-data-descriptor": "^1.0.0", @@ -3440,13 +3587,15 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true + "dev": true, + "optional": true }, "kind-of": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", - "dev": true + "dev": true, + "optional": true } } }, @@ -3827,6 +3976,7 @@ "resolved": "https://registry.npmjs.org/cache-base/-/cache-base-1.0.1.tgz", "integrity": "sha512-AKcdTnFSWATd5/GCPRxr2ChwIJ85CeyrEyjRHlKxQ56d4XJMGym0uAiKn0xbLOGOl3+yRpOTi484dVCEc5AUzQ==", "dev": true, + "optional": true, "requires": { "collection-visit": "^1.0.0", "component-emitter": "^1.2.1", @@ -3843,6 +3993,36 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", + "dev": true, + "optional": true + } + } + }, + "caching-transform": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/caching-transform/-/caching-transform-4.0.0.tgz", + "integrity": "sha512-kpqOvwXnjjN44D89K5ccQC+RUrsy7jB/XLlRrx0D7/2HNcTPqzsb6XgYoErwko6QsV184CA2YgS1fxDiiDZMWA==", + "dev": true, + "requires": { + "hasha": "^5.0.0", + "make-dir": "^3.0.0", + "package-hash": "^4.0.0", + "write-file-atomic": "^3.0.0" + }, + "dependencies": { + "make-dir": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", + "integrity": "sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==", + "dev": true, + "requires": { + "semver": "^6.0.0" + } + }, + "semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", "dev": true } } @@ -3859,6 +4039,12 @@ "integrity": "sha512-P8BjAsXvZS+VIDUI11hHCQEv74YT67YUi5JJFNWIqL235sBmjX4+qx9Muvls5ivyNENctx46xQLQ3aTuE7ssaQ==", "dev": true }, + "camelcase": { + "version": "5.3.1", + "resolved": "https://registry.npmjs.org/camelcase/-/camelcase-5.3.1.tgz", + "integrity": "sha512-L28STB170nwWS63UjtlEOE3dldQApaJXZkOI1uMFfzf3rRuPegHaHesyee+YxQ+W6SvRDQV6UrdOdRiR153wJg==", + "dev": true + }, "caniuse-lite": { "version": "1.0.30001012", "resolved": "https://registry.npmjs.org/caniuse-lite/-/caniuse-lite-1.0.30001012.tgz", @@ -3906,6 +4092,7 @@ "resolved": "https://registry.npmjs.org/class-utils/-/class-utils-0.3.6.tgz", "integrity": "sha512-qOhPa/Fj7s6TY8H8esGu5QNpMMQxz79h+urzrNYN6mn+9BnxlDGf5QZ+XeCDsxSjPqsSR56XOZOJmpeurnLMeg==", "dev": true, + "optional": true, "requires": { "arr-union": "^3.1.0", "define-property": "^0.2.5", @@ -3918,6 +4105,7 @@ "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", "dev": true, + "optional": true, "requires": { "is-descriptor": "^0.1.0" } @@ -3926,10 +4114,17 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true + "dev": true, + "optional": true } } }, + "clean-stack": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/clean-stack/-/clean-stack-2.2.0.tgz", + "integrity": "sha512-4diC9HaTE+KRAMWhDhrGOECgWZxoevMc5TlkObMqNSsVU62PYzXZ/SMTjzyGAFF1YusgxGcSWTEXBhp0CPwQ1A==", + "dev": true + }, "cli-cursor": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/cli-cursor/-/cli-cursor-2.1.0.tgz", @@ -3954,6 +4149,93 @@ "integrity": "sha1-/xnt6Kml5XkyQUewwR8PvLq+1jk=", "dev": true }, + "cliui": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/cliui/-/cliui-6.0.0.tgz", + "integrity": "sha512-t6wbgtoCXvAzst7QgXxJYqPt0usEfbgQdftEPbLL/cvv6HPE5VgvqCuAIDR0NgU52ds6rFwqrgakNLrHEjCbrQ==", + "dev": true, + "requires": { + "string-width": "^4.2.0", + "strip-ansi": "^6.0.0", + "wrap-ansi": "^6.2.0" + }, + "dependencies": { + "ansi-regex": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", + "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", + "dev": true + }, + "ansi-styles": { + "version": "4.2.1", + "resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.2.1.tgz", + "integrity": "sha512-9VGjrMsG1vePxcSweQsN20KY/c4zN0h9fLjqAbwbPfahM3t+NL+M9HC8xeXG2I8pX5NoamTGNuomEUFI7fcUjA==", + "dev": true, + "requires": { + "@types/color-name": "^1.1.1", + "color-convert": "^2.0.1" + } + }, + "color-convert": { + "version": "2.0.1", + "resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz", + "integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==", + "dev": true, + "requires": { + "color-name": "~1.1.4" + } + }, + "color-name": { + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz", + "integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==", + "dev": true + }, + "emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true + }, + "is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true + }, + "string-width": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.0.tgz", + "integrity": "sha512-zUz5JD+tgqtuDjMhwIg5uFVV3dtqZ9yQJlZVfq4I01/K5Paj5UHj7VyrQOJvzawSVlKpObApbfD0Ed6yJc+1eg==", + "dev": true, + "requires": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.0" + } + }, + "strip-ansi": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", + "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", + "dev": true, + "requires": { + "ansi-regex": "^5.0.0" + } + }, + "wrap-ansi": { + "version": "6.2.0", + "resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-6.2.0.tgz", + "integrity": "sha512-r6lPcBGxZXlIcymEu7InxDMhdW0KDxpLgoFLcguasxCaJ/SOIZwINatK9KY/tf+ZrlywOKU0UDj3ATXUBfxJXA==", + "dev": true, + "requires": { + "ansi-styles": "^4.0.0", + "string-width": "^4.1.0", + "strip-ansi": "^6.0.0" + } + } + } + }, "code-point-at": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/code-point-at/-/code-point-at-1.1.0.tgz", @@ -3965,6 +4247,7 @@ "resolved": "https://registry.npmjs.org/collection-visit/-/collection-visit-1.0.0.tgz", "integrity": "sha1-S8A3PBZLwykbTTaMgpzxqApZ3KA=", "dev": true, + "optional": true, "requires": { "map-visit": "^1.0.0", "object-visit": "^1.0.0" @@ -4124,7 +4407,8 @@ "version": "0.1.1", "resolved": "https://registry.npmjs.org/copy-descriptor/-/copy-descriptor-0.1.1.tgz", "integrity": "sha1-Z29us8OZl8LuGsOpJP1hJHSPV40=", - "dev": true + "dev": true, + "optional": true }, "core-js": { "version": "3.1.1", @@ -4260,7 +4544,8 @@ "version": "0.2.0", "resolved": "https://registry.npmjs.org/decode-uri-component/-/decode-uri-component-0.2.0.tgz", "integrity": "sha1-6zkTMzRYd1y4TNGh+uBiEGu4dUU=", - "dev": true + "dev": true, + "optional": true }, "deep-equal": { "version": "1.0.1", @@ -4274,6 +4559,15 @@ "integrity": "sha1-s2nW+128E+7PUk+RsHD+7cNXzzQ=", "dev": true }, + "default-require-extensions": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/default-require-extensions/-/default-require-extensions-3.0.0.tgz", + "integrity": "sha512-ek6DpXq/SCpvjhpFsLFRVtIxJCRw6fUR42lYMVZuUMK7n8eMz4Uh5clckdBjEpLhn/gEBZo7hDJnJcwdKLKQjg==", + "dev": true, + "requires": { + "strip-bom": "^4.0.0" + } + }, "define-properties": { "version": "1.1.3", "resolved": "https://registry.npmjs.org/define-properties/-/define-properties-1.1.3.tgz", @@ -4288,6 +4582,7 @@ "resolved": "https://registry.npmjs.org/define-property/-/define-property-2.0.2.tgz", "integrity": "sha512-jwK2UV4cnPpbcG7+VRARKTZPUWowwXA8bzH5NP6ud0oeAxyYPuGZUAC7hMugpCdz4BeSZl2Dl9k66CHJ/46ZYQ==", "dev": true, + "optional": true, "requires": { "is-descriptor": "^1.0.2", "isobject": "^3.0.1" @@ -4298,6 +4593,7 @@ "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", "dev": true, + "optional": true, "requires": { "kind-of": "^6.0.0" } @@ -4307,6 +4603,7 @@ "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", "dev": true, + "optional": true, "requires": { "kind-of": "^6.0.0" } @@ -4316,6 +4613,7 @@ "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", "dev": true, + "optional": true, "requires": { "is-accessor-descriptor": "^1.0.0", "is-data-descriptor": "^1.0.0", @@ -4326,13 +4624,15 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true + "dev": true, + "optional": true }, "kind-of": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", - "dev": true + "dev": true, + "optional": true } } }, @@ -4640,6 +4940,12 @@ "is-symbol": "^1.0.2" } }, + "es6-error": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/es6-error/-/es6-error-4.1.1.tgz", + "integrity": "sha512-Um/+FxMr9CISWh0bi5Zv0iOD+4cFh5qLeks1qhAopKVAJw3drgKbKySikp7wGhDL0HPeaja0P5ULZrxLkniUVg==", + "dev": true + }, "escape-html": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.3.tgz", @@ -4822,12 +5128,6 @@ } } }, - "estraverse": { - "version": "1.9.3", - "resolved": "https://registry.npmjs.org/estraverse/-/estraverse-1.9.3.tgz", - "integrity": "sha1-r2fy3JIlgkFZUJJgkaQAXSnJu0Q=", - "dev": true - }, "estree-walker": { "version": "0.6.1", "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-0.6.1.tgz", @@ -4946,6 +5246,7 @@ "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-3.0.2.tgz", "integrity": "sha1-Jqcarwc7OfshJxcnRhMcJwQCjbg=", "dev": true, + "optional": true, "requires": { "assign-symbols": "^1.0.0", "is-extendable": "^1.0.1" @@ -4956,6 +5257,7 @@ "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", "dev": true, + "optional": true, "requires": { "is-plain-object": "^2.0.4" } @@ -5129,7 +5431,61 @@ "version": "1.0.2", "resolved": "https://registry.npmjs.org/for-in/-/for-in-1.0.2.tgz", "integrity": "sha1-gQaNKVqBQuwKxybG4iAMMPttXoA=", - "dev": true + "dev": true, + "optional": true + }, + "foreground-child": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/foreground-child/-/foreground-child-2.0.0.tgz", + "integrity": "sha512-dCIq9FpEcyQyXKCkyzmlPTFNgrCzPudOe+mhvJU5zAtlBnGVy2yKxtfsxK2tQBThwq225jcvBjpw1Gr40uzZCA==", + "dev": true, + "requires": { + "cross-spawn": "^7.0.0", + "signal-exit": "^3.0.2" + }, + "dependencies": { + "cross-spawn": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "dev": true, + "requires": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + } + }, + "path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true + }, + "shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", + "dev": true, + "requires": { + "shebang-regex": "^3.0.0" + } + }, + "shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", + "dev": true + }, + "which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "requires": { + "isexe": "^2.0.0" + } + } + } }, "forwarded": { "version": "0.1.2", @@ -5142,6 +5498,7 @@ "resolved": "https://registry.npmjs.org/fragment-cache/-/fragment-cache-0.2.1.tgz", "integrity": "sha1-QpD60n8T6Jvn8zeZxrxaCr//DRk=", "dev": true, + "optional": true, "requires": { "map-cache": "^0.2.2" } @@ -5152,6 +5509,12 @@ "integrity": "sha1-PYyt2Q2XZWn6g1qx+OSyOhBWBac=", "dev": true }, + "fromentries": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/fromentries/-/fromentries-1.2.0.tgz", + "integrity": "sha512-33X7H/wdfO99GdRLLgkjUrD4geAFdq/Uv0kl3HD4da6HDixd2GUg8Mw7dahLCV9r/EARkmtYBB6Tch4EEokFTQ==", + "dev": true + }, "fs-readdir-recursive": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/fs-readdir-recursive/-/fs-readdir-recursive-1.1.0.tgz", @@ -5229,12 +5592,24 @@ } } }, + "gensync": { + "version": "1.0.0-beta.1", + "resolved": "https://registry.npmjs.org/gensync/-/gensync-1.0.0-beta.1.tgz", + "integrity": "sha512-r8EC6NO1sngH/zdD9fiRDLdcgnbayXah+mLgManTaIZJqEC1MZstmnox8KpnI2/fxQwrp5OpCOYWLp4rBl4Jcg==", + "dev": true + }, "get-caller-file": { "version": "2.0.5", "resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz", "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", "dev": true }, + "get-package-type": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/get-package-type/-/get-package-type-0.1.0.tgz", + "integrity": "sha512-pjzuKtY64GYfWizNAJ0fr9VqttZkNiK2iS430LtIHzjBEr6bX8Am2zm4sW4Ro5wjWW5cAlRL1qAMTcXbjNAO2Q==", + "dev": true + }, "get-stream": { "version": "4.1.0", "resolved": "https://registry.npmjs.org/get-stream/-/get-stream-4.1.0.tgz", @@ -5248,7 +5623,8 @@ "version": "2.0.6", "resolved": "https://registry.npmjs.org/get-value/-/get-value-2.0.6.tgz", "integrity": "sha1-3BXKHGcjh8p2vTesCjlbogQqLCg=", - "dev": true + "dev": true, + "optional": true }, "glob": { "version": "4.5.3", @@ -5355,12 +5731,6 @@ "integrity": "sha1-XkdHk/fqmEPRu5nCPu9J/xJv/zk=", "dev": true }, - "has-flag": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-1.0.0.tgz", - "integrity": "sha1-nZ55MWXOAXoA8AQYxD+UKnsdEfo=", - "dev": true - }, "has-symbols": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.0.tgz", @@ -5378,6 +5748,7 @@ "resolved": "https://registry.npmjs.org/has-value/-/has-value-1.0.0.tgz", "integrity": "sha1-GLKB2lhbHFxR3vJMkw7SmgvmsXc=", "dev": true, + "optional": true, "requires": { "get-value": "^2.0.6", "has-values": "^1.0.0", @@ -5388,7 +5759,8 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true + "dev": true, + "optional": true } } }, @@ -5397,6 +5769,7 @@ "resolved": "https://registry.npmjs.org/has-values/-/has-values-1.0.0.tgz", "integrity": "sha1-lbC2P+whRmGab+V/51Yo1aOe/k8=", "dev": true, + "optional": true, "requires": { "is-number": "^3.0.0", "kind-of": "^4.0.0" @@ -5407,6 +5780,7 @@ "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", "dev": true, + "optional": true, "requires": { "kind-of": "^3.0.2" }, @@ -5416,6 +5790,7 @@ "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, + "optional": true, "requires": { "is-buffer": "^1.1.5" } @@ -5427,6 +5802,7 @@ "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-4.0.0.tgz", "integrity": "sha1-IIE989cSkosgc3hpGkUGb65y3Vc=", "dev": true, + "optional": true, "requires": { "is-buffer": "^1.1.5" } @@ -5453,6 +5829,24 @@ "minimalistic-assert": "^1.0.1" } }, + "hasha": { + "version": "5.2.0", + "resolved": "https://registry.npmjs.org/hasha/-/hasha-5.2.0.tgz", + "integrity": "sha512-2W+jKdQbAdSIrggA8Q35Br8qKadTrqCTC8+XZvBWepKDK6m9XkX6Iz1a2yh2KP01kzAR/dpuMeUnocoLYDcskw==", + "dev": true, + "requires": { + "is-stream": "^2.0.0", + "type-fest": "^0.8.0" + }, + "dependencies": { + "is-stream": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-2.0.0.tgz", + "integrity": "sha512-XCoy+WlUr7d1+Z8GgSuXmpuUFC9fOhRXglJMx+dwLKTkL44Cjd4W1Z5P+BQZpr+cR93aGP4S/s7Ftw6Nd/kiEw==", + "dev": true + } + } + }, "he": { "version": "1.2.0", "resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz", @@ -5470,6 +5864,12 @@ "minimalistic-crypto-utils": "^1.0.1" } }, + "html-escaper": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz", + "integrity": "sha512-H2iMtd0I4Mt5eYiapRdIDjp+XzelXQ0tFE4JS7YFwFevXXMmOp9myNrUvCg0D6ws8iqkRPBfKHgbwig1SmlLfg==", + "dev": true + }, "http-browserify": { "version": "1.7.0", "resolved": "https://registry.npmjs.org/http-browserify/-/http-browserify-1.7.0.tgz", @@ -5547,6 +5947,12 @@ "integrity": "sha1-khi5srkoojixPcT7a21XbyMUU+o=", "dev": true }, + "indent-string": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/indent-string/-/indent-string-4.0.0.tgz", + "integrity": "sha512-EdDDZu4A2OyIK7Lr/2zG+w5jmbuk1DVBnEwREQvBzspBJkCEbRa8GxU1lghYcaGJCnRWibjDXlq779X1/y5xwg==", + "dev": true + }, "indexof": { "version": "0.0.1", "resolved": "https://registry.npmjs.org/indexof/-/indexof-0.0.1.tgz", @@ -5729,6 +6135,7 @@ "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-0.1.6.tgz", "integrity": "sha1-qeEss66Nh2cn7u84Q/igiXtcmNY=", "dev": true, + "optional": true, "requires": { "kind-of": "^3.0.2" } @@ -5760,6 +6167,7 @@ "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", "integrity": "sha1-C17mSDiOLIYCgueT8YVv7D8wG1Y=", "dev": true, + "optional": true, "requires": { "kind-of": "^3.0.2" } @@ -5775,6 +6183,7 @@ "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-0.1.6.tgz", "integrity": "sha512-avDYr0SB3DwO9zsMov0gKCESFYqCnE4hq/4z3TdUlukEy5t9C0YRq7HLrsN52NAcqXKaepeCD0n+B0arnVG3Hg==", "dev": true, + "optional": true, "requires": { "is-accessor-descriptor": "^0.1.6", "is-data-descriptor": "^0.1.4", @@ -5785,7 +6194,8 @@ "version": "5.1.0", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-5.1.0.tgz", "integrity": "sha512-NGEErnH6F2vUuXDh+OlbcKW7/wOcfdRHaZ7VWtqCztfHri/++YKmP51OdWeGPuqCOba6kk2OTe5d02VmTB80Pw==", - "dev": true + "dev": true, + "optional": true } } }, @@ -5793,7 +6203,8 @@ "version": "0.1.1", "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-0.1.1.tgz", "integrity": "sha1-YrEQ4omkcUGOPsNqYX1HLjAd/Ik=", - "dev": true + "dev": true, + "optional": true }, "is-fullwidth-code-point": { "version": "2.0.0", @@ -5812,6 +6223,7 @@ "resolved": "https://registry.npmjs.org/is-plain-object/-/is-plain-object-2.0.4.tgz", "integrity": "sha512-h5PpgXkWitc38BBMYawTYMWJHFZJVnBquFE57xFpjB8pJFiF6gZ+bU+WyI/yqXiFR5mdLsgYNaPe8uao6Uv9Og==", "dev": true, + "optional": true, "requires": { "isobject": "^3.0.1" }, @@ -5820,7 +6232,8 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true + "dev": true, + "optional": true } } }, @@ -5863,6 +6276,12 @@ "core-util-is": "~1.0.0" } }, + "is-typedarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/is-typedarray/-/is-typedarray-1.0.0.tgz", + "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=", + "dev": true + }, "is-windows": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz", @@ -5887,155 +6306,488 @@ "integrity": "sha1-6PvzdNxVb/iUehDcsFctYz8s+hA=", "dev": true }, - "istanbul": { - "version": "0.4.5", - "resolved": "https://registry.npmjs.org/istanbul/-/istanbul-0.4.5.tgz", - "integrity": "sha1-ZcfXPUxNqE1POsMQuRj7C4Azczs=", - "dev": true, - "requires": { - "abbrev": "1.0.x", - "async": "1.x", - "escodegen": "1.8.x", - "esprima": "2.7.x", - "glob": "^5.0.15", - "handlebars": "^4.0.1", - "js-yaml": "3.x", - "mkdirp": "0.5.x", - "nopt": "3.x", - "once": "1.x", - "resolve": "1.1.x", - "supports-color": "^3.1.0", - "which": "^1.1.1", - "wordwrap": "^1.0.0" + "istanbul-lib-coverage": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/istanbul-lib-coverage/-/istanbul-lib-coverage-3.0.0.tgz", + "integrity": "sha512-UiUIqxMgRDET6eR+o5HbfRYP1l0hqkWOs7vNxC/mggutCMUIhWMm8gAHb8tHlyfD3/l6rlgNA5cKdDzEAf6hEg==", + "dev": true + }, + "istanbul-lib-hook": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/istanbul-lib-hook/-/istanbul-lib-hook-3.0.0.tgz", + "integrity": "sha512-Pt/uge1Q9s+5VAZ+pCo16TYMWPBIl+oaNIjgLQxcX0itS6ueeaA+pEfThZpH8WxhFgCiEb8sAJY6MdUKgiIWaQ==", + "dev": true, + "requires": { + "append-transform": "^2.0.0" + } + }, + "istanbul-lib-instrument": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/istanbul-lib-instrument/-/istanbul-lib-instrument-4.0.3.tgz", + "integrity": "sha512-BXgQl9kf4WTCPCCpmFGoJkz/+uhvm7h7PFKUYxh7qarQd3ER33vHG//qaE8eN25l07YqZPpHXU9I09l/RD5aGQ==", + "dev": true, + "requires": { + "@babel/core": "^7.7.5", + "@istanbuljs/schema": "^0.1.2", + "istanbul-lib-coverage": "^3.0.0", + "semver": "^6.3.0" }, "dependencies": { - "async": { - "version": "1.5.2", - "resolved": "https://registry.npmjs.org/async/-/async-1.5.2.tgz", - "integrity": "sha1-7GphrlZIDAw8skHJVhjiCJL5Zyo=", + "@babel/code-frame": { + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.10.1.tgz", + "integrity": "sha512-IGhtTmpjGbYzcEDOw7DcQtbQSXcG9ftmAXtWTu9V936vDye4xjjekktFAtgZsWpzTj/X01jocB46mTywm/4SZw==", + "dev": true, + "requires": { + "@babel/highlight": "^7.10.1" + } + }, + "@babel/core": { + "version": "7.10.2", + "resolved": "https://registry.npmjs.org/@babel/core/-/core-7.10.2.tgz", + "integrity": "sha512-KQmV9yguEjQsXqyOUGKjS4+3K8/DlOCE2pZcq4augdQmtTy5iv5EHtmMSJ7V4c1BIPjuwtZYqYLCq9Ga+hGBRQ==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.10.1", + "@babel/generator": "^7.10.2", + "@babel/helper-module-transforms": "^7.10.1", + "@babel/helpers": "^7.10.1", + "@babel/parser": "^7.10.2", + "@babel/template": "^7.10.1", + "@babel/traverse": "^7.10.1", + "@babel/types": "^7.10.2", + "convert-source-map": "^1.7.0", + "debug": "^4.1.0", + "gensync": "^1.0.0-beta.1", + "json5": "^2.1.2", + "lodash": "^4.17.13", + "resolve": "^1.3.2", + "semver": "^5.4.1", + "source-map": "^0.5.0" + }, + "dependencies": { + "semver": { + "version": "5.7.1", + "resolved": "https://registry.npmjs.org/semver/-/semver-5.7.1.tgz", + "integrity": "sha512-sauaDf/PZdVgrLTNYHRtpXa1iRiKcaebiKQ1BJdpQlWH2lCvexQdX55snPFyK7QzpudqbCI0qXFfOasHdyNDGQ==", + "dev": true + } + } + }, + "@babel/generator": { + "version": "7.10.2", + "resolved": "https://registry.npmjs.org/@babel/generator/-/generator-7.10.2.tgz", + "integrity": "sha512-AxfBNHNu99DTMvlUPlt1h2+Hn7knPpH5ayJ8OqDWSeLld+Fi2AYBTC/IejWDM9Edcii4UzZRCsbUt0WlSDsDsA==", + "dev": true, + "requires": { + "@babel/types": "^7.10.2", + "jsesc": "^2.5.1", + "lodash": "^4.17.13", + "source-map": "^0.5.0" + } + }, + "@babel/helper-function-name": { + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/helper-function-name/-/helper-function-name-7.10.1.tgz", + "integrity": "sha512-fcpumwhs3YyZ/ttd5Rz0xn0TpIwVkN7X0V38B9TWNfVF42KEkhkAAuPCQ3oXmtTRtiPJrmZ0TrfS0GKF0eMaRQ==", + "dev": true, + "requires": { + "@babel/helper-get-function-arity": "^7.10.1", + "@babel/template": "^7.10.1", + "@babel/types": "^7.10.1" + } + }, + "@babel/helper-get-function-arity": { + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/helper-get-function-arity/-/helper-get-function-arity-7.10.1.tgz", + "integrity": "sha512-F5qdXkYGOQUb0hpRaPoetF9AnsXknKjWMZ+wmsIRsp5ge5sFh4c3h1eH2pRTTuy9KKAA2+TTYomGXAtEL2fQEw==", + "dev": true, + "requires": { + "@babel/types": "^7.10.1" + } + }, + "@babel/helper-member-expression-to-functions": { + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/helper-member-expression-to-functions/-/helper-member-expression-to-functions-7.10.1.tgz", + "integrity": "sha512-u7XLXeM2n50gb6PWJ9hoO5oO7JFPaZtrh35t8RqKLT1jFKj9IWeD1zrcrYp1q1qiZTdEarfDWfTIP8nGsu0h5g==", + "dev": true, + "requires": { + "@babel/types": "^7.10.1" + } + }, + "@babel/helper-module-imports": { + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/helper-module-imports/-/helper-module-imports-7.10.1.tgz", + "integrity": "sha512-SFxgwYmZ3HZPyZwJRiVNLRHWuW2OgE5k2nrVs6D9Iv4PPnXVffuEHy83Sfx/l4SqF+5kyJXjAyUmrG7tNm+qVg==", + "dev": true, + "requires": { + "@babel/types": "^7.10.1" + } + }, + "@babel/helper-module-transforms": { + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/helper-module-transforms/-/helper-module-transforms-7.10.1.tgz", + "integrity": "sha512-RLHRCAzyJe7Q7sF4oy2cB+kRnU4wDZY/H2xJFGof+M+SJEGhZsb+GFj5j1AD8NiSaVBJ+Pf0/WObiXu/zxWpFg==", + "dev": true, + "requires": { + "@babel/helper-module-imports": "^7.10.1", + "@babel/helper-replace-supers": "^7.10.1", + "@babel/helper-simple-access": "^7.10.1", + "@babel/helper-split-export-declaration": "^7.10.1", + "@babel/template": "^7.10.1", + "@babel/types": "^7.10.1", + "lodash": "^4.17.13" + } + }, + "@babel/helper-optimise-call-expression": { + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/helper-optimise-call-expression/-/helper-optimise-call-expression-7.10.1.tgz", + "integrity": "sha512-a0DjNS1prnBsoKx83dP2falChcs7p3i8VMzdrSbfLhuQra/2ENC4sbri34dz/rWmDADsmF1q5GbfaXydh0Jbjg==", + "dev": true, + "requires": { + "@babel/types": "^7.10.1" + } + }, + "@babel/helper-replace-supers": { + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/helper-replace-supers/-/helper-replace-supers-7.10.1.tgz", + "integrity": "sha512-SOwJzEfpuQwInzzQJGjGaiG578UYmyi2Xw668klPWV5n07B73S0a9btjLk/52Mlcxa+5AdIYqws1KyXRfMoB7A==", + "dev": true, + "requires": { + "@babel/helper-member-expression-to-functions": "^7.10.1", + "@babel/helper-optimise-call-expression": "^7.10.1", + "@babel/traverse": "^7.10.1", + "@babel/types": "^7.10.1" + } + }, + "@babel/helper-simple-access": { + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/helper-simple-access/-/helper-simple-access-7.10.1.tgz", + "integrity": "sha512-VSWpWzRzn9VtgMJBIWTZ+GP107kZdQ4YplJlCmIrjoLVSi/0upixezHCDG8kpPVTBJpKfxTH01wDhh+jS2zKbw==", + "dev": true, + "requires": { + "@babel/template": "^7.10.1", + "@babel/types": "^7.10.1" + } + }, + "@babel/helper-split-export-declaration": { + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/helper-split-export-declaration/-/helper-split-export-declaration-7.10.1.tgz", + "integrity": "sha512-UQ1LVBPrYdbchNhLwj6fetj46BcFwfS4NllJo/1aJsT+1dLTEnXJL0qHqtY7gPzF8S2fXBJamf1biAXV3X077g==", + "dev": true, + "requires": { + "@babel/types": "^7.10.1" + } + }, + "@babel/helpers": { + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/helpers/-/helpers-7.10.1.tgz", + "integrity": "sha512-muQNHF+IdU6wGgkaJyhhEmI54MOZBKsFfsXFhboz1ybwJ1Kl7IHlbm2a++4jwrmY5UYsgitt5lfqo1wMFcHmyw==", + "dev": true, + "requires": { + "@babel/template": "^7.10.1", + "@babel/traverse": "^7.10.1", + "@babel/types": "^7.10.1" + } + }, + "@babel/highlight": { + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/highlight/-/highlight-7.10.1.tgz", + "integrity": "sha512-8rMof+gVP8mxYZApLF/JgNDAkdKa+aJt3ZYxF8z6+j/hpeXL7iMsKCPHa2jNMHu/qqBwzQF4OHNoYi8dMA/rYg==", + "dev": true, + "requires": { + "@babel/helper-validator-identifier": "^7.10.1", + "chalk": "^2.0.0", + "js-tokens": "^4.0.0" + } + }, + "@babel/parser": { + "version": "7.10.2", + "resolved": "https://registry.npmjs.org/@babel/parser/-/parser-7.10.2.tgz", + "integrity": "sha512-PApSXlNMJyB4JiGVhCOlzKIif+TKFTvu0aQAhnTvfP/z3vVSN6ZypH5bfUNwFXXjRQtUEBNFd2PtmCmG2Py3qQ==", "dev": true }, - "escodegen": { - "version": "1.8.1", - "resolved": "https://registry.npmjs.org/escodegen/-/escodegen-1.8.1.tgz", - "integrity": "sha1-WltTr0aTEQvrsIZ6o0MN07cKEBg=", + "@babel/template": { + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/template/-/template-7.10.1.tgz", + "integrity": "sha512-OQDg6SqvFSsc9A0ej6SKINWrpJiNonRIniYondK2ViKhB06i3c0s+76XUft71iqBEe9S1OKsHwPAjfHnuvnCig==", "dev": true, "requires": { - "esprima": "^2.7.1", - "estraverse": "^1.9.1", - "esutils": "^2.0.2", - "optionator": "^0.8.1", - "source-map": "~0.2.0" + "@babel/code-frame": "^7.10.1", + "@babel/parser": "^7.10.1", + "@babel/types": "^7.10.1" + } + }, + "@babel/traverse": { + "version": "7.10.1", + "resolved": "https://registry.npmjs.org/@babel/traverse/-/traverse-7.10.1.tgz", + "integrity": "sha512-C/cTuXeKt85K+p08jN6vMDz8vSV0vZcI0wmQ36o6mjbuo++kPMdpOYw23W2XH04dbRt9/nMEfA4W3eR21CD+TQ==", + "dev": true, + "requires": { + "@babel/code-frame": "^7.10.1", + "@babel/generator": "^7.10.1", + "@babel/helper-function-name": "^7.10.1", + "@babel/helper-split-export-declaration": "^7.10.1", + "@babel/parser": "^7.10.1", + "@babel/types": "^7.10.1", + "debug": "^4.1.0", + "globals": "^11.1.0", + "lodash": "^4.17.13" + } + }, + "@babel/types": { + "version": "7.10.2", + "resolved": "https://registry.npmjs.org/@babel/types/-/types-7.10.2.tgz", + "integrity": "sha512-AD3AwWBSz0AWF0AkCN9VPiWrvldXq+/e3cHa4J89vo4ymjz1XwrBFFVZmkJTsQIPNk+ZVomPSXUJqq8yyjZsng==", + "dev": true, + "requires": { + "@babel/helper-validator-identifier": "^7.10.1", + "lodash": "^4.17.13", + "to-fast-properties": "^2.0.0" + } + }, + "convert-source-map": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.7.0.tgz", + "integrity": "sha512-4FJkXzKXEDB1snCFZlLP4gpC3JILicCpGbzG9f9G7tGqGCzETQ2hWPrcinA9oU4wtf2biUaEH5065UnMeR33oA==", + "dev": true, + "requires": { + "safe-buffer": "~5.1.1" + } + }, + "debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, + "json5": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/json5/-/json5-2.1.3.tgz", + "integrity": "sha512-KXPvOm8K9IJKFM0bmdn8QXh7udDh1g/giieX0NLCaMnb4hEiVFqnop2ImTXCc5e0/oHz3LTqmHGtExn5hfMkOA==", + "dev": true, + "requires": { + "minimist": "^1.2.5" } }, - "esprima": { - "version": "2.7.3", - "resolved": "https://registry.npmjs.org/esprima/-/esprima-2.7.3.tgz", - "integrity": "sha1-luO3DVd59q1JzQMmc9HDEnZ7pYE=", + "lodash": { + "version": "4.17.15", + "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.15.tgz", + "integrity": "sha512-8xOcRHvCjnocdS5cpwXQXVzmmh5e5+saE2QGoeQmbKmRS6J3VQppPOIt0MnmE+4xlZoumy0GPG0D0MVIQbNA1A==", "dev": true }, - "esutils": { - "version": "2.0.2", - "resolved": "https://registry.npmjs.org/esutils/-/esutils-2.0.2.tgz", - "integrity": "sha1-Cr9PHKpbyx96nYrMbepPqqBLrJs=", + "minimist": { + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.5.tgz", + "integrity": "sha512-FM9nNUYrRBAELZQT3xeZQ7fmMOBg6nWNmJKTcgsJeaLstP/UODVpGsr5OhXhhXg6f+qtJ8uiZ+PUxkDWcgIXLw==", + "dev": true + }, + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", "dev": true }, - "fast-levenshtein": { - "version": "2.0.6", - "resolved": "https://registry.npmjs.org/fast-levenshtein/-/fast-levenshtein-2.0.6.tgz", - "integrity": "sha1-PYpcZog6FqMMqGQ+hR8Zuqd5eRc=", + "source-map": { + "version": "0.5.7", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", + "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", "dev": true + } + } + }, + "istanbul-lib-processinfo": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/istanbul-lib-processinfo/-/istanbul-lib-processinfo-2.0.2.tgz", + "integrity": "sha512-kOwpa7z9hme+IBPZMzQ5vdQj8srYgAtaRqeI48NGmAQ+/5yKiHLV0QbYqQpxsdEF0+w14SoB8YbnHKcXE2KnYw==", + "dev": true, + "requires": { + "archy": "^1.0.0", + "cross-spawn": "^7.0.0", + "istanbul-lib-coverage": "^3.0.0-alpha.1", + "make-dir": "^3.0.0", + "p-map": "^3.0.0", + "rimraf": "^3.0.0", + "uuid": "^3.3.3" + }, + "dependencies": { + "cross-spawn": { + "version": "7.0.3", + "resolved": "https://registry.npmjs.org/cross-spawn/-/cross-spawn-7.0.3.tgz", + "integrity": "sha512-iRDPJKUPVEND7dHPO8rkbOnPpyDygcDFtWjpeWNCgy8WP2rXcxXL8TskReQl6OrB2G7+UJrags1q15Fudc7G6w==", + "dev": true, + "requires": { + "path-key": "^3.1.0", + "shebang-command": "^2.0.0", + "which": "^2.0.1" + } }, "glob": { - "version": "5.0.15", - "resolved": "https://registry.npmjs.org/glob/-/glob-5.0.15.tgz", - "integrity": "sha1-G8k2ueAvSmA/zCIuz3Yz0wuLk7E=", + "version": "7.1.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", + "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", "dev": true, "requires": { + "fs.realpath": "^1.0.0", "inflight": "^1.0.4", "inherits": "2", - "minimatch": "2 || 3", + "minimatch": "^3.0.4", "once": "^1.3.0", "path-is-absolute": "^1.0.0" } }, - "handlebars": { - "version": "4.1.2", - "resolved": "https://registry.npmjs.org/handlebars/-/handlebars-4.1.2.tgz", - "integrity": "sha512-nvfrjqvt9xQ8Z/w0ijewdD/vvWDTOweBUm96NTr66Wfvo1mJenBLwcYmPs3TIBP5ruzYGD7Hx/DaM9RmhroGPw==", + "make-dir": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", + "integrity": "sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==", "dev": true, "requires": { - "neo-async": "^2.6.0", - "optimist": "^0.6.1", - "source-map": "^0.6.1", - "uglify-js": "^3.1.4" - }, - "dependencies": { - "source-map": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", - "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", - "dev": true - } + "semver": "^6.0.0" } }, - "levn": { - "version": "0.3.0", - "resolved": "https://registry.npmjs.org/levn/-/levn-0.3.0.tgz", - "integrity": "sha1-OwmSTt+fCDwEkP3UwLxEIeBHZO4=", + "path-key": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/path-key/-/path-key-3.1.1.tgz", + "integrity": "sha512-ojmeN0qd+y0jszEtoY48r0Peq5dwMEkIlCOu6Q5f41lfkswXuKtYrhgoTpLnyIcHm24Uhqx+5Tqm2InSwLhE6Q==", + "dev": true + }, + "rimraf": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", + "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", "dev": true, "requires": { - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2" + "glob": "^7.1.3" } }, - "optionator": { - "version": "0.8.2", - "resolved": "https://registry.npmjs.org/optionator/-/optionator-0.8.2.tgz", - "integrity": "sha1-NkxeQJ0/TWMB1sC0wFu6UBgK62Q=", + "semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true + }, + "shebang-command": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/shebang-command/-/shebang-command-2.0.0.tgz", + "integrity": "sha512-kHxr2zZpYtdmrN1qDjrrX/Z1rR1kG8Dx+gkpK1G4eXmvXswmcE1hTWBWYUzlraYw1/yZp6YuDY77YtvbN0dmDA==", "dev": true, "requires": { - "deep-is": "~0.1.3", - "fast-levenshtein": "~2.0.4", - "levn": "~0.3.0", - "prelude-ls": "~1.1.2", - "type-check": "~0.3.2", - "wordwrap": "~1.0.0" + "shebang-regex": "^3.0.0" } }, - "resolve": { - "version": "1.1.7", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.1.7.tgz", - "integrity": "sha1-IDEU2CrSxe2ejgQRs5ModeiJ6Xs=", + "shebang-regex": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/shebang-regex/-/shebang-regex-3.0.0.tgz", + "integrity": "sha512-7++dFhtcx3353uBaq8DDR4NuxBetBzC7ZQOhmTQInHEd6bSrXdiEyzCvG07Z44UYdLShWUyXt5M/yhz8ekcb1A==", "dev": true }, - "source-map": { - "version": "0.2.0", - "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.2.0.tgz", - "integrity": "sha1-2rc/vPwrqBm03gO9b26qSBZLP50=", + "which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", "dev": true, - "optional": true, "requires": { - "amdefine": ">=0.0.4" + "isexe": "^2.0.0" + } + } + } + }, + "istanbul-lib-report": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/istanbul-lib-report/-/istanbul-lib-report-3.0.0.tgz", + "integrity": "sha512-wcdi+uAKzfiGT2abPpKZ0hSU1rGQjUQnLvtY5MpQ7QCTahD3VODhcu4wcfY1YtkGaDD5yuydOLINXsfbus9ROw==", + "dev": true, + "requires": { + "istanbul-lib-coverage": "^3.0.0", + "make-dir": "^3.0.0", + "supports-color": "^7.1.0" + }, + "dependencies": { + "has-flag": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz", + "integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==", + "dev": true + }, + "make-dir": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", + "integrity": "sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==", + "dev": true, + "requires": { + "semver": "^6.0.0" } }, + "semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true + }, "supports-color": { - "version": "3.2.3", - "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-3.2.3.tgz", - "integrity": "sha1-ZawFBLOVQXHYpklGsq48u4pfVPY=", + "version": "7.1.0", + "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.1.0.tgz", + "integrity": "sha512-oRSIpR8pxT1Wr2FquTNnGet79b3BWljqOuoW/h4oBhxJ/HUbX5nX6JSruTkvXDCFMwDPvsaTTbvMLKZWSy0R5g==", "dev": true, "requires": { - "has-flag": "^1.0.0" + "has-flag": "^4.0.0" + } + } + } + }, + "istanbul-lib-source-maps": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/istanbul-lib-source-maps/-/istanbul-lib-source-maps-4.0.0.tgz", + "integrity": "sha512-c16LpFRkR8vQXyHZ5nLpY35JZtzj1PQY1iZmesUbf1FZHbIupcWfjgOXBY9YHkLEQ6puz1u4Dgj6qmU/DisrZg==", + "dev": true, + "requires": { + "debug": "^4.1.1", + "istanbul-lib-coverage": "^3.0.0", + "source-map": "^0.6.1" + }, + "dependencies": { + "debug": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/debug/-/debug-4.1.1.tgz", + "integrity": "sha512-pYAIzeRo8J6KPEaJ0VWOh5Pzkbw/RetuzehGM7QRRX5he4fPHx2rdKMB256ehJCkX+XRQm16eZLqLNS8RSZXZw==", + "dev": true, + "requires": { + "ms": "^2.1.1" } }, - "wordwrap": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/wordwrap/-/wordwrap-1.0.0.tgz", - "integrity": "sha1-J1hIEIkUVqQXHI0CJkQa3pDLyus=", + "ms": { + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz", + "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==", + "dev": true + }, + "source-map": { + "version": "0.6.1", + "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz", + "integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==", "dev": true } } }, + "istanbul-reports": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/istanbul-reports/-/istanbul-reports-3.0.2.tgz", + "integrity": "sha512-9tZvz7AiR3PEDNGiV9vIouQ/EAcqMXFmkcA1CDFTwOB98OZVDL0PH9glHotf5Ugp6GCOTypfzGWI/OqjWNCRUw==", + "dev": true, + "requires": { + "html-escaper": "^2.0.0", + "istanbul-lib-report": "^3.0.0" + } + }, "jest-worker": { "version": "24.6.0", "resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-24.6.0.tgz", @@ -6165,6 +6917,7 @@ "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-3.2.2.tgz", "integrity": "sha1-MeohpzS6ubuw8yRm2JOupR5KPGQ=", "dev": true, + "optional": true, "requires": { "is-buffer": "^1.1.5" } @@ -6215,9 +6968,9 @@ } }, "linkify-it": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-2.1.0.tgz", - "integrity": "sha512-4REs8/062kV2DSHxNfq5183zrqXMl7WP0WzABH9IeJI+NLm429FgE1PDecltYfnOoFDFlZGh2T8PfZn0r+GTRg==", + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/linkify-it/-/linkify-it-2.2.0.tgz", + "integrity": "sha512-GnAl/knGn+i1U/wjBz3akz2stz+HrHLsxMwHQGofCDfPvlf+gDKN58UtfmUquTY4/MXeE2x7k19KQmeoZi94Iw==", "dev": true, "requires": { "uc.micro": "^1.0.1" @@ -6304,6 +7057,12 @@ "lodash._isiterateecall": "^3.0.0" } }, + "lodash.flattendeep": { + "version": "4.4.0", + "resolved": "https://registry.npmjs.org/lodash.flattendeep/-/lodash.flattendeep-4.4.0.tgz", + "integrity": "sha1-+wMJF/hqMTTlvJvsDWngAT3f7bI=", + "dev": true + }, "lodash.isarguments": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/lodash.isarguments/-/lodash.isarguments-3.1.0.tgz", @@ -6375,13 +7134,15 @@ "version": "0.2.2", "resolved": "https://registry.npmjs.org/map-cache/-/map-cache-0.2.2.tgz", "integrity": "sha1-wyq9C9ZSXZsFFkW7TyasXcmKDb8=", - "dev": true + "dev": true, + "optional": true }, "map-visit": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/map-visit/-/map-visit-1.0.0.tgz", "integrity": "sha1-7Nyo8TFE5mDxtb1B8S80edmN+48=", "dev": true, + "optional": true, "requires": { "object-visit": "^1.0.0" } @@ -6589,6 +7350,7 @@ "resolved": "https://registry.npmjs.org/mixin-deep/-/mixin-deep-1.3.2.tgz", "integrity": "sha512-WRoDn//mXBiJ1H40rqa3vH0toePwSsGb45iInWlTySa+Uu4k3tYUSxa2v1KqAiLtvlrSzaExqS1gtk96A9zvEA==", "dev": true, + "optional": true, "requires": { "for-in": "^1.0.2", "is-extendable": "^1.0.1" @@ -6599,6 +7361,7 @@ "resolved": "https://registry.npmjs.org/is-extendable/-/is-extendable-1.0.1.tgz", "integrity": "sha512-arnXMxT1hhoKo9k1LZdmlNyJdDDfy2v0fXjFlmok4+i8ul/6WlbVge9bhM74OpNPQPMGUToDtz+KXa1PneJxOA==", "dev": true, + "optional": true, "requires": { "is-plain-object": "^2.0.4" } @@ -6841,6 +7604,7 @@ "resolved": "https://registry.npmjs.org/nanomatch/-/nanomatch-1.2.13.tgz", "integrity": "sha512-fpoe2T0RbHwBTBUOftAfBPaDEi06ufaUai0mE6Yn1kacc3SnTErfb/h+X94VXzI64rKFHYImXSvdwGGCmwOqCA==", "dev": true, + "optional": true, "requires": { "arr-diff": "^4.0.0", "array-unique": "^0.3.2", @@ -6859,19 +7623,22 @@ "version": "4.0.0", "resolved": "https://registry.npmjs.org/arr-diff/-/arr-diff-4.0.0.tgz", "integrity": "sha1-1kYQdP6/7HHn4VI1dhoyml3HxSA=", - "dev": true + "dev": true, + "optional": true }, "array-unique": { "version": "0.3.2", "resolved": "https://registry.npmjs.org/array-unique/-/array-unique-0.3.2.tgz", "integrity": "sha1-qJS3XUvE9s1nnvMkSp/Y9Gri1Cg=", - "dev": true + "dev": true, + "optional": true }, "kind-of": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", - "dev": true + "dev": true, + "optional": true } } }, @@ -6957,6 +7724,15 @@ "which": "^1.3.0" } }, + "node-preload": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/node-preload/-/node-preload-0.2.1.tgz", + "integrity": "sha512-RM5oyBy45cLEoHqCeh+MNuFAxO0vTFBLskvQbOKnEE7YTTSN4tbN8QWDIPQ6L+WvKsB/qLEGpYe2ZZ9d4W9OIQ==", + "dev": true, + "requires": { + "process-on-spawn": "^1.0.0" + } + }, "node-releases": { "version": "1.1.41", "resolved": "https://registry.npmjs.org/node-releases/-/node-releases-1.1.41.tgz", @@ -6974,15 +7750,6 @@ } } }, - "nopt": { - "version": "3.0.6", - "resolved": "https://registry.npmjs.org/nopt/-/nopt-3.0.6.tgz", - "integrity": "sha1-xkZdvwirzU2zWTF/eaxopkayj/k=", - "dev": true, - "requires": { - "abbrev": "1" - } - }, "npm-run-path": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz", @@ -7004,12 +7771,161 @@ "set-blocking": "~2.0.0" } }, - "number-is-nan": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", - "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", - "dev": true - }, + "number-is-nan": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/number-is-nan/-/number-is-nan-1.0.1.tgz", + "integrity": "sha1-CXtgK1NCKlIsGvuHkDGDNpQaAR0=", + "dev": true + }, + "nyc": { + "version": "15.0.1", + "resolved": "https://registry.npmjs.org/nyc/-/nyc-15.0.1.tgz", + "integrity": "sha512-n0MBXYBYRqa67IVt62qW1r/d9UH/Qtr7SF1w/nQLJ9KxvWF6b2xCHImRAixHN9tnMMYHC2P14uo6KddNGwMgGg==", + "dev": true, + "requires": { + "@istanbuljs/load-nyc-config": "^1.0.0", + "@istanbuljs/schema": "^0.1.2", + "caching-transform": "^4.0.0", + "convert-source-map": "^1.7.0", + "decamelize": "^1.2.0", + "find-cache-dir": "^3.2.0", + "find-up": "^4.1.0", + "foreground-child": "^2.0.0", + "glob": "^7.1.6", + "istanbul-lib-coverage": "^3.0.0", + "istanbul-lib-hook": "^3.0.0", + "istanbul-lib-instrument": "^4.0.0", + "istanbul-lib-processinfo": "^2.0.2", + "istanbul-lib-report": "^3.0.0", + "istanbul-lib-source-maps": "^4.0.0", + "istanbul-reports": "^3.0.2", + "make-dir": "^3.0.0", + "node-preload": "^0.2.1", + "p-map": "^3.0.0", + "process-on-spawn": "^1.0.0", + "resolve-from": "^5.0.0", + "rimraf": "^3.0.0", + "signal-exit": "^3.0.2", + "spawn-wrap": "^2.0.0", + "test-exclude": "^6.0.0", + "yargs": "^15.0.2" + }, + "dependencies": { + "commondir": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/commondir/-/commondir-1.0.1.tgz", + "integrity": "sha1-3dgA2gxmEnOTzKWVDqloo6rxJTs=", + "dev": true + }, + "convert-source-map": { + "version": "1.7.0", + "resolved": "https://registry.npmjs.org/convert-source-map/-/convert-source-map-1.7.0.tgz", + "integrity": "sha512-4FJkXzKXEDB1snCFZlLP4gpC3JILicCpGbzG9f9G7tGqGCzETQ2hWPrcinA9oU4wtf2biUaEH5065UnMeR33oA==", + "dev": true, + "requires": { + "safe-buffer": "~5.1.1" + } + }, + "find-cache-dir": { + "version": "3.3.1", + "resolved": "https://registry.npmjs.org/find-cache-dir/-/find-cache-dir-3.3.1.tgz", + "integrity": "sha512-t2GDMt3oGC/v+BMwzmllWDuJF/xcDtE5j/fCGbqDD7OLuJkj0cfh1YSA5VKPvwMeLFLNDBkwOKZ2X85jGLVftQ==", + "dev": true, + "requires": { + "commondir": "^1.0.1", + "make-dir": "^3.0.2", + "pkg-dir": "^4.1.0" + } + }, + "find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "dev": true, + "requires": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + } + }, + "glob": { + "version": "7.1.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", + "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "dev": true, + "requires": { + "p-locate": "^4.1.0" + } + }, + "make-dir": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", + "integrity": "sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==", + "dev": true, + "requires": { + "semver": "^6.0.0" + } + }, + "p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "dev": true, + "requires": { + "p-limit": "^2.2.0" + } + }, + "path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true + }, + "pkg-dir": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-4.2.0.tgz", + "integrity": "sha512-HRDzbaKjC+AOWVXxAU/x54COGeIv9eb+6CkDSQoNTt4XyWoIJvuPsXizxu/Fr23EiekbtZwmh1IcIG/l/a10GQ==", + "dev": true, + "requires": { + "find-up": "^4.0.0" + } + }, + "resolve-from": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/resolve-from/-/resolve-from-5.0.0.tgz", + "integrity": "sha512-qYg9KP24dD5qka9J47d0aVky0N+b4fTU89LN9iDnjB5waksiC49rvMB0PrUJQGoTmH50XPiqOvAjDfaijGxYZw==", + "dev": true + }, + "rimraf": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", + "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", + "dev": true, + "requires": { + "glob": "^7.1.3" + } + }, + "semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true + } + } + }, "object-assign": { "version": "4.1.1", "resolved": "https://registry.npmjs.org/object-assign/-/object-assign-4.1.1.tgz", @@ -7027,6 +7943,7 @@ "resolved": "https://registry.npmjs.org/object-copy/-/object-copy-0.1.0.tgz", "integrity": "sha1-fn2Fi3gb18mRpBupde04EnVOmYw=", "dev": true, + "optional": true, "requires": { "copy-descriptor": "^0.1.0", "define-property": "^0.2.5", @@ -7038,6 +7955,7 @@ "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", "dev": true, + "optional": true, "requires": { "is-descriptor": "^0.1.0" } @@ -7055,6 +7973,7 @@ "resolved": "https://registry.npmjs.org/object-visit/-/object-visit-1.0.1.tgz", "integrity": "sha1-95xEk68MU3e1n+OdOV5BBC3QRbs=", "dev": true, + "optional": true, "requires": { "isobject": "^3.0.0" }, @@ -7063,7 +7982,8 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true + "dev": true, + "optional": true } } }, @@ -7094,6 +8014,7 @@ "resolved": "https://registry.npmjs.org/object.pick/-/object.pick-1.3.0.tgz", "integrity": "sha1-h6EKxMFpS9Lhy/U1kaZhQftd10c=", "dev": true, + "optional": true, "requires": { "isobject": "^3.0.1" }, @@ -7102,7 +8023,8 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true + "dev": true, + "optional": true } } }, @@ -7232,12 +8154,41 @@ "p-limit": "^2.0.0" } }, + "p-map": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/p-map/-/p-map-3.0.0.tgz", + "integrity": "sha512-d3qXVTF/s+W+CdJ5A29wywV2n8CQQYahlgz2bFiA+4eVNJbHJodPZ+/gXwPGh0bOqA+j8S+6+ckmvLGPk1QpxQ==", + "dev": true, + "requires": { + "aggregate-error": "^3.0.0" + } + }, "p-try": { "version": "2.2.0", "resolved": "https://registry.npmjs.org/p-try/-/p-try-2.2.0.tgz", "integrity": "sha512-R4nPAVTAU0B9D35/Gk3uJf/7XYbQcyohSKdvAxIRSNghFl4e71hVoGnBNQz9cWaXxO2I10KTC+3jMdvvoKw6dQ==", "dev": true }, + "package-hash": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/package-hash/-/package-hash-4.0.0.tgz", + "integrity": "sha512-whdkPIooSu/bASggZ96BWVvZTRMOFxnyUG5PnTSGKoJE2gd5mbVNmR2Nj20QFzxYYgAXpoqC+AiXzl+UMRh7zQ==", + "dev": true, + "requires": { + "graceful-fs": "^4.1.15", + "hasha": "^5.0.0", + "lodash.flattendeep": "^4.4.0", + "release-zalgo": "^1.0.0" + }, + "dependencies": { + "graceful-fs": { + "version": "4.2.4", + "resolved": "https://registry.npmjs.org/graceful-fs/-/graceful-fs-4.2.4.tgz", + "integrity": "sha512-WjKPNJF79dtJAVniUlGGWHYGz2jWxT6VhN/4m1NdkbZ2nOsEF+cI1Edgql5zCRhs/VsQYRvrXctxktVXZUkixw==", + "dev": true + } + } + }, "pako": { "version": "0.2.9", "resolved": "https://registry.npmjs.org/pako/-/pako-0.2.9.tgz", @@ -7303,7 +8254,8 @@ "version": "0.1.1", "resolved": "https://registry.npmjs.org/pascalcase/-/pascalcase-0.1.1.tgz", "integrity": "sha1-s2PlXoAGym/iF4TS2yK9FdeRfxQ=", - "dev": true + "dev": true, + "optional": true }, "path-browserify": { "version": "0.0.1", @@ -7404,7 +8356,8 @@ "version": "0.1.1", "resolved": "https://registry.npmjs.org/posix-character-classes/-/posix-character-classes-0.1.1.tgz", "integrity": "sha1-AerA/jta9xoqbAL+q7jB/vfgDqs=", - "dev": true + "dev": true, + "optional": true }, "prelude-ls": { "version": "1.1.2", @@ -7436,6 +8389,15 @@ "integrity": "sha512-MtEC1TqN0EU5nephaJ4rAtThHtC86dNN9qCuEhtshvpVBkAW5ZO7BASN9REnF9eoXGcRub+pFuKEpOHE+HbEMw==", "dev": true }, + "process-on-spawn": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/process-on-spawn/-/process-on-spawn-1.0.0.tgz", + "integrity": "sha512-1WsPDsUSMmZH5LeMLegqkPDrsGgsWwk1Exipy2hvB0o/F0ASzbpIctSCcZIK1ykJvtTJULEH+20WOFjMvGnCTg==", + "dev": true, + "requires": { + "fromentries": "^1.2.0" + } + }, "progress": { "version": "2.0.3", "resolved": "https://registry.npmjs.org/progress/-/progress-2.0.3.tgz", @@ -7601,6 +8563,7 @@ "resolved": "https://registry.npmjs.org/regex-not/-/regex-not-1.0.2.tgz", "integrity": "sha512-J6SDjUgDxQj5NusnOtdFxDwN/+HWykR8GELwctJ7mdqhcyy1xEc4SRFHUXvxTp661YaVKAjfRLZ9cCqS6tn32A==", "dev": true, + "optional": true, "requires": { "extend-shallow": "^3.0.2", "safe-regex": "^1.1.0" @@ -7649,6 +8612,15 @@ } } }, + "release-zalgo": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/release-zalgo/-/release-zalgo-1.0.0.tgz", + "integrity": "sha1-CXALflB0Mpc5Mw5TXFqQ+2eFFzA=", + "dev": true, + "requires": { + "es6-error": "^4.0.1" + } + }, "remove-trailing-separator": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/remove-trailing-separator/-/remove-trailing-separator-1.1.0.tgz", @@ -7660,13 +8632,15 @@ "version": "1.1.2", "resolved": "https://registry.npmjs.org/repeat-element/-/repeat-element-1.1.2.tgz", "integrity": "sha1-7wiaF40Ug7quTZPrmLT55OEdmQo=", - "dev": true + "dev": true, + "optional": true }, "repeat-string": { "version": "1.6.1", "resolved": "https://registry.npmjs.org/repeat-string/-/repeat-string-1.6.1.tgz", "integrity": "sha1-jcrkcOHIirwtYA//Sndihtp15jc=", - "dev": true + "dev": true, + "optional": true }, "require-directory": { "version": "2.1.1", @@ -7705,7 +8679,8 @@ "version": "0.2.1", "resolved": "https://registry.npmjs.org/resolve-url/-/resolve-url-0.2.1.tgz", "integrity": "sha1-LGN/53yJOv0qZj/iGqkIAGjiBSo=", - "dev": true + "dev": true, + "optional": true }, "restore-cursor": { "version": "2.0.0", @@ -7721,7 +8696,8 @@ "version": "0.1.15", "resolved": "https://registry.npmjs.org/ret/-/ret-0.1.15.tgz", "integrity": "sha512-TTlYpa+OL+vMMNG24xSlQGEJ3B/RzEfUlLct7b5G/ytav+wPrplCpVMFuwzXbkecJrb6IYo1iFb0S9v37754mg==", - "dev": true + "dev": true, + "optional": true }, "rimraf": { "version": "2.6.3", @@ -7828,6 +8804,7 @@ "resolved": "https://registry.npmjs.org/safe-regex/-/safe-regex-1.1.0.tgz", "integrity": "sha1-QKNmnzsHfR6UPURinhV91IAjvy4=", "dev": true, + "optional": true, "requires": { "ret": "~0.1.10" } @@ -7919,6 +8896,7 @@ "resolved": "https://registry.npmjs.org/set-value/-/set-value-2.0.1.tgz", "integrity": "sha512-JxHc1weCN68wRY0fhCoXpyK55m/XPHafOmK4UWD7m2CI14GMcFypt4w/0+NV5f/ZMby2F6S2wwA7fgynh9gWSw==", "dev": true, + "optional": true, "requires": { "extend-shallow": "^2.0.1", "is-extendable": "^0.1.1", @@ -7931,6 +8909,7 @@ "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, + "optional": true, "requires": { "is-extendable": "^0.1.0" } @@ -8033,6 +9012,7 @@ "resolved": "https://registry.npmjs.org/snapdragon/-/snapdragon-0.8.2.tgz", "integrity": "sha512-FtyOnWN/wCHTVXOMwvSv26d+ko5vWlIDD6zoUJ7LW8vh+ZBC8QdljveRP+crNrtBwioEUWy/4dMtbBjA4ioNlg==", "dev": true, + "optional": true, "requires": { "base": "^0.11.1", "debug": "^2.2.0", @@ -8049,6 +9029,7 @@ "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", "dev": true, + "optional": true, "requires": { "is-descriptor": "^0.1.0" } @@ -8058,6 +9039,7 @@ "resolved": "https://registry.npmjs.org/extend-shallow/-/extend-shallow-2.0.1.tgz", "integrity": "sha1-Ua99YUrZqfYQ6huvu5idaxxWiQ8=", "dev": true, + "optional": true, "requires": { "is-extendable": "^0.1.0" } @@ -8066,7 +9048,8 @@ "version": "0.5.7", "resolved": "https://registry.npmjs.org/source-map/-/source-map-0.5.7.tgz", "integrity": "sha1-igOdLRAh0i0eoUyA2OpGi6LvP8w=", - "dev": true + "dev": true, + "optional": true } } }, @@ -8075,6 +9058,7 @@ "resolved": "https://registry.npmjs.org/snapdragon-node/-/snapdragon-node-2.1.1.tgz", "integrity": "sha512-O27l4xaMYt/RSQ5TR3vpWCAB5Kb/czIcqUFOM/C4fYcLnbZUc1PkjTAMjof2pBWaSTwOUd6qUHcFGVGj7aIwnw==", "dev": true, + "optional": true, "requires": { "define-property": "^1.0.0", "isobject": "^3.0.0", @@ -8086,6 +9070,7 @@ "resolved": "https://registry.npmjs.org/define-property/-/define-property-1.0.0.tgz", "integrity": "sha1-dp66rz9KY6rTr56NMEybvnm/sOY=", "dev": true, + "optional": true, "requires": { "is-descriptor": "^1.0.0" } @@ -8095,6 +9080,7 @@ "resolved": "https://registry.npmjs.org/is-accessor-descriptor/-/is-accessor-descriptor-1.0.0.tgz", "integrity": "sha512-m5hnHTkcVsPfqx3AKlyttIPb7J+XykHvJP2B9bZDjlhLIoEq4XoK64Vg7boZlVWYK6LUY94dYPEE7Lh0ZkZKcQ==", "dev": true, + "optional": true, "requires": { "kind-of": "^6.0.0" } @@ -8104,6 +9090,7 @@ "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-1.0.0.tgz", "integrity": "sha512-jbRXy1FmtAoCjQkVmIVYwuuqDFUbaOeDjmed1tOGPrsMhtJA4rD9tkgA0F1qJ3gRFRXcHYVkdeaP50Q5rE/jLQ==", "dev": true, + "optional": true, "requires": { "kind-of": "^6.0.0" } @@ -8113,6 +9100,7 @@ "resolved": "https://registry.npmjs.org/is-descriptor/-/is-descriptor-1.0.2.tgz", "integrity": "sha512-2eis5WqQGV7peooDyLmNEPUrps9+SXX5c9pL3xEB+4e9HnGuDa7mB7kHxHw4CbqS9k1T2hOH3miL8n8WtiYVtg==", "dev": true, + "optional": true, "requires": { "is-accessor-descriptor": "^1.0.0", "is-data-descriptor": "^1.0.0", @@ -8123,13 +9111,15 @@ "version": "3.0.1", "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true + "dev": true, + "optional": true }, "kind-of": { "version": "6.0.2", "resolved": "https://registry.npmjs.org/kind-of/-/kind-of-6.0.2.tgz", "integrity": "sha512-s5kLOcnH0XqDO+FvuaLX8DDjZ18CGFk7VygH40QoKPUQhW4e2rvM0rwUq0t8IQDOwYSeLK01U90OjzBTme2QqA==", - "dev": true + "dev": true, + "optional": true } } }, @@ -8138,6 +9128,7 @@ "resolved": "https://registry.npmjs.org/snapdragon-util/-/snapdragon-util-3.0.1.tgz", "integrity": "sha512-mbKkMdQKsjX4BAL4bRYTj21edOf8cN7XHdYUJEe+Zn99hVEYcMvKPct1IqNe7+AZPirn8BCDOQBHQZknqmKlZQ==", "dev": true, + "optional": true, "requires": { "kind-of": "^3.2.0" } @@ -8254,6 +9245,7 @@ "resolved": "https://registry.npmjs.org/source-map-resolve/-/source-map-resolve-0.5.2.tgz", "integrity": "sha512-MjqsvNwyz1s0k81Goz/9vRBe9SZdB09Bdw+/zYyO+3CuPk6fouTaxscHkgtE8jKvf01kVfl8riHzERQ/kefaSA==", "dev": true, + "optional": true, "requires": { "atob": "^2.1.1", "decode-uri-component": "^0.2.0", @@ -8284,7 +9276,8 @@ "version": "0.4.0", "resolved": "https://registry.npmjs.org/source-map-url/-/source-map-url-0.4.0.tgz", "integrity": "sha1-PpNdfd1zYxuXZZlW1VEo6HtQhKM=", - "dev": true + "dev": true, + "optional": true }, "spawn-args": { "version": "0.2.0", @@ -8292,11 +9285,75 @@ "integrity": "sha1-+30L0dcP1DFr2ePew4nmX51jYbs=", "dev": true }, + "spawn-wrap": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/spawn-wrap/-/spawn-wrap-2.0.0.tgz", + "integrity": "sha512-EeajNjfN9zMnULLwhZZQU3GWBoFNkbngTUPfaawT4RkMiviTxcX0qfhVbGey39mfctfDHkWtuecgQ8NJcyQWHg==", + "dev": true, + "requires": { + "foreground-child": "^2.0.0", + "is-windows": "^1.0.2", + "make-dir": "^3.0.0", + "rimraf": "^3.0.0", + "signal-exit": "^3.0.2", + "which": "^2.0.1" + }, + "dependencies": { + "glob": { + "version": "7.1.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", + "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "make-dir": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/make-dir/-/make-dir-3.1.0.tgz", + "integrity": "sha512-g3FeP20LNwhALb/6Cz6Dd4F2ngze0jz7tbzrD2wAV+o9FeNHe4rL+yK2md0J/fiSf1sa1ADhXqi5+oVwOM/eGw==", + "dev": true, + "requires": { + "semver": "^6.0.0" + } + }, + "rimraf": { + "version": "3.0.2", + "resolved": "https://registry.npmjs.org/rimraf/-/rimraf-3.0.2.tgz", + "integrity": "sha512-JZkJMZkAGFFPP2YqXZXPbMlMBgsxzE8ILs4lMIX/2o0L9UBw9O/Y3o6wFw/i9YLapcUJWwqbi3kdxIPdC62TIA==", + "dev": true, + "requires": { + "glob": "^7.1.3" + } + }, + "semver": { + "version": "6.3.0", + "resolved": "https://registry.npmjs.org/semver/-/semver-6.3.0.tgz", + "integrity": "sha512-b39TBaTSfV6yBrapU89p5fKekE2m/NwnDocOVruQFS1/veMgdzuPcnOM34M6CwxW8jH/lxEa5rBoDeUwu5HHTw==", + "dev": true + }, + "which": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/which/-/which-2.0.2.tgz", + "integrity": "sha512-BLI3Tl1TW3Pvl70l3yq3Y64i+awpwXqsGBYWkkqMtnbXgrMD+yj7rhW0kuEDxzJaYXGjEW5ogapKNMEKNMjibA==", + "dev": true, + "requires": { + "isexe": "^2.0.0" + } + } + } + }, "split-string": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz", "integrity": "sha512-NzNVhJDYpwceVVii8/Hu6DKfD2G+NrQHlS/V/qgv763EYudVwEcMQNxd2lh+0VrUByXN/oJkl5grOhYWvQUYiw==", "dev": true, + "optional": true, "requires": { "extend-shallow": "^3.0.0" } @@ -8312,6 +9369,7 @@ "resolved": "https://registry.npmjs.org/static-extend/-/static-extend-0.1.2.tgz", "integrity": "sha1-YICcOcv/VTNyJv1eC1IPNB8ftcY=", "dev": true, + "optional": true, "requires": { "define-property": "^0.2.5", "object-copy": "^0.1.0" @@ -8322,6 +9380,7 @@ "resolved": "https://registry.npmjs.org/define-property/-/define-property-0.2.5.tgz", "integrity": "sha1-w1se+RjsPJkPmlvFe+BKrOxcgRY=", "dev": true, + "optional": true, "requires": { "is-descriptor": "^0.1.0" } @@ -8423,6 +9482,12 @@ "ansi-regex": "^3.0.0" } }, + "strip-bom": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-4.0.0.tgz", + "integrity": "sha512-3xurFv5tEgii33Zi8Jtp55wEIILR9eh34FAW00PZf+JnSsTmV/ioewSgQl97JHvgjoRGwPShsWm+IdrxB35d0w==", + "dev": true + }, "strip-eof": { "version": "1.0.0", "resolved": "http://registry.npmjs.org/strip-eof/-/strip-eof-1.0.0.tgz", @@ -8533,6 +9598,33 @@ "minipass": "^2.2.0" } }, + "test-exclude": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/test-exclude/-/test-exclude-6.0.0.tgz", + "integrity": "sha512-cAGWPIyOHU6zlmg88jwm7VRyXnMN7iV68OGAbYDk/Mh/xC/pzVPlQtY6ngoIH/5/tciuhGfvESU8GrHrcxD56w==", + "dev": true, + "requires": { + "@istanbuljs/schema": "^0.1.2", + "glob": "^7.1.4", + "minimatch": "^3.0.4" + }, + "dependencies": { + "glob": { + "version": "7.1.6", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.6.tgz", + "integrity": "sha512-LwaxwyZ72Lk7vZINtNNrywX0ZuLyStrdDtabefZKAY5ZGJhVtgdznluResxNmPitE0SAO+O26sWTHeKSI2wMBA==", + "dev": true, + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + } + } + }, "testem": { "version": "2.16.0", "resolved": "https://registry.npmjs.org/testem/-/testem-2.16.0.tgz", @@ -8650,6 +9742,7 @@ "resolved": "https://registry.npmjs.org/to-object-path/-/to-object-path-0.3.0.tgz", "integrity": "sha1-KXWIt7Dn4KwI4E5nL4XB9JmeF68=", "dev": true, + "optional": true, "requires": { "kind-of": "^3.0.2" } @@ -8659,6 +9752,7 @@ "resolved": "https://registry.npmjs.org/to-regex/-/to-regex-3.0.2.tgz", "integrity": "sha512-FWtleNAtZ/Ki2qtqej2CXTOayOH9bHDQF+Q48VpWyDXjbYxA4Yz8iDB31zXOBUlOHHKidDbqGVrTUvQMPmBGBw==", "dev": true, + "optional": true, "requires": { "define-property": "^2.0.2", "extend-shallow": "^3.0.2", @@ -8671,6 +9765,7 @@ "resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-2.1.1.tgz", "integrity": "sha1-fIDBe53+vlmeJzZ+DU3VWQFB2zg=", "dev": true, + "optional": true, "requires": { "is-number": "^3.0.0", "repeat-string": "^1.6.1" @@ -8681,6 +9776,7 @@ "resolved": "https://registry.npmjs.org/is-number/-/is-number-3.0.0.tgz", "integrity": "sha1-JP1iAaR4LPUFYcgQJ2r8fRLXEZU=", "dev": true, + "optional": true, "requires": { "kind-of": "^3.0.2" } @@ -8732,6 +9828,12 @@ "integrity": "sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==", "dev": true }, + "type-fest": { + "version": "0.8.1", + "resolved": "https://registry.npmjs.org/type-fest/-/type-fest-0.8.1.tgz", + "integrity": "sha512-4dbzIzqvjtgiM5rw1k5rEHtBANKmdudhGyBEajN01fEyhaAIhsoKNy6y7+IN93IfpFtwY9iqi7kD+xwKhQsNJA==", + "dev": true + }, "type-is": { "version": "1.6.18", "resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.18.tgz", @@ -8748,6 +9850,15 @@ "integrity": "sha1-hnrHTjhkGHsdPUfZlqeOxciDB3c=", "dev": true }, + "typedarray-to-buffer": { + "version": "3.1.5", + "resolved": "https://registry.npmjs.org/typedarray-to-buffer/-/typedarray-to-buffer-3.1.5.tgz", + "integrity": "sha512-zdu8XMNEDepKKR+XYOXAVPtWui0ly0NtohUscw+UmaHiAWT8hrV1rr//H6V+0DvJ3OQ19S979M0laLfX8rm82Q==", + "dev": true, + "requires": { + "is-typedarray": "^1.0.0" + } + }, "typify-parser": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/typify-parser/-/typify-parser-1.1.0.tgz", @@ -8829,6 +9940,7 @@ "resolved": "https://registry.npmjs.org/union-value/-/union-value-1.0.1.tgz", "integrity": "sha512-tJfXmxMeWYnczCVs7XAEvIV7ieppALdyepWMkHkwciRpZraG/xwT+s2JN8+pr1+8jCRf80FFzvr+MpQeeoF4Xg==", "dev": true, + "optional": true, "requires": { "arr-union": "^3.1.0", "get-value": "^2.0.6", @@ -8847,6 +9959,7 @@ "resolved": "https://registry.npmjs.org/unset-value/-/unset-value-1.0.0.tgz", "integrity": "sha1-g3aHP30jNRef+x5vw6jtDfyKtVk=", "dev": true, + "optional": true, "requires": { "has-value": "^0.3.1", "isobject": "^3.0.0" @@ -8857,6 +9970,7 @@ "resolved": "https://registry.npmjs.org/has-value/-/has-value-0.3.1.tgz", "integrity": "sha1-ex9YutpiyoJ+wKIHgCVlSEWZXh8=", "dev": true, + "optional": true, "requires": { "get-value": "^2.0.3", "has-values": "^0.1.4", @@ -8868,6 +9982,7 @@ "resolved": "https://registry.npmjs.org/isobject/-/isobject-2.1.0.tgz", "integrity": "sha1-8GVWEJaj8dou9GJy+BXIQNh+DIk=", "dev": true, + "optional": true, "requires": { "isarray": "1.0.0" } @@ -8878,19 +9993,22 @@ "version": "0.1.4", "resolved": "https://registry.npmjs.org/has-values/-/has-values-0.1.4.tgz", "integrity": "sha1-bWHeldkd/Km5oCCJrThL/49it3E=", - "dev": true + "dev": true, + "optional": true }, "isarray": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "dev": true + "dev": true, + "optional": true }, "isobject": { "version": "3.0.1", "resolved": "https://registry.npmjs.org/isobject/-/isobject-3.0.1.tgz", "integrity": "sha1-TkMekrEalzFjaqH5yNHMvP2reN8=", - "dev": true + "dev": true, + "optional": true } } }, @@ -8922,7 +10040,8 @@ "version": "0.1.0", "resolved": "https://registry.npmjs.org/urix/-/urix-0.1.0.tgz", "integrity": "sha1-2pN/emLiH+wf0Y1Js1wpNQZ6bHI=", - "dev": true + "dev": true, + "optional": true }, "url": { "version": "0.10.3", @@ -8946,7 +10065,8 @@ "version": "3.1.1", "resolved": "https://registry.npmjs.org/use/-/use-3.1.1.tgz", "integrity": "sha512-cwESVXlO3url9YWlFW/TA9cshCEhtu7IKJ/p5soJ/gGpj7vbvFrAY/eIioQ6Dw23KjZhYgiIo8HOs1nQ2vr/oQ==", - "dev": true + "dev": true, + "optional": true }, "util": { "version": "0.10.3", @@ -8977,6 +10097,12 @@ "integrity": "sha1-n5VxD1CiZ5R7LMwSR0HBAoQn5xM=", "dev": true }, + "uuid": { + "version": "3.4.0", + "resolved": "https://registry.npmjs.org/uuid/-/uuid-3.4.0.tgz", + "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", + "dev": true + }, "vary": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", @@ -9084,6 +10210,18 @@ "mkdirp": "^0.5.1" } }, + "write-file-atomic": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/write-file-atomic/-/write-file-atomic-3.0.3.tgz", + "integrity": "sha512-AvHcyZ5JnSfq3ioSyjrBkH9yW4m7Ayk8/9My/DD9onKeu/94fwrMocemO2QAJFAlnnDN+ZDS+ZjAR5ua1/PV/Q==", + "dev": true, + "requires": { + "imurmurhash": "^0.1.4", + "is-typedarray": "^1.0.0", + "signal-exit": "^3.0.2", + "typedarray-to-buffer": "^3.1.5" + } + }, "ws": { "version": "6.1.4", "resolved": "https://registry.npmjs.org/ws/-/ws-6.1.4.tgz", @@ -9129,6 +10267,109 @@ "integrity": "sha512-S+Zk8DEWE6oKpV+vI3qWkaK+jSbIK86pCwe2IF/xwIpQ8jEuxpw9NyaGjmp9+BoJv5FV2piqCDcoCtStppiq2A==", "dev": true }, + "yargs": { + "version": "15.3.1", + "resolved": "https://registry.npmjs.org/yargs/-/yargs-15.3.1.tgz", + "integrity": "sha512-92O1HWEjw27sBfgmXiixJWT5hRBp2eobqXicLtPBIDBhYB+1HpwZlXmbW2luivBJHBzki+7VyCLRtAkScbTBQA==", + "dev": true, + "requires": { + "cliui": "^6.0.0", + "decamelize": "^1.2.0", + "find-up": "^4.1.0", + "get-caller-file": "^2.0.1", + "require-directory": "^2.1.1", + "require-main-filename": "^2.0.0", + "set-blocking": "^2.0.0", + "string-width": "^4.2.0", + "which-module": "^2.0.0", + "y18n": "^4.0.0", + "yargs-parser": "^18.1.1" + }, + "dependencies": { + "ansi-regex": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.0.tgz", + "integrity": "sha512-bY6fj56OUQ0hU1KjFNDQuJFezqKdrAyFdIevADiqrWHwSlbmBNMHp5ak2f40Pm8JTFyM2mqxkG6ngkHO11f/lg==", + "dev": true + }, + "emoji-regex": { + "version": "8.0.0", + "resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz", + "integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==", + "dev": true + }, + "find-up": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-4.1.0.tgz", + "integrity": "sha512-PpOwAdQ/YlXQ2vj8a3h8IipDuYRi3wceVQQGYWxNINccq40Anw7BlsEXCMbt1Zt+OLA6Fq9suIpIWD0OsnISlw==", + "dev": true, + "requires": { + "locate-path": "^5.0.0", + "path-exists": "^4.0.0" + } + }, + "is-fullwidth-code-point": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz", + "integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==", + "dev": true + }, + "locate-path": { + "version": "5.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-5.0.0.tgz", + "integrity": "sha512-t7hw9pI+WvuwNJXwk5zVHpyhIqzg2qTlklJOf0mVxGSbe3Fp2VieZcduNYjaLDoy6p9uGpQEGWG87WpMKlNq8g==", + "dev": true, + "requires": { + "p-locate": "^4.1.0" + } + }, + "p-locate": { + "version": "4.1.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-4.1.0.tgz", + "integrity": "sha512-R79ZZ/0wAxKGu3oYMlz8jy/kbhsNrS7SKZ7PxEHBgJ5+F2mtFW2fK2cOtBh1cHYkQsbzFV7I+EoRKe6Yt0oK7A==", + "dev": true, + "requires": { + "p-limit": "^2.2.0" + } + }, + "path-exists": { + "version": "4.0.0", + "resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz", + "integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==", + "dev": true + }, + "string-width": { + "version": "4.2.0", + "resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.0.tgz", + "integrity": "sha512-zUz5JD+tgqtuDjMhwIg5uFVV3dtqZ9yQJlZVfq4I01/K5Paj5UHj7VyrQOJvzawSVlKpObApbfD0Ed6yJc+1eg==", + "dev": true, + "requires": { + "emoji-regex": "^8.0.0", + "is-fullwidth-code-point": "^3.0.0", + "strip-ansi": "^6.0.0" + } + }, + "strip-ansi": { + "version": "6.0.0", + "resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.0.tgz", + "integrity": "sha512-AuvKTrTfQNYNIctbR1K/YGTR1756GycPsg7b9bdV9Duqur4gv6aKqHXah67Z8ImS7WEz5QVcOtlfW2rZEugt6w==", + "dev": true, + "requires": { + "ansi-regex": "^5.0.0" + } + }, + "yargs-parser": { + "version": "18.1.3", + "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-18.1.3.tgz", + "integrity": "sha512-o50j0JeToy/4K6OZcaQmW6lyXXKhq7csREXcDwk2omFPJEwUNOVtJKvmDr9EI1fAJZUyZcRF7kxGBWmRXudrCQ==", + "dev": true, + "requires": { + "camelcase": "^5.0.0", + "decamelize": "^1.2.0" + } + } + } + }, "yargs-parser": { "version": "13.0.0", "resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-13.0.0.tgz", diff --git a/package.json b/package.json index 97212cfabf..22c444b84a 100644 --- a/package.json +++ b/package.json @@ -76,7 +76,7 @@ "partial-build": "node ./scripts/partialBuild", "clean": "rimraf es/* src/* dist/* coverage/*", "prepare": "npm run clean && npm run build", - "coverage": "istanbul cover node_modules/.bin/_mocha -- --reporter spec", + "coverage": "BABEL_ENV=cjs nyc --reporter=lcov mocha -- --require @babel/register", "lint": "eslint scripts/bookmarklet scripts/*.js source/*.js source/internal/*.js test/*.js test/**/*.js lib/sauce/*.js lib/bench/*.js", "browser_test": "testem ci", "test": "cross-env BABEL_ENV=cjs mocha --require @babel/register --reporter spec" @@ -99,10 +99,10 @@ "envvar": "^2.0.0", "eslint": "^5.16.0", "handlebars": ">=4.1.2", - "istanbul": "^0.4.x", "js-yaml": "^3.13.1", "jsverify": "^0.8.4", "mocha": "^6.1.4", + "nyc": "^15.0.1", "rimraf": "^2.6.3", "rollup": "^0.68.2", "rollup-plugin-babel": "^4.3.3", From 1bb8f7dec54e9223f1f89127293b027d4b3c65d4 Mon Sep 17 00:00:00 2001 From: Julien Gonzalez Date: Sat, 6 Jun 2020 17:54:54 +0100 Subject: [PATCH 034/111] Implement R.collectBy (#2715) --- source/collectBy.js | 44 ++++++++++++++++++++++++++++++++++++++++++++ source/index.js | 1 + test/collectBy.js | 37 +++++++++++++++++++++++++++++++++++++ 3 files changed, 82 insertions(+) create mode 100644 source/collectBy.js create mode 100644 test/collectBy.js diff --git a/source/collectBy.js b/source/collectBy.js new file mode 100644 index 0000000000..94adea670b --- /dev/null +++ b/source/collectBy.js @@ -0,0 +1,44 @@ +import _curry2 from './internal/_curry2'; +import _reduce from './internal/_reduce'; + +/** + * Splits a list into sub-lists, based on the result of calling a String-returning function on each element, + * and grouping the results according to values returned. + * + * @func + * @memberOf R + * @category List + * @sig (a -> String) -> [a] -> [[a]] + * @param {Function} fn Function :: a -> String + * @param {Array} list The array to group + * @return {Array} + * An array of arrays where each sub-array contains items for which + * the String-returning function has returned the same value. + * @see R.groupBy, R.partition + * @example + * R.collectBy(R.prop('type'), [ + * {type: 'breakfast', item: '☕️'}, + * {type: 'lunch', item: '🌯'}, + * {type: 'dinner', item: '🍝'}, + * {type: 'breakfast', item: '🥐'}, + * {type: 'lunch', item: '🍕'} + * ]); + * + * // [ [ {type: 'breakfast', item: '☕️'}, + * // {type: 'breakfast', item: '🥐'} ], + * // [ {type: 'lunch', item: '🌯'}, + * // {type: 'lunch', item: '🍕'} ], + * // [ {type: 'dinner', item: '🍝'} ] ] + */ +var collectBy = _curry2(function collectBy(fn, list) { + var group = _reduce(function(o, x) { + var tag = fn(x); + if (o[tag] === undefined) { o[tag] = []; } + o[tag].push(x); + return o; + }, {}, list); + var newList = []; + for (var tag in group) { newList.push(group[tag]); } + return newList; +}); +export default collectBy; diff --git a/source/index.js b/source/index.js index 584d371f94..2a9b0bf60f 100644 --- a/source/index.js +++ b/source/index.js @@ -26,6 +26,7 @@ export { default as call } from './call'; export { default as chain } from './chain'; export { default as clamp } from './clamp'; export { default as clone } from './clone'; +export { default as collectBy } from './collectBy'; export { default as comparator } from './comparator'; export { default as complement } from './complement'; export { default as compose } from './compose'; diff --git a/test/collectBy.js b/test/collectBy.js new file mode 100644 index 0000000000..91f46845a9 --- /dev/null +++ b/test/collectBy.js @@ -0,0 +1,37 @@ +var {all, compose , difference , equals , head , identity , is , isEmpty , length , uniq , unnest , collectBy} = require('../source'); +var {property} = require('jsverify'); +var {spy} = require('sinon'); + +describe('collectBy', function() { + + property('returns a list of lists', '[nat]', function(xs) { + var check = all(is(Array)); + var ys = collectBy(identity)(xs); + return check(ys); + }); + + property('groups items but neiter adds new ones nor removes any', '[nat]', function(xs) { + var check = compose(isEmpty, difference(xs), unnest); + var ys = collectBy(identity)(xs); + return check(ys); + }); + + property('groups related items together', '[bool]', function(xs) { + var ys = collectBy(identity)(xs); + var check = all(compose(equals(1), length, uniq)); + return check(ys); + }); + + property('invokes the tag function for each item in the list', '[nat]', function(xs) { + var id = spy(x => 42); + collectBy(id)(xs); + var check = compose(isEmpty, difference(xs)); + return check(id.getCalls().map(call => call.args[0])); + }); + + property('groups items according to the tag value', '[nat]', function(xs) { + var ys = collectBy(x => 42)(xs); + var check = compose(isEmpty, difference(xs), head); + return isEmpty(xs) && isEmpty(ys) ? true : check(ys); + }); +}); From 7f0c0e070ddbc20e387f68e4b999ae031eee5322 Mon Sep 17 00:00:00 2001 From: customcommander Date: Sun, 14 Jun 2020 07:07:21 +0100 Subject: [PATCH 035/111] doc: update Idx union type with Symbol and use it to update key-returning functions doc --- source/assocPath.js | 2 +- source/collectBy.js | 7 ++++--- source/dissocPath.js | 2 +- source/groupBy.js | 7 ++++--- source/hasPath.js | 2 +- source/indexBy.js | 5 +++-- source/lensPath.js | 2 +- source/path.js | 2 +- source/pathEq.js | 2 +- source/pathOr.js | 2 +- source/pathSatisfies.js | 2 +- source/paths.js | 2 +- source/prop.js | 2 +- 13 files changed, 21 insertions(+), 18 deletions(-) diff --git a/source/assocPath.js b/source/assocPath.js index 145e9de878..bb6a09e14a 100644 --- a/source/assocPath.js +++ b/source/assocPath.js @@ -16,7 +16,7 @@ import isNil from './isNil'; * @memberOf R * @since v0.8.0 * @category Object - * @typedefn Idx = String | Int + * @typedefn Idx = String | Int | Symbol * @sig [Idx] -> a -> {a} -> {a} * @param {Array} path the path to set * @param {*} val The new value diff --git a/source/collectBy.js b/source/collectBy.js index 94adea670b..4ffdc4f39c 100644 --- a/source/collectBy.js +++ b/source/collectBy.js @@ -2,14 +2,15 @@ import _curry2 from './internal/_curry2'; import _reduce from './internal/_reduce'; /** - * Splits a list into sub-lists, based on the result of calling a String-returning function on each element, + * Splits a list into sub-lists, based on the result of calling a key-returning function on each element, * and grouping the results according to values returned. * * @func * @memberOf R * @category List - * @sig (a -> String) -> [a] -> [[a]] - * @param {Function} fn Function :: a -> String + * @typedefn Idx = String | Int | Symbol + * @sig Idx a => (b -> a) -> [b] -> [[b]] + * @param {Function} fn Function :: a -> Idx * @param {Array} list The array to group * @return {Array} * An array of arrays where each sub-array contains items for which diff --git a/source/dissocPath.js b/source/dissocPath.js index d0ee97a676..b803c7567c 100644 --- a/source/dissocPath.js +++ b/source/dissocPath.js @@ -16,7 +16,7 @@ import update from './update'; * @memberOf R * @since v0.11.0 * @category Object - * @typedefn Idx = String | Int + * @typedefn Idx = String | Int | Symbol * @sig [Idx] -> {k: v} -> {k: v} * @param {Array} path The path to the value to omit * @param {Object} obj The object to clone diff --git a/source/groupBy.js b/source/groupBy.js index 61e9cb52ab..0c0be4c02a 100644 --- a/source/groupBy.js +++ b/source/groupBy.js @@ -4,7 +4,7 @@ import reduceBy from './reduceBy'; /** * Splits a list into sub-lists stored in an object, based on the result of - * calling a String-returning function on each element, and grouping the + * calling a key-returning function on each element, and grouping the * results according to values returned. * * Dispatches to the `groupBy` method of the second argument, if present. @@ -15,8 +15,9 @@ import reduceBy from './reduceBy'; * @memberOf R * @since v0.1.0 * @category List - * @sig (a -> String) -> [a] -> {String: [a]} - * @param {Function} fn Function :: a -> String + * @typedefn Idx = String | Int | Symbol + * @sig Idx a => (b -> a) -> [b] -> {a: [b]} + * @param {Function} fn Function :: a -> Idx * @param {Array} list The array to group * @return {Object} An object with the output of `fn` for keys, mapped to arrays of elements * that produced that key when passed to `fn`. diff --git a/source/hasPath.js b/source/hasPath.js index e35914eb9f..474ce73738 100644 --- a/source/hasPath.js +++ b/source/hasPath.js @@ -12,7 +12,7 @@ import isNil from './isNil'; * @memberOf R * @since v0.26.0 * @category Object - * @typedefn Idx = String | Int + * @typedefn Idx = String | Int | Symbol * @sig [Idx] -> {a} -> Boolean * @param {Array} path The path to use. * @param {Object} obj The object to check the path in. diff --git a/source/indexBy.js b/source/indexBy.js index 4f09b5d2fe..a359053c34 100644 --- a/source/indexBy.js +++ b/source/indexBy.js @@ -13,8 +13,9 @@ import reduceBy from './reduceBy'; * @memberOf R * @since v0.19.0 * @category List - * @sig (a -> String) -> [{k: v}] -> {k: {k: v}} - * @param {Function} fn Function :: a -> String + * @typedefn Idx = String | Int | Symbol + * @sig Idx a => (b -> a) -> [b] -> {a: b} + * @param {Function} fn Function :: a -> Idx * @param {Array} array The array of objects to index * @return {Object} An object indexing each array element by the given property. * @example diff --git a/source/lensPath.js b/source/lensPath.js index 8f30c063b3..90d66fa2fc 100644 --- a/source/lensPath.js +++ b/source/lensPath.js @@ -11,7 +11,7 @@ import path from './path'; * @memberOf R * @since v0.19.0 * @category Object - * @typedefn Idx = String | Int + * @typedefn Idx = String | Int | Symbol * @typedefn Lens s a = Functor f => (a -> f a) -> s -> f s * @sig [Idx] -> Lens s a * @param {Array} path The path to use. diff --git a/source/path.js b/source/path.js index 0aee92a4c4..a2952c6d7f 100644 --- a/source/path.js +++ b/source/path.js @@ -8,7 +8,7 @@ import paths from './paths'; * @memberOf R * @since v0.2.0 * @category Object - * @typedefn Idx = String | Int + * @typedefn Idx = String | Int | Symbol * @sig [Idx] -> {a} -> a | Undefined * @param {Array} path The path to use. * @param {Object} obj The object to retrieve the nested property from. diff --git a/source/pathEq.js b/source/pathEq.js index de11da19a8..83a0695b57 100644 --- a/source/pathEq.js +++ b/source/pathEq.js @@ -11,7 +11,7 @@ import path from './path'; * @memberOf R * @since v0.7.0 * @category Relation - * @typedefn Idx = String | Int + * @typedefn Idx = String | Int | Symbol * @sig [Idx] -> a -> {a} -> Boolean * @param {Array} path The path of the nested property to use * @param {*} val The value to compare the nested property with diff --git a/source/pathOr.js b/source/pathOr.js index c4b2128fbe..ecec92ceb7 100644 --- a/source/pathOr.js +++ b/source/pathOr.js @@ -11,7 +11,7 @@ import path from './path'; * @memberOf R * @since v0.18.0 * @category Object - * @typedefn Idx = String | Int + * @typedefn Idx = String | Int | Symbol * @sig a -> [Idx] -> {a} -> a * @param {*} d The default value. * @param {Array} p The path to use. diff --git a/source/pathSatisfies.js b/source/pathSatisfies.js index bdce2769bd..0c01c1321f 100644 --- a/source/pathSatisfies.js +++ b/source/pathSatisfies.js @@ -10,7 +10,7 @@ import path from './path'; * @memberOf R * @since v0.19.0 * @category Logic - * @typedefn Idx = String | Int + * @typedefn Idx = String | Int | Symbol * @sig (a -> Boolean) -> [Idx] -> {a} -> Boolean * @param {Function} pred * @param {Array} propPath diff --git a/source/paths.js b/source/paths.js index 871233dcbd..a79ababa22 100644 --- a/source/paths.js +++ b/source/paths.js @@ -8,7 +8,7 @@ import nth from './nth'; * @func * @memberOf R * @category Object - * @typedefn Idx = [String | Int] + * @typedefn Idx = [String | Int | Symbol] * @sig [Idx] -> {a} -> [a | Undefined] * @param {Array} pathsArray The array of paths to be fetched. * @param {Object} obj The object to retrieve the nested properties from. diff --git a/source/prop.js b/source/prop.js index 424858accf..52c91b1b78 100644 --- a/source/prop.js +++ b/source/prop.js @@ -11,7 +11,7 @@ import nth from './nth'; * @memberOf R * @since v0.1.0 * @category Object - * @typedefn Idx = String | Int + * @typedefn Idx = String | Int | Symbol * @sig Idx -> {s: a} -> a | Undefined * @param {String|Number} p The property name or array index * @param {Object} obj The object to query From 34e88148ab3559516cd63b9d22fb9c4dfe67aaea Mon Sep 17 00:00:00 2001 From: Forrest Akin Date: Tue, 16 Jun 2020 12:29:08 -0700 Subject: [PATCH 036/111] add promap (#3037) Co-authored-by: Julien Gonzalez --- source/index.js | 1 + source/internal/_promap.js | 5 ++++ source/internal/_xpromap.js | 18 +++++++++++++++ source/promap.js | 37 +++++++++++++++++++++++++++++ test/promap.js | 46 +++++++++++++++++++++++++++++++++++++ test/shared/Pair.js | 45 ++++++++++++++++++++++++++++++++++++ 6 files changed, 152 insertions(+) create mode 100644 source/internal/_promap.js create mode 100644 source/internal/_xpromap.js create mode 100644 source/promap.js create mode 100644 test/promap.js create mode 100644 test/shared/Pair.js diff --git a/source/index.js b/source/index.js index 2a9b0bf60f..b498b05947 100644 --- a/source/index.js +++ b/source/index.js @@ -171,6 +171,7 @@ export { default as pluck } from './pluck'; export { default as prepend } from './prepend'; export { default as product } from './product'; export { default as project } from './project'; +export { default as promap } from './promap'; export { default as prop } from './prop'; export { default as propEq } from './propEq'; export { default as propIs } from './propIs'; diff --git a/source/internal/_promap.js b/source/internal/_promap.js new file mode 100644 index 0000000000..3408ae156b --- /dev/null +++ b/source/internal/_promap.js @@ -0,0 +1,5 @@ +export default function _promap(f, g, profunctor) { + return function(x) { + return g(profunctor(f(x))); + }; +} diff --git a/source/internal/_xpromap.js b/source/internal/_xpromap.js new file mode 100644 index 0000000000..d25976e929 --- /dev/null +++ b/source/internal/_xpromap.js @@ -0,0 +1,18 @@ +import _curry3 from './_curry3'; +import _xfBase from './_xfBase'; +import _promap from './_promap'; + + +function XPromap(f, g, xf) { + this.xf = xf; + this.f = f; + this.g = g; +} +XPromap.prototype['@@transducer/init'] = _xfBase.init; +XPromap.prototype['@@transducer/result'] = _xfBase.result; +XPromap.prototype['@@transducer/step'] = function(result, input) { + return this.xf['@@transducer/step'](result, _promap(this.f, this.g, input)); +}; + +var _xpromap = _curry3(function _xpromap(f, g, xf) { return new XPromap(f, g, xf); }); +export default _xpromap; diff --git a/source/promap.js b/source/promap.js new file mode 100644 index 0000000000..7a4e22c52d --- /dev/null +++ b/source/promap.js @@ -0,0 +1,37 @@ +import _curry3 from './internal/_curry3'; +import _dispatchable from './internal/_dispatchable'; +import _promap from './internal/_promap'; +import _xpromap from './internal/_xpromap'; + + +/** + * Takes two functions as pre- and post- processors respectively for a third function, + * i.e. `promap(f, g, h)(x) === g(h(f(x)))`. + * + * Dispatches to the `promap` method of the third argument, if present, + * according to the [FantasyLand Profunctor spec](https://github.com/fantasyland/fantasy-land#profunctor). + * + * Acts as a transducer if a transformer is given in profunctor position. + * + * @func + * @memberOf R + * @category Function + * @sig (a -> b) -> (c -> d) -> (b -> c) -> (a -> d) + * @sig Profunctor p => (a -> b) -> (c -> d) -> p b c -> p a d + * @param {Function} f The preprocessor function, a -> b + * @param {Function} g The postprocessor function, c -> d + * @param {Profunctor} profunctor The profunctor instance to be promapped, e.g. b -> c + * @return {Profunctor} The new profunctor instance, e.g. a -> d + * @see R.transduce + * @example + * + * const decodeChar = R.promap(s => s.charCodeAt(), String.fromCharCode, R.add(-8)) + * const decodeString = R.promap(R.split(''), R.join(''), R.map(decodeChar)) + * decodeString("ziuli") //=> "ramda" + * + * @symb R.promap(f, g, h) = x => g(h(f(x))) + * @symb R.promap(f, g, profunctor) = profunctor.promap(f, g) + */ +var promap = _curry3(_dispatchable(['fantasy-land/promap', 'promap'], _xpromap, _promap)); + +export default promap; diff --git a/test/promap.js b/test/promap.js new file mode 100644 index 0000000000..0841adec46 --- /dev/null +++ b/test/promap.js @@ -0,0 +1,46 @@ +var assert = require('assert'); + +var R = require('../source'); +var eq = require('./shared/eq'); +var Pair = require('./shared/Pair'); + + +describe('promap', function() { + var fromCharCode = String.fromCharCode; + function charCodeAt(s) { return s.charCodeAt(); } + function Costar(run) { + return { + promap: function promap(f, g) { + return Costar(R.pipe(R.map(f), run, g)); + }, + run: run + }; + } + + it(`dispatches to pronfuctor["fantasy-land/promap"]() if present`, function() { + var setJson = R.promap(JSON.parse, JSON.stringify); + var pair = setJson( + Pair(R.assoc("left-promapped", true), R.assoc("right-promapped", true)) + ); + function mergeWithJson(json) { + return function(left, right) { return right(left(json)); }; + }; + + eq(pair.merge(mergeWithJson("{}")), `{"left-promapped":true,"right-promapped":true}`); + }); + + it(`dispatches to pronfuctor.promap() if present`, function() { + var is1337Change = R.promap(R.multiply(100), R.equals(1337), Costar(R.sum)); + var data = [10, 3, 0.3, 0.07]; + + eq(is1337Change.run(data), true); + }); + + it('composes two functions, f and g, before and after the final function respectively', function() { + var decodeChar = R.promap(charCodeAt, fromCharCode, R.add(-8)); + var decodeString = R.promap(R.split(''), R.join(''), R.map(decodeChar)); + var code = "ziuli"; + + eq(decodeString(code), "ramda"); + }); +}); diff --git a/test/shared/Pair.js b/test/shared/Pair.js new file mode 100644 index 0000000000..bc635c4392 --- /dev/null +++ b/test/shared/Pair.js @@ -0,0 +1,45 @@ +var R = require('../../source'); + + +function Pair(left, right) { + return { + '@@type': 'ramda/Pair', + 'fantasy-land/equals': function equals(pair) { + return pair != null + && pair['@@type'] === this['@@type'] + && R.equals(left, pair.left) + && R.equals(right, pair.right); + }, + 'fantasy-land/concat': function concat(pair) { + return Pair(R.concat(left, pair.left), R.concat(right, pair.right)); + }, + 'fantasy-land/map': function map(f) { return Pair(left, f(right)); }, + 'fantasy-land/ap': function ap(pair) { + return Pair(R.concat(left, pair.left), right(pair.right)); + }, + 'fantasy-land/reduce': function reduce(f, x) { return f(x, right); }, + 'fantasy-land/traverse': function traverse(of, f) { + return R.map( + function(x) { return Pair(left, x); }, + of(f(right)) + ); + }, + 'fantasy-land/chain': function chain(f) { + var pair = f(right); + return Pair(R.concat(left, pair.left), pair.right); + }, + 'fantasy-land/bimap': function bimap(f, g) { return Pair(f(left), g(right)); }, + 'fantasy-land/promap': function promap(f, g) { + return Pair(R.promap(f, g, left), R.promap(f, g, right)); + }, + merge: function merge(f) { return f(left, right); }, + toString: function toString() { + return `Pair(${R.toString(left)}, ${R.toString(right)})`; + }, + toArray: function toArray() { return [left, right]; }, + left: left, + right: right, + }; +} + +module.exports = Pair; From d0a54b83858a90c5a4733713e34bc04c54f982d9 Mon Sep 17 00:00:00 2001 From: Sebastien Filion Date: Tue, 16 Jun 2020 09:30:14 -0400 Subject: [PATCH 037/111] Add `.js` extension to source files Omitting the file extension when importing a module is a quirk of the NodeJS' require importing method and should be discouraged -- As standard ES module is getting ground (Browser import, Deno import). --- source/add.js | 2 +- source/addIndex.js | 6 +- source/adjust.js | 4 +- source/all.js | 6 +- source/allPass.js | 10 +- source/always.js | 2 +- source/and.js | 2 +- source/andThen.js | 4 +- source/any.js | 6 +- source/anyPass.js | 10 +- source/ap.js | 8 +- source/aperture.js | 8 +- source/append.js | 4 +- source/apply.js | 2 +- source/applySpec.js | 18 +- source/applyTo.js | 2 +- source/ascend.js | 2 +- source/assoc.js | 2 +- source/assocPath.js | 12 +- source/binary.js | 4 +- source/bind.js | 4 +- source/both.js | 8 +- source/call.js | 2 +- source/chain.js | 10 +- source/clamp.js | 2 +- source/clone.js | 4 +- source/collectBy.js | 4 +- source/comparator.js | 2 +- source/complement.js | 4 +- source/compose.js | 4 +- source/composeWith.js | 6 +- source/concat.js | 10 +- source/cond.js | 10 +- source/construct.js | 4 +- source/constructN.js | 6 +- source/converge.js | 12 +- source/countBy.js | 2 +- source/curry.js | 4 +- source/curryN.js | 8 +- source/dec.js | 2 +- source/defaultTo.js | 2 +- source/descend.js | 2 +- source/difference.js | 4 +- source/differenceWith.js | 4 +- source/dissoc.js | 2 +- source/dissocPath.js | 14 +- source/divide.js | 2 +- source/drop.js | 8 +- source/dropLast.js | 8 +- source/dropLastWhile.js | 8 +- source/dropRepeats.js | 10 +- source/dropRepeatsWith.js | 8 +- source/dropWhile.js | 8 +- source/either.js | 8 +- source/empty.js | 12 +- source/endsWith.js | 6 +- source/eqBy.js | 4 +- source/eqProps.js | 4 +- source/equals.js | 4 +- source/evolve.js | 2 +- source/filter.js | 14 +- source/find.js | 6 +- source/findIndex.js | 6 +- source/findLast.js | 6 +- source/findLastIndex.js | 6 +- source/flatten.js | 4 +- source/flip.js | 4 +- source/forEach.js | 4 +- source/forEachObjIndexed.js | 4 +- source/fromPairs.js | 2 +- source/groupBy.js | 6 +- source/groupWith.js | 2 +- source/gt.js | 2 +- source/gte.js | 2 +- source/has.js | 4 +- source/hasIn.js | 4 +- source/hasPath.js | 6 +- source/head.js | 2 +- source/identical.js | 4 +- source/identity.js | 4 +- source/ifElse.js | 4 +- source/inc.js | 2 +- source/includes.js | 4 +- source/index.js | 512 ++++++++++---------- source/indexBy.js | 2 +- source/indexOf.js | 6 +- source/init.js | 2 +- source/innerJoin.js | 6 +- source/insert.js | 2 +- source/insertAll.js | 2 +- source/internal/_Set.js | 2 +- source/internal/_assertPromise.js | 4 +- source/internal/_checkForMethod.js | 2 +- source/internal/_clone.js | 4 +- source/internal/_createPartialApplicator.js | 4 +- source/internal/_curry1.js | 2 +- source/internal/_curry2.js | 4 +- source/internal/_curry3.js | 6 +- source/internal/_curryN.js | 4 +- source/internal/_dispatchable.js | 4 +- source/internal/_dropLast.js | 2 +- source/internal/_dropLastWhile.js | 2 +- source/internal/_equals.js | 14 +- source/internal/_flatCat.js | 8 +- source/internal/_functionsWith.js | 2 +- source/internal/_includes.js | 2 +- source/internal/_indexOf.js | 2 +- source/internal/_isArguments.js | 2 +- source/internal/_isArrayLike.js | 6 +- source/internal/_makeFlat.js | 2 +- source/internal/_objectAssign.js | 2 +- source/internal/_reduce.js | 6 +- source/internal/_stepCat.js | 10 +- source/internal/_toString.js | 12 +- source/internal/_xall.js | 6 +- source/internal/_xany.js | 6 +- source/internal/_xaperture.js | 6 +- source/internal/_xchain.js | 6 +- source/internal/_xdrop.js | 4 +- source/internal/_xdropLast.js | 4 +- source/internal/_xdropLastWhile.js | 6 +- source/internal/_xdropRepeatsWith.js | 4 +- source/internal/_xdropWhile.js | 4 +- source/internal/_xfilter.js | 4 +- source/internal/_xfind.js | 6 +- source/internal/_xfindIndex.js | 6 +- source/internal/_xfindLast.js | 4 +- source/internal/_xfindLastIndex.js | 4 +- source/internal/_xmap.js | 4 +- source/internal/_xreduceBy.js | 6 +- source/internal/_xtake.js | 6 +- source/internal/_xtakeWhile.js | 6 +- source/internal/_xtap.js | 4 +- source/intersection.js | 10 +- source/intersperse.js | 4 +- source/into.js | 10 +- source/invert.js | 6 +- source/invertObj.js | 4 +- source/invoker.js | 8 +- source/is.js | 2 +- source/isEmpty.js | 6 +- source/isNil.js | 2 +- source/join.js | 2 +- source/juxt.js | 4 +- source/keys.js | 6 +- source/keysIn.js | 2 +- source/last.js | 2 +- source/lastIndexOf.js | 6 +- source/length.js | 4 +- source/lens.js | 4 +- source/lensIndex.js | 8 +- source/lensPath.js | 8 +- source/lensProp.js | 8 +- source/lift.js | 4 +- source/liftN.js | 10 +- source/lt.js | 2 +- source/lte.js | 2 +- source/map.js | 14 +- source/mapAccum.js | 2 +- source/mapAccumRight.js | 2 +- source/mapObjIndexed.js | 6 +- source/match.js | 2 +- source/mathMod.js | 4 +- source/max.js | 2 +- source/maxBy.js | 2 +- source/mean.js | 4 +- source/median.js | 4 +- source/memoizeWith.js | 6 +- source/mergeAll.js | 4 +- source/mergeDeepLeft.js | 4 +- source/mergeDeepRight.js | 4 +- source/mergeDeepWith.js | 4 +- source/mergeDeepWithKey.js | 6 +- source/mergeLeft.js | 4 +- source/mergeRight.js | 4 +- source/mergeWith.js | 4 +- source/mergeWithKey.js | 4 +- source/min.js | 2 +- source/minBy.js | 2 +- source/modulo.js | 2 +- source/move.js | 2 +- source/multiply.js | 2 +- source/nAry.js | 2 +- source/negate.js | 2 +- source/none.js | 6 +- source/not.js | 2 +- source/nth.js | 4 +- source/nthArg.js | 6 +- source/o.js | 2 +- source/objOf.js | 2 +- source/of.js | 4 +- source/omit.js | 2 +- source/on.js | 2 +- source/once.js | 4 +- source/or.js | 2 +- source/otherwise.js | 4 +- source/over.js | 2 +- source/pair.js | 2 +- source/partial.js | 4 +- source/partialRight.js | 6 +- source/partition.js | 6 +- source/path.js | 4 +- source/pathEq.js | 6 +- source/pathOr.js | 6 +- source/pathSatisfies.js | 4 +- source/paths.js | 6 +- source/pick.js | 2 +- source/pickAll.js | 2 +- source/pickBy.js | 2 +- source/pipe.js | 8 +- source/pipeWith.js | 12 +- source/pluck.js | 6 +- source/prepend.js | 4 +- source/product.js | 4 +- source/project.js | 8 +- source/prop.js | 6 +- source/propEq.js | 6 +- source/propIs.js | 6 +- source/propOr.js | 6 +- source/propSatisfies.js | 4 +- source/props.js | 4 +- source/range.js | 4 +- source/reduce.js | 4 +- source/reduceBy.js | 12 +- source/reduceRight.js | 2 +- source/reduceWhile.js | 6 +- source/reduced.js | 4 +- source/reject.js | 6 +- source/remove.js | 2 +- source/repeat.js | 6 +- source/replace.js | 2 +- source/reverse.js | 4 +- source/scan.js | 2 +- source/sequence.js | 10 +- source/set.js | 6 +- source/slice.js | 4 +- source/sort.js | 2 +- source/sortBy.js | 2 +- source/sortWith.js | 2 +- source/split.js | 2 +- source/splitAt.js | 6 +- source/splitEvery.js | 4 +- source/splitWhen.js | 2 +- source/splitWhenever.js | 2 +- source/startsWith.js | 6 +- source/subtract.js | 2 +- source/sum.js | 4 +- source/symmetricDifference.js | 6 +- source/symmetricDifferenceWith.js | 6 +- source/tail.js | 6 +- source/take.js | 8 +- source/takeLast.js | 4 +- source/takeLastWhile.js | 4 +- source/takeWhile.js | 8 +- source/tap.js | 6 +- source/test.js | 8 +- source/thunkify.js | 4 +- source/times.js | 2 +- source/toLower.js | 2 +- source/toPairs.js | 4 +- source/toPairsIn.js | 2 +- source/toString.js | 4 +- source/toUpper.js | 2 +- source/transduce.js | 6 +- source/transpose.js | 2 +- source/traverse.js | 6 +- source/trim.js | 2 +- source/tryCatch.js | 6 +- source/type.js | 2 +- source/unapply.js | 2 +- source/unary.js | 4 +- source/uncurryN.js | 4 +- source/unfold.js | 2 +- source/union.js | 8 +- source/unionWith.js | 6 +- source/uniq.js | 4 +- source/uniqBy.js | 4 +- source/uniqWith.js | 4 +- source/unless.js | 2 +- source/unnest.js | 4 +- source/until.js | 2 +- source/update.js | 6 +- source/useWith.js | 4 +- source/values.js | 4 +- source/valuesIn.js | 2 +- source/view.js | 2 +- source/when.js | 2 +- source/where.js | 4 +- source/whereAny.js | 4 +- source/whereEq.js | 8 +- source/without.js | 8 +- source/xor.js | 2 +- source/xprod.js | 2 +- source/zip.js | 2 +- source/zipObj.js | 2 +- source/zipWith.js | 2 +- 296 files changed, 939 insertions(+), 939 deletions(-) diff --git a/source/add.js b/source/add.js index 9f4fd9c4cf..804d145df0 100644 --- a/source/add.js +++ b/source/add.js @@ -1,4 +1,4 @@ -import _curry2 from './internal/_curry2'; +import _curry2 from './internal/_curry2.js'; /** diff --git a/source/addIndex.js b/source/addIndex.js index 1465d7cd9e..e2e99a6000 100644 --- a/source/addIndex.js +++ b/source/addIndex.js @@ -1,6 +1,6 @@ -import _concat from './internal/_concat'; -import _curry1 from './internal/_curry1'; -import curryN from './curryN'; +import _concat from './internal/_concat.js'; +import _curry1 from './internal/_curry1.js'; +import curryN from './curryN.js'; /** diff --git a/source/adjust.js b/source/adjust.js index c5d009cdb3..f3e9ecd71b 100644 --- a/source/adjust.js +++ b/source/adjust.js @@ -1,5 +1,5 @@ -import _concat from './internal/_concat'; -import _curry3 from './internal/_curry3'; +import _concat from './internal/_concat.js'; +import _curry3 from './internal/_curry3.js'; /** diff --git a/source/all.js b/source/all.js index 0a8cc5c5cd..7100f0fb6c 100644 --- a/source/all.js +++ b/source/all.js @@ -1,6 +1,6 @@ -import _curry2 from './internal/_curry2'; -import _dispatchable from './internal/_dispatchable'; -import _xall from './internal/_xall'; +import _curry2 from './internal/_curry2.js'; +import _dispatchable from './internal/_dispatchable.js'; +import _xall from './internal/_xall.js'; /** diff --git a/source/allPass.js b/source/allPass.js index 5e1afe005b..3df5bf1d47 100644 --- a/source/allPass.js +++ b/source/allPass.js @@ -1,8 +1,8 @@ -import _curry1 from './internal/_curry1'; -import curryN from './curryN'; -import max from './max'; -import pluck from './pluck'; -import reduce from './reduce'; +import _curry1 from './internal/_curry1.js'; +import curryN from './curryN.js'; +import max from './max.js'; +import pluck from './pluck.js'; +import reduce from './reduce.js'; /** diff --git a/source/always.js b/source/always.js index 71b943cea0..d80cdb2203 100644 --- a/source/always.js +++ b/source/always.js @@ -1,4 +1,4 @@ -import _curry1 from './internal/_curry1'; +import _curry1 from './internal/_curry1.js'; /** diff --git a/source/and.js b/source/and.js index 3eb328dc99..46c162a8dc 100644 --- a/source/and.js +++ b/source/and.js @@ -1,4 +1,4 @@ -import _curry2 from './internal/_curry2'; +import _curry2 from './internal/_curry2.js'; /** diff --git a/source/andThen.js b/source/andThen.js index a348b8d353..bd848c8215 100644 --- a/source/andThen.js +++ b/source/andThen.js @@ -1,5 +1,5 @@ -import _curry2 from './internal/_curry2'; -import _assertPromise from './internal/_assertPromise'; +import _curry2 from './internal/_curry2.js'; +import _assertPromise from './internal/_assertPromise.js'; /** diff --git a/source/any.js b/source/any.js index 7c604772c9..68e5fc96e5 100644 --- a/source/any.js +++ b/source/any.js @@ -1,6 +1,6 @@ -import _curry2 from './internal/_curry2'; -import _dispatchable from './internal/_dispatchable'; -import _xany from './internal/_xany'; +import _curry2 from './internal/_curry2.js'; +import _dispatchable from './internal/_dispatchable.js'; +import _xany from './internal/_xany.js'; /** diff --git a/source/anyPass.js b/source/anyPass.js index afb694ddcf..424a61078f 100644 --- a/source/anyPass.js +++ b/source/anyPass.js @@ -1,8 +1,8 @@ -import _curry1 from './internal/_curry1'; -import curryN from './curryN'; -import max from './max'; -import pluck from './pluck'; -import reduce from './reduce'; +import _curry1 from './internal/_curry1.js'; +import curryN from './curryN.js'; +import max from './max.js'; +import pluck from './pluck.js'; +import reduce from './reduce.js'; /** diff --git a/source/ap.js b/source/ap.js index f071e8a97e..19c7920e78 100644 --- a/source/ap.js +++ b/source/ap.js @@ -1,7 +1,7 @@ -import _concat from './internal/_concat'; -import _curry2 from './internal/_curry2'; -import _reduce from './internal/_reduce'; -import map from './map'; +import _concat from './internal/_concat.js'; +import _curry2 from './internal/_curry2.js'; +import _reduce from './internal/_reduce.js'; +import map from './map.js'; /** diff --git a/source/aperture.js b/source/aperture.js index ffef3ef72c..c02526f685 100644 --- a/source/aperture.js +++ b/source/aperture.js @@ -1,7 +1,7 @@ -import _aperture from './internal/_aperture'; -import _curry2 from './internal/_curry2'; -import _dispatchable from './internal/_dispatchable'; -import _xaperture from './internal/_xaperture'; +import _aperture from './internal/_aperture.js'; +import _curry2 from './internal/_curry2.js'; +import _dispatchable from './internal/_dispatchable.js'; +import _xaperture from './internal/_xaperture.js'; /** diff --git a/source/append.js b/source/append.js index 6e529ef499..eb686f0f03 100644 --- a/source/append.js +++ b/source/append.js @@ -1,5 +1,5 @@ -import _concat from './internal/_concat'; -import _curry2 from './internal/_curry2'; +import _concat from './internal/_concat.js'; +import _curry2 from './internal/_curry2.js'; /** diff --git a/source/apply.js b/source/apply.js index 5dc5e5509b..7ba2da5e0d 100644 --- a/source/apply.js +++ b/source/apply.js @@ -1,4 +1,4 @@ -import _curry2 from './internal/_curry2'; +import _curry2 from './internal/_curry2.js'; /** diff --git a/source/applySpec.js b/source/applySpec.js index dba05d2452..ad21c9e094 100644 --- a/source/applySpec.js +++ b/source/applySpec.js @@ -1,12 +1,12 @@ -import _curry1 from './internal/_curry1'; -import _isArray from './internal/_isArray'; -import apply from './apply'; -import curryN from './curryN'; -import max from './max'; -import pluck from './pluck'; -import reduce from './reduce'; -import keys from './keys'; -import values from './values'; +import _curry1 from './internal/_curry1.js'; +import _isArray from './internal/_isArray.js'; +import apply from './apply.js'; +import curryN from './curryN.js'; +import max from './max.js'; +import pluck from './pluck.js'; +import reduce from './reduce.js'; +import keys from './keys.js'; +import values from './values.js'; // Use custom mapValues function to avoid issues with specs that include a "map" key and R.map diff --git a/source/applyTo.js b/source/applyTo.js index f6035d482b..febb3cebc7 100644 --- a/source/applyTo.js +++ b/source/applyTo.js @@ -1,4 +1,4 @@ -import _curry2 from './internal/_curry2'; +import _curry2 from './internal/_curry2.js'; /** * Takes a value and applies a function to it. diff --git a/source/ascend.js b/source/ascend.js index 6ea19f975e..57e23e30e9 100644 --- a/source/ascend.js +++ b/source/ascend.js @@ -1,4 +1,4 @@ -import _curry3 from './internal/_curry3'; +import _curry3 from './internal/_curry3.js'; /** diff --git a/source/assoc.js b/source/assoc.js index 0fc9ac4bff..9a9d18c4e6 100644 --- a/source/assoc.js +++ b/source/assoc.js @@ -1,4 +1,4 @@ -import _curry3 from './internal/_curry3'; +import _curry3 from './internal/_curry3.js'; /** diff --git a/source/assocPath.js b/source/assocPath.js index bb6a09e14a..8199a7b369 100644 --- a/source/assocPath.js +++ b/source/assocPath.js @@ -1,9 +1,9 @@ -import _curry3 from './internal/_curry3'; -import _has from './internal/_has'; -import _isArray from './internal/_isArray'; -import _isInteger from './internal/_isInteger'; -import assoc from './assoc'; -import isNil from './isNil'; +import _curry3 from './internal/_curry3.js'; +import _has from './internal/_has.js'; +import _isArray from './internal/_isArray.js'; +import _isInteger from './internal/_isInteger.js'; +import assoc from './assoc.js'; +import isNil from './isNil.js'; /** diff --git a/source/binary.js b/source/binary.js index bf5f5af823..4e343c572f 100644 --- a/source/binary.js +++ b/source/binary.js @@ -1,5 +1,5 @@ -import _curry1 from './internal/_curry1'; -import nAry from './nAry'; +import _curry1 from './internal/_curry1.js'; +import nAry from './nAry.js'; /** diff --git a/source/bind.js b/source/bind.js index f7bfacd795..ce2598e636 100644 --- a/source/bind.js +++ b/source/bind.js @@ -1,5 +1,5 @@ -import _arity from './internal/_arity'; -import _curry2 from './internal/_curry2'; +import _arity from './internal/_arity.js'; +import _curry2 from './internal/_curry2.js'; /** diff --git a/source/both.js b/source/both.js index 8d2fea8734..8eca922c4f 100644 --- a/source/both.js +++ b/source/both.js @@ -1,7 +1,7 @@ -import _curry2 from './internal/_curry2'; -import _isFunction from './internal/_isFunction'; -import and from './and'; -import lift from './lift'; +import _curry2 from './internal/_curry2.js'; +import _isFunction from './internal/_isFunction.js'; +import and from './and.js'; +import lift from './lift.js'; /** diff --git a/source/call.js b/source/call.js index d654db5339..fc9f9e3e79 100644 --- a/source/call.js +++ b/source/call.js @@ -1,4 +1,4 @@ -import _curry1 from './internal/_curry1'; +import _curry1 from './internal/_curry1.js'; /** diff --git a/source/chain.js b/source/chain.js index 56416ad7db..508ac33ff8 100644 --- a/source/chain.js +++ b/source/chain.js @@ -1,8 +1,8 @@ -import _curry2 from './internal/_curry2'; -import _dispatchable from './internal/_dispatchable'; -import _makeFlat from './internal/_makeFlat'; -import _xchain from './internal/_xchain'; -import map from './map'; +import _curry2 from './internal/_curry2.js'; +import _dispatchable from './internal/_dispatchable.js'; +import _makeFlat from './internal/_makeFlat.js'; +import _xchain from './internal/_xchain.js'; +import map from './map.js'; /** diff --git a/source/clamp.js b/source/clamp.js index d673942ea0..080435546d 100644 --- a/source/clamp.js +++ b/source/clamp.js @@ -1,4 +1,4 @@ -import _curry3 from './internal/_curry3'; +import _curry3 from './internal/_curry3.js'; /** * Restricts a number to be within a range. diff --git a/source/clone.js b/source/clone.js index 7bf7560bb0..7a46d91901 100644 --- a/source/clone.js +++ b/source/clone.js @@ -1,5 +1,5 @@ -import _clone from './internal/_clone'; -import _curry1 from './internal/_curry1'; +import _clone from './internal/_clone.js'; +import _curry1 from './internal/_curry1.js'; /** diff --git a/source/collectBy.js b/source/collectBy.js index 4ffdc4f39c..a5d702d0f7 100644 --- a/source/collectBy.js +++ b/source/collectBy.js @@ -1,5 +1,5 @@ -import _curry2 from './internal/_curry2'; -import _reduce from './internal/_reduce'; +import _curry2 from './internal/_curry2.js'; +import _reduce from './internal/_reduce.js'; /** * Splits a list into sub-lists, based on the result of calling a key-returning function on each element, diff --git a/source/comparator.js b/source/comparator.js index edba2a51f6..09a7e62c1a 100644 --- a/source/comparator.js +++ b/source/comparator.js @@ -1,4 +1,4 @@ -import _curry1 from './internal/_curry1'; +import _curry1 from './internal/_curry1.js'; /** diff --git a/source/complement.js b/source/complement.js index 9fdb52d0bd..cd23757d4f 100644 --- a/source/complement.js +++ b/source/complement.js @@ -1,5 +1,5 @@ -import lift from './lift'; -import not from './not'; +import lift from './lift.js'; +import not from './not.js'; /** diff --git a/source/compose.js b/source/compose.js index b920e82bdd..fc9f5c9a90 100644 --- a/source/compose.js +++ b/source/compose.js @@ -1,5 +1,5 @@ -import pipe from './pipe'; -import reverse from './reverse'; +import pipe from './pipe.js'; +import reverse from './reverse.js'; /** diff --git a/source/composeWith.js b/source/composeWith.js index 817aa6c459..90a6eec391 100644 --- a/source/composeWith.js +++ b/source/composeWith.js @@ -1,6 +1,6 @@ -import _curry2 from './internal/_curry2'; -import pipeWith from './pipeWith'; -import reverse from './reverse'; +import _curry2 from './internal/_curry2.js'; +import pipeWith from './pipeWith.js'; +import reverse from './reverse.js'; /** diff --git a/source/concat.js b/source/concat.js index 13121fd725..bc6f2fc36f 100644 --- a/source/concat.js +++ b/source/concat.js @@ -1,8 +1,8 @@ -import _curry2 from './internal/_curry2'; -import _isArray from './internal/_isArray'; -import _isFunction from './internal/_isFunction'; -import _isString from './internal/_isString'; -import toString from './toString'; +import _curry2 from './internal/_curry2.js'; +import _isArray from './internal/_isArray.js'; +import _isFunction from './internal/_isFunction.js'; +import _isString from './internal/_isString.js'; +import toString from './toString.js'; /** diff --git a/source/cond.js b/source/cond.js index 3796d76701..fd070d5f31 100644 --- a/source/cond.js +++ b/source/cond.js @@ -1,8 +1,8 @@ -import _arity from './internal/_arity'; -import _curry1 from './internal/_curry1'; -import map from './map'; -import max from './max'; -import reduce from './reduce'; +import _arity from './internal/_arity.js'; +import _curry1 from './internal/_curry1.js'; +import map from './map.js'; +import max from './max.js'; +import reduce from './reduce.js'; /** diff --git a/source/construct.js b/source/construct.js index cd0e4e4d4d..d1eecdd56b 100644 --- a/source/construct.js +++ b/source/construct.js @@ -1,5 +1,5 @@ -import _curry1 from './internal/_curry1'; -import constructN from './constructN'; +import _curry1 from './internal/_curry1.js'; +import constructN from './constructN.js'; /** diff --git a/source/constructN.js b/source/constructN.js index 482c5a9fcc..39a44fb724 100644 --- a/source/constructN.js +++ b/source/constructN.js @@ -1,6 +1,6 @@ -import _curry2 from './internal/_curry2'; -import curry from './curry'; -import nAry from './nAry'; +import _curry2 from './internal/_curry2.js'; +import curry from './curry.js'; +import nAry from './nAry.js'; /** diff --git a/source/converge.js b/source/converge.js index 31d53660c3..a8b7610464 100644 --- a/source/converge.js +++ b/source/converge.js @@ -1,9 +1,9 @@ -import _curry2 from './internal/_curry2'; -import _map from './internal/_map'; -import curryN from './curryN'; -import max from './max'; -import pluck from './pluck'; -import reduce from './reduce'; +import _curry2 from './internal/_curry2.js'; +import _map from './internal/_map.js'; +import curryN from './curryN.js'; +import max from './max.js'; +import pluck from './pluck.js'; +import reduce from './reduce.js'; /** diff --git a/source/countBy.js b/source/countBy.js index 482efef2eb..c849be0337 100644 --- a/source/countBy.js +++ b/source/countBy.js @@ -1,4 +1,4 @@ -import reduceBy from './reduceBy'; +import reduceBy from './reduceBy.js'; /** diff --git a/source/curry.js b/source/curry.js index 343f6bf0d6..f7ef095e93 100644 --- a/source/curry.js +++ b/source/curry.js @@ -1,5 +1,5 @@ -import _curry1 from './internal/_curry1'; -import curryN from './curryN'; +import _curry1 from './internal/_curry1.js'; +import curryN from './curryN.js'; /** diff --git a/source/curryN.js b/source/curryN.js index accaa88bd7..792c23637e 100644 --- a/source/curryN.js +++ b/source/curryN.js @@ -1,7 +1,7 @@ -import _arity from './internal/_arity'; -import _curry1 from './internal/_curry1'; -import _curry2 from './internal/_curry2'; -import _curryN from './internal/_curryN'; +import _arity from './internal/_arity.js'; +import _curry1 from './internal/_curry1.js'; +import _curry2 from './internal/_curry2.js'; +import _curryN from './internal/_curryN.js'; /** diff --git a/source/dec.js b/source/dec.js index 9b85d39071..f58490f343 100644 --- a/source/dec.js +++ b/source/dec.js @@ -1,4 +1,4 @@ -import add from './add'; +import add from './add.js'; /** diff --git a/source/defaultTo.js b/source/defaultTo.js index bd201ac424..2ef2e4212a 100644 --- a/source/defaultTo.js +++ b/source/defaultTo.js @@ -1,4 +1,4 @@ -import _curry2 from './internal/_curry2'; +import _curry2 from './internal/_curry2.js'; /** diff --git a/source/descend.js b/source/descend.js index b07d809b3f..8689e84877 100644 --- a/source/descend.js +++ b/source/descend.js @@ -1,4 +1,4 @@ -import _curry3 from './internal/_curry3'; +import _curry3 from './internal/_curry3.js'; /** diff --git a/source/difference.js b/source/difference.js index c5c4c5b2ab..0b3f0cf863 100644 --- a/source/difference.js +++ b/source/difference.js @@ -1,5 +1,5 @@ -import _curry2 from './internal/_curry2'; -import _Set from './internal/_Set'; +import _curry2 from './internal/_curry2.js'; +import _Set from './internal/_Set.js'; /** diff --git a/source/differenceWith.js b/source/differenceWith.js index 5f760ccc51..693afefcb5 100644 --- a/source/differenceWith.js +++ b/source/differenceWith.js @@ -1,5 +1,5 @@ -import _includesWith from './internal/_includesWith'; -import _curry3 from './internal/_curry3'; +import _includesWith from './internal/_includesWith.js'; +import _curry3 from './internal/_curry3.js'; /** diff --git a/source/dissoc.js b/source/dissoc.js index fcea1d5286..a86413cab0 100644 --- a/source/dissoc.js +++ b/source/dissoc.js @@ -1,4 +1,4 @@ -import _curry2 from './internal/_curry2'; +import _curry2 from './internal/_curry2.js'; /** diff --git a/source/dissocPath.js b/source/dissocPath.js index b803c7567c..96c8130406 100644 --- a/source/dissocPath.js +++ b/source/dissocPath.js @@ -1,10 +1,10 @@ -import _curry2 from './internal/_curry2'; -import _isInteger from './internal/_isInteger'; -import _isArray from './internal/_isArray'; -import assoc from './assoc'; -import dissoc from './dissoc'; -import remove from './remove'; -import update from './update'; +import _curry2 from './internal/_curry2.js'; +import _isInteger from './internal/_isInteger.js'; +import _isArray from './internal/_isArray.js'; +import assoc from './assoc.js'; +import dissoc from './dissoc.js'; +import remove from './remove.js'; +import update from './update.js'; /** diff --git a/source/divide.js b/source/divide.js index 4925da6bf3..12b9f8f8ef 100644 --- a/source/divide.js +++ b/source/divide.js @@ -1,4 +1,4 @@ -import _curry2 from './internal/_curry2'; +import _curry2 from './internal/_curry2.js'; /** diff --git a/source/drop.js b/source/drop.js index b9e6fb981e..b6f7fda6e9 100644 --- a/source/drop.js +++ b/source/drop.js @@ -1,7 +1,7 @@ -import _curry2 from './internal/_curry2'; -import _dispatchable from './internal/_dispatchable'; -import _xdrop from './internal/_xdrop'; -import slice from './slice'; +import _curry2 from './internal/_curry2.js'; +import _dispatchable from './internal/_dispatchable.js'; +import _xdrop from './internal/_xdrop.js'; +import slice from './slice.js'; /** diff --git a/source/dropLast.js b/source/dropLast.js index fed00ff8c8..79905ecc62 100644 --- a/source/dropLast.js +++ b/source/dropLast.js @@ -1,7 +1,7 @@ -import _curry2 from './internal/_curry2'; -import _dispatchable from './internal/_dispatchable'; -import _dropLast from './internal/_dropLast'; -import _xdropLast from './internal/_xdropLast'; +import _curry2 from './internal/_curry2.js'; +import _dispatchable from './internal/_dispatchable.js'; +import _dropLast from './internal/_dropLast.js'; +import _xdropLast from './internal/_xdropLast.js'; /** diff --git a/source/dropLastWhile.js b/source/dropLastWhile.js index c253b97d25..c4c9a12d18 100644 --- a/source/dropLastWhile.js +++ b/source/dropLastWhile.js @@ -1,7 +1,7 @@ -import _curry2 from './internal/_curry2'; -import _dispatchable from './internal/_dispatchable'; -import _dropLastWhile from './internal/_dropLastWhile'; -import _xdropLastWhile from './internal/_xdropLastWhile'; +import _curry2 from './internal/_curry2.js'; +import _dispatchable from './internal/_dispatchable.js'; +import _dropLastWhile from './internal/_dropLastWhile.js'; +import _xdropLastWhile from './internal/_xdropLastWhile.js'; /** diff --git a/source/dropRepeats.js b/source/dropRepeats.js index 54b34d02ca..355a4c9194 100644 --- a/source/dropRepeats.js +++ b/source/dropRepeats.js @@ -1,8 +1,8 @@ -import _curry1 from './internal/_curry1'; -import _dispatchable from './internal/_dispatchable'; -import _xdropRepeatsWith from './internal/_xdropRepeatsWith'; -import dropRepeatsWith from './dropRepeatsWith'; -import equals from './equals'; +import _curry1 from './internal/_curry1.js'; +import _dispatchable from './internal/_dispatchable.js'; +import _xdropRepeatsWith from './internal/_xdropRepeatsWith.js'; +import dropRepeatsWith from './dropRepeatsWith.js'; +import equals from './equals.js'; /** diff --git a/source/dropRepeatsWith.js b/source/dropRepeatsWith.js index f962d9c539..1c02dac865 100644 --- a/source/dropRepeatsWith.js +++ b/source/dropRepeatsWith.js @@ -1,7 +1,7 @@ -import _curry2 from './internal/_curry2'; -import _dispatchable from './internal/_dispatchable'; -import _xdropRepeatsWith from './internal/_xdropRepeatsWith'; -import last from './last'; +import _curry2 from './internal/_curry2.js'; +import _dispatchable from './internal/_dispatchable.js'; +import _xdropRepeatsWith from './internal/_xdropRepeatsWith.js'; +import last from './last.js'; /** diff --git a/source/dropWhile.js b/source/dropWhile.js index a7c6ed5ba9..2cbd39aac1 100644 --- a/source/dropWhile.js +++ b/source/dropWhile.js @@ -1,7 +1,7 @@ -import _curry2 from './internal/_curry2'; -import _dispatchable from './internal/_dispatchable'; -import _xdropWhile from './internal/_xdropWhile'; -import slice from './slice'; +import _curry2 from './internal/_curry2.js'; +import _dispatchable from './internal/_dispatchable.js'; +import _xdropWhile from './internal/_xdropWhile.js'; +import slice from './slice.js'; /** diff --git a/source/either.js b/source/either.js index 1c77964508..ff7997b5ec 100644 --- a/source/either.js +++ b/source/either.js @@ -1,7 +1,7 @@ -import _curry2 from './internal/_curry2'; -import _isFunction from './internal/_isFunction'; -import lift from './lift'; -import or from './or'; +import _curry2 from './internal/_curry2.js'; +import _isFunction from './internal/_isFunction.js'; +import lift from './lift.js'; +import or from './or.js'; /** diff --git a/source/empty.js b/source/empty.js index 34d6904ca7..10e68a252e 100644 --- a/source/empty.js +++ b/source/empty.js @@ -1,9 +1,9 @@ -import _curry1 from './internal/_curry1'; -import _isArguments from './internal/_isArguments'; -import _isArray from './internal/_isArray'; -import _isObject from './internal/_isObject'; -import _isString from './internal/_isString'; -import _isTypedArray from './internal/_isTypedArray'; +import _curry1 from './internal/_curry1.js'; +import _isArguments from './internal/_isArguments.js'; +import _isArray from './internal/_isArray.js'; +import _isObject from './internal/_isObject.js'; +import _isString from './internal/_isString.js'; +import _isTypedArray from './internal/_isTypedArray.js'; /** diff --git a/source/endsWith.js b/source/endsWith.js index b2bc5280c2..737c0bfe2e 100644 --- a/source/endsWith.js +++ b/source/endsWith.js @@ -1,6 +1,6 @@ -import _curry2 from './internal/_curry2'; -import equals from './equals'; -import takeLast from './takeLast'; +import _curry2 from './internal/_curry2.js'; +import equals from './equals.js'; +import takeLast from './takeLast.js'; /** * Checks if a list ends with the provided sublist. diff --git a/source/eqBy.js b/source/eqBy.js index 21d085d335..ee4aea6403 100644 --- a/source/eqBy.js +++ b/source/eqBy.js @@ -1,5 +1,5 @@ -import _curry3 from './internal/_curry3'; -import equals from './equals'; +import _curry3 from './internal/_curry3.js'; +import equals from './equals.js'; /** diff --git a/source/eqProps.js b/source/eqProps.js index 5d85beaf56..3a1528f679 100644 --- a/source/eqProps.js +++ b/source/eqProps.js @@ -1,5 +1,5 @@ -import _curry3 from './internal/_curry3'; -import equals from './equals'; +import _curry3 from './internal/_curry3.js'; +import equals from './equals.js'; /** diff --git a/source/equals.js b/source/equals.js index 8f10a70b33..648b03441a 100644 --- a/source/equals.js +++ b/source/equals.js @@ -1,5 +1,5 @@ -import _curry2 from './internal/_curry2'; -import _equals from './internal/_equals'; +import _curry2 from './internal/_curry2.js'; +import _equals from './internal/_equals.js'; /** diff --git a/source/evolve.js b/source/evolve.js index fb6eaa8f7b..31456e26d5 100644 --- a/source/evolve.js +++ b/source/evolve.js @@ -1,4 +1,4 @@ -import _curry2 from './internal/_curry2'; +import _curry2 from './internal/_curry2.js'; /** diff --git a/source/filter.js b/source/filter.js index bc8b42244c..f76cad8b43 100644 --- a/source/filter.js +++ b/source/filter.js @@ -1,10 +1,10 @@ -import _curry2 from './internal/_curry2'; -import _dispatchable from './internal/_dispatchable'; -import _filter from './internal/_filter'; -import _isObject from './internal/_isObject'; -import _reduce from './internal/_reduce'; -import _xfilter from './internal/_xfilter'; -import keys from './keys'; +import _curry2 from './internal/_curry2.js'; +import _dispatchable from './internal/_dispatchable.js'; +import _filter from './internal/_filter.js'; +import _isObject from './internal/_isObject.js'; +import _reduce from './internal/_reduce.js'; +import _xfilter from './internal/_xfilter.js'; +import keys from './keys.js'; /** diff --git a/source/find.js b/source/find.js index 5ca1f78b5b..34bba93911 100644 --- a/source/find.js +++ b/source/find.js @@ -1,6 +1,6 @@ -import _curry2 from './internal/_curry2'; -import _dispatchable from './internal/_dispatchable'; -import _xfind from './internal/_xfind'; +import _curry2 from './internal/_curry2.js'; +import _dispatchable from './internal/_dispatchable.js'; +import _xfind from './internal/_xfind.js'; /** diff --git a/source/findIndex.js b/source/findIndex.js index 693c7d29ed..974d28b199 100644 --- a/source/findIndex.js +++ b/source/findIndex.js @@ -1,6 +1,6 @@ -import _curry2 from './internal/_curry2'; -import _dispatchable from './internal/_dispatchable'; -import _xfindIndex from './internal/_xfindIndex'; +import _curry2 from './internal/_curry2.js'; +import _dispatchable from './internal/_dispatchable.js'; +import _xfindIndex from './internal/_xfindIndex.js'; /** diff --git a/source/findLast.js b/source/findLast.js index 6eb001f6b1..606cfb05f0 100644 --- a/source/findLast.js +++ b/source/findLast.js @@ -1,6 +1,6 @@ -import _curry2 from './internal/_curry2'; -import _dispatchable from './internal/_dispatchable'; -import _xfindLast from './internal/_xfindLast'; +import _curry2 from './internal/_curry2.js'; +import _dispatchable from './internal/_dispatchable.js'; +import _xfindLast from './internal/_xfindLast.js'; /** diff --git a/source/findLastIndex.js b/source/findLastIndex.js index 66f3328e0f..7ee5193740 100644 --- a/source/findLastIndex.js +++ b/source/findLastIndex.js @@ -1,6 +1,6 @@ -import _curry2 from './internal/_curry2'; -import _dispatchable from './internal/_dispatchable'; -import _xfindLastIndex from './internal/_xfindLastIndex'; +import _curry2 from './internal/_curry2.js'; +import _dispatchable from './internal/_dispatchable.js'; +import _xfindLastIndex from './internal/_xfindLastIndex.js'; /** diff --git a/source/flatten.js b/source/flatten.js index 0ad9992814..39c08250da 100644 --- a/source/flatten.js +++ b/source/flatten.js @@ -1,5 +1,5 @@ -import _curry1 from './internal/_curry1'; -import _makeFlat from './internal/_makeFlat'; +import _curry1 from './internal/_curry1.js'; +import _makeFlat from './internal/_makeFlat.js'; /** diff --git a/source/flip.js b/source/flip.js index 006712c257..0793515b85 100644 --- a/source/flip.js +++ b/source/flip.js @@ -1,5 +1,5 @@ -import _curry1 from './internal/_curry1'; -import curryN from './curryN'; +import _curry1 from './internal/_curry1.js'; +import curryN from './curryN.js'; /** diff --git a/source/forEach.js b/source/forEach.js index 82ac80d19c..105a6c3aca 100644 --- a/source/forEach.js +++ b/source/forEach.js @@ -1,5 +1,5 @@ -import _checkForMethod from './internal/_checkForMethod'; -import _curry2 from './internal/_curry2'; +import _checkForMethod from './internal/_checkForMethod.js'; +import _curry2 from './internal/_curry2.js'; /** diff --git a/source/forEachObjIndexed.js b/source/forEachObjIndexed.js index 5ab016b967..27faa98d79 100644 --- a/source/forEachObjIndexed.js +++ b/source/forEachObjIndexed.js @@ -1,5 +1,5 @@ -import _curry2 from './internal/_curry2'; -import keys from './keys'; +import _curry2 from './internal/_curry2.js'; +import keys from './keys.js'; /** diff --git a/source/fromPairs.js b/source/fromPairs.js index 03a6fb9c4b..52cddb932d 100644 --- a/source/fromPairs.js +++ b/source/fromPairs.js @@ -1,4 +1,4 @@ -import _curry1 from './internal/_curry1'; +import _curry1 from './internal/_curry1.js'; /** diff --git a/source/groupBy.js b/source/groupBy.js index 0c0be4c02a..b88a567182 100644 --- a/source/groupBy.js +++ b/source/groupBy.js @@ -1,6 +1,6 @@ -import _checkForMethod from './internal/_checkForMethod'; -import _curry2 from './internal/_curry2'; -import reduceBy from './reduceBy'; +import _checkForMethod from './internal/_checkForMethod.js'; +import _curry2 from './internal/_curry2.js'; +import reduceBy from './reduceBy.js'; /** * Splits a list into sub-lists stored in an object, based on the result of diff --git a/source/groupWith.js b/source/groupWith.js index 1cb3b972cf..d31234a015 100644 --- a/source/groupWith.js +++ b/source/groupWith.js @@ -1,4 +1,4 @@ -import _curry2 from './internal/_curry2'; +import _curry2 from './internal/_curry2.js'; /** * Takes a list and returns a list of lists where each sublist's elements are diff --git a/source/gt.js b/source/gt.js index dc6d5a2ba5..ae4aa5e3b7 100644 --- a/source/gt.js +++ b/source/gt.js @@ -1,4 +1,4 @@ -import _curry2 from './internal/_curry2'; +import _curry2 from './internal/_curry2.js'; /** diff --git a/source/gte.js b/source/gte.js index 6e4c652217..9e49762953 100644 --- a/source/gte.js +++ b/source/gte.js @@ -1,4 +1,4 @@ -import _curry2 from './internal/_curry2'; +import _curry2 from './internal/_curry2.js'; /** diff --git a/source/has.js b/source/has.js index fc01ded607..ec8753ef69 100644 --- a/source/has.js +++ b/source/has.js @@ -1,5 +1,5 @@ -import _curry2 from './internal/_curry2'; -import hasPath from './hasPath'; +import _curry2 from './internal/_curry2.js'; +import hasPath from './hasPath.js'; /** diff --git a/source/hasIn.js b/source/hasIn.js index 1f46a91252..9c7b0e0ad1 100644 --- a/source/hasIn.js +++ b/source/hasIn.js @@ -1,5 +1,5 @@ -import _curry2 from './internal/_curry2'; -import isNil from './isNil'; +import _curry2 from './internal/_curry2.js'; +import isNil from './isNil.js'; /** diff --git a/source/hasPath.js b/source/hasPath.js index 474ce73738..c84a965544 100644 --- a/source/hasPath.js +++ b/source/hasPath.js @@ -1,7 +1,7 @@ -import _curry2 from './internal/_curry2'; -import _has from './internal/_has'; +import _curry2 from './internal/_curry2.js'; +import _has from './internal/_has.js'; -import isNil from './isNil'; +import isNil from './isNil.js'; /** diff --git a/source/head.js b/source/head.js index bb96a91abb..4506ade8fc 100644 --- a/source/head.js +++ b/source/head.js @@ -1,4 +1,4 @@ -import nth from './nth'; +import nth from './nth.js'; /** diff --git a/source/identical.js b/source/identical.js index c22b94da7b..025efb67be 100644 --- a/source/identical.js +++ b/source/identical.js @@ -1,5 +1,5 @@ -import _objectIs from './internal/_objectIs'; -import _curry2 from './internal/_curry2'; +import _objectIs from './internal/_objectIs.js'; +import _curry2 from './internal/_curry2.js'; /** diff --git a/source/identity.js b/source/identity.js index 2cc7326e0b..3aa99c64ea 100644 --- a/source/identity.js +++ b/source/identity.js @@ -1,5 +1,5 @@ -import _curry1 from './internal/_curry1'; -import _identity from './internal/_identity'; +import _curry1 from './internal/_curry1.js'; +import _identity from './internal/_identity.js'; /** diff --git a/source/ifElse.js b/source/ifElse.js index e563c18fc8..b2e2e2af9a 100644 --- a/source/ifElse.js +++ b/source/ifElse.js @@ -1,5 +1,5 @@ -import _curry3 from './internal/_curry3'; -import curryN from './curryN'; +import _curry3 from './internal/_curry3.js'; +import curryN from './curryN.js'; /** diff --git a/source/inc.js b/source/inc.js index 91b2391884..b39a5c6016 100644 --- a/source/inc.js +++ b/source/inc.js @@ -1,4 +1,4 @@ -import add from './add'; +import add from './add.js'; /** diff --git a/source/includes.js b/source/includes.js index 784be5df6c..2fed8c9fd5 100644 --- a/source/includes.js +++ b/source/includes.js @@ -1,5 +1,5 @@ -import _includes from './internal/_includes'; -import _curry2 from './internal/_curry2'; +import _includes from './internal/_includes.js'; +import _curry2 from './internal/_curry2.js'; /** * Returns `true` if the specified value is equal, in [`R.equals`](#equals) diff --git a/source/index.js b/source/index.js index b498b05947..8538cfafa8 100644 --- a/source/index.js +++ b/source/index.js @@ -1,256 +1,256 @@ -export { default as F } from './F'; -export { default as T } from './T'; -export { default as __ } from './__'; -export { default as add } from './add'; -export { default as addIndex } from './addIndex'; -export { default as adjust } from './adjust'; -export { default as all } from './all'; -export { default as allPass } from './allPass'; -export { default as always } from './always'; -export { default as and } from './and'; -export { default as any } from './any'; -export { default as anyPass } from './anyPass'; -export { default as ap } from './ap'; -export { default as aperture } from './aperture'; -export { default as append } from './append'; -export { default as apply } from './apply'; -export { default as applySpec } from './applySpec'; -export { default as applyTo } from './applyTo'; -export { default as ascend } from './ascend'; -export { default as assoc } from './assoc'; -export { default as assocPath } from './assocPath'; -export { default as binary } from './binary'; -export { default as bind } from './bind'; -export { default as both } from './both'; -export { default as call } from './call'; -export { default as chain } from './chain'; -export { default as clamp } from './clamp'; -export { default as clone } from './clone'; -export { default as collectBy } from './collectBy'; -export { default as comparator } from './comparator'; -export { default as complement } from './complement'; -export { default as compose } from './compose'; -export { default as composeWith } from './composeWith'; -export { default as concat } from './concat'; -export { default as cond } from './cond'; -export { default as construct } from './construct'; -export { default as constructN } from './constructN'; -export { default as converge } from './converge'; -export { default as countBy } from './countBy'; -export { default as curry } from './curry'; -export { default as curryN } from './curryN'; -export { default as dec } from './dec'; -export { default as defaultTo } from './defaultTo'; -export { default as descend } from './descend'; -export { default as difference } from './difference'; -export { default as differenceWith } from './differenceWith'; -export { default as dissoc } from './dissoc'; -export { default as dissocPath } from './dissocPath'; -export { default as divide } from './divide'; -export { default as drop } from './drop'; -export { default as dropLast } from './dropLast'; -export { default as dropLastWhile } from './dropLastWhile'; -export { default as dropRepeats } from './dropRepeats'; -export { default as dropRepeatsWith } from './dropRepeatsWith'; -export { default as dropWhile } from './dropWhile'; -export { default as either } from './either'; -export { default as empty } from './empty'; -export { default as endsWith } from './endsWith'; -export { default as eqBy } from './eqBy'; -export { default as eqProps } from './eqProps'; -export { default as equals } from './equals'; -export { default as evolve } from './evolve'; -export { default as filter } from './filter'; -export { default as find } from './find'; -export { default as findIndex } from './findIndex'; -export { default as findLast } from './findLast'; -export { default as findLastIndex } from './findLastIndex'; -export { default as flatten } from './flatten'; -export { default as flip } from './flip'; -export { default as forEach } from './forEach'; -export { default as forEachObjIndexed } from './forEachObjIndexed'; -export { default as fromPairs } from './fromPairs'; -export { default as groupBy } from './groupBy'; -export { default as groupWith } from './groupWith'; -export { default as gt } from './gt'; -export { default as gte } from './gte'; -export { default as has } from './has'; -export { default as hasIn } from './hasIn'; -export { default as hasPath } from './hasPath'; -export { default as head } from './head'; -export { default as identical } from './identical'; -export { default as identity } from './identity'; -export { default as ifElse } from './ifElse'; -export { default as inc } from './inc'; -export { default as includes } from './includes'; -export { default as indexBy } from './indexBy'; -export { default as indexOf } from './indexOf'; -export { default as init } from './init'; -export { default as innerJoin } from './innerJoin'; -export { default as insert } from './insert'; -export { default as insertAll } from './insertAll'; -export { default as intersection } from './intersection'; -export { default as intersperse } from './intersperse'; -export { default as into } from './into'; -export { default as invert } from './invert'; -export { default as invertObj } from './invertObj'; -export { default as invoker } from './invoker'; -export { default as is } from './is'; -export { default as isEmpty } from './isEmpty'; -export { default as isNil } from './isNil'; -export { default as join } from './join'; -export { default as juxt } from './juxt'; -export { default as keys } from './keys'; -export { default as keysIn } from './keysIn'; -export { default as last } from './last'; -export { default as lastIndexOf } from './lastIndexOf'; -export { default as length } from './length'; -export { default as lens } from './lens'; -export { default as lensIndex } from './lensIndex'; -export { default as lensPath } from './lensPath'; -export { default as lensProp } from './lensProp'; -export { default as lift } from './lift'; -export { default as liftN } from './liftN'; -export { default as lt } from './lt'; -export { default as lte } from './lte'; -export { default as map } from './map'; -export { default as mapAccum } from './mapAccum'; -export { default as mapAccumRight } from './mapAccumRight'; -export { default as mapObjIndexed } from './mapObjIndexed'; -export { default as match } from './match'; -export { default as mathMod } from './mathMod'; -export { default as max } from './max'; -export { default as maxBy } from './maxBy'; -export { default as mean } from './mean'; -export { default as median } from './median'; -export { default as memoizeWith } from './memoizeWith'; -export { default as mergeAll } from './mergeAll'; -export { default as mergeDeepLeft } from './mergeDeepLeft'; -export { default as mergeDeepRight } from './mergeDeepRight'; -export { default as mergeDeepWith } from './mergeDeepWith'; -export { default as mergeDeepWithKey } from './mergeDeepWithKey'; -export { default as mergeLeft } from './mergeLeft'; -export { default as mergeRight } from './mergeRight'; -export { default as mergeWith } from './mergeWith'; -export { default as mergeWithKey } from './mergeWithKey'; -export { default as min } from './min'; -export { default as minBy } from './minBy'; -export { default as modulo } from './modulo'; -export { default as move } from './move'; -export { default as multiply } from './multiply'; -export { default as nAry } from './nAry'; -export { default as negate } from './negate'; -export { default as none } from './none'; -export { default as not } from './not'; -export { default as nth } from './nth'; -export { default as nthArg } from './nthArg'; -export { default as o } from './o'; -export { default as objOf } from './objOf'; -export { default as of } from './of'; -export { default as omit } from './omit'; -export { default as on } from './on'; -export { default as once } from './once'; -export { default as or } from './or'; -export { default as otherwise } from './otherwise'; -export { default as over } from './over'; -export { default as pair } from './pair'; -export { default as partial } from './partial'; -export { default as partialRight } from './partialRight'; -export { default as partition } from './partition'; -export { default as path } from './path'; -export { default as paths } from './paths'; -export { default as pathEq } from './pathEq'; -export { default as pathOr } from './pathOr'; -export { default as pathSatisfies } from './pathSatisfies'; -export { default as pick } from './pick'; -export { default as pickAll } from './pickAll'; -export { default as pickBy } from './pickBy'; -export { default as pipe } from './pipe'; -export { default as pipeWith } from './pipeWith'; -export { default as pluck } from './pluck'; -export { default as prepend } from './prepend'; -export { default as product } from './product'; -export { default as project } from './project'; -export { default as promap } from './promap'; -export { default as prop } from './prop'; -export { default as propEq } from './propEq'; -export { default as propIs } from './propIs'; -export { default as propOr } from './propOr'; -export { default as propSatisfies } from './propSatisfies'; -export { default as props } from './props'; -export { default as range } from './range'; -export { default as reduce } from './reduce'; -export { default as reduceBy } from './reduceBy'; -export { default as reduceRight } from './reduceRight'; -export { default as reduceWhile } from './reduceWhile'; -export { default as reduced } from './reduced'; -export { default as reject } from './reject'; -export { default as remove } from './remove'; -export { default as repeat } from './repeat'; -export { default as replace } from './replace'; -export { default as reverse } from './reverse'; -export { default as scan } from './scan'; -export { default as sequence } from './sequence'; -export { default as set } from './set'; -export { default as slice } from './slice'; -export { default as sort } from './sort'; -export { default as sortBy } from './sortBy'; -export { default as sortWith } from './sortWith'; -export { default as split } from './split'; -export { default as splitAt } from './splitAt'; -export { default as splitEvery } from './splitEvery'; -export { default as splitWhen } from './splitWhen'; -export { default as splitWhenever } from './splitWhenever'; -export { default as startsWith } from './startsWith'; -export { default as subtract } from './subtract'; -export { default as sum } from './sum'; -export { default as symmetricDifference } from './symmetricDifference'; -export { default as symmetricDifferenceWith } from './symmetricDifferenceWith'; -export { default as tail } from './tail'; -export { default as take } from './take'; -export { default as takeLast } from './takeLast'; -export { default as takeLastWhile } from './takeLastWhile'; -export { default as takeWhile } from './takeWhile'; -export { default as tap } from './tap'; -export { default as test } from './test'; -export { default as andThen } from './andThen'; -export { default as times } from './times'; -export { default as toLower } from './toLower'; -export { default as toPairs } from './toPairs'; -export { default as toPairsIn } from './toPairsIn'; -export { default as toString } from './toString'; -export { default as toUpper } from './toUpper'; -export { default as transduce } from './transduce'; -export { default as transpose } from './transpose'; -export { default as traverse } from './traverse'; -export { default as trim } from './trim'; -export { default as tryCatch } from './tryCatch'; -export { default as type } from './type'; -export { default as unapply } from './unapply'; -export { default as unary } from './unary'; -export { default as uncurryN } from './uncurryN'; -export { default as unfold } from './unfold'; -export { default as union } from './union'; -export { default as unionWith } from './unionWith'; -export { default as uniq } from './uniq'; -export { default as uniqBy } from './uniqBy'; -export { default as uniqWith } from './uniqWith'; -export { default as unless } from './unless'; -export { default as unnest } from './unnest'; -export { default as until } from './until'; -export { default as update } from './update'; -export { default as useWith } from './useWith'; -export { default as values } from './values'; -export { default as valuesIn } from './valuesIn'; -export { default as view } from './view'; -export { default as when } from './when'; -export { default as where } from './where'; -export { default as whereAny } from './whereAny'; -export { default as whereEq } from './whereEq'; -export { default as without } from './without'; -export { default as xor } from './xor'; -export { default as xprod } from './xprod'; -export { default as zip } from './zip'; -export { default as zipObj } from './zipObj'; -export { default as zipWith } from './zipWith'; -export { default as thunkify } from './thunkify'; +export { default as F } from './F.js'; +export { default as T } from './T.js'; +export { default as __ } from './__.js'; +export { default as add } from './add.js'; +export { default as addIndex } from './addIndex.js'; +export { default as adjust } from './adjust.js'; +export { default as all } from './all.js'; +export { default as allPass } from './allPass.js'; +export { default as always } from './always.js'; +export { default as and } from './and.js'; +export { default as any } from './any.js'; +export { default as anyPass } from './anyPass.js'; +export { default as ap } from './ap.js'; +export { default as aperture } from './aperture.js'; +export { default as append } from './append.js'; +export { default as apply } from './apply.js'; +export { default as applySpec } from './applySpec.js'; +export { default as applyTo } from './applyTo.js'; +export { default as ascend } from './ascend.js'; +export { default as assoc } from './assoc.js'; +export { default as assocPath } from './assocPath.js'; +export { default as binary } from './binary.js'; +export { default as bind } from './bind.js'; +export { default as both } from './both.js'; +export { default as call } from './call.js'; +export { default as chain } from './chain.js'; +export { default as clamp } from './clamp.js'; +export { default as clone } from './clone.js'; +export { default as collectBy } from './collectBy.js'; +export { default as comparator } from './comparator.js'; +export { default as complement } from './complement.js'; +export { default as compose } from './compose.js'; +export { default as composeWith } from './composeWith.js'; +export { default as concat } from './concat.js'; +export { default as cond } from './cond.js'; +export { default as construct } from './construct.js'; +export { default as constructN } from './constructN.js'; +export { default as converge } from './converge.js'; +export { default as countBy } from './countBy.js'; +export { default as curry } from './curry.js'; +export { default as curryN } from './curryN.js'; +export { default as dec } from './dec.js'; +export { default as defaultTo } from './defaultTo.js'; +export { default as descend } from './descend.js'; +export { default as difference } from './difference.js'; +export { default as differenceWith } from './differenceWith.js'; +export { default as dissoc } from './dissoc.js'; +export { default as dissocPath } from './dissocPath.js'; +export { default as divide } from './divide.js'; +export { default as drop } from './drop.js'; +export { default as dropLast } from './dropLast.js'; +export { default as dropLastWhile } from './dropLastWhile.js'; +export { default as dropRepeats } from './dropRepeats.js'; +export { default as dropRepeatsWith } from './dropRepeatsWith.js'; +export { default as dropWhile } from './dropWhile.js'; +export { default as either } from './either.js'; +export { default as empty } from './empty.js'; +export { default as endsWith } from './endsWith.js'; +export { default as eqBy } from './eqBy.js'; +export { default as eqProps } from './eqProps.js'; +export { default as equals } from './equals.js'; +export { default as evolve } from './evolve.js'; +export { default as filter } from './filter.js'; +export { default as find } from './find.js'; +export { default as findIndex } from './findIndex.js'; +export { default as findLast } from './findLast.js'; +export { default as findLastIndex } from './findLastIndex.js'; +export { default as flatten } from './flatten.js'; +export { default as flip } from './flip.js'; +export { default as forEach } from './forEach.js'; +export { default as forEachObjIndexed } from './forEachObjIndexed.js'; +export { default as fromPairs } from './fromPairs.js'; +export { default as groupBy } from './groupBy.js'; +export { default as groupWith } from './groupWith.js'; +export { default as gt } from './gt.js'; +export { default as gte } from './gte.js'; +export { default as has } from './has.js'; +export { default as hasIn } from './hasIn.js'; +export { default as hasPath } from './hasPath.js'; +export { default as head } from './head.js'; +export { default as identical } from './identical.js'; +export { default as identity } from './identity.js'; +export { default as ifElse } from './ifElse.js'; +export { default as inc } from './inc.js'; +export { default as includes } from './includes.js'; +export { default as indexBy } from './indexBy.js'; +export { default as indexOf } from './indexOf.js'; +export { default as init } from './init.js'; +export { default as innerJoin } from './innerJoin.js'; +export { default as insert } from './insert.js'; +export { default as insertAll } from './insertAll.js'; +export { default as intersection } from './intersection.js'; +export { default as intersperse } from './intersperse.js'; +export { default as into } from './into.js'; +export { default as invert } from './invert.js'; +export { default as invertObj } from './invertObj.js'; +export { default as invoker } from './invoker.js'; +export { default as is } from './is.js'; +export { default as isEmpty } from './isEmpty.js'; +export { default as isNil } from './isNil.js'; +export { default as join } from './join.js'; +export { default as juxt } from './juxt.js'; +export { default as keys } from './keys.js'; +export { default as keysIn } from './keysIn.js'; +export { default as last } from './last.js'; +export { default as lastIndexOf } from './lastIndexOf.js'; +export { default as length } from './length.js'; +export { default as lens } from './lens.js'; +export { default as lensIndex } from './lensIndex.js'; +export { default as lensPath } from './lensPath.js'; +export { default as lensProp } from './lensProp.js'; +export { default as lift } from './lift.js'; +export { default as liftN } from './liftN.js'; +export { default as lt } from './lt.js'; +export { default as lte } from './lte.js'; +export { default as map } from './map.js'; +export { default as mapAccum } from './mapAccum.js'; +export { default as mapAccumRight } from './mapAccumRight.js'; +export { default as mapObjIndexed } from './mapObjIndexed.js'; +export { default as match } from './match.js'; +export { default as mathMod } from './mathMod.js'; +export { default as max } from './max.js'; +export { default as maxBy } from './maxBy.js'; +export { default as mean } from './mean.js'; +export { default as median } from './median.js'; +export { default as memoizeWith } from './memoizeWith.js'; +export { default as mergeAll } from './mergeAll.js'; +export { default as mergeDeepLeft } from './mergeDeepLeft.js'; +export { default as mergeDeepRight } from './mergeDeepRight.js'; +export { default as mergeDeepWith } from './mergeDeepWith.js'; +export { default as mergeDeepWithKey } from './mergeDeepWithKey.js'; +export { default as mergeLeft } from './mergeLeft.js'; +export { default as mergeRight } from './mergeRight.js'; +export { default as mergeWith } from './mergeWith.js'; +export { default as mergeWithKey } from './mergeWithKey.js'; +export { default as min } from './min.js'; +export { default as minBy } from './minBy.js'; +export { default as modulo } from './modulo.js'; +export { default as move } from './move.js'; +export { default as multiply } from './multiply.js'; +export { default as nAry } from './nAry.js'; +export { default as negate } from './negate.js'; +export { default as none } from './none.js'; +export { default as not } from './not.js'; +export { default as nth } from './nth.js'; +export { default as nthArg } from './nthArg.js'; +export { default as o } from './o.js'; +export { default as objOf } from './objOf.js'; +export { default as of } from './of.js'; +export { default as omit } from './omit.js'; +export { default as on } from './on.js'; +export { default as once } from './once.js'; +export { default as or } from './or.js'; +export { default as otherwise } from './otherwise.js'; +export { default as over } from './over.js'; +export { default as pair } from './pair.js'; +export { default as partial } from './partial.js'; +export { default as partialRight } from './partialRight.js'; +export { default as partition } from './partition.js'; +export { default as path } from './path.js'; +export { default as paths } from './paths.js'; +export { default as pathEq } from './pathEq.js'; +export { default as pathOr } from './pathOr.js'; +export { default as pathSatisfies } from './pathSatisfies.js'; +export { default as pick } from './pick.js'; +export { default as pickAll } from './pickAll.js'; +export { default as pickBy } from './pickBy.js'; +export { default as pipe } from './pipe.js'; +export { default as pipeWith } from './pipeWith.js'; +export { default as pluck } from './pluck.js'; +export { default as prepend } from './prepend.js'; +export { default as product } from './product.js'; +export { default as project } from './project.js'; +export { default as promap } from './promap.js'; +export { default as prop } from './prop.js'; +export { default as propEq } from './propEq.js'; +export { default as propIs } from './propIs.js'; +export { default as propOr } from './propOr.js'; +export { default as propSatisfies } from './propSatisfies.js'; +export { default as props } from './props.js'; +export { default as range } from './range.js'; +export { default as reduce } from './reduce.js'; +export { default as reduceBy } from './reduceBy.js'; +export { default as reduceRight } from './reduceRight.js'; +export { default as reduceWhile } from './reduceWhile.js'; +export { default as reduced } from './reduced.js'; +export { default as reject } from './reject.js'; +export { default as remove } from './remove.js'; +export { default as repeat } from './repeat.js'; +export { default as replace } from './replace.js'; +export { default as reverse } from './reverse.js'; +export { default as scan } from './scan.js'; +export { default as sequence } from './sequence.js'; +export { default as set } from './set.js'; +export { default as slice } from './slice.js'; +export { default as sort } from './sort.js'; +export { default as sortBy } from './sortBy.js'; +export { default as sortWith } from './sortWith.js'; +export { default as split } from './split.js'; +export { default as splitAt } from './splitAt.js'; +export { default as splitEvery } from './splitEvery.js'; +export { default as splitWhen } from './splitWhen.js'; +export { default as splitWhenever } from './splitWhenever.js'; +export { default as startsWith } from './startsWith.js'; +export { default as subtract } from './subtract.js'; +export { default as sum } from './sum.js'; +export { default as symmetricDifference } from './symmetricDifference.js'; +export { default as symmetricDifferenceWith } from './symmetricDifferenceWith.js'; +export { default as tail } from './tail.js'; +export { default as take } from './take.js'; +export { default as takeLast } from './takeLast.js'; +export { default as takeLastWhile } from './takeLastWhile.js'; +export { default as takeWhile } from './takeWhile.js'; +export { default as tap } from './tap.js'; +export { default as test } from './test.js'; +export { default as andThen } from './andThen.js'; +export { default as times } from './times.js'; +export { default as toLower } from './toLower.js'; +export { default as toPairs } from './toPairs.js'; +export { default as toPairsIn } from './toPairsIn.js'; +export { default as toString } from './toString.js'; +export { default as toUpper } from './toUpper.js'; +export { default as transduce } from './transduce.js'; +export { default as transpose } from './transpose.js'; +export { default as traverse } from './traverse.js'; +export { default as trim } from './trim.js'; +export { default as tryCatch } from './tryCatch.js'; +export { default as type } from './type.js'; +export { default as unapply } from './unapply.js'; +export { default as unary } from './unary.js'; +export { default as uncurryN } from './uncurryN.js'; +export { default as unfold } from './unfold.js'; +export { default as union } from './union.js'; +export { default as unionWith } from './unionWith.js'; +export { default as uniq } from './uniq.js'; +export { default as uniqBy } from './uniqBy.js'; +export { default as uniqWith } from './uniqWith.js'; +export { default as unless } from './unless.js'; +export { default as unnest } from './unnest.js'; +export { default as until } from './until.js'; +export { default as update } from './update.js'; +export { default as useWith } from './useWith.js'; +export { default as values } from './values.js'; +export { default as valuesIn } from './valuesIn.js'; +export { default as view } from './view.js'; +export { default as when } from './when.js'; +export { default as where } from './where.js'; +export { default as whereAny } from './whereAny.js'; +export { default as whereEq } from './whereEq.js'; +export { default as without } from './without.js'; +export { default as xor } from './xor.js'; +export { default as xprod } from './xprod.js'; +export { default as zip } from './zip.js'; +export { default as zipObj } from './zipObj.js'; +export { default as zipWith } from './zipWith.js'; +export { default as thunkify } from './thunkify.js'; diff --git a/source/indexBy.js b/source/indexBy.js index a359053c34..8676296035 100644 --- a/source/indexBy.js +++ b/source/indexBy.js @@ -1,4 +1,4 @@ -import reduceBy from './reduceBy'; +import reduceBy from './reduceBy.js'; /** diff --git a/source/indexOf.js b/source/indexOf.js index 238ac42cef..fd5604dcd8 100644 --- a/source/indexOf.js +++ b/source/indexOf.js @@ -1,6 +1,6 @@ -import _curry2 from './internal/_curry2'; -import _indexOf from './internal/_indexOf'; -import _isArray from './internal/_isArray'; +import _curry2 from './internal/_curry2.js'; +import _indexOf from './internal/_indexOf.js'; +import _isArray from './internal/_isArray.js'; /** diff --git a/source/init.js b/source/init.js index 5099698785..a94d3c34f9 100644 --- a/source/init.js +++ b/source/init.js @@ -1,4 +1,4 @@ -import slice from './slice'; +import slice from './slice.js'; /** diff --git a/source/innerJoin.js b/source/innerJoin.js index 17ef779e77..ab472e4838 100644 --- a/source/innerJoin.js +++ b/source/innerJoin.js @@ -1,6 +1,6 @@ -import _includesWith from './internal/_includesWith'; -import _curry3 from './internal/_curry3'; -import _filter from './internal/_filter'; +import _includesWith from './internal/_includesWith.js'; +import _curry3 from './internal/_curry3.js'; +import _filter from './internal/_filter.js'; /** diff --git a/source/insert.js b/source/insert.js index c74e5b4b66..2aacfd0dfb 100644 --- a/source/insert.js +++ b/source/insert.js @@ -1,4 +1,4 @@ -import _curry3 from './internal/_curry3'; +import _curry3 from './internal/_curry3.js'; /** diff --git a/source/insertAll.js b/source/insertAll.js index b7bc1ad006..62336bb502 100644 --- a/source/insertAll.js +++ b/source/insertAll.js @@ -1,4 +1,4 @@ -import _curry3 from './internal/_curry3'; +import _curry3 from './internal/_curry3.js'; /** diff --git a/source/internal/_Set.js b/source/internal/_Set.js index ab2756ef58..b908fcae50 100644 --- a/source/internal/_Set.js +++ b/source/internal/_Set.js @@ -1,4 +1,4 @@ -import _includes from './_includes'; +import _includes from './_includes.js'; function _Set() { diff --git a/source/internal/_assertPromise.js b/source/internal/_assertPromise.js index 5a91e25e68..7aeba631a0 100644 --- a/source/internal/_assertPromise.js +++ b/source/internal/_assertPromise.js @@ -1,5 +1,5 @@ -import _isFunction from './_isFunction'; -import _toString from './_toString'; +import _isFunction from './_isFunction.js'; +import _toString from './_toString.js'; export default function _assertPromise(name, p) { if (p == null || !_isFunction(p.then)) { diff --git a/source/internal/_checkForMethod.js b/source/internal/_checkForMethod.js index f2d1307a3c..8d2cc7f183 100644 --- a/source/internal/_checkForMethod.js +++ b/source/internal/_checkForMethod.js @@ -1,4 +1,4 @@ -import _isArray from './_isArray'; +import _isArray from './_isArray.js'; /** diff --git a/source/internal/_clone.js b/source/internal/_clone.js index 98a0e34242..5f93182b7e 100644 --- a/source/internal/_clone.js +++ b/source/internal/_clone.js @@ -1,5 +1,5 @@ -import _cloneRegExp from './_cloneRegExp'; -import type from '../type'; +import _cloneRegExp from './_cloneRegExp.js'; +import type from '../type.js'; /** diff --git a/source/internal/_createPartialApplicator.js b/source/internal/_createPartialApplicator.js index a0541dce4c..8a80652cf9 100644 --- a/source/internal/_createPartialApplicator.js +++ b/source/internal/_createPartialApplicator.js @@ -1,5 +1,5 @@ -import _arity from './_arity'; -import _curry2 from './_curry2'; +import _arity from './_arity.js'; +import _curry2 from './_curry2.js'; export default function _createPartialApplicator(concat) { diff --git a/source/internal/_curry1.js b/source/internal/_curry1.js index e24648863c..00573ee99a 100644 --- a/source/internal/_curry1.js +++ b/source/internal/_curry1.js @@ -1,4 +1,4 @@ -import _isPlaceholder from './_isPlaceholder'; +import _isPlaceholder from './_isPlaceholder.js'; /** diff --git a/source/internal/_curry2.js b/source/internal/_curry2.js index f65bdeab25..10a1e57e72 100644 --- a/source/internal/_curry2.js +++ b/source/internal/_curry2.js @@ -1,5 +1,5 @@ -import _curry1 from './_curry1'; -import _isPlaceholder from './_isPlaceholder'; +import _curry1 from './_curry1.js'; +import _isPlaceholder from './_isPlaceholder.js'; /** diff --git a/source/internal/_curry3.js b/source/internal/_curry3.js index 8759e81c09..df7f18634c 100644 --- a/source/internal/_curry3.js +++ b/source/internal/_curry3.js @@ -1,6 +1,6 @@ -import _curry1 from './_curry1'; -import _curry2 from './_curry2'; -import _isPlaceholder from './_isPlaceholder'; +import _curry1 from './_curry1.js'; +import _curry2 from './_curry2.js'; +import _isPlaceholder from './_isPlaceholder.js'; /** diff --git a/source/internal/_curryN.js b/source/internal/_curryN.js index 3f95bd1281..272a6a70c8 100644 --- a/source/internal/_curryN.js +++ b/source/internal/_curryN.js @@ -1,5 +1,5 @@ -import _arity from './_arity'; -import _isPlaceholder from './_isPlaceholder'; +import _arity from './_arity.js'; +import _isPlaceholder from './_isPlaceholder.js'; /** diff --git a/source/internal/_dispatchable.js b/source/internal/_dispatchable.js index 2cf1728a51..d3a55e1c01 100644 --- a/source/internal/_dispatchable.js +++ b/source/internal/_dispatchable.js @@ -1,5 +1,5 @@ -import _isArray from './_isArray'; -import _isTransformer from './_isTransformer'; +import _isArray from './_isArray.js'; +import _isTransformer from './_isTransformer.js'; /** diff --git a/source/internal/_dropLast.js b/source/internal/_dropLast.js index ba845c7f9e..b1029645e7 100644 --- a/source/internal/_dropLast.js +++ b/source/internal/_dropLast.js @@ -1,4 +1,4 @@ -import take from '../take'; +import take from '../take.js'; export default function dropLast(n, xs) { return take(n < xs.length ? xs.length - n : 0, xs); diff --git a/source/internal/_dropLastWhile.js b/source/internal/_dropLastWhile.js index 0cec9548c8..17da9e449d 100644 --- a/source/internal/_dropLastWhile.js +++ b/source/internal/_dropLastWhile.js @@ -1,4 +1,4 @@ -import slice from '../slice'; +import slice from '../slice.js'; export default function dropLastWhile(pred, xs) { var idx = xs.length - 1; diff --git a/source/internal/_equals.js b/source/internal/_equals.js index 3400a1bae5..f5defd7c71 100644 --- a/source/internal/_equals.js +++ b/source/internal/_equals.js @@ -1,10 +1,10 @@ -import _arrayFromIterator from './_arrayFromIterator'; -import _includesWith from './_includesWith'; -import _functionName from './_functionName'; -import _has from './_has'; -import _objectIs from './_objectIs'; -import keys from '../keys'; -import type from '../type'; +import _arrayFromIterator from './_arrayFromIterator.js'; +import _includesWith from './_includesWith.js'; +import _functionName from './_functionName.js'; +import _has from './_has.js'; +import _objectIs from './_objectIs.js'; +import keys from '../keys.js'; +import type from '../type.js'; /** * private _uniqContentEquals function. diff --git a/source/internal/_flatCat.js b/source/internal/_flatCat.js index bad311734f..8ba282d2ae 100644 --- a/source/internal/_flatCat.js +++ b/source/internal/_flatCat.js @@ -1,7 +1,7 @@ -import _forceReduced from './_forceReduced'; -import _isArrayLike from './_isArrayLike'; -import _reduce from './_reduce'; -import _xfBase from './_xfBase'; +import _forceReduced from './_forceReduced.js'; +import _isArrayLike from './_isArrayLike.js'; +import _reduce from './_reduce.js'; +import _xfBase from './_xfBase.js'; var preservingReduced = function(xf) { return { diff --git a/source/internal/_functionsWith.js b/source/internal/_functionsWith.js index 173352b31d..c33635a6cd 100644 --- a/source/internal/_functionsWith.js +++ b/source/internal/_functionsWith.js @@ -1,4 +1,4 @@ -import _filter from './_filter'; +import _filter from './_filter.js'; /** diff --git a/source/internal/_includes.js b/source/internal/_includes.js index c085eb32fd..4f7402d7de 100644 --- a/source/internal/_includes.js +++ b/source/internal/_includes.js @@ -1,4 +1,4 @@ -import _indexOf from './_indexOf'; +import _indexOf from './_indexOf.js'; export default function _includes(a, list) { diff --git a/source/internal/_indexOf.js b/source/internal/_indexOf.js index b622475960..23cc4d461b 100644 --- a/source/internal/_indexOf.js +++ b/source/internal/_indexOf.js @@ -1,4 +1,4 @@ -import equals from '../equals'; +import equals from '../equals.js'; export default function _indexOf(list, a, idx) { diff --git a/source/internal/_isArguments.js b/source/internal/_isArguments.js index df9e51a280..8c4d5fbf09 100644 --- a/source/internal/_isArguments.js +++ b/source/internal/_isArguments.js @@ -1,4 +1,4 @@ -import _has from './_has'; +import _has from './_has.js'; var toString = Object.prototype.toString; diff --git a/source/internal/_isArrayLike.js b/source/internal/_isArrayLike.js index ce4485d0e9..e16bd85f64 100644 --- a/source/internal/_isArrayLike.js +++ b/source/internal/_isArrayLike.js @@ -1,6 +1,6 @@ -import _curry1 from './_curry1'; -import _isArray from './_isArray'; -import _isString from './_isString'; +import _curry1 from './_curry1.js'; +import _isArray from './_isArray.js'; +import _isString from './_isString.js'; /** diff --git a/source/internal/_makeFlat.js b/source/internal/_makeFlat.js index a96002e327..5e8fd8c85e 100644 --- a/source/internal/_makeFlat.js +++ b/source/internal/_makeFlat.js @@ -1,4 +1,4 @@ -import _isArrayLike from './_isArrayLike'; +import _isArrayLike from './_isArrayLike.js'; /** diff --git a/source/internal/_objectAssign.js b/source/internal/_objectAssign.js index 85eb239434..731ea5ca81 100644 --- a/source/internal/_objectAssign.js +++ b/source/internal/_objectAssign.js @@ -1,4 +1,4 @@ -import _has from './_has'; +import _has from './_has.js'; // Based on https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/assign function _objectAssign(target) { diff --git a/source/internal/_reduce.js b/source/internal/_reduce.js index 1ae3336532..6cc796e8f4 100644 --- a/source/internal/_reduce.js +++ b/source/internal/_reduce.js @@ -1,6 +1,6 @@ -import _isArrayLike from './_isArrayLike'; -import _xwrap from './_xwrap'; -import bind from '../bind'; +import _isArrayLike from './_isArrayLike.js'; +import _xwrap from './_xwrap.js'; +import bind from '../bind.js'; function _arrayReduce(xf, acc, list) { diff --git a/source/internal/_stepCat.js b/source/internal/_stepCat.js index c5bf3ede64..010f33fdaf 100644 --- a/source/internal/_stepCat.js +++ b/source/internal/_stepCat.js @@ -1,8 +1,8 @@ -import _objectAssign from './_objectAssign'; -import _identity from './_identity'; -import _isArrayLike from './_isArrayLike'; -import _isTransformer from './_isTransformer'; -import objOf from '../objOf'; +import _objectAssign from './_objectAssign.js'; +import _identity from './_identity.js'; +import _isArrayLike from './_isArrayLike.js'; +import _isTransformer from './_isTransformer.js'; +import objOf from '../objOf.js'; var _stepCatArray = { diff --git a/source/internal/_toString.js b/source/internal/_toString.js index f5702e10f5..ee9b6aa78e 100644 --- a/source/internal/_toString.js +++ b/source/internal/_toString.js @@ -1,9 +1,9 @@ -import _includes from './_includes'; -import _map from './_map'; -import _quote from './_quote'; -import _toISOString from './_toISOString'; -import keys from '../keys'; -import reject from '../reject'; +import _includes from './_includes.js'; +import _map from './_map.js'; +import _quote from './_quote.js'; +import _toISOString from './_toISOString.js'; +import keys from '../keys.js'; +import reject from '../reject.js'; export default function _toString(x, seen) { diff --git a/source/internal/_xall.js b/source/internal/_xall.js index c11b81345a..92d94384f1 100644 --- a/source/internal/_xall.js +++ b/source/internal/_xall.js @@ -1,6 +1,6 @@ -import _curry2 from './_curry2'; -import _reduced from './_reduced'; -import _xfBase from './_xfBase'; +import _curry2 from './_curry2.js'; +import _reduced from './_reduced.js'; +import _xfBase from './_xfBase.js'; function XAll(f, xf) { diff --git a/source/internal/_xany.js b/source/internal/_xany.js index 84ac7d94e0..79278ab3f4 100644 --- a/source/internal/_xany.js +++ b/source/internal/_xany.js @@ -1,6 +1,6 @@ -import _curry2 from './_curry2'; -import _reduced from './_reduced'; -import _xfBase from './_xfBase'; +import _curry2 from './_curry2.js'; +import _reduced from './_reduced.js'; +import _xfBase from './_xfBase.js'; function XAny(f, xf) { diff --git a/source/internal/_xaperture.js b/source/internal/_xaperture.js index b65ddf4ace..9b78692b0e 100644 --- a/source/internal/_xaperture.js +++ b/source/internal/_xaperture.js @@ -1,6 +1,6 @@ -import _concat from './_concat'; -import _curry2 from './_curry2'; -import _xfBase from './_xfBase'; +import _concat from './_concat.js'; +import _curry2 from './_curry2.js'; +import _xfBase from './_xfBase.js'; function XAperture(n, xf) { diff --git a/source/internal/_xchain.js b/source/internal/_xchain.js index 75c9a97892..fc725c801e 100644 --- a/source/internal/_xchain.js +++ b/source/internal/_xchain.js @@ -1,6 +1,6 @@ -import _curry2 from './_curry2'; -import _flatCat from './_flatCat'; -import map from '../map'; +import _curry2 from './_curry2.js'; +import _flatCat from './_flatCat.js'; +import map from '../map.js'; var _xchain = _curry2(function _xchain(f, xf) { diff --git a/source/internal/_xdrop.js b/source/internal/_xdrop.js index 4201543ed6..8044d74c37 100644 --- a/source/internal/_xdrop.js +++ b/source/internal/_xdrop.js @@ -1,5 +1,5 @@ -import _curry2 from './_curry2'; -import _xfBase from './_xfBase'; +import _curry2 from './_curry2.js'; +import _xfBase from './_xfBase.js'; function XDrop(n, xf) { diff --git a/source/internal/_xdropLast.js b/source/internal/_xdropLast.js index 513423bef5..245be0b3e4 100644 --- a/source/internal/_xdropLast.js +++ b/source/internal/_xdropLast.js @@ -1,5 +1,5 @@ -import _curry2 from './_curry2'; -import _xfBase from './_xfBase'; +import _curry2 from './_curry2.js'; +import _xfBase from './_xfBase.js'; function XDropLast(n, xf) { diff --git a/source/internal/_xdropLastWhile.js b/source/internal/_xdropLastWhile.js index 4d8ff8f02f..9040f21db0 100644 --- a/source/internal/_xdropLastWhile.js +++ b/source/internal/_xdropLastWhile.js @@ -1,6 +1,6 @@ -import _curry2 from './_curry2'; -import _reduce from './_reduce'; -import _xfBase from './_xfBase'; +import _curry2 from './_curry2.js'; +import _reduce from './_reduce.js'; +import _xfBase from './_xfBase.js'; function XDropLastWhile(fn, xf) { diff --git a/source/internal/_xdropRepeatsWith.js b/source/internal/_xdropRepeatsWith.js index da3537f61c..7befd3d779 100644 --- a/source/internal/_xdropRepeatsWith.js +++ b/source/internal/_xdropRepeatsWith.js @@ -1,5 +1,5 @@ -import _curry2 from './_curry2'; -import _xfBase from './_xfBase'; +import _curry2 from './_curry2.js'; +import _xfBase from './_xfBase.js'; function XDropRepeatsWith(pred, xf) { diff --git a/source/internal/_xdropWhile.js b/source/internal/_xdropWhile.js index 892906bee2..1e87eac3dc 100644 --- a/source/internal/_xdropWhile.js +++ b/source/internal/_xdropWhile.js @@ -1,5 +1,5 @@ -import _curry2 from './_curry2'; -import _xfBase from './_xfBase'; +import _curry2 from './_curry2.js'; +import _xfBase from './_xfBase.js'; function XDropWhile(f, xf) { diff --git a/source/internal/_xfilter.js b/source/internal/_xfilter.js index 6ffaecdeac..af71092a30 100644 --- a/source/internal/_xfilter.js +++ b/source/internal/_xfilter.js @@ -1,5 +1,5 @@ -import _curry2 from './_curry2'; -import _xfBase from './_xfBase'; +import _curry2 from './_curry2.js'; +import _xfBase from './_xfBase.js'; function XFilter(f, xf) { diff --git a/source/internal/_xfind.js b/source/internal/_xfind.js index 6929da3982..79f5d3c517 100644 --- a/source/internal/_xfind.js +++ b/source/internal/_xfind.js @@ -1,6 +1,6 @@ -import _curry2 from './_curry2'; -import _reduced from './_reduced'; -import _xfBase from './_xfBase'; +import _curry2 from './_curry2.js'; +import _reduced from './_reduced.js'; +import _xfBase from './_xfBase.js'; function XFind(f, xf) { diff --git a/source/internal/_xfindIndex.js b/source/internal/_xfindIndex.js index 6e0f2aa541..be49f36700 100644 --- a/source/internal/_xfindIndex.js +++ b/source/internal/_xfindIndex.js @@ -1,6 +1,6 @@ -import _curry2 from './_curry2'; -import _reduced from './_reduced'; -import _xfBase from './_xfBase'; +import _curry2 from './_curry2.js'; +import _reduced from './_reduced.js'; +import _xfBase from './_xfBase.js'; function XFindIndex(f, xf) { diff --git a/source/internal/_xfindLast.js b/source/internal/_xfindLast.js index 876a6b4d66..2d2631782e 100644 --- a/source/internal/_xfindLast.js +++ b/source/internal/_xfindLast.js @@ -1,5 +1,5 @@ -import _curry2 from './_curry2'; -import _xfBase from './_xfBase'; +import _curry2 from './_curry2.js'; +import _xfBase from './_xfBase.js'; function XFindLast(f, xf) { diff --git a/source/internal/_xfindLastIndex.js b/source/internal/_xfindLastIndex.js index b6f4e4af6e..15297949f0 100644 --- a/source/internal/_xfindLastIndex.js +++ b/source/internal/_xfindLastIndex.js @@ -1,5 +1,5 @@ -import _curry2 from './_curry2'; -import _xfBase from './_xfBase'; +import _curry2 from './_curry2.js'; +import _xfBase from './_xfBase.js'; function XFindLastIndex(f, xf) { diff --git a/source/internal/_xmap.js b/source/internal/_xmap.js index 4fbed5051f..e2bd331503 100644 --- a/source/internal/_xmap.js +++ b/source/internal/_xmap.js @@ -1,5 +1,5 @@ -import _curry2 from './_curry2'; -import _xfBase from './_xfBase'; +import _curry2 from './_curry2.js'; +import _xfBase from './_xfBase.js'; function XMap(f, xf) { diff --git a/source/internal/_xreduceBy.js b/source/internal/_xreduceBy.js index b036a73d99..dca36216e4 100644 --- a/source/internal/_xreduceBy.js +++ b/source/internal/_xreduceBy.js @@ -1,6 +1,6 @@ -import _curryN from './_curryN'; -import _has from './_has'; -import _xfBase from './_xfBase'; +import _curryN from './_curryN.js'; +import _has from './_has.js'; +import _xfBase from './_xfBase.js'; function XReduceBy(valueFn, valueAcc, keyFn, xf) { diff --git a/source/internal/_xtake.js b/source/internal/_xtake.js index 57f98c2004..4f03af8d00 100644 --- a/source/internal/_xtake.js +++ b/source/internal/_xtake.js @@ -1,6 +1,6 @@ -import _curry2 from './_curry2'; -import _reduced from './_reduced'; -import _xfBase from './_xfBase'; +import _curry2 from './_curry2.js'; +import _reduced from './_reduced.js'; +import _xfBase from './_xfBase.js'; function XTake(n, xf) { diff --git a/source/internal/_xtakeWhile.js b/source/internal/_xtakeWhile.js index 9915078f9d..46614ad07f 100644 --- a/source/internal/_xtakeWhile.js +++ b/source/internal/_xtakeWhile.js @@ -1,6 +1,6 @@ -import _curry2 from './_curry2'; -import _reduced from './_reduced'; -import _xfBase from './_xfBase'; +import _curry2 from './_curry2.js'; +import _reduced from './_reduced.js'; +import _xfBase from './_xfBase.js'; function XTakeWhile(f, xf) { diff --git a/source/internal/_xtap.js b/source/internal/_xtap.js index d1b5fbefcd..531d6f4996 100644 --- a/source/internal/_xtap.js +++ b/source/internal/_xtap.js @@ -1,5 +1,5 @@ -import _curry2 from './_curry2'; -import _xfBase from './_xfBase'; +import _curry2 from './_curry2.js'; +import _xfBase from './_xfBase.js'; function XTap(f, xf) { diff --git a/source/intersection.js b/source/intersection.js index 5675315d2c..0dbbeee0d2 100644 --- a/source/intersection.js +++ b/source/intersection.js @@ -1,8 +1,8 @@ -import _includes from './internal/_includes'; -import _curry2 from './internal/_curry2'; -import _filter from './internal/_filter'; -import flip from './flip'; -import uniq from './uniq'; +import _includes from './internal/_includes.js'; +import _curry2 from './internal/_curry2.js'; +import _filter from './internal/_filter.js'; +import flip from './flip.js'; +import uniq from './uniq.js'; /** diff --git a/source/intersperse.js b/source/intersperse.js index c8d919c1a9..3a200de1c2 100644 --- a/source/intersperse.js +++ b/source/intersperse.js @@ -1,5 +1,5 @@ -import _checkForMethod from './internal/_checkForMethod'; -import _curry2 from './internal/_curry2'; +import _checkForMethod from './internal/_checkForMethod.js'; +import _curry2 from './internal/_curry2.js'; /** diff --git a/source/into.js b/source/into.js index 9737dc78d3..3544f7a21b 100644 --- a/source/into.js +++ b/source/into.js @@ -1,8 +1,8 @@ -import _clone from './internal/_clone'; -import _curry3 from './internal/_curry3'; -import _isTransformer from './internal/_isTransformer'; -import _reduce from './internal/_reduce'; -import _stepCat from './internal/_stepCat'; +import _clone from './internal/_clone.js'; +import _curry3 from './internal/_curry3.js'; +import _isTransformer from './internal/_isTransformer.js'; +import _reduce from './internal/_reduce.js'; +import _stepCat from './internal/_stepCat.js'; /** diff --git a/source/invert.js b/source/invert.js index b2469a458d..35681b2144 100644 --- a/source/invert.js +++ b/source/invert.js @@ -1,6 +1,6 @@ -import _curry1 from './internal/_curry1'; -import _has from './internal/_has'; -import keys from './keys'; +import _curry1 from './internal/_curry1.js'; +import _has from './internal/_has.js'; +import keys from './keys.js'; /** diff --git a/source/invertObj.js b/source/invertObj.js index d6723c5740..d76f28a401 100644 --- a/source/invertObj.js +++ b/source/invertObj.js @@ -1,5 +1,5 @@ -import _curry1 from './internal/_curry1'; -import keys from './keys'; +import _curry1 from './internal/_curry1.js'; +import keys from './keys.js'; /** diff --git a/source/invoker.js b/source/invoker.js index 2003e3eea4..da250771c0 100644 --- a/source/invoker.js +++ b/source/invoker.js @@ -1,7 +1,7 @@ -import _curry2 from './internal/_curry2'; -import _isFunction from './internal/_isFunction'; -import curryN from './curryN'; -import toString from './toString'; +import _curry2 from './internal/_curry2.js'; +import _isFunction from './internal/_isFunction.js'; +import curryN from './curryN.js'; +import toString from './toString.js'; /** diff --git a/source/is.js b/source/is.js index e2e2c09ad3..be8106c4a6 100644 --- a/source/is.js +++ b/source/is.js @@ -1,4 +1,4 @@ -import _curry2 from './internal/_curry2'; +import _curry2 from './internal/_curry2.js'; /** diff --git a/source/isEmpty.js b/source/isEmpty.js index b774fab6a2..14f21374d2 100644 --- a/source/isEmpty.js +++ b/source/isEmpty.js @@ -1,6 +1,6 @@ -import _curry1 from './internal/_curry1'; -import empty from './empty'; -import equals from './equals'; +import _curry1 from './internal/_curry1.js'; +import empty from './empty.js'; +import equals from './equals.js'; /** diff --git a/source/isNil.js b/source/isNil.js index e2c9c02032..f76ee6a018 100644 --- a/source/isNil.js +++ b/source/isNil.js @@ -1,4 +1,4 @@ -import _curry1 from './internal/_curry1'; +import _curry1 from './internal/_curry1.js'; /** diff --git a/source/join.js b/source/join.js index d509f7afe3..5b5cf1b9ce 100644 --- a/source/join.js +++ b/source/join.js @@ -1,4 +1,4 @@ -import invoker from './invoker'; +import invoker from './invoker.js'; /** diff --git a/source/juxt.js b/source/juxt.js index df55d07d40..ad7eee3033 100644 --- a/source/juxt.js +++ b/source/juxt.js @@ -1,5 +1,5 @@ -import _curry1 from './internal/_curry1'; -import converge from './converge'; +import _curry1 from './internal/_curry1.js'; +import converge from './converge.js'; /** diff --git a/source/keys.js b/source/keys.js index e35f48b57d..1c20ef9f89 100644 --- a/source/keys.js +++ b/source/keys.js @@ -1,6 +1,6 @@ -import _curry1 from './internal/_curry1'; -import _has from './internal/_has'; -import _isArguments from './internal/_isArguments'; +import _curry1 from './internal/_curry1.js'; +import _has from './internal/_has.js'; +import _isArguments from './internal/_isArguments.js'; // cover IE < 9 keys issues var hasEnumBug = !({toString: null}).propertyIsEnumerable('toString'); diff --git a/source/keysIn.js b/source/keysIn.js index b62b6ed8de..3fe7587e4a 100644 --- a/source/keysIn.js +++ b/source/keysIn.js @@ -1,4 +1,4 @@ -import _curry1 from './internal/_curry1'; +import _curry1 from './internal/_curry1.js'; /** diff --git a/source/last.js b/source/last.js index a8c74fd2db..4b37c93548 100644 --- a/source/last.js +++ b/source/last.js @@ -1,4 +1,4 @@ -import nth from './nth'; +import nth from './nth.js'; /** diff --git a/source/lastIndexOf.js b/source/lastIndexOf.js index 107f9064d3..73610c89f9 100644 --- a/source/lastIndexOf.js +++ b/source/lastIndexOf.js @@ -1,6 +1,6 @@ -import _curry2 from './internal/_curry2'; -import _isArray from './internal/_isArray'; -import equals from './equals'; +import _curry2 from './internal/_curry2.js'; +import _isArray from './internal/_isArray.js'; +import equals from './equals.js'; /** diff --git a/source/length.js b/source/length.js index 1a7db285eb..7f10a00a0d 100644 --- a/source/length.js +++ b/source/length.js @@ -1,5 +1,5 @@ -import _curry1 from './internal/_curry1'; -import _isNumber from './internal/_isNumber'; +import _curry1 from './internal/_curry1.js'; +import _isNumber from './internal/_isNumber.js'; /** diff --git a/source/lens.js b/source/lens.js index b8c594f8fb..d4f211bf08 100644 --- a/source/lens.js +++ b/source/lens.js @@ -1,5 +1,5 @@ -import _curry2 from './internal/_curry2'; -import map from './map'; +import _curry2 from './internal/_curry2.js'; +import map from './map.js'; /** diff --git a/source/lensIndex.js b/source/lensIndex.js index a028c0da1f..1c57ac3230 100644 --- a/source/lensIndex.js +++ b/source/lensIndex.js @@ -1,7 +1,7 @@ -import _curry1 from './internal/_curry1'; -import lens from './lens'; -import nth from './nth'; -import update from './update'; +import _curry1 from './internal/_curry1.js'; +import lens from './lens.js'; +import nth from './nth.js'; +import update from './update.js'; /** diff --git a/source/lensPath.js b/source/lensPath.js index 90d66fa2fc..3458f5a5a3 100644 --- a/source/lensPath.js +++ b/source/lensPath.js @@ -1,7 +1,7 @@ -import _curry1 from './internal/_curry1'; -import assocPath from './assocPath'; -import lens from './lens'; -import path from './path'; +import _curry1 from './internal/_curry1.js'; +import assocPath from './assocPath.js'; +import lens from './lens.js'; +import path from './path.js'; /** diff --git a/source/lensProp.js b/source/lensProp.js index 8cdf0d8d80..7ac22b503b 100644 --- a/source/lensProp.js +++ b/source/lensProp.js @@ -1,7 +1,7 @@ -import _curry1 from './internal/_curry1'; -import assoc from './assoc'; -import lens from './lens'; -import prop from './prop'; +import _curry1 from './internal/_curry1.js'; +import assoc from './assoc.js'; +import lens from './lens.js'; +import prop from './prop.js'; /** diff --git a/source/lift.js b/source/lift.js index 93cd6d3d28..a2628f18c6 100644 --- a/source/lift.js +++ b/source/lift.js @@ -1,5 +1,5 @@ -import _curry1 from './internal/_curry1'; -import liftN from './liftN'; +import _curry1 from './internal/_curry1.js'; +import liftN from './liftN.js'; /** diff --git a/source/liftN.js b/source/liftN.js index 125f6daa2a..3d9fe72441 100644 --- a/source/liftN.js +++ b/source/liftN.js @@ -1,8 +1,8 @@ -import _curry2 from './internal/_curry2'; -import _reduce from './internal/_reduce'; -import ap from './ap'; -import curryN from './curryN'; -import map from './map'; +import _curry2 from './internal/_curry2.js'; +import _reduce from './internal/_reduce.js'; +import ap from './ap.js'; +import curryN from './curryN.js'; +import map from './map.js'; /** diff --git a/source/lt.js b/source/lt.js index bd6bf88508..e8231cf4b0 100644 --- a/source/lt.js +++ b/source/lt.js @@ -1,4 +1,4 @@ -import _curry2 from './internal/_curry2'; +import _curry2 from './internal/_curry2.js'; /** diff --git a/source/lte.js b/source/lte.js index ba4571fe37..abc5ef4058 100644 --- a/source/lte.js +++ b/source/lte.js @@ -1,4 +1,4 @@ -import _curry2 from './internal/_curry2'; +import _curry2 from './internal/_curry2.js'; /** diff --git a/source/map.js b/source/map.js index 09bc1553b0..8a3342dac0 100644 --- a/source/map.js +++ b/source/map.js @@ -1,10 +1,10 @@ -import _curry2 from './internal/_curry2'; -import _dispatchable from './internal/_dispatchable'; -import _map from './internal/_map'; -import _reduce from './internal/_reduce'; -import _xmap from './internal/_xmap'; -import curryN from './curryN'; -import keys from './keys'; +import _curry2 from './internal/_curry2.js'; +import _dispatchable from './internal/_dispatchable.js'; +import _map from './internal/_map.js'; +import _reduce from './internal/_reduce.js'; +import _xmap from './internal/_xmap.js'; +import curryN from './curryN.js'; +import keys from './keys.js'; /** diff --git a/source/mapAccum.js b/source/mapAccum.js index ed5dbeb521..2e2ba0209a 100644 --- a/source/mapAccum.js +++ b/source/mapAccum.js @@ -1,4 +1,4 @@ -import _curry3 from './internal/_curry3'; +import _curry3 from './internal/_curry3.js'; /** diff --git a/source/mapAccumRight.js b/source/mapAccumRight.js index ea721e6406..353b5e1358 100644 --- a/source/mapAccumRight.js +++ b/source/mapAccumRight.js @@ -1,4 +1,4 @@ -import _curry3 from './internal/_curry3'; +import _curry3 from './internal/_curry3.js'; /** diff --git a/source/mapObjIndexed.js b/source/mapObjIndexed.js index 9cd08a7b17..699d5287b4 100644 --- a/source/mapObjIndexed.js +++ b/source/mapObjIndexed.js @@ -1,6 +1,6 @@ -import _curry2 from './internal/_curry2'; -import _reduce from './internal/_reduce'; -import keys from './keys'; +import _curry2 from './internal/_curry2.js'; +import _reduce from './internal/_reduce.js'; +import keys from './keys.js'; /** diff --git a/source/match.js b/source/match.js index b9de4e7444..6a41dcc26f 100644 --- a/source/match.js +++ b/source/match.js @@ -1,4 +1,4 @@ -import _curry2 from './internal/_curry2'; +import _curry2 from './internal/_curry2.js'; /** diff --git a/source/mathMod.js b/source/mathMod.js index de76265dec..3508a43715 100644 --- a/source/mathMod.js +++ b/source/mathMod.js @@ -1,5 +1,5 @@ -import _curry2 from './internal/_curry2'; -import _isInteger from './internal/_isInteger'; +import _curry2 from './internal/_curry2.js'; +import _isInteger from './internal/_isInteger.js'; /** diff --git a/source/max.js b/source/max.js index 5793179d04..f46f6ba621 100644 --- a/source/max.js +++ b/source/max.js @@ -1,4 +1,4 @@ -import _curry2 from './internal/_curry2'; +import _curry2 from './internal/_curry2.js'; /** diff --git a/source/maxBy.js b/source/maxBy.js index d6f3f2113f..936f5c4420 100644 --- a/source/maxBy.js +++ b/source/maxBy.js @@ -1,4 +1,4 @@ -import _curry3 from './internal/_curry3'; +import _curry3 from './internal/_curry3.js'; /** diff --git a/source/mean.js b/source/mean.js index 116b9ce781..df9ce7c896 100644 --- a/source/mean.js +++ b/source/mean.js @@ -1,5 +1,5 @@ -import _curry1 from './internal/_curry1'; -import sum from './sum'; +import _curry1 from './internal/_curry1.js'; +import sum from './sum.js'; /** diff --git a/source/median.js b/source/median.js index d18fc456b3..8b2e657cc6 100644 --- a/source/median.js +++ b/source/median.js @@ -1,5 +1,5 @@ -import _curry1 from './internal/_curry1'; -import mean from './mean'; +import _curry1 from './internal/_curry1.js'; +import mean from './mean.js'; /** diff --git a/source/memoizeWith.js b/source/memoizeWith.js index ea0188ad93..39f907b7e3 100644 --- a/source/memoizeWith.js +++ b/source/memoizeWith.js @@ -1,6 +1,6 @@ -import _arity from './internal/_arity'; -import _curry2 from './internal/_curry2'; -import _has from './internal/_has'; +import _arity from './internal/_arity.js'; +import _curry2 from './internal/_curry2.js'; +import _has from './internal/_has.js'; /** diff --git a/source/mergeAll.js b/source/mergeAll.js index b9951f855d..fa7c365fd4 100644 --- a/source/mergeAll.js +++ b/source/mergeAll.js @@ -1,5 +1,5 @@ -import _objectAssign from './internal/_objectAssign'; -import _curry1 from './internal/_curry1'; +import _objectAssign from './internal/_objectAssign.js'; +import _curry1 from './internal/_curry1.js'; /** diff --git a/source/mergeDeepLeft.js b/source/mergeDeepLeft.js index efc8dce4a9..9ef75dd6f7 100644 --- a/source/mergeDeepLeft.js +++ b/source/mergeDeepLeft.js @@ -1,5 +1,5 @@ -import _curry2 from './internal/_curry2'; -import mergeDeepWithKey from './mergeDeepWithKey'; +import _curry2 from './internal/_curry2.js'; +import mergeDeepWithKey from './mergeDeepWithKey.js'; /** diff --git a/source/mergeDeepRight.js b/source/mergeDeepRight.js index 29af0fb122..bbba626154 100644 --- a/source/mergeDeepRight.js +++ b/source/mergeDeepRight.js @@ -1,5 +1,5 @@ -import _curry2 from './internal/_curry2'; -import mergeDeepWithKey from './mergeDeepWithKey'; +import _curry2 from './internal/_curry2.js'; +import mergeDeepWithKey from './mergeDeepWithKey.js'; /** diff --git a/source/mergeDeepWith.js b/source/mergeDeepWith.js index 4fedcb0fc8..a72fa640c3 100644 --- a/source/mergeDeepWith.js +++ b/source/mergeDeepWith.js @@ -1,5 +1,5 @@ -import _curry3 from './internal/_curry3'; -import mergeDeepWithKey from './mergeDeepWithKey'; +import _curry3 from './internal/_curry3.js'; +import mergeDeepWithKey from './mergeDeepWithKey.js'; /** diff --git a/source/mergeDeepWithKey.js b/source/mergeDeepWithKey.js index 6724cfa299..954db43c5a 100644 --- a/source/mergeDeepWithKey.js +++ b/source/mergeDeepWithKey.js @@ -1,6 +1,6 @@ -import _curry3 from './internal/_curry3'; -import _isObject from './internal/_isObject'; -import mergeWithKey from './mergeWithKey'; +import _curry3 from './internal/_curry3.js'; +import _isObject from './internal/_isObject.js'; +import mergeWithKey from './mergeWithKey.js'; /** diff --git a/source/mergeLeft.js b/source/mergeLeft.js index 94de9e9580..d05b47691c 100644 --- a/source/mergeLeft.js +++ b/source/mergeLeft.js @@ -1,5 +1,5 @@ -import _objectAssign from './internal/_objectAssign'; -import _curry2 from './internal/_curry2'; +import _objectAssign from './internal/_objectAssign.js'; +import _curry2 from './internal/_curry2.js'; /** diff --git a/source/mergeRight.js b/source/mergeRight.js index c9df687f21..6a4329ee48 100644 --- a/source/mergeRight.js +++ b/source/mergeRight.js @@ -1,5 +1,5 @@ -import _objectAssign from './internal/_objectAssign'; -import _curry2 from './internal/_curry2'; +import _objectAssign from './internal/_objectAssign.js'; +import _curry2 from './internal/_curry2.js'; /** diff --git a/source/mergeWith.js b/source/mergeWith.js index 5b4a756bc0..1846244d45 100644 --- a/source/mergeWith.js +++ b/source/mergeWith.js @@ -1,5 +1,5 @@ -import _curry3 from './internal/_curry3'; -import mergeWithKey from './mergeWithKey'; +import _curry3 from './internal/_curry3.js'; +import mergeWithKey from './mergeWithKey.js'; /** diff --git a/source/mergeWithKey.js b/source/mergeWithKey.js index 1cb7332ead..5688c30e66 100644 --- a/source/mergeWithKey.js +++ b/source/mergeWithKey.js @@ -1,5 +1,5 @@ -import _curry3 from './internal/_curry3'; -import _has from './internal/_has'; +import _curry3 from './internal/_curry3.js'; +import _has from './internal/_has.js'; /** diff --git a/source/min.js b/source/min.js index 3d0b599856..d7dd885344 100644 --- a/source/min.js +++ b/source/min.js @@ -1,4 +1,4 @@ -import _curry2 from './internal/_curry2'; +import _curry2 from './internal/_curry2.js'; /** diff --git a/source/minBy.js b/source/minBy.js index e804676b84..aa66015aca 100644 --- a/source/minBy.js +++ b/source/minBy.js @@ -1,4 +1,4 @@ -import _curry3 from './internal/_curry3'; +import _curry3 from './internal/_curry3.js'; /** diff --git a/source/modulo.js b/source/modulo.js index 35e4fa11bf..26e20a47a9 100644 --- a/source/modulo.js +++ b/source/modulo.js @@ -1,4 +1,4 @@ -import _curry2 from './internal/_curry2'; +import _curry2 from './internal/_curry2.js'; /** diff --git a/source/move.js b/source/move.js index 09ec405361..11454ed11a 100644 --- a/source/move.js +++ b/source/move.js @@ -1,4 +1,4 @@ -import _curry3 from './internal/_curry3'; +import _curry3 from './internal/_curry3.js'; /** * Move an item, at index `from`, to index `to`, in a list of elements. diff --git a/source/multiply.js b/source/multiply.js index 45c46a2fd6..b36bc191e0 100644 --- a/source/multiply.js +++ b/source/multiply.js @@ -1,4 +1,4 @@ -import _curry2 from './internal/_curry2'; +import _curry2 from './internal/_curry2.js'; /** diff --git a/source/nAry.js b/source/nAry.js index 63a04b45d3..4b9efdf0be 100644 --- a/source/nAry.js +++ b/source/nAry.js @@ -1,4 +1,4 @@ -import _curry2 from './internal/_curry2'; +import _curry2 from './internal/_curry2.js'; /** diff --git a/source/negate.js b/source/negate.js index 05c66b80e7..73d3163f7c 100644 --- a/source/negate.js +++ b/source/negate.js @@ -1,4 +1,4 @@ -import _curry1 from './internal/_curry1'; +import _curry1 from './internal/_curry1.js'; /** diff --git a/source/none.js b/source/none.js index 58a1aa47d8..dd9f24ec51 100644 --- a/source/none.js +++ b/source/none.js @@ -1,6 +1,6 @@ -import _complement from './internal/_complement'; -import _curry2 from './internal/_curry2'; -import all from './all'; +import _complement from './internal/_complement.js'; +import _curry2 from './internal/_curry2.js'; +import all from './all.js'; /** diff --git a/source/not.js b/source/not.js index 8a28de5578..489dcb2a4d 100644 --- a/source/not.js +++ b/source/not.js @@ -1,4 +1,4 @@ -import _curry1 from './internal/_curry1'; +import _curry1 from './internal/_curry1.js'; /** diff --git a/source/nth.js b/source/nth.js index cd0a837127..806f5d2fa1 100644 --- a/source/nth.js +++ b/source/nth.js @@ -1,5 +1,5 @@ -import _curry2 from './internal/_curry2'; -import _isString from './internal/_isString'; +import _curry2 from './internal/_curry2.js'; +import _isString from './internal/_isString.js'; /** diff --git a/source/nthArg.js b/source/nthArg.js index d850f745c7..8457d7f946 100644 --- a/source/nthArg.js +++ b/source/nthArg.js @@ -1,6 +1,6 @@ -import _curry1 from './internal/_curry1'; -import curryN from './curryN'; -import nth from './nth'; +import _curry1 from './internal/_curry1.js'; +import curryN from './curryN.js'; +import nth from './nth.js'; /** diff --git a/source/o.js b/source/o.js index 7969b0e34e..54e3021084 100644 --- a/source/o.js +++ b/source/o.js @@ -1,4 +1,4 @@ -import _curry3 from './internal/_curry3'; +import _curry3 from './internal/_curry3.js'; /** diff --git a/source/objOf.js b/source/objOf.js index 4b8a98b103..2ffb92b757 100644 --- a/source/objOf.js +++ b/source/objOf.js @@ -1,4 +1,4 @@ -import _curry2 from './internal/_curry2'; +import _curry2 from './internal/_curry2.js'; /** diff --git a/source/of.js b/source/of.js index 2707e12996..db12a14f07 100644 --- a/source/of.js +++ b/source/of.js @@ -1,5 +1,5 @@ -import _curry1 from './internal/_curry1'; -import _of from './internal/_of'; +import _curry1 from './internal/_curry1.js'; +import _of from './internal/_of.js'; /** diff --git a/source/omit.js b/source/omit.js index 1dafc65ded..9d44c3f070 100644 --- a/source/omit.js +++ b/source/omit.js @@ -1,4 +1,4 @@ -import _curry2 from './internal/_curry2'; +import _curry2 from './internal/_curry2.js'; /** * Returns a partial copy of an object omitting the keys specified. diff --git a/source/on.js b/source/on.js index 67734cfcf6..787d3e6956 100644 --- a/source/on.js +++ b/source/on.js @@ -1,4 +1,4 @@ -import curryN from './internal/_curryN'; +import curryN from './internal/_curryN.js'; /** diff --git a/source/once.js b/source/once.js index 332050d9db..e7cb5267a3 100644 --- a/source/once.js +++ b/source/once.js @@ -1,5 +1,5 @@ -import _arity from './internal/_arity'; -import _curry1 from './internal/_curry1'; +import _arity from './internal/_arity.js'; +import _curry1 from './internal/_curry1.js'; /** diff --git a/source/or.js b/source/or.js index 1b82f31405..8b1519fc8e 100644 --- a/source/or.js +++ b/source/or.js @@ -1,4 +1,4 @@ -import _curry2 from './internal/_curry2'; +import _curry2 from './internal/_curry2.js'; /** * Returns `true` if one or both of its arguments are `true`. Returns `false` diff --git a/source/otherwise.js b/source/otherwise.js index d68a1a0d51..39b7262715 100644 --- a/source/otherwise.js +++ b/source/otherwise.js @@ -1,5 +1,5 @@ -import _curry2 from './internal/_curry2'; -import _assertPromise from './internal/_assertPromise'; +import _curry2 from './internal/_curry2.js'; +import _assertPromise from './internal/_assertPromise.js'; /** diff --git a/source/over.js b/source/over.js index ecf036a1d0..db77c13443 100644 --- a/source/over.js +++ b/source/over.js @@ -1,4 +1,4 @@ -import _curry3 from './internal/_curry3'; +import _curry3 from './internal/_curry3.js'; // `Identity` is a functor that holds a single value, where `map` simply // transforms the held value with the provided function. diff --git a/source/pair.js b/source/pair.js index 230155d89f..4b3b6e6518 100644 --- a/source/pair.js +++ b/source/pair.js @@ -1,4 +1,4 @@ -import _curry2 from './internal/_curry2'; +import _curry2 from './internal/_curry2.js'; /** diff --git a/source/partial.js b/source/partial.js index 78d54434a6..9bf207f633 100644 --- a/source/partial.js +++ b/source/partial.js @@ -1,5 +1,5 @@ -import _concat from './internal/_concat'; -import _createPartialApplicator from './internal/_createPartialApplicator'; +import _concat from './internal/_concat.js'; +import _createPartialApplicator from './internal/_createPartialApplicator.js'; /** diff --git a/source/partialRight.js b/source/partialRight.js index 6c9d167a3d..222eb492e7 100644 --- a/source/partialRight.js +++ b/source/partialRight.js @@ -1,6 +1,6 @@ -import _concat from './internal/_concat'; -import _createPartialApplicator from './internal/_createPartialApplicator'; -import flip from './flip'; +import _concat from './internal/_concat.js'; +import _createPartialApplicator from './internal/_createPartialApplicator.js'; +import flip from './flip.js'; /** diff --git a/source/partition.js b/source/partition.js index 0b96927229..d908c594d3 100644 --- a/source/partition.js +++ b/source/partition.js @@ -1,6 +1,6 @@ -import filter from './filter'; -import juxt from './juxt'; -import reject from './reject'; +import filter from './filter.js'; +import juxt from './juxt.js'; +import reject from './reject.js'; /** diff --git a/source/path.js b/source/path.js index a2952c6d7f..fc6ed47986 100644 --- a/source/path.js +++ b/source/path.js @@ -1,5 +1,5 @@ -import _curry2 from './internal/_curry2'; -import paths from './paths'; +import _curry2 from './internal/_curry2.js'; +import paths from './paths.js'; /** * Retrieve the value at a given path. diff --git a/source/pathEq.js b/source/pathEq.js index 83a0695b57..774adb3c29 100644 --- a/source/pathEq.js +++ b/source/pathEq.js @@ -1,6 +1,6 @@ -import _curry3 from './internal/_curry3'; -import equals from './equals'; -import path from './path'; +import _curry3 from './internal/_curry3.js'; +import equals from './equals.js'; +import path from './path.js'; /** diff --git a/source/pathOr.js b/source/pathOr.js index ecec92ceb7..8e77b43a27 100644 --- a/source/pathOr.js +++ b/source/pathOr.js @@ -1,6 +1,6 @@ -import _curry3 from './internal/_curry3'; -import defaultTo from './defaultTo'; -import path from './path'; +import _curry3 from './internal/_curry3.js'; +import defaultTo from './defaultTo.js'; +import path from './path.js'; /** diff --git a/source/pathSatisfies.js b/source/pathSatisfies.js index 0c01c1321f..21b6ed92cc 100644 --- a/source/pathSatisfies.js +++ b/source/pathSatisfies.js @@ -1,5 +1,5 @@ -import _curry3 from './internal/_curry3'; -import path from './path'; +import _curry3 from './internal/_curry3.js'; +import path from './path.js'; /** diff --git a/source/paths.js b/source/paths.js index a79ababa22..bd6fb405a3 100644 --- a/source/paths.js +++ b/source/paths.js @@ -1,6 +1,6 @@ -import _curry2 from './internal/_curry2'; -import _isInteger from './internal/_isInteger'; -import nth from './nth'; +import _curry2 from './internal/_curry2.js'; +import _isInteger from './internal/_isInteger.js'; +import nth from './nth.js'; /** * Retrieves the values at given paths of an object. diff --git a/source/pick.js b/source/pick.js index 5ebbb3013b..d7067b914b 100644 --- a/source/pick.js +++ b/source/pick.js @@ -1,4 +1,4 @@ -import _curry2 from './internal/_curry2'; +import _curry2 from './internal/_curry2.js'; /** diff --git a/source/pickAll.js b/source/pickAll.js index 41fdf9dc16..e6c14b9720 100644 --- a/source/pickAll.js +++ b/source/pickAll.js @@ -1,4 +1,4 @@ -import _curry2 from './internal/_curry2'; +import _curry2 from './internal/_curry2.js'; /** diff --git a/source/pickBy.js b/source/pickBy.js index b560aebc8f..eed625d309 100644 --- a/source/pickBy.js +++ b/source/pickBy.js @@ -1,4 +1,4 @@ -import _curry2 from './internal/_curry2'; +import _curry2 from './internal/_curry2.js'; /** diff --git a/source/pipe.js b/source/pipe.js index 91decacc4c..701fb520d9 100644 --- a/source/pipe.js +++ b/source/pipe.js @@ -1,7 +1,7 @@ -import _arity from './internal/_arity'; -import _pipe from './internal/_pipe'; -import reduce from './reduce'; -import tail from './tail'; +import _arity from './internal/_arity.js'; +import _pipe from './internal/_pipe.js'; +import reduce from './reduce.js'; +import tail from './tail.js'; /** diff --git a/source/pipeWith.js b/source/pipeWith.js index beb17d99ce..2f0e873aae 100644 --- a/source/pipeWith.js +++ b/source/pipeWith.js @@ -1,9 +1,9 @@ -import _arity from './internal/_arity'; -import _curry2 from './internal/_curry2'; -import head from './head'; -import _reduce from './internal/_reduce'; -import tail from './tail'; -import identity from './identity'; +import _arity from './internal/_arity.js'; +import _curry2 from './internal/_curry2.js'; +import head from './head.js'; +import _reduce from './internal/_reduce.js'; +import tail from './tail.js'; +import identity from './identity.js'; /** diff --git a/source/pluck.js b/source/pluck.js index 230010a6f5..319afb2584 100644 --- a/source/pluck.js +++ b/source/pluck.js @@ -1,6 +1,6 @@ -import _curry2 from './internal/_curry2'; -import map from './map'; -import prop from './prop'; +import _curry2 from './internal/_curry2.js'; +import map from './map.js'; +import prop from './prop.js'; /** diff --git a/source/prepend.js b/source/prepend.js index 6dd3510ede..3002dc02f2 100644 --- a/source/prepend.js +++ b/source/prepend.js @@ -1,5 +1,5 @@ -import _concat from './internal/_concat'; -import _curry2 from './internal/_curry2'; +import _concat from './internal/_concat.js'; +import _curry2 from './internal/_curry2.js'; /** diff --git a/source/product.js b/source/product.js index 67c1d4ba74..5bbe8360f8 100644 --- a/source/product.js +++ b/source/product.js @@ -1,5 +1,5 @@ -import multiply from './multiply'; -import reduce from './reduce'; +import multiply from './multiply.js'; +import reduce from './reduce.js'; /** diff --git a/source/project.js b/source/project.js index a0a9ed902f..4a2ec0e8fb 100644 --- a/source/project.js +++ b/source/project.js @@ -1,7 +1,7 @@ -import _map from './internal/_map'; -import identity from './identity'; -import pickAll from './pickAll'; -import useWith from './useWith'; +import _map from './internal/_map.js'; +import identity from './identity.js'; +import pickAll from './pickAll.js'; +import useWith from './useWith.js'; /** diff --git a/source/prop.js b/source/prop.js index 52c91b1b78..37f80e8ed6 100644 --- a/source/prop.js +++ b/source/prop.js @@ -1,6 +1,6 @@ -import _curry2 from './internal/_curry2'; -import _isInteger from './internal/_isInteger'; -import nth from './nth'; +import _curry2 from './internal/_curry2.js'; +import _isInteger from './internal/_isInteger.js'; +import nth from './nth.js'; /** diff --git a/source/propEq.js b/source/propEq.js index 2ecff21409..c658020d3c 100644 --- a/source/propEq.js +++ b/source/propEq.js @@ -1,6 +1,6 @@ -import _curry3 from './internal/_curry3'; -import prop from './prop'; -import equals from './equals'; +import _curry3 from './internal/_curry3.js'; +import prop from './prop.js'; +import equals from './equals.js'; /** diff --git a/source/propIs.js b/source/propIs.js index 236511785d..b117aff7c3 100644 --- a/source/propIs.js +++ b/source/propIs.js @@ -1,6 +1,6 @@ -import _curry3 from './internal/_curry3'; -import prop from './prop'; -import is from './is'; +import _curry3 from './internal/_curry3.js'; +import prop from './prop.js'; +import is from './is.js'; /** diff --git a/source/propOr.js b/source/propOr.js index ce22e62b86..6750630a0c 100644 --- a/source/propOr.js +++ b/source/propOr.js @@ -1,6 +1,6 @@ -import _curry3 from './internal/_curry3'; -import defaultTo from './defaultTo'; -import prop from './prop'; +import _curry3 from './internal/_curry3.js'; +import defaultTo from './defaultTo.js'; +import prop from './prop.js'; /** diff --git a/source/propSatisfies.js b/source/propSatisfies.js index 061d7f8fff..2fb3bdab70 100644 --- a/source/propSatisfies.js +++ b/source/propSatisfies.js @@ -1,5 +1,5 @@ -import _curry3 from './internal/_curry3'; -import prop from './prop'; +import _curry3 from './internal/_curry3.js'; +import prop from './prop.js'; /** * Returns `true` if the specified object property satisfies the given diff --git a/source/props.js b/source/props.js index 08ecb5e8a8..116d95dad5 100644 --- a/source/props.js +++ b/source/props.js @@ -1,5 +1,5 @@ -import _curry2 from './internal/_curry2'; -import path from './path'; +import _curry2 from './internal/_curry2.js'; +import path from './path.js'; /** diff --git a/source/range.js b/source/range.js index 4941f0b19f..690db2e180 100644 --- a/source/range.js +++ b/source/range.js @@ -1,5 +1,5 @@ -import _curry2 from './internal/_curry2'; -import _isNumber from './internal/_isNumber'; +import _curry2 from './internal/_curry2.js'; +import _isNumber from './internal/_isNumber.js'; /** diff --git a/source/reduce.js b/source/reduce.js index 94795cc01b..23549aec0a 100644 --- a/source/reduce.js +++ b/source/reduce.js @@ -1,5 +1,5 @@ -import _curry3 from './internal/_curry3'; -import _reduce from './internal/_reduce'; +import _curry3 from './internal/_curry3.js'; +import _reduce from './internal/_reduce.js'; /** diff --git a/source/reduceBy.js b/source/reduceBy.js index 6f0cb2248a..e1c624df7f 100644 --- a/source/reduceBy.js +++ b/source/reduceBy.js @@ -1,9 +1,9 @@ -import _clone from './internal/_clone'; -import _curryN from './internal/_curryN'; -import _dispatchable from './internal/_dispatchable'; -import _has from './internal/_has'; -import _reduce from './internal/_reduce'; -import _xreduceBy from './internal/_xreduceBy'; +import _clone from './internal/_clone.js'; +import _curryN from './internal/_curryN.js'; +import _dispatchable from './internal/_dispatchable.js'; +import _has from './internal/_has.js'; +import _reduce from './internal/_reduce.js'; +import _xreduceBy from './internal/_xreduceBy.js'; /** diff --git a/source/reduceRight.js b/source/reduceRight.js index cf0ff4048f..6dd6a74707 100644 --- a/source/reduceRight.js +++ b/source/reduceRight.js @@ -1,4 +1,4 @@ -import _curry3 from './internal/_curry3'; +import _curry3 from './internal/_curry3.js'; /** diff --git a/source/reduceWhile.js b/source/reduceWhile.js index 5ff6161baa..6e9e262992 100644 --- a/source/reduceWhile.js +++ b/source/reduceWhile.js @@ -1,6 +1,6 @@ -import _curryN from './internal/_curryN'; -import _reduce from './internal/_reduce'; -import _reduced from './internal/_reduced'; +import _curryN from './internal/_curryN.js'; +import _reduce from './internal/_reduce.js'; +import _reduced from './internal/_reduced.js'; /** diff --git a/source/reduced.js b/source/reduced.js index 8ea0056d56..c8c23648d0 100644 --- a/source/reduced.js +++ b/source/reduced.js @@ -1,5 +1,5 @@ -import _curry1 from './internal/_curry1'; -import _reduced from './internal/_reduced'; +import _curry1 from './internal/_curry1.js'; +import _reduced from './internal/_reduced.js'; /** * Returns a value wrapped to indicate that it is the final value of the reduce diff --git a/source/reject.js b/source/reject.js index a7065fb3a8..40413632e0 100644 --- a/source/reject.js +++ b/source/reject.js @@ -1,6 +1,6 @@ -import _complement from './internal/_complement'; -import _curry2 from './internal/_curry2'; -import filter from './filter'; +import _complement from './internal/_complement.js'; +import _curry2 from './internal/_curry2.js'; +import filter from './filter.js'; /** diff --git a/source/remove.js b/source/remove.js index a5aaaa4e90..7466d75fe5 100644 --- a/source/remove.js +++ b/source/remove.js @@ -1,4 +1,4 @@ -import _curry3 from './internal/_curry3'; +import _curry3 from './internal/_curry3.js'; /** diff --git a/source/repeat.js b/source/repeat.js index d32e81b84f..770179b022 100644 --- a/source/repeat.js +++ b/source/repeat.js @@ -1,6 +1,6 @@ -import _curry2 from './internal/_curry2'; -import always from './always'; -import times from './times'; +import _curry2 from './internal/_curry2.js'; +import always from './always.js'; +import times from './times.js'; /** diff --git a/source/replace.js b/source/replace.js index 80599648aa..29a851b62d 100644 --- a/source/replace.js +++ b/source/replace.js @@ -1,4 +1,4 @@ -import _curry3 from './internal/_curry3'; +import _curry3 from './internal/_curry3.js'; /** diff --git a/source/reverse.js b/source/reverse.js index 0823c0a975..005e512222 100644 --- a/source/reverse.js +++ b/source/reverse.js @@ -1,5 +1,5 @@ -import _curry1 from './internal/_curry1'; -import _isString from './internal/_isString'; +import _curry1 from './internal/_curry1.js'; +import _isString from './internal/_isString.js'; /** diff --git a/source/scan.js b/source/scan.js index 114eb93a24..369aa62a68 100644 --- a/source/scan.js +++ b/source/scan.js @@ -1,4 +1,4 @@ -import _curry3 from './internal/_curry3'; +import _curry3 from './internal/_curry3.js'; /** diff --git a/source/sequence.js b/source/sequence.js index 7366d85332..7da0b50ca4 100644 --- a/source/sequence.js +++ b/source/sequence.js @@ -1,8 +1,8 @@ -import _curry2 from './internal/_curry2'; -import ap from './ap'; -import map from './map'; -import prepend from './prepend'; -import reduceRight from './reduceRight'; +import _curry2 from './internal/_curry2.js'; +import ap from './ap.js'; +import map from './map.js'; +import prepend from './prepend.js'; +import reduceRight from './reduceRight.js'; /** diff --git a/source/set.js b/source/set.js index e7c3be5058..793cdadc42 100644 --- a/source/set.js +++ b/source/set.js @@ -1,6 +1,6 @@ -import _curry3 from './internal/_curry3'; -import always from './always'; -import over from './over'; +import _curry3 from './internal/_curry3.js'; +import always from './always.js'; +import over from './over.js'; /** diff --git a/source/slice.js b/source/slice.js index 9ae7665649..1c685cb342 100644 --- a/source/slice.js +++ b/source/slice.js @@ -1,5 +1,5 @@ -import _checkForMethod from './internal/_checkForMethod'; -import _curry3 from './internal/_curry3'; +import _checkForMethod from './internal/_checkForMethod.js'; +import _curry3 from './internal/_curry3.js'; /** diff --git a/source/sort.js b/source/sort.js index 6d5f879efe..72e95b07e3 100644 --- a/source/sort.js +++ b/source/sort.js @@ -1,4 +1,4 @@ -import _curry2 from './internal/_curry2'; +import _curry2 from './internal/_curry2.js'; /** diff --git a/source/sortBy.js b/source/sortBy.js index e143a444ed..0e51334e07 100644 --- a/source/sortBy.js +++ b/source/sortBy.js @@ -1,4 +1,4 @@ -import _curry2 from './internal/_curry2'; +import _curry2 from './internal/_curry2.js'; /** diff --git a/source/sortWith.js b/source/sortWith.js index a60ac10004..1a287c6cd4 100644 --- a/source/sortWith.js +++ b/source/sortWith.js @@ -1,4 +1,4 @@ -import _curry2 from './internal/_curry2'; +import _curry2 from './internal/_curry2.js'; /** diff --git a/source/split.js b/source/split.js index d4e8af6abf..3101a66c69 100644 --- a/source/split.js +++ b/source/split.js @@ -1,4 +1,4 @@ -import invoker from './invoker'; +import invoker from './invoker.js'; /** diff --git a/source/splitAt.js b/source/splitAt.js index dd1d023fc3..04a9b77720 100644 --- a/source/splitAt.js +++ b/source/splitAt.js @@ -1,6 +1,6 @@ -import _curry2 from './internal/_curry2'; -import length from './length'; -import slice from './slice'; +import _curry2 from './internal/_curry2.js'; +import length from './length.js'; +import slice from './slice.js'; /** diff --git a/source/splitEvery.js b/source/splitEvery.js index 75aae8caf7..8b17292791 100644 --- a/source/splitEvery.js +++ b/source/splitEvery.js @@ -1,5 +1,5 @@ -import _curry2 from './internal/_curry2'; -import slice from './slice'; +import _curry2 from './internal/_curry2.js'; +import slice from './slice.js'; /** diff --git a/source/splitWhen.js b/source/splitWhen.js index 262ee8476c..a67f986504 100644 --- a/source/splitWhen.js +++ b/source/splitWhen.js @@ -1,4 +1,4 @@ -import _curry2 from './internal/_curry2'; +import _curry2 from './internal/_curry2.js'; /** diff --git a/source/splitWhenever.js b/source/splitWhenever.js index 0b578f6334..74b6849428 100644 --- a/source/splitWhenever.js +++ b/source/splitWhenever.js @@ -1,4 +1,4 @@ -import _curryN from './internal/_curryN'; +import _curryN from './internal/_curryN.js'; /** * Splits an array into slices on every occurrence of a value. * diff --git a/source/startsWith.js b/source/startsWith.js index d0e4a761d2..f3074e187f 100644 --- a/source/startsWith.js +++ b/source/startsWith.js @@ -1,6 +1,6 @@ -import _curry2 from './internal/_curry2'; -import equals from './equals'; -import take from './take'; +import _curry2 from './internal/_curry2.js'; +import equals from './equals.js'; +import take from './take.js'; /** * Checks if a list starts with the provided sublist. diff --git a/source/subtract.js b/source/subtract.js index e9ed172ed7..39969c191a 100644 --- a/source/subtract.js +++ b/source/subtract.js @@ -1,4 +1,4 @@ -import _curry2 from './internal/_curry2'; +import _curry2 from './internal/_curry2.js'; /** diff --git a/source/sum.js b/source/sum.js index e2e663b58a..2e1cc80839 100644 --- a/source/sum.js +++ b/source/sum.js @@ -1,5 +1,5 @@ -import add from './add'; -import reduce from './reduce'; +import add from './add.js'; +import reduce from './reduce.js'; /** diff --git a/source/symmetricDifference.js b/source/symmetricDifference.js index 2ee4278e1c..27be9b9d6c 100644 --- a/source/symmetricDifference.js +++ b/source/symmetricDifference.js @@ -1,6 +1,6 @@ -import _curry2 from './internal/_curry2'; -import concat from './concat'; -import difference from './difference'; +import _curry2 from './internal/_curry2.js'; +import concat from './concat.js'; +import difference from './difference.js'; /** diff --git a/source/symmetricDifferenceWith.js b/source/symmetricDifferenceWith.js index 860be03ae0..7daab046aa 100644 --- a/source/symmetricDifferenceWith.js +++ b/source/symmetricDifferenceWith.js @@ -1,6 +1,6 @@ -import _curry3 from './internal/_curry3'; -import concat from './concat'; -import differenceWith from './differenceWith'; +import _curry3 from './internal/_curry3.js'; +import concat from './concat.js'; +import differenceWith from './differenceWith.js'; /** diff --git a/source/tail.js b/source/tail.js index 0b9f8e3036..ae18290fbd 100644 --- a/source/tail.js +++ b/source/tail.js @@ -1,6 +1,6 @@ -import _checkForMethod from './internal/_checkForMethod'; -import _curry1 from './internal/_curry1'; -import slice from './slice'; +import _checkForMethod from './internal/_checkForMethod.js'; +import _curry1 from './internal/_curry1.js'; +import slice from './slice.js'; /** diff --git a/source/take.js b/source/take.js index dd9680919f..35571f9a7b 100644 --- a/source/take.js +++ b/source/take.js @@ -1,7 +1,7 @@ -import _curry2 from './internal/_curry2'; -import _dispatchable from './internal/_dispatchable'; -import _xtake from './internal/_xtake'; -import slice from './slice'; +import _curry2 from './internal/_curry2.js'; +import _dispatchable from './internal/_dispatchable.js'; +import _xtake from './internal/_xtake.js'; +import slice from './slice.js'; /** diff --git a/source/takeLast.js b/source/takeLast.js index 67d9fc96a8..b36e245c1f 100644 --- a/source/takeLast.js +++ b/source/takeLast.js @@ -1,5 +1,5 @@ -import _curry2 from './internal/_curry2'; -import drop from './drop'; +import _curry2 from './internal/_curry2.js'; +import drop from './drop.js'; /** diff --git a/source/takeLastWhile.js b/source/takeLastWhile.js index 4b5874386b..210b796c64 100644 --- a/source/takeLastWhile.js +++ b/source/takeLastWhile.js @@ -1,5 +1,5 @@ -import _curry2 from './internal/_curry2'; -import slice from './slice'; +import _curry2 from './internal/_curry2.js'; +import slice from './slice.js'; /** diff --git a/source/takeWhile.js b/source/takeWhile.js index 4e4217abb0..1b0240d603 100644 --- a/source/takeWhile.js +++ b/source/takeWhile.js @@ -1,7 +1,7 @@ -import _curry2 from './internal/_curry2'; -import _dispatchable from './internal/_dispatchable'; -import _xtakeWhile from './internal/_xtakeWhile'; -import slice from './slice'; +import _curry2 from './internal/_curry2.js'; +import _dispatchable from './internal/_dispatchable.js'; +import _xtakeWhile from './internal/_xtakeWhile.js'; +import slice from './slice.js'; /** diff --git a/source/tap.js b/source/tap.js index 50405b4794..630038a28d 100644 --- a/source/tap.js +++ b/source/tap.js @@ -1,6 +1,6 @@ -import _curry2 from './internal/_curry2'; -import _dispatchable from './internal/_dispatchable'; -import _xtap from './internal/_xtap'; +import _curry2 from './internal/_curry2.js'; +import _dispatchable from './internal/_dispatchable.js'; +import _xtap from './internal/_xtap.js'; /** diff --git a/source/test.js b/source/test.js index 7045c66f79..e49ce252ae 100644 --- a/source/test.js +++ b/source/test.js @@ -1,7 +1,7 @@ -import _cloneRegExp from './internal/_cloneRegExp'; -import _curry2 from './internal/_curry2'; -import _isRegExp from './internal/_isRegExp'; -import toString from './toString'; +import _cloneRegExp from './internal/_cloneRegExp.js'; +import _curry2 from './internal/_curry2.js'; +import _isRegExp from './internal/_isRegExp.js'; +import toString from './toString.js'; /** diff --git a/source/thunkify.js b/source/thunkify.js index 9c82ac8e97..143c8fe9a2 100644 --- a/source/thunkify.js +++ b/source/thunkify.js @@ -1,5 +1,5 @@ -import curryN from './curryN'; -import _curry1 from './internal/_curry1'; +import curryN from './curryN.js'; +import _curry1 from './internal/_curry1.js'; /** * Creates a thunk out of a function. A thunk delays a calculation until diff --git a/source/times.js b/source/times.js index 1a682eea8f..63b63c9a6d 100644 --- a/source/times.js +++ b/source/times.js @@ -1,4 +1,4 @@ -import _curry2 from './internal/_curry2'; +import _curry2 from './internal/_curry2.js'; /** diff --git a/source/toLower.js b/source/toLower.js index 70ddefbef2..be4e4f6cf3 100644 --- a/source/toLower.js +++ b/source/toLower.js @@ -1,4 +1,4 @@ -import invoker from './invoker'; +import invoker from './invoker.js'; /** diff --git a/source/toPairs.js b/source/toPairs.js index 3d06e608df..d3845efff2 100644 --- a/source/toPairs.js +++ b/source/toPairs.js @@ -1,5 +1,5 @@ -import _curry1 from './internal/_curry1'; -import _has from './internal/_has'; +import _curry1 from './internal/_curry1.js'; +import _has from './internal/_has.js'; /** diff --git a/source/toPairsIn.js b/source/toPairsIn.js index 197d501c00..d3434c4ac0 100644 --- a/source/toPairsIn.js +++ b/source/toPairsIn.js @@ -1,4 +1,4 @@ -import _curry1 from './internal/_curry1'; +import _curry1 from './internal/_curry1.js'; /** diff --git a/source/toString.js b/source/toString.js index b907ab5709..eeafb45e75 100644 --- a/source/toString.js +++ b/source/toString.js @@ -1,5 +1,5 @@ -import _curry1 from './internal/_curry1'; -import _toString from './internal/_toString'; +import _curry1 from './internal/_curry1.js'; +import _toString from './internal/_toString.js'; /** diff --git a/source/toUpper.js b/source/toUpper.js index 2476564d9e..becf0e4c9a 100644 --- a/source/toUpper.js +++ b/source/toUpper.js @@ -1,4 +1,4 @@ -import invoker from './invoker'; +import invoker from './invoker.js'; /** diff --git a/source/transduce.js b/source/transduce.js index 18dcc43a6c..10ad5eafb1 100644 --- a/source/transduce.js +++ b/source/transduce.js @@ -1,6 +1,6 @@ -import _reduce from './internal/_reduce'; -import _xwrap from './internal/_xwrap'; -import curryN from './curryN'; +import _reduce from './internal/_reduce.js'; +import _xwrap from './internal/_xwrap.js'; +import curryN from './curryN.js'; /** diff --git a/source/transpose.js b/source/transpose.js index ae5fa9017b..066ccddab2 100644 --- a/source/transpose.js +++ b/source/transpose.js @@ -1,4 +1,4 @@ -import _curry1 from './internal/_curry1'; +import _curry1 from './internal/_curry1.js'; /** diff --git a/source/traverse.js b/source/traverse.js index 10134275e7..65b2ec254e 100644 --- a/source/traverse.js +++ b/source/traverse.js @@ -1,6 +1,6 @@ -import _curry3 from './internal/_curry3'; -import map from './map'; -import sequence from './sequence'; +import _curry3 from './internal/_curry3.js'; +import map from './map.js'; +import sequence from './sequence.js'; /** diff --git a/source/trim.js b/source/trim.js index 73bc528402..7c5ba8cf14 100644 --- a/source/trim.js +++ b/source/trim.js @@ -1,4 +1,4 @@ -import _curry1 from './internal/_curry1'; +import _curry1 from './internal/_curry1.js'; var ws = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003' + diff --git a/source/tryCatch.js b/source/tryCatch.js index 886728eb28..d28043a770 100644 --- a/source/tryCatch.js +++ b/source/tryCatch.js @@ -1,6 +1,6 @@ -import _arity from './internal/_arity'; -import _concat from './internal/_concat'; -import _curry2 from './internal/_curry2'; +import _arity from './internal/_arity.js'; +import _concat from './internal/_concat.js'; +import _curry2 from './internal/_curry2.js'; /** * `tryCatch` takes two functions, a `tryer` and a `catcher`. The returned diff --git a/source/type.js b/source/type.js index 82d2bdab9d..c4472867de 100644 --- a/source/type.js +++ b/source/type.js @@ -1,4 +1,4 @@ -import _curry1 from './internal/_curry1'; +import _curry1 from './internal/_curry1.js'; /** diff --git a/source/unapply.js b/source/unapply.js index d114f0a23a..3426b5a93f 100644 --- a/source/unapply.js +++ b/source/unapply.js @@ -1,4 +1,4 @@ -import _curry1 from './internal/_curry1'; +import _curry1 from './internal/_curry1.js'; /** diff --git a/source/unary.js b/source/unary.js index 74d5f37f76..11bd966b1d 100644 --- a/source/unary.js +++ b/source/unary.js @@ -1,5 +1,5 @@ -import _curry1 from './internal/_curry1'; -import nAry from './nAry'; +import _curry1 from './internal/_curry1.js'; +import nAry from './nAry.js'; /** diff --git a/source/uncurryN.js b/source/uncurryN.js index 78feab5fdb..7f2689414f 100644 --- a/source/uncurryN.js +++ b/source/uncurryN.js @@ -1,5 +1,5 @@ -import _curry2 from './internal/_curry2'; -import curryN from './curryN'; +import _curry2 from './internal/_curry2.js'; +import curryN from './curryN.js'; /** diff --git a/source/unfold.js b/source/unfold.js index 6ccd09585a..b3b7d42a68 100644 --- a/source/unfold.js +++ b/source/unfold.js @@ -1,4 +1,4 @@ -import _curry2 from './internal/_curry2'; +import _curry2 from './internal/_curry2.js'; /** diff --git a/source/union.js b/source/union.js index c047fd51de..288b2462d3 100644 --- a/source/union.js +++ b/source/union.js @@ -1,7 +1,7 @@ -import _concat from './internal/_concat'; -import _curry2 from './internal/_curry2'; -import compose from './compose'; -import uniq from './uniq'; +import _concat from './internal/_concat.js'; +import _curry2 from './internal/_curry2.js'; +import compose from './compose.js'; +import uniq from './uniq.js'; /** diff --git a/source/unionWith.js b/source/unionWith.js index 698ce4cad6..e7c4af7240 100644 --- a/source/unionWith.js +++ b/source/unionWith.js @@ -1,6 +1,6 @@ -import _concat from './internal/_concat'; -import _curry3 from './internal/_curry3'; -import uniqWith from './uniqWith'; +import _concat from './internal/_concat.js'; +import _curry3 from './internal/_curry3.js'; +import uniqWith from './uniqWith.js'; /** diff --git a/source/uniq.js b/source/uniq.js index 6a25211a57..2ae5f1a641 100644 --- a/source/uniq.js +++ b/source/uniq.js @@ -1,5 +1,5 @@ -import identity from './identity'; -import uniqBy from './uniqBy'; +import identity from './identity.js'; +import uniqBy from './uniqBy.js'; /** diff --git a/source/uniqBy.js b/source/uniqBy.js index a66ec6fc9d..3285c0aae5 100644 --- a/source/uniqBy.js +++ b/source/uniqBy.js @@ -1,5 +1,5 @@ -import _Set from './internal/_Set'; -import _curry2 from './internal/_curry2'; +import _Set from './internal/_Set.js'; +import _curry2 from './internal/_curry2.js'; /** diff --git a/source/uniqWith.js b/source/uniqWith.js index 30127c951c..2e3632d070 100644 --- a/source/uniqWith.js +++ b/source/uniqWith.js @@ -1,5 +1,5 @@ -import _includesWith from './internal/_includesWith'; -import _curry2 from './internal/_curry2'; +import _includesWith from './internal/_includesWith.js'; +import _curry2 from './internal/_curry2.js'; /** diff --git a/source/unless.js b/source/unless.js index 578379854e..fb0485f410 100644 --- a/source/unless.js +++ b/source/unless.js @@ -1,4 +1,4 @@ -import _curry3 from './internal/_curry3'; +import _curry3 from './internal/_curry3.js'; /** diff --git a/source/unnest.js b/source/unnest.js index 9e391d39ec..4153fd8e5d 100644 --- a/source/unnest.js +++ b/source/unnest.js @@ -1,5 +1,5 @@ -import _identity from './internal/_identity'; -import chain from './chain'; +import _identity from './internal/_identity.js'; +import chain from './chain.js'; /** diff --git a/source/until.js b/source/until.js index 2aa28d6abb..b539abd8a0 100644 --- a/source/until.js +++ b/source/until.js @@ -1,4 +1,4 @@ -import _curry3 from './internal/_curry3'; +import _curry3 from './internal/_curry3.js'; /** diff --git a/source/update.js b/source/update.js index 6fdafa1c61..68d1b2f275 100644 --- a/source/update.js +++ b/source/update.js @@ -1,6 +1,6 @@ -import _curry3 from './internal/_curry3'; -import adjust from './adjust'; -import always from './always'; +import _curry3 from './internal/_curry3.js'; +import adjust from './adjust.js'; +import always from './always.js'; /** diff --git a/source/useWith.js b/source/useWith.js index d429bbf2ad..6ffe77feff 100644 --- a/source/useWith.js +++ b/source/useWith.js @@ -1,5 +1,5 @@ -import _curry2 from './internal/_curry2'; -import curryN from './curryN'; +import _curry2 from './internal/_curry2.js'; +import curryN from './curryN.js'; /** diff --git a/source/values.js b/source/values.js index b9a99c3ce5..22d613d261 100644 --- a/source/values.js +++ b/source/values.js @@ -1,5 +1,5 @@ -import _curry1 from './internal/_curry1'; -import keys from './keys'; +import _curry1 from './internal/_curry1.js'; +import keys from './keys.js'; /** diff --git a/source/valuesIn.js b/source/valuesIn.js index 318c0712ea..85a5f0d81b 100644 --- a/source/valuesIn.js +++ b/source/valuesIn.js @@ -1,4 +1,4 @@ -import _curry1 from './internal/_curry1'; +import _curry1 from './internal/_curry1.js'; /** diff --git a/source/view.js b/source/view.js index 7dcfdca6dc..35b76e71e7 100644 --- a/source/view.js +++ b/source/view.js @@ -1,4 +1,4 @@ -import _curry2 from './internal/_curry2'; +import _curry2 from './internal/_curry2.js'; // `Const` is a functor that effectively ignores the function given to `map`. diff --git a/source/when.js b/source/when.js index f494bbd771..7bb50ae082 100644 --- a/source/when.js +++ b/source/when.js @@ -1,4 +1,4 @@ -import _curry3 from './internal/_curry3'; +import _curry3 from './internal/_curry3.js'; /** diff --git a/source/where.js b/source/where.js index 4106b2b905..7a357b8a72 100644 --- a/source/where.js +++ b/source/where.js @@ -1,5 +1,5 @@ -import _curry2 from './internal/_curry2'; -import _has from './internal/_has'; +import _curry2 from './internal/_curry2.js'; +import _has from './internal/_has.js'; /** diff --git a/source/whereAny.js b/source/whereAny.js index 410df60b4b..7002299fea 100644 --- a/source/whereAny.js +++ b/source/whereAny.js @@ -1,5 +1,5 @@ -import _curry2 from './internal/_curry2'; -import _has from './internal/_has'; +import _curry2 from './internal/_curry2.js'; +import _has from './internal/_has.js'; /** diff --git a/source/whereEq.js b/source/whereEq.js index 813a9752f5..30f92804c1 100644 --- a/source/whereEq.js +++ b/source/whereEq.js @@ -1,7 +1,7 @@ -import _curry2 from './internal/_curry2'; -import equals from './equals'; -import map from './map'; -import where from './where'; +import _curry2 from './internal/_curry2.js'; +import equals from './equals.js'; +import map from './map.js'; +import where from './where.js'; /** diff --git a/source/without.js b/source/without.js index 32603c39bf..facd562dd4 100644 --- a/source/without.js +++ b/source/without.js @@ -1,7 +1,7 @@ -import _includes from './internal/_includes'; -import _curry2 from './internal/_curry2'; -import flip from './flip'; -import reject from './reject'; +import _includes from './internal/_includes.js'; +import _curry2 from './internal/_curry2.js'; +import flip from './flip.js'; +import reject from './reject.js'; /** diff --git a/source/xor.js b/source/xor.js index 08a9363e1a..c9753e0777 100644 --- a/source/xor.js +++ b/source/xor.js @@ -1,4 +1,4 @@ -import _curry2 from './internal/_curry2'; +import _curry2 from './internal/_curry2.js'; /** * Exclusive disjunction logical operation. diff --git a/source/xprod.js b/source/xprod.js index 948606e866..037f2211ef 100644 --- a/source/xprod.js +++ b/source/xprod.js @@ -1,4 +1,4 @@ -import _curry2 from './internal/_curry2'; +import _curry2 from './internal/_curry2.js'; /** diff --git a/source/zip.js b/source/zip.js index 07b1bda504..4ed630cb32 100644 --- a/source/zip.js +++ b/source/zip.js @@ -1,4 +1,4 @@ -import _curry2 from './internal/_curry2'; +import _curry2 from './internal/_curry2.js'; /** diff --git a/source/zipObj.js b/source/zipObj.js index 240e496ddd..ee596e87f0 100644 --- a/source/zipObj.js +++ b/source/zipObj.js @@ -1,4 +1,4 @@ -import _curry2 from './internal/_curry2'; +import _curry2 from './internal/_curry2.js'; /** diff --git a/source/zipWith.js b/source/zipWith.js index 0c8fa5ab7d..5a46318f23 100644 --- a/source/zipWith.js +++ b/source/zipWith.js @@ -1,4 +1,4 @@ -import _curry3 from './internal/_curry3'; +import _curry3 from './internal/_curry3.js'; /** From 4f6876a267932f282fc5e87befed05548e686579 Mon Sep 17 00:00:00 2001 From: Sebastien Filion Date: Tue, 16 Jun 2020 12:20:36 -0400 Subject: [PATCH 038/111] Update ESLint configuration to handle missing file extensions on import --- .eslintrc | 7 ++++++- package.json | 1 + 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/.eslintrc b/.eslintrc index bc8e2e3ca8..9c9a0b32c7 100644 --- a/.eslintrc +++ b/.eslintrc @@ -10,6 +10,7 @@ "globals": { "Symbol": true }, + "plugins": [ "import" ], "rules": { "no-eval": 2, "eqeqeq": 0, @@ -121,6 +122,10 @@ "no-duplicate-case": 2, "no-extra-semi": 2, "no-unreachable": 2, - "semi": 2 + "semi": 2, + "import/extensions": [ + 2, + "always" + ] } } diff --git a/package.json b/package.json index 22c444b84a..6ae2e18def 100644 --- a/package.json +++ b/package.json @@ -98,6 +98,7 @@ "dox": "latest", "envvar": "^2.0.0", "eslint": "^5.16.0", + "eslint-plugin-import": "^2.21.2", "handlebars": ">=4.1.2", "js-yaml": "^3.13.1", "jsverify": "^0.8.4", From 264344891751f5d9827ca9b7eb13eaa08dbf9f64 Mon Sep 17 00:00:00 2001 From: Giuseppe Mandato Date: Wed, 17 Jun 2020 21:05:24 +0100 Subject: [PATCH 039/111] fix(style): eslint quotes and unused vars #3043 --- test/promap.js | 17 ++++++++--------- test/shared/Pair.js | 2 +- 2 files changed, 9 insertions(+), 10 deletions(-) diff --git a/test/promap.js b/test/promap.js index 0841adec46..c58c3f7383 100644 --- a/test/promap.js +++ b/test/promap.js @@ -1,5 +1,3 @@ -var assert = require('assert'); - var R = require('../source'); var eq = require('./shared/eq'); var Pair = require('./shared/Pair'); @@ -17,19 +15,20 @@ describe('promap', function() { }; } - it(`dispatches to pronfuctor["fantasy-land/promap"]() if present`, function() { + it('dispatches to pronfuctor["fantasy-land/promap"]() if present', function() { var setJson = R.promap(JSON.parse, JSON.stringify); var pair = setJson( - Pair(R.assoc("left-promapped", true), R.assoc("right-promapped", true)) + Pair(R.assoc('left-promapped', true), R.assoc('right-promapped', true)) ); + function mergeWithJson(json) { return function(left, right) { return right(left(json)); }; - }; + } - eq(pair.merge(mergeWithJson("{}")), `{"left-promapped":true,"right-promapped":true}`); + eq(pair.merge(mergeWithJson('{}')), '{"left-promapped":true,"right-promapped":true}'); }); - it(`dispatches to pronfuctor.promap() if present`, function() { + it('dispatches to pronfuctor.promap() if present', function() { var is1337Change = R.promap(R.multiply(100), R.equals(1337), Costar(R.sum)); var data = [10, 3, 0.3, 0.07]; @@ -39,8 +38,8 @@ describe('promap', function() { it('composes two functions, f and g, before and after the final function respectively', function() { var decodeChar = R.promap(charCodeAt, fromCharCode, R.add(-8)); var decodeString = R.promap(R.split(''), R.join(''), R.map(decodeChar)); - var code = "ziuli"; + var code = 'ziuli'; - eq(decodeString(code), "ramda"); + eq(decodeString(code), 'ramda'); }); }); diff --git a/test/shared/Pair.js b/test/shared/Pair.js index bc635c4392..66f7184ee2 100644 --- a/test/shared/Pair.js +++ b/test/shared/Pair.js @@ -38,7 +38,7 @@ function Pair(left, right) { }, toArray: function toArray() { return [left, right]; }, left: left, - right: right, + right: right }; } From d48f6510f6d46aef840df9d644fde9ef0720c8a4 Mon Sep 17 00:00:00 2001 From: Sebastien Filion Date: Fri, 19 Jun 2020 07:51:34 -0400 Subject: [PATCH 040/111] Add extension to new promap function --- source/internal/_xpromap.js | 6 +++--- source/promap.js | 8 ++++---- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/source/internal/_xpromap.js b/source/internal/_xpromap.js index d25976e929..d097624bc7 100644 --- a/source/internal/_xpromap.js +++ b/source/internal/_xpromap.js @@ -1,6 +1,6 @@ -import _curry3 from './_curry3'; -import _xfBase from './_xfBase'; -import _promap from './_promap'; +import _curry3 from './_curry3.js'; +import _xfBase from './_xfBase.js'; +import _promap from './_promap.js'; function XPromap(f, g, xf) { diff --git a/source/promap.js b/source/promap.js index 7a4e22c52d..86805e7c49 100644 --- a/source/promap.js +++ b/source/promap.js @@ -1,7 +1,7 @@ -import _curry3 from './internal/_curry3'; -import _dispatchable from './internal/_dispatchable'; -import _promap from './internal/_promap'; -import _xpromap from './internal/_xpromap'; +import _curry3 from './internal/_curry3.js'; +import _dispatchable from './internal/_dispatchable.js'; +import _promap from './internal/_promap.js'; +import _xpromap from './internal/_xpromap.js'; /** From 937890662254efd2ed28572fb0703d24ed41f9ec Mon Sep 17 00:00:00 2001 From: Josh Howe Date: Mon, 22 Jun 2020 15:11:07 -0400 Subject: [PATCH 041/111] Fix dispatching to `traverse` method (#3031) (#3031) Before this change, R.traverse dispatched only to `fantasy-land/traverse`, and ignored the `traverse` method of the third argument, even if one was available. This makes R.traverse dispatch to `traverse` if it is available and `fantasy-land/traverse` is unavailable. This fixes issue #3026. --- source/traverse.js | 10 +++++++--- test/traverse.js | 30 +++++++++++++++++++++++++++--- 2 files changed, 34 insertions(+), 6 deletions(-) diff --git a/source/traverse.js b/source/traverse.js index 65b2ec254e..6cb182500e 100644 --- a/source/traverse.js +++ b/source/traverse.js @@ -30,8 +30,12 @@ import sequence from './sequence.js'; * R.traverse(Maybe.of, safeDiv(10), [2, 0, 5]); //=> Maybe.Nothing */ var traverse = _curry3(function traverse(of, f, traversable) { - return typeof traversable['fantasy-land/traverse'] === 'function' ? - traversable['fantasy-land/traverse'](f, of) : - sequence(of, map(f, traversable)); + return ( + typeof traversable['fantasy-land/traverse'] === 'function' + ? traversable['fantasy-land/traverse'](f, of) + : typeof traversable.traverse === 'function' + ? traversable.traverse(f, of) + : sequence(of, map(f, traversable)) + ); }); export default traverse; diff --git a/test/traverse.js b/test/traverse.js index 2f5e120a68..7870b14a91 100644 --- a/test/traverse.js +++ b/test/traverse.js @@ -28,9 +28,33 @@ describe('traverse', function() { eq(R.traverse(S.Either.of, R.identity, [S.Left('XXX'), S.Left('YYY')]), S.Left('XXX')); }); - it('dispatches to `sequence` method', function() { - eq(R.traverse(Id, R.map(R.negate), [Id(1), Id(2), Id(3)]), Id([-1, -2, -3])); - eq(R.traverse(R.of, R.map(R.negate), Id([1, 2, 3])), [Id(-1), Id(-2), Id(-3)]); + it('dispatches to `traverse` method', function() { + const mockTraversable = { traverse(_1, _2) { return 'traverse called'; } }; + + eq(R.traverse(Id, R.identity, mockTraversable), 'traverse called'); + }); + + it('dispatches to `fantasy-land/traverse` method', function() { + const mockTraversable2 = { + ['fantasy-land/traverse'](_1, _2) { return 'fantasy-land/traverse called'; } + }; + eq(R.traverse(Id, R.identity, mockTraversable2), 'fantasy-land/traverse called'); + }); + + it('dispatches to `fantasy-land/traverse` method when it and `traverse` exist', function() { + const mockTraversable3 = { + traverse(_1, _2) { return 'traverse called'; }, + ['fantasy-land/traverse'](_1, _2) { return 'fantasy-land/traverse called'; } + }; + eq(R.traverse(Id, R.identity, mockTraversable3), 'fantasy-land/traverse called'); + }); + + it('dispatches to `traverse` when it exists and `fantasy-land/traverse` is not a function', function() { + const mockTraversable4 = { + traverse(_1, _2) { return 'traverse called'; }, + 'fantasy-land/traverse': new Error() + }; + eq(R.traverse(Id, R.identity, mockTraversable4), 'traverse called'); }); }); From 84db70b80ef8797f2fa5e7e5391517fa92dc9469 Mon Sep 17 00:00:00 2001 From: Giuseppe Mandato Date: Thu, 25 Jun 2020 14:42:01 +0100 Subject: [PATCH 042/111] fix(deps): update lockfile --- package-lock.json | 708 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 708 insertions(+) diff --git a/package-lock.json b/package-lock.json index 884ddaed0d..61faac5ef7 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3160,6 +3160,12 @@ "integrity": "sha512-EYNwp3bU+98cpU4lAWYYL7Zz+2gryWH1qbdDTidVd6hkiR6weksdbMadyXKXNPEkQFhXM+hVO9ZygomHXp+AIw==", "dev": true }, + "@types/json5": { + "version": "0.0.29", + "resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz", + "integrity": "sha1-7ihweulOEdK4J7y+UnC86n8+ce4=", + "dev": true + }, "@types/node": { "version": "12.0.2", "resolved": "https://registry.npmjs.org/@types/node/-/node-12.0.2.tgz", @@ -3403,6 +3409,133 @@ "integrity": "sha1-z+nYwmYoudxa7MYqn12PHzUsEZU=", "dev": true }, + "array-includes": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/array-includes/-/array-includes-3.1.1.tgz", + "integrity": "sha512-c2VXaCHl7zPsvpkFsw4nxvFie4fh1ur9bpcgsVkIjqn0H/Xwdg+7fv3n2r/isyS8EBj5b06M9kHyZuIr4El6WQ==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "es-abstract": "^1.17.0", + "is-string": "^1.0.5" + }, + "dependencies": { + "es-abstract": { + "version": "1.17.6", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.17.6.tgz", + "integrity": "sha512-Fr89bON3WFyUi5EvAeI48QTWX0AyekGgLA8H+c+7fbfCkJwRWRMLd8CQedNEyJuoYYhmtEqY92pgte1FAhBlhw==", + "dev": true, + "requires": { + "es-to-primitive": "^1.2.1", + "function-bind": "^1.1.1", + "has": "^1.0.3", + "has-symbols": "^1.0.1", + "is-callable": "^1.2.0", + "is-regex": "^1.1.0", + "object-inspect": "^1.7.0", + "object-keys": "^1.1.1", + "object.assign": "^4.1.0", + "string.prototype.trimend": "^1.0.1", + "string.prototype.trimstart": "^1.0.1" + } + }, + "es-to-primitive": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz", + "integrity": "sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==", + "dev": true, + "requires": { + "is-callable": "^1.1.4", + "is-date-object": "^1.0.1", + "is-symbol": "^1.0.2" + } + }, + "has-symbols": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.1.tgz", + "integrity": "sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg==", + "dev": true + }, + "is-callable": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.0.tgz", + "integrity": "sha512-pyVD9AaGLxtg6srb2Ng6ynWJqkHU9bEM087AKck0w8QwDarTfNcpIYoU8x8Hv2Icm8u6kFJM18Dag8lyqGkviw==", + "dev": true + }, + "is-regex": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.0.tgz", + "integrity": "sha512-iI97M8KTWID2la5uYXlkbSDQIg4F6o1sYboZKKTDpnDQMLtUL86zxhgDet3Q2SriaYsyGqZ6Mn2SjbRKeLHdqw==", + "dev": true, + "requires": { + "has-symbols": "^1.0.1" + } + } + } + }, + "array.prototype.flat": { + "version": "1.2.3", + "resolved": "https://registry.npmjs.org/array.prototype.flat/-/array.prototype.flat-1.2.3.tgz", + "integrity": "sha512-gBlRZV0VSmfPIeWfuuy56XZMvbVfbEUnOXUvt3F/eUUUSyzlgLxhEX4YAEpxNAogRGehPSnfXyPtYyKAhkzQhQ==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "es-abstract": "^1.17.0-next.1" + }, + "dependencies": { + "es-abstract": { + "version": "1.17.6", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.17.6.tgz", + "integrity": "sha512-Fr89bON3WFyUi5EvAeI48QTWX0AyekGgLA8H+c+7fbfCkJwRWRMLd8CQedNEyJuoYYhmtEqY92pgte1FAhBlhw==", + "dev": true, + "requires": { + "es-to-primitive": "^1.2.1", + "function-bind": "^1.1.1", + "has": "^1.0.3", + "has-symbols": "^1.0.1", + "is-callable": "^1.2.0", + "is-regex": "^1.1.0", + "object-inspect": "^1.7.0", + "object-keys": "^1.1.1", + "object.assign": "^4.1.0", + "string.prototype.trimend": "^1.0.1", + "string.prototype.trimstart": "^1.0.1" + } + }, + "es-to-primitive": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz", + "integrity": "sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==", + "dev": true, + "requires": { + "is-callable": "^1.1.4", + "is-date-object": "^1.0.1", + "is-symbol": "^1.0.2" + } + }, + "has-symbols": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.1.tgz", + "integrity": "sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg==", + "dev": true + }, + "is-callable": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.0.tgz", + "integrity": "sha512-pyVD9AaGLxtg6srb2Ng6ynWJqkHU9bEM087AKck0w8QwDarTfNcpIYoU8x8Hv2Icm8u6kFJM18Dag8lyqGkviw==", + "dev": true + }, + "is-regex": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.0.tgz", + "integrity": "sha512-iI97M8KTWID2la5uYXlkbSDQIg4F6o1sYboZKKTDpnDQMLtUL86zxhgDet3Q2SriaYsyGqZ6Mn2SjbRKeLHdqw==", + "dev": true, + "requires": { + "has-symbols": "^1.0.1" + } + } + } + }, "arraybuffer.slice": { "version": "0.0.7", "resolved": "https://registry.npmjs.org/arraybuffer.slice/-/arraybuffer.slice-0.0.7.tgz", @@ -4362,6 +4495,12 @@ "integrity": "sha1-kld9tSe6bEzwpFaNhLwDH0QeIfI=", "dev": true }, + "contains-path": { + "version": "0.1.0", + "resolved": "https://registry.npmjs.org/contains-path/-/contains-path-0.1.0.tgz", + "integrity": "sha1-/ozxhP9mcLa67wGp1IYaXL7EEgo=", + "dev": true + }, "content-disposition": { "version": "0.5.3", "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.3.tgz", @@ -4915,6 +5054,15 @@ "integrity": "sha1-cewM0PmFU5owRtT02lbGfXwr8D8=", "dev": true }, + "error-ex": { + "version": "1.3.2", + "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", + "integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==", + "dev": true, + "requires": { + "is-arrayish": "^0.2.1" + } + }, "es-abstract": { "version": "1.13.0", "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.13.0.tgz", @@ -5039,6 +5187,139 @@ } } }, + "eslint-import-resolver-node": { + "version": "0.3.4", + "resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.4.tgz", + "integrity": "sha512-ogtf+5AB/O+nM6DIeBUNr2fuT7ot9Qg/1harBfBtaP13ekEWFQEEMP94BCB7zaNW3gyY+8SHYF00rnqYwXKWOA==", + "dev": true, + "requires": { + "debug": "^2.6.9", + "resolve": "^1.13.1" + }, + "dependencies": { + "resolve": { + "version": "1.17.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.17.0.tgz", + "integrity": "sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w==", + "dev": true, + "requires": { + "path-parse": "^1.0.6" + } + } + } + }, + "eslint-module-utils": { + "version": "2.6.0", + "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.6.0.tgz", + "integrity": "sha512-6j9xxegbqe8/kZY8cYpcp0xhbK0EgJlg3g9mib3/miLaExuuwc3n5UEfSnU6hWMbT0FAYVvDbL9RrRgpUeQIvA==", + "dev": true, + "requires": { + "debug": "^2.6.9", + "pkg-dir": "^2.0.0" + }, + "dependencies": { + "find-up": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz", + "integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=", + "dev": true, + "requires": { + "locate-path": "^2.0.0" + } + }, + "locate-path": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz", + "integrity": "sha1-K1aLJl7slExtnA3pw9u7ygNUzY4=", + "dev": true, + "requires": { + "p-locate": "^2.0.0", + "path-exists": "^3.0.0" + } + }, + "p-limit": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz", + "integrity": "sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q==", + "dev": true, + "requires": { + "p-try": "^1.0.0" + } + }, + "p-locate": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-2.0.0.tgz", + "integrity": "sha1-IKAQOyIqcMj9OcwuWAaA893l7EM=", + "dev": true, + "requires": { + "p-limit": "^1.1.0" + } + }, + "p-try": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz", + "integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=", + "dev": true + }, + "pkg-dir": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-2.0.0.tgz", + "integrity": "sha1-9tXREJ4Z1j7fQo4L1X4Sd3YVM0s=", + "dev": true, + "requires": { + "find-up": "^2.1.0" + } + } + } + }, + "eslint-plugin-import": { + "version": "2.21.2", + "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.21.2.tgz", + "integrity": "sha512-FEmxeGI6yaz+SnEB6YgNHlQK1Bs2DKLM+YF+vuTk5H8J9CLbJLtlPvRFgZZ2+sXiKAlN5dpdlrWOjK8ZoZJpQA==", + "dev": true, + "requires": { + "array-includes": "^3.1.1", + "array.prototype.flat": "^1.2.3", + "contains-path": "^0.1.0", + "debug": "^2.6.9", + "doctrine": "1.5.0", + "eslint-import-resolver-node": "^0.3.3", + "eslint-module-utils": "^2.6.0", + "has": "^1.0.3", + "minimatch": "^3.0.4", + "object.values": "^1.1.1", + "read-pkg-up": "^2.0.0", + "resolve": "^1.17.0", + "tsconfig-paths": "^3.9.0" + }, + "dependencies": { + "doctrine": { + "version": "1.5.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-1.5.0.tgz", + "integrity": "sha1-N53Ocw9hZvds76TmcHoVmwLFpvo=", + "dev": true, + "requires": { + "esutils": "^2.0.2", + "isarray": "^1.0.0" + } + }, + "isarray": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", + "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "dev": true + }, + "resolve": { + "version": "1.17.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.17.0.tgz", + "integrity": "sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w==", + "dev": true, + "requires": { + "path-parse": "^1.0.6" + } + } + } + }, "eslint-scope": { "version": "4.0.3", "resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-4.0.3.tgz", @@ -5864,6 +6145,12 @@ "minimalistic-crypto-utils": "^1.0.1" } }, + "hosted-git-info": { + "version": "2.8.8", + "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.8.tgz", + "integrity": "sha512-f/wzC2QaWBs7t9IYqB4T3sR1xviIViXJRJTWBlx2Gf3g0Xi5vI7Yy4koXQ1c9OYDGHN9sBy1DQ2AB8fqZBWhUg==", + "dev": true + }, "html-escaper": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz", @@ -6140,6 +6427,12 @@ "kind-of": "^3.0.2" } }, + "is-arrayish": { + "version": "0.2.1", + "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", + "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=", + "dev": true + }, "is-binary-path": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-1.0.1.tgz", @@ -6258,6 +6551,12 @@ "integrity": "sha1-EtSj3U5o4Lec6428hBc66A2RykQ=", "dev": true }, + "is-string": { + "version": "1.0.5", + "resolved": "https://registry.npmjs.org/is-string/-/is-string-1.0.5.tgz", + "integrity": "sha512-buY6VNRjhQMiF1qWDouloZlQbRhDPCebwxSjxMjxgemYT46YMd2NR0/H+fBhEfWX4A/w9TBJ+ol+okqJKFE6vQ==", + "dev": true + }, "is-symbol": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.2.tgz", @@ -6976,6 +7275,32 @@ "uc.micro": "^1.0.1" } }, + "load-json-file": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-2.0.0.tgz", + "integrity": "sha1-eUfkIUmvgNaWy/eXvKq8/h/inKg=", + "dev": true, + "requires": { + "graceful-fs": "^4.1.2", + "parse-json": "^2.2.0", + "pify": "^2.0.0", + "strip-bom": "^3.0.0" + }, + "dependencies": { + "pify": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", + "dev": true + }, + "strip-bom": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", + "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=", + "dev": true + } + } + }, "locate-path": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", @@ -7750,6 +8075,29 @@ } } }, + "normalize-package-data": { + "version": "2.5.0", + "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", + "integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==", + "dev": true, + "requires": { + "hosted-git-info": "^2.1.4", + "resolve": "^1.10.0", + "semver": "2 || 3 || 4 || 5", + "validate-npm-package-license": "^3.0.1" + }, + "dependencies": { + "resolve": { + "version": "1.17.0", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.17.0.tgz", + "integrity": "sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w==", + "dev": true, + "requires": { + "path-parse": "^1.0.6" + } + } + } + }, "npm-run-path": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz", @@ -7962,6 +8310,12 @@ } } }, + "object-inspect": { + "version": "1.8.0", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.8.0.tgz", + "integrity": "sha512-jLdtEOB112fORuypAyl/50VRVIBIdVQOSUUGQHzJ4xBSbit81zRarz7GThkEFZy1RceYrWYcPcBFPQwHyAc1gA==", + "dev": true + }, "object-keys": { "version": "1.1.1", "resolved": "https://registry.npmjs.org/object-keys/-/object-keys-1.1.1.tgz", @@ -8028,6 +8382,71 @@ } } }, + "object.values": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/object.values/-/object.values-1.1.1.tgz", + "integrity": "sha512-WTa54g2K8iu0kmS/us18jEmdv1a4Wi//BZ/DTVYEcH0XhLM5NYdpDHja3gt57VrZLcNAO2WGA+KpWsDBaHt6eA==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "es-abstract": "^1.17.0-next.1", + "function-bind": "^1.1.1", + "has": "^1.0.3" + }, + "dependencies": { + "es-abstract": { + "version": "1.17.6", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.17.6.tgz", + "integrity": "sha512-Fr89bON3WFyUi5EvAeI48QTWX0AyekGgLA8H+c+7fbfCkJwRWRMLd8CQedNEyJuoYYhmtEqY92pgte1FAhBlhw==", + "dev": true, + "requires": { + "es-to-primitive": "^1.2.1", + "function-bind": "^1.1.1", + "has": "^1.0.3", + "has-symbols": "^1.0.1", + "is-callable": "^1.2.0", + "is-regex": "^1.1.0", + "object-inspect": "^1.7.0", + "object-keys": "^1.1.1", + "object.assign": "^4.1.0", + "string.prototype.trimend": "^1.0.1", + "string.prototype.trimstart": "^1.0.1" + } + }, + "es-to-primitive": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz", + "integrity": "sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==", + "dev": true, + "requires": { + "is-callable": "^1.1.4", + "is-date-object": "^1.0.1", + "is-symbol": "^1.0.2" + } + }, + "has-symbols": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.1.tgz", + "integrity": "sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg==", + "dev": true + }, + "is-callable": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.0.tgz", + "integrity": "sha512-pyVD9AaGLxtg6srb2Ng6ynWJqkHU9bEM087AKck0w8QwDarTfNcpIYoU8x8Hv2Icm8u6kFJM18Dag8lyqGkviw==", + "dev": true + }, + "is-regex": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.0.tgz", + "integrity": "sha512-iI97M8KTWID2la5uYXlkbSDQIg4F6o1sYboZKKTDpnDQMLtUL86zxhgDet3Q2SriaYsyGqZ6Mn2SjbRKeLHdqw==", + "dev": true, + "requires": { + "has-symbols": "^1.0.1" + } + } + } + }, "on-finished": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/on-finished/-/on-finished-2.3.0.tgz", @@ -8226,6 +8645,15 @@ "pbkdf2": "^3.0.3" } }, + "parse-json": { + "version": "2.2.0", + "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz", + "integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=", + "dev": true, + "requires": { + "error-ex": "^1.2.0" + } + }, "parseqs": { "version": "0.0.5", "resolved": "https://registry.npmjs.org/parseqs/-/parseqs-0.0.5.tgz", @@ -8315,6 +8743,23 @@ "isarray": "0.0.1" } }, + "path-type": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/path-type/-/path-type-2.0.0.tgz", + "integrity": "sha1-8BLMuEFbcJb8LaoQVMPXI4lZTHM=", + "dev": true, + "requires": { + "pify": "^2.0.0" + }, + "dependencies": { + "pify": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", + "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", + "dev": true + } + } + }, "pbkdf2": { "version": "3.0.17", "resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.0.17.tgz", @@ -8513,6 +8958,72 @@ "integrity": "sha1-CMbgSgFo9utiHCKrbLEVG9n0pk0=", "dev": true }, + "read-pkg": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-2.0.0.tgz", + "integrity": "sha1-jvHAYjxqbbDcZxPEv6xGMysjaPg=", + "dev": true, + "requires": { + "load-json-file": "^2.0.0", + "normalize-package-data": "^2.3.2", + "path-type": "^2.0.0" + } + }, + "read-pkg-up": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-2.0.0.tgz", + "integrity": "sha1-a3KoBImE4MQeeVEP1en6mbO1Sb4=", + "dev": true, + "requires": { + "find-up": "^2.0.0", + "read-pkg": "^2.0.0" + }, + "dependencies": { + "find-up": { + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz", + "integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=", + "dev": true, + "requires": { + "locate-path": "^2.0.0" + } + }, + "locate-path": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz", + "integrity": "sha1-K1aLJl7slExtnA3pw9u7ygNUzY4=", + "dev": true, + "requires": { + "p-locate": "^2.0.0", + "path-exists": "^3.0.0" + } + }, + "p-limit": { + "version": "1.3.0", + "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz", + "integrity": "sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q==", + "dev": true, + "requires": { + "p-try": "^1.0.0" + } + }, + "p-locate": { + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-2.0.0.tgz", + "integrity": "sha1-IKAQOyIqcMj9OcwuWAaA893l7EM=", + "dev": true, + "requires": { + "p-limit": "^1.1.0" + } + }, + "p-try": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz", + "integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=", + "dev": true + } + } + }, "readable-stream": { "version": "1.1.14", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", @@ -9348,6 +9859,38 @@ } } }, + "spdx-correct": { + "version": "3.1.1", + "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.1.1.tgz", + "integrity": "sha512-cOYcUWwhCuHCXi49RhFRCyJEK3iPj1Ziz9DpViV3tbZOwXD49QzIN3MpOLJNxh2qwq2lJJZaKMVw9qNi4jTC0w==", + "dev": true, + "requires": { + "spdx-expression-parse": "^3.0.0", + "spdx-license-ids": "^3.0.0" + } + }, + "spdx-exceptions": { + "version": "2.3.0", + "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.3.0.tgz", + "integrity": "sha512-/tTrYOC7PPI1nUAgx34hUpqXuyJG+DTHJTnIULG4rDygi4xu/tfgmq1e1cIRwRzwZgo4NLySi+ricLkZkw4i5A==", + "dev": true + }, + "spdx-expression-parse": { + "version": "3.0.1", + "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.1.tgz", + "integrity": "sha512-cbqHunsQWnJNE6KhVSMsMeH5H/L9EpymbzqTQ3uLwNCLZ1Q481oWaofqH7nO6V07xlXwY6PhQdQ2IedWx/ZK4Q==", + "dev": true, + "requires": { + "spdx-exceptions": "^2.1.0", + "spdx-license-ids": "^3.0.0" + } + }, + "spdx-license-ids": { + "version": "3.0.5", + "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.5.tgz", + "integrity": "sha512-J+FWzZoynJEXGphVIS+XEh3kFSjZX/1i9gFBaWQcB+/tmpe2qUsSBABpcxqxnAxFdiUFEgAX1bjYGQvIZmoz9Q==", + "dev": true + }, "split-string": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz", @@ -9467,6 +10010,132 @@ "strip-ansi": "^4.0.0" } }, + "string.prototype.trimend": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/string.prototype.trimend/-/string.prototype.trimend-1.0.1.tgz", + "integrity": "sha512-LRPxFUaTtpqYsTeNKaFOw3R4bxIzWOnbQ837QfBylo8jIxtcbK/A/sMV7Q+OAV/vWo+7s25pOE10KYSjaSO06g==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "es-abstract": "^1.17.5" + }, + "dependencies": { + "es-abstract": { + "version": "1.17.6", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.17.6.tgz", + "integrity": "sha512-Fr89bON3WFyUi5EvAeI48QTWX0AyekGgLA8H+c+7fbfCkJwRWRMLd8CQedNEyJuoYYhmtEqY92pgte1FAhBlhw==", + "dev": true, + "requires": { + "es-to-primitive": "^1.2.1", + "function-bind": "^1.1.1", + "has": "^1.0.3", + "has-symbols": "^1.0.1", + "is-callable": "^1.2.0", + "is-regex": "^1.1.0", + "object-inspect": "^1.7.0", + "object-keys": "^1.1.1", + "object.assign": "^4.1.0", + "string.prototype.trimend": "^1.0.1", + "string.prototype.trimstart": "^1.0.1" + } + }, + "es-to-primitive": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz", + "integrity": "sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==", + "dev": true, + "requires": { + "is-callable": "^1.1.4", + "is-date-object": "^1.0.1", + "is-symbol": "^1.0.2" + } + }, + "has-symbols": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.1.tgz", + "integrity": "sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg==", + "dev": true + }, + "is-callable": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.0.tgz", + "integrity": "sha512-pyVD9AaGLxtg6srb2Ng6ynWJqkHU9bEM087AKck0w8QwDarTfNcpIYoU8x8Hv2Icm8u6kFJM18Dag8lyqGkviw==", + "dev": true + }, + "is-regex": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.0.tgz", + "integrity": "sha512-iI97M8KTWID2la5uYXlkbSDQIg4F6o1sYboZKKTDpnDQMLtUL86zxhgDet3Q2SriaYsyGqZ6Mn2SjbRKeLHdqw==", + "dev": true, + "requires": { + "has-symbols": "^1.0.1" + } + } + } + }, + "string.prototype.trimstart": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/string.prototype.trimstart/-/string.prototype.trimstart-1.0.1.tgz", + "integrity": "sha512-XxZn+QpvrBI1FOcg6dIpxUPgWCPuNXvMD72aaRaUQv1eD4e/Qy8i/hFTe0BUmD60p/QA6bh1avmuPTfNjqVWRw==", + "dev": true, + "requires": { + "define-properties": "^1.1.3", + "es-abstract": "^1.17.5" + }, + "dependencies": { + "es-abstract": { + "version": "1.17.6", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.17.6.tgz", + "integrity": "sha512-Fr89bON3WFyUi5EvAeI48QTWX0AyekGgLA8H+c+7fbfCkJwRWRMLd8CQedNEyJuoYYhmtEqY92pgte1FAhBlhw==", + "dev": true, + "requires": { + "es-to-primitive": "^1.2.1", + "function-bind": "^1.1.1", + "has": "^1.0.3", + "has-symbols": "^1.0.1", + "is-callable": "^1.2.0", + "is-regex": "^1.1.0", + "object-inspect": "^1.7.0", + "object-keys": "^1.1.1", + "object.assign": "^4.1.0", + "string.prototype.trimend": "^1.0.1", + "string.prototype.trimstart": "^1.0.1" + } + }, + "es-to-primitive": { + "version": "1.2.1", + "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz", + "integrity": "sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==", + "dev": true, + "requires": { + "is-callable": "^1.1.4", + "is-date-object": "^1.0.1", + "is-symbol": "^1.0.2" + } + }, + "has-symbols": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.1.tgz", + "integrity": "sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg==", + "dev": true + }, + "is-callable": { + "version": "1.2.0", + "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.0.tgz", + "integrity": "sha512-pyVD9AaGLxtg6srb2Ng6ynWJqkHU9bEM087AKck0w8QwDarTfNcpIYoU8x8Hv2Icm8u6kFJM18Dag8lyqGkviw==", + "dev": true + }, + "is-regex": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.0.tgz", + "integrity": "sha512-iI97M8KTWID2la5uYXlkbSDQIg4F6o1sYboZKKTDpnDQMLtUL86zxhgDet3Q2SriaYsyGqZ6Mn2SjbRKeLHdqw==", + "dev": true, + "requires": { + "has-symbols": "^1.0.1" + } + } + } + }, "string_decoder": { "version": "0.10.31", "resolved": "https://registry.npmjs.org/string_decoder/-/string_decoder-0.10.31.tgz", @@ -9801,6 +10470,35 @@ "integrity": "sha1-yy4SAwZ+DI3h9hQJS5/kVwTqYAM=", "dev": true }, + "tsconfig-paths": { + "version": "3.9.0", + "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.9.0.tgz", + "integrity": "sha512-dRcuzokWhajtZWkQsDVKbWyY+jgcLC5sqJhg2PSgf4ZkH2aHPvaOY8YWGhmjb68b5qqTfasSsDO9k7RUiEmZAw==", + "dev": true, + "requires": { + "@types/json5": "^0.0.29", + "json5": "^1.0.1", + "minimist": "^1.2.0", + "strip-bom": "^3.0.0" + }, + "dependencies": { + "json5": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/json5/-/json5-1.0.1.tgz", + "integrity": "sha512-aKS4WQjPenRxiQsC93MNfjx+nbF4PAdYzmd/1JIj8HYzqfbu86beTuNgXDzPknWk0n0uARlyewZo4s++ES36Ow==", + "dev": true, + "requires": { + "minimist": "^1.2.0" + } + }, + "strip-bom": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", + "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=", + "dev": true + } + } + }, "tslib": { "version": "1.9.3", "resolved": "https://registry.npmjs.org/tslib/-/tslib-1.9.3.tgz", @@ -10103,6 +10801,16 @@ "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", "dev": true }, + "validate-npm-package-license": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz", + "integrity": "sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==", + "dev": true, + "requires": { + "spdx-correct": "^3.0.0", + "spdx-expression-parse": "^3.0.0" + } + }, "vary": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", From 74faf72c5b430d33f7329afe00524998ead46021 Mon Sep 17 00:00:00 2001 From: c4605 Date: Fri, 26 Jun 2020 09:06:18 +0800 Subject: [PATCH 043/111] assoc/dissoc support operate array (#2787) --- source/assoc.js | 16 +++++----------- source/assocPath.js | 12 ++---------- source/dissoc.js | 11 ++--------- source/dissocPath.js | 35 ++++++++++++++++++++++++++++------- source/internal/_assoc.js | 29 +++++++++++++++++++++++++++++ source/internal/_dissoc.js | 28 ++++++++++++++++++++++++++++ test/assoc.js | 24 ++++++++++++++++++++++++ test/dissoc.js | 30 ++++++++++++++++++++++++++++++ test/dissocPath.js | 13 +++++++++++++ 9 files changed, 161 insertions(+), 37 deletions(-) create mode 100644 source/internal/_assoc.js create mode 100644 source/internal/_dissoc.js diff --git a/source/assoc.js b/source/assoc.js index 9a9d18c4e6..f7267eb27f 100644 --- a/source/assoc.js +++ b/source/assoc.js @@ -1,5 +1,5 @@ import _curry3 from './internal/_curry3.js'; - +import assocPath from './assocPath.js'; /** * Makes a shallow clone of an object, setting or overriding the specified @@ -11,8 +11,9 @@ import _curry3 from './internal/_curry3.js'; * @memberOf R * @since v0.8.0 * @category Object - * @sig String -> a -> {k: v} -> {k: v} - * @param {String} prop The property name to set + * @typedefn Idx = String | Int + * @sig Idx -> a -> {k: v} -> {k: v} + * @param {String|Number} prop The property name to set * @param {*} val The new value * @param {Object} obj The object to clone * @return {Object} A new object equivalent to the original except for the changed property. @@ -21,12 +22,5 @@ import _curry3 from './internal/_curry3.js'; * * R.assoc('c', 3, {a: 1, b: 2}); //=> {a: 1, b: 2, c: 3} */ -var assoc = _curry3(function assoc(prop, val, obj) { - var result = {}; - for (var p in obj) { - result[p] = obj[p]; - } - result[prop] = val; - return result; -}); +var assoc = _curry3(function assoc(prop, val, obj) { return assocPath([prop], val, obj); }); export default assoc; diff --git a/source/assocPath.js b/source/assocPath.js index 8199a7b369..f9144dea77 100644 --- a/source/assocPath.js +++ b/source/assocPath.js @@ -1,11 +1,9 @@ import _curry3 from './internal/_curry3.js'; import _has from './internal/_has.js'; -import _isArray from './internal/_isArray.js'; import _isInteger from './internal/_isInteger.js'; -import assoc from './assoc.js'; +import _assoc from './internal/_assoc.js'; import isNil from './isNil.js'; - /** * Makes a shallow clone of an object, setting or overriding the nodes required * to create the given path, and placing the specific value at the tail end of @@ -39,12 +37,6 @@ var assocPath = _curry3(function assocPath(path, val, obj) { var nextObj = (!isNil(obj) && _has(idx, obj)) ? obj[idx] : _isInteger(path[1]) ? [] : {}; val = assocPath(Array.prototype.slice.call(path, 1), val, nextObj); } - if (_isInteger(idx) && _isArray(obj)) { - var arr = [].concat(obj); - arr[idx] = val; - return arr; - } else { - return assoc(idx, val, obj); - } + return _assoc(idx, val, obj); }); export default assocPath; diff --git a/source/dissoc.js b/source/dissoc.js index a86413cab0..5404c76c69 100644 --- a/source/dissoc.js +++ b/source/dissoc.js @@ -1,5 +1,5 @@ import _curry2 from './internal/_curry2.js'; - +import dissocPath from './dissocPath.js'; /** * Returns a new object that does not contain a `prop` property. @@ -17,12 +17,5 @@ import _curry2 from './internal/_curry2.js'; * * R.dissoc('b', {a: 1, b: 2, c: 3}); //=> {a: 1, c: 3} */ -var dissoc = _curry2(function dissoc(prop, obj) { - var result = {}; - for (var p in obj) { - result[p] = obj[p]; - } - delete result[prop]; - return result; -}); +var dissoc = _curry2(function dissoc(prop, obj) { return dissocPath([prop], obj); }); export default dissoc; diff --git a/source/dissocPath.js b/source/dissocPath.js index 96c8130406..1fdce85861 100644 --- a/source/dissocPath.js +++ b/source/dissocPath.js @@ -1,11 +1,30 @@ import _curry2 from './internal/_curry2.js'; +import _dissoc from './internal/_dissoc.js'; import _isInteger from './internal/_isInteger.js'; import _isArray from './internal/_isArray.js'; import assoc from './assoc.js'; -import dissoc from './dissoc.js'; -import remove from './remove.js'; -import update from './update.js'; +/** + * Makes a shallow clone of an object. Note that this copies and flattens + * prototype properties onto the new object as well. All non-primitive + * properties are copied by reference. + * + * @private + * @param {String|Integer} prop The prop operating + * @param {Object|Array} obj The object to clone + * @return {Object|Array} A new object equivalent to the original. + */ +function _shallowCloneObject(prop, obj) { + if (_isInteger(prop) && _isArray(obj)) { + return [].concat(obj); + } + + var result = {}; + for (var p in obj) { + result[p] = obj[p]; + } + return result; +} /** * Makes a shallow clone of an object, omitting the property at the given path. @@ -27,18 +46,20 @@ import update from './update.js'; * R.dissocPath(['a', 'b', 'c'], {a: {b: {c: 42}}}); //=> {a: {b: {}}} */ var dissocPath = _curry2(function dissocPath(path, obj) { + if (obj == null) { + return obj; + } + switch (path.length) { case 0: return obj; case 1: - return _isInteger(path[0]) && _isArray(obj) ? remove(path[0], 1, obj) : dissoc(path[0], obj); + return _dissoc(path[0], obj); default: var head = path[0]; var tail = Array.prototype.slice.call(path, 1); if (obj[head] == null) { - return obj; - } else if (_isInteger(head) && _isArray(obj)) { - return update(head, dissocPath(tail, obj[head]), obj); + return _shallowCloneObject(head, obj); } else { return assoc(head, dissocPath(tail, obj[head]), obj); } diff --git a/source/internal/_assoc.js b/source/internal/_assoc.js new file mode 100644 index 0000000000..47aa546e15 --- /dev/null +++ b/source/internal/_assoc.js @@ -0,0 +1,29 @@ +import _isArray from './_isArray'; +import _isInteger from './_isInteger'; + +/** + * Makes a shallow clone of an object, setting or overriding the specified + * property with the given value. Note that this copies and flattens prototype + * properties onto the new object as well. All non-primitive properties are + * copied by reference. + * + * @private + * @param {String|Number} prop The property name to set + * @param {*} val The new value + * @param {Object|Array} obj The object to clone + * @return {Object|Array} A new object equivalent to the original except for the changed property. + */ +export default function _assoc(prop, val, obj) { + if (_isInteger(prop) && _isArray(obj)) { + var arr = [].concat(obj); + arr[prop] = val; + return arr; + } + + var result = {}; + for (var p in obj) { + result[p] = obj[p]; + } + result[prop] = val; + return result; +} diff --git a/source/internal/_dissoc.js b/source/internal/_dissoc.js new file mode 100644 index 0000000000..21b135a189 --- /dev/null +++ b/source/internal/_dissoc.js @@ -0,0 +1,28 @@ +import _isInteger from './_isInteger'; +import _isArray from './_isArray'; +import remove from '../remove'; + +/** + * Returns a new object that does not contain a `prop` property. + * + * @private + * @param {String|Number} prop The name of the property to dissociate + * @param {Object|Array} obj The object to clone + * @return {Object} A new object equivalent to the original but without the specified property + */ +export default function _dissoc(prop, obj) { + if (obj == null) { + return obj; + } + + if (_isInteger(prop) && _isArray(obj)) { + return remove(prop, 1, obj); + } + + var result = {}; + for (var p in obj) { + result[p] = obj[p]; + } + delete result[prop]; + return result; +} diff --git a/test/assoc.js b/test/assoc.js index 827e130c90..51e3ea1ec7 100644 --- a/test/assoc.js +++ b/test/assoc.js @@ -25,4 +25,28 @@ describe('assoc', function() { assert.strictEqual(obj2.f, obj1.f); }); + it('makes a shallow clone of an array, overriding only the specified index', function() { + var newValue = [4, 2]; + var ary1 = [1, [2, 3], 4, 5]; + var ary2 = R.assoc(2, newValue, ary1); + eq(ary2, [1, [2, 3], [4, 2], 5]); + // Note: reference equality below! + assert.strictEqual(ary2[0], ary1[0]); + assert.strictEqual(ary2[1], ary1[1]); + assert.strictEqual(ary2[2], newValue); + assert.strictEqual(ary2[3], ary1[3]); + }); + + it('is the equivalent of clone and set if the index is not on the original', function() { + var newValue = [4, 2]; + var ary1 = [1, [2, 3], 4]; + var ary2 = R.assoc(5, newValue, ary1); + eq(ary2, [1, [2, 3], 4, undefined, undefined, [4, 2]]); + // Note: reference equality below! + assert.strictEqual(ary2[0], ary1[0]); + assert.strictEqual(ary2[1], ary1[1]); + assert.strictEqual(ary2[2], ary1[2]); + assert.strictEqual(ary2[5], newValue); + }); + }); diff --git a/test/dissoc.js b/test/dissoc.js index 01a9e36a90..2a7f7d7a63 100644 --- a/test/dissoc.js +++ b/test/dissoc.js @@ -1,11 +1,41 @@ var R = require('../source'); var eq = require('./shared/eq'); +var assert = require('assert'); describe('dissoc', function() { it('copies an object omitting the specified property', function() { eq(R.dissoc('b', {a: 1, b: 2, c: 3}), {a: 1, c: 3}); eq(R.dissoc('d', {a: 1, b: 2, c: 3}), {a: 1, b: 2, c: 3}); + eq(R.dissoc('c', {a: 1, b: 2, c: null}), {a: 1, b: 2}); + eq(R.dissoc('c', {a: 1, b: 2, c: undefined}), {a: 1, b: 2}); + + var obj1 = {a: 1, b: 2}; + var obj2 = R.dissoc('c', obj1); + + eq(obj2, obj1); + + // Note: reference equality below! + assert.notStrictEqual(obj2, obj1); + }); + + it('makes a shallow clone of an array, remove only the specified index', function() { + var ary1 = [1, [2, 3], 4, 5]; + var ary2 = R.dissoc(2, ary1); + var ary3 = R.dissoc(4, ary1); + + eq(ary2, [1, [2, 3], 5]); + eq(ary3, [1, [2, 3], 4, 5]); + + // Note: reference equality below! + assert.strictEqual(ary2[0], ary1[0]); + assert.strictEqual(ary2[1], ary1[1]); + assert.strictEqual(ary2[2], ary1[3]); + assert.notStrictEqual(ary3, ary1); + assert.strictEqual(ary3[0], ary1[0]); + assert.strictEqual(ary3[1], ary1[1]); + assert.strictEqual(ary3[2], ary1[2]); + assert.strictEqual(ary3[3], ary1[3]); }); it('includes prototype properties', function() { diff --git a/test/dissocPath.js b/test/dissocPath.js index 0006c8a0e3..31c74dfb9f 100644 --- a/test/dissocPath.js +++ b/test/dissocPath.js @@ -64,4 +64,17 @@ describe('dissocPath', function() { eq(R.dissocPath([42], {a: 1, b: 2, 42: 3}), {a: 1, b: 2}); }); + it('support remove null/undefined value path', function() { + eq(R.dissocPath(['c', 'd'], {a: 1, b: 2, c: null}), {a: 1, b: 2, c: null}); + eq(R.dissocPath(['c', 'd'], {a: 1, b: 2, c: undefined}), {a: 1, b: 2, c: undefined}); + + var obj1 = {a: 1, b: 2}; + var obj2 = R.dissocPath(['c', 'd'], obj1); + + eq(obj2, obj1); + + // Note: reference equality below! + assert.notStrictEqual(obj2, obj1); + }); + }); From f24695765f0fd27e97392fc08d7e6353cd07210b Mon Sep 17 00:00:00 2001 From: Ben Bryant Date: Mon, 29 Jun 2020 02:31:49 +0200 Subject: [PATCH 044/111] Copy arguments only when necessary --- source/internal/_dispatchable.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/source/internal/_dispatchable.js b/source/internal/_dispatchable.js index d3a55e1c01..3ece37f5a5 100644 --- a/source/internal/_dispatchable.js +++ b/source/internal/_dispatchable.js @@ -21,18 +21,17 @@ export default function _dispatchable(methodNames, xf, fn) { if (arguments.length === 0) { return fn(); } - var args = Array.prototype.slice.call(arguments, 0); - var obj = args.pop(); + var obj = arguments[arguments.length - 1]; if (!_isArray(obj)) { var idx = 0; while (idx < methodNames.length) { if (typeof obj[methodNames[idx]] === 'function') { - return obj[methodNames[idx]].apply(obj, args); + return obj[methodNames[idx]].apply(obj, Array.prototype.slice.call(arguments, 0, -1)); } idx += 1; } if (_isTransformer(obj)) { - var transducer = xf.apply(null, args); + var transducer = xf.apply(null, Array.prototype.slice.call(arguments, 0, -1)); return transducer(obj); } } From 290b8e7f3e52212cf4fd9cbbee568e948c945d81 Mon Sep 17 00:00:00 2001 From: Sebastien Filion Date: Tue, 30 Jun 2020 19:51:35 -0400 Subject: [PATCH 045/111] Add extension to dissoc and assoc --- source/internal/_assoc.js | 4 ++-- source/internal/_dissoc.js | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/source/internal/_assoc.js b/source/internal/_assoc.js index 47aa546e15..a20d39e058 100644 --- a/source/internal/_assoc.js +++ b/source/internal/_assoc.js @@ -1,5 +1,5 @@ -import _isArray from './_isArray'; -import _isInteger from './_isInteger'; +import _isArray from './_isArray.js'; +import _isInteger from './_isInteger.js'; /** * Makes a shallow clone of an object, setting or overriding the specified diff --git a/source/internal/_dissoc.js b/source/internal/_dissoc.js index 21b135a189..e4cf50f1d9 100644 --- a/source/internal/_dissoc.js +++ b/source/internal/_dissoc.js @@ -1,6 +1,6 @@ -import _isInteger from './_isInteger'; -import _isArray from './_isArray'; -import remove from '../remove'; +import _isInteger from './_isInteger.js'; +import _isArray from './_isArray.js'; +import remove from '../remove.js'; /** * Returns a new object that does not contain a `prop` property. From 8919f26243950cd383901b69f357ea099cb0194b Mon Sep 17 00:00:00 2001 From: Sebastien Filion Date: Wed, 1 Jul 2020 14:41:23 -0400 Subject: [PATCH 046/111] Update documentation for Deno import (#3053) --- README.md | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/README.md b/README.md index 1ffd653a88..c02fd879ee 100644 --- a/README.md +++ b/README.md @@ -92,6 +92,11 @@ Then in the console: const R = require('ramda'); ``` +To use directly in [Deno](https://deno.land): +```javascript +import * as R from "https://deno.land/x/ramda/index.js"; +``` + To use directly in the browser: ```html From 129a0df039c7b613b33eee52b5d1c8c4c6b7dd35 Mon Sep 17 00:00:00 2001 From: Ben Bryant Date: Mon, 29 Jun 2020 23:02:55 +0200 Subject: [PATCH 047/111] Update rollup & plugins --- package-lock.json | 154 ++++++++++++++++++++-------------------------- package.json | 6 +- rollup.config.js | 9 ++- 3 files changed, 77 insertions(+), 92 deletions(-) diff --git a/package-lock.json b/package-lock.json index 61faac5ef7..07fa2b50c6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -3104,6 +3104,27 @@ "integrity": "sha512-tsAQNx32a8CoFhjhijUIhI4kccIAgmGhy8LZMZgGfmXcpMbPRUqn5LWmgRttILi6yeGmBJd2xsPkFMs0PzgPCw==", "dev": true }, + "@rollup/plugin-babel": { + "version": "5.0.4", + "resolved": "https://registry.npmjs.org/@rollup/plugin-babel/-/plugin-babel-5.0.4.tgz", + "integrity": "sha512-MBtNoi5gqBEbqy1gE9jZBfPsi10kbuK2CEu9bx53nk1Z3ATRvBOoZ/GsbhXOeVbS76xXi/DeYM+vYX6EGIDv9A==", + "dev": true, + "requires": { + "@babel/helper-module-imports": "^7.7.4", + "@rollup/pluginutils": "^3.0.8" + } + }, + "@rollup/pluginutils": { + "version": "3.1.0", + "resolved": "https://registry.npmjs.org/@rollup/pluginutils/-/pluginutils-3.1.0.tgz", + "integrity": "sha512-GksZ6pr6TpIjHm8h9lSQ8pi8BE9VeubNT0OMJ3B5uZJ8pz73NPiqOtCog/x2/QzM1ENChPKxMDhiQuRHsqc+lg==", + "dev": true, + "requires": { + "@types/estree": "0.0.39", + "estree-walker": "^1.0.1", + "picomatch": "^2.2.2" + } + }, "@sinonjs/commons": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/@sinonjs/commons/-/commons-1.4.0.tgz", @@ -3167,9 +3188,9 @@ "dev": true }, "@types/node": { - "version": "12.0.2", - "resolved": "https://registry.npmjs.org/@types/node/-/node-12.0.2.tgz", - "integrity": "sha512-5tabW/i+9mhrfEOUcLDu2xBPsHJ+X5Orqy9FKpale3SjDA17j5AEpYq5vfy3oAeAHGcvANRCO3NV3d2D6q3NiA==", + "version": "14.0.14", + "resolved": "https://registry.npmjs.org/@types/node/-/node-14.0.14.tgz", + "integrity": "sha512-syUgf67ZQpaJj01/tRTknkMNoBBLWJOBODF0Zm4NrXmiSuxjymFrxnTu1QVYRubhVkRcZLYZG8STTwJRdVm/WQ==", "dev": true }, "Base64": { @@ -5410,9 +5431,9 @@ } }, "estree-walker": { - "version": "0.6.1", - "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-0.6.1.tgz", - "integrity": "sha512-SqmZANLWS0mnatqbSfRP5g8OXZC12Fgg1IwNtLsyHDzJizORW4khDfjPqJZsemPWBB2uqykUah5YpQ6epsqC/w==", + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/estree-walker/-/estree-walker-1.0.1.tgz", + "integrity": "sha512-1fMXF3YP4pZZVozF8j/ZLfvnR8NSIljt56UhbZ5PeeDmmGHpgpdwQt7ITlGvYaQukCvuBRMLEiKiYC+oeIg4cg==", "dev": true }, "esutils": { @@ -6012,6 +6033,12 @@ "integrity": "sha1-XkdHk/fqmEPRu5nCPu9J/xJv/zk=", "dev": true }, + "has-flag": { + "version": "3.0.0", + "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", + "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", + "dev": true + }, "has-symbols": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.0.tgz", @@ -7088,21 +7115,15 @@ } }, "jest-worker": { - "version": "24.6.0", - "resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-24.6.0.tgz", - "integrity": "sha512-jDwgW5W9qGNvpI1tNnvajh0a5IE/PuGLFmHk6aR/BZFz8tSgGw17GsDPXAJ6p91IvYDjOw8GpFbvvZGAK+DPQQ==", + "version": "24.9.0", + "resolved": "https://registry.npmjs.org/jest-worker/-/jest-worker-24.9.0.tgz", + "integrity": "sha512-51PE4haMSXcHohnSMdM42anbvZANYTqMrr52tVKPqqsPJMzoP6FYYDVqahX/HrAoKEKz3uUPzSvKs9A3qR4iVw==", "dev": true, "requires": { - "merge-stream": "^1.0.1", + "merge-stream": "^2.0.0", "supports-color": "^6.1.0" }, "dependencies": { - "has-flag": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/has-flag/-/has-flag-3.0.0.tgz", - "integrity": "sha1-tdRU3CGZriJWmfNGfloH87lVuv0=", - "dev": true - }, "supports-color": { "version": "6.1.0", "resolved": "https://registry.npmjs.org/supports-color/-/supports-color-6.1.0.tgz", @@ -7542,45 +7563,10 @@ "dev": true }, "merge-stream": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-1.0.1.tgz", - "integrity": "sha1-QEEgLVCKNCugAXQAjfDCUbjBNeE=", - "dev": true, - "requires": { - "readable-stream": "^2.0.1" - }, - "dependencies": { - "isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", - "dev": true - }, - "readable-stream": { - "version": "2.3.6", - "resolved": "http://registry.npmjs.org/readable-stream/-/readable-stream-2.3.6.tgz", - "integrity": "sha512-tQtKA9WIAhBF3+VLAseyMqZeBjW0AHJoxOtYqSUZNJxauErmLbVm2FW1y+J/YA9dUrAC39ITejlZWhVIwawkKw==", - "dev": true, - "requires": { - "core-util-is": "~1.0.0", - "inherits": "~2.0.3", - "isarray": "~1.0.0", - "process-nextick-args": "~2.0.0", - "safe-buffer": "~5.1.1", - "string_decoder": "~1.1.1", - "util-deprecate": "~1.0.1" - } - }, - "string_decoder": { - "version": "1.1.1", - "resolved": "http://registry.npmjs.org/string_decoder/-/string_decoder-1.1.1.tgz", - "integrity": "sha512-n/ShnvDi6FHbbVfviro+WojiFzv+s8MPMHBczVePfUpDJLwoLT0ht1l4YwBCbi8pJAveEEdnkHyPyTP/mzRfwg==", - "dev": true, - "requires": { - "safe-buffer": "~5.1.0" - } - } - } + "version": "2.0.0", + "resolved": "https://registry.npmjs.org/merge-stream/-/merge-stream-2.0.0.tgz", + "integrity": "sha512-abv/qOcuPfk3URPfDzmZU1LKmuw8kT+0nIHvKrKgFrwifol/doWcdA4ZqsWQ8ENrFKkd67Mfpo/LovbIUsbt3w==", + "dev": true }, "methods": { "version": "1.1.2", @@ -8773,6 +8759,12 @@ "sha.js": "^2.4.8" } }, + "picomatch": { + "version": "2.2.2", + "resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.2.2.tgz", + "integrity": "sha512-q0M/9eZHzmr0AulXyPwNfZjtwZ/RBZlbN3K3CErVrk50T2ASYI7Bye0EvekFY3IP1Nt2DHu0re+V2ZHIpMkuWg==", + "dev": true + }, "pify": { "version": "4.0.1", "resolved": "https://registry.npmjs.org/pify/-/pify-4.0.1.tgz", @@ -9246,46 +9238,36 @@ } }, "rollup": { - "version": "0.68.2", - "resolved": "https://registry.npmjs.org/rollup/-/rollup-0.68.2.tgz", - "integrity": "sha512-WgjNCXYv7ZbtStIap1+tz4pd2zwz0XYN//OILwEY6dINIFLVizK1iWdu+ZtUURL/OKnp8Lv2w8FBds8YihzX7Q==", - "dev": true, - "requires": { - "@types/estree": "0.0.39", - "@types/node": "*" - } - }, - "rollup-plugin-babel": { - "version": "4.3.3", - "resolved": "https://registry.npmjs.org/rollup-plugin-babel/-/rollup-plugin-babel-4.3.3.tgz", - "integrity": "sha512-tKzWOCmIJD/6aKNz0H1GMM+lW1q9KyFubbWzGiOG540zxPPifnEAHTZwjo0g991Y+DyOZcLqBgqOdqazYE5fkw==", + "version": "1.32.1", + "resolved": "https://registry.npmjs.org/rollup/-/rollup-1.32.1.tgz", + "integrity": "sha512-/2HA0Ec70TvQnXdzynFffkjA6XN+1e2pEv/uKS5Ulca40g2L7KuOE3riasHoNVHOsFD5KKZgDsMk1CP3Tw9s+A==", "dev": true, "requires": { - "@babel/helper-module-imports": "^7.0.0", - "rollup-pluginutils": "^2.8.1" + "@types/estree": "*", + "@types/node": "*", + "acorn": "^7.1.0" + }, + "dependencies": { + "acorn": { + "version": "7.3.1", + "resolved": "https://registry.npmjs.org/acorn/-/acorn-7.3.1.tgz", + "integrity": "sha512-tLc0wSnatxAQHVHUapaHdz72pi9KUyHjq5KyHjGg9Y8Ifdc79pTh2XvI6I1/chZbnM7QtNKzh66ooDogPZSleA==", + "dev": true + } } }, "rollup-plugin-uglify": { - "version": "6.0.2", - "resolved": "https://registry.npmjs.org/rollup-plugin-uglify/-/rollup-plugin-uglify-6.0.2.tgz", - "integrity": "sha512-qwz2Tryspn5QGtPUowq5oumKSxANKdrnfz7C0jm4lKxvRDsNe/hSGsB9FntUul7UeC4TsZEWKErVgE1qWSO0gw==", + "version": "6.0.4", + "resolved": "https://registry.npmjs.org/rollup-plugin-uglify/-/rollup-plugin-uglify-6.0.4.tgz", + "integrity": "sha512-ddgqkH02klveu34TF0JqygPwZnsbhHVI6t8+hGTcYHngPkQb5MIHI0XiztXIN/d6V9j+efwHAqEL7LspSxQXGw==", "dev": true, "requires": { "@babel/code-frame": "^7.0.0", "jest-worker": "^24.0.0", - "serialize-javascript": "^1.6.1", + "serialize-javascript": "^2.1.2", "uglify-js": "^3.4.9" } }, - "rollup-pluginutils": { - "version": "2.8.2", - "resolved": "https://registry.npmjs.org/rollup-pluginutils/-/rollup-pluginutils-2.8.2.tgz", - "integrity": "sha512-EEp9NhnUkwY8aif6bxgovPHMoMoNr2FulJziTndpt5H9RdwC47GSGuII9XxpSdzVGM0GWrNPHV6ie1LTNJPaLQ==", - "dev": true, - "requires": { - "estree-walker": "^0.6.1" - } - }, "run-async": { "version": "2.3.0", "resolved": "https://registry.npmjs.org/run-async/-/run-async-2.3.0.tgz", @@ -9379,9 +9361,9 @@ } }, "serialize-javascript": { - "version": "1.7.0", - "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-1.7.0.tgz", - "integrity": "sha512-ke8UG8ulpFOxO8f8gRYabHQe/ZntKlcig2Mp+8+URDP1D8vJZ0KUt7LYo07q25Z/+JVSgpr/cui9PIp5H6/+nA==", + "version": "2.1.2", + "resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-2.1.2.tgz", + "integrity": "sha512-rs9OggEUF0V4jUSecXazOYsLfu7OGK2qIn3c7IPBiffz32XniEp/TX9Xmc9LQfK2nQ2QKHvZ2oygKUGU0lG4jQ==", "dev": true }, "serve-static": { diff --git a/package.json b/package.json index 6ae2e18def..211d2b3ebf 100644 --- a/package.json +++ b/package.json @@ -88,6 +88,7 @@ "@babel/preset-env": "^7.7.4", "@babel/register": "^7.4.4", "@babel/types": "^7.4.4", + "@rollup/plugin-babel": "^5.0.4", "babel-plugin-annotate-pure-calls": "^0.4.0", "babel-plugin-import-export-rename": "^1.0.1", "babelify": "^10.0.0", @@ -105,9 +106,8 @@ "mocha": "^6.1.4", "nyc": "^15.0.1", "rimraf": "^2.6.3", - "rollup": "^0.68.2", - "rollup-plugin-babel": "^4.3.3", - "rollup-plugin-uglify": "^6.0.2", + "rollup": "^1.32.1", + "rollup-plugin-uglify": "^6.0.4", "sanctuary": "0.7.x", "sinon": "^7.3.2", "testem": "^2.16.0", diff --git a/rollup.config.js b/rollup.config.js index a28671d75f..0dc48b2ff7 100644 --- a/rollup.config.js +++ b/rollup.config.js @@ -1,8 +1,8 @@ 'use strict'; -var babel = require('rollup-plugin-babel'); +var { babel } = require('@rollup/plugin-babel'); // uglify handles only es5 code, so this also acts as smoke test against shipping es2015+ syntax -var uglify = require('rollup-plugin-uglify').uglify; +var { uglify } = require('rollup-plugin-uglify'); var pkg = require('./package.json'); var banner = '// Ramda v' + pkg.version + '\n' @@ -21,7 +21,10 @@ var config = { banner: banner }, plugins: [ - babel({ presets: [['@babel/preset-env', { targets: { ie: '11' } }]]}) + babel({ + babelHelpers: 'bundled', + presets: [['@babel/preset-env', { targets: { ie: '11' } }]] + }) ] }; From 1e0e5006129f0369700308135f9f0a28fae617ed Mon Sep 17 00:00:00 2001 From: Henry Ivry Date: Wed, 22 Jul 2020 09:56:21 -0400 Subject: [PATCH 048/111] feat: add partialObject (#3047) * feat: add curryN with named param support * fix: fix linting issues * fix: switch arg signature and logic * fix: switch destructure to Object assign * fix: adjust tests, use hasPaths instead of falsey * fix: remove trailing space * fix: adjust tests to work with hasPath * fix: cleanup/add property tests, wrap in curry2, drop placeholders * remove unused import * switch to partialObject and add tests * clean up test * restore package-lock from develop * fix typo Co-authored-by: Gitea --- source/index.js | 1 + source/partialObject.js | 32 ++++++++++++++++++++++++++++++++ test/partialObject.js | 35 +++++++++++++++++++++++++++++++++++ 3 files changed, 68 insertions(+) create mode 100644 source/partialObject.js create mode 100644 test/partialObject.js diff --git a/source/index.js b/source/index.js index 8538cfafa8..70df3e5b80 100644 --- a/source/index.js +++ b/source/index.js @@ -139,6 +139,7 @@ export { default as modulo } from './modulo.js'; export { default as move } from './move.js'; export { default as multiply } from './multiply.js'; export { default as nAry } from './nAry.js'; +export { default as partialObject } from './partialObject.js'; export { default as negate } from './negate.js'; export { default as none } from './none.js'; export { default as not } from './not.js'; diff --git a/source/partialObject.js b/source/partialObject.js new file mode 100644 index 0000000000..2418966f67 --- /dev/null +++ b/source/partialObject.js @@ -0,0 +1,32 @@ +import mergeDeepRight from './mergeDeepRight'; +import _curry2 from './internal/_curry2'; + +/** + * Takes a function `f` and an object, and returns a function `g`. + * When applied, `g` returns the result of applying `f` to the object + * provided initially merged deeply (right) with the object provided as an argument to `g`. + * + * @func + * @memberOf R + * @category Function + * @sig (({ a, b, c, ..., n }) -> x) -> { a, b, c, ...} -> ({ d, e, f, ..., n } -> x) + * @param {Function} f + * @param {Object} props + * @return {Function} + * @see R.partial, R.partialRight, R.curry, R.mergeDeepRight + * @example + * + * const multiply2 = ({ a, b }) => a * b; + * const double = R.partialObject(multiply2, { a: 2 }); + * double({ b: 2 }); //=> 4 + * + * const greet = ({ salutation, title, firstName, lastName }) => + * salutation + ', ' + title + ' ' + firstName + ' ' + lastName + '!'; + * + * const sayHello = R.partialObject(greet, { salutation: 'Hello' }); + * const sayHelloToMs = R.partialObject(sayHello, { title: 'Ms.' }); + * sayHelloToMs({ firstName: 'Jane', lastName: 'Jones' }); //=> 'Hello, Ms. Jane Jones!' + * @symb R.partialObject(f, { a, b })({ c, d }) = f({ a, b, c, d }) + */ + +export default _curry2((f, o) => (props) => f.call(this, mergeDeepRight(o, props))); diff --git a/test/partialObject.js b/test/partialObject.js new file mode 100644 index 0000000000..95d29a5267 --- /dev/null +++ b/test/partialObject.js @@ -0,0 +1,35 @@ +var R = require('../source'); +var eq = require('./shared/eq'); + +describe('partialObject', function() { + var discriminant = function({ a, b, c }) { + return b * b - 4 * a * c; + }; + + it('caches the initially supplied arguments', function() { + var f = R.partialObject(discriminant, { a: 3 }); + eq(f({ b: 7, c: 4 }), 1); + + var g = R.partialObject(discriminant, { a: 3, b: 7 }); + eq(g({ c: 4 }), 1); + }); + + it('works regardless of property order', function() { + var f = R.partialObject(discriminant, { b: 7 }); + eq(f({ c: 4, a: 3 }), 1); + + var g = R.partialObject(discriminant, { a: 3 }); + var h = R.partialObject(g, { c: 4 }); + eq(h({ b: 7 }), 1); + }); + + it('merges deeply right', function() { + var nestedDiscriminant = function ({ a, c, d}) { + return d.b * d.b - 4 * a * c; + }; + + var f = R.partialObject(nestedDiscriminant, { a: 0, d: { b: 0 } }); + var g = R.partialObject(f, { a: 3, d: { b: 7 } }); + eq(g({ c: 4 }), 1); + }); +}); From 6bb8eeaabbe130cc4f9860e9124ae69320636fcd Mon Sep 17 00:00:00 2001 From: David Chambers Date: Thu, 30 Jul 2020 10:43:15 +0200 Subject: [PATCH 049/111] Version 0.27.1 --- BOOKMARKLET.md | 2 +- Makefile | 2 +- dist/ramda.js | 18866 ++++++++++++++++++++++---------------------- dist/ramda.min.js | 2 +- package.json | 2 +- source/andThen.js | 1 + source/move.js | 1 + source/paths.js | 1 + source/xor.js | 1 + 9 files changed, 9515 insertions(+), 9363 deletions(-) diff --git a/BOOKMARKLET.md b/BOOKMARKLET.md index b0295b4a70..856f99329a 100644 --- a/BOOKMARKLET.md +++ b/BOOKMARKLET.md @@ -8,5 +8,5 @@ Use this bookmarklet to load Ramda on any website. To "install": 2. Edit the new bookmark and replace the `URL` with the following: ```javascript - javascript:!function(t,n){function r(r){var e=n.createElement("div"),u=n.body;e.innerHTML=r,e.style.position="fixed",e.style.top="20px",e.style.right="20px",e.style.padding="5px 10px",e.style.zIndex="1001",e.style.fontSize="18px",e.style.color="#222",e.style.backgroundColor="#DFF2BF",e.style.textAlign="center",e.style.border="solid 2px black",e.style.borderRadius="25px",u.appendChild(e),t.setTimeout(u.removeChild.bind(u,e),2500)}var e="???";return"undefined"!=typeof t.R?r("This page already using ramda"):(function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(t.R={})}(this,function(t){"use strict";function n(t){return null!=t&&"object"==typeof t&&t["@@functional/placeholder"]===!0}function r(t){return function r(e){return 0===arguments.length||n(e)?r:t.apply(this,arguments)}}function e(t){return function e(u,i){switch(arguments.length){case 0:return e;case 1:return n(u)?e:r(function(n){return t(u,n)});default:return n(u)&&n(i)?e:n(u)?r(function(n){return t(n,i)}):n(i)?r(function(n){return t(u,n)}):t(u,i)}}}function u(t,n){t=t||[],n=n||[];var r,e=t.length,u=n.length,i=[];for(r=0;e>r;)i[i.length]=t[r],r+=1;for(r=0;u>r;)i[i.length]=n[r],r+=1;return i}function i(t,n){switch(t){case 0:return function(){return n.apply(this,arguments)};case 1:return function(){return n.apply(this,arguments)};case 2:return function(){return n.apply(this,arguments)};case 3:return function(){return n.apply(this,arguments)};case 4:return function(){return n.apply(this,arguments)};case 5:return function(){return n.apply(this,arguments)};case 6:return function(){return n.apply(this,arguments)};case 7:return function(){return n.apply(this,arguments)};case 8:return function(){return n.apply(this,arguments)};case 9:return function(){return n.apply(this,arguments)};case 10:return function(){return n.apply(this,arguments)};default:throw new Error("First argument to _arity must be a non-negative integer no greater than ten")}}function o(t,r,e){return function(){for(var u=[],c=0,a=t,s=0;s=arguments.length)?f=r[s]:(f=arguments[c],c+=1),u[s]=f,n(f)||(a-=1),s+=1}return 0>=a?e.apply(this,u):i(a,o(t,u,e))}}function c(t){return function u(i,o,c){switch(arguments.length){case 0:return u;case 1:return n(i)?u:e(function(n,r){return t(i,n,r)});case 2:return n(i)&&n(o)?u:n(i)?e(function(n,r){return t(n,o,r)}):n(o)?e(function(n,r){return t(i,n,r)}):r(function(n){return t(i,o,n)});default:return n(i)&&n(o)&&n(c)?u:n(i)&&n(o)?e(function(n,r){return t(n,r,c)}):n(i)&&n(c)?e(function(n,r){return t(n,o,r)}):n(o)&&n(c)?e(function(n,r){return t(i,n,r)}):n(i)?r(function(n){return t(n,o,c)}):n(o)?r(function(n){return t(i,n,c)}):n(c)?r(function(n){return t(i,o,n)}):t(i,o,c)}}}function a(t){return"function"==typeof t["@@transducer/step"]}function s(t,n,r){return function(){if(0===arguments.length)return r();var e=Array.prototype.slice.call(arguments,0),u=e.pop();if(!Wn(u)){for(var i=0;ir;)u[r]=t(n[r]),r+=1;return u}function h(t){return"[object String]"===Object.prototype.toString.call(t)}function y(t){this.f=t}function g(t){return new y(t)}function d(t,n,r){for(var e=0,u=r.length;u>e;){if(n=t["@@transducer/step"](n,r[e]),n&&n["@@transducer/reduced"]){n=n["@@transducer/value"];break}e+=1}return t["@@transducer/result"](n)}function m(t,n,r){for(var e=r.next();!e.done;){if(n=t["@@transducer/step"](n,e.value),n&&n["@@transducer/reduced"]){n=n["@@transducer/value"];break}e=r.next()}return t["@@transducer/result"](n)}function v(t,n,r,e){return t["@@transducer/result"](r[e](Rn(t["@@transducer/step"],t),n))}function w(t,n,r){if("function"==typeof t&&(t=g(t)),Fn(r))return d(t,n,r);if("function"==typeof r["fantasy-land/reduce"])return v(t,n,r,"fantasy-land/reduce");if(null!=r[Bn])return m(t,n,r[Bn]());if("function"==typeof r.next)return m(t,n,r);if("function"==typeof r.reduce)return v(t,n,r,"reduce");throw new TypeError("reduce: list must be array or iterable")}function b(t,n){this.xf=n,this.f=t}function x(t,n){return Object.prototype.hasOwnProperty.call(n,t)}function j(t,n){this.xf=n,this.f=t,this.any=!1}function A(t,n){for(var r=0,e=n.length-(t-1),u=new Array(e>=0?e:0);e>r;)u[r]=Array.prototype.slice.call(n,r,r+t),r+=1;return u}function O(t,n){this.xf=n,this.pos=0,this.full=!1,this.acc=new Array(t)}function S(t){return"[object Function]"===Object.prototype.toString.call(t)}function E(t){return function n(r){for(var e,u,i,o=[],c=0,a=r.length;a>c;){if(Fn(r[c]))for(e=t?n(r[c]):r[c],i=0,u=e.length;u>i;)o[o.length]=e[i],i+=1;else o[o.length]=r[c];c+=1}return o}}function _(t){return{"@@transducer/value":t,"@@transducer/reduced":!0}}function q(t){return new RegExp(t.source,(t.global?"g":"")+(t.ignoreCase?"i":"")+(t.multiline?"m":"")+(t.sticky?"y":"")+(t.unicode?"u":""))}function k(t,n,r,e){var u=function(u){for(var i=n.length,o=0;i>o;){if(t===n[o])return r[o];o+=1}n[o+1]=t,r[o+1]=u;for(var c in t)u[c]=e?k(t[c],n,r,!0):t[c];return u};switch(kr(t)){case"Object":return u({});case"Array":return u([]);case"Date":return new Date(t.valueOf());case"RegExp":return q(t);default:return t}}function I(t,n){return function(){return n.call(this,t.apply(this,arguments))}}function W(t,n){return function(){var r=arguments.length;if(0===r)return n();var e=arguments[r-1];return Wn(e)||"function"!=typeof e[t]?n.apply(this,arguments):e[t].apply(e,Array.prototype.slice.call(arguments,0,r-1))}}function C(){if(0===arguments.length)throw new Error("pipe requires at least one argument");return i(arguments[0].length,Gn(I,arguments[0],Pr(arguments)))}function T(){if(0===arguments.length)throw new Error("compose requires at least one argument");return C.apply(this,Fr(arguments))}function N(){if(0===arguments.length)throw new Error("composeK requires at least one argument");var t=Array.prototype.slice.call(arguments),n=t.pop();return T(T.apply(this,Jn(_r,t)),n)}function P(t,n){return function(){var r=this;return t.apply(r,arguments).then(function(t){return n.call(r,t)})}}function F(){if(0===arguments.length)throw new Error("pipeP requires at least one argument");return i(arguments[0].length,Gn(P,arguments[0],Pr(arguments)))}function R(){if(0===arguments.length)throw new Error("composeP requires at least one argument");return F.apply(this,Fr(arguments))}function B(t){for(var n,r=[];!(n=t.next()).done;)r.push(n.value);return r}function z(t,n,r){for(var e=0,u=r.length;u>e;){if(t(n,r[e]))return!0;e+=1}return!1}function D(t){var n=String(t).match(/^function (\w*)/);return null==n?"":n[1]}function U(t,n,r,e){function u(t,n){return M(t,n,r.slice(),e.slice())}var i=B(t),o=B(n);return!z(function(t,n){return!z(u,n,t)},o,i)}function M(t,n,r,e){if(Rr(t,n))return!0;var u=kr(t);if(u!==kr(n))return!1;if(null==t||null==n)return!1;if("function"==typeof t["fantasy-land/equals"]||"function"==typeof n["fantasy-land/equals"])return"function"==typeof t["fantasy-land/equals"]&&t["fantasy-land/equals"](n)&&"function"==typeof n["fantasy-land/equals"]&&n["fantasy-land/equals"](t);if("function"==typeof t.equals||"function"==typeof n.equals)return"function"==typeof t.equals&&t.equals(n)&&"function"==typeof n.equals&&n.equals(t);switch(u){case"Arguments":case"Array":case"Object":if("function"==typeof t.constructor&&"Promise"===D(t.constructor))return t===n;break;case"Boolean":case"Number":case"String":if(typeof t!=typeof n||!Rr(t.valueOf(),n.valueOf()))return!1;break;case"Date":if(!Rr(t.valueOf(),n.valueOf()))return!1;break;case"Error":return t.name===n.name&&t.message===n.message;case"RegExp":if(t.source!==n.source||t.global!==n.global||t.ignoreCase!==n.ignoreCase||t.multiline!==n.multiline||t.sticky!==n.sticky||t.unicode!==n.unicode)return!1}for(var i=r.length-1;i>=0;){if(r[i]===t)return e[i]===n;i-=1}switch(u){case"Map":return t.size!==n.size?!1:U(t.entries(),n.entries(),r.concat([t]),e.concat([n]));case"Set":return t.size!==n.size?!1:U(t.values(),n.values(),r.concat([t]),e.concat([n]));case"Arguments":case"Array":case"Object":case"Boolean":case"Number":case"String":case"Date":case"Error":case"RegExp":case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"ArrayBuffer":break;default:return!1}var o=$n(t);if(o.length!==$n(n).length)return!1;var c=r.concat([t]),a=e.concat([n]);for(i=o.length-1;i>=0;){var s=o[i];if(!x(s,n)||!M(n[s],t[s],c,a))return!1;i-=1}return!0}function L(t,n,r){var e,u;if("function"==typeof t.indexOf)switch(typeof n){case"number":if(0===n){for(e=1/n;r=0}function V(t){var n=t.replace(/\\/g,"\\\\").replace(/[\b]/g,"\\b").replace(/\f/g,"\\f").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t").replace(/\v/g,"\\v").replace(/\0/g,"\\0");return'"'+n.replace(/"/g,'\\"')+'"'}function H(t){return function(){return!t.apply(this,arguments)}}function $(t,n){for(var r=0,e=n.length,u=[];e>r;)t(n[r])&&(u[u.length]=n[r]),r+=1;return u}function J(t){return"[object Object]"===Object.prototype.toString.call(t)}function X(t,n){this.xf=n,this.f=t}function Y(t,n){var r=function(r){var e=n.concat([t]);return K(r,e)?"":Y(r,e)},e=function(t,n){return p(function(n){return V(n)+": "+r(t[n])},n.slice().sort())};switch(Object.prototype.toString.call(t)){case"[object Arguments]":return"(function() { return arguments; }("+p(r,t).join(", ")+"))";case"[object Array]":return"["+p(r,t).concat(e(t,Lr(function(t){return/^\d+$/.test(t)},$n(t)))).join(", ")+"]";case"[object Boolean]":return"object"==typeof t?"new Boolean("+r(t.valueOf())+")":t.toString();case"[object Date]":return"new Date("+(isNaN(t.valueOf())?r(0/0):V(Dr(t)))+")";case"[object Null]":return"null";case"[object Number]":return"object"==typeof t?"new Number("+r(t.valueOf())+")":1/t===-1/0?"-0":t.toString(10);case"[object String]":return"object"==typeof t?"new String("+r(t.valueOf())+")":V(t);case"[object Undefined]":return"undefined";default:if("function"==typeof t.toString){var u=t.toString();if("[object Object]"!==u)return u}return"{"+e(t,$n(t)).join(", ")+"}"}}function Z(t,n,r,e){this.valueFn=t,this.valueAcc=n,this.keyFn=r,this.xf=e,this.inputs={}}function G(t,n){this.xf=n,this.n=t}function Q(t,n){this.xf=n,this.n=t,this.i=0}function tn(t,n){return he(t=0&&t(n[r]);)r-=1;return Nr(0,r+1,n)}function en(t,n){this.f=t,this.retained=[],this.xf=n}function un(t,n){this.xf=n,this.pred=t,this.lastValue=void 0,this.seenFirstValue=!1}function on(t,n){this.xf=n,this.f=t}function cn(t,n){this.xf=n,this.f=t,this.found=!1}function an(t,n){this.xf=n,this.f=t,this.idx=-1,this.found=!1}function sn(t,n){this.xf=n,this.f=t}function fn(t,n){this.xf=n,this.f=t,this.idx=-1,this.lastIdx=-1}function ln(t){return t}function pn(){this._nativeSet="function"==typeof Set?new Set:null,this._items={}}function hn(t,n,r){var e,u,i=typeof t;switch(i){case"string":case"number":return 0===t&&1/t===-1/0?r._items["-0"]?!0:(n&&(r._items["-0"]=!0),!1):null!==r._nativeSet?n?(e=r._nativeSet.size,r._nativeSet.add(t),u=r._nativeSet.size,u===e):r._nativeSet.has(t):i in r._items?t in r._items[i]?!0:(n&&(r._items[i][t]=!0),!1):(n&&(r._items[i]={},r._items[i][t]=!0),!1);case"boolean":if(i in r._items){var o=t?1:0;return r._items[i][o]?!0:(n&&(r._items[i][o]=!0),!1)}return n&&(r._items[i]=t?[!1,!0]:[!0,!1]),!1;case"function":return null!==r._nativeSet?n?(e=r._nativeSet.size,r._nativeSet.add(t),u=r._nativeSet.size,u===e):r._nativeSet.has(t):i in r._items?K(t,r._items[i])?!0:(n&&r._items[i].push(t),!1):(n&&(r._items[i]=[t]),!1);case"undefined":return r._items[i]?!0:(n&&(r._items[i]=!0),!1);case"object":if(null===t)return r._items["null"]?!0:(n&&(r._items["null"]=!0),!1);default:return i=Object.prototype.toString.call(t),i in r._items?K(t,r._items[i])?!0:(n&&r._items[i].push(t),!1):(n&&(r._items[i]=[t]),!1)}}function yn(t){if(null==t)throw new TypeError("Cannot convert undefined or null to object");for(var n=Object(t),r=1,e=arguments.length;e>r;){var u=arguments[r];if(null!=u)for(var i in u)x(i,u)&&(n[i]=u[i]);r+=1}return n}function gn(t){if(a(t))return t;if(Fn(t))return yu;if("string"==typeof t)return gu;if("object"==typeof t)return du;throw new Error("Cannot create transformer for "+t)}function dn(t){return"[object Number]"===Object.prototype.toString.call(t)}function mn(t){return[t]}function vn(t){return e(function(n,r){return i(Math.max(0,n.length-r.length),function(){return n.apply(this,t(r,arguments))})})}function wn(){if(0===arguments.length)throw new Error("pipeK requires at least one argument");return N.apply(this,Fr(arguments))}function bn(t,n){this.xf=n,this.f=t}function xn(t,n){this.xf=n,this.f=t}function jn(t){return"[object RegExp]"===Object.prototype.toString.call(t)}var An=r(function(t){return function(){return t}}),On=An(!1),Sn=An(!0),En={"@@functional/placeholder":!0},_n=e(function(t,n){return Number(t)+Number(n)}),qn=e(function(t,n){return 1===t?r(n):i(t,o(t,[],n))}),kn=r(function(t){return qn(t.length,function(){var n=0,r=arguments[0],e=arguments[arguments.length-1],i=Array.prototype.slice.call(arguments,0);return i[0]=function(){var t=r.apply(this,u(arguments,[n,e]));return n+=1,t},t.apply(this,i)})}),In=c(function(t,n,r){if(n>=r.length||n<-r.length)return r;var e=0>n?r.length:0,i=e+n,o=u(r);return o[i]=t(r[i]),o}),Wn=Array.isArray||function(t){return null!=t&&t.length>=0&&"[object Array]"===Object.prototype.toString.call(t)},Cn={init:function(){return this.xf["@@transducer/init"]()},result:function(t){return this.xf["@@transducer/result"](t)}};l.prototype["@@transducer/init"]=Cn.init,l.prototype["@@transducer/result"]=function(t){return this.all&&(t=this.xf["@@transducer/step"](t,!0)),this.xf["@@transducer/result"](t)},l.prototype["@@transducer/step"]=function(t,n){return this.f(n)||(this.all=!1,t=f(this.xf["@@transducer/step"](t,!1))),t};var Tn=e(function(t,n){return new l(t,n)}),Nn=e(s(["all"],Tn,function(t,n){for(var r=0;rt?n:t}),Fn=r(function(t){return Wn(t)?!0:t?"object"!=typeof t?!1:h(t)?!1:1===t.nodeType?!!t.length:0===t.length?!0:t.length>0?t.hasOwnProperty(0)&&t.hasOwnProperty(t.length-1):!1:!1});y.prototype["@@transducer/init"]=function(){throw new Error("init not implemented on XWrap")},y.prototype["@@transducer/result"]=function(t){return t},y.prototype["@@transducer/step"]=function(t,n){return this.f(t,n)};var Rn=e(function(t,n){return i(t.length,function(){return t.apply(n,arguments)})}),Bn="undefined"!=typeof Symbol?Symbol.iterator:"@@iterator";b.prototype["@@transducer/init"]=Cn.init,b.prototype["@@transducer/result"]=Cn.result,b.prototype["@@transducer/step"]=function(t,n){return this.xf["@@transducer/step"](t,this.f(n))};var zn=e(function(t,n){return new b(t,n)}),Dn=Object.prototype.toString,Un=function(){return"[object Arguments]"===Dn.call(arguments)?function(t){return"[object Arguments]"===Dn.call(t)}:function(t){return x("callee",t)}},Mn=!{toString:null}.propertyIsEnumerable("toString"),Ln=["constructor","valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"],Kn=function(){return arguments.propertyIsEnumerable("length")}(),Vn=function(t,n){for(var r=0;r=0;)n=Ln[r],x(n,t)&&!Vn(e,n)&&(e[e.length]=n),r-=1;return e}:function(t){return Object(t)!==t?[]:Object.keys(t)},$n=r(Hn),Jn=e(s(["fantasy-land/map","map"],zn,function(t,n){switch(Object.prototype.toString.call(n)){case"[object Function]":return qn(n.length,function(){return t.call(this,n.apply(this,arguments))});case"[object Object]":return w(function(r,e){return r[e]=t(n[e]),r},{},$n(n));default:return p(t,n)}})),Xn=e(function(t,n){for(var r=n,e=0;en;){if(!t[n].apply(this,arguments))return!1;n+=1}return!0})}),tr=e(function(t,n){return t&&n});j.prototype["@@transducer/init"]=Cn.init,j.prototype["@@transducer/result"]=function(t){return this.any||(t=this.xf["@@transducer/step"](t,!1)),this.xf["@@transducer/result"](t)},j.prototype["@@transducer/step"]=function(t,n){return this.f(n)&&(this.any=!0,t=f(this.xf["@@transducer/step"](t,!0))),t};var nr=e(function(t,n){return new j(t,n)}),rr=e(s(["any"],nr,function(t,n){for(var r=0;rn;){if(t[n].apply(this,arguments))return!0;n+=1}return!1})}),ur=e(function(t,n){return"function"==typeof n["fantasy-land/ap"]?n["fantasy-land/ap"](t):"function"==typeof t.ap?t.ap(n):"function"==typeof t?function(r){return t(r)(n(r))}:w(function(t,r){return u(t,Jn(r,n))},[],t)});O.prototype["@@transducer/init"]=Cn.init,O.prototype["@@transducer/result"]=function(t){return this.acc=null,this.xf["@@transducer/result"](t)},O.prototype["@@transducer/step"]=function(t,n){return this.store(n),this.full?this.xf["@@transducer/step"](t,this.getCopy()):t},O.prototype.store=function(t){this.acc[this.pos]=t,this.pos+=1,this.pos===this.acc.length&&(this.pos=0,this.full=!0)},O.prototype.getCopy=function(){return u(Array.prototype.slice.call(this.acc,this.pos),Array.prototype.slice.call(this.acc,0,this.pos))};var ir=e(function(t,n){return new O(t,n)}),or=e(s([],ir,A)),cr=e(function(t,n){return u(n,[t])}),ar=e(function(t,n){return t.apply(this,n)}),sr=r(function(t){for(var n=$n(t),r=n.length,e=[],u=0;r>u;)e[u]=t[n[u]],u+=1;return e}),fr=r(function zo(t){return t=Jn(function(t){return"function"==typeof t?t:zo(t)},t),qn(Gn(Pn,0,Zn("length",sr(t))),function(){var n=arguments;return Jn(function(t){return ar(t,n)},t)})}),lr=e(function(t,n){return n(t)}),pr=c(function(t,n,r){var e=t(n),u=t(r);return u>e?-1:e>u?1:0}),hr=c(function(t,n,r){var e={};for(var u in r)e[u]=r[u];return e[t]=n,e}),yr=Number.isInteger||function(t){return t<<0===t},gr=r(function(t){return null==t}),dr=c(function Do(t,n,r){if(0===t.length)return n;var e=t[0];if(t.length>1){var u=!gr(r)&&x(e,r)?r[e]:yr(t[1])?[]:{};n=Do(Array.prototype.slice.call(t,1),n,u)}if(yr(e)&&Wn(r)){var i=[].concat(r);return i[e]=n,i}return hr(e,n,r)}),mr=e(function(t,n){switch(t){case 0:return function(){return n.call(this)};case 1:return function(t){return n.call(this,t)};case 2:return function(t,r){return n.call(this,t,r)};case 3:return function(t,r,e){return n.call(this,t,r,e)};case 4:return function(t,r,e,u){return n.call(this,t,r,e,u)};case 5:return function(t,r,e,u,i){return n.call(this,t,r,e,u,i)};case 6:return function(t,r,e,u,i,o){return n.call(this,t,r,e,u,i,o)};case 7:return function(t,r,e,u,i,o,c){return n.call(this,t,r,e,u,i,o,c)};case 8:return function(t,r,e,u,i,o,c,a){return n.call(this,t,r,e,u,i,o,c,a)};case 9:return function(t,r,e,u,i,o,c,a,s){return n.call(this,t,r,e,u,i,o,c,a,s)};case 10:return function(t,r,e,u,i,o,c,a,s,f){return n.call(this,t,r,e,u,i,o,c,a,s,f)};default:throw new Error("First argument to nAry must be a non-negative integer no greater than ten")}}),vr=r(function(t){return mr(2,t)}),wr=e(function(t,n){var r=qn(t,n);return qn(t,function(){return w(ur,Jn(r,arguments[0]),Array.prototype.slice.call(arguments,1))})}),br=r(function(t){return wr(t.length,t)}),xr=e(function(t,n){return S(t)?function(){return t.apply(this,arguments)&&n.apply(this,arguments)}:br(tr)(t,n)}),jr=r(function(t){return qn(t.length,t)}),Ar=jr(function(t){return t.apply(this,Array.prototype.slice.call(arguments,1))}),Or=function(t){return{"@@transducer/init":Cn.init,"@@transducer/result":function(n){return t["@@transducer/result"](n)},"@@transducer/step":function(n,r){var e=t["@@transducer/step"](n,r);return e["@@transducer/reduced"]?_(e):e}}},Sr=function(t){var n=Or(t);return{"@@transducer/init":Cn.init,"@@transducer/result":function(t){return n["@@transducer/result"](t)},"@@transducer/step":function(t,r){return Fn(r)?w(n,t,r):w(n,t,[r])}}},Er=e(function(t,n){return Jn(t,Sr(n))}),_r=e(s(["fantasy-land/chain","chain"],Er,function(t,n){return"function"==typeof n?function(r){return t(n(r))(r)}:E(!1)(Jn(t,n))})),qr=c(function(t,n,r){if(t>n)throw new Error("min must not be greater than max in clamp(min, max, value)");return t>r?t:r>n?n:r}),kr=r(function(t){return null===t?"Null":void 0===t?"Undefined":Object.prototype.toString.call(t).slice(8,-1)}),Ir=r(function(t){return null!=t&&"function"==typeof t.clone?t.clone():k(t,[],[],!0)}),Wr=r(function(t){return function(n,r){return t(n,r)?-1:t(r,n)?1:0}}),Cr=r(function(t){return!t}),Tr=br(Cr),Nr=c(W("slice",function(t,n,r){return Array.prototype.slice.call(r,t,n)})),Pr=r(W("tail",Nr(1,1/0))),Fr=r(function(t){return h(t)?t.split("").reverse().join(""):Array.prototype.slice.call(t,0).reverse()}),Rr=e(function(t,n){return t===n?0!==t||1/t===1/n:t!==t&&n!==n}),Br=e(function(t,n){return M(t,n,[],[])}),zr=function(t){return(10>t?"0":"")+t},Dr="function"==typeof Date.prototype.toISOString?function(t){return t.toISOString()}:function(t){return t.getUTCFullYear()+"-"+zr(t.getUTCMonth()+1)+"-"+zr(t.getUTCDate())+"T"+zr(t.getUTCHours())+":"+zr(t.getUTCMinutes())+":"+zr(t.getUTCSeconds())+"."+(t.getUTCMilliseconds()/1e3).toFixed(3).slice(2,5)+"Z"};X.prototype["@@transducer/init"]=Cn.init,X.prototype["@@transducer/result"]=Cn.result,X.prototype["@@transducer/step"]=function(t,n){return this.f(n)?this.xf["@@transducer/step"](t,n):t};var Ur=e(function(t,n){return new X(t,n)}),Mr=e(s(["filter"],Ur,function(t,n){return J(n)?w(function(r,e){return t(n[e])&&(r[e]=n[e]),r},{},$n(n)):$(t,n)})),Lr=e(function(t,n){return Mr(H(t),n)}),Kr=r(function(t){return Y(t,[])}),Vr=e(function(t,n){if(Wn(t)){if(Wn(n))return t.concat(n);throw new TypeError(Kr(n)+" is not an array")}if(h(t)){if(h(n))return t+n;throw new TypeError(Kr(n)+" is not a string")}if(null!=t&&S(t["fantasy-land/concat"]))return t["fantasy-land/concat"](n);if(null!=t&&S(t.concat))return t.concat(n);throw new TypeError(Kr(t)+' does not have a method named "concat" or "fantasy-land/concat"')}),Hr=r(function(t){var n=Gn(Pn,0,Jn(function(t){return t[0].length},t));return i(n,function(){for(var n=0;n10)throw new Error("Constructor with greater than ten arguments");return 0===t?function(){return new n}:jr(mr(t,function(t,r,e,u,i,o,c,a,s,f){switch(arguments.length){case 1:return new n(t);case 2:return new n(t,r);case 3:return new n(t,r,e);case 4:return new n(t,r,e,u);case 5:return new n(t,r,e,u,i);case 6:return new n(t,r,e,u,i,o);case 7:return new n(t,r,e,u,i,o,c);case 8:return new n(t,r,e,u,i,o,c,a);case 9:return new n(t,r,e,u,i,o,c,a,s);case 10:return new n(t,r,e,u,i,o,c,a,s,f)}}))}),Jr=r(function(t){return $r(t.length,t)}),Xr=e(K),Yr=e(function(t,n){return qn(Gn(Pn,0,Zn("length",n)),function(){var r=arguments,e=this;return t.apply(e,p(function(t){return t.apply(e,r)},n))})});Z.prototype["@@transducer/init"]=Cn.init,Z.prototype["@@transducer/result"]=function(t){var n;for(n in this.inputs)if(x(n,this.inputs)&&(t=this.xf["@@transducer/step"](t,this.inputs[n]),t["@@transducer/reduced"])){t=t["@@transducer/value"];break}return this.inputs=null,this.xf["@@transducer/result"](t)},Z.prototype["@@transducer/step"]=function(t,n){var r=this.keyFn(n);return this.inputs[r]=this.inputs[r]||[r,this.valueAcc],this.inputs[r][1]=this.valueFn(this.inputs[r][1],n),t};var Zr=o(4,[],function(t,n,r,e){return new Z(t,n,r,e)}),Gr=o(4,[],s([],Zr,function(t,n,r,e){return w(function(e,u){var i=r(u);return e[i]=t(x(i,e)?e[i]:n,u),e},{},e)})),Qr=Gr(function(t){return t+1},0),te=_n(-1),ne=e(function(t,n){return null==n||n!==n?t:n}),re=c(function(t,n,r){var e=t(n),u=t(r);return e>u?-1:u>e?1:0}),ee=e(function(t,n){for(var r=[],e=0,u=t.length;u>e;)K(t[e],n)||K(t[e],r)||(r[r.length]=t[e]),e+=1;return r}),ue=c(function(t,n,r){for(var e=[],u=0,i=n.length;i>u;)z(t,n[u],r)||z(t,n[u],e)||e.push(n[u]),u+=1;return e}),ie=e(function(t,n){var r={};for(var e in n)r[e]=n[e];return delete r[t],r}),oe=c(function(t,n,r){var e=Array.prototype.slice.call(r,0);return e.splice(t,n),e}),ce=c(function(t,n,r){return In(An(n),t,r)}),ae=e(function Uo(t,n){switch(t.length){case 0:return n;case 1:return yr(t[0])?oe(t[0],1,n):ie(t[0],n);default:var r=t[0],e=Array.prototype.slice.call(t,1);return null==n[r]?n:yr(t[0])?ce(r,Uo(e,n[r]),n):hr(r,Uo(e,n[r]),n)}}),se=e(function(t,n){return t/n});G.prototype["@@transducer/init"]=Cn.init,G.prototype["@@transducer/result"]=Cn.result,G.prototype["@@transducer/step"]=function(t,n){return this.n>0?(this.n-=1,t):this.xf["@@transducer/step"](t,n)};var fe=e(function(t,n){return new G(t,n)}),le=e(s(["drop"],fe,function(t,n){return Nr(Math.max(0,t),1/0,n)}));Q.prototype["@@transducer/init"]=Cn.init,Q.prototype["@@transducer/result"]=Cn.result,Q.prototype["@@transducer/step"]=function(t,n){this.i+=1;var r=0===this.n?t:this.xf["@@transducer/step"](t,n);return this.n>=0&&this.i>=this.n?f(r):r};var pe=e(function(t,n){return new Q(t,n)}),he=e(s(["take"],pe,function(t,n){return Nr(0,0>t?1/0:t,n)}));nn.prototype["@@transducer/init"]=Cn.init,nn.prototype["@@transducer/result"]=function(t){return this.acc=null,this.xf["@@transducer/result"](t)},nn.prototype["@@transducer/step"]=function(t,n){return this.full&&(t=this.xf["@@transducer/step"](t,this.acc[this.pos])),this.store(n),t},nn.prototype.store=function(t){this.acc[this.pos]=t,this.pos+=1,this.pos===this.acc.length&&(this.pos=0,this.full=!0)};var ye=e(function(t,n){return new nn(t,n)}),ge=e(s([],ye,tn));en.prototype["@@transducer/init"]=Cn.init,en.prototype["@@transducer/result"]=function(t){return this.retained=null,this.xf["@@transducer/result"](t)},en.prototype["@@transducer/step"]=function(t,n){return this.f(n)?this.retain(t,n):this.flush(t,n)},en.prototype.flush=function(t,n){return t=w(this.xf["@@transducer/step"],t,this.retained),this.retained=[],this.xf["@@transducer/step"](t,n)},en.prototype.retain=function(t,n){return this.retained.push(n),t};var de=e(function(t,n){return new en(t,n)}),me=e(s([],de,rn));un.prototype["@@transducer/init"]=Cn.init,un.prototype["@@transducer/result"]=Cn.result,un.prototype["@@transducer/step"]=function(t,n){var r=!1;return this.seenFirstValue?this.pred(this.lastValue,n)&&(r=!0):this.seenFirstValue=!0,this.lastValue=n,r?t:this.xf["@@transducer/step"](t,n)};var ve=e(function(t,n){return new un(t,n)}),we=e(function(t,n){var r=0>t?n.length+t:t;return h(n)?n.charAt(r):n[r]}),be=we(-1),xe=e(s([],ve,function(t,n){var r=[],e=1,u=n.length;if(0!==u)for(r[0]=n[0];u>e;)t(be(r),n[e])||(r[r.length]=n[e]),e+=1;return r})),je=r(s([],ve(Br),xe(Br)));on.prototype["@@transducer/init"]=Cn.init,on.prototype["@@transducer/result"]=Cn.result,on.prototype["@@transducer/step"]=function(t,n){if(this.f){if(this.f(n))return t;this.f=null}return this.xf["@@transducer/step"](t,n)};var Ae=e(function(t,n){return new on(t,n)}),Oe=e(s(["dropWhile"],Ae,function(t,n){for(var r=0,e=n.length;e>r&&t(n[r]);)r+=1;return Nr(r,1/0,n)})),Se=e(function(t,n){return t||n}),Ee=e(function(t,n){return S(t)?function(){return t.apply(this,arguments)||n.apply(this,arguments)}:br(Se)(t,n)}),_e=r(function(t){return null!=t&&"function"==typeof t["fantasy-land/empty"]?t["fantasy-land/empty"]():null!=t&&null!=t.constructor&&"function"==typeof t.constructor["fantasy-land/empty"]?t.constructor["fantasy-land/empty"]():null!=t&&"function"==typeof t.empty?t.empty():null!=t&&null!=t.constructor&&"function"==typeof t.constructor.empty?t.constructor.empty():Wn(t)?[]:h(t)?"":J(t)?{}:Un(t)?function(){return arguments}():void 0}),qe=e(function(t,n){return le(t>=0?n.length-t:0,n)}),ke=e(function(t,n){return Br(qe(t.length,n),t)}),Ie=c(function(t,n,r){return Br(t(n),t(r))}),We=c(function(t,n,r){return Br(n[t],r[t])}),Ce=e(function Mo(t,n){var r,e,u,i={};for(e in n)r=t[e],u=typeof r,i[e]="function"===u?r(n[e]):r&&"object"===u?Mo(r,n[e]):n[e];return i});cn.prototype["@@transducer/init"]=Cn.init,cn.prototype["@@transducer/result"]=function(t){return this.found||(t=this.xf["@@transducer/step"](t,void 0)),this.xf["@@transducer/result"](t)},cn.prototype["@@transducer/step"]=function(t,n){return this.f(n)&&(this.found=!0,t=f(this.xf["@@transducer/step"](t,n))),t};var Te=e(function(t,n){return new cn(t,n)}),Ne=e(s(["find"],Te,function(t,n){for(var r=0,e=n.length;e>r;){if(t(n[r]))return n[r];r+=1}}));an.prototype["@@transducer/init"]=Cn.init,an.prototype["@@transducer/result"]=function(t){return this.found||(t=this.xf["@@transducer/step"](t,-1)),this.xf["@@transducer/result"](t)},an.prototype["@@transducer/step"]=function(t,n){return this.idx+=1,this.f(n)&&(this.found=!0,t=f(this.xf["@@transducer/step"](t,this.idx))),t};var Pe=e(function(t,n){return new an(t,n)}),Fe=e(s([],Pe,function(t,n){for(var r=0,e=n.length;e>r;){if(t(n[r]))return r;r+=1}return-1}));sn.prototype["@@transducer/init"]=Cn.init,sn.prototype["@@transducer/result"]=function(t){return this.xf["@@transducer/result"](this.xf["@@transducer/step"](t,this.last))},sn.prototype["@@transducer/step"]=function(t,n){return this.f(n)&&(this.last=n),t};var Re=e(function(t,n){return new sn(t,n)}),Be=e(s([],Re,function(t,n){for(var r=n.length-1;r>=0;){if(t(n[r]))return n[r];r-=1}}));fn.prototype["@@transducer/init"]=Cn.init,fn.prototype["@@transducer/result"]=function(t){return this.xf["@@transducer/result"](this.xf["@@transducer/step"](t,this.lastIdx))},fn.prototype["@@transducer/step"]=function(t,n){return this.idx+=1,this.f(n)&&(this.lastIdx=this.idx),t};var ze=e(function(t,n){return new fn(t,n)}),De=e(s([],ze,function(t,n){for(var r=n.length-1;r>=0;){if(t(n[r]))return r;r-=1}return-1})),Ue=r(E(!0)),Me=r(function(t){return qn(t.length,function(n,r){var e=Array.prototype.slice.call(arguments,0);return e[0]=r,e[1]=n,t.apply(this,e)})}),Le=e(W("forEach",function(t,n){for(var r=n.length,e=0;r>e;)t(n[e]),e+=1;return n})),Ke=e(function(t,n){for(var r=$n(n),e=0;ee;){for(var i=e+1;u>i&&t(n[i-1],n[i]);)i+=1;r.push(n.slice(e,i)),e=i}return r}),Je=e(function(t,n){return t>n}),Xe=e(function(t,n){return t>=n}),Ye=e(x),Ze=e(function(t,n){return t in n}),Ge=we(0),Qe=r(ln),tu=c(function(t,n,r){return qn(Math.max(t.length,n.length,r.length),function(){return t.apply(this,arguments)?n.apply(this,arguments):r.apply(this,arguments)})}),nu=_n(1),ru=Gr(function(t,n){return n},null),eu=e(function(t,n){return"function"!=typeof n.indexOf||Wn(n)?L(n,t,0):n.indexOf(t)}),uu=Nr(0,-1),iu=c(function(t,n,r){return $(function(n){return z(t,n,r)},n)}),ou=c(function(t,n,r){t=t=0?t:r.length;var e=Array.prototype.slice.call(r,0);return e.splice(t,0,n),e}),cu=c(function(t,n,r){return t=t=0?t:r.length,[].concat(Array.prototype.slice.call(r,0,t),n,Array.prototype.slice.call(r,t))});pn.prototype.add=function(t){return!hn(t,!0,this)},pn.prototype.has=function(t){return hn(t,!1,this)};var au=e(function(t,n){for(var r,e,u=new pn,i=[],o=0;on.length?(r=t,e=n):(r=n,e=t),su($(Me(K)(r),e))}),lu=e(W("intersperse",function(t,n){for(var r=[],e=0,u=n.length;u>e;)e===u-1?r.push(n[e]):r.push(n[e],t),e+=1;return r})),pu="function"==typeof Object.assign?Object.assign:yn,hu=e(function(t,n){var r={};return r[t]=n,r}),yu={"@@transducer/init":Array,"@@transducer/step":function(t,n){return t.push(n),t},"@@transducer/result":ln},gu={"@@transducer/init":String,"@@transducer/step":function(t,n){return t+n},"@@transducer/result":ln},du={"@@transducer/init":Object,"@@transducer/step":function(t,n){return pu(t,Fn(n)?hu(n[0],n[1]):n)},"@@transducer/result":ln},mu=c(function(t,n,r){return a(t)?w(n(t),t["@@transducer/init"](),r):w(n(gn(t)),k(t,[],[],!1),r)}),vu=r(function(t){for(var n=$n(t),r=n.length,e=0,u={};r>e;){var i=n[e],o=t[i],c=x(o,u)?u[o]:u[o]=[];c[c.length]=i,e+=1}return u}),wu=r(function(t){for(var n=$n(t),r=n.length,e=0,u={};r>e;){var i=n[e];u[t[i]]=i,e+=1}return u}),bu=e(function(t,n){return qn(t+1,function(){var r=arguments[t];if(null!=r&&S(r[n]))return r[n].apply(r,Array.prototype.slice.call(arguments,0,t));throw new TypeError(Kr(r)+' does not have a method named "'+n+'"')})}),xu=e(function(t,n){return null!=n&&n.constructor===t||n instanceof t}),ju=r(function(t){return null!=t&&Br(t,_e(t))}),Au=bu(1,"join"),Ou=r(function(t){return Yr(function(){return Array.prototype.slice.call(arguments,0)},t)}),Su=r(function(t){var n,r=[];for(n in t)r[r.length]=n;return r}),Eu=e(function(t,n){if("function"!=typeof n.lastIndexOf||Wn(n)){for(var r=n.length-1;r>=0;){if(Br(n[r],t))return r;r-=1}return-1}return n.lastIndexOf(t)}),_u=r(function(t){return null!=t&&dn(t.length)?t.length:0/0}),qu=e(function(t,n){return function(r){return function(e){return Jn(function(t){return n(t,e)},r(t(e)))}}}),ku=r(function(t){return qu(we(t),ce(t))}),Iu=r(function(t){return qu(Xn(t),dr(t))}),Wu=r(function(t){return qu(Yn(t),hr(t))}),Cu=e(function(t,n){return n>t}),Tu=e(function(t,n){return n>=t}),Nu=c(function(t,n,r){for(var e=0,u=r.length,i=[],o=[n];u>e;)o=t(o[0],r[e]),i[e]=o[1],e+=1;return[o[0],i]}),Pu=c(function(t,n,r){for(var e=r.length-1,u=[],i=[n];e>=0;)i=t(r[e],i[0]),u[e]=i[1],e-=1;return[u,i[0]]}),Fu=e(function(t,n){return w(function(r,e){return r[e]=t(n[e],e,n),r},{},$n(n))}),Ru=e(function(t,n){return n.match(t)||[]}),Bu=e(function(t,n){return yr(t)?!yr(n)||1>n?0/0:(t%n+n)%n:0/0}),zu=c(function(t,n,r){return t(r)>t(n)?r:n}),Du=Gn(_n,0),Uu=r(function(t){return Du(t)/t.length}),Mu=r(function(t){var n=t.length;if(0===n)return 0/0;var r=2-n%2,e=(n-r)/2;return Uu(Array.prototype.slice.call(t,0).sort(function(t,n){return n>t?-1:t>n?1:0}).slice(e,e+r))}),Lu=e(function(t,n){var r={};return i(n.length,function(){var e=t.apply(this,arguments);return x(e,r)||(r[e]=n.apply(this,arguments)),r[e]})}),Ku=Lu(function(){return Kr(arguments)}),Vu=e(function(t,n){return pu({},t,n)}),Hu=r(function(t){return pu.apply(null,[{}].concat(t))}),$u=c(function(t,n,r){var e,u={};for(e in n)x(e,n)&&(u[e]=x(e,r)?t(e,n[e],r[e]):n[e]);for(e in r)x(e,r)&&!x(e,u)&&(u[e]=r[e]);return u}),Ju=c(function Lo(t,n,r){return $u(function(n,r,e){return J(r)&&J(e)?Lo(t,r,e):t(n,r,e)},n,r)}),Xu=e(function(t,n){return Ju(function(t,n){return n},t,n)}),Yu=e(function(t,n){return Ju(function(t,n,r){return r},t,n)}),Zu=c(function(t,n,r){return Ju(function(n,r,e){return t(r,e)},n,r)}),Gu=c(function(t,n,r){return $u(function(n,r,e){return t(r,e)},n,r)}),Qu=e(function(t,n){return t>n?n:t}),ti=c(function(t,n,r){return t(r)t?1:t+1;return qn(n,function(){return we(t,arguments)})}),oi=c(function(t,n,r){return t(n(r))}),ci=r(mn),ai=e(function(t,n){for(var r={},e={},u=0,i=t.length;i>u;)e[t[u]]=1,u+=1;for(var o in n)e.hasOwnProperty(o)||(r[o]=n[o]);return r}),si=r(function(t){var n,r=!1;return i(t.length,function(){return r?n:(r=!0,n=t.apply(this,arguments))})}),fi=function(t){return{value:t,map:function(n){return fi(n(t))}}},li=c(function(t,n,r){return t(function(t){return fi(n(t))})(r).value}),pi=e(function(t,n){return[t,n]}),hi=vn(u),yi=vn(Me(u)),gi=Ou([Mr,Lr]),di=c(function(t,n,r){return Br(Xn(t,r),n)}),mi=c(function(t,n,r){return ne(t,Xn(n,r))}),vi=c(function(t,n,r){return n.length>0&&t(Xn(n,r))}),wi=e(function(t,n){for(var r={},e=0;ee;){var i=t[e];r[i]=n[i],e+=1}return r}),xi=e(function(t,n){var r={};for(var e in n)t(n[e],e,n)&&(r[e]=n[e]);return r}),ji=e(function(t,n){return u([t],n)}),Ai=Gn(ri,1),Oi=e(function(t,n){return qn(n.length,function(){for(var r=[],e=0;eu;)e[u]=n[t[u]],u+=1;return e}),Wi=e(function(t,n){if(!dn(t)||!dn(n))throw new TypeError("Both arguments to range must be numbers");for(var r=[],e=t;n>e;)r.push(e),e+=1;return r}),Ci=c(function(t,n,r){for(var e=r.length-1;e>=0;)n=t(r[e],n),e-=1;return n}),Ti=o(4,[],function(t,n,r,e){return w(function(r,e){return t(r,e)?n(r,e):f(r)},r,e)}),Ni=r(f),Pi=e(function(t,n){var r,e=Number(n),u=0;if(0>e||isNaN(e))throw new RangeError("n must be a non-negative number");for(r=new Array(e);e>u;)r[u]=t(u),u+=1;return r}),Fi=e(function(t,n){return Pi(An(t),n)}),Ri=c(function(t,n,r){return r.replace(t,n)}),Bi=c(function(t,n,r){for(var e=0,u=r.length,i=[n];u>e;)n=t(n,r[e]),i[e+1]=n,e+=1;return i}),zi=e(function(t,n){return"function"==typeof n.sequence?n.sequence(t):Ci(function(t,n){return ur(Jn(ji,t),n)},t([]),n)}),Di=c(function(t,n,r){return li(t,An(n),r)}),Ui=e(function(t,n){return Array.prototype.slice.call(n,0).sort(t)}),Mi=e(function(t,n){return Array.prototype.slice.call(n,0).sort(function(n,r){var e=t(n),u=t(r);return u>e?-1:e>u?1:0})}),Li=e(function(t,n){return Array.prototype.slice.call(n,0).sort(function(n,r){for(var e=0,u=0;0===e&&u=t)throw new Error("First argument to splitEvery must be a positive integer");for(var r=[],e=0;er&&!t(n[r]);)u.push(n[r]),r+=1;return[u,Array.prototype.slice.call(n,r)]}),Ji=e(function(t,n){return Br(he(t.length,n),t)}),Xi=e(function(t,n){return Number(t)-Number(n)}),Yi=e(function(t,n){return Vr(ee(t,n),ee(n,t))}),Zi=c(function(t,n,r){return Vr(ue(t,n,r),ue(t,r,n))}),Gi=e(function(t,n){for(var r=n.length-1;r>=0&&t(n[r]);)r-=1;return Nr(r+1,1/0,n)});bn.prototype["@@transducer/init"]=Cn.init,bn.prototype["@@transducer/result"]=Cn.result,bn.prototype["@@transducer/step"]=function(t,n){return this.f(n)?this.xf["@@transducer/step"](t,n):f(t)};var Qi=e(function(t,n){return new bn(t,n)}),to=e(s(["takeWhile"],Qi,function(t,n){for(var r=0,e=n.length;e>r&&t(n[r]);)r+=1;return Nr(0,r,n)}));xn.prototype["@@transducer/init"]=Cn.init,xn.prototype["@@transducer/result"]=Cn.result,xn.prototype["@@transducer/step"]=function(t,n){return this.f(n),this.xf["@@transducer/step"](t,n)};var no=e(function(t,n){return new xn(t,n)}),ro=e(s([],no,function(t,n){return t(n),n})),eo=e(function(t,n){if(!jn(t))throw new TypeError("‘test’ requires a value of type RegExp as its first argument; received "+Kr(t));return q(t).test(n)}),uo=bu(0,"toLowerCase"),io=r(function(t){var n=[];for(var r in t)x(r,t)&&(n[n.length]=[r,t[r]]);return n}),oo=r(function(t){var n=[];for(var r in t)n[n.length]=[r,t[r]];return n}),co=bu(0,"toUpperCase"),ao=qn(4,function(t,n,r,e){return w(t("function"==typeof n?g(n):n),r,e)}),so=r(function(t){for(var n=0,r=[];n=e&&"function"==typeof u;)r=e===t?arguments.length:i+u.length,u=u.apply(this,Array.prototype.slice.call(arguments,i,r)),e+=1,i=r;return u})}),xo=e(function(t,n){for(var r=t(n),e=[];r&&r.length;)e[e.length]=r[0],r=t(r[1]);return e}),jo=e(T(su,u)),Ao=e(function(t,n){for(var r,e=0,u=n.length,i=[];u>e;)r=n[e],z(t,r,i)||(i[i.length]=r),e+=1;return i}),Oo=c(function(t,n,r){return Ao(t,u(n,r))}),So=c(function(t,n,r){return t(r)?r:n(r)}),Eo=_r(ln),_o=c(function(t,n,r){for(var e=r;!t(e);)e=n(e);return e}),qo=r(function(t){var n,r=[];for(n in t)r[r.length]=t[n];return r}),ko=function(t){return{value:t,"fantasy-land/map":function(){return this}}},Io=e(function(t,n){return t(ko)(n).value}),Wo=c(function(t,n,r){return t(r)?n(r):r}),Co=e(function(t,n){for(var r in t)if(x(r,t)&&!t[r](n[r]))return!1;return!0}),To=e(function(t,n){return Co(Jn(Br,t),n)}),No=e(function(t,n){return Lr(Me(K)(t),n)}),Po=e(function(t,n){for(var r,e=0,u=t.length,i=n.length,o=[];u>e;){for(r=0;i>r;)o[o.length]=[t[e],n[r]],r+=1;e+=1}return o}),Fo=e(function(t,n){for(var r=[],e=0,u=Math.min(t.length,n.length);u>e;)r[e]=[t[e],n[e]],e+=1;return r}),Ro=e(function(t,n){for(var r=0,e=Math.min(t.length,n.length),u={};e>r;)u[t[r]]=n[r],r+=1;return u}),Bo=c(function(t,n,r){for(var e=[],u=0,i=Math.min(n.length,r.length);i>u;)e[u]=t(n[u],r[u]),u+=1;return e});t.F=On,t.T=Sn,t.__=En,t.add=_n,t.addIndex=kn,t.adjust=In,t.all=Nn,t.allPass=Qn,t.always=An,t.and=tr,t.any=rr,t.anyPass=er,t.ap=ur,t.aperture=or,t.append=cr,t.apply=ar,t.applySpec=fr,t.applyTo=lr,t.ascend=pr,t.assoc=hr,t.assocPath=dr,t.binary=vr,t.bind=Rn,t.both=xr,t.call=Ar,t.chain=_r,t.clamp=qr,t.clone=Ir,t.comparator=Wr,t.complement=Tr,t.compose=T,t.composeK=N,t.composeP=R,t.concat=Vr,t.cond=Hr,t.construct=Jr,t.constructN=$r,t.contains=Xr,t.converge=Yr,t.countBy=Qr,t.curry=jr,t.curryN=qn,t.dec=te,t.defaultTo=ne,t.descend=re,t.difference=ee,t.differenceWith=ue,t.dissoc=ie,t.dissocPath=ae,t.divide=se,t.drop=le,t.dropLast=ge,t.dropLastWhile=me,t.dropRepeats=je,t.dropRepeatsWith=xe,t.dropWhile=Oe,t.either=Ee,t.empty=_e,t.endsWith=ke,t.eqBy=Ie,t.eqProps=We,t.equals=Br,t.evolve=Ce,t.filter=Mr,t.find=Ne,t.findIndex=Fe,t.findLast=Be,t.findLastIndex=De,t.flatten=Ue,t.flip=Me,t.forEach=Le,t.forEachObjIndexed=Ke,t.fromPairs=Ve,t.groupBy=He,t.groupWith=$e,t.gt=Je,t.gte=Xe,t.has=Ye,t.hasIn=Ze,t.head=Ge,t.identical=Rr,t.identity=Qe,t.ifElse=tu,t.inc=nu,t.indexBy=ru,t.indexOf=eu,t.init=uu,t.innerJoin=iu,t.insert=ou,t.insertAll=cu,t.intersection=fu,t.intersperse=lu,t.into=mu,t.invert=vu,t.invertObj=wu,t.invoker=bu,t.is=xu,t.isEmpty=ju,t.isNil=gr,t.join=Au,t.juxt=Ou,t.keys=$n,t.keysIn=Su,t.last=be,t.lastIndexOf=Eu,t.length=_u,t.lens=qu,t.lensIndex=ku,t.lensPath=Iu,t.lensProp=Wu,t.lift=br,t.liftN=wr,t.lt=Cu,t.lte=Tu,t.map=Jn,t.mapAccum=Nu,t.mapAccumRight=Pu,t.mapObjIndexed=Fu,t.match=Ru,t.mathMod=Bu,t.max=Pn,t.maxBy=zu,t.mean=Uu,t.median=Mu,t.memoize=Ku,t.memoizeWith=Lu,t.merge=Vu,t.mergeAll=Hu,t.mergeDeepLeft=Xu,t.mergeDeepRight=Yu,t.mergeDeepWith=Zu,t.mergeDeepWithKey=Ju,t.mergeWith=Gu,t.mergeWithKey=$u,t.min=Qu,t.minBy=ti,t.modulo=ni,t.multiply=ri,t.nAry=mr,t.negate=ei,t.none=ui,t.not=Cr,t.nth=we,t.nthArg=ii,t.o=oi,t.objOf=hu,t.of=ci,t.omit=ai,t.once=si,t.or=Se,t.over=li,t.pair=pi,t.partial=hi,t.partialRight=yi,t.partition=gi,t.path=Xn,t.pathEq=di,t.pathOr=mi,t.pathSatisfies=vi,t.pick=wi,t.pickAll=bi,t.pickBy=xi,t.pipe=C,t.pipeK=wn,t.pipeP=F,t.pluck=Zn,t.prepend=ji,t.product=Ai,t.project=Si,t.prop=Yn,t.propEq=Ei,t.propIs=_i,t.propOr=qi,t.propSatisfies=ki,t.props=Ii,t.range=Wi,t.reduce=Gn,t.reduceBy=Gr,t.reduceRight=Ci,t.reduceWhile=Ti,t.reduced=Ni,t.reject=Lr,t.remove=oe,t.repeat=Fi,t.replace=Ri,t.reverse=Fr,t.scan=Bi,t.sequence=zi,t.set=Di,t.slice=Nr,t.sort=Ui,t.sortBy=Mi,t.sortWith=Li,t.split=Ki,t.splitAt=Vi,t.splitEvery=Hi,t.splitWhen=$i,t.startsWith=Ji,t.subtract=Xi,t.sum=Du,t.symmetricDifference=Yi,t.symmetricDifferenceWith=Zi,t.tail=Pr,t.take=he,t.takeLast=qe,t.takeLastWhile=Gi,t.takeWhile=to,t.tap=ro,t.test=eo,t.times=Pi,t.toLower=uo,t.toPairs=io,t.toPairsIn=oo,t.toString=Kr,t.toUpper=co,t.transduce=ao,t.transpose=so,t.traverse=fo,t.trim=go,t.tryCatch=mo,t.type=kr,t.unapply=vo,t.unary=wo,t.uncurryN=bo,t.unfold=xo,t.union=jo,t.unionWith=Oo,t.uniq=su,t.uniqBy=au,t.uniqWith=Ao,t.unless=So,t.unnest=Eo,t.until=_o,t.update=ce,t.useWith=Oi,t.values=sr,t.valuesIn=qo,t.view=Io,t.when=Wo,t.where=Co,t.whereEq=To,t.without=No,t.xprod=Po,t.zip=Fo,t.zipObj=Ro,t.zipWith=Bo,Object.defineProperty(t,"__esModule",{value:!0})}),e="0.24.1",r("Ramda v"+e+" loaded"),void 0)}(window,document); + javascript: ``` diff --git a/Makefile b/Makefile index 120b3a67ba..6447e37499 100644 --- a/Makefile +++ b/Makefile @@ -1,4 +1,4 @@ -XYZ = node_modules/.bin/xyz --repo git@github.com:ramda/ramda.git --script scripts/prepublish +XYZ = node_modules/.bin/xyz --branch v0.27 --repo git@github.com:ramda/ramda.git --script scripts/prepublish dist/ramda.js: diff --git a/dist/ramda.js b/dist/ramda.js index 02918c6ded..d7d6065466 100644 --- a/dist/ramda.js +++ b/dist/ramda.js @@ -1,9568 +1,9716 @@ -// Ramda v0.25.0 +// Ramda v0.27.1 // https://github.com/ramda/ramda -// (c) 2013-2018 Scott Sauyet, Michael Hurley, and David Chambers +// (c) 2013-2020 Scott Sauyet, Michael Hurley, and David Chambers // Ramda may be freely distributed under the MIT license. (function (global, factory) { - typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : - typeof define === 'function' && define.amd ? define(['exports'], factory) : - (factory((global.R = {}))); -}(this, (function (exports) { 'use strict'; - -/** - * A function that always returns `false`. Any passed in parameters are ignored. - * - * @func - * @memberOf R - * @since v0.9.0 - * @category Function - * @sig * -> Boolean - * @param {*} - * @return {Boolean} - * @see R.T - * @example - * - * R.F(); //=> false - */ -var F = function() {return false;}; - -/** - * A function that always returns `true`. Any passed in parameters are ignored. - * - * @func - * @memberOf R - * @since v0.9.0 - * @category Function - * @sig * -> Boolean - * @param {*} - * @return {Boolean} - * @see R.F - * @example - * - * R.T(); //=> true - */ -var T = function() {return true;}; - -/** - * A special placeholder value used to specify "gaps" within curried functions, - * allowing partial application of any combination of arguments, regardless of - * their positions. - * - * If `g` is a curried ternary function and `_` is `R.__`, the following are - * equivalent: - * - * - `g(1, 2, 3)` - * - `g(_, 2, 3)(1)` - * - `g(_, _, 3)(1)(2)` - * - `g(_, _, 3)(1, 2)` - * - `g(_, 2, _)(1, 3)` - * - `g(_, 2)(1)(3)` - * - `g(_, 2)(1, 3)` - * - `g(_, 2)(_, 3)(1)` - * - * @name __ - * @constant - * @memberOf R - * @since v0.6.0 - * @category Function - * @example - * - * const greet = R.replace('{name}', R.__, 'Hello, {name}!'); - * greet('Alice'); //=> 'Hello, Alice!' - */ -var __ = {'@@functional/placeholder': true}; - -function _isPlaceholder(a) { - return a != null && - typeof a === 'object' && - a['@@functional/placeholder'] === true; -} - -/** - * Optimized internal one-arity curry function. - * - * @private - * @category Function - * @param {Function} fn The function to curry. - * @return {Function} The curried function. - */ -function _curry1(fn) { - return function f1(a) { - if (arguments.length === 0 || _isPlaceholder(a)) { - return f1; - } else { - return fn.apply(this, arguments); - } - }; -} - -/** - * Optimized internal two-arity curry function. - * - * @private - * @category Function - * @param {Function} fn The function to curry. - * @return {Function} The curried function. - */ -function _curry2(fn) { - return function f2(a, b) { - switch (arguments.length) { - case 0: - return f2; - case 1: - return _isPlaceholder(a) ? f2 - : _curry1(function(_b) { return fn(a, _b); }); - default: - return _isPlaceholder(a) && _isPlaceholder(b) ? f2 - : _isPlaceholder(a) ? _curry1(function(_a) { return fn(_a, b); }) - : _isPlaceholder(b) ? _curry1(function(_b) { return fn(a, _b); }) - : fn(a, b); - } - }; -} - -/** - * Adds two values. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Math - * @sig Number -> Number -> Number - * @param {Number} a - * @param {Number} b - * @return {Number} - * @see R.subtract - * @example - * - * R.add(2, 3); //=> 5 - * R.add(7)(10); //=> 17 - */ -var add = _curry2(function add(a, b) { - return Number(a) + Number(b); -}); - -/** - * Private `concat` function to merge two array-like objects. - * - * @private - * @param {Array|Arguments} [set1=[]] An array-like object. - * @param {Array|Arguments} [set2=[]] An array-like object. - * @return {Array} A new, merged array. - * @example - * - * _concat([4, 5, 6], [1, 2, 3]); //=> [4, 5, 6, 1, 2, 3] - */ -function _concat(set1, set2) { - set1 = set1 || []; - set2 = set2 || []; - var idx; - var len1 = set1.length; - var len2 = set2.length; - var result = []; - - idx = 0; - while (idx < len1) { - result[result.length] = set1[idx]; - idx += 1; - } - idx = 0; - while (idx < len2) { - result[result.length] = set2[idx]; - idx += 1; - } - return result; -} - -function _arity(n, fn) { - /* eslint-disable no-unused-vars */ - switch (n) { - case 0: return function() { return fn.apply(this, arguments); }; - case 1: return function(a0) { return fn.apply(this, arguments); }; - case 2: return function(a0, a1) { return fn.apply(this, arguments); }; - case 3: return function(a0, a1, a2) { return fn.apply(this, arguments); }; - case 4: return function(a0, a1, a2, a3) { return fn.apply(this, arguments); }; - case 5: return function(a0, a1, a2, a3, a4) { return fn.apply(this, arguments); }; - case 6: return function(a0, a1, a2, a3, a4, a5) { return fn.apply(this, arguments); }; - case 7: return function(a0, a1, a2, a3, a4, a5, a6) { return fn.apply(this, arguments); }; - case 8: return function(a0, a1, a2, a3, a4, a5, a6, a7) { return fn.apply(this, arguments); }; - case 9: return function(a0, a1, a2, a3, a4, a5, a6, a7, a8) { return fn.apply(this, arguments); }; - case 10: return function(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9) { return fn.apply(this, arguments); }; - default: throw new Error('First argument to _arity must be a non-negative integer no greater than ten'); - } -} - -/** - * Internal curryN function. - * - * @private - * @category Function - * @param {Number} length The arity of the curried function. - * @param {Array} received An array of arguments received thus far. - * @param {Function} fn The function to curry. - * @return {Function} The curried function. - */ -function _curryN(length, received, fn) { - return function() { - var combined = []; - var argsIdx = 0; - var left = length; - var combinedIdx = 0; - while (combinedIdx < received.length || argsIdx < arguments.length) { - var result; - if (combinedIdx < received.length && - (!_isPlaceholder(received[combinedIdx]) || - argsIdx >= arguments.length)) { - result = received[combinedIdx]; + typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : + typeof define === 'function' && define.amd ? define(['exports'], factory) : + (global = global || self, factory(global.R = {})); +}(this, function (exports) { 'use strict'; + + /** + * A function that always returns `false`. Any passed in parameters are ignored. + * + * @func + * @memberOf R + * @since v0.9.0 + * @category Function + * @sig * -> Boolean + * @param {*} + * @return {Boolean} + * @see R.T + * @example + * + * R.F(); //=> false + */ + var F = function() {return false;}; + + /** + * A function that always returns `true`. Any passed in parameters are ignored. + * + * @func + * @memberOf R + * @since v0.9.0 + * @category Function + * @sig * -> Boolean + * @param {*} + * @return {Boolean} + * @see R.F + * @example + * + * R.T(); //=> true + */ + var T = function() {return true;}; + + /** + * A special placeholder value used to specify "gaps" within curried functions, + * allowing partial application of any combination of arguments, regardless of + * their positions. + * + * If `g` is a curried ternary function and `_` is `R.__`, the following are + * equivalent: + * + * - `g(1, 2, 3)` + * - `g(_, 2, 3)(1)` + * - `g(_, _, 3)(1)(2)` + * - `g(_, _, 3)(1, 2)` + * - `g(_, 2, _)(1, 3)` + * - `g(_, 2)(1)(3)` + * - `g(_, 2)(1, 3)` + * - `g(_, 2)(_, 3)(1)` + * + * @name __ + * @constant + * @memberOf R + * @since v0.6.0 + * @category Function + * @example + * + * const greet = R.replace('{name}', R.__, 'Hello, {name}!'); + * greet('Alice'); //=> 'Hello, Alice!' + */ + var __ = {'@@functional/placeholder': true}; + + function _isPlaceholder(a) { + return a != null && + typeof a === 'object' && + a['@@functional/placeholder'] === true; + } + + /** + * Optimized internal one-arity curry function. + * + * @private + * @category Function + * @param {Function} fn The function to curry. + * @return {Function} The curried function. + */ + function _curry1(fn) { + return function f1(a) { + if (arguments.length === 0 || _isPlaceholder(a)) { + return f1; } else { - result = arguments[argsIdx]; - argsIdx += 1; + return fn.apply(this, arguments); } - combined[combinedIdx] = result; - if (!_isPlaceholder(result)) { - left -= 1; - } - combinedIdx += 1; - } - return left <= 0 ? fn.apply(this, combined) - : _arity(left, _curryN(length, combined, fn)); - }; -} - -/** - * Returns a curried equivalent of the provided function, with the specified - * arity. The curried function has two unusual capabilities. First, its - * arguments needn't be provided one at a time. If `g` is `R.curryN(3, f)`, the - * following are equivalent: - * - * - `g(1)(2)(3)` - * - `g(1)(2, 3)` - * - `g(1, 2)(3)` - * - `g(1, 2, 3)` - * - * Secondly, the special placeholder value [`R.__`](#__) may be used to specify - * "gaps", allowing partial application of any combination of arguments, - * regardless of their positions. If `g` is as above and `_` is [`R.__`](#__), - * the following are equivalent: - * - * - `g(1, 2, 3)` - * - `g(_, 2, 3)(1)` - * - `g(_, _, 3)(1)(2)` - * - `g(_, _, 3)(1, 2)` - * - `g(_, 2)(1)(3)` - * - `g(_, 2)(1, 3)` - * - `g(_, 2)(_, 3)(1)` - * - * @func - * @memberOf R - * @since v0.5.0 - * @category Function - * @sig Number -> (* -> a) -> (* -> a) - * @param {Number} length The arity for the returned function. - * @param {Function} fn The function to curry. - * @return {Function} A new, curried function. - * @see R.curry - * @example - * - * const sumArgs = (...args) => R.sum(args); - * - * const curriedAddFourNumbers = R.curryN(4, sumArgs); - * const f = curriedAddFourNumbers(1, 2); - * const g = f(3); - * g(4); //=> 10 - */ -var curryN = _curry2(function curryN(length, fn) { - if (length === 1) { - return _curry1(fn); + }; } - return _arity(length, _curryN(length, [], fn)); -}); - -/** - * Creates a new list iteration function from an existing one by adding two new - * parameters to its callback function: the current index, and the entire list. - * - * This would turn, for instance, [`R.map`](#map) function into one that - * more closely resembles `Array.prototype.map`. Note that this will only work - * for functions in which the iteration callback function is the first - * parameter, and where the list is the last parameter. (This latter might be - * unimportant if the list parameter is not used.) - * - * @func - * @memberOf R - * @since v0.15.0 - * @category Function - * @category List - * @sig ((a ... -> b) ... -> [a] -> *) -> ((a ..., Int, [a] -> b) ... -> [a] -> *) - * @param {Function} fn A list iteration function that does not pass index or list to its callback - * @return {Function} An altered list iteration function that passes (item, index, list) to its callback - * @example - * - * const mapIndexed = R.addIndex(R.map); - * mapIndexed((val, idx) => idx + '-' + val, ['f', 'o', 'o', 'b', 'a', 'r']); - * //=> ['0-f', '1-o', '2-o', '3-b', '4-a', '5-r'] - */ -var addIndex = _curry1(function addIndex(fn) { - return curryN(fn.length, function() { - var idx = 0; - var origFn = arguments[0]; - var list = arguments[arguments.length - 1]; - var args = Array.prototype.slice.call(arguments, 0); - args[0] = function() { - var result = origFn.apply(this, _concat(arguments, [idx, list])); - idx += 1; - return result; + + /** + * Optimized internal two-arity curry function. + * + * @private + * @category Function + * @param {Function} fn The function to curry. + * @return {Function} The curried function. + */ + function _curry2(fn) { + return function f2(a, b) { + switch (arguments.length) { + case 0: + return f2; + case 1: + return _isPlaceholder(a) + ? f2 + : _curry1(function(_b) { return fn(a, _b); }); + default: + return _isPlaceholder(a) && _isPlaceholder(b) + ? f2 + : _isPlaceholder(a) + ? _curry1(function(_a) { return fn(_a, b); }) + : _isPlaceholder(b) + ? _curry1(function(_b) { return fn(a, _b); }) + : fn(a, b); + } }; - return fn.apply(this, args); + } + + /** + * Adds two values. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Math + * @sig Number -> Number -> Number + * @param {Number} a + * @param {Number} b + * @return {Number} + * @see R.subtract + * @example + * + * R.add(2, 3); //=> 5 + * R.add(7)(10); //=> 17 + */ + var add = _curry2(function add(a, b) { + return Number(a) + Number(b); }); -}); - -/** - * Optimized internal three-arity curry function. - * - * @private - * @category Function - * @param {Function} fn The function to curry. - * @return {Function} The curried function. - */ -function _curry3(fn) { - return function f3(a, b, c) { - switch (arguments.length) { - case 0: - return f3; - case 1: - return _isPlaceholder(a) ? f3 - : _curry2(function(_b, _c) { return fn(a, _b, _c); }); - case 2: - return _isPlaceholder(a) && _isPlaceholder(b) ? f3 - : _isPlaceholder(a) ? _curry2(function(_a, _c) { return fn(_a, b, _c); }) - : _isPlaceholder(b) ? _curry2(function(_b, _c) { return fn(a, _b, _c); }) - : _curry1(function(_c) { return fn(a, b, _c); }); - default: - return _isPlaceholder(a) && _isPlaceholder(b) && _isPlaceholder(c) ? f3 - : _isPlaceholder(a) && _isPlaceholder(b) ? _curry2(function(_a, _b) { return fn(_a, _b, c); }) - : _isPlaceholder(a) && _isPlaceholder(c) ? _curry2(function(_a, _c) { return fn(_a, b, _c); }) - : _isPlaceholder(b) && _isPlaceholder(c) ? _curry2(function(_b, _c) { return fn(a, _b, _c); }) - : _isPlaceholder(a) ? _curry1(function(_a) { return fn(_a, b, c); }) - : _isPlaceholder(b) ? _curry1(function(_b) { return fn(a, _b, c); }) - : _isPlaceholder(c) ? _curry1(function(_c) { return fn(a, b, _c); }) - : fn(a, b, c); + + /** + * Private `concat` function to merge two array-like objects. + * + * @private + * @param {Array|Arguments} [set1=[]] An array-like object. + * @param {Array|Arguments} [set2=[]] An array-like object. + * @return {Array} A new, merged array. + * @example + * + * _concat([4, 5, 6], [1, 2, 3]); //=> [4, 5, 6, 1, 2, 3] + */ + function _concat(set1, set2) { + set1 = set1 || []; + set2 = set2 || []; + var idx; + var len1 = set1.length; + var len2 = set2.length; + var result = []; + + idx = 0; + while (idx < len1) { + result[result.length] = set1[idx]; + idx += 1; } - }; -} - -/** - * Applies a function to the value at the given index of an array, returning a - * new copy of the array with the element at the given index replaced with the - * result of the function application. - * - * @func - * @memberOf R - * @since v0.14.0 - * @category List - * @sig Number -> (a -> a) -> [a] -> [a] - * @param {Number} idx The index. - * @param {Function} fn The function to apply. - * @param {Array|Arguments} list An array-like object whose value - * at the supplied index will be replaced. - * @return {Array} A copy of the supplied array-like object with - * the element at index `idx` replaced with the value - * returned by applying `fn` to the existing element. - * @see R.update - * @example - * - * R.adjust(1, R.toUpper, ['a', 'b', 'c', 'd']); //=> ['a', 'B', 'c', 'd'] - * R.adjust(-1, R.toUpper, ['a', 'b', 'c', 'd']); //=> ['a', 'b', 'c', 'D'] - * @symb R.adjust(-1, f, [a, b]) = [a, f(b)] - * @symb R.adjust(0, f, [a, b]) = [f(a), b] - */ -var adjust = _curry3(function adjust(idx, fn, list) { - if (idx >= list.length || idx < -list.length) { - return list; + idx = 0; + while (idx < len2) { + result[result.length] = set2[idx]; + idx += 1; + } + return result; } - var start = idx < 0 ? list.length : 0; - var _idx = start + idx; - var _list = _concat(list); - _list[_idx] = fn(list[_idx]); - return _list; -}); - -/** - * Tests whether or not an object is an array. - * - * @private - * @param {*} val The object to test. - * @return {Boolean} `true` if `val` is an array, `false` otherwise. - * @example - * - * _isArray([]); //=> true - * _isArray(null); //=> false - * _isArray({}); //=> false - */ -var _isArray = Array.isArray || function _isArray(val) { - return (val != null && - val.length >= 0 && - Object.prototype.toString.call(val) === '[object Array]'); -}; - -function _isTransformer(obj) { - return obj != null && typeof obj['@@transducer/step'] === 'function'; -} - -/** - * Returns a function that dispatches with different strategies based on the - * object in list position (last argument). If it is an array, executes [fn]. - * Otherwise, if it has a function with one of the given method names, it will - * execute that function (functor case). Otherwise, if it is a transformer, - * uses transducer [xf] to return a new transformer (transducer case). - * Otherwise, it will default to executing [fn]. - * - * @private - * @param {Array} methodNames properties to check for a custom implementation - * @param {Function} xf transducer to initialize if object is transformer - * @param {Function} fn default ramda implementation - * @return {Function} A function that dispatches on object in list position - */ -function _dispatchable(methodNames, xf, fn) { - return function() { - if (arguments.length === 0) { - return fn(); + + function _arity(n, fn) { + /* eslint-disable no-unused-vars */ + switch (n) { + case 0: return function() { return fn.apply(this, arguments); }; + case 1: return function(a0) { return fn.apply(this, arguments); }; + case 2: return function(a0, a1) { return fn.apply(this, arguments); }; + case 3: return function(a0, a1, a2) { return fn.apply(this, arguments); }; + case 4: return function(a0, a1, a2, a3) { return fn.apply(this, arguments); }; + case 5: return function(a0, a1, a2, a3, a4) { return fn.apply(this, arguments); }; + case 6: return function(a0, a1, a2, a3, a4, a5) { return fn.apply(this, arguments); }; + case 7: return function(a0, a1, a2, a3, a4, a5, a6) { return fn.apply(this, arguments); }; + case 8: return function(a0, a1, a2, a3, a4, a5, a6, a7) { return fn.apply(this, arguments); }; + case 9: return function(a0, a1, a2, a3, a4, a5, a6, a7, a8) { return fn.apply(this, arguments); }; + case 10: return function(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9) { return fn.apply(this, arguments); }; + default: throw new Error('First argument to _arity must be a non-negative integer no greater than ten'); } - var args = Array.prototype.slice.call(arguments, 0); - var obj = args.pop(); - if (!_isArray(obj)) { - var idx = 0; - while (idx < methodNames.length) { - if (typeof obj[methodNames[idx]] === 'function') { - return obj[methodNames[idx]].apply(obj, args); + } + + /** + * Internal curryN function. + * + * @private + * @category Function + * @param {Number} length The arity of the curried function. + * @param {Array} received An array of arguments received thus far. + * @param {Function} fn The function to curry. + * @return {Function} The curried function. + */ + function _curryN(length, received, fn) { + return function() { + var combined = []; + var argsIdx = 0; + var left = length; + var combinedIdx = 0; + while (combinedIdx < received.length || argsIdx < arguments.length) { + var result; + if (combinedIdx < received.length && + (!_isPlaceholder(received[combinedIdx]) || + argsIdx >= arguments.length)) { + result = received[combinedIdx]; + } else { + result = arguments[argsIdx]; + argsIdx += 1; } - idx += 1; - } - if (_isTransformer(obj)) { - var transducer = xf.apply(null, args); - return transducer(obj); + combined[combinedIdx] = result; + if (!_isPlaceholder(result)) { + left -= 1; + } + combinedIdx += 1; } - } - return fn.apply(this, arguments); - }; -} - -function _reduced(x) { - return x && x['@@transducer/reduced'] ? x : - { - '@@transducer/value': x, - '@@transducer/reduced': true + return left <= 0 + ? fn.apply(this, combined) + : _arity(left, _curryN(length, combined, fn)); }; -} - -var _xfBase = { - init: function() { - return this.xf['@@transducer/init'](); - }, - result: function(result) { - return this.xf['@@transducer/result'](result); } -}; - -function XAll(f, xf) { - this.xf = xf; - this.f = f; - this.all = true; -} -XAll.prototype['@@transducer/init'] = _xfBase.init; -XAll.prototype['@@transducer/result'] = function(result) { - if (this.all) { - result = this.xf['@@transducer/step'](result, true); - } - return this.xf['@@transducer/result'](result); -}; -XAll.prototype['@@transducer/step'] = function(result, input) { - if (!this.f(input)) { - this.all = false; - result = _reduced(this.xf['@@transducer/step'](result, false)); - } - return result; -}; - -var _xall = _curry2(function _xall(f, xf) { return new XAll(f, xf); }); - -/** - * Returns `true` if all elements of the list match the predicate, `false` if - * there are any that don't. - * - * Dispatches to the `all` method of the second argument, if present. - * - * Acts as a transducer if a transformer is given in list position. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category List - * @sig (a -> Boolean) -> [a] -> Boolean - * @param {Function} fn The predicate function. - * @param {Array} list The array to consider. - * @return {Boolean} `true` if the predicate is satisfied by every element, `false` - * otherwise. - * @see R.any, R.none, R.transduce - * @example - * - * const equals3 = R.equals(3); - * R.all(equals3)([3, 3, 3, 3]); //=> true - * R.all(equals3)([3, 3, 1, 3]); //=> false - */ -var all = _curry2(_dispatchable(['all'], _xall, function all(fn, list) { - var idx = 0; - while (idx < list.length) { - if (!fn(list[idx])) { - return false; + + /** + * Returns a curried equivalent of the provided function, with the specified + * arity. The curried function has two unusual capabilities. First, its + * arguments needn't be provided one at a time. If `g` is `R.curryN(3, f)`, the + * following are equivalent: + * + * - `g(1)(2)(3)` + * - `g(1)(2, 3)` + * - `g(1, 2)(3)` + * - `g(1, 2, 3)` + * + * Secondly, the special placeholder value [`R.__`](#__) may be used to specify + * "gaps", allowing partial application of any combination of arguments, + * regardless of their positions. If `g` is as above and `_` is [`R.__`](#__), + * the following are equivalent: + * + * - `g(1, 2, 3)` + * - `g(_, 2, 3)(1)` + * - `g(_, _, 3)(1)(2)` + * - `g(_, _, 3)(1, 2)` + * - `g(_, 2)(1)(3)` + * - `g(_, 2)(1, 3)` + * - `g(_, 2)(_, 3)(1)` + * + * @func + * @memberOf R + * @since v0.5.0 + * @category Function + * @sig Number -> (* -> a) -> (* -> a) + * @param {Number} length The arity for the returned function. + * @param {Function} fn The function to curry. + * @return {Function} A new, curried function. + * @see R.curry + * @example + * + * const sumArgs = (...args) => R.sum(args); + * + * const curriedAddFourNumbers = R.curryN(4, sumArgs); + * const f = curriedAddFourNumbers(1, 2); + * const g = f(3); + * g(4); //=> 10 + */ + var curryN = _curry2(function curryN(length, fn) { + if (length === 1) { + return _curry1(fn); } - idx += 1; - } - return true; -})); + return _arity(length, _curryN(length, [], fn)); + }); -/** - * Returns the larger of its two arguments. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Relation - * @sig Ord a => a -> a -> a - * @param {*} a - * @param {*} b - * @return {*} - * @see R.maxBy, R.min - * @example - * - * R.max(789, 123); //=> 789 - * R.max('a', 'b'); //=> 'b' - */ -var max = _curry2(function max(a, b) { return b > a ? b : a; }); - -function _map(fn, functor) { - var idx = 0; - var len = functor.length; - var result = Array(len); - while (idx < len) { - result[idx] = fn(functor[idx]); - idx += 1; - } - return result; -} - -function _isString(x) { - return Object.prototype.toString.call(x) === '[object String]'; -} - -/** - * Tests whether or not an object is similar to an array. - * - * @private - * @category Type - * @category List - * @sig * -> Boolean - * @param {*} x The object to test. - * @return {Boolean} `true` if `x` has a numeric length property and extreme indices defined; `false` otherwise. - * @example - * - * _isArrayLike([]); //=> true - * _isArrayLike(true); //=> false - * _isArrayLike({}); //=> false - * _isArrayLike({length: 10}); //=> false - * _isArrayLike({0: 'zero', 9: 'nine', length: 10}); //=> true - */ -var _isArrayLike = _curry1(function isArrayLike(x) { - if (_isArray(x)) { return true; } - if (!x) { return false; } - if (typeof x !== 'object') { return false; } - if (_isString(x)) { return false; } - if (x.nodeType === 1) { return !!x.length; } - if (x.length === 0) { return true; } - if (x.length > 0) { - return x.hasOwnProperty(0) && x.hasOwnProperty(x.length - 1); - } - return false; -}); - -function XWrap(fn) { - this.f = fn; -} -XWrap.prototype['@@transducer/init'] = function() { - throw new Error('init not implemented on XWrap'); -}; -XWrap.prototype['@@transducer/result'] = function(acc) { return acc; }; -XWrap.prototype['@@transducer/step'] = function(acc, x) { - return this.f(acc, x); -}; - -function _xwrap(fn) { return new XWrap(fn); } - -/** - * Creates a function that is bound to a context. - * Note: `R.bind` does not provide the additional argument-binding capabilities of - * [Function.prototype.bind](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind). - * - * @func - * @memberOf R - * @since v0.6.0 - * @category Function - * @category Object - * @sig (* -> *) -> {*} -> (* -> *) - * @param {Function} fn The function to bind to context - * @param {Object} thisObj The context to bind `fn` to - * @return {Function} A function that will execute in the context of `thisObj`. - * @see R.partial - * @example - * - * const log = R.bind(console.log, console); - * R.pipe(R.assoc('a', 2), R.tap(log), R.assoc('a', 3))({a: 1}); //=> {a: 3} - * // logs {a: 2} - * @symb R.bind(f, o)(a, b) = f.call(o, a, b) - */ -var bind = _curry2(function bind(fn, thisObj) { - return _arity(fn.length, function() { - return fn.apply(thisObj, arguments); - }); -}); - -function _arrayReduce(xf, acc, list) { - var idx = 0; - var len = list.length; - while (idx < len) { - acc = xf['@@transducer/step'](acc, list[idx]); - if (acc && acc['@@transducer/reduced']) { - acc = acc['@@transducer/value']; - break; - } - idx += 1; - } - return xf['@@transducer/result'](acc); -} - -function _iterableReduce(xf, acc, iter) { - var step = iter.next(); - while (!step.done) { - acc = xf['@@transducer/step'](acc, step.value); - if (acc && acc['@@transducer/reduced']) { - acc = acc['@@transducer/value']; - break; - } - step = iter.next(); + /** + * Creates a new list iteration function from an existing one by adding two new + * parameters to its callback function: the current index, and the entire list. + * + * This would turn, for instance, [`R.map`](#map) function into one that + * more closely resembles `Array.prototype.map`. Note that this will only work + * for functions in which the iteration callback function is the first + * parameter, and where the list is the last parameter. (This latter might be + * unimportant if the list parameter is not used.) + * + * @func + * @memberOf R + * @since v0.15.0 + * @category Function + * @category List + * @sig ((a ... -> b) ... -> [a] -> *) -> ((a ..., Int, [a] -> b) ... -> [a] -> *) + * @param {Function} fn A list iteration function that does not pass index or list to its callback + * @return {Function} An altered list iteration function that passes (item, index, list) to its callback + * @example + * + * const mapIndexed = R.addIndex(R.map); + * mapIndexed((val, idx) => idx + '-' + val, ['f', 'o', 'o', 'b', 'a', 'r']); + * //=> ['0-f', '1-o', '2-o', '3-b', '4-a', '5-r'] + */ + var addIndex = _curry1(function addIndex(fn) { + return curryN(fn.length, function() { + var idx = 0; + var origFn = arguments[0]; + var list = arguments[arguments.length - 1]; + var args = Array.prototype.slice.call(arguments, 0); + args[0] = function() { + var result = origFn.apply(this, _concat(arguments, [idx, list])); + idx += 1; + return result; + }; + return fn.apply(this, args); + }); + }); + + /** + * Optimized internal three-arity curry function. + * + * @private + * @category Function + * @param {Function} fn The function to curry. + * @return {Function} The curried function. + */ + function _curry3(fn) { + return function f3(a, b, c) { + switch (arguments.length) { + case 0: + return f3; + case 1: + return _isPlaceholder(a) + ? f3 + : _curry2(function(_b, _c) { return fn(a, _b, _c); }); + case 2: + return _isPlaceholder(a) && _isPlaceholder(b) + ? f3 + : _isPlaceholder(a) + ? _curry2(function(_a, _c) { return fn(_a, b, _c); }) + : _isPlaceholder(b) + ? _curry2(function(_b, _c) { return fn(a, _b, _c); }) + : _curry1(function(_c) { return fn(a, b, _c); }); + default: + return _isPlaceholder(a) && _isPlaceholder(b) && _isPlaceholder(c) + ? f3 + : _isPlaceholder(a) && _isPlaceholder(b) + ? _curry2(function(_a, _b) { return fn(_a, _b, c); }) + : _isPlaceholder(a) && _isPlaceholder(c) + ? _curry2(function(_a, _c) { return fn(_a, b, _c); }) + : _isPlaceholder(b) && _isPlaceholder(c) + ? _curry2(function(_b, _c) { return fn(a, _b, _c); }) + : _isPlaceholder(a) + ? _curry1(function(_a) { return fn(_a, b, c); }) + : _isPlaceholder(b) + ? _curry1(function(_b) { return fn(a, _b, c); }) + : _isPlaceholder(c) + ? _curry1(function(_c) { return fn(a, b, _c); }) + : fn(a, b, c); + } + }; } - return xf['@@transducer/result'](acc); -} -function _methodReduce(xf, acc, obj, methodName) { - return xf['@@transducer/result'](obj[methodName](bind(xf['@@transducer/step'], xf), acc)); -} + /** + * Applies a function to the value at the given index of an array, returning a + * new copy of the array with the element at the given index replaced with the + * result of the function application. + * + * @func + * @memberOf R + * @since v0.14.0 + * @category List + * @sig Number -> (a -> a) -> [a] -> [a] + * @param {Number} idx The index. + * @param {Function} fn The function to apply. + * @param {Array|Arguments} list An array-like object whose value + * at the supplied index will be replaced. + * @return {Array} A copy of the supplied array-like object with + * the element at index `idx` replaced with the value + * returned by applying `fn` to the existing element. + * @see R.update + * @example + * + * R.adjust(1, R.toUpper, ['a', 'b', 'c', 'd']); //=> ['a', 'B', 'c', 'd'] + * R.adjust(-1, R.toUpper, ['a', 'b', 'c', 'd']); //=> ['a', 'b', 'c', 'D'] + * @symb R.adjust(-1, f, [a, b]) = [a, f(b)] + * @symb R.adjust(0, f, [a, b]) = [f(a), b] + */ + var adjust = _curry3(function adjust(idx, fn, list) { + if (idx >= list.length || idx < -list.length) { + return list; + } + var start = idx < 0 ? list.length : 0; + var _idx = start + idx; + var _list = _concat(list); + _list[_idx] = fn(list[_idx]); + return _list; + }); -var symIterator = (typeof Symbol !== 'undefined') ? Symbol.iterator : '@@iterator'; + /** + * Tests whether or not an object is an array. + * + * @private + * @param {*} val The object to test. + * @return {Boolean} `true` if `val` is an array, `false` otherwise. + * @example + * + * _isArray([]); //=> true + * _isArray(null); //=> false + * _isArray({}); //=> false + */ + var _isArray = Array.isArray || function _isArray(val) { + return (val != null && + val.length >= 0 && + Object.prototype.toString.call(val) === '[object Array]'); + }; -function _reduce(fn, acc, list) { - if (typeof fn === 'function') { - fn = _xwrap(fn); - } - if (_isArrayLike(list)) { - return _arrayReduce(fn, acc, list); - } - if (typeof list['fantasy-land/reduce'] === 'function') { - return _methodReduce(fn, acc, list, 'fantasy-land/reduce'); - } - if (list[symIterator] != null) { - return _iterableReduce(fn, acc, list[symIterator]()); - } - if (typeof list.next === 'function') { - return _iterableReduce(fn, acc, list); + function _isTransformer(obj) { + return obj != null && typeof obj['@@transducer/step'] === 'function'; + } + + /** + * Returns a function that dispatches with different strategies based on the + * object in list position (last argument). If it is an array, executes [fn]. + * Otherwise, if it has a function with one of the given method names, it will + * execute that function (functor case). Otherwise, if it is a transformer, + * uses transducer [xf] to return a new transformer (transducer case). + * Otherwise, it will default to executing [fn]. + * + * @private + * @param {Array} methodNames properties to check for a custom implementation + * @param {Function} xf transducer to initialize if object is transformer + * @param {Function} fn default ramda implementation + * @return {Function} A function that dispatches on object in list position + */ + function _dispatchable(methodNames, xf, fn) { + return function() { + if (arguments.length === 0) { + return fn(); + } + var args = Array.prototype.slice.call(arguments, 0); + var obj = args.pop(); + if (!_isArray(obj)) { + var idx = 0; + while (idx < methodNames.length) { + if (typeof obj[methodNames[idx]] === 'function') { + return obj[methodNames[idx]].apply(obj, args); + } + idx += 1; + } + if (_isTransformer(obj)) { + var transducer = xf.apply(null, args); + return transducer(obj); + } + } + return fn.apply(this, arguments); + }; } - if (typeof list.reduce === 'function') { - return _methodReduce(fn, acc, list, 'reduce'); + + function _reduced(x) { + return x && x['@@transducer/reduced'] ? x : + { + '@@transducer/value': x, + '@@transducer/reduced': true + }; } - throw new TypeError('reduce: list must be array or iterable'); -} - -function XMap(f, xf) { - this.xf = xf; - this.f = f; -} -XMap.prototype['@@transducer/init'] = _xfBase.init; -XMap.prototype['@@transducer/result'] = _xfBase.result; -XMap.prototype['@@transducer/step'] = function(result, input) { - return this.xf['@@transducer/step'](result, this.f(input)); -}; - -var _xmap = _curry2(function _xmap(f, xf) { return new XMap(f, xf); }); - -function _has(prop, obj) { - return Object.prototype.hasOwnProperty.call(obj, prop); -} - -var toString = Object.prototype.toString; -var _isArguments = (function() { - return toString.call(arguments) === '[object Arguments]' ? - function _isArguments(x) { return toString.call(x) === '[object Arguments]'; } : - function _isArguments(x) { return _has('callee', x); }; -}()); - -// cover IE < 9 keys issues -var hasEnumBug = !({toString: null}).propertyIsEnumerable('toString'); -var nonEnumerableProps = ['constructor', 'valueOf', 'isPrototypeOf', 'toString', - 'propertyIsEnumerable', 'hasOwnProperty', 'toLocaleString']; -// Safari bug -var hasArgsEnumBug = (function() { - 'use strict'; - return arguments.propertyIsEnumerable('length'); -}()); - -var contains = function contains(list, item) { - var idx = 0; - while (idx < list.length) { - if (list[idx] === item) { - return true; + var _xfBase = { + init: function() { + return this.xf['@@transducer/init'](); + }, + result: function(result) { + return this.xf['@@transducer/result'](result); } - idx += 1; + }; + + function XAll(f, xf) { + this.xf = xf; + this.f = f; + this.all = true; } - return false; -}; - -/** - * Returns a list containing the names of all the enumerable own properties of - * the supplied object. - * Note that the order of the output array is not guaranteed to be consistent - * across different JS platforms. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Object - * @sig {k: v} -> [k] - * @param {Object} obj The object to extract properties from - * @return {Array} An array of the object's own properties. - * @see R.keysIn, R.values - * @example - * - * R.keys({a: 1, b: 2, c: 3}); //=> ['a', 'b', 'c'] - */ -var keys = typeof Object.keys === 'function' && !hasArgsEnumBug ? - _curry1(function keys(obj) { - return Object(obj) !== obj ? [] : Object.keys(obj); - }) : - _curry1(function keys(obj) { - if (Object(obj) !== obj) { - return []; - } - var prop, nIdx; - var ks = []; - var checkArgsLength = hasArgsEnumBug && _isArguments(obj); - for (prop in obj) { - if (_has(prop, obj) && (!checkArgsLength || prop !== 'length')) { - ks[ks.length] = prop; - } + XAll.prototype['@@transducer/init'] = _xfBase.init; + XAll.prototype['@@transducer/result'] = function(result) { + if (this.all) { + result = this.xf['@@transducer/step'](result, true); } - if (hasEnumBug) { - nIdx = nonEnumerableProps.length - 1; - while (nIdx >= 0) { - prop = nonEnumerableProps[nIdx]; - if (_has(prop, obj) && !contains(ks, prop)) { - ks[ks.length] = prop; - } - nIdx -= 1; - } + return this.xf['@@transducer/result'](result); + }; + XAll.prototype['@@transducer/step'] = function(result, input) { + if (!this.f(input)) { + this.all = false; + result = _reduced(this.xf['@@transducer/step'](result, false)); } - return ks; - }); - -/** - * Takes a function and - * a [functor](https://github.com/fantasyland/fantasy-land#functor), - * applies the function to each of the functor's values, and returns - * a functor of the same shape. - * - * Ramda provides suitable `map` implementations for `Array` and `Object`, - * so this function may be applied to `[1, 2, 3]` or `{x: 1, y: 2, z: 3}`. - * - * Dispatches to the `map` method of the second argument, if present. - * - * Acts as a transducer if a transformer is given in list position. - * - * Also treats functions as functors and will compose them together. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category List - * @sig Functor f => (a -> b) -> f a -> f b - * @param {Function} fn The function to be called on every element of the input `list`. - * @param {Array} list The list to be iterated over. - * @return {Array} The new list. - * @see R.transduce, R.addIndex - * @example - * - * const double = x => x * 2; - * - * R.map(double, [1, 2, 3]); //=> [2, 4, 6] - * - * R.map(double, {x: 1, y: 2, z: 3}); //=> {x: 2, y: 4, z: 6} - * @symb R.map(f, [a, b]) = [f(a), f(b)] - * @symb R.map(f, { x: a, y: b }) = { x: f(a), y: f(b) } - * @symb R.map(f, functor_o) = functor_o.map(f) - */ -var map = _curry2(_dispatchable(['fantasy-land/map', 'map'], _xmap, function map(fn, functor) { - switch (Object.prototype.toString.call(functor)) { - case '[object Function]': - return curryN(functor.length, function() { - return fn.call(this, functor.apply(this, arguments)); - }); - case '[object Object]': - return _reduce(function(acc, key) { - acc[key] = fn(functor[key]); - return acc; - }, {}, keys(functor)); - default: - return _map(fn, functor); - } -})); + return result; + }; -/** - * Retrieve the value at a given path. - * - * @func - * @memberOf R - * @since v0.2.0 - * @category Object - * @typedefn Idx = String | Int - * @sig [Idx] -> {a} -> a | Undefined - * @param {Array} path The path to use. - * @param {Object} obj The object to retrieve the nested property from. - * @return {*} The data at `path`. - * @see R.prop - * @example - * - * R.path(['a', 'b'], {a: {b: 2}}); //=> 2 - * R.path(['a', 'b'], {c: {b: 2}}); //=> undefined - */ -var path = _curry2(function path(paths, obj) { - var val = obj; - var idx = 0; - while (idx < paths.length) { - if (val == null) { - return; - } - val = val[paths[idx]]; - idx += 1; - } - return val; -}); - -/** - * Returns a function that when supplied an object returns the indicated - * property of that object, if it exists. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Object - * @sig s -> {s: a} -> a | Undefined - * @param {String} p The property name - * @param {Object} obj The object to query - * @return {*} The value at `obj.p`. - * @see R.path - * @example - * - * R.prop('x', {x: 100}); //=> 100 - * R.prop('x', {}); //=> undefined - * R.compose(R.inc, R.prop('x'))({ x: 3 }) //=> 4 - */ - -var prop = _curry2(function prop(p, obj) { return path([p], obj); }); - -/** - * Returns a new list by plucking the same named property off all objects in - * the list supplied. - * - * `pluck` will work on - * any [functor](https://github.com/fantasyland/fantasy-land#functor) in - * addition to arrays, as it is equivalent to `R.map(R.prop(k), f)`. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category List - * @sig Functor f => k -> f {k: v} -> f v - * @param {Number|String} key The key name to pluck off of each object. - * @param {Array} f The array or functor to consider. - * @return {Array} The list of values for the given key. - * @see R.props - * @example - * - * var getAges = R.pluck('age'); - * getAges([{name: 'fred', age: 29}, {name: 'wilma', age: 27}]); //=> [29, 27] - * - * R.pluck(0, [[1, 2], [3, 4]]); //=> [1, 3] - * R.pluck('val', {a: {val: 3}, b: {val: 5}}); //=> {a: 3, b: 5} - * @symb R.pluck('x', [{x: 1, y: 2}, {x: 3, y: 4}, {x: 5, y: 6}]) = [1, 3, 5] - * @symb R.pluck(0, [[1, 2], [3, 4], [5, 6]]) = [1, 3, 5] - */ -var pluck = _curry2(function pluck(p, list) { - return map(prop(p), list); -}); - -/** - * Returns a single item by iterating through the list, successively calling - * the iterator function and passing it an accumulator value and the current - * value from the array, and then passing the result to the next call. - * - * The iterator function receives two values: *(acc, value)*. It may use - * [`R.reduced`](#reduced) to shortcut the iteration. - * - * The arguments' order of [`reduceRight`](#reduceRight)'s iterator function - * is *(value, acc)*. - * - * Note: `R.reduce` does not skip deleted or unassigned indices (sparse - * arrays), unlike the native `Array.prototype.reduce` method. For more details - * on this behavior, see: - * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce#Description - * - * Dispatches to the `reduce` method of the third argument, if present. When - * doing so, it is up to the user to handle the [`R.reduced`](#reduced) - * shortcuting, as this is not implemented by `reduce`. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category List - * @sig ((a, b) -> a) -> a -> [b] -> a - * @param {Function} fn The iterator function. Receives two values, the accumulator and the - * current element from the array. - * @param {*} acc The accumulator value. - * @param {Array} list The list to iterate over. - * @return {*} The final, accumulated value. - * @see R.reduced, R.addIndex, R.reduceRight - * @example - * - * R.reduce(R.subtract, 0, [1, 2, 3, 4]) // => ((((0 - 1) - 2) - 3) - 4) = -10 - * // - -10 - * // / \ / \ - * // - 4 -6 4 - * // / \ / \ - * // - 3 ==> -3 3 - * // / \ / \ - * // - 2 -1 2 - * // / \ / \ - * // 0 1 0 1 - * - * @symb R.reduce(f, a, [b, c, d]) = f(f(f(a, b), c), d) - */ -var reduce = _curry3(_reduce); - -/** - * Takes a list of predicates and returns a predicate that returns true for a - * given list of arguments if every one of the provided predicates is satisfied - * by those arguments. - * - * The function returned is a curried function whose arity matches that of the - * highest-arity predicate. - * - * @func - * @memberOf R - * @since v0.9.0 - * @category Logic - * @sig [(*... -> Boolean)] -> (*... -> Boolean) - * @param {Array} predicates An array of predicates to check - * @return {Function} The combined predicate - * @see R.anyPass - * @example - * - * const isQueen = R.propEq('rank', 'Q'); - * const isSpade = R.propEq('suit', '♠︎'); - * const isQueenOfSpades = R.allPass([isQueen, isSpade]); - * - * isQueenOfSpades({rank: 'Q', suit: '♣︎'}); //=> false - * isQueenOfSpades({rank: 'Q', suit: '♠︎'}); //=> true - */ -var allPass = _curry1(function allPass(preds) { - return curryN(reduce(max, 0, pluck('length', preds)), function() { + var _xall = _curry2(function _xall(f, xf) { return new XAll(f, xf); }); + + /** + * Returns `true` if all elements of the list match the predicate, `false` if + * there are any that don't. + * + * Dispatches to the `all` method of the second argument, if present. + * + * Acts as a transducer if a transformer is given in list position. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category List + * @sig (a -> Boolean) -> [a] -> Boolean + * @param {Function} fn The predicate function. + * @param {Array} list The array to consider. + * @return {Boolean} `true` if the predicate is satisfied by every element, `false` + * otherwise. + * @see R.any, R.none, R.transduce + * @example + * + * const equals3 = R.equals(3); + * R.all(equals3)([3, 3, 3, 3]); //=> true + * R.all(equals3)([3, 3, 1, 3]); //=> false + */ + var all = _curry2(_dispatchable(['all'], _xall, function all(fn, list) { var idx = 0; - var len = preds.length; - while (idx < len) { - if (!preds[idx].apply(this, arguments)) { + while (idx < list.length) { + if (!fn(list[idx])) { return false; } idx += 1; } return true; - }); -}); - -/** - * Returns a function that always returns the given value. Note that for - * non-primitives the value returned is a reference to the original value. - * - * This function is known as `const`, `constant`, or `K` (for K combinator) in - * other languages and libraries. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Function - * @sig a -> (* -> a) - * @param {*} val The value to wrap in a function - * @return {Function} A Function :: * -> val. - * @example - * - * const t = R.always('Tee'); - * t(); //=> 'Tee' - */ -var always = _curry1(function always(val) { - return function() { - return val; - }; -}); - -/** - * Returns `true` if both arguments are `true`; `false` otherwise. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Logic - * @sig a -> b -> a | b - * @param {Any} a - * @param {Any} b - * @return {Any} the first argument if it is falsy, otherwise the second argument. - * @see R.both - * @example - * - * R.and(true, true); //=> true - * R.and(true, false); //=> false - * R.and(false, true); //=> false - * R.and(false, false); //=> false - */ -var and = _curry2(function and(a, b) { - return a && b; -}); - -function XAny(f, xf) { - this.xf = xf; - this.f = f; - this.any = false; -} -XAny.prototype['@@transducer/init'] = _xfBase.init; -XAny.prototype['@@transducer/result'] = function(result) { - if (!this.any) { - result = this.xf['@@transducer/step'](result, false); - } - return this.xf['@@transducer/result'](result); -}; -XAny.prototype['@@transducer/step'] = function(result, input) { - if (this.f(input)) { - this.any = true; - result = _reduced(this.xf['@@transducer/step'](result, true)); - } - return result; -}; - -var _xany = _curry2(function _xany(f, xf) { return new XAny(f, xf); }); - -/** - * Returns `true` if at least one of the elements of the list match the predicate, - * `false` otherwise. - * - * Dispatches to the `any` method of the second argument, if present. - * - * Acts as a transducer if a transformer is given in list position. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category List - * @sig (a -> Boolean) -> [a] -> Boolean - * @param {Function} fn The predicate function. - * @param {Array} list The array to consider. - * @return {Boolean} `true` if the predicate is satisfied by at least one element, `false` - * otherwise. - * @see R.all, R.none, R.transduce - * @example - * - * const lessThan0 = R.flip(R.lt)(0); - * const lessThan2 = R.flip(R.lt)(2); - * R.any(lessThan0)([1, 2]); //=> false - * R.any(lessThan2)([1, 2]); //=> true - */ -var any = _curry2(_dispatchable(['any'], _xany, function any(fn, list) { - var idx = 0; - while (idx < list.length) { - if (fn(list[idx])) { - return true; - } - idx += 1; - } - return false; -})); + })); -/** - * Takes a list of predicates and returns a predicate that returns true for a - * given list of arguments if at least one of the provided predicates is - * satisfied by those arguments. - * - * The function returned is a curried function whose arity matches that of the - * highest-arity predicate. - * - * @func - * @memberOf R - * @since v0.9.0 - * @category Logic - * @sig [(*... -> Boolean)] -> (*... -> Boolean) - * @param {Array} predicates An array of predicates to check - * @return {Function} The combined predicate - * @see R.allPass - * @example - * - * const isClub = R.propEq('suit', '♣'); - * const isSpade = R.propEq('suit', '♠'); - * const isBlackCard = R.anyPass([isClub, isSpade]); - * - * isBlackCard({rank: '10', suit: '♣'}); //=> true - * isBlackCard({rank: 'Q', suit: '♠'}); //=> true - * isBlackCard({rank: 'Q', suit: '♦'}); //=> false - */ -var anyPass = _curry1(function anyPass(preds) { - return curryN(reduce(max, 0, pluck('length', preds)), function() { + /** + * Returns the larger of its two arguments. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Relation + * @sig Ord a => a -> a -> a + * @param {*} a + * @param {*} b + * @return {*} + * @see R.maxBy, R.min + * @example + * + * R.max(789, 123); //=> 789 + * R.max('a', 'b'); //=> 'b' + */ + var max = _curry2(function max(a, b) { return b > a ? b : a; }); + + function _map(fn, functor) { var idx = 0; - var len = preds.length; + var len = functor.length; + var result = Array(len); while (idx < len) { - if (preds[idx].apply(this, arguments)) { - return true; - } + result[idx] = fn(functor[idx]); idx += 1; } + return result; + } + + function _isString(x) { + return Object.prototype.toString.call(x) === '[object String]'; + } + + /** + * Tests whether or not an object is similar to an array. + * + * @private + * @category Type + * @category List + * @sig * -> Boolean + * @param {*} x The object to test. + * @return {Boolean} `true` if `x` has a numeric length property and extreme indices defined; `false` otherwise. + * @example + * + * _isArrayLike([]); //=> true + * _isArrayLike(true); //=> false + * _isArrayLike({}); //=> false + * _isArrayLike({length: 10}); //=> false + * _isArrayLike({0: 'zero', 9: 'nine', length: 10}); //=> true + */ + var _isArrayLike = _curry1(function isArrayLike(x) { + if (_isArray(x)) { return true; } + if (!x) { return false; } + if (typeof x !== 'object') { return false; } + if (_isString(x)) { return false; } + if (x.nodeType === 1) { return !!x.length; } + if (x.length === 0) { return true; } + if (x.length > 0) { + return x.hasOwnProperty(0) && x.hasOwnProperty(x.length - 1); + } return false; }); -}); - -/** - * ap applies a list of functions to a list of values. - * - * Dispatches to the `ap` method of the second argument, if present. Also - * treats curried functions as applicatives. - * - * @func - * @memberOf R - * @since v0.3.0 - * @category Function - * @sig [a -> b] -> [a] -> [b] - * @sig Apply f => f (a -> b) -> f a -> f b - * @sig (r -> a -> b) -> (r -> a) -> (r -> b) - * @param {*} applyF - * @param {*} applyX - * @return {*} - * @example - * - * R.ap([R.multiply(2), R.add(3)], [1,2,3]); //=> [2, 4, 6, 4, 5, 6] - * R.ap([R.concat('tasty '), R.toUpper], ['pizza', 'salad']); //=> ["tasty pizza", "tasty salad", "PIZZA", "SALAD"] - * - * // R.ap can also be used as S combinator - * // when only two functions are passed - * R.ap(R.concat, R.toUpper)('Ramda') //=> 'RamdaRAMDA' - * @symb R.ap([f, g], [a, b]) = [f(a), f(b), g(a), g(b)] - */ -var ap = _curry2(function ap(applyF, applyX) { - return ( - typeof applyX['fantasy-land/ap'] === 'function' ? - applyX['fantasy-land/ap'](applyF) : - typeof applyF.ap === 'function' ? - applyF.ap(applyX) : - typeof applyF === 'function' ? - function(x) { return applyF(x)(applyX(x)); } : - // else - _reduce(function(acc, f) { return _concat(acc, map(f, applyX)); }, [], applyF) - ); -}); - -function _aperture(n, list) { - var idx = 0; - var limit = list.length - (n - 1); - var acc = new Array(limit >= 0 ? limit : 0); - while (idx < limit) { - acc[idx] = Array.prototype.slice.call(list, idx, idx + n); - idx += 1; - } - return acc; -} - -function XAperture(n, xf) { - this.xf = xf; - this.pos = 0; - this.full = false; - this.acc = new Array(n); -} -XAperture.prototype['@@transducer/init'] = _xfBase.init; -XAperture.prototype['@@transducer/result'] = function(result) { - this.acc = null; - return this.xf['@@transducer/result'](result); -}; -XAperture.prototype['@@transducer/step'] = function(result, input) { - this.store(input); - return this.full ? this.xf['@@transducer/step'](result, this.getCopy()) : result; -}; -XAperture.prototype.store = function(input) { - this.acc[this.pos] = input; - this.pos += 1; - if (this.pos === this.acc.length) { - this.pos = 0; - this.full = true; - } -}; -XAperture.prototype.getCopy = function() { - return _concat(Array.prototype.slice.call(this.acc, this.pos), - Array.prototype.slice.call(this.acc, 0, this.pos)); -}; - -var _xaperture = _curry2(function _xaperture(n, xf) { return new XAperture(n, xf); }); - -/** - * Returns a new list, composed of n-tuples of consecutive elements. If `n` is - * greater than the length of the list, an empty list is returned. - * - * Acts as a transducer if a transformer is given in list position. - * - * @func - * @memberOf R - * @since v0.12.0 - * @category List - * @sig Number -> [a] -> [[a]] - * @param {Number} n The size of the tuples to create - * @param {Array} list The list to split into `n`-length tuples - * @return {Array} The resulting list of `n`-length tuples - * @see R.transduce - * @example - * - * R.aperture(2, [1, 2, 3, 4, 5]); //=> [[1, 2], [2, 3], [3, 4], [4, 5]] - * R.aperture(3, [1, 2, 3, 4, 5]); //=> [[1, 2, 3], [2, 3, 4], [3, 4, 5]] - * R.aperture(7, [1, 2, 3, 4, 5]); //=> [] - */ -var aperture = _curry2(_dispatchable([], _xaperture, _aperture)); - -/** - * Returns a new list containing the contents of the given list, followed by - * the given element. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category List - * @sig a -> [a] -> [a] - * @param {*} el The element to add to the end of the new list. - * @param {Array} list The list of elements to add a new item to. - * list. - * @return {Array} A new list containing the elements of the old list followed by `el`. - * @see R.prepend - * @example - * - * R.append('tests', ['write', 'more']); //=> ['write', 'more', 'tests'] - * R.append('tests', []); //=> ['tests'] - * R.append(['tests'], ['write', 'more']); //=> ['write', 'more', ['tests']] - */ -var append = _curry2(function append(el, list) { - return _concat(list, [el]); -}); - -/** - * Applies function `fn` to the argument list `args`. This is useful for - * creating a fixed-arity function from a variadic function. `fn` should be a - * bound function if context is significant. - * - * @func - * @memberOf R - * @since v0.7.0 - * @category Function - * @sig (*... -> a) -> [*] -> a - * @param {Function} fn The function which will be called with `args` - * @param {Array} args The arguments to call `fn` with - * @return {*} result The result, equivalent to `fn(...args)` - * @see R.call, R.unapply - * @example - * - * const nums = [1, 2, 3, -99, 42, 6, 7]; - * R.apply(Math.max, nums); //=> 42 - * @symb R.apply(f, [a, b, c]) = f(a, b, c) - */ -var apply = _curry2(function apply(fn, args) { - return fn.apply(this, args); -}); - -/** - * Returns a list of all the enumerable own properties of the supplied object. - * Note that the order of the output array is not guaranteed across different - * JS platforms. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Object - * @sig {k: v} -> [v] - * @param {Object} obj The object to extract values from - * @return {Array} An array of the values of the object's own properties. - * @see R.valuesIn, R.keys - * @example - * - * R.values({a: 1, b: 2, c: 3}); //=> [1, 2, 3] - */ -var values = _curry1(function values(obj) { - var props = keys(obj); - var len = props.length; - var vals = []; - var idx = 0; - while (idx < len) { - vals[idx] = obj[props[idx]]; - idx += 1; - } - return vals; -}); - -// Use custom mapValues function to avoid issues with specs that include a "map" key and R.map -// delegating calls to .map -function mapValues(fn, obj) { - return keys(obj).reduce(function(acc, key) { - acc[key] = fn(obj[key]); - return acc; - }, {}); -} - -/** - * Given a spec object recursively mapping properties to functions, creates a - * function producing an object of the same structure, by mapping each property - * to the result of calling its associated function with the supplied arguments. - * - * @func - * @memberOf R - * @since v0.20.0 - * @category Function - * @sig {k: ((a, b, ..., m) -> v)} -> ((a, b, ..., m) -> {k: v}) - * @param {Object} spec an object recursively mapping properties to functions for - * producing the values for these properties. - * @return {Function} A function that returns an object of the same structure - * as `spec', with each property set to the value returned by calling its - * associated function with the supplied arguments. - * @see R.converge, R.juxt - * @example - * - * const getMetrics = R.applySpec({ - * sum: R.add, - * nested: { mul: R.multiply } - * }); - * getMetrics(2, 4); // => { sum: 6, nested: { mul: 8 } } - * @symb R.applySpec({ x: f, y: { z: g } })(a, b) = { x: f(a, b), y: { z: g(a, b) } } - */ -var applySpec = _curry1(function applySpec(spec) { - spec = mapValues( - function(v) { return typeof v == 'function' ? v : applySpec(v); }, - spec - ); - return curryN( - reduce(max, 0, pluck('length', values(spec))), - function() { - var args = arguments; - return mapValues(function(f) { return apply(f, args); }, spec); - }); -}); - -/** - * Takes a value and applies a function to it. - * - * This function is also known as the `thrush` combinator. - * - * @func - * @memberOf R - * @since v0.25.0 - * @category Function - * @sig a -> (a -> b) -> b - * @param {*} x The value - * @param {Function} f The function to apply - * @return {*} The result of applying `f` to `x` - * @example - * - * const t42 = R.applyTo(42); - * t42(R.identity); //=> 42 - * t42(R.add(1)); //=> 43 - */ -var applyTo = _curry2(function applyTo(x, f) { return f(x); }); - -/** - * Makes an ascending comparator function out of a function that returns a value - * that can be compared with `<` and `>`. - * - * @func - * @memberOf R - * @since v0.23.0 - * @category Function - * @sig Ord b => (a -> b) -> a -> a -> Number - * @param {Function} fn A function of arity one that returns a value that can be compared - * @param {*} a The first item to be compared. - * @param {*} b The second item to be compared. - * @return {Number} `-1` if fn(a) < fn(b), `1` if fn(b) < fn(a), otherwise `0` - * @see R.descend - * @example - * - * const byAge = R.ascend(R.prop('age')); - * const people = [ - * { name: 'Emma', age: 70 }, - * { name: 'Peter', age: 78 }, - * { name: 'Mikhail', age: 62 }, - * ]; - * const peopleByYoungestFirst = R.sort(byAge, people); - * //=> [{ name: 'Mikhail', age: 62 },{ name: 'Emma', age: 70 }, { name: 'Peter', age: 78 }] - */ -var ascend = _curry3(function ascend(fn, a, b) { - var aa = fn(a); - var bb = fn(b); - return aa < bb ? -1 : aa > bb ? 1 : 0; -}); - -/** - * Makes a shallow clone of an object, setting or overriding the specified - * property with the given value. Note that this copies and flattens prototype - * properties onto the new object as well. All non-primitive properties are - * copied by reference. - * - * @func - * @memberOf R - * @since v0.8.0 - * @category Object - * @sig String -> a -> {k: v} -> {k: v} - * @param {String} prop The property name to set - * @param {*} val The new value - * @param {Object} obj The object to clone - * @return {Object} A new object equivalent to the original except for the changed property. - * @see R.dissoc, R.pick - * @example - * - * R.assoc('c', 3, {a: 1, b: 2}); //=> {a: 1, b: 2, c: 3} - */ -var assoc = _curry3(function assoc(prop, val, obj) { - var result = {}; - for (var p in obj) { - result[p] = obj[p]; - } - result[prop] = val; - return result; -}); - -/** - * Determine if the passed argument is an integer. - * - * @private - * @param {*} n - * @category Type - * @return {Boolean} - */ -var _isInteger = Number.isInteger || function _isInteger(n) { - return (n << 0) === n; -}; - -/** - * Checks if the input value is `null` or `undefined`. - * - * @func - * @memberOf R - * @since v0.9.0 - * @category Type - * @sig * -> Boolean - * @param {*} x The value to test. - * @return {Boolean} `true` if `x` is `undefined` or `null`, otherwise `false`. - * @example - * - * R.isNil(null); //=> true - * R.isNil(undefined); //=> true - * R.isNil(0); //=> false - * R.isNil([]); //=> false - */ -var isNil = _curry1(function isNil(x) { return x == null; }); - -/** - * Makes a shallow clone of an object, setting or overriding the nodes required - * to create the given path, and placing the specific value at the tail end of - * that path. Note that this copies and flattens prototype properties onto the - * new object as well. All non-primitive properties are copied by reference. - * - * @func - * @memberOf R - * @since v0.8.0 - * @category Object - * @typedefn Idx = String | Int - * @sig [Idx] -> a -> {a} -> {a} - * @param {Array} path the path to set - * @param {*} val The new value - * @param {Object} obj The object to clone - * @return {Object} A new object equivalent to the original except along the specified path. - * @see R.dissocPath - * @example - * - * R.assocPath(['a', 'b', 'c'], 42, {a: {b: {c: 0}}}); //=> {a: {b: {c: 42}}} - * - * // Any missing or non-object keys in path will be overridden - * R.assocPath(['a', 'b', 'c'], 42, {a: 5}); //=> {a: {b: {c: 42}}} - */ -var assocPath = _curry3(function assocPath(path, val, obj) { - if (path.length === 0) { - return val; - } - var idx = path[0]; - if (path.length > 1) { - var nextObj = (!isNil(obj) && _has(idx, obj)) ? obj[idx] : _isInteger(path[1]) ? [] : {}; - val = assocPath(Array.prototype.slice.call(path, 1), val, nextObj); - } - if (_isInteger(idx) && _isArray(obj)) { - var arr = [].concat(obj); - arr[idx] = val; - return arr; - } else { - return assoc(idx, val, obj); + function XWrap(fn) { + this.f = fn; } -}); - -/** - * Wraps a function of any arity (including nullary) in a function that accepts - * exactly `n` parameters. Any extraneous parameters will not be passed to the - * supplied function. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Function - * @sig Number -> (* -> a) -> (* -> a) - * @param {Number} n The desired arity of the new function. - * @param {Function} fn The function to wrap. - * @return {Function} A new function wrapping `fn`. The new function is guaranteed to be of - * arity `n`. - * @see R.binary, R.unary - * @example - * - * const takesTwoArgs = (a, b) => [a, b]; - * - * takesTwoArgs.length; //=> 2 - * takesTwoArgs(1, 2); //=> [1, 2] - * - * const takesOneArg = R.nAry(1, takesTwoArgs); - * takesOneArg.length; //=> 1 - * // Only `n` arguments are passed to the wrapped function - * takesOneArg(1, 2); //=> [1, undefined] - * @symb R.nAry(0, f)(a, b) = f() - * @symb R.nAry(1, f)(a, b) = f(a) - * @symb R.nAry(2, f)(a, b) = f(a, b) - */ -var nAry = _curry2(function nAry(n, fn) { - switch (n) { - case 0: return function() {return fn.call(this);}; - case 1: return function(a0) {return fn.call(this, a0);}; - case 2: return function(a0, a1) {return fn.call(this, a0, a1);}; - case 3: return function(a0, a1, a2) {return fn.call(this, a0, a1, a2);}; - case 4: return function(a0, a1, a2, a3) {return fn.call(this, a0, a1, a2, a3);}; - case 5: return function(a0, a1, a2, a3, a4) {return fn.call(this, a0, a1, a2, a3, a4);}; - case 6: return function(a0, a1, a2, a3, a4, a5) {return fn.call(this, a0, a1, a2, a3, a4, a5);}; - case 7: return function(a0, a1, a2, a3, a4, a5, a6) {return fn.call(this, a0, a1, a2, a3, a4, a5, a6);}; - case 8: return function(a0, a1, a2, a3, a4, a5, a6, a7) {return fn.call(this, a0, a1, a2, a3, a4, a5, a6, a7);}; - case 9: return function(a0, a1, a2, a3, a4, a5, a6, a7, a8) {return fn.call(this, a0, a1, a2, a3, a4, a5, a6, a7, a8);}; - case 10: return function(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9) {return fn.call(this, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9);}; - default: throw new Error('First argument to nAry must be a non-negative integer no greater than ten'); - } -}); - -/** - * Wraps a function of any arity (including nullary) in a function that accepts - * exactly 2 parameters. Any extraneous parameters will not be passed to the - * supplied function. - * - * @func - * @memberOf R - * @since v0.2.0 - * @category Function - * @sig (* -> c) -> (a, b -> c) - * @param {Function} fn The function to wrap. - * @return {Function} A new function wrapping `fn`. The new function is guaranteed to be of - * arity 2. - * @see R.nAry, R.unary - * @example - * - * const takesThreeArgs = function(a, b, c) { - * return [a, b, c]; - * }; - * takesThreeArgs.length; //=> 3 - * takesThreeArgs(1, 2, 3); //=> [1, 2, 3] - * - * const takesTwoArgs = R.binary(takesThreeArgs); - * takesTwoArgs.length; //=> 2 - * // Only 2 arguments are passed to the wrapped function - * takesTwoArgs(1, 2, 3); //=> [1, 2, undefined] - * @symb R.binary(f)(a, b, c) = f(a, b) - */ -var binary = _curry1(function binary(fn) { - return nAry(2, fn); -}); - -function _isFunction(x) { - return Object.prototype.toString.call(x) === '[object Function]'; -} - -/** - * "lifts" a function to be the specified arity, so that it may "map over" that - * many lists, Functions or other objects that satisfy the [FantasyLand Apply spec](https://github.com/fantasyland/fantasy-land#apply). - * - * @func - * @memberOf R - * @since v0.7.0 - * @category Function - * @sig Number -> (*... -> *) -> ([*]... -> [*]) - * @param {Function} fn The function to lift into higher context - * @return {Function} The lifted function. - * @see R.lift, R.ap - * @example - * - * const madd3 = R.liftN(3, (...args) => R.sum(args)); - * madd3([1,2,3], [1,2,3], [1]); //=> [3, 4, 5, 4, 5, 6, 5, 6, 7] - */ -var liftN = _curry2(function liftN(arity, fn) { - var lifted = curryN(arity, fn); - return curryN(arity, function() { - return _reduce(ap, map(lifted, arguments[0]), Array.prototype.slice.call(arguments, 1)); - }); -}); - -/** - * "lifts" a function of arity > 1 so that it may "map over" a list, Function or other - * object that satisfies the [FantasyLand Apply spec](https://github.com/fantasyland/fantasy-land#apply). - * - * @func - * @memberOf R - * @since v0.7.0 - * @category Function - * @sig (*... -> *) -> ([*]... -> [*]) - * @param {Function} fn The function to lift into higher context - * @return {Function} The lifted function. - * @see R.liftN - * @example - * - * const madd3 = R.lift((a, b, c) => a + b + c); - * - * madd3([1,2,3], [1,2,3], [1]); //=> [3, 4, 5, 4, 5, 6, 5, 6, 7] - * - * const madd5 = R.lift((a, b, c, d, e) => a + b + c + d + e); - * - * madd5([1,2], [3], [4, 5], [6], [7, 8]); //=> [21, 22, 22, 23, 22, 23, 23, 24] - */ -var lift = _curry1(function lift(fn) { - return liftN(fn.length, fn); -}); - -/** - * A function which calls the two provided functions and returns the `&&` - * of the results. - * It returns the result of the first function if it is false-y and the result - * of the second function otherwise. Note that this is short-circuited, - * meaning that the second function will not be invoked if the first returns a - * false-y value. - * - * In addition to functions, `R.both` also accepts any fantasy-land compatible - * applicative functor. - * - * @func - * @memberOf R - * @since v0.12.0 - * @category Logic - * @sig (*... -> Boolean) -> (*... -> Boolean) -> (*... -> Boolean) - * @param {Function} f A predicate - * @param {Function} g Another predicate - * @return {Function} a function that applies its arguments to `f` and `g` and `&&`s their outputs together. - * @see R.and - * @example - * - * const gt10 = R.gt(R.__, 10) - * const lt20 = R.lt(R.__, 20) - * const f = R.both(gt10, lt20); - * f(15); //=> true - * f(30); //=> false - * - * R.both(Maybe.Just(false), Maybe.Just(55)); // => Maybe.Just(false) - * R.both([false, false, 'a'], [11]); //=> [false, false, 11] - */ -var both = _curry2(function both(f, g) { - return _isFunction(f) ? - function _both() { - return f.apply(this, arguments) && g.apply(this, arguments); - } : - lift(and)(f, g); -}); - -/** - * Returns a curried equivalent of the provided function. The curried function - * has two unusual capabilities. First, its arguments needn't be provided one - * at a time. If `f` is a ternary function and `g` is `R.curry(f)`, the - * following are equivalent: - * - * - `g(1)(2)(3)` - * - `g(1)(2, 3)` - * - `g(1, 2)(3)` - * - `g(1, 2, 3)` - * - * Secondly, the special placeholder value [`R.__`](#__) may be used to specify - * "gaps", allowing partial application of any combination of arguments, - * regardless of their positions. If `g` is as above and `_` is [`R.__`](#__), - * the following are equivalent: - * - * - `g(1, 2, 3)` - * - `g(_, 2, 3)(1)` - * - `g(_, _, 3)(1)(2)` - * - `g(_, _, 3)(1, 2)` - * - `g(_, 2)(1)(3)` - * - `g(_, 2)(1, 3)` - * - `g(_, 2)(_, 3)(1)` - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Function - * @sig (* -> a) -> (* -> a) - * @param {Function} fn The function to curry. - * @return {Function} A new, curried function. - * @see R.curryN, R.partial - * @example - * - * const addFourNumbers = (a, b, c, d) => a + b + c + d; - * - * const curriedAddFourNumbers = R.curry(addFourNumbers); - * const f = curriedAddFourNumbers(1, 2); - * const g = f(3); - * g(4); //=> 10 - */ -var curry = _curry1(function curry(fn) { - return curryN(fn.length, fn); -}); - -/** - * Returns the result of calling its first argument with the remaining - * arguments. This is occasionally useful as a converging function for - * [`R.converge`](#converge): the first branch can produce a function while the - * remaining branches produce values to be passed to that function as its - * arguments. - * - * @func - * @memberOf R - * @since v0.9.0 - * @category Function - * @sig (*... -> a),*... -> a - * @param {Function} fn The function to apply to the remaining arguments. - * @param {...*} args Any number of positional arguments. - * @return {*} - * @see R.apply - * @example - * - * R.call(R.add, 1, 2); //=> 3 - * - * const indentN = R.pipe(R.repeat(' '), - * R.join(''), - * R.replace(/^(?!$)/gm)); - * - * const format = R.converge(R.call, [ - * R.pipe(R.prop('indent'), indentN), - * R.prop('value') - * ]); - * - * format({indent: 2, value: 'foo\nbar\nbaz\n'}); //=> ' foo\n bar\n baz\n' - * @symb R.call(f, a, b) = f(a, b) - */ -var call = curry(function call(fn) { - return fn.apply(this, Array.prototype.slice.call(arguments, 1)); -}); - -/** - * `_makeFlat` is a helper function that returns a one-level or fully recursive - * function based on the flag passed in. - * - * @private - */ -function _makeFlat(recursive) { - return function flatt(list) { - var value, jlen, j; - var result = []; - var idx = 0; - var ilen = list.length; - - while (idx < ilen) { - if (_isArrayLike(list[idx])) { - value = recursive ? flatt(list[idx]) : list[idx]; - j = 0; - jlen = value.length; - while (j < jlen) { - result[result.length] = value[j]; - j += 1; - } - } else { - result[result.length] = list[idx]; - } - idx += 1; - } - return result; + XWrap.prototype['@@transducer/init'] = function() { + throw new Error('init not implemented on XWrap'); }; -} - -function _forceReduced(x) { - return { - '@@transducer/value': x, - '@@transducer/reduced': true + XWrap.prototype['@@transducer/result'] = function(acc) { return acc; }; + XWrap.prototype['@@transducer/step'] = function(acc, x) { + return this.f(acc, x); }; -} -var preservingReduced = function(xf) { - return { - '@@transducer/init': _xfBase.init, - '@@transducer/result': function(result) { - return xf['@@transducer/result'](result); - }, - '@@transducer/step': function(result, input) { - var ret = xf['@@transducer/step'](result, input); - return ret['@@transducer/reduced'] ? _forceReduced(ret) : ret; - } - }; -}; - -var _flatCat = function _xcat(xf) { - var rxf = preservingReduced(xf); - return { - '@@transducer/init': _xfBase.init, - '@@transducer/result': function(result) { - return rxf['@@transducer/result'](result); - }, - '@@transducer/step': function(result, input) { - return !_isArrayLike(input) ? _reduce(rxf, result, [input]) : _reduce(rxf, result, input); - } - }; -}; - -var _xchain = _curry2(function _xchain(f, xf) { - return map(f, _flatCat(xf)); -}); - -/** - * `chain` maps a function over a list and concatenates the results. `chain` - * is also known as `flatMap` in some libraries. - * - * Dispatches to the `chain` method of the second argument, if present, - * according to the [FantasyLand Chain spec](https://github.com/fantasyland/fantasy-land#chain). - * - * If second argument is a function, `chain(f, g)(x)` is equivalent to `f(g(x), x)`. - * - * Acts as a transducer if a transformer is given in list position. - * - * @func - * @memberOf R - * @since v0.3.0 - * @category List - * @sig Chain m => (a -> m b) -> m a -> m b - * @param {Function} fn The function to map with - * @param {Array} list The list to map over - * @return {Array} The result of flat-mapping `list` with `fn` - * @example - * - * const duplicate = n => [n, n]; - * R.chain(duplicate, [1, 2, 3]); //=> [1, 1, 2, 2, 3, 3] - * - * R.chain(R.append, R.head)([1, 2, 3]); //=> [1, 2, 3, 1] - */ -var chain = _curry2(_dispatchable(['fantasy-land/chain', 'chain'], _xchain, function chain(fn, monad) { - if (typeof monad === 'function') { - return function(x) { return fn(monad(x))(x); }; - } - return _makeFlat(false)(map(fn, monad)); -})); + function _xwrap(fn) { return new XWrap(fn); } + + /** + * Creates a function that is bound to a context. + * Note: `R.bind` does not provide the additional argument-binding capabilities of + * [Function.prototype.bind](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/bind). + * + * @func + * @memberOf R + * @since v0.6.0 + * @category Function + * @category Object + * @sig (* -> *) -> {*} -> (* -> *) + * @param {Function} fn The function to bind to context + * @param {Object} thisObj The context to bind `fn` to + * @return {Function} A function that will execute in the context of `thisObj`. + * @see R.partial + * @example + * + * const log = R.bind(console.log, console); + * R.pipe(R.assoc('a', 2), R.tap(log), R.assoc('a', 3))({a: 1}); //=> {a: 3} + * // logs {a: 2} + * @symb R.bind(f, o)(a, b) = f.call(o, a, b) + */ + var bind = _curry2(function bind(fn, thisObj) { + return _arity(fn.length, function() { + return fn.apply(thisObj, arguments); + }); + }); -/** - * Restricts a number to be within a range. - * - * Also works for other ordered types such as Strings and Dates. - * - * @func - * @memberOf R - * @since v0.20.0 - * @category Relation - * @sig Ord a => a -> a -> a -> a - * @param {Number} minimum The lower limit of the clamp (inclusive) - * @param {Number} maximum The upper limit of the clamp (inclusive) - * @param {Number} value Value to be clamped - * @return {Number} Returns `minimum` when `val < minimum`, `maximum` when `val > maximum`, returns `val` otherwise - * @example - * - * R.clamp(1, 10, -5) // => 1 - * R.clamp(1, 10, 15) // => 10 - * R.clamp(1, 10, 4) // => 4 - */ -var clamp = _curry3(function clamp(min, max, value) { - if (min > max) { - throw new Error('min must not be greater than max in clamp(min, max, value)'); - } - return value < min ? min : - value > max ? max : - value; -}); - -function _cloneRegExp(pattern) { - return new RegExp(pattern.source, (pattern.global ? 'g' : '') + - (pattern.ignoreCase ? 'i' : '') + - (pattern.multiline ? 'm' : '') + - (pattern.sticky ? 'y' : '') + - (pattern.unicode ? 'u' : '')); -} - -/** - * Gives a single-word string description of the (native) type of a value, - * returning such answers as 'Object', 'Number', 'Array', or 'Null'. Does not - * attempt to distinguish user Object types any further, reporting them all as - * 'Object'. - * - * @func - * @memberOf R - * @since v0.8.0 - * @category Type - * @sig (* -> {*}) -> String - * @param {*} val The value to test - * @return {String} - * @example - * - * R.type({}); //=> "Object" - * R.type(1); //=> "Number" - * R.type(false); //=> "Boolean" - * R.type('s'); //=> "String" - * R.type(null); //=> "Null" - * R.type([]); //=> "Array" - * R.type(/[A-z]/); //=> "RegExp" - * R.type(() => {}); //=> "Function" - * R.type(undefined); //=> "Undefined" - */ -var type = _curry1(function type(val) { - return val === null ? 'Null' : - val === undefined ? 'Undefined' : - Object.prototype.toString.call(val).slice(8, -1); -}); - -/** - * Copies an object. - * - * @private - * @param {*} value The value to be copied - * @param {Array} refFrom Array containing the source references - * @param {Array} refTo Array containing the copied source references - * @param {Boolean} deep Whether or not to perform deep cloning. - * @return {*} The copied value. - */ -function _clone(value, refFrom, refTo, deep) { - var copy = function copy(copiedValue) { - var len = refFrom.length; + function _arrayReduce(xf, acc, list) { var idx = 0; + var len = list.length; while (idx < len) { - if (value === refFrom[idx]) { - return refTo[idx]; + acc = xf['@@transducer/step'](acc, list[idx]); + if (acc && acc['@@transducer/reduced']) { + acc = acc['@@transducer/value']; + break; } idx += 1; } - refFrom[idx + 1] = value; - refTo[idx + 1] = copiedValue; - for (var key in value) { - copiedValue[key] = deep ? - _clone(value[key], refFrom, refTo, true) : value[key]; - } - return copiedValue; - }; - switch (type(value)) { - case 'Object': return copy({}); - case 'Array': return copy([]); - case 'Date': return new Date(value.valueOf()); - case 'RegExp': return _cloneRegExp(value); - default: return value; + return xf['@@transducer/result'](acc); } -} - -/** - * Creates a deep copy of the value which may contain (nested) `Array`s and - * `Object`s, `Number`s, `String`s, `Boolean`s and `Date`s. `Function`s are - * assigned by reference rather than copied - * - * Dispatches to a `clone` method if present. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Object - * @sig {*} -> {*} - * @param {*} value The object or array to clone - * @return {*} A deeply cloned copy of `val` - * @example - * - * const objects = [{}, {}, {}]; - * const objectsClone = R.clone(objects); - * objects === objectsClone; //=> false - * objects[0] === objectsClone[0]; //=> false - */ -var clone = _curry1(function clone(value) { - return value != null && typeof value.clone === 'function' ? - value.clone() : - _clone(value, [], [], true); -}); - -/** - * Makes a comparator function out of a function that reports whether the first - * element is less than the second. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Function - * @sig ((a, b) -> Boolean) -> ((a, b) -> Number) - * @param {Function} pred A predicate function of arity two which will return `true` if the first argument - * is less than the second, `false` otherwise - * @return {Function} A Function :: a -> b -> Int that returns `-1` if a < b, `1` if b < a, otherwise `0` - * @example - * - * const byAge = R.comparator((a, b) => a.age < b.age); - * const people = [ - * { name: 'Emma', age: 70 }, - * { name: 'Peter', age: 78 }, - * { name: 'Mikhail', age: 62 }, - * ]; - * const peopleByIncreasingAge = R.sort(byAge, people); - * //=> [{ name: 'Mikhail', age: 62 },{ name: 'Emma', age: 70 }, { name: 'Peter', age: 78 }] - */ -var comparator = _curry1(function comparator(pred) { - return function(a, b) { - return pred(a, b) ? -1 : pred(b, a) ? 1 : 0; - }; -}); - -/** - * A function that returns the `!` of its argument. It will return `true` when - * passed false-y value, and `false` when passed a truth-y one. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Logic - * @sig * -> Boolean - * @param {*} a any value - * @return {Boolean} the logical inverse of passed argument. - * @see R.complement - * @example - * - * R.not(true); //=> false - * R.not(false); //=> true - * R.not(0); //=> true - * R.not(1); //=> false - */ -var not = _curry1(function not(a) { - return !a; -}); - -/** - * Takes a function `f` and returns a function `g` such that if called with the same arguments - * when `f` returns a "truthy" value, `g` returns `false` and when `f` returns a "falsy" value `g` returns `true`. - * - * `R.complement` may be applied to any functor - * - * @func - * @memberOf R - * @since v0.12.0 - * @category Logic - * @sig (*... -> *) -> (*... -> Boolean) - * @param {Function} f - * @return {Function} - * @see R.not - * @example - * - * const isNotNil = R.complement(R.isNil); - * isNil(null); //=> true - * isNotNil(null); //=> false - * isNil(7); //=> false - * isNotNil(7); //=> true - */ -var complement = lift(not); - -function _pipe(f, g) { - return function() { - return g.call(this, f.apply(this, arguments)); - }; -} - -/** - * This checks whether a function has a [methodname] function. If it isn't an - * array it will execute that function otherwise it will default to the ramda - * implementation. - * - * @private - * @param {Function} fn ramda implemtation - * @param {String} methodname property to check for a custom implementation - * @return {Object} Whatever the return value of the method is. - */ -function _checkForMethod(methodname, fn) { - return function() { - var length = arguments.length; - if (length === 0) { - return fn(); - } - var obj = arguments[length - 1]; - return (_isArray(obj) || typeof obj[methodname] !== 'function') ? - fn.apply(this, arguments) : - obj[methodname].apply(obj, Array.prototype.slice.call(arguments, 0, length - 1)); - }; -} - -/** - * Returns the elements of the given list or string (or object with a `slice` - * method) from `fromIndex` (inclusive) to `toIndex` (exclusive). - * - * Dispatches to the `slice` method of the third argument, if present. - * - * @func - * @memberOf R - * @since v0.1.4 - * @category List - * @sig Number -> Number -> [a] -> [a] - * @sig Number -> Number -> String -> String - * @param {Number} fromIndex The start index (inclusive). - * @param {Number} toIndex The end index (exclusive). - * @param {*} list - * @return {*} - * @example - * - * R.slice(1, 3, ['a', 'b', 'c', 'd']); //=> ['b', 'c'] - * R.slice(1, Infinity, ['a', 'b', 'c', 'd']); //=> ['b', 'c', 'd'] - * R.slice(0, -1, ['a', 'b', 'c', 'd']); //=> ['a', 'b', 'c'] - * R.slice(-3, -1, ['a', 'b', 'c', 'd']); //=> ['b', 'c'] - * R.slice(0, 3, 'ramda'); //=> 'ram' - */ -var slice = _curry3(_checkForMethod('slice', function slice(fromIndex, toIndex, list) { - return Array.prototype.slice.call(list, fromIndex, toIndex); -})); -/** - * Returns all but the first element of the given list or string (or object - * with a `tail` method). - * - * Dispatches to the `slice` method of the first argument, if present. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category List - * @sig [a] -> [a] - * @sig String -> String - * @param {*} list - * @return {*} - * @see R.head, R.init, R.last - * @example - * - * R.tail([1, 2, 3]); //=> [2, 3] - * R.tail([1, 2]); //=> [2] - * R.tail([1]); //=> [] - * R.tail([]); //=> [] - * - * R.tail('abc'); //=> 'bc' - * R.tail('ab'); //=> 'b' - * R.tail('a'); //=> '' - * R.tail(''); //=> '' - */ -var tail = _curry1(_checkForMethod('tail', slice(1, Infinity))); - -/** - * Performs left-to-right function composition. The leftmost function may have - * any arity; the remaining functions must be unary. - * - * In some libraries this function is named `sequence`. - * - * **Note:** The result of pipe is not automatically curried. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Function - * @sig (((a, b, ..., n) -> o), (o -> p), ..., (x -> y), (y -> z)) -> ((a, b, ..., n) -> z) - * @param {...Function} functions - * @return {Function} - * @see R.compose - * @example - * - * const f = R.pipe(Math.pow, R.negate, R.inc); - * - * f(3, 4); // -(3^4) + 1 - * @symb R.pipe(f, g, h)(a, b) = h(g(f(a, b))) - */ -function pipe() { - if (arguments.length === 0) { - throw new Error('pipe requires at least one argument'); - } - return _arity(arguments[0].length, - reduce(_pipe, arguments[0], tail(arguments))); -} - -/** - * Returns a new list or string with the elements or characters in reverse - * order. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category List - * @sig [a] -> [a] - * @sig String -> String - * @param {Array|String} list - * @return {Array|String} - * @example - * - * R.reverse([1, 2, 3]); //=> [3, 2, 1] - * R.reverse([1, 2]); //=> [2, 1] - * R.reverse([1]); //=> [1] - * R.reverse([]); //=> [] - * - * R.reverse('abc'); //=> 'cba' - * R.reverse('ab'); //=> 'ba' - * R.reverse('a'); //=> 'a' - * R.reverse(''); //=> '' - */ -var reverse = _curry1(function reverse(list) { - return _isString(list) ? list.split('').reverse().join('') : - Array.prototype.slice.call(list, 0).reverse(); -}); - -/** - * Performs right-to-left function composition. The rightmost function may have - * any arity; the remaining functions must be unary. - * - * **Note:** The result of compose is not automatically curried. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Function - * @sig ((y -> z), (x -> y), ..., (o -> p), ((a, b, ..., n) -> o)) -> ((a, b, ..., n) -> z) - * @param {...Function} ...functions The functions to compose - * @return {Function} - * @see R.pipe - * @example - * - * const classyGreeting = (firstName, lastName) => "The name's " + lastName + ", " + firstName + " " + lastName - * const yellGreeting = R.compose(R.toUpper, classyGreeting); - * yellGreeting('James', 'Bond'); //=> "THE NAME'S BOND, JAMES BOND" - * - * R.compose(Math.abs, R.add(1), R.multiply(2))(-4) //=> 7 - * - * @symb R.compose(f, g, h)(a, b) = f(g(h(a, b))) - */ -function compose() { - if (arguments.length === 0) { - throw new Error('compose requires at least one argument'); - } - return pipe.apply(this, reverse(arguments)); -} - -/** - * Returns the right-to-left Kleisli composition of the provided functions, - * each of which must return a value of a type supported by [`chain`](#chain). - * - * `R.composeK(h, g, f)` is equivalent to `R.compose(R.chain(h), R.chain(g), f)`. - * - * @func - * @memberOf R - * @since v0.16.0 - * @category Function - * @sig Chain m => ((y -> m z), (x -> m y), ..., (a -> m b)) -> (a -> m z) - * @param {...Function} ...functions The functions to compose - * @return {Function} - * @see R.pipeK - * @example - * - * // get :: String -> Object -> Maybe * - * const get = R.curry((propName, obj) => Maybe(obj[propName])) - * - * // getStateCode :: Maybe String -> Maybe String - * const getStateCode = R.composeK( - * R.compose(Maybe.of, R.toUpper), - * get('state'), - * get('address'), - * get('user'), - * ); - * getStateCode({"user":{"address":{"state":"ny"}}}); //=> Maybe.Just("NY") - * getStateCode({}); //=> Maybe.Nothing() - * @symb R.composeK(f, g, h)(a) = R.chain(f, R.chain(g, h(a))) - */ -function composeK() { - if (arguments.length === 0) { - throw new Error('composeK requires at least one argument'); - } - var init = Array.prototype.slice.call(arguments); - var last = init.pop(); - return compose(compose.apply(this, map(chain, init)), last); -} - -function _pipeP(f, g) { - return function() { - var ctx = this; - return f.apply(ctx, arguments).then(function(x) { - return g.call(ctx, x); - }); - }; -} - -/** - * Performs left-to-right composition of one or more Promise-returning - * functions. The leftmost function may have any arity; the remaining functions - * must be unary. - * - * @func - * @memberOf R - * @since v0.10.0 - * @category Function - * @sig ((a -> Promise b), (b -> Promise c), ..., (y -> Promise z)) -> (a -> Promise z) - * @param {...Function} functions - * @return {Function} - * @see R.composeP - * @example - * - * // followersForUser :: String -> Promise [User] - * const followersForUser = R.pipeP(db.getUserById, db.getFollowers); - */ -function pipeP() { - if (arguments.length === 0) { - throw new Error('pipeP requires at least one argument'); - } - return _arity(arguments[0].length, - reduce(_pipeP, arguments[0], tail(arguments))); -} - -/** - * Performs right-to-left composition of one or more Promise-returning - * functions. The rightmost function may have any arity; the remaining - * functions must be unary. - * - * @func - * @memberOf R - * @since v0.10.0 - * @category Function - * @sig ((y -> Promise z), (x -> Promise y), ..., (a -> Promise b)) -> (a -> Promise z) - * @param {...Function} functions The functions to compose - * @return {Function} - * @see R.pipeP - * @example - * - * const db = { - * users: { - * JOE: { - * name: 'Joe', - * followers: ['STEVE', 'SUZY'] - * } - * } - * } - * - * // We'll pretend to do a db lookup which returns a promise - * const lookupUser = (userId) => Promise.resolve(db.users[userId]) - * const lookupFollowers = (user) => Promise.resolve(user.followers) - * lookupUser('JOE').then(lookupFollowers) - * - * // followersForUser :: String -> Promise [UserId] - * const followersForUser = R.composeP(lookupFollowers, lookupUser); - * followersForUser('JOE').then(followers => console.log('Followers:', followers)) - * // Followers: ["STEVE","SUZY"] - */ -function composeP() { - if (arguments.length === 0) { - throw new Error('composeP requires at least one argument'); - } - return pipeP.apply(this, reverse(arguments)); -} - -/** - * Returns the nth element of the given list or string. If n is negative the - * element at index length + n is returned. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category List - * @sig Number -> [a] -> a | Undefined - * @sig Number -> String -> String - * @param {Number} offset - * @param {*} list - * @return {*} - * @example - * - * const list = ['foo', 'bar', 'baz', 'quux']; - * R.nth(1, list); //=> 'bar' - * R.nth(-1, list); //=> 'quux' - * R.nth(-99, list); //=> undefined - * - * R.nth(2, 'abc'); //=> 'c' - * R.nth(3, 'abc'); //=> '' - * @symb R.nth(-1, [a, b, c]) = c - * @symb R.nth(0, [a, b, c]) = a - * @symb R.nth(1, [a, b, c]) = b - */ -var nth = _curry2(function nth(offset, list) { - var idx = offset < 0 ? list.length + offset : offset; - return _isString(list) ? list.charAt(idx) : list[idx]; -}); - -/** - * Returns the first element of the given list or string. In some libraries - * this function is named `first`. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category List - * @sig [a] -> a | Undefined - * @sig String -> String - * @param {Array|String} list - * @return {*} - * @see R.tail, R.init, R.last - * @example - * - * R.head(['fi', 'fo', 'fum']); //=> 'fi' - * R.head([]); //=> undefined - * - * R.head('abc'); //=> 'a' - * R.head(''); //=> '' - */ -var head = nth(0); - -function _identity(x) { return x; } - -/** - * A function that does nothing but return the parameter supplied to it. Good - * as a default or placeholder function. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Function - * @sig a -> a - * @param {*} x The value to return. - * @return {*} The input value, `x`. - * @example - * - * R.identity(1); //=> 1 - * - * const obj = {}; - * R.identity(obj) === obj; //=> true - * @symb R.identity(a) = a - */ -var identity = _curry1(_identity); - -/** - * Performs left-to-right function composition using transforming function. The leftmost function may have - * any arity; the remaining functions must be unary. - * - * **Note:** The result of pipeWith is not automatically curried. - * - * @func - * @memberOf R - * @category Function - * @sig ((* -> *), [((a, b, ..., n) -> o), (o -> p), ..., (x -> y), (y -> z)]) -> ((a, b, ..., n) -> z) - * @param {...Function} functions - * @return {Function} - * @see R.composeWith, R.pipe - * @example - * - * const pipeWhileNotNil = R.pipeWith((f, res) => R.isNil(res) ? res : f(res)); - * const f = pipeWhileNotNil([Math.pow, R.negate, R.inc]) - * - * f(3, 4); // -(3^4) + 1 - * @symb R.pipeWith(f)([g, h, i])(...args) = f(i, f(h, f(g, ...args))) - */ -var pipeWith = _curry2(function pipeWith(xf, list) { - if (list.length <= 0) { - return identity; + function _iterableReduce(xf, acc, iter) { + var step = iter.next(); + while (!step.done) { + acc = xf['@@transducer/step'](acc, step.value); + if (acc && acc['@@transducer/reduced']) { + acc = acc['@@transducer/value']; + break; + } + step = iter.next(); + } + return xf['@@transducer/result'](acc); } - const headList = head(list); - const tailList = tail(list); - - return _arity(headList.length, function() { - return _reduce( - function(result, f) { - return xf.call(this, f, result); - }, - headList.apply(this, arguments), - tailList - ); - }); -}); - -/** - * Performs right-to-left function composition using transforming function. The rightmost function may have - * any arity; the remaining functions must be unary. - * - * **Note:** The result of compose is not automatically curried. - * - * @func - * @memberOf R - * @category Function - * @sig ((* -> *), [(y -> z), (x -> y), ..., (o -> p), ((a, b, ..., n) -> o)]) -> ((a, b, ..., n) -> z) - * @param {...Function} ...functions The functions to compose - * @return {Function} - * @see R.compose, R.pipeWith - * @example - * - * const composeWhileNotNil = R.composeWith((f, res) => R.isNil(res) ? res : f(res)); - * - * composeWhileNotNil([R.inc, R.prop('age')])({age: 1}) //=> 2 - * composeWhileNotNil([R.inc, R.prop('age')])({}) //=> null - * - * @symb R.composeWith(f)([g, h, i])(...args) = f(g, f(h, f(i, ...args))) - */ -var composeWith = _curry2(function composeWith(xf, list) { - return pipeWith.apply(this, [xf, reverse(list)]); -}); - -function _arrayFromIterator(iter) { - var list = []; - var next; - while (!(next = iter.next()).done) { - list.push(next.value); + function _methodReduce(xf, acc, obj, methodName) { + return xf['@@transducer/result'](obj[methodName](bind(xf['@@transducer/step'], xf), acc)); } - return list; -} -function _includesWith(pred, x, list) { - var idx = 0; - var len = list.length; + var symIterator = (typeof Symbol !== 'undefined') ? Symbol.iterator : '@@iterator'; - while (idx < len) { - if (pred(x, list[idx])) { - return true; + function _reduce(fn, acc, list) { + if (typeof fn === 'function') { + fn = _xwrap(fn); + } + if (_isArrayLike(list)) { + return _arrayReduce(fn, acc, list); + } + if (typeof list['fantasy-land/reduce'] === 'function') { + return _methodReduce(fn, acc, list, 'fantasy-land/reduce'); + } + if (list[symIterator] != null) { + return _iterableReduce(fn, acc, list[symIterator]()); + } + if (typeof list.next === 'function') { + return _iterableReduce(fn, acc, list); + } + if (typeof list.reduce === 'function') { + return _methodReduce(fn, acc, list, 'reduce'); } - idx += 1; - } - return false; -} - -function _functionName(f) { - // String(x => x) evaluates to "x => x", so the pattern may not match. - var match = String(f).match(/^function (\w*)/); - return match == null ? '' : match[1]; -} - -// Based on https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is -function _objectIs(a, b) { - // SameValue algorithm - if (a === b) { // Steps 1-5, 7-10 - // Steps 6.b-6.e: +0 != -0 - return a !== 0 || 1 / a === 1 / b; - } else { - // Step 6.a: NaN == NaN - return a !== a && b !== b; - } -} - -var _objectIs$1 = typeof Object.is === 'function' ? Object.is : _objectIs; - -/** - * private _uniqContentEquals function. - * That function is checking equality of 2 iterator contents with 2 assumptions - * - iterators lengths are the same - * - iterators values are unique - * - * false-positive result will be returned for comparision of, e.g. - * - [1,2,3] and [1,2,3,4] - * - [1,1,1] and [1,2,3] - * */ - -function _uniqContentEquals(aIterator, bIterator, stackA, stackB) { - var a = _arrayFromIterator(aIterator); - var b = _arrayFromIterator(bIterator); - - function eq(_a, _b) { - return _equals(_a, _b, stackA.slice(), stackB.slice()); - } - - // if *a* array contains any element that is not included in *b* - return !_includesWith(function(b, aItem) { - return !_includesWith(eq, aItem, b); - }, b, a); -} -function _equals(a, b, stackA, stackB) { - if (_objectIs$1(a, b)) { - return true; + throw new TypeError('reduce: list must be array or iterable'); } - var typeA = type(a); - - if (typeA !== type(b)) { - return false; + function XMap(f, xf) { + this.xf = xf; + this.f = f; } + XMap.prototype['@@transducer/init'] = _xfBase.init; + XMap.prototype['@@transducer/result'] = _xfBase.result; + XMap.prototype['@@transducer/step'] = function(result, input) { + return this.xf['@@transducer/step'](result, this.f(input)); + }; - if (a == null || b == null) { - return false; - } + var _xmap = _curry2(function _xmap(f, xf) { return new XMap(f, xf); }); - if (typeof a['fantasy-land/equals'] === 'function' || typeof b['fantasy-land/equals'] === 'function') { - return typeof a['fantasy-land/equals'] === 'function' && a['fantasy-land/equals'](b) && - typeof b['fantasy-land/equals'] === 'function' && b['fantasy-land/equals'](a); + function _has(prop, obj) { + return Object.prototype.hasOwnProperty.call(obj, prop); } - if (typeof a.equals === 'function' || typeof b.equals === 'function') { - return typeof a.equals === 'function' && a.equals(b) && - typeof b.equals === 'function' && b.equals(a); - } + var toString = Object.prototype.toString; + var _isArguments = (function() { + return toString.call(arguments) === '[object Arguments]' ? + function _isArguments(x) { return toString.call(x) === '[object Arguments]'; } : + function _isArguments(x) { return _has('callee', x); }; + }()); + + // cover IE < 9 keys issues + var hasEnumBug = !({toString: null}).propertyIsEnumerable('toString'); + var nonEnumerableProps = [ + 'constructor', 'valueOf', 'isPrototypeOf', 'toString', + 'propertyIsEnumerable', 'hasOwnProperty', 'toLocaleString' + ]; + // Safari bug + var hasArgsEnumBug = (function() { + return arguments.propertyIsEnumerable('length'); + }()); - switch (typeA) { - case 'Arguments': - case 'Array': - case 'Object': - if (typeof a.constructor === 'function' && - _functionName(a.constructor) === 'Promise') { - return a === b; + var contains = function contains(list, item) { + var idx = 0; + while (idx < list.length) { + if (list[idx] === item) { + return true; } - break; - case 'Boolean': - case 'Number': - case 'String': - if (!(typeof a === typeof b && _objectIs$1(a.valueOf(), b.valueOf()))) { - return false; + idx += 1; + } + return false; + }; + + /** + * Returns a list containing the names of all the enumerable own properties of + * the supplied object. + * Note that the order of the output array is not guaranteed to be consistent + * across different JS platforms. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Object + * @sig {k: v} -> [k] + * @param {Object} obj The object to extract properties from + * @return {Array} An array of the object's own properties. + * @see R.keysIn, R.values + * @example + * + * R.keys({a: 1, b: 2, c: 3}); //=> ['a', 'b', 'c'] + */ + var keys = typeof Object.keys === 'function' && !hasArgsEnumBug ? + _curry1(function keys(obj) { + return Object(obj) !== obj ? [] : Object.keys(obj); + }) : + _curry1(function keys(obj) { + if (Object(obj) !== obj) { + return []; } - break; - case 'Date': - if (!_objectIs$1(a.valueOf(), b.valueOf())) { - return false; + var prop, nIdx; + var ks = []; + var checkArgsLength = hasArgsEnumBug && _isArguments(obj); + for (prop in obj) { + if (_has(prop, obj) && (!checkArgsLength || prop !== 'length')) { + ks[ks.length] = prop; + } } - break; - case 'Error': - return a.name === b.name && a.message === b.message; - case 'RegExp': - if (!(a.source === b.source && - a.global === b.global && - a.ignoreCase === b.ignoreCase && - a.multiline === b.multiline && - a.sticky === b.sticky && - a.unicode === b.unicode)) { - return false; + if (hasEnumBug) { + nIdx = nonEnumerableProps.length - 1; + while (nIdx >= 0) { + prop = nonEnumerableProps[nIdx]; + if (_has(prop, obj) && !contains(ks, prop)) { + ks[ks.length] = prop; + } + nIdx -= 1; + } } - break; - } + return ks; + }); - var idx = stackA.length - 1; - while (idx >= 0) { - if (stackA[idx] === a) { - return stackB[idx] === b; + /** + * Takes a function and + * a [functor](https://github.com/fantasyland/fantasy-land#functor), + * applies the function to each of the functor's values, and returns + * a functor of the same shape. + * + * Ramda provides suitable `map` implementations for `Array` and `Object`, + * so this function may be applied to `[1, 2, 3]` or `{x: 1, y: 2, z: 3}`. + * + * Dispatches to the `map` method of the second argument, if present. + * + * Acts as a transducer if a transformer is given in list position. + * + * Also treats functions as functors and will compose them together. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category List + * @sig Functor f => (a -> b) -> f a -> f b + * @param {Function} fn The function to be called on every element of the input `list`. + * @param {Array} list The list to be iterated over. + * @return {Array} The new list. + * @see R.transduce, R.addIndex + * @example + * + * const double = x => x * 2; + * + * R.map(double, [1, 2, 3]); //=> [2, 4, 6] + * + * R.map(double, {x: 1, y: 2, z: 3}); //=> {x: 2, y: 4, z: 6} + * @symb R.map(f, [a, b]) = [f(a), f(b)] + * @symb R.map(f, { x: a, y: b }) = { x: f(a), y: f(b) } + * @symb R.map(f, functor_o) = functor_o.map(f) + */ + var map = _curry2(_dispatchable(['fantasy-land/map', 'map'], _xmap, function map(fn, functor) { + switch (Object.prototype.toString.call(functor)) { + case '[object Function]': + return curryN(functor.length, function() { + return fn.call(this, functor.apply(this, arguments)); + }); + case '[object Object]': + return _reduce(function(acc, key) { + acc[key] = fn(functor[key]); + return acc; + }, {}, keys(functor)); + default: + return _map(fn, functor); } - idx -= 1; - } + })); - switch (typeA) { - case 'Map': - if (a.size !== b.size) { - return false; - } + /** + * Determine if the passed argument is an integer. + * + * @private + * @param {*} n + * @category Type + * @return {Boolean} + */ + var _isInteger = Number.isInteger || function _isInteger(n) { + return (n << 0) === n; + }; - return _uniqContentEquals(a.entries(), b.entries(), stackA.concat([a]), stackB.concat([b])); - case 'Set': - if (a.size !== b.size) { - return false; - } + /** + * Returns the nth element of the given list or string. If n is negative the + * element at index length + n is returned. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category List + * @sig Number -> [a] -> a | Undefined + * @sig Number -> String -> String + * @param {Number} offset + * @param {*} list + * @return {*} + * @example + * + * const list = ['foo', 'bar', 'baz', 'quux']; + * R.nth(1, list); //=> 'bar' + * R.nth(-1, list); //=> 'quux' + * R.nth(-99, list); //=> undefined + * + * R.nth(2, 'abc'); //=> 'c' + * R.nth(3, 'abc'); //=> '' + * @symb R.nth(-1, [a, b, c]) = c + * @symb R.nth(0, [a, b, c]) = a + * @symb R.nth(1, [a, b, c]) = b + */ + var nth = _curry2(function nth(offset, list) { + var idx = offset < 0 ? list.length + offset : offset; + return _isString(list) ? list.charAt(idx) : list[idx]; + }); - return _uniqContentEquals(a.values(), b.values(), stackA.concat([a]), stackB.concat([b])); - case 'Arguments': - case 'Array': - case 'Object': - case 'Boolean': - case 'Number': - case 'String': - case 'Date': - case 'Error': - case 'RegExp': - case 'Int8Array': - case 'Uint8Array': - case 'Uint8ClampedArray': - case 'Int16Array': - case 'Uint16Array': - case 'Int32Array': - case 'Uint32Array': - case 'Float32Array': - case 'Float64Array': - case 'ArrayBuffer': - break; - default: - // Values of other types are only equal if identical. - return false; - } + /** + * Retrieves the values at given paths of an object. + * + * @func + * @memberOf R + * @since v0.27.1 + * @category Object + * @typedefn Idx = [String | Int] + * @sig [Idx] -> {a} -> [a | Undefined] + * @param {Array} pathsArray The array of paths to be fetched. + * @param {Object} obj The object to retrieve the nested properties from. + * @return {Array} A list consisting of values at paths specified by "pathsArray". + * @see R.path + * @example + * + * R.paths([['a', 'b'], ['p', 0, 'q']], {a: {b: 2}, p: [{q: 3}]}); //=> [2, 3] + * R.paths([['a', 'b'], ['p', 'r']], {a: {b: 2}, p: [{q: 3}]}); //=> [2, undefined] + */ + var paths = _curry2(function paths(pathsArray, obj) { + return pathsArray.map(function(paths) { + var val = obj; + var idx = 0; + var p; + while (idx < paths.length) { + if (val == null) { + return; + } + p = paths[idx]; + val = _isInteger(p) ? nth(p, val) : val[p]; + idx += 1; + } + return val; + }); + }); - var keysA = keys(a); - if (keysA.length !== keys(b).length) { - return false; - } + /** + * Retrieve the value at a given path. + * + * @func + * @memberOf R + * @since v0.2.0 + * @category Object + * @typedefn Idx = String | Int + * @sig [Idx] -> {a} -> a | Undefined + * @param {Array} path The path to use. + * @param {Object} obj The object to retrieve the nested property from. + * @return {*} The data at `path`. + * @see R.prop, R.nth + * @example + * + * R.path(['a', 'b'], {a: {b: 2}}); //=> 2 + * R.path(['a', 'b'], {c: {b: 2}}); //=> undefined + * R.path(['a', 'b', 0], {a: {b: [1, 2, 3]}}); //=> 1 + * R.path(['a', 'b', -2], {a: {b: [1, 2, 3]}}); //=> 2 + */ + + var path = _curry2(function path(pathAr, obj) { + return paths([pathAr], obj)[0]; + }); - var extendedStackA = stackA.concat([a]); - var extendedStackB = stackB.concat([b]); + /** + * Returns a function that when supplied an object returns the indicated + * property of that object, if it exists. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Object + * @typedefn Idx = String | Int + * @sig Idx -> {s: a} -> a | Undefined + * @param {String|Number} p The property name or array index + * @param {Object} obj The object to query + * @return {*} The value at `obj.p`. + * @see R.path, R.nth + * @example + * + * R.prop('x', {x: 100}); //=> 100 + * R.prop('x', {}); //=> undefined + * R.prop(0, [100]); //=> 100 + * R.compose(R.inc, R.prop('x'))({ x: 3 }) //=> 4 + */ + + var prop = _curry2(function prop(p, obj) { return path([p], obj); }); + + /** + * Returns a new list by plucking the same named property off all objects in + * the list supplied. + * + * `pluck` will work on + * any [functor](https://github.com/fantasyland/fantasy-land#functor) in + * addition to arrays, as it is equivalent to `R.map(R.prop(k), f)`. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category List + * @sig Functor f => k -> f {k: v} -> f v + * @param {Number|String} key The key name to pluck off of each object. + * @param {Array} f The array or functor to consider. + * @return {Array} The list of values for the given key. + * @see R.props + * @example + * + * var getAges = R.pluck('age'); + * getAges([{name: 'fred', age: 29}, {name: 'wilma', age: 27}]); //=> [29, 27] + * + * R.pluck(0, [[1, 2], [3, 4]]); //=> [1, 3] + * R.pluck('val', {a: {val: 3}, b: {val: 5}}); //=> {a: 3, b: 5} + * @symb R.pluck('x', [{x: 1, y: 2}, {x: 3, y: 4}, {x: 5, y: 6}]) = [1, 3, 5] + * @symb R.pluck(0, [[1, 2], [3, 4], [5, 6]]) = [1, 3, 5] + */ + var pluck = _curry2(function pluck(p, list) { + return map(prop(p), list); + }); - idx = keysA.length - 1; - while (idx >= 0) { - var key = keysA[idx]; - if (!(_has(key, b) && _equals(b[key], a[key], extendedStackA, extendedStackB))) { - return false; - } - idx -= 1; - } - return true; -} - -/** - * Returns `true` if its arguments are equivalent, `false` otherwise. Handles - * cyclical data structures. - * - * Dispatches symmetrically to the `equals` methods of both arguments, if - * present. - * - * @func - * @memberOf R - * @since v0.15.0 - * @category Relation - * @sig a -> b -> Boolean - * @param {*} a - * @param {*} b - * @return {Boolean} - * @example - * - * R.equals(1, 1); //=> true - * R.equals(1, '1'); //=> false - * R.equals([1, 2, 3], [1, 2, 3]); //=> true - * - * const a = {}; a.v = a; - * const b = {}; b.v = b; - * R.equals(a, b); //=> true - */ -var equals = _curry2(function equals(a, b) { - return _equals(a, b, [], []); -}); - -function _indexOf(list, a, idx) { - var inf, item; - // Array.prototype.indexOf doesn't exist below IE9 - if (typeof list.indexOf === 'function') { - switch (typeof a) { - case 'number': - if (a === 0) { - // manually crawl the list to distinguish between +0 and -0 - inf = 1 / a; - while (idx < list.length) { - item = list[idx]; - if (item === 0 && 1 / item === inf) { - return idx; - } - idx += 1; - } - return -1; - } else if (a !== a) { - // NaN - while (idx < list.length) { - item = list[idx]; - if (typeof item === 'number' && item !== item) { - return idx; - } - idx += 1; - } - return -1; + /** + * Returns a single item by iterating through the list, successively calling + * the iterator function and passing it an accumulator value and the current + * value from the array, and then passing the result to the next call. + * + * The iterator function receives two values: *(acc, value)*. It may use + * [`R.reduced`](#reduced) to shortcut the iteration. + * + * The arguments' order of [`reduceRight`](#reduceRight)'s iterator function + * is *(value, acc)*. + * + * Note: `R.reduce` does not skip deleted or unassigned indices (sparse + * arrays), unlike the native `Array.prototype.reduce` method. For more details + * on this behavior, see: + * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce#Description + * + * Dispatches to the `reduce` method of the third argument, if present. When + * doing so, it is up to the user to handle the [`R.reduced`](#reduced) + * shortcuting, as this is not implemented by `reduce`. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category List + * @sig ((a, b) -> a) -> a -> [b] -> a + * @param {Function} fn The iterator function. Receives two values, the accumulator and the + * current element from the array. + * @param {*} acc The accumulator value. + * @param {Array} list The list to iterate over. + * @return {*} The final, accumulated value. + * @see R.reduced, R.addIndex, R.reduceRight + * @example + * + * R.reduce(R.subtract, 0, [1, 2, 3, 4]) // => ((((0 - 1) - 2) - 3) - 4) = -10 + * // - -10 + * // / \ / \ + * // - 4 -6 4 + * // / \ / \ + * // - 3 ==> -3 3 + * // / \ / \ + * // - 2 -1 2 + * // / \ / \ + * // 0 1 0 1 + * + * @symb R.reduce(f, a, [b, c, d]) = f(f(f(a, b), c), d) + */ + var reduce = _curry3(_reduce); + + /** + * Takes a list of predicates and returns a predicate that returns true for a + * given list of arguments if every one of the provided predicates is satisfied + * by those arguments. + * + * The function returned is a curried function whose arity matches that of the + * highest-arity predicate. + * + * @func + * @memberOf R + * @since v0.9.0 + * @category Logic + * @sig [(*... -> Boolean)] -> (*... -> Boolean) + * @param {Array} predicates An array of predicates to check + * @return {Function} The combined predicate + * @see R.anyPass + * @example + * + * const isQueen = R.propEq('rank', 'Q'); + * const isSpade = R.propEq('suit', '♠︎'); + * const isQueenOfSpades = R.allPass([isQueen, isSpade]); + * + * isQueenOfSpades({rank: 'Q', suit: '♣︎'}); //=> false + * isQueenOfSpades({rank: 'Q', suit: '♠︎'}); //=> true + */ + var allPass = _curry1(function allPass(preds) { + return curryN(reduce(max, 0, pluck('length', preds)), function() { + var idx = 0; + var len = preds.length; + while (idx < len) { + if (!preds[idx].apply(this, arguments)) { + return false; } - // non-zero numbers can utilise Set - return list.indexOf(a, idx); + idx += 1; + } + return true; + }); + }); - // all these types can utilise Set - case 'string': - case 'boolean': - case 'function': - case 'undefined': - return list.indexOf(a, idx); + /** + * Returns a function that always returns the given value. Note that for + * non-primitives the value returned is a reference to the original value. + * + * This function is known as `const`, `constant`, or `K` (for K combinator) in + * other languages and libraries. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Function + * @sig a -> (* -> a) + * @param {*} val The value to wrap in a function + * @return {Function} A Function :: * -> val. + * @example + * + * const t = R.always('Tee'); + * t(); //=> 'Tee' + */ + var always = _curry1(function always(val) { + return function() { + return val; + }; + }); - case 'object': - if (a === null) { - // null can utilise Set - return list.indexOf(a, idx); + /** + * Returns `true` if both arguments are `true`; `false` otherwise. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Logic + * @sig a -> b -> a | b + * @param {Any} a + * @param {Any} b + * @return {Any} the first argument if it is falsy, otherwise the second argument. + * @see R.both, R.xor + * @example + * + * R.and(true, true); //=> true + * R.and(true, false); //=> false + * R.and(false, true); //=> false + * R.and(false, false); //=> false + */ + var and = _curry2(function and(a, b) { + return a && b; + }); + + function XAny(f, xf) { + this.xf = xf; + this.f = f; + this.any = false; + } + XAny.prototype['@@transducer/init'] = _xfBase.init; + XAny.prototype['@@transducer/result'] = function(result) { + if (!this.any) { + result = this.xf['@@transducer/step'](result, false); + } + return this.xf['@@transducer/result'](result); + }; + XAny.prototype['@@transducer/step'] = function(result, input) { + if (this.f(input)) { + this.any = true; + result = _reduced(this.xf['@@transducer/step'](result, true)); + } + return result; + }; + + var _xany = _curry2(function _xany(f, xf) { return new XAny(f, xf); }); + + /** + * Returns `true` if at least one of the elements of the list match the predicate, + * `false` otherwise. + * + * Dispatches to the `any` method of the second argument, if present. + * + * Acts as a transducer if a transformer is given in list position. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category List + * @sig (a -> Boolean) -> [a] -> Boolean + * @param {Function} fn The predicate function. + * @param {Array} list The array to consider. + * @return {Boolean} `true` if the predicate is satisfied by at least one element, `false` + * otherwise. + * @see R.all, R.none, R.transduce + * @example + * + * const lessThan0 = R.flip(R.lt)(0); + * const lessThan2 = R.flip(R.lt)(2); + * R.any(lessThan0)([1, 2]); //=> false + * R.any(lessThan2)([1, 2]); //=> true + */ + var any = _curry2(_dispatchable(['any'], _xany, function any(fn, list) { + var idx = 0; + while (idx < list.length) { + if (fn(list[idx])) { + return true; + } + idx += 1; + } + return false; + })); + + /** + * Takes a list of predicates and returns a predicate that returns true for a + * given list of arguments if at least one of the provided predicates is + * satisfied by those arguments. + * + * The function returned is a curried function whose arity matches that of the + * highest-arity predicate. + * + * @func + * @memberOf R + * @since v0.9.0 + * @category Logic + * @sig [(*... -> Boolean)] -> (*... -> Boolean) + * @param {Array} predicates An array of predicates to check + * @return {Function} The combined predicate + * @see R.allPass + * @example + * + * const isClub = R.propEq('suit', '♣'); + * const isSpade = R.propEq('suit', '♠'); + * const isBlackCard = R.anyPass([isClub, isSpade]); + * + * isBlackCard({rank: '10', suit: '♣'}); //=> true + * isBlackCard({rank: 'Q', suit: '♠'}); //=> true + * isBlackCard({rank: 'Q', suit: '♦'}); //=> false + */ + var anyPass = _curry1(function anyPass(preds) { + return curryN(reduce(max, 0, pluck('length', preds)), function() { + var idx = 0; + var len = preds.length; + while (idx < len) { + if (preds[idx].apply(this, arguments)) { + return true; } + idx += 1; + } + return false; + }); + }); + + /** + * ap applies a list of functions to a list of values. + * + * Dispatches to the `ap` method of the second argument, if present. Also + * treats curried functions as applicatives. + * + * @func + * @memberOf R + * @since v0.3.0 + * @category Function + * @sig [a -> b] -> [a] -> [b] + * @sig Apply f => f (a -> b) -> f a -> f b + * @sig (r -> a -> b) -> (r -> a) -> (r -> b) + * @param {*} applyF + * @param {*} applyX + * @return {*} + * @example + * + * R.ap([R.multiply(2), R.add(3)], [1,2,3]); //=> [2, 4, 6, 4, 5, 6] + * R.ap([R.concat('tasty '), R.toUpper], ['pizza', 'salad']); //=> ["tasty pizza", "tasty salad", "PIZZA", "SALAD"] + * + * // R.ap can also be used as S combinator + * // when only two functions are passed + * R.ap(R.concat, R.toUpper)('Ramda') //=> 'RamdaRAMDA' + * @symb R.ap([f, g], [a, b]) = [f(a), f(b), g(a), g(b)] + */ + var ap = _curry2(function ap(applyF, applyX) { + return ( + typeof applyX['fantasy-land/ap'] === 'function' + ? applyX['fantasy-land/ap'](applyF) + : typeof applyF.ap === 'function' + ? applyF.ap(applyX) + : typeof applyF === 'function' + ? function(x) { return applyF(x)(applyX(x)); } + : _reduce(function(acc, f) { return _concat(acc, map(f, applyX)); }, [], applyF) + ); + }); + + function _aperture(n, list) { + var idx = 0; + var limit = list.length - (n - 1); + var acc = new Array(limit >= 0 ? limit : 0); + while (idx < limit) { + acc[idx] = Array.prototype.slice.call(list, idx, idx + n); + idx += 1; } + return acc; } - // anything else not covered above, defer to R.equals - while (idx < list.length) { - if (equals(list[idx], a)) { - return idx; - } - idx += 1; + + function XAperture(n, xf) { + this.xf = xf; + this.pos = 0; + this.full = false; + this.acc = new Array(n); } - return -1; -} - -function _includes(a, list) { - return _indexOf(list, a, 0) >= 0; -} - -function _quote(s) { - var escaped = s - .replace(/\\/g, '\\\\') - .replace(/[\b]/g, '\\b') // \b matches word boundary; [\b] matches backspace - .replace(/\f/g, '\\f') - .replace(/\n/g, '\\n') - .replace(/\r/g, '\\r') - .replace(/\t/g, '\\t') - .replace(/\v/g, '\\v') - .replace(/\0/g, '\\0'); - - return '"' + escaped.replace(/"/g, '\\"') + '"'; -} - -/** - * Polyfill from . - */ -var pad = function pad(n) { return (n < 10 ? '0' : '') + n; }; - -var _toISOString = typeof Date.prototype.toISOString === 'function' ? - function _toISOString(d) { - return d.toISOString(); - } : - function _toISOString(d) { - return ( - d.getUTCFullYear() + '-' + - pad(d.getUTCMonth() + 1) + '-' + - pad(d.getUTCDate()) + 'T' + - pad(d.getUTCHours()) + ':' + - pad(d.getUTCMinutes()) + ':' + - pad(d.getUTCSeconds()) + '.' + - (d.getUTCMilliseconds() / 1000).toFixed(3).slice(2, 5) + 'Z' + XAperture.prototype['@@transducer/init'] = _xfBase.init; + XAperture.prototype['@@transducer/result'] = function(result) { + this.acc = null; + return this.xf['@@transducer/result'](result); + }; + XAperture.prototype['@@transducer/step'] = function(result, input) { + this.store(input); + return this.full ? this.xf['@@transducer/step'](result, this.getCopy()) : result; + }; + XAperture.prototype.store = function(input) { + this.acc[this.pos] = input; + this.pos += 1; + if (this.pos === this.acc.length) { + this.pos = 0; + this.full = true; + } + }; + XAperture.prototype.getCopy = function() { + return _concat(Array.prototype.slice.call(this.acc, this.pos), + Array.prototype.slice.call(this.acc, 0, this.pos) ); }; -function _complement(f) { - return function() { - return !f.apply(this, arguments); - }; -} + var _xaperture = _curry2(function _xaperture(n, xf) { return new XAperture(n, xf); }); + + /** + * Returns a new list, composed of n-tuples of consecutive elements. If `n` is + * greater than the length of the list, an empty list is returned. + * + * Acts as a transducer if a transformer is given in list position. + * + * @func + * @memberOf R + * @since v0.12.0 + * @category List + * @sig Number -> [a] -> [[a]] + * @param {Number} n The size of the tuples to create + * @param {Array} list The list to split into `n`-length tuples + * @return {Array} The resulting list of `n`-length tuples + * @see R.transduce + * @example + * + * R.aperture(2, [1, 2, 3, 4, 5]); //=> [[1, 2], [2, 3], [3, 4], [4, 5]] + * R.aperture(3, [1, 2, 3, 4, 5]); //=> [[1, 2, 3], [2, 3, 4], [3, 4, 5]] + * R.aperture(7, [1, 2, 3, 4, 5]); //=> [] + */ + var aperture = _curry2(_dispatchable([], _xaperture, _aperture)); + + /** + * Returns a new list containing the contents of the given list, followed by + * the given element. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category List + * @sig a -> [a] -> [a] + * @param {*} el The element to add to the end of the new list. + * @param {Array} list The list of elements to add a new item to. + * list. + * @return {Array} A new list containing the elements of the old list followed by `el`. + * @see R.prepend + * @example + * + * R.append('tests', ['write', 'more']); //=> ['write', 'more', 'tests'] + * R.append('tests', []); //=> ['tests'] + * R.append(['tests'], ['write', 'more']); //=> ['write', 'more', ['tests']] + */ + var append = _curry2(function append(el, list) { + return _concat(list, [el]); + }); -function _filter(fn, list) { - var idx = 0; - var len = list.length; - var result = []; + /** + * Applies function `fn` to the argument list `args`. This is useful for + * creating a fixed-arity function from a variadic function. `fn` should be a + * bound function if context is significant. + * + * @func + * @memberOf R + * @since v0.7.0 + * @category Function + * @sig (*... -> a) -> [*] -> a + * @param {Function} fn The function which will be called with `args` + * @param {Array} args The arguments to call `fn` with + * @return {*} result The result, equivalent to `fn(...args)` + * @see R.call, R.unapply + * @example + * + * const nums = [1, 2, 3, -99, 42, 6, 7]; + * R.apply(Math.max, nums); //=> 42 + * @symb R.apply(f, [a, b, c]) = f(a, b, c) + */ + var apply = _curry2(function apply(fn, args) { + return fn.apply(this, args); + }); - while (idx < len) { - if (fn(list[idx])) { - result[result.length] = list[idx]; + /** + * Returns a list of all the enumerable own properties of the supplied object. + * Note that the order of the output array is not guaranteed across different + * JS platforms. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Object + * @sig {k: v} -> [v] + * @param {Object} obj The object to extract values from + * @return {Array} An array of the values of the object's own properties. + * @see R.valuesIn, R.keys + * @example + * + * R.values({a: 1, b: 2, c: 3}); //=> [1, 2, 3] + */ + var values = _curry1(function values(obj) { + var props = keys(obj); + var len = props.length; + var vals = []; + var idx = 0; + while (idx < len) { + vals[idx] = obj[props[idx]]; + idx += 1; } - idx += 1; - } - return result; -} - -function _isObject(x) { - return Object.prototype.toString.call(x) === '[object Object]'; -} - -function XFilter(f, xf) { - this.xf = xf; - this.f = f; -} -XFilter.prototype['@@transducer/init'] = _xfBase.init; -XFilter.prototype['@@transducer/result'] = _xfBase.result; -XFilter.prototype['@@transducer/step'] = function(result, input) { - return this.f(input) ? this.xf['@@transducer/step'](result, input) : result; -}; - -var _xfilter = _curry2(function _xfilter(f, xf) { return new XFilter(f, xf); }); - -/** - * Takes a predicate and a `Filterable`, and returns a new filterable of the - * same type containing the members of the given filterable which satisfy the - * given predicate. Filterable objects include plain objects or any object - * that has a filter method such as `Array`. - * - * Dispatches to the `filter` method of the second argument, if present. - * - * Acts as a transducer if a transformer is given in list position. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category List - * @sig Filterable f => (a -> Boolean) -> f a -> f a - * @param {Function} pred - * @param {Array} filterable - * @return {Array} Filterable - * @see R.reject, R.transduce, R.addIndex - * @example - * - * const isEven = n => n % 2 === 0; - * - * R.filter(isEven, [1, 2, 3, 4]); //=> [2, 4] - * - * R.filter(isEven, {a: 1, b: 2, c: 3, d: 4}); //=> {b: 2, d: 4} - */ -var filter = _curry2(_dispatchable(['filter'], _xfilter, function(pred, filterable) { - return ( - _isObject(filterable) ? - _reduce(function(acc, key) { - if (pred(filterable[key])) { - acc[key] = filterable[key]; + return vals; + }); + + // Use custom mapValues function to avoid issues with specs that include a "map" key and R.map + // delegating calls to .map + function mapValues(fn, obj) { + return keys(obj).reduce(function(acc, key) { + acc[key] = fn(obj[key]); + return acc; + }, {}); + } + + /** + * Given a spec object recursively mapping properties to functions, creates a + * function producing an object of the same structure, by mapping each property + * to the result of calling its associated function with the supplied arguments. + * + * @func + * @memberOf R + * @since v0.20.0 + * @category Function + * @sig {k: ((a, b, ..., m) -> v)} -> ((a, b, ..., m) -> {k: v}) + * @param {Object} spec an object recursively mapping properties to functions for + * producing the values for these properties. + * @return {Function} A function that returns an object of the same structure + * as `spec', with each property set to the value returned by calling its + * associated function with the supplied arguments. + * @see R.converge, R.juxt + * @example + * + * const getMetrics = R.applySpec({ + * sum: R.add, + * nested: { mul: R.multiply } + * }); + * getMetrics(2, 4); // => { sum: 6, nested: { mul: 8 } } + * @symb R.applySpec({ x: f, y: { z: g } })(a, b) = { x: f(a, b), y: { z: g(a, b) } } + */ + var applySpec = _curry1(function applySpec(spec) { + spec = mapValues( + function(v) { return typeof v == 'function' ? v : applySpec(v); }, + spec + ); + + return curryN( + reduce(max, 0, pluck('length', values(spec))), + function() { + var args = arguments; + return mapValues(function(f) { return apply(f, args); }, spec); + }); + }); + + /** + * Takes a value and applies a function to it. + * + * This function is also known as the `thrush` combinator. + * + * @func + * @memberOf R + * @since v0.25.0 + * @category Function + * @sig a -> (a -> b) -> b + * @param {*} x The value + * @param {Function} f The function to apply + * @return {*} The result of applying `f` to `x` + * @example + * + * const t42 = R.applyTo(42); + * t42(R.identity); //=> 42 + * t42(R.add(1)); //=> 43 + */ + var applyTo = _curry2(function applyTo(x, f) { return f(x); }); + + /** + * Makes an ascending comparator function out of a function that returns a value + * that can be compared with `<` and `>`. + * + * @func + * @memberOf R + * @since v0.23.0 + * @category Function + * @sig Ord b => (a -> b) -> a -> a -> Number + * @param {Function} fn A function of arity one that returns a value that can be compared + * @param {*} a The first item to be compared. + * @param {*} b The second item to be compared. + * @return {Number} `-1` if fn(a) < fn(b), `1` if fn(b) < fn(a), otherwise `0` + * @see R.descend + * @example + * + * const byAge = R.ascend(R.prop('age')); + * const people = [ + * { name: 'Emma', age: 70 }, + * { name: 'Peter', age: 78 }, + * { name: 'Mikhail', age: 62 }, + * ]; + * const peopleByYoungestFirst = R.sort(byAge, people); + * //=> [{ name: 'Mikhail', age: 62 },{ name: 'Emma', age: 70 }, { name: 'Peter', age: 78 }] + */ + var ascend = _curry3(function ascend(fn, a, b) { + var aa = fn(a); + var bb = fn(b); + return aa < bb ? -1 : aa > bb ? 1 : 0; + }); + + /** + * Makes a shallow clone of an object, setting or overriding the specified + * property with the given value. Note that this copies and flattens prototype + * properties onto the new object as well. All non-primitive properties are + * copied by reference. + * + * @func + * @memberOf R + * @since v0.8.0 + * @category Object + * @sig String -> a -> {k: v} -> {k: v} + * @param {String} prop The property name to set + * @param {*} val The new value + * @param {Object} obj The object to clone + * @return {Object} A new object equivalent to the original except for the changed property. + * @see R.dissoc, R.pick + * @example + * + * R.assoc('c', 3, {a: 1, b: 2}); //=> {a: 1, b: 2, c: 3} + */ + var assoc = _curry3(function assoc(prop, val, obj) { + var result = {}; + for (var p in obj) { + result[p] = obj[p]; + } + result[prop] = val; + return result; + }); + + /** + * Checks if the input value is `null` or `undefined`. + * + * @func + * @memberOf R + * @since v0.9.0 + * @category Type + * @sig * -> Boolean + * @param {*} x The value to test. + * @return {Boolean} `true` if `x` is `undefined` or `null`, otherwise `false`. + * @example + * + * R.isNil(null); //=> true + * R.isNil(undefined); //=> true + * R.isNil(0); //=> false + * R.isNil([]); //=> false + */ + var isNil = _curry1(function isNil(x) { return x == null; }); + + /** + * Makes a shallow clone of an object, setting or overriding the nodes required + * to create the given path, and placing the specific value at the tail end of + * that path. Note that this copies and flattens prototype properties onto the + * new object as well. All non-primitive properties are copied by reference. + * + * @func + * @memberOf R + * @since v0.8.0 + * @category Object + * @typedefn Idx = String | Int + * @sig [Idx] -> a -> {a} -> {a} + * @param {Array} path the path to set + * @param {*} val The new value + * @param {Object} obj The object to clone + * @return {Object} A new object equivalent to the original except along the specified path. + * @see R.dissocPath + * @example + * + * R.assocPath(['a', 'b', 'c'], 42, {a: {b: {c: 0}}}); //=> {a: {b: {c: 42}}} + * + * // Any missing or non-object keys in path will be overridden + * R.assocPath(['a', 'b', 'c'], 42, {a: 5}); //=> {a: {b: {c: 42}}} + */ + var assocPath = _curry3(function assocPath(path, val, obj) { + if (path.length === 0) { + return val; + } + var idx = path[0]; + if (path.length > 1) { + var nextObj = (!isNil(obj) && _has(idx, obj)) ? obj[idx] : _isInteger(path[1]) ? [] : {}; + val = assocPath(Array.prototype.slice.call(path, 1), val, nextObj); + } + if (_isInteger(idx) && _isArray(obj)) { + var arr = [].concat(obj); + arr[idx] = val; + return arr; + } else { + return assoc(idx, val, obj); + } + }); + + /** + * Wraps a function of any arity (including nullary) in a function that accepts + * exactly `n` parameters. Any extraneous parameters will not be passed to the + * supplied function. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Function + * @sig Number -> (* -> a) -> (* -> a) + * @param {Number} n The desired arity of the new function. + * @param {Function} fn The function to wrap. + * @return {Function} A new function wrapping `fn`. The new function is guaranteed to be of + * arity `n`. + * @see R.binary, R.unary + * @example + * + * const takesTwoArgs = (a, b) => [a, b]; + * + * takesTwoArgs.length; //=> 2 + * takesTwoArgs(1, 2); //=> [1, 2] + * + * const takesOneArg = R.nAry(1, takesTwoArgs); + * takesOneArg.length; //=> 1 + * // Only `n` arguments are passed to the wrapped function + * takesOneArg(1, 2); //=> [1, undefined] + * @symb R.nAry(0, f)(a, b) = f() + * @symb R.nAry(1, f)(a, b) = f(a) + * @symb R.nAry(2, f)(a, b) = f(a, b) + */ + var nAry = _curry2(function nAry(n, fn) { + switch (n) { + case 0: return function() {return fn.call(this);}; + case 1: return function(a0) {return fn.call(this, a0);}; + case 2: return function(a0, a1) {return fn.call(this, a0, a1);}; + case 3: return function(a0, a1, a2) {return fn.call(this, a0, a1, a2);}; + case 4: return function(a0, a1, a2, a3) {return fn.call(this, a0, a1, a2, a3);}; + case 5: return function(a0, a1, a2, a3, a4) {return fn.call(this, a0, a1, a2, a3, a4);}; + case 6: return function(a0, a1, a2, a3, a4, a5) {return fn.call(this, a0, a1, a2, a3, a4, a5);}; + case 7: return function(a0, a1, a2, a3, a4, a5, a6) {return fn.call(this, a0, a1, a2, a3, a4, a5, a6);}; + case 8: return function(a0, a1, a2, a3, a4, a5, a6, a7) {return fn.call(this, a0, a1, a2, a3, a4, a5, a6, a7);}; + case 9: return function(a0, a1, a2, a3, a4, a5, a6, a7, a8) {return fn.call(this, a0, a1, a2, a3, a4, a5, a6, a7, a8);}; + case 10: return function(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9) {return fn.call(this, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9);}; + default: throw new Error('First argument to nAry must be a non-negative integer no greater than ten'); + } + }); + + /** + * Wraps a function of any arity (including nullary) in a function that accepts + * exactly 2 parameters. Any extraneous parameters will not be passed to the + * supplied function. + * + * @func + * @memberOf R + * @since v0.2.0 + * @category Function + * @sig (* -> c) -> (a, b -> c) + * @param {Function} fn The function to wrap. + * @return {Function} A new function wrapping `fn`. The new function is guaranteed to be of + * arity 2. + * @see R.nAry, R.unary + * @example + * + * const takesThreeArgs = function(a, b, c) { + * return [a, b, c]; + * }; + * takesThreeArgs.length; //=> 3 + * takesThreeArgs(1, 2, 3); //=> [1, 2, 3] + * + * const takesTwoArgs = R.binary(takesThreeArgs); + * takesTwoArgs.length; //=> 2 + * // Only 2 arguments are passed to the wrapped function + * takesTwoArgs(1, 2, 3); //=> [1, 2, undefined] + * @symb R.binary(f)(a, b, c) = f(a, b) + */ + var binary = _curry1(function binary(fn) { + return nAry(2, fn); + }); + + function _isFunction(x) { + var type = Object.prototype.toString.call(x); + return type === '[object Function]' || + type === '[object AsyncFunction]' || + type === '[object GeneratorFunction]' || + type === '[object AsyncGeneratorFunction]'; + } + + /** + * "lifts" a function to be the specified arity, so that it may "map over" that + * many lists, Functions or other objects that satisfy the [FantasyLand Apply spec](https://github.com/fantasyland/fantasy-land#apply). + * + * @func + * @memberOf R + * @since v0.7.0 + * @category Function + * @sig Number -> (*... -> *) -> ([*]... -> [*]) + * @param {Function} fn The function to lift into higher context + * @return {Function} The lifted function. + * @see R.lift, R.ap + * @example + * + * const madd3 = R.liftN(3, (...args) => R.sum(args)); + * madd3([1,2,3], [1,2,3], [1]); //=> [3, 4, 5, 4, 5, 6, 5, 6, 7] + */ + var liftN = _curry2(function liftN(arity, fn) { + var lifted = curryN(arity, fn); + return curryN(arity, function() { + return _reduce(ap, map(lifted, arguments[0]), Array.prototype.slice.call(arguments, 1)); + }); + }); + + /** + * "lifts" a function of arity > 1 so that it may "map over" a list, Function or other + * object that satisfies the [FantasyLand Apply spec](https://github.com/fantasyland/fantasy-land#apply). + * + * @func + * @memberOf R + * @since v0.7.0 + * @category Function + * @sig (*... -> *) -> ([*]... -> [*]) + * @param {Function} fn The function to lift into higher context + * @return {Function} The lifted function. + * @see R.liftN + * @example + * + * const madd3 = R.lift((a, b, c) => a + b + c); + * + * madd3([1,2,3], [1,2,3], [1]); //=> [3, 4, 5, 4, 5, 6, 5, 6, 7] + * + * const madd5 = R.lift((a, b, c, d, e) => a + b + c + d + e); + * + * madd5([1,2], [3], [4, 5], [6], [7, 8]); //=> [21, 22, 22, 23, 22, 23, 23, 24] + */ + var lift = _curry1(function lift(fn) { + return liftN(fn.length, fn); + }); + + /** + * A function which calls the two provided functions and returns the `&&` + * of the results. + * It returns the result of the first function if it is false-y and the result + * of the second function otherwise. Note that this is short-circuited, + * meaning that the second function will not be invoked if the first returns a + * false-y value. + * + * In addition to functions, `R.both` also accepts any fantasy-land compatible + * applicative functor. + * + * @func + * @memberOf R + * @since v0.12.0 + * @category Logic + * @sig (*... -> Boolean) -> (*... -> Boolean) -> (*... -> Boolean) + * @param {Function} f A predicate + * @param {Function} g Another predicate + * @return {Function} a function that applies its arguments to `f` and `g` and `&&`s their outputs together. + * @see R.and + * @example + * + * const gt10 = R.gt(R.__, 10) + * const lt20 = R.lt(R.__, 20) + * const f = R.both(gt10, lt20); + * f(15); //=> true + * f(30); //=> false + * + * R.both(Maybe.Just(false), Maybe.Just(55)); // => Maybe.Just(false) + * R.both([false, false, 'a'], [11]); //=> [false, false, 11] + */ + var both = _curry2(function both(f, g) { + return _isFunction(f) ? + function _both() { + return f.apply(this, arguments) && g.apply(this, arguments); + } : + lift(and)(f, g); + }); + + /** + * Returns a curried equivalent of the provided function. The curried function + * has two unusual capabilities. First, its arguments needn't be provided one + * at a time. If `f` is a ternary function and `g` is `R.curry(f)`, the + * following are equivalent: + * + * - `g(1)(2)(3)` + * - `g(1)(2, 3)` + * - `g(1, 2)(3)` + * - `g(1, 2, 3)` + * + * Secondly, the special placeholder value [`R.__`](#__) may be used to specify + * "gaps", allowing partial application of any combination of arguments, + * regardless of their positions. If `g` is as above and `_` is [`R.__`](#__), + * the following are equivalent: + * + * - `g(1, 2, 3)` + * - `g(_, 2, 3)(1)` + * - `g(_, _, 3)(1)(2)` + * - `g(_, _, 3)(1, 2)` + * - `g(_, 2)(1)(3)` + * - `g(_, 2)(1, 3)` + * - `g(_, 2)(_, 3)(1)` + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Function + * @sig (* -> a) -> (* -> a) + * @param {Function} fn The function to curry. + * @return {Function} A new, curried function. + * @see R.curryN, R.partial + * @example + * + * const addFourNumbers = (a, b, c, d) => a + b + c + d; + * + * const curriedAddFourNumbers = R.curry(addFourNumbers); + * const f = curriedAddFourNumbers(1, 2); + * const g = f(3); + * g(4); //=> 10 + */ + var curry = _curry1(function curry(fn) { + return curryN(fn.length, fn); + }); + + /** + * Returns the result of calling its first argument with the remaining + * arguments. This is occasionally useful as a converging function for + * [`R.converge`](#converge): the first branch can produce a function while the + * remaining branches produce values to be passed to that function as its + * arguments. + * + * @func + * @memberOf R + * @since v0.9.0 + * @category Function + * @sig (*... -> a),*... -> a + * @param {Function} fn The function to apply to the remaining arguments. + * @param {...*} args Any number of positional arguments. + * @return {*} + * @see R.apply + * @example + * + * R.call(R.add, 1, 2); //=> 3 + * + * const indentN = R.pipe(R.repeat(' '), + * R.join(''), + * R.replace(/^(?!$)/gm)); + * + * const format = R.converge(R.call, [ + * R.pipe(R.prop('indent'), indentN), + * R.prop('value') + * ]); + * + * format({indent: 2, value: 'foo\nbar\nbaz\n'}); //=> ' foo\n bar\n baz\n' + * @symb R.call(f, a, b) = f(a, b) + */ + var call = curry(function call(fn) { + return fn.apply(this, Array.prototype.slice.call(arguments, 1)); + }); + + /** + * `_makeFlat` is a helper function that returns a one-level or fully recursive + * function based on the flag passed in. + * + * @private + */ + function _makeFlat(recursive) { + return function flatt(list) { + var value, jlen, j; + var result = []; + var idx = 0; + var ilen = list.length; + + while (idx < ilen) { + if (_isArrayLike(list[idx])) { + value = recursive ? flatt(list[idx]) : list[idx]; + j = 0; + jlen = value.length; + while (j < jlen) { + result[result.length] = value[j]; + j += 1; + } + } else { + result[result.length] = list[idx]; } - return acc; - }, {}, keys(filterable)) : - // else - _filter(pred, filterable) - ); -})); + idx += 1; + } + return result; + }; + } + + function _forceReduced(x) { + return { + '@@transducer/value': x, + '@@transducer/reduced': true + }; + } -/** - * The complement of [`filter`](#filter). - * - * Acts as a transducer if a transformer is given in list position. Filterable - * objects include plain objects or any object that has a filter method such - * as `Array`. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category List - * @sig Filterable f => (a -> Boolean) -> f a -> f a - * @param {Function} pred - * @param {Array} filterable - * @return {Array} - * @see R.filter, R.transduce, R.addIndex - * @example - * - * const isOdd = (n) => n % 2 === 1; - * - * R.reject(isOdd, [1, 2, 3, 4]); //=> [2, 4] - * - * R.reject(isOdd, {a: 1, b: 2, c: 3, d: 4}); //=> {b: 2, d: 4} - */ -var reject = _curry2(function reject(pred, filterable) { - return filter(_complement(pred), filterable); -}); - -function _toString(x, seen) { - var recur = function recur(y) { - var xs = seen.concat([x]); - return _includes(y, xs) ? '' : _toString(y, xs); + var preservingReduced = function(xf) { + return { + '@@transducer/init': _xfBase.init, + '@@transducer/result': function(result) { + return xf['@@transducer/result'](result); + }, + '@@transducer/step': function(result, input) { + var ret = xf['@@transducer/step'](result, input); + return ret['@@transducer/reduced'] ? _forceReduced(ret) : ret; + } + }; }; - // mapPairs :: (Object, [String]) -> [String] - var mapPairs = function(obj, keys$$1) { - return _map(function(k) { return _quote(k) + ': ' + recur(obj[k]); }, keys$$1.slice().sort()); + var _flatCat = function _xcat(xf) { + var rxf = preservingReduced(xf); + return { + '@@transducer/init': _xfBase.init, + '@@transducer/result': function(result) { + return rxf['@@transducer/result'](result); + }, + '@@transducer/step': function(result, input) { + return !_isArrayLike(input) ? _reduce(rxf, result, [input]) : _reduce(rxf, result, input); + } + }; }; - switch (Object.prototype.toString.call(x)) { - case '[object Arguments]': - return '(function() { return arguments; }(' + _map(recur, x).join(', ') + '))'; - case '[object Array]': - return '[' + _map(recur, x).concat(mapPairs(x, reject(function(k) { return /^\d+$/.test(k); }, keys(x)))).join(', ') + ']'; - case '[object Boolean]': - return typeof x === 'object' ? 'new Boolean(' + recur(x.valueOf()) + ')' : x.toString(); - case '[object Date]': - return 'new Date(' + (isNaN(x.valueOf()) ? recur(NaN) : _quote(_toISOString(x))) + ')'; - case '[object Null]': - return 'null'; - case '[object Number]': - return typeof x === 'object' ? 'new Number(' + recur(x.valueOf()) + ')' : 1 / x === -Infinity ? '-0' : x.toString(10); - case '[object String]': - return typeof x === 'object' ? 'new String(' + recur(x.valueOf()) + ')' : _quote(x); - case '[object Undefined]': - return 'undefined'; - default: - if (typeof x.toString === 'function') { - var repr = x.toString(); - if (repr !== '[object Object]') { - return repr; + var _xchain = _curry2(function _xchain(f, xf) { + return map(f, _flatCat(xf)); + }); + + /** + * `chain` maps a function over a list and concatenates the results. `chain` + * is also known as `flatMap` in some libraries. + * + * Dispatches to the `chain` method of the second argument, if present, + * according to the [FantasyLand Chain spec](https://github.com/fantasyland/fantasy-land#chain). + * + * If second argument is a function, `chain(f, g)(x)` is equivalent to `f(g(x), x)`. + * + * Acts as a transducer if a transformer is given in list position. + * + * @func + * @memberOf R + * @since v0.3.0 + * @category List + * @sig Chain m => (a -> m b) -> m a -> m b + * @param {Function} fn The function to map with + * @param {Array} list The list to map over + * @return {Array} The result of flat-mapping `list` with `fn` + * @example + * + * const duplicate = n => [n, n]; + * R.chain(duplicate, [1, 2, 3]); //=> [1, 1, 2, 2, 3, 3] + * + * R.chain(R.append, R.head)([1, 2, 3]); //=> [1, 2, 3, 1] + */ + var chain = _curry2(_dispatchable(['fantasy-land/chain', 'chain'], _xchain, function chain(fn, monad) { + if (typeof monad === 'function') { + return function(x) { return fn(monad(x))(x); }; + } + return _makeFlat(false)(map(fn, monad)); + })); + + /** + * Restricts a number to be within a range. + * + * Also works for other ordered types such as Strings and Dates. + * + * @func + * @memberOf R + * @since v0.20.0 + * @category Relation + * @sig Ord a => a -> a -> a -> a + * @param {Number} minimum The lower limit of the clamp (inclusive) + * @param {Number} maximum The upper limit of the clamp (inclusive) + * @param {Number} value Value to be clamped + * @return {Number} Returns `minimum` when `val < minimum`, `maximum` when `val > maximum`, returns `val` otherwise + * @example + * + * R.clamp(1, 10, -5) // => 1 + * R.clamp(1, 10, 15) // => 10 + * R.clamp(1, 10, 4) // => 4 + */ + var clamp = _curry3(function clamp(min, max, value) { + if (min > max) { + throw new Error('min must not be greater than max in clamp(min, max, value)'); + } + return value < min + ? min + : value > max + ? max + : value; + }); + + function _cloneRegExp(pattern) { + return new RegExp(pattern.source, (pattern.global ? 'g' : '') + + (pattern.ignoreCase ? 'i' : '') + + (pattern.multiline ? 'm' : '') + + (pattern.sticky ? 'y' : '') + + (pattern.unicode ? 'u' : '')); + } + + /** + * Gives a single-word string description of the (native) type of a value, + * returning such answers as 'Object', 'Number', 'Array', or 'Null'. Does not + * attempt to distinguish user Object types any further, reporting them all as + * 'Object'. + * + * @func + * @memberOf R + * @since v0.8.0 + * @category Type + * @sig (* -> {*}) -> String + * @param {*} val The value to test + * @return {String} + * @example + * + * R.type({}); //=> "Object" + * R.type(1); //=> "Number" + * R.type(false); //=> "Boolean" + * R.type('s'); //=> "String" + * R.type(null); //=> "Null" + * R.type([]); //=> "Array" + * R.type(/[A-z]/); //=> "RegExp" + * R.type(() => {}); //=> "Function" + * R.type(undefined); //=> "Undefined" + */ + var type = _curry1(function type(val) { + return val === null + ? 'Null' + : val === undefined + ? 'Undefined' + : Object.prototype.toString.call(val).slice(8, -1); + }); + + /** + * Copies an object. + * + * @private + * @param {*} value The value to be copied + * @param {Array} refFrom Array containing the source references + * @param {Array} refTo Array containing the copied source references + * @param {Boolean} deep Whether or not to perform deep cloning. + * @return {*} The copied value. + */ + function _clone(value, refFrom, refTo, deep) { + var copy = function copy(copiedValue) { + var len = refFrom.length; + var idx = 0; + while (idx < len) { + if (value === refFrom[idx]) { + return refTo[idx]; } + idx += 1; } - return '{' + mapPairs(x, keys(x)).join(', ') + '}'; + refFrom[idx + 1] = value; + refTo[idx + 1] = copiedValue; + for (var key in value) { + copiedValue[key] = deep ? + _clone(value[key], refFrom, refTo, true) : value[key]; + } + return copiedValue; + }; + switch (type(value)) { + case 'Object': return copy({}); + case 'Array': return copy([]); + case 'Date': return new Date(value.valueOf()); + case 'RegExp': return _cloneRegExp(value); + default: return value; + } } -} - -/** - * Returns the string representation of the given value. `eval`'ing the output - * should result in a value equivalent to the input value. Many of the built-in - * `toString` methods do not satisfy this requirement. - * - * If the given value is an `[object Object]` with a `toString` method other - * than `Object.prototype.toString`, this method is invoked with no arguments - * to produce the return value. This means user-defined constructor functions - * can provide a suitable `toString` method. For example: - * - * function Point(x, y) { - * this.x = x; - * this.y = y; - * } - * - * Point.prototype.toString = function() { - * return 'new Point(' + this.x + ', ' + this.y + ')'; - * }; - * - * R.toString(new Point(1, 2)); //=> 'new Point(1, 2)' - * - * @func - * @memberOf R - * @since v0.14.0 - * @category String - * @sig * -> String - * @param {*} val - * @return {String} - * @example - * - * R.toString(42); //=> '42' - * R.toString('abc'); //=> '"abc"' - * R.toString([1, 2, 3]); //=> '[1, 2, 3]' - * R.toString({foo: 1, bar: 2, baz: 3}); //=> '{"bar": 2, "baz": 3, "foo": 1}' - * R.toString(new Date('2001-02-03T04:05:06Z')); //=> 'new Date("2001-02-03T04:05:06.000Z")' - */ -var toString$1 = _curry1(function toString(val) { return _toString(val, []); }); - -/** - * Returns the result of concatenating the given lists or strings. - * - * Note: `R.concat` expects both arguments to be of the same type, - * unlike the native `Array.prototype.concat` method. It will throw - * an error if you `concat` an Array with a non-Array value. - * - * Dispatches to the `concat` method of the first argument, if present. - * Can also concatenate two members of a [fantasy-land - * compatible semigroup](https://github.com/fantasyland/fantasy-land#semigroup). - * - * @func - * @memberOf R - * @since v0.1.0 - * @category List - * @sig [a] -> [a] -> [a] - * @sig String -> String -> String - * @param {Array|String} firstList The first list - * @param {Array|String} secondList The second list - * @return {Array|String} A list consisting of the elements of `firstList` followed by the elements of - * `secondList`. - * - * @example - * - * R.concat('ABC', 'DEF'); // 'ABCDEF' - * R.concat([4, 5, 6], [1, 2, 3]); //=> [4, 5, 6, 1, 2, 3] - * R.concat([], []); //=> [] - */ -var concat = _curry2(function concat(a, b) { - if (_isArray(a)) { - if (_isArray(b)) { - return a.concat(b); + + /** + * Creates a deep copy of the value which may contain (nested) `Array`s and + * `Object`s, `Number`s, `String`s, `Boolean`s and `Date`s. `Function`s are + * assigned by reference rather than copied + * + * Dispatches to a `clone` method if present. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Object + * @sig {*} -> {*} + * @param {*} value The object or array to clone + * @return {*} A deeply cloned copy of `val` + * @example + * + * const objects = [{}, {}, {}]; + * const objectsClone = R.clone(objects); + * objects === objectsClone; //=> false + * objects[0] === objectsClone[0]; //=> false + */ + var clone = _curry1(function clone(value) { + return value != null && typeof value.clone === 'function' ? + value.clone() : + _clone(value, [], [], true); + }); + + /** + * Makes a comparator function out of a function that reports whether the first + * element is less than the second. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Function + * @sig ((a, b) -> Boolean) -> ((a, b) -> Number) + * @param {Function} pred A predicate function of arity two which will return `true` if the first argument + * is less than the second, `false` otherwise + * @return {Function} A Function :: a -> b -> Int that returns `-1` if a < b, `1` if b < a, otherwise `0` + * @example + * + * const byAge = R.comparator((a, b) => a.age < b.age); + * const people = [ + * { name: 'Emma', age: 70 }, + * { name: 'Peter', age: 78 }, + * { name: 'Mikhail', age: 62 }, + * ]; + * const peopleByIncreasingAge = R.sort(byAge, people); + * //=> [{ name: 'Mikhail', age: 62 },{ name: 'Emma', age: 70 }, { name: 'Peter', age: 78 }] + */ + var comparator = _curry1(function comparator(pred) { + return function(a, b) { + return pred(a, b) ? -1 : pred(b, a) ? 1 : 0; + }; + }); + + /** + * A function that returns the `!` of its argument. It will return `true` when + * passed false-y value, and `false` when passed a truth-y one. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Logic + * @sig * -> Boolean + * @param {*} a any value + * @return {Boolean} the logical inverse of passed argument. + * @see R.complement + * @example + * + * R.not(true); //=> false + * R.not(false); //=> true + * R.not(0); //=> true + * R.not(1); //=> false + */ + var not = _curry1(function not(a) { + return !a; + }); + + /** + * Takes a function `f` and returns a function `g` such that if called with the same arguments + * when `f` returns a "truthy" value, `g` returns `false` and when `f` returns a "falsy" value `g` returns `true`. + * + * `R.complement` may be applied to any functor + * + * @func + * @memberOf R + * @since v0.12.0 + * @category Logic + * @sig (*... -> *) -> (*... -> Boolean) + * @param {Function} f + * @return {Function} + * @see R.not + * @example + * + * const isNotNil = R.complement(R.isNil); + * isNil(null); //=> true + * isNotNil(null); //=> false + * isNil(7); //=> false + * isNotNil(7); //=> true + */ + var complement = lift(not); + + function _pipe(f, g) { + return function() { + return g.call(this, f.apply(this, arguments)); + }; + } + + /** + * This checks whether a function has a [methodname] function. If it isn't an + * array it will execute that function otherwise it will default to the ramda + * implementation. + * + * @private + * @param {Function} fn ramda implemtation + * @param {String} methodname property to check for a custom implementation + * @return {Object} Whatever the return value of the method is. + */ + function _checkForMethod(methodname, fn) { + return function() { + var length = arguments.length; + if (length === 0) { + return fn(); + } + var obj = arguments[length - 1]; + return (_isArray(obj) || typeof obj[methodname] !== 'function') ? + fn.apply(this, arguments) : + obj[methodname].apply(obj, Array.prototype.slice.call(arguments, 0, length - 1)); + }; + } + + /** + * Returns the elements of the given list or string (or object with a `slice` + * method) from `fromIndex` (inclusive) to `toIndex` (exclusive). + * + * Dispatches to the `slice` method of the third argument, if present. + * + * @func + * @memberOf R + * @since v0.1.4 + * @category List + * @sig Number -> Number -> [a] -> [a] + * @sig Number -> Number -> String -> String + * @param {Number} fromIndex The start index (inclusive). + * @param {Number} toIndex The end index (exclusive). + * @param {*} list + * @return {*} + * @example + * + * R.slice(1, 3, ['a', 'b', 'c', 'd']); //=> ['b', 'c'] + * R.slice(1, Infinity, ['a', 'b', 'c', 'd']); //=> ['b', 'c', 'd'] + * R.slice(0, -1, ['a', 'b', 'c', 'd']); //=> ['a', 'b', 'c'] + * R.slice(-3, -1, ['a', 'b', 'c', 'd']); //=> ['b', 'c'] + * R.slice(0, 3, 'ramda'); //=> 'ram' + */ + var slice = _curry3(_checkForMethod('slice', function slice(fromIndex, toIndex, list) { + return Array.prototype.slice.call(list, fromIndex, toIndex); + })); + + /** + * Returns all but the first element of the given list or string (or object + * with a `tail` method). + * + * Dispatches to the `slice` method of the first argument, if present. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category List + * @sig [a] -> [a] + * @sig String -> String + * @param {*} list + * @return {*} + * @see R.head, R.init, R.last + * @example + * + * R.tail([1, 2, 3]); //=> [2, 3] + * R.tail([1, 2]); //=> [2] + * R.tail([1]); //=> [] + * R.tail([]); //=> [] + * + * R.tail('abc'); //=> 'bc' + * R.tail('ab'); //=> 'b' + * R.tail('a'); //=> '' + * R.tail(''); //=> '' + */ + var tail = _curry1(_checkForMethod('tail', slice(1, Infinity))); + + /** + * Performs left-to-right function composition. The first argument may have + * any arity; the remaining arguments must be unary. + * + * In some libraries this function is named `sequence`. + * + * **Note:** The result of pipe is not automatically curried. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Function + * @sig (((a, b, ..., n) -> o), (o -> p), ..., (x -> y), (y -> z)) -> ((a, b, ..., n) -> z) + * @param {...Function} functions + * @return {Function} + * @see R.compose + * @example + * + * const f = R.pipe(Math.pow, R.negate, R.inc); + * + * f(3, 4); // -(3^4) + 1 + * @symb R.pipe(f, g, h)(a, b) = h(g(f(a, b))) + */ + function pipe() { + if (arguments.length === 0) { + throw new Error('pipe requires at least one argument'); } - throw new TypeError(toString$1(b) + ' is not an array'); + return _arity( + arguments[0].length, + reduce(_pipe, arguments[0], tail(arguments)) + ); } - if (_isString(a)) { - if (_isString(b)) { - return a + b; + + /** + * Returns a new list or string with the elements or characters in reverse + * order. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category List + * @sig [a] -> [a] + * @sig String -> String + * @param {Array|String} list + * @return {Array|String} + * @example + * + * R.reverse([1, 2, 3]); //=> [3, 2, 1] + * R.reverse([1, 2]); //=> [2, 1] + * R.reverse([1]); //=> [1] + * R.reverse([]); //=> [] + * + * R.reverse('abc'); //=> 'cba' + * R.reverse('ab'); //=> 'ba' + * R.reverse('a'); //=> 'a' + * R.reverse(''); //=> '' + */ + var reverse = _curry1(function reverse(list) { + return _isString(list) + ? list.split('').reverse().join('') + : Array.prototype.slice.call(list, 0).reverse(); + }); + + /** + * Performs right-to-left function composition. The last argument may have + * any arity; the remaining arguments must be unary. + * + * **Note:** The result of compose is not automatically curried. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Function + * @sig ((y -> z), (x -> y), ..., (o -> p), ((a, b, ..., n) -> o)) -> ((a, b, ..., n) -> z) + * @param {...Function} ...functions The functions to compose + * @return {Function} + * @see R.pipe + * @example + * + * const classyGreeting = (firstName, lastName) => "The name's " + lastName + ", " + firstName + " " + lastName + * const yellGreeting = R.compose(R.toUpper, classyGreeting); + * yellGreeting('James', 'Bond'); //=> "THE NAME'S BOND, JAMES BOND" + * + * R.compose(Math.abs, R.add(1), R.multiply(2))(-4) //=> 7 + * + * @symb R.compose(f, g, h)(a, b) = f(g(h(a, b))) + */ + function compose() { + if (arguments.length === 0) { + throw new Error('compose requires at least one argument'); + } + return pipe.apply(this, reverse(arguments)); + } + + /** + * Returns the right-to-left Kleisli composition of the provided functions, + * each of which must return a value of a type supported by [`chain`](#chain). + * + * `R.composeK(h, g, f)` is equivalent to `R.compose(R.chain(h), R.chain(g), f)`. + * + * @func + * @memberOf R + * @since v0.16.0 + * @category Function + * @sig Chain m => ((y -> m z), (x -> m y), ..., (a -> m b)) -> (a -> m z) + * @param {...Function} ...functions The functions to compose + * @return {Function} + * @see R.pipeK + * @deprecated since v0.26.0 + * @example + * + * // get :: String -> Object -> Maybe * + * const get = R.curry((propName, obj) => Maybe(obj[propName])) + * + * // getStateCode :: Maybe String -> Maybe String + * const getStateCode = R.composeK( + * R.compose(Maybe.of, R.toUpper), + * get('state'), + * get('address'), + * get('user'), + * ); + * getStateCode({"user":{"address":{"state":"ny"}}}); //=> Maybe.Just("NY") + * getStateCode({}); //=> Maybe.Nothing() + * @symb R.composeK(f, g, h)(a) = R.chain(f, R.chain(g, h(a))) + */ + function composeK() { + if (arguments.length === 0) { + throw new Error('composeK requires at least one argument'); } - throw new TypeError(toString$1(b) + ' is not a string'); + var init = Array.prototype.slice.call(arguments); + var last = init.pop(); + return compose(compose.apply(this, map(chain, init)), last); + } + + function _pipeP(f, g) { + return function() { + var ctx = this; + return f.apply(ctx, arguments).then(function(x) { + return g.call(ctx, x); + }); + }; } - if (a != null && _isFunction(a['fantasy-land/concat'])) { - return a['fantasy-land/concat'](b); + + /** + * Performs left-to-right composition of one or more Promise-returning + * functions. The first argument may have any arity; the remaining arguments + * must be unary. + * + * @func + * @memberOf R + * @since v0.10.0 + * @category Function + * @sig ((a -> Promise b), (b -> Promise c), ..., (y -> Promise z)) -> (a -> Promise z) + * @param {...Function} functions + * @return {Function} + * @see R.composeP + * @deprecated since v0.26.0 + * @example + * + * // followersForUser :: String -> Promise [User] + * const followersForUser = R.pipeP(db.getUserById, db.getFollowers); + */ + function pipeP() { + if (arguments.length === 0) { + throw new Error('pipeP requires at least one argument'); + } + return _arity( + arguments[0].length, + reduce(_pipeP, arguments[0], tail(arguments)) + ); } - if (a != null && _isFunction(a.concat)) { - return a.concat(b); + + /** + * Performs right-to-left composition of one or more Promise-returning + * functions. The last arguments may have any arity; the remaining + * arguments must be unary. + * + * @func + * @memberOf R + * @since v0.10.0 + * @category Function + * @sig ((y -> Promise z), (x -> Promise y), ..., (a -> Promise b)) -> (a -> Promise z) + * @param {...Function} functions The functions to compose + * @return {Function} + * @see R.pipeP + * @deprecated since v0.26.0 + * @example + * + * const db = { + * users: { + * JOE: { + * name: 'Joe', + * followers: ['STEVE', 'SUZY'] + * } + * } + * } + * + * // We'll pretend to do a db lookup which returns a promise + * const lookupUser = (userId) => Promise.resolve(db.users[userId]) + * const lookupFollowers = (user) => Promise.resolve(user.followers) + * lookupUser('JOE').then(lookupFollowers) + * + * // followersForUser :: String -> Promise [UserId] + * const followersForUser = R.composeP(lookupFollowers, lookupUser); + * followersForUser('JOE').then(followers => console.log('Followers:', followers)) + * // Followers: ["STEVE","SUZY"] + */ + function composeP() { + if (arguments.length === 0) { + throw new Error('composeP requires at least one argument'); + } + return pipeP.apply(this, reverse(arguments)); + } + + /** + * Returns the first element of the given list or string. In some libraries + * this function is named `first`. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category List + * @sig [a] -> a | Undefined + * @sig String -> String + * @param {Array|String} list + * @return {*} + * @see R.tail, R.init, R.last + * @example + * + * R.head(['fi', 'fo', 'fum']); //=> 'fi' + * R.head([]); //=> undefined + * + * R.head('abc'); //=> 'a' + * R.head(''); //=> '' + */ + var head = nth(0); + + function _identity(x) { return x; } + + /** + * A function that does nothing but return the parameter supplied to it. Good + * as a default or placeholder function. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Function + * @sig a -> a + * @param {*} x The value to return. + * @return {*} The input value, `x`. + * @example + * + * R.identity(1); //=> 1 + * + * const obj = {}; + * R.identity(obj) === obj; //=> true + * @symb R.identity(a) = a + */ + var identity = _curry1(_identity); + + /** + * Performs left-to-right function composition using transforming function. The first argument may have + * any arity; the remaining arguments must be unary. + * + * **Note:** The result of pipeWith is not automatically curried. Transforming function is not used on the + * first argument. + * + * @func + * @memberOf R + * @since v0.26.0 + * @category Function + * @sig ((* -> *), [((a, b, ..., n) -> o), (o -> p), ..., (x -> y), (y -> z)]) -> ((a, b, ..., n) -> z) + * @param {...Function} functions + * @return {Function} + * @see R.composeWith, R.pipe + * @example + * + * const pipeWhileNotNil = R.pipeWith((f, res) => R.isNil(res) ? res : f(res)); + * const f = pipeWhileNotNil([Math.pow, R.negate, R.inc]) + * + * f(3, 4); // -(3^4) + 1 + * @symb R.pipeWith(f)([g, h, i])(...args) = f(i, f(h, g(...args))) + */ + var pipeWith = _curry2(function pipeWith(xf, list) { + if (list.length <= 0) { + return identity; + } + + var headList = head(list); + var tailList = tail(list); + + return _arity(headList.length, function() { + return _reduce( + function(result, f) { + return xf.call(this, f, result); + }, + headList.apply(this, arguments), + tailList + ); + }); + }); + + /** + * Performs right-to-left function composition using transforming function. The last argument may have + * any arity; the remaining arguments must be unary. + * + * **Note:** The result of compose is not automatically curried. Transforming function is not used on the + * last argument. + * + * @func + * @memberOf R + * @since v0.26.0 + * @category Function + * @sig ((* -> *), [(y -> z), (x -> y), ..., (o -> p), ((a, b, ..., n) -> o)]) -> ((a, b, ..., n) -> z) + * @param {...Function} ...functions The functions to compose + * @return {Function} + * @see R.compose, R.pipeWith + * @example + * + * const composeWhileNotNil = R.composeWith((f, res) => R.isNil(res) ? res : f(res)); + * + * composeWhileNotNil([R.inc, R.prop('age')])({age: 1}) //=> 2 + * composeWhileNotNil([R.inc, R.prop('age')])({}) //=> undefined + * + * @symb R.composeWith(f)([g, h, i])(...args) = f(g, f(h, i(...args))) + */ + var composeWith = _curry2(function composeWith(xf, list) { + return pipeWith.apply(this, [xf, reverse(list)]); + }); + + function _arrayFromIterator(iter) { + var list = []; + var next; + while (!(next = iter.next()).done) { + list.push(next.value); + } + return list; } - throw new TypeError(toString$1(a) + ' does not have a method named "concat" or "fantasy-land/concat"'); -}); - -/** - * Returns a function, `fn`, which encapsulates `if/else, if/else, ...` logic. - * `R.cond` takes a list of [predicate, transformer] pairs. All of the arguments - * to `fn` are applied to each of the predicates in turn until one returns a - * "truthy" value, at which point `fn` returns the result of applying its - * arguments to the corresponding transformer. If none of the predicates - * matches, `fn` returns undefined. - * - * @func - * @memberOf R - * @since v0.6.0 - * @category Logic - * @sig [[(*... -> Boolean),(*... -> *)]] -> (*... -> *) - * @param {Array} pairs A list of [predicate, transformer] - * @return {Function} - * @see R.ifElse, R.unless, R.when - * @example - * - * const fn = R.cond([ - * [R.equals(0), R.always('water freezes at 0°C')], - * [R.equals(100), R.always('water boils at 100°C')], - * [R.T, temp => 'nothing special happens at ' + temp + '°C'] - * ]); - * fn(0); //=> 'water freezes at 0°C' - * fn(50); //=> 'nothing special happens at 50°C' - * fn(100); //=> 'water boils at 100°C' - */ -var cond = _curry1(function cond(pairs) { - var arity = reduce(max, - 0, - map(function(pair) { return pair[0].length; }, pairs)); - return _arity(arity, function() { + + function _includesWith(pred, x, list) { var idx = 0; - while (idx < pairs.length) { - if (pairs[idx][0].apply(this, arguments)) { - return pairs[idx][1].apply(this, arguments); + var len = list.length; + + while (idx < len) { + if (pred(x, list[idx])) { + return true; } idx += 1; } - }); -}); - -/** - * Wraps a constructor function inside a curried function that can be called - * with the same arguments and returns the same type. The arity of the function - * returned is specified to allow using variadic constructor functions. - * - * @func - * @memberOf R - * @since v0.4.0 - * @category Function - * @sig Number -> (* -> {*}) -> (* -> {*}) - * @param {Number} n The arity of the constructor function. - * @param {Function} Fn The constructor function to wrap. - * @return {Function} A wrapped, curried constructor function. - * @example - * - * // Variadic Constructor function - * function Salad() { - * this.ingredients = arguments; - * } - * - * Salad.prototype.recipe = function() { - * const instructions = R.map(ingredient => 'Add a dollop of ' + ingredient, this.ingredients); - * return R.join('\n', instructions); - * }; - * - * const ThreeLayerSalad = R.constructN(3, Salad); - * - * // Notice we no longer need the 'new' keyword, and the constructor is curried for 3 arguments. - * const salad = ThreeLayerSalad('Mayonnaise')('Potato Chips')('Ketchup'); - * - * console.log(salad.recipe()); - * // Add a dollop of Mayonnaise - * // Add a dollop of Potato Chips - * // Add a dollop of Ketchup - */ -var constructN = _curry2(function constructN(n, Fn) { - if (n > 10) { - throw new Error('Constructor with greater than ten arguments'); + return false; } - if (n === 0) { - return function() { return new Fn(); }; + + function _functionName(f) { + // String(x => x) evaluates to "x => x", so the pattern may not match. + var match = String(f).match(/^function (\w*)/); + return match == null ? '' : match[1]; } - return curry(nAry(n, function($0, $1, $2, $3, $4, $5, $6, $7, $8, $9) { - switch (arguments.length) { - case 1: return new Fn($0); - case 2: return new Fn($0, $1); - case 3: return new Fn($0, $1, $2); - case 4: return new Fn($0, $1, $2, $3); - case 5: return new Fn($0, $1, $2, $3, $4); - case 6: return new Fn($0, $1, $2, $3, $4, $5); - case 7: return new Fn($0, $1, $2, $3, $4, $5, $6); - case 8: return new Fn($0, $1, $2, $3, $4, $5, $6, $7); - case 9: return new Fn($0, $1, $2, $3, $4, $5, $6, $7, $8); - case 10: return new Fn($0, $1, $2, $3, $4, $5, $6, $7, $8, $9); + + // Based on https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is + function _objectIs(a, b) { + // SameValue algorithm + if (a === b) { // Steps 1-5, 7-10 + // Steps 6.b-6.e: +0 != -0 + return a !== 0 || 1 / a === 1 / b; + } else { + // Step 6.a: NaN == NaN + return a !== a && b !== b; } - })); -}); - -/** - * Wraps a constructor function inside a curried function that can be called - * with the same arguments and returns the same type. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Function - * @sig (* -> {*}) -> (* -> {*}) - * @param {Function} fn The constructor function to wrap. - * @return {Function} A wrapped, curried constructor function. - * @see R.invoker - * @example - * - * // Constructor function - * function Animal(kind) { - * this.kind = kind; - * }; - * Animal.prototype.sighting = function() { - * return "It's a " + this.kind + "!"; - * } - * - * const AnimalConstructor = R.construct(Animal) - * - * // Notice we no longer need the 'new' keyword: - * AnimalConstructor('Pig'); //=> {"kind": "Pig", "sighting": function (){...}}; - * - * const animalTypes = ["Lion", "Tiger", "Bear"]; - * const animalSighting = R.invoker(0, 'sighting'); - * const sightNewAnimal = R.compose(animalSighting, AnimalConstructor); - * R.map(sightNewAnimal, animalTypes); //=> ["It's a Lion!", "It's a Tiger!", "It's a Bear!"] - */ -var construct = _curry1(function construct(Fn) { - return constructN(Fn.length, Fn); -}); - -/** - * Returns `true` if the specified value is equal, in [`R.equals`](#equals) - * terms, to at least one element of the given list; `false` otherwise. - * Works also with strings. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category List - * @sig a -> [a] -> Boolean - * @param {Object} a The item to compare against. - * @param {Array} list The array to consider. - * @return {Boolean} `true` if an equivalent item is in the list, `false` otherwise. - * @see R.includes - * @deprecated since v0.26.0 - * @example - * - * R.contains(3, [1, 2, 3]); //=> true - * R.contains(4, [1, 2, 3]); //=> false - * R.contains({ name: 'Fred' }, [{ name: 'Fred' }]); //=> true - * R.contains([42], [[42]]); //=> true - * R.contains('ba', 'banana'); //=>true - */ -var contains$1 = _curry2(_includes); - -/** - * Accepts a converging function and a list of branching functions and returns - * a new function. The arity of the new function is the same as the arity of - * the longest branching function. When invoked, this new function is applied - * to some arguments, and each branching function is applied to those same - * arguments. The results of each branching function are passed as arguments - * to the converging function to produce the return value. - * - * @func - * @memberOf R - * @since v0.4.2 - * @category Function - * @sig ((x1, x2, ...) -> z) -> [((a, b, ...) -> x1), ((a, b, ...) -> x2), ...] -> (a -> b -> ... -> z) - * @param {Function} after A function. `after` will be invoked with the return values of - * `fn1` and `fn2` as its arguments. - * @param {Array} functions A list of functions. - * @return {Function} A new function. - * @see R.useWith - * @example - * - * const average = R.converge(R.divide, [R.sum, R.length]) - * average([1, 2, 3, 4, 5, 6, 7]) //=> 4 - * - * const strangeConcat = R.converge(R.concat, [R.toUpper, R.toLower]) - * strangeConcat("Yodel") //=> "YODELyodel" - * - * @symb R.converge(f, [g, h])(a, b) = f(g(a, b), h(a, b)) - */ -var converge = _curry2(function converge(after, fns) { - return curryN(reduce(max, 0, pluck('length', fns)), function() { - var args = arguments; - var context = this; - return after.apply(context, _map(function(fn) { - return fn.apply(context, args); - }, fns)); - }); -}); - -function XReduceBy(valueFn, valueAcc, keyFn, xf) { - this.valueFn = valueFn; - this.valueAcc = valueAcc; - this.keyFn = keyFn; - this.xf = xf; - this.inputs = {}; -} -XReduceBy.prototype['@@transducer/init'] = _xfBase.init; -XReduceBy.prototype['@@transducer/result'] = function(result) { - var key; - for (key in this.inputs) { - if (_has(key, this.inputs)) { - result = this.xf['@@transducer/step'](result, this.inputs[key]); - if (result['@@transducer/reduced']) { - result = result['@@transducer/value']; - break; - } + } + + var _objectIs$1 = typeof Object.is === 'function' ? Object.is : _objectIs; + + /** + * private _uniqContentEquals function. + * That function is checking equality of 2 iterator contents with 2 assumptions + * - iterators lengths are the same + * - iterators values are unique + * + * false-positive result will be returned for comparision of, e.g. + * - [1,2,3] and [1,2,3,4] + * - [1,1,1] and [1,2,3] + * */ + + function _uniqContentEquals(aIterator, bIterator, stackA, stackB) { + var a = _arrayFromIterator(aIterator); + var b = _arrayFromIterator(bIterator); + + function eq(_a, _b) { + return _equals(_a, _b, stackA.slice(), stackB.slice()); } + + // if *a* array contains any element that is not included in *b* + return !_includesWith(function(b, aItem) { + return !_includesWith(eq, aItem, b); + }, b, a); } - this.inputs = null; - return this.xf['@@transducer/result'](result); -}; -XReduceBy.prototype['@@transducer/step'] = function(result, input) { - var key = this.keyFn(input); - this.inputs[key] = this.inputs[key] || [key, this.valueAcc]; - this.inputs[key][1] = this.valueFn(this.inputs[key][1], input); - return result; -}; - -var _xreduceBy = _curryN(4, [], - function _xreduceBy(valueFn, valueAcc, keyFn, xf) { - return new XReduceBy(valueFn, valueAcc, keyFn, xf); - }); - -/** - * Groups the elements of the list according to the result of calling - * the String-returning function `keyFn` on each element and reduces the elements - * of each group to a single value via the reducer function `valueFn`. - * - * This function is basically a more general [`groupBy`](#groupBy) function. - * - * Acts as a transducer if a transformer is given in list position. - * - * @func - * @memberOf R - * @since v0.20.0 - * @category List - * @sig ((a, b) -> a) -> a -> (b -> String) -> [b] -> {String: a} - * @param {Function} valueFn The function that reduces the elements of each group to a single - * value. Receives two values, accumulator for a particular group and the current element. - * @param {*} acc The (initial) accumulator value for each group. - * @param {Function} keyFn The function that maps the list's element into a key. - * @param {Array} list The array to group. - * @return {Object} An object with the output of `keyFn` for keys, mapped to the output of - * `valueFn` for elements which produced that key when passed to `keyFn`. - * @see R.groupBy, R.reduce - * @example - * - * const groupNames = (acc, {name}) => acc.concat(name) - * const toGrade = ({score}) => - * score < 65 ? 'F' : - * score < 70 ? 'D' : - * score < 80 ? 'C' : - * score < 90 ? 'B' : 'A' - * - * var students = [ - * {name: 'Abby', score: 83}, - * {name: 'Bart', score: 62}, - * {name: 'Curt', score: 88}, - * {name: 'Dora', score: 92}, - * ] - * - * reduceBy(groupNames, [], toGrade, students) - * //=> {"A": ["Dora"], "B": ["Abby", "Curt"], "F": ["Bart"]} - */ -var reduceBy = _curryN(4, [], _dispatchable([], _xreduceBy, - function reduceBy(valueFn, valueAcc, keyFn, list) { - return _reduce(function(acc, elt) { - var key = keyFn(elt); - acc[key] = valueFn(_has(key, acc) ? acc[key] : valueAcc, elt); - return acc; - }, {}, list); - })); -/** - * Counts the elements of a list according to how many match each value of a - * key generated by the supplied function. Returns an object mapping the keys - * produced by `fn` to the number of occurrences in the list. Note that all - * keys are coerced to strings because of how JavaScript objects work. - * - * Acts as a transducer if a transformer is given in list position. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Relation - * @sig (a -> String) -> [a] -> {*} - * @param {Function} fn The function used to map values to keys. - * @param {Array} list The list to count elements from. - * @return {Object} An object mapping keys to number of occurrences in the list. - * @example - * - * const numbers = [1.0, 1.1, 1.2, 2.0, 3.0, 2.2]; - * R.countBy(Math.floor)(numbers); //=> {'1': 3, '2': 2, '3': 1} - * - * const letters = ['a', 'b', 'A', 'a', 'B', 'c']; - * R.countBy(R.toLower)(letters); //=> {'a': 3, 'b': 2, 'c': 1} - */ -var countBy = reduceBy(function(acc, elem) { return acc + 1; }, 0); - -/** - * Decrements its argument. - * - * @func - * @memberOf R - * @since v0.9.0 - * @category Math - * @sig Number -> Number - * @param {Number} n - * @return {Number} n - 1 - * @see R.inc - * @example - * - * R.dec(42); //=> 41 - */ -var dec = add(-1); - -/** - * Returns the second argument if it is not `null`, `undefined` or `NaN`; - * otherwise the first argument is returned. - * - * @func - * @memberOf R - * @since v0.10.0 - * @category Logic - * @sig a -> b -> a | b - * @param {a} default The default value. - * @param {b} val `val` will be returned instead of `default` unless `val` is `null`, `undefined` or `NaN`. - * @return {*} The second value if it is not `null`, `undefined` or `NaN`, otherwise the default value - * @example - * - * const defaultTo42 = R.defaultTo(42); - * - * defaultTo42(null); //=> 42 - * defaultTo42(undefined); //=> 42 - * defaultTo42(false); //=> false - * defaultTo42('Ramda'); //=> 'Ramda' - * // parseInt('string') results in NaN - * defaultTo42(parseInt('string')); //=> 42 - */ -var defaultTo = _curry2(function defaultTo(d, v) { - return v == null || v !== v ? d : v; -}); - -/** - * Makes a descending comparator function out of a function that returns a value - * that can be compared with `<` and `>`. - * - * @func - * @memberOf R - * @since v0.23.0 - * @category Function - * @sig Ord b => (a -> b) -> a -> a -> Number - * @param {Function} fn A function of arity one that returns a value that can be compared - * @param {*} a The first item to be compared. - * @param {*} b The second item to be compared. - * @return {Number} `-1` if fn(a) > fn(b), `1` if fn(b) > fn(a), otherwise `0` - * @see R.ascend - * @example - * - * const byAge = R.descend(R.prop('age')); - * const people = [ - * { name: 'Emma', age: 70 }, - * { name: 'Peter', age: 78 }, - * { name: 'Mikhail', age: 62 }, - * ]; - * const peopleByOldestFirst = R.sort(byAge, people); - * //=> [{ name: 'Peter', age: 78 }, { name: 'Emma', age: 70 }, { name: 'Mikhail', age: 62 }] - */ -var descend = _curry3(function descend(fn, a, b) { - var aa = fn(a); - var bb = fn(b); - return aa > bb ? -1 : aa < bb ? 1 : 0; -}); - -function _Set() { - /* globals Set */ - this._nativeSet = typeof Set === 'function' ? new Set() : null; - this._items = {}; -} - -// until we figure out why jsdoc chokes on this -// @param item The item to add to the Set -// @returns {boolean} true if the item did not exist prior, otherwise false -// -_Set.prototype.add = function(item) { - return !hasOrAdd(item, true, this); -}; - -// -// @param item The item to check for existence in the Set -// @returns {boolean} true if the item exists in the Set, otherwise false -// -_Set.prototype.has = function(item) { - return hasOrAdd(item, false, this); -}; - -// -// Combines the logic for checking whether an item is a member of the set and -// for adding a new item to the set. -// -// @param item The item to check or add to the Set instance. -// @param shouldAdd If true, the item will be added to the set if it doesn't -// already exist. -// @param set The set instance to check or add to. -// @return {boolean} true if the item already existed, otherwise false. -// -function hasOrAdd(item, shouldAdd, set) { - var type = typeof item; - var prevSize, newSize; - switch (type) { - case 'string': - case 'number': - // distinguish between +0 and -0 - if (item === 0 && 1 / item === -Infinity) { - if (set._items['-0']) { - return true; - } else { - if (shouldAdd) { - set._items['-0'] = true; - } - return false; + function _equals(a, b, stackA, stackB) { + if (_objectIs$1(a, b)) { + return true; + } + + var typeA = type(a); + + if (typeA !== type(b)) { + return false; + } + + if (a == null || b == null) { + return false; + } + + if (typeof a['fantasy-land/equals'] === 'function' || typeof b['fantasy-land/equals'] === 'function') { + return typeof a['fantasy-land/equals'] === 'function' && a['fantasy-land/equals'](b) && + typeof b['fantasy-land/equals'] === 'function' && b['fantasy-land/equals'](a); + } + + if (typeof a.equals === 'function' || typeof b.equals === 'function') { + return typeof a.equals === 'function' && a.equals(b) && + typeof b.equals === 'function' && b.equals(a); + } + + switch (typeA) { + case 'Arguments': + case 'Array': + case 'Object': + if (typeof a.constructor === 'function' && + _functionName(a.constructor) === 'Promise') { + return a === b; } - } - // these types can all utilise the native Set - if (set._nativeSet !== null) { - if (shouldAdd) { - prevSize = set._nativeSet.size; - set._nativeSet.add(item); - newSize = set._nativeSet.size; - return newSize === prevSize; - } else { - return set._nativeSet.has(item); + break; + case 'Boolean': + case 'Number': + case 'String': + if (!(typeof a === typeof b && _objectIs$1(a.valueOf(), b.valueOf()))) { + return false; } - } else { - if (!(type in set._items)) { - if (shouldAdd) { - set._items[type] = {}; - set._items[type][item] = true; - } + break; + case 'Date': + if (!_objectIs$1(a.valueOf(), b.valueOf())) { return false; - } else if (item in set._items[type]) { - return true; - } else { - if (shouldAdd) { - set._items[type][item] = true; - } + } + break; + case 'Error': + return a.name === b.name && a.message === b.message; + case 'RegExp': + if (!(a.source === b.source && + a.global === b.global && + a.ignoreCase === b.ignoreCase && + a.multiline === b.multiline && + a.sticky === b.sticky && + a.unicode === b.unicode)) { return false; } + break; + } + + var idx = stackA.length - 1; + while (idx >= 0) { + if (stackA[idx] === a) { + return stackB[idx] === b; } + idx -= 1; + } - case 'boolean': - // set._items['boolean'] holds a two element array - // representing [ falseExists, trueExists ] - if (type in set._items) { - var bIdx = item ? 1 : 0; - if (set._items[type][bIdx]) { - return true; - } else { - if (shouldAdd) { - set._items[type][bIdx] = true; - } + switch (typeA) { + case 'Map': + if (a.size !== b.size) { return false; } - } else { - if (shouldAdd) { - set._items[type] = item ? [false, true] : [true, false]; - } - return false; - } - case 'function': - // compare functions for reference equality - if (set._nativeSet !== null) { - if (shouldAdd) { - prevSize = set._nativeSet.size; - set._nativeSet.add(item); - newSize = set._nativeSet.size; - return newSize === prevSize; - } else { - return set._nativeSet.has(item); + return _uniqContentEquals(a.entries(), b.entries(), stackA.concat([a]), stackB.concat([b])); + case 'Set': + if (a.size !== b.size) { + return false; } - } else { - if (!(type in set._items)) { + + return _uniqContentEquals(a.values(), b.values(), stackA.concat([a]), stackB.concat([b])); + case 'Arguments': + case 'Array': + case 'Object': + case 'Boolean': + case 'Number': + case 'String': + case 'Date': + case 'Error': + case 'RegExp': + case 'Int8Array': + case 'Uint8Array': + case 'Uint8ClampedArray': + case 'Int16Array': + case 'Uint16Array': + case 'Int32Array': + case 'Uint32Array': + case 'Float32Array': + case 'Float64Array': + case 'ArrayBuffer': + break; + default: + // Values of other types are only equal if identical. + return false; + } + + var keysA = keys(a); + if (keysA.length !== keys(b).length) { + return false; + } + + var extendedStackA = stackA.concat([a]); + var extendedStackB = stackB.concat([b]); + + idx = keysA.length - 1; + while (idx >= 0) { + var key = keysA[idx]; + if (!(_has(key, b) && _equals(b[key], a[key], extendedStackA, extendedStackB))) { + return false; + } + idx -= 1; + } + return true; + } + + /** + * Returns `true` if its arguments are equivalent, `false` otherwise. Handles + * cyclical data structures. + * + * Dispatches symmetrically to the `equals` methods of both arguments, if + * present. + * + * @func + * @memberOf R + * @since v0.15.0 + * @category Relation + * @sig a -> b -> Boolean + * @param {*} a + * @param {*} b + * @return {Boolean} + * @example + * + * R.equals(1, 1); //=> true + * R.equals(1, '1'); //=> false + * R.equals([1, 2, 3], [1, 2, 3]); //=> true + * + * const a = {}; a.v = a; + * const b = {}; b.v = b; + * R.equals(a, b); //=> true + */ + var equals = _curry2(function equals(a, b) { + return _equals(a, b, [], []); + }); + + function _indexOf(list, a, idx) { + var inf, item; + // Array.prototype.indexOf doesn't exist below IE9 + if (typeof list.indexOf === 'function') { + switch (typeof a) { + case 'number': + if (a === 0) { + // manually crawl the list to distinguish between +0 and -0 + inf = 1 / a; + while (idx < list.length) { + item = list[idx]; + if (item === 0 && 1 / item === inf) { + return idx; + } + idx += 1; + } + return -1; + } else if (a !== a) { + // NaN + while (idx < list.length) { + item = list[idx]; + if (typeof item === 'number' && item !== item) { + return idx; + } + idx += 1; + } + return -1; + } + // non-zero numbers can utilise Set + return list.indexOf(a, idx); + + // all these types can utilise Set + case 'string': + case 'boolean': + case 'function': + case 'undefined': + return list.indexOf(a, idx); + + case 'object': + if (a === null) { + // null can utilise Set + return list.indexOf(a, idx); + } + } + } + // anything else not covered above, defer to R.equals + while (idx < list.length) { + if (equals(list[idx], a)) { + return idx; + } + idx += 1; + } + return -1; + } + + function _includes(a, list) { + return _indexOf(list, a, 0) >= 0; + } + + function _quote(s) { + var escaped = s + .replace(/\\/g, '\\\\') + .replace(/[\b]/g, '\\b') // \b matches word boundary; [\b] matches backspace + .replace(/\f/g, '\\f') + .replace(/\n/g, '\\n') + .replace(/\r/g, '\\r') + .replace(/\t/g, '\\t') + .replace(/\v/g, '\\v') + .replace(/\0/g, '\\0'); + + return '"' + escaped.replace(/"/g, '\\"') + '"'; + } + + /** + * Polyfill from . + */ + var pad = function pad(n) { return (n < 10 ? '0' : '') + n; }; + + var _toISOString = typeof Date.prototype.toISOString === 'function' ? + function _toISOString(d) { + return d.toISOString(); + } : + function _toISOString(d) { + return ( + d.getUTCFullYear() + '-' + + pad(d.getUTCMonth() + 1) + '-' + + pad(d.getUTCDate()) + 'T' + + pad(d.getUTCHours()) + ':' + + pad(d.getUTCMinutes()) + ':' + + pad(d.getUTCSeconds()) + '.' + + (d.getUTCMilliseconds() / 1000).toFixed(3).slice(2, 5) + 'Z' + ); + }; + + function _complement(f) { + return function() { + return !f.apply(this, arguments); + }; + } + + function _filter(fn, list) { + var idx = 0; + var len = list.length; + var result = []; + + while (idx < len) { + if (fn(list[idx])) { + result[result.length] = list[idx]; + } + idx += 1; + } + return result; + } + + function _isObject(x) { + return Object.prototype.toString.call(x) === '[object Object]'; + } + + function XFilter(f, xf) { + this.xf = xf; + this.f = f; + } + XFilter.prototype['@@transducer/init'] = _xfBase.init; + XFilter.prototype['@@transducer/result'] = _xfBase.result; + XFilter.prototype['@@transducer/step'] = function(result, input) { + return this.f(input) ? this.xf['@@transducer/step'](result, input) : result; + }; + + var _xfilter = _curry2(function _xfilter(f, xf) { return new XFilter(f, xf); }); + + /** + * Takes a predicate and a `Filterable`, and returns a new filterable of the + * same type containing the members of the given filterable which satisfy the + * given predicate. Filterable objects include plain objects or any object + * that has a filter method such as `Array`. + * + * Dispatches to the `filter` method of the second argument, if present. + * + * Acts as a transducer if a transformer is given in list position. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category List + * @sig Filterable f => (a -> Boolean) -> f a -> f a + * @param {Function} pred + * @param {Array} filterable + * @return {Array} Filterable + * @see R.reject, R.transduce, R.addIndex + * @example + * + * const isEven = n => n % 2 === 0; + * + * R.filter(isEven, [1, 2, 3, 4]); //=> [2, 4] + * + * R.filter(isEven, {a: 1, b: 2, c: 3, d: 4}); //=> {b: 2, d: 4} + */ + var filter = _curry2(_dispatchable(['filter'], _xfilter, function(pred, filterable) { + return ( + _isObject(filterable) ? + _reduce(function(acc, key) { + if (pred(filterable[key])) { + acc[key] = filterable[key]; + } + return acc; + }, {}, keys(filterable)) : + // else + _filter(pred, filterable) + ); + })); + + /** + * The complement of [`filter`](#filter). + * + * Acts as a transducer if a transformer is given in list position. Filterable + * objects include plain objects or any object that has a filter method such + * as `Array`. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category List + * @sig Filterable f => (a -> Boolean) -> f a -> f a + * @param {Function} pred + * @param {Array} filterable + * @return {Array} + * @see R.filter, R.transduce, R.addIndex + * @example + * + * const isOdd = (n) => n % 2 === 1; + * + * R.reject(isOdd, [1, 2, 3, 4]); //=> [2, 4] + * + * R.reject(isOdd, {a: 1, b: 2, c: 3, d: 4}); //=> {b: 2, d: 4} + */ + var reject = _curry2(function reject(pred, filterable) { + return filter(_complement(pred), filterable); + }); + + function _toString(x, seen) { + var recur = function recur(y) { + var xs = seen.concat([x]); + return _includes(y, xs) ? '' : _toString(y, xs); + }; + + // mapPairs :: (Object, [String]) -> [String] + var mapPairs = function(obj, keys$$1) { + return _map(function(k) { return _quote(k) + ': ' + recur(obj[k]); }, keys$$1.slice().sort()); + }; + + switch (Object.prototype.toString.call(x)) { + case '[object Arguments]': + return '(function() { return arguments; }(' + _map(recur, x).join(', ') + '))'; + case '[object Array]': + return '[' + _map(recur, x).concat(mapPairs(x, reject(function(k) { return /^\d+$/.test(k); }, keys(x)))).join(', ') + ']'; + case '[object Boolean]': + return typeof x === 'object' ? 'new Boolean(' + recur(x.valueOf()) + ')' : x.toString(); + case '[object Date]': + return 'new Date(' + (isNaN(x.valueOf()) ? recur(NaN) : _quote(_toISOString(x))) + ')'; + case '[object Null]': + return 'null'; + case '[object Number]': + return typeof x === 'object' ? 'new Number(' + recur(x.valueOf()) + ')' : 1 / x === -Infinity ? '-0' : x.toString(10); + case '[object String]': + return typeof x === 'object' ? 'new String(' + recur(x.valueOf()) + ')' : _quote(x); + case '[object Undefined]': + return 'undefined'; + default: + if (typeof x.toString === 'function') { + var repr = x.toString(); + if (repr !== '[object Object]') { + return repr; + } + } + return '{' + mapPairs(x, keys(x)).join(', ') + '}'; + } + } + + /** + * Returns the string representation of the given value. `eval`'ing the output + * should result in a value equivalent to the input value. Many of the built-in + * `toString` methods do not satisfy this requirement. + * + * If the given value is an `[object Object]` with a `toString` method other + * than `Object.prototype.toString`, this method is invoked with no arguments + * to produce the return value. This means user-defined constructor functions + * can provide a suitable `toString` method. For example: + * + * function Point(x, y) { + * this.x = x; + * this.y = y; + * } + * + * Point.prototype.toString = function() { + * return 'new Point(' + this.x + ', ' + this.y + ')'; + * }; + * + * R.toString(new Point(1, 2)); //=> 'new Point(1, 2)' + * + * @func + * @memberOf R + * @since v0.14.0 + * @category String + * @sig * -> String + * @param {*} val + * @return {String} + * @example + * + * R.toString(42); //=> '42' + * R.toString('abc'); //=> '"abc"' + * R.toString([1, 2, 3]); //=> '[1, 2, 3]' + * R.toString({foo: 1, bar: 2, baz: 3}); //=> '{"bar": 2, "baz": 3, "foo": 1}' + * R.toString(new Date('2001-02-03T04:05:06Z')); //=> 'new Date("2001-02-03T04:05:06.000Z")' + */ + var toString$1 = _curry1(function toString(val) { return _toString(val, []); }); + + /** + * Returns the result of concatenating the given lists or strings. + * + * Note: `R.concat` expects both arguments to be of the same type, + * unlike the native `Array.prototype.concat` method. It will throw + * an error if you `concat` an Array with a non-Array value. + * + * Dispatches to the `concat` method of the first argument, if present. + * Can also concatenate two members of a [fantasy-land + * compatible semigroup](https://github.com/fantasyland/fantasy-land#semigroup). + * + * @func + * @memberOf R + * @since v0.1.0 + * @category List + * @sig [a] -> [a] -> [a] + * @sig String -> String -> String + * @param {Array|String} firstList The first list + * @param {Array|String} secondList The second list + * @return {Array|String} A list consisting of the elements of `firstList` followed by the elements of + * `secondList`. + * + * @example + * + * R.concat('ABC', 'DEF'); // 'ABCDEF' + * R.concat([4, 5, 6], [1, 2, 3]); //=> [4, 5, 6, 1, 2, 3] + * R.concat([], []); //=> [] + */ + var concat = _curry2(function concat(a, b) { + if (_isArray(a)) { + if (_isArray(b)) { + return a.concat(b); + } + throw new TypeError(toString$1(b) + ' is not an array'); + } + if (_isString(a)) { + if (_isString(b)) { + return a + b; + } + throw new TypeError(toString$1(b) + ' is not a string'); + } + if (a != null && _isFunction(a['fantasy-land/concat'])) { + return a['fantasy-land/concat'](b); + } + if (a != null && _isFunction(a.concat)) { + return a.concat(b); + } + throw new TypeError(toString$1(a) + ' does not have a method named "concat" or "fantasy-land/concat"'); + }); + + /** + * Returns a function, `fn`, which encapsulates `if/else, if/else, ...` logic. + * `R.cond` takes a list of [predicate, transformer] pairs. All of the arguments + * to `fn` are applied to each of the predicates in turn until one returns a + * "truthy" value, at which point `fn` returns the result of applying its + * arguments to the corresponding transformer. If none of the predicates + * matches, `fn` returns undefined. + * + * @func + * @memberOf R + * @since v0.6.0 + * @category Logic + * @sig [[(*... -> Boolean),(*... -> *)]] -> (*... -> *) + * @param {Array} pairs A list of [predicate, transformer] + * @return {Function} + * @see R.ifElse, R.unless, R.when + * @example + * + * const fn = R.cond([ + * [R.equals(0), R.always('water freezes at 0°C')], + * [R.equals(100), R.always('water boils at 100°C')], + * [R.T, temp => 'nothing special happens at ' + temp + '°C'] + * ]); + * fn(0); //=> 'water freezes at 0°C' + * fn(50); //=> 'nothing special happens at 50°C' + * fn(100); //=> 'water boils at 100°C' + */ + var cond = _curry1(function cond(pairs) { + var arity = reduce( + max, + 0, + map(function(pair) { return pair[0].length; }, pairs) + ); + return _arity(arity, function() { + var idx = 0; + while (idx < pairs.length) { + if (pairs[idx][0].apply(this, arguments)) { + return pairs[idx][1].apply(this, arguments); + } + idx += 1; + } + }); + }); + + /** + * Wraps a constructor function inside a curried function that can be called + * with the same arguments and returns the same type. The arity of the function + * returned is specified to allow using variadic constructor functions. + * + * @func + * @memberOf R + * @since v0.4.0 + * @category Function + * @sig Number -> (* -> {*}) -> (* -> {*}) + * @param {Number} n The arity of the constructor function. + * @param {Function} Fn The constructor function to wrap. + * @return {Function} A wrapped, curried constructor function. + * @example + * + * // Variadic Constructor function + * function Salad() { + * this.ingredients = arguments; + * } + * + * Salad.prototype.recipe = function() { + * const instructions = R.map(ingredient => 'Add a dollop of ' + ingredient, this.ingredients); + * return R.join('\n', instructions); + * }; + * + * const ThreeLayerSalad = R.constructN(3, Salad); + * + * // Notice we no longer need the 'new' keyword, and the constructor is curried for 3 arguments. + * const salad = ThreeLayerSalad('Mayonnaise')('Potato Chips')('Ketchup'); + * + * console.log(salad.recipe()); + * // Add a dollop of Mayonnaise + * // Add a dollop of Potato Chips + * // Add a dollop of Ketchup + */ + var constructN = _curry2(function constructN(n, Fn) { + if (n > 10) { + throw new Error('Constructor with greater than ten arguments'); + } + if (n === 0) { + return function() { return new Fn(); }; + } + return curry(nAry(n, function($0, $1, $2, $3, $4, $5, $6, $7, $8, $9) { + switch (arguments.length) { + case 1: return new Fn($0); + case 2: return new Fn($0, $1); + case 3: return new Fn($0, $1, $2); + case 4: return new Fn($0, $1, $2, $3); + case 5: return new Fn($0, $1, $2, $3, $4); + case 6: return new Fn($0, $1, $2, $3, $4, $5); + case 7: return new Fn($0, $1, $2, $3, $4, $5, $6); + case 8: return new Fn($0, $1, $2, $3, $4, $5, $6, $7); + case 9: return new Fn($0, $1, $2, $3, $4, $5, $6, $7, $8); + case 10: return new Fn($0, $1, $2, $3, $4, $5, $6, $7, $8, $9); + } + })); + }); + + /** + * Wraps a constructor function inside a curried function that can be called + * with the same arguments and returns the same type. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Function + * @sig (* -> {*}) -> (* -> {*}) + * @param {Function} fn The constructor function to wrap. + * @return {Function} A wrapped, curried constructor function. + * @see R.invoker + * @example + * + * // Constructor function + * function Animal(kind) { + * this.kind = kind; + * }; + * Animal.prototype.sighting = function() { + * return "It's a " + this.kind + "!"; + * } + * + * const AnimalConstructor = R.construct(Animal) + * + * // Notice we no longer need the 'new' keyword: + * AnimalConstructor('Pig'); //=> {"kind": "Pig", "sighting": function (){...}}; + * + * const animalTypes = ["Lion", "Tiger", "Bear"]; + * const animalSighting = R.invoker(0, 'sighting'); + * const sightNewAnimal = R.compose(animalSighting, AnimalConstructor); + * R.map(sightNewAnimal, animalTypes); //=> ["It's a Lion!", "It's a Tiger!", "It's a Bear!"] + */ + var construct = _curry1(function construct(Fn) { + return constructN(Fn.length, Fn); + }); + + /** + * Returns `true` if the specified value is equal, in [`R.equals`](#equals) + * terms, to at least one element of the given list; `false` otherwise. + * Works also with strings. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category List + * @sig a -> [a] -> Boolean + * @param {Object} a The item to compare against. + * @param {Array} list The array to consider. + * @return {Boolean} `true` if an equivalent item is in the list, `false` otherwise. + * @see R.includes + * @deprecated since v0.26.0 + * @example + * + * R.contains(3, [1, 2, 3]); //=> true + * R.contains(4, [1, 2, 3]); //=> false + * R.contains({ name: 'Fred' }, [{ name: 'Fred' }]); //=> true + * R.contains([42], [[42]]); //=> true + * R.contains('ba', 'banana'); //=>true + */ + var contains$1 = _curry2(_includes); + + /** + * Accepts a converging function and a list of branching functions and returns + * a new function. The arity of the new function is the same as the arity of + * the longest branching function. When invoked, this new function is applied + * to some arguments, and each branching function is applied to those same + * arguments. The results of each branching function are passed as arguments + * to the converging function to produce the return value. + * + * @func + * @memberOf R + * @since v0.4.2 + * @category Function + * @sig ((x1, x2, ...) -> z) -> [((a, b, ...) -> x1), ((a, b, ...) -> x2), ...] -> (a -> b -> ... -> z) + * @param {Function} after A function. `after` will be invoked with the return values of + * `fn1` and `fn2` as its arguments. + * @param {Array} functions A list of functions. + * @return {Function} A new function. + * @see R.useWith + * @example + * + * const average = R.converge(R.divide, [R.sum, R.length]) + * average([1, 2, 3, 4, 5, 6, 7]) //=> 4 + * + * const strangeConcat = R.converge(R.concat, [R.toUpper, R.toLower]) + * strangeConcat("Yodel") //=> "YODELyodel" + * + * @symb R.converge(f, [g, h])(a, b) = f(g(a, b), h(a, b)) + */ + var converge = _curry2(function converge(after, fns) { + return curryN(reduce(max, 0, pluck('length', fns)), function() { + var args = arguments; + var context = this; + return after.apply(context, _map(function(fn) { + return fn.apply(context, args); + }, fns)); + }); + }); + + function XReduceBy(valueFn, valueAcc, keyFn, xf) { + this.valueFn = valueFn; + this.valueAcc = valueAcc; + this.keyFn = keyFn; + this.xf = xf; + this.inputs = {}; + } + XReduceBy.prototype['@@transducer/init'] = _xfBase.init; + XReduceBy.prototype['@@transducer/result'] = function(result) { + var key; + for (key in this.inputs) { + if (_has(key, this.inputs)) { + result = this.xf['@@transducer/step'](result, this.inputs[key]); + if (result['@@transducer/reduced']) { + result = result['@@transducer/value']; + break; + } + } + } + this.inputs = null; + return this.xf['@@transducer/result'](result); + }; + XReduceBy.prototype['@@transducer/step'] = function(result, input) { + var key = this.keyFn(input); + this.inputs[key] = this.inputs[key] || [key, this.valueAcc]; + this.inputs[key][1] = this.valueFn(this.inputs[key][1], input); + return result; + }; + + var _xreduceBy = _curryN(4, [], + function _xreduceBy(valueFn, valueAcc, keyFn, xf) { + return new XReduceBy(valueFn, valueAcc, keyFn, xf); + } + ); + + /** + * Groups the elements of the list according to the result of calling + * the String-returning function `keyFn` on each element and reduces the elements + * of each group to a single value via the reducer function `valueFn`. + * + * This function is basically a more general [`groupBy`](#groupBy) function. + * + * Acts as a transducer if a transformer is given in list position. + * + * @func + * @memberOf R + * @since v0.20.0 + * @category List + * @sig ((a, b) -> a) -> a -> (b -> String) -> [b] -> {String: a} + * @param {Function} valueFn The function that reduces the elements of each group to a single + * value. Receives two values, accumulator for a particular group and the current element. + * @param {*} acc The (initial) accumulator value for each group. + * @param {Function} keyFn The function that maps the list's element into a key. + * @param {Array} list The array to group. + * @return {Object} An object with the output of `keyFn` for keys, mapped to the output of + * `valueFn` for elements which produced that key when passed to `keyFn`. + * @see R.groupBy, R.reduce + * @example + * + * const groupNames = (acc, {name}) => acc.concat(name) + * const toGrade = ({score}) => + * score < 65 ? 'F' : + * score < 70 ? 'D' : + * score < 80 ? 'C' : + * score < 90 ? 'B' : 'A' + * + * var students = [ + * {name: 'Abby', score: 83}, + * {name: 'Bart', score: 62}, + * {name: 'Curt', score: 88}, + * {name: 'Dora', score: 92}, + * ] + * + * reduceBy(groupNames, [], toGrade, students) + * //=> {"A": ["Dora"], "B": ["Abby", "Curt"], "F": ["Bart"]} + */ + var reduceBy = _curryN(4, [], _dispatchable([], _xreduceBy, + function reduceBy(valueFn, valueAcc, keyFn, list) { + return _reduce(function(acc, elt) { + var key = keyFn(elt); + acc[key] = valueFn(_has(key, acc) ? acc[key] : _clone(valueAcc, [], [], false), elt); + return acc; + }, {}, list); + })); + + /** + * Counts the elements of a list according to how many match each value of a + * key generated by the supplied function. Returns an object mapping the keys + * produced by `fn` to the number of occurrences in the list. Note that all + * keys are coerced to strings because of how JavaScript objects work. + * + * Acts as a transducer if a transformer is given in list position. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Relation + * @sig (a -> String) -> [a] -> {*} + * @param {Function} fn The function used to map values to keys. + * @param {Array} list The list to count elements from. + * @return {Object} An object mapping keys to number of occurrences in the list. + * @example + * + * const numbers = [1.0, 1.1, 1.2, 2.0, 3.0, 2.2]; + * R.countBy(Math.floor)(numbers); //=> {'1': 3, '2': 2, '3': 1} + * + * const letters = ['a', 'b', 'A', 'a', 'B', 'c']; + * R.countBy(R.toLower)(letters); //=> {'a': 3, 'b': 2, 'c': 1} + */ + var countBy = reduceBy(function(acc, elem) { return acc + 1; }, 0); + + /** + * Decrements its argument. + * + * @func + * @memberOf R + * @since v0.9.0 + * @category Math + * @sig Number -> Number + * @param {Number} n + * @return {Number} n - 1 + * @see R.inc + * @example + * + * R.dec(42); //=> 41 + */ + var dec = add(-1); + + /** + * Returns the second argument if it is not `null`, `undefined` or `NaN`; + * otherwise the first argument is returned. + * + * @func + * @memberOf R + * @since v0.10.0 + * @category Logic + * @sig a -> b -> a | b + * @param {a} default The default value. + * @param {b} val `val` will be returned instead of `default` unless `val` is `null`, `undefined` or `NaN`. + * @return {*} The second value if it is not `null`, `undefined` or `NaN`, otherwise the default value + * @example + * + * const defaultTo42 = R.defaultTo(42); + * + * defaultTo42(null); //=> 42 + * defaultTo42(undefined); //=> 42 + * defaultTo42(false); //=> false + * defaultTo42('Ramda'); //=> 'Ramda' + * // parseInt('string') results in NaN + * defaultTo42(parseInt('string')); //=> 42 + */ + var defaultTo = _curry2(function defaultTo(d, v) { + return v == null || v !== v ? d : v; + }); + + /** + * Makes a descending comparator function out of a function that returns a value + * that can be compared with `<` and `>`. + * + * @func + * @memberOf R + * @since v0.23.0 + * @category Function + * @sig Ord b => (a -> b) -> a -> a -> Number + * @param {Function} fn A function of arity one that returns a value that can be compared + * @param {*} a The first item to be compared. + * @param {*} b The second item to be compared. + * @return {Number} `-1` if fn(a) > fn(b), `1` if fn(b) > fn(a), otherwise `0` + * @see R.ascend + * @example + * + * const byAge = R.descend(R.prop('age')); + * const people = [ + * { name: 'Emma', age: 70 }, + * { name: 'Peter', age: 78 }, + * { name: 'Mikhail', age: 62 }, + * ]; + * const peopleByOldestFirst = R.sort(byAge, people); + * //=> [{ name: 'Peter', age: 78 }, { name: 'Emma', age: 70 }, { name: 'Mikhail', age: 62 }] + */ + var descend = _curry3(function descend(fn, a, b) { + var aa = fn(a); + var bb = fn(b); + return aa > bb ? -1 : aa < bb ? 1 : 0; + }); + + function _Set() { + /* globals Set */ + this._nativeSet = typeof Set === 'function' ? new Set() : null; + this._items = {}; + } + + // until we figure out why jsdoc chokes on this + // @param item The item to add to the Set + // @returns {boolean} true if the item did not exist prior, otherwise false + // + _Set.prototype.add = function(item) { + return !hasOrAdd(item, true, this); + }; + + // + // @param item The item to check for existence in the Set + // @returns {boolean} true if the item exists in the Set, otherwise false + // + _Set.prototype.has = function(item) { + return hasOrAdd(item, false, this); + }; + + // + // Combines the logic for checking whether an item is a member of the set and + // for adding a new item to the set. + // + // @param item The item to check or add to the Set instance. + // @param shouldAdd If true, the item will be added to the set if it doesn't + // already exist. + // @param set The set instance to check or add to. + // @return {boolean} true if the item already existed, otherwise false. + // + function hasOrAdd(item, shouldAdd, set) { + var type = typeof item; + var prevSize, newSize; + switch (type) { + case 'string': + case 'number': + // distinguish between +0 and -0 + if (item === 0 && 1 / item === -Infinity) { + if (set._items['-0']) { + return true; + } else { + if (shouldAdd) { + set._items['-0'] = true; + } + return false; + } + } + // these types can all utilise the native Set + if (set._nativeSet !== null) { if (shouldAdd) { - set._items[type] = [item]; + prevSize = set._nativeSet.size; + set._nativeSet.add(item); + newSize = set._nativeSet.size; + return newSize === prevSize; + } else { + return set._nativeSet.has(item); + } + } else { + if (!(type in set._items)) { + if (shouldAdd) { + set._items[type] = {}; + set._items[type][item] = true; + } + return false; + } else if (item in set._items[type]) { + return true; + } else { + if (shouldAdd) { + set._items[type][item] = true; + } + return false; } - return false; } - if (!_includes(item, set._items[type])) { + + case 'boolean': + // set._items['boolean'] holds a two element array + // representing [ falseExists, trueExists ] + if (type in set._items) { + var bIdx = item ? 1 : 0; + if (set._items[type][bIdx]) { + return true; + } else { + if (shouldAdd) { + set._items[type][bIdx] = true; + } + return false; + } + } else { if (shouldAdd) { - set._items[type].push(item); + set._items[type] = item ? [false, true] : [true, false]; } return false; } - return true; - } - case 'undefined': - if (set._items[type]) { - return true; - } else { - if (shouldAdd) { - set._items[type] = true; + case 'function': + // compare functions for reference equality + if (set._nativeSet !== null) { + if (shouldAdd) { + prevSize = set._nativeSet.size; + set._nativeSet.add(item); + newSize = set._nativeSet.size; + return newSize === prevSize; + } else { + return set._nativeSet.has(item); + } + } else { + if (!(type in set._items)) { + if (shouldAdd) { + set._items[type] = [item]; + } + return false; + } + if (!_includes(item, set._items[type])) { + if (shouldAdd) { + set._items[type].push(item); + } + return false; + } + return true; + } + + case 'undefined': + if (set._items[type]) { + return true; + } else { + if (shouldAdd) { + set._items[type] = true; + } + return false; } - return false; - } - case 'object': - if (item === null) { - if (!set._items['null']) { + case 'object': + if (item === null) { + if (!set._items['null']) { + if (shouldAdd) { + set._items['null'] = true; + } + return false; + } + return true; + } + /* falls through */ + default: + // reduce the search size of heterogeneous sets by creating buckets + // for each type. + type = Object.prototype.toString.call(item); + if (!(type in set._items)) { if (shouldAdd) { - set._items['null'] = true; + set._items[type] = [item]; + } + return false; + } + // scan through all previously applied items + if (!_includes(item, set._items[type])) { + if (shouldAdd) { + set._items[type].push(item); } return false; } return true; + } + } + + /** + * Finds the set (i.e. no duplicates) of all elements in the first list not + * contained in the second list. Objects and Arrays are compared in terms of + * value equality, not reference equality. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Relation + * @sig [*] -> [*] -> [*] + * @param {Array} list1 The first list. + * @param {Array} list2 The second list. + * @return {Array} The elements in `list1` that are not in `list2`. + * @see R.differenceWith, R.symmetricDifference, R.symmetricDifferenceWith, R.without + * @example + * + * R.difference([1,2,3,4], [7,6,5,4,3]); //=> [1,2] + * R.difference([7,6,5,4,3], [1,2,3,4]); //=> [7,6,5] + * R.difference([{a: 1}, {b: 2}], [{a: 1}, {c: 3}]) //=> [{b: 2}] + */ + var difference = _curry2(function difference(first, second) { + var out = []; + var idx = 0; + var firstLen = first.length; + var secondLen = second.length; + var toFilterOut = new _Set(); + + for (var i = 0; i < secondLen; i += 1) { + toFilterOut.add(second[i]); + } + + while (idx < firstLen) { + if (toFilterOut.add(first[idx])) { + out[out.length] = first[idx]; } - /* falls through */ - default: - // reduce the search size of heterogeneous sets by creating buckets - // for each type. - type = Object.prototype.toString.call(item); - if (!(type in set._items)) { - if (shouldAdd) { - set._items[type] = [item]; - } - return false; + idx += 1; + } + return out; + }); + + /** + * Finds the set (i.e. no duplicates) of all elements in the first list not + * contained in the second list. Duplication is determined according to the + * value returned by applying the supplied predicate to two list elements. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Relation + * @sig ((a, a) -> Boolean) -> [a] -> [a] -> [a] + * @param {Function} pred A predicate used to test whether two items are equal. + * @param {Array} list1 The first list. + * @param {Array} list2 The second list. + * @return {Array} The elements in `list1` that are not in `list2`. + * @see R.difference, R.symmetricDifference, R.symmetricDifferenceWith + * @example + * + * const cmp = (x, y) => x.a === y.a; + * const l1 = [{a: 1}, {a: 2}, {a: 3}]; + * const l2 = [{a: 3}, {a: 4}]; + * R.differenceWith(cmp, l1, l2); //=> [{a: 1}, {a: 2}] + */ + var differenceWith = _curry3(function differenceWith(pred, first, second) { + var out = []; + var idx = 0; + var firstLen = first.length; + while (idx < firstLen) { + if (!_includesWith(pred, first[idx], second) && + !_includesWith(pred, first[idx], out)) { + out.push(first[idx]); } - // scan through all previously applied items - if (!_includes(item, set._items[type])) { - if (shouldAdd) { - set._items[type].push(item); + idx += 1; + } + return out; + }); + + /** + * Returns a new object that does not contain a `prop` property. + * + * @func + * @memberOf R + * @since v0.10.0 + * @category Object + * @sig String -> {k: v} -> {k: v} + * @param {String} prop The name of the property to dissociate + * @param {Object} obj The object to clone + * @return {Object} A new object equivalent to the original but without the specified property + * @see R.assoc, R.omit + * @example + * + * R.dissoc('b', {a: 1, b: 2, c: 3}); //=> {a: 1, c: 3} + */ + var dissoc = _curry2(function dissoc(prop, obj) { + var result = {}; + for (var p in obj) { + result[p] = obj[p]; + } + delete result[prop]; + return result; + }); + + /** + * Removes the sub-list of `list` starting at index `start` and containing + * `count` elements. _Note that this is not destructive_: it returns a copy of + * the list with the changes. + * No lists have been harmed in the application of this function. + * + * @func + * @memberOf R + * @since v0.2.2 + * @category List + * @sig Number -> Number -> [a] -> [a] + * @param {Number} start The position to start removing elements + * @param {Number} count The number of elements to remove + * @param {Array} list The list to remove from + * @return {Array} A new Array with `count` elements from `start` removed. + * @see R.without + * @example + * + * R.remove(2, 3, [1,2,3,4,5,6,7,8]); //=> [1,2,6,7,8] + */ + var remove = _curry3(function remove(start, count, list) { + var result = Array.prototype.slice.call(list, 0); + result.splice(start, count); + return result; + }); + + /** + * Returns a new copy of the array with the element at the provided index + * replaced with the given value. + * + * @func + * @memberOf R + * @since v0.14.0 + * @category List + * @sig Number -> a -> [a] -> [a] + * @param {Number} idx The index to update. + * @param {*} x The value to exist at the given index of the returned array. + * @param {Array|Arguments} list The source array-like object to be updated. + * @return {Array} A copy of `list` with the value at index `idx` replaced with `x`. + * @see R.adjust + * @example + * + * R.update(1, '_', ['a', 'b', 'c']); //=> ['a', '_', 'c'] + * R.update(-1, '_', ['a', 'b', 'c']); //=> ['a', 'b', '_'] + * @symb R.update(-1, a, [b, c]) = [b, a] + * @symb R.update(0, a, [b, c]) = [a, c] + * @symb R.update(1, a, [b, c]) = [b, a] + */ + var update = _curry3(function update(idx, x, list) { + return adjust(idx, always(x), list); + }); + + /** + * Makes a shallow clone of an object, omitting the property at the given path. + * Note that this copies and flattens prototype properties onto the new object + * as well. All non-primitive properties are copied by reference. + * + * @func + * @memberOf R + * @since v0.11.0 + * @category Object + * @typedefn Idx = String | Int + * @sig [Idx] -> {k: v} -> {k: v} + * @param {Array} path The path to the value to omit + * @param {Object} obj The object to clone + * @return {Object} A new object without the property at path + * @see R.assocPath + * @example + * + * R.dissocPath(['a', 'b', 'c'], {a: {b: {c: 42}}}); //=> {a: {b: {}}} + */ + var dissocPath = _curry2(function dissocPath(path, obj) { + switch (path.length) { + case 0: + return obj; + case 1: + return _isInteger(path[0]) && _isArray(obj) ? remove(path[0], 1, obj) : dissoc(path[0], obj); + default: + var head = path[0]; + var tail = Array.prototype.slice.call(path, 1); + if (obj[head] == null) { + return obj; + } else if (_isInteger(head) && _isArray(obj)) { + return update(head, dissocPath(tail, obj[head]), obj); + } else { + return assoc(head, dissocPath(tail, obj[head]), obj); } - return false; - } - return true; - } -} - -/** - * Finds the set (i.e. no duplicates) of all elements in the first list not - * contained in the second list. Objects and Arrays are compared in terms of - * value equality, not reference equality. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Relation - * @sig [*] -> [*] -> [*] - * @param {Array} list1 The first list. - * @param {Array} list2 The second list. - * @return {Array} The elements in `list1` that are not in `list2`. - * @see R.differenceWith, R.symmetricDifference, R.symmetricDifferenceWith, R.without - * @example - * - * R.difference([1,2,3,4], [7,6,5,4,3]); //=> [1,2] - * R.difference([7,6,5,4,3], [1,2,3,4]); //=> [7,6,5] - * R.difference([{a: 1}, {b: 2}], [{a: 1}, {c: 3}]) //=> [{b: 2}] - */ -var difference = _curry2(function difference(first, second) { - var out = []; - var idx = 0; - var firstLen = first.length; - var secondLen = second.length; - var toFilterOut = new _Set(); - - for (var i = 0; i < secondLen; i += 1) { - toFilterOut.add(second[i]); - } + } + }); - while (idx < firstLen) { - if (toFilterOut.add(first[idx])) { - out[out.length] = first[idx]; + /** + * Divides two numbers. Equivalent to `a / b`. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Math + * @sig Number -> Number -> Number + * @param {Number} a The first value. + * @param {Number} b The second value. + * @return {Number} The result of `a / b`. + * @see R.multiply + * @example + * + * R.divide(71, 100); //=> 0.71 + * + * const half = R.divide(R.__, 2); + * half(42); //=> 21 + * + * const reciprocal = R.divide(1); + * reciprocal(4); //=> 0.25 + */ + var divide = _curry2(function divide(a, b) { return a / b; }); + + function XDrop(n, xf) { + this.xf = xf; + this.n = n; + } + XDrop.prototype['@@transducer/init'] = _xfBase.init; + XDrop.prototype['@@transducer/result'] = _xfBase.result; + XDrop.prototype['@@transducer/step'] = function(result, input) { + if (this.n > 0) { + this.n -= 1; + return result; } - idx += 1; - } - return out; -}); - -/** - * Finds the set (i.e. no duplicates) of all elements in the first list not - * contained in the second list. Duplication is determined according to the - * value returned by applying the supplied predicate to two list elements. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Relation - * @sig ((a, a) -> Boolean) -> [a] -> [a] -> [a] - * @param {Function} pred A predicate used to test whether two items are equal. - * @param {Array} list1 The first list. - * @param {Array} list2 The second list. - * @return {Array} The elements in `list1` that are not in `list2`. - * @see R.difference, R.symmetricDifference, R.symmetricDifferenceWith - * @example - * - * const cmp = (x, y) => x.a === y.a; - * const l1 = [{a: 1}, {a: 2}, {a: 3}]; - * const l2 = [{a: 3}, {a: 4}]; - * R.differenceWith(cmp, l1, l2); //=> [{a: 1}, {a: 2}] - */ -var differenceWith = _curry3(function differenceWith(pred, first, second) { - var out = []; - var idx = 0; - var firstLen = first.length; - while (idx < firstLen) { - if (!_includesWith(pred, first[idx], second) && - !_includesWith(pred, first[idx], out)) { - out.push(first[idx]); - } - idx += 1; - } - return out; -}); - -/** - * Returns a new object that does not contain a `prop` property. - * - * @func - * @memberOf R - * @since v0.10.0 - * @category Object - * @sig String -> {k: v} -> {k: v} - * @param {String} prop The name of the property to dissociate - * @param {Object} obj The object to clone - * @return {Object} A new object equivalent to the original but without the specified property - * @see R.assoc, R.omit - * @example - * - * R.dissoc('b', {a: 1, b: 2, c: 3}); //=> {a: 1, c: 3} - */ -var dissoc = _curry2(function dissoc(prop, obj) { - var result = {}; - for (var p in obj) { - result[p] = obj[p]; + return this.xf['@@transducer/step'](result, input); + }; + + var _xdrop = _curry2(function _xdrop(n, xf) { return new XDrop(n, xf); }); + + /** + * Returns all but the first `n` elements of the given list, string, or + * transducer/transformer (or object with a `drop` method). + * + * Dispatches to the `drop` method of the second argument, if present. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category List + * @sig Number -> [a] -> [a] + * @sig Number -> String -> String + * @param {Number} n + * @param {*} list + * @return {*} A copy of list without the first `n` elements + * @see R.take, R.transduce, R.dropLast, R.dropWhile + * @example + * + * R.drop(1, ['foo', 'bar', 'baz']); //=> ['bar', 'baz'] + * R.drop(2, ['foo', 'bar', 'baz']); //=> ['baz'] + * R.drop(3, ['foo', 'bar', 'baz']); //=> [] + * R.drop(4, ['foo', 'bar', 'baz']); //=> [] + * R.drop(3, 'ramda'); //=> 'da' + */ + var drop = _curry2(_dispatchable(['drop'], _xdrop, function drop(n, xs) { + return slice(Math.max(0, n), Infinity, xs); + })); + + function XTake(n, xf) { + this.xf = xf; + this.n = n; + this.i = 0; + } + XTake.prototype['@@transducer/init'] = _xfBase.init; + XTake.prototype['@@transducer/result'] = _xfBase.result; + XTake.prototype['@@transducer/step'] = function(result, input) { + this.i += 1; + var ret = this.n === 0 ? result : this.xf['@@transducer/step'](result, input); + return this.n >= 0 && this.i >= this.n ? _reduced(ret) : ret; + }; + + var _xtake = _curry2(function _xtake(n, xf) { return new XTake(n, xf); }); + + /** + * Returns the first `n` elements of the given list, string, or + * transducer/transformer (or object with a `take` method). + * + * Dispatches to the `take` method of the second argument, if present. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category List + * @sig Number -> [a] -> [a] + * @sig Number -> String -> String + * @param {Number} n + * @param {*} list + * @return {*} + * @see R.drop + * @example + * + * R.take(1, ['foo', 'bar', 'baz']); //=> ['foo'] + * R.take(2, ['foo', 'bar', 'baz']); //=> ['foo', 'bar'] + * R.take(3, ['foo', 'bar', 'baz']); //=> ['foo', 'bar', 'baz'] + * R.take(4, ['foo', 'bar', 'baz']); //=> ['foo', 'bar', 'baz'] + * R.take(3, 'ramda'); //=> 'ram' + * + * const personnel = [ + * 'Dave Brubeck', + * 'Paul Desmond', + * 'Eugene Wright', + * 'Joe Morello', + * 'Gerry Mulligan', + * 'Bob Bates', + * 'Joe Dodge', + * 'Ron Crotty' + * ]; + * + * const takeFive = R.take(5); + * takeFive(personnel); + * //=> ['Dave Brubeck', 'Paul Desmond', 'Eugene Wright', 'Joe Morello', 'Gerry Mulligan'] + * @symb R.take(-1, [a, b]) = [a, b] + * @symb R.take(0, [a, b]) = [] + * @symb R.take(1, [a, b]) = [a] + * @symb R.take(2, [a, b]) = [a, b] + */ + var take = _curry2(_dispatchable(['take'], _xtake, function take(n, xs) { + return slice(0, n < 0 ? Infinity : n, xs); + })); + + function dropLast(n, xs) { + return take(n < xs.length ? xs.length - n : 0, xs); } - delete result[prop]; - return result; -}); - -/** - * Removes the sub-list of `list` starting at index `start` and containing - * `count` elements. _Note that this is not destructive_: it returns a copy of - * the list with the changes. - * No lists have been harmed in the application of this function. - * - * @func - * @memberOf R - * @since v0.2.2 - * @category List - * @sig Number -> Number -> [a] -> [a] - * @param {Number} start The position to start removing elements - * @param {Number} count The number of elements to remove - * @param {Array} list The list to remove from - * @return {Array} A new Array with `count` elements from `start` removed. - * @see R.without - * @example - * - * R.remove(2, 3, [1,2,3,4,5,6,7,8]); //=> [1,2,6,7,8] - */ -var remove = _curry3(function remove(start, count, list) { - var result = Array.prototype.slice.call(list, 0); - result.splice(start, count); - return result; -}); - -/** - * Returns a new copy of the array with the element at the provided index - * replaced with the given value. - * - * @func - * @memberOf R - * @since v0.14.0 - * @category List - * @sig Number -> a -> [a] -> [a] - * @param {Number} idx The index to update. - * @param {*} x The value to exist at the given index of the returned array. - * @param {Array|Arguments} list The source array-like object to be updated. - * @return {Array} A copy of `list` with the value at index `idx` replaced with `x`. - * @see R.adjust - * @example - * - * R.update(1, '_', ['a', 'b', 'c']); //=> ['a', '_', 'c'] - * R.update(-1, '_', ['a', 'b', 'c']); //=> ['a', 'b', '_'] - * @symb R.update(-1, a, [b, c]) = [b, a] - * @symb R.update(0, a, [b, c]) = [a, c] - * @symb R.update(1, a, [b, c]) = [b, a] - */ -var update = _curry3(function update(idx, x, list) { - return adjust(idx, always(x), list); -}); - -/** - * Makes a shallow clone of an object, omitting the property at the given path. - * Note that this copies and flattens prototype properties onto the new object - * as well. All non-primitive properties are copied by reference. - * - * @func - * @memberOf R - * @since v0.11.0 - * @category Object - * @typedefn Idx = String | Int - * @sig [Idx] -> {k: v} -> {k: v} - * @param {Array} path The path to the value to omit - * @param {Object} obj The object to clone - * @return {Object} A new object without the property at path - * @see R.assocPath - * @example - * - * R.dissocPath(['a', 'b', 'c'], {a: {b: {c: 42}}}); //=> {a: {b: {}}} - */ -var dissocPath = _curry2(function dissocPath(path, obj) { - switch (path.length) { - case 0: - return obj; - case 1: - return _isInteger(path[0]) && _isArray(obj) ? remove(path[0], 1, obj) : dissoc(path[0], obj); - default: - var head = path[0]; - var tail = Array.prototype.slice.call(path, 1); - if (obj[head] == null) { - return obj; - } else if (_isInteger(head) && _isArray(obj)) { - return update(head, dissocPath(tail, obj[head]), obj); - } else { - return assoc(head, dissocPath(tail, obj[head]), obj); - } + + function XDropLast(n, xf) { + this.xf = xf; + this.pos = 0; + this.full = false; + this.acc = new Array(n); } -}); - -/** - * Divides two numbers. Equivalent to `a / b`. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Math - * @sig Number -> Number -> Number - * @param {Number} a The first value. - * @param {Number} b The second value. - * @return {Number} The result of `a / b`. - * @see R.multiply - * @example - * - * R.divide(71, 100); //=> 0.71 - * - * const half = R.divide(R.__, 2); - * half(42); //=> 21 - * - * const reciprocal = R.divide(1); - * reciprocal(4); //=> 0.25 - */ -var divide = _curry2(function divide(a, b) { return a / b; }); - -function XDrop(n, xf) { - this.xf = xf; - this.n = n; -} -XDrop.prototype['@@transducer/init'] = _xfBase.init; -XDrop.prototype['@@transducer/result'] = _xfBase.result; -XDrop.prototype['@@transducer/step'] = function(result, input) { - if (this.n > 0) { - this.n -= 1; + XDropLast.prototype['@@transducer/init'] = _xfBase.init; + XDropLast.prototype['@@transducer/result'] = function(result) { + this.acc = null; + return this.xf['@@transducer/result'](result); + }; + XDropLast.prototype['@@transducer/step'] = function(result, input) { + if (this.full) { + result = this.xf['@@transducer/step'](result, this.acc[this.pos]); + } + this.store(input); return result; - } - return this.xf['@@transducer/step'](result, input); -}; - -var _xdrop = _curry2(function _xdrop(n, xf) { return new XDrop(n, xf); }); - -/** - * Returns all but the first `n` elements of the given list, string, or - * transducer/transformer (or object with a `drop` method). - * - * Dispatches to the `drop` method of the second argument, if present. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category List - * @sig Number -> [a] -> [a] - * @sig Number -> String -> String - * @param {Number} n - * @param {*} list - * @return {*} A copy of list without the first `n` elements - * @see R.take, R.transduce, R.dropLast, R.dropWhile - * @example - * - * R.drop(1, ['foo', 'bar', 'baz']); //=> ['bar', 'baz'] - * R.drop(2, ['foo', 'bar', 'baz']); //=> ['baz'] - * R.drop(3, ['foo', 'bar', 'baz']); //=> [] - * R.drop(4, ['foo', 'bar', 'baz']); //=> [] - * R.drop(3, 'ramda'); //=> 'da' - */ -var drop = _curry2(_dispatchable(['drop'], _xdrop, function drop(n, xs) { - return slice(Math.max(0, n), Infinity, xs); -})); + }; + XDropLast.prototype.store = function(input) { + this.acc[this.pos] = input; + this.pos += 1; + if (this.pos === this.acc.length) { + this.pos = 0; + this.full = true; + } + }; -function XTake(n, xf) { - this.xf = xf; - this.n = n; - this.i = 0; -} -XTake.prototype['@@transducer/init'] = _xfBase.init; -XTake.prototype['@@transducer/result'] = _xfBase.result; -XTake.prototype['@@transducer/step'] = function(result, input) { - this.i += 1; - var ret = this.n === 0 ? result : this.xf['@@transducer/step'](result, input); - return this.n >= 0 && this.i >= this.n ? _reduced(ret) : ret; -}; - -var _xtake = _curry2(function _xtake(n, xf) { return new XTake(n, xf); }); - -/** - * Returns the first `n` elements of the given list, string, or - * transducer/transformer (or object with a `take` method). - * - * Dispatches to the `take` method of the second argument, if present. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category List - * @sig Number -> [a] -> [a] - * @sig Number -> String -> String - * @param {Number} n - * @param {*} list - * @return {*} - * @see R.drop - * @example - * - * R.take(1, ['foo', 'bar', 'baz']); //=> ['foo'] - * R.take(2, ['foo', 'bar', 'baz']); //=> ['foo', 'bar'] - * R.take(3, ['foo', 'bar', 'baz']); //=> ['foo', 'bar', 'baz'] - * R.take(4, ['foo', 'bar', 'baz']); //=> ['foo', 'bar', 'baz'] - * R.take(3, 'ramda'); //=> 'ram' - * - * const personnel = [ - * 'Dave Brubeck', - * 'Paul Desmond', - * 'Eugene Wright', - * 'Joe Morello', - * 'Gerry Mulligan', - * 'Bob Bates', - * 'Joe Dodge', - * 'Ron Crotty' - * ]; - * - * const takeFive = R.take(5); - * takeFive(personnel); - * //=> ['Dave Brubeck', 'Paul Desmond', 'Eugene Wright', 'Joe Morello', 'Gerry Mulligan'] - * @symb R.take(-1, [a, b]) = [a, b] - * @symb R.take(0, [a, b]) = [] - * @symb R.take(1, [a, b]) = [a] - * @symb R.take(2, [a, b]) = [a, b] - */ -var take = _curry2(_dispatchable(['take'], _xtake, function take(n, xs) { - return slice(0, n < 0 ? Infinity : n, xs); -})); + var _xdropLast = _curry2(function _xdropLast(n, xf) { return new XDropLast(n, xf); }); + + /** + * Returns a list containing all but the last `n` elements of the given `list`. + * + * Acts as a transducer if a transformer is given in list position. + * + * @func + * @memberOf R + * @since v0.16.0 + * @category List + * @sig Number -> [a] -> [a] + * @sig Number -> String -> String + * @param {Number} n The number of elements of `list` to skip. + * @param {Array} list The list of elements to consider. + * @return {Array} A copy of the list with only the first `list.length - n` elements + * @see R.takeLast, R.drop, R.dropWhile, R.dropLastWhile + * @example + * + * R.dropLast(1, ['foo', 'bar', 'baz']); //=> ['foo', 'bar'] + * R.dropLast(2, ['foo', 'bar', 'baz']); //=> ['foo'] + * R.dropLast(3, ['foo', 'bar', 'baz']); //=> [] + * R.dropLast(4, ['foo', 'bar', 'baz']); //=> [] + * R.dropLast(3, 'ramda'); //=> 'ra' + */ + var dropLast$1 = _curry2(_dispatchable([], _xdropLast, dropLast)); + + function dropLastWhile(pred, xs) { + var idx = xs.length - 1; + while (idx >= 0 && pred(xs[idx])) { + idx -= 1; + } + return slice(0, idx + 1, xs); + } + + function XDropLastWhile(fn, xf) { + this.f = fn; + this.retained = []; + this.xf = xf; + } + XDropLastWhile.prototype['@@transducer/init'] = _xfBase.init; + XDropLastWhile.prototype['@@transducer/result'] = function(result) { + this.retained = null; + return this.xf['@@transducer/result'](result); + }; + XDropLastWhile.prototype['@@transducer/step'] = function(result, input) { + return this.f(input) + ? this.retain(result, input) + : this.flush(result, input); + }; + XDropLastWhile.prototype.flush = function(result, input) { + result = _reduce( + this.xf['@@transducer/step'], + result, + this.retained + ); + this.retained = []; + return this.xf['@@transducer/step'](result, input); + }; + XDropLastWhile.prototype.retain = function(result, input) { + this.retained.push(input); + return result; + }; + + var _xdropLastWhile = _curry2(function _xdropLastWhile(fn, xf) { return new XDropLastWhile(fn, xf); }); + + /** + * Returns a new list excluding all the tailing elements of a given list which + * satisfy the supplied predicate function. It passes each value from the right + * to the supplied predicate function, skipping elements until the predicate + * function returns a `falsy` value. The predicate function is applied to one argument: + * *(value)*. + * + * Acts as a transducer if a transformer is given in list position. + * + * @func + * @memberOf R + * @since v0.16.0 + * @category List + * @sig (a -> Boolean) -> [a] -> [a] + * @sig (a -> Boolean) -> String -> String + * @param {Function} predicate The function to be called on each element + * @param {Array} xs The collection to iterate over. + * @return {Array} A new array without any trailing elements that return `falsy` values from the `predicate`. + * @see R.takeLastWhile, R.addIndex, R.drop, R.dropWhile + * @example + * + * const lteThree = x => x <= 3; + * + * R.dropLastWhile(lteThree, [1, 2, 3, 4, 3, 2, 1]); //=> [1, 2, 3, 4] + * + * R.dropLastWhile(x => x !== 'd' , 'Ramda'); //=> 'Ramd' + */ + var dropLastWhile$1 = _curry2(_dispatchable([], _xdropLastWhile, dropLastWhile)); + + function XDropRepeatsWith(pred, xf) { + this.xf = xf; + this.pred = pred; + this.lastValue = undefined; + this.seenFirstValue = false; + } + + XDropRepeatsWith.prototype['@@transducer/init'] = _xfBase.init; + XDropRepeatsWith.prototype['@@transducer/result'] = _xfBase.result; + XDropRepeatsWith.prototype['@@transducer/step'] = function(result, input) { + var sameAsLast = false; + if (!this.seenFirstValue) { + this.seenFirstValue = true; + } else if (this.pred(this.lastValue, input)) { + sameAsLast = true; + } + this.lastValue = input; + return sameAsLast ? result : this.xf['@@transducer/step'](result, input); + }; + + var _xdropRepeatsWith = _curry2(function _xdropRepeatsWith(pred, xf) { return new XDropRepeatsWith(pred, xf); }); + + /** + * Returns the last element of the given list or string. + * + * @func + * @memberOf R + * @since v0.1.4 + * @category List + * @sig [a] -> a | Undefined + * @sig String -> String + * @param {*} list + * @return {*} + * @see R.init, R.head, R.tail + * @example + * + * R.last(['fi', 'fo', 'fum']); //=> 'fum' + * R.last([]); //=> undefined + * + * R.last('abc'); //=> 'c' + * R.last(''); //=> '' + */ + var last = nth(-1); + + /** + * Returns a new list without any consecutively repeating elements. Equality is + * determined by applying the supplied predicate to each pair of consecutive elements. The + * first element in a series of equal elements will be preserved. + * + * Acts as a transducer if a transformer is given in list position. + * + * @func + * @memberOf R + * @since v0.14.0 + * @category List + * @sig ((a, a) -> Boolean) -> [a] -> [a] + * @param {Function} pred A predicate used to test whether two items are equal. + * @param {Array} list The array to consider. + * @return {Array} `list` without repeating elements. + * @see R.transduce + * @example + * + * const l = [1, -1, 1, 3, 4, -4, -4, -5, 5, 3, 3]; + * R.dropRepeatsWith(R.eqBy(Math.abs), l); //=> [1, 3, 4, -5, 3] + */ + var dropRepeatsWith = _curry2(_dispatchable([], _xdropRepeatsWith, function dropRepeatsWith(pred, list) { + var result = []; + var idx = 1; + var len = list.length; + if (len !== 0) { + result[0] = list[0]; + while (idx < len) { + if (!pred(last(result), list[idx])) { + result[result.length] = list[idx]; + } + idx += 1; + } + } + return result; + })); + + /** + * Returns a new list without any consecutively repeating elements. + * [`R.equals`](#equals) is used to determine equality. + * + * Acts as a transducer if a transformer is given in list position. + * + * @func + * @memberOf R + * @since v0.14.0 + * @category List + * @sig [a] -> [a] + * @param {Array} list The array to consider. + * @return {Array} `list` without repeating elements. + * @see R.transduce + * @example + * + * R.dropRepeats([1, 1, 1, 2, 3, 4, 4, 2, 2]); //=> [1, 2, 3, 4, 2] + */ + var dropRepeats = _curry1( + _dispatchable([], _xdropRepeatsWith(equals), dropRepeatsWith(equals)) + ); + + function XDropWhile(f, xf) { + this.xf = xf; + this.f = f; + } + XDropWhile.prototype['@@transducer/init'] = _xfBase.init; + XDropWhile.prototype['@@transducer/result'] = _xfBase.result; + XDropWhile.prototype['@@transducer/step'] = function(result, input) { + if (this.f) { + if (this.f(input)) { + return result; + } + this.f = null; + } + return this.xf['@@transducer/step'](result, input); + }; + + var _xdropWhile = _curry2(function _xdropWhile(f, xf) { return new XDropWhile(f, xf); }); + + /** + * Returns a new list excluding the leading elements of a given list which + * satisfy the supplied predicate function. It passes each value to the supplied + * predicate function, skipping elements while the predicate function returns + * `true`. The predicate function is applied to one argument: *(value)*. + * + * Dispatches to the `dropWhile` method of the second argument, if present. + * + * Acts as a transducer if a transformer is given in list position. + * + * @func + * @memberOf R + * @since v0.9.0 + * @category List + * @sig (a -> Boolean) -> [a] -> [a] + * @sig (a -> Boolean) -> String -> String + * @param {Function} fn The function called per iteration. + * @param {Array} xs The collection to iterate over. + * @return {Array} A new array. + * @see R.takeWhile, R.transduce, R.addIndex + * @example + * + * const lteTwo = x => x <= 2; + * + * R.dropWhile(lteTwo, [1, 2, 3, 4, 3, 2, 1]); //=> [3, 4, 3, 2, 1] + * + * R.dropWhile(x => x !== 'd' , 'Ramda'); //=> 'da' + */ + var dropWhile = _curry2(_dispatchable(['dropWhile'], _xdropWhile, function dropWhile(pred, xs) { + var idx = 0; + var len = xs.length; + while (idx < len && pred(xs[idx])) { + idx += 1; + } + return slice(idx, Infinity, xs); + })); + + /** + * Returns `true` if one or both of its arguments are `true`. Returns `false` + * if both arguments are `false`. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Logic + * @sig a -> b -> a | b + * @param {Any} a + * @param {Any} b + * @return {Any} the first argument if truthy, otherwise the second argument. + * @see R.either, R.xor + * @example + * + * R.or(true, true); //=> true + * R.or(true, false); //=> true + * R.or(false, true); //=> true + * R.or(false, false); //=> false + */ + var or = _curry2(function or(a, b) { + return a || b; + }); + + /** + * A function wrapping calls to the two functions in an `||` operation, + * returning the result of the first function if it is truth-y and the result + * of the second function otherwise. Note that this is short-circuited, + * meaning that the second function will not be invoked if the first returns a + * truth-y value. + * + * In addition to functions, `R.either` also accepts any fantasy-land compatible + * applicative functor. + * + * @func + * @memberOf R + * @since v0.12.0 + * @category Logic + * @sig (*... -> Boolean) -> (*... -> Boolean) -> (*... -> Boolean) + * @param {Function} f a predicate + * @param {Function} g another predicate + * @return {Function} a function that applies its arguments to `f` and `g` and `||`s their outputs together. + * @see R.or + * @example + * + * const gt10 = x => x > 10; + * const even = x => x % 2 === 0; + * const f = R.either(gt10, even); + * f(101); //=> true + * f(8); //=> true + * + * R.either(Maybe.Just(false), Maybe.Just(55)); // => Maybe.Just(55) + * R.either([false, false, 'a'], [11]) // => [11, 11, "a"] + */ + var either = _curry2(function either(f, g) { + return _isFunction(f) ? + function _either() { + return f.apply(this, arguments) || g.apply(this, arguments); + } : + lift(or)(f, g); + }); + + /** + * Returns the empty value of its argument's type. Ramda defines the empty + * value of Array (`[]`), Object (`{}`), String (`''`), and Arguments. Other + * types are supported if they define `.empty`, + * `.prototype.empty` or implement the + * [FantasyLand Monoid spec](https://github.com/fantasyland/fantasy-land#monoid). + * + * Dispatches to the `empty` method of the first argument, if present. + * + * @func + * @memberOf R + * @since v0.3.0 + * @category Function + * @sig a -> a + * @param {*} x + * @return {*} + * @example + * + * R.empty(Just(42)); //=> Nothing() + * R.empty([1, 2, 3]); //=> [] + * R.empty('unicorns'); //=> '' + * R.empty({x: 1, y: 2}); //=> {} + */ + var empty = _curry1(function empty(x) { + return ( + (x != null && typeof x['fantasy-land/empty'] === 'function') + ? x['fantasy-land/empty']() + : (x != null && x.constructor != null && typeof x.constructor['fantasy-land/empty'] === 'function') + ? x.constructor['fantasy-land/empty']() + : (x != null && typeof x.empty === 'function') + ? x.empty() + : (x != null && x.constructor != null && typeof x.constructor.empty === 'function') + ? x.constructor.empty() + : _isArray(x) + ? [] + : _isString(x) + ? '' + : _isObject(x) + ? {} + : _isArguments(x) + ? (function() { return arguments; }()) + : void 0 // else + ); + }); + + /** + * Returns a new list containing the last `n` elements of the given list. + * If `n > list.length`, returns a list of `list.length` elements. + * + * @func + * @memberOf R + * @since v0.16.0 + * @category List + * @sig Number -> [a] -> [a] + * @sig Number -> String -> String + * @param {Number} n The number of elements to return. + * @param {Array} xs The collection to consider. + * @return {Array} + * @see R.dropLast + * @example + * + * R.takeLast(1, ['foo', 'bar', 'baz']); //=> ['baz'] + * R.takeLast(2, ['foo', 'bar', 'baz']); //=> ['bar', 'baz'] + * R.takeLast(3, ['foo', 'bar', 'baz']); //=> ['foo', 'bar', 'baz'] + * R.takeLast(4, ['foo', 'bar', 'baz']); //=> ['foo', 'bar', 'baz'] + * R.takeLast(3, 'ramda'); //=> 'mda' + */ + var takeLast = _curry2(function takeLast(n, xs) { + return drop(n >= 0 ? xs.length - n : 0, xs); + }); + + /** + * Checks if a list ends with the provided sublist. + * + * Similarly, checks if a string ends with the provided substring. + * + * @func + * @memberOf R + * @since v0.24.0 + * @category List + * @sig [a] -> [a] -> Boolean + * @sig String -> String -> Boolean + * @param {*} suffix + * @param {*} list + * @return {Boolean} + * @see R.startsWith + * @example + * + * R.endsWith('c', 'abc') //=> true + * R.endsWith('b', 'abc') //=> false + * R.endsWith(['c'], ['a', 'b', 'c']) //=> true + * R.endsWith(['b'], ['a', 'b', 'c']) //=> false + */ + var endsWith = _curry2(function(suffix, list) { + return equals(takeLast(suffix.length, list), suffix); + }); + + /** + * Takes a function and two values in its domain and returns `true` if the + * values map to the same value in the codomain; `false` otherwise. + * + * @func + * @memberOf R + * @since v0.18.0 + * @category Relation + * @sig (a -> b) -> a -> a -> Boolean + * @param {Function} f + * @param {*} x + * @param {*} y + * @return {Boolean} + * @example + * + * R.eqBy(Math.abs, 5, -5); //=> true + */ + var eqBy = _curry3(function eqBy(f, x, y) { + return equals(f(x), f(y)); + }); + + /** + * Reports whether two objects have the same value, in [`R.equals`](#equals) + * terms, for the specified property. Useful as a curried predicate. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Object + * @sig k -> {k: v} -> {k: v} -> Boolean + * @param {String} prop The name of the property to compare + * @param {Object} obj1 + * @param {Object} obj2 + * @return {Boolean} + * + * @example + * + * const o1 = { a: 1, b: 2, c: 3, d: 4 }; + * const o2 = { a: 10, b: 20, c: 3, d: 40 }; + * R.eqProps('a', o1, o2); //=> false + * R.eqProps('c', o1, o2); //=> true + */ + var eqProps = _curry3(function eqProps(prop, obj1, obj2) { + return equals(obj1[prop], obj2[prop]); + }); + + /** + * Creates a new object by recursively evolving a shallow copy of `object`, + * according to the `transformation` functions. All non-primitive properties + * are copied by reference. + * + * A `transformation` function will not be invoked if its corresponding key + * does not exist in the evolved object. + * + * @func + * @memberOf R + * @since v0.9.0 + * @category Object + * @sig {k: (v -> v)} -> {k: v} -> {k: v} + * @param {Object} transformations The object specifying transformation functions to apply + * to the object. + * @param {Object} object The object to be transformed. + * @return {Object} The transformed object. + * @example + * + * const tomato = {firstName: ' Tomato ', data: {elapsed: 100, remaining: 1400}, id:123}; + * const transformations = { + * firstName: R.trim, + * lastName: R.trim, // Will not get invoked. + * data: {elapsed: R.add(1), remaining: R.add(-1)} + * }; + * R.evolve(transformations, tomato); //=> {firstName: 'Tomato', data: {elapsed: 101, remaining: 1399}, id:123} + */ + var evolve = _curry2(function evolve(transformations, object) { + var result = object instanceof Array ? [] : {}; + var transformation, key, type; + for (key in object) { + transformation = transformations[key]; + type = typeof transformation; + result[key] = type === 'function' + ? transformation(object[key]) + : transformation && type === 'object' + ? evolve(transformation, object[key]) + : object[key]; + } + return result; + }); + + function XFind(f, xf) { + this.xf = xf; + this.f = f; + this.found = false; + } + XFind.prototype['@@transducer/init'] = _xfBase.init; + XFind.prototype['@@transducer/result'] = function(result) { + if (!this.found) { + result = this.xf['@@transducer/step'](result, void 0); + } + return this.xf['@@transducer/result'](result); + }; + XFind.prototype['@@transducer/step'] = function(result, input) { + if (this.f(input)) { + this.found = true; + result = _reduced(this.xf['@@transducer/step'](result, input)); + } + return result; + }; + + var _xfind = _curry2(function _xfind(f, xf) { return new XFind(f, xf); }); + + /** + * Returns the first element of the list which matches the predicate, or + * `undefined` if no element matches. + * + * Dispatches to the `find` method of the second argument, if present. + * + * Acts as a transducer if a transformer is given in list position. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category List + * @sig (a -> Boolean) -> [a] -> a | undefined + * @param {Function} fn The predicate function used to determine if the element is the + * desired one. + * @param {Array} list The array to consider. + * @return {Object} The element found, or `undefined`. + * @see R.transduce + * @example + * + * const xs = [{a: 1}, {a: 2}, {a: 3}]; + * R.find(R.propEq('a', 2))(xs); //=> {a: 2} + * R.find(R.propEq('a', 4))(xs); //=> undefined + */ + var find = _curry2(_dispatchable(['find'], _xfind, function find(fn, list) { + var idx = 0; + var len = list.length; + while (idx < len) { + if (fn(list[idx])) { + return list[idx]; + } + idx += 1; + } + })); + + function XFindIndex(f, xf) { + this.xf = xf; + this.f = f; + this.idx = -1; + this.found = false; + } + XFindIndex.prototype['@@transducer/init'] = _xfBase.init; + XFindIndex.prototype['@@transducer/result'] = function(result) { + if (!this.found) { + result = this.xf['@@transducer/step'](result, -1); + } + return this.xf['@@transducer/result'](result); + }; + XFindIndex.prototype['@@transducer/step'] = function(result, input) { + this.idx += 1; + if (this.f(input)) { + this.found = true; + result = _reduced(this.xf['@@transducer/step'](result, this.idx)); + } + return result; + }; + + var _xfindIndex = _curry2(function _xfindIndex(f, xf) { return new XFindIndex(f, xf); }); + + /** + * Returns the index of the first element of the list which matches the + * predicate, or `-1` if no element matches. + * + * Acts as a transducer if a transformer is given in list position. + * + * @func + * @memberOf R + * @since v0.1.1 + * @category List + * @sig (a -> Boolean) -> [a] -> Number + * @param {Function} fn The predicate function used to determine if the element is the + * desired one. + * @param {Array} list The array to consider. + * @return {Number} The index of the element found, or `-1`. + * @see R.transduce + * @example + * + * const xs = [{a: 1}, {a: 2}, {a: 3}]; + * R.findIndex(R.propEq('a', 2))(xs); //=> 1 + * R.findIndex(R.propEq('a', 4))(xs); //=> -1 + */ + var findIndex = _curry2(_dispatchable([], _xfindIndex, function findIndex(fn, list) { + var idx = 0; + var len = list.length; + while (idx < len) { + if (fn(list[idx])) { + return idx; + } + idx += 1; + } + return -1; + })); + + function XFindLast(f, xf) { + this.xf = xf; + this.f = f; + } + XFindLast.prototype['@@transducer/init'] = _xfBase.init; + XFindLast.prototype['@@transducer/result'] = function(result) { + return this.xf['@@transducer/result'](this.xf['@@transducer/step'](result, this.last)); + }; + XFindLast.prototype['@@transducer/step'] = function(result, input) { + if (this.f(input)) { + this.last = input; + } + return result; + }; + + var _xfindLast = _curry2(function _xfindLast(f, xf) { return new XFindLast(f, xf); }); + + /** + * Returns the last element of the list which matches the predicate, or + * `undefined` if no element matches. + * + * Acts as a transducer if a transformer is given in list position. + * + * @func + * @memberOf R + * @since v0.1.1 + * @category List + * @sig (a -> Boolean) -> [a] -> a | undefined + * @param {Function} fn The predicate function used to determine if the element is the + * desired one. + * @param {Array} list The array to consider. + * @return {Object} The element found, or `undefined`. + * @see R.transduce + * @example + * + * const xs = [{a: 1, b: 0}, {a:1, b: 1}]; + * R.findLast(R.propEq('a', 1))(xs); //=> {a: 1, b: 1} + * R.findLast(R.propEq('a', 4))(xs); //=> undefined + */ + var findLast = _curry2(_dispatchable([], _xfindLast, function findLast(fn, list) { + var idx = list.length - 1; + while (idx >= 0) { + if (fn(list[idx])) { + return list[idx]; + } + idx -= 1; + } + })); + + function XFindLastIndex(f, xf) { + this.xf = xf; + this.f = f; + this.idx = -1; + this.lastIdx = -1; + } + XFindLastIndex.prototype['@@transducer/init'] = _xfBase.init; + XFindLastIndex.prototype['@@transducer/result'] = function(result) { + return this.xf['@@transducer/result'](this.xf['@@transducer/step'](result, this.lastIdx)); + }; + XFindLastIndex.prototype['@@transducer/step'] = function(result, input) { + this.idx += 1; + if (this.f(input)) { + this.lastIdx = this.idx; + } + return result; + }; + + var _xfindLastIndex = _curry2(function _xfindLastIndex(f, xf) { return new XFindLastIndex(f, xf); }); + + /** + * Returns the index of the last element of the list which matches the + * predicate, or `-1` if no element matches. + * + * Acts as a transducer if a transformer is given in list position. + * + * @func + * @memberOf R + * @since v0.1.1 + * @category List + * @sig (a -> Boolean) -> [a] -> Number + * @param {Function} fn The predicate function used to determine if the element is the + * desired one. + * @param {Array} list The array to consider. + * @return {Number} The index of the element found, or `-1`. + * @see R.transduce + * @example + * + * const xs = [{a: 1, b: 0}, {a:1, b: 1}]; + * R.findLastIndex(R.propEq('a', 1))(xs); //=> 1 + * R.findLastIndex(R.propEq('a', 4))(xs); //=> -1 + */ + var findLastIndex = _curry2(_dispatchable([], _xfindLastIndex, function findLastIndex(fn, list) { + var idx = list.length - 1; + while (idx >= 0) { + if (fn(list[idx])) { + return idx; + } + idx -= 1; + } + return -1; + })); + + /** + * Returns a new list by pulling every item out of it (and all its sub-arrays) + * and putting them in a new array, depth-first. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category List + * @sig [a] -> [b] + * @param {Array} list The array to consider. + * @return {Array} The flattened list. + * @see R.unnest + * @example + * + * R.flatten([1, 2, [3, 4], 5, [6, [7, 8, [9, [10, 11], 12]]]]); + * //=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] + */ + var flatten = _curry1(_makeFlat(true)); + + /** + * Returns a new function much like the supplied one, except that the first two + * arguments' order is reversed. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Function + * @sig ((a, b, c, ...) -> z) -> (b -> a -> c -> ... -> z) + * @param {Function} fn The function to invoke with its first two parameters reversed. + * @return {*} The result of invoking `fn` with its first two parameters' order reversed. + * @example + * + * const mergeThree = (a, b, c) => [].concat(a, b, c); + * + * mergeThree(1, 2, 3); //=> [1, 2, 3] + * + * R.flip(mergeThree)(1, 2, 3); //=> [2, 1, 3] + * @symb R.flip(f)(a, b, c) = f(b, a, c) + */ + var flip = _curry1(function flip(fn) { + return curryN(fn.length, function(a, b) { + var args = Array.prototype.slice.call(arguments, 0); + args[0] = b; + args[1] = a; + return fn.apply(this, args); + }); + }); + + /** + * Iterate over an input `list`, calling a provided function `fn` for each + * element in the list. + * + * `fn` receives one argument: *(value)*. + * + * Note: `R.forEach` does not skip deleted or unassigned indices (sparse + * arrays), unlike the native `Array.prototype.forEach` method. For more + * details on this behavior, see: + * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach#Description + * + * Also note that, unlike `Array.prototype.forEach`, Ramda's `forEach` returns + * the original array. In some libraries this function is named `each`. + * + * Dispatches to the `forEach` method of the second argument, if present. + * + * @func + * @memberOf R + * @since v0.1.1 + * @category List + * @sig (a -> *) -> [a] -> [a] + * @param {Function} fn The function to invoke. Receives one argument, `value`. + * @param {Array} list The list to iterate over. + * @return {Array} The original list. + * @see R.addIndex + * @example + * + * const printXPlusFive = x => console.log(x + 5); + * R.forEach(printXPlusFive, [1, 2, 3]); //=> [1, 2, 3] + * // logs 6 + * // logs 7 + * // logs 8 + * @symb R.forEach(f, [a, b, c]) = [a, b, c] + */ + var forEach = _curry2(_checkForMethod('forEach', function forEach(fn, list) { + var len = list.length; + var idx = 0; + while (idx < len) { + fn(list[idx]); + idx += 1; + } + return list; + })); + + /** + * Iterate over an input `object`, calling a provided function `fn` for each + * key and value in the object. + * + * `fn` receives three argument: *(value, key, obj)*. + * + * @func + * @memberOf R + * @since v0.23.0 + * @category Object + * @sig ((a, String, StrMap a) -> Any) -> StrMap a -> StrMap a + * @param {Function} fn The function to invoke. Receives three argument, `value`, `key`, `obj`. + * @param {Object} obj The object to iterate over. + * @return {Object} The original object. + * @example + * + * const printKeyConcatValue = (value, key) => console.log(key + ':' + value); + * R.forEachObjIndexed(printKeyConcatValue, {x: 1, y: 2}); //=> {x: 1, y: 2} + * // logs x:1 + * // logs y:2 + * @symb R.forEachObjIndexed(f, {x: a, y: b}) = {x: a, y: b} + */ + var forEachObjIndexed = _curry2(function forEachObjIndexed(fn, obj) { + var keyList = keys(obj); + var idx = 0; + while (idx < keyList.length) { + var key = keyList[idx]; + fn(obj[key], key, obj); + idx += 1; + } + return obj; + }); + + /** + * Creates a new object from a list key-value pairs. If a key appears in + * multiple pairs, the rightmost pair is included in the object. + * + * @func + * @memberOf R + * @since v0.3.0 + * @category List + * @sig [[k,v]] -> {k: v} + * @param {Array} pairs An array of two-element arrays that will be the keys and values of the output object. + * @return {Object} The object made by pairing up `keys` and `values`. + * @see R.toPairs, R.pair + * @example + * + * R.fromPairs([['a', 1], ['b', 2], ['c', 3]]); //=> {a: 1, b: 2, c: 3} + */ + var fromPairs = _curry1(function fromPairs(pairs) { + var result = {}; + var idx = 0; + while (idx < pairs.length) { + result[pairs[idx][0]] = pairs[idx][1]; + idx += 1; + } + return result; + }); + + /** + * Splits a list into sub-lists stored in an object, based on the result of + * calling a String-returning function on each element, and grouping the + * results according to values returned. + * + * Dispatches to the `groupBy` method of the second argument, if present. + * + * Acts as a transducer if a transformer is given in list position. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category List + * @sig (a -> String) -> [a] -> {String: [a]} + * @param {Function} fn Function :: a -> String + * @param {Array} list The array to group + * @return {Object} An object with the output of `fn` for keys, mapped to arrays of elements + * that produced that key when passed to `fn`. + * @see R.reduceBy, R.transduce + * @example + * + * const byGrade = R.groupBy(function(student) { + * const score = student.score; + * return score < 65 ? 'F' : + * score < 70 ? 'D' : + * score < 80 ? 'C' : + * score < 90 ? 'B' : 'A'; + * }); + * const students = [{name: 'Abby', score: 84}, + * {name: 'Eddy', score: 58}, + * // ... + * {name: 'Jack', score: 69}]; + * byGrade(students); + * // { + * // 'A': [{name: 'Dianne', score: 99}], + * // 'B': [{name: 'Abby', score: 84}] + * // // ..., + * // 'F': [{name: 'Eddy', score: 58}] + * // } + */ + var groupBy = _curry2(_checkForMethod('groupBy', reduceBy(function(acc, item) { + if (acc == null) { + acc = []; + } + acc.push(item); + return acc; + }, null))); + + /** + * Takes a list and returns a list of lists where each sublist's elements are + * all satisfied pairwise comparison according to the provided function. + * Only adjacent elements are passed to the comparison function. + * + * @func + * @memberOf R + * @since v0.21.0 + * @category List + * @sig ((a, a) → Boolean) → [a] → [[a]] + * @param {Function} fn Function for determining whether two given (adjacent) + * elements should be in the same group + * @param {Array} list The array to group. Also accepts a string, which will be + * treated as a list of characters. + * @return {List} A list that contains sublists of elements, + * whose concatenations are equal to the original list. + * @example + * + * R.groupWith(R.equals, [0, 1, 1, 2, 3, 5, 8, 13, 21]) + * //=> [[0], [1, 1], [2], [3], [5], [8], [13], [21]] + * + * R.groupWith((a, b) => a + 1 === b, [0, 1, 1, 2, 3, 5, 8, 13, 21]) + * //=> [[0, 1], [1, 2, 3], [5], [8], [13], [21]] + * + * R.groupWith((a, b) => a % 2 === b % 2, [0, 1, 1, 2, 3, 5, 8, 13, 21]) + * //=> [[0], [1, 1], [2], [3, 5], [8], [13, 21]] + * + * R.groupWith(R.eqBy(isVowel), 'aestiou') + * //=> ['ae', 'st', 'iou'] + */ + var groupWith = _curry2(function(fn, list) { + var res = []; + var idx = 0; + var len = list.length; + while (idx < len) { + var nextidx = idx + 1; + while (nextidx < len && fn(list[nextidx - 1], list[nextidx])) { + nextidx += 1; + } + res.push(list.slice(idx, nextidx)); + idx = nextidx; + } + return res; + }); + + /** + * Returns `true` if the first argument is greater than the second; `false` + * otherwise. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Relation + * @sig Ord a => a -> a -> Boolean + * @param {*} a + * @param {*} b + * @return {Boolean} + * @see R.lt + * @example + * + * R.gt(2, 1); //=> true + * R.gt(2, 2); //=> false + * R.gt(2, 3); //=> false + * R.gt('a', 'z'); //=> false + * R.gt('z', 'a'); //=> true + */ + var gt = _curry2(function gt(a, b) { return a > b; }); + + /** + * Returns `true` if the first argument is greater than or equal to the second; + * `false` otherwise. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Relation + * @sig Ord a => a -> a -> Boolean + * @param {Number} a + * @param {Number} b + * @return {Boolean} + * @see R.lte + * @example + * + * R.gte(2, 1); //=> true + * R.gte(2, 2); //=> true + * R.gte(2, 3); //=> false + * R.gte('a', 'z'); //=> false + * R.gte('z', 'a'); //=> true + */ + var gte = _curry2(function gte(a, b) { return a >= b; }); + + /** + * Returns whether or not a path exists in an object. Only the object's + * own properties are checked. + * + * @func + * @memberOf R + * @since v0.26.0 + * @category Object + * @typedefn Idx = String | Int + * @sig [Idx] -> {a} -> Boolean + * @param {Array} path The path to use. + * @param {Object} obj The object to check the path in. + * @return {Boolean} Whether the path exists. + * @see R.has + * @example + * + * R.hasPath(['a', 'b'], {a: {b: 2}}); // => true + * R.hasPath(['a', 'b'], {a: {b: undefined}}); // => true + * R.hasPath(['a', 'b'], {a: {c: 2}}); // => false + * R.hasPath(['a', 'b'], {}); // => false + */ + var hasPath = _curry2(function hasPath(_path, obj) { + if (_path.length === 0 || isNil(obj)) { + return false; + } + var val = obj; + var idx = 0; + while (idx < _path.length) { + if (!isNil(val) && _has(_path[idx], val)) { + val = val[_path[idx]]; + idx += 1; + } else { + return false; + } + } + return true; + }); + + /** + * Returns whether or not an object has an own property with the specified name + * + * @func + * @memberOf R + * @since v0.7.0 + * @category Object + * @sig s -> {s: x} -> Boolean + * @param {String} prop The name of the property to check for. + * @param {Object} obj The object to query. + * @return {Boolean} Whether the property exists. + * @example + * + * const hasName = R.has('name'); + * hasName({name: 'alice'}); //=> true + * hasName({name: 'bob'}); //=> true + * hasName({}); //=> false + * + * const point = {x: 0, y: 0}; + * const pointHas = R.has(R.__, point); + * pointHas('x'); //=> true + * pointHas('y'); //=> true + * pointHas('z'); //=> false + */ + var has = _curry2(function has(prop, obj) { + return hasPath([prop], obj); + }); + + /** + * Returns whether or not an object or its prototype chain has a property with + * the specified name + * + * @func + * @memberOf R + * @since v0.7.0 + * @category Object + * @sig s -> {s: x} -> Boolean + * @param {String} prop The name of the property to check for. + * @param {Object} obj The object to query. + * @return {Boolean} Whether the property exists. + * @example + * + * function Rectangle(width, height) { + * this.width = width; + * this.height = height; + * } + * Rectangle.prototype.area = function() { + * return this.width * this.height; + * }; + * + * const square = new Rectangle(2, 2); + * R.hasIn('width', square); //=> true + * R.hasIn('area', square); //=> true + */ + var hasIn = _curry2(function hasIn(prop, obj) { + return prop in obj; + }); + + /** + * Returns true if its arguments are identical, false otherwise. Values are + * identical if they reference the same memory. `NaN` is identical to `NaN`; + * `0` and `-0` are not identical. + * + * Note this is merely a curried version of ES6 `Object.is`. + * + * @func + * @memberOf R + * @since v0.15.0 + * @category Relation + * @sig a -> a -> Boolean + * @param {*} a + * @param {*} b + * @return {Boolean} + * @example + * + * const o = {}; + * R.identical(o, o); //=> true + * R.identical(1, 1); //=> true + * R.identical(1, '1'); //=> false + * R.identical([], []); //=> false + * R.identical(0, -0); //=> false + * R.identical(NaN, NaN); //=> true + */ + var identical = _curry2(_objectIs$1); + + /** + * Creates a function that will process either the `onTrue` or the `onFalse` + * function depending upon the result of the `condition` predicate. + * + * @func + * @memberOf R + * @since v0.8.0 + * @category Logic + * @sig (*... -> Boolean) -> (*... -> *) -> (*... -> *) -> (*... -> *) + * @param {Function} condition A predicate function + * @param {Function} onTrue A function to invoke when the `condition` evaluates to a truthy value. + * @param {Function} onFalse A function to invoke when the `condition` evaluates to a falsy value. + * @return {Function} A new function that will process either the `onTrue` or the `onFalse` + * function depending upon the result of the `condition` predicate. + * @see R.unless, R.when, R.cond + * @example + * + * const incCount = R.ifElse( + * R.has('count'), + * R.over(R.lensProp('count'), R.inc), + * R.assoc('count', 1) + * ); + * incCount({}); //=> { count: 1 } + * incCount({ count: 1 }); //=> { count: 2 } + */ + var ifElse = _curry3(function ifElse(condition, onTrue, onFalse) { + return curryN(Math.max(condition.length, onTrue.length, onFalse.length), + function _ifElse() { + return condition.apply(this, arguments) ? onTrue.apply(this, arguments) : onFalse.apply(this, arguments); + } + ); + }); + + /** + * Increments its argument. + * + * @func + * @memberOf R + * @since v0.9.0 + * @category Math + * @sig Number -> Number + * @param {Number} n + * @return {Number} n + 1 + * @see R.dec + * @example + * + * R.inc(42); //=> 43 + */ + var inc = add(1); + + /** + * Returns `true` if the specified value is equal, in [`R.equals`](#equals) + * terms, to at least one element of the given list; `false` otherwise. + * Works also with strings. + * + * @func + * @memberOf R + * @since v0.26.0 + * @category List + * @sig a -> [a] -> Boolean + * @param {Object} a The item to compare against. + * @param {Array} list The array to consider. + * @return {Boolean} `true` if an equivalent item is in the list, `false` otherwise. + * @see R.any + * @example + * + * R.includes(3, [1, 2, 3]); //=> true + * R.includes(4, [1, 2, 3]); //=> false + * R.includes({ name: 'Fred' }, [{ name: 'Fred' }]); //=> true + * R.includes([42], [[42]]); //=> true + * R.includes('ba', 'banana'); //=>true + */ + var includes = _curry2(_includes); + + /** + * Given a function that generates a key, turns a list of objects into an + * object indexing the objects by the given key. Note that if multiple + * objects generate the same value for the indexing key only the last value + * will be included in the generated object. + * + * Acts as a transducer if a transformer is given in list position. + * + * @func + * @memberOf R + * @since v0.19.0 + * @category List + * @sig (a -> String) -> [{k: v}] -> {k: {k: v}} + * @param {Function} fn Function :: a -> String + * @param {Array} array The array of objects to index + * @return {Object} An object indexing each array element by the given property. + * @example + * + * const list = [{id: 'xyz', title: 'A'}, {id: 'abc', title: 'B'}]; + * R.indexBy(R.prop('id'), list); + * //=> {abc: {id: 'abc', title: 'B'}, xyz: {id: 'xyz', title: 'A'}} + */ + var indexBy = reduceBy(function(acc, elem) { return elem; }, null); + + /** + * Returns the position of the first occurrence of an item in an array, or -1 + * if the item is not included in the array. [`R.equals`](#equals) is used to + * determine equality. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category List + * @sig a -> [a] -> Number + * @param {*} target The item to find. + * @param {Array} xs The array to search in. + * @return {Number} the index of the target, or -1 if the target is not found. + * @see R.lastIndexOf + * @example + * + * R.indexOf(3, [1,2,3,4]); //=> 2 + * R.indexOf(10, [1,2,3,4]); //=> -1 + */ + var indexOf = _curry2(function indexOf(target, xs) { + return typeof xs.indexOf === 'function' && !_isArray(xs) ? + xs.indexOf(target) : + _indexOf(xs, target, 0); + }); + + /** + * Returns all but the last element of the given list or string. + * + * @func + * @memberOf R + * @since v0.9.0 + * @category List + * @sig [a] -> [a] + * @sig String -> String + * @param {*} list + * @return {*} + * @see R.last, R.head, R.tail + * @example + * + * R.init([1, 2, 3]); //=> [1, 2] + * R.init([1, 2]); //=> [1] + * R.init([1]); //=> [] + * R.init([]); //=> [] + * + * R.init('abc'); //=> 'ab' + * R.init('ab'); //=> 'a' + * R.init('a'); //=> '' + * R.init(''); //=> '' + */ + var init = slice(0, -1); + + /** + * Takes a predicate `pred`, a list `xs`, and a list `ys`, and returns a list + * `xs'` comprising each of the elements of `xs` which is equal to one or more + * elements of `ys` according to `pred`. + * + * `pred` must be a binary function expecting an element from each list. + * + * `xs`, `ys`, and `xs'` are treated as sets, semantically, so ordering should + * not be significant, but since `xs'` is ordered the implementation guarantees + * that its values are in the same order as they appear in `xs`. Duplicates are + * not removed, so `xs'` may contain duplicates if `xs` contains duplicates. + * + * @func + * @memberOf R + * @since v0.24.0 + * @category Relation + * @sig ((a, b) -> Boolean) -> [a] -> [b] -> [a] + * @param {Function} pred + * @param {Array} xs + * @param {Array} ys + * @return {Array} + * @see R.intersection + * @example + * + * R.innerJoin( + * (record, id) => record.id === id, + * [{id: 824, name: 'Richie Furay'}, + * {id: 956, name: 'Dewey Martin'}, + * {id: 313, name: 'Bruce Palmer'}, + * {id: 456, name: 'Stephen Stills'}, + * {id: 177, name: 'Neil Young'}], + * [177, 456, 999] + * ); + * //=> [{id: 456, name: 'Stephen Stills'}, {id: 177, name: 'Neil Young'}] + */ + var innerJoin = _curry3(function innerJoin(pred, xs, ys) { + return _filter(function(x) { return _includesWith(pred, x, ys); }, xs); + }); + + /** + * Inserts the supplied element into the list, at the specified `index`. _Note that + + * this is not destructive_: it returns a copy of the list with the changes. + * No lists have been harmed in the application of this function. + * + * @func + * @memberOf R + * @since v0.2.2 + * @category List + * @sig Number -> a -> [a] -> [a] + * @param {Number} index The position to insert the element + * @param {*} elt The element to insert into the Array + * @param {Array} list The list to insert into + * @return {Array} A new Array with `elt` inserted at `index`. + * @example + * + * R.insert(2, 'x', [1,2,3,4]); //=> [1,2,'x',3,4] + */ + var insert = _curry3(function insert(idx, elt, list) { + idx = idx < list.length && idx >= 0 ? idx : list.length; + var result = Array.prototype.slice.call(list, 0); + result.splice(idx, 0, elt); + return result; + }); + + /** + * Inserts the sub-list into the list, at the specified `index`. _Note that this is not + * destructive_: it returns a copy of the list with the changes. + * No lists have been harmed in the application of this function. + * + * @func + * @memberOf R + * @since v0.9.0 + * @category List + * @sig Number -> [a] -> [a] -> [a] + * @param {Number} index The position to insert the sub-list + * @param {Array} elts The sub-list to insert into the Array + * @param {Array} list The list to insert the sub-list into + * @return {Array} A new Array with `elts` inserted starting at `index`. + * @example + * + * R.insertAll(2, ['x','y','z'], [1,2,3,4]); //=> [1,2,'x','y','z',3,4] + */ + var insertAll = _curry3(function insertAll(idx, elts, list) { + idx = idx < list.length && idx >= 0 ? idx : list.length; + return [].concat( + Array.prototype.slice.call(list, 0, idx), + elts, + Array.prototype.slice.call(list, idx) + ); + }); + + /** + * Returns a new list containing only one copy of each element in the original + * list, based upon the value returned by applying the supplied function to + * each list element. Prefers the first item if the supplied function produces + * the same value on two items. [`R.equals`](#equals) is used for comparison. + * + * @func + * @memberOf R + * @since v0.16.0 + * @category List + * @sig (a -> b) -> [a] -> [a] + * @param {Function} fn A function used to produce a value to use during comparisons. + * @param {Array} list The array to consider. + * @return {Array} The list of unique items. + * @example + * + * R.uniqBy(Math.abs, [-1, -5, 2, 10, 1, 2]); //=> [-1, -5, 2, 10] + */ + var uniqBy = _curry2(function uniqBy(fn, list) { + var set = new _Set(); + var result = []; + var idx = 0; + var appliedItem, item; + + while (idx < list.length) { + item = list[idx]; + appliedItem = fn(item); + if (set.add(appliedItem)) { + result.push(item); + } + idx += 1; + } + return result; + }); + + /** + * Returns a new list containing only one copy of each element in the original + * list. [`R.equals`](#equals) is used to determine equality. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category List + * @sig [a] -> [a] + * @param {Array} list The array to consider. + * @return {Array} The list of unique items. + * @example + * + * R.uniq([1, 1, 2, 1]); //=> [1, 2] + * R.uniq([1, '1']); //=> [1, '1'] + * R.uniq([[42], [42]]); //=> [[42]] + */ + var uniq = uniqBy(identity); + + /** + * Combines two lists into a set (i.e. no duplicates) composed of those + * elements common to both lists. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Relation + * @sig [*] -> [*] -> [*] + * @param {Array} list1 The first list. + * @param {Array} list2 The second list. + * @return {Array} The list of elements found in both `list1` and `list2`. + * @see R.innerJoin + * @example + * + * R.intersection([1,2,3,4], [7,6,5,4,3]); //=> [4, 3] + */ + var intersection = _curry2(function intersection(list1, list2) { + var lookupList, filteredList; + if (list1.length > list2.length) { + lookupList = list1; + filteredList = list2; + } else { + lookupList = list2; + filteredList = list1; + } + return uniq(_filter(flip(_includes)(lookupList), filteredList)); + }); + + /** + * Creates a new list with the separator interposed between elements. + * + * Dispatches to the `intersperse` method of the second argument, if present. + * + * @func + * @memberOf R + * @since v0.14.0 + * @category List + * @sig a -> [a] -> [a] + * @param {*} separator The element to add to the list. + * @param {Array} list The list to be interposed. + * @return {Array} The new list. + * @example + * + * R.intersperse('a', ['b', 'n', 'n', 's']); //=> ['b', 'a', 'n', 'a', 'n', 'a', 's'] + */ + var intersperse = _curry2(_checkForMethod('intersperse', function intersperse(separator, list) { + var out = []; + var idx = 0; + var length = list.length; + while (idx < length) { + if (idx === length - 1) { + out.push(list[idx]); + } else { + out.push(list[idx], separator); + } + idx += 1; + } + return out; + })); + + // Based on https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/assign + function _objectAssign(target) { + if (target == null) { + throw new TypeError('Cannot convert undefined or null to object'); + } + + var output = Object(target); + var idx = 1; + var length = arguments.length; + while (idx < length) { + var source = arguments[idx]; + if (source != null) { + for (var nextKey in source) { + if (_has(nextKey, source)) { + output[nextKey] = source[nextKey]; + } + } + } + idx += 1; + } + return output; + } + + var _objectAssign$1 = typeof Object.assign === 'function' ? Object.assign : _objectAssign; + + /** + * Creates an object containing a single key:value pair. + * + * @func + * @memberOf R + * @since v0.18.0 + * @category Object + * @sig String -> a -> {String:a} + * @param {String} key + * @param {*} val + * @return {Object} + * @see R.pair + * @example + * + * const matchPhrases = R.compose( + * R.objOf('must'), + * R.map(R.objOf('match_phrase')) + * ); + * matchPhrases(['foo', 'bar', 'baz']); //=> {must: [{match_phrase: 'foo'}, {match_phrase: 'bar'}, {match_phrase: 'baz'}]} + */ + var objOf = _curry2(function objOf(key, val) { + var obj = {}; + obj[key] = val; + return obj; + }); + + var _stepCatArray = { + '@@transducer/init': Array, + '@@transducer/step': function(xs, x) { + xs.push(x); + return xs; + }, + '@@transducer/result': _identity + }; + var _stepCatString = { + '@@transducer/init': String, + '@@transducer/step': function(a, b) { return a + b; }, + '@@transducer/result': _identity + }; + var _stepCatObject = { + '@@transducer/init': Object, + '@@transducer/step': function(result, input) { + return _objectAssign$1( + result, + _isArrayLike(input) ? objOf(input[0], input[1]) : input + ); + }, + '@@transducer/result': _identity + }; + + function _stepCat(obj) { + if (_isTransformer(obj)) { + return obj; + } + if (_isArrayLike(obj)) { + return _stepCatArray; + } + if (typeof obj === 'string') { + return _stepCatString; + } + if (typeof obj === 'object') { + return _stepCatObject; + } + throw new Error('Cannot create transformer for ' + obj); + } + + /** + * Transforms the items of the list with the transducer and appends the + * transformed items to the accumulator using an appropriate iterator function + * based on the accumulator type. + * + * The accumulator can be an array, string, object or a transformer. Iterated + * items will be appended to arrays and concatenated to strings. Objects will + * be merged directly or 2-item arrays will be merged as key, value pairs. + * + * The accumulator can also be a transformer object that provides a 2-arity + * reducing iterator function, step, 0-arity initial value function, init, and + * 1-arity result extraction function result. The step function is used as the + * iterator function in reduce. The result function is used to convert the + * final accumulator into the return type and in most cases is R.identity. The + * init function is used to provide the initial accumulator. + * + * The iteration is performed with [`R.reduce`](#reduce) after initializing the + * transducer. + * + * @func + * @memberOf R + * @since v0.12.0 + * @category List + * @sig a -> (b -> b) -> [c] -> a + * @param {*} acc The initial accumulator value. + * @param {Function} xf The transducer function. Receives a transformer and returns a transformer. + * @param {Array} list The list to iterate over. + * @return {*} The final, accumulated value. + * @see R.transduce + * @example + * + * const numbers = [1, 2, 3, 4]; + * const transducer = R.compose(R.map(R.add(1)), R.take(2)); + * + * R.into([], transducer, numbers); //=> [2, 3] + * + * const intoArray = R.into([]); + * intoArray(transducer, numbers); //=> [2, 3] + */ + var into = _curry3(function into(acc, xf, list) { + return _isTransformer(acc) ? + _reduce(xf(acc), acc['@@transducer/init'](), list) : + _reduce(xf(_stepCat(acc)), _clone(acc, [], [], false), list); + }); + + /** + * Same as [`R.invertObj`](#invertObj), however this accounts for objects with + * duplicate values by putting the values into an array. + * + * @func + * @memberOf R + * @since v0.9.0 + * @category Object + * @sig {s: x} -> {x: [ s, ... ]} + * @param {Object} obj The object or array to invert + * @return {Object} out A new object with keys in an array. + * @see R.invertObj + * @example + * + * const raceResultsByFirstName = { + * first: 'alice', + * second: 'jake', + * third: 'alice', + * }; + * R.invert(raceResultsByFirstName); + * //=> { 'alice': ['first', 'third'], 'jake':['second'] } + */ + var invert = _curry1(function invert(obj) { + var props = keys(obj); + var len = props.length; + var idx = 0; + var out = {}; + + while (idx < len) { + var key = props[idx]; + var val = obj[key]; + var list = _has(val, out) ? out[val] : (out[val] = []); + list[list.length] = key; + idx += 1; + } + return out; + }); + + /** + * Returns a new object with the keys of the given object as values, and the + * values of the given object, which are coerced to strings, as keys. Note + * that the last key found is preferred when handling the same value. + * + * @func + * @memberOf R + * @since v0.9.0 + * @category Object + * @sig {s: x} -> {x: s} + * @param {Object} obj The object or array to invert + * @return {Object} out A new object + * @see R.invert + * @example + * + * const raceResults = { + * first: 'alice', + * second: 'jake' + * }; + * R.invertObj(raceResults); + * //=> { 'alice': 'first', 'jake':'second' } + * + * // Alternatively: + * const raceResults = ['alice', 'jake']; + * R.invertObj(raceResults); + * //=> { 'alice': '0', 'jake':'1' } + */ + var invertObj = _curry1(function invertObj(obj) { + var props = keys(obj); + var len = props.length; + var idx = 0; + var out = {}; + + while (idx < len) { + var key = props[idx]; + out[obj[key]] = key; + idx += 1; + } + return out; + }); + + /** + * Turns a named method with a specified arity into a function that can be + * called directly supplied with arguments and a target object. + * + * The returned function is curried and accepts `arity + 1` parameters where + * the final parameter is the target object. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Function + * @sig Number -> String -> (a -> b -> ... -> n -> Object -> *) + * @param {Number} arity Number of arguments the returned function should take + * before the target object. + * @param {String} method Name of any of the target object's methods to call. + * @return {Function} A new curried function. + * @see R.construct + * @example + * + * const sliceFrom = R.invoker(1, 'slice'); + * sliceFrom(6, 'abcdefghijklm'); //=> 'ghijklm' + * const sliceFrom6 = R.invoker(2, 'slice')(6); + * sliceFrom6(8, 'abcdefghijklm'); //=> 'gh' + * + * const dog = { + * speak: async () => 'Woof!' + * }; + * const speak = R.invoker(0, 'speak'); + * speak(dog).then(console.log) //~> 'Woof!' + * + * @symb R.invoker(0, 'method')(o) = o['method']() + * @symb R.invoker(1, 'method')(a, o) = o['method'](a) + * @symb R.invoker(2, 'method')(a, b, o) = o['method'](a, b) + */ + var invoker = _curry2(function invoker(arity, method) { + return curryN(arity + 1, function() { + var target = arguments[arity]; + if (target != null && _isFunction(target[method])) { + return target[method].apply(target, Array.prototype.slice.call(arguments, 0, arity)); + } + throw new TypeError(toString$1(target) + ' does not have a method named "' + method + '"'); + }); + }); + + /** + * See if an object (`val`) is an instance of the supplied constructor. This + * function will check up the inheritance chain, if any. + * + * @func + * @memberOf R + * @since v0.3.0 + * @category Type + * @sig (* -> {*}) -> a -> Boolean + * @param {Object} ctor A constructor + * @param {*} val The value to test + * @return {Boolean} + * @example + * + * R.is(Object, {}); //=> true + * R.is(Number, 1); //=> true + * R.is(Object, 1); //=> false + * R.is(String, 's'); //=> true + * R.is(String, new String('')); //=> true + * R.is(Object, new String('')); //=> true + * R.is(Object, 's'); //=> false + * R.is(Number, {}); //=> false + */ + var is = _curry2(function is(Ctor, val) { + return val != null && val.constructor === Ctor || val instanceof Ctor; + }); + + /** + * Returns `true` if the given value is its type's empty value; `false` + * otherwise. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Logic + * @sig a -> Boolean + * @param {*} x + * @return {Boolean} + * @see R.empty + * @example + * + * R.isEmpty([1, 2, 3]); //=> false + * R.isEmpty([]); //=> true + * R.isEmpty(''); //=> true + * R.isEmpty(null); //=> false + * R.isEmpty({}); //=> true + * R.isEmpty({length: 0}); //=> false + */ + var isEmpty = _curry1(function isEmpty(x) { + return x != null && equals(x, empty(x)); + }); + + /** + * Returns a string made by inserting the `separator` between each element and + * concatenating all the elements into a single string. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category List + * @sig String -> [a] -> String + * @param {Number|String} separator The string used to separate the elements. + * @param {Array} xs The elements to join into a string. + * @return {String} str The string made by concatenating `xs` with `separator`. + * @see R.split + * @example + * + * const spacer = R.join(' '); + * spacer(['a', 2, 3.4]); //=> 'a 2 3.4' + * R.join('|', [1, 2, 3]); //=> '1|2|3' + */ + var join = invoker(1, 'join'); + + /** + * juxt applies a list of functions to a list of values. + * + * @func + * @memberOf R + * @since v0.19.0 + * @category Function + * @sig [(a, b, ..., m) -> n] -> ((a, b, ..., m) -> [n]) + * @param {Array} fns An array of functions + * @return {Function} A function that returns a list of values after applying each of the original `fns` to its parameters. + * @see R.applySpec + * @example + * + * const getRange = R.juxt([Math.min, Math.max]); + * getRange(3, 4, 9, -3); //=> [-3, 9] + * @symb R.juxt([f, g, h])(a, b) = [f(a, b), g(a, b), h(a, b)] + */ + var juxt = _curry1(function juxt(fns) { + return converge(function() { return Array.prototype.slice.call(arguments, 0); }, fns); + }); + + /** + * Returns a list containing the names of all the properties of the supplied + * object, including prototype properties. + * Note that the order of the output array is not guaranteed to be consistent + * across different JS platforms. + * + * @func + * @memberOf R + * @since v0.2.0 + * @category Object + * @sig {k: v} -> [k] + * @param {Object} obj The object to extract properties from + * @return {Array} An array of the object's own and prototype properties. + * @see R.keys, R.valuesIn + * @example + * + * const F = function() { this.x = 'X'; }; + * F.prototype.y = 'Y'; + * const f = new F(); + * R.keysIn(f); //=> ['x', 'y'] + */ + var keysIn = _curry1(function keysIn(obj) { + var prop; + var ks = []; + for (prop in obj) { + ks[ks.length] = prop; + } + return ks; + }); + + /** + * Returns the position of the last occurrence of an item in an array, or -1 if + * the item is not included in the array. [`R.equals`](#equals) is used to + * determine equality. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category List + * @sig a -> [a] -> Number + * @param {*} target The item to find. + * @param {Array} xs The array to search in. + * @return {Number} the index of the target, or -1 if the target is not found. + * @see R.indexOf + * @example + * + * R.lastIndexOf(3, [-1,3,3,0,1,2,3,4]); //=> 6 + * R.lastIndexOf(10, [1,2,3,4]); //=> -1 + */ + var lastIndexOf = _curry2(function lastIndexOf(target, xs) { + if (typeof xs.lastIndexOf === 'function' && !_isArray(xs)) { + return xs.lastIndexOf(target); + } else { + var idx = xs.length - 1; + while (idx >= 0) { + if (equals(xs[idx], target)) { + return idx; + } + idx -= 1; + } + return -1; + } + }); + + function _isNumber(x) { + return Object.prototype.toString.call(x) === '[object Number]'; + } + + /** + * Returns the number of elements in the array by returning `list.length`. + * + * @func + * @memberOf R + * @since v0.3.0 + * @category List + * @sig [a] -> Number + * @param {Array} list The array to inspect. + * @return {Number} The length of the array. + * @example + * + * R.length([]); //=> 0 + * R.length([1, 2, 3]); //=> 3 + */ + var length = _curry1(function length(list) { + return list != null && _isNumber(list.length) ? list.length : NaN; + }); + + /** + * Returns a lens for the given getter and setter functions. The getter "gets" + * the value of the focus; the setter "sets" the value of the focus. The setter + * should not mutate the data structure. + * + * @func + * @memberOf R + * @since v0.8.0 + * @category Object + * @typedefn Lens s a = Functor f => (a -> f a) -> s -> f s + * @sig (s -> a) -> ((a, s) -> s) -> Lens s a + * @param {Function} getter + * @param {Function} setter + * @return {Lens} + * @see R.view, R.set, R.over, R.lensIndex, R.lensProp + * @example + * + * const xLens = R.lens(R.prop('x'), R.assoc('x')); + * + * R.view(xLens, {x: 1, y: 2}); //=> 1 + * R.set(xLens, 4, {x: 1, y: 2}); //=> {x: 4, y: 2} + * R.over(xLens, R.negate, {x: 1, y: 2}); //=> {x: -1, y: 2} + */ + var lens = _curry2(function lens(getter, setter) { + return function(toFunctorFn) { + return function(target) { + return map( + function(focus) { + return setter(focus, target); + }, + toFunctorFn(getter(target)) + ); + }; + }; + }); + + /** + * Returns a lens whose focus is the specified index. + * + * @func + * @memberOf R + * @since v0.14.0 + * @category Object + * @typedefn Lens s a = Functor f => (a -> f a) -> s -> f s + * @sig Number -> Lens s a + * @param {Number} n + * @return {Lens} + * @see R.view, R.set, R.over, R.nth + * @example + * + * const headLens = R.lensIndex(0); + * + * R.view(headLens, ['a', 'b', 'c']); //=> 'a' + * R.set(headLens, 'x', ['a', 'b', 'c']); //=> ['x', 'b', 'c'] + * R.over(headLens, R.toUpper, ['a', 'b', 'c']); //=> ['A', 'b', 'c'] + */ + var lensIndex = _curry1(function lensIndex(n) { + return lens(nth(n), update(n)); + }); + + /** + * Returns a lens whose focus is the specified path. + * + * @func + * @memberOf R + * @since v0.19.0 + * @category Object + * @typedefn Idx = String | Int + * @typedefn Lens s a = Functor f => (a -> f a) -> s -> f s + * @sig [Idx] -> Lens s a + * @param {Array} path The path to use. + * @return {Lens} + * @see R.view, R.set, R.over + * @example + * + * const xHeadYLens = R.lensPath(['x', 0, 'y']); + * + * R.view(xHeadYLens, {x: [{y: 2, z: 3}, {y: 4, z: 5}]}); + * //=> 2 + * R.set(xHeadYLens, 1, {x: [{y: 2, z: 3}, {y: 4, z: 5}]}); + * //=> {x: [{y: 1, z: 3}, {y: 4, z: 5}]} + * R.over(xHeadYLens, R.negate, {x: [{y: 2, z: 3}, {y: 4, z: 5}]}); + * //=> {x: [{y: -2, z: 3}, {y: 4, z: 5}]} + */ + var lensPath = _curry1(function lensPath(p) { + return lens(path(p), assocPath(p)); + }); + + /** + * Returns a lens whose focus is the specified property. + * + * @func + * @memberOf R + * @since v0.14.0 + * @category Object + * @typedefn Lens s a = Functor f => (a -> f a) -> s -> f s + * @sig String -> Lens s a + * @param {String} k + * @return {Lens} + * @see R.view, R.set, R.over + * @example + * + * const xLens = R.lensProp('x'); + * + * R.view(xLens, {x: 1, y: 2}); //=> 1 + * R.set(xLens, 4, {x: 1, y: 2}); //=> {x: 4, y: 2} + * R.over(xLens, R.negate, {x: 1, y: 2}); //=> {x: -1, y: 2} + */ + var lensProp = _curry1(function lensProp(k) { + return lens(prop(k), assoc(k)); + }); + + /** + * Returns `true` if the first argument is less than the second; `false` + * otherwise. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Relation + * @sig Ord a => a -> a -> Boolean + * @param {*} a + * @param {*} b + * @return {Boolean} + * @see R.gt + * @example + * + * R.lt(2, 1); //=> false + * R.lt(2, 2); //=> false + * R.lt(2, 3); //=> true + * R.lt('a', 'z'); //=> true + * R.lt('z', 'a'); //=> false + */ + var lt = _curry2(function lt(a, b) { return a < b; }); + + /** + * Returns `true` if the first argument is less than or equal to the second; + * `false` otherwise. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Relation + * @sig Ord a => a -> a -> Boolean + * @param {Number} a + * @param {Number} b + * @return {Boolean} + * @see R.gte + * @example + * + * R.lte(2, 1); //=> false + * R.lte(2, 2); //=> true + * R.lte(2, 3); //=> true + * R.lte('a', 'z'); //=> true + * R.lte('z', 'a'); //=> false + */ + var lte = _curry2(function lte(a, b) { return a <= b; }); + + /** + * The `mapAccum` function behaves like a combination of map and reduce; it + * applies a function to each element of a list, passing an accumulating + * parameter from left to right, and returning a final value of this + * accumulator together with the new list. + * + * The iterator function receives two arguments, *acc* and *value*, and should + * return a tuple *[acc, value]*. + * + * @func + * @memberOf R + * @since v0.10.0 + * @category List + * @sig ((acc, x) -> (acc, y)) -> acc -> [x] -> (acc, [y]) + * @param {Function} fn The function to be called on every element of the input `list`. + * @param {*} acc The accumulator value. + * @param {Array} list The list to iterate over. + * @return {*} The final, accumulated value. + * @see R.scan, R.addIndex, R.mapAccumRight + * @example + * + * const digits = ['1', '2', '3', '4']; + * const appender = (a, b) => [a + b, a + b]; + * + * R.mapAccum(appender, 0, digits); //=> ['01234', ['01', '012', '0123', '01234']] + * @symb R.mapAccum(f, a, [b, c, d]) = [ + * f(f(f(a, b)[0], c)[0], d)[0], + * [ + * f(a, b)[1], + * f(f(a, b)[0], c)[1], + * f(f(f(a, b)[0], c)[0], d)[1] + * ] + * ] + */ + var mapAccum = _curry3(function mapAccum(fn, acc, list) { + var idx = 0; + var len = list.length; + var result = []; + var tuple = [acc]; + while (idx < len) { + tuple = fn(tuple[0], list[idx]); + result[idx] = tuple[1]; + idx += 1; + } + return [tuple[0], result]; + }); + + /** + * The `mapAccumRight` function behaves like a combination of map and reduce; it + * applies a function to each element of a list, passing an accumulating + * parameter from right to left, and returning a final value of this + * accumulator together with the new list. + * + * Similar to [`mapAccum`](#mapAccum), except moves through the input list from + * the right to the left. + * + * The iterator function receives two arguments, *acc* and *value*, and should + * return a tuple *[acc, value]*. + * + * @func + * @memberOf R + * @since v0.10.0 + * @category List + * @sig ((acc, x) -> (acc, y)) -> acc -> [x] -> (acc, [y]) + * @param {Function} fn The function to be called on every element of the input `list`. + * @param {*} acc The accumulator value. + * @param {Array} list The list to iterate over. + * @return {*} The final, accumulated value. + * @see R.addIndex, R.mapAccum + * @example + * + * const digits = ['1', '2', '3', '4']; + * const appender = (a, b) => [b + a, b + a]; + * + * R.mapAccumRight(appender, 5, digits); //=> ['12345', ['12345', '2345', '345', '45']] + * @symb R.mapAccumRight(f, a, [b, c, d]) = [ + * f(f(f(a, d)[0], c)[0], b)[0], + * [ + * f(a, d)[1], + * f(f(a, d)[0], c)[1], + * f(f(f(a, d)[0], c)[0], b)[1] + * ] + * ] + */ + var mapAccumRight = _curry3(function mapAccumRight(fn, acc, list) { + var idx = list.length - 1; + var result = []; + var tuple = [acc]; + while (idx >= 0) { + tuple = fn(tuple[0], list[idx]); + result[idx] = tuple[1]; + idx -= 1; + } + return [tuple[0], result]; + }); + + /** + * An Object-specific version of [`map`](#map). The function is applied to three + * arguments: *(value, key, obj)*. If only the value is significant, use + * [`map`](#map) instead. + * + * @func + * @memberOf R + * @since v0.9.0 + * @category Object + * @sig ((*, String, Object) -> *) -> Object -> Object + * @param {Function} fn + * @param {Object} obj + * @return {Object} + * @see R.map + * @example + * + * const xyz = { x: 1, y: 2, z: 3 }; + * const prependKeyAndDouble = (num, key, obj) => key + (num * 2); + * + * R.mapObjIndexed(prependKeyAndDouble, xyz); //=> { x: 'x2', y: 'y4', z: 'z6' } + */ + var mapObjIndexed = _curry2(function mapObjIndexed(fn, obj) { + return _reduce(function(acc, key) { + acc[key] = fn(obj[key], key, obj); + return acc; + }, {}, keys(obj)); + }); + + /** + * Tests a regular expression against a String. Note that this function will + * return an empty array when there are no matches. This differs from + * [`String.prototype.match`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/match) + * which returns `null` when there are no matches. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category String + * @sig RegExp -> String -> [String | Undefined] + * @param {RegExp} rx A regular expression. + * @param {String} str The string to match against + * @return {Array} The list of matches or empty array. + * @see R.test + * @example + * + * R.match(/([a-z]a)/g, 'bananas'); //=> ['ba', 'na', 'na'] + * R.match(/a/, 'b'); //=> [] + * R.match(/a/, null); //=> TypeError: null does not have a method named "match" + */ + var match = _curry2(function match(rx, str) { + return str.match(rx) || []; + }); + + /** + * `mathMod` behaves like the modulo operator should mathematically, unlike the + * `%` operator (and by extension, [`R.modulo`](#modulo)). So while + * `-17 % 5` is `-2`, `mathMod(-17, 5)` is `3`. `mathMod` requires Integer + * arguments, and returns NaN when the modulus is zero or negative. + * + * @func + * @memberOf R + * @since v0.3.0 + * @category Math + * @sig Number -> Number -> Number + * @param {Number} m The dividend. + * @param {Number} p the modulus. + * @return {Number} The result of `b mod a`. + * @see R.modulo + * @example + * + * R.mathMod(-17, 5); //=> 3 + * R.mathMod(17, 5); //=> 2 + * R.mathMod(17, -5); //=> NaN + * R.mathMod(17, 0); //=> NaN + * R.mathMod(17.2, 5); //=> NaN + * R.mathMod(17, 5.3); //=> NaN + * + * const clock = R.mathMod(R.__, 12); + * clock(15); //=> 3 + * clock(24); //=> 0 + * + * const seventeenMod = R.mathMod(17); + * seventeenMod(3); //=> 2 + * seventeenMod(4); //=> 1 + * seventeenMod(10); //=> 7 + */ + var mathMod = _curry2(function mathMod(m, p) { + if (!_isInteger(m)) { return NaN; } + if (!_isInteger(p) || p < 1) { return NaN; } + return ((m % p) + p) % p; + }); + + /** + * Takes a function and two values, and returns whichever value produces the + * larger result when passed to the provided function. + * + * @func + * @memberOf R + * @since v0.8.0 + * @category Relation + * @sig Ord b => (a -> b) -> a -> a -> a + * @param {Function} f + * @param {*} a + * @param {*} b + * @return {*} + * @see R.max, R.minBy + * @example + * + * // square :: Number -> Number + * const square = n => n * n; + * + * R.maxBy(square, -3, 2); //=> -3 + * + * R.reduce(R.maxBy(square), 0, [3, -5, 4, 1, -2]); //=> -5 + * R.reduce(R.maxBy(square), 0, []); //=> 0 + */ + var maxBy = _curry3(function maxBy(f, a, b) { + return f(b) > f(a) ? b : a; + }); + + /** + * Adds together all the elements of a list. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Math + * @sig [Number] -> Number + * @param {Array} list An array of numbers + * @return {Number} The sum of all the numbers in the list. + * @see R.reduce + * @example + * + * R.sum([2,4,6,8,100,1]); //=> 121 + */ + var sum = reduce(add, 0); + + /** + * Returns the mean of the given list of numbers. + * + * @func + * @memberOf R + * @since v0.14.0 + * @category Math + * @sig [Number] -> Number + * @param {Array} list + * @return {Number} + * @see R.median + * @example + * + * R.mean([2, 7, 9]); //=> 6 + * R.mean([]); //=> NaN + */ + var mean = _curry1(function mean(list) { + return sum(list) / list.length; + }); + + /** + * Returns the median of the given list of numbers. + * + * @func + * @memberOf R + * @since v0.14.0 + * @category Math + * @sig [Number] -> Number + * @param {Array} list + * @return {Number} + * @see R.mean + * @example + * + * R.median([2, 9, 7]); //=> 7 + * R.median([7, 2, 10, 9]); //=> 8 + * R.median([]); //=> NaN + */ + var median = _curry1(function median(list) { + var len = list.length; + if (len === 0) { + return NaN; + } + var width = 2 - len % 2; + var idx = (len - width) / 2; + return mean(Array.prototype.slice.call(list, 0).sort(function(a, b) { + return a < b ? -1 : a > b ? 1 : 0; + }).slice(idx, idx + width)); + }); + + /** + * Creates a new function that, when invoked, caches the result of calling `fn` + * for a given argument set and returns the result. Subsequent calls to the + * memoized `fn` with the same argument set will not result in an additional + * call to `fn`; instead, the cached result for that set of arguments will be + * returned. + * + * + * @func + * @memberOf R + * @since v0.24.0 + * @category Function + * @sig (*... -> String) -> (*... -> a) -> (*... -> a) + * @param {Function} fn The function to generate the cache key. + * @param {Function} fn The function to memoize. + * @return {Function} Memoized version of `fn`. + * @example + * + * let count = 0; + * const factorial = R.memoizeWith(R.identity, n => { + * count += 1; + * return R.product(R.range(1, n + 1)); + * }); + * factorial(5); //=> 120 + * factorial(5); //=> 120 + * factorial(5); //=> 120 + * count; //=> 1 + */ + var memoizeWith = _curry2(function memoizeWith(mFn, fn) { + var cache = {}; + return _arity(fn.length, function() { + var key = mFn.apply(this, arguments); + if (!_has(key, cache)) { + cache[key] = fn.apply(this, arguments); + } + return cache[key]; + }); + }); + + /** + * Create a new object with the own properties of the first object merged with + * the own properties of the second object. If a key exists in both objects, + * the value from the second object will be used. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Object + * @sig {k: v} -> {k: v} -> {k: v} + * @param {Object} l + * @param {Object} r + * @return {Object} + * @see R.mergeRight, R.mergeDeepRight, R.mergeWith, R.mergeWithKey + * @deprecated since v0.26.0 + * @example + * + * R.merge({ 'name': 'fred', 'age': 10 }, { 'age': 40 }); + * //=> { 'name': 'fred', 'age': 40 } + * + * const withDefaults = R.merge({x: 0, y: 0}); + * withDefaults({y: 2}); //=> {x: 0, y: 2} + * @symb R.merge(a, b) = {...a, ...b} + */ + var merge = _curry2(function merge(l, r) { + return _objectAssign$1({}, l, r); + }); + + /** + * Merges a list of objects together into one object. + * + * @func + * @memberOf R + * @since v0.10.0 + * @category List + * @sig [{k: v}] -> {k: v} + * @param {Array} list An array of objects + * @return {Object} A merged object. + * @see R.reduce + * @example + * + * R.mergeAll([{foo:1},{bar:2},{baz:3}]); //=> {foo:1,bar:2,baz:3} + * R.mergeAll([{foo:1},{foo:2},{bar:2}]); //=> {foo:2,bar:2} + * @symb R.mergeAll([{ x: 1 }, { y: 2 }, { z: 3 }]) = { x: 1, y: 2, z: 3 } + */ + var mergeAll = _curry1(function mergeAll(list) { + return _objectAssign$1.apply(null, [{}].concat(list)); + }); + + /** + * Creates a new object with the own properties of the two provided objects. If + * a key exists in both objects, the provided function is applied to the key + * and the values associated with the key in each object, with the result being + * used as the value associated with the key in the returned object. + * + * @func + * @memberOf R + * @since v0.19.0 + * @category Object + * @sig ((String, a, a) -> a) -> {a} -> {a} -> {a} + * @param {Function} fn + * @param {Object} l + * @param {Object} r + * @return {Object} + * @see R.mergeDeepWithKey, R.merge, R.mergeWith + * @example + * + * let concatValues = (k, l, r) => k == 'values' ? R.concat(l, r) : r + * R.mergeWithKey(concatValues, + * { a: true, thing: 'foo', values: [10, 20] }, + * { b: true, thing: 'bar', values: [15, 35] }); + * //=> { a: true, b: true, thing: 'bar', values: [10, 20, 15, 35] } + * @symb R.mergeWithKey(f, { x: 1, y: 2 }, { y: 5, z: 3 }) = { x: 1, y: f('y', 2, 5), z: 3 } + */ + var mergeWithKey = _curry3(function mergeWithKey(fn, l, r) { + var result = {}; + var k; + + for (k in l) { + if (_has(k, l)) { + result[k] = _has(k, r) ? fn(k, l[k], r[k]) : l[k]; + } + } + + for (k in r) { + if (_has(k, r) && !(_has(k, result))) { + result[k] = r[k]; + } + } + + return result; + }); + + /** + * Creates a new object with the own properties of the two provided objects. + * If a key exists in both objects: + * - and both associated values are also objects then the values will be + * recursively merged. + * - otherwise the provided function is applied to the key and associated values + * using the resulting value as the new value associated with the key. + * If a key only exists in one object, the value will be associated with the key + * of the resulting object. + * + * @func + * @memberOf R + * @since v0.24.0 + * @category Object + * @sig ((String, a, a) -> a) -> {a} -> {a} -> {a} + * @param {Function} fn + * @param {Object} lObj + * @param {Object} rObj + * @return {Object} + * @see R.mergeWithKey, R.mergeDeepWith + * @example + * + * let concatValues = (k, l, r) => k == 'values' ? R.concat(l, r) : r + * R.mergeDeepWithKey(concatValues, + * { a: true, c: { thing: 'foo', values: [10, 20] }}, + * { b: true, c: { thing: 'bar', values: [15, 35] }}); + * //=> { a: true, b: true, c: { thing: 'bar', values: [10, 20, 15, 35] }} + */ + var mergeDeepWithKey = _curry3(function mergeDeepWithKey(fn, lObj, rObj) { + return mergeWithKey(function(k, lVal, rVal) { + if (_isObject(lVal) && _isObject(rVal)) { + return mergeDeepWithKey(fn, lVal, rVal); + } else { + return fn(k, lVal, rVal); + } + }, lObj, rObj); + }); + + /** + * Creates a new object with the own properties of the first object merged with + * the own properties of the second object. If a key exists in both objects: + * - and both values are objects, the two values will be recursively merged + * - otherwise the value from the first object will be used. + * + * @func + * @memberOf R + * @since v0.24.0 + * @category Object + * @sig {a} -> {a} -> {a} + * @param {Object} lObj + * @param {Object} rObj + * @return {Object} + * @see R.merge, R.mergeDeepRight, R.mergeDeepWith, R.mergeDeepWithKey + * @example + * + * R.mergeDeepLeft({ name: 'fred', age: 10, contact: { email: 'moo@example.com' }}, + * { age: 40, contact: { email: 'baa@example.com' }}); + * //=> { name: 'fred', age: 10, contact: { email: 'moo@example.com' }} + */ + var mergeDeepLeft = _curry2(function mergeDeepLeft(lObj, rObj) { + return mergeDeepWithKey(function(k, lVal, rVal) { + return lVal; + }, lObj, rObj); + }); + + /** + * Creates a new object with the own properties of the first object merged with + * the own properties of the second object. If a key exists in both objects: + * - and both values are objects, the two values will be recursively merged + * - otherwise the value from the second object will be used. + * + * @func + * @memberOf R + * @since v0.24.0 + * @category Object + * @sig {a} -> {a} -> {a} + * @param {Object} lObj + * @param {Object} rObj + * @return {Object} + * @see R.merge, R.mergeDeepLeft, R.mergeDeepWith, R.mergeDeepWithKey + * @example + * + * R.mergeDeepRight({ name: 'fred', age: 10, contact: { email: 'moo@example.com' }}, + * { age: 40, contact: { email: 'baa@example.com' }}); + * //=> { name: 'fred', age: 40, contact: { email: 'baa@example.com' }} + */ + var mergeDeepRight = _curry2(function mergeDeepRight(lObj, rObj) { + return mergeDeepWithKey(function(k, lVal, rVal) { + return rVal; + }, lObj, rObj); + }); + + /** + * Creates a new object with the own properties of the two provided objects. + * If a key exists in both objects: + * - and both associated values are also objects then the values will be + * recursively merged. + * - otherwise the provided function is applied to associated values using the + * resulting value as the new value associated with the key. + * If a key only exists in one object, the value will be associated with the key + * of the resulting object. + * + * @func + * @memberOf R + * @since v0.24.0 + * @category Object + * @sig ((a, a) -> a) -> {a} -> {a} -> {a} + * @param {Function} fn + * @param {Object} lObj + * @param {Object} rObj + * @return {Object} + * @see R.mergeWith, R.mergeDeepWithKey + * @example + * + * R.mergeDeepWith(R.concat, + * { a: true, c: { values: [10, 20] }}, + * { b: true, c: { values: [15, 35] }}); + * //=> { a: true, b: true, c: { values: [10, 20, 15, 35] }} + */ + var mergeDeepWith = _curry3(function mergeDeepWith(fn, lObj, rObj) { + return mergeDeepWithKey(function(k, lVal, rVal) { + return fn(lVal, rVal); + }, lObj, rObj); + }); + + /** + * Create a new object with the own properties of the first object merged with + * the own properties of the second object. If a key exists in both objects, + * the value from the first object will be used. + * + * @func + * @memberOf R + * @since v0.26.0 + * @category Object + * @sig {k: v} -> {k: v} -> {k: v} + * @param {Object} l + * @param {Object} r + * @return {Object} + * @see R.mergeRight, R.mergeDeepLeft, R.mergeWith, R.mergeWithKey + * @example + * + * R.mergeLeft({ 'age': 40 }, { 'name': 'fred', 'age': 10 }); + * //=> { 'name': 'fred', 'age': 40 } + * + * const resetToDefault = R.mergeLeft({x: 0}); + * resetToDefault({x: 5, y: 2}); //=> {x: 0, y: 2} + * @symb R.mergeLeft(a, b) = {...b, ...a} + */ + var mergeLeft = _curry2(function mergeLeft(l, r) { + return _objectAssign$1({}, r, l); + }); + + /** + * Create a new object with the own properties of the first object merged with + * the own properties of the second object. If a key exists in both objects, + * the value from the second object will be used. + * + * @func + * @memberOf R + * @since v0.26.0 + * @category Object + * @sig {k: v} -> {k: v} -> {k: v} + * @param {Object} l + * @param {Object} r + * @return {Object} + * @see R.mergeLeft, R.mergeDeepRight, R.mergeWith, R.mergeWithKey + * @example + * + * R.mergeRight({ 'name': 'fred', 'age': 10 }, { 'age': 40 }); + * //=> { 'name': 'fred', 'age': 40 } + * + * const withDefaults = R.mergeRight({x: 0, y: 0}); + * withDefaults({y: 2}); //=> {x: 0, y: 2} + * @symb R.mergeRight(a, b) = {...a, ...b} + */ + var mergeRight = _curry2(function mergeRight(l, r) { + return _objectAssign$1({}, l, r); + }); + + /** + * Creates a new object with the own properties of the two provided objects. If + * a key exists in both objects, the provided function is applied to the values + * associated with the key in each object, with the result being used as the + * value associated with the key in the returned object. + * + * @func + * @memberOf R + * @since v0.19.0 + * @category Object + * @sig ((a, a) -> a) -> {a} -> {a} -> {a} + * @param {Function} fn + * @param {Object} l + * @param {Object} r + * @return {Object} + * @see R.mergeDeepWith, R.merge, R.mergeWithKey + * @example + * + * R.mergeWith(R.concat, + * { a: true, values: [10, 20] }, + * { b: true, values: [15, 35] }); + * //=> { a: true, b: true, values: [10, 20, 15, 35] } + */ + var mergeWith = _curry3(function mergeWith(fn, l, r) { + return mergeWithKey(function(_, _l, _r) { + return fn(_l, _r); + }, l, r); + }); + + /** + * Returns the smaller of its two arguments. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Relation + * @sig Ord a => a -> a -> a + * @param {*} a + * @param {*} b + * @return {*} + * @see R.minBy, R.max + * @example + * + * R.min(789, 123); //=> 123 + * R.min('a', 'b'); //=> 'a' + */ + var min = _curry2(function min(a, b) { return b < a ? b : a; }); + + /** + * Takes a function and two values, and returns whichever value produces the + * smaller result when passed to the provided function. + * + * @func + * @memberOf R + * @since v0.8.0 + * @category Relation + * @sig Ord b => (a -> b) -> a -> a -> a + * @param {Function} f + * @param {*} a + * @param {*} b + * @return {*} + * @see R.min, R.maxBy + * @example + * + * // square :: Number -> Number + * const square = n => n * n; + * + * R.minBy(square, -3, 2); //=> 2 + * + * R.reduce(R.minBy(square), Infinity, [3, -5, 4, 1, -2]); //=> 1 + * R.reduce(R.minBy(square), Infinity, []); //=> Infinity + */ + var minBy = _curry3(function minBy(f, a, b) { + return f(b) < f(a) ? b : a; + }); + + /** + * Divides the first parameter by the second and returns the remainder. Note + * that this function preserves the JavaScript-style behavior for modulo. For + * mathematical modulo see [`mathMod`](#mathMod). + * + * @func + * @memberOf R + * @since v0.1.1 + * @category Math + * @sig Number -> Number -> Number + * @param {Number} a The value to the divide. + * @param {Number} b The pseudo-modulus + * @return {Number} The result of `b % a`. + * @see R.mathMod + * @example + * + * R.modulo(17, 3); //=> 2 + * // JS behavior: + * R.modulo(-17, 3); //=> -2 + * R.modulo(17, -3); //=> 2 + * + * const isOdd = R.modulo(R.__, 2); + * isOdd(42); //=> 0 + * isOdd(21); //=> 1 + */ + var modulo = _curry2(function modulo(a, b) { return a % b; }); + + /** + * Move an item, at index `from`, to index `to`, in a list of elements. + * A new list will be created containing the new elements order. + * + * @func + * @memberOf R + * @since v0.27.1 + * @category List + * @sig Number -> Number -> [a] -> [a] + * @param {Number} from The source index + * @param {Number} to The destination index + * @param {Array} list The list which will serve to realise the move + * @return {Array} The new list reordered + * @example + * + * R.move(0, 2, ['a', 'b', 'c', 'd', 'e', 'f']); //=> ['b', 'c', 'a', 'd', 'e', 'f'] + * R.move(-1, 0, ['a', 'b', 'c', 'd', 'e', 'f']); //=> ['f', 'a', 'b', 'c', 'd', 'e'] list rotation + */ + var move = _curry3(function(from, to, list) { + var length = list.length; + var result = list.slice(); + var positiveFrom = from < 0 ? length + from : from; + var positiveTo = to < 0 ? length + to : to; + var item = result.splice(positiveFrom, 1); + + return positiveFrom < 0 || positiveFrom >= list.length + || positiveTo < 0 || positiveTo >= list.length + ? list + : [] + .concat(result.slice(0, positiveTo)) + .concat(item) + .concat(result.slice(positiveTo, list.length)); + }); + + /** + * Multiplies two numbers. Equivalent to `a * b` but curried. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Math + * @sig Number -> Number -> Number + * @param {Number} a The first value. + * @param {Number} b The second value. + * @return {Number} The result of `a * b`. + * @see R.divide + * @example + * + * const double = R.multiply(2); + * const triple = R.multiply(3); + * double(3); //=> 6 + * triple(4); //=> 12 + * R.multiply(2, 5); //=> 10 + */ + var multiply = _curry2(function multiply(a, b) { return a * b; }); + + /** + * Negates its argument. + * + * @func + * @memberOf R + * @since v0.9.0 + * @category Math + * @sig Number -> Number + * @param {Number} n + * @return {Number} + * @example + * + * R.negate(42); //=> -42 + */ + var negate = _curry1(function negate(n) { return -n; }); + + /** + * Returns `true` if no elements of the list match the predicate, `false` + * otherwise. + * + * Dispatches to the `all` method of the second argument, if present. + * + * Acts as a transducer if a transformer is given in list position. + * + * @func + * @memberOf R + * @since v0.12.0 + * @category List + * @sig (a -> Boolean) -> [a] -> Boolean + * @param {Function} fn The predicate function. + * @param {Array} list The array to consider. + * @return {Boolean} `true` if the predicate is not satisfied by every element, `false` otherwise. + * @see R.all, R.any + * @example + * + * const isEven = n => n % 2 === 0; + * const isOdd = n => n % 2 === 1; + * + * R.none(isEven, [1, 3, 5, 7, 9, 11]); //=> true + * R.none(isOdd, [1, 3, 5, 7, 8, 11]); //=> false + */ + var none = _curry2(function none(fn, input) { + return all(_complement(fn), input); + }); + + /** + * Returns a function which returns its nth argument. + * + * @func + * @memberOf R + * @since v0.9.0 + * @category Function + * @sig Number -> *... -> * + * @param {Number} n + * @return {Function} + * @example + * + * R.nthArg(1)('a', 'b', 'c'); //=> 'b' + * R.nthArg(-1)('a', 'b', 'c'); //=> 'c' + * @symb R.nthArg(-1)(a, b, c) = c + * @symb R.nthArg(0)(a, b, c) = a + * @symb R.nthArg(1)(a, b, c) = b + */ + var nthArg = _curry1(function nthArg(n) { + var arity = n < 0 ? 1 : n + 1; + return curryN(arity, function() { + return nth(n, arguments); + }); + }); + + /** + * `o` is a curried composition function that returns a unary function. + * Like [`compose`](#compose), `o` performs right-to-left function composition. + * Unlike [`compose`](#compose), the rightmost function passed to `o` will be + * invoked with only one argument. Also, unlike [`compose`](#compose), `o` is + * limited to accepting only 2 unary functions. The name o was chosen because + * of its similarity to the mathematical composition operator ∘. + * + * @func + * @memberOf R + * @since v0.24.0 + * @category Function + * @sig (b -> c) -> (a -> b) -> a -> c + * @param {Function} f + * @param {Function} g + * @return {Function} + * @see R.compose, R.pipe + * @example + * + * const classyGreeting = name => "The name's " + name.last + ", " + name.first + " " + name.last + * const yellGreeting = R.o(R.toUpper, classyGreeting); + * yellGreeting({first: 'James', last: 'Bond'}); //=> "THE NAME'S BOND, JAMES BOND" + * + * R.o(R.multiply(10), R.add(10))(-4) //=> 60 + * + * @symb R.o(f, g, x) = f(g(x)) + */ + var o = _curry3(function o(f, g, x) { + return f(g(x)); + }); + + function _of(x) { return [x]; } + + /** + * Returns a singleton array containing the value provided. + * + * Note this `of` is different from the ES6 `of`; See + * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/of + * + * @func + * @memberOf R + * @since v0.3.0 + * @category Function + * @sig a -> [a] + * @param {*} x any value + * @return {Array} An array wrapping `x`. + * @example + * + * R.of(null); //=> [null] + * R.of([42]); //=> [[42]] + */ + var of = _curry1(_of); + + /** + * Returns a partial copy of an object omitting the keys specified. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Object + * @sig [String] -> {String: *} -> {String: *} + * @param {Array} names an array of String property names to omit from the new object + * @param {Object} obj The object to copy from + * @return {Object} A new object with properties from `names` not on it. + * @see R.pick + * @example + * + * R.omit(['a', 'd'], {a: 1, b: 2, c: 3, d: 4}); //=> {b: 2, c: 3} + */ + var omit = _curry2(function omit(names, obj) { + var result = {}; + var index = {}; + var idx = 0; + var len = names.length; + + while (idx < len) { + index[names[idx]] = 1; + idx += 1; + } + + for (var prop in obj) { + if (!index.hasOwnProperty(prop)) { + result[prop] = obj[prop]; + } + } + return result; + }); + + /** + * Accepts a function `fn` and returns a function that guards invocation of + * `fn` such that `fn` can only ever be called once, no matter how many times + * the returned function is invoked. The first value calculated is returned in + * subsequent invocations. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Function + * @sig (a... -> b) -> (a... -> b) + * @param {Function} fn The function to wrap in a call-only-once wrapper. + * @return {Function} The wrapped function. + * @example + * + * const addOneOnce = R.once(x => x + 1); + * addOneOnce(10); //=> 11 + * addOneOnce(addOneOnce(50)); //=> 11 + */ + var once = _curry1(function once(fn) { + var called = false; + var result; + return _arity(fn.length, function() { + if (called) { + return result; + } + called = true; + result = fn.apply(this, arguments); + return result; + }); + }); + + function _assertPromise(name, p) { + if (p == null || !_isFunction(p.then)) { + throw new TypeError('`' + name + '` expected a Promise, received ' + _toString(p, [])); + } + } + + /** + * Returns the result of applying the onFailure function to the value inside + * a failed promise. This is useful for handling rejected promises + * inside function compositions. + * + * @func + * @memberOf R + * @since v0.26.0 + * @category Function + * @sig (e -> b) -> (Promise e a) -> (Promise e b) + * @sig (e -> (Promise f b)) -> (Promise e a) -> (Promise f b) + * @param {Function} onFailure The function to apply. Can return a value or a promise of a value. + * @param {Promise} p + * @return {Promise} The result of calling `p.then(null, onFailure)` + * @see R.then + * @example + * + * var failedFetch = (id) => Promise.reject('bad ID'); + * var useDefault = () => ({ firstName: 'Bob', lastName: 'Loblaw' }) + * + * //recoverFromFailure :: String -> Promise ({firstName, lastName}) + * var recoverFromFailure = R.pipe( + * failedFetch, + * R.otherwise(useDefault), + * R.then(R.pick(['firstName', 'lastName'])), + * ); + * recoverFromFailure(12345).then(console.log) + */ + var otherwise = _curry2(function otherwise(f, p) { + _assertPromise('otherwise', p); + + return p.then(null, f); + }); + + // `Identity` is a functor that holds a single value, where `map` simply + // transforms the held value with the provided function. + var Identity = function(x) { + return {value: x, map: function(f) { return Identity(f(x)); }}; + }; + + + /** + * Returns the result of "setting" the portion of the given data structure + * focused by the given lens to the result of applying the given function to + * the focused value. + * + * @func + * @memberOf R + * @since v0.16.0 + * @category Object + * @typedefn Lens s a = Functor f => (a -> f a) -> s -> f s + * @sig Lens s a -> (a -> a) -> s -> s + * @param {Lens} lens + * @param {*} v + * @param {*} x + * @return {*} + * @see R.prop, R.lensIndex, R.lensProp + * @example + * + * const headLens = R.lensIndex(0); + * + * R.over(headLens, R.toUpper, ['foo', 'bar', 'baz']); //=> ['FOO', 'bar', 'baz'] + */ + var over = _curry3(function over(lens, f, x) { + // The value returned by the getter function is first transformed with `f`, + // then set as the value of an `Identity`. This is then mapped over with the + // setter function of the lens. + return lens(function(y) { return Identity(f(y)); })(x).value; + }); + + /** + * Takes two arguments, `fst` and `snd`, and returns `[fst, snd]`. + * + * @func + * @memberOf R + * @since v0.18.0 + * @category List + * @sig a -> b -> (a,b) + * @param {*} fst + * @param {*} snd + * @return {Array} + * @see R.objOf, R.of + * @example + * + * R.pair('foo', 'bar'); //=> ['foo', 'bar'] + */ + var pair = _curry2(function pair(fst, snd) { return [fst, snd]; }); + + function _createPartialApplicator(concat) { + return _curry2(function(fn, args) { + return _arity(Math.max(0, fn.length - args.length), function() { + return fn.apply(this, concat(args, arguments)); + }); + }); + } + + /** + * Takes a function `f` and a list of arguments, and returns a function `g`. + * When applied, `g` returns the result of applying `f` to the arguments + * provided initially followed by the arguments provided to `g`. + * + * @func + * @memberOf R + * @since v0.10.0 + * @category Function + * @sig ((a, b, c, ..., n) -> x) -> [a, b, c, ...] -> ((d, e, f, ..., n) -> x) + * @param {Function} f + * @param {Array} args + * @return {Function} + * @see R.partialRight, R.curry + * @example + * + * const multiply2 = (a, b) => a * b; + * const double = R.partial(multiply2, [2]); + * double(2); //=> 4 + * + * const greet = (salutation, title, firstName, lastName) => + * salutation + ', ' + title + ' ' + firstName + ' ' + lastName + '!'; + * + * const sayHello = R.partial(greet, ['Hello']); + * const sayHelloToMs = R.partial(sayHello, ['Ms.']); + * sayHelloToMs('Jane', 'Jones'); //=> 'Hello, Ms. Jane Jones!' + * @symb R.partial(f, [a, b])(c, d) = f(a, b, c, d) + */ + var partial = _createPartialApplicator(_concat); + + /** + * Takes a function `f` and a list of arguments, and returns a function `g`. + * When applied, `g` returns the result of applying `f` to the arguments + * provided to `g` followed by the arguments provided initially. + * + * @func + * @memberOf R + * @since v0.10.0 + * @category Function + * @sig ((a, b, c, ..., n) -> x) -> [d, e, f, ..., n] -> ((a, b, c, ...) -> x) + * @param {Function} f + * @param {Array} args + * @return {Function} + * @see R.partial + * @example + * + * const greet = (salutation, title, firstName, lastName) => + * salutation + ', ' + title + ' ' + firstName + ' ' + lastName + '!'; + * + * const greetMsJaneJones = R.partialRight(greet, ['Ms.', 'Jane', 'Jones']); + * + * greetMsJaneJones('Hello'); //=> 'Hello, Ms. Jane Jones!' + * @symb R.partialRight(f, [a, b])(c, d) = f(c, d, a, b) + */ + var partialRight = _createPartialApplicator(flip(_concat)); + + /** + * Takes a predicate and a list or other `Filterable` object and returns the + * pair of filterable objects of the same type of elements which do and do not + * satisfy, the predicate, respectively. Filterable objects include plain objects or any object + * that has a filter method such as `Array`. + * + * @func + * @memberOf R + * @since v0.1.4 + * @category List + * @sig Filterable f => (a -> Boolean) -> f a -> [f a, f a] + * @param {Function} pred A predicate to determine which side the element belongs to. + * @param {Array} filterable the list (or other filterable) to partition. + * @return {Array} An array, containing first the subset of elements that satisfy the + * predicate, and second the subset of elements that do not satisfy. + * @see R.filter, R.reject + * @example + * + * R.partition(R.includes('s'), ['sss', 'ttt', 'foo', 'bars']); + * // => [ [ 'sss', 'bars' ], [ 'ttt', 'foo' ] ] + * + * R.partition(R.includes('s'), { a: 'sss', b: 'ttt', foo: 'bars' }); + * // => [ { a: 'sss', foo: 'bars' }, { b: 'ttt' } ] + */ + var partition = juxt([filter, reject]); + + /** + * Determines whether a nested path on an object has a specific value, in + * [`R.equals`](#equals) terms. Most likely used to filter a list. + * + * @func + * @memberOf R + * @since v0.7.0 + * @category Relation + * @typedefn Idx = String | Int + * @sig [Idx] -> a -> {a} -> Boolean + * @param {Array} path The path of the nested property to use + * @param {*} val The value to compare the nested property with + * @param {Object} obj The object to check the nested property in + * @return {Boolean} `true` if the value equals the nested object property, + * `false` otherwise. + * @example + * + * const user1 = { address: { zipCode: 90210 } }; + * const user2 = { address: { zipCode: 55555 } }; + * const user3 = { name: 'Bob' }; + * const users = [ user1, user2, user3 ]; + * const isFamous = R.pathEq(['address', 'zipCode'], 90210); + * R.filter(isFamous, users); //=> [ user1 ] + */ + var pathEq = _curry3(function pathEq(_path, val, obj) { + return equals(path(_path, obj), val); + }); + + /** + * If the given, non-null object has a value at the given path, returns the + * value at that path. Otherwise returns the provided default value. + * + * @func + * @memberOf R + * @since v0.18.0 + * @category Object + * @typedefn Idx = String | Int + * @sig a -> [Idx] -> {a} -> a + * @param {*} d The default value. + * @param {Array} p The path to use. + * @param {Object} obj The object to retrieve the nested property from. + * @return {*} The data at `path` of the supplied object or the default value. + * @example + * + * R.pathOr('N/A', ['a', 'b'], {a: {b: 2}}); //=> 2 + * R.pathOr('N/A', ['a', 'b'], {c: {b: 2}}); //=> "N/A" + */ + var pathOr = _curry3(function pathOr(d, p, obj) { + return defaultTo(d, path(p, obj)); + }); + + /** + * Returns `true` if the specified object property at given path satisfies the + * given predicate; `false` otherwise. + * + * @func + * @memberOf R + * @since v0.19.0 + * @category Logic + * @typedefn Idx = String | Int + * @sig (a -> Boolean) -> [Idx] -> {a} -> Boolean + * @param {Function} pred + * @param {Array} propPath + * @param {*} obj + * @return {Boolean} + * @see R.propSatisfies, R.path + * @example + * + * R.pathSatisfies(y => y > 0, ['x', 'y'], {x: {y: 2}}); //=> true + * R.pathSatisfies(R.is(Object), [], {x: {y: 2}}); //=> true + */ + var pathSatisfies = _curry3(function pathSatisfies(pred, propPath, obj) { + return pred(path(propPath, obj)); + }); + + /** + * Returns a partial copy of an object containing only the keys specified. If + * the key does not exist, the property is ignored. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Object + * @sig [k] -> {k: v} -> {k: v} + * @param {Array} names an array of String property names to copy onto a new object + * @param {Object} obj The object to copy from + * @return {Object} A new object with only properties from `names` on it. + * @see R.omit, R.props + * @example + * + * R.pick(['a', 'd'], {a: 1, b: 2, c: 3, d: 4}); //=> {a: 1, d: 4} + * R.pick(['a', 'e', 'f'], {a: 1, b: 2, c: 3, d: 4}); //=> {a: 1} + */ + var pick = _curry2(function pick(names, obj) { + var result = {}; + var idx = 0; + while (idx < names.length) { + if (names[idx] in obj) { + result[names[idx]] = obj[names[idx]]; + } + idx += 1; + } + return result; + }); + + /** + * Similar to `pick` except that this one includes a `key: undefined` pair for + * properties that don't exist. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Object + * @sig [k] -> {k: v} -> {k: v} + * @param {Array} names an array of String property names to copy onto a new object + * @param {Object} obj The object to copy from + * @return {Object} A new object with only properties from `names` on it. + * @see R.pick + * @example + * + * R.pickAll(['a', 'd'], {a: 1, b: 2, c: 3, d: 4}); //=> {a: 1, d: 4} + * R.pickAll(['a', 'e', 'f'], {a: 1, b: 2, c: 3, d: 4}); //=> {a: 1, e: undefined, f: undefined} + */ + var pickAll = _curry2(function pickAll(names, obj) { + var result = {}; + var idx = 0; + var len = names.length; + while (idx < len) { + var name = names[idx]; + result[name] = obj[name]; + idx += 1; + } + return result; + }); + + /** + * Returns a partial copy of an object containing only the keys that satisfy + * the supplied predicate. + * + * @func + * @memberOf R + * @since v0.8.0 + * @category Object + * @sig ((v, k) -> Boolean) -> {k: v} -> {k: v} + * @param {Function} pred A predicate to determine whether or not a key + * should be included on the output object. + * @param {Object} obj The object to copy from + * @return {Object} A new object with only properties that satisfy `pred` + * on it. + * @see R.pick, R.filter + * @example + * + * const isUpperCase = (val, key) => key.toUpperCase() === key; + * R.pickBy(isUpperCase, {a: 1, b: 2, A: 3, B: 4}); //=> {A: 3, B: 4} + */ + var pickBy = _curry2(function pickBy(test, obj) { + var result = {}; + for (var prop in obj) { + if (test(obj[prop], prop, obj)) { + result[prop] = obj[prop]; + } + } + return result; + }); + + /** + * Returns the left-to-right Kleisli composition of the provided functions, + * each of which must return a value of a type supported by [`chain`](#chain). + * + * `R.pipeK(f, g, h)` is equivalent to `R.pipe(f, R.chain(g), R.chain(h))`. + * + * @func + * @memberOf R + * @since v0.16.0 + * @category Function + * @sig Chain m => ((a -> m b), (b -> m c), ..., (y -> m z)) -> (a -> m z) + * @param {...Function} + * @return {Function} + * @see R.composeK + * @deprecated since v0.26.0 + * @example + * + * // parseJson :: String -> Maybe * + * // get :: String -> Object -> Maybe * + * + * // getStateCode :: Maybe String -> Maybe String + * const getStateCode = R.pipeK( + * parseJson, + * get('user'), + * get('address'), + * get('state'), + * R.compose(Maybe.of, R.toUpper) + * ); + * + * getStateCode('{"user":{"address":{"state":"ny"}}}'); + * //=> Just('NY') + * getStateCode('[Invalid JSON]'); + * //=> Nothing() + * @symb R.pipeK(f, g, h)(a) = R.chain(h, R.chain(g, f(a))) + */ + function pipeK() { + if (arguments.length === 0) { + throw new Error('pipeK requires at least one argument'); + } + return composeK.apply(this, reverse(arguments)); + } + + /** + * Returns a new list with the given element at the front, followed by the + * contents of the list. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category List + * @sig a -> [a] -> [a] + * @param {*} el The item to add to the head of the output list. + * @param {Array} list The array to add to the tail of the output list. + * @return {Array} A new array. + * @see R.append + * @example + * + * R.prepend('fee', ['fi', 'fo', 'fum']); //=> ['fee', 'fi', 'fo', 'fum'] + */ + var prepend = _curry2(function prepend(el, list) { + return _concat([el], list); + }); + + /** + * Multiplies together all the elements of a list. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Math + * @sig [Number] -> Number + * @param {Array} list An array of numbers + * @return {Number} The product of all the numbers in the list. + * @see R.reduce + * @example + * + * R.product([2,4,6,8,100,1]); //=> 38400 + */ + var product = reduce(multiply, 1); + + /** + * Accepts a function `fn` and a list of transformer functions and returns a + * new curried function. When the new function is invoked, it calls the + * function `fn` with parameters consisting of the result of calling each + * supplied handler on successive arguments to the new function. + * + * If more arguments are passed to the returned function than transformer + * functions, those arguments are passed directly to `fn` as additional + * parameters. If you expect additional arguments that don't need to be + * transformed, although you can ignore them, it's best to pass an identity + * function so that the new function reports the correct arity. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Function + * @sig ((x1, x2, ...) -> z) -> [(a -> x1), (b -> x2), ...] -> (a -> b -> ... -> z) + * @param {Function} fn The function to wrap. + * @param {Array} transformers A list of transformer functions + * @return {Function} The wrapped function. + * @see R.converge + * @example + * + * R.useWith(Math.pow, [R.identity, R.identity])(3, 4); //=> 81 + * R.useWith(Math.pow, [R.identity, R.identity])(3)(4); //=> 81 + * R.useWith(Math.pow, [R.dec, R.inc])(3, 4); //=> 32 + * R.useWith(Math.pow, [R.dec, R.inc])(3)(4); //=> 32 + * @symb R.useWith(f, [g, h])(a, b) = f(g(a), h(b)) + */ + var useWith = _curry2(function useWith(fn, transformers) { + return curryN(transformers.length, function() { + var args = []; + var idx = 0; + while (idx < transformers.length) { + args.push(transformers[idx].call(this, arguments[idx])); + idx += 1; + } + return fn.apply(this, args.concat(Array.prototype.slice.call(arguments, transformers.length))); + }); + }); + + /** + * Reasonable analog to SQL `select` statement. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Object + * @category Relation + * @sig [k] -> [{k: v}] -> [{k: v}] + * @param {Array} props The property names to project + * @param {Array} objs The objects to query + * @return {Array} An array of objects with just the `props` properties. + * @example + * + * const abby = {name: 'Abby', age: 7, hair: 'blond', grade: 2}; + * const fred = {name: 'Fred', age: 12, hair: 'brown', grade: 7}; + * const kids = [abby, fred]; + * R.project(['name', 'grade'], kids); //=> [{name: 'Abby', grade: 2}, {name: 'Fred', grade: 7}] + */ + var project = useWith(_map, [pickAll, identity]); // passing `identity` gives correct arity + + /** + * Returns `true` if the specified object property is equal, in + * [`R.equals`](#equals) terms, to the given value; `false` otherwise. + * You can test multiple properties with [`R.whereEq`](#whereEq). + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Relation + * @sig String -> a -> Object -> Boolean + * @param {String} name + * @param {*} val + * @param {*} obj + * @return {Boolean} + * @see R.whereEq, R.propSatisfies, R.equals + * @example + * + * const abby = {name: 'Abby', age: 7, hair: 'blond'}; + * const fred = {name: 'Fred', age: 12, hair: 'brown'}; + * const rusty = {name: 'Rusty', age: 10, hair: 'brown'}; + * const alois = {name: 'Alois', age: 15, disposition: 'surly'}; + * const kids = [abby, fred, rusty, alois]; + * const hasBrownHair = R.propEq('hair', 'brown'); + * R.filter(hasBrownHair, kids); //=> [fred, rusty] + */ + var propEq = _curry3(function propEq(name, val, obj) { + return equals(val, obj[name]); + }); + + /** + * Returns `true` if the specified object property is of the given type; + * `false` otherwise. + * + * @func + * @memberOf R + * @since v0.16.0 + * @category Type + * @sig Type -> String -> Object -> Boolean + * @param {Function} type + * @param {String} name + * @param {*} obj + * @return {Boolean} + * @see R.is, R.propSatisfies + * @example + * + * R.propIs(Number, 'x', {x: 1, y: 2}); //=> true + * R.propIs(Number, 'x', {x: 'foo'}); //=> false + * R.propIs(Number, 'x', {}); //=> false + */ + var propIs = _curry3(function propIs(type, name, obj) { + return is(type, obj[name]); + }); + + /** + * If the given, non-null object has an own property with the specified name, + * returns the value of that property. Otherwise returns the provided default + * value. + * + * @func + * @memberOf R + * @since v0.6.0 + * @category Object + * @sig a -> String -> Object -> a + * @param {*} val The default value. + * @param {String} p The name of the property to return. + * @param {Object} obj The object to query. + * @return {*} The value of given property of the supplied object or the default value. + * @example + * + * const alice = { + * name: 'ALICE', + * age: 101 + * }; + * const favorite = R.prop('favoriteLibrary'); + * const favoriteWithDefault = R.propOr('Ramda', 'favoriteLibrary'); + * + * favorite(alice); //=> undefined + * favoriteWithDefault(alice); //=> 'Ramda' + */ + var propOr = _curry3(function propOr(val, p, obj) { + return pathOr(val, [p], obj); + }); + + /** + * Returns `true` if the specified object property satisfies the given + * predicate; `false` otherwise. You can test multiple properties with + * [`R.where`](#where). + * + * @func + * @memberOf R + * @since v0.16.0 + * @category Logic + * @sig (a -> Boolean) -> String -> {String: a} -> Boolean + * @param {Function} pred + * @param {String} name + * @param {*} obj + * @return {Boolean} + * @see R.where, R.propEq, R.propIs + * @example + * + * R.propSatisfies(x => x > 0, 'x', {x: 1, y: 2}); //=> true + */ + var propSatisfies = _curry3(function propSatisfies(pred, name, obj) { + return pred(obj[name]); + }); + + /** + * Acts as multiple `prop`: array of keys in, array of values out. Preserves + * order. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Object + * @sig [k] -> {k: v} -> [v] + * @param {Array} ps The property names to fetch + * @param {Object} obj The object to query + * @return {Array} The corresponding values or partially applied function. + * @example + * + * R.props(['x', 'y'], {x: 1, y: 2}); //=> [1, 2] + * R.props(['c', 'a', 'b'], {b: 2, a: 1}); //=> [undefined, 1, 2] + * + * const fullName = R.compose(R.join(' '), R.props(['first', 'last'])); + * fullName({last: 'Bullet-Tooth', age: 33, first: 'Tony'}); //=> 'Tony Bullet-Tooth' + */ + var props = _curry2(function props(ps, obj) { + return ps.map(function(p) { + return path([p], obj); + }); + }); + + /** + * Returns a list of numbers from `from` (inclusive) to `to` (exclusive). + * + * @func + * @memberOf R + * @since v0.1.0 + * @category List + * @sig Number -> Number -> [Number] + * @param {Number} from The first number in the list. + * @param {Number} to One more than the last number in the list. + * @return {Array} The list of numbers in the set `[a, b)`. + * @example + * + * R.range(1, 5); //=> [1, 2, 3, 4] + * R.range(50, 53); //=> [50, 51, 52] + */ + var range = _curry2(function range(from, to) { + if (!(_isNumber(from) && _isNumber(to))) { + throw new TypeError('Both arguments to range must be numbers'); + } + var result = []; + var n = from; + while (n < to) { + result.push(n); + n += 1; + } + return result; + }); + + /** + * Returns a single item by iterating through the list, successively calling + * the iterator function and passing it an accumulator value and the current + * value from the array, and then passing the result to the next call. + * + * Similar to [`reduce`](#reduce), except moves through the input list from the + * right to the left. + * + * The iterator function receives two values: *(value, acc)*, while the arguments' + * order of `reduce`'s iterator function is *(acc, value)*. + * + * Note: `R.reduceRight` does not skip deleted or unassigned indices (sparse + * arrays), unlike the native `Array.prototype.reduceRight` method. For more details + * on this behavior, see: + * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduceRight#Description + * + * @func + * @memberOf R + * @since v0.1.0 + * @category List + * @sig ((a, b) -> b) -> b -> [a] -> b + * @param {Function} fn The iterator function. Receives two values, the current element from the array + * and the accumulator. + * @param {*} acc The accumulator value. + * @param {Array} list The list to iterate over. + * @return {*} The final, accumulated value. + * @see R.reduce, R.addIndex + * @example + * + * R.reduceRight(R.subtract, 0, [1, 2, 3, 4]) // => (1 - (2 - (3 - (4 - 0)))) = -2 + * // - -2 + * // / \ / \ + * // 1 - 1 3 + * // / \ / \ + * // 2 - ==> 2 -1 + * // / \ / \ + * // 3 - 3 4 + * // / \ / \ + * // 4 0 4 0 + * + * @symb R.reduceRight(f, a, [b, c, d]) = f(b, f(c, f(d, a))) + */ + var reduceRight = _curry3(function reduceRight(fn, acc, list) { + var idx = list.length - 1; + while (idx >= 0) { + acc = fn(list[idx], acc); + idx -= 1; + } + return acc; + }); + + /** + * Like [`reduce`](#reduce), `reduceWhile` returns a single item by iterating + * through the list, successively calling the iterator function. `reduceWhile` + * also takes a predicate that is evaluated before each step. If the predicate + * returns `false`, it "short-circuits" the iteration and returns the current + * value of the accumulator. + * + * @func + * @memberOf R + * @since v0.22.0 + * @category List + * @sig ((a, b) -> Boolean) -> ((a, b) -> a) -> a -> [b] -> a + * @param {Function} pred The predicate. It is passed the accumulator and the + * current element. + * @param {Function} fn The iterator function. Receives two values, the + * accumulator and the current element. + * @param {*} a The accumulator value. + * @param {Array} list The list to iterate over. + * @return {*} The final, accumulated value. + * @see R.reduce, R.reduced + * @example + * + * const isOdd = (acc, x) => x % 2 === 1; + * const xs = [1, 3, 5, 60, 777, 800]; + * R.reduceWhile(isOdd, R.add, 0, xs); //=> 9 + * + * const ys = [2, 4, 6] + * R.reduceWhile(isOdd, R.add, 111, ys); //=> 111 + */ + var reduceWhile = _curryN(4, [], function _reduceWhile(pred, fn, a, list) { + return _reduce(function(acc, x) { + return pred(acc, x) ? fn(acc, x) : _reduced(acc); + }, a, list); + }); + + /** + * Returns a value wrapped to indicate that it is the final value of the reduce + * and transduce functions. The returned value should be considered a black + * box: the internal structure is not guaranteed to be stable. + * + * Note: this optimization is only available to the below functions: + * - [`reduce`](#reduce) + * - [`reduceWhile`](#reduceWhile) + * - [`transduce`](#transduce) + * + * @func + * @memberOf R + * @since v0.15.0 + * @category List + * @sig a -> * + * @param {*} x The final value of the reduce. + * @return {*} The wrapped value. + * @see R.reduce, R.reduceWhile, R.transduce + * @example + * + * R.reduce( + * (acc, item) => item > 3 ? R.reduced(acc) : acc.concat(item), + * [], + * [1, 2, 3, 4, 5]) // [1, 2, 3] + */ + var reduced = _curry1(_reduced); + + /** + * Calls an input function `n` times, returning an array containing the results + * of those function calls. + * + * `fn` is passed one argument: The current value of `n`, which begins at `0` + * and is gradually incremented to `n - 1`. + * + * @func + * @memberOf R + * @since v0.2.3 + * @category List + * @sig (Number -> a) -> Number -> [a] + * @param {Function} fn The function to invoke. Passed one argument, the current value of `n`. + * @param {Number} n A value between `0` and `n - 1`. Increments after each function call. + * @return {Array} An array containing the return values of all calls to `fn`. + * @see R.repeat + * @example + * + * R.times(R.identity, 5); //=> [0, 1, 2, 3, 4] + * @symb R.times(f, 0) = [] + * @symb R.times(f, 1) = [f(0)] + * @symb R.times(f, 2) = [f(0), f(1)] + */ + var times = _curry2(function times(fn, n) { + var len = Number(n); + var idx = 0; + var list; + + if (len < 0 || isNaN(len)) { + throw new RangeError('n must be a non-negative number'); + } + list = new Array(len); + while (idx < len) { + list[idx] = fn(idx); + idx += 1; + } + return list; + }); + + /** + * Returns a fixed list of size `n` containing a specified identical value. + * + * @func + * @memberOf R + * @since v0.1.1 + * @category List + * @sig a -> n -> [a] + * @param {*} value The value to repeat. + * @param {Number} n The desired size of the output list. + * @return {Array} A new array containing `n` `value`s. + * @see R.times + * @example + * + * R.repeat('hi', 5); //=> ['hi', 'hi', 'hi', 'hi', 'hi'] + * + * const obj = {}; + * const repeatedObjs = R.repeat(obj, 5); //=> [{}, {}, {}, {}, {}] + * repeatedObjs[0] === repeatedObjs[1]; //=> true + * @symb R.repeat(a, 0) = [] + * @symb R.repeat(a, 1) = [a] + * @symb R.repeat(a, 2) = [a, a] + */ + var repeat = _curry2(function repeat(value, n) { + return times(always(value), n); + }); + + /** + * Replace a substring or regex match in a string with a replacement. + * + * The first two parameters correspond to the parameters of the + * `String.prototype.replace()` function, so the second parameter can also be a + * function. + * + * @func + * @memberOf R + * @since v0.7.0 + * @category String + * @sig RegExp|String -> String -> String -> String + * @param {RegExp|String} pattern A regular expression or a substring to match. + * @param {String} replacement The string to replace the matches with. + * @param {String} str The String to do the search and replacement in. + * @return {String} The result. + * @example + * + * R.replace('foo', 'bar', 'foo foo foo'); //=> 'bar foo foo' + * R.replace(/foo/, 'bar', 'foo foo foo'); //=> 'bar foo foo' + * + * // Use the "g" (global) flag to replace all occurrences: + * R.replace(/foo/g, 'bar', 'foo foo foo'); //=> 'bar bar bar' + */ + var replace = _curry3(function replace(regex, replacement, str) { + return str.replace(regex, replacement); + }); -function dropLast$2(n, xs) { - return take(n < xs.length ? xs.length - n : 0, xs); -} - -function XDropLast(n, xf) { - this.xf = xf; - this.pos = 0; - this.full = false; - this.acc = new Array(n); -} -XDropLast.prototype['@@transducer/init'] = _xfBase.init; -XDropLast.prototype['@@transducer/result'] = function(result) { - this.acc = null; - return this.xf['@@transducer/result'](result); -}; -XDropLast.prototype['@@transducer/step'] = function(result, input) { - if (this.full) { - result = this.xf['@@transducer/step'](result, this.acc[this.pos]); - } - this.store(input); - return result; -}; -XDropLast.prototype.store = function(input) { - this.acc[this.pos] = input; - this.pos += 1; - if (this.pos === this.acc.length) { - this.pos = 0; - this.full = true; - } -}; - -var _xdropLast = _curry2(function _xdropLast(n, xf) { return new XDropLast(n, xf); }); - -/** - * Returns a list containing all but the last `n` elements of the given `list`. - * - * Acts as a transducer if a transformer is given in list position. - * - * @func - * @memberOf R - * @since v0.16.0 - * @category List - * @sig Number -> [a] -> [a] - * @sig Number -> String -> String - * @param {Number} n The number of elements of `list` to skip. - * @param {Array} list The list of elements to consider. - * @return {Array} A copy of the list with only the first `list.length - n` elements - * @see R.takeLast, R.drop, R.dropWhile, R.dropLastWhile - * @example - * - * R.dropLast(1, ['foo', 'bar', 'baz']); //=> ['foo', 'bar'] - * R.dropLast(2, ['foo', 'bar', 'baz']); //=> ['foo'] - * R.dropLast(3, ['foo', 'bar', 'baz']); //=> [] - * R.dropLast(4, ['foo', 'bar', 'baz']); //=> [] - * R.dropLast(3, 'ramda'); //=> 'ra' - */ -var dropLast = _curry2(_dispatchable([], _xdropLast, dropLast$2)); - -function dropLastWhile$2(pred, xs) { - var idx = xs.length - 1; - while (idx >= 0 && pred(xs[idx])) { - idx -= 1; - } - return slice(0, idx + 1, xs); -} - -function XDropLastWhile(fn, xf) { - this.f = fn; - this.retained = []; - this.xf = xf; -} -XDropLastWhile.prototype['@@transducer/init'] = _xfBase.init; -XDropLastWhile.prototype['@@transducer/result'] = function(result) { - this.retained = null; - return this.xf['@@transducer/result'](result); -}; -XDropLastWhile.prototype['@@transducer/step'] = function(result, input) { - return this.f(input) ? this.retain(result, input) - : this.flush(result, input); -}; -XDropLastWhile.prototype.flush = function(result, input) { - result = _reduce( - this.xf['@@transducer/step'], - result, - this.retained - ); - this.retained = []; - return this.xf['@@transducer/step'](result, input); -}; -XDropLastWhile.prototype.retain = function(result, input) { - this.retained.push(input); - return result; -}; - -var _xdropLastWhile = _curry2(function _xdropLastWhile(fn, xf) { return new XDropLastWhile(fn, xf); }); - -/** - * Returns a new list excluding all the tailing elements of a given list which - * satisfy the supplied predicate function. It passes each value from the right - * to the supplied predicate function, skipping elements until the predicate - * function returns a `falsy` value. The predicate function is applied to one argument: - * *(value)*. - * - * Acts as a transducer if a transformer is given in list position. - * - * @func - * @memberOf R - * @since v0.16.0 - * @category List - * @sig (a -> Boolean) -> [a] -> [a] - * @sig (a -> Boolean) -> String -> String - * @param {Function} predicate The function to be called on each element - * @param {Array} xs The collection to iterate over. - * @return {Array} A new array without any trailing elements that return `falsy` values from the `predicate`. - * @see R.takeLastWhile, R.addIndex, R.drop, R.dropWhile - * @example - * - * const lteThree = x => x <= 3; - * - * R.dropLastWhile(lteThree, [1, 2, 3, 4, 3, 2, 1]); //=> [1, 2, 3, 4] - * - * R.dropLastWhile(x => x !== 'd' , 'Ramda'); //=> 'Ramd' - */ -var dropLastWhile = _curry2(_dispatchable([], _xdropLastWhile, dropLastWhile$2)); - -function XDropRepeatsWith(pred, xf) { - this.xf = xf; - this.pred = pred; - this.lastValue = undefined; - this.seenFirstValue = false; -} - -XDropRepeatsWith.prototype['@@transducer/init'] = _xfBase.init; -XDropRepeatsWith.prototype['@@transducer/result'] = _xfBase.result; -XDropRepeatsWith.prototype['@@transducer/step'] = function(result, input) { - var sameAsLast = false; - if (!this.seenFirstValue) { - this.seenFirstValue = true; - } else if (this.pred(this.lastValue, input)) { - sameAsLast = true; - } - this.lastValue = input; - return sameAsLast ? result : this.xf['@@transducer/step'](result, input); -}; - -var _xdropRepeatsWith = _curry2(function _xdropRepeatsWith(pred, xf) { return new XDropRepeatsWith(pred, xf); }); - -/** - * Returns the last element of the given list or string. - * - * @func - * @memberOf R - * @since v0.1.4 - * @category List - * @sig [a] -> a | Undefined - * @sig String -> String - * @param {*} list - * @return {*} - * @see R.init, R.head, R.tail - * @example - * - * R.last(['fi', 'fo', 'fum']); //=> 'fum' - * R.last([]); //=> undefined - * - * R.last('abc'); //=> 'c' - * R.last(''); //=> '' - */ -var last = nth(-1); - -/** - * Returns a new list without any consecutively repeating elements. Equality is - * determined by applying the supplied predicate to each pair of consecutive elements. The - * first element in a series of equal elements will be preserved. - * - * Acts as a transducer if a transformer is given in list position. - * - * @func - * @memberOf R - * @since v0.14.0 - * @category List - * @sig ((a, a) -> Boolean) -> [a] -> [a] - * @param {Function} pred A predicate used to test whether two items are equal. - * @param {Array} list The array to consider. - * @return {Array} `list` without repeating elements. - * @see R.transduce - * @example - * - * const l = [1, -1, 1, 3, 4, -4, -4, -5, 5, 3, 3]; - * R.dropRepeatsWith(R.eqBy(Math.abs), l); //=> [1, 3, 4, -5, 3] - */ -var dropRepeatsWith = _curry2(_dispatchable([], _xdropRepeatsWith, function dropRepeatsWith(pred, list) { - var result = []; - var idx = 1; - var len = list.length; - if (len !== 0) { - result[0] = list[0]; + /** + * Scan is similar to [`reduce`](#reduce), but returns a list of successively + * reduced values from the left + * + * @func + * @memberOf R + * @since v0.10.0 + * @category List + * @sig ((a, b) -> a) -> a -> [b] -> [a] + * @param {Function} fn The iterator function. Receives two values, the accumulator and the + * current element from the array + * @param {*} acc The accumulator value. + * @param {Array} list The list to iterate over. + * @return {Array} A list of all intermediately reduced values. + * @see R.reduce, R.mapAccum + * @example + * + * const numbers = [1, 2, 3, 4]; + * const factorials = R.scan(R.multiply, 1, numbers); //=> [1, 1, 2, 6, 24] + * @symb R.scan(f, a, [b, c]) = [a, f(a, b), f(f(a, b), c)] + */ + var scan = _curry3(function scan(fn, acc, list) { + var idx = 0; + var len = list.length; + var result = [acc]; while (idx < len) { - if (!pred(last(result), list[idx])) { - result[result.length] = list[idx]; - } + acc = fn(acc, list[idx]); + result[idx + 1] = acc; idx += 1; } - } - return result; -})); + return result; + }); -/** - * Returns a new list without any consecutively repeating elements. - * [`R.equals`](#equals) is used to determine equality. - * - * Acts as a transducer if a transformer is given in list position. - * - * @func - * @memberOf R - * @since v0.14.0 - * @category List - * @sig [a] -> [a] - * @param {Array} list The array to consider. - * @return {Array} `list` without repeating elements. - * @see R.transduce - * @example - * - * R.dropRepeats([1, 1, 1, 2, 3, 4, 4, 2, 2]); //=> [1, 2, 3, 4, 2] - */ -var dropRepeats = _curry1(_dispatchable([], - _xdropRepeatsWith(equals), - dropRepeatsWith(equals))); - -function XDropWhile(f, xf) { - this.xf = xf; - this.f = f; -} -XDropWhile.prototype['@@transducer/init'] = _xfBase.init; -XDropWhile.prototype['@@transducer/result'] = _xfBase.result; -XDropWhile.prototype['@@transducer/step'] = function(result, input) { - if (this.f) { - if (this.f(input)) { - return result; - } - this.f = null; - } - return this.xf['@@transducer/step'](result, input); -}; - -var _xdropWhile = _curry2(function _xdropWhile(f, xf) { return new XDropWhile(f, xf); }); - -/** - * Returns a new list excluding the leading elements of a given list which - * satisfy the supplied predicate function. It passes each value to the supplied - * predicate function, skipping elements while the predicate function returns - * `true`. The predicate function is applied to one argument: *(value)*. - * - * Dispatches to the `dropWhile` method of the second argument, if present. - * - * Acts as a transducer if a transformer is given in list position. - * - * @func - * @memberOf R - * @since v0.9.0 - * @category List - * @sig (a -> Boolean) -> [a] -> [a] - * @sig (a -> Boolean) -> String -> String - * @param {Function} fn The function called per iteration. - * @param {Array} xs The collection to iterate over. - * @return {Array} A new array. - * @see R.takeWhile, R.transduce, R.addIndex - * @example - * - * const lteTwo = x => x <= 2; - * - * R.dropWhile(lteTwo, [1, 2, 3, 4, 3, 2, 1]); //=> [3, 4, 3, 2, 1] - * - * R.dropWhile(x => x !== 'd' , 'Ramda'); //=> 'da' - */ -var dropWhile = _curry2(_dispatchable(['dropWhile'], _xdropWhile, function dropWhile(pred, xs) { - var idx = 0; - var len = xs.length; - while (idx < len && pred(xs[idx])) { - idx += 1; - } - return slice(idx, Infinity, xs); -})); + /** + * Transforms a [Traversable](https://github.com/fantasyland/fantasy-land#traversable) + * of [Applicative](https://github.com/fantasyland/fantasy-land#applicative) into an + * Applicative of Traversable. + * + * Dispatches to the `sequence` method of the second argument, if present. + * + * @func + * @memberOf R + * @since v0.19.0 + * @category List + * @sig (Applicative f, Traversable t) => (a -> f a) -> t (f a) -> f (t a) + * @param {Function} of + * @param {*} traversable + * @return {*} + * @see R.traverse + * @example + * + * R.sequence(Maybe.of, [Just(1), Just(2), Just(3)]); //=> Just([1, 2, 3]) + * R.sequence(Maybe.of, [Just(1), Just(2), Nothing()]); //=> Nothing() + * + * R.sequence(R.of, Just([1, 2, 3])); //=> [Just(1), Just(2), Just(3)] + * R.sequence(R.of, Nothing()); //=> [Nothing()] + */ + var sequence = _curry2(function sequence(of, traversable) { + return typeof traversable.sequence === 'function' ? + traversable.sequence(of) : + reduceRight( + function(x, acc) { return ap(map(prepend, x), acc); }, + of([]), + traversable + ); + }); -/** - * Returns `true` if one or both of its arguments are `true`. Returns `false` - * if both arguments are `false`. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Logic - * @sig a -> b -> a | b - * @param {Any} a - * @param {Any} b - * @return {Any} the first argument if truthy, otherwise the second argument. - * @see R.either - * @example - * - * R.or(true, true); //=> true - * R.or(true, false); //=> true - * R.or(false, true); //=> true - * R.or(false, false); //=> false - */ -var or = _curry2(function or(a, b) { - return a || b; -}); - -/** - * A function wrapping calls to the two functions in an `||` operation, - * returning the result of the first function if it is truth-y and the result - * of the second function otherwise. Note that this is short-circuited, - * meaning that the second function will not be invoked if the first returns a - * truth-y value. - * - * In addition to functions, `R.either` also accepts any fantasy-land compatible - * applicative functor. - * - * @func - * @memberOf R - * @since v0.12.0 - * @category Logic - * @sig (*... -> Boolean) -> (*... -> Boolean) -> (*... -> Boolean) - * @param {Function} f a predicate - * @param {Function} g another predicate - * @return {Function} a function that applies its arguments to `f` and `g` and `||`s their outputs together. - * @see R.or - * @example - * - * const gt10 = x => x > 10; - * const even = x => x % 2 === 0; - * const f = R.either(gt10, even); - * f(101); //=> true - * f(8); //=> true - * - * R.either(Maybe.Just(false), Maybe.Just(55)); // => Maybe.Just(55) - * R.either([false, false, 'a'], [11]) // => [11, 11, "a"] - */ -var either = _curry2(function either(f, g) { - return _isFunction(f) ? - function _either() { - return f.apply(this, arguments) || g.apply(this, arguments); - } : - lift(or)(f, g); -}); - -/** - * Returns the empty value of its argument's type. Ramda defines the empty - * value of Array (`[]`), Object (`{}`), String (`''`), and Arguments. Other - * types are supported if they define `.empty`, - * `.prototype.empty` or implement the - * [FantasyLand Monoid spec](https://github.com/fantasyland/fantasy-land#monoid). - * - * Dispatches to the `empty` method of the first argument, if present. - * - * @func - * @memberOf R - * @since v0.3.0 - * @category Function - * @sig a -> a - * @param {*} x - * @return {*} - * @example - * - * R.empty(Just(42)); //=> Nothing() - * R.empty([1, 2, 3]); //=> [] - * R.empty('unicorns'); //=> '' - * R.empty({x: 1, y: 2}); //=> {} - */ -var empty = _curry1(function empty(x) { - return ( - (x != null && typeof x['fantasy-land/empty'] === 'function') ? - x['fantasy-land/empty']() : - (x != null && x.constructor != null && typeof x.constructor['fantasy-land/empty'] === 'function') ? - x.constructor['fantasy-land/empty']() : - (x != null && typeof x.empty === 'function') ? - x.empty() : - (x != null && x.constructor != null && typeof x.constructor.empty === 'function') ? - x.constructor.empty() : - _isArray(x) ? - [] : - _isString(x) ? - '' : - _isObject(x) ? - {} : - _isArguments(x) ? - (function() { return arguments; }()) : - // else - void 0 - ); -}); - -/** - * Returns a new list containing the last `n` elements of the given list. - * If `n > list.length`, returns a list of `list.length` elements. - * - * @func - * @memberOf R - * @since v0.16.0 - * @category List - * @sig Number -> [a] -> [a] - * @sig Number -> String -> String - * @param {Number} n The number of elements to return. - * @param {Array} xs The collection to consider. - * @return {Array} - * @see R.dropLast - * @example - * - * R.takeLast(1, ['foo', 'bar', 'baz']); //=> ['baz'] - * R.takeLast(2, ['foo', 'bar', 'baz']); //=> ['bar', 'baz'] - * R.takeLast(3, ['foo', 'bar', 'baz']); //=> ['foo', 'bar', 'baz'] - * R.takeLast(4, ['foo', 'bar', 'baz']); //=> ['foo', 'bar', 'baz'] - * R.takeLast(3, 'ramda'); //=> 'mda' - */ -var takeLast = _curry2(function takeLast(n, xs) { - return drop(n >= 0 ? xs.length - n : 0, xs); -}); - -/** - * Checks if a list ends with the provided sublist. - * - * Similarly, checks if a string ends with the provided substring. - * - * @func - * @memberOf R - * @since v0.24.0 - * @category List - * @sig [a] -> [a] -> Boolean - * @sig String -> String -> Boolean - * @param {*} suffix - * @param {*} list - * @return {Boolean} - * @see R.startsWith - * @example - * - * R.endsWith('c', 'abc') //=> true - * R.endsWith('b', 'abc') //=> false - * R.endsWith(['c'], ['a', 'b', 'c']) //=> true - * R.endsWith(['b'], ['a', 'b', 'c']) //=> false - */ -var endsWith = _curry2(function(suffix, list) { - return equals(takeLast(suffix.length, list), suffix); -}); - -/** - * Takes a function and two values in its domain and returns `true` if the - * values map to the same value in the codomain; `false` otherwise. - * - * @func - * @memberOf R - * @since v0.18.0 - * @category Relation - * @sig (a -> b) -> a -> a -> Boolean - * @param {Function} f - * @param {*} x - * @param {*} y - * @return {Boolean} - * @example - * - * R.eqBy(Math.abs, 5, -5); //=> true - */ -var eqBy = _curry3(function eqBy(f, x, y) { - return equals(f(x), f(y)); -}); - -/** - * Reports whether two objects have the same value, in [`R.equals`](#equals) - * terms, for the specified property. Useful as a curried predicate. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Object - * @sig k -> {k: v} -> {k: v} -> Boolean - * @param {String} prop The name of the property to compare - * @param {Object} obj1 - * @param {Object} obj2 - * @return {Boolean} - * - * @example - * - * const o1 = { a: 1, b: 2, c: 3, d: 4 }; - * const o2 = { a: 10, b: 20, c: 3, d: 40 }; - * R.eqProps('a', o1, o2); //=> false - * R.eqProps('c', o1, o2); //=> true - */ -var eqProps = _curry3(function eqProps(prop, obj1, obj2) { - return equals(obj1[prop], obj2[prop]); -}); - -/** - * Creates a new object by recursively evolving a shallow copy of `object`, - * according to the `transformation` functions. All non-primitive properties - * are copied by reference. - * - * A `transformation` function will not be invoked if its corresponding key - * does not exist in the evolved object. - * - * @func - * @memberOf R - * @since v0.9.0 - * @category Object - * @sig {k: (v -> v)} -> {k: v} -> {k: v} - * @param {Object} transformations The object specifying transformation functions to apply - * to the object. - * @param {Object} object The object to be transformed. - * @return {Object} The transformed object. - * @example - * - * const tomato = {firstName: ' Tomato ', data: {elapsed: 100, remaining: 1400}, id:123}; - * const transformations = { - * firstName: R.trim, - * lastName: R.trim, // Will not get invoked. - * data: {elapsed: R.add(1), remaining: R.add(-1)} - * }; - * R.evolve(transformations, tomato); //=> {firstName: 'Tomato', data: {elapsed: 101, remaining: 1399}, id:123} - */ -var evolve = _curry2(function evolve(transformations, object) { - var result = object instanceof Array ? [] : {}; - var transformation, key, type; - for (key in object) { - transformation = transformations[key]; - type = typeof transformation; - result[key] = type === 'function' ? transformation(object[key]) - : transformation && type === 'object' ? evolve(transformation, object[key]) - : object[key]; - } - return result; -}); - -function XFind(f, xf) { - this.xf = xf; - this.f = f; - this.found = false; -} -XFind.prototype['@@transducer/init'] = _xfBase.init; -XFind.prototype['@@transducer/result'] = function(result) { - if (!this.found) { - result = this.xf['@@transducer/step'](result, void 0); - } - return this.xf['@@transducer/result'](result); -}; -XFind.prototype['@@transducer/step'] = function(result, input) { - if (this.f(input)) { - this.found = true; - result = _reduced(this.xf['@@transducer/step'](result, input)); - } - return result; -}; - -var _xfind = _curry2(function _xfind(f, xf) { return new XFind(f, xf); }); - -/** - * Returns the first element of the list which matches the predicate, or - * `undefined` if no element matches. - * - * Dispatches to the `find` method of the second argument, if present. - * - * Acts as a transducer if a transformer is given in list position. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category List - * @sig (a -> Boolean) -> [a] -> a | undefined - * @param {Function} fn The predicate function used to determine if the element is the - * desired one. - * @param {Array} list The array to consider. - * @return {Object} The element found, or `undefined`. - * @see R.transduce - * @example - * - * const xs = [{a: 1}, {a: 2}, {a: 3}]; - * R.find(R.propEq('a', 2))(xs); //=> {a: 2} - * R.find(R.propEq('a', 4))(xs); //=> undefined - */ -var find = _curry2(_dispatchable(['find'], _xfind, function find(fn, list) { - var idx = 0; - var len = list.length; - while (idx < len) { - if (fn(list[idx])) { - return list[idx]; - } - idx += 1; - } -})); + /** + * Returns the result of "setting" the portion of the given data structure + * focused by the given lens to the given value. + * + * @func + * @memberOf R + * @since v0.16.0 + * @category Object + * @typedefn Lens s a = Functor f => (a -> f a) -> s -> f s + * @sig Lens s a -> a -> s -> s + * @param {Lens} lens + * @param {*} v + * @param {*} x + * @return {*} + * @see R.prop, R.lensIndex, R.lensProp + * @example + * + * const xLens = R.lensProp('x'); + * + * R.set(xLens, 4, {x: 1, y: 2}); //=> {x: 4, y: 2} + * R.set(xLens, 8, {x: 1, y: 2}); //=> {x: 8, y: 2} + */ + var set = _curry3(function set(lens, v, x) { + return over(lens, always(v), x); + }); -function XFindIndex(f, xf) { - this.xf = xf; - this.f = f; - this.idx = -1; - this.found = false; -} -XFindIndex.prototype['@@transducer/init'] = _xfBase.init; -XFindIndex.prototype['@@transducer/result'] = function(result) { - if (!this.found) { - result = this.xf['@@transducer/step'](result, -1); - } - return this.xf['@@transducer/result'](result); -}; -XFindIndex.prototype['@@transducer/step'] = function(result, input) { - this.idx += 1; - if (this.f(input)) { - this.found = true; - result = _reduced(this.xf['@@transducer/step'](result, this.idx)); - } - return result; -}; - -var _xfindIndex = _curry2(function _xfindIndex(f, xf) { return new XFindIndex(f, xf); }); - -/** - * Returns the index of the first element of the list which matches the - * predicate, or `-1` if no element matches. - * - * Acts as a transducer if a transformer is given in list position. - * - * @func - * @memberOf R - * @since v0.1.1 - * @category List - * @sig (a -> Boolean) -> [a] -> Number - * @param {Function} fn The predicate function used to determine if the element is the - * desired one. - * @param {Array} list The array to consider. - * @return {Number} The index of the element found, or `-1`. - * @see R.transduce - * @example - * - * const xs = [{a: 1}, {a: 2}, {a: 3}]; - * R.findIndex(R.propEq('a', 2))(xs); //=> 1 - * R.findIndex(R.propEq('a', 4))(xs); //=> -1 - */ -var findIndex = _curry2(_dispatchable([], _xfindIndex, function findIndex(fn, list) { - var idx = 0; - var len = list.length; - while (idx < len) { - if (fn(list[idx])) { - return idx; - } - idx += 1; - } - return -1; -})); + /** + * Returns a copy of the list, sorted according to the comparator function, + * which should accept two values at a time and return a negative number if the + * first value is smaller, a positive number if it's larger, and zero if they + * are equal. Please note that this is a **copy** of the list. It does not + * modify the original. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category List + * @sig ((a, a) -> Number) -> [a] -> [a] + * @param {Function} comparator A sorting function :: a -> b -> Int + * @param {Array} list The list to sort + * @return {Array} a new array with its elements sorted by the comparator function. + * @example + * + * const diff = function(a, b) { return a - b; }; + * R.sort(diff, [4,2,7,5]); //=> [2, 4, 5, 7] + */ + var sort = _curry2(function sort(comparator, list) { + return Array.prototype.slice.call(list, 0).sort(comparator); + }); -function XFindLast(f, xf) { - this.xf = xf; - this.f = f; -} -XFindLast.prototype['@@transducer/init'] = _xfBase.init; -XFindLast.prototype['@@transducer/result'] = function(result) { - return this.xf['@@transducer/result'](this.xf['@@transducer/step'](result, this.last)); -}; -XFindLast.prototype['@@transducer/step'] = function(result, input) { - if (this.f(input)) { - this.last = input; - } - return result; -}; - -var _xfindLast = _curry2(function _xfindLast(f, xf) { return new XFindLast(f, xf); }); - -/** - * Returns the last element of the list which matches the predicate, or - * `undefined` if no element matches. - * - * Acts as a transducer if a transformer is given in list position. - * - * @func - * @memberOf R - * @since v0.1.1 - * @category List - * @sig (a -> Boolean) -> [a] -> a | undefined - * @param {Function} fn The predicate function used to determine if the element is the - * desired one. - * @param {Array} list The array to consider. - * @return {Object} The element found, or `undefined`. - * @see R.transduce - * @example - * - * const xs = [{a: 1, b: 0}, {a:1, b: 1}]; - * R.findLast(R.propEq('a', 1))(xs); //=> {a: 1, b: 1} - * R.findLast(R.propEq('a', 4))(xs); //=> undefined - */ -var findLast = _curry2(_dispatchable([], _xfindLast, function findLast(fn, list) { - var idx = list.length - 1; - while (idx >= 0) { - if (fn(list[idx])) { - return list[idx]; - } - idx -= 1; - } -})); + /** + * Sorts the list according to the supplied function. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Relation + * @sig Ord b => (a -> b) -> [a] -> [a] + * @param {Function} fn + * @param {Array} list The list to sort. + * @return {Array} A new list sorted by the keys generated by `fn`. + * @example + * + * const sortByFirstItem = R.sortBy(R.prop(0)); + * const pairs = [[-1, 1], [-2, 2], [-3, 3]]; + * sortByFirstItem(pairs); //=> [[-3, 3], [-2, 2], [-1, 1]] + * + * const sortByNameCaseInsensitive = R.sortBy(R.compose(R.toLower, R.prop('name'))); + * const alice = { + * name: 'ALICE', + * age: 101 + * }; + * const bob = { + * name: 'Bob', + * age: -10 + * }; + * const clara = { + * name: 'clara', + * age: 314.159 + * }; + * const people = [clara, bob, alice]; + * sortByNameCaseInsensitive(people); //=> [alice, bob, clara] + */ + var sortBy = _curry2(function sortBy(fn, list) { + return Array.prototype.slice.call(list, 0).sort(function(a, b) { + var aa = fn(a); + var bb = fn(b); + return aa < bb ? -1 : aa > bb ? 1 : 0; + }); + }); -function XFindLastIndex(f, xf) { - this.xf = xf; - this.f = f; - this.idx = -1; - this.lastIdx = -1; -} -XFindLastIndex.prototype['@@transducer/init'] = _xfBase.init; -XFindLastIndex.prototype['@@transducer/result'] = function(result) { - return this.xf['@@transducer/result'](this.xf['@@transducer/step'](result, this.lastIdx)); -}; -XFindLastIndex.prototype['@@transducer/step'] = function(result, input) { - this.idx += 1; - if (this.f(input)) { - this.lastIdx = this.idx; - } - return result; -}; - -var _xfindLastIndex = _curry2(function _xfindLastIndex(f, xf) { return new XFindLastIndex(f, xf); }); - -/** - * Returns the index of the last element of the list which matches the - * predicate, or `-1` if no element matches. - * - * Acts as a transducer if a transformer is given in list position. - * - * @func - * @memberOf R - * @since v0.1.1 - * @category List - * @sig (a -> Boolean) -> [a] -> Number - * @param {Function} fn The predicate function used to determine if the element is the - * desired one. - * @param {Array} list The array to consider. - * @return {Number} The index of the element found, or `-1`. - * @see R.transduce - * @example - * - * const xs = [{a: 1, b: 0}, {a:1, b: 1}]; - * R.findLastIndex(R.propEq('a', 1))(xs); //=> 1 - * R.findLastIndex(R.propEq('a', 4))(xs); //=> -1 - */ -var findLastIndex = _curry2(_dispatchable([], _xfindLastIndex, function findLastIndex(fn, list) { - var idx = list.length - 1; - while (idx >= 0) { - if (fn(list[idx])) { - return idx; - } - idx -= 1; - } - return -1; -})); + /** + * Sorts a list according to a list of comparators. + * + * @func + * @memberOf R + * @since v0.23.0 + * @category Relation + * @sig [(a, a) -> Number] -> [a] -> [a] + * @param {Array} functions A list of comparator functions. + * @param {Array} list The list to sort. + * @return {Array} A new list sorted according to the comarator functions. + * @example + * + * const alice = { + * name: 'alice', + * age: 40 + * }; + * const bob = { + * name: 'bob', + * age: 30 + * }; + * const clara = { + * name: 'clara', + * age: 40 + * }; + * const people = [clara, bob, alice]; + * const ageNameSort = R.sortWith([ + * R.descend(R.prop('age')), + * R.ascend(R.prop('name')) + * ]); + * ageNameSort(people); //=> [alice, clara, bob] + */ + var sortWith = _curry2(function sortWith(fns, list) { + return Array.prototype.slice.call(list, 0).sort(function(a, b) { + var result = 0; + var i = 0; + while (result === 0 && i < fns.length) { + result = fns[i](a, b); + i += 1; + } + return result; + }); + }); -/** - * Returns a new list by pulling every item out of it (and all its sub-arrays) - * and putting them in a new array, depth-first. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category List - * @sig [a] -> [b] - * @param {Array} list The array to consider. - * @return {Array} The flattened list. - * @see R.unnest - * @example - * - * R.flatten([1, 2, [3, 4], 5, [6, [7, 8, [9, [10, 11], 12]]]]); - * //=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] - */ -var flatten = _curry1(_makeFlat(true)); - -/** - * Returns a new function much like the supplied one, except that the first two - * arguments' order is reversed. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Function - * @sig ((a, b, c, ...) -> z) -> (b -> a -> c -> ... -> z) - * @param {Function} fn The function to invoke with its first two parameters reversed. - * @return {*} The result of invoking `fn` with its first two parameters' order reversed. - * @example - * - * const mergeThree = (a, b, c) => [].concat(a, b, c); - * - * mergeThree(1, 2, 3); //=> [1, 2, 3] - * - * R.flip(mergeThree)(1, 2, 3); //=> [2, 1, 3] - * @symb R.flip(f)(a, b, c) = f(b, a, c) - */ -var flip = _curry1(function flip(fn) { - return curryN(fn.length, function(a, b) { - var args = Array.prototype.slice.call(arguments, 0); - args[0] = b; - args[1] = a; - return fn.apply(this, args); + /** + * Splits a string into an array of strings based on the given + * separator. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category String + * @sig (String | RegExp) -> String -> [String] + * @param {String|RegExp} sep The pattern. + * @param {String} str The string to separate into an array. + * @return {Array} The array of strings from `str` separated by `sep`. + * @see R.join + * @example + * + * const pathComponents = R.split('/'); + * R.tail(pathComponents('/usr/local/bin/node')); //=> ['usr', 'local', 'bin', 'node'] + * + * R.split('.', 'a.b.c.xyz.d'); //=> ['a', 'b', 'c', 'xyz', 'd'] + */ + var split = invoker(1, 'split'); + + /** + * Splits a given list or string at a given index. + * + * @func + * @memberOf R + * @since v0.19.0 + * @category List + * @sig Number -> [a] -> [[a], [a]] + * @sig Number -> String -> [String, String] + * @param {Number} index The index where the array/string is split. + * @param {Array|String} array The array/string to be split. + * @return {Array} + * @example + * + * R.splitAt(1, [1, 2, 3]); //=> [[1], [2, 3]] + * R.splitAt(5, 'hello world'); //=> ['hello', ' world'] + * R.splitAt(-1, 'foobar'); //=> ['fooba', 'r'] + */ + var splitAt = _curry2(function splitAt(index, array) { + return [slice(0, index, array), slice(index, length(array), array)]; }); -}); - -/** - * Iterate over an input `list`, calling a provided function `fn` for each - * element in the list. - * - * `fn` receives one argument: *(value)*. - * - * Note: `R.forEach` does not skip deleted or unassigned indices (sparse - * arrays), unlike the native `Array.prototype.forEach` method. For more - * details on this behavior, see: - * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/forEach#Description - * - * Also note that, unlike `Array.prototype.forEach`, Ramda's `forEach` returns - * the original array. In some libraries this function is named `each`. - * - * Dispatches to the `forEach` method of the second argument, if present. - * - * @func - * @memberOf R - * @since v0.1.1 - * @category List - * @sig (a -> *) -> [a] -> [a] - * @param {Function} fn The function to invoke. Receives one argument, `value`. - * @param {Array} list The list to iterate over. - * @return {Array} The original list. - * @see R.addIndex - * @example - * - * const printXPlusFive = x => console.log(x + 5); - * R.forEach(printXPlusFive, [1, 2, 3]); //=> [1, 2, 3] - * // logs 6 - * // logs 7 - * // logs 8 - * @symb R.forEach(f, [a, b, c]) = [a, b, c] - */ -var forEach = _curry2(_checkForMethod('forEach', function forEach(fn, list) { - var len = list.length; - var idx = 0; - while (idx < len) { - fn(list[idx]); - idx += 1; - } - return list; -})); -/** - * Iterate over an input `object`, calling a provided function `fn` for each - * key and value in the object. - * - * `fn` receives three argument: *(value, key, obj)*. - * - * @func - * @memberOf R - * @since v0.23.0 - * @category Object - * @sig ((a, String, StrMap a) -> Any) -> StrMap a -> StrMap a - * @param {Function} fn The function to invoke. Receives three argument, `value`, `key`, `obj`. - * @param {Object} obj The object to iterate over. - * @return {Object} The original object. - * @example - * - * const printKeyConcatValue = (value, key) => console.log(key + ':' + value); - * R.forEachObjIndexed(printKeyConcatValue, {x: 1, y: 2}); //=> {x: 1, y: 2} - * // logs x:1 - * // logs y:2 - * @symb R.forEachObjIndexed(f, {x: a, y: b}) = {x: a, y: b} - */ -var forEachObjIndexed = _curry2(function forEachObjIndexed(fn, obj) { - var keyList = keys(obj); - var idx = 0; - while (idx < keyList.length) { - var key = keyList[idx]; - fn(obj[key], key, obj); - idx += 1; - } - return obj; -}); - -/** - * Creates a new object from a list key-value pairs. If a key appears in - * multiple pairs, the rightmost pair is included in the object. - * - * @func - * @memberOf R - * @since v0.3.0 - * @category List - * @sig [[k,v]] -> {k: v} - * @param {Array} pairs An array of two-element arrays that will be the keys and values of the output object. - * @return {Object} The object made by pairing up `keys` and `values`. - * @see R.toPairs, R.pair - * @example - * - * R.fromPairs([['a', 1], ['b', 2], ['c', 3]]); //=> {a: 1, b: 2, c: 3} - */ -var fromPairs = _curry1(function fromPairs(pairs) { - var result = {}; - var idx = 0; - while (idx < pairs.length) { - result[pairs[idx][0]] = pairs[idx][1]; - idx += 1; - } - return result; -}); - -/** - * Splits a list into sub-lists stored in an object, based on the result of - * calling a String-returning function on each element, and grouping the - * results according to values returned. - * - * Dispatches to the `groupBy` method of the second argument, if present. - * - * Acts as a transducer if a transformer is given in list position. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category List - * @sig (a -> String) -> [a] -> {String: [a]} - * @param {Function} fn Function :: a -> String - * @param {Array} list The array to group - * @return {Object} An object with the output of `fn` for keys, mapped to arrays of elements - * that produced that key when passed to `fn`. - * @see R.reduceBy, R.transduce - * @example - * - * const byGrade = R.groupBy(function(student) { - * const score = student.score; - * return score < 65 ? 'F' : - * score < 70 ? 'D' : - * score < 80 ? 'C' : - * score < 90 ? 'B' : 'A'; - * }); - * const students = [{name: 'Abby', score: 84}, - * {name: 'Eddy', score: 58}, - * // ... - * {name: 'Jack', score: 69}]; - * byGrade(students); - * // { - * // 'A': [{name: 'Dianne', score: 99}], - * // 'B': [{name: 'Abby', score: 84}] - * // // ..., - * // 'F': [{name: 'Eddy', score: 58}] - * // } - */ -var groupBy = _curry2(_checkForMethod('groupBy', reduceBy(function(acc, item) { - if (acc == null) { - acc = []; - } - acc.push(item); - return acc; -}, null))); - -/** - * Takes a list and returns a list of lists where each sublist's elements are - * all satisfied pairwise comparison according to the provided function. - * Only adjacent elements are passed to the comparison function. - * - * @func - * @memberOf R - * @since v0.21.0 - * @category List - * @sig ((a, a) → Boolean) → [a] → [[a]] - * @param {Function} fn Function for determining whether two given (adjacent) - * elements should be in the same group - * @param {Array} list The array to group. Also accepts a string, which will be - * treated as a list of characters. - * @return {List} A list that contains sublists of elements, - * whose concatenations are equal to the original list. - * @example - * - * R.groupWith(R.equals, [0, 1, 1, 2, 3, 5, 8, 13, 21]) - * //=> [[0], [1, 1], [2], [3], [5], [8], [13], [21]] - * - * R.groupWith((a, b) => a + 1 === b, [0, 1, 1, 2, 3, 5, 8, 13, 21]) - * //=> [[0, 1], [1, 2, 3], [5], [8], [13], [21]] - * - * R.groupWith((a, b) => a % 2 === b % 2, [0, 1, 1, 2, 3, 5, 8, 13, 21]) - * //=> [[0], [1, 1], [2], [3, 5], [8], [13, 21]] - * - * R.groupWith(R.eqBy(isVowel), 'aestiou') - * //=> ['ae', 'st', 'iou'] - */ -var groupWith = _curry2(function(fn, list) { - var res = []; - var idx = 0; - var len = list.length; - while (idx < len) { - var nextidx = idx + 1; - while (nextidx < len && fn(list[nextidx - 1], list[nextidx])) { - nextidx += 1; - } - res.push(list.slice(idx, nextidx)); - idx = nextidx; - } - return res; -}); - -/** - * Returns `true` if the first argument is greater than the second; `false` - * otherwise. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Relation - * @sig Ord a => a -> a -> Boolean - * @param {*} a - * @param {*} b - * @return {Boolean} - * @see R.lt - * @example - * - * R.gt(2, 1); //=> true - * R.gt(2, 2); //=> false - * R.gt(2, 3); //=> false - * R.gt('a', 'z'); //=> false - * R.gt('z', 'a'); //=> true - */ -var gt = _curry2(function gt(a, b) { return a > b; }); - -/** - * Returns `true` if the first argument is greater than or equal to the second; - * `false` otherwise. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Relation - * @sig Ord a => a -> a -> Boolean - * @param {Number} a - * @param {Number} b - * @return {Boolean} - * @see R.lte - * @example - * - * R.gte(2, 1); //=> true - * R.gte(2, 2); //=> true - * R.gte(2, 3); //=> false - * R.gte('a', 'z'); //=> false - * R.gte('z', 'a'); //=> true - */ -var gte = _curry2(function gte(a, b) { return a >= b; }); - -/** - * Returns whether or not a path exists in an object. Only the object's - * own properties are checked. - * - * @func - * @memberOf R - * @since v0.26.0 - * @category Object - * @typedefn Idx = String | Int - * @sig [Idx] -> {a} -> Boolean - * @param {Array} path The path to use. - * @param {Object} obj The object to check the path in. - * @return {Boolean} Whether the path exists. - * @see R.has - * @example - * - * R.hasPath(['a', 'b'], {a: {b: 2}}); // => true - * R.hasPath(['a', 'b'], {a: {b: undefined}}); // => true - * R.hasPath(['a', 'b'], {a: {c: 2}}); // => false - * R.hasPath(['a', 'b'], {}); // => false - */ -var hasPath = _curry2(function hasPath(_path, obj) { - if (_path.length === 0) { - return false; - } - var val = obj; - var idx = 0; - while (idx < _path.length) { - if (_has(_path[idx], val)) { - val = val[_path[idx]]; - idx += 1; - } else { - return false; - } - } - return true; -}); - -/** - * Returns whether or not an object has an own property with the specified name - * - * @func - * @memberOf R - * @since v0.7.0 - * @category Object - * @sig s -> {s: x} -> Boolean - * @param {String} prop The name of the property to check for. - * @param {Object} obj The object to query. - * @return {Boolean} Whether the property exists. - * @example - * - * const hasName = R.has('name'); - * hasName({name: 'alice'}); //=> true - * hasName({name: 'bob'}); //=> true - * hasName({}); //=> false - * - * const point = {x: 0, y: 0}; - * const pointHas = R.has(R.__, point); - * pointHas('x'); //=> true - * pointHas('y'); //=> true - * pointHas('z'); //=> false - */ -var has = _curry2(function has(prop, obj) { - return hasPath([prop], obj); -}); - -/** - * Returns whether or not an object or its prototype chain has a property with - * the specified name - * - * @func - * @memberOf R - * @since v0.7.0 - * @category Object - * @sig s -> {s: x} -> Boolean - * @param {String} prop The name of the property to check for. - * @param {Object} obj The object to query. - * @return {Boolean} Whether the property exists. - * @example - * - * function Rectangle(width, height) { - * this.width = width; - * this.height = height; - * } - * Rectangle.prototype.area = function() { - * return this.width * this.height; - * }; - * - * const square = new Rectangle(2, 2); - * R.hasIn('width', square); //=> true - * R.hasIn('area', square); //=> true - */ -var hasIn = _curry2(function hasIn(prop, obj) { - return prop in obj; -}); - -/** - * Returns true if its arguments are identical, false otherwise. Values are - * identical if they reference the same memory. `NaN` is identical to `NaN`; - * `0` and `-0` are not identical. - * - * Note this is merely a curried version of ES6 `Object.is`. - * - * @func - * @memberOf R - * @since v0.15.0 - * @category Relation - * @sig a -> a -> Boolean - * @param {*} a - * @param {*} b - * @return {Boolean} - * @example - * - * const o = {}; - * R.identical(o, o); //=> true - * R.identical(1, 1); //=> true - * R.identical(1, '1'); //=> false - * R.identical([], []); //=> false - * R.identical(0, -0); //=> false - * R.identical(NaN, NaN); //=> true - */ -var identical = _curry2(_objectIs$1); - -/** - * Creates a function that will process either the `onTrue` or the `onFalse` - * function depending upon the result of the `condition` predicate. - * - * @func - * @memberOf R - * @since v0.8.0 - * @category Logic - * @sig (*... -> Boolean) -> (*... -> *) -> (*... -> *) -> (*... -> *) - * @param {Function} condition A predicate function - * @param {Function} onTrue A function to invoke when the `condition` evaluates to a truthy value. - * @param {Function} onFalse A function to invoke when the `condition` evaluates to a falsy value. - * @return {Function} A new function that will process either the `onTrue` or the `onFalse` - * function depending upon the result of the `condition` predicate. - * @see R.unless, R.when, R.cond - * @example - * - * const incCount = R.ifElse( - * R.has('count'), - * R.over(R.lensProp('count'), R.inc), - * R.assoc('count', 1) - * ); - * incCount({}); //=> { count: 1 } - * incCount({ count: 1 }); //=> { count: 2 } - */ -var ifElse = _curry3(function ifElse(condition, onTrue, onFalse) { - return curryN(Math.max(condition.length, onTrue.length, onFalse.length), - function _ifElse() { - return condition.apply(this, arguments) ? onTrue.apply(this, arguments) : onFalse.apply(this, arguments); + /** + * Splits a collection into slices of the specified length. + * + * @func + * @memberOf R + * @since v0.16.0 + * @category List + * @sig Number -> [a] -> [[a]] + * @sig Number -> String -> [String] + * @param {Number} n + * @param {Array} list + * @return {Array} + * @example + * + * R.splitEvery(3, [1, 2, 3, 4, 5, 6, 7]); //=> [[1, 2, 3], [4, 5, 6], [7]] + * R.splitEvery(3, 'foobarbaz'); //=> ['foo', 'bar', 'baz'] + */ + var splitEvery = _curry2(function splitEvery(n, list) { + if (n <= 0) { + throw new Error('First argument to splitEvery must be a positive integer'); } - ); -}); - -/** - * Increments its argument. - * - * @func - * @memberOf R - * @since v0.9.0 - * @category Math - * @sig Number -> Number - * @param {Number} n - * @return {Number} n + 1 - * @see R.dec - * @example - * - * R.inc(42); //=> 43 - */ -var inc = add(1); - -/** - * Returns `true` if the specified value is equal, in [`R.equals`](#equals) - * terms, to at least one element of the given list; `false` otherwise. - * Works also with strings. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category List - * @sig a -> [a] -> Boolean - * @param {Object} a The item to compare against. - * @param {Array} list The array to consider. - * @return {Boolean} `true` if an equivalent item is in the list, `false` otherwise. - * @see R.any - * @example - * - * R.includes(3, [1, 2, 3]); //=> true - * R.includes(4, [1, 2, 3]); //=> false - * R.includes({ name: 'Fred' }, [{ name: 'Fred' }]); //=> true - * R.includes([42], [[42]]); //=> true - * R.includes('ba', 'banana'); //=>true - */ -var includes = _curry2(_includes); - -/** - * Given a function that generates a key, turns a list of objects into an - * object indexing the objects by the given key. Note that if multiple - * objects generate the same value for the indexing key only the last value - * will be included in the generated object. - * - * Acts as a transducer if a transformer is given in list position. - * - * @func - * @memberOf R - * @since v0.19.0 - * @category List - * @sig (a -> String) -> [{k: v}] -> {k: {k: v}} - * @param {Function} fn Function :: a -> String - * @param {Array} array The array of objects to index - * @return {Object} An object indexing each array element by the given property. - * @example - * - * const list = [{id: 'xyz', title: 'A'}, {id: 'abc', title: 'B'}]; - * R.indexBy(R.prop('id'), list); - * //=> {abc: {id: 'abc', title: 'B'}, xyz: {id: 'xyz', title: 'A'}} - */ -var indexBy = reduceBy(function(acc, elem) { return elem; }, null); - -/** - * Returns the position of the first occurrence of an item in an array, or -1 - * if the item is not included in the array. [`R.equals`](#equals) is used to - * determine equality. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category List - * @sig a -> [a] -> Number - * @param {*} target The item to find. - * @param {Array} xs The array to search in. - * @return {Number} the index of the target, or -1 if the target is not found. - * @see R.lastIndexOf - * @example - * - * R.indexOf(3, [1,2,3,4]); //=> 2 - * R.indexOf(10, [1,2,3,4]); //=> -1 - */ -var indexOf = _curry2(function indexOf(target, xs) { - return typeof xs.indexOf === 'function' && !_isArray(xs) ? - xs.indexOf(target) : - _indexOf(xs, target, 0); -}); - -/** - * Returns all but the last element of the given list or string. - * - * @func - * @memberOf R - * @since v0.9.0 - * @category List - * @sig [a] -> [a] - * @sig String -> String - * @param {*} list - * @return {*} - * @see R.last, R.head, R.tail - * @example - * - * R.init([1, 2, 3]); //=> [1, 2] - * R.init([1, 2]); //=> [1] - * R.init([1]); //=> [] - * R.init([]); //=> [] - * - * R.init('abc'); //=> 'ab' - * R.init('ab'); //=> 'a' - * R.init('a'); //=> '' - * R.init(''); //=> '' - */ -var init = slice(0, -1); - -/** - * Takes a predicate `pred`, a list `xs`, and a list `ys`, and returns a list - * `xs'` comprising each of the elements of `xs` which is equal to one or more - * elements of `ys` according to `pred`. - * - * `pred` must be a binary function expecting an element from each list. - * - * `xs`, `ys`, and `xs'` are treated as sets, semantically, so ordering should - * not be significant, but since `xs'` is ordered the implementation guarantees - * that its values are in the same order as they appear in `xs`. Duplicates are - * not removed, so `xs'` may contain duplicates if `xs` contains duplicates. - * - * @func - * @memberOf R - * @since v0.24.0 - * @category Relation - * @sig ((a, b) -> Boolean) -> [a] -> [b] -> [a] - * @param {Function} pred - * @param {Array} xs - * @param {Array} ys - * @return {Array} - * @see R.intersection - * @example - * - * R.innerJoin( - * (record, id) => record.id === id, - * [{id: 824, name: 'Richie Furay'}, - * {id: 956, name: 'Dewey Martin'}, - * {id: 313, name: 'Bruce Palmer'}, - * {id: 456, name: 'Stephen Stills'}, - * {id: 177, name: 'Neil Young'}], - * [177, 456, 999] - * ); - * //=> [{id: 456, name: 'Stephen Stills'}, {id: 177, name: 'Neil Young'}] - */ -var innerJoin = _curry3(function innerJoin(pred, xs, ys) { - return _filter(function(x) { return _includesWith(pred, x, ys); }, xs); -}); - -/** - * Inserts the supplied element into the list, at the specified `index`. _Note that - - * this is not destructive_: it returns a copy of the list with the changes. - * No lists have been harmed in the application of this function. - * - * @func - * @memberOf R - * @since v0.2.2 - * @category List - * @sig Number -> a -> [a] -> [a] - * @param {Number} index The position to insert the element - * @param {*} elt The element to insert into the Array - * @param {Array} list The list to insert into - * @return {Array} A new Array with `elt` inserted at `index`. - * @example - * - * R.insert(2, 'x', [1,2,3,4]); //=> [1,2,'x',3,4] - */ -var insert = _curry3(function insert(idx, elt, list) { - idx = idx < list.length && idx >= 0 ? idx : list.length; - var result = Array.prototype.slice.call(list, 0); - result.splice(idx, 0, elt); - return result; -}); - -/** - * Inserts the sub-list into the list, at the specified `index`. _Note that this is not - * destructive_: it returns a copy of the list with the changes. - * No lists have been harmed in the application of this function. - * - * @func - * @memberOf R - * @since v0.9.0 - * @category List - * @sig Number -> [a] -> [a] -> [a] - * @param {Number} index The position to insert the sub-list - * @param {Array} elts The sub-list to insert into the Array - * @param {Array} list The list to insert the sub-list into - * @return {Array} A new Array with `elts` inserted starting at `index`. - * @example - * - * R.insertAll(2, ['x','y','z'], [1,2,3,4]); //=> [1,2,'x','y','z',3,4] - */ -var insertAll = _curry3(function insertAll(idx, elts, list) { - idx = idx < list.length && idx >= 0 ? idx : list.length; - return [].concat(Array.prototype.slice.call(list, 0, idx), - elts, - Array.prototype.slice.call(list, idx)); -}); - -/** - * Returns a new list containing only one copy of each element in the original - * list, based upon the value returned by applying the supplied function to - * each list element. Prefers the first item if the supplied function produces - * the same value on two items. [`R.equals`](#equals) is used for comparison. - * - * @func - * @memberOf R - * @since v0.16.0 - * @category List - * @sig (a -> b) -> [a] -> [a] - * @param {Function} fn A function used to produce a value to use during comparisons. - * @param {Array} list The array to consider. - * @return {Array} The list of unique items. - * @example - * - * R.uniqBy(Math.abs, [-1, -5, 2, 10, 1, 2]); //=> [-1, -5, 2, 10] - */ -var uniqBy = _curry2(function uniqBy(fn, list) { - var set = new _Set(); - var result = []; - var idx = 0; - var appliedItem, item; - - while (idx < list.length) { - item = list[idx]; - appliedItem = fn(item); - if (set.add(appliedItem)) { - result.push(item); - } - idx += 1; - } - return result; -}); - -/** - * Returns a new list containing only one copy of each element in the original - * list. [`R.equals`](#equals) is used to determine equality. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category List - * @sig [a] -> [a] - * @param {Array} list The array to consider. - * @return {Array} The list of unique items. - * @example - * - * R.uniq([1, 1, 2, 1]); //=> [1, 2] - * R.uniq([1, '1']); //=> [1, '1'] - * R.uniq([[42], [42]]); //=> [[42]] - */ -var uniq = uniqBy(identity); - -/** - * Combines two lists into a set (i.e. no duplicates) composed of those - * elements common to both lists. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Relation - * @sig [*] -> [*] -> [*] - * @param {Array} list1 The first list. - * @param {Array} list2 The second list. - * @return {Array} The list of elements found in both `list1` and `list2`. - * @see R.innerJoin - * @example - * - * R.intersection([1,2,3,4], [7,6,5,4,3]); //=> [4, 3] - */ -var intersection = _curry2(function intersection(list1, list2) { - var lookupList, filteredList; - if (list1.length > list2.length) { - lookupList = list1; - filteredList = list2; - } else { - lookupList = list2; - filteredList = list1; - } - return uniq(_filter(flip(_includes)(lookupList), filteredList)); -}); - -/** - * Creates a new list with the separator interposed between elements. - * - * Dispatches to the `intersperse` method of the second argument, if present. - * - * @func - * @memberOf R - * @since v0.14.0 - * @category List - * @sig a -> [a] -> [a] - * @param {*} separator The element to add to the list. - * @param {Array} list The list to be interposed. - * @return {Array} The new list. - * @example - * - * R.intersperse('a', ['b', 'n', 'n', 's']); //=> ['b', 'a', 'n', 'a', 'n', 'a', 's'] - */ -var intersperse = _curry2(_checkForMethod('intersperse', function intersperse(separator, list) { - var out = []; - var idx = 0; - var length = list.length; - while (idx < length) { - if (idx === length - 1) { - out.push(list[idx]); - } else { - out.push(list[idx], separator); + var result = []; + var idx = 0; + while (idx < list.length) { + result.push(slice(idx, idx += n, list)); } - idx += 1; - } - return out; -})); + return result; + }); -// Based on https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/assign -function _objectAssign(target) { - if (target == null) { - throw new TypeError('Cannot convert undefined or null to object'); - } + /** + * Takes a list and a predicate and returns a pair of lists with the following properties: + * + * - the result of concatenating the two output lists is equivalent to the input list; + * - none of the elements of the first output list satisfies the predicate; and + * - if the second output list is non-empty, its first element satisfies the predicate. + * + * @func + * @memberOf R + * @since v0.19.0 + * @category List + * @sig (a -> Boolean) -> [a] -> [[a], [a]] + * @param {Function} pred The predicate that determines where the array is split. + * @param {Array} list The array to be split. + * @return {Array} + * @example + * + * R.splitWhen(R.equals(2), [1, 2, 3, 1, 2, 3]); //=> [[1], [2, 3, 1, 2, 3]] + */ + var splitWhen = _curry2(function splitWhen(pred, list) { + var idx = 0; + var len = list.length; + var prefix = []; - var output = Object(target); - var idx = 1; - var length = arguments.length; - while (idx < length) { - var source = arguments[idx]; - if (source != null) { - for (var nextKey in source) { - if (_has(nextKey, source)) { - output[nextKey] = source[nextKey]; - } - } + while (idx < len && !pred(list[idx])) { + prefix.push(list[idx]); + idx += 1; } - idx += 1; - } - return output; -} - -var _objectAssign$1 = typeof Object.assign === 'function' ? Object.assign : _objectAssign; - -/** - * Creates an object containing a single key:value pair. - * - * @func - * @memberOf R - * @since v0.18.0 - * @category Object - * @sig String -> a -> {String:a} - * @param {String} key - * @param {*} val - * @return {Object} - * @see R.pair - * @example - * - * const matchPhrases = R.compose( - * R.objOf('must'), - * R.map(R.objOf('match_phrase')) - * ); - * matchPhrases(['foo', 'bar', 'baz']); //=> {must: [{match_phrase: 'foo'}, {match_phrase: 'bar'}, {match_phrase: 'baz'}]} - */ -var objOf = _curry2(function objOf(key, val) { - var obj = {}; - obj[key] = val; - return obj; -}); - -var _stepCatArray = { - '@@transducer/init': Array, - '@@transducer/step': function(xs, x) { - xs.push(x); - return xs; - }, - '@@transducer/result': _identity -}; -var _stepCatString = { - '@@transducer/init': String, - '@@transducer/step': function(a, b) { return a + b; }, - '@@transducer/result': _identity -}; -var _stepCatObject = { - '@@transducer/init': Object, - '@@transducer/step': function(result, input) { - return _objectAssign$1( - result, - _isArrayLike(input) ? objOf(input[0], input[1]) : input - ); - }, - '@@transducer/result': _identity -}; -function _stepCat(obj) { - if (_isTransformer(obj)) { - return obj; - } - if (_isArrayLike(obj)) { - return _stepCatArray; - } - if (typeof obj === 'string') { - return _stepCatString; - } - if (typeof obj === 'object') { - return _stepCatObject; - } - throw new Error('Cannot create transformer for ' + obj); -} - -/** - * Transforms the items of the list with the transducer and appends the - * transformed items to the accumulator using an appropriate iterator function - * based on the accumulator type. - * - * The accumulator can be an array, string, object or a transformer. Iterated - * items will be appended to arrays and concatenated to strings. Objects will - * be merged directly or 2-item arrays will be merged as key, value pairs. - * - * The accumulator can also be a transformer object that provides a 2-arity - * reducing iterator function, step, 0-arity initial value function, init, and - * 1-arity result extraction function result. The step function is used as the - * iterator function in reduce. The result function is used to convert the - * final accumulator into the return type and in most cases is R.identity. The - * init function is used to provide the initial accumulator. - * - * The iteration is performed with [`R.reduce`](#reduce) after initializing the - * transducer. - * - * @func - * @memberOf R - * @since v0.12.0 - * @category List - * @sig a -> (b -> b) -> [c] -> a - * @param {*} acc The initial accumulator value. - * @param {Function} xf The transducer function. Receives a transformer and returns a transformer. - * @param {Array} list The list to iterate over. - * @return {*} The final, accumulated value. - * @see R.transduce - * @example - * - * const numbers = [1, 2, 3, 4]; - * const transducer = R.compose(R.map(R.add(1)), R.take(2)); - * - * R.into([], transducer, numbers); //=> [2, 3] - * - * const intoArray = R.into([]); - * intoArray(transducer, numbers); //=> [2, 3] - */ -var into = _curry3(function into(acc, xf, list) { - return _isTransformer(acc) ? - _reduce(xf(acc), acc['@@transducer/init'](), list) : - _reduce(xf(_stepCat(acc)), _clone(acc, [], [], false), list); -}); - -/** - * Same as [`R.invertObj`](#invertObj), however this accounts for objects with - * duplicate values by putting the values into an array. - * - * @func - * @memberOf R - * @since v0.9.0 - * @category Object - * @sig {s: x} -> {x: [ s, ... ]} - * @param {Object} obj The object or array to invert - * @return {Object} out A new object with keys in an array. - * @see R.invertObj - * @example - * - * const raceResultsByFirstName = { - * first: 'alice', - * second: 'jake', - * third: 'alice', - * }; - * R.invert(raceResultsByFirstName); - * //=> { 'alice': ['first', 'third'], 'jake':['second'] } - */ -var invert = _curry1(function invert(obj) { - var props = keys(obj); - var len = props.length; - var idx = 0; - var out = {}; - - while (idx < len) { - var key = props[idx]; - var val = obj[key]; - var list = _has(val, out) ? out[val] : (out[val] = []); - list[list.length] = key; - idx += 1; - } - return out; -}); - -/** - * Returns a new object with the keys of the given object as values, and the - * values of the given object, which are coerced to strings, as keys. Note - * that the last key found is preferred when handling the same value. - * - * @func - * @memberOf R - * @since v0.9.0 - * @category Object - * @sig {s: x} -> {x: s} - * @param {Object} obj The object or array to invert - * @return {Object} out A new object - * @see R.invert - * @example - * - * const raceResults = { - * first: 'alice', - * second: 'jake' - * }; - * R.invertObj(raceResults); - * //=> { 'alice': 'first', 'jake':'second' } - * - * // Alternatively: - * const raceResults = ['alice', 'jake']; - * R.invertObj(raceResults); - * //=> { 'alice': '0', 'jake':'1' } - */ -var invertObj = _curry1(function invertObj(obj) { - var props = keys(obj); - var len = props.length; - var idx = 0; - var out = {}; - - while (idx < len) { - var key = props[idx]; - out[obj[key]] = key; - idx += 1; - } - return out; -}); - -/** - * Turns a named method with a specified arity into a function that can be - * called directly supplied with arguments and a target object. - * - * The returned function is curried and accepts `arity + 1` parameters where - * the final parameter is the target object. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Function - * @sig Number -> String -> (a -> b -> ... -> n -> Object -> *) - * @param {Number} arity Number of arguments the returned function should take - * before the target object. - * @param {String} method Name of the method to call. - * @return {Function} A new curried function. - * @see R.construct - * @example - * - * const sliceFrom = R.invoker(1, 'slice'); - * sliceFrom(6, 'abcdefghijklm'); //=> 'ghijklm' - * const sliceFrom6 = R.invoker(2, 'slice')(6); - * sliceFrom6(8, 'abcdefghijklm'); //=> 'gh' - * @symb R.invoker(0, 'method')(o) = o['method']() - * @symb R.invoker(1, 'method')(a, o) = o['method'](a) - * @symb R.invoker(2, 'method')(a, b, o) = o['method'](a, b) - */ -var invoker = _curry2(function invoker(arity, method) { - return curryN(arity + 1, function() { - var target = arguments[arity]; - if (target != null && _isFunction(target[method])) { - return target[method].apply(target, Array.prototype.slice.call(arguments, 0, arity)); - } - throw new TypeError(toString$1(target) + ' does not have a method named "' + method + '"'); - }); -}); - -/** - * See if an object (`val`) is an instance of the supplied constructor. This - * function will check up the inheritance chain, if any. - * - * @func - * @memberOf R - * @since v0.3.0 - * @category Type - * @sig (* -> {*}) -> a -> Boolean - * @param {Object} ctor A constructor - * @param {*} val The value to test - * @return {Boolean} - * @example - * - * R.is(Object, {}); //=> true - * R.is(Number, 1); //=> true - * R.is(Object, 1); //=> false - * R.is(String, 's'); //=> true - * R.is(String, new String('')); //=> true - * R.is(Object, new String('')); //=> true - * R.is(Object, 's'); //=> false - * R.is(Number, {}); //=> false - */ -var is = _curry2(function is(Ctor, val) { - return val != null && val.constructor === Ctor || val instanceof Ctor; -}); - -/** - * Returns `true` if the given value is its type's empty value; `false` - * otherwise. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Logic - * @sig a -> Boolean - * @param {*} x - * @return {Boolean} - * @see R.empty - * @example - * - * R.isEmpty([1, 2, 3]); //=> false - * R.isEmpty([]); //=> true - * R.isEmpty(''); //=> true - * R.isEmpty(null); //=> false - * R.isEmpty({}); //=> true - * R.isEmpty({length: 0}); //=> false - */ -var isEmpty = _curry1(function isEmpty(x) { - return x != null && equals(x, empty(x)); -}); - -/** - * Returns a string made by inserting the `separator` between each element and - * concatenating all the elements into a single string. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category List - * @sig String -> [a] -> String - * @param {Number|String} separator The string used to separate the elements. - * @param {Array} xs The elements to join into a string. - * @return {String} str The string made by concatenating `xs` with `separator`. - * @see R.split - * @example - * - * const spacer = R.join(' '); - * spacer(['a', 2, 3.4]); //=> 'a 2 3.4' - * R.join('|', [1, 2, 3]); //=> '1|2|3' - */ -var join = invoker(1, 'join'); - -/** - * juxt applies a list of functions to a list of values. - * - * @func - * @memberOf R - * @since v0.19.0 - * @category Function - * @sig [(a, b, ..., m) -> n] -> ((a, b, ..., m) -> [n]) - * @param {Array} fns An array of functions - * @return {Function} A function that returns a list of values after applying each of the original `fns` to its parameters. - * @see R.applySpec - * @example - * - * const getRange = R.juxt([Math.min, Math.max]); - * getRange(3, 4, 9, -3); //=> [-3, 9] - * @symb R.juxt([f, g, h])(a, b) = [f(a, b), g(a, b), h(a, b)] - */ -var juxt = _curry1(function juxt(fns) { - return converge(function() { return Array.prototype.slice.call(arguments, 0); }, fns); -}); - -/** - * Returns a list containing the names of all the properties of the supplied - * object, including prototype properties. - * Note that the order of the output array is not guaranteed to be consistent - * across different JS platforms. - * - * @func - * @memberOf R - * @since v0.2.0 - * @category Object - * @sig {k: v} -> [k] - * @param {Object} obj The object to extract properties from - * @return {Array} An array of the object's own and prototype properties. - * @see R.keys, R.valuesIn - * @example - * - * const F = function() { this.x = 'X'; }; - * F.prototype.y = 'Y'; - * const f = new F(); - * R.keysIn(f); //=> ['x', 'y'] - */ -var keysIn = _curry1(function keysIn(obj) { - var prop; - var ks = []; - for (prop in obj) { - ks[ks.length] = prop; - } - return ks; -}); - -/** - * Returns the position of the last occurrence of an item in an array, or -1 if - * the item is not included in the array. [`R.equals`](#equals) is used to - * determine equality. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category List - * @sig a -> [a] -> Number - * @param {*} target The item to find. - * @param {Array} xs The array to search in. - * @return {Number} the index of the target, or -1 if the target is not found. - * @see R.indexOf - * @example - * - * R.lastIndexOf(3, [-1,3,3,0,1,2,3,4]); //=> 6 - * R.lastIndexOf(10, [1,2,3,4]); //=> -1 - */ -var lastIndexOf = _curry2(function lastIndexOf(target, xs) { - if (typeof xs.lastIndexOf === 'function' && !_isArray(xs)) { - return xs.lastIndexOf(target); - } else { + return [prefix, Array.prototype.slice.call(list, idx)]; + }); + + /** + * Checks if a list starts with the provided sublist. + * + * Similarly, checks if a string starts with the provided substring. + * + * @func + * @memberOf R + * @since v0.24.0 + * @category List + * @sig [a] -> [a] -> Boolean + * @sig String -> String -> Boolean + * @param {*} prefix + * @param {*} list + * @return {Boolean} + * @see R.endsWith + * @example + * + * R.startsWith('a', 'abc') //=> true + * R.startsWith('b', 'abc') //=> false + * R.startsWith(['a'], ['a', 'b', 'c']) //=> true + * R.startsWith(['b'], ['a', 'b', 'c']) //=> false + */ + var startsWith = _curry2(function(prefix, list) { + return equals(take(prefix.length, list), prefix); + }); + + /** + * Subtracts its second argument from its first argument. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Math + * @sig Number -> Number -> Number + * @param {Number} a The first value. + * @param {Number} b The second value. + * @return {Number} The result of `a - b`. + * @see R.add + * @example + * + * R.subtract(10, 8); //=> 2 + * + * const minus5 = R.subtract(R.__, 5); + * minus5(17); //=> 12 + * + * const complementaryAngle = R.subtract(90); + * complementaryAngle(30); //=> 60 + * complementaryAngle(72); //=> 18 + */ + var subtract = _curry2(function subtract(a, b) { + return Number(a) - Number(b); + }); + + /** + * Finds the set (i.e. no duplicates) of all elements contained in the first or + * second list, but not both. + * + * @func + * @memberOf R + * @since v0.19.0 + * @category Relation + * @sig [*] -> [*] -> [*] + * @param {Array} list1 The first list. + * @param {Array} list2 The second list. + * @return {Array} The elements in `list1` or `list2`, but not both. + * @see R.symmetricDifferenceWith, R.difference, R.differenceWith + * @example + * + * R.symmetricDifference([1,2,3,4], [7,6,5,4,3]); //=> [1,2,7,6,5] + * R.symmetricDifference([7,6,5,4,3], [1,2,3,4]); //=> [7,6,5,1,2] + */ + var symmetricDifference = _curry2(function symmetricDifference(list1, list2) { + return concat(difference(list1, list2), difference(list2, list1)); + }); + + /** + * Finds the set (i.e. no duplicates) of all elements contained in the first or + * second list, but not both. Duplication is determined according to the value + * returned by applying the supplied predicate to two list elements. + * + * @func + * @memberOf R + * @since v0.19.0 + * @category Relation + * @sig ((a, a) -> Boolean) -> [a] -> [a] -> [a] + * @param {Function} pred A predicate used to test whether two items are equal. + * @param {Array} list1 The first list. + * @param {Array} list2 The second list. + * @return {Array} The elements in `list1` or `list2`, but not both. + * @see R.symmetricDifference, R.difference, R.differenceWith + * @example + * + * const eqA = R.eqBy(R.prop('a')); + * const l1 = [{a: 1}, {a: 2}, {a: 3}, {a: 4}]; + * const l2 = [{a: 3}, {a: 4}, {a: 5}, {a: 6}]; + * R.symmetricDifferenceWith(eqA, l1, l2); //=> [{a: 1}, {a: 2}, {a: 5}, {a: 6}] + */ + var symmetricDifferenceWith = _curry3(function symmetricDifferenceWith(pred, list1, list2) { + return concat(differenceWith(pred, list1, list2), differenceWith(pred, list2, list1)); + }); + + /** + * Returns a new list containing the last `n` elements of a given list, passing + * each value to the supplied predicate function, and terminating when the + * predicate function returns `false`. Excludes the element that caused the + * predicate function to fail. The predicate function is passed one argument: + * *(value)*. + * + * @func + * @memberOf R + * @since v0.16.0 + * @category List + * @sig (a -> Boolean) -> [a] -> [a] + * @sig (a -> Boolean) -> String -> String + * @param {Function} fn The function called per iteration. + * @param {Array} xs The collection to iterate over. + * @return {Array} A new array. + * @see R.dropLastWhile, R.addIndex + * @example + * + * const isNotOne = x => x !== 1; + * + * R.takeLastWhile(isNotOne, [1, 2, 3, 4]); //=> [2, 3, 4] + * + * R.takeLastWhile(x => x !== 'R' , 'Ramda'); //=> 'amda' + */ + var takeLastWhile = _curry2(function takeLastWhile(fn, xs) { var idx = xs.length - 1; - while (idx >= 0) { - if (equals(xs[idx], target)) { - return idx; - } + while (idx >= 0 && fn(xs[idx])) { idx -= 1; } - return -1; + return slice(idx + 1, Infinity, xs); + }); + + function XTakeWhile(f, xf) { + this.xf = xf; + this.f = f; } -}); - -function _isNumber(x) { - return Object.prototype.toString.call(x) === '[object Number]'; -} - -/** - * Returns the number of elements in the array by returning `list.length`. - * - * @func - * @memberOf R - * @since v0.3.0 - * @category List - * @sig [a] -> Number - * @param {Array} list The array to inspect. - * @return {Number} The length of the array. - * @example - * - * R.length([]); //=> 0 - * R.length([1, 2, 3]); //=> 3 - */ -var length = _curry1(function length(list) { - return list != null && _isNumber(list.length) ? list.length : NaN; -}); - -/** - * Returns a lens for the given getter and setter functions. The getter "gets" - * the value of the focus; the setter "sets" the value of the focus. The setter - * should not mutate the data structure. - * - * @func - * @memberOf R - * @since v0.8.0 - * @category Object - * @typedefn Lens s a = Functor f => (a -> f a) -> s -> f s - * @sig (s -> a) -> ((a, s) -> s) -> Lens s a - * @param {Function} getter - * @param {Function} setter - * @return {Lens} - * @see R.view, R.set, R.over, R.lensIndex, R.lensProp - * @example - * - * const xLens = R.lens(R.prop('x'), R.assoc('x')); - * - * R.view(xLens, {x: 1, y: 2}); //=> 1 - * R.set(xLens, 4, {x: 1, y: 2}); //=> {x: 4, y: 2} - * R.over(xLens, R.negate, {x: 1, y: 2}); //=> {x: -1, y: 2} - */ -var lens = _curry2(function lens(getter, setter) { - return function(toFunctorFn) { - return function(target) { - return map( - function(focus) { - return setter(focus, target); - }, - toFunctorFn(getter(target)) - ); - }; + XTakeWhile.prototype['@@transducer/init'] = _xfBase.init; + XTakeWhile.prototype['@@transducer/result'] = _xfBase.result; + XTakeWhile.prototype['@@transducer/step'] = function(result, input) { + return this.f(input) ? this.xf['@@transducer/step'](result, input) : _reduced(result); }; -}); - -/** - * Returns a lens whose focus is the specified index. - * - * @func - * @memberOf R - * @since v0.14.0 - * @category Object - * @typedefn Lens s a = Functor f => (a -> f a) -> s -> f s - * @sig Number -> Lens s a - * @param {Number} n - * @return {Lens} - * @see R.view, R.set, R.over - * @example - * - * const headLens = R.lensIndex(0); - * - * R.view(headLens, ['a', 'b', 'c']); //=> 'a' - * R.set(headLens, 'x', ['a', 'b', 'c']); //=> ['x', 'b', 'c'] - * R.over(headLens, R.toUpper, ['a', 'b', 'c']); //=> ['A', 'b', 'c'] - */ -var lensIndex = _curry1(function lensIndex(n) { - return lens(nth(n), update(n)); -}); - -/** - * Returns a lens whose focus is the specified path. - * - * @func - * @memberOf R - * @since v0.19.0 - * @category Object - * @typedefn Idx = String | Int - * @typedefn Lens s a = Functor f => (a -> f a) -> s -> f s - * @sig [Idx] -> Lens s a - * @param {Array} path The path to use. - * @return {Lens} - * @see R.view, R.set, R.over - * @example - * - * const xHeadYLens = R.lensPath(['x', 0, 'y']); - * - * R.view(xHeadYLens, {x: [{y: 2, z: 3}, {y: 4, z: 5}]}); - * //=> 2 - * R.set(xHeadYLens, 1, {x: [{y: 2, z: 3}, {y: 4, z: 5}]}); - * //=> {x: [{y: 1, z: 3}, {y: 4, z: 5}]} - * R.over(xHeadYLens, R.negate, {x: [{y: 2, z: 3}, {y: 4, z: 5}]}); - * //=> {x: [{y: -2, z: 3}, {y: 4, z: 5}]} - */ -var lensPath = _curry1(function lensPath(p) { - return lens(path(p), assocPath(p)); -}); - -/** - * Returns a lens whose focus is the specified property. - * - * @func - * @memberOf R - * @since v0.14.0 - * @category Object - * @typedefn Lens s a = Functor f => (a -> f a) -> s -> f s - * @sig String -> Lens s a - * @param {String} k - * @return {Lens} - * @see R.view, R.set, R.over - * @example - * - * const xLens = R.lensProp('x'); - * - * R.view(xLens, {x: 1, y: 2}); //=> 1 - * R.set(xLens, 4, {x: 1, y: 2}); //=> {x: 4, y: 2} - * R.over(xLens, R.negate, {x: 1, y: 2}); //=> {x: -1, y: 2} - */ -var lensProp = _curry1(function lensProp(k) { - return lens(prop(k), assoc(k)); -}); - -/** - * Returns `true` if the first argument is less than the second; `false` - * otherwise. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Relation - * @sig Ord a => a -> a -> Boolean - * @param {*} a - * @param {*} b - * @return {Boolean} - * @see R.gt - * @example - * - * R.lt(2, 1); //=> false - * R.lt(2, 2); //=> false - * R.lt(2, 3); //=> true - * R.lt('a', 'z'); //=> true - * R.lt('z', 'a'); //=> false - */ -var lt = _curry2(function lt(a, b) { return a < b; }); - -/** - * Returns `true` if the first argument is less than or equal to the second; - * `false` otherwise. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Relation - * @sig Ord a => a -> a -> Boolean - * @param {Number} a - * @param {Number} b - * @return {Boolean} - * @see R.gte - * @example - * - * R.lte(2, 1); //=> false - * R.lte(2, 2); //=> true - * R.lte(2, 3); //=> true - * R.lte('a', 'z'); //=> true - * R.lte('z', 'a'); //=> false - */ -var lte = _curry2(function lte(a, b) { return a <= b; }); - -/** - * The `mapAccum` function behaves like a combination of map and reduce; it - * applies a function to each element of a list, passing an accumulating - * parameter from left to right, and returning a final value of this - * accumulator together with the new list. - * - * The iterator function receives two arguments, *acc* and *value*, and should - * return a tuple *[acc, value]*. - * - * @func - * @memberOf R - * @since v0.10.0 - * @category List - * @sig ((acc, x) -> (acc, y)) -> acc -> [x] -> (acc, [y]) - * @param {Function} fn The function to be called on every element of the input `list`. - * @param {*} acc The accumulator value. - * @param {Array} list The list to iterate over. - * @return {*} The final, accumulated value. - * @see R.scan, R.addIndex, R.mapAccumRight - * @example - * - * const digits = ['1', '2', '3', '4']; - * const appender = (a, b) => [a + b, a + b]; - * - * R.mapAccum(appender, 0, digits); //=> ['01234', ['01', '012', '0123', '01234']] - * @symb R.mapAccum(f, a, [b, c, d]) = [ - * f(f(f(a, b)[0], c)[0], d)[0], - * [ - * f(a, b)[1], - * f(f(a, b)[0], c)[1], - * f(f(f(a, b)[0], c)[0], d)[1] - * ] - * ] - */ -var mapAccum = _curry3(function mapAccum(fn, acc, list) { - var idx = 0; - var len = list.length; - var result = []; - var tuple = [acc]; - while (idx < len) { - tuple = fn(tuple[0], list[idx]); - result[idx] = tuple[1]; - idx += 1; - } - return [tuple[0], result]; -}); - -/** - * The `mapAccumRight` function behaves like a combination of map and reduce; it - * applies a function to each element of a list, passing an accumulating - * parameter from right to left, and returning a final value of this - * accumulator together with the new list. - * - * Similar to [`mapAccum`](#mapAccum), except moves through the input list from - * the right to the left. - * - * The iterator function receives two arguments, *acc* and *value*, and should - * return a tuple *[acc, value]*. - * - * @func - * @memberOf R - * @since v0.10.0 - * @category List - * @sig ((acc, x) -> (acc, y)) -> acc -> [x] -> (acc, [y]) - * @param {Function} fn The function to be called on every element of the input `list`. - * @param {*} acc The accumulator value. - * @param {Array} list The list to iterate over. - * @return {*} The final, accumulated value. - * @see R.addIndex, R.mapAccum - * @example - * - * const digits = ['1', '2', '3', '4']; - * const appender = (a, b) => [b + a, b + a]; - * - * R.mapAccumRight(appender, 5, digits); //=> ['12345', ['12345', '2345', '345', '45']] - * @symb R.mapAccumRight(f, a, [b, c, d]) = [ - * f(f(f(a, d)[0], c)[0], b)[0], - * [ - * f(a, d)[1], - * f(f(a, d)[0], c)[1], - * f(f(f(a, d)[0], c)[0], b)[1] - * ] - * ] - */ -var mapAccumRight = _curry3(function mapAccumRight(fn, acc, list) { - var idx = list.length - 1; - var result = []; - var tuple = [acc]; - while (idx >= 0) { - tuple = fn(tuple[0], list[idx]); - result[idx] = tuple[1]; - idx -= 1; - } - return [tuple[0], result]; -}); - -/** - * An Object-specific version of [`map`](#map). The function is applied to three - * arguments: *(value, key, obj)*. If only the value is significant, use - * [`map`](#map) instead. - * - * @func - * @memberOf R - * @since v0.9.0 - * @category Object - * @sig ((*, String, Object) -> *) -> Object -> Object - * @param {Function} fn - * @param {Object} obj - * @return {Object} - * @see R.map - * @example - * - * const xyz = { x: 1, y: 2, z: 3 }; - * const prependKeyAndDouble = (num, key, obj) => key + (num * 2); - * - * R.mapObjIndexed(prependKeyAndDouble, xyz); //=> { x: 'x2', y: 'y4', z: 'z6' } - */ -var mapObjIndexed = _curry2(function mapObjIndexed(fn, obj) { - return _reduce(function(acc, key) { - acc[key] = fn(obj[key], key, obj); - return acc; - }, {}, keys(obj)); -}); - -/** - * Tests a regular expression against a String. Note that this function will - * return an empty array when there are no matches. This differs from - * [`String.prototype.match`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/match) - * which returns `null` when there are no matches. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category String - * @sig RegExp -> String -> [String | Undefined] - * @param {RegExp} rx A regular expression. - * @param {String} str The string to match against - * @return {Array} The list of matches or empty array. - * @see R.test - * @example - * - * R.match(/([a-z]a)/g, 'bananas'); //=> ['ba', 'na', 'na'] - * R.match(/a/, 'b'); //=> [] - * R.match(/a/, null); //=> TypeError: null does not have a method named "match" - */ -var match = _curry2(function match(rx, str) { - return str.match(rx) || []; -}); - -/** - * `mathMod` behaves like the modulo operator should mathematically, unlike the - * `%` operator (and by extension, [`R.modulo`](#modulo)). So while - * `-17 % 5` is `-2`, `mathMod(-17, 5)` is `3`. `mathMod` requires Integer - * arguments, and returns NaN when the modulus is zero or negative. - * - * @func - * @memberOf R - * @since v0.3.0 - * @category Math - * @sig Number -> Number -> Number - * @param {Number} m The dividend. - * @param {Number} p the modulus. - * @return {Number} The result of `b mod a`. - * @see R.modulo - * @example - * - * R.mathMod(-17, 5); //=> 3 - * R.mathMod(17, 5); //=> 2 - * R.mathMod(17, -5); //=> NaN - * R.mathMod(17, 0); //=> NaN - * R.mathMod(17.2, 5); //=> NaN - * R.mathMod(17, 5.3); //=> NaN - * - * const clock = R.mathMod(R.__, 12); - * clock(15); //=> 3 - * clock(24); //=> 0 - * - * const seventeenMod = R.mathMod(17); - * seventeenMod(3); //=> 2 - * seventeenMod(4); //=> 1 - * seventeenMod(10); //=> 7 - */ -var mathMod = _curry2(function mathMod(m, p) { - if (!_isInteger(m)) { return NaN; } - if (!_isInteger(p) || p < 1) { return NaN; } - return ((m % p) + p) % p; -}); - -/** - * Takes a function and two values, and returns whichever value produces the - * larger result when passed to the provided function. - * - * @func - * @memberOf R - * @since v0.8.0 - * @category Relation - * @sig Ord b => (a -> b) -> a -> a -> a - * @param {Function} f - * @param {*} a - * @param {*} b - * @return {*} - * @see R.max, R.minBy - * @example - * - * // square :: Number -> Number - * const square = n => n * n; - * - * R.maxBy(square, -3, 2); //=> -3 - * - * R.reduce(R.maxBy(square), 0, [3, -5, 4, 1, -2]); //=> -5 - * R.reduce(R.maxBy(square), 0, []); //=> 0 - */ -var maxBy = _curry3(function maxBy(f, a, b) { - return f(b) > f(a) ? b : a; -}); - -/** - * Adds together all the elements of a list. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Math - * @sig [Number] -> Number - * @param {Array} list An array of numbers - * @return {Number} The sum of all the numbers in the list. - * @see R.reduce - * @example - * - * R.sum([2,4,6,8,100,1]); //=> 121 - */ -var sum = reduce(add, 0); - -/** - * Returns the mean of the given list of numbers. - * - * @func - * @memberOf R - * @since v0.14.0 - * @category Math - * @sig [Number] -> Number - * @param {Array} list - * @return {Number} - * @see R.median - * @example - * - * R.mean([2, 7, 9]); //=> 6 - * R.mean([]); //=> NaN - */ -var mean = _curry1(function mean(list) { - return sum(list) / list.length; -}); - -/** - * Returns the median of the given list of numbers. - * - * @func - * @memberOf R - * @since v0.14.0 - * @category Math - * @sig [Number] -> Number - * @param {Array} list - * @return {Number} - * @see R.mean - * @example - * - * R.median([2, 9, 7]); //=> 7 - * R.median([7, 2, 10, 9]); //=> 8 - * R.median([]); //=> NaN - */ -var median = _curry1(function median(list) { - var len = list.length; - if (len === 0) { - return NaN; - } - var width = 2 - len % 2; - var idx = (len - width) / 2; - return mean(Array.prototype.slice.call(list, 0).sort(function(a, b) { - return a < b ? -1 : a > b ? 1 : 0; - }).slice(idx, idx + width)); -}); - -/** - * A customisable version of [`R.memoize`](#memoize). `memoizeWith` takes an - * additional function that will be applied to a given argument set and used to - * create the cache key under which the results of the function to be memoized - * will be stored. Care must be taken when implementing key generation to avoid - * clashes that may overwrite previous entries erroneously. - * - * - * @func - * @memberOf R - * @since v0.24.0 - * @category Function - * @sig (*... -> String) -> (*... -> a) -> (*... -> a) - * @param {Function} fn The function to generate the cache key. - * @param {Function} fn The function to memoize. - * @return {Function} Memoized version of `fn`. - * @example - * - * let count = 0; - * const factorial = R.memoizeWith(R.identity, n => { - * count += 1; - * return R.product(R.range(1, n + 1)); - * }); - * factorial(5); //=> 120 - * factorial(5); //=> 120 - * factorial(5); //=> 120 - * count; //=> 1 - */ -var memoizeWith = _curry2(function memoizeWith(mFn, fn) { - var cache = {}; - return _arity(fn.length, function() { - var key = mFn.apply(this, arguments); - if (!_has(key, cache)) { - cache[key] = fn.apply(this, arguments); - } - return cache[key]; - }); -}); - -/** - * Create a new object with the own properties of the first object merged with - * the own properties of the second object. If a key exists in both objects, - * the value from the second object will be used. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Object - * @sig {k: v} -> {k: v} -> {k: v} - * @param {Object} l - * @param {Object} r - * @return {Object} - * @see R.mergeRight, R.mergeDeepRight, R.mergeWith, R.mergeWithKey - * @deprecated - * @example - * - * R.merge({ 'name': 'fred', 'age': 10 }, { 'age': 40 }); - * //=> { 'name': 'fred', 'age': 40 } - * - * const withDefaults = R.merge({x: 0, y: 0}); - * withDefaults({y: 2}); //=> {x: 0, y: 2} - * @symb R.merge(a, b) = {...a, ...b} - */ -var merge = _curry2(function merge(l, r) { - return _objectAssign$1({}, l, r); -}); - -/** - * Merges a list of objects together into one object. - * - * @func - * @memberOf R - * @since v0.10.0 - * @category List - * @sig [{k: v}] -> {k: v} - * @param {Array} list An array of objects - * @return {Object} A merged object. - * @see R.reduce - * @example - * - * R.mergeAll([{foo:1},{bar:2},{baz:3}]); //=> {foo:1,bar:2,baz:3} - * R.mergeAll([{foo:1},{foo:2},{bar:2}]); //=> {foo:2,bar:2} - * @symb R.mergeAll([{ x: 1 }, { y: 2 }, { z: 3 }]) = { x: 1, y: 2, z: 3 } - */ -var mergeAll = _curry1(function mergeAll(list) { - return _objectAssign$1.apply(null, [{}].concat(list)); -}); - -/** - * Creates a new object with the own properties of the two provided objects. If - * a key exists in both objects, the provided function is applied to the key - * and the values associated with the key in each object, with the result being - * used as the value associated with the key in the returned object. - * - * @func - * @memberOf R - * @since v0.19.0 - * @category Object - * @sig ((String, a, a) -> a) -> {a} -> {a} -> {a} - * @param {Function} fn - * @param {Object} l - * @param {Object} r - * @return {Object} - * @see R.mergeDeepWithKey, R.merge, R.mergeWith - * @example - * - * let concatValues = (k, l, r) => k == 'values' ? R.concat(l, r) : r - * R.mergeWithKey(concatValues, - * { a: true, thing: 'foo', values: [10, 20] }, - * { b: true, thing: 'bar', values: [15, 35] }); - * //=> { a: true, b: true, thing: 'bar', values: [10, 20, 15, 35] } - * @symb R.mergeWithKey(f, { x: 1, y: 2 }, { y: 5, z: 3 }) = { x: 1, y: f('y', 2, 5), z: 3 } - */ -var mergeWithKey = _curry3(function mergeWithKey(fn, l, r) { - var result = {}; - var k; - - for (k in l) { - if (_has(k, l)) { - result[k] = _has(k, r) ? fn(k, l[k], r[k]) : l[k]; + + var _xtakeWhile = _curry2(function _xtakeWhile(f, xf) { return new XTakeWhile(f, xf); }); + + /** + * Returns a new list containing the first `n` elements of a given list, + * passing each value to the supplied predicate function, and terminating when + * the predicate function returns `false`. Excludes the element that caused the + * predicate function to fail. The predicate function is passed one argument: + * *(value)*. + * + * Dispatches to the `takeWhile` method of the second argument, if present. + * + * Acts as a transducer if a transformer is given in list position. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category List + * @sig (a -> Boolean) -> [a] -> [a] + * @sig (a -> Boolean) -> String -> String + * @param {Function} fn The function called per iteration. + * @param {Array} xs The collection to iterate over. + * @return {Array} A new array. + * @see R.dropWhile, R.transduce, R.addIndex + * @example + * + * const isNotFour = x => x !== 4; + * + * R.takeWhile(isNotFour, [1, 2, 3, 4, 3, 2, 1]); //=> [1, 2, 3] + * + * R.takeWhile(x => x !== 'd' , 'Ramda'); //=> 'Ram' + */ + var takeWhile = _curry2(_dispatchable(['takeWhile'], _xtakeWhile, function takeWhile(fn, xs) { + var idx = 0; + var len = xs.length; + while (idx < len && fn(xs[idx])) { + idx += 1; } + return slice(0, idx, xs); + })); + + function XTap(f, xf) { + this.xf = xf; + this.f = f; } + XTap.prototype['@@transducer/init'] = _xfBase.init; + XTap.prototype['@@transducer/result'] = _xfBase.result; + XTap.prototype['@@transducer/step'] = function(result, input) { + this.f(input); + return this.xf['@@transducer/step'](result, input); + }; - for (k in r) { - if (_has(k, r) && !(_has(k, result))) { - result[k] = r[k]; + var _xtap = _curry2(function _xtap(f, xf) { return new XTap(f, xf); }); + + /** + * Runs the given function with the supplied object, then returns the object. + * + * Acts as a transducer if a transformer is given as second parameter. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Function + * @sig (a -> *) -> a -> a + * @param {Function} fn The function to call with `x`. The return value of `fn` will be thrown away. + * @param {*} x + * @return {*} `x`. + * @example + * + * const sayX = x => console.log('x is ' + x); + * R.tap(sayX, 100); //=> 100 + * // logs 'x is 100' + * @symb R.tap(f, a) = a + */ + var tap = _curry2(_dispatchable([], _xtap, function tap(fn, x) { + fn(x); + return x; + })); + + function _isRegExp(x) { + return Object.prototype.toString.call(x) === '[object RegExp]'; + } + + /** + * Determines whether a given string matches a given regular expression. + * + * @func + * @memberOf R + * @since v0.12.0 + * @category String + * @sig RegExp -> String -> Boolean + * @param {RegExp} pattern + * @param {String} str + * @return {Boolean} + * @see R.match + * @example + * + * R.test(/^x/, 'xyz'); //=> true + * R.test(/^y/, 'xyz'); //=> false + */ + var test = _curry2(function test(pattern, str) { + if (!_isRegExp(pattern)) { + throw new TypeError('‘test’ requires a value of type RegExp as its first argument; received ' + toString$1(pattern)); } - } + return _cloneRegExp(pattern).test(str); + }); - return result; -}); - -/** - * Creates a new object with the own properties of the two provided objects. - * If a key exists in both objects: - * - and both associated values are also objects then the values will be - * recursively merged. - * - otherwise the provided function is applied to the key and associated values - * using the resulting value as the new value associated with the key. - * If a key only exists in one object, the value will be associated with the key - * of the resulting object. - * - * @func - * @memberOf R - * @since v0.24.0 - * @category Object - * @sig ((String, a, a) -> a) -> {a} -> {a} -> {a} - * @param {Function} fn - * @param {Object} lObj - * @param {Object} rObj - * @return {Object} - * @see R.mergeWithKey, R.mergeDeepWith - * @example - * - * let concatValues = (k, l, r) => k == 'values' ? R.concat(l, r) : r - * R.mergeDeepWithKey(concatValues, - * { a: true, c: { thing: 'foo', values: [10, 20] }}, - * { b: true, c: { thing: 'bar', values: [15, 35] }}); - * //=> { a: true, b: true, c: { thing: 'bar', values: [10, 20, 15, 35] }} - */ -var mergeDeepWithKey = _curry3(function mergeDeepWithKey(fn, lObj, rObj) { - return mergeWithKey(function(k, lVal, rVal) { - if (_isObject(lVal) && _isObject(rVal)) { - return mergeDeepWithKey(fn, lVal, rVal); - } else { - return fn(k, lVal, rVal); - } - }, lObj, rObj); -}); - -/** - * Creates a new object with the own properties of the first object merged with - * the own properties of the second object. If a key exists in both objects: - * - and both values are objects, the two values will be recursively merged - * - otherwise the value from the first object will be used. - * - * @func - * @memberOf R - * @since v0.24.0 - * @category Object - * @sig {a} -> {a} -> {a} - * @param {Object} lObj - * @param {Object} rObj - * @return {Object} - * @see R.merge, R.mergeDeepRight, R.mergeDeepWith, R.mergeDeepWithKey - * @example - * - * R.mergeDeepLeft({ name: 'fred', age: 10, contact: { email: 'moo@example.com' }}, - * { age: 40, contact: { email: 'baa@example.com' }}); - * //=> { name: 'fred', age: 10, contact: { email: 'moo@example.com' }} - */ -var mergeDeepLeft = _curry2(function mergeDeepLeft(lObj, rObj) { - return mergeDeepWithKey(function(k, lVal, rVal) { - return lVal; - }, lObj, rObj); -}); - -/** - * Creates a new object with the own properties of the first object merged with - * the own properties of the second object. If a key exists in both objects: - * - and both values are objects, the two values will be recursively merged - * - otherwise the value from the second object will be used. - * - * @func - * @memberOf R - * @since v0.24.0 - * @category Object - * @sig {a} -> {a} -> {a} - * @param {Object} lObj - * @param {Object} rObj - * @return {Object} - * @see R.merge, R.mergeDeepLeft, R.mergeDeepWith, R.mergeDeepWithKey - * @example - * - * R.mergeDeepRight({ name: 'fred', age: 10, contact: { email: 'moo@example.com' }}, - * { age: 40, contact: { email: 'baa@example.com' }}); - * //=> { name: 'fred', age: 40, contact: { email: 'baa@example.com' }} - */ -var mergeDeepRight = _curry2(function mergeDeepRight(lObj, rObj) { - return mergeDeepWithKey(function(k, lVal, rVal) { - return rVal; - }, lObj, rObj); -}); - -/** - * Creates a new object with the own properties of the two provided objects. - * If a key exists in both objects: - * - and both associated values are also objects then the values will be - * recursively merged. - * - otherwise the provided function is applied to associated values using the - * resulting value as the new value associated with the key. - * If a key only exists in one object, the value will be associated with the key - * of the resulting object. - * - * @func - * @memberOf R - * @since v0.24.0 - * @category Object - * @sig ((a, a) -> a) -> {a} -> {a} -> {a} - * @param {Function} fn - * @param {Object} lObj - * @param {Object} rObj - * @return {Object} - * @see R.mergeWith, R.mergeDeepWithKey - * @example - * - * R.mergeDeepWith(R.concat, - * { a: true, c: { values: [10, 20] }}, - * { b: true, c: { values: [15, 35] }}); - * //=> { a: true, b: true, c: { values: [10, 20, 15, 35] }} - */ -var mergeDeepWith = _curry3(function mergeDeepWith(fn, lObj, rObj) { - return mergeDeepWithKey(function(k, lVal, rVal) { - return fn(lVal, rVal); - }, lObj, rObj); -}); - -/** - * Create a new object with the own properties of the first object merged with - * the own properties of the second object. If a key exists in both objects, - * the value from the first object will be used. - * - * @func - * @memberOf R - * @category Object - * @sig {k: v} -> {k: v} -> {k: v} - * @param {Object} l - * @param {Object} r - * @return {Object} - * @see R.mergeRight, R.mergeDeepLeft, R.mergeWith, R.mergeWithKey - * @example - * - * R.mergeLeft({ 'age': 40 }, { 'name': 'fred', 'age': 10 }); - * //=> { 'name': 'fred', 'age': 40 } - * - * const resetToDefault = R.mergeLeft({x: 0}); - * resetToDefault({x: 5, y: 2}); //=> {x: 0, y: 2} - * @symb R.mergeLeft(a, b) = {...b, ...a} - */ -var mergeLeft = _curry2(function mergeLeft(l, r) { - return _objectAssign$1({}, r, l); -}); - -/** - * Create a new object with the own properties of the first object merged with - * the own properties of the second object. If a key exists in both objects, - * the value from the second object will be used. - * - * @func - * @memberOf R - * @category Object - * @sig {k: v} -> {k: v} -> {k: v} - * @param {Object} l - * @param {Object} r - * @return {Object} - * @see R.mergeLeft, R.mergeDeepRight, R.mergeWith, R.mergeWithKey - * @example - * - * R.mergeRight({ 'name': 'fred', 'age': 10 }, { 'age': 40 }); - * //=> { 'name': 'fred', 'age': 40 } - * - * const withDefaults = R.mergeRight({x: 0, y: 0}); - * withDefaults({y: 2}); //=> {x: 0, y: 2} - * @symb R.mergeRight(a, b) = {...a, ...b} - */ -var mergeRight = _curry2(function mergeRight(l, r) { - return _objectAssign$1({}, l, r); -}); - -/** - * Creates a new object with the own properties of the two provided objects. If - * a key exists in both objects, the provided function is applied to the values - * associated with the key in each object, with the result being used as the - * value associated with the key in the returned object. - * - * @func - * @memberOf R - * @since v0.19.0 - * @category Object - * @sig ((a, a) -> a) -> {a} -> {a} -> {a} - * @param {Function} fn - * @param {Object} l - * @param {Object} r - * @return {Object} - * @see R.mergeDeepWith, R.merge, R.mergeWithKey - * @example - * - * R.mergeWith(R.concat, - * { a: true, values: [10, 20] }, - * { b: true, values: [15, 35] }); - * //=> { a: true, b: true, values: [10, 20, 15, 35] } - */ -var mergeWith = _curry3(function mergeWith(fn, l, r) { - return mergeWithKey(function(_, _l, _r) { - return fn(_l, _r); - }, l, r); -}); - -/** - * Returns the smaller of its two arguments. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Relation - * @sig Ord a => a -> a -> a - * @param {*} a - * @param {*} b - * @return {*} - * @see R.minBy, R.max - * @example - * - * R.min(789, 123); //=> 123 - * R.min('a', 'b'); //=> 'a' - */ -var min = _curry2(function min(a, b) { return b < a ? b : a; }); - -/** - * Takes a function and two values, and returns whichever value produces the - * smaller result when passed to the provided function. - * - * @func - * @memberOf R - * @since v0.8.0 - * @category Relation - * @sig Ord b => (a -> b) -> a -> a -> a - * @param {Function} f - * @param {*} a - * @param {*} b - * @return {*} - * @see R.min, R.maxBy - * @example - * - * // square :: Number -> Number - * const square = n => n * n; - * - * R.minBy(square, -3, 2); //=> 2 - * - * R.reduce(R.minBy(square), Infinity, [3, -5, 4, 1, -2]); //=> 1 - * R.reduce(R.minBy(square), Infinity, []); //=> Infinity - */ -var minBy = _curry3(function minBy(f, a, b) { - return f(b) < f(a) ? b : a; -}); - -/** - * Divides the first parameter by the second and returns the remainder. Note - * that this function preserves the JavaScript-style behavior for modulo. For - * mathematical modulo see [`mathMod`](#mathMod). - * - * @func - * @memberOf R - * @since v0.1.1 - * @category Math - * @sig Number -> Number -> Number - * @param {Number} a The value to the divide. - * @param {Number} b The pseudo-modulus - * @return {Number} The result of `b % a`. - * @see R.mathMod - * @example - * - * R.modulo(17, 3); //=> 2 - * // JS behavior: - * R.modulo(-17, 3); //=> -2 - * R.modulo(17, -3); //=> 2 - * - * const isOdd = R.modulo(R.__, 2); - * isOdd(42); //=> 0 - * isOdd(21); //=> 1 - */ -var modulo = _curry2(function modulo(a, b) { return a % b; }); - -/** - * Multiplies two numbers. Equivalent to `a * b` but curried. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Math - * @sig Number -> Number -> Number - * @param {Number} a The first value. - * @param {Number} b The second value. - * @return {Number} The result of `a * b`. - * @see R.divide - * @example - * - * const double = R.multiply(2); - * const triple = R.multiply(3); - * double(3); //=> 6 - * triple(4); //=> 12 - * R.multiply(2, 5); //=> 10 - */ -var multiply = _curry2(function multiply(a, b) { return a * b; }); - -/** - * Negates its argument. - * - * @func - * @memberOf R - * @since v0.9.0 - * @category Math - * @sig Number -> Number - * @param {Number} n - * @return {Number} - * @example - * - * R.negate(42); //=> -42 - */ -var negate = _curry1(function negate(n) { return -n; }); - -/** - * Returns `true` if no elements of the list match the predicate, `false` - * otherwise. - * - * Dispatches to the `all` method of the second argument, if present. - * - * Acts as a transducer if a transformer is given in list position. - * - * @func - * @memberOf R - * @since v0.12.0 - * @category List - * @sig (a -> Boolean) -> [a] -> Boolean - * @param {Function} fn The predicate function. - * @param {Array} list The array to consider. - * @return {Boolean} `true` if the predicate is not satisfied by every element, `false` otherwise. - * @see R.all, R.any - * @example - * - * const isEven = n => n % 2 === 0; - * const isOdd = n => n % 2 === 1; - * - * R.none(isEven, [1, 3, 5, 7, 9, 11]); //=> true - * R.none(isOdd, [1, 3, 5, 7, 8, 11]); //=> false - */ -const none = _curry2(function none(fn, input) { - return all(_complement(fn), input); -}); - -/** - * Returns a function which returns its nth argument. - * - * @func - * @memberOf R - * @since v0.9.0 - * @category Function - * @sig Number -> *... -> * - * @param {Number} n - * @return {Function} - * @example - * - * R.nthArg(1)('a', 'b', 'c'); //=> 'b' - * R.nthArg(-1)('a', 'b', 'c'); //=> 'c' - * @symb R.nthArg(-1)(a, b, c) = c - * @symb R.nthArg(0)(a, b, c) = a - * @symb R.nthArg(1)(a, b, c) = b - */ -var nthArg = _curry1(function nthArg(n) { - var arity = n < 0 ? 1 : n + 1; - return curryN(arity, function() { - return nth(n, arguments); - }); -}); - -/** - * `o` is a curried composition function that returns a unary function. - * Like [`compose`](#compose), `o` performs right-to-left function composition. - * Unlike [`compose`](#compose), the rightmost function passed to `o` will be - * invoked with only one argument. Also, unlike [`compose`](#compose), `o` is - * limited to accepting only 2 unary functions. The name o was chosen because - * of its similarity to the mathematical composition operator ∘. - * - * @func - * @memberOf R - * @since v0.24.0 - * @category Function - * @sig (b -> c) -> (a -> b) -> a -> c - * @param {Function} f - * @param {Function} g - * @return {Function} - * @see R.compose, R.pipe - * @example - * - * const classyGreeting = name => "The name's " + name.last + ", " + name.first + " " + name.last - * const yellGreeting = R.o(R.toUpper, classyGreeting); - * yellGreeting({first: 'James', last: 'Bond'}); //=> "THE NAME'S BOND, JAMES BOND" - * - * R.o(R.multiply(10), R.add(10))(-4) //=> 60 - * - * @symb R.o(f, g, x) = f(g(x)) - */ -var o = _curry3(function o(f, g, x) { - return f(g(x)); -}); - -function _of(x) { return [x]; } - -/** - * Returns a singleton array containing the value provided. - * - * Note this `of` is different from the ES6 `of`; See - * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/of - * - * @func - * @memberOf R - * @since v0.3.0 - * @category Function - * @sig a -> [a] - * @param {*} x any value - * @return {Array} An array wrapping `x`. - * @example - * - * R.of(null); //=> [null] - * R.of([42]); //=> [[42]] - */ -var of = _curry1(_of); - -/** - * Returns a partial copy of an object omitting the keys specified. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Object - * @sig [String] -> {String: *} -> {String: *} - * @param {Array} names an array of String property names to omit from the new object - * @param {Object} obj The object to copy from - * @return {Object} A new object with properties from `names` not on it. - * @see R.pick - * @example - * - * R.omit(['a', 'd'], {a: 1, b: 2, c: 3, d: 4}); //=> {b: 2, c: 3} - */ -var omit = _curry2(function omit(names, obj) { - var result = {}; - var index = {}; - var idx = 0; - var len = names.length; - - while (idx < len) { - index[names[idx]] = 1; - idx += 1; - } + /** + * Returns the result of applying the onSuccess function to the value inside + * a successfully resolved promise. This is useful for working with promises + * inside function compositions. + * + * @func + * @memberOf R + * @since v0.27.1 + * @category Function + * @sig (a -> b) -> (Promise e a) -> (Promise e b) + * @sig (a -> (Promise e b)) -> (Promise e a) -> (Promise e b) + * @param {Function} onSuccess The function to apply. Can return a value or a promise of a value. + * @param {Promise} p + * @return {Promise} The result of calling `p.then(onSuccess)` + * @see R.otherwise + * @example + * + * var makeQuery = (email) => ({ query: { email }}); + * + * //getMemberName :: String -> Promise ({firstName, lastName}) + * var getMemberName = R.pipe( + * makeQuery, + * fetchMember, + * R.andThen(R.pick(['firstName', 'lastName'])) + * ); + */ + var andThen = _curry2(function andThen(f, p) { + _assertPromise('andThen', p); + + return p.then(f); + }); - for (var prop in obj) { - if (!index.hasOwnProperty(prop)) { - result[prop] = obj[prop]; + /** + * The lower case version of a string. + * + * @func + * @memberOf R + * @since v0.9.0 + * @category String + * @sig String -> String + * @param {String} str The string to lower case. + * @return {String} The lower case version of `str`. + * @see R.toUpper + * @example + * + * R.toLower('XYZ'); //=> 'xyz' + */ + var toLower = invoker(0, 'toLowerCase'); + + /** + * Converts an object into an array of key, value arrays. Only the object's + * own properties are used. + * Note that the order of the output array is not guaranteed to be consistent + * across different JS platforms. + * + * @func + * @memberOf R + * @since v0.4.0 + * @category Object + * @sig {String: *} -> [[String,*]] + * @param {Object} obj The object to extract from + * @return {Array} An array of key, value arrays from the object's own properties. + * @see R.fromPairs + * @example + * + * R.toPairs({a: 1, b: 2, c: 3}); //=> [['a', 1], ['b', 2], ['c', 3]] + */ + var toPairs = _curry1(function toPairs(obj) { + var pairs = []; + for (var prop in obj) { + if (_has(prop, obj)) { + pairs[pairs.length] = [prop, obj[prop]]; + } } - } - return result; -}); - -/** - * Accepts a function `fn` and returns a function that guards invocation of - * `fn` such that `fn` can only ever be called once, no matter how many times - * the returned function is invoked. The first value calculated is returned in - * subsequent invocations. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Function - * @sig (a... -> b) -> (a... -> b) - * @param {Function} fn The function to wrap in a call-only-once wrapper. - * @return {Function} The wrapped function. - * @example - * - * const addOneOnce = R.once(x => x + 1); - * addOneOnce(10); //=> 11 - * addOneOnce(addOneOnce(50)); //=> 11 - */ -var once = _curry1(function once(fn) { - var called = false; - var result; - return _arity(fn.length, function() { - if (called) { - return result; + return pairs; + }); + + /** + * Converts an object into an array of key, value arrays. The object's own + * properties and prototype properties are used. Note that the order of the + * output array is not guaranteed to be consistent across different JS + * platforms. + * + * @func + * @memberOf R + * @since v0.4.0 + * @category Object + * @sig {String: *} -> [[String,*]] + * @param {Object} obj The object to extract from + * @return {Array} An array of key, value arrays from the object's own + * and prototype properties. + * @example + * + * const F = function() { this.x = 'X'; }; + * F.prototype.y = 'Y'; + * const f = new F(); + * R.toPairsIn(f); //=> [['x','X'], ['y','Y']] + */ + var toPairsIn = _curry1(function toPairsIn(obj) { + var pairs = []; + for (var prop in obj) { + pairs[pairs.length] = [prop, obj[prop]]; + } + return pairs; + }); + + /** + * The upper case version of a string. + * + * @func + * @memberOf R + * @since v0.9.0 + * @category String + * @sig String -> String + * @param {String} str The string to upper case. + * @return {String} The upper case version of `str`. + * @see R.toLower + * @example + * + * R.toUpper('abc'); //=> 'ABC' + */ + var toUpper = invoker(0, 'toUpperCase'); + + /** + * Initializes a transducer using supplied iterator function. Returns a single + * item by iterating through the list, successively calling the transformed + * iterator function and passing it an accumulator value and the current value + * from the array, and then passing the result to the next call. + * + * The iterator function receives two values: *(acc, value)*. It will be + * wrapped as a transformer to initialize the transducer. A transformer can be + * passed directly in place of an iterator function. In both cases, iteration + * may be stopped early with the [`R.reduced`](#reduced) function. + * + * A transducer is a function that accepts a transformer and returns a + * transformer and can be composed directly. + * + * A transformer is an an object that provides a 2-arity reducing iterator + * function, step, 0-arity initial value function, init, and 1-arity result + * extraction function, result. The step function is used as the iterator + * function in reduce. The result function is used to convert the final + * accumulator into the return type and in most cases is + * [`R.identity`](#identity). The init function can be used to provide an + * initial accumulator, but is ignored by transduce. + * + * The iteration is performed with [`R.reduce`](#reduce) after initializing the transducer. + * + * @func + * @memberOf R + * @since v0.12.0 + * @category List + * @sig (c -> c) -> ((a, b) -> a) -> a -> [b] -> a + * @param {Function} xf The transducer function. Receives a transformer and returns a transformer. + * @param {Function} fn The iterator function. Receives two values, the accumulator and the + * current element from the array. Wrapped as transformer, if necessary, and used to + * initialize the transducer + * @param {*} acc The initial accumulator value. + * @param {Array} list The list to iterate over. + * @return {*} The final, accumulated value. + * @see R.reduce, R.reduced, R.into + * @example + * + * const numbers = [1, 2, 3, 4]; + * const transducer = R.compose(R.map(R.add(1)), R.take(2)); + * R.transduce(transducer, R.flip(R.append), [], numbers); //=> [2, 3] + * + * const isOdd = (x) => x % 2 === 1; + * const firstOddTransducer = R.compose(R.filter(isOdd), R.take(1)); + * R.transduce(firstOddTransducer, R.flip(R.append), [], R.range(0, 100)); //=> [1] + */ + var transduce = curryN(4, function transduce(xf, fn, acc, list) { + return _reduce(xf(typeof fn === 'function' ? _xwrap(fn) : fn), acc, list); + }); + + /** + * Transposes the rows and columns of a 2D list. + * When passed a list of `n` lists of length `x`, + * returns a list of `x` lists of length `n`. + * + * + * @func + * @memberOf R + * @since v0.19.0 + * @category List + * @sig [[a]] -> [[a]] + * @param {Array} list A 2D list + * @return {Array} A 2D list + * @example + * + * R.transpose([[1, 'a'], [2, 'b'], [3, 'c']]) //=> [[1, 2, 3], ['a', 'b', 'c']] + * R.transpose([[1, 2, 3], ['a', 'b', 'c']]) //=> [[1, 'a'], [2, 'b'], [3, 'c']] + * + * // If some of the rows are shorter than the following rows, their elements are skipped: + * R.transpose([[10, 11], [20], [], [30, 31, 32]]) //=> [[10, 20, 30], [11, 31], [32]] + * @symb R.transpose([[a], [b], [c]]) = [a, b, c] + * @symb R.transpose([[a, b], [c, d]]) = [[a, c], [b, d]] + * @symb R.transpose([[a, b], [c]]) = [[a, c], [b]] + */ + var transpose = _curry1(function transpose(outerlist) { + var i = 0; + var result = []; + while (i < outerlist.length) { + var innerlist = outerlist[i]; + var j = 0; + while (j < innerlist.length) { + if (typeof result[j] === 'undefined') { + result[j] = []; + } + result[j].push(innerlist[j]); + j += 1; + } + i += 1; } - called = true; - result = fn.apply(this, arguments); return result; }); -}); -function _assertPromise(name, p) { - if (p == null || !_isFunction(p.then)) { - throw new TypeError('`' + name + '` expected a Promise, received ' + _toString(p, [])); - } -} - -/** - * Returns the result of applying the onFailure function to the value inside - * a failed promise. This is useful for handling rejected promises - * inside function compositions. - * - * @func - * @memberOf R - * @category Function - * @sig (e -> b) -> (Promise e a) -> (Promise e b) - * @sig (e -> (Promise f b)) -> (Promise e a) -> (Promise f b) - * @param {Function} onFailure The function to apply. Can return a value or a promise of a value. - * @param {Promise} p - * @return {Promise} The result of calling `p.then(null, onFailure)` - * @see R.then - * @example - * - * var failedFetch = (id) => Promise.reject('bad ID'); - * var useDefault = () => ({ firstName: 'Bob', lastName: 'Loblaw' }) - * - * //recoverFromFailure :: String -> Promise ({firstName, lastName}) - * var recoverFromFailure = R.pipe( - * failedFetch(12345), - * R.otherwise(useDefault), - * R.then(R.pick(['firstName', 'lastName'])) - * ); - */ -const otherwise = _curry2(function otherwise(f, p) { - _assertPromise('otherwise', p); - - return p.then(null, f); -}); - -// `Identity` is a functor that holds a single value, where `map` simply -// transforms the held value with the provided function. -var Identity = function(x) { - return {value: x, map: function(f) { return Identity(f(x)); }}; -}; - - -/** - * Returns the result of "setting" the portion of the given data structure - * focused by the given lens to the result of applying the given function to - * the focused value. - * - * @func - * @memberOf R - * @since v0.16.0 - * @category Object - * @typedefn Lens s a = Functor f => (a -> f a) -> s -> f s - * @sig Lens s a -> (a -> a) -> s -> s - * @param {Lens} lens - * @param {*} v - * @param {*} x - * @return {*} - * @see R.prop, R.lensIndex, R.lensProp - * @example - * - * const headLens = R.lensIndex(0); - * - * R.over(headLens, R.toUpper, ['foo', 'bar', 'baz']); //=> ['FOO', 'bar', 'baz'] - */ -var over = _curry3(function over(lens, f, x) { - // The value returned by the getter function is first transformed with `f`, - // then set as the value of an `Identity`. This is then mapped over with the - // setter function of the lens. - return lens(function(y) { return Identity(f(y)); })(x).value; -}); - -/** - * Takes two arguments, `fst` and `snd`, and returns `[fst, snd]`. - * - * @func - * @memberOf R - * @since v0.18.0 - * @category List - * @sig a -> b -> (a,b) - * @param {*} fst - * @param {*} snd - * @return {Array} - * @see R.objOf, R.of - * @example - * - * R.pair('foo', 'bar'); //=> ['foo', 'bar'] - */ -var pair = _curry2(function pair(fst, snd) { return [fst, snd]; }); - -function _createPartialApplicator(concat) { - return _curry2(function(fn, args) { - return _arity(Math.max(0, fn.length - args.length), function() { - return fn.apply(this, concat(args, arguments)); + /** + * Maps an [Applicative](https://github.com/fantasyland/fantasy-land#applicative)-returning + * function over a [Traversable](https://github.com/fantasyland/fantasy-land#traversable), + * then uses [`sequence`](#sequence) to transform the resulting Traversable of Applicative + * into an Applicative of Traversable. + * + * Dispatches to the `traverse` method of the third argument, if present. + * + * @func + * @memberOf R + * @since v0.19.0 + * @category List + * @sig (Applicative f, Traversable t) => (a -> f a) -> (a -> f b) -> t a -> f (t b) + * @param {Function} of + * @param {Function} f + * @param {*} traversable + * @return {*} + * @see R.sequence + * @example + * + * // Returns `Maybe.Nothing` if the given divisor is `0` + * const safeDiv = n => d => d === 0 ? Maybe.Nothing() : Maybe.Just(n / d) + * + * R.traverse(Maybe.of, safeDiv(10), [2, 4, 5]); //=> Maybe.Just([5, 2.5, 2]) + * R.traverse(Maybe.of, safeDiv(10), [2, 0, 5]); //=> Maybe.Nothing + */ + var traverse = _curry3(function traverse(of, f, traversable) { + return typeof traversable['fantasy-land/traverse'] === 'function' ? + traversable['fantasy-land/traverse'](f, of) : + sequence(of, map(f, traversable)); + }); + + var ws = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003' + + '\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028' + + '\u2029\uFEFF'; + var zeroWidth = '\u200b'; + var hasProtoTrim = (typeof String.prototype.trim === 'function'); + /** + * Removes (strips) whitespace from both ends of the string. + * + * @func + * @memberOf R + * @since v0.6.0 + * @category String + * @sig String -> String + * @param {String} str The string to trim. + * @return {String} Trimmed version of `str`. + * @example + * + * R.trim(' xyz '); //=> 'xyz' + * R.map(R.trim, R.split(',', 'x, y, z')); //=> ['x', 'y', 'z'] + */ + var trim = !hasProtoTrim || (ws.trim() || !zeroWidth.trim()) ? + _curry1(function trim(str) { + var beginRx = new RegExp('^[' + ws + '][' + ws + ']*'); + var endRx = new RegExp('[' + ws + '][' + ws + ']*$'); + return str.replace(beginRx, '').replace(endRx, ''); + }) : + _curry1(function trim(str) { + return str.trim(); + }); + + /** + * `tryCatch` takes two functions, a `tryer` and a `catcher`. The returned + * function evaluates the `tryer`; if it does not throw, it simply returns the + * result. If the `tryer` *does* throw, the returned function evaluates the + * `catcher` function and returns its result. Note that for effective + * composition with this function, both the `tryer` and `catcher` functions + * must return the same type of results. + * + * @func + * @memberOf R + * @since v0.20.0 + * @category Function + * @sig (...x -> a) -> ((e, ...x) -> a) -> (...x -> a) + * @param {Function} tryer The function that may throw. + * @param {Function} catcher The function that will be evaluated if `tryer` throws. + * @return {Function} A new function that will catch exceptions and send then to the catcher. + * @example + * + * R.tryCatch(R.prop('x'), R.F)({x: true}); //=> true + * R.tryCatch(() => { throw 'foo'}, R.always('catched'))('bar') // => 'catched' + * R.tryCatch(R.times(R.identity), R.always([]))('s') // => [] + * R.tryCatch(() => { throw 'this is not a valid value'}, (err, value)=>({error : err, value }))('bar') // => {'error': 'this is not a valid value', 'value': 'bar'} + */ + var tryCatch = _curry2(function _tryCatch(tryer, catcher) { + return _arity(tryer.length, function() { + try { + return tryer.apply(this, arguments); + } catch (e) { + return catcher.apply(this, _concat([e], arguments)); + } }); }); -} - -/** - * Takes a function `f` and a list of arguments, and returns a function `g`. - * When applied, `g` returns the result of applying `f` to the arguments - * provided initially followed by the arguments provided to `g`. - * - * @func - * @memberOf R - * @since v0.10.0 - * @category Function - * @sig ((a, b, c, ..., n) -> x) -> [a, b, c, ...] -> ((d, e, f, ..., n) -> x) - * @param {Function} f - * @param {Array} args - * @return {Function} - * @see R.partialRight, R.curry - * @example - * - * const multiply2 = (a, b) => a * b; - * const double = R.partial(multiply2, [2]); - * double(2); //=> 4 - * - * const greet = (salutation, title, firstName, lastName) => - * salutation + ', ' + title + ' ' + firstName + ' ' + lastName + '!'; - * - * const sayHello = R.partial(greet, ['Hello']); - * const sayHelloToMs = R.partial(sayHello, ['Ms.']); - * sayHelloToMs('Jane', 'Jones'); //=> 'Hello, Ms. Jane Jones!' - * @symb R.partial(f, [a, b])(c, d) = f(a, b, c, d) - */ -var partial = _createPartialApplicator(_concat); - -/** - * Takes a function `f` and a list of arguments, and returns a function `g`. - * When applied, `g` returns the result of applying `f` to the arguments - * provided to `g` followed by the arguments provided initially. - * - * @func - * @memberOf R - * @since v0.10.0 - * @category Function - * @sig ((a, b, c, ..., n) -> x) -> [d, e, f, ..., n] -> ((a, b, c, ...) -> x) - * @param {Function} f - * @param {Array} args - * @return {Function} - * @see R.partial - * @example - * - * const greet = (salutation, title, firstName, lastName) => - * salutation + ', ' + title + ' ' + firstName + ' ' + lastName + '!'; - * - * const greetMsJaneJones = R.partialRight(greet, ['Ms.', 'Jane', 'Jones']); - * - * greetMsJaneJones('Hello'); //=> 'Hello, Ms. Jane Jones!' - * @symb R.partialRight(f, [a, b])(c, d) = f(c, d, a, b) - */ -var partialRight = _createPartialApplicator(flip(_concat)); - -/** - * Takes a predicate and a list or other `Filterable` object and returns the - * pair of filterable objects of the same type of elements which do and do not - * satisfy, the predicate, respectively. Filterable objects include plain objects or any object - * that has a filter method such as `Array`. - * - * @func - * @memberOf R - * @since v0.1.4 - * @category List - * @sig Filterable f => (a -> Boolean) -> f a -> [f a, f a] - * @param {Function} pred A predicate to determine which side the element belongs to. - * @param {Array} filterable the list (or other filterable) to partition. - * @return {Array} An array, containing first the subset of elements that satisfy the - * predicate, and second the subset of elements that do not satisfy. - * @see R.filter, R.reject - * @example - * - * R.partition(R.includes('s'), ['sss', 'ttt', 'foo', 'bars']); - * // => [ [ 'sss', 'bars' ], [ 'ttt', 'foo' ] ] - * - * R.partition(R.includes('s'), { a: 'sss', b: 'ttt', foo: 'bars' }); - * // => [ { a: 'sss', foo: 'bars' }, { b: 'ttt' } ] - */ -var partition = juxt([filter, reject]); - -/** - * Determines whether a nested path on an object has a specific value, in - * [`R.equals`](#equals) terms. Most likely used to filter a list. - * - * @func - * @memberOf R - * @since v0.7.0 - * @category Relation - * @typedefn Idx = String | Int - * @sig [Idx] -> a -> {a} -> Boolean - * @param {Array} path The path of the nested property to use - * @param {*} val The value to compare the nested property with - * @param {Object} obj The object to check the nested property in - * @return {Boolean} `true` if the value equals the nested object property, - * `false` otherwise. - * @example - * - * const user1 = { address: { zipCode: 90210 } }; - * const user2 = { address: { zipCode: 55555 } }; - * const user3 = { name: 'Bob' }; - * const users = [ user1, user2, user3 ]; - * const isFamous = R.pathEq(['address', 'zipCode'], 90210); - * R.filter(isFamous, users); //=> [ user1 ] - */ -var pathEq = _curry3(function pathEq(_path, val, obj) { - return equals(path(_path, obj), val); -}); - -/** - * If the given, non-null object has a value at the given path, returns the - * value at that path. Otherwise returns the provided default value. - * - * @func - * @memberOf R - * @since v0.18.0 - * @category Object - * @typedefn Idx = String | Int - * @sig a -> [Idx] -> {a} -> a - * @param {*} d The default value. - * @param {Array} p The path to use. - * @param {Object} obj The object to retrieve the nested property from. - * @return {*} The data at `path` of the supplied object or the default value. - * @example - * - * R.pathOr('N/A', ['a', 'b'], {a: {b: 2}}); //=> 2 - * R.pathOr('N/A', ['a', 'b'], {c: {b: 2}}); //=> "N/A" - */ -var pathOr = _curry3(function pathOr(d, p, obj) { - return defaultTo(d, path(p, obj)); -}); - -/** - * Returns `true` if the specified object property at given path satisfies the - * given predicate; `false` otherwise. - * - * @func - * @memberOf R - * @since v0.19.0 - * @category Logic - * @typedefn Idx = String | Int - * @sig (a -> Boolean) -> [Idx] -> {a} -> Boolean - * @param {Function} pred - * @param {Array} propPath - * @param {*} obj - * @return {Boolean} - * @see R.propSatisfies, R.path - * @example - * - * R.pathSatisfies(y => y > 0, ['x', 'y'], {x: {y: 2}}); //=> true - */ -var pathSatisfies = _curry3(function pathSatisfies(pred, propPath, obj) { - return propPath.length > 0 && pred(path(propPath, obj)); -}); - -/** - * Returns a partial copy of an object containing only the keys specified. If - * the key does not exist, the property is ignored. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Object - * @sig [k] -> {k: v} -> {k: v} - * @param {Array} names an array of String property names to copy onto a new object - * @param {Object} obj The object to copy from - * @return {Object} A new object with only properties from `names` on it. - * @see R.omit, R.props - * @example - * - * R.pick(['a', 'd'], {a: 1, b: 2, c: 3, d: 4}); //=> {a: 1, d: 4} - * R.pick(['a', 'e', 'f'], {a: 1, b: 2, c: 3, d: 4}); //=> {a: 1} - */ -var pick = _curry2(function pick(names, obj) { - var result = {}; - var idx = 0; - while (idx < names.length) { - if (names[idx] in obj) { - result[names[idx]] = obj[names[idx]]; - } - idx += 1; - } - return result; -}); - -/** - * Similar to `pick` except that this one includes a `key: undefined` pair for - * properties that don't exist. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Object - * @sig [k] -> {k: v} -> {k: v} - * @param {Array} names an array of String property names to copy onto a new object - * @param {Object} obj The object to copy from - * @return {Object} A new object with only properties from `names` on it. - * @see R.pick - * @example - * - * R.pickAll(['a', 'd'], {a: 1, b: 2, c: 3, d: 4}); //=> {a: 1, d: 4} - * R.pickAll(['a', 'e', 'f'], {a: 1, b: 2, c: 3, d: 4}); //=> {a: 1, e: undefined, f: undefined} - */ -var pickAll = _curry2(function pickAll(names, obj) { - var result = {}; - var idx = 0; - var len = names.length; - while (idx < len) { - var name = names[idx]; - result[name] = obj[name]; - idx += 1; - } - return result; -}); - -/** - * Returns a partial copy of an object containing only the keys that satisfy - * the supplied predicate. - * - * @func - * @memberOf R - * @since v0.8.0 - * @category Object - * @sig ((v, k) -> Boolean) -> {k: v} -> {k: v} - * @param {Function} pred A predicate to determine whether or not a key - * should be included on the output object. - * @param {Object} obj The object to copy from - * @return {Object} A new object with only properties that satisfy `pred` - * on it. - * @see R.pick, R.filter - * @example - * - * const isUpperCase = (val, key) => key.toUpperCase() === key; - * R.pickBy(isUpperCase, {a: 1, b: 2, A: 3, B: 4}); //=> {A: 3, B: 4} - */ -var pickBy = _curry2(function pickBy(test, obj) { - var result = {}; - for (var prop in obj) { - if (test(obj[prop], prop, obj)) { - result[prop] = obj[prop]; + + /** + * Takes a function `fn`, which takes a single array argument, and returns a + * function which: + * + * - takes any number of positional arguments; + * - passes these arguments to `fn` as an array; and + * - returns the result. + * + * In other words, `R.unapply` derives a variadic function from a function which + * takes an array. `R.unapply` is the inverse of [`R.apply`](#apply). + * + * @func + * @memberOf R + * @since v0.8.0 + * @category Function + * @sig ([*...] -> a) -> (*... -> a) + * @param {Function} fn + * @return {Function} + * @see R.apply + * @example + * + * R.unapply(JSON.stringify)(1, 2, 3); //=> '[1,2,3]' + * @symb R.unapply(f)(a, b) = f([a, b]) + */ + var unapply = _curry1(function unapply(fn) { + return function() { + return fn(Array.prototype.slice.call(arguments, 0)); + }; + }); + + /** + * Wraps a function of any arity (including nullary) in a function that accepts + * exactly 1 parameter. Any extraneous parameters will not be passed to the + * supplied function. + * + * @func + * @memberOf R + * @since v0.2.0 + * @category Function + * @sig (* -> b) -> (a -> b) + * @param {Function} fn The function to wrap. + * @return {Function} A new function wrapping `fn`. The new function is guaranteed to be of + * arity 1. + * @see R.binary, R.nAry + * @example + * + * const takesTwoArgs = function(a, b) { + * return [a, b]; + * }; + * takesTwoArgs.length; //=> 2 + * takesTwoArgs(1, 2); //=> [1, 2] + * + * const takesOneArg = R.unary(takesTwoArgs); + * takesOneArg.length; //=> 1 + * // Only 1 argument is passed to the wrapped function + * takesOneArg(1, 2); //=> [1, undefined] + * @symb R.unary(f)(a, b, c) = f(a) + */ + var unary = _curry1(function unary(fn) { + return nAry(1, fn); + }); + + /** + * Returns a function of arity `n` from a (manually) curried function. + * + * @func + * @memberOf R + * @since v0.14.0 + * @category Function + * @sig Number -> (a -> b) -> (a -> c) + * @param {Number} length The arity for the returned function. + * @param {Function} fn The function to uncurry. + * @return {Function} A new function. + * @see R.curry + * @example + * + * const addFour = a => b => c => d => a + b + c + d; + * + * const uncurriedAddFour = R.uncurryN(4, addFour); + * uncurriedAddFour(1, 2, 3, 4); //=> 10 + */ + var uncurryN = _curry2(function uncurryN(depth, fn) { + return curryN(depth, function() { + var currentDepth = 1; + var value = fn; + var idx = 0; + var endIdx; + while (currentDepth <= depth && typeof value === 'function') { + endIdx = currentDepth === depth ? arguments.length : idx + value.length; + value = value.apply(this, Array.prototype.slice.call(arguments, idx, endIdx)); + currentDepth += 1; + idx = endIdx; + } + return value; + }); + }); + + /** + * Builds a list from a seed value. Accepts an iterator function, which returns + * either false to stop iteration or an array of length 2 containing the value + * to add to the resulting list and the seed to be used in the next call to the + * iterator function. + * + * The iterator function receives one argument: *(seed)*. + * + * @func + * @memberOf R + * @since v0.10.0 + * @category List + * @sig (a -> [b]) -> * -> [b] + * @param {Function} fn The iterator function. receives one argument, `seed`, and returns + * either false to quit iteration or an array of length two to proceed. The element + * at index 0 of this array will be added to the resulting array, and the element + * at index 1 will be passed to the next call to `fn`. + * @param {*} seed The seed value. + * @return {Array} The final list. + * @example + * + * const f = n => n > 50 ? false : [-n, n + 10]; + * R.unfold(f, 10); //=> [-10, -20, -30, -40, -50] + * @symb R.unfold(f, x) = [f(x)[0], f(f(x)[1])[0], f(f(f(x)[1])[1])[0], ...] + */ + var unfold = _curry2(function unfold(fn, seed) { + var pair = fn(seed); + var result = []; + while (pair && pair.length) { + result[result.length] = pair[0]; + pair = fn(pair[1]); } - } - return result; -}); - -/** - * Returns the left-to-right Kleisli composition of the provided functions, - * each of which must return a value of a type supported by [`chain`](#chain). - * - * `R.pipeK(f, g, h)` is equivalent to `R.pipe(f, R.chain(g), R.chain(h))`. - * - * @func - * @memberOf R - * @since v0.16.0 - * @category Function - * @sig Chain m => ((a -> m b), (b -> m c), ..., (y -> m z)) -> (a -> m z) - * @param {...Function} - * @return {Function} - * @see R.composeK - * @example - * - * // parseJson :: String -> Maybe * - * // get :: String -> Object -> Maybe * - * - * // getStateCode :: Maybe String -> Maybe String - * const getStateCode = R.pipeK( - * parseJson, - * get('user'), - * get('address'), - * get('state'), - * R.compose(Maybe.of, R.toUpper) - * ); - * - * getStateCode('{"user":{"address":{"state":"ny"}}}'); - * //=> Just('NY') - * getStateCode('[Invalid JSON]'); - * //=> Nothing() - * @symb R.pipeK(f, g, h)(a) = R.chain(h, R.chain(g, f(a))) - */ -function pipeK() { - if (arguments.length === 0) { - throw new Error('pipeK requires at least one argument'); - } - return composeK.apply(this, reverse(arguments)); -} - -/** - * Returns a new list with the given element at the front, followed by the - * contents of the list. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category List - * @sig a -> [a] -> [a] - * @param {*} el The item to add to the head of the output list. - * @param {Array} list The array to add to the tail of the output list. - * @return {Array} A new array. - * @see R.append - * @example - * - * R.prepend('fee', ['fi', 'fo', 'fum']); //=> ['fee', 'fi', 'fo', 'fum'] - */ -var prepend = _curry2(function prepend(el, list) { - return _concat([el], list); -}); - -/** - * Multiplies together all the elements of a list. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Math - * @sig [Number] -> Number - * @param {Array} list An array of numbers - * @return {Number} The product of all the numbers in the list. - * @see R.reduce - * @example - * - * R.product([2,4,6,8,100,1]); //=> 38400 - */ -var product = reduce(multiply, 1); - -/** - * Accepts a function `fn` and a list of transformer functions and returns a - * new curried function. When the new function is invoked, it calls the - * function `fn` with parameters consisting of the result of calling each - * supplied handler on successive arguments to the new function. - * - * If more arguments are passed to the returned function than transformer - * functions, those arguments are passed directly to `fn` as additional - * parameters. If you expect additional arguments that don't need to be - * transformed, although you can ignore them, it's best to pass an identity - * function so that the new function reports the correct arity. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Function - * @sig ((x1, x2, ...) -> z) -> [(a -> x1), (b -> x2), ...] -> (a -> b -> ... -> z) - * @param {Function} fn The function to wrap. - * @param {Array} transformers A list of transformer functions - * @return {Function} The wrapped function. - * @see R.converge - * @example - * - * R.useWith(Math.pow, [R.identity, R.identity])(3, 4); //=> 81 - * R.useWith(Math.pow, [R.identity, R.identity])(3)(4); //=> 81 - * R.useWith(Math.pow, [R.dec, R.inc])(3, 4); //=> 32 - * R.useWith(Math.pow, [R.dec, R.inc])(3)(4); //=> 32 - * @symb R.useWith(f, [g, h])(a, b) = f(g(a), h(b)) - */ -var useWith = _curry2(function useWith(fn, transformers) { - return curryN(transformers.length, function() { - var args = []; + return result; + }); + + /** + * Combines two lists into a set (i.e. no duplicates) composed of the elements + * of each list. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Relation + * @sig [*] -> [*] -> [*] + * @param {Array} as The first list. + * @param {Array} bs The second list. + * @return {Array} The first and second lists concatenated, with + * duplicates removed. + * @example + * + * R.union([1, 2, 3], [2, 3, 4]); //=> [1, 2, 3, 4] + */ + var union = _curry2(compose(uniq, _concat)); + + /** + * Returns a new list containing only one copy of each element in the original + * list, based upon the value returned by applying the supplied predicate to + * two list elements. Prefers the first item if two items compare equal based + * on the predicate. + * + * @func + * @memberOf R + * @since v0.2.0 + * @category List + * @sig ((a, a) -> Boolean) -> [a] -> [a] + * @param {Function} pred A predicate used to test whether two items are equal. + * @param {Array} list The array to consider. + * @return {Array} The list of unique items. + * @example + * + * const strEq = R.eqBy(String); + * R.uniqWith(strEq)([1, '1', 2, 1]); //=> [1, 2] + * R.uniqWith(strEq)([{}, {}]); //=> [{}] + * R.uniqWith(strEq)([1, '1', 1]); //=> [1] + * R.uniqWith(strEq)(['1', 1, 1]); //=> ['1'] + */ + var uniqWith = _curry2(function uniqWith(pred, list) { var idx = 0; - while (idx < transformers.length) { - args.push(transformers[idx].call(this, arguments[idx])); + var len = list.length; + var result = []; + var item; + while (idx < len) { + item = list[idx]; + if (!_includesWith(pred, item, result)) { + result[result.length] = item; + } idx += 1; } - return fn.apply(this, args.concat(Array.prototype.slice.call(arguments, transformers.length))); - }); -}); - -/** - * Reasonable analog to SQL `select` statement. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Object - * @category Relation - * @sig [k] -> [{k: v}] -> [{k: v}] - * @param {Array} props The property names to project - * @param {Array} objs The objects to query - * @return {Array} An array of objects with just the `props` properties. - * @example - * - * const abby = {name: 'Abby', age: 7, hair: 'blond', grade: 2}; - * const fred = {name: 'Fred', age: 12, hair: 'brown', grade: 7}; - * const kids = [abby, fred]; - * R.project(['name', 'grade'], kids); //=> [{name: 'Abby', grade: 2}, {name: 'Fred', grade: 7}] - */ -var project = useWith(_map, [pickAll, identity]); // passing `identity` gives correct arity - -/** - * Returns `true` if the specified object property is equal, in - * [`R.equals`](#equals) terms, to the given value; `false` otherwise. - * You can test multiple properties with [`R.whereEq`](#whereEq). - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Relation - * @sig String -> a -> Object -> Boolean - * @param {String} name - * @param {*} val - * @param {*} obj - * @return {Boolean} - * @see R.whereEq, R.propSatisfies, R.equals - * @example - * - * const abby = {name: 'Abby', age: 7, hair: 'blond'}; - * const fred = {name: 'Fred', age: 12, hair: 'brown'}; - * const rusty = {name: 'Rusty', age: 10, hair: 'brown'}; - * const alois = {name: 'Alois', age: 15, disposition: 'surly'}; - * const kids = [abby, fred, rusty, alois]; - * const hasBrownHair = R.propEq('hair', 'brown'); - * R.filter(hasBrownHair, kids); //=> [fred, rusty] - */ -var propEq = _curry3(function propEq(name, val, obj) { - return equals(val, obj[name]); -}); - -/** - * Returns `true` if the specified object property is of the given type; - * `false` otherwise. - * - * @func - * @memberOf R - * @since v0.16.0 - * @category Type - * @sig Type -> String -> Object -> Boolean - * @param {Function} type - * @param {String} name - * @param {*} obj - * @return {Boolean} - * @see R.is, R.propSatisfies - * @example - * - * R.propIs(Number, 'x', {x: 1, y: 2}); //=> true - * R.propIs(Number, 'x', {x: 'foo'}); //=> false - * R.propIs(Number, 'x', {}); //=> false - */ -var propIs = _curry3(function propIs(type, name, obj) { - return is(type, obj[name]); -}); - -/** - * If the given, non-null object has an own property with the specified name, - * returns the value of that property. Otherwise returns the provided default - * value. - * - * @func - * @memberOf R - * @since v0.6.0 - * @category Object - * @sig a -> String -> Object -> a - * @param {*} val The default value. - * @param {String} p The name of the property to return. - * @param {Object} obj The object to query. - * @return {*} The value of given property of the supplied object or the default value. - * @example - * - * const alice = { - * name: 'ALICE', - * age: 101 - * }; - * const favorite = R.prop('favoriteLibrary'); - * const favoriteWithDefault = R.propOr('Ramda', 'favoriteLibrary'); - * - * favorite(alice); //=> undefined - * favoriteWithDefault(alice); //=> 'Ramda' - */ -var propOr = _curry3(function propOr(val, p, obj) { - return pathOr(val, [p], obj); -}); - -/** - * Returns `true` if the specified object property satisfies the given - * predicate; `false` otherwise. You can test multiple properties with - * [`R.where`](#where). - * - * @func - * @memberOf R - * @since v0.16.0 - * @category Logic - * @sig (a -> Boolean) -> String -> {String: a} -> Boolean - * @param {Function} pred - * @param {String} name - * @param {*} obj - * @return {Boolean} - * @see R.where, R.propEq, R.propIs - * @example - * - * R.propSatisfies(x => x > 0, 'x', {x: 1, y: 2}); //=> true - */ -var propSatisfies = _curry3(function propSatisfies(pred, name, obj) { - return pred(obj[name]); -}); - -/** - * Acts as multiple `prop`: array of keys in, array of values out. Preserves - * order. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Object - * @sig [k] -> {k: v} -> [v] - * @param {Array} ps The property names to fetch - * @param {Object} obj The object to query - * @return {Array} The corresponding values or partially applied function. - * @example - * - * R.props(['x', 'y'], {x: 1, y: 2}); //=> [1, 2] - * R.props(['c', 'a', 'b'], {b: 2, a: 1}); //=> [undefined, 1, 2] - * - * const fullName = R.compose(R.join(' '), R.props(['first', 'last'])); - * fullName({last: 'Bullet-Tooth', age: 33, first: 'Tony'}); //=> 'Tony Bullet-Tooth' - */ -var props = _curry2(function props(ps, obj) { - var len = ps.length; - var out = []; - var idx = 0; - - while (idx < len) { - out[idx] = obj[ps[idx]]; - idx += 1; - } + return result; + }); - return out; -}); - -/** - * Returns a list of numbers from `from` (inclusive) to `to` (exclusive). - * - * @func - * @memberOf R - * @since v0.1.0 - * @category List - * @sig Number -> Number -> [Number] - * @param {Number} from The first number in the list. - * @param {Number} to One more than the last number in the list. - * @return {Array} The list of numbers in the set `[a, b)`. - * @example - * - * R.range(1, 5); //=> [1, 2, 3, 4] - * R.range(50, 53); //=> [50, 51, 52] - */ -var range = _curry2(function range(from, to) { - if (!(_isNumber(from) && _isNumber(to))) { - throw new TypeError('Both arguments to range must be numbers'); - } - var result = []; - var n = from; - while (n < to) { - result.push(n); - n += 1; - } - return result; -}); - -/** - * Returns a single item by iterating through the list, successively calling - * the iterator function and passing it an accumulator value and the current - * value from the array, and then passing the result to the next call. - * - * Similar to [`reduce`](#reduce), except moves through the input list from the - * right to the left. - * - * The iterator function receives two values: *(value, acc)*, while the arguments' - * order of `reduce`'s iterator function is *(acc, value)*. - * - * Note: `R.reduceRight` does not skip deleted or unassigned indices (sparse - * arrays), unlike the native `Array.prototype.reduceRight` method. For more details - * on this behavior, see: - * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduceRight#Description - * - * @func - * @memberOf R - * @since v0.1.0 - * @category List - * @sig ((a, b) -> b) -> b -> [a] -> b - * @param {Function} fn The iterator function. Receives two values, the current element from the array - * and the accumulator. - * @param {*} acc The accumulator value. - * @param {Array} list The list to iterate over. - * @return {*} The final, accumulated value. - * @see R.reduce, R.addIndex - * @example - * - * R.reduceRight(R.subtract, 0, [1, 2, 3, 4]) // => (1 - (2 - (3 - (4 - 0)))) = -2 - * // - -2 - * // / \ / \ - * // 1 - 1 3 - * // / \ / \ - * // 2 - ==> 2 -1 - * // / \ / \ - * // 3 - 3 4 - * // / \ / \ - * // 4 0 4 0 - * - * @symb R.reduceRight(f, a, [b, c, d]) = f(b, f(c, f(d, a))) - */ -var reduceRight = _curry3(function reduceRight(fn, acc, list) { - var idx = list.length - 1; - while (idx >= 0) { - acc = fn(list[idx], acc); - idx -= 1; - } - return acc; -}); - -/** - * Like [`reduce`](#reduce), `reduceWhile` returns a single item by iterating - * through the list, successively calling the iterator function. `reduceWhile` - * also takes a predicate that is evaluated before each step. If the predicate - * returns `false`, it "short-circuits" the iteration and returns the current - * value of the accumulator. - * - * @func - * @memberOf R - * @since v0.22.0 - * @category List - * @sig ((a, b) -> Boolean) -> ((a, b) -> a) -> a -> [b] -> a - * @param {Function} pred The predicate. It is passed the accumulator and the - * current element. - * @param {Function} fn The iterator function. Receives two values, the - * accumulator and the current element. - * @param {*} a The accumulator value. - * @param {Array} list The list to iterate over. - * @return {*} The final, accumulated value. - * @see R.reduce, R.reduced - * @example - * - * const isOdd = (acc, x) => x % 2 === 1; - * const xs = [1, 3, 5, 60, 777, 800]; - * R.reduceWhile(isOdd, R.add, 0, xs); //=> 9 - * - * const ys = [2, 4, 6] - * R.reduceWhile(isOdd, R.add, 111, ys); //=> 111 - */ -var reduceWhile = _curryN(4, [], function _reduceWhile(pred, fn, a, list) { - return _reduce(function(acc, x) { - return pred(acc, x) ? fn(acc, x) : _reduced(acc); - }, a, list); -}); - -/** - * Returns a value wrapped to indicate that it is the final value of the reduce - * and transduce functions. The returned value should be considered a black - * box: the internal structure is not guaranteed to be stable. - * - * Note: this optimization is only available to the below functions: - * - [`reduce`](#reduce) - * - [`reduceWhile`](#reduceWhile) - * - [`transduce`](#transduce) - * - * @func - * @memberOf R - * @since v0.15.0 - * @category List - * @sig a -> * - * @param {*} x The final value of the reduce. - * @return {*} The wrapped value. - * @see R.reduce, R.reduceWhile, R.transduce - * @example - * - * R.reduce( - * (acc, item) => item > 3 ? R.reduced(acc) : acc.concat(item), - * [], - * [1, 2, 3, 4, 5]) // [1, 2, 3] - */ -var reduced = _curry1(_reduced); - -/** - * Calls an input function `n` times, returning an array containing the results - * of those function calls. - * - * `fn` is passed one argument: The current value of `n`, which begins at `0` - * and is gradually incremented to `n - 1`. - * - * @func - * @memberOf R - * @since v0.2.3 - * @category List - * @sig (Number -> a) -> Number -> [a] - * @param {Function} fn The function to invoke. Passed one argument, the current value of `n`. - * @param {Number} n A value between `0` and `n - 1`. Increments after each function call. - * @return {Array} An array containing the return values of all calls to `fn`. - * @see R.repeat - * @example - * - * R.times(R.identity, 5); //=> [0, 1, 2, 3, 4] - * @symb R.times(f, 0) = [] - * @symb R.times(f, 1) = [f(0)] - * @symb R.times(f, 2) = [f(0), f(1)] - */ -var times = _curry2(function times(fn, n) { - var len = Number(n); - var idx = 0; - var list; - - if (len < 0 || isNaN(len)) { - throw new RangeError('n must be a non-negative number'); - } - list = new Array(len); - while (idx < len) { - list[idx] = fn(idx); - idx += 1; - } - return list; -}); - -/** - * Returns a fixed list of size `n` containing a specified identical value. - * - * @func - * @memberOf R - * @since v0.1.1 - * @category List - * @sig a -> n -> [a] - * @param {*} value The value to repeat. - * @param {Number} n The desired size of the output list. - * @return {Array} A new array containing `n` `value`s. - * @see R.times - * @example - * - * R.repeat('hi', 5); //=> ['hi', 'hi', 'hi', 'hi', 'hi'] - * - * const obj = {}; - * const repeatedObjs = R.repeat(obj, 5); //=> [{}, {}, {}, {}, {}] - * repeatedObjs[0] === repeatedObjs[1]; //=> true - * @symb R.repeat(a, 0) = [] - * @symb R.repeat(a, 1) = [a] - * @symb R.repeat(a, 2) = [a, a] - */ -var repeat = _curry2(function repeat(value, n) { - return times(always(value), n); -}); - -/** - * Replace a substring or regex match in a string with a replacement. - * - * The first two parameters correspond to the parameters of the - * `String.prototype.replace()` function, so the second parameter can also be a - * function. - * - * @func - * @memberOf R - * @since v0.7.0 - * @category String - * @sig RegExp|String -> String -> String -> String - * @param {RegExp|String} pattern A regular expression or a substring to match. - * @param {String} replacement The string to replace the matches with. - * @param {String} str The String to do the search and replacement in. - * @return {String} The result. - * @example - * - * R.replace('foo', 'bar', 'foo foo foo'); //=> 'bar foo foo' - * R.replace(/foo/, 'bar', 'foo foo foo'); //=> 'bar foo foo' - * - * // Use the "g" (global) flag to replace all occurrences: - * R.replace(/foo/g, 'bar', 'foo foo foo'); //=> 'bar bar bar' - */ -var replace = _curry3(function replace(regex, replacement, str) { - return str.replace(regex, replacement); -}); - -/** - * Scan is similar to [`reduce`](#reduce), but returns a list of successively - * reduced values from the left - * - * @func - * @memberOf R - * @since v0.10.0 - * @category List - * @sig ((a, b) -> a) -> a -> [b] -> [a] - * @param {Function} fn The iterator function. Receives two values, the accumulator and the - * current element from the array - * @param {*} acc The accumulator value. - * @param {Array} list The list to iterate over. - * @return {Array} A list of all intermediately reduced values. - * @see R.reduce, R.mapAccum - * @example - * - * const numbers = [1, 2, 3, 4]; - * const factorials = R.scan(R.multiply, 1, numbers); //=> [1, 1, 2, 6, 24] - * @symb R.scan(f, a, [b, c]) = [a, f(a, b), f(f(a, b), c)] - */ -var scan = _curry3(function scan(fn, acc, list) { - var idx = 0; - var len = list.length; - var result = [acc]; - while (idx < len) { - acc = fn(acc, list[idx]); - result[idx + 1] = acc; - idx += 1; - } - return result; -}); - -/** - * Transforms a [Traversable](https://github.com/fantasyland/fantasy-land#traversable) - * of [Applicative](https://github.com/fantasyland/fantasy-land#applicative) into an - * Applicative of Traversable. - * - * Dispatches to the `sequence` method of the second argument, if present. - * - * @func - * @memberOf R - * @since v0.19.0 - * @category List - * @sig (Applicative f, Traversable t) => (a -> f a) -> t (f a) -> f (t a) - * @param {Function} of - * @param {*} traversable - * @return {*} - * @see R.traverse - * @example - * - * R.sequence(Maybe.of, [Just(1), Just(2), Just(3)]); //=> Just([1, 2, 3]) - * R.sequence(Maybe.of, [Just(1), Just(2), Nothing()]); //=> Nothing() - * - * R.sequence(R.of, Just([1, 2, 3])); //=> [Just(1), Just(2), Just(3)] - * R.sequence(R.of, Nothing()); //=> [Nothing()] - */ -var sequence = _curry2(function sequence(of, traversable) { - return typeof traversable.sequence === 'function' ? - traversable.sequence(of) : - reduceRight(function(x, acc) { return ap(map(prepend, x), acc); }, - of([]), - traversable); -}); - -/** - * Returns the result of "setting" the portion of the given data structure - * focused by the given lens to the given value. - * - * @func - * @memberOf R - * @since v0.16.0 - * @category Object - * @typedefn Lens s a = Functor f => (a -> f a) -> s -> f s - * @sig Lens s a -> a -> s -> s - * @param {Lens} lens - * @param {*} v - * @param {*} x - * @return {*} - * @see R.prop, R.lensIndex, R.lensProp - * @example - * - * const xLens = R.lensProp('x'); - * - * R.set(xLens, 4, {x: 1, y: 2}); //=> {x: 4, y: 2} - * R.set(xLens, 8, {x: 1, y: 2}); //=> {x: 8, y: 2} - */ -var set = _curry3(function set(lens, v, x) { - return over(lens, always(v), x); -}); - -/** - * Returns a copy of the list, sorted according to the comparator function, - * which should accept two values at a time and return a negative number if the - * first value is smaller, a positive number if it's larger, and zero if they - * are equal. Please note that this is a **copy** of the list. It does not - * modify the original. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category List - * @sig ((a, a) -> Number) -> [a] -> [a] - * @param {Function} comparator A sorting function :: a -> b -> Int - * @param {Array} list The list to sort - * @return {Array} a new array with its elements sorted by the comparator function. - * @example - * - * const diff = function(a, b) { return a - b; }; - * R.sort(diff, [4,2,7,5]); //=> [2, 4, 5, 7] - */ -var sort = _curry2(function sort(comparator, list) { - return Array.prototype.slice.call(list, 0).sort(comparator); -}); - -/** - * Sorts the list according to the supplied function. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Relation - * @sig Ord b => (a -> b) -> [a] -> [a] - * @param {Function} fn - * @param {Array} list The list to sort. - * @return {Array} A new list sorted by the keys generated by `fn`. - * @example - * - * const sortByFirstItem = R.sortBy(R.prop(0)); - * const pairs = [[-1, 1], [-2, 2], [-3, 3]]; - * sortByFirstItem(pairs); //=> [[-3, 3], [-2, 2], [-1, 1]] - * - * const sortByNameCaseInsensitive = R.sortBy(R.compose(R.toLower, R.prop('name'))); - * const alice = { - * name: 'ALICE', - * age: 101 - * }; - * const bob = { - * name: 'Bob', - * age: -10 - * }; - * const clara = { - * name: 'clara', - * age: 314.159 - * }; - * const people = [clara, bob, alice]; - * sortByNameCaseInsensitive(people); //=> [alice, bob, clara] - */ -var sortBy = _curry2(function sortBy(fn, list) { - return Array.prototype.slice.call(list, 0).sort(function(a, b) { - var aa = fn(a); - var bb = fn(b); - return aa < bb ? -1 : aa > bb ? 1 : 0; + /** + * Combines two lists into a set (i.e. no duplicates) composed of the elements + * of each list. Duplication is determined according to the value returned by + * applying the supplied predicate to two list elements. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Relation + * @sig ((a, a) -> Boolean) -> [*] -> [*] -> [*] + * @param {Function} pred A predicate used to test whether two items are equal. + * @param {Array} list1 The first list. + * @param {Array} list2 The second list. + * @return {Array} The first and second lists concatenated, with + * duplicates removed. + * @see R.union + * @example + * + * const l1 = [{a: 1}, {a: 2}]; + * const l2 = [{a: 1}, {a: 4}]; + * R.unionWith(R.eqBy(R.prop('a')), l1, l2); //=> [{a: 1}, {a: 2}, {a: 4}] + */ + var unionWith = _curry3(function unionWith(pred, list1, list2) { + return uniqWith(pred, _concat(list1, list2)); }); -}); - -/** - * Sorts a list according to a list of comparators. - * - * @func - * @memberOf R - * @since v0.23.0 - * @category Relation - * @sig [(a, a) -> Number] -> [a] -> [a] - * @param {Array} functions A list of comparator functions. - * @param {Array} list The list to sort. - * @return {Array} A new list sorted according to the comarator functions. - * @example - * - * const alice = { - * name: 'alice', - * age: 40 - * }; - * const bob = { - * name: 'bob', - * age: 30 - * }; - * const clara = { - * name: 'clara', - * age: 40 - * }; - * const people = [clara, bob, alice]; - * const ageNameSort = R.sortWith([ - * R.descend(R.prop('age')), - * R.ascend(R.prop('name')) - * ]); - * ageNameSort(people); //=> [alice, clara, bob] - */ -var sortWith = _curry2(function sortWith(fns, list) { - return Array.prototype.slice.call(list, 0).sort(function(a, b) { - var result = 0; - var i = 0; - while (result === 0 && i < fns.length) { - result = fns[i](a, b); - i += 1; + + /** + * Tests the final argument by passing it to the given predicate function. If + * the predicate is not satisfied, the function will return the result of + * calling the `whenFalseFn` function with the same argument. If the predicate + * is satisfied, the argument is returned as is. + * + * @func + * @memberOf R + * @since v0.18.0 + * @category Logic + * @sig (a -> Boolean) -> (a -> a) -> a -> a + * @param {Function} pred A predicate function + * @param {Function} whenFalseFn A function to invoke when the `pred` evaluates + * to a falsy value. + * @param {*} x An object to test with the `pred` function and + * pass to `whenFalseFn` if necessary. + * @return {*} Either `x` or the result of applying `x` to `whenFalseFn`. + * @see R.ifElse, R.when, R.cond + * @example + * + * let safeInc = R.unless(R.isNil, R.inc); + * safeInc(null); //=> null + * safeInc(1); //=> 2 + */ + var unless = _curry3(function unless(pred, whenFalseFn, x) { + return pred(x) ? x : whenFalseFn(x); + }); + + /** + * Shorthand for `R.chain(R.identity)`, which removes one level of nesting from + * any [Chain](https://github.com/fantasyland/fantasy-land#chain). + * + * @func + * @memberOf R + * @since v0.3.0 + * @category List + * @sig Chain c => c (c a) -> c a + * @param {*} list + * @return {*} + * @see R.flatten, R.chain + * @example + * + * R.unnest([1, [2], [[3]]]); //=> [1, 2, [3]] + * R.unnest([[1, 2], [3, 4], [5, 6]]); //=> [1, 2, 3, 4, 5, 6] + */ + var unnest = chain(_identity); + + /** + * Takes a predicate, a transformation function, and an initial value, + * and returns a value of the same type as the initial value. + * It does so by applying the transformation until the predicate is satisfied, + * at which point it returns the satisfactory value. + * + * @func + * @memberOf R + * @since v0.20.0 + * @category Logic + * @sig (a -> Boolean) -> (a -> a) -> a -> a + * @param {Function} pred A predicate function + * @param {Function} fn The iterator function + * @param {*} init Initial value + * @return {*} Final value that satisfies predicate + * @example + * + * R.until(R.gt(R.__, 100), R.multiply(2))(1) // => 128 + */ + var until = _curry3(function until(pred, fn, init) { + var val = init; + while (!pred(val)) { + val = fn(val); } - return result; + return val; }); -}); - -/** - * Splits a string into an array of strings based on the given - * separator. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category String - * @sig (String | RegExp) -> String -> [String] - * @param {String|RegExp} sep The pattern. - * @param {String} str The string to separate into an array. - * @return {Array} The array of strings from `str` separated by `str`. - * @see R.join - * @example - * - * const pathComponents = R.split('/'); - * R.tail(pathComponents('/usr/local/bin/node')); //=> ['usr', 'local', 'bin', 'node'] - * - * R.split('.', 'a.b.c.xyz.d'); //=> ['a', 'b', 'c', 'xyz', 'd'] - */ -var split = invoker(1, 'split'); - -/** - * Splits a given list or string at a given index. - * - * @func - * @memberOf R - * @since v0.19.0 - * @category List - * @sig Number -> [a] -> [[a], [a]] - * @sig Number -> String -> [String, String] - * @param {Number} index The index where the array/string is split. - * @param {Array|String} array The array/string to be split. - * @return {Array} - * @example - * - * R.splitAt(1, [1, 2, 3]); //=> [[1], [2, 3]] - * R.splitAt(5, 'hello world'); //=> ['hello', ' world'] - * R.splitAt(-1, 'foobar'); //=> ['fooba', 'r'] - */ -var splitAt = _curry2(function splitAt(index, array) { - return [slice(0, index, array), slice(index, length(array), array)]; -}); - -/** - * Splits a collection into slices of the specified length. - * - * @func - * @memberOf R - * @since v0.16.0 - * @category List - * @sig Number -> [a] -> [[a]] - * @sig Number -> String -> [String] - * @param {Number} n - * @param {Array} list - * @return {Array} - * @example - * - * R.splitEvery(3, [1, 2, 3, 4, 5, 6, 7]); //=> [[1, 2, 3], [4, 5, 6], [7]] - * R.splitEvery(3, 'foobarbaz'); //=> ['foo', 'bar', 'baz'] - */ -var splitEvery = _curry2(function splitEvery(n, list) { - if (n <= 0) { - throw new Error('First argument to splitEvery must be a positive integer'); - } - var result = []; - var idx = 0; - while (idx < list.length) { - result.push(slice(idx, idx += n, list)); - } - return result; -}); - -/** - * Takes a list and a predicate and returns a pair of lists with the following properties: - * - * - the result of concatenating the two output lists is equivalent to the input list; - * - none of the elements of the first output list satisfies the predicate; and - * - if the second output list is non-empty, its first element satisfies the predicate. - * - * @func - * @memberOf R - * @since v0.19.0 - * @category List - * @sig (a -> Boolean) -> [a] -> [[a], [a]] - * @param {Function} pred The predicate that determines where the array is split. - * @param {Array} list The array to be split. - * @return {Array} - * @example - * - * R.splitWhen(R.equals(2), [1, 2, 3, 1, 2, 3]); //=> [[1], [2, 3, 1, 2, 3]] - */ -var splitWhen = _curry2(function splitWhen(pred, list) { - var idx = 0; - var len = list.length; - var prefix = []; - - while (idx < len && !pred(list[idx])) { - prefix.push(list[idx]); - idx += 1; - } - return [prefix, Array.prototype.slice.call(list, idx)]; -}); - -/** - * Checks if a list starts with the provided sublist. - * - * Similarly, checks if a string starts with the provided substring. - * - * @func - * @memberOf R - * @since v0.24.0 - * @category List - * @sig [a] -> [a] -> Boolean - * @sig String -> String -> Boolean - * @param {*} prefix - * @param {*} list - * @return {Boolean} - * @see R.endsWith - * @example - * - * R.startsWith('a', 'abc') //=> true - * R.startsWith('b', 'abc') //=> false - * R.startsWith(['a'], ['a', 'b', 'c']) //=> true - * R.startsWith(['b'], ['a', 'b', 'c']) //=> false - */ -var startsWith = _curry2(function(prefix, list) { - return equals(take(prefix.length, list), prefix); -}); - -/** - * Subtracts its second argument from its first argument. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Math - * @sig Number -> Number -> Number - * @param {Number} a The first value. - * @param {Number} b The second value. - * @return {Number} The result of `a - b`. - * @see R.add - * @example - * - * R.subtract(10, 8); //=> 2 - * - * const minus5 = R.subtract(R.__, 5); - * minus5(17); //=> 12 - * - * const complementaryAngle = R.subtract(90); - * complementaryAngle(30); //=> 60 - * complementaryAngle(72); //=> 18 - */ -var subtract = _curry2(function subtract(a, b) { - return Number(a) - Number(b); -}); - -/** - * Finds the set (i.e. no duplicates) of all elements contained in the first or - * second list, but not both. - * - * @func - * @memberOf R - * @since v0.19.0 - * @category Relation - * @sig [*] -> [*] -> [*] - * @param {Array} list1 The first list. - * @param {Array} list2 The second list. - * @return {Array} The elements in `list1` or `list2`, but not both. - * @see R.symmetricDifferenceWith, R.difference, R.differenceWith - * @example - * - * R.symmetricDifference([1,2,3,4], [7,6,5,4,3]); //=> [1,2,7,6,5] - * R.symmetricDifference([7,6,5,4,3], [1,2,3,4]); //=> [7,6,5,1,2] - */ -var symmetricDifference = _curry2(function symmetricDifference(list1, list2) { - return concat(difference(list1, list2), difference(list2, list1)); -}); - -/** - * Finds the set (i.e. no duplicates) of all elements contained in the first or - * second list, but not both. Duplication is determined according to the value - * returned by applying the supplied predicate to two list elements. - * - * @func - * @memberOf R - * @since v0.19.0 - * @category Relation - * @sig ((a, a) -> Boolean) -> [a] -> [a] -> [a] - * @param {Function} pred A predicate used to test whether two items are equal. - * @param {Array} list1 The first list. - * @param {Array} list2 The second list. - * @return {Array} The elements in `list1` or `list2`, but not both. - * @see R.symmetricDifference, R.difference, R.differenceWith - * @example - * - * const eqA = R.eqBy(R.prop('a')); - * const l1 = [{a: 1}, {a: 2}, {a: 3}, {a: 4}]; - * const l2 = [{a: 3}, {a: 4}, {a: 5}, {a: 6}]; - * R.symmetricDifferenceWith(eqA, l1, l2); //=> [{a: 1}, {a: 2}, {a: 5}, {a: 6}] - */ -var symmetricDifferenceWith = _curry3(function symmetricDifferenceWith(pred, list1, list2) { - return concat(differenceWith(pred, list1, list2), differenceWith(pred, list2, list1)); -}); - -/** - * Returns a new list containing the last `n` elements of a given list, passing - * each value to the supplied predicate function, and terminating when the - * predicate function returns `false`. Excludes the element that caused the - * predicate function to fail. The predicate function is passed one argument: - * *(value)*. - * - * @func - * @memberOf R - * @since v0.16.0 - * @category List - * @sig (a -> Boolean) -> [a] -> [a] - * @sig (a -> Boolean) -> String -> String - * @param {Function} fn The function called per iteration. - * @param {Array} xs The collection to iterate over. - * @return {Array} A new array. - * @see R.dropLastWhile, R.addIndex - * @example - * - * const isNotOne = x => x !== 1; - * - * R.takeLastWhile(isNotOne, [1, 2, 3, 4]); //=> [2, 3, 4] - * - * R.takeLastWhile(x => x !== 'R' , 'Ramda'); //=> 'amda' - */ -var takeLastWhile = _curry2(function takeLastWhile(fn, xs) { - var idx = xs.length - 1; - while (idx >= 0 && fn(xs[idx])) { - idx -= 1; - } - return slice(idx + 1, Infinity, xs); -}); - -function XTakeWhile(f, xf) { - this.xf = xf; - this.f = f; -} -XTakeWhile.prototype['@@transducer/init'] = _xfBase.init; -XTakeWhile.prototype['@@transducer/result'] = _xfBase.result; -XTakeWhile.prototype['@@transducer/step'] = function(result, input) { - return this.f(input) ? this.xf['@@transducer/step'](result, input) : _reduced(result); -}; - -var _xtakeWhile = _curry2(function _xtakeWhile(f, xf) { return new XTakeWhile(f, xf); }); - -/** - * Returns a new list containing the first `n` elements of a given list, - * passing each value to the supplied predicate function, and terminating when - * the predicate function returns `false`. Excludes the element that caused the - * predicate function to fail. The predicate function is passed one argument: - * *(value)*. - * - * Dispatches to the `takeWhile` method of the second argument, if present. - * - * Acts as a transducer if a transformer is given in list position. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category List - * @sig (a -> Boolean) -> [a] -> [a] - * @sig (a -> Boolean) -> String -> String - * @param {Function} fn The function called per iteration. - * @param {Array} xs The collection to iterate over. - * @return {Array} A new array. - * @see R.dropWhile, R.transduce, R.addIndex - * @example - * - * const isNotFour = x => x !== 4; - * - * R.takeWhile(isNotFour, [1, 2, 3, 4, 3, 2, 1]); //=> [1, 2, 3] - * - * R.takeWhile(x => x !== 'd' , 'Ramda'); //=> 'Ram' - */ -var takeWhile = _curry2(_dispatchable(['takeWhile'], _xtakeWhile, function takeWhile(fn, xs) { - var idx = 0; - var len = xs.length; - while (idx < len && fn(xs[idx])) { - idx += 1; - } - return slice(0, idx, xs); -})); + /** + * Returns a list of all the properties, including prototype properties, of the + * supplied object. + * Note that the order of the output array is not guaranteed to be consistent + * across different JS platforms. + * + * @func + * @memberOf R + * @since v0.2.0 + * @category Object + * @sig {k: v} -> [v] + * @param {Object} obj The object to extract values from + * @return {Array} An array of the values of the object's own and prototype properties. + * @see R.values, R.keysIn + * @example + * + * const F = function() { this.x = 'X'; }; + * F.prototype.y = 'Y'; + * const f = new F(); + * R.valuesIn(f); //=> ['X', 'Y'] + */ + var valuesIn = _curry1(function valuesIn(obj) { + var prop; + var vs = []; + for (prop in obj) { + vs[vs.length] = obj[prop]; + } + return vs; + }); -function XTap(f, xf) { - this.xf = xf; - this.f = f; -} -XTap.prototype['@@transducer/init'] = _xfBase.init; -XTap.prototype['@@transducer/result'] = _xfBase.result; -XTap.prototype['@@transducer/step'] = function(result, input) { - this.f(input); - return this.xf['@@transducer/step'](result, input); -}; - -var _xtap = _curry2(function _xtap(f, xf) { return new XTap(f, xf); }); - -/** - * Runs the given function with the supplied object, then returns the object. - * - * Acts as a transducer if a transformer is given as second parameter. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Function - * @sig (a -> *) -> a -> a - * @param {Function} fn The function to call with `x`. The return value of `fn` will be thrown away. - * @param {*} x - * @return {*} `x`. - * @example - * - * const sayX = x => console.log('x is ' + x); - * R.tap(sayX, 100); //=> 100 - * // logs 'x is 100' - * @symb R.tap(f, a) = a - */ -var tap = _curry2(_dispatchable([], _xtap, function tap(fn, x) { - fn(x); - return x; -})); + // `Const` is a functor that effectively ignores the function given to `map`. + var Const = function(x) { + return {value: x, 'fantasy-land/map': function() { return this; }}; + }; -function _isRegExp(x) { - return Object.prototype.toString.call(x) === '[object RegExp]'; -} - -/** - * Determines whether a given string matches a given regular expression. - * - * @func - * @memberOf R - * @since v0.12.0 - * @category String - * @sig RegExp -> String -> Boolean - * @param {RegExp} pattern - * @param {String} str - * @return {Boolean} - * @see R.match - * @example - * - * R.test(/^x/, 'xyz'); //=> true - * R.test(/^y/, 'xyz'); //=> false - */ -var test = _curry2(function test(pattern, str) { - if (!_isRegExp(pattern)) { - throw new TypeError('‘test’ requires a value of type RegExp as its first argument; received ' + toString$1(pattern)); - } - return _cloneRegExp(pattern).test(str); -}); - -/** - * Returns the result of applying the onSuccess function to the value inside - * a successfully resolved promise. This is useful for working with promises - * inside function compositions. - * - * @func - * @memberOf R - * @category Function - * @sig (a -> b) -> (Promise e a) -> (Promise e b) - * @sig (a -> (Promise e b)) -> (Promise e a) -> (Promise e b) - * @param {Function} onSuccess The function to apply. Can return a value or a promise of a value. - * @param {Promise} p - * @return {Promise} The result of calling `p.then(onSuccess)` - * @see R.otherwise - * @example - * - * var makeQuery = (email) => ({ query: { email }}); - * - * //getMemberName :: String -> Promise ({firstName, lastName}) - * var getMemberName = R.pipe( - * makeQuery, - * fetchMember, - * R.then(R.pick(['firstName', 'lastName'])) - * ); - */ -const then = _curry2(function then(f, p) { - _assertPromise('then', p); - - return p.then(f); -}); - -/** - * The lower case version of a string. - * - * @func - * @memberOf R - * @since v0.9.0 - * @category String - * @sig String -> String - * @param {String} str The string to lower case. - * @return {String} The lower case version of `str`. - * @see R.toUpper - * @example - * - * R.toLower('XYZ'); //=> 'xyz' - */ -var toLower = invoker(0, 'toLowerCase'); - -/** - * Converts an object into an array of key, value arrays. Only the object's - * own properties are used. - * Note that the order of the output array is not guaranteed to be consistent - * across different JS platforms. - * - * @func - * @memberOf R - * @since v0.4.0 - * @category Object - * @sig {String: *} -> [[String,*]] - * @param {Object} obj The object to extract from - * @return {Array} An array of key, value arrays from the object's own properties. - * @see R.fromPairs - * @example - * - * R.toPairs({a: 1, b: 2, c: 3}); //=> [['a', 1], ['b', 2], ['c', 3]] - */ -var toPairs = _curry1(function toPairs(obj) { - var pairs = []; - for (var prop in obj) { - if (_has(prop, obj)) { - pairs[pairs.length] = [prop, obj[prop]]; + /** + * Returns a "view" of the given data structure, determined by the given lens. + * The lens's focus determines which portion of the data structure is visible. + * + * @func + * @memberOf R + * @since v0.16.0 + * @category Object + * @typedefn Lens s a = Functor f => (a -> f a) -> s -> f s + * @sig Lens s a -> s -> a + * @param {Lens} lens + * @param {*} x + * @return {*} + * @see R.prop, R.lensIndex, R.lensProp + * @example + * + * const xLens = R.lensProp('x'); + * + * R.view(xLens, {x: 1, y: 2}); //=> 1 + * R.view(xLens, {x: 4, y: 2}); //=> 4 + */ + var view = _curry2(function view(lens, x) { + // Using `Const` effectively ignores the setter function of the `lens`, + // leaving the value returned by the getter function unmodified. + return lens(Const)(x).value; + }); + + /** + * Tests the final argument by passing it to the given predicate function. If + * the predicate is satisfied, the function will return the result of calling + * the `whenTrueFn` function with the same argument. If the predicate is not + * satisfied, the argument is returned as is. + * + * @func + * @memberOf R + * @since v0.18.0 + * @category Logic + * @sig (a -> Boolean) -> (a -> a) -> a -> a + * @param {Function} pred A predicate function + * @param {Function} whenTrueFn A function to invoke when the `condition` + * evaluates to a truthy value. + * @param {*} x An object to test with the `pred` function and + * pass to `whenTrueFn` if necessary. + * @return {*} Either `x` or the result of applying `x` to `whenTrueFn`. + * @see R.ifElse, R.unless, R.cond + * @example + * + * // truncate :: String -> String + * const truncate = R.when( + * R.propSatisfies(R.gt(R.__, 10), 'length'), + * R.pipe(R.take(10), R.append('…'), R.join('')) + * ); + * truncate('12345'); //=> '12345' + * truncate('0123456789ABC'); //=> '0123456789…' + */ + var when = _curry3(function when(pred, whenTrueFn, x) { + return pred(x) ? whenTrueFn(x) : x; + }); + + /** + * Takes a spec object and a test object; returns true if the test satisfies + * the spec. Each of the spec's own properties must be a predicate function. + * Each predicate is applied to the value of the corresponding property of the + * test object. `where` returns true if all the predicates return true, false + * otherwise. + * + * `where` is well suited to declaratively expressing constraints for other + * functions such as [`filter`](#filter) and [`find`](#find). + * + * @func + * @memberOf R + * @since v0.1.1 + * @category Object + * @sig {String: (* -> Boolean)} -> {String: *} -> Boolean + * @param {Object} spec + * @param {Object} testObj + * @return {Boolean} + * @see R.propSatisfies, R.whereEq + * @example + * + * // pred :: Object -> Boolean + * const pred = R.where({ + * a: R.equals('foo'), + * b: R.complement(R.equals('bar')), + * x: R.gt(R.__, 10), + * y: R.lt(R.__, 20) + * }); + * + * pred({a: 'foo', b: 'xxx', x: 11, y: 19}); //=> true + * pred({a: 'xxx', b: 'xxx', x: 11, y: 19}); //=> false + * pred({a: 'foo', b: 'bar', x: 11, y: 19}); //=> false + * pred({a: 'foo', b: 'xxx', x: 10, y: 19}); //=> false + * pred({a: 'foo', b: 'xxx', x: 11, y: 20}); //=> false + */ + var where = _curry2(function where(spec, testObj) { + for (var prop in spec) { + if (_has(prop, spec) && !spec[prop](testObj[prop])) { + return false; + } } - } - return pairs; -}); - -/** - * Converts an object into an array of key, value arrays. The object's own - * properties and prototype properties are used. Note that the order of the - * output array is not guaranteed to be consistent across different JS - * platforms. - * - * @func - * @memberOf R - * @since v0.4.0 - * @category Object - * @sig {String: *} -> [[String,*]] - * @param {Object} obj The object to extract from - * @return {Array} An array of key, value arrays from the object's own - * and prototype properties. - * @example - * - * const F = function() { this.x = 'X'; }; - * F.prototype.y = 'Y'; - * const f = new F(); - * R.toPairsIn(f); //=> [['x','X'], ['y','Y']] - */ -var toPairsIn = _curry1(function toPairsIn(obj) { - var pairs = []; - for (var prop in obj) { - pairs[pairs.length] = [prop, obj[prop]]; - } - return pairs; -}); - -/** - * The upper case version of a string. - * - * @func - * @memberOf R - * @since v0.9.0 - * @category String - * @sig String -> String - * @param {String} str The string to upper case. - * @return {String} The upper case version of `str`. - * @see R.toLower - * @example - * - * R.toUpper('abc'); //=> 'ABC' - */ -var toUpper = invoker(0, 'toUpperCase'); - -/** - * Initializes a transducer using supplied iterator function. Returns a single - * item by iterating through the list, successively calling the transformed - * iterator function and passing it an accumulator value and the current value - * from the array, and then passing the result to the next call. - * - * The iterator function receives two values: *(acc, value)*. It will be - * wrapped as a transformer to initialize the transducer. A transformer can be - * passed directly in place of an iterator function. In both cases, iteration - * may be stopped early with the [`R.reduced`](#reduced) function. - * - * A transducer is a function that accepts a transformer and returns a - * transformer and can be composed directly. - * - * A transformer is an an object that provides a 2-arity reducing iterator - * function, step, 0-arity initial value function, init, and 1-arity result - * extraction function, result. The step function is used as the iterator - * function in reduce. The result function is used to convert the final - * accumulator into the return type and in most cases is - * [`R.identity`](#identity). The init function can be used to provide an - * initial accumulator, but is ignored by transduce. - * - * The iteration is performed with [`R.reduce`](#reduce) after initializing the transducer. - * - * @func - * @memberOf R - * @since v0.12.0 - * @category List - * @sig (c -> c) -> ((a, b) -> a) -> a -> [b] -> a - * @param {Function} xf The transducer function. Receives a transformer and returns a transformer. - * @param {Function} fn The iterator function. Receives two values, the accumulator and the - * current element from the array. Wrapped as transformer, if necessary, and used to - * initialize the transducer - * @param {*} acc The initial accumulator value. - * @param {Array} list The list to iterate over. - * @return {*} The final, accumulated value. - * @see R.reduce, R.reduced, R.into - * @example - * - * const numbers = [1, 2, 3, 4]; - * const transducer = R.compose(R.map(R.add(1)), R.take(2)); - * R.transduce(transducer, R.flip(R.append), [], numbers); //=> [2, 3] - * - * const isOdd = (x) => x % 2 === 1; - * const firstOddTransducer = R.compose(R.filter(isOdd), R.take(1)); - * R.transduce(firstOddTransducer, R.flip(R.append), [], R.range(0, 100)); //=> [1] - */ -var transduce = curryN(4, function transduce(xf, fn, acc, list) { - return _reduce(xf(typeof fn === 'function' ? _xwrap(fn) : fn), acc, list); -}); - -/** - * Transposes the rows and columns of a 2D list. - * When passed a list of `n` lists of length `x`, - * returns a list of `x` lists of length `n`. - * - * - * @func - * @memberOf R - * @since v0.19.0 - * @category List - * @sig [[a]] -> [[a]] - * @param {Array} list A 2D list - * @return {Array} A 2D list - * @example - * - * R.transpose([[1, 'a'], [2, 'b'], [3, 'c']]) //=> [[1, 2, 3], ['a', 'b', 'c']] - * R.transpose([[1, 2, 3], ['a', 'b', 'c']]) //=> [[1, 'a'], [2, 'b'], [3, 'c']] - * - * // If some of the rows are shorter than the following rows, their elements are skipped: - * R.transpose([[10, 11], [20], [], [30, 31, 32]]) //=> [[10, 20, 30], [11, 31], [32]] - * @symb R.transpose([[a], [b], [c]]) = [a, b, c] - * @symb R.transpose([[a, b], [c, d]]) = [[a, c], [b, d]] - * @symb R.transpose([[a, b], [c]]) = [[a, c], [b]] - */ -var transpose = _curry1(function transpose(outerlist) { - var i = 0; - var result = []; - while (i < outerlist.length) { - var innerlist = outerlist[i]; - var j = 0; - while (j < innerlist.length) { - if (typeof result[j] === 'undefined') { - result[j] = []; + return true; + }); + + /** + * Takes a spec object and a test object; returns true if the test satisfies + * the spec, false otherwise. An object satisfies the spec if, for each of the + * spec's own properties, accessing that property of the object gives the same + * value (in [`R.equals`](#equals) terms) as accessing that property of the + * spec. + * + * `whereEq` is a specialization of [`where`](#where). + * + * @func + * @memberOf R + * @since v0.14.0 + * @category Object + * @sig {String: *} -> {String: *} -> Boolean + * @param {Object} spec + * @param {Object} testObj + * @return {Boolean} + * @see R.propEq, R.where + * @example + * + * // pred :: Object -> Boolean + * const pred = R.whereEq({a: 1, b: 2}); + * + * pred({a: 1}); //=> false + * pred({a: 1, b: 2}); //=> true + * pred({a: 1, b: 2, c: 3}); //=> true + * pred({a: 1, b: 1}); //=> false + */ + var whereEq = _curry2(function whereEq(spec, testObj) { + return where(map(equals, spec), testObj); + }); + + /** + * Returns a new list without values in the first argument. + * [`R.equals`](#equals) is used to determine equality. + * + * Acts as a transducer if a transformer is given in list position. + * + * @func + * @memberOf R + * @since v0.19.0 + * @category List + * @sig [a] -> [a] -> [a] + * @param {Array} list1 The values to be removed from `list2`. + * @param {Array} list2 The array to remove values from. + * @return {Array} The new array without values in `list1`. + * @see R.transduce, R.difference, R.remove + * @example + * + * R.without([1, 2], [1, 2, 1, 3, 4]); //=> [3, 4] + */ + var without = _curry2(function(xs, list) { + return reject(flip(_includes)(xs), list); + }); + + /** + * Exclusive disjunction logical operation. + * Returns `true` if one of the arguments is truthy and the other is falsy. + * Otherwise, it returns `false`. + * + * @func + * @memberOf R + * @since v0.27.1 + * @category Logic + * @sig a -> b -> Boolean + * @param {Any} a + * @param {Any} b + * @return {Boolean} true if one of the arguments is truthy and the other is falsy + * @see R.or, R.and + * @example + * + * R.xor(true, true); //=> false + * R.xor(true, false); //=> true + * R.xor(false, true); //=> true + * R.xor(false, false); //=> false + */ + var xor = _curry2(function xor(a, b) { + return Boolean(!a ^ !b); + }); + + /** + * Creates a new list out of the two supplied by creating each possible pair + * from the lists. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category List + * @sig [a] -> [b] -> [[a,b]] + * @param {Array} as The first list. + * @param {Array} bs The second list. + * @return {Array} The list made by combining each possible pair from + * `as` and `bs` into pairs (`[a, b]`). + * @example + * + * R.xprod([1, 2], ['a', 'b']); //=> [[1, 'a'], [1, 'b'], [2, 'a'], [2, 'b']] + * @symb R.xprod([a, b], [c, d]) = [[a, c], [a, d], [b, c], [b, d]] + */ + var xprod = _curry2(function xprod(a, b) { // = xprodWith(prepend); (takes about 3 times as long...) + var idx = 0; + var ilen = a.length; + var j; + var jlen = b.length; + var result = []; + while (idx < ilen) { + j = 0; + while (j < jlen) { + result[result.length] = [a[idx], b[j]]; + j += 1; } - result[j].push(innerlist[j]); - j += 1; + idx += 1; } - i += 1; - } - return result; -}); - -/** - * Maps an [Applicative](https://github.com/fantasyland/fantasy-land#applicative)-returning - * function over a [Traversable](https://github.com/fantasyland/fantasy-land#traversable), - * then uses [`sequence`](#sequence) to transform the resulting Traversable of Applicative - * into an Applicative of Traversable. - * - * Dispatches to the `traverse` method of the third argument, if present. - * - * @func - * @memberOf R - * @since v0.19.0 - * @category List - * @sig (Applicative f, Traversable t) => (a -> f a) -> (a -> f b) -> t a -> f (t b) - * @param {Function} of - * @param {Function} f - * @param {*} traversable - * @return {*} - * @see R.sequence - * @example - * - * // Returns `Maybe.Nothing` if the given divisor is `0` - * const safeDiv = n => d => d === 0 ? Maybe.Nothing() : Maybe.Just(n / d) - * - * R.traverse(Maybe.of, safeDiv(10), [2, 4, 5]); //=> Maybe.Just([5, 2.5, 2]) - * R.traverse(Maybe.of, safeDiv(10), [2, 0, 5]); //=> Maybe.Nothing - */ -var traverse = _curry3(function traverse(of, f, traversable) { - return typeof traversable['fantasy-land/traverse'] === 'function' ? - traversable['fantasy-land/traverse'](f, of) : - sequence(of, map(f, traversable)); -}); - -var ws = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003' + - '\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028' + - '\u2029\uFEFF'; -var zeroWidth = '\u200b'; -var hasProtoTrim = (typeof String.prototype.trim === 'function'); -/** - * Removes (strips) whitespace from both ends of the string. - * - * @func - * @memberOf R - * @since v0.6.0 - * @category String - * @sig String -> String - * @param {String} str The string to trim. - * @return {String} Trimmed version of `str`. - * @example - * - * R.trim(' xyz '); //=> 'xyz' - * R.map(R.trim, R.split(',', 'x, y, z')); //=> ['x', 'y', 'z'] - */ -var trim = !hasProtoTrim || (ws.trim() || !zeroWidth.trim()) ? - _curry1(function trim(str) { - var beginRx = new RegExp('^[' + ws + '][' + ws + ']*'); - var endRx = new RegExp('[' + ws + '][' + ws + ']*$'); - return str.replace(beginRx, '').replace(endRx, ''); - }) : - _curry1(function trim(str) { - return str.trim(); - }); - -/** - * `tryCatch` takes two functions, a `tryer` and a `catcher`. The returned - * function evaluates the `tryer`; if it does not throw, it simply returns the - * result. If the `tryer` *does* throw, the returned function evaluates the - * `catcher` function and returns its result. Note that for effective - * composition with this function, both the `tryer` and `catcher` functions - * must return the same type of results. - * - * @func - * @memberOf R - * @since v0.20.0 - * @category Function - * @sig (...x -> a) -> ((e, ...x) -> a) -> (...x -> a) - * @param {Function} tryer The function that may throw. - * @param {Function} catcher The function that will be evaluated if `tryer` throws. - * @return {Function} A new function that will catch exceptions and send then to the catcher. - * @example - * - * R.tryCatch(R.prop('x'), R.F)({x: true}); //=> true - * R.tryCatch(() => { throw 'foo'}, R.always('catched'))('bar') // => 'catched' - * R.tryCatch(R.times(R.identity), R.always([]))('s') // => [] - `` */ -var tryCatch = _curry2(function _tryCatch(tryer, catcher) { - return _arity(tryer.length, function() { - try { - return tryer.apply(this, arguments); - } catch (e) { - return catcher.apply(this, _concat([e], arguments)); - } - }); -}); - -/** - * Takes a function `fn`, which takes a single array argument, and returns a - * function which: - * - * - takes any number of positional arguments; - * - passes these arguments to `fn` as an array; and - * - returns the result. - * - * In other words, `R.unapply` derives a variadic function from a function which - * takes an array. `R.unapply` is the inverse of [`R.apply`](#apply). - * - * @func - * @memberOf R - * @since v0.8.0 - * @category Function - * @sig ([*...] -> a) -> (*... -> a) - * @param {Function} fn - * @return {Function} - * @see R.apply - * @example - * - * R.unapply(JSON.stringify)(1, 2, 3); //=> '[1,2,3]' - * @symb R.unapply(f)(a, b) = f([a, b]) - */ -var unapply = _curry1(function unapply(fn) { - return function() { - return fn(Array.prototype.slice.call(arguments, 0)); - }; -}); - -/** - * Wraps a function of any arity (including nullary) in a function that accepts - * exactly 1 parameter. Any extraneous parameters will not be passed to the - * supplied function. - * - * @func - * @memberOf R - * @since v0.2.0 - * @category Function - * @sig (* -> b) -> (a -> b) - * @param {Function} fn The function to wrap. - * @return {Function} A new function wrapping `fn`. The new function is guaranteed to be of - * arity 1. - * @see R.binary, R.nAry - * @example - * - * const takesTwoArgs = function(a, b) { - * return [a, b]; - * }; - * takesTwoArgs.length; //=> 2 - * takesTwoArgs(1, 2); //=> [1, 2] - * - * const takesOneArg = R.unary(takesTwoArgs); - * takesOneArg.length; //=> 1 - * // Only 1 argument is passed to the wrapped function - * takesOneArg(1, 2); //=> [1, undefined] - * @symb R.unary(f)(a, b, c) = f(a) - */ -var unary = _curry1(function unary(fn) { - return nAry(1, fn); -}); - -/** - * Returns a function of arity `n` from a (manually) curried function. - * - * @func - * @memberOf R - * @since v0.14.0 - * @category Function - * @sig Number -> (a -> b) -> (a -> c) - * @param {Number} length The arity for the returned function. - * @param {Function} fn The function to uncurry. - * @return {Function} A new function. - * @see R.curry - * @example - * - * const addFour = a => b => c => d => a + b + c + d; - * - * const uncurriedAddFour = R.uncurryN(4, addFour); - * uncurriedAddFour(1, 2, 3, 4); //=> 10 - */ -var uncurryN = _curry2(function uncurryN(depth, fn) { - return curryN(depth, function() { - var currentDepth = 1; - var value = fn; + return result; + }); + + /** + * Creates a new list out of the two supplied by pairing up equally-positioned + * items from both lists. The returned list is truncated to the length of the + * shorter of the two input lists. + * Note: `zip` is equivalent to `zipWith(function(a, b) { return [a, b] })`. + * + * @func + * @memberOf R + * @since v0.1.0 + * @category List + * @sig [a] -> [b] -> [[a,b]] + * @param {Array} list1 The first array to consider. + * @param {Array} list2 The second array to consider. + * @return {Array} The list made by pairing up same-indexed elements of `list1` and `list2`. + * @example + * + * R.zip([1, 2, 3], ['a', 'b', 'c']); //=> [[1, 'a'], [2, 'b'], [3, 'c']] + * @symb R.zip([a, b, c], [d, e, f]) = [[a, d], [b, e], [c, f]] + */ + var zip = _curry2(function zip(a, b) { + var rv = []; var idx = 0; - var endIdx; - while (currentDepth <= depth && typeof value === 'function') { - endIdx = currentDepth === depth ? arguments.length : idx + value.length; - value = value.apply(this, Array.prototype.slice.call(arguments, idx, endIdx)); - currentDepth += 1; - idx = endIdx; - } - return value; - }); -}); - -/** - * Builds a list from a seed value. Accepts an iterator function, which returns - * either false to stop iteration or an array of length 2 containing the value - * to add to the resulting list and the seed to be used in the next call to the - * iterator function. - * - * The iterator function receives one argument: *(seed)*. - * - * @func - * @memberOf R - * @since v0.10.0 - * @category List - * @sig (a -> [b]) -> * -> [b] - * @param {Function} fn The iterator function. receives one argument, `seed`, and returns - * either false to quit iteration or an array of length two to proceed. The element - * at index 0 of this array will be added to the resulting array, and the element - * at index 1 will be passed to the next call to `fn`. - * @param {*} seed The seed value. - * @return {Array} The final list. - * @example - * - * const f = n => n > 50 ? false : [-n, n + 10]; - * R.unfold(f, 10); //=> [-10, -20, -30, -40, -50] - * @symb R.unfold(f, x) = [f(x)[0], f(f(x)[1])[0], f(f(f(x)[1])[1])[0], ...] - */ -var unfold = _curry2(function unfold(fn, seed) { - var pair = fn(seed); - var result = []; - while (pair && pair.length) { - result[result.length] = pair[0]; - pair = fn(pair[1]); - } - return result; -}); - -/** - * Combines two lists into a set (i.e. no duplicates) composed of the elements - * of each list. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Relation - * @sig [*] -> [*] -> [*] - * @param {Array} as The first list. - * @param {Array} bs The second list. - * @return {Array} The first and second lists concatenated, with - * duplicates removed. - * @example - * - * R.union([1, 2, 3], [2, 3, 4]); //=> [1, 2, 3, 4] - */ -var union = _curry2(compose(uniq, _concat)); - -/** - * Returns a new list containing only one copy of each element in the original - * list, based upon the value returned by applying the supplied predicate to - * two list elements. Prefers the first item if two items compare equal based - * on the predicate. - * - * @func - * @memberOf R - * @since v0.2.0 - * @category List - * @sig ((a, a) -> Boolean) -> [a] -> [a] - * @param {Function} pred A predicate used to test whether two items are equal. - * @param {Array} list The array to consider. - * @return {Array} The list of unique items. - * @example - * - * const strEq = R.eqBy(String); - * R.uniqWith(strEq)([1, '1', 2, 1]); //=> [1, 2] - * R.uniqWith(strEq)([{}, {}]); //=> [{}] - * R.uniqWith(strEq)([1, '1', 1]); //=> [1] - * R.uniqWith(strEq)(['1', 1, 1]); //=> ['1'] - */ -var uniqWith = _curry2(function uniqWith(pred, list) { - var idx = 0; - var len = list.length; - var result = []; - var item; - while (idx < len) { - item = list[idx]; - if (!_includesWith(pred, item, result)) { - result[result.length] = item; - } - idx += 1; - } - return result; -}); - -/** - * Combines two lists into a set (i.e. no duplicates) composed of the elements - * of each list. Duplication is determined according to the value returned by - * applying the supplied predicate to two list elements. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Relation - * @sig ((a, a) -> Boolean) -> [*] -> [*] -> [*] - * @param {Function} pred A predicate used to test whether two items are equal. - * @param {Array} list1 The first list. - * @param {Array} list2 The second list. - * @return {Array} The first and second lists concatenated, with - * duplicates removed. - * @see R.union - * @example - * - * const l1 = [{a: 1}, {a: 2}]; - * const l2 = [{a: 1}, {a: 4}]; - * R.unionWith(R.eqBy(R.prop('a')), l1, l2); //=> [{a: 1}, {a: 2}, {a: 4}] - */ -var unionWith = _curry3(function unionWith(pred, list1, list2) { - return uniqWith(pred, _concat(list1, list2)); -}); - -/** - * Tests the final argument by passing it to the given predicate function. If - * the predicate is not satisfied, the function will return the result of - * calling the `whenFalseFn` function with the same argument. If the predicate - * is satisfied, the argument is returned as is. - * - * @func - * @memberOf R - * @since v0.18.0 - * @category Logic - * @sig (a -> Boolean) -> (a -> a) -> a -> a - * @param {Function} pred A predicate function - * @param {Function} whenFalseFn A function to invoke when the `pred` evaluates - * to a falsy value. - * @param {*} x An object to test with the `pred` function and - * pass to `whenFalseFn` if necessary. - * @return {*} Either `x` or the result of applying `x` to `whenFalseFn`. - * @see R.ifElse, R.when, R.cond - * @example - * - * let safeInc = R.unless(R.isNil, R.inc); - * safeInc(null); //=> null - * safeInc(1); //=> 2 - */ -var unless = _curry3(function unless(pred, whenFalseFn, x) { - return pred(x) ? x : whenFalseFn(x); -}); - -/** - * Shorthand for `R.chain(R.identity)`, which removes one level of nesting from - * any [Chain](https://github.com/fantasyland/fantasy-land#chain). - * - * @func - * @memberOf R - * @since v0.3.0 - * @category List - * @sig Chain c => c (c a) -> c a - * @param {*} list - * @return {*} - * @see R.flatten, R.chain - * @example - * - * R.unnest([1, [2], [[3]]]); //=> [1, 2, [3]] - * R.unnest([[1, 2], [3, 4], [5, 6]]); //=> [1, 2, 3, 4, 5, 6] - */ -var unnest = chain(_identity); - -/** - * Takes a predicate, a transformation function, and an initial value, - * and returns a value of the same type as the initial value. - * It does so by applying the transformation until the predicate is satisfied, - * at which point it returns the satisfactory value. - * - * @func - * @memberOf R - * @since v0.20.0 - * @category Logic - * @sig (a -> Boolean) -> (a -> a) -> a -> a - * @param {Function} pred A predicate function - * @param {Function} fn The iterator function - * @param {*} init Initial value - * @return {*} Final value that satisfies predicate - * @example - * - * R.until(R.gt(R.__, 100), R.multiply(2))(1) // => 128 - */ -var until = _curry3(function until(pred, fn, init) { - var val = init; - while (!pred(val)) { - val = fn(val); - } - return val; -}); - -/** - * Returns a list of all the properties, including prototype properties, of the - * supplied object. - * Note that the order of the output array is not guaranteed to be consistent - * across different JS platforms. - * - * @func - * @memberOf R - * @since v0.2.0 - * @category Object - * @sig {k: v} -> [v] - * @param {Object} obj The object to extract values from - * @return {Array} An array of the values of the object's own and prototype properties. - * @see R.values, R.keysIn - * @example - * - * const F = function() { this.x = 'X'; }; - * F.prototype.y = 'Y'; - * const f = new F(); - * R.valuesIn(f); //=> ['X', 'Y'] - */ -var valuesIn = _curry1(function valuesIn(obj) { - var prop; - var vs = []; - for (prop in obj) { - vs[vs.length] = obj[prop]; - } - return vs; -}); - -// `Const` is a functor that effectively ignores the function given to `map`. -var Const = function(x) { - return {value: x, 'fantasy-land/map': function() { return this; }}; -}; - -/** - * Returns a "view" of the given data structure, determined by the given lens. - * The lens's focus determines which portion of the data structure is visible. - * - * @func - * @memberOf R - * @since v0.16.0 - * @category Object - * @typedefn Lens s a = Functor f => (a -> f a) -> s -> f s - * @sig Lens s a -> s -> a - * @param {Lens} lens - * @param {*} x - * @return {*} - * @see R.prop, R.lensIndex, R.lensProp - * @example - * - * const xLens = R.lensProp('x'); - * - * R.view(xLens, {x: 1, y: 2}); //=> 1 - * R.view(xLens, {x: 4, y: 2}); //=> 4 - */ -var view = _curry2(function view(lens, x) { - // Using `Const` effectively ignores the setter function of the `lens`, - // leaving the value returned by the getter function unmodified. - return lens(Const)(x).value; -}); - -/** - * Tests the final argument by passing it to the given predicate function. If - * the predicate is satisfied, the function will return the result of calling - * the `whenTrueFn` function with the same argument. If the predicate is not - * satisfied, the argument is returned as is. - * - * @func - * @memberOf R - * @since v0.18.0 - * @category Logic - * @sig (a -> Boolean) -> (a -> a) -> a -> a - * @param {Function} pred A predicate function - * @param {Function} whenTrueFn A function to invoke when the `condition` - * evaluates to a truthy value. - * @param {*} x An object to test with the `pred` function and - * pass to `whenTrueFn` if necessary. - * @return {*} Either `x` or the result of applying `x` to `whenTrueFn`. - * @see R.ifElse, R.unless, R.cond - * @example - * - * // truncate :: String -> String - * const truncate = R.when( - * R.propSatisfies(R.gt(R.__, 10), 'length'), - * R.pipe(R.take(10), R.append('…'), R.join('')) - * ); - * truncate('12345'); //=> '12345' - * truncate('0123456789ABC'); //=> '0123456789…' - */ -var when = _curry3(function when(pred, whenTrueFn, x) { - return pred(x) ? whenTrueFn(x) : x; -}); - -/** - * Takes a spec object and a test object; returns true if the test satisfies - * the spec. Each of the spec's own properties must be a predicate function. - * Each predicate is applied to the value of the corresponding property of the - * test object. `where` returns true if all the predicates return true, false - * otherwise. - * - * `where` is well suited to declaratively expressing constraints for other - * functions such as [`filter`](#filter) and [`find`](#find). - * - * @func - * @memberOf R - * @since v0.1.1 - * @category Object - * @sig {String: (* -> Boolean)} -> {String: *} -> Boolean - * @param {Object} spec - * @param {Object} testObj - * @return {Boolean} - * @see R.propSatisfies, R.whereEq - * @example - * - * // pred :: Object -> Boolean - * const pred = R.where({ - * a: R.equals('foo'), - * b: R.complement(R.equals('bar')), - * x: R.gt(R.__, 10), - * y: R.lt(R.__, 20) - * }); - * - * pred({a: 'foo', b: 'xxx', x: 11, y: 19}); //=> true - * pred({a: 'xxx', b: 'xxx', x: 11, y: 19}); //=> false - * pred({a: 'foo', b: 'bar', x: 11, y: 19}); //=> false - * pred({a: 'foo', b: 'xxx', x: 10, y: 19}); //=> false - * pred({a: 'foo', b: 'xxx', x: 11, y: 20}); //=> false - */ -var where = _curry2(function where(spec, testObj) { - for (var prop in spec) { - if (_has(prop, spec) && !spec[prop](testObj[prop])) { - return false; + var len = Math.min(a.length, b.length); + while (idx < len) { + rv[idx] = [a[idx], b[idx]]; + idx += 1; } - } - return true; -}); - -/** - * Takes a spec object and a test object; returns true if the test satisfies - * the spec, false otherwise. An object satisfies the spec if, for each of the - * spec's own properties, accessing that property of the object gives the same - * value (in [`R.equals`](#equals) terms) as accessing that property of the - * spec. - * - * `whereEq` is a specialization of [`where`](#where). - * - * @func - * @memberOf R - * @since v0.14.0 - * @category Object - * @sig {String: *} -> {String: *} -> Boolean - * @param {Object} spec - * @param {Object} testObj - * @return {Boolean} - * @see R.propEq, R.where - * @example - * - * // pred :: Object -> Boolean - * const pred = R.whereEq({a: 1, b: 2}); - * - * pred({a: 1}); //=> false - * pred({a: 1, b: 2}); //=> true - * pred({a: 1, b: 2, c: 3}); //=> true - * pred({a: 1, b: 1}); //=> false - */ -var whereEq = _curry2(function whereEq(spec, testObj) { - return where(map(equals, spec), testObj); -}); - -/** - * Returns a new list without values in the first argument. - * [`R.equals`](#equals) is used to determine equality. - * - * Acts as a transducer if a transformer is given in list position. - * - * @func - * @memberOf R - * @since v0.19.0 - * @category List - * @sig [a] -> [a] -> [a] - * @param {Array} list1 The values to be removed from `list2`. - * @param {Array} list2 The array to remove values from. - * @return {Array} The new array without values in `list1`. - * @see R.transduce, R.difference, R.remove - * @example - * - * R.without([1, 2], [1, 2, 1, 3, 4]); //=> [3, 4] - */ -var without = _curry2(function(xs, list) { - return reject(flip(_includes)(xs), list); -}); - -/** - * Creates a new list out of the two supplied by creating each possible pair - * from the lists. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category List - * @sig [a] -> [b] -> [[a,b]] - * @param {Array} as The first list. - * @param {Array} bs The second list. - * @return {Array} The list made by combining each possible pair from - * `as` and `bs` into pairs (`[a, b]`). - * @example - * - * R.xprod([1, 2], ['a', 'b']); //=> [[1, 'a'], [1, 'b'], [2, 'a'], [2, 'b']] - * @symb R.xprod([a, b], [c, d]) = [[a, c], [a, d], [b, c], [b, d]] - */ -var xprod = _curry2(function xprod(a, b) { // = xprodWith(prepend); (takes about 3 times as long...) - var idx = 0; - var ilen = a.length; - var j; - var jlen = b.length; - var result = []; - while (idx < ilen) { - j = 0; - while (j < jlen) { - result[result.length] = [a[idx], b[j]]; - j += 1; - } - idx += 1; - } - return result; -}); - -/** - * Creates a new list out of the two supplied by pairing up equally-positioned - * items from both lists. The returned list is truncated to the length of the - * shorter of the two input lists. - * Note: `zip` is equivalent to `zipWith(function(a, b) { return [a, b] })`. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category List - * @sig [a] -> [b] -> [[a,b]] - * @param {Array} list1 The first array to consider. - * @param {Array} list2 The second array to consider. - * @return {Array} The list made by pairing up same-indexed elements of `list1` and `list2`. - * @example - * - * R.zip([1, 2, 3], ['a', 'b', 'c']); //=> [[1, 'a'], [2, 'b'], [3, 'c']] - * @symb R.zip([a, b, c], [d, e, f]) = [[a, d], [b, e], [c, f]] - */ -var zip = _curry2(function zip(a, b) { - var rv = []; - var idx = 0; - var len = Math.min(a.length, b.length); - while (idx < len) { - rv[idx] = [a[idx], b[idx]]; - idx += 1; - } - return rv; -}); - -/** - * Creates a new object out of a list of keys and a list of values. - * Key/value pairing is truncated to the length of the shorter of the two lists. - * Note: `zipObj` is equivalent to `pipe(zip, fromPairs)`. - * - * @func - * @memberOf R - * @since v0.3.0 - * @category List - * @sig [String] -> [*] -> {String: *} - * @param {Array} keys The array that will be properties on the output object. - * @param {Array} values The list of values on the output object. - * @return {Object} The object made by pairing up same-indexed elements of `keys` and `values`. - * @example - * - * R.zipObj(['a', 'b', 'c'], [1, 2, 3]); //=> {a: 1, b: 2, c: 3} - */ -var zipObj = _curry2(function zipObj(keys, values) { - var idx = 0; - var len = Math.min(keys.length, values.length); - var out = {}; - while (idx < len) { - out[keys[idx]] = values[idx]; - idx += 1; - } - return out; -}); - -/** - * Creates a new list out of the two supplied by applying the function to each - * equally-positioned pair in the lists. The returned list is truncated to the - * length of the shorter of the two input lists. - * - * @function - * @memberOf R - * @since v0.1.0 - * @category List - * @sig ((a, b) -> c) -> [a] -> [b] -> [c] - * @param {Function} fn The function used to combine the two elements into one value. - * @param {Array} list1 The first array to consider. - * @param {Array} list2 The second array to consider. - * @return {Array} The list made by combining same-indexed elements of `list1` and `list2` - * using `fn`. - * @example - * - * const f = (x, y) => { - * // ... - * }; - * R.zipWith(f, [1, 2, 3], ['a', 'b', 'c']); - * //=> [f(1, 'a'), f(2, 'b'), f(3, 'c')] - * @symb R.zipWith(fn, [a, b, c], [d, e, f]) = [fn(a, d), fn(b, e), fn(c, f)] - */ -var zipWith = _curry3(function zipWith(fn, a, b) { - var rv = []; - var idx = 0; - var len = Math.min(a.length, b.length); - while (idx < len) { - rv[idx] = fn(a[idx], b[idx]); - idx += 1; - } - return rv; -}); - -/** - * Creates a thunk out of a function. A thunk delays a calculation until - * its result is needed, providing lazy evaluation of arguments. - * - * @func - * @memberOf R - * @category Function - * @sig ((a, b, ..., j) -> k) -> (a, b, ..., j) -> (() -> k) - * @param {Function} fn A function to wrap in a thunk - * @return {Function} Expects arguments for `fn` and returns a new function - * that, when called, applies those arguments to `fn`. - * @see R.partial, R.partialRight - * @example - * - * R.thunkify(R.identity)(42)(); //=> 42 - * R.thunkify((a, b) => a + b)(25, 17)(); //=> 42 - */ -var thunkify = _curry1(function thunkify(fn) { - return curryN(fn.length, function createThunk() { - const fnArgs = arguments; - return function invokeThunk() { - return fn.apply(this, fnArgs); - }; + return rv; + }); + + /** + * Creates a new object out of a list of keys and a list of values. + * Key/value pairing is truncated to the length of the shorter of the two lists. + * Note: `zipObj` is equivalent to `pipe(zip, fromPairs)`. + * + * @func + * @memberOf R + * @since v0.3.0 + * @category List + * @sig [String] -> [*] -> {String: *} + * @param {Array} keys The array that will be properties on the output object. + * @param {Array} values The list of values on the output object. + * @return {Object} The object made by pairing up same-indexed elements of `keys` and `values`. + * @example + * + * R.zipObj(['a', 'b', 'c'], [1, 2, 3]); //=> {a: 1, b: 2, c: 3} + */ + var zipObj = _curry2(function zipObj(keys, values) { + var idx = 0; + var len = Math.min(keys.length, values.length); + var out = {}; + while (idx < len) { + out[keys[idx]] = values[idx]; + idx += 1; + } + return out; + }); + + /** + * Creates a new list out of the two supplied by applying the function to each + * equally-positioned pair in the lists. The returned list is truncated to the + * length of the shorter of the two input lists. + * + * @function + * @memberOf R + * @since v0.1.0 + * @category List + * @sig ((a, b) -> c) -> [a] -> [b] -> [c] + * @param {Function} fn The function used to combine the two elements into one value. + * @param {Array} list1 The first array to consider. + * @param {Array} list2 The second array to consider. + * @return {Array} The list made by combining same-indexed elements of `list1` and `list2` + * using `fn`. + * @example + * + * const f = (x, y) => { + * // ... + * }; + * R.zipWith(f, [1, 2, 3], ['a', 'b', 'c']); + * //=> [f(1, 'a'), f(2, 'b'), f(3, 'c')] + * @symb R.zipWith(fn, [a, b, c], [d, e, f]) = [fn(a, d), fn(b, e), fn(c, f)] + */ + var zipWith = _curry3(function zipWith(fn, a, b) { + var rv = []; + var idx = 0; + var len = Math.min(a.length, b.length); + while (idx < len) { + rv[idx] = fn(a[idx], b[idx]); + idx += 1; + } + return rv; + }); + + /** + * Creates a thunk out of a function. A thunk delays a calculation until + * its result is needed, providing lazy evaluation of arguments. + * + * @func + * @memberOf R + * @since v0.26.0 + * @category Function + * @sig ((a, b, ..., j) -> k) -> (a, b, ..., j) -> (() -> k) + * @param {Function} fn A function to wrap in a thunk + * @return {Function} Expects arguments for `fn` and returns a new function + * that, when called, applies those arguments to `fn`. + * @see R.partial, R.partialRight + * @example + * + * R.thunkify(R.identity)(42)(); //=> 42 + * R.thunkify((a, b) => a + b)(25, 17)(); //=> 42 + */ + var thunkify = _curry1(function thunkify(fn) { + return curryN(fn.length, function createThunk() { + var fnArgs = arguments; + return function invokeThunk() { + return fn.apply(this, fnArgs); + }; + }); }); -}); - -exports.F = F; -exports.T = T; -exports.__ = __; -exports.add = add; -exports.addIndex = addIndex; -exports.adjust = adjust; -exports.all = all; -exports.allPass = allPass; -exports.always = always; -exports.and = and; -exports.any = any; -exports.anyPass = anyPass; -exports.ap = ap; -exports.aperture = aperture; -exports.append = append; -exports.apply = apply; -exports.applySpec = applySpec; -exports.applyTo = applyTo; -exports.ascend = ascend; -exports.assoc = assoc; -exports.assocPath = assocPath; -exports.binary = binary; -exports.bind = bind; -exports.both = both; -exports.call = call; -exports.chain = chain; -exports.clamp = clamp; -exports.clone = clone; -exports.comparator = comparator; -exports.complement = complement; -exports.compose = compose; -exports.composeK = composeK; -exports.composeP = composeP; -exports.composeWith = composeWith; -exports.concat = concat; -exports.cond = cond; -exports.construct = construct; -exports.constructN = constructN; -exports.contains = contains$1; -exports.converge = converge; -exports.countBy = countBy; -exports.curry = curry; -exports.curryN = curryN; -exports.dec = dec; -exports.defaultTo = defaultTo; -exports.descend = descend; -exports.difference = difference; -exports.differenceWith = differenceWith; -exports.dissoc = dissoc; -exports.dissocPath = dissocPath; -exports.divide = divide; -exports.drop = drop; -exports.dropLast = dropLast; -exports.dropLastWhile = dropLastWhile; -exports.dropRepeats = dropRepeats; -exports.dropRepeatsWith = dropRepeatsWith; -exports.dropWhile = dropWhile; -exports.either = either; -exports.empty = empty; -exports.endsWith = endsWith; -exports.eqBy = eqBy; -exports.eqProps = eqProps; -exports.equals = equals; -exports.evolve = evolve; -exports.filter = filter; -exports.find = find; -exports.findIndex = findIndex; -exports.findLast = findLast; -exports.findLastIndex = findLastIndex; -exports.flatten = flatten; -exports.flip = flip; -exports.forEach = forEach; -exports.forEachObjIndexed = forEachObjIndexed; -exports.fromPairs = fromPairs; -exports.groupBy = groupBy; -exports.groupWith = groupWith; -exports.gt = gt; -exports.gte = gte; -exports.has = has; -exports.hasIn = hasIn; -exports.hasPath = hasPath; -exports.head = head; -exports.identical = identical; -exports.identity = identity; -exports.ifElse = ifElse; -exports.inc = inc; -exports.includes = includes; -exports.indexBy = indexBy; -exports.indexOf = indexOf; -exports.init = init; -exports.innerJoin = innerJoin; -exports.insert = insert; -exports.insertAll = insertAll; -exports.intersection = intersection; -exports.intersperse = intersperse; -exports.into = into; -exports.invert = invert; -exports.invertObj = invertObj; -exports.invoker = invoker; -exports.is = is; -exports.isEmpty = isEmpty; -exports.isNil = isNil; -exports.join = join; -exports.juxt = juxt; -exports.keys = keys; -exports.keysIn = keysIn; -exports.last = last; -exports.lastIndexOf = lastIndexOf; -exports.length = length; -exports.lens = lens; -exports.lensIndex = lensIndex; -exports.lensPath = lensPath; -exports.lensProp = lensProp; -exports.lift = lift; -exports.liftN = liftN; -exports.lt = lt; -exports.lte = lte; -exports.map = map; -exports.mapAccum = mapAccum; -exports.mapAccumRight = mapAccumRight; -exports.mapObjIndexed = mapObjIndexed; -exports.match = match; -exports.mathMod = mathMod; -exports.max = max; -exports.maxBy = maxBy; -exports.mean = mean; -exports.median = median; -exports.memoizeWith = memoizeWith; -exports.merge = merge; -exports.mergeAll = mergeAll; -exports.mergeDeepLeft = mergeDeepLeft; -exports.mergeDeepRight = mergeDeepRight; -exports.mergeDeepWith = mergeDeepWith; -exports.mergeDeepWithKey = mergeDeepWithKey; -exports.mergeLeft = mergeLeft; -exports.mergeRight = mergeRight; -exports.mergeWith = mergeWith; -exports.mergeWithKey = mergeWithKey; -exports.min = min; -exports.minBy = minBy; -exports.modulo = modulo; -exports.multiply = multiply; -exports.nAry = nAry; -exports.negate = negate; -exports.none = none; -exports.not = not; -exports.nth = nth; -exports.nthArg = nthArg; -exports.o = o; -exports.objOf = objOf; -exports.of = of; -exports.omit = omit; -exports.once = once; -exports.or = or; -exports.otherwise = otherwise; -exports.over = over; -exports.pair = pair; -exports.partial = partial; -exports.partialRight = partialRight; -exports.partition = partition; -exports.path = path; -exports.pathEq = pathEq; -exports.pathOr = pathOr; -exports.pathSatisfies = pathSatisfies; -exports.pick = pick; -exports.pickAll = pickAll; -exports.pickBy = pickBy; -exports.pipe = pipe; -exports.pipeK = pipeK; -exports.pipeP = pipeP; -exports.pipeWith = pipeWith; -exports.pluck = pluck; -exports.prepend = prepend; -exports.product = product; -exports.project = project; -exports.prop = prop; -exports.propEq = propEq; -exports.propIs = propIs; -exports.propOr = propOr; -exports.propSatisfies = propSatisfies; -exports.props = props; -exports.range = range; -exports.reduce = reduce; -exports.reduceBy = reduceBy; -exports.reduceRight = reduceRight; -exports.reduceWhile = reduceWhile; -exports.reduced = reduced; -exports.reject = reject; -exports.remove = remove; -exports.repeat = repeat; -exports.replace = replace; -exports.reverse = reverse; -exports.scan = scan; -exports.sequence = sequence; -exports.set = set; -exports.slice = slice; -exports.sort = sort; -exports.sortBy = sortBy; -exports.sortWith = sortWith; -exports.split = split; -exports.splitAt = splitAt; -exports.splitEvery = splitEvery; -exports.splitWhen = splitWhen; -exports.startsWith = startsWith; -exports.subtract = subtract; -exports.sum = sum; -exports.symmetricDifference = symmetricDifference; -exports.symmetricDifferenceWith = symmetricDifferenceWith; -exports.tail = tail; -exports.take = take; -exports.takeLast = takeLast; -exports.takeLastWhile = takeLastWhile; -exports.takeWhile = takeWhile; -exports.tap = tap; -exports.test = test; -exports.then = then; -exports.times = times; -exports.toLower = toLower; -exports.toPairs = toPairs; -exports.toPairsIn = toPairsIn; -exports.toString = toString$1; -exports.toUpper = toUpper; -exports.transduce = transduce; -exports.transpose = transpose; -exports.traverse = traverse; -exports.trim = trim; -exports.tryCatch = tryCatch; -exports.type = type; -exports.unapply = unapply; -exports.unary = unary; -exports.uncurryN = uncurryN; -exports.unfold = unfold; -exports.union = union; -exports.unionWith = unionWith; -exports.uniq = uniq; -exports.uniqBy = uniqBy; -exports.uniqWith = uniqWith; -exports.unless = unless; -exports.unnest = unnest; -exports.until = until; -exports.update = update; -exports.useWith = useWith; -exports.values = values; -exports.valuesIn = valuesIn; -exports.view = view; -exports.when = when; -exports.where = where; -exports.whereEq = whereEq; -exports.without = without; -exports.xprod = xprod; -exports.zip = zip; -exports.zipObj = zipObj; -exports.zipWith = zipWith; -exports.thunkify = thunkify; - -Object.defineProperty(exports, '__esModule', { value: true }); - -}))); + + exports.F = F; + exports.T = T; + exports.__ = __; + exports.add = add; + exports.addIndex = addIndex; + exports.adjust = adjust; + exports.all = all; + exports.allPass = allPass; + exports.always = always; + exports.and = and; + exports.any = any; + exports.anyPass = anyPass; + exports.ap = ap; + exports.aperture = aperture; + exports.append = append; + exports.apply = apply; + exports.applySpec = applySpec; + exports.applyTo = applyTo; + exports.ascend = ascend; + exports.assoc = assoc; + exports.assocPath = assocPath; + exports.binary = binary; + exports.bind = bind; + exports.both = both; + exports.call = call; + exports.chain = chain; + exports.clamp = clamp; + exports.clone = clone; + exports.comparator = comparator; + exports.complement = complement; + exports.compose = compose; + exports.composeK = composeK; + exports.composeP = composeP; + exports.composeWith = composeWith; + exports.concat = concat; + exports.cond = cond; + exports.construct = construct; + exports.constructN = constructN; + exports.contains = contains$1; + exports.converge = converge; + exports.countBy = countBy; + exports.curry = curry; + exports.curryN = curryN; + exports.dec = dec; + exports.defaultTo = defaultTo; + exports.descend = descend; + exports.difference = difference; + exports.differenceWith = differenceWith; + exports.dissoc = dissoc; + exports.dissocPath = dissocPath; + exports.divide = divide; + exports.drop = drop; + exports.dropLast = dropLast$1; + exports.dropLastWhile = dropLastWhile$1; + exports.dropRepeats = dropRepeats; + exports.dropRepeatsWith = dropRepeatsWith; + exports.dropWhile = dropWhile; + exports.either = either; + exports.empty = empty; + exports.endsWith = endsWith; + exports.eqBy = eqBy; + exports.eqProps = eqProps; + exports.equals = equals; + exports.evolve = evolve; + exports.filter = filter; + exports.find = find; + exports.findIndex = findIndex; + exports.findLast = findLast; + exports.findLastIndex = findLastIndex; + exports.flatten = flatten; + exports.flip = flip; + exports.forEach = forEach; + exports.forEachObjIndexed = forEachObjIndexed; + exports.fromPairs = fromPairs; + exports.groupBy = groupBy; + exports.groupWith = groupWith; + exports.gt = gt; + exports.gte = gte; + exports.has = has; + exports.hasIn = hasIn; + exports.hasPath = hasPath; + exports.head = head; + exports.identical = identical; + exports.identity = identity; + exports.ifElse = ifElse; + exports.inc = inc; + exports.includes = includes; + exports.indexBy = indexBy; + exports.indexOf = indexOf; + exports.init = init; + exports.innerJoin = innerJoin; + exports.insert = insert; + exports.insertAll = insertAll; + exports.intersection = intersection; + exports.intersperse = intersperse; + exports.into = into; + exports.invert = invert; + exports.invertObj = invertObj; + exports.invoker = invoker; + exports.is = is; + exports.isEmpty = isEmpty; + exports.isNil = isNil; + exports.join = join; + exports.juxt = juxt; + exports.keys = keys; + exports.keysIn = keysIn; + exports.last = last; + exports.lastIndexOf = lastIndexOf; + exports.length = length; + exports.lens = lens; + exports.lensIndex = lensIndex; + exports.lensPath = lensPath; + exports.lensProp = lensProp; + exports.lift = lift; + exports.liftN = liftN; + exports.lt = lt; + exports.lte = lte; + exports.map = map; + exports.mapAccum = mapAccum; + exports.mapAccumRight = mapAccumRight; + exports.mapObjIndexed = mapObjIndexed; + exports.match = match; + exports.mathMod = mathMod; + exports.max = max; + exports.maxBy = maxBy; + exports.mean = mean; + exports.median = median; + exports.memoizeWith = memoizeWith; + exports.merge = merge; + exports.mergeAll = mergeAll; + exports.mergeDeepLeft = mergeDeepLeft; + exports.mergeDeepRight = mergeDeepRight; + exports.mergeDeepWith = mergeDeepWith; + exports.mergeDeepWithKey = mergeDeepWithKey; + exports.mergeLeft = mergeLeft; + exports.mergeRight = mergeRight; + exports.mergeWith = mergeWith; + exports.mergeWithKey = mergeWithKey; + exports.min = min; + exports.minBy = minBy; + exports.modulo = modulo; + exports.move = move; + exports.multiply = multiply; + exports.nAry = nAry; + exports.negate = negate; + exports.none = none; + exports.not = not; + exports.nth = nth; + exports.nthArg = nthArg; + exports.o = o; + exports.objOf = objOf; + exports.of = of; + exports.omit = omit; + exports.once = once; + exports.or = or; + exports.otherwise = otherwise; + exports.over = over; + exports.pair = pair; + exports.partial = partial; + exports.partialRight = partialRight; + exports.partition = partition; + exports.path = path; + exports.paths = paths; + exports.pathEq = pathEq; + exports.pathOr = pathOr; + exports.pathSatisfies = pathSatisfies; + exports.pick = pick; + exports.pickAll = pickAll; + exports.pickBy = pickBy; + exports.pipe = pipe; + exports.pipeK = pipeK; + exports.pipeP = pipeP; + exports.pipeWith = pipeWith; + exports.pluck = pluck; + exports.prepend = prepend; + exports.product = product; + exports.project = project; + exports.prop = prop; + exports.propEq = propEq; + exports.propIs = propIs; + exports.propOr = propOr; + exports.propSatisfies = propSatisfies; + exports.props = props; + exports.range = range; + exports.reduce = reduce; + exports.reduceBy = reduceBy; + exports.reduceRight = reduceRight; + exports.reduceWhile = reduceWhile; + exports.reduced = reduced; + exports.reject = reject; + exports.remove = remove; + exports.repeat = repeat; + exports.replace = replace; + exports.reverse = reverse; + exports.scan = scan; + exports.sequence = sequence; + exports.set = set; + exports.slice = slice; + exports.sort = sort; + exports.sortBy = sortBy; + exports.sortWith = sortWith; + exports.split = split; + exports.splitAt = splitAt; + exports.splitEvery = splitEvery; + exports.splitWhen = splitWhen; + exports.startsWith = startsWith; + exports.subtract = subtract; + exports.sum = sum; + exports.symmetricDifference = symmetricDifference; + exports.symmetricDifferenceWith = symmetricDifferenceWith; + exports.tail = tail; + exports.take = take; + exports.takeLast = takeLast; + exports.takeLastWhile = takeLastWhile; + exports.takeWhile = takeWhile; + exports.tap = tap; + exports.test = test; + exports.andThen = andThen; + exports.times = times; + exports.toLower = toLower; + exports.toPairs = toPairs; + exports.toPairsIn = toPairsIn; + exports.toString = toString$1; + exports.toUpper = toUpper; + exports.transduce = transduce; + exports.transpose = transpose; + exports.traverse = traverse; + exports.trim = trim; + exports.tryCatch = tryCatch; + exports.type = type; + exports.unapply = unapply; + exports.unary = unary; + exports.uncurryN = uncurryN; + exports.unfold = unfold; + exports.union = union; + exports.unionWith = unionWith; + exports.uniq = uniq; + exports.uniqBy = uniqBy; + exports.uniqWith = uniqWith; + exports.unless = unless; + exports.unnest = unnest; + exports.until = until; + exports.update = update; + exports.useWith = useWith; + exports.values = values; + exports.valuesIn = valuesIn; + exports.view = view; + exports.when = when; + exports.where = where; + exports.whereEq = whereEq; + exports.without = without; + exports.xor = xor; + exports.xprod = xprod; + exports.zip = zip; + exports.zipObj = zipObj; + exports.zipWith = zipWith; + exports.thunkify = thunkify; + + Object.defineProperty(exports, '__esModule', { value: true }); + +})); diff --git a/dist/ramda.min.js b/dist/ramda.min.js index e180905db0..ee0823ca11 100644 --- a/dist/ramda.min.js +++ b/dist/ramda.min.js @@ -1 +1 @@ -!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n(t.R={})}(this,function(t){"use strict";function n(t){return null!=t&&"object"==typeof t&&!0===t["@@functional/placeholder"]}function r(t){return function r(e){return 0===arguments.length||n(e)?r:t.apply(this,arguments)}}function e(t){return function e(u,i){switch(arguments.length){case 0:return e;case 1:return n(u)?e:r(function(n){return t(u,n)});default:return n(u)&&n(i)?e:n(u)?r(function(n){return t(n,i)}):n(i)?r(function(n){return t(u,n)}):t(u,i)}}}var u=e(function(t,n){return+t+ +n});function i(t,n){var r,e=(t=t||[]).length,u=(n=n||[]).length,i=[];for(r=0;e>r;)i[i.length]=t[r],r+=1;for(r=0;u>r;)i[i.length]=n[r],r+=1;return i}function o(t,n){switch(t){case 0:return function(){return n.apply(this,arguments)};case 1:return function(t){return n.apply(this,arguments)};case 2:return function(t,r){return n.apply(this,arguments)};case 3:return function(t,r,e){return n.apply(this,arguments)};case 4:return function(t,r,e,u){return n.apply(this,arguments)};case 5:return function(t,r,e,u,i){return n.apply(this,arguments)};case 6:return function(t,r,e,u,i,o){return n.apply(this,arguments)};case 7:return function(t,r,e,u,i,o,c){return n.apply(this,arguments)};case 8:return function(t,r,e,u,i,o,c,a){return n.apply(this,arguments)};case 9:return function(t,r,e,u,i,o,c,a,s){return n.apply(this,arguments)};case 10:return function(t,r,e,u,i,o,c,a,s,f){return n.apply(this,arguments)};default:throw Error("First argument to _arity must be a non-negative integer no greater than ten")}}function c(t,r,e){return function(){for(var u=[],i=0,a=t,s=0;r.length>s||arguments.length>i;){var f;s>=r.length||n(r[s])&&arguments.length>i?(f=arguments[i],i+=1):f=r[s],u[s]=f,n(f)||(a-=1),s+=1}return a>0?o(a,c(t,u,e)):e.apply(this,u)}}var a=e(function(t,n){return 1===t?r(n):o(t,c(t,[],n))}),s=r(function(t){return a(t.length,function(){var n=0,r=arguments[0],e=arguments[arguments.length-1],u=Array.prototype.slice.call(arguments,0);return u[0]=function(){var t=r.apply(this,i(arguments,[n,e]));return n+=1,t},t.apply(this,u)})});function f(t){return function u(i,o,c){switch(arguments.length){case 0:return u;case 1:return n(i)?u:e(function(n,r){return t(i,n,r)});case 2:return n(i)&&n(o)?u:n(i)?e(function(n,r){return t(n,o,r)}):n(o)?e(function(n,r){return t(i,n,r)}):r(function(n){return t(i,o,n)});default:return n(i)&&n(o)&&n(c)?u:n(i)&&n(o)?e(function(n,r){return t(n,r,c)}):n(i)&&n(c)?e(function(n,r){return t(n,o,r)}):n(o)&&n(c)?e(function(n,r){return t(i,n,r)}):n(i)?r(function(n){return t(n,o,c)}):n(o)?r(function(n){return t(i,n,c)}):n(c)?r(function(n){return t(i,o,n)}):t(i,o,c)}}}var l=f(function(t,n,r){if(t>=r.length||-r.length>t)return r;var e=(0>t?r.length:0)+t,u=i(r);return u[e]=n(r[e]),u}),p=Array.isArray||function(t){return null!=t&&t.length>=0&&"[object Array]"===Object.prototype.toString.call(t)};function h(t){return null!=t&&"function"==typeof t["@@transducer/step"]}function y(t,n,r){return function(){if(0===arguments.length)return r();var e=Array.prototype.slice.call(arguments,0),u=e.pop();if(!p(u)){for(var i=0;t.length>i;){if("function"==typeof u[t[i]])return u[t[i]].apply(u,e);i+=1}if(h(u))return n.apply(null,e)(u)}return r.apply(this,arguments)}}function d(t){return t&&t["@@transducer/reduced"]?t:{"@@transducer/value":t,"@@transducer/reduced":!0}}var g={init:function(){return this.xf["@@transducer/init"]()},result:function(t){return this.xf["@@transducer/result"](t)}};function v(t,n){this.xf=n,this.f=t,this.all=!0}v.prototype["@@transducer/init"]=g.init,v.prototype["@@transducer/result"]=function(t){return this.all&&(t=this.xf["@@transducer/step"](t,!0)),this.xf["@@transducer/result"](t)},v.prototype["@@transducer/step"]=function(t,n){return this.f(n)||(this.all=!1,t=d(this.xf["@@transducer/step"](t,!1))),t};var m=e(function(t,n){return new v(t,n)}),b=e(y(["all"],m,function(t,n){for(var r=0;n.length>r;){if(!t(n[r]))return!1;r+=1}return!0})),x=e(function(t,n){return n>t?n:t});function w(t,n){for(var r=0,e=n.length,u=Array(e);e>r;)u[r]=t(n[r]),r+=1;return u}function j(t){return"[object String]"===Object.prototype.toString.call(t)}var A=r(function(t){return!!p(t)||!!t&&("object"==typeof t&&(!j(t)&&(1===t.nodeType?!!t.length:0===t.length||t.length>0&&(t.hasOwnProperty(0)&&t.hasOwnProperty(t.length-1)))))});function O(t){this.f=t}function S(t){return new O(t)}O.prototype["@@transducer/init"]=function(){throw Error("init not implemented on XWrap")},O.prototype["@@transducer/result"]=function(t){return t},O.prototype["@@transducer/step"]=function(t,n){return this.f(t,n)};var E=e(function(t,n){return o(t.length,function(){return t.apply(n,arguments)})});function _(t,n,r){for(var e=r.next();!e.done;){if((n=t["@@transducer/step"](n,e.value))&&n["@@transducer/reduced"]){n=n["@@transducer/value"];break}e=r.next()}return t["@@transducer/result"](n)}function q(t,n,r,e){return t["@@transducer/result"](r[e](E(t["@@transducer/step"],t),n))}var k="undefined"!=typeof Symbol?Symbol.iterator:"@@iterator";function N(t,n,r){if("function"==typeof t&&(t=S(t)),A(r))return function(t,n,r){for(var e=0,u=r.length;u>e;){if((n=t["@@transducer/step"](n,r[e]))&&n["@@transducer/reduced"]){n=n["@@transducer/value"];break}e+=1}return t["@@transducer/result"](n)}(t,n,r);if("function"==typeof r["fantasy-land/reduce"])return q(t,n,r,"fantasy-land/reduce");if(null!=r[k])return _(t,n,r[k]());if("function"==typeof r.next)return _(t,n,r);if("function"==typeof r.reduce)return q(t,n,r,"reduce");throw new TypeError("reduce: list must be array or iterable")}function W(t,n){this.xf=n,this.f=t}W.prototype["@@transducer/init"]=g.init,W.prototype["@@transducer/result"]=g.result,W.prototype["@@transducer/step"]=function(t,n){return this.xf["@@transducer/step"](t,this.f(n))};var I=e(function(t,n){return new W(t,n)});function P(t,n){return Object.prototype.hasOwnProperty.call(n,t)}var T=Object.prototype.toString,C=function(){return"[object Arguments]"===T.call(arguments)?function(t){return"[object Arguments]"===T.call(t)}:function(t){return P("callee",t)}}(),B=!{toString:null}.propertyIsEnumerable("toString"),F=["constructor","valueOf","isPrototypeOf","toString","propertyIsEnumerable","hasOwnProperty","toLocaleString"],R=function(){return arguments.propertyIsEnumerable("length")}(),U=function(t,n){for(var r=0;t.length>r;){if(t[r]===n)return!0;r+=1}return!1},D=r("function"!=typeof Object.keys||R?function(t){if(Object(t)!==t)return[];var n,r,e=[],u=R&&C(t);for(n in t)!P(n,t)||u&&"length"===n||(e[e.length]=n);if(B)for(r=F.length-1;r>=0;)P(n=F[r],t)&&!U(e,n)&&(e[e.length]=n),r-=1;return e}:function(t){return Object(t)!==t?[]:Object.keys(t)}),z=e(y(["fantasy-land/map","map"],I,function(t,n){switch(Object.prototype.toString.call(n)){case"[object Function]":return a(n.length,function(){return t.call(this,n.apply(this,arguments))});case"[object Object]":return N(function(r,e){return r[e]=t(n[e]),r},{},D(n));default:return w(t,n)}})),M=e(function(t,n){for(var r=n,e=0;t.length>e;){if(null==r)return;r=r[t[e]],e+=1}return r}),L=e(function(t,n){return M([t],n)}),K=e(function(t,n){return z(L(t),n)}),V=f(N),$=r(function(t){return a(V(x,0,K("length",t)),function(){for(var n=0,r=t.length;r>n;){if(!t[n].apply(this,arguments))return!1;n+=1}return!0})}),H=r(function(t){return function(){return t}}),J=e(function(t,n){return t&&n});function X(t,n){this.xf=n,this.f=t,this.any=!1}X.prototype["@@transducer/init"]=g.init,X.prototype["@@transducer/result"]=function(t){return this.any||(t=this.xf["@@transducer/step"](t,!1)),this.xf["@@transducer/result"](t)},X.prototype["@@transducer/step"]=function(t,n){return this.f(n)&&(this.any=!0,t=d(this.xf["@@transducer/step"](t,!0))),t};var Y=e(function(t,n){return new X(t,n)}),Z=e(y(["any"],Y,function(t,n){for(var r=0;n.length>r;){if(t(n[r]))return!0;r+=1}return!1})),G=r(function(t){return a(V(x,0,K("length",t)),function(){for(var n=0,r=t.length;r>n;){if(t[n].apply(this,arguments))return!0;n+=1}return!1})}),Q=e(function(t,n){return"function"==typeof n["fantasy-land/ap"]?n["fantasy-land/ap"](t):"function"==typeof t.ap?t.ap(n):"function"==typeof t?function(r){return t(r)(n(r))}:N(function(t,r){return i(t,z(r,n))},[],t)});function tt(t,n){this.xf=n,this.pos=0,this.full=!1,this.acc=Array(t)}tt.prototype["@@transducer/init"]=g.init,tt.prototype["@@transducer/result"]=function(t){return this.acc=null,this.xf["@@transducer/result"](t)},tt.prototype["@@transducer/step"]=function(t,n){return this.store(n),this.full?this.xf["@@transducer/step"](t,this.getCopy()):t},tt.prototype.store=function(t){this.acc[this.pos]=t,this.pos+=1,this.pos===this.acc.length&&(this.pos=0,this.full=!0)},tt.prototype.getCopy=function(){return i(Array.prototype.slice.call(this.acc,this.pos),Array.prototype.slice.call(this.acc,0,this.pos))};var nt=e(function(t,n){return new tt(t,n)}),rt=e(y([],nt,function(t,n){for(var r=0,e=n.length-(t-1),u=Array(0>e?0:e);e>r;)u[r]=Array.prototype.slice.call(n,r,r+t),r+=1;return u})),et=e(function(t,n){return i(n,[t])}),ut=e(function(t,n){return t.apply(this,n)}),it=r(function(t){for(var n=D(t),r=n.length,e=[],u=0;r>u;)e[u]=t[n[u]],u+=1;return e});function ot(t,n){return D(n).reduce(function(r,e){return r[e]=t(n[e]),r},{})}var ct=r(function t(n){return n=ot(function(n){return"function"==typeof n?n:t(n)},n),a(V(x,0,K("length",it(n))),function(){var t=arguments;return ot(function(n){return ut(n,t)},n)})}),at=e(function(t,n){return n(t)}),st=f(function(t,n,r){var e=t(n),u=t(r);return u>e?-1:e>u?1:0}),ft=f(function(t,n,r){var e={};for(var u in r)e[u]=r[u];return e[t]=n,e}),lt=Number.isInteger||function(t){return t<<0===t},pt=r(function(t){return null==t}),ht=f(function t(n,r,e){if(0===n.length)return r;var u=n[0];if(n.length>1){var i=!pt(e)&&P(u,e)?e[u]:lt(n[1])?[]:{};r=t(Array.prototype.slice.call(n,1),r,i)}if(lt(u)&&p(e)){var o=[].concat(e);return o[u]=r,o}return ft(u,r,e)}),yt=e(function(t,n){switch(t){case 0:return function(){return n.call(this)};case 1:return function(t){return n.call(this,t)};case 2:return function(t,r){return n.call(this,t,r)};case 3:return function(t,r,e){return n.call(this,t,r,e)};case 4:return function(t,r,e,u){return n.call(this,t,r,e,u)};case 5:return function(t,r,e,u,i){return n.call(this,t,r,e,u,i)};case 6:return function(t,r,e,u,i,o){return n.call(this,t,r,e,u,i,o)};case 7:return function(t,r,e,u,i,o,c){return n.call(this,t,r,e,u,i,o,c)};case 8:return function(t,r,e,u,i,o,c,a){return n.call(this,t,r,e,u,i,o,c,a)};case 9:return function(t,r,e,u,i,o,c,a,s){return n.call(this,t,r,e,u,i,o,c,a,s)};case 10:return function(t,r,e,u,i,o,c,a,s,f){return n.call(this,t,r,e,u,i,o,c,a,s,f)};default:throw Error("First argument to nAry must be a non-negative integer no greater than ten")}}),dt=r(function(t){return yt(2,t)});function gt(t){return"[object Function]"===Object.prototype.toString.call(t)}var vt=e(function(t,n){var r=a(t,n);return a(t,function(){return N(Q,z(r,arguments[0]),Array.prototype.slice.call(arguments,1))})}),mt=r(function(t){return vt(t.length,t)}),bt=e(function(t,n){return gt(t)?function(){return t.apply(this,arguments)&&n.apply(this,arguments)}:mt(J)(t,n)}),xt=r(function(t){return a(t.length,t)}),wt=xt(function(t){return t.apply(this,Array.prototype.slice.call(arguments,1))});function jt(t){return function n(r){for(var e,u,i,o=[],c=0,a=r.length;a>c;){if(A(r[c]))for(i=0,u=(e=t?n(r[c]):r[c]).length;u>i;)o[o.length]=e[i],i+=1;else o[o.length]=r[c];c+=1}return o}}var At=function(t){var n=function(t){return{"@@transducer/init":g.init,"@@transducer/result":function(n){return t["@@transducer/result"](n)},"@@transducer/step":function(n,r){var e=t["@@transducer/step"](n,r);return e["@@transducer/reduced"]?{"@@transducer/value":e,"@@transducer/reduced":!0}:e}}}(t);return{"@@transducer/init":g.init,"@@transducer/result":function(t){return n["@@transducer/result"](t)},"@@transducer/step":function(t,r){return A(r)?N(n,t,r):N(n,t,[r])}}},Ot=e(function(t,n){return z(t,At(n))}),St=e(y(["fantasy-land/chain","chain"],Ot,function(t,n){return"function"==typeof n?function(r){return t(n(r))(r)}:jt(!1)(z(t,n))})),Et=f(function(t,n,r){if(t>n)throw Error("min must not be greater than max in clamp(min, max, value)");return t>r?t:r>n?n:r});function _t(t){return RegExp(t.source,(t.global?"g":"")+(t.ignoreCase?"i":"")+(t.multiline?"m":"")+(t.sticky?"y":"")+(t.unicode?"u":""))}var qt=r(function(t){return null===t?"Null":void 0===t?"Undefined":Object.prototype.toString.call(t).slice(8,-1)});function kt(t,n,r,e){var u=function(u){for(var i=n.length,o=0;i>o;){if(t===n[o])return r[o];o+=1}for(var c in n[o+1]=t,r[o+1]=u,t)u[c]=e?kt(t[c],n,r,!0):t[c];return u};switch(qt(t)){case"Object":return u({});case"Array":return u([]);case"Date":return new Date(t.valueOf());case"RegExp":return _t(t);default:return t}}var Nt=r(function(t){return null!=t&&"function"==typeof t.clone?t.clone():kt(t,[],[],!0)}),Wt=r(function(t){return function(n,r){return t(n,r)?-1:t(r,n)?1:0}}),It=r(function(t){return!t}),Pt=mt(It);function Tt(t,n){return function(){return n.call(this,t.apply(this,arguments))}}function Ct(t,n){return function(){var r=arguments.length;if(0===r)return n();var e=arguments[r-1];return p(e)||"function"!=typeof e[t]?n.apply(this,arguments):e[t].apply(e,Array.prototype.slice.call(arguments,0,r-1))}}var Bt=f(Ct("slice",function(t,n,r){return Array.prototype.slice.call(r,t,n)})),Ft=r(Ct("tail",Bt(1,1/0)));function Rt(){if(0===arguments.length)throw Error("pipe requires at least one argument");return o(arguments[0].length,V(Tt,arguments[0],Ft(arguments)))}var Ut=r(function(t){return j(t)?t.split("").reverse().join(""):Array.prototype.slice.call(t,0).reverse()});function Dt(){if(0===arguments.length)throw Error("compose requires at least one argument");return Rt.apply(this,Ut(arguments))}function zt(){if(0===arguments.length)throw Error("composeK requires at least one argument");var t=Array.prototype.slice.call(arguments),n=t.pop();return Dt(Dt.apply(this,z(St,t)),n)}function Mt(t,n){return function(){var r=this;return t.apply(r,arguments).then(function(t){return n.call(r,t)})}}function Lt(){if(0===arguments.length)throw Error("pipeP requires at least one argument");return o(arguments[0].length,V(Mt,arguments[0],Ft(arguments)))}var Kt=e(function(t,n){var r=0>t?n.length+t:t;return j(n)?n.charAt(r):n[r]}),Vt=Kt(0);function $t(t){return t}var Ht=r($t),Jt=e(function(t,n){if(0>=n.length)return Ht;const r=Vt(n),e=Ft(n);return o(r.length,function(){return N(function(n,r){return t.call(this,r,n)},r.apply(this,arguments),e)})}),Xt=e(function(t,n){return Jt.call(this,t,Ut(n))});function Yt(t){for(var n,r=[];!(n=t.next()).done;)r.push(n.value);return r}function Zt(t,n,r){for(var e=0,u=r.length;u>e;){if(t(n,r[e]))return!0;e+=1}return!1}var Gt="function"==typeof Object.is?Object.is:function(t,n){return t===n?0!==t||1/t==1/n:t!=t&&n!=n};function Qt(t,n,r,e){var u=Yt(t);function i(t,n){return tn(t,n,r.slice(),e.slice())}return!Zt(function(t,n){return!Zt(i,n,t)},Yt(n),u)}function tn(t,n,r,e){if(Gt(t,n))return!0;var u,i=qt(t);if(i!==qt(n))return!1;if(null==t||null==n)return!1;if("function"==typeof t["fantasy-land/equals"]||"function"==typeof n["fantasy-land/equals"])return"function"==typeof t["fantasy-land/equals"]&&t["fantasy-land/equals"](n)&&"function"==typeof n["fantasy-land/equals"]&&n["fantasy-land/equals"](t);if("function"==typeof t.equals||"function"==typeof n.equals)return"function"==typeof t.equals&&t.equals(n)&&"function"==typeof n.equals&&n.equals(t);switch(i){case"Arguments":case"Array":case"Object":if("function"==typeof t.constructor&&"Promise"===(null==(u=(t.constructor+"").match(/^function (\w*)/))?"":u[1]))return t===n;break;case"Boolean":case"Number":case"String":if(typeof t!=typeof n||!Gt(t.valueOf(),n.valueOf()))return!1;break;case"Date":if(!Gt(t.valueOf(),n.valueOf()))return!1;break;case"Error":return t.name===n.name&&t.message===n.message;case"RegExp":if(t.source!==n.source||t.global!==n.global||t.ignoreCase!==n.ignoreCase||t.multiline!==n.multiline||t.sticky!==n.sticky||t.unicode!==n.unicode)return!1}for(var o=r.length-1;o>=0;){if(r[o]===t)return e[o]===n;o-=1}switch(i){case"Map":return t.size===n.size&&Qt(t.entries(),n.entries(),r.concat([t]),e.concat([n]));case"Set":return t.size===n.size&&Qt(t.values(),n.values(),r.concat([t]),e.concat([n]));case"Arguments":case"Array":case"Object":case"Boolean":case"Number":case"String":case"Date":case"Error":case"RegExp":case"Int8Array":case"Uint8Array":case"Uint8ClampedArray":case"Int16Array":case"Uint16Array":case"Int32Array":case"Uint32Array":case"Float32Array":case"Float64Array":case"ArrayBuffer":break;default:return!1}var c=D(t);if(c.length!==D(n).length)return!1;var a=r.concat([t]),s=e.concat([n]);for(o=c.length-1;o>=0;){var f=c[o];if(!P(f,n)||!tn(n[f],t[f],a,s))return!1;o-=1}return!0}var nn=e(function(t,n){return tn(t,n,[],[])});function rn(t,n,r){var e,u;if("function"==typeof t.indexOf)switch(typeof n){case"number":if(0===n){for(e=1/n;t.length>r;){if(0===(u=t[r])&&1/u===e)return r;r+=1}return-1}if(n!=n){for(;t.length>r;){if("number"==typeof(u=t[r])&&u!=u)return r;r+=1}return-1}return t.indexOf(n,r);case"string":case"boolean":case"function":case"undefined":return t.indexOf(n,r);case"object":if(null===n)return t.indexOf(n,r)}for(;t.length>r;){if(nn(t[r],n))return r;r+=1}return-1}function en(t,n){return rn(n,t,0)>=0}function un(t){return'"'+t.replace(/\\/g,"\\\\").replace(/[\b]/g,"\\b").replace(/\f/g,"\\f").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t").replace(/\v/g,"\\v").replace(/\0/g,"\\0").replace(/"/g,'\\"')+'"'}var on=function(t){return(10>t?"0":"")+t},cn="function"==typeof Date.prototype.toISOString?function(t){return t.toISOString()}:function(t){return t.getUTCFullYear()+"-"+on(t.getUTCMonth()+1)+"-"+on(t.getUTCDate())+"T"+on(t.getUTCHours())+":"+on(t.getUTCMinutes())+":"+on(t.getUTCSeconds())+"."+(t.getUTCMilliseconds()/1e3).toFixed(3).slice(2,5)+"Z"};function an(t){return function(){return!t.apply(this,arguments)}}function sn(t,n){for(var r=0,e=n.length,u=[];e>r;)t(n[r])&&(u[u.length]=n[r]),r+=1;return u}function fn(t){return"[object Object]"===Object.prototype.toString.call(t)}function ln(t,n){this.xf=n,this.f=t}ln.prototype["@@transducer/init"]=g.init,ln.prototype["@@transducer/result"]=g.result,ln.prototype["@@transducer/step"]=function(t,n){return this.f(n)?this.xf["@@transducer/step"](t,n):t};var pn=e(function(t,n){return new ln(t,n)}),hn=e(y(["filter"],pn,function(t,n){return fn(n)?N(function(r,e){return t(n[e])&&(r[e]=n[e]),r},{},D(n)):sn(t,n)})),yn=e(function(t,n){return hn(an(t),n)});function dn(t,n){var r=function(r){var e=n.concat([t]);return en(r,e)?"":dn(r,e)},e=function(t,n){return w(function(n){return un(n)+": "+r(t[n])},n.slice().sort())};switch(Object.prototype.toString.call(t)){case"[object Arguments]":return"(function() { return arguments; }("+w(r,t).join(", ")+"))";case"[object Array]":return"["+w(r,t).concat(e(t,yn(function(t){return/^\d+$/.test(t)},D(t)))).join(", ")+"]";case"[object Boolean]":return"object"==typeof t?"new Boolean("+r(t.valueOf())+")":""+t;case"[object Date]":return"new Date("+(isNaN(t.valueOf())?r(NaN):un(cn(t)))+")";case"[object Null]":return"null";case"[object Number]":return"object"==typeof t?"new Number("+r(t.valueOf())+")":1/t==-1/0?"-0":t.toString(10);case"[object String]":return"object"==typeof t?"new String("+r(t.valueOf())+")":un(t);case"[object Undefined]":return"undefined";default:if("function"==typeof t.toString){var u=""+t;if("[object Object]"!==u)return u}return"{"+e(t,D(t)).join(", ")+"}"}}var gn=r(function(t){return dn(t,[])}),vn=e(function(t,n){if(p(t)){if(p(n))return t.concat(n);throw new TypeError(gn(n)+" is not an array")}if(j(t)){if(j(n))return t+n;throw new TypeError(gn(n)+" is not a string")}if(null!=t&>(t["fantasy-land/concat"]))return t["fantasy-land/concat"](n);if(null!=t&>(t.concat))return t.concat(n);throw new TypeError(gn(t)+' does not have a method named "concat" or "fantasy-land/concat"')}),mn=r(function(t){return o(V(x,0,z(function(t){return t[0].length},t)),function(){for(var n=0;t.length>n;){if(t[n][0].apply(this,arguments))return t[n][1].apply(this,arguments);n+=1}})}),bn=e(function(t,n){if(t>10)throw Error("Constructor with greater than ten arguments");return 0===t?function(){return new n}:xt(yt(t,function(t,r,e,u,i,o,c,a,s,f){switch(arguments.length){case 1:return new n(t);case 2:return new n(t,r);case 3:return new n(t,r,e);case 4:return new n(t,r,e,u);case 5:return new n(t,r,e,u,i);case 6:return new n(t,r,e,u,i,o);case 7:return new n(t,r,e,u,i,o,c);case 8:return new n(t,r,e,u,i,o,c,a);case 9:return new n(t,r,e,u,i,o,c,a,s);case 10:return new n(t,r,e,u,i,o,c,a,s,f)}}))}),xn=r(function(t){return bn(t.length,t)}),wn=e(en),jn=e(function(t,n){return a(V(x,0,K("length",n)),function(){var r=arguments,e=this;return t.apply(e,w(function(t){return t.apply(e,r)},n))})});function An(t,n,r,e){this.valueFn=t,this.valueAcc=n,this.keyFn=r,this.xf=e,this.inputs={}}An.prototype["@@transducer/init"]=g.init,An.prototype["@@transducer/result"]=function(t){var n;for(n in this.inputs)if(P(n,this.inputs)&&(t=this.xf["@@transducer/step"](t,this.inputs[n]))["@@transducer/reduced"]){t=t["@@transducer/value"];break}return this.inputs=null,this.xf["@@transducer/result"](t)},An.prototype["@@transducer/step"]=function(t,n){var r=this.keyFn(n);return this.inputs[r]=this.inputs[r]||[r,this.valueAcc],this.inputs[r][1]=this.valueFn(this.inputs[r][1],n),t};var On=c(4,[],function(t,n,r,e){return new An(t,n,r,e)}),Sn=c(4,[],y([],On,function(t,n,r,e){return N(function(e,u){var i=r(u);return e[i]=t(P(i,e)?e[i]:n,u),e},{},e)})),En=Sn(function(t,n){return t+1},0),_n=u(-1),qn=e(function(t,n){return null==n||n!=n?t:n}),kn=f(function(t,n,r){var e=t(n),u=t(r);return e>u?-1:u>e?1:0});function Nn(){this._nativeSet="function"==typeof Set?new Set:null,this._items={}}function Wn(t,n,r){var e,u=typeof t;switch(u){case"string":case"number":return 0===t&&1/t==-1/0?!!r._items["-0"]||(n&&(r._items["-0"]=!0),!1):null!==r._nativeSet?n?(e=r._nativeSet.size,r._nativeSet.add(t),r._nativeSet.size===e):r._nativeSet.has(t):u in r._items?t in r._items[u]||(n&&(r._items[u][t]=!0),!1):(n&&(r._items[u]={},r._items[u][t]=!0),!1);case"boolean":if(u in r._items){var i=t?1:0;return!!r._items[u][i]||(n&&(r._items[u][i]=!0),!1)}return n&&(r._items[u]=t?[!1,!0]:[!0,!1]),!1;case"function":return null!==r._nativeSet?n?(e=r._nativeSet.size,r._nativeSet.add(t),r._nativeSet.size===e):r._nativeSet.has(t):u in r._items?!!en(t,r._items[u])||(n&&r._items[u].push(t),!1):(n&&(r._items[u]=[t]),!1);case"undefined":return!!r._items[u]||(n&&(r._items[u]=!0),!1);case"object":if(null===t)return!!r._items.null||(n&&(r._items.null=!0),!1);default:return(u=Object.prototype.toString.call(t))in r._items?!!en(t,r._items[u])||(n&&r._items[u].push(t),!1):(n&&(r._items[u]=[t]),!1)}}Nn.prototype.add=function(t){return!Wn(t,!0,this)},Nn.prototype.has=function(t){return Wn(t,!1,this)};var In=e(function(t,n){for(var r=[],e=0,u=t.length,i=n.length,o=new Nn,c=0;i>c;c+=1)o.add(n[c]);for(;u>e;)o.add(t[e])&&(r[r.length]=t[e]),e+=1;return r}),Pn=f(function(t,n,r){for(var e=[],u=0,i=n.length;i>u;)Zt(t,n[u],r)||Zt(t,n[u],e)||e.push(n[u]),u+=1;return e}),Tn=e(function(t,n){var r={};for(var e in n)r[e]=n[e];return delete r[t],r}),Cn=f(function(t,n,r){var e=Array.prototype.slice.call(r,0);return e.splice(t,n),e}),Bn=f(function(t,n,r){return l(t,H(n),r)}),Fn=e(function t(n,r){switch(n.length){case 0:return r;case 1:return lt(n[0])&&p(r)?Cn(n[0],1,r):Tn(n[0],r);default:var e=n[0],u=Array.prototype.slice.call(n,1);return null==r[e]?r:lt(e)&&p(r)?Bn(e,t(u,r[e]),r):ft(e,t(u,r[e]),r)}}),Rn=e(function(t,n){return t/n});function Un(t,n){this.xf=n,this.n=t}Un.prototype["@@transducer/init"]=g.init,Un.prototype["@@transducer/result"]=g.result,Un.prototype["@@transducer/step"]=function(t,n){return this.n>0?(this.n-=1,t):this.xf["@@transducer/step"](t,n)};var Dn=e(function(t,n){return new Un(t,n)}),zn=e(y(["drop"],Dn,function(t,n){return Bt(Math.max(0,t),1/0,n)}));function Mn(t,n){this.xf=n,this.n=t,this.i=0}Mn.prototype["@@transducer/init"]=g.init,Mn.prototype["@@transducer/result"]=g.result,Mn.prototype["@@transducer/step"]=function(t,n){this.i+=1;var r=0===this.n?t:this.xf["@@transducer/step"](t,n);return 0>this.n||this.n>this.i?r:d(r)};var Ln=e(function(t,n){return new Mn(t,n)}),Kn=e(y(["take"],Ln,function(t,n){return Bt(0,0>t?1/0:t,n)}));function Vn(t,n){this.xf=n,this.pos=0,this.full=!1,this.acc=Array(t)}Vn.prototype["@@transducer/init"]=g.init,Vn.prototype["@@transducer/result"]=function(t){return this.acc=null,this.xf["@@transducer/result"](t)},Vn.prototype["@@transducer/step"]=function(t,n){return this.full&&(t=this.xf["@@transducer/step"](t,this.acc[this.pos])),this.store(n),t},Vn.prototype.store=function(t){this.acc[this.pos]=t,this.pos+=1,this.pos===this.acc.length&&(this.pos=0,this.full=!0)};var $n=e(function(t,n){return new Vn(t,n)}),Hn=e(y([],$n,function(t,n){return Kn(n.length>t?n.length-t:0,n)}));function Jn(t,n){this.f=t,this.retained=[],this.xf=n}Jn.prototype["@@transducer/init"]=g.init,Jn.prototype["@@transducer/result"]=function(t){return this.retained=null,this.xf["@@transducer/result"](t)},Jn.prototype["@@transducer/step"]=function(t,n){return this.f(n)?this.retain(t,n):this.flush(t,n)},Jn.prototype.flush=function(t,n){return t=N(this.xf["@@transducer/step"],t,this.retained),this.retained=[],this.xf["@@transducer/step"](t,n)},Jn.prototype.retain=function(t,n){return this.retained.push(n),t};var Xn=e(function(t,n){return new Jn(t,n)}),Yn=e(y([],Xn,function(t,n){for(var r=n.length-1;r>=0&&t(n[r]);)r-=1;return Bt(0,r+1,n)}));function Zn(t,n){this.xf=n,this.pred=t,this.lastValue=void 0,this.seenFirstValue=!1}Zn.prototype["@@transducer/init"]=g.init,Zn.prototype["@@transducer/result"]=g.result,Zn.prototype["@@transducer/step"]=function(t,n){var r=!1;return this.seenFirstValue?this.pred(this.lastValue,n)&&(r=!0):this.seenFirstValue=!0,this.lastValue=n,r?t:this.xf["@@transducer/step"](t,n)};var Gn=e(function(t,n){return new Zn(t,n)}),Qn=Kt(-1),tr=e(y([],Gn,function(t,n){var r=[],e=1,u=n.length;if(0!==u)for(r[0]=n[0];u>e;)t(Qn(r),n[e])||(r[r.length]=n[e]),e+=1;return r})),nr=r(y([],Gn(nn),tr(nn)));function rr(t,n){this.xf=n,this.f=t}rr.prototype["@@transducer/init"]=g.init,rr.prototype["@@transducer/result"]=g.result,rr.prototype["@@transducer/step"]=function(t,n){if(this.f){if(this.f(n))return t;this.f=null}return this.xf["@@transducer/step"](t,n)};var er=e(function(t,n){return new rr(t,n)}),ur=e(y(["dropWhile"],er,function(t,n){for(var r=0,e=n.length;e>r&&t(n[r]);)r+=1;return Bt(r,1/0,n)})),ir=e(function(t,n){return t||n}),or=e(function(t,n){return gt(t)?function(){return t.apply(this,arguments)||n.apply(this,arguments)}:mt(ir)(t,n)}),cr=r(function(t){return null!=t&&"function"==typeof t["fantasy-land/empty"]?t["fantasy-land/empty"]():null!=t&&null!=t.constructor&&"function"==typeof t.constructor["fantasy-land/empty"]?t.constructor["fantasy-land/empty"]():null!=t&&"function"==typeof t.empty?t.empty():null!=t&&null!=t.constructor&&"function"==typeof t.constructor.empty?t.constructor.empty():p(t)?[]:j(t)?"":fn(t)?{}:C(t)?function(){return arguments}():void 0}),ar=e(function(t,n){return zn(0>t?0:n.length-t,n)}),sr=e(function(t,n){return nn(ar(t.length,n),t)}),fr=f(function(t,n,r){return nn(t(n),t(r))}),lr=f(function(t,n,r){return nn(n[t],r[t])}),pr=e(function t(n,r){var e,u,i,o=r instanceof Array?[]:{};for(u in r)o[u]="function"===(i=typeof(e=n[u]))?e(r[u]):e&&"object"===i?t(e,r[u]):r[u];return o});function hr(t,n){this.xf=n,this.f=t,this.found=!1}hr.prototype["@@transducer/init"]=g.init,hr.prototype["@@transducer/result"]=function(t){return this.found||(t=this.xf["@@transducer/step"](t,void 0)),this.xf["@@transducer/result"](t)},hr.prototype["@@transducer/step"]=function(t,n){return this.f(n)&&(this.found=!0,t=d(this.xf["@@transducer/step"](t,n))),t};var yr=e(function(t,n){return new hr(t,n)}),dr=e(y(["find"],yr,function(t,n){for(var r=0,e=n.length;e>r;){if(t(n[r]))return n[r];r+=1}}));function gr(t,n){this.xf=n,this.f=t,this.idx=-1,this.found=!1}gr.prototype["@@transducer/init"]=g.init,gr.prototype["@@transducer/result"]=function(t){return this.found||(t=this.xf["@@transducer/step"](t,-1)),this.xf["@@transducer/result"](t)},gr.prototype["@@transducer/step"]=function(t,n){return this.idx+=1,this.f(n)&&(this.found=!0,t=d(this.xf["@@transducer/step"](t,this.idx))),t};var vr=e(function(t,n){return new gr(t,n)}),mr=e(y([],vr,function(t,n){for(var r=0,e=n.length;e>r;){if(t(n[r]))return r;r+=1}return-1}));function br(t,n){this.xf=n,this.f=t}br.prototype["@@transducer/init"]=g.init,br.prototype["@@transducer/result"]=function(t){return this.xf["@@transducer/result"](this.xf["@@transducer/step"](t,this.last))},br.prototype["@@transducer/step"]=function(t,n){return this.f(n)&&(this.last=n),t};var xr=e(function(t,n){return new br(t,n)}),wr=e(y([],xr,function(t,n){for(var r=n.length-1;r>=0;){if(t(n[r]))return n[r];r-=1}}));function jr(t,n){this.xf=n,this.f=t,this.idx=-1,this.lastIdx=-1}jr.prototype["@@transducer/init"]=g.init,jr.prototype["@@transducer/result"]=function(t){return this.xf["@@transducer/result"](this.xf["@@transducer/step"](t,this.lastIdx))},jr.prototype["@@transducer/step"]=function(t,n){return this.idx+=1,this.f(n)&&(this.lastIdx=this.idx),t};var Ar=e(function(t,n){return new jr(t,n)}),Or=e(y([],Ar,function(t,n){for(var r=n.length-1;r>=0;){if(t(n[r]))return r;r-=1}return-1})),Sr=r(jt(!0)),Er=r(function(t){return a(t.length,function(n,r){var e=Array.prototype.slice.call(arguments,0);return e[0]=r,e[1]=n,t.apply(this,e)})}),_r=e(Ct("forEach",function(t,n){for(var r=n.length,e=0;r>e;)t(n[e]),e+=1;return n})),qr=e(function(t,n){for(var r=D(n),e=0;r.length>e;){var u=r[e];t(n[u],u,n),e+=1}return n}),kr=r(function(t){for(var n={},r=0;t.length>r;)n[t[r][0]]=t[r][1],r+=1;return n}),Nr=e(Ct("groupBy",Sn(function(t,n){return null==t&&(t=[]),t.push(n),t},null))),Wr=e(function(t,n){for(var r=[],e=0,u=n.length;u>e;){for(var i=e+1;u>i&&t(n[i-1],n[i]);)i+=1;r.push(n.slice(e,i)),e=i}return r}),Ir=e(function(t,n){return t>n}),Pr=e(function(t,n){return t>=n}),Tr=e(function(t,n){if(0===t.length)return!1;for(var r=n,e=0;t.length>e;){if(!P(t[e],r))return!1;r=r[t[e]],e+=1}return!0}),Cr=e(function(t,n){return Tr([t],n)}),Br=e(function(t,n){return t in n}),Fr=e(Gt),Rr=f(function(t,n,r){return a(Math.max(t.length,n.length,r.length),function(){return t.apply(this,arguments)?n.apply(this,arguments):r.apply(this,arguments)})}),Ur=u(1),Dr=e(en),zr=Sn(function(t,n){return n},null),Mr=e(function(t,n){return"function"!=typeof n.indexOf||p(n)?rn(n,t,0):n.indexOf(t)}),Lr=Bt(0,-1),Kr=f(function(t,n,r){return sn(function(n){return Zt(t,n,r)},n)}),Vr=f(function(t,n,r){t=r.length>t&&t>=0?t:r.length;var e=Array.prototype.slice.call(r,0);return e.splice(t,0,n),e}),$r=f(function(t,n,r){return[].concat(Array.prototype.slice.call(r,0,t=r.length>t&&t>=0?t:r.length),n,Array.prototype.slice.call(r,t))}),Hr=e(function(t,n){for(var r,e,u=new Nn,i=[],o=0;n.length>o;)r=t(e=n[o]),u.add(r)&&i.push(e),o+=1;return i}),Jr=Hr(Ht),Xr=e(function(t,n){var r,e;return t.length>n.length?(r=t,e=n):(r=n,e=t),Jr(sn(Er(en)(r),e))}),Yr=e(Ct("intersperse",function(t,n){for(var r=[],e=0,u=n.length;u>e;)e===u-1?r.push(n[e]):r.push(n[e],t),e+=1;return r}));var Zr="function"==typeof Object.assign?Object.assign:function(t){if(null==t)throw new TypeError("Cannot convert undefined or null to object");for(var n=Object(t),r=1,e=arguments.length;e>r;){var u=arguments[r];if(null!=u)for(var i in u)P(i,u)&&(n[i]=u[i]);r+=1}return n},Gr=e(function(t,n){var r={};return r[t]=n,r}),Qr={"@@transducer/init":Array,"@@transducer/step":function(t,n){return t.push(n),t},"@@transducer/result":$t},te={"@@transducer/init":String,"@@transducer/step":function(t,n){return t+n},"@@transducer/result":$t},ne={"@@transducer/init":Object,"@@transducer/step":function(t,n){return Zr(t,A(n)?Gr(n[0],n[1]):n)},"@@transducer/result":$t};var re=f(function(t,n,r){return h(t)?N(n(t),t["@@transducer/init"](),r):N(n(function(t){if(h(t))return t;if(A(t))return Qr;if("string"==typeof t)return te;if("object"==typeof t)return ne;throw Error("Cannot create transformer for "+t)}(t)),kt(t,[],[],!1),r)}),ee=r(function(t){for(var n=D(t),r=n.length,e=0,u={};r>e;){var i=n[e],o=t[i],c=P(o,u)?u[o]:u[o]=[];c[c.length]=i,e+=1}return u}),ue=r(function(t){for(var n=D(t),r=n.length,e=0,u={};r>e;){var i=n[e];u[t[i]]=i,e+=1}return u}),ie=e(function(t,n){return a(t+1,function(){var r=arguments[t];if(null!=r&>(r[n]))return r[n].apply(r,Array.prototype.slice.call(arguments,0,t));throw new TypeError(gn(r)+' does not have a method named "'+n+'"')})}),oe=e(function(t,n){return null!=n&&n.constructor===t||n instanceof t}),ce=r(function(t){return null!=t&&nn(t,cr(t))}),ae=ie(1,"join"),se=r(function(t){return jn(function(){return Array.prototype.slice.call(arguments,0)},t)}),fe=r(function(t){var n,r=[];for(n in t)r[r.length]=n;return r}),le=e(function(t,n){if("function"!=typeof n.lastIndexOf||p(n)){for(var r=n.length-1;r>=0;){if(nn(n[r],t))return r;r-=1}return-1}return n.lastIndexOf(t)});function pe(t){return"[object Number]"===Object.prototype.toString.call(t)}var he=r(function(t){return null!=t&&pe(t.length)?t.length:NaN}),ye=e(function(t,n){return function(r){return function(e){return z(function(t){return n(t,e)},r(t(e)))}}}),de=r(function(t){return ye(Kt(t),Bn(t))}),ge=r(function(t){return ye(M(t),ht(t))}),ve=r(function(t){return ye(L(t),ft(t))}),me=e(function(t,n){return n>t}),be=e(function(t,n){return n>=t}),xe=f(function(t,n,r){for(var e=0,u=r.length,i=[],o=[n];u>e;)o=t(o[0],r[e]),i[e]=o[1],e+=1;return[o[0],i]}),we=f(function(t,n,r){for(var e=r.length-1,u=[],i=[n];e>=0;)i=t(i[0],r[e]),u[e]=i[1],e-=1;return[i[0],u]}),je=e(function(t,n){return N(function(r,e){return r[e]=t(n[e],e,n),r},{},D(n))}),Ae=e(function(t,n){return n.match(t)||[]}),Oe=e(function(t,n){return lt(t)?!lt(n)||1>n?NaN:(t%n+n)%n:NaN}),Se=f(function(t,n,r){return t(r)>t(n)?r:n}),Ee=V(u,0),_e=r(function(t){return Ee(t)/t.length}),qe=r(function(t){var n=t.length;if(0===n)return NaN;var r=2-n%2,e=(n-r)/2;return _e(Array.prototype.slice.call(t,0).sort(function(t,n){return n>t?-1:t>n?1:0}).slice(e,e+r))}),ke=e(function(t,n){var r={};return o(n.length,function(){var e=t.apply(this,arguments);return P(e,r)||(r[e]=n.apply(this,arguments)),r[e]})}),Ne=e(function(t,n){return Zr({},t,n)}),We=r(function(t){return Zr.apply(null,[{}].concat(t))}),Ie=f(function(t,n,r){var e,u={};for(e in n)P(e,n)&&(u[e]=P(e,r)?t(e,n[e],r[e]):n[e]);for(e in r)P(e,r)&&!P(e,u)&&(u[e]=r[e]);return u}),Pe=f(function t(n,r,e){return Ie(function(r,e,u){return fn(e)&&fn(u)?t(n,e,u):n(r,e,u)},r,e)}),Te=e(function(t,n){return Pe(function(t,n,r){return n},t,n)}),Ce=e(function(t,n){return Pe(function(t,n,r){return r},t,n)}),Be=f(function(t,n,r){return Pe(function(n,r,e){return t(r,e)},n,r)}),Fe=e(function(t,n){return Zr({},n,t)}),Re=e(function(t,n){return Zr({},t,n)}),Ue=f(function(t,n,r){return Ie(function(n,r,e){return t(r,e)},n,r)}),De=e(function(t,n){return t>n?n:t}),ze=f(function(t,n,r){return t(r)t?1:t+1,function(){return Kt(t,arguments)})}),He=f(function(t,n,r){return t(n(r))});var Je=r(function(t){return[t]}),Xe=e(function(t,n){for(var r={},e={},u=0,i=t.length;i>u;)e[t[u]]=1,u+=1;for(var o in n)e.hasOwnProperty(o)||(r[o]=n[o]);return r}),Ye=r(function(t){var n,r=!1;return o(t.length,function(){return r?n:(r=!0,n=t.apply(this,arguments))})});function Ze(t,n){if(null==n||!gt(n.then))throw new TypeError("`"+t+"` expected a Promise, received "+dn(n,[]))}const Ge=e(function(t,n){return Ze("otherwise",n),n.then(null,t)});var Qe=function(t){return{value:t,map:function(n){return Qe(n(t))}}},tu=f(function(t,n,r){return t(function(t){return Qe(n(t))})(r).value}),nu=e(function(t,n){return[t,n]});function ru(t){return e(function(n,r){return o(Math.max(0,n.length-r.length),function(){return n.apply(this,t(r,arguments))})})}var eu=ru(i),uu=ru(Er(i)),iu=se([hn,yn]),ou=f(function(t,n,r){return nn(M(t,r),n)}),cu=f(function(t,n,r){return qn(t,M(n,r))}),au=f(function(t,n,r){return n.length>0&&t(M(n,r))}),su=e(function(t,n){for(var r={},e=0;t.length>e;)t[e]in n&&(r[t[e]]=n[t[e]]),e+=1;return r}),fu=e(function(t,n){for(var r={},e=0,u=t.length;u>e;){var i=t[e];r[i]=n[i],e+=1}return r}),lu=e(function(t,n){var r={};for(var e in n)t(n[e],e,n)&&(r[e]=n[e]);return r});var pu=e(function(t,n){return i([t],n)}),hu=V(Le,1),yu=e(function(t,n){return a(n.length,function(){for(var r=[],e=0;n.length>e;)r.push(n[e].call(this,arguments[e])),e+=1;return t.apply(this,r.concat(Array.prototype.slice.call(arguments,n.length)))})}),du=yu(w,[fu,Ht]),gu=f(function(t,n,r){return nn(n,r[t])}),vu=f(function(t,n,r){return oe(t,r[n])}),mu=f(function(t,n,r){return cu(t,[n],r)}),bu=f(function(t,n,r){return t(r[n])}),xu=e(function(t,n){for(var r=t.length,e=[],u=0;r>u;)e[u]=n[t[u]],u+=1;return e}),wu=e(function(t,n){if(!pe(t)||!pe(n))throw new TypeError("Both arguments to range must be numbers");for(var r=[],e=t;n>e;)r.push(e),e+=1;return r}),ju=f(function(t,n,r){for(var e=r.length-1;e>=0;)n=t(r[e],n),e-=1;return n}),Au=c(4,[],function(t,n,r,e){return N(function(r,e){return t(r,e)?n(r,e):d(r)},r,e)}),Ou=r(d),Su=e(function(t,n){var r,e=+n,u=0;if(0>e||isNaN(e))throw new RangeError("n must be a non-negative number");for(r=Array(e);e>u;)r[u]=t(u),u+=1;return r}),Eu=e(function(t,n){return Su(H(t),n)}),_u=f(function(t,n,r){return r.replace(t,n)}),qu=f(function(t,n,r){for(var e=0,u=r.length,i=[n];u>e;)n=t(n,r[e]),i[e+1]=n,e+=1;return i}),ku=e(function(t,n){return"function"==typeof n.sequence?n.sequence(t):ju(function(t,n){return Q(z(pu,t),n)},t([]),n)}),Nu=f(function(t,n,r){return tu(t,H(n),r)}),Wu=e(function(t,n){return Array.prototype.slice.call(n,0).sort(t)}),Iu=e(function(t,n){return Array.prototype.slice.call(n,0).sort(function(n,r){var e=t(n),u=t(r);return u>e?-1:e>u?1:0})}),Pu=e(function(t,n){return Array.prototype.slice.call(n,0).sort(function(n,r){for(var e=0,u=0;0===e&&t.length>u;)e=t[u](n,r),u+=1;return e})}),Tu=ie(1,"split"),Cu=e(function(t,n){return[Bt(0,t,n),Bt(t,he(n),n)]}),Bu=e(function(t,n){if(0>=t)throw Error("First argument to splitEvery must be a positive integer");for(var r=[],e=0;n.length>e;)r.push(Bt(e,e+=t,n));return r}),Fu=e(function(t,n){for(var r=0,e=n.length,u=[];e>r&&!t(n[r]);)u.push(n[r]),r+=1;return[u,Array.prototype.slice.call(n,r)]}),Ru=e(function(t,n){return nn(Kn(t.length,n),t)}),Uu=e(function(t,n){return+t-+n}),Du=e(function(t,n){return vn(In(t,n),In(n,t))}),zu=f(function(t,n,r){return vn(Pn(t,n,r),Pn(t,r,n))}),Mu=e(function(t,n){for(var r=n.length-1;r>=0&&t(n[r]);)r-=1;return Bt(r+1,1/0,n)});function Lu(t,n){this.xf=n,this.f=t}Lu.prototype["@@transducer/init"]=g.init,Lu.prototype["@@transducer/result"]=g.result,Lu.prototype["@@transducer/step"]=function(t,n){return this.f(n)?this.xf["@@transducer/step"](t,n):d(t)};var Ku=e(function(t,n){return new Lu(t,n)}),Vu=e(y(["takeWhile"],Ku,function(t,n){for(var r=0,e=n.length;e>r&&t(n[r]);)r+=1;return Bt(0,r,n)}));function $u(t,n){this.xf=n,this.f=t}$u.prototype["@@transducer/init"]=g.init,$u.prototype["@@transducer/result"]=g.result,$u.prototype["@@transducer/step"]=function(t,n){return this.f(n),this.xf["@@transducer/step"](t,n)};var Hu=e(function(t,n){return new $u(t,n)}),Ju=e(y([],Hu,function(t,n){return t(n),n}));var Xu=e(function(t,n){if("[object RegExp]"!==Object.prototype.toString.call(t))throw new TypeError("‘test’ requires a value of type RegExp as its first argument; received "+gn(t));return _t(t).test(n)});const Yu=e(function(t,n){return Ze("then",n),n.then(t)});var Zu=ie(0,"toLowerCase"),Gu=r(function(t){var n=[];for(var r in t)P(r,t)&&(n[n.length]=[r,t[r]]);return n}),Qu=r(function(t){var n=[];for(var r in t)n[n.length]=[r,t[r]];return n}),ti=ie(0,"toUpperCase"),ni=a(4,function(t,n,r,e){return N(t("function"==typeof n?S(n):n),r,e)}),ri=r(function(t){for(var n=0,r=[];t.length>n;){for(var e=t[n],u=0;e.length>u;)void 0===r[u]&&(r[u]=[]),r[u].push(e[u]),u+=1;n+=1}return r}),ei=f(function(t,n,r){return"function"==typeof r["fantasy-land/traverse"]?r["fantasy-land/traverse"](n,t):ku(t,z(n,r))}),ui="\t\n\v\f\r   ᠎              \u2028\u2029\ufeff",ii=!("function"==typeof String.prototype.trim)||ui.trim()?r(function(t){var n=RegExp("^["+ui+"]["+ui+"]*"),r=RegExp("["+ui+"]["+ui+"]*$");return t.replace(n,"").replace(r,"")}):r(function(t){return t.trim()}),oi=e(function(t,n){return o(t.length,function(){try{return t.apply(this,arguments)}catch(t){return n.apply(this,i([t],arguments))}})}),ci=r(function(t){return function(){return t(Array.prototype.slice.call(arguments,0))}}),ai=r(function(t){return yt(1,t)}),si=e(function(t,n){return a(t,function(){for(var r,e=1,u=n,i=0;t>=e&&"function"==typeof u;)u=u.apply(this,Array.prototype.slice.call(arguments,i,r=e===t?arguments.length:i+u.length)),e+=1,i=r;return u})}),fi=e(function(t,n){for(var r=t(n),e=[];r&&r.length;)e[e.length]=r[0],r=t(r[1]);return e}),li=e(Dt(Jr,i)),pi=e(function(t,n){for(var r,e=0,u=n.length,i=[];u>e;)Zt(t,r=n[e],i)||(i[i.length]=r),e+=1;return i}),hi=f(function(t,n,r){return pi(t,i(n,r))}),yi=f(function(t,n,r){return t(r)?r:n(r)}),di=St($t),gi=f(function(t,n,r){for(var e=r;!t(e);)e=n(e);return e}),vi=r(function(t){var n,r=[];for(n in t)r[r.length]=t[n];return r}),mi=function(t){return{value:t,"fantasy-land/map":function(){return this}}},bi=e(function(t,n){return t(mi)(n).value}),xi=f(function(t,n,r){return t(r)?n(r):r}),wi=e(function(t,n){for(var r in t)if(P(r,t)&&!t[r](n[r]))return!1;return!0}),ji=e(function(t,n){return wi(z(nn,t),n)}),Ai=e(function(t,n){return yn(Er(en)(t),n)}),Oi=e(function(t,n){for(var r,e=0,u=t.length,i=n.length,o=[];u>e;){for(r=0;i>r;)o[o.length]=[t[e],n[r]],r+=1;e+=1}return o}),Si=e(function(t,n){for(var r=[],e=0,u=Math.min(t.length,n.length);u>e;)r[e]=[t[e],n[e]],e+=1;return r}),Ei=e(function(t,n){for(var r=0,e=Math.min(t.length,n.length),u={};e>r;)u[t[r]]=n[r],r+=1;return u}),_i=f(function(t,n,r){for(var e=[],u=0,i=Math.min(n.length,r.length);i>u;)e[u]=t(n[u],r[u]),u+=1;return e}),qi=r(function(t){return a(t.length,function(){const n=arguments;return function(){return t.apply(this,n)}})});t.F=function(){return!1},t.T=function(){return!0},t.__={"@@functional/placeholder":!0},t.add=u,t.addIndex=s,t.adjust=l,t.all=b,t.allPass=$,t.always=H,t.and=J,t.any=Z,t.anyPass=G,t.ap=Q,t.aperture=rt,t.append=et,t.apply=ut,t.applySpec=ct,t.applyTo=at,t.ascend=st,t.assoc=ft,t.assocPath=ht,t.binary=dt,t.bind=E,t.both=bt,t.call=wt,t.chain=St,t.clamp=Et,t.clone=Nt,t.comparator=Wt,t.complement=Pt,t.compose=Dt,t.composeK=zt,t.composeP=function(){if(0===arguments.length)throw Error("composeP requires at least one argument");return Lt.apply(this,Ut(arguments))},t.composeWith=Xt,t.concat=vn,t.cond=mn,t.construct=xn,t.constructN=bn,t.contains=wn,t.converge=jn,t.countBy=En,t.curry=xt,t.curryN=a,t.dec=_n,t.defaultTo=qn,t.descend=kn,t.difference=In,t.differenceWith=Pn,t.dissoc=Tn,t.dissocPath=Fn,t.divide=Rn,t.drop=zn,t.dropLast=Hn,t.dropLastWhile=Yn,t.dropRepeats=nr,t.dropRepeatsWith=tr,t.dropWhile=ur,t.either=or,t.empty=cr,t.endsWith=sr,t.eqBy=fr,t.eqProps=lr,t.equals=nn,t.evolve=pr,t.filter=hn,t.find=dr,t.findIndex=mr,t.findLast=wr,t.findLastIndex=Or,t.flatten=Sr,t.flip=Er,t.forEach=_r,t.forEachObjIndexed=qr,t.fromPairs=kr,t.groupBy=Nr,t.groupWith=Wr,t.gt=Ir,t.gte=Pr,t.has=Cr,t.hasIn=Br,t.hasPath=Tr,t.head=Vt,t.identical=Fr,t.identity=Ht,t.ifElse=Rr,t.inc=Ur,t.includes=Dr,t.indexBy=zr,t.indexOf=Mr,t.init=Lr,t.innerJoin=Kr,t.insert=Vr,t.insertAll=$r,t.intersection=Xr,t.intersperse=Yr,t.into=re,t.invert=ee,t.invertObj=ue,t.invoker=ie,t.is=oe,t.isEmpty=ce,t.isNil=pt,t.join=ae,t.juxt=se,t.keys=D,t.keysIn=fe,t.last=Qn,t.lastIndexOf=le,t.length=he,t.lens=ye,t.lensIndex=de,t.lensPath=ge,t.lensProp=ve,t.lift=mt,t.liftN=vt,t.lt=me,t.lte=be,t.map=z,t.mapAccum=xe,t.mapAccumRight=we,t.mapObjIndexed=je,t.match=Ae,t.mathMod=Oe,t.max=x,t.maxBy=Se,t.mean=_e,t.median=qe,t.memoizeWith=ke,t.merge=Ne,t.mergeAll=We,t.mergeDeepLeft=Te,t.mergeDeepRight=Ce,t.mergeDeepWith=Be,t.mergeDeepWithKey=Pe,t.mergeLeft=Fe,t.mergeRight=Re,t.mergeWith=Ue,t.mergeWithKey=Ie,t.min=De,t.minBy=ze,t.modulo=Me,t.multiply=Le,t.nAry=yt,t.negate=Ke,t.none=Ve,t.not=It,t.nth=Kt,t.nthArg=$e,t.o=He,t.objOf=Gr,t.of=Je,t.omit=Xe,t.once=Ye,t.or=ir,t.otherwise=Ge,t.over=tu,t.pair=nu,t.partial=eu,t.partialRight=uu,t.partition=iu,t.path=M,t.pathEq=ou,t.pathOr=cu,t.pathSatisfies=au,t.pick=su,t.pickAll=fu,t.pickBy=lu,t.pipe=Rt,t.pipeK=function(){if(0===arguments.length)throw Error("pipeK requires at least one argument");return zt.apply(this,Ut(arguments))},t.pipeP=Lt,t.pipeWith=Jt,t.pluck=K,t.prepend=pu,t.product=hu,t.project=du,t.prop=L,t.propEq=gu,t.propIs=vu,t.propOr=mu,t.propSatisfies=bu,t.props=xu,t.range=wu,t.reduce=V,t.reduceBy=Sn,t.reduceRight=ju,t.reduceWhile=Au,t.reduced=Ou,t.reject=yn,t.remove=Cn,t.repeat=Eu,t.replace=_u,t.reverse=Ut,t.scan=qu,t.sequence=ku,t.set=Nu,t.slice=Bt,t.sort=Wu,t.sortBy=Iu,t.sortWith=Pu,t.split=Tu,t.splitAt=Cu,t.splitEvery=Bu,t.splitWhen=Fu,t.startsWith=Ru,t.subtract=Uu,t.sum=Ee,t.symmetricDifference=Du,t.symmetricDifferenceWith=zu,t.tail=Ft,t.take=Kn,t.takeLast=ar,t.takeLastWhile=Mu,t.takeWhile=Vu,t.tap=Ju,t.test=Xu,t.then=Yu,t.times=Su,t.toLower=Zu,t.toPairs=Gu,t.toPairsIn=Qu,t.toString=gn,t.toUpper=ti,t.transduce=ni,t.transpose=ri,t.traverse=ei,t.trim=ii,t.tryCatch=oi,t.type=qt,t.unapply=ci,t.unary=ai,t.uncurryN=si,t.unfold=fi,t.union=li,t.unionWith=hi,t.uniq=Jr,t.uniqBy=Hr,t.uniqWith=pi,t.unless=yi,t.unnest=di,t.until=gi,t.update=Bn,t.useWith=yu,t.values=it,t.valuesIn=vi,t.view=bi,t.when=xi,t.where=wi,t.whereEq=ji,t.without=Ai,t.xprod=Oi,t.zip=Si,t.zipObj=Ei,t.zipWith=_i,t.thunkify=qi,Object.defineProperty(t,"__esModule",{value:!0})}); +!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((t=t||self).R={})}(this,function(t){"use strict";function a(t){return null!=t&&"object"==typeof t&&!0===t["@@functional/placeholder"]}function o(r){return function t(n){return 0===arguments.length||a(n)?t:r.apply(this,arguments)}}function n(e){return function t(n,r){switch(arguments.length){case 0:return t;case 1:return a(n)?t:o(function(t){return e(n,t)});default:return a(n)&&a(r)?t:a(n)?o(function(t){return e(t,r)}):a(r)?o(function(t){return e(n,t)}):e(n,r)}}}var r=n(function(t,n){return+t+ +n});function i(t,n){var r,e=(t=t||[]).length,u=(n=n||[]).length,i=[];for(r=0;r":ln(t,n)}function t(n,t){return x(function(t){return nn(t)+": "+u(n[t])},t.slice().sort())}switch(Object.prototype.toString.call(r)){case"[object Arguments]":return"(function() { return arguments; }("+x(u,r).join(", ")+"))";case"[object Array]":return"["+x(u,r).concat(t(r,sn(function(t){return/^\d+$/.test(t)},U(r)))).join(", ")+"]";case"[object Boolean]":return"object"==typeof r?"new Boolean("+u(r.valueOf())+")":""+r;case"[object Date]":return"new Date("+(isNaN(r.valueOf())?u(NaN):nn(en(r)))+")";case"[object Null]":return"null";case"[object Number]":return"object"==typeof r?"new Number("+u(r.valueOf())+")":1/r==-1/0?"-0":r.toString(10);case"[object String]":return"object"==typeof r?"new String("+u(r.valueOf())+")":nn(r);case"[object Undefined]":return"undefined";default:if("function"==typeof r.toString){var n=""+r;if("[object Object]"!=n)return n}return"{"+t(r,U(r)).join(", ")+"}"}}var pn=o(function(t){return ln(t,[])}),hn=n(function(t,n){if(p(t)){if(p(n))return t.concat(n);throw new TypeError(pn(n)+" is not an array")}if(w(t)){if(w(n))return t+n;throw new TypeError(pn(n)+" is not a string")}if(null!=t&&dt(t["fantasy-land/concat"]))return t["fantasy-land/concat"](n);if(null!=t&&dt(t.concat))return t.concat(n);throw new TypeError(pn(t)+' does not have a method named "concat" or "fantasy-land/concat"')}),yn=o(function(n){return f($(b,0,D(function(t){return t[0].length},n)),function(){for(var t=0;tt(n)?r:n}),pe=$(r,0),he=o(function(t){return pe(t)/t.length}),ye=o(function(t){var n=t.length;if(0===n)return NaN;var r=2-n%2,e=(n-r)/2;return he(Array.prototype.slice.call(t,0).sort(function(t,n){return t b) -> (Promise e a) -> (Promise e b) * @sig (a -> (Promise e b)) -> (Promise e a) -> (Promise e b) diff --git a/source/move.js b/source/move.js index 09ec405361..e0329ce329 100644 --- a/source/move.js +++ b/source/move.js @@ -6,6 +6,7 @@ import _curry3 from './internal/_curry3'; * * @func * @memberOf R + * @since v0.27.1 * @category List * @sig Number -> Number -> [a] -> [a] * @param {Number} from The source index diff --git a/source/paths.js b/source/paths.js index 871233dcbd..b7c0b613c0 100644 --- a/source/paths.js +++ b/source/paths.js @@ -7,6 +7,7 @@ import nth from './nth'; * * @func * @memberOf R + * @since v0.27.1 * @category Object * @typedefn Idx = [String | Int] * @sig [Idx] -> {a} -> [a | Undefined] diff --git a/source/xor.js b/source/xor.js index 08a9363e1a..2b048e21d4 100644 --- a/source/xor.js +++ b/source/xor.js @@ -7,6 +7,7 @@ import _curry2 from './internal/_curry2'; * * @func * @memberOf R + * @since v0.27.1 * @category Logic * @sig a -> b -> Boolean * @param {Any} a From 1cd34a0dc028c1eaf44f22b9900c4bde8e1b7848 Mon Sep 17 00:00:00 2001 From: Brad Compton Date: Wed, 5 Aug 2020 15:43:28 -0700 Subject: [PATCH 050/111] lint: partialObject linting errors --- source/partialObject.js | 4 ++-- test/partialObject.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/source/partialObject.js b/source/partialObject.js index 2418966f67..85a4484527 100644 --- a/source/partialObject.js +++ b/source/partialObject.js @@ -1,5 +1,5 @@ -import mergeDeepRight from './mergeDeepRight'; -import _curry2 from './internal/_curry2'; +import mergeDeepRight from './mergeDeepRight.js'; +import _curry2 from './internal/_curry2.js'; /** * Takes a function `f` and an object, and returns a function `g`. diff --git a/test/partialObject.js b/test/partialObject.js index 95d29a5267..de07a7cbcd 100644 --- a/test/partialObject.js +++ b/test/partialObject.js @@ -24,7 +24,7 @@ describe('partialObject', function() { }); it('merges deeply right', function() { - var nestedDiscriminant = function ({ a, c, d}) { + var nestedDiscriminant = function({ a, c, d}) { return d.b * d.b - 4 * a * c; }; From 04fa9ef9ee976644d952ff6bc0d53b2ac66573ec Mon Sep 17 00:00:00 2001 From: Chuan-Tse Kao Date: Mon, 17 Aug 2020 21:19:55 +0800 Subject: [PATCH 051/111] Fix Clone Function Copy Prototype Issue (#3067) * Fix Clone Function Copy Prototype Issue 1. Check hasOwnProperty when copy to avoid copying prototype 2. Make the new value's prototype point to the origin value's prototype * Replace deprecate __proto__ with buid-in method in Object * Add test for the issue deep copying prototype properties * Shorten the num of line --- source/internal/_clone.js | 7 ++++--- test/clone.js | 26 ++++++++++++++++++++++++++ 2 files changed, 30 insertions(+), 3 deletions(-) diff --git a/source/internal/_clone.js b/source/internal/_clone.js index 5f93182b7e..8831fc35e8 100644 --- a/source/internal/_clone.js +++ b/source/internal/_clone.js @@ -25,13 +25,14 @@ export default function _clone(value, refFrom, refTo, deep) { refFrom[idx] = value; refTo[idx] = copiedValue; for (var key in value) { - copiedValue[key] = deep ? - _clone(value[key], refFrom, refTo, true) : value[key]; + if (value.hasOwnProperty(key)) { + copiedValue[key] = deep ? _clone(value[key], refFrom, refTo, true) : value[key]; + } } return copiedValue; }; switch (type(value)) { - case 'Object': return copy({}); + case 'Object': return copy(Object.create(Object.getPrototypeOf(value))); case 'Array': return copy([]); case 'Date': return new Date(value.valueOf()); case 'RegExp': return _cloneRegExp(value); diff --git a/test/clone.js b/test/clone.js index e223e7c6ec..b99f2c24e9 100644 --- a/test/clone.js +++ b/test/clone.js @@ -86,6 +86,32 @@ describe('deep clone objects', function() { eq(clone.get(), 10); }); + it('only own properties be copied', function() { + function Obj() { + this.x = 'own property'; + } + + Obj.prototype = { + y: 'not own property' + }; + + const obj = new Obj(); + const cloneObj = R.clone(obj); + eq(Object.keys(obj), Object.keys(cloneObj)); + }); + + it('the prototype should keep the same', function() { + function Obj() {} + + Obj.prototype = { + x: 'prototype property' + }; + + const obj = new Obj(); + const cloneObj = R.clone(obj); + eq(Object.getPrototypeOf(obj), Object.getPrototypeOf(cloneObj)); + }); + }); describe('deep clone arrays', function() { From 86c3ec1a89e2614a6c52d00ccde6e64888ce6314 Mon Sep 17 00:00:00 2001 From: Burak YILDIRIM Date: Mon, 17 Aug 2020 16:21:30 +0300 Subject: [PATCH 052/111] Update Copyright year (#3073) Updated the Copyright year as 2013-2020 in License.txt --- LICENSE.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/LICENSE.txt b/LICENSE.txt index d5af6c5221..247612230c 100644 --- a/LICENSE.txt +++ b/LICENSE.txt @@ -1,6 +1,6 @@ The MIT License (MIT) -Copyright (c) 2013-2019 Scott Sauyet and Michael Hurley +Copyright (c) 2013-2020 Scott Sauyet and Michael Hurley Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal From 5f0cadbacedbdd88da7a476bf2615e7c5890b80d Mon Sep 17 00:00:00 2001 From: Sebastien Filion Date: Mon, 17 Aug 2020 09:30:32 -0400 Subject: [PATCH 053/111] Add support for Nest.land - a package manager for Deno (#3054) --- README.md | 6 ++++++ egg.json | 12 ++++++++++++ mod.ts | 1 + 3 files changed, 19 insertions(+) create mode 100644 egg.json create mode 100644 mod.ts diff --git a/README.md b/README.md index c02fd879ee..b8d35eae52 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ A practical functional library for JavaScript programmers. [![Build Status](https://github.com/ramda/ramda/workflows/Build/badge.svg)](https://github.com/ramda/ramda/actions?query=workflow%3ABuild) [![Test Coverage](https://api.codeclimate.com/v1/badges/953a3c5ee423e5301d18/test_coverage)](https://codeclimate.com/github/ramda/ramda/test_coverage) [![npm module](https://badge.fury.io/js/ramda.svg)](https://www.npmjs.org/package/ramda) +[![nest badge](https://nest.land/badge.svg)](https://nest.land/package/ramda) [![dependencies](https://david-dm.org/ramda/ramda.svg)](https://david-dm.org/ramda/ramda) [![Gitter](https://badges.gitter.im/Join_Chat.svg)](https://gitter.im/ramda/ramda?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) @@ -97,6 +98,11 @@ To use directly in [Deno](https://deno.land): import * as R from "https://deno.land/x/ramda/index.js"; ``` +or using Nest.land: +```javascript +import * as R from "https://x.nest.land/ramda@0.27.0/mod.ts"; +``` + To use directly in the browser: ```html diff --git a/egg.json b/egg.json new file mode 100644 index 0000000000..d8279619d3 --- /dev/null +++ b/egg.json @@ -0,0 +1,12 @@ +{ + "name": "ramda", + "description": "A practical functional library for JavaScript programmers.", + "stable": true, + "entry": "./source/index.js", + "files": [ + "./source/**/*.js", + "./README.md" + ], + "version": "0.27.0", + "repository": "https://github.com/ramda/ramda" +} diff --git a/mod.ts b/mod.ts new file mode 100644 index 0000000000..3ef245047d --- /dev/null +++ b/mod.ts @@ -0,0 +1 @@ +export * from "./source/index.js"; From c8f0b7fb74da5af1d8538d4cae402f2a59597766 Mon Sep 17 00:00:00 2001 From: "Brad Compton (he/him)" Date: Mon, 17 Aug 2020 06:37:25 -0700 Subject: [PATCH 054/111] update CONTRIBUTING and package.json to prevent linting errors (#3069) Co-authored-by: Brad Compton --- CONTRIBUTING.md | 9 +++++---- package.json | 3 ++- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index fe76f16ea8..bfbaa10d90 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -18,10 +18,11 @@ commit message, wrapped at 72 characters. Do not commit changes to `dist/ramda.js`. -1. Run `npm test` (or `make test lint`) and address any errors. It will install - needed dependencies locally. Preferably, fix commits in place using `git - rebase` or `git commit --amend` to make the changes easier to review and to - keep the history tidy. +1. Run `npm install` to install needed local dependencies. + +1. Run `npm test` and address any errors. Preferably, fix commits in place + using `git rebase` or `git commit --amend` to make the changes easier to + review and to keep the history tidy. 1. Push to your fork: diff --git a/package.json b/package.json index 538b1cf943..1997ff8fbb 100644 --- a/package.json +++ b/package.json @@ -79,7 +79,8 @@ "coverage": "BABEL_ENV=cjs nyc --reporter=lcov mocha -- --require @babel/register", "lint": "eslint scripts/bookmarklet scripts/*.js source/*.js source/internal/*.js test/*.js test/**/*.js lib/sauce/*.js lib/bench/*.js", "browser_test": "testem ci", - "test": "cross-env BABEL_ENV=cjs mocha --require @babel/register --reporter spec" + "spec": "cross-env BABEL_ENV=cjs mocha --require @babel/register --reporter spec", + "test": "npm run spec && npm run lint" }, "dependencies": {}, "devDependencies": { From 60b1b80a7917598f5b3bb23c20beb8f971a8f72a Mon Sep 17 00:00:00 2001 From: "Brad Compton (he/him)" Date: Wed, 26 Aug 2020 11:57:45 -0700 Subject: [PATCH 055/111] added links between groupBy and indexBy (#3080) Co-authored-by: Brad Compton --- source/groupBy.js | 2 +- source/indexBy.js | 1 + 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/source/groupBy.js b/source/groupBy.js index b88a567182..f9983ca580 100644 --- a/source/groupBy.js +++ b/source/groupBy.js @@ -21,7 +21,7 @@ import reduceBy from './reduceBy.js'; * @param {Array} list The array to group * @return {Object} An object with the output of `fn` for keys, mapped to arrays of elements * that produced that key when passed to `fn`. - * @see R.reduceBy, R.transduce + * @see R.reduceBy, R.transduce, R.indexBy * @example * * const byGrade = R.groupBy(function(student) { diff --git a/source/indexBy.js b/source/indexBy.js index 8676296035..5db3822f7c 100644 --- a/source/indexBy.js +++ b/source/indexBy.js @@ -18,6 +18,7 @@ import reduceBy from './reduceBy.js'; * @param {Function} fn Function :: a -> Idx * @param {Array} array The array of objects to index * @return {Object} An object indexing each array element by the given property. + * @see R.groupBy * @example * * const list = [{id: 'xyz', title: 'A'}, {id: 'abc', title: 'B'}]; From 058646e022e8f1cd6afdee1d5b5395aa39990583 Mon Sep 17 00:00:00 2001 From: wangzengdi Date: Thu, 3 Sep 2020 04:06:04 +0800 Subject: [PATCH 056/111] evolve: ignores transformations if the input value is not Array and Object (#3081) --- source/evolve.js | 5 +++++ test/evolve.js | 7 +++++++ 2 files changed, 12 insertions(+) diff --git a/source/evolve.js b/source/evolve.js index 31456e26d5..120d3c2ebc 100644 --- a/source/evolve.js +++ b/source/evolve.js @@ -1,4 +1,6 @@ import _curry2 from './internal/_curry2.js'; +import _isArray from './internal/_isArray.js'; +import _isObject from './internal/_isObject.js'; /** @@ -29,6 +31,9 @@ import _curry2 from './internal/_curry2.js'; * R.evolve(transformations, tomato); //=> {firstName: 'Tomato', data: {elapsed: 101, remaining: 1399}, id:123} */ var evolve = _curry2(function evolve(transformations, object) { + if (!_isObject(object) && !_isArray(object)) { + return object; + } var result = object instanceof Array ? [] : {}; var transformation, key, type; for (key in object) { diff --git a/test/evolve.js b/test/evolve.js index fc1c6c8973..cc233d53a8 100644 --- a/test/evolve.js +++ b/test/evolve.js @@ -53,4 +53,11 @@ describe('evolve', function() { eq(R.evolve(transf, object), expected); }); + it('ignores transformations if the input value is not Array and Object', function() { + var transf = { a: R.add(1) }; + eq(R.evolve(transf, 42), 42); + eq(R.evolve(transf, undefined), undefined); + eq(R.evolve(transf, null), null); + eq(R.evolve(transf, ''), ''); + }); }); From 3438734be1c559f50e2d7e150a0ae1b5b3f87f22 Mon Sep 17 00:00:00 2001 From: Raphael Krut-Landau Date: Sun, 13 Sep 2020 21:37:31 -0400 Subject: [PATCH 057/111] Fixed typo (#3083) --- source/transduce.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/transduce.js b/source/transduce.js index 10ad5eafb1..4582a3f42d 100644 --- a/source/transduce.js +++ b/source/transduce.js @@ -17,7 +17,7 @@ import curryN from './curryN.js'; * A transducer is a function that accepts a transformer and returns a * transformer and can be composed directly. * - * A transformer is an an object that provides a 2-arity reducing iterator + * A transformer is an object that provides a 2-arity reducing iterator * function, step, 0-arity initial value function, init, and 1-arity result * extraction function, result. The step function is used as the iterator * function in reduce. The result function is used to convert the final From 1f363a25ea25624396d80187076d3364c1967ef2 Mon Sep 17 00:00:00 2001 From: Ed Costello Date: Wed, 16 Sep 2020 08:01:43 +1200 Subject: [PATCH 058/111] Update documentation of propOr to describe beahviour. fixes: 3084 The documentation here is based on the documentation for `prop` and `defaultTo` which is what is used in the implementation so should be an accurate description of the behaviour. --- source/propOr.js | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/source/propOr.js b/source/propOr.js index 6750630a0c..16650e51b8 100644 --- a/source/propOr.js +++ b/source/propOr.js @@ -4,9 +4,10 @@ import prop from './prop.js'; /** - * If the given, non-null object has an own property with the specified name, - * returns the value of that property. Otherwise returns the provided default - * value. + * Return the specified property of the given non-null object if the property + * is present and it's value is not `null`, `undefined` or `NaN`. + * + * Otherwise the first argument is returned. * * @func * @memberOf R From bd143816267e432a3905cb47ab5e62b413b6d12f Mon Sep 17 00:00:00 2001 From: wangzengdi Date: Wed, 23 Sep 2020 05:55:47 +0800 Subject: [PATCH 059/111] chore: rename xf to transducerCreator (#3088) * chore: rename xf to transducerCreator * chore: changes constructor to factory Co-authored-by: adispring --- source/internal/_dispatchable.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/source/internal/_dispatchable.js b/source/internal/_dispatchable.js index 3ece37f5a5..43d419bcd2 100644 --- a/source/internal/_dispatchable.js +++ b/source/internal/_dispatchable.js @@ -7,16 +7,17 @@ import _isTransformer from './_isTransformer.js'; * object in list position (last argument). If it is an array, executes [fn]. * Otherwise, if it has a function with one of the given method names, it will * execute that function (functor case). Otherwise, if it is a transformer, - * uses transducer [xf] to return a new transformer (transducer case). + * uses transducer created by [transducerCreator] to return a new transformer + * (transducer case). * Otherwise, it will default to executing [fn]. * * @private * @param {Array} methodNames properties to check for a custom implementation - * @param {Function} xf transducer to initialize if object is transformer + * @param {Function} transducerCreator transducer factory if object is transformer * @param {Function} fn default ramda implementation * @return {Function} A function that dispatches on object in list position */ -export default function _dispatchable(methodNames, xf, fn) { +export default function _dispatchable(methodNames, transducerCreator, fn) { return function() { if (arguments.length === 0) { return fn(); @@ -31,7 +32,7 @@ export default function _dispatchable(methodNames, xf, fn) { idx += 1; } if (_isTransformer(obj)) { - var transducer = xf.apply(null, Array.prototype.slice.call(arguments, 0, -1)); + var transducer = transducerCreator.apply(null, Array.prototype.slice.call(arguments, 0, -1)); return transducer(obj); } } From cbc65c7f311a366aa3618a18c1a439a72f482218 Mon Sep 17 00:00:00 2001 From: cviejo Date: Fri, 9 Oct 2020 21:12:44 +0200 Subject: [PATCH 060/111] fix: partial build (#3096) * fixed partial build output * write multiple chunks --- scripts/partialBuild.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/scripts/partialBuild.js b/scripts/partialBuild.js index 5cb37100cf..261ebd391a 100644 --- a/scripts/partialBuild.js +++ b/scripts/partialBuild.js @@ -12,7 +12,7 @@ rollupConfig.plugins.push(partialBuildPlugin); rollup.rollup(rollupConfig).then(function(bundle) { return bundle.generate(rollupConfig.output); }).then(function(result) { - process.stdout.write(result.code); + result.output.forEach(x => process.stdout.write(x.code)) }); function partialBuild(options) { From 4e5fffe221e163591a6db2991461a500538a2bfd Mon Sep 17 00:00:00 2001 From: Daniel Grant Date: Fri, 13 Nov 2020 01:04:00 +0000 Subject: [PATCH 061/111] new functions: modify and modifyPath (#3107) * Add modify and modifyPath functions * Update parameter validations, add documentation * Fix tests for modification in function param validation * Refactor modifyPath to fail first * Fix minor issues with order, parentheses and linting --- scripts/partialBuild.js | 2 +- source/index.js | 2 ++ source/internal/_modify.js | 29 ++++++++++++++++++++ source/modify.js | 27 +++++++++++++++++++ source/modifyPath.js | 55 ++++++++++++++++++++++++++++++++++++++ test/modify.js | 50 ++++++++++++++++++++++++++++++++++ test/modifyPath.js | 45 +++++++++++++++++++++++++++++++ 7 files changed, 209 insertions(+), 1 deletion(-) create mode 100644 source/internal/_modify.js create mode 100644 source/modify.js create mode 100644 source/modifyPath.js create mode 100644 test/modify.js create mode 100644 test/modifyPath.js diff --git a/scripts/partialBuild.js b/scripts/partialBuild.js index 261ebd391a..1f91ee2174 100644 --- a/scripts/partialBuild.js +++ b/scripts/partialBuild.js @@ -12,7 +12,7 @@ rollupConfig.plugins.push(partialBuildPlugin); rollup.rollup(rollupConfig).then(function(bundle) { return bundle.generate(rollupConfig.output); }).then(function(result) { - result.output.forEach(x => process.stdout.write(x.code)) + result.output.forEach(x => process.stdout.write(x.code)); }); function partialBuild(options) { diff --git a/source/index.js b/source/index.js index 70df3e5b80..d9b631ea4a 100644 --- a/source/index.js +++ b/source/index.js @@ -135,6 +135,8 @@ export { default as mergeWith } from './mergeWith.js'; export { default as mergeWithKey } from './mergeWithKey.js'; export { default as min } from './min.js'; export { default as minBy } from './minBy.js'; +export { default as modify } from './modify.js'; +export { default as modifyPath } from './modifyPath.js'; export { default as modulo } from './modulo.js'; export { default as move } from './move.js'; export { default as multiply } from './multiply.js'; diff --git a/source/internal/_modify.js b/source/internal/_modify.js new file mode 100644 index 0000000000..e1e148027c --- /dev/null +++ b/source/internal/_modify.js @@ -0,0 +1,29 @@ +import _isArray from './_isArray.js'; +import _isInteger from './_isInteger.js'; + +/** + * Makes a shallow clone of an object, applying the given fn to the specified + * property with the given value. Note that this copies and flattens prototype + * properties onto the new object as well. All non-primitive properties are + * copied by reference. + * + * @private + * @param {String|Number} prop The property name to set + * @param {Function} fn The function to apply to the property + * @param {Object|Array} obj The object to clone + * @return {Object|Array} A new object equivalent to the original except for the changed property. + */ +export default function _modify(prop, fn, obj) { + if (_isInteger(prop) && _isArray(obj)) { + var arr = [].concat(obj); + arr[prop] = fn(arr[prop]); + return arr; + } + + var result = {}; + for (var p in obj) { + result[p] = obj[p]; + } + result[prop] = fn(result[prop]); + return result; +} diff --git a/source/modify.js b/source/modify.js new file mode 100644 index 0000000000..25ffd55308 --- /dev/null +++ b/source/modify.js @@ -0,0 +1,27 @@ +import _curry3 from './internal/_curry3.js'; +import modifyPath from './modifyPath.js'; + + +/** + * Creates a copy of the passed object by applying an `fn` function to the given `prop` property. + * + * The function will not be invoked, and the object will not change + * if its corresponding property does not exist in the object. + * All non-primitive properties are copied to the new object by reference. + * + * @func + * @memberOf R + * @category Object + * @sig Idx -> (v -> v) -> {k: v} -> {k: v} + * @param {String|Number} prop The property to be modified. + * @param {Function} fn The function to apply to the property. + * @param {Object} object The object to be transformed. + * @return {Object} The transformed object. + * @example + * + * const person = {name: 'James', age: 20, pets: ['dog', 'cat']}; + * R.modify('age', R.add(1), person); //=> {name: 'James', age: 21, pets: ['dog', 'cat']} + * R.modify('pets', R.append('turtle'), person); //=> {name: 'James', age: 20, pets: ['dog', 'cat', 'turtle']} + */ +var modify = _curry3(function modify(prop, fn, object) { return modifyPath([prop], fn, object); }); +export default modify; diff --git a/source/modifyPath.js b/source/modifyPath.js new file mode 100644 index 0000000000..4760e5644a --- /dev/null +++ b/source/modifyPath.js @@ -0,0 +1,55 @@ +import _curry3 from './internal/_curry3.js'; +import _isArray from './internal/_isArray.js'; +import _isObject from './internal/_isObject.js'; +import _has from './internal/_has.js'; +import _assoc from './internal/_assoc.js'; +import _modify from './internal/_modify.js'; + + +/** + * Creates a shallow clone of the passed object by applying an `fn` function + * to the value at the given path. + * + * The function will not be invoked, and the object will not change + * if its corresponding path does not exist in the object. + * All non-primitive properties are copied to the new object by reference. + * + * @func + * @memberOf R + * @category Object + * @sig [Idx] -> (v -> v) -> {k: v} -> {k: v} + * @param {Array} path The path to be modified. + * @param {Function} fn The function to apply to the path. + * @param {Object} object The object to be transformed. + * @return {Object} The transformed object. + * @example + * + * const person = {name: 'James', address: { zipCode: '90216' }}; + * R.modifyPath(['address', 'zipCode'], R.reverse, person); //=> {name: 'James', address: { zipCode: '61209' }} + * + * // Can handle arrays too + * const person = {name: 'James', addresses: [{ zipCode: '90216' }]}; + * R.modifyPath(['addresses', 0, 'zipCode'], R.reverse, person); //=> {name: 'James', addresses: [{ zipCode: '61209' }]} + */ +var modifyPath = _curry3(function modifyPath(path, fn, object) { + if ((!_isObject(object) && !_isArray(object)) || path.length === 0) { + return object; + } + + var idx = path[0]; + if (!_has(idx, object)) { + return object; + } + + if (path.length === 1) { + return _modify(idx, fn, object); + } + + var val = modifyPath(Array.prototype.slice.call(path, 1), fn, object[idx]); + if (val === object[idx]) { + return object; + } + return _assoc(idx, val, object); + +}); +export default modifyPath; diff --git a/test/modify.js b/test/modify.js new file mode 100644 index 0000000000..a326ecc34a --- /dev/null +++ b/test/modify.js @@ -0,0 +1,50 @@ +var R = require('../source'); +var eq = require('./shared/eq'); + + +describe('modify', function() { + it('creates a new object by applying the `transformation` function to the given `property` of the `object`', function() { + var object = {name: 'Tomato', elapsed: 100, remaining: 1400}; + var expected = {name: 'Tomato', elapsed: 101, remaining: 1400}; + eq(R.modify('elapsed', R.add(1), object), expected); + }); + + it('returns the original object if object does not contain the property', function() { + var object = {name: 'Tomato', elapsed: 100, remaining: 1400}; + eq(R.modify('nonexistent', R.add(1), object), object); + }); + + it('is not destructive', function() { + var object = {name: 'Tomato', elapsed: 100, remaining: 1400}; + var expected = {name: 'Tomato', elapsed: 100, remaining: 1400}; + R.modify('elapsed', R.add(1), object); + eq(object, expected); + }); + + it('ignores primitive value transformations', function() { + var object = {n: 0, m: 1}; + var expected = {n: 0, m: 1}; + eq(R.modify('elapsed', 2, object), expected); + }); + + it('ignores null transformations', function() { + var object = {n: 0}; + var expected = {n: 0}; + eq(R.modify('elapsed', null, object), expected); + }); + + it('adjust if `array` at the given key with the `transformation` function', function() { + var object = [100, 1400]; + var expected = [100, 1401]; + eq(R.modify(1, R.add(1), object), expected); + }); + + it('ignores transformations if the input value is not Array and Object', function() { + eq(R.modify('a', R.add(1), 42), 42); + eq(R.modify('a', R.add(1), undefined), undefined); + eq(R.modify('a', R.add(1), null), null); + eq(R.modify('a', R.add(1), ''), ''); + }); + + // TODO: check reference equality? +}); diff --git a/test/modifyPath.js b/test/modifyPath.js new file mode 100644 index 0000000000..7d5404d849 --- /dev/null +++ b/test/modifyPath.js @@ -0,0 +1,45 @@ +var assert = require('assert'); + +var R = require('../source'); +var eq = require('./shared/eq'); + + +describe('modifyPath', function() { + it('creates a new object by applying the `transformation` function to the given `properties` of the `object`', function() { + var object = {a: 'Tomato', b: { c: { d: [100, 101, 102] } }, e: { f: 'g', h: [1, 2, 3] }}; + var expected = {a: 'Tomato', b: { c: { d: [100, 102, 102] } }, e: { f: 'g', h: [1, 2, 3] }}; + var created = R.modifyPath(['b', 'c', 'd', 1], R.add(1), object); + eq(created, expected); + // Note: reference equality below! + assert.strictEqual(object.a, created.a); + assert.strictEqual(object.e, created.e); + assert.strictEqual(object.e.h, created.e.h); + }); + + it('returns the original object if object does not contain the key', function() { + var object = {a: 'Tomato', b: { c: { d: [100, 101, 102] } }, e: { f: 'g', h: [1, 2, 3] }}; + var created = R.modifyPath(['b', 'nonexistent', 'd', 1], R.add(1), object); + eq(created, object); + // Note: reference equality below! + assert.strictEqual(object, created); + }); + + it('is not destructive', function() { + var object = {a: 'Tomato', b: { c: { d: [100, 101, 102] } }, e: { f: 'g', h: [1, 2, 3] }}; + var expected = {a: 'Tomato', b: { c: { d: [100, 101, 102] } }, e: { f: 'g', h: [1, 2, 3] }}; + R.modifyPath(['b', 'c', 'd', 1], R.add(1), object); + eq(object, expected); + }); + + it('throws error for non-function transformations', function() { + var object = {a: 'Tomato', b: { c: { d: [100, 101, 102] } }, e: { f: 'g', h: [1, 2, 3] }}; + assert.throws( + function() { R.modifyPath(['b', 'c', 'd', 1], 2, object) ;}, + function(err) { + return err.constructor === TypeError && + err.message === 'fn is not a function'; + } + ); + }); + +}); From 81368c9ddcd02fc8c74c46af2da021a0a90c36f8 Mon Sep 17 00:00:00 2001 From: Julien Gonzalez Date: Fri, 13 Nov 2020 20:35:46 +0000 Subject: [PATCH 062/111] doc: better lift examples (#3109) --- source/lift.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/lift.js b/source/lift.js index a2628f18c6..5e8cc931e5 100644 --- a/source/lift.js +++ b/source/lift.js @@ -18,11 +18,11 @@ import liftN from './liftN.js'; * * const madd3 = R.lift((a, b, c) => a + b + c); * - * madd3([100, 200, 300], [10, 20], [1]); //=> [111, 121, 211, 221, 311, 321] + * madd3([100, 200], [30, 40], [5, 6, 7]); //=> [135, 136, 137, 145, 146, 147, 235, 236, 237, 245, 246, 247] * * const madd5 = R.lift((a, b, c, d, e) => a + b + c + d + e); * - * madd5([1,2], [3], [4, 5], [6], [7, 8]); //=> [21, 22, 22, 23, 22, 23, 23, 24] + * madd5([10, 20], [1], [2, 3], [4], [100, 200]); //=> [117, 217, 118, 218, 127, 227, 128, 228] */ var lift = _curry1(function lift(fn) { return liftN(fn.length, fn); From 9a84319bb9c21edd05d8f0370e68ba9106aa7208 Mon Sep 17 00:00:00 2001 From: Carlos Mori Date: Tue, 15 Dec 2020 17:16:17 -0300 Subject: [PATCH 063/111] Update partial.js docs (#3119) As a newbie to Ramda, I find it clearer this way --- source/partial.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/partial.js b/source/partial.js index 9bf207f633..b29a9e21a2 100644 --- a/source/partial.js +++ b/source/partial.js @@ -20,7 +20,7 @@ import _createPartialApplicator from './internal/_createPartialApplicator.js'; * * const multiply2 = (a, b) => a * b; * const double = R.partial(multiply2, [2]); - * double(2); //=> 4 + * double(3); //=> 6 * * const greet = (salutation, title, firstName, lastName) => * salutation + ', ' + title + ' ' + firstName + ' ' + lastName + '!'; From a5bae4b251793f4b4e16cc5de7bb27c6ff391b07 Mon Sep 17 00:00:00 2001 From: Sebastien Filion Date: Sun, 3 Jan 2021 19:44:13 -0500 Subject: [PATCH 064/111] Update the README to reflect changes to Deno and Nest packages (#3123) (cherry picked from commit a59507a0688c81b24fef5a77a0755e6885a246d9) --- README.md | 5 +++-- egg.json | 14 +++++++++----- 2 files changed, 12 insertions(+), 7 deletions(-) diff --git a/README.md b/README.md index b8d35eae52..7ba8eda9bc 100644 --- a/README.md +++ b/README.md @@ -6,6 +6,7 @@ A practical functional library for JavaScript programmers. [![Build Status](https://github.com/ramda/ramda/workflows/Build/badge.svg)](https://github.com/ramda/ramda/actions?query=workflow%3ABuild) [![Test Coverage](https://api.codeclimate.com/v1/badges/953a3c5ee423e5301d18/test_coverage)](https://codeclimate.com/github/ramda/ramda/test_coverage) [![npm module](https://badge.fury.io/js/ramda.svg)](https://www.npmjs.org/package/ramda) +[![deno land](http://img.shields.io/badge/available%20on-deno.land/x-lightgrey.svg?logo=deno&labelColor=black)](https://deno.land/x/ramda@v0.27.2) [![nest badge](https://nest.land/badge.svg)](https://nest.land/package/ramda) [![dependencies](https://david-dm.org/ramda/ramda.svg)](https://david-dm.org/ramda/ramda) [![Gitter](https://badges.gitter.im/Join_Chat.svg)](https://gitter.im/ramda/ramda?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) @@ -95,12 +96,12 @@ const R = require('ramda'); To use directly in [Deno](https://deno.land): ```javascript -import * as R from "https://deno.land/x/ramda/index.js"; +import * as R from "https://deno.land/x/ramda@v0.27.2/mod.ts"; ``` or using Nest.land: ```javascript -import * as R from "https://x.nest.land/ramda@0.27.0/mod.ts"; +import * as R from "https://x.nest.land/ramda@0.27.2/mod.ts"; ``` To use directly in the browser: diff --git a/egg.json b/egg.json index d8279619d3..7298ce56b6 100644 --- a/egg.json +++ b/egg.json @@ -2,11 +2,15 @@ "name": "ramda", "description": "A practical functional library for JavaScript programmers.", "stable": true, - "entry": "./source/index.js", + "entry": "./mod.ts", "files": [ - "./source/**/*.js", - "./README.md" + "./README.md", + "./source/**/*.js" ], - "version": "0.27.0", - "repository": "https://github.com/ramda/ramda" + "version": "0.27.2", + "repository": "https://github.com/ramda/ramda", + "check": false, + "homepage": "https://github.com/ramda/ramda", + "ignore": [], + "unlisted": false } From 39a16870c83089800909e564387706af7eb0b85f Mon Sep 17 00:00:00 2001 From: Dev Baweja <53691664+DevBaweja@users.noreply.github.com> Date: Tue, 12 Jan 2021 08:40:50 +0530 Subject: [PATCH 065/111] Added unwind function with unwind test files (#3125) * Added unwind function with unwind test files * Corrected source and test file for unwind function * Removed unnecessary test for negative number in unwind * Removed extra spaces * Fixed documentation indentation for unwind * Fixed documentation indentation for unwind --- source/index.js | 1 + source/unwind.js | 42 ++++++++++++++++++++++++++++++++++++++ test/unwind.js | 53 ++++++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 96 insertions(+) create mode 100644 source/unwind.js create mode 100644 test/unwind.js diff --git a/source/index.js b/source/index.js index d9b631ea4a..d0d1a8723c 100644 --- a/source/index.js +++ b/source/index.js @@ -241,6 +241,7 @@ export { default as uniqWith } from './uniqWith.js'; export { default as unless } from './unless.js'; export { default as unnest } from './unnest.js'; export { default as until } from './until.js'; +export { default as unwind } from './unwind.js'; export { default as update } from './update.js'; export { default as useWith } from './useWith.js'; export { default as values } from './values.js'; diff --git a/source/unwind.js b/source/unwind.js new file mode 100644 index 0000000000..46ef62da4e --- /dev/null +++ b/source/unwind.js @@ -0,0 +1,42 @@ +import _curry2 from './internal/_curry2.js'; +import _isArray from './internal/_isArray.js'; +import _map from './internal/_map.js'; +import _assoc from './internal/_assoc.js'; + +/** + * + * Deconstructs an array field from the input documents to output a document for each element. + * Each output document is the input document with the value of the array field replaced by the element. + * + * @func + * @memberOf R + * @category Object + * @sig String -> {k: [v]} -> [{k: v}] + * @param {String} key The key to determine which property of the object should be unwind + * @param {Object} object The object containing list under property named as key which is to unwind + * @return {List} A new list of object containing the value of input key having list replaced by each element in the object. + * @example + * + * R.unwind('hobbies', { + * name: 'alice', + * hobbies: ['Golf', 'Hacking'], + * colors: ['red', 'green'], + * }); + * // [ + * // { name: 'alice', hobbies: 'Golf', colors: ['red', 'green'] }, + * // { name: 'alice', hobbies: 'Hacking', colors: ['red', 'green'] } + * // ] + */ + +var unwind = _curry2(function(key, object) { + // If key is not in object or key is not as a list in object + if (!(key in object && _isArray(object[key]))) { + return [object]; + } + // Map over object[key] which is a list and assoc each element with key + return _map(function(item) { + return _assoc(key, item, object); + }, object[key]); +}); + +export default unwind; diff --git a/test/unwind.js b/test/unwind.js new file mode 100644 index 0000000000..c67c9153de --- /dev/null +++ b/test/unwind.js @@ -0,0 +1,53 @@ +var R = require('../source'); +var eq = require('./shared/eq'); + + +describe('unwind', function() { + var object = { + name: 'alice', + hobbies: ['Golf', 'Hacking'], + colors: ['red', 'green'] + }; + + + it('returns list of destructed object if key is present as list in the object', function() { + eq(R.unwind('hobbies', object), [ + {name: 'alice', hobbies: 'Golf', colors: ['red', 'green']}, + {name: 'alice', hobbies: 'Hacking', colors: ['red', 'green']} + ]); + eq(R.unwind('colors', object), [ + {name: 'alice', hobbies: ['Golf', 'Hacking'], colors: 'red'}, + {name: 'alice', hobbies: ['Golf', 'Hacking'], colors: 'green'} + ]); + }); + + it('returns a list containing only the original object if the key is not present in the object', function() { + eq(R.unwind('hobby', object), [object]); + }); + + it('returns a list containing only the original object if the the value for that key is not iterable', function() { + eq(R.unwind('passtimes', object), [object]); + eq(R.unwind('options', { + title: 'What is the best programming language?', + options: {0: 'Python', 1: 'Java', 2: 'JavaScript', 3: 'C++'}, + ans: 'Correct Answer is 2' + }), [{ + title: 'What is the best programming language?', + options: {0: 'Python', 1: 'Java', 2: 'JavaScript', 3: 'C++'}, + ans: 'Correct Answer is 2' + }]); + eq(R.unwind('hobbies', { name: 'Berney', hobbies: NaN}), [{ name: 'Berney', hobbies: NaN}]); + }); + + it('does not treat a String as a list', function() { + eq(R.unwind('hobbies', { name: 'alice', hobbies:'Golf' }), [ + { name: 'alice', hobbies: 'Golf'} + ]); + // Incorrect: result <- [ + // { name: 'alice', hobbies: 'G'}, + // { name: 'alice', hobbies: 'o'}, + // { name: 'alice', hobbies: 'l'}, + // { name: 'alice', hobbies: 'f'}, + // ] + }); +}); From 95ed1c1a71d6c32af35318212ae2f3797e10e93f Mon Sep 17 00:00:00 2001 From: Morgan McCauley Date: Wed, 13 Jan 2021 04:30:34 +1300 Subject: [PATCH 066/111] Add reduced support to reduceBy and reduceRight (#2663) * Add reduced support to reduceBy * Add reduced support to reduceRight * Update reduced and associated docs for newly supporting functions * Rename shortcut -> short circuit --- source/reduceBy.js | 14 ++++++++-- source/reduceRight.js | 9 +++++-- source/reduceWhile.js | 3 ++- source/reduced.js | 6 +++-- test/reduceBy.js | 59 ++++++++++++++++++++----------------------- test/reduceRight.js | 4 +++ 6 files changed, 56 insertions(+), 39 deletions(-) diff --git a/source/reduceBy.js b/source/reduceBy.js index e1c624df7f..27783de84f 100644 --- a/source/reduceBy.js +++ b/source/reduceBy.js @@ -3,6 +3,7 @@ import _curryN from './internal/_curryN.js'; import _dispatchable from './internal/_dispatchable.js'; import _has from './internal/_has.js'; import _reduce from './internal/_reduce.js'; +import _reduced from './internal/_reduced.js'; import _xreduceBy from './internal/_xreduceBy.js'; @@ -11,6 +12,9 @@ import _xreduceBy from './internal/_xreduceBy.js'; * the String-returning function `keyFn` on each element and reduces the elements * of each group to a single value via the reducer function `valueFn`. * + * The value function receives two values: *(acc, value)*. It may use + * [`R.reduced`](#reduced) to short circuit the iteration. + * * This function is basically a more general [`groupBy`](#groupBy) function. * * Acts as a transducer if a transformer is given in list position. @@ -27,7 +31,7 @@ import _xreduceBy from './internal/_xreduceBy.js'; * @param {Array} list The array to group. * @return {Object} An object with the output of `keyFn` for keys, mapped to the output of * `valueFn` for elements which produced that key when passed to `keyFn`. - * @see R.groupBy, R.reduce + * @see R.groupBy, R.reduce, R.reduced * @example * * const groupNames = (acc, {name}) => acc.concat(name) @@ -51,7 +55,13 @@ var reduceBy = _curryN(4, [], _dispatchable([], _xreduceBy, function reduceBy(valueFn, valueAcc, keyFn, list) { return _reduce(function(acc, elt) { var key = keyFn(elt); - acc[key] = valueFn(_has(key, acc) ? acc[key] : _clone(valueAcc, [], [], false), elt); + var value = valueFn(_has(key, acc) ? acc[key] : _clone(valueAcc, [], [], false), elt); + + if (value && value['@@transducer/reduced']) { + return _reduced(acc); + } + + acc[key] = value; return acc; }, {}, list); })); diff --git a/source/reduceRight.js b/source/reduceRight.js index 6dd6a74707..0d87810dd4 100644 --- a/source/reduceRight.js +++ b/source/reduceRight.js @@ -10,7 +10,8 @@ import _curry3 from './internal/_curry3.js'; * right to the left. * * The iterator function receives two values: *(value, acc)*, while the arguments' - * order of `reduce`'s iterator function is *(acc, value)*. + * order of `reduce`'s iterator function is *(acc, value)*. `reduceRight` may use [`reduced`](#reduced) + * to short circuit the iteration. * * Note: `R.reduceRight` does not skip deleted or unassigned indices (sparse * arrays), unlike the native `Array.prototype.reduceRight` method. For more details @@ -27,7 +28,7 @@ import _curry3 from './internal/_curry3.js'; * @param {*} acc The accumulator value. * @param {Array} list The list to iterate over. * @return {*} The final, accumulated value. - * @see R.reduce, R.addIndex + * @see R.reduce, R.addIndex, R.reduced * @example * * R.reduceRight(R.subtract, 0, [1, 2, 3, 4]) // => (1 - (2 - (3 - (4 - 0)))) = -2 @@ -47,6 +48,10 @@ var reduceRight = _curry3(function reduceRight(fn, acc, list) { var idx = list.length - 1; while (idx >= 0) { acc = fn(list[idx], acc); + if (acc && acc['@@transducer/reduced']) { + acc = acc['@@transducer/value']; + break; + } idx -= 1; } return acc; diff --git a/source/reduceWhile.js b/source/reduceWhile.js index 6e9e262992..a411915c0e 100644 --- a/source/reduceWhile.js +++ b/source/reduceWhile.js @@ -8,7 +8,8 @@ import _reduced from './internal/_reduced.js'; * through the list, successively calling the iterator function. `reduceWhile` * also takes a predicate that is evaluated before each step. If the predicate * returns `false`, it "short-circuits" the iteration and returns the current - * value of the accumulator. + * value of the accumulator. `reduceWhile` may alternatively be short-circuited + * via [`reduced`](#reduced). * * @func * @memberOf R diff --git a/source/reduced.js b/source/reduced.js index c8c23648d0..d056dbfab0 100644 --- a/source/reduced.js +++ b/source/reduced.js @@ -6,9 +6,11 @@ import _reduced from './internal/_reduced.js'; * and transduce functions. The returned value should be considered a black * box: the internal structure is not guaranteed to be stable. * - * Note: this optimization is only available to the below functions: + * This optimization is available to the below functions: * - [`reduce`](#reduce) * - [`reduceWhile`](#reduceWhile) + * - [`reduceBy`](#reduceBy) + * - [`reduceRight`](#reduceRight) * - [`transduce`](#transduce) * * @func @@ -18,7 +20,7 @@ import _reduced from './internal/_reduced.js'; * @sig a -> * * @param {*} x The final value of the reduce. * @return {*} The wrapped value. - * @see R.reduce, R.reduceWhile, R.transduce + * @see R.reduce, R.reduceWhile, R.reduceBy, R.reduceRight, R.transduce * @example * * R.reduce( diff --git a/test/reduceBy.js b/test/reduceBy.js index 4321e46bca..f01cab4992 100644 --- a/test/reduceBy.js +++ b/test/reduceBy.js @@ -14,23 +14,24 @@ var sumInput = [ ]; describe('reduceBy', function() { + var grade = function(score) { + return (score < 65) ? 'F' : (score < 70) ? 'D' : (score < 80) ? 'C' : (score < 90) ? 'B' : 'A'; + }; + var students = [ + {name: 'Abby', score: 84}, + {name: 'Brad', score: 73}, + {name: 'Chris', score: 89}, + {name: 'Dianne', score: 99}, + {name: 'Eddy', score: 58}, + {name: 'Fred', score: 67}, + {name: 'Gillian', score: 91}, + {name: 'Hannah', score: 78}, + {name: 'Irene', score: 85}, + {name: 'Jack', score: 69} + ]; + var byGrade = function(student) {return grade(student.score || 0);}; + it('splits the list into groups according to the grouping function', function() { - var grade = function(score) { - return (score < 65) ? 'F' : (score < 70) ? 'D' : (score < 80) ? 'C' : (score < 90) ? 'B' : 'A'; - }; - var students = [ - {name: 'Abby', score: 84}, - {name: 'Brad', score: 73}, - {name: 'Chris', score: 89}, - {name: 'Dianne', score: 99}, - {name: 'Eddy', score: 58}, - {name: 'Fred', score: 67}, - {name: 'Gillian', score: 91}, - {name: 'Hannah', score: 78}, - {name: 'Irene', score: 85}, - {name: 'Jack', score: 69} - ]; - var byGrade = function(student) {return grade(student.score || 0);}; var collectNames = function(acc, student) {return acc.concat(student.name);}; eq(R.reduceBy(collectNames, [], byGrade, students), { A: ['Dianne', 'Gillian'], @@ -42,22 +43,6 @@ describe('reduceBy', function() { }); it('splits the list into mutation-free groups', function() { - var grade = function(score) { - return (score < 65) ? 'F' : (score < 70) ? 'D' : (score < 80) ? 'C' : (score < 90) ? 'B' : 'A'; - }; - var students = [ - {name: 'Abby', score: 84}, - {name: 'Brad', score: 73}, - {name: 'Chris', score: 89}, - {name: 'Dianne', score: 99}, - {name: 'Eddy', score: 58}, - {name: 'Fred', score: 67}, - {name: 'Gillian', score: 91}, - {name: 'Hannah', score: 78}, - {name: 'Irene', score: 85}, - {name: 'Jack', score: 69} - ]; - var byGrade = function(student) {return grade(student.score || 0);}; var collectNames = function(acc, student) { acc.push(student.name); return acc; @@ -84,4 +69,14 @@ describe('reduceBy', function() { sumInput ), {A: 800, B: 800, C: 500}); }); + + it('short circuits with reduced', function() { + var collectNames = function(acc, student) { return student.name === 'Fred' ? R.reduced(acc) : acc.concat(student.name); }; + eq(R.reduceBy(collectNames, [], byGrade, students), { + A: ['Dianne'], + B: ['Abby', 'Chris'], + C: ['Brad'], + F: ['Eddy'] + }); + }); }); diff --git a/test/reduceRight.js b/test/reduceRight.js index 79394fa465..cc1fb895fb 100644 --- a/test/reduceRight.js +++ b/test/reduceRight.js @@ -4,6 +4,7 @@ var eq = require('./shared/eq'); describe('reduceRight', function() { var avg = function(a, b) {return (a + b) / 2;}; + var concatFirstThree = function(val, acc) {return acc.length === 3 ? R.reduced(acc) : acc.concat(val);}; it('folds lists in the right order', function() { eq(R.reduceRight(function(a, b) {return a + b;}, '', ['a', 'b', 'c', 'd']), 'abcd'); @@ -21,4 +22,7 @@ describe('reduceRight', function() { eq(R.reduceRight(avg, 0, []), 0); }); + it('short circuits with reduced', function() { + eq(R.reduceRight(concatFirstThree, '', ['a', 'd', 'm', 'a', 'r']), 'ram'); + }); }); From cf64dd7a4f6f053441414871221882d3fc10f110 Mon Sep 17 00:00:00 2001 From: Nicolas DUBIEN Date: Mon, 25 Jan 2021 19:19:18 +0100 Subject: [PATCH 067/111] Move existing PBT tests to fast-check and add some more (#3095) * Migrate property based tests to fast-check * Add some more property based testing tests * Add missing semicolon * Move test from uniq to equals * Use R.uniq * Bump to latest version of fast-check * Bump fast-check * Add tests for prop --- package-lock.json | 53 +++++++++++----------------------- package.json | 2 +- test/add.js | 20 ++++++++----- test/always.js | 12 ++++---- test/collectBy.js | 54 +++++++++++++++++++++-------------- test/compose.js | 24 +++++++++------- test/curry.js | 55 ++++++++++++++++++++--------------- test/equals.js | 23 +++++++++++++++ test/flip.js | 12 ++++---- test/o.js | 31 +++++++++++--------- test/prop.js | 41 +++++++++++++++++++++++++- test/reverse.js | 13 +++++++++ test/shared/funcN.js | 41 -------------------------- test/symmetricDifference.js | 57 +++++++++++++++++++++++++++++++++++++ 14 files changed, 271 insertions(+), 167 deletions(-) delete mode 100644 test/shared/funcN.js diff --git a/package-lock.json b/package-lock.json index 07fa2b50c6..5ae9b61fc6 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "ramda", - "version": "0.26.1", + "version": "0.27.1", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -5577,6 +5577,15 @@ "tmp": "^0.0.33" } }, + "fast-check": { + "version": "2.12.0", + "resolved": "https://registry.npmjs.org/fast-check/-/fast-check-2.12.0.tgz", + "integrity": "sha512-6wZK9r2zymqtj/7k9LB4TTJGiyoGtN7NamXAKOWa4svZlFOdE3p7kbC46Au474E6R6votoQrM5aAjRnYnx0BNg==", + "dev": true, + "requires": { + "pure-rand": "^4.1.1" + } + }, "fast-deep-equal": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/fast-deep-equal/-/fast-deep-equal-2.0.1.tgz", @@ -7214,18 +7223,6 @@ "integrity": "sha1-P02uSpH6wxX3EGL4UhzCOfE2YoA=", "dev": true }, - "jsverify": { - "version": "0.8.4", - "resolved": "https://registry.npmjs.org/jsverify/-/jsverify-0.8.4.tgz", - "integrity": "sha512-nUG73Sfi8L4eOkc7pv9sflgAm43v+z6XMuePGVdRoBUxBLJiVcMcf3Xgc4h19eHHF3JwsaagOkUu825UnPBLJw==", - "dev": true, - "requires": { - "lazy-seq": "^1.0.0", - "rc4": "~0.1.5", - "trampa": "^1.0.0", - "typify-parser": "^1.1.0" - } - }, "just-extend": { "version": "4.0.2", "resolved": "https://registry.npmjs.org/just-extend/-/just-extend-4.0.2.tgz", @@ -7253,12 +7250,6 @@ "stream-splicer": "^1.1.0" } }, - "lazy-seq": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/lazy-seq/-/lazy-seq-1.0.0.tgz", - "integrity": "sha1-iAy4qrJWAmOC4C9T7AiWgqdMW2o=", - "dev": true - }, "lcid": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/lcid/-/lcid-2.0.0.tgz", @@ -8889,6 +8880,12 @@ "integrity": "sha1-VACKyXKux0F13vnLpt9/qdORh0A=", "dev": true }, + "pure-rand": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/pure-rand/-/pure-rand-4.1.1.tgz", + "integrity": "sha512-cZw4AL/KI6aDTdqHEbJPe2ZoHM3kSdpJRLJetv8c3tfq9o+PvQDXrHNEpB0AWukAGFx4fmeOerAGwkA4rtUgdA==", + "dev": true + }, "qs": { "version": "6.7.0", "resolved": "https://registry.npmjs.org/qs/-/qs-6.7.0.tgz", @@ -8944,12 +8941,6 @@ "unpipe": "1.0.0" } }, - "rc4": { - "version": "0.1.5", - "resolved": "https://registry.npmjs.org/rc4/-/rc4-0.1.5.tgz", - "integrity": "sha1-CMbgSgFo9utiHCKrbLEVG9n0pk0=", - "dev": true - }, "read-pkg": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-2.0.0.tgz", @@ -10440,12 +10431,6 @@ "integrity": "sha512-yaOH/Pk/VEhBWWTlhI+qXxDFXlejDGcQipMlyxda9nthulaxLZUNcUqFxokp0vcYnvteJln5FNQDRrxj3YcbVw==", "dev": true }, - "trampa": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/trampa/-/trampa-1.0.1.tgz", - "integrity": "sha512-93WeyHNuRggPEsfCe+yHxCgM2s6H3Q8Wmlt6b6ObJL8qc7eZlRaFjQxwTrB+zbvGtlDRnAkMoYYo3+2uH/fEwA==", - "dev": true - }, "trim-right": { "version": "1.0.1", "resolved": "https://registry.npmjs.org/trim-right/-/trim-right-1.0.1.tgz", @@ -10539,12 +10524,6 @@ "is-typedarray": "^1.0.0" } }, - "typify-parser": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/typify-parser/-/typify-parser-1.1.0.tgz", - "integrity": "sha1-rHO/pfJTQ0aOLQ8zRsYRe8A9PJk=", - "dev": true - }, "uc.micro": { "version": "1.0.6", "resolved": "https://registry.npmjs.org/uc.micro/-/uc.micro-1.0.6.tgz", diff --git a/package.json b/package.json index 24c1d4fc7c..30438cd688 100644 --- a/package.json +++ b/package.json @@ -101,9 +101,9 @@ "envvar": "^2.0.0", "eslint": "^5.16.0", "eslint-plugin-import": "^2.21.2", + "fast-check": "^2.12.0", "handlebars": ">=4.1.2", "js-yaml": "^3.13.1", - "jsverify": "^0.8.4", "mocha": "^6.1.4", "nyc": "^15.0.1", "rimraf": "^2.6.3", diff --git a/test/add.js b/test/add.js index 509ed0a02b..87719cc478 100644 --- a/test/add.js +++ b/test/add.js @@ -1,6 +1,6 @@ var R = require('../source'); var eq = require('./shared/eq'); -var jsv = require('jsverify'); +var fc = require('fast-check'); describe('add', function() { @@ -20,15 +20,21 @@ describe('add', function() { }); describe('add properties', function() { - jsv.property('commutative', jsv.number, jsv.number, function(a, b) { - return R.add(a, b) === R.add(b, a); + it('commutative', function() { + fc.assert(fc.property(fc.integer(), fc.integer(), function(a, b) { + return R.add(a, b) === R.add(b, a); + })); }); - jsv.property('associative', jsv.number, jsv.number, jsv.number, function(a, b, c) { - return R.add(a, R.add(b, c)) === R.add(R.add(a, b), c); + it('associative', function() { + fc.assert(fc.property(fc.integer(), fc.integer(), fc.integer(), function(a, b, c) { + return R.add(a, R.add(b, c)) === R.add(R.add(a, b), c); + })); }); - jsv.property('identity', jsv.number, function(a) { - return R.add(a, 0) === a && R.add(0, a) === a; + it('identity', function() { + fc.assert(fc.property(fc.integer(), function(a) { + return R.add(a, 0) === a && R.add(0, a) === a; + })); }); }); diff --git a/test/always.js b/test/always.js index f4398e9dc5..7855a37545 100644 --- a/test/always.js +++ b/test/always.js @@ -1,6 +1,6 @@ var R = require('../source'); var eq = require('./shared/eq'); -var jsv = require('jsverify'); +var fc = require('fast-check'); describe('always', function() { @@ -25,9 +25,11 @@ describe('always', function() { }); describe('always properties', function() { - jsv.property('returns initial argument', jsv.json, jsv.json, function(a, b) { - var f = R.always(a); - - return f() === a && f(b) === a; + it('returns initial argument', function() { + fc.assert(fc.property(fc.anything(), fc.anything(), function(a, b) { + fc.pre(a === a); + var f = R.always(a); + return f() === a && f(b) === a; + })); }); }); diff --git a/test/collectBy.js b/test/collectBy.js index 91f46845a9..95282a0778 100644 --- a/test/collectBy.js +++ b/test/collectBy.js @@ -1,37 +1,47 @@ var {all, compose , difference , equals , head , identity , is , isEmpty , length , uniq , unnest , collectBy} = require('../source'); -var {property} = require('jsverify'); +var fc = require('fast-check'); var {spy} = require('sinon'); describe('collectBy', function() { - property('returns a list of lists', '[nat]', function(xs) { - var check = all(is(Array)); - var ys = collectBy(identity)(xs); - return check(ys); + it('returns a list of lists', function() { + fc.assert(fc.property(fc.array(fc.nat()), function(xs) { + var check = all(is(Array)); + var ys = collectBy(identity)(xs); + return check(ys); + })); }); - property('groups items but neiter adds new ones nor removes any', '[nat]', function(xs) { - var check = compose(isEmpty, difference(xs), unnest); - var ys = collectBy(identity)(xs); - return check(ys); + it('groups items but neiter adds new ones nor removes any', function() { + fc.assert(fc.property(fc.array(fc.nat()), function(xs) { + var check = compose(isEmpty, difference(xs), unnest); + var ys = collectBy(identity)(xs); + return check(ys); + })); }); - property('groups related items together', '[bool]', function(xs) { - var ys = collectBy(identity)(xs); - var check = all(compose(equals(1), length, uniq)); - return check(ys); + it('groups related items together', function() { + fc.assert(fc.property(fc.array(fc.boolean()), function(xs) { + var ys = collectBy(identity)(xs); + var check = all(compose(equals(1), length, uniq)); + return check(ys); + })); }); - property('invokes the tag function for each item in the list', '[nat]', function(xs) { - var id = spy(x => 42); - collectBy(id)(xs); - var check = compose(isEmpty, difference(xs)); - return check(id.getCalls().map(call => call.args[0])); + it('invokes the tag function for each item in the list', function() { + fc.assert(fc.property(fc.array(fc.nat()), function(xs) { + var id = spy(x => 42); + collectBy(id)(xs); + var check = compose(isEmpty, difference(xs)); + return check(id.getCalls().map(call => call.args[0])); + })); }); - property('groups items according to the tag value', '[nat]', function(xs) { - var ys = collectBy(x => 42)(xs); - var check = compose(isEmpty, difference(xs), head); - return isEmpty(xs) && isEmpty(ys) ? true : check(ys); + it('groups items according to the tag value', function() { + fc.assert(fc.property(fc.array(fc.nat()), function(xs) { + var ys = collectBy(x => 42)(xs); + var check = compose(isEmpty, difference(xs), head); + return isEmpty(xs) && isEmpty(ys) ? true : check(ys); + })); }); }); diff --git a/test/compose.js b/test/compose.js index 6338ecdee8..aacc13359c 100644 --- a/test/compose.js +++ b/test/compose.js @@ -1,8 +1,8 @@ var assert = require('assert'); -var jsv = require('jsverify'); var R = require('../source'); var eq = require('./shared/eq'); +var fc = require('fast-check'); describe('compose', function() { @@ -62,16 +62,20 @@ describe('compose', function() { describe('compose properties', function() { - jsv.property('composes two functions', jsv.fn(), jsv.fn(), jsv.nat, function(f, g, x) { - return R.equals(R.compose(f, g)(x), f(g(x))); + it('composes two functions', function() { + fc.assert(fc.property(fc.func(fc.nat()), fc.func(fc.nat()), fc.nat(), function(f, g, x) { + return R.equals(R.compose(f, g)(x), f(g(x))); + })); }); - jsv.property('associative', jsv.fn(), jsv.fn(), jsv.fn(), jsv.nat, function(f, g, h, x) { - var result = f(g(h(x))); - return R.all(R.equals(result), [ - R.compose(f, g, h)(x), - R.compose(f, R.compose(g, h))(x), - R.compose(R.compose(f, g), h)(x) - ]); + it('associative', function() { + fc.assert(fc.property(fc.func(fc.nat()), fc.func(fc.nat()), fc.func(fc.nat()), fc.nat(), function(f, g, h, x) { + var result = f(g(h(x))); + return R.all(R.equals(result), [ + R.compose(f, g, h)(x), + R.compose(f, R.compose(g, h))(x), + R.compose(R.compose(f, g), h)(x) + ]); + })); }); }); diff --git a/test/curry.js b/test/curry.js index cd9043b21f..20681c0ed1 100644 --- a/test/curry.js +++ b/test/curry.js @@ -1,7 +1,6 @@ var R = require('../source'); var eq = require('./shared/eq'); -var jsv = require('jsverify'); -var funcN = require('./shared/funcN'); +var fc = require('fast-check'); describe('curry', function() { it('curries a single value', function() { @@ -123,28 +122,38 @@ describe('curry', function() { }); describe('curry properties', function() { - jsv.property('curries multiple values', funcN(4), jsv.json, jsv.json, jsv.json, jsv.json, function(f, a, b, c, d) { - var g = R.curry(f); - - return R.all(R.equals(f(a, b, c, d)), [ - g(a, b, c, d), - g(a)(b)(c)(d), - g(a)(b, c, d), - g(a, b)(c, d), - g(a, b, c)(d) - ]); + it('curries multiple values', function() { + fc.assert(fc.property(fc.func(fc.anything()), fc.anything(), fc.anything(), fc.anything(), fc.anything(), function(f, a, b, c, d) { + var f4 = function(a, b, c, d) { + return f(a, b, c, d); + }; + var g = R.curry(f4); + + return R.all(R.equals(f4(a, b, c, d)), [ + g(a, b, c, d), + g(a)(b)(c)(d), + g(a)(b, c, d), + g(a, b)(c, d), + g(a, b, c)(d) + ]); + })); }); - jsv.property('curries with placeholder', funcN(3), jsv.json, jsv.json, jsv.json, function(f, a, b, c) { - var _ = {'@@functional/placeholder': true, x: Math.random()}; - var g = R.curry(f); - - return R.all(R.equals(f(a, b, c)), [ - g(_, _, c)(a, b), - g(a, _, c)(b), - g(_, b, c)(a), - g(a, _, _)(_, c)(b), - g(a, b, _)(c) - ]); + it('curries with placeholder', function() { + fc.assert(fc.property(fc.func(fc.anything()), fc.anything(), fc.anything(), fc.anything(), function(f, a, b, c) { + var _ = {'@@functional/placeholder': true, x: Math.random()}; + var f3 = function(a, b, c) { + return f(a, b, c); + }; + var g = R.curry(f3); + + return R.all(R.equals(f3(a, b, c)), [ + g(_, _, c)(a, b), + g(a, _, c)(b), + g(_, b, c)(a), + g(a, _, _)(_, c)(b), + g(a, b, _)(c) + ]); + })); }); }); diff --git a/test/equals.js b/test/equals.js index d56cd4970a..73f6bae80e 100644 --- a/test/equals.js +++ b/test/equals.js @@ -2,6 +2,7 @@ var R = require('../source'); var eq = require('./shared/eq'); +var fc = require('fast-check'); describe('equals', function() { var a = []; @@ -329,4 +330,26 @@ describe('equals', function() { eq(R.equals(new ColorPoint(2, 2, 'red'), new Point(2, 2)), false); }); + // Arbitrary configured to produce any kind of values + // from simple numbers to complex objects + const anythingInstanceArb = fc.anything({ + withBoxedValues: true, // eg.: new Number(1), ... + withNullPrototype: true, // eg.: Object.create(null), ... + withObjectString: true, // eg.: "{}", "null", ... + withMap: typeof Map !== 'undefined', + withSet: typeof Set !== 'undefined' + }); + + it('perfect clones should be considered equal', function() { + fc.assert(fc.property(fc.clone(anythingInstanceArb, 2), function(values) { + eq(R.equals(values[0], values[1]), true); + })); + }); + + it('is commutative whatever the values', function() { + fc.assert(fc.property(anythingInstanceArb, anythingInstanceArb, function(v1, v2) { + eq(R.equals(v1, v2), R.equals(v2, v1)); + })); + }); + }); diff --git a/test/flip.js b/test/flip.js index 2c046b78bb..882d8f8ae2 100644 --- a/test/flip.js +++ b/test/flip.js @@ -1,8 +1,6 @@ -var jsv = require('jsverify'); - var R = require('../source'); var eq = require('./shared/eq'); -var funcN = require('./shared/funcN'); +var fc = require('fast-check'); describe('flip', function() { @@ -29,8 +27,10 @@ describe('flip', function() { }); describe('flip properties', function() { - jsv.property('inverts first two arguments', funcN(3), jsv.json, jsv.json, jsv.json, function(f, a, b, c) { - var g = R.flip(f); - return R.equals(f(a, b, c), g(b, a, c)); + it('inverts first two arguments', function() { + fc.assert(fc.property(fc.func(fc.anything()), fc.anything(), fc.anything(), fc.anything(), function(f, a, b, c) { + var g = R.flip(f); + return R.equals(f(a, b, c), g(b, a, c)); + })); }); }); diff --git a/test/o.js b/test/o.js index 8cbf14708c..fe743d3fb5 100644 --- a/test/o.js +++ b/test/o.js @@ -1,7 +1,6 @@ -var jsv = require('jsverify'); - var R = require('../source'); var eq = require('./shared/eq'); +var fc = require('fast-check'); describe('o', function() { @@ -25,20 +24,24 @@ describe('o', function() { describe('o properties', function() { - jsv.property('composes two functions', jsv.fn(), jsv.fn(), jsv.nat, function(f, g, x) { - return R.equals(R.o(f, g)(x), f(g(x))); + it('composes two functions', function() { + fc.assert(fc.property(fc.func(fc.nat()), fc.func(fc.nat()), fc.nat(), function(f, g, x) { + return R.equals(R.o(f, g)(x), f(g(x))); + })); }); - jsv.property('associative', jsv.fn(), jsv.fn(), jsv.fn(), jsv.nat, function(f, g, h, x) { - var result = f(g(h(x))); - var fg = R.o(f, g); - var gh = R.o(g, h); - return R.all(R.equals(result), [ - R.o(f, gh, x), - R.o(fg, h, x), - R.o(f, gh)(x), - R.o(fg, h)(x) - ]); + it('associative', function() { + fc.assert(fc.property(fc.func(fc.nat()), fc.func(fc.nat()), fc.func(fc.nat()), fc.nat(), function(f, g, h, x) { + var result = f(g(h(x))); + var fg = R.o(f, g); + var gh = R.o(g, h); + return R.all(R.equals(result), [ + R.o(f, gh, x), + R.o(fg, h, x), + R.o(f, gh)(x), + R.o(fg, h)(x) + ]); + })); }); }); }); diff --git a/test/prop.js b/test/prop.js index b941d70c8d..05d321c657 100644 --- a/test/prop.js +++ b/test/prop.js @@ -1,6 +1,6 @@ var R = require('../source'); var eq = require('./shared/eq'); - +var fc = require('fast-check'); describe('prop', function() { var fred = {name: 'Fred', age: 23}; @@ -66,4 +66,43 @@ describe('prop', function() { eq(propResult, pathResult); eq(propException, pathException); }); + + it('returns that value associated to a property given valid one', function() { + fc.assert( + fc.property(fc.string(), fc.anything(), function(p, value) { + const o = { [p]: value }; + eq(R.prop(p, o), value); + }) + ); + }); + + it('shows the same behaviour as path on any object', function() { + fc.assert( + fc.property(fc.string(), fc.object(), function(p, o) { + eq(R.prop(p, o), R.path([p], o)); + }) + ); + }); + + it('shows the same behaviour as path on any value', function() { + fc.assert( + fc.property(fc.string(), fc.anything(), function(p, o) { + var propResult, propException, pathResult, pathException; + try { + propResult = R.prop(p, o); + } catch (e) { + propException = e; + } + + try { + pathResult = R.path([p], o); + } catch (e) { + pathException = e; + } + + eq(propResult, pathResult); + eq(propException, pathException); + }) + ); + }); }); diff --git a/test/reverse.js b/test/reverse.js index 0259267d91..c11c441222 100644 --- a/test/reverse.js +++ b/test/reverse.js @@ -1,5 +1,6 @@ var R = require('../source'); var eq = require('./shared/eq'); +var fc = require('fast-check'); describe('reverse', function() { @@ -11,6 +12,12 @@ describe('reverse', function() { eq(R.reverse([1, 2, 3]), [3, 2, 1]); }); + it('reverses twice an array should be the array itself', function() { + fc.assert(fc.property(fc.array(fc.anything()), function(array) { + eq(R.reverse(R.reverse(array)), array); + })); + }); + it('reverses strings', function() { eq(R.reverse(''), ''); eq(R.reverse('a'), 'a'); @@ -18,4 +25,10 @@ describe('reverse', function() { eq(R.reverse('abc'), 'cba'); }); + it('reverses twice a string should be the string itself', function() { + fc.assert(fc.property(fc.fullUnicodeString(), function(str) { + eq(R.reverse(R.reverse(str)), str); + })); + }); + }); diff --git a/test/shared/funcN.js b/test/shared/funcN.js deleted file mode 100644 index adf12efc15..0000000000 --- a/test/shared/funcN.js +++ /dev/null @@ -1,41 +0,0 @@ -var jsv = require('jsverify'); - -var FMap = jsv._.FMap; - -module.exports = function(n, arb) { - arb = jsv.utils.force(arb || jsv.json); - - return jsv.bless({ - generator: jsv.generator.bless(function(size) { - var m = new FMap(); - - var f = function(a0) { - if (!m.contains(a0)) { - var value = arb.generator(size); - m.insert(a0, value); - } - - return m.get(a0); - }; - - switch (n) { - case 1: return function(a0) { return f([a0]); }; - case 2: return function(a0, a1) { return f([a0, a1]); }; - case 3: return function(a0, a1, a2) { return f([a0, a1, a2]); }; - case 4: return function(a0, a1, a2, a3) { return f([a0, a1, a2, a3]); }; - case 5: return function(a0, a1, a2, a3, a4) { return f([a0, a1, a2, a3, a4]); }; - case 6: return function(a0, a1, a2, a3, a4, a5) { return f([a0, a1, a2, a3, a4, a5]); }; - case 7: return function(a0, a1, a2, a3, a4, a5, a6) { return f([a0, a1, a2, a3, a4, a5, a6]); }; - case 8: return function(a0, a1, a2, a3, a4, a5, a6, a7) { return f([a0, a1, a2, a3, a4, a5, a6, a7]); }; - case 9: return function(a0, a1, a2, a3, a4, a5, a6, a7, a8) { return f([a0, a1, a2, a3, a4, a5, a6, a7, a8]); }; - case 10: return function(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9) { return f([a0, a1, a2, a3, a4, a5, a6, a7, a8, a9]); }; - default: throw new Error('First argument to funcN must be a positive integer no greater than ten'); - } - }), - - shrink: jsv.shrink.noop, - show: function(f) { - return 'Function of arity' + f.length; - } - }); -}; diff --git a/test/symmetricDifference.js b/test/symmetricDifference.js index 4f34e3dc0b..eb6e38a62f 100644 --- a/test/symmetricDifference.js +++ b/test/symmetricDifference.js @@ -1,5 +1,6 @@ var R = require('../source'); var eq = require('./shared/eq'); +var fc = require('fast-check'); describe('symmetricDifference', function() { @@ -44,4 +45,60 @@ describe('symmetricDifference', function() { eq(R.symmetricDifference(M, M2), []); }); + // Arbitrary producing arrays of unique values (with respect to R.equals) + var compatibleREquals = fc.array(fc.anything({ + maxDepth: 0, + withBoxedValues: true, + withNullPrototype: true, + withObjectString: true + })).map(array => R.uniq(array)); + + it('returns empty arrays when receiving twice the same array', function() { + fc.assert(fc.property(fc.clone(compatibleREquals, 2), function(arrays) { + var A1 = arrays[0]; + var A2 = arrays[1]; + eq(R.symmetricDifference(A1, A2), []); + })); + }); + + it('returns empty arrays when receiving an array and a permutation of it', function() { + fc.assert(fc.property(fc.clone(compatibleREquals, 2).chain(function(arrays) { + return fc.tuple(fc.constant(arrays[0]), fc.shuffledSubarray(arrays[1], arrays[1].length, arrays[1].length)); + }), function(arrays) { + var A1 = arrays[0]; + var A2 = arrays[1]; + eq(R.symmetricDifference(A1, A2), []); + })); + }); + + it('returns missing items when receiving an array and a permuted subset of it', function() { + fc.assert(fc.property(fc.clone(compatibleREquals, 2).chain(function(arrays) { + return fc.tuple(fc.constant(arrays[0]), fc.shuffledSubarray(arrays[1])); + }), function(arrays) { + var A1 = arrays[0]; + var A2 = arrays[1]; + eq(R.symmetricDifference(A1, A2).length, A1.length - A2.length); + })); + }); + + it('returns an array not containing too many items', function() { + fc.assert(fc.property(compatibleREquals, compatibleREquals, compatibleREquals, compatibleREquals, compatibleREquals, function(A1, A2, B, C1, C2) { + var M = R.uniq(A1.concat(B).concat(C1)); + var N = R.uniq(A2.concat(B).concat(C2)); + var difference = R.symmetricDifference(M, N); + var upperBoundDifferenceLength = A1.length + A2.length + C1.length + C2.length; + eq(difference.length <= upperBoundDifferenceLength, true); + })); + }); + + it('returns an array containing only items coming from one of the sources', function() { + fc.assert(fc.property(compatibleREquals, compatibleREquals, compatibleREquals, compatibleREquals, compatibleREquals, function(A1, A2, B, C1, C2) { + var M = R.uniq(A1.concat(B).concat(C1)); + var N = R.uniq(A2.concat(B).concat(C2)); + var MN = R.uniq(M.concat(N)); + var difference = R.symmetricDifference(M, N); + eq(R.symmetricDifference(difference, MN).length, MN.length - difference.length); + })); + }); + }); From 9dbcacbe4c3c7963984c44da9c23a2ed10e3bc8b Mon Sep 17 00:00:00 2001 From: Kartik Maurya Date: Tue, 9 Feb 2021 02:43:33 +0530 Subject: [PATCH 068/111] adjust code refactoring : using modulo to cycle through indices positive and negative; adding array length as a pavariable as it was being reused often (#3134) --- source/adjust.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/source/adjust.js b/source/adjust.js index f3e9ecd71b..f59385e8c2 100644 --- a/source/adjust.js +++ b/source/adjust.js @@ -28,11 +28,11 @@ import _curry3 from './internal/_curry3.js'; * @symb R.adjust(0, f, [a, b]) = [f(a), b] */ var adjust = _curry3(function adjust(idx, fn, list) { - if (idx >= list.length || idx < -list.length) { + var len = list.length; + if (idx >= len || idx < -len) { return list; } - var start = idx < 0 ? list.length : 0; - var _idx = start + idx; + var _idx = (len + idx) % len; var _list = _concat(list); _list[_idx] = fn(list[_idx]); return _list; From 84af16091e8c19518f189a8cf087d1318ff57d60 Mon Sep 17 00:00:00 2001 From: Liam Tait Date: Sat, 20 Feb 2021 07:45:55 +1300 Subject: [PATCH 069/111] fix: clone typed arrays (#3135) --- source/internal/_clone.js | 14 +++++++- test/clone.js | 75 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 88 insertions(+), 1 deletion(-) diff --git a/source/internal/_clone.js b/source/internal/_clone.js index 8831fc35e8..8416e641b2 100644 --- a/source/internal/_clone.js +++ b/source/internal/_clone.js @@ -35,7 +35,19 @@ export default function _clone(value, refFrom, refTo, deep) { case 'Object': return copy(Object.create(Object.getPrototypeOf(value))); case 'Array': return copy([]); case 'Date': return new Date(value.valueOf()); - case 'RegExp': return _cloneRegExp(value); + case 'RegExp': return _cloneRegExp(value); + case 'Int8Array': + case 'Uint8Array': + case 'Uint8ClampedArray': + case 'Int16Array': + case 'Uint16Array': + case 'Int32Array': + case 'Uint32Array': + case 'Float32Array': + case 'Float64Array': + case 'BigInt64Array': + case 'BigUint64Array': + return value.slice(); default: return value; } } diff --git a/test/clone.js b/test/clone.js index b99f2c24e9..2428fb646d 100644 --- a/test/clone.js +++ b/test/clone.js @@ -135,6 +135,81 @@ describe('deep clone arrays', function() { }); +describe('deep clone typed arrays', function() { + it('clones Uint16Array', function() { + var array = new Uint16Array([1, 2, 3]); + var clone = R.clone(array); + + assert.notStrictEqual(array, clone); + eq(clone, new Uint16Array([1, 2, 3])); + }); + + it('clones Int8Array', function() { + var array = new Int8Array([1,2,3]); + var clone = R.clone(array); + + assert.notStrictEqual(array, clone); + eq(clone, new Int8Array([1,2,3])); + }); + it('clones Uint8Array', function() { + var array = new Uint8Array([1,2,3]); + var clone = R.clone(array); + + assert.notStrictEqual(array, clone); + eq(clone, new Uint8Array([1,2,3])); + }); + it('clones Uint8ClampedArray', function() { + var array = new Uint8ClampedArray([1,2,3]); + var clone = R.clone(array); + + assert.notStrictEqual(array, clone); + eq(clone, new Uint8ClampedArray([1,2,3])); + }); + it('clones Int16Array', function() { + var array = new Int16Array([1,2,3]); + var clone = R.clone(array); + + assert.notStrictEqual(array, clone); + eq(clone, new Int16Array([1,2,3])); + }); + it('clones Uint16Array', function() { + var array = new Uint16Array([1,2,3]); + var clone = R.clone(array); + + assert.notStrictEqual(array, clone); + eq(clone, new Uint16Array([1,2,3])); + }); + it('clones Int32Array', function() { + var array = new Int32Array([1,2,3]); + var clone = R.clone(array); + + assert.notStrictEqual(array, clone); + eq(clone, new Int32Array([1,2,3])); + }); + it('clones Uint32Array', function() { + var array = new Uint32Array([1,2,3]); + var clone = R.clone(array); + + assert.notStrictEqual(array, clone); + eq(clone, new Uint32Array([1,2,3])); + }); + it('clones Float32Array', function() { + var array = new Float32Array([1,2,3]); + var clone = R.clone(array); + + assert.notStrictEqual(array, clone); + eq(clone, new Float32Array([1,2,3])); + }); + it('clones Float64Array', function() { + var array = new Float64Array([1,2,3]); + var clone = R.clone(array); + + assert.notStrictEqual(array, clone); + eq(clone, new Float64Array([1,2,3])); + }); + +}); + describe('deep clone functions', function() { it('keep reference to function', function() { var fn = function(x) { return x + x;}; From 9b5d8925f23f0f44a2e656bfd0cf23ff30031794 Mon Sep 17 00:00:00 2001 From: wangzengdi Date: Sat, 6 Mar 2021 03:56:15 +0800 Subject: [PATCH 070/111] chore: There is no need to check if acc is empty every time. (#3136) --- source/groupBy.js | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/source/groupBy.js b/source/groupBy.js index f9983ca580..60a0366b86 100644 --- a/source/groupBy.js +++ b/source/groupBy.js @@ -44,10 +44,7 @@ import reduceBy from './reduceBy.js'; * // } */ var groupBy = _curry2(_checkForMethod('groupBy', reduceBy(function(acc, item) { - if (acc == null) { - acc = []; - } acc.push(item); return acc; -}, null))); +}, []))); export default groupBy; From 0b3deef8845b873f12f909887cb94d422a3a0def Mon Sep 17 00:00:00 2001 From: Scott Sauyet Date: Wed, 24 Mar 2021 08:28:11 -0400 Subject: [PATCH 071/111] Adding note to cond documentation (#3139) --- source/cond.js | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/source/cond.js b/source/cond.js index fd070d5f31..479d68afb3 100644 --- a/source/cond.js +++ b/source/cond.js @@ -12,6 +12,10 @@ import reduce from './reduce.js'; * "truthy" value, at which point `fn` returns the result of applying its * arguments to the corresponding transformer. If none of the predicates * matches, `fn` returns undefined. + * + * **Please note**: This is not a direct substitute for a `switch` statement. + * Remember that both elements of every pair passed to `cond` are *functions*, + * and `cond` returns a function. * * @func * @memberOf R From 6b6a85d3fe30ac1a41ac05734be9f61bd92325e5 Mon Sep 17 00:00:00 2001 From: wangzengdi Date: Sat, 3 Apr 2021 09:19:36 +0800 Subject: [PATCH 072/111] fix: isOdd: n % 2 may be 1 and -1. (#3140) --- dist/ramda.js | 2 +- source/cond.js | 2 +- source/none.js | 2 +- source/reduceWhile.js | 2 +- source/reject.js | 2 +- source/transduce.js | 2 +- test/into.js | 2 +- test/reduceWhile.js | 2 +- test/transduce.js | 2 +- 9 files changed, 9 insertions(+), 9 deletions(-) diff --git a/dist/ramda.js b/dist/ramda.js index d7d6065466..8268eb7c78 100644 --- a/dist/ramda.js +++ b/dist/ramda.js @@ -2998,7 +2998,7 @@ * @see R.filter, R.transduce, R.addIndex * @example * - * const isOdd = (n) => n % 2 === 1; + * const isOdd = (n) => n % 2 !== 0; * * R.reject(isOdd, [1, 2, 3, 4]); //=> [2, 4] * diff --git a/source/cond.js b/source/cond.js index 479d68afb3..1d1ee37745 100644 --- a/source/cond.js +++ b/source/cond.js @@ -12,7 +12,7 @@ import reduce from './reduce.js'; * "truthy" value, at which point `fn` returns the result of applying its * arguments to the corresponding transformer. If none of the predicates * matches, `fn` returns undefined. - * + * * **Please note**: This is not a direct substitute for a `switch` statement. * Remember that both elements of every pair passed to `cond` are *functions*, * and `cond` returns a function. diff --git a/source/none.js b/source/none.js index dd9f24ec51..5f18621760 100644 --- a/source/none.js +++ b/source/none.js @@ -23,7 +23,7 @@ import all from './all.js'; * @example * * const isEven = n => n % 2 === 0; - * const isOdd = n => n % 2 === 1; + * const isOdd = n => n % 2 !== 0; * * R.none(isEven, [1, 3, 5, 7, 9, 11]); //=> true * R.none(isOdd, [1, 3, 5, 7, 8, 11]); //=> false diff --git a/source/reduceWhile.js b/source/reduceWhile.js index a411915c0e..d3b9e77c50 100644 --- a/source/reduceWhile.js +++ b/source/reduceWhile.js @@ -26,7 +26,7 @@ import _reduced from './internal/_reduced.js'; * @see R.reduce, R.reduced * @example * - * const isOdd = (acc, x) => x % 2 === 1; + * const isOdd = (acc, x) => x % 2 !== 0; * const xs = [1, 3, 5, 60, 777, 800]; * R.reduceWhile(isOdd, R.add, 0, xs); //=> 9 * diff --git a/source/reject.js b/source/reject.js index 40413632e0..66641efa1d 100644 --- a/source/reject.js +++ b/source/reject.js @@ -21,7 +21,7 @@ import filter from './filter.js'; * @see R.filter, R.transduce, R.addIndex * @example * - * const isOdd = (n) => n % 2 === 1; + * const isOdd = (n) => n % 2 !== 0; * * R.reject(isOdd, [1, 2, 3, 4]); //=> [2, 4] * diff --git a/source/transduce.js b/source/transduce.js index 4582a3f42d..4c94975947 100644 --- a/source/transduce.js +++ b/source/transduce.js @@ -46,7 +46,7 @@ import curryN from './curryN.js'; * const transducer = R.compose(R.map(R.add(1)), R.take(2)); * R.transduce(transducer, R.flip(R.append), [], numbers); //=> [2, 3] * - * const isOdd = (x) => x % 2 === 1; + * const isOdd = (x) => x % 2 !== 0; * const firstOddTransducer = R.compose(R.filter(isOdd), R.take(1)); * R.transduce(firstOddTransducer, R.flip(R.append), [], R.range(0, 100)); //=> [1] */ diff --git a/test/into.js b/test/into.js index ae80b4015c..0ac72928d3 100644 --- a/test/into.js +++ b/test/into.js @@ -4,7 +4,7 @@ var eq = require('./shared/eq'); describe('into', function() { var add = R.add; - var isOdd = function(b) {return b % 2 === 1;}; + var isOdd = function(b) { return b % 2 !== 0; }; var addXf = { '@@transducer/step': add, '@@transducer/init': R.always(0), diff --git a/test/reduceWhile.js b/test/reduceWhile.js index 6eb1815026..d10284ffc6 100644 --- a/test/reduceWhile.js +++ b/test/reduceWhile.js @@ -1,7 +1,7 @@ var R = require('../source'); var eq = require('./shared/eq'); -var isOdd = function(_, x) {return x % 2 === 1; }; +var isOdd = function(_, x) { return x % 2 !== 0; }; describe('reduceWhile', function() { it('reduces until its predicate fails', function() { diff --git a/test/transduce.js b/test/transduce.js index 4287a9c782..795b7f2153 100644 --- a/test/transduce.js +++ b/test/transduce.js @@ -4,7 +4,7 @@ var eq = require('./shared/eq'); describe('transduce', function() { var add = R.add; var mult = function(a, b) {return a * b;}; - var isOdd = function(b) {return b % 2 === 1;}; + var isOdd = function(b) { return b % 2 !== 0; }; var square = function(a) {return a * a;}; var addxf = { '@@transducer/step': function(acc, x) { return acc + x; }, From 66e37fe7c8002ca1b99f5f7115c07ccc6ca92814 Mon Sep 17 00:00:00 2001 From: wangzengdi Date: Fri, 21 May 2021 09:42:58 +0800 Subject: [PATCH 073/111] chore: link findIndex and indexOf, and their 'last' version (#3151) --- source/findIndex.js | 2 +- source/findLastIndex.js | 2 +- source/indexOf.js | 2 +- source/lastIndexOf.js | 2 +- 4 files changed, 4 insertions(+), 4 deletions(-) diff --git a/source/findIndex.js b/source/findIndex.js index 974d28b199..580e749023 100644 --- a/source/findIndex.js +++ b/source/findIndex.js @@ -18,7 +18,7 @@ import _xfindIndex from './internal/_xfindIndex.js'; * desired one. * @param {Array} list The array to consider. * @return {Number} The index of the element found, or `-1`. - * @see R.transduce + * @see R.transduce, R.indexOf * @example * * const xs = [{a: 1}, {a: 2}, {a: 3}]; diff --git a/source/findLastIndex.js b/source/findLastIndex.js index 7ee5193740..d437b1b145 100644 --- a/source/findLastIndex.js +++ b/source/findLastIndex.js @@ -18,7 +18,7 @@ import _xfindLastIndex from './internal/_xfindLastIndex.js'; * desired one. * @param {Array} list The array to consider. * @return {Number} The index of the element found, or `-1`. - * @see R.transduce + * @see R.transduce, R.lastIndexOf * @example * * const xs = [{a: 1, b: 0}, {a:1, b: 1}]; diff --git a/source/indexOf.js b/source/indexOf.js index fd5604dcd8..a1626a0c48 100644 --- a/source/indexOf.js +++ b/source/indexOf.js @@ -16,7 +16,7 @@ import _isArray from './internal/_isArray.js'; * @param {*} target The item to find. * @param {Array} xs The array to search in. * @return {Number} the index of the target, or -1 if the target is not found. - * @see R.lastIndexOf + * @see R.lastIndexOf, R.findIndex * @example * * R.indexOf(3, [1,2,3,4]); //=> 2 diff --git a/source/lastIndexOf.js b/source/lastIndexOf.js index 73610c89f9..7a4e28fe93 100644 --- a/source/lastIndexOf.js +++ b/source/lastIndexOf.js @@ -16,7 +16,7 @@ import equals from './equals.js'; * @param {*} target The item to find. * @param {Array} xs The array to search in. * @return {Number} the index of the target, or -1 if the target is not found. - * @see R.indexOf + * @see R.indexOf, R.findLastIndex * @example * * R.lastIndexOf(3, [-1,3,3,0,1,2,3,4]); //=> 6 From fd278f42f82cefebdfe9ef14b86b8880ee52668b Mon Sep 17 00:00:00 2001 From: Dmitry Non Date: Tue, 8 Jun 2021 17:22:38 +0100 Subject: [PATCH 074/111] Add `count` function (#3144) * feat: add `count` function * addressed comments re:tests * refactor(count): inline lambda * refactor: use internal _reduce --- source/count.js | 25 +++++++++++++++++++++++++ source/index.js | 1 + test/count.js | 18 ++++++++++++++++++ 3 files changed, 44 insertions(+) create mode 100644 source/count.js create mode 100644 test/count.js diff --git a/source/count.js b/source/count.js new file mode 100644 index 0000000000..4b444b3071 --- /dev/null +++ b/source/count.js @@ -0,0 +1,25 @@ +import _reduce from './internal/_reduce.js'; +import curry from './curry.js'; + + +/** + * Returns the number of items in a given `list` matching the predicate `f` + * + * @func + * @memberOf R + * @category List + * @sig (a -> Boolean) -> [a] -> Number + * @param {Function} predicate to match items against + * @return {Array} list of items to count in + * @example + * + * const even = x => x % 2 == 0; + * + * R.count(even, [1, 2, 3, 4, 5]); // => 2 + * R.map(R.count(even), [[1, 1, 1], [2, 3, 4, 5], [6]]); // => [0, 2, 1] + */ +var count = curry(function(pred, list) { + return _reduce(function(a, e) { return pred(e) ? a + 1 : a; }, 0, list); +}); + +export default count; diff --git a/source/index.js b/source/index.js index d0d1a8723c..9c605b0b4e 100644 --- a/source/index.js +++ b/source/index.js @@ -36,6 +36,7 @@ export { default as cond } from './cond.js'; export { default as construct } from './construct.js'; export { default as constructN } from './constructN.js'; export { default as converge } from './converge.js'; +export { default as count } from './count.js'; export { default as countBy } from './countBy.js'; export { default as curry } from './curry.js'; export { default as curryN } from './curryN.js'; diff --git a/test/count.js b/test/count.js new file mode 100644 index 0000000000..b8dc43dd34 --- /dev/null +++ b/test/count.js @@ -0,0 +1,18 @@ +var R = require('../source'); +var eq = require('./shared/eq'); + +describe('count', function() { + var even = function(x) { return x % 2 === 0; }; + it('counts items in a list that match a filter', function() { + eq(R.count(even, [1, 2, 3, 4, 5]), 2); + eq(R.count(even, [2, 8, 10, 200]), 4); + }); + + it('returns zero when no element matches', function() { + eq(R.count(even, [1, 3, 5, 7]), 0); + }); + + it('returns zero for an empty list', function() { + eq(R.count(even, []), 0); + }); +}); From 68535de7f8b1bc0c7848948c3bf998d5da88b85a Mon Sep 17 00:00:00 2001 From: wangzengdi Date: Tue, 15 Jun 2021 00:29:31 +0800 Subject: [PATCH 075/111] chore: link toPairs, keys and values (#3161) --- source/keys.js | 2 +- source/toPairs.js | 2 +- source/values.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/source/keys.js b/source/keys.js index 1c20ef9f89..4c2f2dce54 100644 --- a/source/keys.js +++ b/source/keys.js @@ -38,7 +38,7 @@ var contains = function contains(list, item) { * @sig {k: v} -> [k] * @param {Object} obj The object to extract properties from * @return {Array} An array of the object's own properties. - * @see R.keysIn, R.values + * @see R.keysIn, R.values, R.toPairs * @example * * R.keys({a: 1, b: 2, c: 3}); //=> ['a', 'b', 'c'] diff --git a/source/toPairs.js b/source/toPairs.js index d3845efff2..5d29564c7c 100644 --- a/source/toPairs.js +++ b/source/toPairs.js @@ -15,7 +15,7 @@ import _has from './internal/_has.js'; * @sig {String: *} -> [[String,*]] * @param {Object} obj The object to extract from * @return {Array} An array of key, value arrays from the object's own properties. - * @see R.fromPairs + * @see R.fromPairs, R.keys, R.values * @example * * R.toPairs({a: 1, b: 2, c: 3}); //=> [['a', 1], ['b', 2], ['c', 3]] diff --git a/source/values.js b/source/values.js index 22d613d261..1b3644c1cb 100644 --- a/source/values.js +++ b/source/values.js @@ -14,7 +14,7 @@ import keys from './keys.js'; * @sig {k: v} -> [v] * @param {Object} obj The object to extract values from * @return {Array} An array of the values of the object's own properties. - * @see R.valuesIn, R.keys + * @see R.valuesIn, R.keys, R.toPairs * @example * * R.values({a: 1, b: 2, c: 3}); //=> [1, 2, 3] From b17c8e2f200d1b006033028db73771b3e09ac1b3 Mon Sep 17 00:00:00 2001 From: bunglegrind Date: Wed, 25 Aug 2021 20:23:52 +0200 Subject: [PATCH 076/111] Update README.md (#3174) * Update README.md Closes 3173 * Update README.md --- README.md | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/README.md b/README.md index 7ba8eda9bc..60e290bec2 100644 --- a/README.md +++ b/README.md @@ -141,6 +141,10 @@ Ramda versions > 0.25 don't have a default export. So instead of `import R from 'ramda';`, one has to use `import * as R from 'ramda';` Or better yet, import only the required functions via `import { functionName } from 'ramda';` +**Note for ES6 module and browsers** +In order to access to the ES6 module in browsers, one has to provide the content of the __es__ directory (see below for the build instructions) and use `import * as R from './node_modules/ramda/es/index.js';` + + ### Build `npm run build` creates `es`, `src` directories and updates both __dist/ramda.js__ and __dist/ramda.min.js__ From fe4a05528f1b08cad45f61f0db34501c51cee650 Mon Sep 17 00:00:00 2001 From: Scott Sauyet Date: Thu, 26 Aug 2021 11:19:33 -0400 Subject: [PATCH 077/111] Create SECURITY.md --- SECURITY.md | 12 ++++++++++++ 1 file changed, 12 insertions(+) create mode 100644 SECURITY.md diff --git a/SECURITY.md b/SECURITY.md new file mode 100644 index 0000000000..88c08e6237 --- /dev/null +++ b/SECURITY.md @@ -0,0 +1,12 @@ +# Security Policy + +## Supported Versions + +| Version | Supported | +| ------- | ------------------ | +| 0.27.* | :white_check_mark: | +| < 0.27 | :x: | + +## Reporting a Vulnerability + +Feel free to email Scott Sauyet with any security issues From d0e72a81dc077440eac176c918746d40e2199321 Mon Sep 17 00:00:00 2001 From: Kara Jovian Date: Thu, 16 Sep 2021 21:33:15 +0300 Subject: [PATCH 078/111] Move detailed spec to description section (#3170) * Move detailed spec to description section * Supplement description for `and` * Use detailed description for `or` --- source/and.js | 5 +++-- source/or.js | 7 ++++--- 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/source/and.js b/source/and.js index 46c162a8dc..ab7ca5afea 100644 --- a/source/and.js +++ b/source/and.js @@ -2,7 +2,8 @@ import _curry2 from './internal/_curry2.js'; /** - * Returns `true` if both arguments are `true`; `false` otherwise. + * Returns the first argument if it is falsy, otherwise the second argument. + * Acts as the boolean `and` statement if both inputs are `Boolean`s. * * @func * @memberOf R @@ -11,7 +12,7 @@ import _curry2 from './internal/_curry2.js'; * @sig a -> b -> a | b * @param {Any} a * @param {Any} b - * @return {Any} the first argument if it is falsy, otherwise the second argument. + * @return {Any} * @see R.both, R.or * @example * diff --git a/source/or.js b/source/or.js index 8b1519fc8e..6d609a798b 100644 --- a/source/or.js +++ b/source/or.js @@ -1,8 +1,9 @@ import _curry2 from './internal/_curry2.js'; + /** - * Returns `true` if one or both of its arguments are `true`. Returns `false` - * if both arguments are `false`. + * Returns the first argument if it is truthy, otherwise the second argument. + * Acts as the boolean `or` statement if both inputs are `Boolean`s. * * @func * @memberOf R @@ -11,7 +12,7 @@ import _curry2 from './internal/_curry2.js'; * @sig a -> b -> a | b * @param {Any} a * @param {Any} b - * @return {Any} the first argument if truthy, otherwise the second argument. + * @return {Any} * @see R.either, R.and * @example * From a1a90ddd34c66d8738598beccbb0d50c3ed9ad99 Mon Sep 17 00:00:00 2001 From: Tristan Matthews Date: Thu, 30 Sep 2021 11:07:56 -0400 Subject: [PATCH 079/111] Fix typos detected by codespell (#3188) * equals: fix spelling * test: fix spelling * test: collectBy: fix spelling --- source/internal/_equals.js | 2 +- test/collectBy.js | 2 +- test/index.js | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/source/internal/_equals.js b/source/internal/_equals.js index f5defd7c71..5c29f75085 100644 --- a/source/internal/_equals.js +++ b/source/internal/_equals.js @@ -12,7 +12,7 @@ import type from '../type.js'; * - iterators lengths are the same * - iterators values are unique * - * false-positive result will be returned for comparision of, e.g. + * false-positive result will be returned for comparison of, e.g. * - [1,2,3] and [1,2,3,4] * - [1,1,1] and [1,2,3] * */ diff --git a/test/collectBy.js b/test/collectBy.js index 95282a0778..84ecba1bdf 100644 --- a/test/collectBy.js +++ b/test/collectBy.js @@ -12,7 +12,7 @@ describe('collectBy', function() { })); }); - it('groups items but neiter adds new ones nor removes any', function() { + it('groups items but neither adds new ones nor removes any', function() { fc.assert(fc.property(fc.array(fc.nat()), function(xs) { var check = compose(isEmpty, difference(xs), unnest); var ys = collectBy(identity)(xs); diff --git a/test/index.js b/test/index.js index 4fd4387cfa..7b1071e57b 100644 --- a/test/index.js +++ b/test/index.js @@ -24,7 +24,7 @@ function sourceMethods(dir) { * * 1st case is detected in first assertion, and detailed in second one * - * 2st case doesnt need detection, because NodeJS will throw an error + * 2nd case does not need detection, because NodeJS will throw an error * if you would attempt to require non existing file */ describe('API surface', function() { From 37af6ae2ca8b94656996dd27fb0a1f208d69134e Mon Sep 17 00:00:00 2001 From: ready-research <72916209+ready-research@users.noreply.github.com> Date: Fri, 8 Oct 2021 01:25:54 +0530 Subject: [PATCH 080/111] Security fix for ReDoS (#3177) * Security fix for ReDoS Security fix for ReDoS vulnerability. * Update trim.js * Update trim.js * Update trim.js --- source/trim.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/trim.js b/source/trim.js index 7c5ba8cf14..5cf5278ee1 100644 --- a/source/trim.js +++ b/source/trim.js @@ -1,7 +1,7 @@ import _curry1 from './internal/_curry1.js'; -var ws = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003' + +var ws = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u2000\u2001\u2002\u2003' + '\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028' + '\u2029\uFEFF'; var zeroWidth = '\u200b'; @@ -21,7 +21,7 @@ var hasProtoTrim = (typeof String.prototype.trim === 'function'); * R.trim(' xyz '); //=> 'xyz' * R.map(R.trim, R.split(',', 'x, y, z')); //=> ['x', 'y', 'z'] */ -var trim = !hasProtoTrim || (ws.trim() || !zeroWidth.trim()) ? +var trim = !hasProtoTrim || ws.trim() || !zeroWidth.trim() ? _curry1(function trim(str) { var beginRx = new RegExp('^[' + ws + '][' + ws + ']*'); var endRx = new RegExp('[' + ws + '][' + ws + ']*$'); From 9c5e2178e7467a05f9962956dcd390933da6fc50 Mon Sep 17 00:00:00 2001 From: Mohit Malik Date: Wed, 27 Oct 2021 15:21:45 +0530 Subject: [PATCH 081/111] fixed typo in test --- test/endsWith.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/endsWith.js b/test/endsWith.js index de7022a5c2..1198129874 100644 --- a/test/endsWith.js +++ b/test/endsWith.js @@ -1,7 +1,7 @@ var R = require('../source'); var eq = require('./shared/eq'); -describe('startsWith', function() { +describe('endsWith', function() { it('should return true when a string ends with the provided value', function() { eq(R.endsWith('c', 'abc'), true); }); From a02e6ae55b388bf158213e2154af06630534e792 Mon Sep 17 00:00:00 2001 From: Behram Kapadia Date: Fri, 12 Nov 2021 11:45:14 -0500 Subject: [PATCH 082/111] Bugfix is 3196 (#3198) * Object.create(null) should be considered an object * removing parens in for val in docs * fixing docs Co-authored-by: Behram Kapadia --- source/is.js | 10 +++++++--- test/is.js | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/source/is.js b/source/is.js index be8106c4a6..0679c05fcb 100644 --- a/source/is.js +++ b/source/is.js @@ -2,8 +2,9 @@ import _curry2 from './internal/_curry2.js'; /** - * See if an object (`val`) is an instance of the supplied constructor. This - * function will check up the inheritance chain, if any. + * See if an object (i.e. `val`) is an instance of the supplied constructor. This + * function will check up the inheritance chain, if any. + * If `val` was created using `Object.create`, `R.is(Object, val) === true`. * * @func * @memberOf R @@ -25,6 +26,9 @@ import _curry2 from './internal/_curry2.js'; * R.is(Number, {}); //=> false */ var is = _curry2(function is(Ctor, val) { - return val != null && val.constructor === Ctor || val instanceof Ctor; + return val instanceof Ctor || + val != null && ( + val.constructor === Ctor || + (Ctor.name === 'Object' && typeof val === 'object')); }); export default is; diff --git a/test/is.js b/test/is.js index feda0d24ba..1d307f3ead 100644 --- a/test/is.js +++ b/test/is.js @@ -42,6 +42,7 @@ describe('is', function() { eq(isObject(new Number(0)), true); eq(isObject(/(?:)/), true); eq(isObject(new String('')), true); + eq(isObject(Object.create(null)), true); eq(isObject(null), false); eq(isObject(undefined), false); From ef6451f0ce8527c647d53b01990d4b854515e846 Mon Sep 17 00:00:00 2001 From: wangzengdi Date: Wed, 24 Nov 2021 10:27:07 +0800 Subject: [PATCH 083/111] feat: There's no need to restrict whenTrue and whenFalse's return type (#3199) --- source/unless.js | 2 +- source/when.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source/unless.js b/source/unless.js index fb0485f410..2beb9a32e0 100644 --- a/source/unless.js +++ b/source/unless.js @@ -11,7 +11,7 @@ import _curry3 from './internal/_curry3.js'; * @memberOf R * @since v0.18.0 * @category Logic - * @sig (a -> Boolean) -> (a -> a) -> a -> a + * @sig (a -> Boolean) -> (a -> b) -> a -> a | b * @param {Function} pred A predicate function * @param {Function} whenFalseFn A function to invoke when the `pred` evaluates * to a falsy value. diff --git a/source/when.js b/source/when.js index 7bb50ae082..6cfa515761 100644 --- a/source/when.js +++ b/source/when.js @@ -11,7 +11,7 @@ import _curry3 from './internal/_curry3.js'; * @memberOf R * @since v0.18.0 * @category Logic - * @sig (a -> Boolean) -> (a -> a) -> a -> a + * @sig (a -> Boolean) -> (a -> b) -> a -> a | b * @param {Function} pred A predicate function * @param {Function} whenTrueFn A function to invoke when the `condition` * evaluates to a truthy value. From d5e178deb0cc6380287b3c42b070d2e6803a3b0b Mon Sep 17 00:00:00 2001 From: Lei Tan Date: Wed, 1 Dec 2021 09:55:10 +0800 Subject: [PATCH 084/111] feat: add transducer support for uniqBy/uniqWith (#3201) Co-authored-by: louie --- source/internal/_xuniqBy.js | 18 ++++++++++++++++++ source/internal/_xuniqWith.js | 24 ++++++++++++++++++++++++ source/uniqBy.js | 8 ++++++-- source/uniqWith.js | 10 +++++++--- test/transduce.js | 6 ++++++ 5 files changed, 61 insertions(+), 5 deletions(-) create mode 100644 source/internal/_xuniqBy.js create mode 100644 source/internal/_xuniqWith.js diff --git a/source/internal/_xuniqBy.js b/source/internal/_xuniqBy.js new file mode 100644 index 0000000000..cf4ff38a83 --- /dev/null +++ b/source/internal/_xuniqBy.js @@ -0,0 +1,18 @@ +import _curry2 from './_curry2.js'; +import _Set from './_Set.js'; +import _xfBase from './_xfBase.js'; + + +function XUniqBy(f, xf) { + this.xf = xf; + this.f = f; + this.set = new _Set(); +} +XUniqBy.prototype['@@transducer/init'] = _xfBase.init; +XUniqBy.prototype['@@transducer/result'] = _xfBase.result; +XUniqBy.prototype['@@transducer/step'] = function(result, input) { + return this.set.add(this.f(input)) ? this.xf['@@transducer/step'](result, input) : result; +}; + +var _xuniqBy = _curry2(function _xuniqBy(f, xf) { return new XUniqBy(f, xf); }); +export default _xuniqBy; diff --git a/source/internal/_xuniqWith.js b/source/internal/_xuniqWith.js new file mode 100644 index 0000000000..940c6ba253 --- /dev/null +++ b/source/internal/_xuniqWith.js @@ -0,0 +1,24 @@ +import _Set from './_Set.js'; +import _curry2 from './_curry2.js'; +import _includesWith from './_includesWith.js'; +import _xfBase from './_xfBase.js'; + + +function XUniqWith(pred, xf) { + this.xf = xf; + this.pred = pred; + this.items = []; +} +XUniqWith.prototype['@@transducer/init'] = _xfBase.init; +XUniqWith.prototype['@@transducer/result'] = _xfBase.result; +XUniqWith.prototype['@@transducer/step'] = function(result, input) { + if (_includesWith(this.pred, input, this.items)) { + return result; + } else { + this.items.push(input); + return this.xf['@@transducer/step'](result, input); + } +}; + +var _xuniqWith = _curry2(function _xuniqWith(pred, xf) { return new XUniqWith(pred, xf); }); +export default _xuniqWith; diff --git a/source/uniqBy.js b/source/uniqBy.js index 3285c0aae5..cdf7e96434 100644 --- a/source/uniqBy.js +++ b/source/uniqBy.js @@ -1,5 +1,7 @@ import _Set from './internal/_Set.js'; import _curry2 from './internal/_curry2.js'; +import _dispatchable from './internal/_dispatchable.js'; +import _xuniqBy from './internal/_xuniqBy.js'; /** @@ -8,6 +10,8 @@ import _curry2 from './internal/_curry2.js'; * each list element. Prefers the first item if the supplied function produces * the same value on two items. [`R.equals`](#equals) is used for comparison. * + * Acts as a transducer if a transformer is given in list position. + * * @func * @memberOf R * @since v0.16.0 @@ -20,7 +24,7 @@ import _curry2 from './internal/_curry2.js'; * * R.uniqBy(Math.abs, [-1, -5, 2, 10, 1, 2]); //=> [-1, -5, 2, 10] */ -var uniqBy = _curry2(function uniqBy(fn, list) { +var uniqBy = _curry2(_dispatchable([], _xuniqBy, function(fn, list) { var set = new _Set(); var result = []; var idx = 0; @@ -35,5 +39,5 @@ var uniqBy = _curry2(function uniqBy(fn, list) { idx += 1; } return result; -}); +})); export default uniqBy; diff --git a/source/uniqWith.js b/source/uniqWith.js index 2e3632d070..a5fd03af49 100644 --- a/source/uniqWith.js +++ b/source/uniqWith.js @@ -1,5 +1,7 @@ -import _includesWith from './internal/_includesWith.js'; import _curry2 from './internal/_curry2.js'; +import _dispatchable from './internal/_dispatchable.js'; +import _includesWith from './internal/_includesWith.js'; +import _xuniqWith from './internal/_xuniqWith.js'; /** @@ -8,6 +10,8 @@ import _curry2 from './internal/_curry2.js'; * two list elements. Prefers the first item if two items compare equal based * on the predicate. * + * Acts as a transducer if a transformer is given in list position. + * * @func * @memberOf R * @since v0.2.0 @@ -24,7 +28,7 @@ import _curry2 from './internal/_curry2.js'; * R.uniqWith(strEq)([1, '1', 1]); //=> [1] * R.uniqWith(strEq)(['1', 1, 1]); //=> ['1'] */ -var uniqWith = _curry2(function uniqWith(pred, list) { +var uniqWith = _curry2(_dispatchable([], _xuniqWith, function(pred, list) { var idx = 0; var len = list.length; var result = []; @@ -37,5 +41,5 @@ var uniqWith = _curry2(function uniqWith(pred, list) { idx += 1; } return result; -}); +})); export default uniqWith; diff --git a/test/transduce.js b/test/transduce.js index 795b7f2153..9f7df41769 100644 --- a/test/transduce.js +++ b/test/transduce.js @@ -5,7 +5,9 @@ describe('transduce', function() { var add = R.add; var mult = function(a, b) {return a * b;}; var isOdd = function(b) { return b % 2 !== 0; }; + var isEven = function(b) { return b % 2 === 0; }; var square = function(a) {return a * a;}; + var negate = function(a) {return -1 * a;}; var addxf = { '@@transducer/step': function(acc, x) { return acc + x; }, '@@transducer/init': function() { return 0; }, @@ -40,6 +42,10 @@ describe('transduce', function() { eq(R.transduce(R.filter(isOdd), R.flip(R.append), [], [1, 2, 3, 4]), [1, 3]); eq(R.transduce(R.compose(R.map(add(1)), R.take(2)), R.flip(R.append), [], [1, 2, 3, 4]), [2, 3]); eq(R.transduce(R.compose(R.filter(isOdd), R.take(1)), R.flip(R.append), [], [1, 2, 3, 4]), [1]); + eq(R.transduce(R.compose(R.uniq, R.map(square), R.take(3)), R.flip(R.append), [], [1, 1, 2, 2, 3, 3, 4, 4]), [1, 4, 9]); + eq(R.transduce(R.compose(R.filter(isEven), R.uniq), R.flip(R.append), [], [1, 1, 2, 2, 3, 3, 4, 4]), [2, 4]); + eq(R.transduce(R.compose(R.map(negate), R.uniqBy(Math.abs), R.map(square)), R.flip(R.append), [], [-1, -5, 2, 10, 1, 2]), [1, 25, 4, 100]); + eq(R.transduce(R.compose(R.uniqWith(R.eqBy(String)), R.map(square), R.take(3)), R.flip(R.append), [], [1, '1', '2', 2, 3, '3', '4', 4]), [1, 4, 9]); }); it('transduces into strings', function() { From 1843493ca24a87642924f49bad5d4577d2b26666 Mon Sep 17 00:00:00 2001 From: Julien Gonzalez Date: Fri, 17 Dec 2021 21:44:12 +0000 Subject: [PATCH 085/111] Fix for failing builds (#3206) * build: fix linting errors * test: remove u180E from test string as it was no longer considered as whitespace * build: run ci pipeline on pull request too --- .github/workflows/build.yml | 2 +- source/internal/_xuniqWith.js | 1 - source/is.js | 6 +++--- test/trim.js | 2 +- 4 files changed, 5 insertions(+), 6 deletions(-) diff --git a/.github/workflows/build.yml b/.github/workflows/build.yml index 793ef92009..8438fec13b 100644 --- a/.github/workflows/build.yml +++ b/.github/workflows/build.yml @@ -1,6 +1,6 @@ name: Build -on: [push] +on: [push, pull_request] jobs: coverage: diff --git a/source/internal/_xuniqWith.js b/source/internal/_xuniqWith.js index 940c6ba253..7e7b16160e 100644 --- a/source/internal/_xuniqWith.js +++ b/source/internal/_xuniqWith.js @@ -1,4 +1,3 @@ -import _Set from './_Set.js'; import _curry2 from './_curry2.js'; import _includesWith from './_includesWith.js'; import _xfBase from './_xfBase.js'; diff --git a/source/is.js b/source/is.js index 0679c05fcb..5b37ef8693 100644 --- a/source/is.js +++ b/source/is.js @@ -3,7 +3,7 @@ import _curry2 from './internal/_curry2.js'; /** * See if an object (i.e. `val`) is an instance of the supplied constructor. This - * function will check up the inheritance chain, if any. + * function will check up the inheritance chain, if any. * If `val` was created using `Object.create`, `R.is(Object, val) === true`. * * @func @@ -26,9 +26,9 @@ import _curry2 from './internal/_curry2.js'; * R.is(Number, {}); //=> false */ var is = _curry2(function is(Ctor, val) { - return val instanceof Ctor || + return val instanceof Ctor || val != null && ( - val.constructor === Ctor || + val.constructor === Ctor || (Ctor.name === 'Object' && typeof val === 'object')); }); export default is; diff --git a/test/trim.js b/test/trim.js index 850b5c2b39..9eb4dd0978 100644 --- a/test/trim.js +++ b/test/trim.js @@ -3,7 +3,7 @@ var eq = require('./shared/eq'); describe('trim', function() { - var test = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFFHello, World!\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF'; + var test = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFFHello, World!\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF'; it('trims a string', function() { eq(R.trim(' xyz '), 'xyz'); From b8307a7d29d78af18234b99a1bd7aae5087d082a Mon Sep 17 00:00:00 2001 From: wangzengdi Date: Sun, 19 Dec 2021 06:42:23 +0800 Subject: [PATCH 086/111] chore: lift can wrap 1-arity function (#3205) * chore: lift can wrap 1-arity function * fix: try to fix github ci/cd workflows --- source/lift.js | 2 +- test/lift.js | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/source/lift.js b/source/lift.js index 5e8cc931e5..d4f07909a3 100644 --- a/source/lift.js +++ b/source/lift.js @@ -3,7 +3,7 @@ import liftN from './liftN.js'; /** - * "lifts" a function of arity > 1 so that it may "map over" a list, Function or other + * "lifts" a function of arity >= 1 so that it may "map over" a list, Function or other * object that satisfies the [FantasyLand Apply spec](https://github.com/fantasyland/fantasy-land#apply). * * @func diff --git a/test/lift.js b/test/lift.js index f5431cbb76..9d273c399f 100644 --- a/test/lift.js +++ b/test/lift.js @@ -3,7 +3,7 @@ var R = require('../source'); var eq = require('./shared/eq'); var Maybe = require('./shared/Maybe'); - +var not = function(x) { return !x; }; var add3 = R.curry(function add3(a, b, c) { return a + b + c; }); @@ -13,6 +13,7 @@ var add4 = R.curry(function add4(a, b, c, d) { var add5 = R.curry(function add5(a, b, c, d, e) { return a + b + c + d + e; }); +var complement = R.lift(not); var madd3 = R.lift(add3); var madd4 = R.lift(add4); var madd5 = R.lift(add5); @@ -31,6 +32,7 @@ describe('lift', function() { }); it('can lift functions of any arity', function() { + eq(complement(R.isNil)(null), false); eq(madd3([1, 10], [2], [3]), [6, 15]); eq(madd4([1, 10], [2], [3], [40]), [46, 55]); eq(madd5([1, 10], [2], [3], [40], [500, 1000]), [546, 1046, 555, 1055]); From 8ae355e8ad80b5a24c5eec149a1a3c583d494afb Mon Sep 17 00:00:00 2001 From: David Chambers Date: Thu, 6 Jan 2022 12:10:31 +0100 Subject: [PATCH 087/111] update test string for trim --- test/trim.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/trim.js b/test/trim.js index 850b5c2b39..9eb4dd0978 100644 --- a/test/trim.js +++ b/test/trim.js @@ -3,7 +3,7 @@ var eq = require('./shared/eq'); describe('trim', function() { - var test = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFFHello, World!\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF'; + var test = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFFHello, World!\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u2000\u2001\u2002\u2003\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028\u2029\uFEFF'; it('trims a string', function() { eq(R.trim(' xyz '), 'xyz'); From 94d057032c9b3ecf26d9842fbb12c981bda29f4b Mon Sep 17 00:00:00 2001 From: ready-research <72916209+ready-research@users.noreply.github.com> Date: Fri, 8 Oct 2021 01:25:54 +0530 Subject: [PATCH 088/111] Security fix for ReDoS (#3177) * Security fix for ReDoS Security fix for ReDoS vulnerability. * Update trim.js * Update trim.js * Update trim.js --- source/trim.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/trim.js b/source/trim.js index 73bc528402..52c90a5953 100644 --- a/source/trim.js +++ b/source/trim.js @@ -1,7 +1,7 @@ import _curry1 from './internal/_curry1'; -var ws = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003' + +var ws = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u2000\u2001\u2002\u2003' + '\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028' + '\u2029\uFEFF'; var zeroWidth = '\u200b'; @@ -21,7 +21,7 @@ var hasProtoTrim = (typeof String.prototype.trim === 'function'); * R.trim(' xyz '); //=> 'xyz' * R.map(R.trim, R.split(',', 'x, y, z')); //=> ['x', 'y', 'z'] */ -var trim = !hasProtoTrim || (ws.trim() || !zeroWidth.trim()) ? +var trim = !hasProtoTrim || ws.trim() || !zeroWidth.trim() ? _curry1(function trim(str) { var beginRx = new RegExp('^[' + ws + '][' + ws + ']*'); var endRx = new RegExp('[' + ws + '][' + ws + ']*$'); From 1a5d40bb143738d7366aa26e5e2957e42ecd7ce6 Mon Sep 17 00:00:00 2001 From: David Chambers Date: Tue, 11 Jan 2022 12:46:43 +0100 Subject: [PATCH 089/111] Version 0.27.2 --- dist/ramda.js | 8 ++++---- dist/ramda.min.js | 2 +- package.json | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/dist/ramda.js b/dist/ramda.js index d7d6065466..f7526c9672 100644 --- a/dist/ramda.js +++ b/dist/ramda.js @@ -1,6 +1,6 @@ -// Ramda v0.27.1 +// Ramda v0.27.2 // https://github.com/ramda/ramda -// (c) 2013-2020 Scott Sauyet, Michael Hurley, and David Chambers +// (c) 2013-2022 Scott Sauyet, Michael Hurley, and David Chambers // Ramda may be freely distributed under the MIT license. (function (global, factory) { @@ -8729,7 +8729,7 @@ sequence(of, map(f, traversable)); }); - var ws = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u180E\u2000\u2001\u2002\u2003' + + var ws = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u2000\u2001\u2002\u2003' + '\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028' + '\u2029\uFEFF'; var zeroWidth = '\u200b'; @@ -8749,7 +8749,7 @@ * R.trim(' xyz '); //=> 'xyz' * R.map(R.trim, R.split(',', 'x, y, z')); //=> ['x', 'y', 'z'] */ - var trim = !hasProtoTrim || (ws.trim() || !zeroWidth.trim()) ? + var trim = !hasProtoTrim || ws.trim() || !zeroWidth.trim() ? _curry1(function trim(str) { var beginRx = new RegExp('^[' + ws + '][' + ws + ']*'); var endRx = new RegExp('[' + ws + '][' + ws + ']*$'); diff --git a/dist/ramda.min.js b/dist/ramda.min.js index ee0823ca11..b75c5e898b 100644 --- a/dist/ramda.min.js +++ b/dist/ramda.min.js @@ -1 +1 @@ -!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((t=t||self).R={})}(this,function(t){"use strict";function a(t){return null!=t&&"object"==typeof t&&!0===t["@@functional/placeholder"]}function o(r){return function t(n){return 0===arguments.length||a(n)?t:r.apply(this,arguments)}}function n(e){return function t(n,r){switch(arguments.length){case 0:return t;case 1:return a(n)?t:o(function(t){return e(n,t)});default:return a(n)&&a(r)?t:a(n)?o(function(t){return e(t,r)}):a(r)?o(function(t){return e(n,t)}):e(n,r)}}}var r=n(function(t,n){return+t+ +n});function i(t,n){var r,e=(t=t||[]).length,u=(n=n||[]).length,i=[];for(r=0;r":ln(t,n)}function t(n,t){return x(function(t){return nn(t)+": "+u(n[t])},t.slice().sort())}switch(Object.prototype.toString.call(r)){case"[object Arguments]":return"(function() { return arguments; }("+x(u,r).join(", ")+"))";case"[object Array]":return"["+x(u,r).concat(t(r,sn(function(t){return/^\d+$/.test(t)},U(r)))).join(", ")+"]";case"[object Boolean]":return"object"==typeof r?"new Boolean("+u(r.valueOf())+")":""+r;case"[object Date]":return"new Date("+(isNaN(r.valueOf())?u(NaN):nn(en(r)))+")";case"[object Null]":return"null";case"[object Number]":return"object"==typeof r?"new Number("+u(r.valueOf())+")":1/r==-1/0?"-0":r.toString(10);case"[object String]":return"object"==typeof r?"new String("+u(r.valueOf())+")":nn(r);case"[object Undefined]":return"undefined";default:if("function"==typeof r.toString){var n=""+r;if("[object Object]"!=n)return n}return"{"+t(r,U(r)).join(", ")+"}"}}var pn=o(function(t){return ln(t,[])}),hn=n(function(t,n){if(p(t)){if(p(n))return t.concat(n);throw new TypeError(pn(n)+" is not an array")}if(w(t)){if(w(n))return t+n;throw new TypeError(pn(n)+" is not a string")}if(null!=t&&dt(t["fantasy-land/concat"]))return t["fantasy-land/concat"](n);if(null!=t&&dt(t.concat))return t.concat(n);throw new TypeError(pn(t)+' does not have a method named "concat" or "fantasy-land/concat"')}),yn=o(function(n){return f($(b,0,D(function(t){return t[0].length},n)),function(){for(var t=0;tt(n)?r:n}),pe=$(r,0),he=o(function(t){return pe(t)/t.length}),ye=o(function(t){var n=t.length;if(0===n)return NaN;var r=2-n%2,e=(n-r)/2;return he(Array.prototype.slice.call(t,0).sort(function(t,n){return t":ln(t,n)}function t(n,t){return x(function(t){return nn(t)+": "+u(n[t])},t.slice().sort())}switch(Object.prototype.toString.call(r)){case"[object Arguments]":return"(function() { return arguments; }("+x(u,r).join(", ")+"))";case"[object Array]":return"["+x(u,r).concat(t(r,sn(function(t){return/^\d+$/.test(t)},U(r)))).join(", ")+"]";case"[object Boolean]":return"object"==typeof r?"new Boolean("+u(r.valueOf())+")":""+r;case"[object Date]":return"new Date("+(isNaN(r.valueOf())?u(NaN):nn(en(r)))+")";case"[object Null]":return"null";case"[object Number]":return"object"==typeof r?"new Number("+u(r.valueOf())+")":1/r==-1/0?"-0":r.toString(10);case"[object String]":return"object"==typeof r?"new String("+u(r.valueOf())+")":nn(r);case"[object Undefined]":return"undefined";default:if("function"==typeof r.toString){var n=""+r;if("[object Object]"!=n)return n}return"{"+t(r,U(r)).join(", ")+"}"}}var pn=o(function(t){return ln(t,[])}),hn=n(function(t,n){if(p(t)){if(p(n))return t.concat(n);throw new TypeError(pn(n)+" is not an array")}if(w(t)){if(w(n))return t+n;throw new TypeError(pn(n)+" is not a string")}if(null!=t&&dt(t["fantasy-land/concat"]))return t["fantasy-land/concat"](n);if(null!=t&&dt(t.concat))return t.concat(n);throw new TypeError(pn(t)+' does not have a method named "concat" or "fantasy-land/concat"')}),yn=o(function(n){return f($(b,0,D(function(t){return t[0].length},n)),function(){for(var t=0;tt(n)?r:n}),pe=$(r,0),he=o(function(t){return pe(t)/t.length}),ye=o(function(t){var n=t.length;if(0===n)return NaN;var r=2-n%2,e=(n-r)/2;return he(Array.prototype.slice.call(t,0).sort(function(t,n){return t Date: Wed, 12 Jan 2022 01:53:45 +0000 Subject: [PATCH 090/111] chore: remove dependencies badge (#3207) As of time of writing the service https://david-dm.org/ seems to be down and/or unreliable. As Ramda is a no-dependency library I'm not seeing much value in this badge. --- README.md | 1 - 1 file changed, 1 deletion(-) diff --git a/README.md b/README.md index 60e290bec2..561ae63b35 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,6 @@ A practical functional library for JavaScript programmers. [![npm module](https://badge.fury.io/js/ramda.svg)](https://www.npmjs.org/package/ramda) [![deno land](http://img.shields.io/badge/available%20on-deno.land/x-lightgrey.svg?logo=deno&labelColor=black)](https://deno.land/x/ramda@v0.27.2) [![nest badge](https://nest.land/badge.svg)](https://nest.land/package/ramda) -[![dependencies](https://david-dm.org/ramda/ramda.svg)](https://david-dm.org/ramda/ramda) [![Gitter](https://badges.gitter.im/Join_Chat.svg)](https://gitter.im/ramda/ramda?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge) From 95d897e60b359cadd22c8d19c13bd75d100eb40a Mon Sep 17 00:00:00 2001 From: Julien Gonzalez Date: Wed, 12 Jan 2022 02:14:39 +0000 Subject: [PATCH 091/111] chore: publicise funding options. close #3016 (#3208) --- .github/FUNDING.yml | 1 + README.md | 6 ++++++ package.json | 4 ++++ 3 files changed, 11 insertions(+) create mode 100644 .github/FUNDING.yml diff --git a/.github/FUNDING.yml b/.github/FUNDING.yml new file mode 100644 index 0000000000..1ed22cbfe8 --- /dev/null +++ b/.github/FUNDING.yml @@ -0,0 +1 @@ +open_collective: ramda diff --git a/README.md b/README.md index 561ae63b35..543e229bec 100644 --- a/README.md +++ b/README.md @@ -260,6 +260,12 @@ Translations +Funding +----------------- + +If you wish to donate to Ramda please see our [Open Collective](https://opencollective.com/ramda) page. Thank you! + + Acknowledgements ----------------- diff --git a/package.json b/package.json index 84a23c5088..40df68a032 100644 --- a/package.json +++ b/package.json @@ -45,6 +45,10 @@ "type": "git", "url": "git://github.com/ramda/ramda.git" }, + "funding": { + "type": "opencollective", + "url": "https://opencollective.com/ramda" + }, "main": "./src/index.js", "exports": { ".": { From c207cf1be650e8373bef85a77198ba23647c9165 Mon Sep 17 00:00:00 2001 From: Scott Sauyet Date: Sat, 15 Jan 2022 22:01:48 -0500 Subject: [PATCH 092/111] Version 0.28.0 --- dist/ramda.js | 3476 ++++++++++++++++++++++++++------------- dist/ramda.min.js | 2 +- package.json | 2 +- source/collectBy.js | 1 + source/count.js | 1 + source/modify.js | 1 + source/modifyPath.js | 1 + source/on.js | 1 + source/partialObject.js | 1 + source/promap.js | 1 + source/unwind.js | 1 + source/whereAny.js | 1 + 12 files changed, 2341 insertions(+), 1148 deletions(-) diff --git a/dist/ramda.js b/dist/ramda.js index f43abc26c8..44e4169577 100644 --- a/dist/ramda.js +++ b/dist/ramda.js @@ -1,4 +1,4 @@ -// Ramda v0.27.2 +// Ramda v0.28.0 // https://github.com/ramda/ramda // (c) 2013-2022 Scott Sauyet, Michael Hurley, and David Chambers // Ramda may be freely distributed under the MIT license. @@ -7,7 +7,7 @@ typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports) : typeof define === 'function' && define.amd ? define(['exports'], factory) : (global = global || self, factory(global.R = {})); -}(this, function (exports) { 'use strict'; +}(this, (function (exports) { 'use strict'; /** * A function that always returns `false`. Any passed in parameters are ignored. @@ -24,7 +24,9 @@ * * R.F(); //=> false */ - var F = function() {return false;}; + var F = function F() { + return false; + }; /** * A function that always returns `true`. Any passed in parameters are ignored. @@ -41,7 +43,9 @@ * * R.T(); //=> true */ - var T = function() {return true;}; + var T = function T() { + return true; + }; /** * A special placeholder value used to specify "gaps" within curried functions, @@ -70,12 +74,26 @@ * const greet = R.replace('{name}', R.__, 'Hello, {name}!'); * greet('Alice'); //=> 'Hello, Alice!' */ - var __ = {'@@functional/placeholder': true}; + var __ = { + '@@functional/placeholder': true + }; + + function _typeof(obj) { + if (typeof Symbol === "function" && typeof Symbol.iterator === "symbol") { + _typeof = function (obj) { + return typeof obj; + }; + } else { + _typeof = function (obj) { + return obj && typeof Symbol === "function" && obj.constructor === Symbol && obj !== Symbol.prototype ? "symbol" : typeof obj; + }; + } + + return _typeof(obj); + } function _isPlaceholder(a) { - return a != null && - typeof a === 'object' && - a['@@functional/placeholder'] === true; + return a != null && _typeof(a) === 'object' && a['@@functional/placeholder'] === true; } /** @@ -86,6 +104,7 @@ * @param {Function} fn The function to curry. * @return {Function} The curried function. */ + function _curry1(fn) { return function f1(a) { if (arguments.length === 0 || _isPlaceholder(a)) { @@ -104,23 +123,24 @@ * @param {Function} fn The function to curry. * @return {Function} The curried function. */ + function _curry2(fn) { return function f2(a, b) { switch (arguments.length) { case 0: return f2; + case 1: - return _isPlaceholder(a) - ? f2 - : _curry1(function(_b) { return fn(a, _b); }); + return _isPlaceholder(a) ? f2 : _curry1(function (_b) { + return fn(a, _b); + }); + default: - return _isPlaceholder(a) && _isPlaceholder(b) - ? f2 - : _isPlaceholder(a) - ? _curry1(function(_a) { return fn(_a, b); }) - : _isPlaceholder(b) - ? _curry1(function(_b) { return fn(a, _b); }) - : fn(a, b); + return _isPlaceholder(a) && _isPlaceholder(b) ? f2 : _isPlaceholder(a) ? _curry1(function (_a) { + return fn(_a, b); + }) : _isPlaceholder(b) ? _curry1(function (_b) { + return fn(a, _b); + }) : fn(a, b); } }; } @@ -142,6 +162,7 @@ * R.add(2, 3); //=> 5 * R.add(7)(10); //=> 17 */ + var add = _curry2(function add(a, b) { return Number(a) + Number(b); }); @@ -164,35 +185,83 @@ var len1 = set1.length; var len2 = set2.length; var result = []; - idx = 0; + while (idx < len1) { result[result.length] = set1[idx]; idx += 1; } + idx = 0; + while (idx < len2) { result[result.length] = set2[idx]; idx += 1; } + return result; } function _arity(n, fn) { /* eslint-disable no-unused-vars */ switch (n) { - case 0: return function() { return fn.apply(this, arguments); }; - case 1: return function(a0) { return fn.apply(this, arguments); }; - case 2: return function(a0, a1) { return fn.apply(this, arguments); }; - case 3: return function(a0, a1, a2) { return fn.apply(this, arguments); }; - case 4: return function(a0, a1, a2, a3) { return fn.apply(this, arguments); }; - case 5: return function(a0, a1, a2, a3, a4) { return fn.apply(this, arguments); }; - case 6: return function(a0, a1, a2, a3, a4, a5) { return fn.apply(this, arguments); }; - case 7: return function(a0, a1, a2, a3, a4, a5, a6) { return fn.apply(this, arguments); }; - case 8: return function(a0, a1, a2, a3, a4, a5, a6, a7) { return fn.apply(this, arguments); }; - case 9: return function(a0, a1, a2, a3, a4, a5, a6, a7, a8) { return fn.apply(this, arguments); }; - case 10: return function(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9) { return fn.apply(this, arguments); }; - default: throw new Error('First argument to _arity must be a non-negative integer no greater than ten'); + case 0: + return function () { + return fn.apply(this, arguments); + }; + + case 1: + return function (a0) { + return fn.apply(this, arguments); + }; + + case 2: + return function (a0, a1) { + return fn.apply(this, arguments); + }; + + case 3: + return function (a0, a1, a2) { + return fn.apply(this, arguments); + }; + + case 4: + return function (a0, a1, a2, a3) { + return fn.apply(this, arguments); + }; + + case 5: + return function (a0, a1, a2, a3, a4) { + return fn.apply(this, arguments); + }; + + case 6: + return function (a0, a1, a2, a3, a4, a5) { + return fn.apply(this, arguments); + }; + + case 7: + return function (a0, a1, a2, a3, a4, a5, a6) { + return fn.apply(this, arguments); + }; + + case 8: + return function (a0, a1, a2, a3, a4, a5, a6, a7) { + return fn.apply(this, arguments); + }; + + case 9: + return function (a0, a1, a2, a3, a4, a5, a6, a7, a8) { + return fn.apply(this, arguments); + }; + + case 10: + return function (a0, a1, a2, a3, a4, a5, a6, a7, a8, a9) { + return fn.apply(this, arguments); + }; + + default: + throw new Error('First argument to _arity must be a non-negative integer no greater than ten'); } } @@ -206,31 +275,34 @@ * @param {Function} fn The function to curry. * @return {Function} The curried function. */ + function _curryN(length, received, fn) { - return function() { + return function () { var combined = []; var argsIdx = 0; var left = length; var combinedIdx = 0; + while (combinedIdx < received.length || argsIdx < arguments.length) { var result; - if (combinedIdx < received.length && - (!_isPlaceholder(received[combinedIdx]) || - argsIdx >= arguments.length)) { + + if (combinedIdx < received.length && (!_isPlaceholder(received[combinedIdx]) || argsIdx >= arguments.length)) { result = received[combinedIdx]; } else { result = arguments[argsIdx]; argsIdx += 1; } + combined[combinedIdx] = result; + if (!_isPlaceholder(result)) { left -= 1; } + combinedIdx += 1; } - return left <= 0 - ? fn.apply(this, combined) - : _arity(left, _curryN(length, combined, fn)); + + return left <= 0 ? fn.apply(this, combined) : _arity(left, _curryN(length, combined, fn)); }; } @@ -276,10 +348,12 @@ * const g = f(3); * g(4); //=> 10 */ + var curryN = _curry2(function curryN(length, fn) { if (length === 1) { return _curry1(fn); } + return _arity(length, _curryN(length, [], fn)); }); @@ -298,7 +372,7 @@ * @since v0.15.0 * @category Function * @category List - * @sig ((a ... -> b) ... -> [a] -> *) -> ((a ..., Int, [a] -> b) ... -> [a] -> *) + * @sig (((a ...) -> b) ... -> [a] -> *) -> (((a ..., Int, [a]) -> b) ... -> [a] -> *) * @param {Function} fn A list iteration function that does not pass index or list to its callback * @return {Function} An altered list iteration function that passes (item, index, list) to its callback * @example @@ -307,17 +381,20 @@ * mapIndexed((val, idx) => idx + '-' + val, ['f', 'o', 'o', 'b', 'a', 'r']); * //=> ['0-f', '1-o', '2-o', '3-b', '4-a', '5-r'] */ + var addIndex = _curry1(function addIndex(fn) { - return curryN(fn.length, function() { + return curryN(fn.length, function () { var idx = 0; var origFn = arguments[0]; var list = arguments[arguments.length - 1]; var args = Array.prototype.slice.call(arguments, 0); - args[0] = function() { + + args[0] = function () { var result = origFn.apply(this, _concat(arguments, [idx, list])); idx += 1; return result; }; + return fn.apply(this, args); }); }); @@ -330,39 +407,41 @@ * @param {Function} fn The function to curry. * @return {Function} The curried function. */ + function _curry3(fn) { return function f3(a, b, c) { switch (arguments.length) { case 0: return f3; + case 1: - return _isPlaceholder(a) - ? f3 - : _curry2(function(_b, _c) { return fn(a, _b, _c); }); + return _isPlaceholder(a) ? f3 : _curry2(function (_b, _c) { + return fn(a, _b, _c); + }); + case 2: - return _isPlaceholder(a) && _isPlaceholder(b) - ? f3 - : _isPlaceholder(a) - ? _curry2(function(_a, _c) { return fn(_a, b, _c); }) - : _isPlaceholder(b) - ? _curry2(function(_b, _c) { return fn(a, _b, _c); }) - : _curry1(function(_c) { return fn(a, b, _c); }); + return _isPlaceholder(a) && _isPlaceholder(b) ? f3 : _isPlaceholder(a) ? _curry2(function (_a, _c) { + return fn(_a, b, _c); + }) : _isPlaceholder(b) ? _curry2(function (_b, _c) { + return fn(a, _b, _c); + }) : _curry1(function (_c) { + return fn(a, b, _c); + }); + default: - return _isPlaceholder(a) && _isPlaceholder(b) && _isPlaceholder(c) - ? f3 - : _isPlaceholder(a) && _isPlaceholder(b) - ? _curry2(function(_a, _b) { return fn(_a, _b, c); }) - : _isPlaceholder(a) && _isPlaceholder(c) - ? _curry2(function(_a, _c) { return fn(_a, b, _c); }) - : _isPlaceholder(b) && _isPlaceholder(c) - ? _curry2(function(_b, _c) { return fn(a, _b, _c); }) - : _isPlaceholder(a) - ? _curry1(function(_a) { return fn(_a, b, c); }) - : _isPlaceholder(b) - ? _curry1(function(_b) { return fn(a, _b, c); }) - : _isPlaceholder(c) - ? _curry1(function(_c) { return fn(a, b, _c); }) - : fn(a, b, c); + return _isPlaceholder(a) && _isPlaceholder(b) && _isPlaceholder(c) ? f3 : _isPlaceholder(a) && _isPlaceholder(b) ? _curry2(function (_a, _b) { + return fn(_a, _b, c); + }) : _isPlaceholder(a) && _isPlaceholder(c) ? _curry2(function (_a, _c) { + return fn(_a, b, _c); + }) : _isPlaceholder(b) && _isPlaceholder(c) ? _curry2(function (_b, _c) { + return fn(a, _b, _c); + }) : _isPlaceholder(a) ? _curry1(function (_a) { + return fn(_a, b, c); + }) : _isPlaceholder(b) ? _curry1(function (_b) { + return fn(a, _b, c); + }) : _isPlaceholder(c) ? _curry1(function (_c) { + return fn(a, b, _c); + }) : fn(a, b, c); } }; } @@ -392,13 +471,18 @@ * @symb R.adjust(-1, f, [a, b]) = [a, f(b)] * @symb R.adjust(0, f, [a, b]) = [f(a), b] */ + var adjust = _curry3(function adjust(idx, fn, list) { - if (idx >= list.length || idx < -list.length) { + var len = list.length; + + if (idx >= len || idx < -len) { return list; } - var start = idx < 0 ? list.length : 0; - var _idx = start + idx; + + var _idx = (len + idx) % len; + var _list = _concat(list); + _list[_idx] = fn(list[_idx]); return _list; }); @@ -416,9 +500,7 @@ * _isArray({}); //=> false */ var _isArray = Array.isArray || function _isArray(val) { - return (val != null && - val.length >= 0 && - Object.prototype.toString.call(val) === '[object Array]'); + return val != null && val.length >= 0 && Object.prototype.toString.call(val) === '[object Array]'; }; function _isTransformer(obj) { @@ -430,53 +512,59 @@ * object in list position (last argument). If it is an array, executes [fn]. * Otherwise, if it has a function with one of the given method names, it will * execute that function (functor case). Otherwise, if it is a transformer, - * uses transducer [xf] to return a new transformer (transducer case). + * uses transducer created by [transducerCreator] to return a new transformer + * (transducer case). * Otherwise, it will default to executing [fn]. * * @private * @param {Array} methodNames properties to check for a custom implementation - * @param {Function} xf transducer to initialize if object is transformer + * @param {Function} transducerCreator transducer factory if object is transformer * @param {Function} fn default ramda implementation * @return {Function} A function that dispatches on object in list position */ - function _dispatchable(methodNames, xf, fn) { - return function() { + + function _dispatchable(methodNames, transducerCreator, fn) { + return function () { if (arguments.length === 0) { return fn(); } - var args = Array.prototype.slice.call(arguments, 0); - var obj = args.pop(); + + var obj = arguments[arguments.length - 1]; + if (!_isArray(obj)) { var idx = 0; + while (idx < methodNames.length) { if (typeof obj[methodNames[idx]] === 'function') { - return obj[methodNames[idx]].apply(obj, args); + return obj[methodNames[idx]].apply(obj, Array.prototype.slice.call(arguments, 0, -1)); } + idx += 1; } + if (_isTransformer(obj)) { - var transducer = xf.apply(null, args); + var transducer = transducerCreator.apply(null, Array.prototype.slice.call(arguments, 0, -1)); return transducer(obj); } } + return fn.apply(this, arguments); }; } function _reduced(x) { - return x && x['@@transducer/reduced'] ? x : - { - '@@transducer/value': x, - '@@transducer/reduced': true - }; + return x && x['@@transducer/reduced'] ? x : { + '@@transducer/value': x, + '@@transducer/reduced': true + }; } var _xfBase = { - init: function() { + init: function init() { return this.xf['@@transducer/init'](); }, - result: function(result) { - return this.xf['@@transducer/result'](result); + result: function result(_result) { + return this.xf['@@transducer/result'](_result); } }; @@ -485,22 +573,29 @@ this.f = f; this.all = true; } + XAll.prototype['@@transducer/init'] = _xfBase.init; - XAll.prototype['@@transducer/result'] = function(result) { + + XAll.prototype['@@transducer/result'] = function (result) { if (this.all) { result = this.xf['@@transducer/step'](result, true); } + return this.xf['@@transducer/result'](result); }; - XAll.prototype['@@transducer/step'] = function(result, input) { + + XAll.prototype['@@transducer/step'] = function (result, input) { if (!this.f(input)) { this.all = false; result = _reduced(this.xf['@@transducer/step'](result, false)); } + return result; }; - var _xall = _curry2(function _xall(f, xf) { return new XAll(f, xf); }); + var _xall = _curry2(function _xall(f, xf) { + return new XAll(f, xf); + }); /** * Returns `true` if all elements of the list match the predicate, `false` if @@ -526,14 +621,18 @@ * R.all(equals3)([3, 3, 3, 3]); //=> true * R.all(equals3)([3, 3, 1, 3]); //=> false */ + var all = _curry2(_dispatchable(['all'], _xall, function all(fn, list) { var idx = 0; + while (idx < list.length) { if (!fn(list[idx])) { return false; } + idx += 1; } + return true; })); @@ -554,16 +653,21 @@ * R.max(789, 123); //=> 789 * R.max('a', 'b'); //=> 'b' */ - var max = _curry2(function max(a, b) { return b > a ? b : a; }); + + var max = _curry2(function max(a, b) { + return b > a ? b : a; + }); function _map(fn, functor) { var idx = 0; var len = functor.length; var result = Array(len); + while (idx < len) { result[idx] = fn(functor[idx]); idx += 1; } + return result; } @@ -587,32 +691,56 @@ * _isArrayLike({}); //=> false * _isArrayLike({length: 10}); //=> false * _isArrayLike({0: 'zero', 9: 'nine', length: 10}); //=> true + * _isArrayLike({nodeType: 1, length: 1}) // => false */ + var _isArrayLike = _curry1(function isArrayLike(x) { - if (_isArray(x)) { return true; } - if (!x) { return false; } - if (typeof x !== 'object') { return false; } - if (_isString(x)) { return false; } - if (x.nodeType === 1) { return !!x.length; } - if (x.length === 0) { return true; } + if (_isArray(x)) { + return true; + } + + if (!x) { + return false; + } + + if (_typeof(x) !== 'object') { + return false; + } + + if (_isString(x)) { + return false; + } + + if (x.length === 0) { + return true; + } + if (x.length > 0) { return x.hasOwnProperty(0) && x.hasOwnProperty(x.length - 1); } + return false; }); function XWrap(fn) { this.f = fn; } - XWrap.prototype['@@transducer/init'] = function() { + + XWrap.prototype['@@transducer/init'] = function () { throw new Error('init not implemented on XWrap'); }; - XWrap.prototype['@@transducer/result'] = function(acc) { return acc; }; - XWrap.prototype['@@transducer/step'] = function(acc, x) { + + XWrap.prototype['@@transducer/result'] = function (acc) { + return acc; + }; + + XWrap.prototype['@@transducer/step'] = function (acc, x) { return this.f(acc, x); }; - function _xwrap(fn) { return new XWrap(fn); } + function _xwrap(fn) { + return new XWrap(fn); + } /** * Creates a function that is bound to a context. @@ -636,8 +764,9 @@ * // logs {a: 2} * @symb R.bind(f, o)(a, b) = f.call(o, a, b) */ + var bind = _curry2(function bind(fn, thisObj) { - return _arity(fn.length, function() { + return _arity(fn.length, function () { return fn.apply(thisObj, arguments); }); }); @@ -645,27 +774,35 @@ function _arrayReduce(xf, acc, list) { var idx = 0; var len = list.length; + while (idx < len) { acc = xf['@@transducer/step'](acc, list[idx]); + if (acc && acc['@@transducer/reduced']) { acc = acc['@@transducer/value']; break; } + idx += 1; } + return xf['@@transducer/result'](acc); } function _iterableReduce(xf, acc, iter) { var step = iter.next(); + while (!step.done) { acc = xf['@@transducer/step'](acc, step.value); + if (acc && acc['@@transducer/reduced']) { acc = acc['@@transducer/value']; break; } + step = iter.next(); } + return xf['@@transducer/result'](acc); } @@ -673,24 +810,28 @@ return xf['@@transducer/result'](obj[methodName](bind(xf['@@transducer/step'], xf), acc)); } - var symIterator = (typeof Symbol !== 'undefined') ? Symbol.iterator : '@@iterator'; - + var symIterator = typeof Symbol !== 'undefined' ? Symbol.iterator : '@@iterator'; function _reduce(fn, acc, list) { if (typeof fn === 'function') { fn = _xwrap(fn); } + if (_isArrayLike(list)) { return _arrayReduce(fn, acc, list); } + if (typeof list['fantasy-land/reduce'] === 'function') { return _methodReduce(fn, acc, list, 'fantasy-land/reduce'); } + if (list[symIterator] != null) { return _iterableReduce(fn, acc, list[symIterator]()); } + if (typeof list.next === 'function') { return _iterableReduce(fn, acc, list); } + if (typeof list.reduce === 'function') { return _methodReduce(fn, acc, list, 'reduce'); } @@ -702,47 +843,55 @@ this.xf = xf; this.f = f; } + XMap.prototype['@@transducer/init'] = _xfBase.init; XMap.prototype['@@transducer/result'] = _xfBase.result; - XMap.prototype['@@transducer/step'] = function(result, input) { + + XMap.prototype['@@transducer/step'] = function (result, input) { return this.xf['@@transducer/step'](result, this.f(input)); }; - var _xmap = _curry2(function _xmap(f, xf) { return new XMap(f, xf); }); + var _xmap = _curry2(function _xmap(f, xf) { + return new XMap(f, xf); + }); function _has(prop, obj) { return Object.prototype.hasOwnProperty.call(obj, prop); } var toString = Object.prototype.toString; - var _isArguments = (function() { - return toString.call(arguments) === '[object Arguments]' ? - function _isArguments(x) { return toString.call(x) === '[object Arguments]'; } : - function _isArguments(x) { return _has('callee', x); }; - }()); - - // cover IE < 9 keys issues - var hasEnumBug = !({toString: null}).propertyIsEnumerable('toString'); - var nonEnumerableProps = [ - 'constructor', 'valueOf', 'isPrototypeOf', 'toString', - 'propertyIsEnumerable', 'hasOwnProperty', 'toLocaleString' - ]; - // Safari bug - var hasArgsEnumBug = (function() { + + var _isArguments = function () { + return toString.call(arguments) === '[object Arguments]' ? function _isArguments(x) { + return toString.call(x) === '[object Arguments]'; + } : function _isArguments(x) { + return _has('callee', x); + }; + }(); + + var hasEnumBug = !{ + toString: null + }.propertyIsEnumerable('toString'); + var nonEnumerableProps = ['constructor', 'valueOf', 'isPrototypeOf', 'toString', 'propertyIsEnumerable', 'hasOwnProperty', 'toLocaleString']; // Safari bug + + var hasArgsEnumBug = function () { + return arguments.propertyIsEnumerable('length'); - }()); + }(); var contains = function contains(list, item) { var idx = 0; + while (idx < list.length) { if (list[idx] === item) { return true; } + idx += 1; } + return false; }; - /** * Returns a list containing the names of all the enumerable own properties of * the supplied object. @@ -756,39 +905,47 @@ * @sig {k: v} -> [k] * @param {Object} obj The object to extract properties from * @return {Array} An array of the object's own properties. - * @see R.keysIn, R.values + * @see R.keysIn, R.values, R.toPairs * @example * * R.keys({a: 1, b: 2, c: 3}); //=> ['a', 'b', 'c'] */ - var keys = typeof Object.keys === 'function' && !hasArgsEnumBug ? - _curry1(function keys(obj) { - return Object(obj) !== obj ? [] : Object.keys(obj); - }) : - _curry1(function keys(obj) { - if (Object(obj) !== obj) { - return []; + + + var keys = typeof Object.keys === 'function' && !hasArgsEnumBug ? _curry1(function keys(obj) { + return Object(obj) !== obj ? [] : Object.keys(obj); + }) : _curry1(function keys(obj) { + if (Object(obj) !== obj) { + return []; + } + + var prop, nIdx; + var ks = []; + + var checkArgsLength = hasArgsEnumBug && _isArguments(obj); + + for (prop in obj) { + if (_has(prop, obj) && (!checkArgsLength || prop !== 'length')) { + ks[ks.length] = prop; } - var prop, nIdx; - var ks = []; - var checkArgsLength = hasArgsEnumBug && _isArguments(obj); - for (prop in obj) { - if (_has(prop, obj) && (!checkArgsLength || prop !== 'length')) { + } + + if (hasEnumBug) { + nIdx = nonEnumerableProps.length - 1; + + while (nIdx >= 0) { + prop = nonEnumerableProps[nIdx]; + + if (_has(prop, obj) && !contains(ks, prop)) { ks[ks.length] = prop; } + + nIdx -= 1; } - if (hasEnumBug) { - nIdx = nonEnumerableProps.length - 1; - while (nIdx >= 0) { - prop = nonEnumerableProps[nIdx]; - if (_has(prop, obj) && !contains(ks, prop)) { - ks[ks.length] = prop; - } - nIdx -= 1; - } - } - return ks; - }); + } + + return ks; + }); /** * Takes a function and @@ -813,7 +970,7 @@ * @param {Function} fn The function to be called on every element of the input `list`. * @param {Array} list The list to be iterated over. * @return {Array} The new list. - * @see R.transduce, R.addIndex + * @see R.transduce, R.addIndex, R.pluck, R.project * @example * * const double = x => x * 2; @@ -825,17 +982,20 @@ * @symb R.map(f, { x: a, y: b }) = { x: f(a), y: f(b) } * @symb R.map(f, functor_o) = functor_o.map(f) */ + var map = _curry2(_dispatchable(['fantasy-land/map', 'map'], _xmap, function map(fn, functor) { switch (Object.prototype.toString.call(functor)) { case '[object Function]': - return curryN(functor.length, function() { + return curryN(functor.length, function () { return fn.call(this, functor.apply(this, arguments)); }); + case '[object Object]': - return _reduce(function(acc, key) { + return _reduce(function (acc, key) { acc[key] = fn(functor[key]); return acc; }, {}, keys(functor)); + default: return _map(fn, functor); } @@ -850,7 +1010,7 @@ * @return {Boolean} */ var _isInteger = Number.isInteger || function _isInteger(n) { - return (n << 0) === n; + return n << 0 === n; }; /** @@ -879,71 +1039,12 @@ * @symb R.nth(0, [a, b, c]) = a * @symb R.nth(1, [a, b, c]) = b */ + var nth = _curry2(function nth(offset, list) { var idx = offset < 0 ? list.length + offset : offset; return _isString(list) ? list.charAt(idx) : list[idx]; }); - /** - * Retrieves the values at given paths of an object. - * - * @func - * @memberOf R - * @since v0.27.1 - * @category Object - * @typedefn Idx = [String | Int] - * @sig [Idx] -> {a} -> [a | Undefined] - * @param {Array} pathsArray The array of paths to be fetched. - * @param {Object} obj The object to retrieve the nested properties from. - * @return {Array} A list consisting of values at paths specified by "pathsArray". - * @see R.path - * @example - * - * R.paths([['a', 'b'], ['p', 0, 'q']], {a: {b: 2}, p: [{q: 3}]}); //=> [2, 3] - * R.paths([['a', 'b'], ['p', 'r']], {a: {b: 2}, p: [{q: 3}]}); //=> [2, undefined] - */ - var paths = _curry2(function paths(pathsArray, obj) { - return pathsArray.map(function(paths) { - var val = obj; - var idx = 0; - var p; - while (idx < paths.length) { - if (val == null) { - return; - } - p = paths[idx]; - val = _isInteger(p) ? nth(p, val) : val[p]; - idx += 1; - } - return val; - }); - }); - - /** - * Retrieve the value at a given path. - * - * @func - * @memberOf R - * @since v0.2.0 - * @category Object - * @typedefn Idx = String | Int - * @sig [Idx] -> {a} -> a | Undefined - * @param {Array} path The path to use. - * @param {Object} obj The object to retrieve the nested property from. - * @return {*} The data at `path`. - * @see R.prop, R.nth - * @example - * - * R.path(['a', 'b'], {a: {b: 2}}); //=> 2 - * R.path(['a', 'b'], {c: {b: 2}}); //=> undefined - * R.path(['a', 'b', 0], {a: {b: [1, 2, 3]}}); //=> 1 - * R.path(['a', 'b', -2], {a: {b: [1, 2, 3]}}); //=> 2 - */ - - var path = _curry2(function path(pathAr, obj) { - return paths([pathAr], obj)[0]; - }); - /** * Returns a function that when supplied an object returns the indicated * property of that object, if it exists. @@ -952,12 +1053,12 @@ * @memberOf R * @since v0.1.0 * @category Object - * @typedefn Idx = String | Int + * @typedefn Idx = String | Int | Symbol * @sig Idx -> {s: a} -> a | Undefined * @param {String|Number} p The property name or array index * @param {Object} obj The object to query * @return {*} The value at `obj.p`. - * @see R.path, R.nth + * @see R.path, R.props, R.pluck, R.project, R.nth * @example * * R.prop('x', {x: 100}); //=> 100 @@ -966,7 +1067,13 @@ * R.compose(R.inc, R.prop('x'))({ x: 3 }) //=> 4 */ - var prop = _curry2(function prop(p, obj) { return path([p], obj); }); + var prop = _curry2(function prop(p, obj) { + if (obj == null) { + return; + } + + return _isInteger(p) ? nth(p, obj) : obj[p]; + }); /** * Returns a new list by plucking the same named property off all objects in @@ -984,7 +1091,7 @@ * @param {Number|String} key The key name to pluck off of each object. * @param {Array} f The array or functor to consider. * @return {Array} The list of values for the given key. - * @see R.props + * @see R.project, R.prop, R.props * @example * * var getAges = R.pluck('age'); @@ -995,6 +1102,7 @@ * @symb R.pluck('x', [{x: 1, y: 2}, {x: 3, y: 4}, {x: 5, y: 6}]) = [1, 3, 5] * @symb R.pluck(0, [[1, 2], [3, 4], [5, 6]]) = [1, 3, 5] */ + var pluck = _curry2(function pluck(p, list) { return map(prop(p), list); }); @@ -1045,6 +1153,7 @@ * * @symb R.reduce(f, a, [b, c, d]) = f(f(f(a, b), c), d) */ + var reduce = _curry3(_reduce); /** @@ -1072,16 +1181,20 @@ * isQueenOfSpades({rank: 'Q', suit: '♣︎'}); //=> false * isQueenOfSpades({rank: 'Q', suit: '♠︎'}); //=> true */ + var allPass = _curry1(function allPass(preds) { - return curryN(reduce(max, 0, pluck('length', preds)), function() { + return curryN(reduce(max, 0, pluck('length', preds)), function () { var idx = 0; var len = preds.length; + while (idx < len) { if (!preds[idx].apply(this, arguments)) { return false; } + idx += 1; } + return true; }); }); @@ -1105,14 +1218,16 @@ * const t = R.always('Tee'); * t(); //=> 'Tee' */ + var always = _curry1(function always(val) { - return function() { + return function () { return val; }; }); /** - * Returns `true` if both arguments are `true`; `false` otherwise. + * Returns the first argument if it is falsy, otherwise the second argument. + * Acts as the boolean `and` statement if both inputs are `Boolean`s. * * @func * @memberOf R @@ -1121,8 +1236,8 @@ * @sig a -> b -> a | b * @param {Any} a * @param {Any} b - * @return {Any} the first argument if it is falsy, otherwise the second argument. - * @see R.both, R.xor + * @return {Any} + * @see R.both, R.or * @example * * R.and(true, true); //=> true @@ -1130,6 +1245,7 @@ * R.and(false, true); //=> false * R.and(false, false); //=> false */ + var and = _curry2(function and(a, b) { return a && b; }); @@ -1139,22 +1255,29 @@ this.f = f; this.any = false; } + XAny.prototype['@@transducer/init'] = _xfBase.init; - XAny.prototype['@@transducer/result'] = function(result) { + + XAny.prototype['@@transducer/result'] = function (result) { if (!this.any) { result = this.xf['@@transducer/step'](result, false); } + return this.xf['@@transducer/result'](result); }; - XAny.prototype['@@transducer/step'] = function(result, input) { + + XAny.prototype['@@transducer/step'] = function (result, input) { if (this.f(input)) { this.any = true; result = _reduced(this.xf['@@transducer/step'](result, true)); } + return result; }; - var _xany = _curry2(function _xany(f, xf) { return new XAny(f, xf); }); + var _xany = _curry2(function _xany(f, xf) { + return new XAny(f, xf); + }); /** * Returns `true` if at least one of the elements of the list match the predicate, @@ -1181,14 +1304,18 @@ * R.any(lessThan0)([1, 2]); //=> false * R.any(lessThan2)([1, 2]); //=> true */ + var any = _curry2(_dispatchable(['any'], _xany, function any(fn, list) { var idx = 0; + while (idx < list.length) { if (fn(list[idx])) { return true; } + idx += 1; } + return false; })); @@ -1218,16 +1345,20 @@ * isBlackCard({rank: 'Q', suit: '♠'}); //=> true * isBlackCard({rank: 'Q', suit: '♦'}); //=> false */ + var anyPass = _curry1(function anyPass(preds) { - return curryN(reduce(max, 0, pluck('length', preds)), function() { + return curryN(reduce(max, 0, pluck('length', preds)), function () { var idx = 0; var len = preds.length; + while (idx < len) { if (preds[idx].apply(this, arguments)) { return true; } + idx += 1; } + return false; }); }); @@ -1258,26 +1389,25 @@ * R.ap(R.concat, R.toUpper)('Ramda') //=> 'RamdaRAMDA' * @symb R.ap([f, g], [a, b]) = [f(a), f(b), g(a), g(b)] */ + var ap = _curry2(function ap(applyF, applyX) { - return ( - typeof applyX['fantasy-land/ap'] === 'function' - ? applyX['fantasy-land/ap'](applyF) - : typeof applyF.ap === 'function' - ? applyF.ap(applyX) - : typeof applyF === 'function' - ? function(x) { return applyF(x)(applyX(x)); } - : _reduce(function(acc, f) { return _concat(acc, map(f, applyX)); }, [], applyF) - ); + return typeof applyX['fantasy-land/ap'] === 'function' ? applyX['fantasy-land/ap'](applyF) : typeof applyF.ap === 'function' ? applyF.ap(applyX) : typeof applyF === 'function' ? function (x) { + return applyF(x)(applyX(x)); + } : _reduce(function (acc, f) { + return _concat(acc, map(f, applyX)); + }, [], applyF); }); function _aperture(n, list) { var idx = 0; var limit = list.length - (n - 1); var acc = new Array(limit >= 0 ? limit : 0); + while (idx < limit) { acc[idx] = Array.prototype.slice.call(list, idx, idx + n); idx += 1; } + return acc; } @@ -1287,30 +1417,36 @@ this.full = false; this.acc = new Array(n); } + XAperture.prototype['@@transducer/init'] = _xfBase.init; - XAperture.prototype['@@transducer/result'] = function(result) { + + XAperture.prototype['@@transducer/result'] = function (result) { this.acc = null; return this.xf['@@transducer/result'](result); }; - XAperture.prototype['@@transducer/step'] = function(result, input) { + + XAperture.prototype['@@transducer/step'] = function (result, input) { this.store(input); return this.full ? this.xf['@@transducer/step'](result, this.getCopy()) : result; }; - XAperture.prototype.store = function(input) { + + XAperture.prototype.store = function (input) { this.acc[this.pos] = input; this.pos += 1; + if (this.pos === this.acc.length) { this.pos = 0; this.full = true; } }; - XAperture.prototype.getCopy = function() { - return _concat(Array.prototype.slice.call(this.acc, this.pos), - Array.prototype.slice.call(this.acc, 0, this.pos) - ); + + XAperture.prototype.getCopy = function () { + return _concat(Array.prototype.slice.call(this.acc, this.pos), Array.prototype.slice.call(this.acc, 0, this.pos)); }; - var _xaperture = _curry2(function _xaperture(n, xf) { return new XAperture(n, xf); }); + var _xaperture = _curry2(function _xaperture(n, xf) { + return new XAperture(n, xf); + }); /** * Returns a new list, composed of n-tuples of consecutive elements. If `n` is @@ -1333,6 +1469,7 @@ * R.aperture(3, [1, 2, 3, 4, 5]); //=> [[1, 2, 3], [2, 3, 4], [3, 4, 5]] * R.aperture(7, [1, 2, 3, 4, 5]); //=> [] */ + var aperture = _curry2(_dispatchable([], _xaperture, _aperture)); /** @@ -1355,6 +1492,7 @@ * R.append('tests', []); //=> ['tests'] * R.append(['tests'], ['write', 'more']); //=> ['write', 'more', ['tests']] */ + var append = _curry2(function append(el, list) { return _concat(list, [el]); }); @@ -1379,6 +1517,7 @@ * R.apply(Math.max, nums); //=> 42 * @symb R.apply(f, [a, b, c]) = f(a, b, c) */ + var apply = _curry2(function apply(fn, args) { return fn.apply(this, args); }); @@ -1395,32 +1534,34 @@ * @sig {k: v} -> [v] * @param {Object} obj The object to extract values from * @return {Array} An array of the values of the object's own properties. - * @see R.valuesIn, R.keys + * @see R.valuesIn, R.keys, R.toPairs * @example * * R.values({a: 1, b: 2, c: 3}); //=> [1, 2, 3] */ + var values = _curry1(function values(obj) { var props = keys(obj); var len = props.length; var vals = []; var idx = 0; + while (idx < len) { vals[idx] = obj[props[idx]]; idx += 1; } + return vals; }); - // Use custom mapValues function to avoid issues with specs that include a "map" key and R.map // delegating calls to .map + function mapValues(fn, obj) { - return keys(obj).reduce(function(acc, key) { + return _isArray(obj) ? obj.map(fn) : keys(obj).reduce(function (acc, key) { acc[key] = fn(obj[key]); return acc; }, {}); } - /** * Given a spec object recursively mapping properties to functions, creates a * function producing an object of the same structure, by mapping each property @@ -1446,21 +1587,21 @@ * getMetrics(2, 4); // => { sum: 6, nested: { mul: 8 } } * @symb R.applySpec({ x: f, y: { z: g } })(a, b) = { x: f(a, b), y: { z: g(a, b) } } */ - var applySpec = _curry1(function applySpec(spec) { - spec = mapValues( - function(v) { return typeof v == 'function' ? v : applySpec(v); }, - spec - ); - - return curryN( - reduce(max, 0, pluck('length', values(spec))), - function() { - var args = arguments; - return mapValues(function(f) { return apply(f, args); }, spec); - }); - }); - /** + + var applySpec = _curry1(function applySpec(spec) { + spec = mapValues(function (v) { + return typeof v == 'function' ? v : applySpec(v); + }, spec); + return curryN(reduce(max, 0, pluck('length', values(spec))), function () { + var args = arguments; + return mapValues(function (f) { + return apply(f, args); + }, spec); + }); + }); + + /** * Takes a value and applies a function to it. * * This function is also known as the `thrush` combinator. @@ -1479,7 +1620,10 @@ * t42(R.identity); //=> 42 * t42(R.add(1)); //=> 43 */ - var applyTo = _curry2(function applyTo(x, f) { return f(x); }); + + var applyTo = _curry2(function applyTo(x, f) { + return f(x); + }); /** * Makes an ascending comparator function out of a function that returns a value @@ -1506,6 +1650,7 @@ * const peopleByYoungestFirst = R.sort(byAge, people); * //=> [{ name: 'Mikhail', age: 62 },{ name: 'Emma', age: 70 }, { name: 'Peter', age: 78 }] */ + var ascend = _curry3(function ascend(fn, a, b) { var aa = fn(a); var bb = fn(b); @@ -1518,28 +1663,29 @@ * properties onto the new object as well. All non-primitive properties are * copied by reference. * - * @func - * @memberOf R - * @since v0.8.0 - * @category Object - * @sig String -> a -> {k: v} -> {k: v} - * @param {String} prop The property name to set + * @private + * @param {String|Number} prop The property name to set * @param {*} val The new value - * @param {Object} obj The object to clone - * @return {Object} A new object equivalent to the original except for the changed property. - * @see R.dissoc, R.pick - * @example - * - * R.assoc('c', 3, {a: 1, b: 2}); //=> {a: 1, b: 2, c: 3} + * @param {Object|Array} obj The object to clone + * @return {Object|Array} A new object equivalent to the original except for the changed property. */ - var assoc = _curry3(function assoc(prop, val, obj) { + + function _assoc(prop, val, obj) { + if (_isInteger(prop) && _isArray(obj)) { + var arr = [].concat(obj); + arr[prop] = val; + return arr; + } + var result = {}; + for (var p in obj) { result[p] = obj[p]; } + result[prop] = val; return result; - }); + } /** * Checks if the input value is `null` or `undefined`. @@ -1558,7 +1704,10 @@ * R.isNil(0); //=> false * R.isNil([]); //=> false */ - var isNil = _curry1(function isNil(x) { return x == null; }); + + var isNil = _curry1(function isNil(x) { + return x == null; + }); /** * Makes a shallow clone of an object, setting or overriding the nodes required @@ -1570,7 +1719,7 @@ * @memberOf R * @since v0.8.0 * @category Object - * @typedefn Idx = String | Int + * @typedefn Idx = String | Int | Symbol * @sig [Idx] -> a -> {a} -> {a} * @param {Array} path the path to set * @param {*} val The new value @@ -1584,22 +1733,46 @@ * // Any missing or non-object keys in path will be overridden * R.assocPath(['a', 'b', 'c'], 42, {a: 5}); //=> {a: {b: {c: 42}}} */ + var assocPath = _curry3(function assocPath(path, val, obj) { if (path.length === 0) { return val; } + var idx = path[0]; + if (path.length > 1) { - var nextObj = (!isNil(obj) && _has(idx, obj)) ? obj[idx] : _isInteger(path[1]) ? [] : {}; + var nextObj = !isNil(obj) && _has(idx, obj) ? obj[idx] : _isInteger(path[1]) ? [] : {}; val = assocPath(Array.prototype.slice.call(path, 1), val, nextObj); } - if (_isInteger(idx) && _isArray(obj)) { - var arr = [].concat(obj); - arr[idx] = val; - return arr; - } else { - return assoc(idx, val, obj); - } + + return _assoc(idx, val, obj); + }); + + /** + * Makes a shallow clone of an object, setting or overriding the specified + * property with the given value. Note that this copies and flattens prototype + * properties onto the new object as well. All non-primitive properties are + * copied by reference. + * + * @func + * @memberOf R + * @since v0.8.0 + * @category Object + * @typedefn Idx = String | Int + * @sig Idx -> a -> {k: v} -> {k: v} + * @param {String|Number} prop The property name to set + * @param {*} val The new value + * @param {Object} obj The object to clone + * @return {Object} A new object equivalent to the original except for the changed property. + * @see R.dissoc, R.pick + * @example + * + * R.assoc('c', 3, {a: 1, b: 2}); //=> {a: 1, b: 2, c: 3} + */ + + var assoc = _curry3(function assoc(prop, val, obj) { + return assocPath([prop], val, obj); }); /** @@ -1632,20 +1805,66 @@ * @symb R.nAry(1, f)(a, b) = f(a) * @symb R.nAry(2, f)(a, b) = f(a, b) */ + var nAry = _curry2(function nAry(n, fn) { switch (n) { - case 0: return function() {return fn.call(this);}; - case 1: return function(a0) {return fn.call(this, a0);}; - case 2: return function(a0, a1) {return fn.call(this, a0, a1);}; - case 3: return function(a0, a1, a2) {return fn.call(this, a0, a1, a2);}; - case 4: return function(a0, a1, a2, a3) {return fn.call(this, a0, a1, a2, a3);}; - case 5: return function(a0, a1, a2, a3, a4) {return fn.call(this, a0, a1, a2, a3, a4);}; - case 6: return function(a0, a1, a2, a3, a4, a5) {return fn.call(this, a0, a1, a2, a3, a4, a5);}; - case 7: return function(a0, a1, a2, a3, a4, a5, a6) {return fn.call(this, a0, a1, a2, a3, a4, a5, a6);}; - case 8: return function(a0, a1, a2, a3, a4, a5, a6, a7) {return fn.call(this, a0, a1, a2, a3, a4, a5, a6, a7);}; - case 9: return function(a0, a1, a2, a3, a4, a5, a6, a7, a8) {return fn.call(this, a0, a1, a2, a3, a4, a5, a6, a7, a8);}; - case 10: return function(a0, a1, a2, a3, a4, a5, a6, a7, a8, a9) {return fn.call(this, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9);}; - default: throw new Error('First argument to nAry must be a non-negative integer no greater than ten'); + case 0: + return function () { + return fn.call(this); + }; + + case 1: + return function (a0) { + return fn.call(this, a0); + }; + + case 2: + return function (a0, a1) { + return fn.call(this, a0, a1); + }; + + case 3: + return function (a0, a1, a2) { + return fn.call(this, a0, a1, a2); + }; + + case 4: + return function (a0, a1, a2, a3) { + return fn.call(this, a0, a1, a2, a3); + }; + + case 5: + return function (a0, a1, a2, a3, a4) { + return fn.call(this, a0, a1, a2, a3, a4); + }; + + case 6: + return function (a0, a1, a2, a3, a4, a5) { + return fn.call(this, a0, a1, a2, a3, a4, a5); + }; + + case 7: + return function (a0, a1, a2, a3, a4, a5, a6) { + return fn.call(this, a0, a1, a2, a3, a4, a5, a6); + }; + + case 8: + return function (a0, a1, a2, a3, a4, a5, a6, a7) { + return fn.call(this, a0, a1, a2, a3, a4, a5, a6, a7); + }; + + case 9: + return function (a0, a1, a2, a3, a4, a5, a6, a7, a8) { + return fn.call(this, a0, a1, a2, a3, a4, a5, a6, a7, a8); + }; + + case 10: + return function (a0, a1, a2, a3, a4, a5, a6, a7, a8, a9) { + return fn.call(this, a0, a1, a2, a3, a4, a5, a6, a7, a8, a9); + }; + + default: + throw new Error('First argument to nAry must be a non-negative integer no greater than ten'); } }); @@ -1658,7 +1877,7 @@ * @memberOf R * @since v0.2.0 * @category Function - * @sig (* -> c) -> (a, b -> c) + * @sig (a -> b -> c -> ... -> z) -> ((a, b) -> z) * @param {Function} fn The function to wrap. * @return {Function} A new function wrapping `fn`. The new function is guaranteed to be of * arity 2. @@ -1677,16 +1896,14 @@ * takesTwoArgs(1, 2, 3); //=> [1, 2, undefined] * @symb R.binary(f)(a, b, c) = f(a, b) */ + var binary = _curry1(function binary(fn) { return nAry(2, fn); }); function _isFunction(x) { var type = Object.prototype.toString.call(x); - return type === '[object Function]' || - type === '[object AsyncFunction]' || - type === '[object GeneratorFunction]' || - type === '[object AsyncGeneratorFunction]'; + return type === '[object Function]' || type === '[object AsyncFunction]' || type === '[object GeneratorFunction]' || type === '[object AsyncGeneratorFunction]'; } /** @@ -1706,15 +1923,16 @@ * const madd3 = R.liftN(3, (...args) => R.sum(args)); * madd3([1,2,3], [1,2,3], [1]); //=> [3, 4, 5, 4, 5, 6, 5, 6, 7] */ + var liftN = _curry2(function liftN(arity, fn) { var lifted = curryN(arity, fn); - return curryN(arity, function() { + return curryN(arity, function () { return _reduce(ap, map(lifted, arguments[0]), Array.prototype.slice.call(arguments, 1)); }); }); /** - * "lifts" a function of arity > 1 so that it may "map over" a list, Function or other + * "lifts" a function of arity >= 1 so that it may "map over" a list, Function or other * object that satisfies the [FantasyLand Apply spec](https://github.com/fantasyland/fantasy-land#apply). * * @func @@ -1729,12 +1947,13 @@ * * const madd3 = R.lift((a, b, c) => a + b + c); * - * madd3([1,2,3], [1,2,3], [1]); //=> [3, 4, 5, 4, 5, 6, 5, 6, 7] + * madd3([100, 200], [30, 40], [5, 6, 7]); //=> [135, 136, 137, 145, 146, 147, 235, 236, 237, 245, 246, 247] * * const madd5 = R.lift((a, b, c, d, e) => a + b + c + d + e); * - * madd5([1,2], [3], [4, 5], [6], [7, 8]); //=> [21, 22, 22, 23, 22, 23, 23, 24] + * madd5([10, 20], [1], [2, 3], [4], [100, 200]); //=> [117, 217, 118, 218, 127, 227, 128, 228] */ + var lift = _curry1(function lift(fn) { return liftN(fn.length, fn); }); @@ -1758,7 +1977,7 @@ * @param {Function} f A predicate * @param {Function} g Another predicate * @return {Function} a function that applies its arguments to `f` and `g` and `&&`s their outputs together. - * @see R.and + * @see R.either, R.and * @example * * const gt10 = R.gt(R.__, 10) @@ -1770,57 +1989,11 @@ * R.both(Maybe.Just(false), Maybe.Just(55)); // => Maybe.Just(false) * R.both([false, false, 'a'], [11]); //=> [false, false, 11] */ - var both = _curry2(function both(f, g) { - return _isFunction(f) ? - function _both() { - return f.apply(this, arguments) && g.apply(this, arguments); - } : - lift(and)(f, g); - }); - /** - * Returns a curried equivalent of the provided function. The curried function - * has two unusual capabilities. First, its arguments needn't be provided one - * at a time. If `f` is a ternary function and `g` is `R.curry(f)`, the - * following are equivalent: - * - * - `g(1)(2)(3)` - * - `g(1)(2, 3)` - * - `g(1, 2)(3)` - * - `g(1, 2, 3)` - * - * Secondly, the special placeholder value [`R.__`](#__) may be used to specify - * "gaps", allowing partial application of any combination of arguments, - * regardless of their positions. If `g` is as above and `_` is [`R.__`](#__), - * the following are equivalent: - * - * - `g(1, 2, 3)` - * - `g(_, 2, 3)(1)` - * - `g(_, _, 3)(1)(2)` - * - `g(_, _, 3)(1, 2)` - * - `g(_, 2)(1)(3)` - * - `g(_, 2)(1, 3)` - * - `g(_, 2)(_, 3)(1)` - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Function - * @sig (* -> a) -> (* -> a) - * @param {Function} fn The function to curry. - * @return {Function} A new, curried function. - * @see R.curryN, R.partial - * @example - * - * const addFourNumbers = (a, b, c, d) => a + b + c + d; - * - * const curriedAddFourNumbers = R.curry(addFourNumbers); - * const f = curriedAddFourNumbers(1, 2); - * const g = f(3); - * g(4); //=> 10 - */ - var curry = _curry1(function curry(fn) { - return curryN(fn.length, fn); + var both = _curry2(function both(f, g) { + return _isFunction(f) ? function _both() { + return f.apply(this, arguments) && g.apply(this, arguments); + } : lift(and)(f, g); }); /** @@ -1834,7 +2007,7 @@ * @memberOf R * @since v0.9.0 * @category Function - * @sig (*... -> a),*... -> a + * @sig ((*... -> a), *...) -> a * @param {Function} fn The function to apply to the remaining arguments. * @param {...*} args Any number of positional arguments. * @return {*} @@ -1843,19 +2016,25 @@ * * R.call(R.add, 1, 2); //=> 3 * - * const indentN = R.pipe(R.repeat(' '), - * R.join(''), - * R.replace(/^(?!$)/gm)); + * const indentN = R.pipe( + * R.repeat(' '), + * R.join(''), + * R.replace(/^(?!$)/gm) + * ); * - * const format = R.converge(R.call, [ - * R.pipe(R.prop('indent'), indentN), - * R.prop('value') - * ]); + * const format = R.converge( + * R.call, + * [ + * R.pipe(R.prop('indent'), indentN), + * R.prop('value') + * ] + * ); * * format({indent: 2, value: 'foo\nbar\nbaz\n'}); //=> ' foo\n bar\n baz\n' * @symb R.call(f, a, b) = f(a, b) */ - var call = curry(function call(fn) { + + var call = _curry1(function call(fn) { return fn.apply(this, Array.prototype.slice.call(arguments, 1)); }); @@ -1865,6 +2044,7 @@ * * @private */ + function _makeFlat(recursive) { return function flatt(list) { var value, jlen, j; @@ -1877,6 +2057,7 @@ value = recursive ? flatt(list[idx]) : list[idx]; j = 0; jlen = value.length; + while (j < jlen) { result[result.length] = value[j]; j += 1; @@ -1884,8 +2065,10 @@ } else { result[result.length] = list[idx]; } + idx += 1; } + return result; }; } @@ -1897,13 +2080,13 @@ }; } - var preservingReduced = function(xf) { + var preservingReduced = function preservingReduced(xf) { return { '@@transducer/init': _xfBase.init, - '@@transducer/result': function(result) { + '@@transducer/result': function transducerResult(result) { return xf['@@transducer/result'](result); }, - '@@transducer/step': function(result, input) { + '@@transducer/step': function transducerStep(result, input) { var ret = xf['@@transducer/step'](result, input); return ret['@@transducer/reduced'] ? _forceReduced(ret) : ret; } @@ -1914,10 +2097,10 @@ var rxf = preservingReduced(xf); return { '@@transducer/init': _xfBase.init, - '@@transducer/result': function(result) { + '@@transducer/result': function transducerResult(result) { return rxf['@@transducer/result'](result); }, - '@@transducer/step': function(result, input) { + '@@transducer/step': function transducerStep(result, input) { return !_isArrayLike(input) ? _reduce(rxf, result, [input]) : _reduce(rxf, result, input); } }; @@ -1953,10 +2136,14 @@ * * R.chain(R.append, R.head)([1, 2, 3]); //=> [1, 2, 3, 1] */ + var chain = _curry2(_dispatchable(['fantasy-land/chain', 'chain'], _xchain, function chain(fn, monad) { if (typeof monad === 'function') { - return function(x) { return fn(monad(x))(x); }; + return function (x) { + return fn(monad(x))(x); + }; } + return _makeFlat(false)(map(fn, monad)); })); @@ -1980,23 +2167,17 @@ * R.clamp(1, 10, 15) // => 10 * R.clamp(1, 10, 4) // => 4 */ + var clamp = _curry3(function clamp(min, max, value) { if (min > max) { throw new Error('min must not be greater than max in clamp(min, max, value)'); } - return value < min - ? min - : value > max - ? max - : value; + + return value < min ? min : value > max ? max : value; }); function _cloneRegExp(pattern) { - return new RegExp(pattern.source, (pattern.global ? 'g' : '') + - (pattern.ignoreCase ? 'i' : '') + - (pattern.multiline ? 'm' : '') + - (pattern.sticky ? 'y' : '') + - (pattern.unicode ? 'u' : '')); + return new RegExp(pattern.source, (pattern.global ? 'g' : '') + (pattern.ignoreCase ? 'i' : '') + (pattern.multiline ? 'm' : '') + (pattern.sticky ? 'y' : '') + (pattern.unicode ? 'u' : '')); } /** @@ -2024,12 +2205,9 @@ * R.type(() => {}); //=> "Function" * R.type(undefined); //=> "Undefined" */ + var type = _curry1(function type(val) { - return val === null - ? 'Null' - : val === undefined - ? 'Undefined' - : Object.prototype.toString.call(val).slice(8, -1); + return val === null ? 'Null' : val === undefined ? 'Undefined' : Object.prototype.toString.call(val).slice(8, -1); }); /** @@ -2042,40 +2220,76 @@ * @param {Boolean} deep Whether or not to perform deep cloning. * @return {*} The copied value. */ + function _clone(value, refFrom, refTo, deep) { var copy = function copy(copiedValue) { var len = refFrom.length; var idx = 0; + while (idx < len) { if (value === refFrom[idx]) { return refTo[idx]; } + idx += 1; } - refFrom[idx + 1] = value; - refTo[idx + 1] = copiedValue; + + refFrom[idx] = value; + refTo[idx] = copiedValue; + for (var key in value) { - copiedValue[key] = deep ? - _clone(value[key], refFrom, refTo, true) : value[key]; + if (value.hasOwnProperty(key)) { + copiedValue[key] = deep ? _clone(value[key], refFrom, refTo, true) : value[key]; + } } + return copiedValue; }; + switch (type(value)) { - case 'Object': return copy({}); - case 'Array': return copy([]); - case 'Date': return new Date(value.valueOf()); - case 'RegExp': return _cloneRegExp(value); - default: return value; + case 'Object': + return copy(Object.create(Object.getPrototypeOf(value))); + + case 'Array': + return copy([]); + + case 'Date': + return new Date(value.valueOf()); + + case 'RegExp': + return _cloneRegExp(value); + + case 'Int8Array': + case 'Uint8Array': + case 'Uint8ClampedArray': + case 'Int16Array': + case 'Uint16Array': + case 'Int32Array': + case 'Uint32Array': + case 'Float32Array': + case 'Float64Array': + case 'BigInt64Array': + case 'BigUint64Array': + return value.slice(); + + default: + return value; } } /** - * Creates a deep copy of the value which may contain (nested) `Array`s and - * `Object`s, `Number`s, `String`s, `Boolean`s and `Date`s. `Function`s are - * assigned by reference rather than copied + * Creates a deep copy of the source that can be used in place of the source + * object without retaining any references to it. + * The source object may contain (nested) `Array`s and `Object`s, + * `Number`s, `String`s, `Boolean`s and `Date`s. + * `Function`s are assigned by reference rather than copied. * * Dispatches to a `clone` method if present. * + * Note that if the source object has multiple nodes that share a reference, + * the returned object will have the same structure, but the references will + * be pointed to the location within the cloned value. + * * @func * @memberOf R * @since v0.1.0 @@ -2090,10 +2304,62 @@ * objects === objectsClone; //=> false * objects[0] === objectsClone[0]; //=> false */ + var clone = _curry1(function clone(value) { - return value != null && typeof value.clone === 'function' ? - value.clone() : - _clone(value, [], [], true); + return value != null && typeof value.clone === 'function' ? value.clone() : _clone(value, [], [], true); + }); + + /** + * Splits a list into sub-lists, based on the result of calling a key-returning function on each element, + * and grouping the results according to values returned. + * + * @func + * @memberOf R + * @since v0.28.0 + * @category List + * @typedefn Idx = String | Int | Symbol + * @sig Idx a => (b -> a) -> [b] -> [[b]] + * @param {Function} fn Function :: a -> Idx + * @param {Array} list The array to group + * @return {Array} + * An array of arrays where each sub-array contains items for which + * the String-returning function has returned the same value. + * @see R.groupBy, R.partition + * @example + * R.collectBy(R.prop('type'), [ + * {type: 'breakfast', item: '☕️'}, + * {type: 'lunch', item: '🌯'}, + * {type: 'dinner', item: '🍝'}, + * {type: 'breakfast', item: '🥐'}, + * {type: 'lunch', item: '🍕'} + * ]); + * + * // [ [ {type: 'breakfast', item: '☕️'}, + * // {type: 'breakfast', item: '🥐'} ], + * // [ {type: 'lunch', item: '🌯'}, + * // {type: 'lunch', item: '🍕'} ], + * // [ {type: 'dinner', item: '🍝'} ] ] + */ + + var collectBy = _curry2(function collectBy(fn, list) { + var group = _reduce(function (o, x) { + var tag = fn(x); + + if (o[tag] === undefined) { + o[tag] = []; + } + + o[tag].push(x); + return o; + }, {}, list); + + var newList = []; + + for (var tag in group) { + newList.push(group[tag]); + } + + return newList; }); /** @@ -2119,8 +2385,9 @@ * const peopleByIncreasingAge = R.sort(byAge, people); * //=> [{ name: 'Mikhail', age: 62 },{ name: 'Emma', age: 70 }, { name: 'Peter', age: 78 }] */ + var comparator = _curry1(function comparator(pred) { - return function(a, b) { + return function (a, b) { return pred(a, b) ? -1 : pred(b, a) ? 1 : 0; }; }); @@ -2144,6 +2411,7 @@ * R.not(0); //=> true * R.not(1); //=> false */ + var not = _curry1(function not(a) { return !a; }); @@ -2165,15 +2433,16 @@ * @example * * const isNotNil = R.complement(R.isNil); - * isNil(null); //=> true + * R.isNil(null); //=> true * isNotNil(null); //=> false - * isNil(7); //=> false + * R.isNil(7); //=> false * isNotNil(7); //=> true */ + var complement = lift(not); function _pipe(f, g) { - return function() { + return function () { return g.call(this, f.apply(this, arguments)); }; } @@ -2184,20 +2453,21 @@ * implementation. * * @private - * @param {Function} fn ramda implemtation + * @param {Function} fn ramda implementation * @param {String} methodname property to check for a custom implementation * @return {Object} Whatever the return value of the method is. */ + function _checkForMethod(methodname, fn) { - return function() { + return function () { var length = arguments.length; + if (length === 0) { return fn(); } + var obj = arguments[length - 1]; - return (_isArray(obj) || typeof obj[methodname] !== 'function') ? - fn.apply(this, arguments) : - obj[methodname].apply(obj, Array.prototype.slice.call(arguments, 0, length - 1)); + return _isArray(obj) || typeof obj[methodname] !== 'function' ? fn.apply(this, arguments) : obj[methodname].apply(obj, Array.prototype.slice.call(arguments, 0, length - 1)); }; } @@ -2225,6 +2495,7 @@ * R.slice(-3, -1, ['a', 'b', 'c', 'd']); //=> ['b', 'c'] * R.slice(0, 3, 'ramda'); //=> 'ram' */ + var slice = _curry3(_checkForMethod('slice', function slice(fromIndex, toIndex, list) { return Array.prototype.slice.call(list, fromIndex, toIndex); })); @@ -2256,6 +2527,7 @@ * R.tail('a'); //=> '' * R.tail(''); //=> '' */ + var tail = _curry1(_checkForMethod('tail', slice(1, Infinity))); /** @@ -2280,15 +2552,15 @@ * * f(3, 4); // -(3^4) + 1 * @symb R.pipe(f, g, h)(a, b) = h(g(f(a, b))) + * @symb R.pipe(f, g, h)(a)(b) = h(g(f(a)))(b) */ + function pipe() { if (arguments.length === 0) { throw new Error('pipe requires at least one argument'); } - return _arity( - arguments[0].length, - reduce(_pipe, arguments[0], tail(arguments)) - ); + + return _arity(arguments[0].length, reduce(_pipe, arguments[0], tail(arguments))); } /** @@ -2315,10 +2587,9 @@ * R.reverse('a'); //=> 'a' * R.reverse(''); //=> '' */ + var reverse = _curry1(function reverse(list) { - return _isString(list) - ? list.split('').reverse().join('') - : Array.prototype.slice.call(list, 0).reverse(); + return _isString(list) ? list.split('').reverse().join('') : Array.prototype.slice.call(list, 0).reverse(); }); /** @@ -2344,132 +2615,15 @@ * R.compose(Math.abs, R.add(1), R.multiply(2))(-4) //=> 7 * * @symb R.compose(f, g, h)(a, b) = f(g(h(a, b))) + * @symb R.compose(f, g, h)(a)(b) = f(g(h(a)))(b) */ + function compose() { if (arguments.length === 0) { throw new Error('compose requires at least one argument'); } - return pipe.apply(this, reverse(arguments)); - } - - /** - * Returns the right-to-left Kleisli composition of the provided functions, - * each of which must return a value of a type supported by [`chain`](#chain). - * - * `R.composeK(h, g, f)` is equivalent to `R.compose(R.chain(h), R.chain(g), f)`. - * - * @func - * @memberOf R - * @since v0.16.0 - * @category Function - * @sig Chain m => ((y -> m z), (x -> m y), ..., (a -> m b)) -> (a -> m z) - * @param {...Function} ...functions The functions to compose - * @return {Function} - * @see R.pipeK - * @deprecated since v0.26.0 - * @example - * - * // get :: String -> Object -> Maybe * - * const get = R.curry((propName, obj) => Maybe(obj[propName])) - * - * // getStateCode :: Maybe String -> Maybe String - * const getStateCode = R.composeK( - * R.compose(Maybe.of, R.toUpper), - * get('state'), - * get('address'), - * get('user'), - * ); - * getStateCode({"user":{"address":{"state":"ny"}}}); //=> Maybe.Just("NY") - * getStateCode({}); //=> Maybe.Nothing() - * @symb R.composeK(f, g, h)(a) = R.chain(f, R.chain(g, h(a))) - */ - function composeK() { - if (arguments.length === 0) { - throw new Error('composeK requires at least one argument'); - } - var init = Array.prototype.slice.call(arguments); - var last = init.pop(); - return compose(compose.apply(this, map(chain, init)), last); - } - - function _pipeP(f, g) { - return function() { - var ctx = this; - return f.apply(ctx, arguments).then(function(x) { - return g.call(ctx, x); - }); - }; - } - /** - * Performs left-to-right composition of one or more Promise-returning - * functions. The first argument may have any arity; the remaining arguments - * must be unary. - * - * @func - * @memberOf R - * @since v0.10.0 - * @category Function - * @sig ((a -> Promise b), (b -> Promise c), ..., (y -> Promise z)) -> (a -> Promise z) - * @param {...Function} functions - * @return {Function} - * @see R.composeP - * @deprecated since v0.26.0 - * @example - * - * // followersForUser :: String -> Promise [User] - * const followersForUser = R.pipeP(db.getUserById, db.getFollowers); - */ - function pipeP() { - if (arguments.length === 0) { - throw new Error('pipeP requires at least one argument'); - } - return _arity( - arguments[0].length, - reduce(_pipeP, arguments[0], tail(arguments)) - ); - } - - /** - * Performs right-to-left composition of one or more Promise-returning - * functions. The last arguments may have any arity; the remaining - * arguments must be unary. - * - * @func - * @memberOf R - * @since v0.10.0 - * @category Function - * @sig ((y -> Promise z), (x -> Promise y), ..., (a -> Promise b)) -> (a -> Promise z) - * @param {...Function} functions The functions to compose - * @return {Function} - * @see R.pipeP - * @deprecated since v0.26.0 - * @example - * - * const db = { - * users: { - * JOE: { - * name: 'Joe', - * followers: ['STEVE', 'SUZY'] - * } - * } - * } - * - * // We'll pretend to do a db lookup which returns a promise - * const lookupUser = (userId) => Promise.resolve(db.users[userId]) - * const lookupFollowers = (user) => Promise.resolve(user.followers) - * lookupUser('JOE').then(lookupFollowers) - * - * // followersForUser :: String -> Promise [UserId] - * const followersForUser = R.composeP(lookupFollowers, lookupUser); - * followersForUser('JOE').then(followers => console.log('Followers:', followers)) - * // Followers: ["STEVE","SUZY"] - */ - function composeP() { - if (arguments.length === 0) { - throw new Error('composeP requires at least one argument'); - } - return pipeP.apply(this, reverse(arguments)); + return pipe.apply(this, reverse(arguments)); } /** @@ -2493,9 +2647,12 @@ * R.head('abc'); //=> 'a' * R.head(''); //=> '' */ + var head = nth(0); - function _identity(x) { return x; } + function _identity(x) { + return x; + } /** * A function that does nothing but return the parameter supplied to it. Good @@ -2516,11 +2673,12 @@ * R.identity(obj) === obj; //=> true * @symb R.identity(a) = a */ + var identity = _curry1(_identity); /** - * Performs left-to-right function composition using transforming function. The first argument may have - * any arity; the remaining arguments must be unary. + * Performs left-to-right function composition using transforming function. The first function may have + * any arity; the remaining functions must be unary. * * **Note:** The result of pipeWith is not automatically curried. Transforming function is not used on the * first argument. @@ -2530,7 +2688,8 @@ * @since v0.26.0 * @category Function * @sig ((* -> *), [((a, b, ..., n) -> o), (o -> p), ..., (x -> y), (y -> z)]) -> ((a, b, ..., n) -> z) - * @param {...Function} functions + * @param {Function} transformer The transforming function + * @param {Array} functions The functions to pipe * @return {Function} * @see R.composeWith, R.pipe * @example @@ -2541,6 +2700,7 @@ * f(3, 4); // -(3^4) + 1 * @symb R.pipeWith(f)([g, h, i])(...args) = f(i, f(h, g(...args))) */ + var pipeWith = _curry2(function pipeWith(xf, list) { if (list.length <= 0) { return identity; @@ -2548,31 +2708,27 @@ var headList = head(list); var tailList = tail(list); - - return _arity(headList.length, function() { - return _reduce( - function(result, f) { - return xf.call(this, f, result); - }, - headList.apply(this, arguments), - tailList - ); + return _arity(headList.length, function () { + return _reduce(function (result, f) { + return xf.call(this, f, result); + }, headList.apply(this, arguments), tailList); }); }); /** - * Performs right-to-left function composition using transforming function. The last argument may have - * any arity; the remaining arguments must be unary. + * Performs right-to-left function composition using transforming function. The last function may have + * any arity; the remaining functions must be unary. * - * **Note:** The result of compose is not automatically curried. Transforming function is not used on the - * last argument. + * **Note:** The result of composeWith is not automatically curried. Transforming function is not used + * on the last argument. * * @func * @memberOf R * @since v0.26.0 * @category Function * @sig ((* -> *), [(y -> z), (x -> y), ..., (o -> p), ((a, b, ..., n) -> o)]) -> ((a, b, ..., n) -> z) - * @param {...Function} ...functions The functions to compose + * @param {Function} transformer The transforming function + * @param {Array} functions The functions to compose * @return {Function} * @see R.compose, R.pipeWith * @example @@ -2584,6 +2740,7 @@ * * @symb R.composeWith(f)([g, h, i])(...args) = f(g, f(h, i(...args))) */ + var composeWith = _curry2(function composeWith(xf, list) { return pipeWith.apply(this, [xf, reverse(list)]); }); @@ -2591,9 +2748,11 @@ function _arrayFromIterator(iter) { var list = []; var next; + while (!(next = iter.next()).done) { list.push(next.value); } + return list; } @@ -2605,8 +2764,10 @@ if (pred(x, list[idx])) { return true; } + idx += 1; } + return false; } @@ -2619,7 +2780,8 @@ // Based on https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is function _objectIs(a, b) { // SameValue algorithm - if (a === b) { // Steps 1-5, 7-10 + if (a === b) { + // Steps 1-5, 7-10 // Steps 6.b-6.e: +0 != -0 return a !== 0 || 1 / a === 1 / b; } else { @@ -2636,21 +2798,22 @@ * - iterators lengths are the same * - iterators values are unique * - * false-positive result will be returned for comparision of, e.g. + * false-positive result will be returned for comparison of, e.g. * - [1,2,3] and [1,2,3,4] * - [1,1,1] and [1,2,3] * */ function _uniqContentEquals(aIterator, bIterator, stackA, stackB) { var a = _arrayFromIterator(aIterator); + var b = _arrayFromIterator(bIterator); function eq(_a, _b) { return _equals(_a, _b, stackA.slice(), stackB.slice()); - } + } // if *a* array contains any element that is not included in *b* + - // if *a* array contains any element that is not included in *b* - return !_includesWith(function(b, aItem) { + return !_includesWith(function (b, aItem) { return !_includesWith(eq, aItem, b); }, b, a); } @@ -2666,60 +2829,58 @@ return false; } - if (a == null || b == null) { - return false; - } - if (typeof a['fantasy-land/equals'] === 'function' || typeof b['fantasy-land/equals'] === 'function') { - return typeof a['fantasy-land/equals'] === 'function' && a['fantasy-land/equals'](b) && - typeof b['fantasy-land/equals'] === 'function' && b['fantasy-land/equals'](a); + return typeof a['fantasy-land/equals'] === 'function' && a['fantasy-land/equals'](b) && typeof b['fantasy-land/equals'] === 'function' && b['fantasy-land/equals'](a); } if (typeof a.equals === 'function' || typeof b.equals === 'function') { - return typeof a.equals === 'function' && a.equals(b) && - typeof b.equals === 'function' && b.equals(a); + return typeof a.equals === 'function' && a.equals(b) && typeof b.equals === 'function' && b.equals(a); } switch (typeA) { case 'Arguments': case 'Array': case 'Object': - if (typeof a.constructor === 'function' && - _functionName(a.constructor) === 'Promise') { + if (typeof a.constructor === 'function' && _functionName(a.constructor) === 'Promise') { return a === b; } + break; + case 'Boolean': case 'Number': case 'String': - if (!(typeof a === typeof b && _objectIs$1(a.valueOf(), b.valueOf()))) { + if (!(_typeof(a) === _typeof(b) && _objectIs$1(a.valueOf(), b.valueOf()))) { return false; } + break; + case 'Date': if (!_objectIs$1(a.valueOf(), b.valueOf())) { return false; } + break; + case 'Error': return a.name === b.name && a.message === b.message; + case 'RegExp': - if (!(a.source === b.source && - a.global === b.global && - a.ignoreCase === b.ignoreCase && - a.multiline === b.multiline && - a.sticky === b.sticky && - a.unicode === b.unicode)) { + if (!(a.source === b.source && a.global === b.global && a.ignoreCase === b.ignoreCase && a.multiline === b.multiline && a.sticky === b.sticky && a.unicode === b.unicode)) { return false; } + break; } var idx = stackA.length - 1; + while (idx >= 0) { if (stackA[idx] === a) { return stackB[idx] === b; } + idx -= 1; } @@ -2730,12 +2891,14 @@ } return _uniqContentEquals(a.entries(), b.entries(), stackA.concat([a]), stackB.concat([b])); + case 'Set': if (a.size !== b.size) { return false; } return _uniqContentEquals(a.values(), b.values(), stackA.concat([a]), stackB.concat([b])); + case 'Arguments': case 'Array': case 'Object': @@ -2756,27 +2919,32 @@ case 'Float64Array': case 'ArrayBuffer': break; + default: // Values of other types are only equal if identical. return false; } var keysA = keys(a); + if (keysA.length !== keys(b).length) { return false; } var extendedStackA = stackA.concat([a]); var extendedStackB = stackB.concat([b]); - idx = keysA.length - 1; + while (idx >= 0) { var key = keysA[idx]; + if (!(_has(key, b) && _equals(b[key], a[key], extendedStackA, extendedStackB))) { return false; } + idx -= 1; } + return true; } @@ -2805,42 +2973,51 @@ * const b = {}; b.v = b; * R.equals(a, b); //=> true */ + var equals = _curry2(function equals(a, b) { return _equals(a, b, [], []); }); function _indexOf(list, a, idx) { - var inf, item; - // Array.prototype.indexOf doesn't exist below IE9 + var inf, item; // Array.prototype.indexOf doesn't exist below IE9 + if (typeof list.indexOf === 'function') { - switch (typeof a) { + switch (_typeof(a)) { case 'number': if (a === 0) { // manually crawl the list to distinguish between +0 and -0 inf = 1 / a; + while (idx < list.length) { item = list[idx]; + if (item === 0 && 1 / item === inf) { return idx; } + idx += 1; } + return -1; } else if (a !== a) { // NaN while (idx < list.length) { item = list[idx]; + if (typeof item === 'number' && item !== item) { return idx; } + idx += 1; } + return -1; - } - // non-zero numbers can utilise Set - return list.indexOf(a, idx); + } // non-zero numbers can utilise Set + + return list.indexOf(a, idx); // all these types can utilise Set + case 'string': case 'boolean': case 'function': @@ -2852,15 +3029,19 @@ // null can utilise Set return list.indexOf(a, idx); } + } - } - // anything else not covered above, defer to R.equals + } // anything else not covered above, defer to R.equals + + while (idx < list.length) { if (equals(list[idx], a)) { return idx; } + idx += 1; } + return -1; } @@ -2869,42 +3050,26 @@ } function _quote(s) { - var escaped = s - .replace(/\\/g, '\\\\') - .replace(/[\b]/g, '\\b') // \b matches word boundary; [\b] matches backspace - .replace(/\f/g, '\\f') - .replace(/\n/g, '\\n') - .replace(/\r/g, '\\r') - .replace(/\t/g, '\\t') - .replace(/\v/g, '\\v') - .replace(/\0/g, '\\0'); - + var escaped = s.replace(/\\/g, '\\\\').replace(/[\b]/g, '\\b') // \b matches word boundary; [\b] matches backspace + .replace(/\f/g, '\\f').replace(/\n/g, '\\n').replace(/\r/g, '\\r').replace(/\t/g, '\\t').replace(/\v/g, '\\v').replace(/\0/g, '\\0'); return '"' + escaped.replace(/"/g, '\\"') + '"'; } /** * Polyfill from . */ - var pad = function pad(n) { return (n < 10 ? '0' : '') + n; }; - - var _toISOString = typeof Date.prototype.toISOString === 'function' ? - function _toISOString(d) { - return d.toISOString(); - } : - function _toISOString(d) { - return ( - d.getUTCFullYear() + '-' + - pad(d.getUTCMonth() + 1) + '-' + - pad(d.getUTCDate()) + 'T' + - pad(d.getUTCHours()) + ':' + - pad(d.getUTCMinutes()) + ':' + - pad(d.getUTCSeconds()) + '.' + - (d.getUTCMilliseconds() / 1000).toFixed(3).slice(2, 5) + 'Z' - ); - }; + var pad = function pad(n) { + return (n < 10 ? '0' : '') + n; + }; + + var _toISOString = typeof Date.prototype.toISOString === 'function' ? function _toISOString(d) { + return d.toISOString(); + } : function _toISOString(d) { + return d.getUTCFullYear() + '-' + pad(d.getUTCMonth() + 1) + '-' + pad(d.getUTCDate()) + 'T' + pad(d.getUTCHours()) + ':' + pad(d.getUTCMinutes()) + ':' + pad(d.getUTCSeconds()) + '.' + (d.getUTCMilliseconds() / 1000).toFixed(3).slice(2, 5) + 'Z'; + }; function _complement(f) { - return function() { + return function () { return !f.apply(this, arguments); }; } @@ -2918,8 +3083,10 @@ if (fn(list[idx])) { result[result.length] = list[idx]; } + idx += 1; } + return result; } @@ -2931,13 +3098,17 @@ this.xf = xf; this.f = f; } + XFilter.prototype['@@transducer/init'] = _xfBase.init; XFilter.prototype['@@transducer/result'] = _xfBase.result; - XFilter.prototype['@@transducer/step'] = function(result, input) { + + XFilter.prototype['@@transducer/step'] = function (result, input) { return this.f(input) ? this.xf['@@transducer/step'](result, input) : result; }; - var _xfilter = _curry2(function _xfilter(f, xf) { return new XFilter(f, xf); }); + var _xfilter = _curry2(function _xfilter(f, xf) { + return new XFilter(f, xf); + }); /** * Takes a predicate and a `Filterable`, and returns a new filterable of the @@ -2966,18 +3137,16 @@ * * R.filter(isEven, {a: 1, b: 2, c: 3, d: 4}); //=> {b: 2, d: 4} */ - var filter = _curry2(_dispatchable(['filter'], _xfilter, function(pred, filterable) { - return ( - _isObject(filterable) ? - _reduce(function(acc, key) { - if (pred(filterable[key])) { - acc[key] = filterable[key]; - } - return acc; - }, {}, keys(filterable)) : - // else - _filter(pred, filterable) - ); + + var filter = _curry2(_dispatchable(['fantasy-land/filter', 'filter'], _xfilter, function (pred, filterable) { + return _isObject(filterable) ? _reduce(function (acc, key) { + if (pred(filterable[key])) { + acc[key] = filterable[key]; + } + + return acc; + }, {}, keys(filterable)) : // else + _filter(pred, filterable); })); /** @@ -3004,6 +3173,7 @@ * * R.reject(isOdd, {a: 1, b: 2, c: 3, d: 4}); //=> {b: 2, d: 4} */ + var reject = _curry2(function reject(pred, filterable) { return filter(_complement(pred), filterable); }); @@ -3012,37 +3182,51 @@ var recur = function recur(y) { var xs = seen.concat([x]); return _includes(y, xs) ? '' : _toString(y, xs); - }; + }; // mapPairs :: (Object, [String]) -> [String] + - // mapPairs :: (Object, [String]) -> [String] - var mapPairs = function(obj, keys$$1) { - return _map(function(k) { return _quote(k) + ': ' + recur(obj[k]); }, keys$$1.slice().sort()); + var mapPairs = function mapPairs(obj, keys) { + return _map(function (k) { + return _quote(k) + ': ' + recur(obj[k]); + }, keys.slice().sort()); }; switch (Object.prototype.toString.call(x)) { case '[object Arguments]': return '(function() { return arguments; }(' + _map(recur, x).join(', ') + '))'; + case '[object Array]': - return '[' + _map(recur, x).concat(mapPairs(x, reject(function(k) { return /^\d+$/.test(k); }, keys(x)))).join(', ') + ']'; + return '[' + _map(recur, x).concat(mapPairs(x, reject(function (k) { + return /^\d+$/.test(k); + }, keys(x)))).join(', ') + ']'; + case '[object Boolean]': - return typeof x === 'object' ? 'new Boolean(' + recur(x.valueOf()) + ')' : x.toString(); + return _typeof(x) === 'object' ? 'new Boolean(' + recur(x.valueOf()) + ')' : x.toString(); + case '[object Date]': return 'new Date(' + (isNaN(x.valueOf()) ? recur(NaN) : _quote(_toISOString(x))) + ')'; + case '[object Null]': return 'null'; + case '[object Number]': - return typeof x === 'object' ? 'new Number(' + recur(x.valueOf()) + ')' : 1 / x === -Infinity ? '-0' : x.toString(10); + return _typeof(x) === 'object' ? 'new Number(' + recur(x.valueOf()) + ')' : 1 / x === -Infinity ? '-0' : x.toString(10); + case '[object String]': - return typeof x === 'object' ? 'new String(' + recur(x.valueOf()) + ')' : _quote(x); + return _typeof(x) === 'object' ? 'new String(' + recur(x.valueOf()) + ')' : _quote(x); + case '[object Undefined]': return 'undefined'; + default: if (typeof x.toString === 'function') { var repr = x.toString(); + if (repr !== '[object Object]') { return repr; } } + return '{' + mapPairs(x, keys(x)).join(', ') + '}'; } } @@ -3083,7 +3267,10 @@ * R.toString({foo: 1, bar: 2, baz: 3}); //=> '{"bar": 2, "baz": 3, "foo": 1}' * R.toString(new Date('2001-02-03T04:05:06Z')); //=> 'new Date("2001-02-03T04:05:06.000Z")' */ - var toString$1 = _curry1(function toString(val) { return _toString(val, []); }); + + var toString$1 = _curry1(function toString(val) { + return _toString(val, []); + }); /** * Returns the result of concatenating the given lists or strings. @@ -3113,25 +3300,32 @@ * R.concat([4, 5, 6], [1, 2, 3]); //=> [4, 5, 6, 1, 2, 3] * R.concat([], []); //=> [] */ + var concat = _curry2(function concat(a, b) { if (_isArray(a)) { if (_isArray(b)) { return a.concat(b); } + throw new TypeError(toString$1(b) + ' is not an array'); } + if (_isString(a)) { if (_isString(b)) { return a + b; } + throw new TypeError(toString$1(b) + ' is not a string'); } + if (a != null && _isFunction(a['fantasy-land/concat'])) { return a['fantasy-land/concat'](b); } + if (a != null && _isFunction(a.concat)) { return a.concat(b); } + throw new TypeError(toString$1(a) + ' does not have a method named "concat" or "fantasy-land/concat"'); }); @@ -3143,6 +3337,10 @@ * arguments to the corresponding transformer. If none of the predicates * matches, `fn` returns undefined. * + * **Please note**: This is not a direct substitute for a `switch` statement. + * Remember that both elements of every pair passed to `cond` are *functions*, + * and `cond` returns a function. + * * @func * @memberOf R * @since v0.6.0 @@ -3162,23 +3360,70 @@ * fn(50); //=> 'nothing special happens at 50°C' * fn(100); //=> 'water boils at 100°C' */ + var cond = _curry1(function cond(pairs) { - var arity = reduce( - max, - 0, - map(function(pair) { return pair[0].length; }, pairs) - ); - return _arity(arity, function() { + var arity = reduce(max, 0, map(function (pair) { + return pair[0].length; + }, pairs)); + return _arity(arity, function () { var idx = 0; + while (idx < pairs.length) { if (pairs[idx][0].apply(this, arguments)) { return pairs[idx][1].apply(this, arguments); } + idx += 1; } }); }); + /** + * Returns a curried equivalent of the provided function. The curried function + * has two unusual capabilities. First, its arguments needn't be provided one + * at a time. If `f` is a ternary function and `g` is `R.curry(f)`, the + * following are equivalent: + * + * - `g(1)(2)(3)` + * - `g(1)(2, 3)` + * - `g(1, 2)(3)` + * - `g(1, 2, 3)` + * + * Secondly, the special placeholder value [`R.__`](#__) may be used to specify + * "gaps", allowing partial application of any combination of arguments, + * regardless of their positions. If `g` is as above and `_` is [`R.__`](#__), + * the following are equivalent: + * + * - `g(1, 2, 3)` + * - `g(_, 2, 3)(1)` + * - `g(_, _, 3)(1)(2)` + * - `g(_, _, 3)(1, 2)` + * - `g(_, 2)(1)(3)` + * - `g(_, 2)(1, 3)` + * - `g(_, 2)(_, 3)(1)` + * + * @func + * @memberOf R + * @since v0.1.0 + * @category Function + * @sig (* -> a) -> (* -> a) + * @param {Function} fn The function to curry. + * @return {Function} A new, curried function. + * @see R.curryN, R.partial + * @example + * + * const addFourNumbers = (a, b, c, d) => a + b + c + d; + * + * const curriedAddFourNumbers = R.curry(addFourNumbers); + * const f = curriedAddFourNumbers(1, 2); + * const g = f(3); + * g(4); //=> 10 + */ + + var curry = _curry1(function curry(fn) { + return curryN(fn.length, fn); + }); + /** * Wraps a constructor function inside a curried function that can be called * with the same arguments and returns the same type. The arity of the function @@ -3214,25 +3459,49 @@ * // Add a dollop of Potato Chips * // Add a dollop of Ketchup */ + var constructN = _curry2(function constructN(n, Fn) { if (n > 10) { throw new Error('Constructor with greater than ten arguments'); } + if (n === 0) { - return function() { return new Fn(); }; + return function () { + return new Fn(); + }; } - return curry(nAry(n, function($0, $1, $2, $3, $4, $5, $6, $7, $8, $9) { + + return curry(nAry(n, function ($0, $1, $2, $3, $4, $5, $6, $7, $8, $9) { switch (arguments.length) { - case 1: return new Fn($0); - case 2: return new Fn($0, $1); - case 3: return new Fn($0, $1, $2); - case 4: return new Fn($0, $1, $2, $3); - case 5: return new Fn($0, $1, $2, $3, $4); - case 6: return new Fn($0, $1, $2, $3, $4, $5); - case 7: return new Fn($0, $1, $2, $3, $4, $5, $6); - case 8: return new Fn($0, $1, $2, $3, $4, $5, $6, $7); - case 9: return new Fn($0, $1, $2, $3, $4, $5, $6, $7, $8); - case 10: return new Fn($0, $1, $2, $3, $4, $5, $6, $7, $8, $9); + case 1: + return new Fn($0); + + case 2: + return new Fn($0, $1); + + case 3: + return new Fn($0, $1, $2); + + case 4: + return new Fn($0, $1, $2, $3); + + case 5: + return new Fn($0, $1, $2, $3, $4); + + case 6: + return new Fn($0, $1, $2, $3, $4, $5); + + case 7: + return new Fn($0, $1, $2, $3, $4, $5, $6); + + case 8: + return new Fn($0, $1, $2, $3, $4, $5, $6, $7); + + case 9: + return new Fn($0, $1, $2, $3, $4, $5, $6, $7, $8); + + case 10: + return new Fn($0, $1, $2, $3, $4, $5, $6, $7, $8, $9); } })); }); @@ -3269,35 +3538,11 @@ * const sightNewAnimal = R.compose(animalSighting, AnimalConstructor); * R.map(sightNewAnimal, animalTypes); //=> ["It's a Lion!", "It's a Tiger!", "It's a Bear!"] */ + var construct = _curry1(function construct(Fn) { return constructN(Fn.length, Fn); }); - /** - * Returns `true` if the specified value is equal, in [`R.equals`](#equals) - * terms, to at least one element of the given list; `false` otherwise. - * Works also with strings. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category List - * @sig a -> [a] -> Boolean - * @param {Object} a The item to compare against. - * @param {Array} list The array to consider. - * @return {Boolean} `true` if an equivalent item is in the list, `false` otherwise. - * @see R.includes - * @deprecated since v0.26.0 - * @example - * - * R.contains(3, [1, 2, 3]); //=> true - * R.contains(4, [1, 2, 3]); //=> false - * R.contains({ name: 'Fred' }, [{ name: 'Fred' }]); //=> true - * R.contains([42], [[42]]); //=> true - * R.contains('ba', 'banana'); //=>true - */ - var contains$1 = _curry2(_includes); - /** * Accepts a converging function and a list of branching functions and returns * a new function. The arity of the new function is the same as the arity of @@ -3326,16 +3571,41 @@ * * @symb R.converge(f, [g, h])(a, b) = f(g(a, b), h(a, b)) */ + var converge = _curry2(function converge(after, fns) { - return curryN(reduce(max, 0, pluck('length', fns)), function() { + return curryN(reduce(max, 0, pluck('length', fns)), function () { var args = arguments; var context = this; - return after.apply(context, _map(function(fn) { + return after.apply(context, _map(function (fn) { return fn.apply(context, args); }, fns)); }); }); + /** + * Returns the number of items in a given `list` matching the predicate `f` + * + * @func + * @memberOf R + * @since v0.28.0 + * @category List + * @sig (a -> Boolean) -> [a] -> Number + * @param {Function} predicate to match items against + * @return {Array} list of items to count in + * @example + * + * const even = x => x % 2 == 0; + * + * R.count(even, [1, 2, 3, 4, 5]); // => 2 + * R.map(R.count(even), [[1, 1, 1], [2, 3, 4, 5], [6]]); // => [0, 2, 1] + */ + + var count = curry(function (pred, list) { + return _reduce(function (a, e) { + return pred(e) ? a + 1 : a; + }, 0, list); + }); + function XReduceBy(valueFn, valueAcc, keyFn, xf) { this.valueFn = valueFn; this.valueAcc = valueAcc; @@ -3343,39 +3613,46 @@ this.xf = xf; this.inputs = {}; } + XReduceBy.prototype['@@transducer/init'] = _xfBase.init; - XReduceBy.prototype['@@transducer/result'] = function(result) { + + XReduceBy.prototype['@@transducer/result'] = function (result) { var key; + for (key in this.inputs) { if (_has(key, this.inputs)) { result = this.xf['@@transducer/step'](result, this.inputs[key]); + if (result['@@transducer/reduced']) { result = result['@@transducer/value']; break; } } } + this.inputs = null; return this.xf['@@transducer/result'](result); }; - XReduceBy.prototype['@@transducer/step'] = function(result, input) { + + XReduceBy.prototype['@@transducer/step'] = function (result, input) { var key = this.keyFn(input); this.inputs[key] = this.inputs[key] || [key, this.valueAcc]; this.inputs[key][1] = this.valueFn(this.inputs[key][1], input); return result; }; - var _xreduceBy = _curryN(4, [], - function _xreduceBy(valueFn, valueAcc, keyFn, xf) { - return new XReduceBy(valueFn, valueAcc, keyFn, xf); - } - ); + var _xreduceBy = _curryN(4, [], function _xreduceBy(valueFn, valueAcc, keyFn, xf) { + return new XReduceBy(valueFn, valueAcc, keyFn, xf); + }); /** * Groups the elements of the list according to the result of calling * the String-returning function `keyFn` on each element and reduces the elements * of each group to a single value via the reducer function `valueFn`. * + * The value function receives two values: *(acc, value)*. It may use + * [`R.reduced`](#reduced) to short circuit the iteration. + * * This function is basically a more general [`groupBy`](#groupBy) function. * * Acts as a transducer if a transformer is given in list position. @@ -3392,7 +3669,7 @@ * @param {Array} list The array to group. * @return {Object} An object with the output of `keyFn` for keys, mapped to the output of * `valueFn` for elements which produced that key when passed to `keyFn`. - * @see R.groupBy, R.reduce + * @see R.groupBy, R.reduce, R.reduced * @example * * const groupNames = (acc, {name}) => acc.concat(name) @@ -3412,14 +3689,20 @@ * reduceBy(groupNames, [], toGrade, students) * //=> {"A": ["Dora"], "B": ["Abby", "Curt"], "F": ["Bart"]} */ - var reduceBy = _curryN(4, [], _dispatchable([], _xreduceBy, - function reduceBy(valueFn, valueAcc, keyFn, list) { - return _reduce(function(acc, elt) { - var key = keyFn(elt); - acc[key] = valueFn(_has(key, acc) ? acc[key] : _clone(valueAcc, [], [], false), elt); - return acc; - }, {}, list); - })); + + var reduceBy = _curryN(4, [], _dispatchable([], _xreduceBy, function reduceBy(valueFn, valueAcc, keyFn, list) { + return _reduce(function (acc, elt) { + var key = keyFn(elt); + var value = valueFn(_has(key, acc) ? acc[key] : _clone(valueAcc, [], [], false), elt); + + if (value && value['@@transducer/reduced']) { + return _reduced(acc); + } + + acc[key] = value; + return acc; + }, {}, list); + })); /** * Counts the elements of a list according to how many match each value of a @@ -3445,7 +3728,10 @@ * const letters = ['a', 'b', 'A', 'a', 'B', 'c']; * R.countBy(R.toLower)(letters); //=> {'a': 3, 'b': 2, 'c': 1} */ - var countBy = reduceBy(function(acc, elem) { return acc + 1; }, 0); + + var countBy = reduceBy(function (acc, elem) { + return acc + 1; + }, 0); /** * Decrements its argument. @@ -3462,6 +3748,7 @@ * * R.dec(42); //=> 41 */ + var dec = add(-1); /** @@ -3487,6 +3774,7 @@ * // parseInt('string') results in NaN * defaultTo42(parseInt('string')); //=> 42 */ + var defaultTo = _curry2(function defaultTo(d, v) { return v == null || v !== v ? d : v; }); @@ -3516,6 +3804,7 @@ * const peopleByOldestFirst = R.sort(byAge, people); * //=> [{ name: 'Peter', age: 78 }, { name: 'Emma', age: 70 }, { name: 'Mikhail', age: 62 }] */ + var descend = _curry3(function descend(fn, a, b) { var aa = fn(a); var bb = fn(b); @@ -3526,25 +3815,23 @@ /* globals Set */ this._nativeSet = typeof Set === 'function' ? new Set() : null; this._items = {}; - } - - // until we figure out why jsdoc chokes on this + } // until we figure out why jsdoc chokes on this // @param item The item to add to the Set // @returns {boolean} true if the item did not exist prior, otherwise false // - _Set.prototype.add = function(item) { - return !hasOrAdd(item, true, this); - }; - // + + _Set.prototype.add = function (item) { + return !hasOrAdd(item, true, this); + }; // // @param item The item to check for existence in the Set // @returns {boolean} true if the item exists in the Set, otherwise false // - _Set.prototype.has = function(item) { - return hasOrAdd(item, false, this); - }; - // + + _Set.prototype.has = function (item) { + return hasOrAdd(item, false, this); + }; // // Combines the logic for checking whether an item is a member of the set and // for adding a new item to the set. // @@ -3554,9 +3841,13 @@ // @param set The set instance to check or add to. // @return {boolean} true if the item already existed, otherwise false. // + + function hasOrAdd(item, shouldAdd, set) { - var type = typeof item; + var type = _typeof(item); + var prevSize, newSize; + switch (type) { case 'string': case 'number': @@ -3568,14 +3859,18 @@ if (shouldAdd) { set._items['-0'] = true; } + return false; } - } - // these types can all utilise the native Set + } // these types can all utilise the native Set + + if (set._nativeSet !== null) { if (shouldAdd) { prevSize = set._nativeSet.size; + set._nativeSet.add(item); + newSize = set._nativeSet.size; return newSize === prevSize; } else { @@ -3587,6 +3882,7 @@ set._items[type] = {}; set._items[type][item] = true; } + return false; } else if (item in set._items[type]) { return true; @@ -3594,6 +3890,7 @@ if (shouldAdd) { set._items[type][item] = true; } + return false; } } @@ -3603,18 +3900,21 @@ // representing [ falseExists, trueExists ] if (type in set._items) { var bIdx = item ? 1 : 0; + if (set._items[type][bIdx]) { return true; } else { if (shouldAdd) { set._items[type][bIdx] = true; } + return false; } } else { if (shouldAdd) { set._items[type] = item ? [false, true] : [true, false]; } + return false; } @@ -3623,7 +3923,9 @@ if (set._nativeSet !== null) { if (shouldAdd) { prevSize = set._nativeSet.size; + set._nativeSet.add(item); + newSize = set._nativeSet.size; return newSize === prevSize; } else { @@ -3634,14 +3936,18 @@ if (shouldAdd) { set._items[type] = [item]; } + return false; } + if (!_includes(item, set._items[type])) { if (shouldAdd) { set._items[type].push(item); } + return false; } + return true; } @@ -3652,6 +3958,7 @@ if (shouldAdd) { set._items[type] = true; } + return false; } @@ -3661,31 +3968,40 @@ if (shouldAdd) { set._items['null'] = true; } + return false; } + return true; } + /* falls through */ + default: // reduce the search size of heterogeneous sets by creating buckets // for each type. type = Object.prototype.toString.call(item); + if (!(type in set._items)) { if (shouldAdd) { set._items[type] = [item]; } + return false; - } - // scan through all previously applied items + } // scan through all previously applied items + + if (!_includes(item, set._items[type])) { if (shouldAdd) { set._items[type].push(item); } + return false; } + return true; } - } + } // A simple Set type that honours R.equals semantics /** * Finds the set (i.e. no duplicates) of all elements in the first list not @@ -3707,6 +4023,7 @@ * R.difference([7,6,5,4,3], [1,2,3,4]); //=> [7,6,5] * R.difference([{a: 1}, {b: 2}], [{a: 1}, {c: 3}]) //=> [{b: 2}] */ + var difference = _curry2(function difference(first, second) { var out = []; var idx = 0; @@ -3722,8 +4039,10 @@ if (toFilterOut.add(first[idx])) { out[out.length] = first[idx]; } + idx += 1; } + return out; }); @@ -3749,43 +4068,21 @@ * const l2 = [{a: 3}, {a: 4}]; * R.differenceWith(cmp, l1, l2); //=> [{a: 1}, {a: 2}] */ + var differenceWith = _curry3(function differenceWith(pred, first, second) { var out = []; var idx = 0; var firstLen = first.length; + while (idx < firstLen) { - if (!_includesWith(pred, first[idx], second) && - !_includesWith(pred, first[idx], out)) { + if (!_includesWith(pred, first[idx], second) && !_includesWith(pred, first[idx], out)) { out.push(first[idx]); } + idx += 1; } - return out; - }); - /** - * Returns a new object that does not contain a `prop` property. - * - * @func - * @memberOf R - * @since v0.10.0 - * @category Object - * @sig String -> {k: v} -> {k: v} - * @param {String} prop The name of the property to dissociate - * @param {Object} obj The object to clone - * @return {Object} A new object equivalent to the original but without the specified property - * @see R.assoc, R.omit - * @example - * - * R.dissoc('b', {a: 1, b: 2, c: 3}); //=> {a: 1, c: 3} - */ - var dissoc = _curry2(function dissoc(prop, obj) { - var result = {}; - for (var p in obj) { - result[p] = obj[p]; - } - delete result[prop]; - return result; + return out; }); /** @@ -3808,6 +4105,7 @@ * * R.remove(2, 3, [1,2,3,4,5,6,7,8]); //=> [1,2,6,7,8] */ + var remove = _curry3(function remove(start, count, list) { var result = Array.prototype.slice.call(list, 0); result.splice(start, count); @@ -3815,31 +4113,57 @@ }); /** - * Returns a new copy of the array with the element at the provided index - * replaced with the given value. + * Returns a new object that does not contain a `prop` property. * - * @func - * @memberOf R - * @since v0.14.0 - * @category List - * @sig Number -> a -> [a] -> [a] - * @param {Number} idx The index to update. - * @param {*} x The value to exist at the given index of the returned array. - * @param {Array|Arguments} list The source array-like object to be updated. - * @return {Array} A copy of `list` with the value at index `idx` replaced with `x`. - * @see R.adjust - * @example + * @private + * @param {String|Number} prop The name of the property to dissociate + * @param {Object|Array} obj The object to clone + * @return {Object} A new object equivalent to the original but without the specified property + */ + + function _dissoc(prop, obj) { + if (obj == null) { + return obj; + } + + if (_isInteger(prop) && _isArray(obj)) { + return remove(prop, 1, obj); + } + + var result = {}; + + for (var p in obj) { + result[p] = obj[p]; + } + + delete result[prop]; + return result; + } + + /** + * Makes a shallow clone of an object. Note that this copies and flattens + * prototype properties onto the new object as well. All non-primitive + * properties are copied by reference. * - * R.update(1, '_', ['a', 'b', 'c']); //=> ['a', '_', 'c'] - * R.update(-1, '_', ['a', 'b', 'c']); //=> ['a', 'b', '_'] - * @symb R.update(-1, a, [b, c]) = [b, a] - * @symb R.update(0, a, [b, c]) = [a, c] - * @symb R.update(1, a, [b, c]) = [b, a] + * @private + * @param {String|Integer} prop The prop operating + * @param {Object|Array} obj The object to clone + * @return {Object|Array} A new object equivalent to the original. */ - var update = _curry3(function update(idx, x, list) { - return adjust(idx, always(x), list); - }); + function _shallowCloneObject(prop, obj) { + if (_isInteger(prop) && _isArray(obj)) { + return [].concat(obj); + } + + var result = {}; + + for (var p in obj) { + result[p] = obj[p]; + } + + return result; + } /** * Makes a shallow clone of an object, omitting the property at the given path. * Note that this copies and flattens prototype properties onto the new object @@ -3849,7 +4173,7 @@ * @memberOf R * @since v0.11.0 * @category Object - * @typedefn Idx = String | Int + * @typedefn Idx = String | Int | Symbol * @sig [Idx] -> {k: v} -> {k: v} * @param {Array} path The path to the value to omit * @param {Object} obj The object to clone @@ -3859,25 +4183,54 @@ * * R.dissocPath(['a', 'b', 'c'], {a: {b: {c: 42}}}); //=> {a: {b: {}}} */ + + var dissocPath = _curry2(function dissocPath(path, obj) { + if (obj == null) { + return obj; + } + switch (path.length) { case 0: return obj; + case 1: - return _isInteger(path[0]) && _isArray(obj) ? remove(path[0], 1, obj) : dissoc(path[0], obj); + return _dissoc(path[0], obj); + default: var head = path[0]; var tail = Array.prototype.slice.call(path, 1); + if (obj[head] == null) { - return obj; - } else if (_isInteger(head) && _isArray(obj)) { - return update(head, dissocPath(tail, obj[head]), obj); + return _shallowCloneObject(head, obj); } else { return assoc(head, dissocPath(tail, obj[head]), obj); } + } }); + /** + * Returns a new object that does not contain a `prop` property. + * + * @func + * @memberOf R + * @since v0.10.0 + * @category Object + * @sig String -> {k: v} -> {k: v} + * @param {String} prop The name of the property to dissociate + * @param {Object} obj The object to clone + * @return {Object} A new object equivalent to the original but without the specified property + * @see R.assoc, R.omit + * @example + * + * R.dissoc('b', {a: 1, b: 2, c: 3}); //=> {a: 1, c: 3} + */ + + var dissoc = _curry2(function dissoc(prop, obj) { + return dissocPath([prop], obj); + }); + /** * Divides two numbers. Equivalent to `a / b`. * @@ -3900,23 +4253,31 @@ * const reciprocal = R.divide(1); * reciprocal(4); //=> 0.25 */ - var divide = _curry2(function divide(a, b) { return a / b; }); + + var divide = _curry2(function divide(a, b) { + return a / b; + }); function XDrop(n, xf) { this.xf = xf; this.n = n; } + XDrop.prototype['@@transducer/init'] = _xfBase.init; XDrop.prototype['@@transducer/result'] = _xfBase.result; - XDrop.prototype['@@transducer/step'] = function(result, input) { + + XDrop.prototype['@@transducer/step'] = function (result, input) { if (this.n > 0) { this.n -= 1; return result; } + return this.xf['@@transducer/step'](result, input); }; - var _xdrop = _curry2(function _xdrop(n, xf) { return new XDrop(n, xf); }); + var _xdrop = _curry2(function _xdrop(n, xf) { + return new XDrop(n, xf); + }); /** * Returns all but the first `n` elements of the given list, string, or @@ -3942,6 +4303,7 @@ * R.drop(4, ['foo', 'bar', 'baz']); //=> [] * R.drop(3, 'ramda'); //=> 'da' */ + var drop = _curry2(_dispatchable(['drop'], _xdrop, function drop(n, xs) { return slice(Math.max(0, n), Infinity, xs); })); @@ -3951,15 +4313,19 @@ this.n = n; this.i = 0; } + XTake.prototype['@@transducer/init'] = _xfBase.init; XTake.prototype['@@transducer/result'] = _xfBase.result; - XTake.prototype['@@transducer/step'] = function(result, input) { + + XTake.prototype['@@transducer/step'] = function (result, input) { this.i += 1; var ret = this.n === 0 ? result : this.xf['@@transducer/step'](result, input); return this.n >= 0 && this.i >= this.n ? _reduced(ret) : ret; }; - var _xtake = _curry2(function _xtake(n, xf) { return new XTake(n, xf); }); + var _xtake = _curry2(function _xtake(n, xf) { + return new XTake(n, xf); + }); /** * Returns the first `n` elements of the given list, string, or @@ -4004,6 +4370,7 @@ * @symb R.take(1, [a, b]) = [a] * @symb R.take(2, [a, b]) = [a, b] */ + var take = _curry2(_dispatchable(['take'], _xtake, function take(n, xs) { return slice(0, n < 0 ? Infinity : n, xs); })); @@ -4018,28 +4385,36 @@ this.full = false; this.acc = new Array(n); } + XDropLast.prototype['@@transducer/init'] = _xfBase.init; - XDropLast.prototype['@@transducer/result'] = function(result) { + + XDropLast.prototype['@@transducer/result'] = function (result) { this.acc = null; return this.xf['@@transducer/result'](result); }; - XDropLast.prototype['@@transducer/step'] = function(result, input) { + + XDropLast.prototype['@@transducer/step'] = function (result, input) { if (this.full) { result = this.xf['@@transducer/step'](result, this.acc[this.pos]); } + this.store(input); return result; }; - XDropLast.prototype.store = function(input) { + + XDropLast.prototype.store = function (input) { this.acc[this.pos] = input; this.pos += 1; + if (this.pos === this.acc.length) { this.pos = 0; this.full = true; } }; - var _xdropLast = _curry2(function _xdropLast(n, xf) { return new XDropLast(n, xf); }); + var _xdropLast = _curry2(function _xdropLast(n, xf) { + return new XDropLast(n, xf); + }); /** * Returns a list containing all but the last `n` elements of the given `list`. @@ -4064,13 +4439,16 @@ * R.dropLast(4, ['foo', 'bar', 'baz']); //=> [] * R.dropLast(3, 'ramda'); //=> 'ra' */ + var dropLast$1 = _curry2(_dispatchable([], _xdropLast, dropLast)); function dropLastWhile(pred, xs) { var idx = xs.length - 1; + while (idx >= 0 && pred(xs[idx])) { idx -= 1; } + return slice(0, idx + 1, xs); } @@ -4079,31 +4457,32 @@ this.retained = []; this.xf = xf; } + XDropLastWhile.prototype['@@transducer/init'] = _xfBase.init; - XDropLastWhile.prototype['@@transducer/result'] = function(result) { + + XDropLastWhile.prototype['@@transducer/result'] = function (result) { this.retained = null; return this.xf['@@transducer/result'](result); }; - XDropLastWhile.prototype['@@transducer/step'] = function(result, input) { - return this.f(input) - ? this.retain(result, input) - : this.flush(result, input); + + XDropLastWhile.prototype['@@transducer/step'] = function (result, input) { + return this.f(input) ? this.retain(result, input) : this.flush(result, input); }; - XDropLastWhile.prototype.flush = function(result, input) { - result = _reduce( - this.xf['@@transducer/step'], - result, - this.retained - ); + + XDropLastWhile.prototype.flush = function (result, input) { + result = _reduce(this.xf['@@transducer/step'], result, this.retained); this.retained = []; return this.xf['@@transducer/step'](result, input); }; - XDropLastWhile.prototype.retain = function(result, input) { + + XDropLastWhile.prototype.retain = function (result, input) { this.retained.push(input); return result; }; - var _xdropLastWhile = _curry2(function _xdropLastWhile(fn, xf) { return new XDropLastWhile(fn, xf); }); + var _xdropLastWhile = _curry2(function _xdropLastWhile(fn, xf) { + return new XDropLastWhile(fn, xf); + }); /** * Returns a new list excluding all the tailing elements of a given list which @@ -4132,6 +4511,7 @@ * * R.dropLastWhile(x => x !== 'd' , 'Ramda'); //=> 'Ramd' */ + var dropLastWhile$1 = _curry2(_dispatchable([], _xdropLastWhile, dropLastWhile)); function XDropRepeatsWith(pred, xf) { @@ -4143,18 +4523,23 @@ XDropRepeatsWith.prototype['@@transducer/init'] = _xfBase.init; XDropRepeatsWith.prototype['@@transducer/result'] = _xfBase.result; - XDropRepeatsWith.prototype['@@transducer/step'] = function(result, input) { + + XDropRepeatsWith.prototype['@@transducer/step'] = function (result, input) { var sameAsLast = false; + if (!this.seenFirstValue) { this.seenFirstValue = true; } else if (this.pred(this.lastValue, input)) { sameAsLast = true; } + this.lastValue = input; return sameAsLast ? result : this.xf['@@transducer/step'](result, input); }; - var _xdropRepeatsWith = _curry2(function _xdropRepeatsWith(pred, xf) { return new XDropRepeatsWith(pred, xf); }); + var _xdropRepeatsWith = _curry2(function _xdropRepeatsWith(pred, xf) { + return new XDropRepeatsWith(pred, xf); + }); /** * Returns the last element of the given list or string. @@ -4176,6 +4561,7 @@ * R.last('abc'); //=> 'c' * R.last(''); //=> '' */ + var last = nth(-1); /** @@ -4199,19 +4585,24 @@ * const l = [1, -1, 1, 3, 4, -4, -4, -5, 5, 3, 3]; * R.dropRepeatsWith(R.eqBy(Math.abs), l); //=> [1, 3, 4, -5, 3] */ + var dropRepeatsWith = _curry2(_dispatchable([], _xdropRepeatsWith, function dropRepeatsWith(pred, list) { var result = []; var idx = 1; var len = list.length; + if (len !== 0) { result[0] = list[0]; + while (idx < len) { if (!pred(last(result), list[idx])) { result[result.length] = list[idx]; } + idx += 1; } } + return result; })); @@ -4233,27 +4624,32 @@ * * R.dropRepeats([1, 1, 1, 2, 3, 4, 4, 2, 2]); //=> [1, 2, 3, 4, 2] */ - var dropRepeats = _curry1( - _dispatchable([], _xdropRepeatsWith(equals), dropRepeatsWith(equals)) - ); + + var dropRepeats = _curry1(_dispatchable([], _xdropRepeatsWith(equals), dropRepeatsWith(equals))); function XDropWhile(f, xf) { this.xf = xf; this.f = f; } + XDropWhile.prototype['@@transducer/init'] = _xfBase.init; XDropWhile.prototype['@@transducer/result'] = _xfBase.result; - XDropWhile.prototype['@@transducer/step'] = function(result, input) { + + XDropWhile.prototype['@@transducer/step'] = function (result, input) { if (this.f) { if (this.f(input)) { return result; } + this.f = null; } + return this.xf['@@transducer/step'](result, input); }; - var _xdropWhile = _curry2(function _xdropWhile(f, xf) { return new XDropWhile(f, xf); }); + var _xdropWhile = _curry2(function _xdropWhile(f, xf) { + return new XDropWhile(f, xf); + }); /** * Returns a new list excluding the leading elements of a given list which @@ -4283,18 +4679,21 @@ * * R.dropWhile(x => x !== 'd' , 'Ramda'); //=> 'da' */ + var dropWhile = _curry2(_dispatchable(['dropWhile'], _xdropWhile, function dropWhile(pred, xs) { var idx = 0; var len = xs.length; + while (idx < len && pred(xs[idx])) { idx += 1; } + return slice(idx, Infinity, xs); })); /** - * Returns `true` if one or both of its arguments are `true`. Returns `false` - * if both arguments are `false`. + * Returns the first argument if it is truthy, otherwise the second argument. + * Acts as the boolean `or` statement if both inputs are `Boolean`s. * * @func * @memberOf R @@ -4303,8 +4702,8 @@ * @sig a -> b -> a | b * @param {Any} a * @param {Any} b - * @return {Any} the first argument if truthy, otherwise the second argument. - * @see R.either, R.xor + * @return {Any} + * @see R.either, R.and * @example * * R.or(true, true); //=> true @@ -4312,6 +4711,7 @@ * R.or(false, true); //=> true * R.or(false, false); //=> false */ + var or = _curry2(function or(a, b) { return a || b; }); @@ -4334,7 +4734,7 @@ * @param {Function} f a predicate * @param {Function} g another predicate * @return {Function} a function that applies its arguments to `f` and `g` and `||`s their outputs together. - * @see R.or + * @see R.both, R.or * @example * * const gt10 = x => x > 10; @@ -4346,17 +4746,36 @@ * R.either(Maybe.Just(false), Maybe.Just(55)); // => Maybe.Just(55) * R.either([false, false, 'a'], [11]) // => [11, 11, "a"] */ + var either = _curry2(function either(f, g) { - return _isFunction(f) ? - function _either() { - return f.apply(this, arguments) || g.apply(this, arguments); - } : - lift(or)(f, g); + return _isFunction(f) ? function _either() { + return f.apply(this, arguments) || g.apply(this, arguments); + } : lift(or)(f, g); }); + /** + * Tests whether or not an object is a typed array. + * + * @private + * @param {*} val The object to test. + * @return {Boolean} `true` if `val` is a typed array, `false` otherwise. + * @example + * + * _isTypedArray(new Uint8Array([])); //=> true + * _isTypedArray(new Float32Array([])); //=> true + * _isTypedArray([]); //=> false + * _isTypedArray(null); //=> false + * _isTypedArray({}); //=> false + */ + function _isTypedArray(val) { + var type = Object.prototype.toString.call(val); + return type === '[object Uint8ClampedArray]' || type === '[object Int8Array]' || type === '[object Uint8Array]' || type === '[object Int16Array]' || type === '[object Uint16Array]' || type === '[object Int32Array]' || type === '[object Uint32Array]' || type === '[object Float32Array]' || type === '[object Float64Array]' || type === '[object BigInt64Array]' || type === '[object BigUint64Array]'; + } + /** * Returns the empty value of its argument's type. Ramda defines the empty - * value of Array (`[]`), Object (`{}`), String (`''`), and Arguments. Other + * value of Array (`[]`), Object (`{}`), String (`''`), + * TypedArray (`Uint8Array []`, `Float32Array []`, etc), and Arguments. Other * types are supported if they define `.empty`, * `.prototype.empty` or implement the * [FantasyLand Monoid spec](https://github.com/fantasyland/fantasy-land#monoid). @@ -4372,31 +4791,18 @@ * @return {*} * @example * - * R.empty(Just(42)); //=> Nothing() - * R.empty([1, 2, 3]); //=> [] - * R.empty('unicorns'); //=> '' - * R.empty({x: 1, y: 2}); //=> {} + * R.empty(Just(42)); //=> Nothing() + * R.empty([1, 2, 3]); //=> [] + * R.empty('unicorns'); //=> '' + * R.empty({x: 1, y: 2}); //=> {} + * R.empty(Uint8Array.from('123')); //=> Uint8Array [] */ + var empty = _curry1(function empty(x) { - return ( - (x != null && typeof x['fantasy-land/empty'] === 'function') - ? x['fantasy-land/empty']() - : (x != null && x.constructor != null && typeof x.constructor['fantasy-land/empty'] === 'function') - ? x.constructor['fantasy-land/empty']() - : (x != null && typeof x.empty === 'function') - ? x.empty() - : (x != null && x.constructor != null && typeof x.constructor.empty === 'function') - ? x.constructor.empty() - : _isArray(x) - ? [] - : _isString(x) - ? '' - : _isObject(x) - ? {} - : _isArguments(x) - ? (function() { return arguments; }()) - : void 0 // else - ); + return x != null && typeof x['fantasy-land/empty'] === 'function' ? x['fantasy-land/empty']() : x != null && x.constructor != null && typeof x.constructor['fantasy-land/empty'] === 'function' ? x.constructor['fantasy-land/empty']() : x != null && typeof x.empty === 'function' ? x.empty() : x != null && x.constructor != null && typeof x.constructor.empty === 'function' ? x.constructor.empty() : _isArray(x) ? [] : _isString(x) ? '' : _isObject(x) ? {} : _isArguments(x) ? function () { + return arguments; + }() : _isTypedArray(x) ? x.constructor.from('') : void 0 // else + ; }); /** @@ -4421,6 +4827,7 @@ * R.takeLast(4, ['foo', 'bar', 'baz']); //=> ['foo', 'bar', 'baz'] * R.takeLast(3, 'ramda'); //=> 'mda' */ + var takeLast = _curry2(function takeLast(n, xs) { return drop(n >= 0 ? xs.length - n : 0, xs); }); @@ -4447,7 +4854,8 @@ * R.endsWith(['c'], ['a', 'b', 'c']) //=> true * R.endsWith(['b'], ['a', 'b', 'c']) //=> false */ - var endsWith = _curry2(function(suffix, list) { + + var endsWith = _curry2(function (suffix, list) { return equals(takeLast(suffix.length, list), suffix); }); @@ -4468,6 +4876,7 @@ * * R.eqBy(Math.abs, 5, -5); //=> true */ + var eqBy = _curry3(function eqBy(f, x, y) { return equals(f(x), f(y)); }); @@ -4493,6 +4902,7 @@ * R.eqProps('a', o1, o2); //=> false * R.eqProps('c', o1, o2); //=> true */ + var eqProps = _curry3(function eqProps(prop, obj1, obj2) { return equals(obj1[prop], obj2[prop]); }); @@ -4524,18 +4934,21 @@ * }; * R.evolve(transformations, tomato); //=> {firstName: 'Tomato', data: {elapsed: 101, remaining: 1399}, id:123} */ + var evolve = _curry2(function evolve(transformations, object) { + if (!_isObject(object) && !_isArray(object)) { + return object; + } + var result = object instanceof Array ? [] : {}; var transformation, key, type; + for (key in object) { transformation = transformations[key]; - type = typeof transformation; - result[key] = type === 'function' - ? transformation(object[key]) - : transformation && type === 'object' - ? evolve(transformation, object[key]) - : object[key]; + type = _typeof(transformation); + result[key] = type === 'function' ? transformation(object[key]) : transformation && type === 'object' ? evolve(transformation, object[key]) : object[key]; } + return result; }); @@ -4544,22 +4957,29 @@ this.f = f; this.found = false; } + XFind.prototype['@@transducer/init'] = _xfBase.init; - XFind.prototype['@@transducer/result'] = function(result) { + + XFind.prototype['@@transducer/result'] = function (result) { if (!this.found) { result = this.xf['@@transducer/step'](result, void 0); } + return this.xf['@@transducer/result'](result); }; - XFind.prototype['@@transducer/step'] = function(result, input) { + + XFind.prototype['@@transducer/step'] = function (result, input) { if (this.f(input)) { this.found = true; result = _reduced(this.xf['@@transducer/step'](result, input)); } + return result; }; - var _xfind = _curry2(function _xfind(f, xf) { return new XFind(f, xf); }); + var _xfind = _curry2(function _xfind(f, xf) { + return new XFind(f, xf); + }); /** * Returns the first element of the list which matches the predicate, or @@ -4585,13 +5005,16 @@ * R.find(R.propEq('a', 2))(xs); //=> {a: 2} * R.find(R.propEq('a', 4))(xs); //=> undefined */ + var find = _curry2(_dispatchable(['find'], _xfind, function find(fn, list) { var idx = 0; var len = list.length; + while (idx < len) { if (fn(list[idx])) { return list[idx]; } + idx += 1; } })); @@ -4602,23 +5025,31 @@ this.idx = -1; this.found = false; } + XFindIndex.prototype['@@transducer/init'] = _xfBase.init; - XFindIndex.prototype['@@transducer/result'] = function(result) { + + XFindIndex.prototype['@@transducer/result'] = function (result) { if (!this.found) { result = this.xf['@@transducer/step'](result, -1); } + return this.xf['@@transducer/result'](result); }; - XFindIndex.prototype['@@transducer/step'] = function(result, input) { + + XFindIndex.prototype['@@transducer/step'] = function (result, input) { this.idx += 1; + if (this.f(input)) { this.found = true; result = _reduced(this.xf['@@transducer/step'](result, this.idx)); } + return result; }; - var _xfindIndex = _curry2(function _xfindIndex(f, xf) { return new XFindIndex(f, xf); }); + var _xfindIndex = _curry2(function _xfindIndex(f, xf) { + return new XFindIndex(f, xf); + }); /** * Returns the index of the first element of the list which matches the @@ -4635,22 +5066,26 @@ * desired one. * @param {Array} list The array to consider. * @return {Number} The index of the element found, or `-1`. - * @see R.transduce + * @see R.transduce, R.indexOf * @example * * const xs = [{a: 1}, {a: 2}, {a: 3}]; * R.findIndex(R.propEq('a', 2))(xs); //=> 1 * R.findIndex(R.propEq('a', 4))(xs); //=> -1 */ + var findIndex = _curry2(_dispatchable([], _xfindIndex, function findIndex(fn, list) { var idx = 0; var len = list.length; + while (idx < len) { if (fn(list[idx])) { return idx; } + idx += 1; } + return -1; })); @@ -4658,18 +5093,24 @@ this.xf = xf; this.f = f; } + XFindLast.prototype['@@transducer/init'] = _xfBase.init; - XFindLast.prototype['@@transducer/result'] = function(result) { + + XFindLast.prototype['@@transducer/result'] = function (result) { return this.xf['@@transducer/result'](this.xf['@@transducer/step'](result, this.last)); }; - XFindLast.prototype['@@transducer/step'] = function(result, input) { + + XFindLast.prototype['@@transducer/step'] = function (result, input) { if (this.f(input)) { this.last = input; } + return result; }; - var _xfindLast = _curry2(function _xfindLast(f, xf) { return new XFindLast(f, xf); }); + var _xfindLast = _curry2(function _xfindLast(f, xf) { + return new XFindLast(f, xf); + }); /** * Returns the last element of the list which matches the predicate, or @@ -4693,12 +5134,15 @@ * R.findLast(R.propEq('a', 1))(xs); //=> {a: 1, b: 1} * R.findLast(R.propEq('a', 4))(xs); //=> undefined */ + var findLast = _curry2(_dispatchable([], _xfindLast, function findLast(fn, list) { var idx = list.length - 1; + while (idx >= 0) { if (fn(list[idx])) { return list[idx]; } + idx -= 1; } })); @@ -4709,19 +5153,26 @@ this.idx = -1; this.lastIdx = -1; } + XFindLastIndex.prototype['@@transducer/init'] = _xfBase.init; - XFindLastIndex.prototype['@@transducer/result'] = function(result) { + + XFindLastIndex.prototype['@@transducer/result'] = function (result) { return this.xf['@@transducer/result'](this.xf['@@transducer/step'](result, this.lastIdx)); }; - XFindLastIndex.prototype['@@transducer/step'] = function(result, input) { + + XFindLastIndex.prototype['@@transducer/step'] = function (result, input) { this.idx += 1; + if (this.f(input)) { this.lastIdx = this.idx; } + return result; }; - var _xfindLastIndex = _curry2(function _xfindLastIndex(f, xf) { return new XFindLastIndex(f, xf); }); + var _xfindLastIndex = _curry2(function _xfindLastIndex(f, xf) { + return new XFindLastIndex(f, xf); + }); /** * Returns the index of the last element of the list which matches the @@ -4738,21 +5189,25 @@ * desired one. * @param {Array} list The array to consider. * @return {Number} The index of the element found, or `-1`. - * @see R.transduce + * @see R.transduce, R.lastIndexOf * @example * * const xs = [{a: 1, b: 0}, {a:1, b: 1}]; * R.findLastIndex(R.propEq('a', 1))(xs); //=> 1 * R.findLastIndex(R.propEq('a', 4))(xs); //=> -1 */ + var findLastIndex = _curry2(_dispatchable([], _xfindLastIndex, function findLastIndex(fn, list) { var idx = list.length - 1; + while (idx >= 0) { if (fn(list[idx])) { return idx; } + idx -= 1; } + return -1; })); @@ -4773,6 +5228,7 @@ * R.flatten([1, 2, [3, 4], 5, [6, [7, 8, [9, [10, 11], 12]]]]); * //=> [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12] */ + var flatten = _curry1(_makeFlat(true)); /** @@ -4795,8 +5251,9 @@ * R.flip(mergeThree)(1, 2, 3); //=> [2, 1, 3] * @symb R.flip(f)(a, b, c) = f(b, a, c) */ + var flip = _curry1(function flip(fn) { - return curryN(fn.length, function(a, b) { + return curryN(fn.length, function (a, b) { var args = Array.prototype.slice.call(arguments, 0); args[0] = b; args[1] = a; @@ -4838,13 +5295,16 @@ * // logs 8 * @symb R.forEach(f, [a, b, c]) = [a, b, c] */ + var forEach = _curry2(_checkForMethod('forEach', function forEach(fn, list) { var len = list.length; var idx = 0; + while (idx < len) { fn(list[idx]); idx += 1; } + return list; })); @@ -4870,14 +5330,17 @@ * // logs y:2 * @symb R.forEachObjIndexed(f, {x: a, y: b}) = {x: a, y: b} */ + var forEachObjIndexed = _curry2(function forEachObjIndexed(fn, obj) { var keyList = keys(obj); var idx = 0; + while (idx < keyList.length) { var key = keyList[idx]; fn(obj[key], key, obj); idx += 1; } + return obj; }); @@ -4897,19 +5360,22 @@ * * R.fromPairs([['a', 1], ['b', 2], ['c', 3]]); //=> {a: 1, b: 2, c: 3} */ + var fromPairs = _curry1(function fromPairs(pairs) { var result = {}; var idx = 0; + while (idx < pairs.length) { result[pairs[idx][0]] = pairs[idx][1]; idx += 1; } + return result; }); /** * Splits a list into sub-lists stored in an object, based on the result of - * calling a String-returning function on each element, and grouping the + * calling a key-returning function on each element, and grouping the * results according to values returned. * * Dispatches to the `groupBy` method of the second argument, if present. @@ -4920,12 +5386,13 @@ * @memberOf R * @since v0.1.0 * @category List - * @sig (a -> String) -> [a] -> {String: [a]} - * @param {Function} fn Function :: a -> String + * @typedefn Idx = String | Int | Symbol + * @sig Idx a => (b -> a) -> [b] -> {a: [b]} + * @param {Function} fn Function :: a -> Idx * @param {Array} list The array to group * @return {Object} An object with the output of `fn` for keys, mapped to arrays of elements * that produced that key when passed to `fn`. - * @see R.reduceBy, R.transduce + * @see R.reduceBy, R.transduce, R.indexBy * @example * * const byGrade = R.groupBy(function(student) { @@ -4947,13 +5414,11 @@ * // 'F': [{name: 'Eddy', score: 58}] * // } */ - var groupBy = _curry2(_checkForMethod('groupBy', reduceBy(function(acc, item) { - if (acc == null) { - acc = []; - } + + var groupBy = _curry2(_checkForMethod('groupBy', reduceBy(function (acc, item) { acc.push(item); return acc; - }, null))); + }, []))); /** * Takes a list and returns a list of lists where each sublist's elements are @@ -4982,21 +5447,27 @@ * R.groupWith((a, b) => a % 2 === b % 2, [0, 1, 1, 2, 3, 5, 8, 13, 21]) * //=> [[0], [1, 1], [2], [3, 5], [8], [13, 21]] * + * const isVowel = R.test(/^[aeiou]$/i); * R.groupWith(R.eqBy(isVowel), 'aestiou') * //=> ['ae', 'st', 'iou'] */ - var groupWith = _curry2(function(fn, list) { + + var groupWith = _curry2(function (fn, list) { var res = []; var idx = 0; var len = list.length; + while (idx < len) { var nextidx = idx + 1; + while (nextidx < len && fn(list[nextidx - 1], list[nextidx])) { nextidx += 1; } + res.push(list.slice(idx, nextidx)); idx = nextidx; } + return res; }); @@ -5021,7 +5492,10 @@ * R.gt('a', 'z'); //=> false * R.gt('z', 'a'); //=> true */ - var gt = _curry2(function gt(a, b) { return a > b; }); + + var gt = _curry2(function gt(a, b) { + return a > b; + }); /** * Returns `true` if the first argument is greater than or equal to the second; @@ -5044,7 +5518,10 @@ * R.gte('a', 'z'); //=> false * R.gte('z', 'a'); //=> true */ - var gte = _curry2(function gte(a, b) { return a >= b; }); + + var gte = _curry2(function gte(a, b) { + return a >= b; + }); /** * Returns whether or not a path exists in an object. Only the object's @@ -5054,7 +5531,7 @@ * @memberOf R * @since v0.26.0 * @category Object - * @typedefn Idx = String | Int + * @typedefn Idx = String | Int | Symbol * @sig [Idx] -> {a} -> Boolean * @param {Array} path The path to use. * @param {Object} obj The object to check the path in. @@ -5067,12 +5544,15 @@ * R.hasPath(['a', 'b'], {a: {c: 2}}); // => false * R.hasPath(['a', 'b'], {}); // => false */ + var hasPath = _curry2(function hasPath(_path, obj) { if (_path.length === 0 || isNil(obj)) { return false; } + var val = obj; var idx = 0; + while (idx < _path.length) { if (!isNil(val) && _has(_path[idx], val)) { val = val[_path[idx]]; @@ -5081,6 +5561,7 @@ return false; } } + return true; }); @@ -5108,6 +5589,7 @@ * pointHas('y'); //=> true * pointHas('z'); //=> false */ + var has = _curry2(function has(prop, obj) { return hasPath([prop], obj); }); @@ -5138,7 +5620,12 @@ * R.hasIn('width', square); //=> true * R.hasIn('area', square); //=> true */ + var hasIn = _curry2(function hasIn(prop, obj) { + if (isNil(obj)) { + return false; + } + return prop in obj; }); @@ -5167,6 +5654,7 @@ * R.identical(0, -0); //=> false * R.identical(NaN, NaN); //=> true */ + var identical = _curry2(_objectIs$1); /** @@ -5191,15 +5679,14 @@ * R.over(R.lensProp('count'), R.inc), * R.assoc('count', 1) * ); - * incCount({}); //=> { count: 1 } * incCount({ count: 1 }); //=> { count: 2 } + * incCount({}); //=> { count: 1 } */ + var ifElse = _curry3(function ifElse(condition, onTrue, onFalse) { - return curryN(Math.max(condition.length, onTrue.length, onFalse.length), - function _ifElse() { - return condition.apply(this, arguments) ? onTrue.apply(this, arguments) : onFalse.apply(this, arguments); - } - ); + return curryN(Math.max(condition.length, onTrue.length, onFalse.length), function _ifElse() { + return condition.apply(this, arguments) ? onTrue.apply(this, arguments) : onFalse.apply(this, arguments); + }); }); /** @@ -5217,12 +5704,13 @@ * * R.inc(42); //=> 43 */ + var inc = add(1); /** * Returns `true` if the specified value is equal, in [`R.equals`](#equals) * terms, to at least one element of the given list; `false` otherwise. - * Works also with strings. + * Also works with strings. * * @func * @memberOf R @@ -5241,6 +5729,7 @@ * R.includes([42], [[42]]); //=> true * R.includes('ba', 'banana'); //=>true */ + var includes = _curry2(_includes); /** @@ -5255,17 +5744,22 @@ * @memberOf R * @since v0.19.0 * @category List - * @sig (a -> String) -> [{k: v}] -> {k: {k: v}} - * @param {Function} fn Function :: a -> String + * @typedefn Idx = String | Int | Symbol + * @sig Idx a => (b -> a) -> [b] -> {a: b} + * @param {Function} fn Function :: a -> Idx * @param {Array} array The array of objects to index * @return {Object} An object indexing each array element by the given property. + * @see R.groupBy * @example * * const list = [{id: 'xyz', title: 'A'}, {id: 'abc', title: 'B'}]; * R.indexBy(R.prop('id'), list); * //=> {abc: {id: 'abc', title: 'B'}, xyz: {id: 'xyz', title: 'A'}} */ - var indexBy = reduceBy(function(acc, elem) { return elem; }, null); + + var indexBy = reduceBy(function (acc, elem) { + return elem; + }, null); /** * Returns the position of the first occurrence of an item in an array, or -1 @@ -5280,16 +5774,15 @@ * @param {*} target The item to find. * @param {Array} xs The array to search in. * @return {Number} the index of the target, or -1 if the target is not found. - * @see R.lastIndexOf + * @see R.lastIndexOf, R.findIndex * @example * * R.indexOf(3, [1,2,3,4]); //=> 2 * R.indexOf(10, [1,2,3,4]); //=> -1 */ + var indexOf = _curry2(function indexOf(target, xs) { - return typeof xs.indexOf === 'function' && !_isArray(xs) ? - xs.indexOf(target) : - _indexOf(xs, target, 0); + return typeof xs.indexOf === 'function' && !_isArray(xs) ? xs.indexOf(target) : _indexOf(xs, target, 0); }); /** @@ -5316,6 +5809,7 @@ * R.init('a'); //=> '' * R.init(''); //=> '' */ + var init = slice(0, -1); /** @@ -5353,8 +5847,11 @@ * ); * //=> [{id: 456, name: 'Stephen Stills'}, {id: 177, name: 'Neil Young'}] */ + var innerJoin = _curry3(function innerJoin(pred, xs, ys) { - return _filter(function(x) { return _includesWith(pred, x, ys); }, xs); + return _filter(function (x) { + return _includesWith(pred, x, ys); + }, xs); }); /** @@ -5376,6 +5873,7 @@ * * R.insert(2, 'x', [1,2,3,4]); //=> [1,2,'x',3,4] */ + var insert = _curry3(function insert(idx, elt, list) { idx = idx < list.length && idx >= 0 ? idx : list.length; var result = Array.prototype.slice.call(list, 0); @@ -5401,13 +5899,27 @@ * * R.insertAll(2, ['x','y','z'], [1,2,3,4]); //=> [1,2,'x','y','z',3,4] */ + var insertAll = _curry3(function insertAll(idx, elts, list) { idx = idx < list.length && idx >= 0 ? idx : list.length; - return [].concat( - Array.prototype.slice.call(list, 0, idx), - elts, - Array.prototype.slice.call(list, idx) - ); + return [].concat(Array.prototype.slice.call(list, 0, idx), elts, Array.prototype.slice.call(list, idx)); + }); + + function XUniqBy(f, xf) { + this.xf = xf; + this.f = f; + this.set = new _Set(); + } + + XUniqBy.prototype['@@transducer/init'] = _xfBase.init; + XUniqBy.prototype['@@transducer/result'] = _xfBase.result; + + XUniqBy.prototype['@@transducer/step'] = function (result, input) { + return this.set.add(this.f(input)) ? this.xf['@@transducer/step'](result, input) : result; + }; + + var _xuniqBy = _curry2(function _xuniqBy(f, xf) { + return new XUniqBy(f, xf); }); /** @@ -5416,6 +5928,8 @@ * each list element. Prefers the first item if the supplied function produces * the same value on two items. [`R.equals`](#equals) is used for comparison. * + * Acts as a transducer if a transformer is given in list position. + * * @func * @memberOf R * @since v0.16.0 @@ -5428,7 +5942,8 @@ * * R.uniqBy(Math.abs, [-1, -5, 2, 10, 1, 2]); //=> [-1, -5, 2, 10] */ - var uniqBy = _curry2(function uniqBy(fn, list) { + + var uniqBy = _curry2(_dispatchable([], _xuniqBy, function (fn, list) { var set = new _Set(); var result = []; var idx = 0; @@ -5437,13 +5952,16 @@ while (idx < list.length) { item = list[idx]; appliedItem = fn(item); + if (set.add(appliedItem)) { result.push(item); } + idx += 1; } + return result; - }); + })); /** * Returns a new list containing only one copy of each element in the original @@ -5462,6 +5980,7 @@ * R.uniq([1, '1']); //=> [1, '1'] * R.uniq([[42], [42]]); //=> [[42]] */ + var uniq = uniqBy(identity); /** @@ -5481,8 +6000,10 @@ * * R.intersection([1,2,3,4], [7,6,5,4,3]); //=> [4, 3] */ + var intersection = _curry2(function intersection(list1, list2) { var lookupList, filteredList; + if (list1.length > list2.length) { lookupList = list1; filteredList = list2; @@ -5490,6 +6011,7 @@ lookupList = list2; filteredList = list1; } + return uniq(_filter(flip(_includes)(lookupList), filteredList)); }); @@ -5510,22 +6032,25 @@ * * R.intersperse('a', ['b', 'n', 'n', 's']); //=> ['b', 'a', 'n', 'a', 'n', 'a', 's'] */ + var intersperse = _curry2(_checkForMethod('intersperse', function intersperse(separator, list) { var out = []; var idx = 0; var length = list.length; + while (idx < length) { if (idx === length - 1) { out.push(list[idx]); } else { out.push(list[idx], separator); } + idx += 1; } + return out; })); - // Based on https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Global_Objects/Object/assign function _objectAssign(target) { if (target == null) { throw new TypeError('Cannot convert undefined or null to object'); @@ -5534,8 +6059,10 @@ var output = Object(target); var idx = 1; var length = arguments.length; + while (idx < length) { var source = arguments[idx]; + if (source != null) { for (var nextKey in source) { if (_has(nextKey, source)) { @@ -5543,8 +6070,10 @@ } } } + idx += 1; } + return output; } @@ -5570,6 +6099,7 @@ * ); * matchPhrases(['foo', 'bar', 'baz']); //=> {must: [{match_phrase: 'foo'}, {match_phrase: 'bar'}, {match_phrase: 'baz'}]} */ + var objOf = _curry2(function objOf(key, val) { var obj = {}; obj[key] = val; @@ -5578,7 +6108,7 @@ var _stepCatArray = { '@@transducer/init': Array, - '@@transducer/step': function(xs, x) { + '@@transducer/step': function transducerStep(xs, x) { xs.push(x); return xs; }, @@ -5586,33 +6116,35 @@ }; var _stepCatString = { '@@transducer/init': String, - '@@transducer/step': function(a, b) { return a + b; }, + '@@transducer/step': function transducerStep(a, b) { + return a + b; + }, '@@transducer/result': _identity }; var _stepCatObject = { '@@transducer/init': Object, - '@@transducer/step': function(result, input) { - return _objectAssign$1( - result, - _isArrayLike(input) ? objOf(input[0], input[1]) : input - ); + '@@transducer/step': function transducerStep(result, input) { + return _objectAssign$1(result, _isArrayLike(input) ? objOf(input[0], input[1]) : input); }, '@@transducer/result': _identity }; - function _stepCat(obj) { if (_isTransformer(obj)) { return obj; } + if (_isArrayLike(obj)) { return _stepCatArray; } + if (typeof obj === 'string') { return _stepCatString; } - if (typeof obj === 'object') { + + if (_typeof(obj) === 'object') { return _stepCatObject; } + throw new Error('Cannot create transformer for ' + obj); } @@ -5655,10 +6187,9 @@ * const intoArray = R.into([]); * intoArray(transducer, numbers); //=> [2, 3] */ + var into = _curry3(function into(acc, xf, list) { - return _isTransformer(acc) ? - _reduce(xf(acc), acc['@@transducer/init'](), list) : - _reduce(xf(_stepCat(acc)), _clone(acc, [], [], false), list); + return _isTransformer(acc) ? _reduce(xf(acc), acc['@@transducer/init'](), list) : _reduce(xf(_stepCat(acc)), _clone(acc, [], [], false), list); }); /** @@ -5683,6 +6214,7 @@ * R.invert(raceResultsByFirstName); * //=> { 'alice': ['first', 'third'], 'jake':['second'] } */ + var invert = _curry1(function invert(obj) { var props = keys(obj); var len = props.length; @@ -5692,10 +6224,11 @@ while (idx < len) { var key = props[idx]; var val = obj[key]; - var list = _has(val, out) ? out[val] : (out[val] = []); + var list = _has(val, out) ? out[val] : out[val] = []; list[list.length] = key; idx += 1; } + return out; }); @@ -5726,6 +6259,7 @@ * R.invertObj(raceResults); * //=> { 'alice': '0', 'jake':'1' } */ + var invertObj = _curry1(function invertObj(obj) { var props = keys(obj); var len = props.length; @@ -5737,6 +6271,7 @@ out[obj[key]] = key; idx += 1; } + return out; }); @@ -5774,19 +6309,23 @@ * @symb R.invoker(1, 'method')(a, o) = o['method'](a) * @symb R.invoker(2, 'method')(a, b, o) = o['method'](a, b) */ + var invoker = _curry2(function invoker(arity, method) { - return curryN(arity + 1, function() { + return curryN(arity + 1, function () { var target = arguments[arity]; + if (target != null && _isFunction(target[method])) { return target[method].apply(target, Array.prototype.slice.call(arguments, 0, arity)); } + throw new TypeError(toString$1(target) + ' does not have a method named "' + method + '"'); }); }); /** - * See if an object (`val`) is an instance of the supplied constructor. This + * See if an object (i.e. `val`) is an instance of the supplied constructor. This * function will check up the inheritance chain, if any. + * If `val` was created using `Object.create`, `R.is(Object, val) === true`. * * @func * @memberOf R @@ -5807,8 +6346,9 @@ * R.is(Object, 's'); //=> false * R.is(Number, {}); //=> false */ + var is = _curry2(function is(Ctor, val) { - return val != null && val.constructor === Ctor || val instanceof Ctor; + return val instanceof Ctor || val != null && (val.constructor === Ctor || Ctor.name === 'Object' && _typeof(val) === 'object'); }); /** @@ -5825,13 +6365,15 @@ * @see R.empty * @example * - * R.isEmpty([1, 2, 3]); //=> false - * R.isEmpty([]); //=> true - * R.isEmpty(''); //=> true - * R.isEmpty(null); //=> false - * R.isEmpty({}); //=> true - * R.isEmpty({length: 0}); //=> false + * R.isEmpty([1, 2, 3]); //=> false + * R.isEmpty([]); //=> true + * R.isEmpty(''); //=> true + * R.isEmpty(null); //=> false + * R.isEmpty({}); //=> true + * R.isEmpty({length: 0}); //=> false + * R.isEmpty(Uint8Array.from('')); //=> true */ + var isEmpty = _curry1(function isEmpty(x) { return x != null && equals(x, empty(x)); }); @@ -5855,6 +6397,7 @@ * spacer(['a', 2, 3.4]); //=> 'a 2 3.4' * R.join('|', [1, 2, 3]); //=> '1|2|3' */ + var join = invoker(1, 'join'); /** @@ -5874,8 +6417,11 @@ * getRange(3, 4, 9, -3); //=> [-3, 9] * @symb R.juxt([f, g, h])(a, b) = [f(a, b), g(a, b), h(a, b)] */ + var juxt = _curry1(function juxt(fns) { - return converge(function() { return Array.prototype.slice.call(arguments, 0); }, fns); + return converge(function () { + return Array.prototype.slice.call(arguments, 0); + }, fns); }); /** @@ -5899,12 +6445,15 @@ * const f = new F(); * R.keysIn(f); //=> ['x', 'y'] */ + var keysIn = _curry1(function keysIn(obj) { var prop; var ks = []; + for (prop in obj) { ks[ks.length] = prop; } + return ks; }); @@ -5921,23 +6470,27 @@ * @param {*} target The item to find. * @param {Array} xs The array to search in. * @return {Number} the index of the target, or -1 if the target is not found. - * @see R.indexOf + * @see R.indexOf, R.findLastIndex * @example * * R.lastIndexOf(3, [-1,3,3,0,1,2,3,4]); //=> 6 * R.lastIndexOf(10, [1,2,3,4]); //=> -1 */ + var lastIndexOf = _curry2(function lastIndexOf(target, xs) { if (typeof xs.lastIndexOf === 'function' && !_isArray(xs)) { return xs.lastIndexOf(target); } else { var idx = xs.length - 1; + while (idx >= 0) { if (equals(xs[idx], target)) { return idx; } + idx -= 1; } + return -1; } }); @@ -5961,6 +6514,7 @@ * R.length([]); //=> 0 * R.length([1, 2, 3]); //=> 3 */ + var length = _curry1(function length(list) { return list != null && _isNumber(list.length) ? list.length : NaN; }); @@ -5988,41 +6542,131 @@ * R.set(xLens, 4, {x: 1, y: 2}); //=> {x: 4, y: 2} * R.over(xLens, R.negate, {x: 1, y: 2}); //=> {x: -1, y: 2} */ + var lens = _curry2(function lens(getter, setter) { - return function(toFunctorFn) { - return function(target) { - return map( - function(focus) { - return setter(focus, target); - }, - toFunctorFn(getter(target)) - ); + return function (toFunctorFn) { + return function (target) { + return map(function (focus) { + return setter(focus, target); + }, toFunctorFn(getter(target))); }; }; }); /** - * Returns a lens whose focus is the specified index. + * Returns a new copy of the array with the element at the provided index + * replaced with the given value. + * + * @func + * @memberOf R + * @since v0.14.0 + * @category List + * @sig Number -> a -> [a] -> [a] + * @param {Number} idx The index to update. + * @param {*} x The value to exist at the given index of the returned array. + * @param {Array|Arguments} list The source array-like object to be updated. + * @return {Array} A copy of `list` with the value at index `idx` replaced with `x`. + * @see R.adjust + * @example + * + * R.update(1, '_', ['a', 'b', 'c']); //=> ['a', '_', 'c'] + * R.update(-1, '_', ['a', 'b', 'c']); //=> ['a', 'b', '_'] + * @symb R.update(-1, a, [b, c]) = [b, a] + * @symb R.update(0, a, [b, c]) = [a, c] + * @symb R.update(1, a, [b, c]) = [b, a] + */ + + var update = _curry3(function update(idx, x, list) { + return adjust(idx, always(x), list); + }); + + /** + * Returns a lens whose focus is the specified index. + * + * @func + * @memberOf R + * @since v0.14.0 + * @category Object + * @typedefn Lens s a = Functor f => (a -> f a) -> s -> f s + * @sig Number -> Lens s a + * @param {Number} n + * @return {Lens} + * @see R.view, R.set, R.over, R.nth + * @example + * + * const headLens = R.lensIndex(0); + * + * R.view(headLens, ['a', 'b', 'c']); //=> 'a' + * R.set(headLens, 'x', ['a', 'b', 'c']); //=> ['x', 'b', 'c'] + * R.over(headLens, R.toUpper, ['a', 'b', 'c']); //=> ['A', 'b', 'c'] + */ + + var lensIndex = _curry1(function lensIndex(n) { + return lens(nth(n), update(n)); + }); + + /** + * Retrieves the values at given paths of an object. + * + * @func + * @memberOf R + * @since v0.27.1 + * @category Object + * @typedefn Idx = [String | Int | Symbol] + * @sig [Idx] -> {a} -> [a | Undefined] + * @param {Array} pathsArray The array of paths to be fetched. + * @param {Object} obj The object to retrieve the nested properties from. + * @return {Array} A list consisting of values at paths specified by "pathsArray". + * @see R.path + * @example + * + * R.paths([['a', 'b'], ['p', 0, 'q']], {a: {b: 2}, p: [{q: 3}]}); //=> [2, 3] + * R.paths([['a', 'b'], ['p', 'r']], {a: {b: 2}, p: [{q: 3}]}); //=> [2, undefined] + */ + + var paths = _curry2(function paths(pathsArray, obj) { + return pathsArray.map(function (paths) { + var val = obj; + var idx = 0; + var p; + + while (idx < paths.length) { + if (val == null) { + return; + } + + p = paths[idx]; + val = _isInteger(p) ? nth(p, val) : val[p]; + idx += 1; + } + + return val; + }); + }); + + /** + * Retrieve the value at a given path. * * @func * @memberOf R - * @since v0.14.0 + * @since v0.2.0 * @category Object - * @typedefn Lens s a = Functor f => (a -> f a) -> s -> f s - * @sig Number -> Lens s a - * @param {Number} n - * @return {Lens} - * @see R.view, R.set, R.over, R.nth + * @typedefn Idx = String | Int | Symbol + * @sig [Idx] -> {a} -> a | Undefined + * @param {Array} path The path to use. + * @param {Object} obj The object to retrieve the nested property from. + * @return {*} The data at `path`. + * @see R.prop, R.nth * @example * - * const headLens = R.lensIndex(0); - * - * R.view(headLens, ['a', 'b', 'c']); //=> 'a' - * R.set(headLens, 'x', ['a', 'b', 'c']); //=> ['x', 'b', 'c'] - * R.over(headLens, R.toUpper, ['a', 'b', 'c']); //=> ['A', 'b', 'c'] + * R.path(['a', 'b'], {a: {b: 2}}); //=> 2 + * R.path(['a', 'b'], {c: {b: 2}}); //=> undefined + * R.path(['a', 'b', 0], {a: {b: [1, 2, 3]}}); //=> 1 + * R.path(['a', 'b', -2], {a: {b: [1, 2, 3]}}); //=> 2 */ - var lensIndex = _curry1(function lensIndex(n) { - return lens(nth(n), update(n)); + + var path = _curry2(function path(pathAr, obj) { + return paths([pathAr], obj)[0]; }); /** @@ -6032,7 +6676,7 @@ * @memberOf R * @since v0.19.0 * @category Object - * @typedefn Idx = String | Int + * @typedefn Idx = String | Int | Symbol * @typedefn Lens s a = Functor f => (a -> f a) -> s -> f s * @sig [Idx] -> Lens s a * @param {Array} path The path to use. @@ -6049,6 +6693,7 @@ * R.over(xHeadYLens, R.negate, {x: [{y: 2, z: 3}, {y: 4, z: 5}]}); * //=> {x: [{y: -2, z: 3}, {y: 4, z: 5}]} */ + var lensPath = _curry1(function lensPath(p) { return lens(path(p), assocPath(p)); }); @@ -6073,6 +6718,7 @@ * R.set(xLens, 4, {x: 1, y: 2}); //=> {x: 4, y: 2} * R.over(xLens, R.negate, {x: 1, y: 2}); //=> {x: -1, y: 2} */ + var lensProp = _curry1(function lensProp(k) { return lens(prop(k), assoc(k)); }); @@ -6098,7 +6744,10 @@ * R.lt('a', 'z'); //=> true * R.lt('z', 'a'); //=> false */ - var lt = _curry2(function lt(a, b) { return a < b; }); + + var lt = _curry2(function lt(a, b) { + return a < b; + }); /** * Returns `true` if the first argument is less than or equal to the second; @@ -6121,7 +6770,10 @@ * R.lte('a', 'z'); //=> true * R.lte('z', 'a'); //=> false */ - var lte = _curry2(function lte(a, b) { return a <= b; }); + + var lte = _curry2(function lte(a, b) { + return a <= b; + }); /** * The `mapAccum` function behaves like a combination of map and reduce; it @@ -6157,16 +6809,19 @@ * ] * ] */ + var mapAccum = _curry3(function mapAccum(fn, acc, list) { var idx = 0; var len = list.length; var result = []; var tuple = [acc]; + while (idx < len) { tuple = fn(tuple[0], list[idx]); result[idx] = tuple[1]; idx += 1; } + return [tuple[0], result]; }); @@ -6207,15 +6862,18 @@ * ] * ] */ + var mapAccumRight = _curry3(function mapAccumRight(fn, acc, list) { var idx = list.length - 1; var result = []; var tuple = [acc]; + while (idx >= 0) { tuple = fn(tuple[0], list[idx]); result[idx] = tuple[1]; idx -= 1; } + return [tuple[0], result]; }); @@ -6240,8 +6898,9 @@ * * R.mapObjIndexed(prependKeyAndDouble, xyz); //=> { x: 'x2', y: 'y4', z: 'z6' } */ + var mapObjIndexed = _curry2(function mapObjIndexed(fn, obj) { - return _reduce(function(acc, key) { + return _reduce(function (acc, key) { acc[key] = fn(obj[key], key, obj); return acc; }, {}, keys(obj)); @@ -6268,6 +6927,7 @@ * R.match(/a/, 'b'); //=> [] * R.match(/a/, null); //=> TypeError: null does not have a method named "match" */ + var match = _curry2(function match(rx, str) { return str.match(rx) || []; }); @@ -6305,10 +6965,17 @@ * seventeenMod(4); //=> 1 * seventeenMod(10); //=> 7 */ + var mathMod = _curry2(function mathMod(m, p) { - if (!_isInteger(m)) { return NaN; } - if (!_isInteger(p) || p < 1) { return NaN; } - return ((m % p) + p) % p; + if (!_isInteger(m)) { + return NaN; + } + + if (!_isInteger(p) || p < 1) { + return NaN; + } + + return (m % p + p) % p; }); /** @@ -6335,6 +7002,7 @@ * R.reduce(R.maxBy(square), 0, [3, -5, 4, 1, -2]); //=> -5 * R.reduce(R.maxBy(square), 0, []); //=> 0 */ + var maxBy = _curry3(function maxBy(f, a, b) { return f(b) > f(a) ? b : a; }); @@ -6354,6 +7022,7 @@ * * R.sum([2,4,6,8,100,1]); //=> 121 */ + var sum = reduce(add, 0); /** @@ -6372,6 +7041,7 @@ * R.mean([2, 7, 9]); //=> 6 * R.mean([]); //=> NaN */ + var mean = _curry1(function mean(list) { return sum(list) / list.length; }); @@ -6393,14 +7063,17 @@ * R.median([7, 2, 10, 9]); //=> 8 * R.median([]); //=> NaN */ + var median = _curry1(function median(list) { var len = list.length; + if (len === 0) { return NaN; } + var width = 2 - len % 2; var idx = (len - width) / 2; - return mean(Array.prototype.slice.call(list, 0).sort(function(a, b) { + return mean(Array.prototype.slice.call(list, 0).sort(function (a, b) { return a < b ? -1 : a > b ? 1 : 0; }).slice(idx, idx + width)); }); @@ -6412,6 +7085,8 @@ * call to `fn`; instead, the cached result for that set of arguments will be * returned. * + * Care must be taken when implementing key generation to avoid key collision, + * or if tracking references, memory leaks and mutating arguments. * * @func * @memberOf R @@ -6424,7 +7099,7 @@ * @example * * let count = 0; - * const factorial = R.memoizeWith(R.identity, n => { + * const factorial = R.memoizeWith(Number, n => { * count += 1; * return R.product(R.range(1, n + 1)); * }); @@ -6433,47 +7108,24 @@ * factorial(5); //=> 120 * count; //=> 1 */ + var memoizeWith = _curry2(function memoizeWith(mFn, fn) { var cache = {}; - return _arity(fn.length, function() { + return _arity(fn.length, function () { var key = mFn.apply(this, arguments); + if (!_has(key, cache)) { cache[key] = fn.apply(this, arguments); } + return cache[key]; }); }); /** - * Create a new object with the own properties of the first object merged with - * the own properties of the second object. If a key exists in both objects, - * the value from the second object will be used. - * - * @func - * @memberOf R - * @since v0.1.0 - * @category Object - * @sig {k: v} -> {k: v} -> {k: v} - * @param {Object} l - * @param {Object} r - * @return {Object} - * @see R.mergeRight, R.mergeDeepRight, R.mergeWith, R.mergeWithKey - * @deprecated since v0.26.0 - * @example - * - * R.merge({ 'name': 'fred', 'age': 10 }, { 'age': 40 }); - * //=> { 'name': 'fred', 'age': 40 } - * - * const withDefaults = R.merge({x: 0, y: 0}); - * withDefaults({y: 2}); //=> {x: 0, y: 2} - * @symb R.merge(a, b) = {...a, ...b} - */ - var merge = _curry2(function merge(l, r) { - return _objectAssign$1({}, l, r); - }); - - /** - * Merges a list of objects together into one object. + * Creates one new object with the own properties from a list of objects. + * If a key exists in more than one object, the value from the last + * object it exists in will be used. * * @func * @memberOf R @@ -6489,6 +7141,7 @@ * R.mergeAll([{foo:1},{foo:2},{bar:2}]); //=> {foo:2,bar:2} * @symb R.mergeAll([{ x: 1 }, { y: 2 }, { z: 3 }]) = { x: 1, y: 2, z: 3 } */ + var mergeAll = _curry1(function mergeAll(list) { return _objectAssign$1.apply(null, [{}].concat(list)); }); @@ -6518,6 +7171,7 @@ * //=> { a: true, b: true, thing: 'bar', values: [10, 20, 15, 35] } * @symb R.mergeWithKey(f, { x: 1, y: 2 }, { y: 5, z: 3 }) = { x: 1, y: f('y', 2, 5), z: 3 } */ + var mergeWithKey = _curry3(function mergeWithKey(fn, l, r) { var result = {}; var k; @@ -6529,7 +7183,7 @@ } for (k in r) { - if (_has(k, r) && !(_has(k, result))) { + if (_has(k, r) && !_has(k, result)) { result[k] = r[k]; } } @@ -6565,8 +7219,9 @@ * { b: true, c: { thing: 'bar', values: [15, 35] }}); * //=> { a: true, b: true, c: { thing: 'bar', values: [10, 20, 15, 35] }} */ + var mergeDeepWithKey = _curry3(function mergeDeepWithKey(fn, lObj, rObj) { - return mergeWithKey(function(k, lVal, rVal) { + return mergeWithKey(function (k, lVal, rVal) { if (_isObject(lVal) && _isObject(rVal)) { return mergeDeepWithKey(fn, lVal, rVal); } else { @@ -6596,8 +7251,9 @@ * { age: 40, contact: { email: 'baa@example.com' }}); * //=> { name: 'fred', age: 10, contact: { email: 'moo@example.com' }} */ + var mergeDeepLeft = _curry2(function mergeDeepLeft(lObj, rObj) { - return mergeDeepWithKey(function(k, lVal, rVal) { + return mergeDeepWithKey(function (k, lVal, rVal) { return lVal; }, lObj, rObj); }); @@ -6623,8 +7279,9 @@ * { age: 40, contact: { email: 'baa@example.com' }}); * //=> { name: 'fred', age: 40, contact: { email: 'baa@example.com' }} */ + var mergeDeepRight = _curry2(function mergeDeepRight(lObj, rObj) { - return mergeDeepWithKey(function(k, lVal, rVal) { + return mergeDeepWithKey(function (k, lVal, rVal) { return rVal; }, lObj, rObj); }); @@ -6656,8 +7313,9 @@ * { b: true, c: { values: [15, 35] }}); * //=> { a: true, b: true, c: { values: [10, 20, 15, 35] }} */ + var mergeDeepWith = _curry3(function mergeDeepWith(fn, lObj, rObj) { - return mergeDeepWithKey(function(k, lVal, rVal) { + return mergeDeepWithKey(function (k, lVal, rVal) { return fn(lVal, rVal); }, lObj, rObj); }); @@ -6685,6 +7343,7 @@ * resetToDefault({x: 5, y: 2}); //=> {x: 0, y: 2} * @symb R.mergeLeft(a, b) = {...b, ...a} */ + var mergeLeft = _curry2(function mergeLeft(l, r) { return _objectAssign$1({}, r, l); }); @@ -6712,6 +7371,7 @@ * withDefaults({y: 2}); //=> {x: 0, y: 2} * @symb R.mergeRight(a, b) = {...a, ...b} */ + var mergeRight = _curry2(function mergeRight(l, r) { return _objectAssign$1({}, l, r); }); @@ -6739,8 +7399,9 @@ * { b: true, values: [15, 35] }); * //=> { a: true, b: true, values: [10, 20, 15, 35] } */ + var mergeWith = _curry3(function mergeWith(fn, l, r) { - return mergeWithKey(function(_, _l, _r) { + return mergeWithKey(function (_, _l, _r) { return fn(_l, _r); }, l, r); }); @@ -6762,7 +7423,10 @@ * R.min(789, 123); //=> 123 * R.min('a', 'b'); //=> 'a' */ - var min = _curry2(function min(a, b) { return b < a ? b : a; }); + + var min = _curry2(function min(a, b) { + return b < a ? b : a; + }); /** * Takes a function and two values, and returns whichever value produces the @@ -6788,10 +7452,119 @@ * R.reduce(R.minBy(square), Infinity, [3, -5, 4, 1, -2]); //=> 1 * R.reduce(R.minBy(square), Infinity, []); //=> Infinity */ + var minBy = _curry3(function minBy(f, a, b) { return f(b) < f(a) ? b : a; }); + /** + * Makes a shallow clone of an object, applying the given fn to the specified + * property with the given value. Note that this copies and flattens prototype + * properties onto the new object as well. All non-primitive properties are + * copied by reference. + * + * @private + * @param {String|Number} prop The property name to set + * @param {Function} fn The function to apply to the property + * @param {Object|Array} obj The object to clone + * @return {Object|Array} A new object equivalent to the original except for the changed property. + */ + + function _modify(prop, fn, obj) { + if (_isInteger(prop) && _isArray(obj)) { + var arr = [].concat(obj); + arr[prop] = fn(arr[prop]); + return arr; + } + + var result = {}; + + for (var p in obj) { + result[p] = obj[p]; + } + + result[prop] = fn(result[prop]); + return result; + } + + /** + * Creates a shallow clone of the passed object by applying an `fn` function + * to the value at the given path. + * + * The function will not be invoked, and the object will not change + * if its corresponding path does not exist in the object. + * All non-primitive properties are copied to the new object by reference. + * + * @func + * @memberOf R + * @since v0.28.0 + * @category Object + * @sig [Idx] -> (v -> v) -> {k: v} -> {k: v} + * @param {Array} path The path to be modified. + * @param {Function} fn The function to apply to the path. + * @param {Object} object The object to be transformed. + * @return {Object} The transformed object. + * @example + * + * const person = {name: 'James', address: { zipCode: '90216' }}; + * R.modifyPath(['address', 'zipCode'], R.reverse, person); //=> {name: 'James', address: { zipCode: '61209' }} + * + * // Can handle arrays too + * const person = {name: 'James', addresses: [{ zipCode: '90216' }]}; + * R.modifyPath(['addresses', 0, 'zipCode'], R.reverse, person); //=> {name: 'James', addresses: [{ zipCode: '61209' }]} + */ + + var modifyPath = _curry3(function modifyPath(path, fn, object) { + if (!_isObject(object) && !_isArray(object) || path.length === 0) { + return object; + } + + var idx = path[0]; + + if (!_has(idx, object)) { + return object; + } + + if (path.length === 1) { + return _modify(idx, fn, object); + } + + var val = modifyPath(Array.prototype.slice.call(path, 1), fn, object[idx]); + + if (val === object[idx]) { + return object; + } + + return _assoc(idx, val, object); + }); + + /** + * Creates a copy of the passed object by applying an `fn` function to the given `prop` property. + * + * The function will not be invoked, and the object will not change + * if its corresponding property does not exist in the object. + * All non-primitive properties are copied to the new object by reference. + * + * @func + * @memberOf R + * @since v0.28.0 + * @category Object + * @sig Idx -> (v -> v) -> {k: v} -> {k: v} + * @param {String|Number} prop The property to be modified. + * @param {Function} fn The function to apply to the property. + * @param {Object} object The object to be transformed. + * @return {Object} The transformed object. + * @example + * + * const person = {name: 'James', age: 20, pets: ['dog', 'cat']}; + * R.modify('age', R.add(1), person); //=> {name: 'James', age: 21, pets: ['dog', 'cat']} + * R.modify('pets', R.append('turtle'), person); //=> {name: 'James', age: 20, pets: ['dog', 'cat', 'turtle']} + */ + + var modify = _curry3(function modify(prop, fn, object) { + return modifyPath([prop], fn, object); + }); + /** * Divides the first parameter by the second and returns the remainder. Note * that this function preserves the JavaScript-style behavior for modulo. For @@ -6817,7 +7590,10 @@ * isOdd(42); //=> 0 * isOdd(21); //=> 1 */ - var modulo = _curry2(function modulo(a, b) { return a % b; }); + + var modulo = _curry2(function modulo(a, b) { + return a % b; + }); /** * Move an item, at index `from`, to index `to`, in a list of elements. @@ -6837,20 +7613,14 @@ * R.move(0, 2, ['a', 'b', 'c', 'd', 'e', 'f']); //=> ['b', 'c', 'a', 'd', 'e', 'f'] * R.move(-1, 0, ['a', 'b', 'c', 'd', 'e', 'f']); //=> ['f', 'a', 'b', 'c', 'd', 'e'] list rotation */ - var move = _curry3(function(from, to, list) { + + var move = _curry3(function (from, to, list) { var length = list.length; var result = list.slice(); var positiveFrom = from < 0 ? length + from : from; var positiveTo = to < 0 ? length + to : to; var item = result.splice(positiveFrom, 1); - - return positiveFrom < 0 || positiveFrom >= list.length - || positiveTo < 0 || positiveTo >= list.length - ? list - : [] - .concat(result.slice(0, positiveTo)) - .concat(item) - .concat(result.slice(positiveTo, list.length)); + return positiveFrom < 0 || positiveFrom >= list.length || positiveTo < 0 || positiveTo >= list.length ? list : [].concat(result.slice(0, positiveTo)).concat(item).concat(result.slice(positiveTo, list.length)); }); /** @@ -6873,7 +7643,46 @@ * triple(4); //=> 12 * R.multiply(2, 5); //=> 10 */ - var multiply = _curry2(function multiply(a, b) { return a * b; }); + + var multiply = _curry2(function multiply(a, b) { + return a * b; + }); + + var _this = undefined; + /** + * Takes a function `f` and an object, and returns a function `g`. + * When applied, `g` returns the result of applying `f` to the object + * provided initially merged deeply (right) with the object provided as an argument to `g`. + * + * @func + * @memberOf R + * @since v0.28.0 + * @category Function + * @sig (({ a, b, c, ..., n }) -> x) -> { a, b, c, ...} -> ({ d, e, f, ..., n } -> x) + * @param {Function} f + * @param {Object} props + * @return {Function} + * @see R.partial, R.partialRight, R.curry, R.mergeDeepRight + * @example + * + * const multiply2 = ({ a, b }) => a * b; + * const double = R.partialObject(multiply2, { a: 2 }); + * double({ b: 2 }); //=> 4 + * + * const greet = ({ salutation, title, firstName, lastName }) => + * salutation + ', ' + title + ' ' + firstName + ' ' + lastName + '!'; + * + * const sayHello = R.partialObject(greet, { salutation: 'Hello' }); + * const sayHelloToMs = R.partialObject(sayHello, { title: 'Ms.' }); + * sayHelloToMs({ firstName: 'Jane', lastName: 'Jones' }); //=> 'Hello, Ms. Jane Jones!' + * @symb R.partialObject(f, { a, b })({ c, d }) = f({ a, b, c, d }) + */ + + var partialObject = _curry2(function (f, o) { + return function (props) { + return f.call(_this, mergeDeepRight(o, props)); + }; + }); /** * Negates its argument. @@ -6889,7 +7698,10 @@ * * R.negate(42); //=> -42 */ - var negate = _curry1(function negate(n) { return -n; }); + + var negate = _curry1(function negate(n) { + return -n; + }); /** * Returns `true` if no elements of the list match the predicate, `false` @@ -6911,11 +7723,12 @@ * @example * * const isEven = n => n % 2 === 0; - * const isOdd = n => n % 2 === 1; + * const isOdd = n => n % 2 !== 0; * * R.none(isEven, [1, 3, 5, 7, 9, 11]); //=> true * R.none(isOdd, [1, 3, 5, 7, 8, 11]); //=> false */ + var none = _curry2(function none(fn, input) { return all(_complement(fn), input); }); @@ -6938,9 +7751,10 @@ * @symb R.nthArg(0)(a, b, c) = a * @symb R.nthArg(1)(a, b, c) = b */ + var nthArg = _curry1(function nthArg(n) { var arity = n < 0 ? 1 : n + 1; - return curryN(arity, function() { + return curryN(arity, function () { return nth(n, arguments); }); }); @@ -6972,11 +7786,14 @@ * * @symb R.o(f, g, x) = f(g(x)) */ + var o = _curry3(function o(f, g, x) { return f(g(x)); }); - function _of(x) { return [x]; } + function _of(x) { + return [x]; + } /** * Returns a singleton array containing the value provided. @@ -6996,6 +7813,7 @@ * R.of(null); //=> [null] * R.of([42]); //=> [[42]] */ + var of = _curry1(_of); /** @@ -7014,6 +7832,7 @@ * * R.omit(['a', 'd'], {a: 1, b: 2, c: 3, d: 4}); //=> {b: 2, c: 3} */ + var omit = _curry2(function omit(names, obj) { var result = {}; var index = {}; @@ -7030,9 +7849,40 @@ result[prop] = obj[prop]; } } + return result; }); + /** + * Takes a binary function `f`, a unary function `g`, and two values. + * Applies `g` to each value, then applies the result of each to `f`. + * + * Also known as the P combinator. + * + * @func + * @memberOf R + * @since v0.28.0 + * @category Function + * @sig ((a, a) -> b) -> (c -> a) -> c -> c -> b + * @param {Function} f a binary function + * @param {Function} g a unary function + * @param {any} a any value + * @param {any} b any value + * @return {any} The result of `f` + * @example + * + * const eqBy = R.on((a, b) => a === b); + * eqBy(R.prop('a'), {b:0, a:1}, {a:1}) //=> true; + * + * const containsInsensitive = R.on(R.contains, R.toLower); + * containsInsensitive('o', 'FOO'); //=> true + * @symb R.on(f, g, a, b) = f(g(a), g(b)) + */ + + var on = _curryN(4, [], function on(f, g, a, b) { + return f(g(a), g(b)); + }); + /** * Accepts a function `fn` and returns a function that guards invocation of * `fn` such that `fn` can only ever be called once, no matter how many times @@ -7052,13 +7902,15 @@ * addOneOnce(10); //=> 11 * addOneOnce(addOneOnce(50)); //=> 11 */ + var once = _curry1(function once(fn) { var called = false; var result; - return _arity(fn.length, function() { + return _arity(fn.length, function () { if (called) { return result; } + called = true; result = fn.apply(this, arguments); return result; @@ -7085,33 +7937,37 @@ * @param {Function} onFailure The function to apply. Can return a value or a promise of a value. * @param {Promise} p * @return {Promise} The result of calling `p.then(null, onFailure)` - * @see R.then + * @see R.andThen * @example * - * var failedFetch = (id) => Promise.reject('bad ID'); - * var useDefault = () => ({ firstName: 'Bob', lastName: 'Loblaw' }) + * const failedFetch = id => Promise.reject('bad ID'); + * const useDefault = () => ({ firstName: 'Bob', lastName: 'Loblaw' }); * - * //recoverFromFailure :: String -> Promise ({firstName, lastName}) - * var recoverFromFailure = R.pipe( + * //recoverFromFailure :: String -> Promise ({ firstName, lastName }) + * const recoverFromFailure = R.pipe( * failedFetch, * R.otherwise(useDefault), - * R.then(R.pick(['firstName', 'lastName'])), + * R.andThen(R.pick(['firstName', 'lastName'])), * ); - * recoverFromFailure(12345).then(console.log) + * recoverFromFailure(12345).then(console.log); */ + var otherwise = _curry2(function otherwise(f, p) { _assertPromise('otherwise', p); return p.then(null, f); }); - // `Identity` is a functor that holds a single value, where `map` simply // transforms the held value with the provided function. - var Identity = function(x) { - return {value: x, map: function(f) { return Identity(f(x)); }}; - }; - + var Identity = function Identity(x) { + return { + value: x, + map: function map(f) { + return Identity(f(x)); + } + }; + }; /** * Returns the result of "setting" the portion of the given data structure * focused by the given lens to the result of applying the given function to @@ -7127,18 +7983,22 @@ * @param {*} v * @param {*} x * @return {*} - * @see R.prop, R.lensIndex, R.lensProp + * @see R.view, R.set, R.lens, R.lensIndex, R.lensProp, R.lensPath * @example * * const headLens = R.lensIndex(0); * * R.over(headLens, R.toUpper, ['foo', 'bar', 'baz']); //=> ['FOO', 'bar', 'baz'] */ + + var over = _curry3(function over(lens, f, x) { // The value returned by the getter function is first transformed with `f`, // then set as the value of an `Identity`. This is then mapped over with the // setter function of the lens. - return lens(function(y) { return Identity(f(y)); })(x).value; + return lens(function (y) { + return Identity(f(y)); + })(x).value; }); /** @@ -7157,11 +8017,14 @@ * * R.pair('foo', 'bar'); //=> ['foo', 'bar'] */ - var pair = _curry2(function pair(fst, snd) { return [fst, snd]; }); + + var pair = _curry2(function pair(fst, snd) { + return [fst, snd]; + }); function _createPartialApplicator(concat) { - return _curry2(function(fn, args) { - return _arity(Math.max(0, fn.length - args.length), function() { + return _curry2(function (fn, args) { + return _arity(Math.max(0, fn.length - args.length), function () { return fn.apply(this, concat(args, arguments)); }); }); @@ -7185,7 +8048,7 @@ * * const multiply2 = (a, b) => a * b; * const double = R.partial(multiply2, [2]); - * double(2); //=> 4 + * double(3); //=> 6 * * const greet = (salutation, title, firstName, lastName) => * salutation + ', ' + title + ' ' + firstName + ' ' + lastName + '!'; @@ -7195,6 +8058,7 @@ * sayHelloToMs('Jane', 'Jones'); //=> 'Hello, Ms. Jane Jones!' * @symb R.partial(f, [a, b])(c, d) = f(a, b, c, d) */ + var partial = _createPartialApplicator(_concat); /** @@ -7221,6 +8085,7 @@ * greetMsJaneJones('Hello'); //=> 'Hello, Ms. Jane Jones!' * @symb R.partialRight(f, [a, b])(c, d) = f(c, d, a, b) */ + var partialRight = _createPartialApplicator(flip(_concat)); /** @@ -7247,6 +8112,7 @@ * R.partition(R.includes('s'), { a: 'sss', b: 'ttt', foo: 'bars' }); * // => [ { a: 'sss', foo: 'bars' }, { b: 'ttt' } ] */ + var partition = juxt([filter, reject]); /** @@ -7257,7 +8123,7 @@ * @memberOf R * @since v0.7.0 * @category Relation - * @typedefn Idx = String | Int + * @typedefn Idx = String | Int | Symbol * @sig [Idx] -> a -> {a} -> Boolean * @param {Array} path The path of the nested property to use * @param {*} val The value to compare the nested property with @@ -7273,6 +8139,7 @@ * const isFamous = R.pathEq(['address', 'zipCode'], 90210); * R.filter(isFamous, users); //=> [ user1 ] */ + var pathEq = _curry3(function pathEq(_path, val, obj) { return equals(path(_path, obj), val); }); @@ -7285,7 +8152,7 @@ * @memberOf R * @since v0.18.0 * @category Object - * @typedefn Idx = String | Int + * @typedefn Idx = String | Int | Symbol * @sig a -> [Idx] -> {a} -> a * @param {*} d The default value. * @param {Array} p The path to use. @@ -7296,6 +8163,7 @@ * R.pathOr('N/A', ['a', 'b'], {a: {b: 2}}); //=> 2 * R.pathOr('N/A', ['a', 'b'], {c: {b: 2}}); //=> "N/A" */ + var pathOr = _curry3(function pathOr(d, p, obj) { return defaultTo(d, path(p, obj)); }); @@ -7308,7 +8176,7 @@ * @memberOf R * @since v0.19.0 * @category Logic - * @typedefn Idx = String | Int + * @typedefn Idx = String | Int | Symbol * @sig (a -> Boolean) -> [Idx] -> {a} -> Boolean * @param {Function} pred * @param {Array} propPath @@ -7320,6 +8188,7 @@ * R.pathSatisfies(y => y > 0, ['x', 'y'], {x: {y: 2}}); //=> true * R.pathSatisfies(R.is(Object), [], {x: {y: 2}}); //=> true */ + var pathSatisfies = _curry3(function pathSatisfies(pred, propPath, obj) { return pred(path(propPath, obj)); }); @@ -7342,15 +8211,19 @@ * R.pick(['a', 'd'], {a: 1, b: 2, c: 3, d: 4}); //=> {a: 1, d: 4} * R.pick(['a', 'e', 'f'], {a: 1, b: 2, c: 3, d: 4}); //=> {a: 1} */ + var pick = _curry2(function pick(names, obj) { var result = {}; var idx = 0; + while (idx < names.length) { if (names[idx] in obj) { result[names[idx]] = obj[names[idx]]; } + idx += 1; } + return result; }); @@ -7372,15 +8245,18 @@ * R.pickAll(['a', 'd'], {a: 1, b: 2, c: 3, d: 4}); //=> {a: 1, d: 4} * R.pickAll(['a', 'e', 'f'], {a: 1, b: 2, c: 3, d: 4}); //=> {a: 1, e: undefined, f: undefined} */ + var pickAll = _curry2(function pickAll(names, obj) { var result = {}; var idx = 0; var len = names.length; + while (idx < len) { var name = names[idx]; result[name] = obj[name]; idx += 1; } + return result; }); @@ -7404,58 +8280,19 @@ * const isUpperCase = (val, key) => key.toUpperCase() === key; * R.pickBy(isUpperCase, {a: 1, b: 2, A: 3, B: 4}); //=> {A: 3, B: 4} */ + var pickBy = _curry2(function pickBy(test, obj) { var result = {}; + for (var prop in obj) { if (test(obj[prop], prop, obj)) { result[prop] = obj[prop]; } } + return result; }); - /** - * Returns the left-to-right Kleisli composition of the provided functions, - * each of which must return a value of a type supported by [`chain`](#chain). - * - * `R.pipeK(f, g, h)` is equivalent to `R.pipe(f, R.chain(g), R.chain(h))`. - * - * @func - * @memberOf R - * @since v0.16.0 - * @category Function - * @sig Chain m => ((a -> m b), (b -> m c), ..., (y -> m z)) -> (a -> m z) - * @param {...Function} - * @return {Function} - * @see R.composeK - * @deprecated since v0.26.0 - * @example - * - * // parseJson :: String -> Maybe * - * // get :: String -> Object -> Maybe * - * - * // getStateCode :: Maybe String -> Maybe String - * const getStateCode = R.pipeK( - * parseJson, - * get('user'), - * get('address'), - * get('state'), - * R.compose(Maybe.of, R.toUpper) - * ); - * - * getStateCode('{"user":{"address":{"state":"ny"}}}'); - * //=> Just('NY') - * getStateCode('[Invalid JSON]'); - * //=> Nothing() - * @symb R.pipeK(f, g, h)(a) = R.chain(h, R.chain(g, f(a))) - */ - function pipeK() { - if (arguments.length === 0) { - throw new Error('pipeK requires at least one argument'); - } - return composeK.apply(this, reverse(arguments)); - } - /** * Returns a new list with the given element at the front, followed by the * contents of the list. @@ -7473,6 +8310,7 @@ * * R.prepend('fee', ['fi', 'fo', 'fum']); //=> ['fee', 'fi', 'fo', 'fum'] */ + var prepend = _curry2(function prepend(el, list) { return _concat([el], list); }); @@ -7492,6 +8330,7 @@ * * R.product([2,4,6,8,100,1]); //=> 38400 */ + var product = reduce(multiply, 1); /** @@ -7523,14 +8362,17 @@ * R.useWith(Math.pow, [R.dec, R.inc])(3)(4); //=> 32 * @symb R.useWith(f, [g, h])(a, b) = f(g(a), h(b)) */ + var useWith = _curry2(function useWith(fn, transformers) { - return curryN(transformers.length, function() { + return curryN(transformers.length, function () { var args = []; var idx = 0; + while (idx < transformers.length) { args.push(transformers[idx].call(this, arguments[idx])); idx += 1; } + return fn.apply(this, args.concat(Array.prototype.slice.call(arguments, transformers.length))); }); }); @@ -7547,6 +8389,7 @@ * @param {Array} props The property names to project * @param {Array} objs The objects to query * @return {Array} An array of objects with just the `props` properties. + * @see R.pluck, R.props, R.prop * @example * * const abby = {name: 'Abby', age: 7, hair: 'blond', grade: 2}; @@ -7554,8 +8397,64 @@ * const kids = [abby, fred]; * R.project(['name', 'grade'], kids); //=> [{name: 'Abby', grade: 2}, {name: 'Fred', grade: 7}] */ + var project = useWith(_map, [pickAll, identity]); // passing `identity` gives correct arity + function _promap(f, g, profunctor) { + return function (x) { + return g(profunctor(f(x))); + }; + } + + function XPromap(f, g, xf) { + this.xf = xf; + this.f = f; + this.g = g; + } + + XPromap.prototype['@@transducer/init'] = _xfBase.init; + XPromap.prototype['@@transducer/result'] = _xfBase.result; + + XPromap.prototype['@@transducer/step'] = function (result, input) { + return this.xf['@@transducer/step'](result, _promap(this.f, this.g, input)); + }; + + var _xpromap = _curry3(function _xpromap(f, g, xf) { + return new XPromap(f, g, xf); + }); + + /** + * Takes two functions as pre- and post- processors respectively for a third function, + * i.e. `promap(f, g, h)(x) === g(h(f(x)))`. + * + * Dispatches to the `promap` method of the third argument, if present, + * according to the [FantasyLand Profunctor spec](https://github.com/fantasyland/fantasy-land#profunctor). + * + * Acts as a transducer if a transformer is given in profunctor position. + * + * @func + * @memberOf R + * @since v0.28.0 + * @category Function + * @sig (a -> b) -> (c -> d) -> (b -> c) -> (a -> d) + * @sig Profunctor p => (a -> b) -> (c -> d) -> p b c -> p a d + * @param {Function} f The preprocessor function, a -> b + * @param {Function} g The postprocessor function, c -> d + * @param {Profunctor} profunctor The profunctor instance to be promapped, e.g. b -> c + * @return {Profunctor} The new profunctor instance, e.g. a -> d + * @see R.transduce + * @example + * + * const decodeChar = R.promap(s => s.charCodeAt(), String.fromCharCode, R.add(-8)) + * const decodeString = R.promap(R.split(''), R.join(''), R.map(decodeChar)) + * decodeString("ziuli") //=> "ramda" + * + * @symb R.promap(f, g, h) = x => g(h(f(x))) + * @symb R.promap(f, g, profunctor) = profunctor.promap(f, g) + */ + + var promap = _curry3(_dispatchable(['fantasy-land/promap', 'promap'], _xpromap, _promap)); + /** * Returns `true` if the specified object property is equal, in * [`R.equals`](#equals) terms, to the given value; `false` otherwise. @@ -7581,8 +8480,9 @@ * const hasBrownHair = R.propEq('hair', 'brown'); * R.filter(hasBrownHair, kids); //=> [fred, rusty] */ + var propEq = _curry3(function propEq(name, val, obj) { - return equals(val, obj[name]); + return equals(val, prop(name, obj)); }); /** @@ -7605,14 +8505,16 @@ * R.propIs(Number, 'x', {x: 'foo'}); //=> false * R.propIs(Number, 'x', {}); //=> false */ + var propIs = _curry3(function propIs(type, name, obj) { - return is(type, obj[name]); + return is(type, prop(name, obj)); }); /** - * If the given, non-null object has an own property with the specified name, - * returns the value of that property. Otherwise returns the provided default - * value. + * Return the specified property of the given non-null object if the property + * is present and it's value is not `null`, `undefined` or `NaN`. + * + * Otherwise the first argument is returned. * * @func * @memberOf R @@ -7635,8 +8537,9 @@ * favorite(alice); //=> undefined * favoriteWithDefault(alice); //=> 'Ramda' */ + var propOr = _curry3(function propOr(val, p, obj) { - return pathOr(val, [p], obj); + return defaultTo(val, prop(p, obj)); }); /** @@ -7658,8 +8561,9 @@ * * R.propSatisfies(x => x > 0, 'x', {x: 1, y: 2}); //=> true */ + var propSatisfies = _curry3(function propSatisfies(pred, name, obj) { - return pred(obj[name]); + return pred(prop(name, obj)); }); /** @@ -7674,6 +8578,7 @@ * @param {Array} ps The property names to fetch * @param {Object} obj The object to query * @return {Array} The corresponding values or partially applied function. + * @see R.prop, R.pluck, R.project * @example * * R.props(['x', 'y'], {x: 1, y: 2}); //=> [1, 2] @@ -7682,8 +8587,9 @@ * const fullName = R.compose(R.join(' '), R.props(['first', 'last'])); * fullName({last: 'Bullet-Tooth', age: 33, first: 'Tony'}); //=> 'Tony Bullet-Tooth' */ + var props = _curry2(function props(ps, obj) { - return ps.map(function(p) { + return ps.map(function (p) { return path([p], obj); }); }); @@ -7704,16 +8610,20 @@ * R.range(1, 5); //=> [1, 2, 3, 4] * R.range(50, 53); //=> [50, 51, 52] */ + var range = _curry2(function range(from, to) { if (!(_isNumber(from) && _isNumber(to))) { throw new TypeError('Both arguments to range must be numbers'); } + var result = []; var n = from; + while (n < to) { result.push(n); n += 1; } + return result; }); @@ -7726,7 +8636,8 @@ * right to the left. * * The iterator function receives two values: *(value, acc)*, while the arguments' - * order of `reduce`'s iterator function is *(acc, value)*. + * order of `reduce`'s iterator function is *(acc, value)*. `reduceRight` may use [`reduced`](#reduced) + * to short circuit the iteration. * * Note: `R.reduceRight` does not skip deleted or unassigned indices (sparse * arrays), unlike the native `Array.prototype.reduceRight` method. For more details @@ -7743,7 +8654,7 @@ * @param {*} acc The accumulator value. * @param {Array} list The list to iterate over. * @return {*} The final, accumulated value. - * @see R.reduce, R.addIndex + * @see R.reduce, R.addIndex, R.reduced * @example * * R.reduceRight(R.subtract, 0, [1, 2, 3, 4]) // => (1 - (2 - (3 - (4 - 0)))) = -2 @@ -7759,12 +8670,21 @@ * * @symb R.reduceRight(f, a, [b, c, d]) = f(b, f(c, f(d, a))) */ + var reduceRight = _curry3(function reduceRight(fn, acc, list) { var idx = list.length - 1; + while (idx >= 0) { acc = fn(list[idx], acc); + + if (acc && acc['@@transducer/reduced']) { + acc = acc['@@transducer/value']; + break; + } + idx -= 1; } + return acc; }); @@ -7773,7 +8693,8 @@ * through the list, successively calling the iterator function. `reduceWhile` * also takes a predicate that is evaluated before each step. If the predicate * returns `false`, it "short-circuits" the iteration and returns the current - * value of the accumulator. + * value of the accumulator. `reduceWhile` may alternatively be short-circuited + * via [`reduced`](#reduced). * * @func * @memberOf R @@ -7790,15 +8711,16 @@ * @see R.reduce, R.reduced * @example * - * const isOdd = (acc, x) => x % 2 === 1; + * const isOdd = (acc, x) => x % 2 !== 0; * const xs = [1, 3, 5, 60, 777, 800]; * R.reduceWhile(isOdd, R.add, 0, xs); //=> 9 * * const ys = [2, 4, 6] * R.reduceWhile(isOdd, R.add, 111, ys); //=> 111 */ + var reduceWhile = _curryN(4, [], function _reduceWhile(pred, fn, a, list) { - return _reduce(function(acc, x) { + return _reduce(function (acc, x) { return pred(acc, x) ? fn(acc, x) : _reduced(acc); }, a, list); }); @@ -7808,9 +8730,11 @@ * and transduce functions. The returned value should be considered a black * box: the internal structure is not guaranteed to be stable. * - * Note: this optimization is only available to the below functions: + * This optimization is available to the below functions: * - [`reduce`](#reduce) * - [`reduceWhile`](#reduceWhile) + * - [`reduceBy`](#reduceBy) + * - [`reduceRight`](#reduceRight) * - [`transduce`](#transduce) * * @func @@ -7820,7 +8744,7 @@ * @sig a -> * * @param {*} x The final value of the reduce. * @return {*} The wrapped value. - * @see R.reduce, R.reduceWhile, R.transduce + * @see R.reduce, R.reduceWhile, R.reduceBy, R.reduceRight, R.transduce * @example * * R.reduce( @@ -7828,6 +8752,7 @@ * [], * [1, 2, 3, 4, 5]) // [1, 2, 3] */ + var reduced = _curry1(_reduced); /** @@ -7853,6 +8778,7 @@ * @symb R.times(f, 1) = [f(0)] * @symb R.times(f, 2) = [f(0), f(1)] */ + var times = _curry2(function times(fn, n) { var len = Number(n); var idx = 0; @@ -7861,11 +8787,14 @@ if (len < 0 || isNaN(len)) { throw new RangeError('n must be a non-negative number'); } + list = new Array(len); + while (idx < len) { list[idx] = fn(idx); idx += 1; } + return list; }); @@ -7892,6 +8821,7 @@ * @symb R.repeat(a, 1) = [a] * @symb R.repeat(a, 2) = [a, a] */ + var repeat = _curry2(function repeat(value, n) { return times(always(value), n); }); @@ -7920,6 +8850,7 @@ * // Use the "g" (global) flag to replace all occurrences: * R.replace(/foo/g, 'bar', 'foo foo foo'); //=> 'bar bar bar' */ + var replace = _curry3(function replace(regex, replacement, str) { return str.replace(regex, replacement); }); @@ -7945,15 +8876,18 @@ * const factorials = R.scan(R.multiply, 1, numbers); //=> [1, 1, 2, 6, 24] * @symb R.scan(f, a, [b, c]) = [a, f(a, b), f(f(a, b), c)] */ + var scan = _curry3(function scan(fn, acc, list) { var idx = 0; var len = list.length; var result = [acc]; + while (idx < len) { acc = fn(acc, list[idx]); result[idx + 1] = acc; idx += 1; } + return result; }); @@ -7981,14 +8915,11 @@ * R.sequence(R.of, Just([1, 2, 3])); //=> [Just(1), Just(2), Just(3)] * R.sequence(R.of, Nothing()); //=> [Nothing()] */ + var sequence = _curry2(function sequence(of, traversable) { - return typeof traversable.sequence === 'function' ? - traversable.sequence(of) : - reduceRight( - function(x, acc) { return ap(map(prepend, x), acc); }, - of([]), - traversable - ); + return typeof traversable.sequence === 'function' ? traversable.sequence(of) : reduceRight(function (x, acc) { + return ap(map(prepend, x), acc); + }, of([]), traversable); }); /** @@ -8005,7 +8936,7 @@ * @param {*} v * @param {*} x * @return {*} - * @see R.prop, R.lensIndex, R.lensProp + * @see R.view, R.over, R.lens, R.lensIndex, R.lensProp, R.lensPath * @example * * const xLens = R.lensProp('x'); @@ -8013,6 +8944,7 @@ * R.set(xLens, 4, {x: 1, y: 2}); //=> {x: 4, y: 2} * R.set(xLens, 8, {x: 1, y: 2}); //=> {x: 8, y: 2} */ + var set = _curry3(function set(lens, v, x) { return over(lens, always(v), x); }); @@ -8032,11 +8964,13 @@ * @param {Function} comparator A sorting function :: a -> b -> Int * @param {Array} list The list to sort * @return {Array} a new array with its elements sorted by the comparator function. + * @see R.ascend, R.descend * @example * * const diff = function(a, b) { return a - b; }; * R.sort(diff, [4,2,7,5]); //=> [2, 4, 5, 7] */ + var sort = _curry2(function sort(comparator, list) { return Array.prototype.slice.call(list, 0).sort(comparator); }); @@ -8074,8 +9008,9 @@ * const people = [clara, bob, alice]; * sortByNameCaseInsensitive(people); //=> [alice, bob, clara] */ + var sortBy = _curry2(function sortBy(fn, list) { - return Array.prototype.slice.call(list, 0).sort(function(a, b) { + return Array.prototype.slice.call(list, 0).sort(function (a, b) { var aa = fn(a); var bb = fn(b); return aa < bb ? -1 : aa > bb ? 1 : 0; @@ -8093,6 +9028,7 @@ * @param {Array} functions A list of comparator functions. * @param {Array} list The list to sort. * @return {Array} A new list sorted according to the comarator functions. + * @see R.ascend, R.descend * @example * * const alice = { @@ -8114,14 +9050,17 @@ * ]); * ageNameSort(people); //=> [alice, clara, bob] */ + var sortWith = _curry2(function sortWith(fns, list) { - return Array.prototype.slice.call(list, 0).sort(function(a, b) { + return Array.prototype.slice.call(list, 0).sort(function (a, b) { var result = 0; var i = 0; + while (result === 0 && i < fns.length) { result = fns[i](a, b); i += 1; } + return result; }); }); @@ -8146,6 +9085,7 @@ * * R.split('.', 'a.b.c.xyz.d'); //=> ['a', 'b', 'c', 'xyz', 'd'] */ + var split = invoker(1, 'split'); /** @@ -8166,6 +9106,7 @@ * R.splitAt(5, 'hello world'); //=> ['hello', ' world'] * R.splitAt(-1, 'foobar'); //=> ['fooba', 'r'] */ + var splitAt = _curry2(function splitAt(index, array) { return [slice(0, index, array), slice(index, length(array), array)]; }); @@ -8187,15 +9128,19 @@ * R.splitEvery(3, [1, 2, 3, 4, 5, 6, 7]); //=> [[1, 2, 3], [4, 5, 6], [7]] * R.splitEvery(3, 'foobarbaz'); //=> ['foo', 'bar', 'baz'] */ + var splitEvery = _curry2(function splitEvery(n, list) { if (n <= 0) { throw new Error('First argument to splitEvery must be a positive integer'); } + var result = []; var idx = 0; + while (idx < list.length) { result.push(slice(idx, idx += n, list)); } + return result; }); @@ -8218,6 +9163,7 @@ * * R.splitWhen(R.equals(2), [1, 2, 3, 1, 2, 3]); //=> [[1], [2, 3, 1, 2, 3]] */ + var splitWhen = _curry2(function splitWhen(pred, list) { var idx = 0; var len = list.length; @@ -8231,6 +9177,40 @@ return [prefix, Array.prototype.slice.call(list, idx)]; }); + /** + * Splits an array into slices on every occurrence of a value. + * + * @func + * @memberOf R + * @since v0.26.1 + * @category List + * @sig (a -> Boolean) -> [a] -> [[a]] + * @param {Function} pred The predicate that determines where the array is split. + * @param {Array} list The array to be split. + * @return {Array} + * @example + * + * R.splitWhenever(R.equals(2), [1, 2, 3, 2, 4, 5, 2, 6, 7]); //=> [[1], [3], [4, 5], [6, 7]] + */ + + var splitWhenever = _curryN(2, [], function splitWhenever(pred, list) { + var acc = []; + var curr = []; + + for (var i = 0; i < list.length; i = i + 1) { + if (!pred(list[i])) { + curr.push(list[i]); + } + + if ((i < list.length - 1 && pred(list[i + 1]) || i === list.length - 1) && curr.length > 0) { + acc.push(curr); + curr = []; + } + } + + return acc; + }); + /** * Checks if a list starts with the provided sublist. * @@ -8253,7 +9233,8 @@ * R.startsWith(['a'], ['a', 'b', 'c']) //=> true * R.startsWith(['b'], ['a', 'b', 'c']) //=> false */ - var startsWith = _curry2(function(prefix, list) { + + var startsWith = _curry2(function (prefix, list) { return equals(take(prefix.length, list), prefix); }); @@ -8280,6 +9261,7 @@ * complementaryAngle(30); //=> 60 * complementaryAngle(72); //=> 18 */ + var subtract = _curry2(function subtract(a, b) { return Number(a) - Number(b); }); @@ -8302,6 +9284,7 @@ * R.symmetricDifference([1,2,3,4], [7,6,5,4,3]); //=> [1,2,7,6,5] * R.symmetricDifference([7,6,5,4,3], [1,2,3,4]); //=> [7,6,5,1,2] */ + var symmetricDifference = _curry2(function symmetricDifference(list1, list2) { return concat(difference(list1, list2), difference(list2, list1)); }); @@ -8328,6 +9311,7 @@ * const l2 = [{a: 3}, {a: 4}, {a: 5}, {a: 6}]; * R.symmetricDifferenceWith(eqA, l1, l2); //=> [{a: 1}, {a: 2}, {a: 5}, {a: 6}] */ + var symmetricDifferenceWith = _curry3(function symmetricDifferenceWith(pred, list1, list2) { return concat(differenceWith(pred, list1, list2), differenceWith(pred, list2, list1)); }); @@ -8357,11 +9341,14 @@ * * R.takeLastWhile(x => x !== 'R' , 'Ramda'); //=> 'amda' */ + var takeLastWhile = _curry2(function takeLastWhile(fn, xs) { var idx = xs.length - 1; + while (idx >= 0 && fn(xs[idx])) { idx -= 1; } + return slice(idx + 1, Infinity, xs); }); @@ -8369,13 +9356,17 @@ this.xf = xf; this.f = f; } + XTakeWhile.prototype['@@transducer/init'] = _xfBase.init; XTakeWhile.prototype['@@transducer/result'] = _xfBase.result; - XTakeWhile.prototype['@@transducer/step'] = function(result, input) { + + XTakeWhile.prototype['@@transducer/step'] = function (result, input) { return this.f(input) ? this.xf['@@transducer/step'](result, input) : _reduced(result); }; - var _xtakeWhile = _curry2(function _xtakeWhile(f, xf) { return new XTakeWhile(f, xf); }); + var _xtakeWhile = _curry2(function _xtakeWhile(f, xf) { + return new XTakeWhile(f, xf); + }); /** * Returns a new list containing the first `n` elements of a given list, @@ -8406,12 +9397,15 @@ * * R.takeWhile(x => x !== 'd' , 'Ramda'); //=> 'Ram' */ + var takeWhile = _curry2(_dispatchable(['takeWhile'], _xtakeWhile, function takeWhile(fn, xs) { var idx = 0; var len = xs.length; + while (idx < len && fn(xs[idx])) { idx += 1; } + return slice(0, idx, xs); })); @@ -8419,14 +9413,18 @@ this.xf = xf; this.f = f; } + XTap.prototype['@@transducer/init'] = _xfBase.init; XTap.prototype['@@transducer/result'] = _xfBase.result; - XTap.prototype['@@transducer/step'] = function(result, input) { + + XTap.prototype['@@transducer/step'] = function (result, input) { this.f(input); return this.xf['@@transducer/step'](result, input); }; - var _xtap = _curry2(function _xtap(f, xf) { return new XTap(f, xf); }); + var _xtap = _curry2(function _xtap(f, xf) { + return new XTap(f, xf); + }); /** * Runs the given function with the supplied object, then returns the object. @@ -8448,6 +9446,7 @@ * // logs 'x is 100' * @symb R.tap(f, a) = a */ + var tap = _curry2(_dispatchable([], _xtap, function tap(fn, x) { fn(x); return x; @@ -8474,10 +9473,12 @@ * R.test(/^x/, 'xyz'); //=> true * R.test(/^y/, 'xyz'); //=> false */ + var test = _curry2(function test(pattern, str) { if (!_isRegExp(pattern)) { throw new TypeError('‘test’ requires a value of type RegExp as its first argument; received ' + toString$1(pattern)); } + return _cloneRegExp(pattern).test(str); }); @@ -8498,15 +9499,20 @@ * @see R.otherwise * @example * - * var makeQuery = (email) => ({ query: { email }}); + * const makeQuery = email => ({ query: { email }}); + * const fetchMember = request => + * Promise.resolve({ firstName: 'Bob', lastName: 'Loblaw', id: 42 }); * - * //getMemberName :: String -> Promise ({firstName, lastName}) - * var getMemberName = R.pipe( + * //getMemberName :: String -> Promise ({ firstName, lastName }) + * const getMemberName = R.pipe( * makeQuery, * fetchMember, * R.andThen(R.pick(['firstName', 'lastName'])) * ); + * + * getMemberName('bob@gmail.com').then(console.log); */ + var andThen = _curry2(function andThen(f, p) { _assertPromise('andThen', p); @@ -8528,6 +9534,7 @@ * * R.toLower('XYZ'); //=> 'xyz' */ + var toLower = invoker(0, 'toLowerCase'); /** @@ -8543,18 +9550,21 @@ * @sig {String: *} -> [[String,*]] * @param {Object} obj The object to extract from * @return {Array} An array of key, value arrays from the object's own properties. - * @see R.fromPairs + * @see R.fromPairs, R.keys, R.values * @example * * R.toPairs({a: 1, b: 2, c: 3}); //=> [['a', 1], ['b', 2], ['c', 3]] */ + var toPairs = _curry1(function toPairs(obj) { var pairs = []; + for (var prop in obj) { if (_has(prop, obj)) { pairs[pairs.length] = [prop, obj[prop]]; } } + return pairs; }); @@ -8579,11 +9589,14 @@ * const f = new F(); * R.toPairsIn(f); //=> [['x','X'], ['y','Y']] */ + var toPairsIn = _curry1(function toPairsIn(obj) { var pairs = []; + for (var prop in obj) { pairs[pairs.length] = [prop, obj[prop]]; } + return pairs; }); @@ -8602,6 +9615,7 @@ * * R.toUpper('abc'); //=> 'ABC' */ + var toUpper = invoker(0, 'toUpperCase'); /** @@ -8618,7 +9632,7 @@ * A transducer is a function that accepts a transformer and returns a * transformer and can be composed directly. * - * A transformer is an an object that provides a 2-arity reducing iterator + * A transformer is an object that provides a 2-arity reducing iterator * function, step, 0-arity initial value function, init, and 1-arity result * extraction function, result. The step function is used as the iterator * function in reduce. The result function is used to convert the final @@ -8647,10 +9661,11 @@ * const transducer = R.compose(R.map(R.add(1)), R.take(2)); * R.transduce(transducer, R.flip(R.append), [], numbers); //=> [2, 3] * - * const isOdd = (x) => x % 2 === 1; + * const isOdd = (x) => x % 2 !== 0; * const firstOddTransducer = R.compose(R.filter(isOdd), R.take(1)); * R.transduce(firstOddTransducer, R.flip(R.append), [], R.range(0, 100)); //=> [1] */ + var transduce = curryN(4, function transduce(xf, fn, acc, list) { return _reduce(xf(typeof fn === 'function' ? _xwrap(fn) : fn), acc, list); }); @@ -8679,21 +9694,27 @@ * @symb R.transpose([[a, b], [c, d]]) = [[a, c], [b, d]] * @symb R.transpose([[a, b], [c]]) = [[a, c], [b]] */ + var transpose = _curry1(function transpose(outerlist) { var i = 0; var result = []; + while (i < outerlist.length) { var innerlist = outerlist[i]; var j = 0; + while (j < innerlist.length) { if (typeof result[j] === 'undefined') { result[j] = []; } + result[j].push(innerlist[j]); j += 1; } + i += 1; } + return result; }); @@ -8723,17 +9744,14 @@ * R.traverse(Maybe.of, safeDiv(10), [2, 4, 5]); //=> Maybe.Just([5, 2.5, 2]) * R.traverse(Maybe.of, safeDiv(10), [2, 0, 5]); //=> Maybe.Nothing */ + var traverse = _curry3(function traverse(of, f, traversable) { - return typeof traversable['fantasy-land/traverse'] === 'function' ? - traversable['fantasy-land/traverse'](f, of) : - sequence(of, map(f, traversable)); + return typeof traversable['fantasy-land/traverse'] === 'function' ? traversable['fantasy-land/traverse'](f, of) : typeof traversable.traverse === 'function' ? traversable.traverse(f, of) : sequence(of, map(f, traversable)); }); - var ws = '\x09\x0A\x0B\x0C\x0D\x20\xA0\u1680\u2000\u2001\u2002\u2003' + - '\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028' + - '\u2029\uFEFF'; - var zeroWidth = '\u200b'; - var hasProtoTrim = (typeof String.prototype.trim === 'function'); + var ws = "\t\n\x0B\f\r \xA0\u1680\u2000\u2001\u2002\u2003" + "\u2004\u2005\u2006\u2007\u2008\u2009\u200A\u202F\u205F\u3000\u2028" + "\u2029\uFEFF"; + var zeroWidth = "\u200B"; + var hasProtoTrim = typeof String.prototype.trim === 'function'; /** * Removes (strips) whitespace from both ends of the string. * @@ -8749,15 +9767,14 @@ * R.trim(' xyz '); //=> 'xyz' * R.map(R.trim, R.split(',', 'x, y, z')); //=> ['x', 'y', 'z'] */ - var trim = !hasProtoTrim || ws.trim() || !zeroWidth.trim() ? - _curry1(function trim(str) { - var beginRx = new RegExp('^[' + ws + '][' + ws + ']*'); - var endRx = new RegExp('[' + ws + '][' + ws + ']*$'); - return str.replace(beginRx, '').replace(endRx, ''); - }) : - _curry1(function trim(str) { - return str.trim(); - }); + + var trim = !hasProtoTrim || ws.trim() || !zeroWidth.trim() ? _curry1(function trim(str) { + var beginRx = new RegExp('^[' + ws + '][' + ws + ']*'); + var endRx = new RegExp('[' + ws + '][' + ws + ']*$'); + return str.replace(beginRx, '').replace(endRx, ''); + }) : _curry1(function trim(str) { + return str.trim(); + }); /** * `tryCatch` takes two functions, a `tryer` and a `catcher`. The returned @@ -8774,16 +9791,18 @@ * @sig (...x -> a) -> ((e, ...x) -> a) -> (...x -> a) * @param {Function} tryer The function that may throw. * @param {Function} catcher The function that will be evaluated if `tryer` throws. - * @return {Function} A new function that will catch exceptions and send then to the catcher. + * @return {Function} A new function that will catch exceptions and send them to the catcher. * @example * * R.tryCatch(R.prop('x'), R.F)({x: true}); //=> true - * R.tryCatch(() => { throw 'foo'}, R.always('catched'))('bar') // => 'catched' + * R.tryCatch(() => { throw 'foo'}, R.always('caught'))('bar') // => + * 'caught' * R.tryCatch(R.times(R.identity), R.always([]))('s') // => [] * R.tryCatch(() => { throw 'this is not a valid value'}, (err, value)=>({error : err, value }))('bar') // => {'error': 'this is not a valid value', 'value': 'bar'} */ + var tryCatch = _curry2(function _tryCatch(tryer, catcher) { - return _arity(tryer.length, function() { + return _arity(tryer.length, function () { try { return tryer.apply(this, arguments); } catch (e) { @@ -8816,8 +9835,9 @@ * R.unapply(JSON.stringify)(1, 2, 3); //=> '[1,2,3]' * @symb R.unapply(f)(a, b) = f([a, b]) */ + var unapply = _curry1(function unapply(fn) { - return function() { + return function () { return fn(Array.prototype.slice.call(arguments, 0)); }; }); @@ -8831,7 +9851,7 @@ * @memberOf R * @since v0.2.0 * @category Function - * @sig (* -> b) -> (a -> b) + * @sig (a -> b -> c -> ... -> z) -> (a -> z) * @param {Function} fn The function to wrap. * @return {Function} A new function wrapping `fn`. The new function is guaranteed to be of * arity 1. @@ -8850,22 +9870,26 @@ * takesOneArg(1, 2); //=> [1, undefined] * @symb R.unary(f)(a, b, c) = f(a) */ + var unary = _curry1(function unary(fn) { return nAry(1, fn); }); /** * Returns a function of arity `n` from a (manually) curried function. + * Note that, the returned function is actually a ramda style + * curryied function, which can accept one or more arguments in each + * function calling. * * @func * @memberOf R * @since v0.14.0 * @category Function - * @sig Number -> (a -> b) -> (a -> c) + * @sig Number -> (a -> b -> c ... -> z) -> ((a -> b -> c ...) -> z) * @param {Number} length The arity for the returned function. * @param {Function} fn The function to uncurry. * @return {Function} A new function. - * @see R.curry + * @see R.curry, R.curryN * @example * * const addFour = a => b => c => d => a + b + c + d; @@ -8873,18 +9897,21 @@ * const uncurriedAddFour = R.uncurryN(4, addFour); * uncurriedAddFour(1, 2, 3, 4); //=> 10 */ + var uncurryN = _curry2(function uncurryN(depth, fn) { - return curryN(depth, function() { + return curryN(depth, function () { var currentDepth = 1; var value = fn; var idx = 0; var endIdx; + while (currentDepth <= depth && typeof value === 'function') { endIdx = currentDepth === depth ? arguments.length : idx + value.length; value = value.apply(this, Array.prototype.slice.call(arguments, idx, endIdx)); currentDepth += 1; idx = endIdx; } + return value; }); }); @@ -8914,13 +9941,16 @@ * R.unfold(f, 10); //=> [-10, -20, -30, -40, -50] * @symb R.unfold(f, x) = [f(x)[0], f(f(x)[1])[0], f(f(f(x)[1])[1])[0], ...] */ + var unfold = _curry2(function unfold(fn, seed) { var pair = fn(seed); var result = []; + while (pair && pair.length) { result[result.length] = pair[0]; pair = fn(pair[1]); } + return result; }); @@ -8941,14 +9971,39 @@ * * R.union([1, 2, 3], [2, 3, 4]); //=> [1, 2, 3, 4] */ + var union = _curry2(compose(uniq, _concat)); + function XUniqWith(pred, xf) { + this.xf = xf; + this.pred = pred; + this.items = []; + } + + XUniqWith.prototype['@@transducer/init'] = _xfBase.init; + XUniqWith.prototype['@@transducer/result'] = _xfBase.result; + + XUniqWith.prototype['@@transducer/step'] = function (result, input) { + if (_includesWith(this.pred, input, this.items)) { + return result; + } else { + this.items.push(input); + return this.xf['@@transducer/step'](result, input); + } + }; + + var _xuniqWith = _curry2(function _xuniqWith(pred, xf) { + return new XUniqWith(pred, xf); + }); + /** * Returns a new list containing only one copy of each element in the original * list, based upon the value returned by applying the supplied predicate to * two list elements. Prefers the first item if two items compare equal based * on the predicate. * + * Acts as a transducer if a transformer is given in list position. + * * @func * @memberOf R * @since v0.2.0 @@ -8965,25 +10020,31 @@ * R.uniqWith(strEq)([1, '1', 1]); //=> [1] * R.uniqWith(strEq)(['1', 1, 1]); //=> ['1'] */ - var uniqWith = _curry2(function uniqWith(pred, list) { + + var uniqWith = _curry2(_dispatchable([], _xuniqWith, function (pred, list) { var idx = 0; var len = list.length; var result = []; var item; + while (idx < len) { item = list[idx]; + if (!_includesWith(pred, item, result)) { result[result.length] = item; } + idx += 1; } + return result; - }); + })); /** * Combines two lists into a set (i.e. no duplicates) composed of the elements * of each list. Duplication is determined according to the value returned by - * applying the supplied predicate to two list elements. + * applying the supplied predicate to two list elements. If an element exists + * in both lists, the first element from the first list will be used. * * @func * @memberOf R @@ -9002,6 +10063,7 @@ * const l2 = [{a: 1}, {a: 4}]; * R.unionWith(R.eqBy(R.prop('a')), l1, l2); //=> [{a: 1}, {a: 2}, {a: 4}] */ + var unionWith = _curry3(function unionWith(pred, list1, list2) { return uniqWith(pred, _concat(list1, list2)); }); @@ -9016,7 +10078,7 @@ * @memberOf R * @since v0.18.0 * @category Logic - * @sig (a -> Boolean) -> (a -> a) -> a -> a + * @sig (a -> Boolean) -> (a -> b) -> a -> a | b * @param {Function} pred A predicate function * @param {Function} whenFalseFn A function to invoke when the `pred` evaluates * to a falsy value. @@ -9030,6 +10092,7 @@ * safeInc(null); //=> null * safeInc(1); //=> 2 */ + var unless = _curry3(function unless(pred, whenFalseFn, x) { return pred(x) ? x : whenFalseFn(x); }); @@ -9051,6 +10114,7 @@ * R.unnest([1, [2], [[3]]]); //=> [1, 2, [3]] * R.unnest([[1, 2], [3, 4], [5, 6]]); //=> [1, 2, 3, 4, 5, 6] */ + var unnest = chain(_identity); /** @@ -9072,14 +10136,55 @@ * * R.until(R.gt(R.__, 100), R.multiply(2))(1) // => 128 */ + var until = _curry3(function until(pred, fn, init) { var val = init; + while (!pred(val)) { val = fn(val); } + return val; }); + /** + * + * Deconstructs an array field from the input documents to output a document for each element. + * Each output document is the input document with the value of the array field replaced by the element. + * + * @func + * @memberOf R + * @since v0.28.0 + * @category Object + * @sig String -> {k: [v]} -> [{k: v}] + * @param {String} key The key to determine which property of the object should be unwind + * @param {Object} object The object containing list under property named as key which is to unwind + * @return {List} A new list of object containing the value of input key having list replaced by each element in the object. + * @example + * + * R.unwind('hobbies', { + * name: 'alice', + * hobbies: ['Golf', 'Hacking'], + * colors: ['red', 'green'], + * }); + * // [ + * // { name: 'alice', hobbies: 'Golf', colors: ['red', 'green'] }, + * // { name: 'alice', hobbies: 'Hacking', colors: ['red', 'green'] } + * // ] + */ + + var unwind = _curry2(function (key, object) { + // If key is not in object or key is not as a list in object + if (!(key in object && _isArray(object[key]))) { + return [object]; + } // Map over object[key] which is a list and assoc each element with key + + + return _map(function (item) { + return _assoc(key, item, object); + }, object[key]); + }); + /** * Returns a list of all the properties, including prototype properties, of the * supplied object. @@ -9101,20 +10206,26 @@ * const f = new F(); * R.valuesIn(f); //=> ['X', 'Y'] */ + var valuesIn = _curry1(function valuesIn(obj) { var prop; var vs = []; + for (prop in obj) { vs[vs.length] = obj[prop]; } + return vs; }); - // `Const` is a functor that effectively ignores the function given to `map`. - var Const = function(x) { - return {value: x, 'fantasy-land/map': function() { return this; }}; + var Const = function Const(x) { + return { + value: x, + 'fantasy-land/map': function fantasyLandMap() { + return this; + } + }; }; - /** * Returns a "view" of the given data structure, determined by the given lens. * The lens's focus determines which portion of the data structure is visible. @@ -9128,7 +10239,7 @@ * @param {Lens} lens * @param {*} x * @return {*} - * @see R.prop, R.lensIndex, R.lensProp + * @see R.set, R.over, R.lens, R.lensIndex, R.lensProp, R.lensPath * @example * * const xLens = R.lensProp('x'); @@ -9136,6 +10247,8 @@ * R.view(xLens, {x: 1, y: 2}); //=> 1 * R.view(xLens, {x: 4, y: 2}); //=> 4 */ + + var view = _curry2(function view(lens, x) { // Using `Const` effectively ignores the setter function of the `lens`, // leaving the value returned by the getter function unmodified. @@ -9152,7 +10265,7 @@ * @memberOf R * @since v0.18.0 * @category Logic - * @sig (a -> Boolean) -> (a -> a) -> a -> a + * @sig (a -> Boolean) -> (a -> b) -> a -> a | b * @param {Function} pred A predicate function * @param {Function} whenTrueFn A function to invoke when the `condition` * evaluates to a truthy value. @@ -9170,6 +10283,7 @@ * truncate('12345'); //=> '12345' * truncate('0123456789ABC'); //=> '0123456789…' */ + var when = _curry3(function when(pred, whenTrueFn, x) { return pred(x) ? whenTrueFn(x) : x; }); @@ -9209,15 +10323,62 @@ * pred({a: 'foo', b: 'xxx', x: 10, y: 19}); //=> false * pred({a: 'foo', b: 'xxx', x: 11, y: 20}); //=> false */ + var where = _curry2(function where(spec, testObj) { for (var prop in spec) { if (_has(prop, spec) && !spec[prop](testObj[prop])) { return false; } } + return true; }); + /** + * Takes a spec object and a test object; each of the spec's own properties must be a predicate function. + * Each predicate is applied to the value of the corresponding property of the + * test object. `whereAny` returns true if at least one of the predicates return true, + * false otherwise. + * + * `whereAny` is well suited to declaratively expressing constraints for other + * functions such as [`filter`](#filter) and [`find`](#find). + * + * @func + * @memberOf R + * @since v0.28.0 + * @category Object + * @sig {String: (* -> Boolean)} -> {String: *} -> Boolean + * @param {Object} spec + * @param {Object} testObj + * @return {Boolean} + * @see R.propSatisfies, R.where + * @example + * + * // pred :: Object -> Boolean + * const pred = R.whereAny({ + * a: R.equals('foo'), + * b: R.complement(R.equals('xxx')), + * x: R.gt(R.__, 10), + * y: R.lt(R.__, 20) + * }); + * + * pred({a: 'foo', b: 'xxx', x: 8, y: 34}); //=> true + * pred({a: 'xxx', b: 'xxx', x: 9, y: 21}); //=> false + * pred({a: 'bar', b: 'xxx', x: 10, y: 20}); //=> false + * pred({a: 'foo', b: 'bar', x: 10, y: 20}); //=> true + * pred({a: 'foo', b: 'xxx', x: 11, y: 20}); //=> true + */ + + var whereAny = _curry2(function whereAny(spec, testObj) { + for (var prop in spec) { + if (_has(prop, spec) && spec[prop](testObj[prop])) { + return true; + } + } + + return false; + }); + /** * Takes a spec object and a test object; returns true if the test satisfies * the spec, false otherwise. An object satisfies the spec if, for each of the @@ -9246,6 +10407,7 @@ * pred({a: 1, b: 2, c: 3}); //=> true * pred({a: 1, b: 1}); //=> false */ + var whereEq = _curry2(function whereEq(spec, testObj) { return where(map(equals, spec), testObj); }); @@ -9269,7 +10431,8 @@ * * R.without([1, 2], [1, 2, 1, 3, 4]); //=> [3, 4] */ - var without = _curry2(function(xs, list) { + + var without = _curry2(function (xs, list) { return reject(flip(_includes)(xs), list); }); @@ -9294,6 +10457,7 @@ * R.xor(false, true); //=> true * R.xor(false, false); //=> false */ + var xor = _curry2(function xor(a, b) { return Boolean(!a ^ !b); }); @@ -9316,20 +10480,26 @@ * R.xprod([1, 2], ['a', 'b']); //=> [[1, 'a'], [1, 'b'], [2, 'a'], [2, 'b']] * @symb R.xprod([a, b], [c, d]) = [[a, c], [a, d], [b, c], [b, d]] */ - var xprod = _curry2(function xprod(a, b) { // = xprodWith(prepend); (takes about 3 times as long...) + + var xprod = _curry2(function xprod(a, b) { + // = xprodWith(prepend); (takes about 3 times as long...) var idx = 0; var ilen = a.length; var j; var jlen = b.length; var result = []; + while (idx < ilen) { j = 0; + while (j < jlen) { result[result.length] = [a[idx], b[j]]; j += 1; } + idx += 1; } + return result; }); @@ -9352,14 +10522,17 @@ * R.zip([1, 2, 3], ['a', 'b', 'c']); //=> [[1, 'a'], [2, 'b'], [3, 'c']] * @symb R.zip([a, b, c], [d, e, f]) = [[a, d], [b, e], [c, f]] */ + var zip = _curry2(function zip(a, b) { var rv = []; var idx = 0; var len = Math.min(a.length, b.length); + while (idx < len) { rv[idx] = [a[idx], b[idx]]; idx += 1; } + return rv; }); @@ -9380,14 +10553,17 @@ * * R.zipObj(['a', 'b', 'c'], [1, 2, 3]); //=> {a: 1, b: 2, c: 3} */ + var zipObj = _curry2(function zipObj(keys, values) { var idx = 0; var len = Math.min(keys.length, values.length); var out = {}; + while (idx < len) { out[keys[idx]] = values[idx]; idx += 1; } + return out; }); @@ -9415,14 +10591,17 @@ * //=> [f(1, 'a'), f(2, 'b'), f(3, 'c')] * @symb R.zipWith(fn, [a, b, c], [d, e, f]) = [fn(a, d), fn(b, e), fn(c, f)] */ + var zipWith = _curry3(function zipWith(fn, a, b) { var rv = []; var idx = 0; var len = Math.min(a.length, b.length); + while (idx < len) { rv[idx] = fn(a[idx], b[idx]); idx += 1; } + return rv; }); @@ -9444,6 +10623,7 @@ * R.thunkify(R.identity)(42)(); //=> 42 * R.thunkify((a, b) => a + b)(25, 17)(); //=> 42 */ + var thunkify = _curry1(function thunkify(fn) { return curryN(fn.length, function createThunk() { var fnArgs = arguments; @@ -9463,6 +10643,7 @@ exports.allPass = allPass; exports.always = always; exports.and = and; + exports.andThen = andThen; exports.any = any; exports.anyPass = anyPass; exports.ap = ap; @@ -9481,18 +10662,17 @@ exports.chain = chain; exports.clamp = clamp; exports.clone = clone; + exports.collectBy = collectBy; exports.comparator = comparator; exports.complement = complement; exports.compose = compose; - exports.composeK = composeK; - exports.composeP = composeP; exports.composeWith = composeWith; exports.concat = concat; exports.cond = cond; exports.construct = construct; exports.constructN = constructN; - exports.contains = contains$1; exports.converge = converge; + exports.count = count; exports.countBy = countBy; exports.curry = curry; exports.curryN = curryN; @@ -9581,7 +10761,6 @@ exports.mean = mean; exports.median = median; exports.memoizeWith = memoizeWith; - exports.merge = merge; exports.mergeAll = mergeAll; exports.mergeDeepLeft = mergeDeepLeft; exports.mergeDeepRight = mergeDeepRight; @@ -9593,6 +10772,8 @@ exports.mergeWithKey = mergeWithKey; exports.min = min; exports.minBy = minBy; + exports.modify = modify; + exports.modifyPath = modifyPath; exports.modulo = modulo; exports.move = move; exports.multiply = multiply; @@ -9606,30 +10787,31 @@ exports.objOf = objOf; exports.of = of; exports.omit = omit; + exports.on = on; exports.once = once; exports.or = or; exports.otherwise = otherwise; exports.over = over; exports.pair = pair; exports.partial = partial; + exports.partialObject = partialObject; exports.partialRight = partialRight; exports.partition = partition; exports.path = path; - exports.paths = paths; exports.pathEq = pathEq; exports.pathOr = pathOr; exports.pathSatisfies = pathSatisfies; + exports.paths = paths; exports.pick = pick; exports.pickAll = pickAll; exports.pickBy = pickBy; exports.pipe = pipe; - exports.pipeK = pipeK; - exports.pipeP = pipeP; exports.pipeWith = pipeWith; exports.pluck = pluck; exports.prepend = prepend; exports.product = product; exports.project = project; + exports.promap = promap; exports.prop = prop; exports.propEq = propEq; exports.propIs = propIs; @@ -9658,6 +10840,7 @@ exports.splitAt = splitAt; exports.splitEvery = splitEvery; exports.splitWhen = splitWhen; + exports.splitWhenever = splitWhenever; exports.startsWith = startsWith; exports.subtract = subtract; exports.sum = sum; @@ -9670,7 +10853,7 @@ exports.takeWhile = takeWhile; exports.tap = tap; exports.test = test; - exports.andThen = andThen; + exports.thunkify = thunkify; exports.times = times; exports.toLower = toLower; exports.toPairs = toPairs; @@ -9695,6 +10878,7 @@ exports.unless = unless; exports.unnest = unnest; exports.until = until; + exports.unwind = unwind; exports.update = update; exports.useWith = useWith; exports.values = values; @@ -9702,6 +10886,7 @@ exports.view = view; exports.when = when; exports.where = where; + exports.whereAny = whereAny; exports.whereEq = whereEq; exports.without = without; exports.xor = xor; @@ -9709,8 +10894,7 @@ exports.zip = zip; exports.zipObj = zipObj; exports.zipWith = zipWith; - exports.thunkify = thunkify; Object.defineProperty(exports, '__esModule', { value: true }); -})); +}))); diff --git a/dist/ramda.min.js b/dist/ramda.min.js index b75c5e898b..b6f32d53ba 100644 --- a/dist/ramda.min.js +++ b/dist/ramda.min.js @@ -1 +1 @@ -!function(t,n){"object"==typeof exports&&"undefined"!=typeof module?n(exports):"function"==typeof define&&define.amd?define(["exports"],n):n((t=t||self).R={})}(this,function(t){"use strict";function a(t){return null!=t&&"object"==typeof t&&!0===t["@@functional/placeholder"]}function o(r){return function t(n){return 0===arguments.length||a(n)?t:r.apply(this,arguments)}}function n(e){return function t(n,r){switch(arguments.length){case 0:return t;case 1:return a(n)?t:o(function(t){return e(n,t)});default:return a(n)&&a(r)?t:a(n)?o(function(t){return e(t,r)}):a(r)?o(function(t){return e(n,t)}):e(n,r)}}}var r=n(function(t,n){return+t+ +n});function i(t,n){var r,e=(t=t||[]).length,u=(n=n||[]).length,i=[];for(r=0;r":ln(t,n)}function t(n,t){return x(function(t){return nn(t)+": "+u(n[t])},t.slice().sort())}switch(Object.prototype.toString.call(r)){case"[object Arguments]":return"(function() { return arguments; }("+x(u,r).join(", ")+"))";case"[object Array]":return"["+x(u,r).concat(t(r,sn(function(t){return/^\d+$/.test(t)},U(r)))).join(", ")+"]";case"[object Boolean]":return"object"==typeof r?"new Boolean("+u(r.valueOf())+")":""+r;case"[object Date]":return"new Date("+(isNaN(r.valueOf())?u(NaN):nn(en(r)))+")";case"[object Null]":return"null";case"[object Number]":return"object"==typeof r?"new Number("+u(r.valueOf())+")":1/r==-1/0?"-0":r.toString(10);case"[object String]":return"object"==typeof r?"new String("+u(r.valueOf())+")":nn(r);case"[object Undefined]":return"undefined";default:if("function"==typeof r.toString){var n=""+r;if("[object Object]"!=n)return n}return"{"+t(r,U(r)).join(", ")+"}"}}var pn=o(function(t){return ln(t,[])}),hn=n(function(t,n){if(p(t)){if(p(n))return t.concat(n);throw new TypeError(pn(n)+" is not an array")}if(w(t)){if(w(n))return t+n;throw new TypeError(pn(n)+" is not a string")}if(null!=t&&dt(t["fantasy-land/concat"]))return t["fantasy-land/concat"](n);if(null!=t&&dt(t.concat))return t.concat(n);throw new TypeError(pn(t)+' does not have a method named "concat" or "fantasy-land/concat"')}),yn=o(function(n){return f($(b,0,D(function(t){return t[0].length},n)),function(){for(var t=0;tt(n)?r:n}),pe=$(r,0),he=o(function(t){return pe(t)/t.length}),ye=o(function(t){var n=t.length;if(0===n)return NaN;var r=2-n%2,e=(n-r)/2;return he(Array.prototype.slice.call(t,0).sort(function(t,n){return t":an(t,n)}function t(n,t){return w(function(t){return Zt(t)+": "+u(n[t])},t.slice().sort())}switch(Object.prototype.toString.call(r)){case"[object Arguments]":return"(function() { return arguments; }("+w(u,r).join(", ")+"))";case"[object Array]":return"["+w(u,r).concat(t(r,cn(function(t){return/^\d+$/.test(t)},D(r)))).join(", ")+"]";case"[object Boolean]":return"object"===f(r)?"new Boolean("+u(r.valueOf())+")":""+r;case"[object Date]":return"new Date("+(isNaN(r.valueOf())?u(NaN):Zt(tn(r)))+")";case"[object Null]":return"null";case"[object Number]":return"object"===f(r)?"new Number("+u(r.valueOf())+")":1/r==-1/0?"-0":r.toString(10);case"[object String]":return"object"===f(r)?"new String("+u(r.valueOf())+")":Zt(r);case"[object Undefined]":return"undefined";default:if("function"==typeof r.toString){var n=""+r;if("[object Object]"!=n)return n}return"{"+t(r,D(r)).join(", ")+"}"}}var sn=o(function(t){return an(t,[])}),fn=n(function(t,n){if(h(t)){if(h(n))return t.concat(n);throw new TypeError(sn(n)+" is not an array")}if(j(t)){if(j(n))return t+n;throw new TypeError(sn(n)+" is not a string")}if(null!=t&&dt(t["fantasy-land/concat"]))return t["fantasy-land/concat"](n);if(null!=t&&dt(t.concat))return t.concat(n);throw new TypeError(sn(t)+' does not have a method named "concat" or "fantasy-land/concat"')}),ln=o(function(n){return s(K(x,0,z(function(t){return t[0].length},n)),function(){for(var t=0;tt(n)?r:n}),he=K(r,0),ye=o(function(t){return he(t)/t.length}),de=o(function(t){var n=t.length;if(0===n)return NaN;var r=2-n%2,e=(n-r)/2;return ye(Array.prototype.slice.call(t,0).sort(function(t,n){return t (b -> a) -> [b] -> [[b]] diff --git a/source/count.js b/source/count.js index 4b444b3071..02a0978caf 100644 --- a/source/count.js +++ b/source/count.js @@ -7,6 +7,7 @@ import curry from './curry.js'; * * @func * @memberOf R + * @since v0.28.0 * @category List * @sig (a -> Boolean) -> [a] -> Number * @param {Function} predicate to match items against diff --git a/source/modify.js b/source/modify.js index 25ffd55308..b10e6efadd 100644 --- a/source/modify.js +++ b/source/modify.js @@ -11,6 +11,7 @@ import modifyPath from './modifyPath.js'; * * @func * @memberOf R + * @since v0.28.0 * @category Object * @sig Idx -> (v -> v) -> {k: v} -> {k: v} * @param {String|Number} prop The property to be modified. diff --git a/source/modifyPath.js b/source/modifyPath.js index 4760e5644a..698e3b6dd1 100644 --- a/source/modifyPath.js +++ b/source/modifyPath.js @@ -16,6 +16,7 @@ import _modify from './internal/_modify.js'; * * @func * @memberOf R + * @since v0.28.0 * @category Object * @sig [Idx] -> (v -> v) -> {k: v} -> {k: v} * @param {Array} path The path to be modified. diff --git a/source/on.js b/source/on.js index 787d3e6956..c89a54aa22 100644 --- a/source/on.js +++ b/source/on.js @@ -9,6 +9,7 @@ import curryN from './internal/_curryN.js'; * * @func * @memberOf R + * @since v0.28.0 * @category Function * @sig ((a, a) -> b) -> (c -> a) -> c -> c -> b * @param {Function} f a binary function diff --git a/source/partialObject.js b/source/partialObject.js index 85a4484527..35d703329e 100644 --- a/source/partialObject.js +++ b/source/partialObject.js @@ -8,6 +8,7 @@ import _curry2 from './internal/_curry2.js'; * * @func * @memberOf R + * @since v0.28.0 * @category Function * @sig (({ a, b, c, ..., n }) -> x) -> { a, b, c, ...} -> ({ d, e, f, ..., n } -> x) * @param {Function} f diff --git a/source/promap.js b/source/promap.js index 86805e7c49..cd055d0e07 100644 --- a/source/promap.js +++ b/source/promap.js @@ -15,6 +15,7 @@ import _xpromap from './internal/_xpromap.js'; * * @func * @memberOf R + * @since v0.28.0 * @category Function * @sig (a -> b) -> (c -> d) -> (b -> c) -> (a -> d) * @sig Profunctor p => (a -> b) -> (c -> d) -> p b c -> p a d diff --git a/source/unwind.js b/source/unwind.js index 46ef62da4e..b593f2f069 100644 --- a/source/unwind.js +++ b/source/unwind.js @@ -10,6 +10,7 @@ import _assoc from './internal/_assoc.js'; * * @func * @memberOf R + * @since v0.28.0 * @category Object * @sig String -> {k: [v]} -> [{k: v}] * @param {String} key The key to determine which property of the object should be unwind diff --git a/source/whereAny.js b/source/whereAny.js index 7002299fea..0297ec1b83 100644 --- a/source/whereAny.js +++ b/source/whereAny.js @@ -13,6 +13,7 @@ import _has from './internal/_has.js'; * * @func * @memberOf R + * @since v0.28.0 * @category Object * @sig {String: (* -> Boolean)} -> {String: *} -> Boolean * @param {Object} spec From 698bdc4efa56dae0f41b6529b860c3a6ed02a0ec Mon Sep 17 00:00:00 2001 From: Scott Sauyet Date: Tue, 18 Jan 2022 20:57:12 -0500 Subject: [PATCH 093/111] Reduce doc enhancement (#3220) * docs: Warn about mutating accumulators` -m " Fixes #3200 * docs: Warn about mutating accumulators Fixes #3200 * Remove trailing spaces --- source/reduce.js | 6 ++++++ source/reduceRight.js | 6 ++++++ 2 files changed, 12 insertions(+) diff --git a/source/reduce.js b/source/reduce.js index 23549aec0a..853a4b5d49 100644 --- a/source/reduce.js +++ b/source/reduce.js @@ -18,6 +18,12 @@ import _reduce from './internal/_reduce.js'; * on this behavior, see: * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduce#Description * + * Be cautious of mutating and returning the accumulator. If you reuse it across + * invocations, it will continue to accumulate onto the same value. The general + * recommendation is to always return a new value. If you can't do so for + * performance reasons, then be sure to reinitialize the accumulator on each + * invocation. + * * Dispatches to the `reduce` method of the third argument, if present. When * doing so, it is up to the user to handle the [`R.reduced`](#reduced) * shortcuting, as this is not implemented by `reduce`. diff --git a/source/reduceRight.js b/source/reduceRight.js index 0d87810dd4..bc7bd1bc8d 100644 --- a/source/reduceRight.js +++ b/source/reduceRight.js @@ -18,6 +18,12 @@ import _curry3 from './internal/_curry3.js'; * on this behavior, see: * https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Array/reduceRight#Description * + * Be cautious of mutating and returning the accumulator. If you reuse it across + * invocations, it will continue to accumulate onto the same value. The general + * recommendation is to always return a new value. If you can't do so for + * performance reasons, then be sure to reinitialize the accumulator on each + * invocation. + * * @func * @memberOf R * @since v0.1.0 From 31ed57432232da47f697fe8bc0a9e4789558d5f2 Mon Sep 17 00:00:00 2001 From: Julien Gonzalez Date: Wed, 19 Jan 2022 21:15:32 +0000 Subject: [PATCH 094/111] refactor: assign partialObject function to var so that JSDoc can infer its name (#3221) fix ramda/ramda.github.io#261 --- source/partialObject.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/partialObject.js b/source/partialObject.js index 35d703329e..8d67f6e64a 100644 --- a/source/partialObject.js +++ b/source/partialObject.js @@ -29,5 +29,5 @@ import _curry2 from './internal/_curry2.js'; * sayHelloToMs({ firstName: 'Jane', lastName: 'Jones' }); //=> 'Hello, Ms. Jane Jones!' * @symb R.partialObject(f, { a, b })({ c, d }) = f({ a, b, c, d }) */ - -export default _curry2((f, o) => (props) => f.call(this, mergeDeepRight(o, props))); +var partialObject = _curry2((f, o) => (props) => f.call(this, mergeDeepRight(o, props))); +export default partialObject; From 56072b23532058d99d2f85108ef7fb8387a98c8e Mon Sep 17 00:00:00 2001 From: Matthias Seemann <296476+semmel@users.noreply.github.com> Date: Thu, 20 Jan 2022 01:49:32 +0100 Subject: [PATCH 095/111] Remove placeholder check from `identical` (#3210) * Remove placeholder check from identical This fixes [#2533](https://github.com/ramda/ramda/issues/2533), were using identical with cross-origin browser window objects throws a DOMException. The reason for the exception is the checking for the placeholder property in the `curry*` functions. Since placeholder support makes no sense for commutative functions it can be removed from identical. This is done here by rewriting `identical` as `isObject` in a self-written `curry2` wrapper. * test: identical: check properly curried function and placeholder property access * fix: support more than 2 arguments to identical * test(identical): mock cross-origin window, doc: added comment to source file why cannot use _curry2 as before * test: excempt identical from placeholder check, doc: note about missing placeholder support * linting --- source/identical.js | 29 +++++++++++++++++++++++-- test/identical.js | 52 +++++++++++++++++++++++++++++++++++++++++++++ test/invariants.js | 3 ++- 3 files changed, 81 insertions(+), 3 deletions(-) diff --git a/source/identical.js b/source/identical.js index 025efb67be..e60f72ef3f 100644 --- a/source/identical.js +++ b/source/identical.js @@ -1,5 +1,4 @@ import _objectIs from './internal/_objectIs.js'; -import _curry2 from './internal/_curry2.js'; /** @@ -9,6 +8,8 @@ import _curry2 from './internal/_curry2.js'; * * Note this is merely a curried version of ES6 `Object.is`. * + * `identical` does not support the `__` placeholder. + * * @func * @memberOf R * @since v0.15.0 @@ -27,5 +28,29 @@ import _curry2 from './internal/_curry2.js'; * R.identical(0, -0); //=> false * R.identical(NaN, NaN); //=> true */ -var identical = _curry2(_objectIs); +var identical = function(a, b) { + switch (arguments.length) { + case 0: + return identical; + case 1: + return (function() { + return function unaryIdentical(_b) { + switch (arguments.length) { + case 0: + return unaryIdentical; + default: + return _objectIs(a, _b); + } + }; + }()); + default: + return _objectIs(a, b); + } +}; + +// In order to support Cross-origin Window objects as arguments to identical, +// it cannot be implemented as _curry2(_objectIs). +// The reason is that _curry2 checks if a function argument is the placeholder __ +// by accessing a paritcular property. However, across URL origins access +// to most properties of Window is forbidden. export default identical; diff --git a/test/identical.js b/test/identical.js index 8be618889b..4f90b813b5 100644 --- a/test/identical.js +++ b/test/identical.js @@ -1,5 +1,9 @@ var R = require('../source'); var eq = require('./shared/eq'); +var assert = require('assert'); + +// see https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy#cross-origin_script_api_access +const allowedCrossOriginProperties = ['blur', 'close', 'focus', 'postMessage', 'closed', 'frames', 'length', 'location', 'opener', 'parent', 'top', 'window']; describe('identical', function() { @@ -26,4 +30,52 @@ describe('identical', function() { eq(R.identical(new Number(0), new Number(0)), false); }); + it('is auto-curried', function() { + assert.strictEqual(R.identical.length, 2); + var unaryFn = R.identical('foo'); + assert.strictEqual(unaryFn.length, 1); + eq(unaryFn('bar'), false); + eq(unaryFn('foo'), true); + }); + + it('does not access the placeholder property of its arguments which is forbidden for cross-origin browser windows', function() { + // mock cross origin window object + // Access is just to a few properties allowed + // See https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy#cross-origin_script_api_access + + function CrossOriginWindow() {} + + // disallow instanceof + Object.defineProperty( + CrossOriginWindow, + Symbol.hasInstance, + { value: function() { throw new Error('Not allowed instanceof!'); } } + ); + + const crossOriginWindowObject = new Proxy( + new CrossOriginWindow(), + { + get(target, key, context) { + if (allowedCrossOriginProperties.includes(key)) { + return Reflect.get(target, key, context); + } + throw new Error(`Not allowed property "${key}" access!`); + } + } + ); + + assert.doesNotThrow( + () => R.identical(crossOriginWindowObject, {}), + Error + ); + + assert.doesNotThrow( + () => R.identical({}, crossOriginWindowObject), + Error + ); + + eq(R.identical(crossOriginWindowObject, crossOriginWindowObject), true); + eq(R.identical(crossOriginWindowObject, {}), false); + }); + }); diff --git a/test/invariants.js b/test/invariants.js index fe798bc9dd..971d66cea4 100644 --- a/test/invariants.js +++ b/test/invariants.js @@ -15,8 +15,9 @@ describe('invariants', function() { }); it('-- applying function f with length n (where n > 0) to R.__ gives function with length n', function() { + var unsupportedFunctionNames = ['identical']; for (var prop in R) { - if (typeof R[prop] === 'function' && R[prop].length > 0) { + if (typeof R[prop] === 'function' && R[prop].length > 0 && unsupportedFunctionNames.indexOf(prop) === -1) { var result = R[prop](R.__); eq(typeof result, 'function'); eq(result.length, R[prop].length); From 7f37e8a4243de2b6c39d0490ef282873e405f9ad Mon Sep 17 00:00:00 2001 From: Scott Sauyet Date: Fri, 21 Jan 2022 13:46:01 -0500 Subject: [PATCH 096/111] Fix merge with nil objects (#3222) --- source/mergeWithKey.js | 2 ++ test/mergeAll.js | 12 ++++++++++++ test/mergeLeft.js | 17 +++++++++++++++++ test/mergeRight.js | 18 ++++++++++++++++++ test/mergeWith.js | 22 ++++++++++++++++++++++ test/mergeWithKey.js | 21 +++++++++++++++++++++ 6 files changed, 92 insertions(+) diff --git a/source/mergeWithKey.js b/source/mergeWithKey.js index 5688c30e66..40cf66eb6d 100644 --- a/source/mergeWithKey.js +++ b/source/mergeWithKey.js @@ -30,6 +30,8 @@ import _has from './internal/_has.js'; var mergeWithKey = _curry3(function mergeWithKey(fn, l, r) { var result = {}; var k; + l = l || {}; + r = r || {}; for (k in l) { if (_has(k, l)) { diff --git a/test/mergeAll.js b/test/mergeAll.js index 539c32bb29..2e961148c8 100644 --- a/test/mergeAll.js +++ b/test/mergeAll.js @@ -19,4 +19,16 @@ describe('mergeAll', function() { eq(res, {fizz: 'buzz'}); }); + describe('acts as if nil values are simply empty objects', function() { + it('... if the first object is nil', function() { + eq(R.mergeAll([null, {foo:1}, {foo:2}, {bar:2}]), {foo:2, bar:2}); + }); + it('... if the last object is nil', function() { + eq(R.mergeAll([{foo:1}, {foo:2}, {bar:2}, undefined]), {foo:2, bar:2}); + }); + it('... if an intermediate object is nil', function() { + eq(R.mergeAll([{foo:1}, {foo:2}, null, {bar:2}]), {foo:2, bar:2}); + }); + }); + }); diff --git a/test/mergeLeft.js b/test/mergeLeft.js index ea7d7fabdb..4244ac3015 100644 --- a/test/mergeLeft.js +++ b/test/mergeLeft.js @@ -40,4 +40,21 @@ describe('mergeLeft', function() { eq(res, { x: { u: 1, v: 2 }, y: 0, z: 0 }); }); + describe('acts as if nil values are simply empty objects', function() { + var a = {w: 1, x: 2}; + var b = {w: 100, y: 3, z: 4}; + + it('... if the first object is nil', function() { + eq(R.mergeLeft(null, b), b); + }); + + it('... if the second object is nil', function() { + eq(R.mergeLeft(a, undefined), a); + }); + + it('... if both objects are nil', function() { + eq(R.mergeLeft(null, undefined), {}); + }); + }); + }); diff --git a/test/mergeRight.js b/test/mergeRight.js index 4247b8205d..6c1ce90c1c 100644 --- a/test/mergeRight.js +++ b/test/mergeRight.js @@ -40,4 +40,22 @@ describe('mergeRight', function() { eq(res, { x: { u: 3, w: 4 }, y: 0, z: 0 }); }); + describe('acts as if nil values are simply empty objects', function() { + var a = {w: 1, x: 2}; + var b = {w: 100, y: 3, z: 4}; + + it('... if the first object is nil', function() { + eq(R.mergeRight(null, b), b); + }); + + it('... if the second object is nil', function() { + eq(R.mergeRight(a, undefined), a); + }); + + it('... if both objects are nil', function() { + eq(R.mergeRight(null, undefined), {}); + }); + + }); + }); diff --git a/test/mergeWith.js b/test/mergeWith.js index 82dccc6709..031e9549b9 100644 --- a/test/mergeWith.js +++ b/test/mergeWith.js @@ -37,4 +37,26 @@ describe('mergeWith', function() { eq(R.mergeWith(last, new Cla(), {w: 1}), {w: 1}); }); + describe('acts as if nil values are simply empty objects', function() { + it('... if the first object is nil and the second empty', function() { + eq(R.mergeWith(R.concat, undefined, {}), {}); + }); + + it('... if the first object is empty and the second nil', function() { + eq(R.mergeWith(R.concat, {}, null), {}); + }); + + it('... if both objects are nil', function() { + eq(R.mergeWith(R.concat, undefined, null), {}); + }); + + it('... if the first object is not empty and the second is nil', function() { + eq(R.mergeWith(R.concat, {a: 'a'}, null), {a: 'a'}); + }); + + it('... if the first object is nil and the second is not empty', function() { + eq(R.mergeWith(R.concat, undefined, {a: 'a'}), {a: 'a'}); + }); + }); + }); diff --git a/test/mergeWithKey.js b/test/mergeWithKey.js index bcea5b408a..f19d6937c2 100644 --- a/test/mergeWithKey.js +++ b/test/mergeWithKey.js @@ -37,4 +37,25 @@ describe('mergeWithKey', function() { eq(R.mergeWithKey(last, a, new Cla()), {w: 1, x: 2}); }); + describe('acts as if nil values are simply empty objects', function() { + var a = {a: 'b', x: 'd'}; + var b = {a: 'c', y: 'e'}; + const combine = function(k, a, b) { return k + a + b; }; + + eq(R.mergeWithKey(combine, a, b), {a: 'abc', x: 'd', y: 'e'}); + + it('... if the first object is nil', function() { + eq(R.mergeWithKey(combine, null, b), b); + + }); + + it('... if the second object is nil', function() { + eq(R.mergeWithKey(combine, a, undefined), a); + }); + + it('... if both objects are nil', function() { + eq(R.mergeWithKey(combine, null, undefined), {}); + }); + }); + }); From 727770903c09351dc1a981b03ba87a97b9d1cd3e Mon Sep 17 00:00:00 2001 From: Cotton Hou Date: Sun, 23 Jan 2022 01:15:53 +0800 Subject: [PATCH 097/111] Upgrade and fixing up eslint-plugin-import (#3223) * Update eslint-plugin-import to ^2.25.4 * Lint extensions fixing under lib/* and test/* --- lib/bench/concat.bench.js | 2 +- lib/bench/curry.bench.js | 2 +- lib/bench/each.bench.js | 2 +- lib/bench/either.bench.js | 2 +- lib/bench/filter-where.bench.js | 2 +- lib/bench/filter.bench.js | 2 +- lib/bench/find-where.bench.js | 2 +- lib/bench/find.bench.js | 2 +- lib/bench/findIndex-where.bench.js | 2 +- lib/bench/findIndex.bench.js | 2 +- lib/bench/includes.bench.js | 2 +- lib/bench/indexof.bench.js | 2 +- lib/bench/map.bench.js | 2 +- lib/bench/maxWith.bench.js | 2 +- lib/bench/propEq.bench.js | 2 +- lib/bench/reduce.bench.js | 2 +- lib/bench/uniq.bench.js | 2 +- lib/sauce/browsers.js | 10 +- lib/sauce/conf.js | 2 +- package-lock.json | 918 ++++++++++++++-------------- package.json | 2 +- test/F.js | 4 +- test/T.js | 4 +- test/add.js | 4 +- test/addIndex.js | 4 +- test/adjust.js | 4 +- test/all.js | 6 +- test/allPass.js | 4 +- test/always.js | 4 +- test/and.js | 4 +- test/andThen.js | 4 +- test/any.js | 6 +- test/anyPass.js | 4 +- test/ap.js | 4 +- test/aperture.js | 4 +- test/append.js | 4 +- test/apply.js | 4 +- test/applySpec.js | 4 +- test/applyTo.js | 4 +- test/ascend.js | 4 +- test/assoc.js | 4 +- test/assocPath.js | 4 +- test/binary.js | 4 +- test/bind.js | 4 +- test/both.js | 4 +- test/call.js | 4 +- test/chain.js | 8 +- test/clamp.js | 4 +- test/clone.js | 4 +- test/collectBy.js | 2 +- test/comparator.js | 4 +- test/complement.js | 4 +- test/compose.js | 4 +- test/composeWith.js | 4 +- test/concat.js | 4 +- test/cond.js | 4 +- test/construct.js | 4 +- test/constructN.js | 4 +- test/converge.js | 4 +- test/count.js | 4 +- test/countBy.js | 4 +- test/curry.js | 4 +- test/curryN.js | 4 +- test/dec.js | 4 +- test/defaultTo.js | 4 +- test/descend.js | 4 +- test/difference.js | 4 +- test/differenceWith.js | 4 +- test/dissoc.js | 4 +- test/dissocPath.js | 4 +- test/divide.js | 4 +- test/drop.js | 4 +- test/dropLast.js | 4 +- test/dropLastWhile.js | 4 +- test/dropRepeats.js | 4 +- test/dropRepeatsWith.js | 4 +- test/dropWhile.js | 4 +- test/either.js | 4 +- test/empty.js | 4 +- test/endsWith.js | 4 +- test/eqBy.js | 4 +- test/eqProps.js | 4 +- test/equals.js | 4 +- test/evolve.js | 4 +- test/filter.js | 6 +- test/find.js | 6 +- test/findIndex.js | 6 +- test/findLast.js | 6 +- test/findLastIndex.js | 6 +- test/flatten.js | 4 +- test/flip.js | 4 +- test/forEach.js | 4 +- test/forEachObjIndexed.js | 4 +- test/fromPairs.js | 4 +- test/groupBy.js | 6 +- test/groupWith.js | 4 +- test/gt.js | 4 +- test/gte.js | 4 +- test/has.js | 4 +- test/hasIn.js | 4 +- test/hasPath.js | 4 +- test/head.js | 4 +- test/helpers/test.examplesRunner.js | 2 +- test/identical.js | 4 +- test/identity.js | 4 +- test/ifElse.js | 4 +- test/inc.js | 4 +- test/includes.js | 4 +- test/index.js | 4 +- test/indexBy.js | 4 +- test/indexOf.js | 4 +- test/init.js | 4 +- test/innerJoin.js | 4 +- test/insert.js | 4 +- test/insertAll.js | 4 +- test/internal/_curry2.js | 6 +- test/internal/_curry3.js | 6 +- test/internal/_isArrayLike.js | 4 +- test/intersection.js | 4 +- test/intersperse.js | 4 +- test/into.js | 4 +- test/invariants.js | 4 +- test/invert.js | 4 +- test/invertObj.js | 4 +- test/invoker.js | 4 +- test/is.js | 4 +- test/isEmpty.js | 4 +- test/isNil.js | 4 +- test/join.js | 4 +- test/juxt.js | 4 +- test/keys.js | 4 +- test/keysIn.js | 4 +- test/last.js | 4 +- test/lastIndexOf.js | 4 +- test/length.js | 4 +- test/lensIndex.js | 4 +- test/lensPath.js | 4 +- test/lensProp.js | 4 +- test/lenses.js | 4 +- test/lift.js | 6 +- test/liftN.js | 6 +- test/lt.js | 4 +- test/lte.js | 4 +- test/map.js | 8 +- test/mapAccum.js | 4 +- test/mapAccumRight.js | 4 +- test/mapObjIndexed.js | 4 +- test/match.js | 4 +- test/mathMod.js | 4 +- test/max.js | 4 +- test/maxBy.js | 4 +- test/mean.js | 4 +- test/median.js | 4 +- test/memoizeWith.js | 4 +- test/mergeAll.js | 4 +- test/mergeDeepLeft.js | 4 +- test/mergeDeepRight.js | 4 +- test/mergeDeepWith.js | 4 +- test/mergeDeepWithKey.js | 4 +- test/mergeLeft.js | 4 +- test/mergeRight.js | 4 +- test/mergeWith.js | 4 +- test/mergeWithKey.js | 4 +- test/min.js | 4 +- test/minBy.js | 4 +- test/modify.js | 4 +- test/modifyPath.js | 4 +- test/modulo.js | 4 +- test/move.js | 4 +- test/multiply.js | 4 +- test/nAry.js | 4 +- test/negate.js | 4 +- test/none.js | 4 +- test/not.js | 4 +- test/nth.js | 4 +- test/nthArg.js | 4 +- test/o.js | 4 +- test/objOf.js | 4 +- test/of.js | 4 +- test/omit.js | 4 +- test/on.js | 4 +- test/once.js | 4 +- test/or.js | 4 +- test/otherwise.js | 4 +- test/pair.js | 4 +- test/partial.js | 4 +- test/partialObject.js | 4 +- test/partialRight.js | 4 +- test/partition.js | 4 +- test/path.js | 4 +- test/pathEq.js | 4 +- test/pathOr.js | 4 +- test/pathSatisfies.js | 4 +- test/paths.js | 4 +- test/pick.js | 4 +- test/pickAll.js | 4 +- test/pickBy.js | 4 +- test/pipe.js | 4 +- test/pipeWith.js | 4 +- test/pluck.js | 4 +- test/prepend.js | 4 +- test/product.js | 4 +- test/project.js | 4 +- test/promap.js | 6 +- test/prop.js | 4 +- test/propEq.js | 4 +- test/propIs.js | 4 +- test/propOr.js | 4 +- test/propSatisfies.js | 4 +- test/props.js | 4 +- test/range.js | 4 +- test/reduce.js | 4 +- test/reduceBy.js | 4 +- test/reduceRight.js | 4 +- test/reduceWhile.js | 4 +- test/reduced.js | 4 +- test/reject.js | 4 +- test/remove.js | 4 +- test/repeat.js | 4 +- test/replace.js | 4 +- test/reverse.js | 4 +- test/scan.js | 4 +- test/sequence.js | 6 +- test/shared/Id.js | 2 +- test/shared/Maybe.js | 2 +- test/shared/Pair.js | 2 +- test/shared/eq.js | 2 +- test/slice.js | 4 +- test/sort.js | 4 +- test/sortBy.js | 4 +- test/sortWith.js | 4 +- test/split.js | 4 +- test/splitAt.js | 4 +- test/splitEvery.js | 4 +- test/splitWhen.js | 4 +- test/splitWhenever.js | 4 +- test/startsWith.js | 4 +- test/subtract.js | 4 +- test/sum.js | 4 +- test/symmetricDifference.js | 4 +- test/symmetricDifferenceWith.js | 4 +- test/tail.js | 4 +- test/take.js | 4 +- test/takeLast.js | 4 +- test/takeLastWhile.js | 4 +- test/takeWhile.js | 4 +- test/tap.js | 8 +- test/test.js | 4 +- test/thunkify.js | 4 +- test/times.js | 4 +- test/toLower.js | 4 +- test/toPairs.js | 4 +- test/toPairsIn.js | 4 +- test/toString.js | 2 +- test/toUpper.js | 4 +- test/transduce.js | 4 +- test/transpose.js | 4 +- test/traverse.js | 6 +- test/trim.js | 4 +- test/tryCatch.js | 4 +- test/type.js | 4 +- test/unapply.js | 4 +- test/unary.js | 4 +- test/uncurryN.js | 4 +- test/unfold.js | 4 +- test/union.js | 4 +- test/unionWith.js | 4 +- test/uniq.js | 4 +- test/uniqBy.js | 4 +- test/uniqWith.js | 4 +- test/unless.js | 6 +- test/unnest.js | 6 +- test/until.js | 6 +- test/unwind.js | 4 +- test/update.js | 4 +- test/useWith.js | 4 +- test/values.js | 4 +- test/valuesIn.js | 4 +- test/when.js | 4 +- test/where.js | 4 +- test/whereAny.js | 4 +- test/whereEq.js | 4 +- test/without.js | 4 +- test/xor.js | 4 +- test/xprod.js | 4 +- test/zip.js | 4 +- test/zipObj.js | 4 +- test/zipWith.js | 4 +- 288 files changed, 1033 insertions(+), 1035 deletions(-) diff --git a/lib/bench/concat.bench.js b/lib/bench/concat.bench.js index bae08ed468..362cce8f7f 100644 --- a/lib/bench/concat.bench.js +++ b/lib/bench/concat.bench.js @@ -1,4 +1,4 @@ -var concat = require('../..').concat; +var concat = require('../../src/index.js').concat; var s1 = [8, 2, 85, 2, 34, 3, 23]; var s2 = [247, 57, 8, 0, 6, 5, 46, 54, 643]; diff --git a/lib/bench/curry.bench.js b/lib/bench/curry.bench.js index 6a9e780873..06fb0490ef 100644 --- a/lib/bench/curry.bench.js +++ b/lib/bench/curry.bench.js @@ -1,4 +1,4 @@ -var curry = require('../..').curry; +var curry = require('../../src/index.js').curry; function mult(x, y) { return x * y; } var mult4 = curry(mult)(4); diff --git a/lib/bench/each.bench.js b/lib/bench/each.bench.js index 8f00f6a561..5182b8a096 100644 --- a/lib/bench/each.bench.js +++ b/lib/bench/each.bench.js @@ -1,4 +1,4 @@ -var forEach = require('../..').forEach; +var forEach = require('../../src/index.js').forEach; var nums = [8, 2, 85, 2, 34, 3, 23, 247, 57, 8, 0, 6, 5, 46, 54, 643]; diff --git a/lib/bench/either.bench.js b/lib/bench/either.bench.js index 1fe503c35b..e1d55d8361 100644 --- a/lib/bench/either.bench.js +++ b/lib/bench/either.bench.js @@ -1,4 +1,4 @@ -var R = require('../..'); +var R = require('../../src/index.js'); var gt10 = x => x > 10; var even = x => x % 2 === 0; diff --git a/lib/bench/filter-where.bench.js b/lib/bench/filter-where.bench.js index aca1f34376..425c6833d3 100644 --- a/lib/bench/filter-where.bench.js +++ b/lib/bench/filter-where.bench.js @@ -1,4 +1,4 @@ -var R = require('../..'); +var R = require('../../src/index.js'); var objs = [ {x: [1, 2], y: true}, {x: [1, 3], y: true}, {x: [], y: false}, {x: [2], y: false}, diff --git a/lib/bench/filter.bench.js b/lib/bench/filter.bench.js index 7d908eaf00..c15510c039 100644 --- a/lib/bench/filter.bench.js +++ b/lib/bench/filter.bench.js @@ -1,4 +1,4 @@ -var filter = require('../..').filter; +var filter = require('../../src/index.js').filter; var nums = [8, 2, 85, 2, 34, 3, 23, 247, 57, 8, 0, 6, 5, 46, 54, 643]; function isEven(x) { return x % 2 === 0; } diff --git a/lib/bench/find-where.bench.js b/lib/bench/find-where.bench.js index 0077c99f3d..2e47cd6507 100644 --- a/lib/bench/find-where.bench.js +++ b/lib/bench/find-where.bench.js @@ -1,4 +1,4 @@ -var R = require('../..'); +var R = require('../../src/index.js'); var objs = [ {x: [1, 2], y: true}, diff --git a/lib/bench/find.bench.js b/lib/bench/find.bench.js index a633bf86ab..2626801a96 100644 --- a/lib/bench/find.bench.js +++ b/lib/bench/find.bench.js @@ -1,4 +1,4 @@ -var find = require('../..').find; +var find = require('../../src/index.js').find; var nums = [8, 2, 85, 2, 34, 3, 23, 247, 57, 8, 0, 6, 5, 46, 54, 643]; function isZero(x) { return x === 0; } diff --git a/lib/bench/findIndex-where.bench.js b/lib/bench/findIndex-where.bench.js index a8312440bf..54e43e63c2 100644 --- a/lib/bench/findIndex-where.bench.js +++ b/lib/bench/findIndex-where.bench.js @@ -1,4 +1,4 @@ -var R = require('../..'); +var R = require('../../src/index.js'); var objs = [ {x: [1, 2], y: true}, {x: [1, 3], y: true}, {x: [], y: false}, {x: [2], y: false}, diff --git a/lib/bench/findIndex.bench.js b/lib/bench/findIndex.bench.js index ab0842218a..22b1b762b9 100644 --- a/lib/bench/findIndex.bench.js +++ b/lib/bench/findIndex.bench.js @@ -1,4 +1,4 @@ -var findIndex = require('../..').findIndex; +var findIndex = require('../../src/index.js').findIndex; var nums = [8, 2, 85, 2, 34, 3, 23, 247, 57, 8, 0, 6, 5, 46, 54, 643]; function isZero(x) { return x === 0; } diff --git a/lib/bench/includes.bench.js b/lib/bench/includes.bench.js index db93e32a1d..d3ced3ebda 100644 --- a/lib/bench/includes.bench.js +++ b/lib/bench/includes.bench.js @@ -1,4 +1,4 @@ -var includes = require('../..').includes; +var includes = require('../../src/index.js').includes; var alphabet = 'abcdefghijklmnopqrstuvwxyz'.split(''); diff --git a/lib/bench/indexof.bench.js b/lib/bench/indexof.bench.js index 67e336222d..b7ba6c0449 100644 --- a/lib/bench/indexof.bench.js +++ b/lib/bench/indexof.bench.js @@ -1,4 +1,4 @@ -var indexOf = require('../..').indexOf; +var indexOf = require('../../src/index.js').indexOf; var nums = [8, 2, 85, 2, 34, 3, 23, 247, 57, 8, 0, 6, 5, 46, 54, 643]; var idxOf23 = indexOf(23); diff --git a/lib/bench/map.bench.js b/lib/bench/map.bench.js index cabf5cb813..57f8a523da 100644 --- a/lib/bench/map.bench.js +++ b/lib/bench/map.bench.js @@ -1,4 +1,4 @@ -var map = require('../..').map; +var map = require('../../src/index.js').map; var nums = [8, 2, 85, 2, 34, 3, 23, 247, 57, 8, 0, 6, 5, 46, 54, 643]; function sq(x) { return x * x; } diff --git a/lib/bench/maxWith.bench.js b/lib/bench/maxWith.bench.js index 46a33f2852..a5be2790d1 100644 --- a/lib/bench/maxWith.bench.js +++ b/lib/bench/maxWith.bench.js @@ -1,4 +1,4 @@ -var R = require('../..'); +var R = require('../../src/index.js'); var maxBy = R.maxBy; var computer = R.prop('val'); var maxVal = maxBy(computer); diff --git a/lib/bench/propEq.bench.js b/lib/bench/propEq.bench.js index 132110312e..0ff2f19627 100644 --- a/lib/bench/propEq.bench.js +++ b/lib/bench/propEq.bench.js @@ -1,4 +1,4 @@ -var propEq = require('../..').propEq; +var propEq = require('../../src/index.js').propEq; module.exports = { name: 'propEq', diff --git a/lib/bench/reduce.bench.js b/lib/bench/reduce.bench.js index e49e90a422..47e6799619 100644 --- a/lib/bench/reduce.bench.js +++ b/lib/bench/reduce.bench.js @@ -1,4 +1,4 @@ -var reduce = require('../..').reduce; +var reduce = require('../../src/index.js').reduce; var nums = [8, 2, 85, 2, 34, 3, 23, 247, 57, 8, 0, 6, 5, 46, 54, 643]; function add(acc, x) { return acc + x; } var reduceAdd = reduce(add, 0); diff --git a/lib/bench/uniq.bench.js b/lib/bench/uniq.bench.js index 87c50dcc9a..4ae2abe164 100644 --- a/lib/bench/uniq.bench.js +++ b/lib/bench/uniq.bench.js @@ -1,4 +1,4 @@ -var R = require('../..'); +var R = require('../../src/index.js'); var arr1 = R.times(function() { var n = (Math.random() * 100) >>> 0; diff --git a/lib/sauce/browsers.js b/lib/sauce/browsers.js index cae1c95196..18c70bb248 100644 --- a/lib/sauce/browsers.js +++ b/lib/sauce/browsers.js @@ -1,7 +1,7 @@ -var windows = require('./windows'); -var apple = require('./apple'); -var linux = require('./linux'); -var android = require('./android'); -var ios = require('./ios'); +var windows = require('./windows.js'); +var apple = require('./apple.js'); +var linux = require('./linux.js'); +var android = require('./android.js'); +var ios = require('./ios.js'); module.exports = windows.concat(apple, android, ios, linux); diff --git a/lib/sauce/conf.js b/lib/sauce/conf.js index e97e8d8dda..145ddebffe 100644 --- a/lib/sauce/conf.js +++ b/lib/sauce/conf.js @@ -1,5 +1,5 @@ var envvar = require('envvar'); -var browsers = require('./browsers'); +var browsers = require('./browsers.js'); module.exports = { all: { options: { diff --git a/package-lock.json b/package-lock.json index 5ae9b61fc6..cf0e7eb3e1 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,6 +1,6 @@ { "name": "ramda", - "version": "0.27.1", + "version": "0.28.0", "lockfileVersion": 1, "requires": true, "dependencies": { @@ -3431,33 +3431,44 @@ "dev": true }, "array-includes": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/array-includes/-/array-includes-3.1.1.tgz", - "integrity": "sha512-c2VXaCHl7zPsvpkFsw4nxvFie4fh1ur9bpcgsVkIjqn0H/Xwdg+7fv3n2r/isyS8EBj5b06M9kHyZuIr4El6WQ==", + "version": "3.1.4", + "resolved": "https://registry.npmjs.org/array-includes/-/array-includes-3.1.4.tgz", + "integrity": "sha512-ZTNSQkmWumEbiHO2GF4GmWxYVTiQyJy2XOTa15sdQSrvKn7l+180egQMqlrMOUMCyLMD7pmyQe4mMDUT6Behrw==", "dev": true, "requires": { + "call-bind": "^1.0.2", "define-properties": "^1.1.3", - "es-abstract": "^1.17.0", - "is-string": "^1.0.5" + "es-abstract": "^1.19.1", + "get-intrinsic": "^1.1.1", + "is-string": "^1.0.7" }, "dependencies": { "es-abstract": { - "version": "1.17.6", - "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.17.6.tgz", - "integrity": "sha512-Fr89bON3WFyUi5EvAeI48QTWX0AyekGgLA8H+c+7fbfCkJwRWRMLd8CQedNEyJuoYYhmtEqY92pgte1FAhBlhw==", + "version": "1.19.1", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.19.1.tgz", + "integrity": "sha512-2vJ6tjA/UfqLm2MPs7jxVybLoB8i1t1Jd9R3kISld20sIxPcTbLuggQOUxeWeAvIUkduv/CfMjuh4WmiXr2v9w==", "dev": true, "requires": { + "call-bind": "^1.0.2", "es-to-primitive": "^1.2.1", "function-bind": "^1.1.1", + "get-intrinsic": "^1.1.1", + "get-symbol-description": "^1.0.0", "has": "^1.0.3", - "has-symbols": "^1.0.1", - "is-callable": "^1.2.0", - "is-regex": "^1.1.0", - "object-inspect": "^1.7.0", + "has-symbols": "^1.0.2", + "internal-slot": "^1.0.3", + "is-callable": "^1.2.4", + "is-negative-zero": "^2.0.1", + "is-regex": "^1.1.4", + "is-shared-array-buffer": "^1.0.1", + "is-string": "^1.0.7", + "is-weakref": "^1.0.1", + "object-inspect": "^1.11.0", "object-keys": "^1.1.1", - "object.assign": "^4.1.0", - "string.prototype.trimend": "^1.0.1", - "string.prototype.trimstart": "^1.0.1" + "object.assign": "^4.1.2", + "string.prototype.trimend": "^1.0.4", + "string.prototype.trimstart": "^1.0.4", + "unbox-primitive": "^1.0.1" } }, "es-to-primitive": { @@ -3472,55 +3483,78 @@ } }, "has-symbols": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.1.tgz", - "integrity": "sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.2.tgz", + "integrity": "sha512-chXa79rL/UC2KlX17jo3vRGz0azaWEx5tGqZg5pO3NUyEJVB17dMruQlzCCOfUvElghKcm5194+BCRvi2Rv/Gw==", "dev": true }, "is-callable": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.0.tgz", - "integrity": "sha512-pyVD9AaGLxtg6srb2Ng6ynWJqkHU9bEM087AKck0w8QwDarTfNcpIYoU8x8Hv2Icm8u6kFJM18Dag8lyqGkviw==", + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.4.tgz", + "integrity": "sha512-nsuwtxZfMX67Oryl9LCQ+upnC0Z0BgpwntpS89m1H/TLF0zNfzfLMV/9Wa/6MZsj0acpEjAO0KF1xT6ZdLl95w==", "dev": true }, "is-regex": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.0.tgz", - "integrity": "sha512-iI97M8KTWID2la5uYXlkbSDQIg4F6o1sYboZKKTDpnDQMLtUL86zxhgDet3Q2SriaYsyGqZ6Mn2SjbRKeLHdqw==", + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.4.tgz", + "integrity": "sha512-kvRdxDsxZjhzUX07ZnLydzS1TU/TJlTUHHY4YLL87e37oUA49DfkLqgy+VjFocowy29cKvcSiu+kIv728jTTVg==", "dev": true, "requires": { - "has-symbols": "^1.0.1" + "call-bind": "^1.0.2", + "has-tostringtag": "^1.0.0" + } + }, + "object.assign": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.2.tgz", + "integrity": "sha512-ixT2L5THXsApyiUPYKmW+2EHpXXe5Ii3M+f4e+aJFAHao5amFRW6J0OO6c/LU8Be47utCx2GL89hxGB6XSmKuQ==", + "dev": true, + "requires": { + "call-bind": "^1.0.0", + "define-properties": "^1.1.3", + "has-symbols": "^1.0.1", + "object-keys": "^1.1.1" } } } }, "array.prototype.flat": { - "version": "1.2.3", - "resolved": "https://registry.npmjs.org/array.prototype.flat/-/array.prototype.flat-1.2.3.tgz", - "integrity": "sha512-gBlRZV0VSmfPIeWfuuy56XZMvbVfbEUnOXUvt3F/eUUUSyzlgLxhEX4YAEpxNAogRGehPSnfXyPtYyKAhkzQhQ==", + "version": "1.2.5", + "resolved": "https://registry.npmjs.org/array.prototype.flat/-/array.prototype.flat-1.2.5.tgz", + "integrity": "sha512-KaYU+S+ndVqyUnignHftkwc58o3uVU1jzczILJ1tN2YaIZpFIKBiP/x/j97E5MVPsaCloPbqWLB/8qCTVvT2qg==", "dev": true, "requires": { + "call-bind": "^1.0.2", "define-properties": "^1.1.3", - "es-abstract": "^1.17.0-next.1" + "es-abstract": "^1.19.0" }, "dependencies": { "es-abstract": { - "version": "1.17.6", - "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.17.6.tgz", - "integrity": "sha512-Fr89bON3WFyUi5EvAeI48QTWX0AyekGgLA8H+c+7fbfCkJwRWRMLd8CQedNEyJuoYYhmtEqY92pgte1FAhBlhw==", + "version": "1.19.1", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.19.1.tgz", + "integrity": "sha512-2vJ6tjA/UfqLm2MPs7jxVybLoB8i1t1Jd9R3kISld20sIxPcTbLuggQOUxeWeAvIUkduv/CfMjuh4WmiXr2v9w==", "dev": true, "requires": { + "call-bind": "^1.0.2", "es-to-primitive": "^1.2.1", "function-bind": "^1.1.1", + "get-intrinsic": "^1.1.1", + "get-symbol-description": "^1.0.0", "has": "^1.0.3", - "has-symbols": "^1.0.1", - "is-callable": "^1.2.0", - "is-regex": "^1.1.0", - "object-inspect": "^1.7.0", + "has-symbols": "^1.0.2", + "internal-slot": "^1.0.3", + "is-callable": "^1.2.4", + "is-negative-zero": "^2.0.1", + "is-regex": "^1.1.4", + "is-shared-array-buffer": "^1.0.1", + "is-string": "^1.0.7", + "is-weakref": "^1.0.1", + "object-inspect": "^1.11.0", "object-keys": "^1.1.1", - "object.assign": "^4.1.0", - "string.prototype.trimend": "^1.0.1", - "string.prototype.trimstart": "^1.0.1" + "object.assign": "^4.1.2", + "string.prototype.trimend": "^1.0.4", + "string.prototype.trimstart": "^1.0.4", + "unbox-primitive": "^1.0.1" } }, "es-to-primitive": { @@ -3535,24 +3569,37 @@ } }, "has-symbols": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.1.tgz", - "integrity": "sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.2.tgz", + "integrity": "sha512-chXa79rL/UC2KlX17jo3vRGz0azaWEx5tGqZg5pO3NUyEJVB17dMruQlzCCOfUvElghKcm5194+BCRvi2Rv/Gw==", "dev": true }, "is-callable": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.0.tgz", - "integrity": "sha512-pyVD9AaGLxtg6srb2Ng6ynWJqkHU9bEM087AKck0w8QwDarTfNcpIYoU8x8Hv2Icm8u6kFJM18Dag8lyqGkviw==", + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.4.tgz", + "integrity": "sha512-nsuwtxZfMX67Oryl9LCQ+upnC0Z0BgpwntpS89m1H/TLF0zNfzfLMV/9Wa/6MZsj0acpEjAO0KF1xT6ZdLl95w==", "dev": true }, "is-regex": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.0.tgz", - "integrity": "sha512-iI97M8KTWID2la5uYXlkbSDQIg4F6o1sYboZKKTDpnDQMLtUL86zxhgDet3Q2SriaYsyGqZ6Mn2SjbRKeLHdqw==", + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.4.tgz", + "integrity": "sha512-kvRdxDsxZjhzUX07ZnLydzS1TU/TJlTUHHY4YLL87e37oUA49DfkLqgy+VjFocowy29cKvcSiu+kIv728jTTVg==", + "dev": true, + "requires": { + "call-bind": "^1.0.2", + "has-tostringtag": "^1.0.0" + } + }, + "object.assign": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.2.tgz", + "integrity": "sha512-ixT2L5THXsApyiUPYKmW+2EHpXXe5Ii3M+f4e+aJFAHao5amFRW6J0OO6c/LU8Be47utCx2GL89hxGB6XSmKuQ==", "dev": true, "requires": { - "has-symbols": "^1.0.1" + "call-bind": "^1.0.0", + "define-properties": "^1.1.3", + "has-symbols": "^1.0.1", + "object-keys": "^1.1.1" } } } @@ -4181,6 +4228,16 @@ } } }, + "call-bind": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/call-bind/-/call-bind-1.0.2.tgz", + "integrity": "sha512-7O+FbCihrB5WGbFYesctwmTKae6rOiIzmz1icreWJ+0aA7LJfuqhEso2T9ncpcFtzMQtzXf2QGGueWJGTYsqrA==", + "dev": true, + "requires": { + "function-bind": "^1.1.1", + "get-intrinsic": "^1.0.2" + } + }, "callsite": { "version": "1.0.0", "resolved": "https://registry.npmjs.org/callsite/-/callsite-1.0.0.tgz", @@ -4516,12 +4573,6 @@ "integrity": "sha1-kld9tSe6bEzwpFaNhLwDH0QeIfI=", "dev": true }, - "contains-path": { - "version": "0.1.0", - "resolved": "https://registry.npmjs.org/contains-path/-/contains-path-0.1.0.tgz", - "integrity": "sha1-/ozxhP9mcLa67wGp1IYaXL7EEgo=", - "dev": true - }, "content-disposition": { "version": "0.5.3", "resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.3.tgz", @@ -5075,15 +5126,6 @@ "integrity": "sha1-cewM0PmFU5owRtT02lbGfXwr8D8=", "dev": true }, - "error-ex": { - "version": "1.3.2", - "resolved": "https://registry.npmjs.org/error-ex/-/error-ex-1.3.2.tgz", - "integrity": "sha512-7dFHNmqeFSEt2ZBsCriorKnn3Z2pj+fd9kmI6QoWw4//DL+icEBfc0U7qJCisqrTsKTjw4fNFy2pW9OqStD84g==", - "dev": true, - "requires": { - "is-arrayish": "^0.2.1" - } - }, "es-abstract": { "version": "1.13.0", "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.13.0.tgz", @@ -5209,36 +5251,68 @@ } }, "eslint-import-resolver-node": { - "version": "0.3.4", - "resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.4.tgz", - "integrity": "sha512-ogtf+5AB/O+nM6DIeBUNr2fuT7ot9Qg/1harBfBtaP13ekEWFQEEMP94BCB7zaNW3gyY+8SHYF00rnqYwXKWOA==", + "version": "0.3.6", + "resolved": "https://registry.npmjs.org/eslint-import-resolver-node/-/eslint-import-resolver-node-0.3.6.tgz", + "integrity": "sha512-0En0w03NRVMn9Uiyn8YRPDKvWjxCWkslUEhGNTdGx15RvPJYQ+lbOlqrlNI2vEAs4pDYK4f/HN2TbDmk5TP0iw==", "dev": true, "requires": { - "debug": "^2.6.9", - "resolve": "^1.13.1" + "debug": "^3.2.7", + "resolve": "^1.20.0" }, "dependencies": { + "debug": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, + "ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true + }, + "path-parse": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", + "dev": true + }, "resolve": { - "version": "1.17.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.17.0.tgz", - "integrity": "sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w==", + "version": "1.21.1", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.21.1.tgz", + "integrity": "sha512-lfEImVbnolPuaSZuLQ52cAxPBHeI77sPwCOWRdy12UG/CNa8an7oBHH1R+Fp1/mUqSJi4c8TIP6FOIPSZAUrEQ==", "dev": true, "requires": { - "path-parse": "^1.0.6" + "is-core-module": "^2.8.0", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" } } } }, "eslint-module-utils": { - "version": "2.6.0", - "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.6.0.tgz", - "integrity": "sha512-6j9xxegbqe8/kZY8cYpcp0xhbK0EgJlg3g9mib3/miLaExuuwc3n5UEfSnU6hWMbT0FAYVvDbL9RrRgpUeQIvA==", + "version": "2.7.2", + "resolved": "https://registry.npmjs.org/eslint-module-utils/-/eslint-module-utils-2.7.2.tgz", + "integrity": "sha512-zquepFnWCY2ISMFwD/DqzaM++H+7PDzOpUvotJWm/y1BAFt5R4oeULgdrTejKqLkz7MA/tgstsUMNYc7wNdTrg==", "dev": true, "requires": { - "debug": "^2.6.9", - "pkg-dir": "^2.0.0" + "debug": "^3.2.7", + "find-up": "^2.1.0" }, "dependencies": { + "debug": { + "version": "3.2.7", + "resolved": "https://registry.npmjs.org/debug/-/debug-3.2.7.tgz", + "integrity": "sha512-CFjzYYAi4ThfiQvizrFQevTTXHtnCqWfe7x1AhgEscTz6ZbLbfoLRLPugTQyBth6f8ZERVUSyWHFD/7Wu4t1XQ==", + "dev": true, + "requires": { + "ms": "^2.1.1" + } + }, "find-up": { "version": "2.1.0", "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz", @@ -5258,6 +5332,12 @@ "path-exists": "^3.0.0" } }, + "ms": { + "version": "2.1.3", + "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz", + "integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==", + "dev": true + }, "p-limit": { "version": "1.3.0", "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz", @@ -5281,62 +5361,54 @@ "resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz", "integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=", "dev": true - }, - "pkg-dir": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/pkg-dir/-/pkg-dir-2.0.0.tgz", - "integrity": "sha1-9tXREJ4Z1j7fQo4L1X4Sd3YVM0s=", - "dev": true, - "requires": { - "find-up": "^2.1.0" - } } } }, "eslint-plugin-import": { - "version": "2.21.2", - "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.21.2.tgz", - "integrity": "sha512-FEmxeGI6yaz+SnEB6YgNHlQK1Bs2DKLM+YF+vuTk5H8J9CLbJLtlPvRFgZZ2+sXiKAlN5dpdlrWOjK8ZoZJpQA==", + "version": "2.25.4", + "resolved": "https://registry.npmjs.org/eslint-plugin-import/-/eslint-plugin-import-2.25.4.tgz", + "integrity": "sha512-/KJBASVFxpu0xg1kIBn9AUa8hQVnszpwgE7Ld0lKAlx7Ie87yzEzCgSkekt+le/YVhiaosO4Y14GDAOc41nfxA==", "dev": true, "requires": { - "array-includes": "^3.1.1", - "array.prototype.flat": "^1.2.3", - "contains-path": "^0.1.0", + "array-includes": "^3.1.4", + "array.prototype.flat": "^1.2.5", "debug": "^2.6.9", - "doctrine": "1.5.0", - "eslint-import-resolver-node": "^0.3.3", - "eslint-module-utils": "^2.6.0", + "doctrine": "^2.1.0", + "eslint-import-resolver-node": "^0.3.6", + "eslint-module-utils": "^2.7.2", "has": "^1.0.3", + "is-core-module": "^2.8.0", + "is-glob": "^4.0.3", "minimatch": "^3.0.4", - "object.values": "^1.1.1", - "read-pkg-up": "^2.0.0", - "resolve": "^1.17.0", - "tsconfig-paths": "^3.9.0" + "object.values": "^1.1.5", + "resolve": "^1.20.0", + "tsconfig-paths": "^3.12.0" }, "dependencies": { "doctrine": { - "version": "1.5.0", - "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-1.5.0.tgz", - "integrity": "sha1-N53Ocw9hZvds76TmcHoVmwLFpvo=", + "version": "2.1.0", + "resolved": "https://registry.npmjs.org/doctrine/-/doctrine-2.1.0.tgz", + "integrity": "sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==", "dev": true, "requires": { - "esutils": "^2.0.2", - "isarray": "^1.0.0" + "esutils": "^2.0.2" } }, - "isarray": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/isarray/-/isarray-1.0.0.tgz", - "integrity": "sha1-u5NdSFgsuhaMBoNJV6VKPgcSTxE=", + "path-parse": { + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/path-parse/-/path-parse-1.0.7.tgz", + "integrity": "sha512-LDJzPVEEEPR+y48z93A0Ed0yXb8pAByGWo/k5YYdYgpY2/2EsOsksJrq7lOHxryrVOn1ejG6oAp8ahvOIQD8sw==", "dev": true }, "resolve": { - "version": "1.17.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.17.0.tgz", - "integrity": "sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w==", + "version": "1.21.1", + "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.21.1.tgz", + "integrity": "sha512-lfEImVbnolPuaSZuLQ52cAxPBHeI77sPwCOWRdy12UG/CNa8an7oBHH1R+Fp1/mUqSJi4c8TIP6FOIPSZAUrEQ==", "dev": true, "requires": { - "path-parse": "^1.0.6" + "is-core-module": "^2.8.0", + "path-parse": "^1.0.7", + "supports-preserve-symlinks-flag": "^1.0.0" } } } @@ -5915,6 +5987,25 @@ "integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==", "dev": true }, + "get-intrinsic": { + "version": "1.1.1", + "resolved": "https://registry.npmjs.org/get-intrinsic/-/get-intrinsic-1.1.1.tgz", + "integrity": "sha512-kWZrnVM42QCiEA2Ig1bG8zjoIMOgxWwYCEeNdwY6Tv/cOSeGpcoX4pXHfKUxNKVoArnrEr2e9srnAxxGIraS9Q==", + "dev": true, + "requires": { + "function-bind": "^1.1.1", + "has": "^1.0.3", + "has-symbols": "^1.0.1" + }, + "dependencies": { + "has-symbols": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.2.tgz", + "integrity": "sha512-chXa79rL/UC2KlX17jo3vRGz0azaWEx5tGqZg5pO3NUyEJVB17dMruQlzCCOfUvElghKcm5194+BCRvi2Rv/Gw==", + "dev": true + } + } + }, "get-package-type": { "version": "0.1.0", "resolved": "https://registry.npmjs.org/get-package-type/-/get-package-type-0.1.0.tgz", @@ -5930,6 +6021,16 @@ "pump": "^3.0.0" } }, + "get-symbol-description": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/get-symbol-description/-/get-symbol-description-1.0.0.tgz", + "integrity": "sha512-2EmdH1YvIQiZpltCNgkuiUnyukzxM/R6NDJX31Ke3BG1Nq5b0S2PhX59UKi9vZpPDQVdqn+1IcaAwnzTT5vCjw==", + "dev": true, + "requires": { + "call-bind": "^1.0.2", + "get-intrinsic": "^1.1.1" + } + }, "get-value": { "version": "2.0.6", "resolved": "https://registry.npmjs.org/get-value/-/get-value-2.0.6.tgz", @@ -6019,6 +6120,12 @@ "function-bind": "^1.1.1" } }, + "has-bigints": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/has-bigints/-/has-bigints-1.0.1.tgz", + "integrity": "sha512-LSBS2LjbNBTf6287JEbEzvJgftkF5qFkmCo9hDRpAzKhUOlJ+hx8dd4USs00SgsUNwc4617J9ki5YtEClM2ffA==", + "dev": true + }, "has-binary2": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/has-binary2/-/has-binary2-1.0.3.tgz", @@ -6054,6 +6161,23 @@ "integrity": "sha1-uhqPGvKg/DllD1yFA2dwQSIGO0Q=", "dev": true }, + "has-tostringtag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/has-tostringtag/-/has-tostringtag-1.0.0.tgz", + "integrity": "sha512-kFjcSNhnlGV1kyoGk7OXKSawH5JOb/LzUc5w9B02hOTO0dfFRjbHQKvg1d6cf3HbeUmtU9VbbV3qzZ2Teh97WQ==", + "dev": true, + "requires": { + "has-symbols": "^1.0.2" + }, + "dependencies": { + "has-symbols": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.2.tgz", + "integrity": "sha512-chXa79rL/UC2KlX17jo3vRGz0azaWEx5tGqZg5pO3NUyEJVB17dMruQlzCCOfUvElghKcm5194+BCRvi2Rv/Gw==", + "dev": true + } + } + }, "has-unicode": { "version": "2.0.1", "resolved": "https://registry.npmjs.org/has-unicode/-/has-unicode-2.0.1.tgz", @@ -6181,12 +6305,6 @@ "minimalistic-crypto-utils": "^1.0.1" } }, - "hosted-git-info": { - "version": "2.8.8", - "resolved": "https://registry.npmjs.org/hosted-git-info/-/hosted-git-info-2.8.8.tgz", - "integrity": "sha512-f/wzC2QaWBs7t9IYqB4T3sR1xviIViXJRJTWBlx2Gf3g0Xi5vI7Yy4koXQ1c9OYDGHN9sBy1DQ2AB8fqZBWhUg==", - "dev": true - }, "html-escaper": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/html-escaper/-/html-escaper-2.0.2.tgz", @@ -6432,6 +6550,17 @@ } } }, + "internal-slot": { + "version": "1.0.3", + "resolved": "https://registry.npmjs.org/internal-slot/-/internal-slot-1.0.3.tgz", + "integrity": "sha512-O0DB1JC/sPyZl7cIo78n5dR7eUSwwpYPiXRhTzNxZVAMUuB8vlnRFyLxdrVToks6XPLVnFfbzaVd5WLjhgg+vA==", + "dev": true, + "requires": { + "get-intrinsic": "^1.1.0", + "has": "^1.0.3", + "side-channel": "^1.0.4" + } + }, "invariant": { "version": "2.2.4", "resolved": "https://registry.npmjs.org/invariant/-/invariant-2.2.4.tgz", @@ -6463,11 +6592,14 @@ "kind-of": "^3.0.2" } }, - "is-arrayish": { - "version": "0.2.1", - "resolved": "https://registry.npmjs.org/is-arrayish/-/is-arrayish-0.2.1.tgz", - "integrity": "sha1-d8mYQFJ6qOyxqLppe4BkWnqSap0=", - "dev": true + "is-bigint": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/is-bigint/-/is-bigint-1.0.4.tgz", + "integrity": "sha512-zB9CruMamjym81i2JZ3UMn54PKGsQzsJeo6xvN3HJJ4CAsQNB6iRutp2To77OfCNuoxspsIhzaPoO1zyCEhFOg==", + "dev": true, + "requires": { + "has-bigints": "^1.0.1" + } }, "is-binary-path": { "version": "1.0.1", @@ -6479,6 +6611,16 @@ "binary-extensions": "^1.0.0" } }, + "is-boolean-object": { + "version": "1.1.2", + "resolved": "https://registry.npmjs.org/is-boolean-object/-/is-boolean-object-1.1.2.tgz", + "integrity": "sha512-gDYaKHJmnj4aWxyj6YHyXVpdQawtVLHU5cb+eztPGczf6cjuTdwve5ZIEfgXqH4e57An1D1AKf8CZ3kYrQRqYA==", + "dev": true, + "requires": { + "call-bind": "^1.0.2", + "has-tostringtag": "^1.0.0" + } + }, "is-buffer": { "version": "1.1.5", "resolved": "https://registry.npmjs.org/is-buffer/-/is-buffer-1.1.5.tgz", @@ -6491,6 +6633,15 @@ "integrity": "sha512-r5p9sxJjYnArLjObpjA4xu5EKI3CuKHkJXMhT7kwbpUyIFD1n5PMAsoPvWnvtZiNz7LjkYDRZhd7FlI0eMijEA==", "dev": true }, + "is-core-module": { + "version": "2.8.1", + "resolved": "https://registry.npmjs.org/is-core-module/-/is-core-module-2.8.1.tgz", + "integrity": "sha512-SdNCUs284hr40hFTFP6l0IfZ/RSrMXF3qgoRHd3/79unUTvrFO/JoXwkGm+5J/Oe3E/b5GsnG330uUNgRpu1PA==", + "dev": true, + "requires": { + "has": "^1.0.3" + } + }, "is-data-descriptor": { "version": "0.1.4", "resolved": "https://registry.npmjs.org/is-data-descriptor/-/is-data-descriptor-0.1.4.tgz", @@ -6535,12 +6686,42 @@ "dev": true, "optional": true }, + "is-extglob": { + "version": "2.1.1", + "resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz", + "integrity": "sha1-qIwCU1eR8C7TfHahueqXc8gz+MI=", + "dev": true + }, "is-fullwidth-code-point": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-2.0.0.tgz", "integrity": "sha1-o7MKXE8ZkYMWeqq5O+764937ZU8=", "dev": true }, + "is-glob": { + "version": "4.0.3", + "resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz", + "integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==", + "dev": true, + "requires": { + "is-extglob": "^2.1.1" + } + }, + "is-negative-zero": { + "version": "2.0.2", + "resolved": "https://registry.npmjs.org/is-negative-zero/-/is-negative-zero-2.0.2.tgz", + "integrity": "sha512-dqJvarLawXsFbNDeJW7zAz8ItJ9cd28YufuuFzh0G8pNHjJMnY08Dv7sYX2uF5UpQOwieAeOExEYAWWfu7ZZUA==", + "dev": true + }, + "is-number-object": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/is-number-object/-/is-number-object-1.0.6.tgz", + "integrity": "sha512-bEVOqiRcvo3zO1+G2lVMy+gkkEm9Yh7cDMRusKKu5ZJKPUYSJwICTKZrNKHA2EbSP0Tu0+6B/emsYNHZyn6K8g==", + "dev": true, + "requires": { + "has-tostringtag": "^1.0.0" + } + }, "is-plain-obj": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-1.1.0.tgz", @@ -6581,6 +6762,12 @@ "has": "^1.0.1" } }, + "is-shared-array-buffer": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/is-shared-array-buffer/-/is-shared-array-buffer-1.0.1.tgz", + "integrity": "sha512-IU0NmyknYZN0rChcKhRO1X8LYz5Isj/Fsqh8NJOSf+N/hCOTwy29F32Ik7a+QszE63IdvmwdTPDd6cZ5pg4cwA==", + "dev": true + }, "is-stream": { "version": "1.1.0", "resolved": "https://registry.npmjs.org/is-stream/-/is-stream-1.1.0.tgz", @@ -6588,10 +6775,13 @@ "dev": true }, "is-string": { - "version": "1.0.5", - "resolved": "https://registry.npmjs.org/is-string/-/is-string-1.0.5.tgz", - "integrity": "sha512-buY6VNRjhQMiF1qWDouloZlQbRhDPCebwxSjxMjxgemYT46YMd2NR0/H+fBhEfWX4A/w9TBJ+ol+okqJKFE6vQ==", - "dev": true + "version": "1.0.7", + "resolved": "https://registry.npmjs.org/is-string/-/is-string-1.0.7.tgz", + "integrity": "sha512-tE2UXzivje6ofPW7l23cjDOMa09gb7xlAqG6jG5ej6uPV32TlWP3NKPigtaGeHNu9fohccRYvIiZMfOOnOYUtg==", + "dev": true, + "requires": { + "has-tostringtag": "^1.0.0" + } }, "is-symbol": { "version": "1.0.2", @@ -6617,6 +6807,15 @@ "integrity": "sha1-5HnICFjfDBsR3dppQPlgEfzaSpo=", "dev": true }, + "is-weakref": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/is-weakref/-/is-weakref-1.0.2.tgz", + "integrity": "sha512-qctsuLZmIQ0+vSSMfoVvyFe2+GSEvnmZ2ezTup1SBse9+twCCeial6EEi3Nc2KFcf6+qz2FBPnjXsk8xhKSaPQ==", + "dev": true, + "requires": { + "call-bind": "^1.0.2" + } + }, "is-windows": { "version": "1.0.2", "resolved": "https://registry.npmjs.org/is-windows/-/is-windows-1.0.2.tgz", @@ -7287,32 +7486,6 @@ "uc.micro": "^1.0.1" } }, - "load-json-file": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/load-json-file/-/load-json-file-2.0.0.tgz", - "integrity": "sha1-eUfkIUmvgNaWy/eXvKq8/h/inKg=", - "dev": true, - "requires": { - "graceful-fs": "^4.1.2", - "parse-json": "^2.2.0", - "pify": "^2.0.0", - "strip-bom": "^3.0.0" - }, - "dependencies": { - "pify": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", - "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", - "dev": true - }, - "strip-bom": { - "version": "3.0.0", - "resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz", - "integrity": "sha1-IzTBjpx1n3vdVv3vfprj1YjmjtM=", - "dev": true - } - } - }, "locate-path": { "version": "3.0.0", "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-3.0.0.tgz", @@ -8052,29 +8225,6 @@ } } }, - "normalize-package-data": { - "version": "2.5.0", - "resolved": "https://registry.npmjs.org/normalize-package-data/-/normalize-package-data-2.5.0.tgz", - "integrity": "sha512-/5CMN3T0R4XTj4DcGaexo+roZSdSFW/0AOOTROrjxzCG1wrWXEsGbRKevjlIL+ZDE4sZlJr5ED4YW0yqmkK+eA==", - "dev": true, - "requires": { - "hosted-git-info": "^2.1.4", - "resolve": "^1.10.0", - "semver": "2 || 3 || 4 || 5", - "validate-npm-package-license": "^3.0.1" - }, - "dependencies": { - "resolve": { - "version": "1.17.0", - "resolved": "https://registry.npmjs.org/resolve/-/resolve-1.17.0.tgz", - "integrity": "sha512-ic+7JYiV8Vi2yzQGFWOkiZD5Z9z7O2Zhm9XMaTxdJExKasieFCr+yXZ/WmXsckHiKl12ar0y6XiXDx3m4RHn1w==", - "dev": true, - "requires": { - "path-parse": "^1.0.6" - } - } - } - }, "npm-run-path": { "version": "2.0.2", "resolved": "https://registry.npmjs.org/npm-run-path/-/npm-run-path-2.0.2.tgz", @@ -8288,9 +8438,9 @@ } }, "object-inspect": { - "version": "1.8.0", - "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.8.0.tgz", - "integrity": "sha512-jLdtEOB112fORuypAyl/50VRVIBIdVQOSUUGQHzJ4xBSbit81zRarz7GThkEFZy1RceYrWYcPcBFPQwHyAc1gA==", + "version": "1.12.0", + "resolved": "https://registry.npmjs.org/object-inspect/-/object-inspect-1.12.0.tgz", + "integrity": "sha512-Ho2z80bVIvJloH+YzRmpZVQe87+qASmBUKZDWgx9cu+KDrX2ZDH/3tMy+gXbZETVGs2M8YdxObOh7XAtim9Y0g==", "dev": true }, "object-keys": { @@ -8360,34 +8510,42 @@ } }, "object.values": { - "version": "1.1.1", - "resolved": "https://registry.npmjs.org/object.values/-/object.values-1.1.1.tgz", - "integrity": "sha512-WTa54g2K8iu0kmS/us18jEmdv1a4Wi//BZ/DTVYEcH0XhLM5NYdpDHja3gt57VrZLcNAO2WGA+KpWsDBaHt6eA==", + "version": "1.1.5", + "resolved": "https://registry.npmjs.org/object.values/-/object.values-1.1.5.tgz", + "integrity": "sha512-QUZRW0ilQ3PnPpbNtgdNV1PDbEqLIiSFB3l+EnGtBQ/8SUTLj1PZwtQHABZtLgwpJZTSZhuGLOGk57Drx2IvYg==", "dev": true, "requires": { + "call-bind": "^1.0.2", "define-properties": "^1.1.3", - "es-abstract": "^1.17.0-next.1", - "function-bind": "^1.1.1", - "has": "^1.0.3" + "es-abstract": "^1.19.1" }, "dependencies": { "es-abstract": { - "version": "1.17.6", - "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.17.6.tgz", - "integrity": "sha512-Fr89bON3WFyUi5EvAeI48QTWX0AyekGgLA8H+c+7fbfCkJwRWRMLd8CQedNEyJuoYYhmtEqY92pgte1FAhBlhw==", + "version": "1.19.1", + "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.19.1.tgz", + "integrity": "sha512-2vJ6tjA/UfqLm2MPs7jxVybLoB8i1t1Jd9R3kISld20sIxPcTbLuggQOUxeWeAvIUkduv/CfMjuh4WmiXr2v9w==", "dev": true, "requires": { + "call-bind": "^1.0.2", "es-to-primitive": "^1.2.1", "function-bind": "^1.1.1", + "get-intrinsic": "^1.1.1", + "get-symbol-description": "^1.0.0", "has": "^1.0.3", - "has-symbols": "^1.0.1", - "is-callable": "^1.2.0", - "is-regex": "^1.1.0", - "object-inspect": "^1.7.0", + "has-symbols": "^1.0.2", + "internal-slot": "^1.0.3", + "is-callable": "^1.2.4", + "is-negative-zero": "^2.0.1", + "is-regex": "^1.1.4", + "is-shared-array-buffer": "^1.0.1", + "is-string": "^1.0.7", + "is-weakref": "^1.0.1", + "object-inspect": "^1.11.0", "object-keys": "^1.1.1", - "object.assign": "^4.1.0", - "string.prototype.trimend": "^1.0.1", - "string.prototype.trimstart": "^1.0.1" + "object.assign": "^4.1.2", + "string.prototype.trimend": "^1.0.4", + "string.prototype.trimstart": "^1.0.4", + "unbox-primitive": "^1.0.1" } }, "es-to-primitive": { @@ -8402,24 +8560,37 @@ } }, "has-symbols": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.1.tgz", - "integrity": "sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg==", + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.2.tgz", + "integrity": "sha512-chXa79rL/UC2KlX17jo3vRGz0azaWEx5tGqZg5pO3NUyEJVB17dMruQlzCCOfUvElghKcm5194+BCRvi2Rv/Gw==", "dev": true }, "is-callable": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.0.tgz", - "integrity": "sha512-pyVD9AaGLxtg6srb2Ng6ynWJqkHU9bEM087AKck0w8QwDarTfNcpIYoU8x8Hv2Icm8u6kFJM18Dag8lyqGkviw==", + "version": "1.2.4", + "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.4.tgz", + "integrity": "sha512-nsuwtxZfMX67Oryl9LCQ+upnC0Z0BgpwntpS89m1H/TLF0zNfzfLMV/9Wa/6MZsj0acpEjAO0KF1xT6ZdLl95w==", "dev": true }, "is-regex": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.0.tgz", - "integrity": "sha512-iI97M8KTWID2la5uYXlkbSDQIg4F6o1sYboZKKTDpnDQMLtUL86zxhgDet3Q2SriaYsyGqZ6Mn2SjbRKeLHdqw==", + "version": "1.1.4", + "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.4.tgz", + "integrity": "sha512-kvRdxDsxZjhzUX07ZnLydzS1TU/TJlTUHHY4YLL87e37oUA49DfkLqgy+VjFocowy29cKvcSiu+kIv728jTTVg==", + "dev": true, + "requires": { + "call-bind": "^1.0.2", + "has-tostringtag": "^1.0.0" + } + }, + "object.assign": { + "version": "4.1.2", + "resolved": "https://registry.npmjs.org/object.assign/-/object.assign-4.1.2.tgz", + "integrity": "sha512-ixT2L5THXsApyiUPYKmW+2EHpXXe5Ii3M+f4e+aJFAHao5amFRW6J0OO6c/LU8Be47utCx2GL89hxGB6XSmKuQ==", "dev": true, "requires": { - "has-symbols": "^1.0.1" + "call-bind": "^1.0.0", + "define-properties": "^1.1.3", + "has-symbols": "^1.0.1", + "object-keys": "^1.1.1" } } } @@ -8622,15 +8793,6 @@ "pbkdf2": "^3.0.3" } }, - "parse-json": { - "version": "2.2.0", - "resolved": "https://registry.npmjs.org/parse-json/-/parse-json-2.2.0.tgz", - "integrity": "sha1-9ID0BDTvgHQfhGkJn43qGPVaTck=", - "dev": true, - "requires": { - "error-ex": "^1.2.0" - } - }, "parseqs": { "version": "0.0.5", "resolved": "https://registry.npmjs.org/parseqs/-/parseqs-0.0.5.tgz", @@ -8720,23 +8882,6 @@ "isarray": "0.0.1" } }, - "path-type": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/path-type/-/path-type-2.0.0.tgz", - "integrity": "sha1-8BLMuEFbcJb8LaoQVMPXI4lZTHM=", - "dev": true, - "requires": { - "pify": "^2.0.0" - }, - "dependencies": { - "pify": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/pify/-/pify-2.3.0.tgz", - "integrity": "sha1-7RQaasBDqEnqWISY59yosVMw6Qw=", - "dev": true - } - } - }, "pbkdf2": { "version": "3.0.17", "resolved": "https://registry.npmjs.org/pbkdf2/-/pbkdf2-3.0.17.tgz", @@ -8941,72 +9086,6 @@ "unpipe": "1.0.0" } }, - "read-pkg": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/read-pkg/-/read-pkg-2.0.0.tgz", - "integrity": "sha1-jvHAYjxqbbDcZxPEv6xGMysjaPg=", - "dev": true, - "requires": { - "load-json-file": "^2.0.0", - "normalize-package-data": "^2.3.2", - "path-type": "^2.0.0" - } - }, - "read-pkg-up": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/read-pkg-up/-/read-pkg-up-2.0.0.tgz", - "integrity": "sha1-a3KoBImE4MQeeVEP1en6mbO1Sb4=", - "dev": true, - "requires": { - "find-up": "^2.0.0", - "read-pkg": "^2.0.0" - }, - "dependencies": { - "find-up": { - "version": "2.1.0", - "resolved": "https://registry.npmjs.org/find-up/-/find-up-2.1.0.tgz", - "integrity": "sha1-RdG35QbHF93UgndaK3eSCjwMV6c=", - "dev": true, - "requires": { - "locate-path": "^2.0.0" - } - }, - "locate-path": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/locate-path/-/locate-path-2.0.0.tgz", - "integrity": "sha1-K1aLJl7slExtnA3pw9u7ygNUzY4=", - "dev": true, - "requires": { - "p-locate": "^2.0.0", - "path-exists": "^3.0.0" - } - }, - "p-limit": { - "version": "1.3.0", - "resolved": "https://registry.npmjs.org/p-limit/-/p-limit-1.3.0.tgz", - "integrity": "sha512-vvcXsLAJ9Dr5rQOPk7toZQZJApBl2K4J6dANSsEuh6QI41JYcsS/qhTGa9ErIUUgK3WNQoJYvylxvjqmiqEA9Q==", - "dev": true, - "requires": { - "p-try": "^1.0.0" - } - }, - "p-locate": { - "version": "2.0.0", - "resolved": "https://registry.npmjs.org/p-locate/-/p-locate-2.0.0.tgz", - "integrity": "sha1-IKAQOyIqcMj9OcwuWAaA893l7EM=", - "dev": true, - "requires": { - "p-limit": "^1.1.0" - } - }, - "p-try": { - "version": "1.0.0", - "resolved": "https://registry.npmjs.org/p-try/-/p-try-1.0.0.tgz", - "integrity": "sha1-y8ec26+P1CKOE/Yh8rGiN8GyB7M=", - "dev": true - } - } - }, "readable-stream": { "version": "1.1.14", "resolved": "https://registry.npmjs.org/readable-stream/-/readable-stream-1.1.14.tgz", @@ -9459,6 +9538,17 @@ "integrity": "sha512-vFwSUfQvqybiICwZY5+DAWIPLKsWO31Q91JSKl3UYv+K5c2QRPzn0qzec6QPu1Qc9eHYItiP3NdJqNVqetYAww==", "dev": true }, + "side-channel": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/side-channel/-/side-channel-1.0.4.tgz", + "integrity": "sha512-q5XPytqFEIKHkGdiMIrY10mvLRvnQh42/+GoBlFW3b2LXLE2xxJpZFdm94we0BaoV3RwJyGqg5wS7epxTv0Zvw==", + "dev": true, + "requires": { + "call-bind": "^1.0.0", + "get-intrinsic": "^1.0.2", + "object-inspect": "^1.9.0" + } + }, "signal-exit": { "version": "3.0.2", "resolved": "https://registry.npmjs.org/signal-exit/-/signal-exit-3.0.2.tgz", @@ -9832,38 +9922,6 @@ } } }, - "spdx-correct": { - "version": "3.1.1", - "resolved": "https://registry.npmjs.org/spdx-correct/-/spdx-correct-3.1.1.tgz", - "integrity": "sha512-cOYcUWwhCuHCXi49RhFRCyJEK3iPj1Ziz9DpViV3tbZOwXD49QzIN3MpOLJNxh2qwq2lJJZaKMVw9qNi4jTC0w==", - "dev": true, - "requires": { - "spdx-expression-parse": "^3.0.0", - "spdx-license-ids": "^3.0.0" - } - }, - "spdx-exceptions": { - "version": "2.3.0", - "resolved": "https://registry.npmjs.org/spdx-exceptions/-/spdx-exceptions-2.3.0.tgz", - "integrity": "sha512-/tTrYOC7PPI1nUAgx34hUpqXuyJG+DTHJTnIULG4rDygi4xu/tfgmq1e1cIRwRzwZgo4NLySi+ricLkZkw4i5A==", - "dev": true - }, - "spdx-expression-parse": { - "version": "3.0.1", - "resolved": "https://registry.npmjs.org/spdx-expression-parse/-/spdx-expression-parse-3.0.1.tgz", - "integrity": "sha512-cbqHunsQWnJNE6KhVSMsMeH5H/L9EpymbzqTQ3uLwNCLZ1Q481oWaofqH7nO6V07xlXwY6PhQdQ2IedWx/ZK4Q==", - "dev": true, - "requires": { - "spdx-exceptions": "^2.1.0", - "spdx-license-ids": "^3.0.0" - } - }, - "spdx-license-ids": { - "version": "3.0.5", - "resolved": "https://registry.npmjs.org/spdx-license-ids/-/spdx-license-ids-3.0.5.tgz", - "integrity": "sha512-J+FWzZoynJEXGphVIS+XEh3kFSjZX/1i9gFBaWQcB+/tmpe2qUsSBABpcxqxnAxFdiUFEgAX1bjYGQvIZmoz9Q==", - "dev": true - }, "split-string": { "version": "3.1.0", "resolved": "https://registry.npmjs.org/split-string/-/split-string-3.1.0.tgz", @@ -9984,129 +10042,23 @@ } }, "string.prototype.trimend": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/string.prototype.trimend/-/string.prototype.trimend-1.0.1.tgz", - "integrity": "sha512-LRPxFUaTtpqYsTeNKaFOw3R4bxIzWOnbQ837QfBylo8jIxtcbK/A/sMV7Q+OAV/vWo+7s25pOE10KYSjaSO06g==", + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/string.prototype.trimend/-/string.prototype.trimend-1.0.4.tgz", + "integrity": "sha512-y9xCjw1P23Awk8EvTpcyL2NIr1j7wJ39f+k6lvRnSMz+mz9CGz9NYPelDk42kOz6+ql8xjfK8oYzy3jAP5QU5A==", "dev": true, "requires": { - "define-properties": "^1.1.3", - "es-abstract": "^1.17.5" - }, - "dependencies": { - "es-abstract": { - "version": "1.17.6", - "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.17.6.tgz", - "integrity": "sha512-Fr89bON3WFyUi5EvAeI48QTWX0AyekGgLA8H+c+7fbfCkJwRWRMLd8CQedNEyJuoYYhmtEqY92pgte1FAhBlhw==", - "dev": true, - "requires": { - "es-to-primitive": "^1.2.1", - "function-bind": "^1.1.1", - "has": "^1.0.3", - "has-symbols": "^1.0.1", - "is-callable": "^1.2.0", - "is-regex": "^1.1.0", - "object-inspect": "^1.7.0", - "object-keys": "^1.1.1", - "object.assign": "^4.1.0", - "string.prototype.trimend": "^1.0.1", - "string.prototype.trimstart": "^1.0.1" - } - }, - "es-to-primitive": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz", - "integrity": "sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==", - "dev": true, - "requires": { - "is-callable": "^1.1.4", - "is-date-object": "^1.0.1", - "is-symbol": "^1.0.2" - } - }, - "has-symbols": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.1.tgz", - "integrity": "sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg==", - "dev": true - }, - "is-callable": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.0.tgz", - "integrity": "sha512-pyVD9AaGLxtg6srb2Ng6ynWJqkHU9bEM087AKck0w8QwDarTfNcpIYoU8x8Hv2Icm8u6kFJM18Dag8lyqGkviw==", - "dev": true - }, - "is-regex": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.0.tgz", - "integrity": "sha512-iI97M8KTWID2la5uYXlkbSDQIg4F6o1sYboZKKTDpnDQMLtUL86zxhgDet3Q2SriaYsyGqZ6Mn2SjbRKeLHdqw==", - "dev": true, - "requires": { - "has-symbols": "^1.0.1" - } - } + "call-bind": "^1.0.2", + "define-properties": "^1.1.3" } }, "string.prototype.trimstart": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/string.prototype.trimstart/-/string.prototype.trimstart-1.0.1.tgz", - "integrity": "sha512-XxZn+QpvrBI1FOcg6dIpxUPgWCPuNXvMD72aaRaUQv1eD4e/Qy8i/hFTe0BUmD60p/QA6bh1avmuPTfNjqVWRw==", + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/string.prototype.trimstart/-/string.prototype.trimstart-1.0.4.tgz", + "integrity": "sha512-jh6e984OBfvxS50tdY2nRZnoC5/mLFKOREQfw8t5yytkoUsJRNxvI/E39qu1sD0OtWI3OC0XgKSmcWwziwYuZw==", "dev": true, "requires": { - "define-properties": "^1.1.3", - "es-abstract": "^1.17.5" - }, - "dependencies": { - "es-abstract": { - "version": "1.17.6", - "resolved": "https://registry.npmjs.org/es-abstract/-/es-abstract-1.17.6.tgz", - "integrity": "sha512-Fr89bON3WFyUi5EvAeI48QTWX0AyekGgLA8H+c+7fbfCkJwRWRMLd8CQedNEyJuoYYhmtEqY92pgte1FAhBlhw==", - "dev": true, - "requires": { - "es-to-primitive": "^1.2.1", - "function-bind": "^1.1.1", - "has": "^1.0.3", - "has-symbols": "^1.0.1", - "is-callable": "^1.2.0", - "is-regex": "^1.1.0", - "object-inspect": "^1.7.0", - "object-keys": "^1.1.1", - "object.assign": "^4.1.0", - "string.prototype.trimend": "^1.0.1", - "string.prototype.trimstart": "^1.0.1" - } - }, - "es-to-primitive": { - "version": "1.2.1", - "resolved": "https://registry.npmjs.org/es-to-primitive/-/es-to-primitive-1.2.1.tgz", - "integrity": "sha512-QCOllgZJtaUo9miYBcLChTUaHNjJF3PYs1VidD7AwiEj1kYxKeQTctLAezAOH5ZKRH0g2IgPn6KwB4IT8iRpvA==", - "dev": true, - "requires": { - "is-callable": "^1.1.4", - "is-date-object": "^1.0.1", - "is-symbol": "^1.0.2" - } - }, - "has-symbols": { - "version": "1.0.1", - "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.1.tgz", - "integrity": "sha512-PLcsoqu++dmEIZB+6totNFKq/7Do+Z0u4oT0zKOJNl3lYK6vGwwu2hjHs+68OEZbTjiUE9bgOABXbP/GvrS0Kg==", - "dev": true - }, - "is-callable": { - "version": "1.2.0", - "resolved": "https://registry.npmjs.org/is-callable/-/is-callable-1.2.0.tgz", - "integrity": "sha512-pyVD9AaGLxtg6srb2Ng6ynWJqkHU9bEM087AKck0w8QwDarTfNcpIYoU8x8Hv2Icm8u6kFJM18Dag8lyqGkviw==", - "dev": true - }, - "is-regex": { - "version": "1.1.0", - "resolved": "https://registry.npmjs.org/is-regex/-/is-regex-1.1.0.tgz", - "integrity": "sha512-iI97M8KTWID2la5uYXlkbSDQIg4F6o1sYboZKKTDpnDQMLtUL86zxhgDet3Q2SriaYsyGqZ6Mn2SjbRKeLHdqw==", - "dev": true, - "requires": { - "has-symbols": "^1.0.1" - } - } + "call-bind": "^1.0.2", + "define-properties": "^1.1.3" } }, "string_decoder": { @@ -10174,6 +10126,12 @@ } } }, + "supports-preserve-symlinks-flag": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/supports-preserve-symlinks-flag/-/supports-preserve-symlinks-flag-1.0.0.tgz", + "integrity": "sha512-ot0WnXS9fgdkgIcePe6RHNk1WA8+muPa6cSjeR3V8K27q9BB1rTE3R1p7Hv0z1ZyAc8s6Vvv8DIyWf681MAt0w==", + "dev": true + }, "syntax-error": { "version": "1.4.0", "resolved": "https://registry.npmjs.org/syntax-error/-/syntax-error-1.4.0.tgz", @@ -10438,9 +10396,9 @@ "dev": true }, "tsconfig-paths": { - "version": "3.9.0", - "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.9.0.tgz", - "integrity": "sha512-dRcuzokWhajtZWkQsDVKbWyY+jgcLC5sqJhg2PSgf4ZkH2aHPvaOY8YWGhmjb68b5qqTfasSsDO9k7RUiEmZAw==", + "version": "3.12.0", + "resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.12.0.tgz", + "integrity": "sha512-e5adrnOYT6zqVnWqZu7i/BQ3BnhzvGbjEjejFXO20lKIKpwTaupkCPgEfv4GZK1IBciJUEhYs3J3p75FdaTFVg==", "dev": true, "requires": { "@types/json5": "^0.0.29", @@ -10560,6 +10518,26 @@ "integrity": "sha512-4IcGSufhFshvLNcMCV80UnQVlZ5pMOC8mvNPForqwA4+lzYQuetTESLDQkeLmihq8bRcnpbQa48Wb8Lh16/xow==", "dev": true }, + "unbox-primitive": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/unbox-primitive/-/unbox-primitive-1.0.1.tgz", + "integrity": "sha512-tZU/3NqK3dA5gpE1KtyiJUrEB0lxnGkMFHptJ7q6ewdZ8s12QrODwNbhIJStmJkd1QDXa1NRA8aF2A1zk/Ypyw==", + "dev": true, + "requires": { + "function-bind": "^1.1.1", + "has-bigints": "^1.0.1", + "has-symbols": "^1.0.2", + "which-boxed-primitive": "^1.0.2" + }, + "dependencies": { + "has-symbols": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.2.tgz", + "integrity": "sha512-chXa79rL/UC2KlX17jo3vRGz0azaWEx5tGqZg5pO3NUyEJVB17dMruQlzCCOfUvElghKcm5194+BCRvi2Rv/Gw==", + "dev": true + } + } + }, "underscore": { "version": "1.9.1", "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.9.1.tgz", @@ -10762,16 +10740,6 @@ "integrity": "sha512-HjSDRw6gZE5JMggctHBcjVak08+KEVhSIiDzFnT9S9aegmp85S/bReBVTb4QTFaRNptJ9kuYaNhnbNEOkbKb/A==", "dev": true }, - "validate-npm-package-license": { - "version": "3.0.4", - "resolved": "https://registry.npmjs.org/validate-npm-package-license/-/validate-npm-package-license-3.0.4.tgz", - "integrity": "sha512-DpKm2Ui/xN7/HQKCtpZxoRWBhZ9Z0kqtygG8XCgNQ8ZlDnxuQmWhj566j8fN4Cu3/JmbhsDo7fcAJq4s9h27Ew==", - "dev": true, - "requires": { - "spdx-correct": "^3.0.0", - "spdx-expression-parse": "^3.0.0" - } - }, "vary": { "version": "1.1.2", "resolved": "https://registry.npmjs.org/vary/-/vary-1.1.2.tgz", @@ -10796,6 +10764,36 @@ "isexe": "^2.0.0" } }, + "which-boxed-primitive": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/which-boxed-primitive/-/which-boxed-primitive-1.0.2.tgz", + "integrity": "sha512-bwZdv0AKLpplFY2KZRX6TvyuN7ojjr7lwkg6ml0roIy9YeuSr7JS372qlNW18UQYzgYK9ziGcerWqZOmEn9VNg==", + "dev": true, + "requires": { + "is-bigint": "^1.0.1", + "is-boolean-object": "^1.1.0", + "is-number-object": "^1.0.4", + "is-string": "^1.0.5", + "is-symbol": "^1.0.3" + }, + "dependencies": { + "has-symbols": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/has-symbols/-/has-symbols-1.0.2.tgz", + "integrity": "sha512-chXa79rL/UC2KlX17jo3vRGz0azaWEx5tGqZg5pO3NUyEJVB17dMruQlzCCOfUvElghKcm5194+BCRvi2Rv/Gw==", + "dev": true + }, + "is-symbol": { + "version": "1.0.4", + "resolved": "https://registry.npmjs.org/is-symbol/-/is-symbol-1.0.4.tgz", + "integrity": "sha512-C/CPBqKWnvdcxqIARxyOh4v1UUEOCHpgDa0WYgpKDFMszcrPcffg5uhwSgPCLD2WWxmq6isisz87tzT01tuGhg==", + "dev": true, + "requires": { + "has-symbols": "^1.0.2" + } + } + } + }, "which-module": { "version": "2.0.0", "resolved": "https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz", diff --git a/package.json b/package.json index 24c94763a7..7f9de9b9ba 100644 --- a/package.json +++ b/package.json @@ -104,7 +104,7 @@ "dox": "latest", "envvar": "^2.0.0", "eslint": "^5.16.0", - "eslint-plugin-import": "^2.21.2", + "eslint-plugin-import": "^2.25.4", "fast-check": "^2.12.0", "handlebars": ">=4.1.2", "js-yaml": "^3.13.1", diff --git a/test/F.js b/test/F.js index c83b9092ef..bfb1ee6751 100644 --- a/test/F.js +++ b/test/F.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('F', function() { diff --git a/test/T.js b/test/T.js index 941e515235..6b56e7fa52 100644 --- a/test/T.js +++ b/test/T.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('T', function() { diff --git a/test/add.js b/test/add.js index 87719cc478..85f69635c8 100644 --- a/test/add.js +++ b/test/add.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); var fc = require('fast-check'); diff --git a/test/addIndex.js b/test/addIndex.js index 549e04d10b..29bc2b1489 100644 --- a/test/addIndex.js +++ b/test/addIndex.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('addIndex', function() { diff --git a/test/adjust.js b/test/adjust.js index 67ce5e7388..3121a386c5 100644 --- a/test/adjust.js +++ b/test/adjust.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('adjust', function() { it('applies the given function to the value at the given index of the supplied array', function() { diff --git a/test/all.js b/test/all.js index 426c5aa644..341f53cbe8 100644 --- a/test/all.js +++ b/test/all.js @@ -1,7 +1,7 @@ -var listXf = require('./helpers/listXf'); +var listXf = require('./helpers/listXf.js'); -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('all', function() { diff --git a/test/allPass.js b/test/allPass.js index 4d3694956f..268f8cd9a1 100644 --- a/test/allPass.js +++ b/test/allPass.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('allPass', function() { diff --git a/test/always.js b/test/always.js index 7855a37545..2e9ef59800 100644 --- a/test/always.js +++ b/test/always.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); var fc = require('fast-check'); diff --git a/test/and.js b/test/and.js index 80f8d86a9c..be0deb8bca 100644 --- a/test/and.js +++ b/test/and.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('and', function() { diff --git a/test/andThen.js b/test/andThen.js index d43adfc6db..5c6a8a1c70 100644 --- a/test/andThen.js +++ b/test/andThen.js @@ -1,7 +1,7 @@ var assert = require('assert'); -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('andThen', function() { diff --git a/test/any.js b/test/any.js index 43b8cdf1c7..40a71eb92f 100644 --- a/test/any.js +++ b/test/any.js @@ -1,7 +1,7 @@ -var listXf = require('./helpers/listXf'); +var listXf = require('./helpers/listXf.js'); -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('any', function() { diff --git a/test/anyPass.js b/test/anyPass.js index c2b151c3b7..a8045a43aa 100644 --- a/test/anyPass.js +++ b/test/anyPass.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('anyPass', function() { diff --git a/test/ap.js b/test/ap.js index 62f79ce33e..d12d3832e7 100644 --- a/test/ap.js +++ b/test/ap.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('ap', function() { diff --git a/test/aperture.js b/test/aperture.js index 0643a0a952..f537d82f27 100644 --- a/test/aperture.js +++ b/test/aperture.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('aperture', function() { diff --git a/test/append.js b/test/append.js index 8d16ad8bab..11a531183b 100644 --- a/test/append.js +++ b/test/append.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('append', function() { diff --git a/test/apply.js b/test/apply.js index ab6136b9cc..bc92f3aaa1 100644 --- a/test/apply.js +++ b/test/apply.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('apply', function() { diff --git a/test/applySpec.js b/test/applySpec.js index 3e32e458b2..6f8b9aca95 100644 --- a/test/applySpec.js +++ b/test/applySpec.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('applySpec', function() { diff --git a/test/applyTo.js b/test/applyTo.js index f81966d412..a6537c76bb 100644 --- a/test/applyTo.js +++ b/test/applyTo.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('applyTo', function() { it('applies the function to its first argument', function() { diff --git a/test/ascend.js b/test/ascend.js index 4f285bdadc..79cd22f61d 100644 --- a/test/ascend.js +++ b/test/ascend.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('ascend', function() { it('builds an ascending comparator function out of the identity function', function() { diff --git a/test/assoc.js b/test/assoc.js index 51e3ea1ec7..aee925d746 100644 --- a/test/assoc.js +++ b/test/assoc.js @@ -1,7 +1,7 @@ var assert = require('assert'); -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('assoc', function() { diff --git a/test/assocPath.js b/test/assocPath.js index 4a6ccfe640..25ee21f625 100644 --- a/test/assocPath.js +++ b/test/assocPath.js @@ -1,7 +1,7 @@ var assert = require('assert'); -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('assocPath', function() { diff --git a/test/binary.js b/test/binary.js index b45c478a4e..602e82c914 100644 --- a/test/binary.js +++ b/test/binary.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('binary', function() { diff --git a/test/bind.js b/test/bind.js index e058e4993c..9b2be568ac 100644 --- a/test/bind.js +++ b/test/bind.js @@ -1,6 +1,6 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('bind', function() { diff --git a/test/both.js b/test/both.js index 9b89de23f8..c24f9b8b5d 100644 --- a/test/both.js +++ b/test/both.js @@ -1,7 +1,7 @@ var S = require('sanctuary'); -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('both', function() { diff --git a/test/call.js b/test/call.js index f4b4ab2dbc..3b6afd9acf 100644 --- a/test/call.js +++ b/test/call.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('call', function() { diff --git a/test/chain.js b/test/chain.js index b1066b076c..79fdcef944 100644 --- a/test/chain.js +++ b/test/chain.js @@ -1,8 +1,8 @@ -var listXf = require('./helpers/listXf'); +var listXf = require('./helpers/listXf.js'); -var R = require('../source'); -var eq = require('./shared/eq'); -var _isTransformer = require('../source/internal/_isTransformer'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); +var _isTransformer = require('../source/internal/_isTransformer.js'); describe('chain', function() { var intoArray = R.into([]); diff --git a/test/clamp.js b/test/clamp.js index a34e699ccf..0026ade40f 100644 --- a/test/clamp.js +++ b/test/clamp.js @@ -1,5 +1,5 @@ -var eq = require('./shared/eq'); -var R = require('../source'); +var eq = require('./shared/eq.js'); +var R = require('../source/index.js'); describe('clamp', function() { it('clamps to the lower bound', function() { diff --git a/test/clone.js b/test/clone.js index 2428fb646d..5817f68c44 100644 --- a/test/clone.js +++ b/test/clone.js @@ -1,7 +1,7 @@ var assert = require('assert'); -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('deep clone integers, strings and booleans', function() { diff --git a/test/collectBy.js b/test/collectBy.js index 84ecba1bdf..2c13bf15b2 100644 --- a/test/collectBy.js +++ b/test/collectBy.js @@ -1,4 +1,4 @@ -var {all, compose , difference , equals , head , identity , is , isEmpty , length , uniq , unnest , collectBy} = require('../source'); +var {all, compose , difference , equals , head , identity , is , isEmpty , length , uniq , unnest , collectBy} = require('../source/index.js'); var fc = require('fast-check'); var {spy} = require('sinon'); diff --git a/test/comparator.js b/test/comparator.js index 2d2b35638a..e740021fc2 100644 --- a/test/comparator.js +++ b/test/comparator.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('comparator', function() { diff --git a/test/complement.js b/test/complement.js index 480fee020c..9f6fb8f72f 100644 --- a/test/complement.js +++ b/test/complement.js @@ -1,7 +1,7 @@ var S = require('sanctuary'); -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('complement', function() { diff --git a/test/compose.js b/test/compose.js index aacc13359c..36c8de7481 100644 --- a/test/compose.js +++ b/test/compose.js @@ -1,7 +1,7 @@ var assert = require('assert'); -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); var fc = require('fast-check'); diff --git a/test/composeWith.js b/test/composeWith.js index d05d051291..70664b932e 100644 --- a/test/composeWith.js +++ b/test/composeWith.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('composeWith', function() { diff --git a/test/concat.js b/test/concat.js index 88514bc0c4..399e012a71 100644 --- a/test/concat.js +++ b/test/concat.js @@ -1,7 +1,7 @@ var assert = require('assert'); -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('concat', function() { diff --git a/test/cond.js b/test/cond.js index 5d7d085eed..c8403a55ac 100644 --- a/test/cond.js +++ b/test/cond.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('cond', function() { diff --git a/test/construct.js b/test/construct.js index 8bcac81df8..39b558b45d 100644 --- a/test/construct.js +++ b/test/construct.js @@ -1,7 +1,7 @@ var assert = require('assert'); -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('construct', function() { diff --git a/test/constructN.js b/test/constructN.js index 1695bf8c94..7e41f1c084 100644 --- a/test/constructN.js +++ b/test/constructN.js @@ -1,7 +1,7 @@ var assert = require('assert'); -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('constructN', function() { diff --git a/test/converge.js b/test/converge.js index 29c9faea27..17edbe6f09 100644 --- a/test/converge.js +++ b/test/converge.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('converge', function() { diff --git a/test/count.js b/test/count.js index b8dc43dd34..12effcbc5a 100644 --- a/test/count.js +++ b/test/count.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('count', function() { var even = function(x) { return x % 2 === 0; }; diff --git a/test/countBy.js b/test/countBy.js index f8a09b9a6f..ece6154139 100644 --- a/test/countBy.js +++ b/test/countBy.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); var albums = [ diff --git a/test/curry.js b/test/curry.js index 20681c0ed1..124af851a9 100644 --- a/test/curry.js +++ b/test/curry.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); var fc = require('fast-check'); describe('curry', function() { diff --git a/test/curryN.js b/test/curryN.js index 0e233febf8..17afc05861 100644 --- a/test/curryN.js +++ b/test/curryN.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('curryN', function() { diff --git a/test/dec.js b/test/dec.js index dd558a11de..c00022d89a 100644 --- a/test/dec.js +++ b/test/dec.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('dec', function() { diff --git a/test/defaultTo.js b/test/defaultTo.js index 4ffa01f904..17688a7f5f 100644 --- a/test/defaultTo.js +++ b/test/defaultTo.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('defaultTo', function() { diff --git a/test/descend.js b/test/descend.js index 7a70777a74..d8fa43d0d2 100644 --- a/test/descend.js +++ b/test/descend.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('descend', function() { it('builds a descending comparator function out of the identity function', function() { diff --git a/test/difference.js b/test/difference.js index 635d427221..c891002a72 100644 --- a/test/difference.js +++ b/test/difference.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('difference', function() { diff --git a/test/differenceWith.js b/test/differenceWith.js index b6e45d2f04..fb11d7531f 100644 --- a/test/differenceWith.js +++ b/test/differenceWith.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('differenceWith', function() { diff --git a/test/dissoc.js b/test/dissoc.js index 2a7f7d7a63..77641c1ed7 100644 --- a/test/dissoc.js +++ b/test/dissoc.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); var assert = require('assert'); diff --git a/test/dissocPath.js b/test/dissocPath.js index 31c74dfb9f..2e7fdedd6f 100644 --- a/test/dissocPath.js +++ b/test/dissocPath.js @@ -1,7 +1,7 @@ var assert = require('assert'); -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('dissocPath', function() { diff --git a/test/divide.js b/test/divide.js index ce8637a24f..68a98f273c 100644 --- a/test/divide.js +++ b/test/divide.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('divide', function() { diff --git a/test/drop.js b/test/drop.js index 7806c8021a..5613d0b8b5 100644 --- a/test/drop.js +++ b/test/drop.js @@ -1,7 +1,7 @@ var assert = require('assert'); -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('drop', function() { diff --git a/test/dropLast.js b/test/dropLast.js index 401f36b653..a7e93afe66 100644 --- a/test/dropLast.js +++ b/test/dropLast.js @@ -1,7 +1,7 @@ var assert = require('assert'); -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('dropLast', function() { diff --git a/test/dropLastWhile.js b/test/dropLastWhile.js index d80f29ac09..c24ac893ea 100644 --- a/test/dropLastWhile.js +++ b/test/dropLastWhile.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('dropLastWhile', function() { diff --git a/test/dropRepeats.js b/test/dropRepeats.js index 812ade99d4..e74cd20874 100644 --- a/test/dropRepeats.js +++ b/test/dropRepeats.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('dropRepeats', function() { diff --git a/test/dropRepeatsWith.js b/test/dropRepeatsWith.js index 3d742f02a8..cf21539551 100644 --- a/test/dropRepeatsWith.js +++ b/test/dropRepeatsWith.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('dropRepeatsWith', function() { diff --git a/test/dropWhile.js b/test/dropWhile.js index 705182f0fc..485263a36b 100644 --- a/test/dropWhile.js +++ b/test/dropWhile.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('dropWhile', function() { diff --git a/test/either.js b/test/either.js index 3730bc4ca8..4278dae0c8 100644 --- a/test/either.js +++ b/test/either.js @@ -1,7 +1,7 @@ var S = require('sanctuary'); -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('either', function() { diff --git a/test/empty.js b/test/empty.js index 5083e730d4..1d9ec691dd 100644 --- a/test/empty.js +++ b/test/empty.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('empty', function() { diff --git a/test/endsWith.js b/test/endsWith.js index 1198129874..ad7b7d33b5 100644 --- a/test/endsWith.js +++ b/test/endsWith.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('endsWith', function() { it('should return true when a string ends with the provided value', function() { diff --git a/test/eqBy.js b/test/eqBy.js index 5d4f0f7c76..c584851c29 100644 --- a/test/eqBy.js +++ b/test/eqBy.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('eqBy', function() { diff --git a/test/eqProps.js b/test/eqProps.js index 87f6fe0843..c43493014c 100644 --- a/test/eqProps.js +++ b/test/eqProps.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('eqProps', function() { diff --git a/test/equals.js b/test/equals.js index 73f6bae80e..43e14957e5 100644 --- a/test/equals.js +++ b/test/equals.js @@ -1,7 +1,7 @@ /* global Map, Set, WeakMap, WeakSet */ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); var fc = require('fast-check'); describe('equals', function() { diff --git a/test/evolve.js b/test/evolve.js index cc233d53a8..ebdc85d81e 100644 --- a/test/evolve.js +++ b/test/evolve.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('evolve', function() { diff --git a/test/filter.js b/test/filter.js index dcc80d7abc..e18a3adafa 100644 --- a/test/filter.js +++ b/test/filter.js @@ -1,6 +1,6 @@ -var R = require('../source'); -var eq = require('./shared/eq'); -var Maybe = require('./shared/Maybe'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); +var Maybe = require('./shared/Maybe.js'); describe('filter', function() { diff --git a/test/find.js b/test/find.js index bffeff3b79..7b6ee07bbb 100644 --- a/test/find.js +++ b/test/find.js @@ -1,6 +1,6 @@ -var R = require('../source'); -var eq = require('./shared/eq'); -var listXf = require('./helpers/listXf'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); +var listXf = require('./helpers/listXf.js'); describe('find', function() { diff --git a/test/findIndex.js b/test/findIndex.js index 35bb68e1c2..cf47091d84 100644 --- a/test/findIndex.js +++ b/test/findIndex.js @@ -1,6 +1,6 @@ -var R = require('../source'); -var eq = require('./shared/eq'); -var listXf = require('./helpers/listXf'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); +var listXf = require('./helpers/listXf.js'); describe('findIndex', function() { diff --git a/test/findLast.js b/test/findLast.js index 8efde0edb9..c52b441ae4 100644 --- a/test/findLast.js +++ b/test/findLast.js @@ -1,6 +1,6 @@ -var R = require('../source'); -var eq = require('./shared/eq'); -var listXf = require('./helpers/listXf'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); +var listXf = require('./helpers/listXf.js'); describe('findLast', function() { diff --git a/test/findLastIndex.js b/test/findLastIndex.js index c72b892131..9eb8b3e72e 100644 --- a/test/findLastIndex.js +++ b/test/findLastIndex.js @@ -1,6 +1,6 @@ -var R = require('../source'); -var eq = require('./shared/eq'); -var listXf = require('./helpers/listXf'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); +var listXf = require('./helpers/listXf.js'); describe('findLastIndex', function() { diff --git a/test/flatten.js b/test/flatten.js index 85021111c8..d7d08b2bab 100644 --- a/test/flatten.js +++ b/test/flatten.js @@ -1,7 +1,7 @@ var assert = require('assert'); -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('flatten', function() { diff --git a/test/flip.js b/test/flip.js index 882d8f8ae2..7babace05f 100644 --- a/test/flip.js +++ b/test/flip.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); var fc = require('fast-check'); diff --git a/test/forEach.js b/test/forEach.js index 301eba3f7c..f8bd17ea48 100644 --- a/test/forEach.js +++ b/test/forEach.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('forEach', function() { diff --git a/test/forEachObjIndexed.js b/test/forEachObjIndexed.js index 5320f6b86a..c6437442cf 100644 --- a/test/forEachObjIndexed.js +++ b/test/forEachObjIndexed.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('forEachObjIndexed', function() { diff --git a/test/fromPairs.js b/test/fromPairs.js index fffe43ea1e..73e21f4ed5 100644 --- a/test/fromPairs.js +++ b/test/fromPairs.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('fromPairs', function() { diff --git a/test/groupBy.js b/test/groupBy.js index 61d224192d..fcb416490e 100644 --- a/test/groupBy.js +++ b/test/groupBy.js @@ -1,6 +1,6 @@ -var R = require('../source'); -var eq = require('./shared/eq'); -var _isTransformer = require('../source/internal/_isTransformer'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); +var _isTransformer = require('../source/internal/_isTransformer.js'); describe('groupBy', function() { diff --git a/test/groupWith.js b/test/groupWith.js index fbad305afa..ade1875771 100644 --- a/test/groupWith.js +++ b/test/groupWith.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('groupWith', function() { diff --git a/test/gt.js b/test/gt.js index 1b49a562ad..94432294e2 100644 --- a/test/gt.js +++ b/test/gt.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('gt', function() { diff --git a/test/gte.js b/test/gte.js index 5a69c76380..2f96c6f181 100644 --- a/test/gte.js +++ b/test/gte.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('gte', function() { diff --git a/test/has.js b/test/has.js index a0762f9601..9103dd87c9 100644 --- a/test/has.js +++ b/test/has.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('has', function() { diff --git a/test/hasIn.js b/test/hasIn.js index cb702cfb3b..8e8f756a61 100644 --- a/test/hasIn.js +++ b/test/hasIn.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('hasIn', function() { diff --git a/test/hasPath.js b/test/hasPath.js index 7ed7fed7a6..9edd6088f0 100644 --- a/test/hasPath.js +++ b/test/hasPath.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('hasPath', function() { diff --git a/test/head.js b/test/head.js index 9747ef477c..cc6e0d12e5 100644 --- a/test/head.js +++ b/test/head.js @@ -1,7 +1,7 @@ var assert = require('assert'); -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('head', function() { diff --git a/test/helpers/test.examplesRunner.js b/test/helpers/test.examplesRunner.js index 824689b29e..c3dfcef887 100644 --- a/test/helpers/test.examplesRunner.js +++ b/test/helpers/test.examplesRunner.js @@ -1,6 +1,6 @@ var assert = require('assert'); var fs = require('fs'); -var R = require('../source'); +var R = require('../source/index.js'); var dox = require('dox'); // simple object to hold info about our examples diff --git a/test/identical.js b/test/identical.js index 4f90b813b5..6144428f4f 100644 --- a/test/identical.js +++ b/test/identical.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); var assert = require('assert'); // see https://developer.mozilla.org/en-US/docs/Web/Security/Same-origin_policy#cross-origin_script_api_access diff --git a/test/identity.js b/test/identity.js index a6f27ab035..eb04e6bd95 100644 --- a/test/identity.js +++ b/test/identity.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('identity', function() { diff --git a/test/ifElse.js b/test/ifElse.js index 30ae11fc59..3ebec6f93e 100644 --- a/test/ifElse.js +++ b/test/ifElse.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('ifElse', function() { diff --git a/test/inc.js b/test/inc.js index 05c281ae89..ffb1374beb 100644 --- a/test/inc.js +++ b/test/inc.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('inc', function() { diff --git a/test/includes.js b/test/includes.js index cff45cf67f..7720014935 100644 --- a/test/includes.js +++ b/test/includes.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('includes', function() { diff --git a/test/index.js b/test/index.js index 7b1071e57b..a9b5dcd1a6 100644 --- a/test/index.js +++ b/test/index.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); var fs = require('fs'); var path = require('path'); diff --git a/test/indexBy.js b/test/indexBy.js index 380450aac0..c4e7a19fb2 100644 --- a/test/indexBy.js +++ b/test/indexBy.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('indexBy', function() { diff --git a/test/indexOf.js b/test/indexOf.js index 00c46b3e1f..47d32ac675 100644 --- a/test/indexOf.js +++ b/test/indexOf.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('indexOf', function() { diff --git a/test/init.js b/test/init.js index bb6fee60ab..3ccc1b1de0 100644 --- a/test/init.js +++ b/test/init.js @@ -1,7 +1,7 @@ var assert = require('assert'); -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('init', function() { diff --git a/test/innerJoin.js b/test/innerJoin.js index bb95ca464f..4c7182321a 100644 --- a/test/innerJoin.js +++ b/test/innerJoin.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); var a = {id: 1, name: 'a'}; diff --git a/test/insert.js b/test/insert.js index 1f1433f527..1850c27610 100644 --- a/test/insert.js +++ b/test/insert.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('insert', function() { diff --git a/test/insertAll.js b/test/insertAll.js index 80922b6f47..bc4c7b33e9 100644 --- a/test/insertAll.js +++ b/test/insertAll.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('insertAll', function() { diff --git a/test/internal/_curry2.js b/test/internal/_curry2.js index 8e295b062e..9178c6299b 100644 --- a/test/internal/_curry2.js +++ b/test/internal/_curry2.js @@ -1,6 +1,6 @@ -var eq = require('../shared/eq'); -var _ = require('../../source/__'); -var _curry2 = require('../../source/internal/_curry2'); +var eq = require('../shared/eq.js'); +var _ = require('../../source/__.js'); +var _curry2 = require('../../source/internal/_curry2.js'); describe('_curry2', function() { diff --git a/test/internal/_curry3.js b/test/internal/_curry3.js index 266049cd80..6f017c6880 100644 --- a/test/internal/_curry3.js +++ b/test/internal/_curry3.js @@ -1,6 +1,6 @@ -var eq = require('../shared/eq'); -var _ = require('../../source/__'); -var _curry3 = require('../../source/internal/_curry3'); +var eq = require('../shared/eq.js'); +var _ = require('../../source/__.js'); +var _curry3 = require('../../source/internal/_curry3.js'); describe('_curry3', function() { diff --git a/test/internal/_isArrayLike.js b/test/internal/_isArrayLike.js index dc8e161c02..fb166fcd8c 100644 --- a/test/internal/_isArrayLike.js +++ b/test/internal/_isArrayLike.js @@ -1,5 +1,5 @@ -var eq = require('../shared/eq'); -var _isArrayLike = require('../../source/internal/_isArrayLike'); +var eq = require('../shared/eq.js'); +var _isArrayLike = require('../../source/internal/_isArrayLike.js'); describe('isArrayLike', function() { diff --git a/test/intersection.js b/test/intersection.js index da99bd5aaf..7906ef5069 100644 --- a/test/intersection.js +++ b/test/intersection.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('intersection', function() { diff --git a/test/intersperse.js b/test/intersperse.js index 4afd0dc5b9..75b20f7a36 100644 --- a/test/intersperse.js +++ b/test/intersperse.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('intersperse', function() { diff --git a/test/into.js b/test/into.js index 0ac72928d3..c390ce0469 100644 --- a/test/into.js +++ b/test/into.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('into', function() { diff --git a/test/invariants.js b/test/invariants.js index 971d66cea4..b3c0db1290 100644 --- a/test/invariants.js +++ b/test/invariants.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('invariants', function() { diff --git a/test/invert.js b/test/invert.js index 7745af98e6..c9bf223ae5 100644 --- a/test/invert.js +++ b/test/invert.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('invert', function() { diff --git a/test/invertObj.js b/test/invertObj.js index 99c05aed10..79ae8faf02 100644 --- a/test/invertObj.js +++ b/test/invertObj.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('invertObj', function() { diff --git a/test/invoker.js b/test/invoker.js index bb3957a9ce..b80e54e0d4 100644 --- a/test/invoker.js +++ b/test/invoker.js @@ -1,8 +1,8 @@ var assert = require('assert'); var vm = require('vm'); -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('invoker', function() { diff --git a/test/is.js b/test/is.js index 1d307f3ead..64f56b1770 100644 --- a/test/is.js +++ b/test/is.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('is', function() { diff --git a/test/isEmpty.js b/test/isEmpty.js index 162e986904..a559b5aa4f 100644 --- a/test/isEmpty.js +++ b/test/isEmpty.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('isEmpty', function() { diff --git a/test/isNil.js b/test/isNil.js index 06ea79502e..6b86eb7cff 100644 --- a/test/isNil.js +++ b/test/isNil.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('isNil', function() { it('tests a value for `null` or `undefined`', function() { diff --git a/test/join.js b/test/join.js index fd4552ad97..861334bdbf 100644 --- a/test/join.js +++ b/test/join.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('join', function() { diff --git a/test/juxt.js b/test/juxt.js index f14c9b7524..a2dfd34153 100644 --- a/test/juxt.js +++ b/test/juxt.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('juxt', function() { diff --git a/test/keys.js b/test/keys.js index 382415d012..2cb5a06de9 100644 --- a/test/keys.js +++ b/test/keys.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('keys', function() { diff --git a/test/keysIn.js b/test/keysIn.js index ccd5282873..e89924fb69 100644 --- a/test/keysIn.js +++ b/test/keysIn.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('keysIn', function() { diff --git a/test/last.js b/test/last.js index 8152fc6e57..1aa6604a04 100644 --- a/test/last.js +++ b/test/last.js @@ -1,7 +1,7 @@ var assert = require('assert'); -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('last', function() { diff --git a/test/lastIndexOf.js b/test/lastIndexOf.js index 9f0120c7b3..2f118e38fb 100644 --- a/test/lastIndexOf.js +++ b/test/lastIndexOf.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('lastIndexOf', function() { diff --git a/test/length.js b/test/length.js index d698468031..18face3006 100644 --- a/test/length.js +++ b/test/length.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('length', function() { diff --git a/test/lensIndex.js b/test/lensIndex.js index 828b7582ac..d16056a3ed 100644 --- a/test/lensIndex.js +++ b/test/lensIndex.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); var testList = [{a: 1}, {b: 2}, {c: 3}]; diff --git a/test/lensPath.js b/test/lensPath.js index a3ac0acc92..52cb3f3a65 100644 --- a/test/lensPath.js +++ b/test/lensPath.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); var testObj = { diff --git a/test/lensProp.js b/test/lensProp.js index a176240f61..c36c72b2f5 100644 --- a/test/lensProp.js +++ b/test/lensProp.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); var testObj = { diff --git a/test/lenses.js b/test/lenses.js index 1b1442126d..30e0ad1069 100644 --- a/test/lenses.js +++ b/test/lenses.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); var they = it; diff --git a/test/lift.js b/test/lift.js index 9d273c399f..38ad6e9e17 100644 --- a/test/lift.js +++ b/test/lift.js @@ -1,7 +1,7 @@ -var R = require('../source'); -var eq = require('./shared/eq'); -var Maybe = require('./shared/Maybe'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); +var Maybe = require('./shared/Maybe.js'); var not = function(x) { return !x; }; var add3 = R.curry(function add3(a, b, c) { diff --git a/test/liftN.js b/test/liftN.js index 5f1b5d58d9..8d9ce06de8 100644 --- a/test/liftN.js +++ b/test/liftN.js @@ -1,7 +1,7 @@ -var R = require('../source'); -var eq = require('./shared/eq'); -var Maybe = require('./shared/Maybe'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); +var Maybe = require('./shared/Maybe.js'); var addN = function() { diff --git a/test/lt.js b/test/lt.js index f5bcd75d4b..3e1171dcdb 100644 --- a/test/lt.js +++ b/test/lt.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('lt', function() { diff --git a/test/lte.js b/test/lte.js index b0a1ae102d..033c97ea4a 100644 --- a/test/lte.js +++ b/test/lte.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('lte', function() { diff --git a/test/map.js b/test/map.js index bf7e2a0395..14011328c0 100644 --- a/test/map.js +++ b/test/map.js @@ -1,9 +1,9 @@ -var listXf = require('./helpers/listXf'); +var listXf = require('./helpers/listXf.js'); -var R = require('../source'); +var R = require('../source/index.js'); var assert = require('assert'); -var eq = require('./shared/eq'); -var Id = require('./shared/Id'); +var eq = require('./shared/eq.js'); +var Id = require('./shared/Id.js'); describe('map', function() { var times2 = function(x) {return x * 2;}; diff --git a/test/mapAccum.js b/test/mapAccum.js index b98d9bbb50..1c59fbbb5e 100644 --- a/test/mapAccum.js +++ b/test/mapAccum.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('mapAccum', function() { diff --git a/test/mapAccumRight.js b/test/mapAccumRight.js index 75289fa8be..ca95b2cbce 100644 --- a/test/mapAccumRight.js +++ b/test/mapAccumRight.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('mapAccumRight', function() { diff --git a/test/mapObjIndexed.js b/test/mapObjIndexed.js index e2c719fcf0..56d9c3a191 100644 --- a/test/mapObjIndexed.js +++ b/test/mapObjIndexed.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('mapObjIndexed', function() { diff --git a/test/match.js b/test/match.js index 8f36f87171..b6323c02a4 100644 --- a/test/match.js +++ b/test/match.js @@ -1,7 +1,7 @@ var assert = require('assert'); -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('match', function() { diff --git a/test/mathMod.js b/test/mathMod.js index a72d068cd3..fe24f334e2 100644 --- a/test/mathMod.js +++ b/test/mathMod.js @@ -1,7 +1,7 @@ var assert = require('assert'); -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('mathMod', function() { diff --git a/test/max.js b/test/max.js index adee1c2462..692208d2ef 100644 --- a/test/max.js +++ b/test/max.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('max', function() { diff --git a/test/maxBy.js b/test/maxBy.js index c03ea977e2..bab702a649 100644 --- a/test/maxBy.js +++ b/test/maxBy.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('maxBy', function() { diff --git a/test/mean.js b/test/mean.js index 98d6c51c77..6f08f41ba2 100644 --- a/test/mean.js +++ b/test/mean.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('mean', function() { diff --git a/test/median.js b/test/median.js index c5e59efb37..0323076cd4 100644 --- a/test/median.js +++ b/test/median.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('median', function() { diff --git a/test/memoizeWith.js b/test/memoizeWith.js index 7609062b5d..4656d9d4e3 100644 --- a/test/memoizeWith.js +++ b/test/memoizeWith.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('memoizeWith', function() { diff --git a/test/mergeAll.js b/test/mergeAll.js index 2e961148c8..6c5fa3f566 100644 --- a/test/mergeAll.js +++ b/test/mergeAll.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('mergeAll', function() { diff --git a/test/mergeDeepLeft.js b/test/mergeDeepLeft.js index 196eef28b7..b8cfbc34d4 100644 --- a/test/mergeDeepLeft.js +++ b/test/mergeDeepLeft.js @@ -1,7 +1,7 @@ var assert = require('assert'); -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('mergeDeepLeft', function() { diff --git a/test/mergeDeepRight.js b/test/mergeDeepRight.js index efbc10abbc..21dfaa7189 100644 --- a/test/mergeDeepRight.js +++ b/test/mergeDeepRight.js @@ -1,7 +1,7 @@ var assert = require('assert'); -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('mergeDeepRight', function() { diff --git a/test/mergeDeepWith.js b/test/mergeDeepWith.js index 846a5e96f6..5ec55d939c 100644 --- a/test/mergeDeepWith.js +++ b/test/mergeDeepWith.js @@ -1,7 +1,7 @@ var assert = require('assert'); -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('mergeDeepWith', function() { diff --git a/test/mergeDeepWithKey.js b/test/mergeDeepWithKey.js index 2f41aa657e..6279c2dced 100644 --- a/test/mergeDeepWithKey.js +++ b/test/mergeDeepWithKey.js @@ -1,7 +1,7 @@ var assert = require('assert'); -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('mergeDeepWithKey', function() { diff --git a/test/mergeLeft.js b/test/mergeLeft.js index 4244ac3015..298906a87c 100644 --- a/test/mergeLeft.js +++ b/test/mergeLeft.js @@ -1,7 +1,7 @@ var assert = require('assert'); -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('mergeLeft', function() { diff --git a/test/mergeRight.js b/test/mergeRight.js index 6c1ce90c1c..44a2e820c9 100644 --- a/test/mergeRight.js +++ b/test/mergeRight.js @@ -1,7 +1,7 @@ var assert = require('assert'); -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('mergeRight', function() { diff --git a/test/mergeWith.js b/test/mergeWith.js index 031e9549b9..8654492e6e 100644 --- a/test/mergeWith.js +++ b/test/mergeWith.js @@ -1,7 +1,7 @@ var assert = require('assert'); -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('mergeWith', function() { diff --git a/test/mergeWithKey.js b/test/mergeWithKey.js index f19d6937c2..0e93de7d74 100644 --- a/test/mergeWithKey.js +++ b/test/mergeWithKey.js @@ -1,7 +1,7 @@ var assert = require('assert'); -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('mergeWithKey', function() { diff --git a/test/min.js b/test/min.js index b2d6871c09..61f4edd7d2 100644 --- a/test/min.js +++ b/test/min.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('min', function() { diff --git a/test/minBy.js b/test/minBy.js index 1ddf53d00a..1c9acd6ee1 100644 --- a/test/minBy.js +++ b/test/minBy.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('minBy', function() { diff --git a/test/modify.js b/test/modify.js index a326ecc34a..71ce63b81d 100644 --- a/test/modify.js +++ b/test/modify.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('modify', function() { diff --git a/test/modifyPath.js b/test/modifyPath.js index 7d5404d849..848e0d5aa0 100644 --- a/test/modifyPath.js +++ b/test/modifyPath.js @@ -1,7 +1,7 @@ var assert = require('assert'); -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('modifyPath', function() { diff --git a/test/modulo.js b/test/modulo.js index f264f83ef9..89f038d95d 100644 --- a/test/modulo.js +++ b/test/modulo.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('modulo', function() { diff --git a/test/move.js b/test/move.js index 5c302e8131..66bea1d245 100644 --- a/test/move.js +++ b/test/move.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); var list = ['a', 'b', 'c', 'd', 'e', 'f']; diff --git a/test/multiply.js b/test/multiply.js index 5041320067..52b1289938 100644 --- a/test/multiply.js +++ b/test/multiply.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('multiply', function() { diff --git a/test/nAry.js b/test/nAry.js index ccd4888949..29bae88451 100644 --- a/test/nAry.js +++ b/test/nAry.js @@ -1,7 +1,7 @@ var assert = require('assert'); -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('nAry', function() { diff --git a/test/negate.js b/test/negate.js index c143482259..2d5e12cd37 100644 --- a/test/negate.js +++ b/test/negate.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('negate', function() { diff --git a/test/none.js b/test/none.js index 596b013e09..1daff7b0ac 100644 --- a/test/none.js +++ b/test/none.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('none', function() { diff --git a/test/not.js b/test/not.js index ad5c284c56..89bd68f730 100644 --- a/test/not.js +++ b/test/not.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('not', function() { diff --git a/test/nth.js b/test/nth.js index 7955765ff7..f083995d25 100644 --- a/test/nth.js +++ b/test/nth.js @@ -1,7 +1,7 @@ var assert = require('assert'); -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('nth', function() { diff --git a/test/nthArg.js b/test/nthArg.js index 4a7084c823..779f1b9c46 100644 --- a/test/nthArg.js +++ b/test/nthArg.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('nthArg', function() { diff --git a/test/o.js b/test/o.js index fe743d3fb5..fd571efc53 100644 --- a/test/o.js +++ b/test/o.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); var fc = require('fast-check'); diff --git a/test/objOf.js b/test/objOf.js index 81739954ae..d7cfe2415e 100644 --- a/test/objOf.js +++ b/test/objOf.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('objOf', function() { diff --git a/test/of.js b/test/of.js index ef23c92018..116260af03 100644 --- a/test/of.js +++ b/test/of.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('of', function() { diff --git a/test/omit.js b/test/omit.js index c4c0df14d3..c11548c9f4 100644 --- a/test/omit.js +++ b/test/omit.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('omit', function() { diff --git a/test/on.js b/test/on.js index c14dc5e0be..df37d00dce 100644 --- a/test/on.js +++ b/test/on.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('on', function() { diff --git a/test/once.js b/test/once.js index 2bcbf1706a..6bc25b20ac 100644 --- a/test/once.js +++ b/test/once.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('once', function() { diff --git a/test/or.js b/test/or.js index bdc1d8e2a5..2475cbc6be 100644 --- a/test/or.js +++ b/test/or.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('or', function() { diff --git a/test/otherwise.js b/test/otherwise.js index 12a27c6644..f0ac7655bd 100644 --- a/test/otherwise.js +++ b/test/otherwise.js @@ -1,7 +1,7 @@ var assert = require('assert'); -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('otherwise', function() { diff --git a/test/pair.js b/test/pair.js index 47f84e56cf..f1dc85965f 100644 --- a/test/pair.js +++ b/test/pair.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('pair', function() { diff --git a/test/partial.js b/test/partial.js index 85a7aeebd9..a2aa070bc0 100644 --- a/test/partial.js +++ b/test/partial.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('partial', function() { diff --git a/test/partialObject.js b/test/partialObject.js index de07a7cbcd..e3ba8ac2ac 100644 --- a/test/partialObject.js +++ b/test/partialObject.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('partialObject', function() { var discriminant = function({ a, b, c }) { diff --git a/test/partialRight.js b/test/partialRight.js index 476b9fbdf1..19cac30e26 100644 --- a/test/partialRight.js +++ b/test/partialRight.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('partialRight', function() { diff --git a/test/partition.js b/test/partition.js index 095d1a7744..a3d1265d2a 100644 --- a/test/partition.js +++ b/test/partition.js @@ -1,7 +1,7 @@ var S = require('sanctuary'); -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('partition', function() { diff --git a/test/path.js b/test/path.js index 49e3a393a8..aeca67eb95 100644 --- a/test/path.js +++ b/test/path.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('path', function() { diff --git a/test/pathEq.js b/test/pathEq.js index a984994a55..280ca664eb 100644 --- a/test/pathEq.js +++ b/test/pathEq.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('pathEq', function() { diff --git a/test/pathOr.js b/test/pathOr.js index 407e52d969..397d974cab 100644 --- a/test/pathOr.js +++ b/test/pathOr.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('pathOr', function() { diff --git a/test/pathSatisfies.js b/test/pathSatisfies.js index f4624941f8..a23061b926 100644 --- a/test/pathSatisfies.js +++ b/test/pathSatisfies.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('pathSatisfies', function() { diff --git a/test/paths.js b/test/paths.js index f0fc7962c2..f3d2e95cc5 100644 --- a/test/paths.js +++ b/test/paths.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('paths', function() { var obj = { diff --git a/test/pick.js b/test/pick.js index 6315b2f849..13bc1c244e 100644 --- a/test/pick.js +++ b/test/pick.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('pick', function() { diff --git a/test/pickAll.js b/test/pickAll.js index aff479180c..108397df96 100644 --- a/test/pickAll.js +++ b/test/pickAll.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('pickAll', function() { diff --git a/test/pickBy.js b/test/pickBy.js index b64acb4f94..29550b5d43 100644 --- a/test/pickBy.js +++ b/test/pickBy.js @@ -1,7 +1,7 @@ var assert = require('assert'); -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('pickBy', function() { diff --git a/test/pipe.js b/test/pipe.js index fac69f1d4d..c784ab419f 100644 --- a/test/pipe.js +++ b/test/pipe.js @@ -1,7 +1,7 @@ var assert = require('assert'); -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('pipe', function() { diff --git a/test/pipeWith.js b/test/pipeWith.js index a907b05a17..5d931130af 100644 --- a/test/pipeWith.js +++ b/test/pipeWith.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('pipeWith', function() { diff --git a/test/pluck.js b/test/pluck.js index 85df9a5bb1..f1dabcea71 100644 --- a/test/pluck.js +++ b/test/pluck.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('pluck', function() { diff --git a/test/prepend.js b/test/prepend.js index f971e67992..08473b9051 100644 --- a/test/prepend.js +++ b/test/prepend.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('prepend', function() { diff --git a/test/product.js b/test/product.js index cff5735e4f..a6ec4d2899 100644 --- a/test/product.js +++ b/test/product.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('product', function() { diff --git a/test/project.js b/test/project.js index 28c2f1e487..70b1c66fba 100644 --- a/test/project.js +++ b/test/project.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('project', function() { diff --git a/test/promap.js b/test/promap.js index c58c3f7383..0b8acd1fad 100644 --- a/test/promap.js +++ b/test/promap.js @@ -1,6 +1,6 @@ -var R = require('../source'); -var eq = require('./shared/eq'); -var Pair = require('./shared/Pair'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); +var Pair = require('./shared/Pair.js'); describe('promap', function() { diff --git a/test/prop.js b/test/prop.js index 05d321c657..8563c9b3e0 100644 --- a/test/prop.js +++ b/test/prop.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); var fc = require('fast-check'); describe('prop', function() { diff --git a/test/propEq.js b/test/propEq.js index de22e267d8..877acf4815 100644 --- a/test/propEq.js +++ b/test/propEq.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('propEq', function() { diff --git a/test/propIs.js b/test/propIs.js index 12c4e15b30..d7a74b3b2c 100644 --- a/test/propIs.js +++ b/test/propIs.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('propIs', function() { diff --git a/test/propOr.js b/test/propOr.js index 72bf8f367c..6cbca2ef0b 100644 --- a/test/propOr.js +++ b/test/propOr.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('propOr', function() { diff --git a/test/propSatisfies.js b/test/propSatisfies.js index 5512a87909..f407d2d7ac 100644 --- a/test/propSatisfies.js +++ b/test/propSatisfies.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('propSatisfies', function() { diff --git a/test/props.js b/test/props.js index 4e128c0e94..daf6a6127e 100644 --- a/test/props.js +++ b/test/props.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('props', function() { diff --git a/test/range.js b/test/range.js index 9acb12da50..88f0a5048d 100644 --- a/test/range.js +++ b/test/range.js @@ -1,7 +1,7 @@ var assert = require('assert'); -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('range', function() { diff --git a/test/reduce.js b/test/reduce.js index cdc5fc6e77..0ea0f62b14 100644 --- a/test/reduce.js +++ b/test/reduce.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('reduce', function() { var add = function(a, b) {return a + b;}; diff --git a/test/reduceBy.js b/test/reduceBy.js index f01cab4992..3c19b6b6f7 100644 --- a/test/reduceBy.js +++ b/test/reduceBy.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); var byType = R.prop('type'); var sumValues = function(acc, obj) {return acc + obj.val;}; diff --git a/test/reduceRight.js b/test/reduceRight.js index cc1fb895fb..28554bd2ef 100644 --- a/test/reduceRight.js +++ b/test/reduceRight.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('reduceRight', function() { diff --git a/test/reduceWhile.js b/test/reduceWhile.js index d10284ffc6..607b6cbf4d 100644 --- a/test/reduceWhile.js +++ b/test/reduceWhile.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); var isOdd = function(_, x) { return x % 2 !== 0; }; diff --git a/test/reduced.js b/test/reduced.js index 993eb095f8..d9aa76218a 100644 --- a/test/reduced.js +++ b/test/reduced.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('reduced', function() { diff --git a/test/reject.js b/test/reject.js index ca00e36ee2..fce00c76bd 100644 --- a/test/reject.js +++ b/test/reject.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('reject', function() { diff --git a/test/remove.js b/test/remove.js index a77516e930..96bda4f6c3 100644 --- a/test/remove.js +++ b/test/remove.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('remove', function() { diff --git a/test/repeat.js b/test/repeat.js index 44381c9b43..8a25b40a1e 100644 --- a/test/repeat.js +++ b/test/repeat.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('repeat', function() { diff --git a/test/replace.js b/test/replace.js index e7af76bb6e..d313ed2d3f 100644 --- a/test/replace.js +++ b/test/replace.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('replace', function() { diff --git a/test/reverse.js b/test/reverse.js index c11c441222..543d2ffbd8 100644 --- a/test/reverse.js +++ b/test/reverse.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); var fc = require('fast-check'); diff --git a/test/scan.js b/test/scan.js index 3d8e699485..28d54a72a1 100644 --- a/test/scan.js +++ b/test/scan.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('scan', function() { diff --git a/test/sequence.js b/test/sequence.js index db6d97d7d2..7d21bf1f7e 100644 --- a/test/sequence.js +++ b/test/sequence.js @@ -1,8 +1,8 @@ var S = require('sanctuary'); -var R = require('../source'); -var Id = require('./shared/Id'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var Id = require('./shared/Id.js'); +var eq = require('./shared/eq.js'); describe('sequence', function() { diff --git a/test/shared/Id.js b/test/shared/Id.js index b768c17541..33f4be8d92 100644 --- a/test/shared/Id.js +++ b/test/shared/Id.js @@ -1,4 +1,4 @@ -var R = require('../../source'); +var R = require('../../source/index.js'); // Id :: a -> Id a diff --git a/test/shared/Maybe.js b/test/shared/Maybe.js index 7fc89fe3b7..379187e204 100644 --- a/test/shared/Maybe.js +++ b/test/shared/Maybe.js @@ -1,4 +1,4 @@ -var R = require('../../source'); +var R = require('../../source/index.js'); var sentinel = {}; diff --git a/test/shared/Pair.js b/test/shared/Pair.js index 66f7184ee2..0bc9883631 100644 --- a/test/shared/Pair.js +++ b/test/shared/Pair.js @@ -1,4 +1,4 @@ -var R = require('../../source'); +var R = require('../../source/index.js'); function Pair(left, right) { diff --git a/test/shared/eq.js b/test/shared/eq.js index 362cf37a30..1498a127ce 100644 --- a/test/shared/eq.js +++ b/test/shared/eq.js @@ -1,6 +1,6 @@ var assert = require('assert'); -var R = require('../../source'); +var R = require('../../source/index.js'); module.exports = function(actual, expected) { diff --git a/test/slice.js b/test/slice.js index 2bc5c2171d..2feea12ab3 100644 --- a/test/slice.js +++ b/test/slice.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('slice', function() { diff --git a/test/sort.js b/test/sort.js index e6a5c61a00..7bef2b1817 100644 --- a/test/sort.js +++ b/test/sort.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('sort', function() { diff --git a/test/sortBy.js b/test/sortBy.js index 7dd5c26029..6c1c6c01b3 100644 --- a/test/sortBy.js +++ b/test/sortBy.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); var albums = [ diff --git a/test/sortWith.js b/test/sortWith.js index 01ee005ebb..868d5810c2 100644 --- a/test/sortWith.js +++ b/test/sortWith.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); var albums = [ diff --git a/test/split.js b/test/split.js index 57b9ba1daa..8ad2c199b9 100644 --- a/test/split.js +++ b/test/split.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('split', function() { diff --git a/test/splitAt.js b/test/splitAt.js index 56ea281f3e..02c1fe4617 100644 --- a/test/splitAt.js +++ b/test/splitAt.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('splitAt', function() { diff --git a/test/splitEvery.js b/test/splitEvery.js index 28ab5fbeed..a846578d9f 100644 --- a/test/splitEvery.js +++ b/test/splitEvery.js @@ -1,7 +1,7 @@ var assert = require('assert'); -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('splitEvery', function() { diff --git a/test/splitWhen.js b/test/splitWhen.js index e76ee8ba67..3e192f680b 100644 --- a/test/splitWhen.js +++ b/test/splitWhen.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('splitWhen', function() { diff --git a/test/splitWhenever.js b/test/splitWhenever.js index 0d53f623c8..e8837969ac 100644 --- a/test/splitWhenever.js +++ b/test/splitWhenever.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('splitWhenever', function() { diff --git a/test/startsWith.js b/test/startsWith.js index 65e5d5cc88..b4b76b366c 100644 --- a/test/startsWith.js +++ b/test/startsWith.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('startsWith', function() { it('should return true when a string starts with the provided value', function() { diff --git a/test/subtract.js b/test/subtract.js index 951c2d1b58..0d7bce9ea9 100644 --- a/test/subtract.js +++ b/test/subtract.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('subtract', function() { diff --git a/test/sum.js b/test/sum.js index 2411bf9c8c..581bd77ca1 100644 --- a/test/sum.js +++ b/test/sum.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('sum', function() { diff --git a/test/symmetricDifference.js b/test/symmetricDifference.js index eb6e38a62f..1a4f11bfba 100644 --- a/test/symmetricDifference.js +++ b/test/symmetricDifference.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); var fc = require('fast-check'); diff --git a/test/symmetricDifferenceWith.js b/test/symmetricDifferenceWith.js index 708fc493f6..942540e968 100644 --- a/test/symmetricDifferenceWith.js +++ b/test/symmetricDifferenceWith.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('symmetricDifferenceWith', function() { diff --git a/test/tail.js b/test/tail.js index 4350950e85..a6dc47776f 100644 --- a/test/tail.js +++ b/test/tail.js @@ -1,7 +1,7 @@ var assert = require('assert'); -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('tail', function() { diff --git a/test/take.js b/test/take.js index a49228de5e..12f846adf8 100644 --- a/test/take.js +++ b/test/take.js @@ -1,8 +1,8 @@ var assert = require('assert'); var sinon = require('sinon'); -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('take', function() { diff --git a/test/takeLast.js b/test/takeLast.js index 0cccb5ddb6..277da697eb 100644 --- a/test/takeLast.js +++ b/test/takeLast.js @@ -1,7 +1,7 @@ var assert = require('assert'); -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('takeLast', function() { diff --git a/test/takeLastWhile.js b/test/takeLastWhile.js index f2d77d273a..04a84347b2 100644 --- a/test/takeLastWhile.js +++ b/test/takeLastWhile.js @@ -1,7 +1,7 @@ var assert = require('assert'); -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('takeLastWhile', function() { diff --git a/test/takeWhile.js b/test/takeWhile.js index a05d1de42d..6e601894aa 100644 --- a/test/takeWhile.js +++ b/test/takeWhile.js @@ -1,7 +1,7 @@ var assert = require('assert'); -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('takeWhile', function() { diff --git a/test/tap.js b/test/tap.js index 0611a8feb5..65dcd156d2 100644 --- a/test/tap.js +++ b/test/tap.js @@ -1,7 +1,7 @@ -var R = require('../source'); -var eq = require('./shared/eq'); -var listXf = require('./helpers/listXf'); -var _curry2 = require('../source/internal/_curry2'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); +var listXf = require('./helpers/listXf.js'); +var _curry2 = require('../source/internal/_curry2.js'); describe('tap', function() { diff --git a/test/test.js b/test/test.js index af1c0412dc..28aaa1f0f3 100644 --- a/test/test.js +++ b/test/test.js @@ -1,7 +1,7 @@ var assert = require('assert'); -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('test', function() { diff --git a/test/thunkify.js b/test/thunkify.js index a0d5f546b8..7426e36251 100644 --- a/test/thunkify.js +++ b/test/thunkify.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('thunkify', function() { it('returns a function with the same arity as the given function', function() { diff --git a/test/times.js b/test/times.js index 2f621a036b..087b81019a 100644 --- a/test/times.js +++ b/test/times.js @@ -1,7 +1,7 @@ var assert = require('assert'); -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('times', function() { diff --git a/test/toLower.js b/test/toLower.js index af42c95eed..851b1a2144 100644 --- a/test/toLower.js +++ b/test/toLower.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('toLower', function() { diff --git a/test/toPairs.js b/test/toPairs.js index f9e847062f..5e821de595 100644 --- a/test/toPairs.js +++ b/test/toPairs.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('toPairs', function() { diff --git a/test/toPairsIn.js b/test/toPairsIn.js index 4ac5a6bdbb..472d51e721 100644 --- a/test/toPairsIn.js +++ b/test/toPairsIn.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('toPairsIn', function() { diff --git a/test/toString.js b/test/toString.js index ae6807de63..70116da1fb 100644 --- a/test/toString.js +++ b/test/toString.js @@ -1,6 +1,6 @@ var assert = require('assert'); -var R = require('../source'); +var R = require('../source/index.js'); describe('toString', function() { diff --git a/test/toUpper.js b/test/toUpper.js index b4f2f04e7d..6bf18b1a21 100644 --- a/test/toUpper.js +++ b/test/toUpper.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('toUpper', function() { diff --git a/test/transduce.js b/test/transduce.js index 9f7df41769..f0af24e128 100644 --- a/test/transduce.js +++ b/test/transduce.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('transduce', function() { var add = R.add; diff --git a/test/transpose.js b/test/transpose.js index 18b98db2dd..66288a1035 100644 --- a/test/transpose.js +++ b/test/transpose.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('transpose', function() { it('returns an array of two arrays', function() { diff --git a/test/traverse.js b/test/traverse.js index 7870b14a91..42424a1f9b 100644 --- a/test/traverse.js +++ b/test/traverse.js @@ -1,8 +1,8 @@ var S = require('sanctuary'); -var R = require('../source'); -var Id = require('./shared/Id'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var Id = require('./shared/Id.js'); +var eq = require('./shared/eq.js'); describe('traverse', function() { diff --git a/test/trim.js b/test/trim.js index 9eb4dd0978..df7448fb73 100644 --- a/test/trim.js +++ b/test/trim.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('trim', function() { diff --git a/test/tryCatch.js b/test/tryCatch.js index 8d243f3033..d92f4c66ff 100644 --- a/test/tryCatch.js +++ b/test/tryCatch.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('tryCatch', function() { diff --git a/test/type.js b/test/type.js index 777041bcb2..c4046d7ac7 100644 --- a/test/type.js +++ b/test/type.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('type', function() { diff --git a/test/unapply.js b/test/unapply.js index da3a980eb2..e29e233aa7 100644 --- a/test/unapply.js +++ b/test/unapply.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('unapply', function() { diff --git a/test/unary.js b/test/unary.js index 17f496e40b..fbe79b51b7 100644 --- a/test/unary.js +++ b/test/unary.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('unary', function() { diff --git a/test/uncurryN.js b/test/uncurryN.js index 4705be496e..1ac19cd39d 100644 --- a/test/uncurryN.js +++ b/test/uncurryN.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('uncurryN', function() { diff --git a/test/unfold.js b/test/unfold.js index 6e85bc6ede..aa1bea8f58 100644 --- a/test/unfold.js +++ b/test/unfold.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('unfold', function() { diff --git a/test/union.js b/test/union.js index 754ea00206..8415f6f20a 100644 --- a/test/union.js +++ b/test/union.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('union', function() { diff --git a/test/unionWith.js b/test/unionWith.js index e97800765c..1f91ae095f 100644 --- a/test/unionWith.js +++ b/test/unionWith.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('unionWith', function() { diff --git a/test/uniq.js b/test/uniq.js index fdf1d8e25e..d421a52819 100644 --- a/test/uniq.js +++ b/test/uniq.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('uniq', function() { diff --git a/test/uniqBy.js b/test/uniqBy.js index cea40a848d..3362dc776c 100644 --- a/test/uniqBy.js +++ b/test/uniqBy.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('uniqBy', function() { diff --git a/test/uniqWith.js b/test/uniqWith.js index 20154feec0..105d0d80d1 100644 --- a/test/uniqWith.js +++ b/test/uniqWith.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('uniqWith', function() { diff --git a/test/unless.js b/test/unless.js index ade18dd78a..be0c028e12 100644 --- a/test/unless.js +++ b/test/unless.js @@ -1,6 +1,6 @@ -var R = require('../source'); -var eq = require('./shared/eq'); -var _isArrayLike = require('../source/internal/_isArrayLike'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); +var _isArrayLike = require('../source/internal/_isArrayLike.js'); describe('unless', function() { diff --git a/test/unnest.js b/test/unnest.js index ad24251c40..936f75a80c 100644 --- a/test/unnest.js +++ b/test/unnest.js @@ -1,8 +1,8 @@ var assert = require('assert'); -var R = require('../source'); -var eq = require('./shared/eq'); -var Maybe = require('./shared/Maybe'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); +var Maybe = require('./shared/Maybe.js'); describe('unnest', function() { diff --git a/test/until.js b/test/until.js index 8d03d7f1e6..492c04199a 100644 --- a/test/until.js +++ b/test/until.js @@ -1,6 +1,6 @@ -var R = require('../source'); -var eq = require('./shared/eq'); -var _isArrayLike = require('../source/internal/_isArrayLike'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); +var _isArrayLike = require('../source/internal/_isArrayLike.js'); describe('until', function() { diff --git a/test/unwind.js b/test/unwind.js index c67c9153de..407eb1e373 100644 --- a/test/unwind.js +++ b/test/unwind.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('unwind', function() { diff --git a/test/update.js b/test/update.js index 831cd8f408..e521816ac3 100644 --- a/test/update.js +++ b/test/update.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('update', function() { it('updates the value at the given index of the supplied array', function() { diff --git a/test/useWith.js b/test/useWith.js index 551aa5c37d..07362c1180 100644 --- a/test/useWith.js +++ b/test/useWith.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('useWith', function() { diff --git a/test/values.js b/test/values.js index b7f00556a9..c4cf9376a5 100644 --- a/test/values.js +++ b/test/values.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('values', function() { diff --git a/test/valuesIn.js b/test/valuesIn.js index 41c58e2159..012c3590d6 100644 --- a/test/valuesIn.js +++ b/test/valuesIn.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('valuesIn', function() { diff --git a/test/when.js b/test/when.js index dbd7e810d9..51f02a0b31 100644 --- a/test/when.js +++ b/test/when.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('when', function() { diff --git a/test/where.js b/test/where.js index 5d98da0738..2fd9af7d2d 100644 --- a/test/where.js +++ b/test/where.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('where', function() { diff --git a/test/whereAny.js b/test/whereAny.js index 8d7602f566..8f56bb397f 100644 --- a/test/whereAny.js +++ b/test/whereAny.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('whereAny', function() { diff --git a/test/whereEq.js b/test/whereEq.js index 88a9a89577..9f000a3bb2 100644 --- a/test/whereEq.js +++ b/test/whereEq.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('whereEq', function() { diff --git a/test/without.js b/test/without.js index 3c98f4289f..ebc766f550 100644 --- a/test/without.js +++ b/test/without.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('without', function() { diff --git a/test/xor.js b/test/xor.js index 99816b834e..a548d49255 100644 --- a/test/xor.js +++ b/test/xor.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('xor', function() { it('compares two values with exclusive or', function() { diff --git a/test/xprod.js b/test/xprod.js index 5a62991905..9ae1b590fd 100644 --- a/test/xprod.js +++ b/test/xprod.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('xprod', function() { diff --git a/test/zip.js b/test/zip.js index 163771b304..8d9b63ce40 100644 --- a/test/zip.js +++ b/test/zip.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('zip', function() { diff --git a/test/zipObj.js b/test/zipObj.js index adca35787b..a1efb48c34 100644 --- a/test/zipObj.js +++ b/test/zipObj.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('zipObj', function() { diff --git a/test/zipWith.js b/test/zipWith.js index 0ea242b8a0..7a98bf749d 100644 --- a/test/zipWith.js +++ b/test/zipWith.js @@ -1,5 +1,5 @@ -var R = require('../source'); -var eq = require('./shared/eq'); +var R = require('../source/index.js'); +var eq = require('./shared/eq.js'); describe('zipWith', function() { From 1bd60c53d18c04e93f51d6cff0070d8320a8a790 Mon Sep 17 00:00:00 2001 From: HoKangInfo Date: Sun, 23 Jan 2022 01:27:10 +0800 Subject: [PATCH 098/111] fix, add use first flags property, and support dotAll flag (#3158) * fix, add use first flags property, and support dotAll flag * add dotAll flag test case * move eslint-env comment to top * remove eslint-env comment --- source/internal/_cloneRegExp.js | 11 ++++++----- test/test.js | 3 +++ 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/source/internal/_cloneRegExp.js b/source/internal/_cloneRegExp.js index 581890d8bc..8c6365ea6e 100644 --- a/source/internal/_cloneRegExp.js +++ b/source/internal/_cloneRegExp.js @@ -1,7 +1,8 @@ export default function _cloneRegExp(pattern) { - return new RegExp(pattern.source, (pattern.global ? 'g' : '') + - (pattern.ignoreCase ? 'i' : '') + - (pattern.multiline ? 'm' : '') + - (pattern.sticky ? 'y' : '') + - (pattern.unicode ? 'u' : '')); + return new RegExp(pattern.source, (pattern.flags ? pattern.flags : (pattern.global ? 'g' : '') + + (pattern.ignoreCase ? 'i' : '') + + (pattern.multiline ? 'm' : '') + + (pattern.sticky ? 'y' : '') + + (pattern.unicode ? 'u' : '') + + (pattern.dotAll ? 's' : ''))); } diff --git a/test/test.js b/test/test.js index 28aaa1f0f3..862cd6dec3 100644 --- a/test/test.js +++ b/test/test.js @@ -5,6 +5,9 @@ var eq = require('./shared/eq.js'); describe('test', function() { + it('returns true if string matches dotAll pattern', function() { + eq(R.test(/x.*z/s, 'x.\nyz'), true); + }); it('returns true if string matches pattern', function() { eq(R.test(/^x/, 'xyz'), true); From 3e100e9b899874bbe7d98ee43a8e89e6380cd986 Mon Sep 17 00:00:00 2001 From: Jonathan Berube Date: Sat, 22 Jan 2022 09:37:58 -0800 Subject: [PATCH 099/111] feat: add swap function (#3094) --- source/index.js | 1 + source/swap.js | 77 +++++++++++++++++++++++++++++++++++++++++++++++++ test/swap.js | 51 ++++++++++++++++++++++++++++++++ 3 files changed, 129 insertions(+) create mode 100644 source/swap.js create mode 100644 test/swap.js diff --git a/source/index.js b/source/index.js index 9c605b0b4e..a91ddfb014 100644 --- a/source/index.js +++ b/source/index.js @@ -208,6 +208,7 @@ export { default as splitWhenever } from './splitWhenever.js'; export { default as startsWith } from './startsWith.js'; export { default as subtract } from './subtract.js'; export { default as sum } from './sum.js'; +export { default as swap } from './swap.js'; export { default as symmetricDifference } from './symmetricDifference.js'; export { default as symmetricDifferenceWith } from './symmetricDifferenceWith.js'; export { default as tail } from './tail.js'; diff --git a/source/swap.js b/source/swap.js new file mode 100644 index 0000000000..1d3c13fda4 --- /dev/null +++ b/source/swap.js @@ -0,0 +1,77 @@ +import _curry3 from './internal/_curry3.js'; +import _isArray from './internal/_isArray.js'; +import _isString from './internal/_isString.js'; +import clone from './clone.js'; + +var swapObject = function(indexA, indexB, o) { + var copy = clone(o); + + var properties = Object.getOwnPropertyNames(copy); + if (properties.includes(indexA) && properties.includes(indexB)) { + var tmp = copy[indexA]; + + copy[indexA] = copy[indexB]; + copy[indexB] = tmp; + } + + return copy; +}; + +var swapList = function(indexA, indexB, list) { + var length = list.length; + var result = list.slice(); + var positiveIndexA = indexA < 0 ? length + indexA : indexA; + var positiveIndexB = indexB < 0 ? length + indexB : indexB; + var positiveMin = Math.min(positiveIndexA, positiveIndexB); + var positiveMax = Math.max(positiveIndexA, positiveIndexB); + + return positiveIndexA < 0 || positiveIndexA >= list.length + || positiveIndexB < 0 || positiveIndexB >= list.length + || positiveIndexA == positiveIndexB + ? result + : [] + .concat(result.slice(0, positiveMin)) + .concat(result[positiveMax]) + .concat(result.slice(positiveMin + 1, positiveMax)) + .concat(result[positiveMin]) + .concat(result.slice(positiveMax + 1, list.length)); +}; + +var swapString = function(indexA, indexB, s) { + var result = swapList(indexA, indexB, s); + return _isArray(result) + ? result.join('') + : result; +}; + +/** + * Swap an item, at index `indexA` with another item, at index `indexB`, in an object or a list of elements. + * A new result will be created containing the new elements order. + * + * @func + * @memberOf R + * @category List + * @sig Number -> Number -> [a] -> [a] + * @param {Number|string|Object} indexA The first index + * @param {Number|string|Object} indexB The second index + * @param {Array|Object} o Either the object or list which will serve to realise the swap + * @return {Array|Object} The new object or list reordered + * @example + * + * R.swap(0, 2, ['a', 'b', 'c', 'd', 'e', 'f']); //=> ['c', 'b', 'a', 'd', 'e', 'f'] + * R.swap(-1, 0, ['a', 'b', 'c', 'd', 'e', 'f']); //=> ['f', 'b', 'c', 'd', 'e', 'a'] list rotation + * R.swap('a', 'b', {a: 1, b: 2}); //=> {a: 2, b: 2} + * R.swap(0, 2, 'foo'); //=> 'oof' + * R.swap(obj1, obj2, new Map ([[obj1, 1] [obj2, 2]]); //=> new Map ([[obj1, 2], [obj2, 1]]) + */ +var swap = _curry3(function(indexA, indexB, o) { + if (_isArray(o)) { + return swapList(indexA, indexB, o); + } else if (_isString(o)) { + return swapString(indexA, indexB, o); + } else { + return swapObject(indexA, indexB, o); + } +}); + +export default swap; diff --git a/test/swap.js b/test/swap.js new file mode 100644 index 0000000000..def84cdc0a --- /dev/null +++ b/test/swap.js @@ -0,0 +1,51 @@ +var R = require('../source'); +var eq = require('./shared/eq'); + +var list = ['a', 'b', 'c', 'd', 'e', 'f']; +var o = {a: 1, b: 2}; +var o2 = {}; +var map = new Map([[o, 1], [o2, 2]]); + +describe('swap', function() { + it('swaps an element from one index to the other', function() { + eq(R.swap(0, 1, list), ['b', 'a', 'c', 'd', 'e', 'f']); + eq(R.swap(2, 1, list), ['a', 'c', 'b', 'd', 'e', 'f']); + eq(R.swap(-1, 0, list), ['f', 'b', 'c', 'd', 'e', 'a']); + eq(R.swap(4, 1, list), ['a', 'e', 'c', 'd', 'b', 'f']); + }); + + it('does nothing when indexes are outside the list boundaries', function() { + eq(R.swap(-20, 2, list), list); + eq(R.swap(20, 2, list), list); + eq(R.swap(2, 20, list), list); + eq(R.swap(2, -20, list), list); + eq(R.swap(20, 20, list), list); + eq(R.swap(-20, -20, list), list); + }); + + it('does nothing when indexes are equal', function() { + eq(R.swap(0, 0, list), list); + }); + + it('should be the same when swapping index order', function() { + eq(R.swap(0, 1, list), R.swap(1, 0, list)); + }); + + it('swaps property values from one property to another', function() { + eq(R.swap('a', 'b', o), {a: 2, b: 1}); + eq(R.swap('b', 'a', o), {a: 2, b: 1}); + }); + + it('does nothing when property names are not defined', function() { + eq(R.swap('a', 'b', {a: 1}), {a: 1}); + eq(R.swap('a', 'b', {b: 2}), {b: 2}); + }); + + it('swaps characters in string from one index to another', function() { + eq(R.swap(0, 2, 'foo'), 'oof'); + }); + + it('swaps object indexes in map from one index to another', function() { + eq(R.swap(o, o2, map), new Map([[o, 2], [o2, 1]])); + }); +}); From 713400da67664a1cf3eb14029a325ea6bdb86cb0 Mon Sep 17 00:00:00 2001 From: wangzengdi Date: Sun, 23 Jan 2022 01:44:08 +0800 Subject: [PATCH 100/111] fix: update readme.md ramda version before publish (#3082) * fix: update readme.md ramda version before publish * chore: update LICENSE.txt copyright date if needed. --- README.md | 5 ++--- scripts/beforePublish.js | 25 +++++++++++++++++++++++++ scripts/prepublish | 7 +------ 3 files changed, 28 insertions(+), 9 deletions(-) create mode 100644 scripts/beforePublish.js diff --git a/README.md b/README.md index 543e229bec..1987313e65 100644 --- a/README.md +++ b/README.md @@ -118,14 +118,13 @@ or the minified version: or from a CDN, either cdnjs: ```html - + ``` or one of the below links from [jsDelivr](http://jsdelivr.com): ```html - - + ``` diff --git a/scripts/beforePublish.js b/scripts/beforePublish.js new file mode 100644 index 0000000000..b22f43b666 --- /dev/null +++ b/scripts/beforePublish.js @@ -0,0 +1,25 @@ +var fs = require('fs'); +var path = require('path'); +var pkg = require('../package.json'); + +var readme_path = path.resolve('./README.md'); + +var readme_content = fs.readFileSync(readme_path, 'utf8'); +var new_readme_content = readme_content.replace( + /((?:libs|npm)\/ramda[\/@])(\d+\.\d+(?:\.\d+)?)/g, + function (v, p1, p2) { + return p1 + pkg.version; + } +); +fs.writeFileSync(readme_path, new_readme_content, { encoding: 'utf8' }); + +var license_path = path.resolve('./LICENSE.txt'); + +var license_content = fs.readFileSync(license_path, 'utf8'); +var new_license_content = license_content.replace( + /(Copyright\ \(c\)\ 2013-)(\d{4})/g, + function (v, p1, p2) { + return p1 + new Date().getFullYear(); + } +); +fs.writeFileSync(license_path, new_license_content, { encoding: 'utf8' }); diff --git a/scripts/prepublish b/scripts/prepublish index b10b48c73b..3de57d7107 100755 --- a/scripts/prepublish +++ b/scripts/prepublish @@ -1,12 +1,7 @@ #!/usr/bin/env bash set -e -slash=/ -README="$(cat README.md)" -README="${README//${PREVIOUS_VERSION}${slash}ramda.min.js/${VERSION}${slash}ramda.min.js}" -README="${README//${PREVIOUS_VERSION}${slash}dist${slash}ramda.min.js/${VERSION}${slash}dist${slash}ramda.min.js}" -README="${README//${PREVIOUS_VERSION%.*}${slash}dist${slash}ramda.min.js/${VERSION%.*}${slash}dist${slash}ramda.min.js}" -echo "$README" >README.md +node ./scripts/beforePublish.js git add README.md for filename in $(find source -maxdepth 1 -name "*.js" | xargs grep --files-without-match "@since v") ; do From 33de5cd0906c00dc62d78ea46f27bf232a79cfd5 Mon Sep 17 00:00:00 2001 From: wangzengdi Date: Sun, 23 Jan 2022 01:51:42 +0800 Subject: [PATCH 101/111] arguments.length will always be the same as n (#3018) --- source/constructN.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/constructN.js b/source/constructN.js index 39a44fb724..049de47ad2 100644 --- a/source/constructN.js +++ b/source/constructN.js @@ -46,7 +46,7 @@ var constructN = _curry2(function constructN(n, Fn) { return function() { return new Fn(); }; } return curry(nAry(n, function($0, $1, $2, $3, $4, $5, $6, $7, $8, $9) { - switch (arguments.length) { + switch (n) { case 1: return new Fn($0); case 2: return new Fn($0, $1); case 3: return new Fn($0, $1, $2); From f0de0fd008988fea5052cfe26b2f0be646bb0d4b Mon Sep 17 00:00:00 2001 From: Andrew Smith Date: Sat, 22 Jan 2022 09:53:56 -0800 Subject: [PATCH 102/111] Add docs to `path`. (#3010) * Add docs to `path`. * docs: update path doc, signatures and related functions. address Scott comments in #3010 Co-authored-by: customcommander --- source/path.js | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/source/path.js b/source/path.js index fc6ed47986..3cfc739462 100644 --- a/source/path.js +++ b/source/path.js @@ -2,7 +2,8 @@ import _curry2 from './internal/_curry2.js'; import paths from './paths.js'; /** - * Retrieve the value at a given path. + * Retrieves the value at a given path. The nodes of the path can be arbitrary strings or non-negative integers. + * For anything else, the value is unspecified. Integer paths are meant to index arrays, strings are meant for objects. * * @func * @memberOf R @@ -10,16 +11,19 @@ import paths from './paths.js'; * @category Object * @typedefn Idx = String | Int | Symbol * @sig [Idx] -> {a} -> a | Undefined + * @sig Idx = String | NonNegativeInt * @param {Array} path The path to use. - * @param {Object} obj The object to retrieve the nested property from. + * @param {Object} obj The object or array to retrieve the nested property from. * @return {*} The data at `path`. - * @see R.prop, R.nth + * @see R.prop, R.nth, R.assocPath, R.dissocPath * @example * * R.path(['a', 'b'], {a: {b: 2}}); //=> 2 * R.path(['a', 'b'], {c: {b: 2}}); //=> undefined * R.path(['a', 'b', 0], {a: {b: [1, 2, 3]}}); //=> 1 * R.path(['a', 'b', -2], {a: {b: [1, 2, 3]}}); //=> 2 + * R.path([2], {'2': 2}); //=> 2 + * R.path([-2], {'-2': 'a'}); //=> undefined */ var path = _curry2(function path(pathAr, obj) { From 6aadd7b7a7198001ba77b4af539d00e06fdcb06f Mon Sep 17 00:00:00 2001 From: Kuba Juszczyk Date: Sat, 22 Jan 2022 21:58:04 +0400 Subject: [PATCH 103/111] reduce - null safety (#2997) * hasIn: added protection against undefined object * null safety reduce --- source/internal/_reduce.js | 3 +++ test/reduce.js | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/source/internal/_reduce.js b/source/internal/_reduce.js index 6cc796e8f4..9ea792df40 100644 --- a/source/internal/_reduce.js +++ b/source/internal/_reduce.js @@ -43,6 +43,9 @@ export default function _reduce(fn, acc, list) { if (_isArrayLike(list)) { return _arrayReduce(fn, acc, list); } + if (list == null) { + return acc; + } if (typeof list['fantasy-land/reduce'] === 'function') { return _methodReduce(fn, acc, list, 'fantasy-land/reduce'); } diff --git a/test/reduce.js b/test/reduce.js index 0ea0f62b14..dfc88d0ba7 100644 --- a/test/reduce.js +++ b/test/reduce.js @@ -22,6 +22,13 @@ describe('reduce', function() { eq(R.reduce(R.concat, [], []), []); }); + it('returns the accumulator for an null/undefined list', function() { + eq(R.reduce(add, 0, null), 0); + eq(R.reduce(R.concat, [], null), []); + eq(R.reduce(add, 0, undefined), 0); + eq(R.reduce(R.concat, [], undefined), []); + }); + it('Prefers the use of the iterator of an object over reduce (and handles short-circuits)', function() { var symIterator = (typeof Symbol !== 'undefined') ? Symbol.iterator : '@@iterator'; From d197043e75ec08a344e647ea555eee56fb6e64ea Mon Sep 17 00:00:00 2001 From: wangzengdi Date: Sun, 23 Jan 2022 02:00:39 +0800 Subject: [PATCH 104/111] make tap's symb description more clearly (#2955) --- source/tap.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/tap.js b/source/tap.js index 630038a28d..32e19cd391 100644 --- a/source/tap.js +++ b/source/tap.js @@ -21,7 +21,7 @@ import _xtap from './internal/_xtap.js'; * const sayX = x => console.log('x is ' + x); * R.tap(sayX, 100); //=> 100 * // logs 'x is 100' - * @symb R.tap(f, a) = a + * @symb R.tap(f, a) = (f(a), a) */ var tap = _curry2(_dispatchable([], _xtap, function tap(fn, x) { fn(x); From 9bffeb7c6e06d9617578e99d0d4abb4b1ac2bd90 Mon Sep 17 00:00:00 2001 From: Jeff Downie Date: Sat, 22 Jan 2022 19:37:51 +0000 Subject: [PATCH 105/111] Updating ap's description (#2004) --- source/ap.js | 2 +- test/ap.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/source/ap.js b/source/ap.js index 19c7920e78..ced2b9296c 100644 --- a/source/ap.js +++ b/source/ap.js @@ -7,7 +7,7 @@ import map from './map.js'; /** * ap applies a list of functions to a list of values. * - * Dispatches to the `ap` method of the second argument, if present. Also + * Dispatches to the `ap` method of the first argument, if present. Also * treats curried functions as applicatives. * * @func diff --git a/test/ap.js b/test/ap.js index d12d3832e7..ba532033b0 100644 --- a/test/ap.js +++ b/test/ap.js @@ -25,7 +25,7 @@ describe('ap', function() { eq(R.ap(R.add)(g)(10), 10 + (10 * 2)); }); - it('dispatches to the passed object\'s ap method when values is a non-Array object', function() { + it('dispatches to the first passed object\'s ap method when values is a non-Array object', function() { var obj = {ap: function(n) { return 'called ap with ' + n; }}; eq(R.ap(obj, 10), obj.ap(10)); }); From 049893d27c16b1632e8a3af76b813ebf1a2a407f Mon Sep 17 00:00:00 2001 From: Kurtis Rainbolt-Greene Date: Sat, 22 Jan 2022 12:05:05 -0800 Subject: [PATCH 106/111] Make the invoker documentation a little more understandable to newbies like myself (#2116) * Make the invoker documentation a little more understandable to newbies like myself * Clarifications from @buzzdecafe * Making more copy changes * docs: address buzzdecafe comment. 'invoker()' -> 'invoker' * docs: use const instead of var in example for invoker Co-authored-by: Kurtis Rainbolt-Greene Co-authored-by: customcommander --- source/invoker.js | 32 ++++++++++++++++++++------------ 1 file changed, 20 insertions(+), 12 deletions(-) diff --git a/source/invoker.js b/source/invoker.js index da250771c0..28e2072432 100644 --- a/source/invoker.js +++ b/source/invoker.js @@ -5,11 +5,10 @@ import toString from './toString.js'; /** - * Turns a named method with a specified arity into a function that can be - * called directly supplied with arguments and a target object. - * - * The returned function is curried and accepts `arity + 1` parameters where - * the final parameter is the target object. + * Given an `arity` (Number) and a `name` (String) the `invoker` function + * returns a curried function that takes `arity` arguments and a `context` + * object. It will "invoke" the `name`'d function (a method) on the `context` + * object. * * @func * @memberOf R @@ -22,17 +21,26 @@ import toString from './toString.js'; * @return {Function} A new curried function. * @see R.construct * @example + * // A function with no arguments + * const asJson = invoker(0, "json") + * // Just like calling .then((response) => response.json()) + * fetch("http://example.com/index.json").then(asJson) * - * const sliceFrom = R.invoker(1, 'slice'); + * // A function with one argument + * const sliceFrom = invoker(1, 'slice'); * sliceFrom(6, 'abcdefghijklm'); //=> 'ghijklm' - * const sliceFrom6 = R.invoker(2, 'slice')(6); + * + * // A function with two arguments + * const sliceFrom6 = invoker(2, 'slice')(6); * sliceFrom6(8, 'abcdefghijklm'); //=> 'gh' * - * const dog = { - * speak: async () => 'Woof!' - * }; - * const speak = R.invoker(0, 'speak'); - * speak(dog).then(console.log) //~> 'Woof!' + * // NOTE: You can't simply pass some of the arguments to the initial invoker function. + * const firstCreditCardSection = invoker(2, "slice", 0, 4) + * firstCreditCardSection("4242 4242 4242 4242") // => Function<...> + * + * // Since invoker returns a curried function, you may partially apply it to create the function you need. + * const firstCreditCardSection = invoker(2, "slice")(0, 4) + * firstCreditCardSection("4242 4242 4242 4242") // => "4242" * * @symb R.invoker(0, 'method')(o) = o['method']() * @symb R.invoker(1, 'method')(a, o) = o['method'](a) From ab928b3a9a3229b76bde2cd2f20f413cd50c3f78 Mon Sep 17 00:00:00 2001 From: James Conkling Date: Sat, 22 Jan 2022 14:28:16 -0800 Subject: [PATCH 107/111] make assocPath overwrite primitive values with keys in path (#2524) --- source/assocPath.js | 2 +- test/assocPath.js | 6 ++++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/source/assocPath.js b/source/assocPath.js index f9144dea77..b32eb9035f 100644 --- a/source/assocPath.js +++ b/source/assocPath.js @@ -34,7 +34,7 @@ var assocPath = _curry3(function assocPath(path, val, obj) { } var idx = path[0]; if (path.length > 1) { - var nextObj = (!isNil(obj) && _has(idx, obj)) ? obj[idx] : _isInteger(path[1]) ? [] : {}; + var nextObj = (!isNil(obj) && _has(idx, obj) && typeof obj[idx] === 'object') ? obj[idx] : _isInteger(path[1]) ? [] : {}; val = assocPath(Array.prototype.slice.call(path, 1), val, nextObj); } return _assoc(idx, val, obj); diff --git a/test/assocPath.js b/test/assocPath.js index 25ee21f625..ff03625b6f 100644 --- a/test/assocPath.js +++ b/test/assocPath.js @@ -27,6 +27,12 @@ describe('assocPath', function() { assert.strictEqual(obj2.f, obj1.f); }); + it('overwrites primitive values with keys in the path', function() { + var obj1 = {a: 'str'}; + var obj2 = R.assocPath(['a', 'b'], 42, obj1); + eq(obj2, {a: {b: 42}}); + }); + it('empty path replaces the the whole object', function() { eq(R.assocPath([], 3, {a: 1, b: 2}), 3); }); From 4bb8dd81cb5d8ba522836426543f72e35cdc2b90 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lars=20K=C3=B6lpin?= Date: Sat, 22 Jan 2022 23:50:14 +0100 Subject: [PATCH 108/111] Add isNotNil (#2818) * Add isNotNil In javascript projects it is often necessary to to someething if something is not nil. This commits adds a function "isNotNil" and its corresponding test which does the null and undefined checking. * chore: isNotNil: add missing extensions in import statements Co-authored-by: customcommander --- source/index.js | 1 + source/isNotNil.js | 22 ++++++++++++++++++++++ test/isNotNil.js | 15 +++++++++++++++ 3 files changed, 38 insertions(+) create mode 100644 source/isNotNil.js create mode 100644 test/isNotNil.js diff --git a/source/index.js b/source/index.js index a91ddfb014..77209a79dc 100644 --- a/source/index.js +++ b/source/index.js @@ -99,6 +99,7 @@ export { default as invoker } from './invoker.js'; export { default as is } from './is.js'; export { default as isEmpty } from './isEmpty.js'; export { default as isNil } from './isNil.js'; +export { default as isNotNil } from './isNotNil.js'; export { default as join } from './join.js'; export { default as juxt } from './juxt.js'; export { default as keys } from './keys.js'; diff --git a/source/isNotNil.js b/source/isNotNil.js new file mode 100644 index 0000000000..8dbb623e1b --- /dev/null +++ b/source/isNotNil.js @@ -0,0 +1,22 @@ +import isNil from './isNil.js'; +import _curry1 from './internal/_curry1.js'; + + +/** + * Checks if the input value is not `null` and not `undefined`. + * + * @func + * @memberOf R + * @category Type + * @sig * -> Boolean + * @param {*} x The value to test. + * @return {Boolean} `true` if `x` is not `undefined` or not `null`, otherwise `false`. + * @example + * + * R.isNotNil(null); //=> false + * R.isNotNil(undefined); //=> false + * R.isNotNil(0); //=> true + * R.isNotNil([]); //=> true + */ +var isNotNil = _curry1(function isNotNil(x) { return !isNil(x); }); +export default isNotNil; diff --git a/test/isNotNil.js b/test/isNotNil.js new file mode 100644 index 0000000000..1775ceeb87 --- /dev/null +++ b/test/isNotNil.js @@ -0,0 +1,15 @@ +var R = require('../source'); +var eq = require('./shared/eq'); + +describe('isNotNil', function() { + it('tests a value for `null` or `undefined`', function() { + eq(R.isNotNil(void 0), false); + eq(R.isNotNil(undefined), false); + eq(R.isNotNil(null), false); + eq(R.isNotNil([]), true); + eq(R.isNotNil({}), true); + eq(R.isNotNil(0), true); + eq(R.isNotNil(''), true); + }); + +}); From e575baa5e3cb47a42648258298d976d526e61b1b Mon Sep 17 00:00:00 2001 From: Wojciech Pawlik Date: Sat, 22 Jan 2022 23:53:47 +0100 Subject: [PATCH 109/111] Add Map and Set support to toString (#2624) --- source/internal/_toString.js | 4 ++++ test/toString.js | 14 ++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/source/internal/_toString.js b/source/internal/_toString.js index ee9b6aa78e..da9e1835d1 100644 --- a/source/internal/_toString.js +++ b/source/internal/_toString.js @@ -26,10 +26,14 @@ export default function _toString(x, seen) { return typeof x === 'object' ? 'new Boolean(' + recur(x.valueOf()) + ')' : x.toString(); case '[object Date]': return 'new Date(' + (isNaN(x.valueOf()) ? recur(NaN) : _quote(_toISOString(x))) + ')'; + case '[object Map]': + return 'new Map(' + recur(Array.from(x)) + ')'; case '[object Null]': return 'null'; case '[object Number]': return typeof x === 'object' ? 'new Number(' + recur(x.valueOf()) + ')' : 1 / x === -Infinity ? '-0' : x.toString(10); + case '[object Set]': + return 'new Set(' + recur(Array.from(x).sort()) + ')'; case '[object String]': return typeof x === 'object' ? 'new String(' + recur(x.valueOf()) + ')' : _quote(x); case '[object Undefined]': diff --git a/test/toString.js b/test/toString.js index 70116da1fb..eaa723744a 100644 --- a/test/toString.js +++ b/test/toString.js @@ -52,11 +52,25 @@ describe('toString', function() { assert.strictEqual(R.toString(new Boolean(false)), 'new Boolean(false)'); }); + it('returns the string representation of a Map object', function() { + if (typeof Map !== 'function') { + return; + } + assert.strictEqual(R.toString(new Map([[1, 2], [3, 4]])), 'new Map([[1, 2], [3, 4]])'); + }); + it('returns the string representation of a Number object', function() { assert.strictEqual(R.toString(new Number(0)), 'new Number(0)'); assert.strictEqual(R.toString(new Number(-0)), 'new Number(-0)'); }); + it('returns the string representation of a Set object', function() { + if (typeof Set !== 'function') { + return; + } + assert.strictEqual(R.toString(new Set([2, 1])), 'new Set([1, 2])'); + }); + it('returns the string representation of a String object', function() { assert.strictEqual(R.toString(new String('abc')), 'new String("abc")'); assert.strictEqual(R.toString(new String('x "y" z')), 'new String("x \\"y\\" z")'); From fd97ee3e9a43fb24486fd90c7184cd0657b3ee2f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Miika=20H=C3=A4nninen?= Date: Sun, 23 Jan 2022 22:38:43 +0200 Subject: [PATCH 110/111] Fix traverse type signature in documentation comment (#2797) Since `traverse = sequence of (map f traversable)`, and `sequence :: (x -> f x) -> t (f x) -> f (t x)`, `f :: a -> f b` and `traversable :: t a`, the type of `(map f traversable)` is `t (f b)`. Therefore the type parameter `x` in `sequence` is `b`, and the type of the `of` parameter needs to be `b -> f b`. --- source/traverse.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/source/traverse.js b/source/traverse.js index 6cb182500e..36b4f64d3c 100644 --- a/source/traverse.js +++ b/source/traverse.js @@ -15,7 +15,7 @@ import sequence from './sequence.js'; * @memberOf R * @since v0.19.0 * @category List - * @sig (Applicative f, Traversable t) => (a -> f a) -> (a -> f b) -> t a -> f (t b) + * @sig (Applicative f, Traversable t) => (b -> f b) -> (a -> f b) -> t a -> f (t b) * @param {Function} of * @param {Function} f * @param {*} traversable From 4fb5c61875108842932371167e8b439a040acde7 Mon Sep 17 00:00:00 2001 From: BobbieBarker Date: Sun, 23 Jan 2022 12:50:09 -0800 Subject: [PATCH 111/111] chore(differenceWith): updated code example for difference with to better illuminate the behaviour of the function through the documentation (#2893) --- source/differenceWith.js | 3 +++ 1 file changed, 3 insertions(+) diff --git a/source/differenceWith.js b/source/differenceWith.js index 693afefcb5..b4a2ce457a 100644 --- a/source/differenceWith.js +++ b/source/differenceWith.js @@ -23,6 +23,9 @@ import _curry3 from './internal/_curry3.js'; * const l1 = [{a: 1}, {a: 2}, {a: 3}]; * const l2 = [{a: 3}, {a: 4}]; * R.differenceWith(cmp, l1, l2); //=> [{a: 1}, {a: 2}] + * + * R.differenceWith(R.equals, [1, 2, 3, 3, 3], []); //=> [1, 2, 3] + * R.differenceWith(R.equals, [1, 2, 3, 3, 3], [1]); //=> [2, 3] */ var differenceWith = _curry3(function differenceWith(pred, first, second) { var out = [];