rambda 9.4.2 → 10.0.0-beta.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (271) hide show
  1. package/CHANGELOG.md +177 -1
  2. package/README.md +6799 -11799
  3. package/dist/rambda.cjs +1795 -0
  4. package/dist/rambda.js +1162 -2234
  5. package/dist/rambda.umd.js +1801 -1
  6. package/immutable.d.ts +1154 -1403
  7. package/index.d.ts +1154 -1403
  8. package/package.json +102 -94
  9. package/rambda.js +24 -137
  10. package/src/_internals/baseSlice.js +5 -7
  11. package/src/_internals/createPath.js +4 -6
  12. package/src/_internals/includes.js +8 -4
  13. package/src/_internals/set.js +11 -11
  14. package/src/addProp.js +3 -0
  15. package/src/all.js +8 -6
  16. package/src/allPass.js +4 -4
  17. package/src/any.js +10 -10
  18. package/src/anyPass.js +4 -4
  19. package/src/append.js +6 -8
  20. package/src/ascend.js +8 -15
  21. package/src/checkObjectWithSpec.js +16 -0
  22. package/src/compact.js +12 -0
  23. package/src/complement.js +1 -1
  24. package/src/concat.js +2 -4
  25. package/src/count.js +7 -6
  26. package/src/countBy.js +13 -14
  27. package/src/createObjectFromKeys.js +10 -0
  28. package/src/defaultTo.js +4 -6
  29. package/src/descend.js +6 -13
  30. package/src/drop.js +4 -2
  31. package/src/dropLast.js +2 -8
  32. package/src/dropLastWhile.js +17 -26
  33. package/src/dropWhile.js +14 -22
  34. package/src/eqBy.js +3 -8
  35. package/src/eqProps.js +3 -9
  36. package/src/equals.js +99 -58
  37. package/src/evolve.js +3 -57
  38. package/src/excludes.js +5 -0
  39. package/src/filter.js +13 -43
  40. package/src/filterObject.js +13 -0
  41. package/src/find.js +10 -10
  42. package/src/findIndex.js +10 -10
  43. package/src/findLast.js +9 -9
  44. package/src/findLastIndex.js +9 -9
  45. package/src/findNth.js +16 -0
  46. package/src/flatMap.js +3 -0
  47. package/src/flatten.js +5 -5
  48. package/src/groupBy.js +14 -11
  49. package/src/head.js +5 -3
  50. package/src/includes.js +13 -11
  51. package/src/indexOf.js +2 -6
  52. package/src/init.js +6 -8
  53. package/src/innerJoin.js +11 -19
  54. package/src/interpolate.js +29 -0
  55. package/src/intersection.js +2 -4
  56. package/src/intersperse.js +13 -13
  57. package/src/join.js +2 -4
  58. package/src/last.js +4 -4
  59. package/src/lastIndexOf.js +2 -6
  60. package/src/map.js +9 -49
  61. package/src/mapAsync.js +11 -0
  62. package/src/mapKeys.js +11 -0
  63. package/src/mapObject.js +18 -0
  64. package/src/mapObjectAsync.js +10 -0
  65. package/src/mapParallelAsync.js +3 -0
  66. package/src/match.js +5 -5
  67. package/src/maxBy.js +2 -8
  68. package/src/merge.js +4 -1
  69. package/src/mergeTypes.js +3 -0
  70. package/src/minBy.js +2 -8
  71. package/src/modifyProp.js +20 -0
  72. package/src/none.js +8 -6
  73. package/src/objOf.js +2 -6
  74. package/src/objectIncludes.js +12 -0
  75. package/src/omit.js +26 -11
  76. package/src/partition.js +15 -42
  77. package/src/partitionObject.js +15 -0
  78. package/src/path.js +14 -15
  79. package/src/permutations.js +40 -0
  80. package/src/pick.js +15 -15
  81. package/src/pipe.js +70 -13
  82. package/src/pipeAsync.js +11 -0
  83. package/src/pluck.js +12 -14
  84. package/src/prepend.js +2 -6
  85. package/src/prop.js +2 -10
  86. package/src/propEq.js +8 -10
  87. package/src/propOr.js +7 -8
  88. package/src/propSatisfies.js +2 -9
  89. package/src/range.js +34 -11
  90. package/src/reduce.js +15 -30
  91. package/src/reject.js +2 -4
  92. package/src/rejectObject.js +13 -0
  93. package/src/replace.js +2 -8
  94. package/src/replaceItemAtIndex.js +15 -0
  95. package/src/shuffle.js +13 -0
  96. package/src/sort.js +2 -4
  97. package/src/sortBy.js +12 -10
  98. package/src/sortObject.js +15 -0
  99. package/src/sortWith.js +12 -16
  100. package/src/split.js +2 -4
  101. package/src/splitEvery.js +11 -13
  102. package/src/symmetricDifference.js +5 -8
  103. package/src/tail.js +2 -2
  104. package/src/take.js +11 -9
  105. package/src/takeLast.js +14 -14
  106. package/src/takeLastWhile.js +15 -16
  107. package/src/takeWhile.js +12 -21
  108. package/src/tap.js +5 -5
  109. package/src/test.js +2 -8
  110. package/src/tryCatch.js +5 -14
  111. package/src/type.js +6 -5
  112. package/src/union.js +10 -8
  113. package/src/uniq.js +2 -2
  114. package/src/uniqBy.js +5 -6
  115. package/src/uniqWith.js +15 -19
  116. package/src/unless.js +7 -9
  117. package/src/unwind.js +6 -14
  118. package/src/update.js +8 -11
  119. package/src/when.js +7 -9
  120. package/src/zip.js +8 -8
  121. package/src/zipWith.js +5 -7
  122. package/src/F.js +0 -3
  123. package/src/T.js +0 -3
  124. package/src/_internals/_arity.js +0 -64
  125. package/src/_internals/compare.js +0 -3
  126. package/src/_internals/constants.js +0 -1
  127. package/src/_internals/createPathInput.js +0 -7
  128. package/src/_internals/isFalsy.js +0 -13
  129. package/src/_internals/isInteger.js +0 -10
  130. package/src/_internals/isIterable.js +0 -5
  131. package/src/_internals/isObject.js +0 -5
  132. package/src/_internals/isTruthy.js +0 -13
  133. package/src/_internals/objectIs.js +0 -9
  134. package/src/_internals/utils.js +0 -21
  135. package/src/add.js +0 -5
  136. package/src/addIndex.js +0 -23
  137. package/src/addIndexRight.js +0 -9
  138. package/src/adjust.js +0 -16
  139. package/src/always.js +0 -3
  140. package/src/and.js +0 -5
  141. package/src/ap.js +0 -7
  142. package/src/aperture.js +0 -15
  143. package/src/apply.js +0 -7
  144. package/src/applySpec.js +0 -132
  145. package/src/applyTo.js +0 -7
  146. package/src/assoc.js +0 -11
  147. package/src/assocPath.js +0 -46
  148. package/src/binary.js +0 -5
  149. package/src/bind.js +0 -9
  150. package/src/both.js +0 -5
  151. package/src/call.js +0 -1
  152. package/src/chain.js +0 -7
  153. package/src/clamp.js +0 -15
  154. package/src/clone.js +0 -18
  155. package/src/collectBy.js +0 -27
  156. package/src/comparator.js +0 -5
  157. package/src/compose.js +0 -9
  158. package/src/composeWith.js +0 -33
  159. package/src/cond.js +0 -14
  160. package/src/converge.js +0 -18
  161. package/src/curry.js +0 -7
  162. package/src/curryN.js +0 -40
  163. package/src/dec.js +0 -1
  164. package/src/difference.js +0 -8
  165. package/src/differenceWith.js +0 -20
  166. package/src/dissoc.js +0 -13
  167. package/src/dissocPath.js +0 -47
  168. package/src/divide.js +0 -5
  169. package/src/dropRepeats.js +0 -20
  170. package/src/dropRepeatsBy.js +0 -21
  171. package/src/dropRepeatsWith.js +0 -28
  172. package/src/either.js +0 -8
  173. package/src/empty.js +0 -15
  174. package/src/endsWith.js +0 -23
  175. package/src/flip.js +0 -23
  176. package/src/forEach.js +0 -19
  177. package/src/forEachObjIndexed.js +0 -24
  178. package/src/fromPairs.js +0 -6
  179. package/src/groupWith.js +0 -46
  180. package/src/gt.js +0 -6
  181. package/src/gte.js +0 -6
  182. package/src/has.js +0 -7
  183. package/src/hasIn.js +0 -9
  184. package/src/hasPath.js +0 -9
  185. package/src/identical.js +0 -7
  186. package/src/identity.js +0 -3
  187. package/src/ifElse.js +0 -17
  188. package/src/inc.js +0 -1
  189. package/src/indexBy.js +0 -29
  190. package/src/insert.js +0 -11
  191. package/src/insertAll.js +0 -7
  192. package/src/is.js +0 -8
  193. package/src/isEmpty.js +0 -18
  194. package/src/isNil.js +0 -3
  195. package/src/isNotEmpty.js +0 -5
  196. package/src/isNotNil.js +0 -3
  197. package/src/isPromise.js +0 -5
  198. package/src/juxt.js +0 -3
  199. package/src/keys.js +0 -3
  200. package/src/length.js +0 -8
  201. package/src/lens.js +0 -7
  202. package/src/lensIndex.js +0 -7
  203. package/src/lensPath.js +0 -7
  204. package/src/lensProp.js +0 -7
  205. package/src/lt.js +0 -6
  206. package/src/lte.js +0 -6
  207. package/src/mathMod.js +0 -8
  208. package/src/max.js +0 -5
  209. package/src/maybe.js +0 -13
  210. package/src/mean.js +0 -5
  211. package/src/median.js +0 -17
  212. package/src/mergeAll.js +0 -11
  213. package/src/mergeDeepLeft.js +0 -5
  214. package/src/mergeDeepRight.js +0 -24
  215. package/src/mergeLeft.js +0 -7
  216. package/src/mergeRight.js +0 -8
  217. package/src/mergeWith.js +0 -25
  218. package/src/min.js +0 -5
  219. package/src/modify.js +0 -23
  220. package/src/modifyPath.js +0 -33
  221. package/src/modulo.js +0 -5
  222. package/src/move.js +0 -19
  223. package/src/multiply.js +0 -5
  224. package/src/negate.js +0 -3
  225. package/src/not.js +0 -3
  226. package/src/nth.js +0 -9
  227. package/src/of.js +0 -3
  228. package/src/on.js +0 -16
  229. package/src/once.js +0 -24
  230. package/src/or.js +0 -5
  231. package/src/over.js +0 -14
  232. package/src/partial.js +0 -17
  233. package/src/partialObject.js +0 -5
  234. package/src/pathEq.js +0 -11
  235. package/src/pathOr.js +0 -11
  236. package/src/pathSatisfies.js +0 -9
  237. package/src/paths.js +0 -9
  238. package/src/pickAll.js +0 -23
  239. package/src/pickBy.js +0 -11
  240. package/src/product.js +0 -4
  241. package/src/propIs.js +0 -10
  242. package/src/props.js +0 -13
  243. package/src/reduceBy.js +0 -29
  244. package/src/removeIndex.js +0 -7
  245. package/src/repeat.js +0 -7
  246. package/src/reverse.js +0 -9
  247. package/src/set.js +0 -9
  248. package/src/slice.js +0 -9
  249. package/src/splitAt.js +0 -21
  250. package/src/splitWhen.js +0 -25
  251. package/src/startsWith.js +0 -23
  252. package/src/subtract.js +0 -5
  253. package/src/sum.js +0 -3
  254. package/src/swap.js +0 -42
  255. package/src/times.js +0 -12
  256. package/src/toLower.js +0 -3
  257. package/src/toPairs.js +0 -3
  258. package/src/toString.js +0 -3
  259. package/src/toUpper.js +0 -3
  260. package/src/transpose.js +0 -10
  261. package/src/trim.js +0 -3
  262. package/src/unapply.js +0 -5
  263. package/src/unnest.js +0 -9
  264. package/src/values.js +0 -6
  265. package/src/view.js +0 -10
  266. package/src/where.js +0 -15
  267. package/src/whereAny.js +0 -12
  268. package/src/whereEq.js +0 -14
  269. package/src/without.js +0 -15
  270. package/src/xor.js +0 -5
  271. package/src/zipObj.js +0 -13
package/src/update.js CHANGED
@@ -1,15 +1,12 @@
1
1
  import { cloneList } from './_internals/cloneList.js'
2
- import { curry } from './curry.js'
3
2
 
4
- export function updateFn(
5
- index, newValue, list
6
- ){
7
- const clone = cloneList(list)
8
- if (index === -1) return clone.fill(newValue, index)
3
+ export function update(index, newValue) {
4
+ return list => {
5
+ const clone = cloneList(list)
6
+ if (index === -1) {
7
+ return clone.fill(newValue, index)
8
+ }
9
9
 
10
- return clone.fill(
11
- newValue, index, index + 1
12
- )
10
+ return clone.fill(newValue, index, index + 1)
11
+ }
13
12
  }
14
-
15
- export const update = curry(updateFn)
package/src/when.js CHANGED
@@ -1,11 +1,9 @@
1
- import { curry } from './curry.js'
1
+ export function when(predicate, whenTrueFn) {
2
+ return input => {
3
+ if (!predicate(input)) {
4
+ return input
5
+ }
2
6
 
3
- function whenFn(
4
- predicate, whenTrueFn, input
5
- ){
6
- if (!predicate(input)) return input
7
-
8
- return whenTrueFn(input)
7
+ return whenTrueFn(input)
8
+ }
9
9
  }
10
-
11
- export const when = curry(whenFn)
package/src/zip.js CHANGED
@@ -1,12 +1,12 @@
1
- export function zip(left, right){
2
- if (arguments.length === 1) return _right => zip(left, _right)
1
+ export function zip(left) {
2
+ return right => {
3
+ const result = []
4
+ const length = Math.min(left.length, right.length)
3
5
 
4
- const result = []
5
- const length = Math.min(left.length, right.length)
6
+ for (let i = 0; i < length; i++) {
7
+ result[i] = [left[i], right[i]]
8
+ }
6
9
 
7
- for (let i = 0; i < length; i++){
8
- result[ i ] = [ left[ i ], right[ i ] ]
10
+ return result
9
11
  }
10
-
11
- return result
12
12
  }
package/src/zipWith.js CHANGED
@@ -1,10 +1,8 @@
1
- import { curry } from './curry.js'
2
1
  import { take } from './take.js'
3
2
 
4
- function zipWithFn(
5
- fn, x, y
6
- ){
7
- return take(x.length > y.length ? y.length : x.length, x).map((xInstance, i) => fn(xInstance, y[ i ]))
3
+ export function zipWith(fn, x) {
4
+ return y =>
5
+ take(x.length > y.length ? y.length : x.length)(x).map((xInstance, i) =>
6
+ fn(xInstance, y[i]),
7
+ )
8
8
  }
9
-
10
- export const zipWith = curry(zipWithFn)
package/src/F.js DELETED
@@ -1,3 +0,0 @@
1
- export function F(){
2
- return false
3
- }
package/src/T.js DELETED
@@ -1,3 +0,0 @@
1
- export function T(){
2
- return true
3
- }
@@ -1,64 +0,0 @@
1
- export function _arity(n, fn){
2
- switch (n){
3
- case 0:
4
- return function (){
5
- return fn.apply(this, arguments)
6
- }
7
- case 1:
8
- return function (_1){
9
- return fn.apply(this, arguments)
10
- }
11
- case 2:
12
- return function (_1, _2){
13
- return fn.apply(this, arguments)
14
- }
15
- case 3:
16
- return function (
17
- _1, _2, _3
18
- ){
19
- return fn.apply(this, arguments)
20
- }
21
- case 4:
22
- return function (
23
- _1, _2, _3, _4
24
- ){
25
- return fn.apply(this, arguments)
26
- }
27
- case 5:
28
- return function (
29
- _1, _2, _3, _4, _5
30
- ){
31
- return fn.apply(this, arguments)
32
- }
33
- case 6:
34
- return function (
35
- _1, _2, _3, _4, _5, _6
36
- ){
37
- return fn.apply(this, arguments)
38
- }
39
- case 7:
40
- return function (
41
- _1, _2, _3, _4, _5, _6, _7
42
- ){
43
- return fn.apply(this, arguments)
44
- }
45
- case 8:
46
- return function (
47
- _1, _2, _3, _4, _5, _6, _7, _8
48
- ){
49
- return fn.apply(this, arguments)
50
- }
51
- case 9:
52
- return function (
53
- _1, _2, _3, _4, _5, _6, _7, _8, _9
54
- ){
55
- return fn.apply(this, arguments)
56
- }
57
- default:
58
- return function (
59
- _1, _2, _3, _4, _5, _6, _7, _8, _9, _10
60
- ){
61
- return fn.apply(this, arguments)
62
- }
63
- }
64
- }
@@ -1,3 +0,0 @@
1
- export function compare(a, b){
2
- return String(a) === String(b)
3
- }
@@ -1 +0,0 @@
1
- export const INCORRECT_ITERABLE_INPUT = 'Incorrect iterable input'
@@ -1,7 +0,0 @@
1
- import { isInteger } from './isInteger.js'
2
-
3
- export function createPathInput(path){
4
- return typeof path === 'string' ?
5
- path.split('.').map(x => isInteger(Number(x)) ? Number(x) : x) :
6
- path
7
- }
@@ -1,13 +0,0 @@
1
- import { type } from '../type.js'
2
- import { isArray } from './isArray.js'
3
-
4
- export function isFalsy(x){
5
- if (isArray(x)){
6
- return x.length === 0
7
- }
8
- if (type(x) === 'Object'){
9
- return Object.keys(x).length === 0
10
- }
11
-
12
- return !x
13
- }
@@ -1,10 +0,0 @@
1
- function _isInteger(n){
2
- return n << 0 === n
3
- }
4
-
5
- export const isInteger = Number.isInteger || _isInteger
6
-
7
- /**
8
- * Check if `index` is integer even if it is a string.
9
- */
10
- export const isIndexInteger = index => Number.isInteger(Number(index))
@@ -1,5 +0,0 @@
1
- import { type } from '../type.js'
2
-
3
- export function isIterable(input){
4
- return Array.isArray(input) || type(input) === 'Object'
5
- }
@@ -1,5 +0,0 @@
1
- import { type } from '../type.js'
2
-
3
- export function isObject(input){
4
- return type(input) === 'Object'
5
- }
@@ -1,13 +0,0 @@
1
- import { type } from '../type.js'
2
- import { isArray } from './isArray.js'
3
-
4
- export function isTruthy(x){
5
- if (isArray(x)){
6
- return x.length > 0
7
- }
8
- if (type(x) === 'Object'){
9
- return Object.keys(x).length > 0
10
- }
11
-
12
- return Boolean(x)
13
- }
@@ -1,9 +0,0 @@
1
- function _objectIs(a, b){
2
- if (a === b){
3
- return a !== 0 || 1 / a === 1 / b
4
- }
5
-
6
- return a !== a && b !== b
7
- }
8
-
9
- export const objectIs = Object.is || _objectIs
@@ -1,21 +0,0 @@
1
- export function _concat(set1, set2){
2
- set1 = set1 || []
3
- set2 = set2 || []
4
- let idx
5
- const len1 = set1.length
6
- const len2 = set2.length
7
- const result = []
8
-
9
- idx = 0
10
- while (idx < len1){
11
- result[ result.length ] = set1[ idx ]
12
- idx += 1
13
- }
14
- idx = 0
15
- while (idx < len2){
16
- result[ result.length ] = set2[ idx ]
17
- idx += 1
18
- }
19
-
20
- return result
21
- }
package/src/add.js DELETED
@@ -1,5 +0,0 @@
1
- export function add(a, b){
2
- if (arguments.length === 1) return _b => add(a, _b)
3
-
4
- return Number(a) + Number(b)
5
- }
package/src/addIndex.js DELETED
@@ -1,23 +0,0 @@
1
- import { _concat } from './_internals/utils.js'
2
- import { curryN } from './curryN.js'
3
-
4
- export function addIndex(
5
- originalFunction,
6
- initialIndexFn = () => 0,
7
- loopIndexChange = x => x + 1
8
- ){
9
- return curryN(originalFunction.length, function (){
10
- const origFn = arguments[ 0 ]
11
- const list = arguments[ arguments.length - 1 ]
12
- let idx = initialIndexFn(list.length)
13
- const args = Array.prototype.slice.call(arguments, 0)
14
- args[ 0 ] = function (){
15
- const result = origFn.apply(this, _concat(arguments, [ idx, list ]))
16
- idx = loopIndexChange(idx)
17
-
18
- return result
19
- }
20
-
21
- return originalFunction.apply(this, args)
22
- })
23
- }
@@ -1,9 +0,0 @@
1
- import { addIndex } from './addIndex.js'
2
-
3
- export function addIndexRight(originalFunction){
4
- return addIndex(
5
- originalFunction,
6
- listLength => listLength - 1,
7
- x => x - 1
8
- )
9
- }
package/src/adjust.js DELETED
@@ -1,16 +0,0 @@
1
- import { cloneList } from './_internals/cloneList.js'
2
- import { curry } from './curry.js'
3
-
4
- function adjustFn(
5
- index, replaceFn, list
6
- ){
7
- const actualIndex = index < 0 ? list.length + index : index
8
- if (index >= list.length || actualIndex < 0) return list
9
-
10
- const clone = cloneList(list)
11
- clone[ actualIndex ] = replaceFn(clone[ actualIndex ])
12
-
13
- return clone
14
- }
15
-
16
- export const adjust = curry(adjustFn)
package/src/always.js DELETED
@@ -1,3 +0,0 @@
1
- export function always(x){
2
- return _ => x
3
- }
package/src/and.js DELETED
@@ -1,5 +0,0 @@
1
- export function and(a, b){
2
- if (arguments.length === 1) return _b => and(a, _b)
3
-
4
- return a && b
5
- }
package/src/ap.js DELETED
@@ -1,7 +0,0 @@
1
- export function ap(functions, input){
2
- if (arguments.length === 1){
3
- return _inputs => ap(functions, _inputs)
4
- }
5
-
6
- return functions.reduce((acc, fn) => [ ...acc, ...input.map(fn) ], [])
7
- }
package/src/aperture.js DELETED
@@ -1,15 +0,0 @@
1
- export function aperture(step, list){
2
- if (arguments.length === 1){
3
- return _list => aperture(step, _list)
4
- }
5
- if (step > list.length) return []
6
- let idx = 0
7
- const limit = list.length - (step - 1)
8
- const acc = new Array(limit)
9
- while (idx < limit){
10
- acc[ idx ] = list.slice(idx, idx + step)
11
- idx += 1
12
- }
13
-
14
- return acc
15
- }
package/src/apply.js DELETED
@@ -1,7 +0,0 @@
1
- export function apply(fn, args){
2
- if (arguments.length === 1){
3
- return _args => apply(fn, _args)
4
- }
5
-
6
- return fn.apply(this, args)
7
- }
package/src/applySpec.js DELETED
@@ -1,132 +0,0 @@
1
- import { isArray } from './_internals/isArray.js'
2
-
3
- // recursively traverse the given spec object to find the highest arity function
4
- export function __findHighestArity(spec, max = 0){
5
- for (const key in spec){
6
- if (spec.hasOwnProperty(key) === false || key === 'constructor') continue
7
-
8
- if (typeof spec[ key ] === 'object'){
9
- max = Math.max(max, __findHighestArity(spec[ key ]))
10
- }
11
-
12
- if (typeof spec[ key ] === 'function'){
13
- max = Math.max(max, spec[ key ].length)
14
- }
15
- }
16
-
17
- return max
18
- }
19
-
20
- function __filterUndefined(){
21
- const defined = []
22
- let i = 0
23
- const l = arguments.length
24
- while (i < l){
25
- if (typeof arguments[ i ] === 'undefined') break
26
- defined[ i ] = arguments[ i ]
27
- i++
28
- }
29
-
30
- return defined
31
- }
32
-
33
- function __applySpecWithArity(
34
- spec, arity, cache
35
- ){
36
- const remaining = arity - cache.length
37
-
38
- if (remaining === 1)
39
- return x =>
40
- __applySpecWithArity(
41
- spec, arity, __filterUndefined(...cache, x)
42
- )
43
- if (remaining === 2)
44
- return (x, y) =>
45
- __applySpecWithArity(
46
- spec, arity, __filterUndefined(
47
- ...cache, x, y
48
- )
49
- )
50
- if (remaining === 3)
51
- return (
52
- x, y, z
53
- ) =>
54
- __applySpecWithArity(
55
- spec, arity, __filterUndefined(
56
- ...cache, x, y, z
57
- )
58
- )
59
- if (remaining === 4)
60
- return (
61
- x, y, z, a
62
- ) =>
63
- __applySpecWithArity(
64
- spec,
65
- arity,
66
- __filterUndefined(
67
- ...cache, x, y, z, a
68
- )
69
- )
70
- if (remaining > 4)
71
- return (...args) =>
72
- __applySpecWithArity(
73
- spec, arity, __filterUndefined(...cache, ...args)
74
- )
75
-
76
- // handle spec as Array
77
- if (isArray(spec)){
78
- const ret = []
79
- let i = 0
80
- const l = spec.length
81
- for (; i < l; i++){
82
- // handle recursive spec inside array
83
- if (typeof spec[ i ] === 'object' || isArray(spec[ i ])){
84
- ret[ i ] = __applySpecWithArity(
85
- spec[ i ], arity, cache
86
- )
87
- }
88
- // apply spec to the key
89
- if (typeof spec[ i ] === 'function'){
90
- ret[ i ] = spec[ i ](...cache)
91
- }
92
- }
93
-
94
- return ret
95
- }
96
-
97
- // handle spec as Object
98
- const ret = {}
99
- // apply callbacks to each property in the spec object
100
- for (const key in spec){
101
- if (spec.hasOwnProperty(key) === false || key === 'constructor') continue
102
-
103
- // apply the spec recursively
104
- if (typeof spec[ key ] === 'object'){
105
- ret[ key ] = __applySpecWithArity(
106
- spec[ key ], arity, cache
107
- )
108
- continue
109
- }
110
-
111
- // apply spec to the key
112
- if (typeof spec[ key ] === 'function'){
113
- ret[ key ] = spec[ key ](...cache)
114
- }
115
- }
116
-
117
- return ret
118
- }
119
-
120
- export function applySpec(spec, ...args){
121
- // get the highest arity spec function, cache the result and pass to __applySpecWithArity
122
- const arity = __findHighestArity(spec)
123
-
124
- if (arity === 0){
125
- return () => ({})
126
- }
127
- const toReturn = __applySpecWithArity(
128
- spec, arity, args
129
- )
130
-
131
- return toReturn
132
- }
package/src/applyTo.js DELETED
@@ -1,7 +0,0 @@
1
- export function applyTo(input, fn){
2
- if (arguments.length === 1){
3
- return _fn => applyTo(input, _fn)
4
- }
5
-
6
- return fn(input)
7
- }
package/src/assoc.js DELETED
@@ -1,11 +0,0 @@
1
- import { curry } from './curry.js'
2
-
3
- export function assocFn(
4
- prop, newValue, obj
5
- ){
6
- return Object.assign(
7
- {}, obj, { [ prop ] : newValue }
8
- )
9
- }
10
-
11
- export const assoc = curry(assocFn)
package/src/assocPath.js DELETED
@@ -1,46 +0,0 @@
1
- import { cloneList } from './_internals/cloneList.js'
2
- import { createPath } from './_internals/createPath.js'
3
- import { isArray } from './_internals/isArray.js'
4
- import { isIndexInteger } from './_internals/isInteger.js'
5
- import { assocFn } from './assoc.js'
6
- import { curry } from './curry.js'
7
-
8
- export function assocPathFn(
9
- path, newValue, input
10
- ){
11
- const pathArrValue = createPath(path)
12
- if (pathArrValue.length === 0) return newValue
13
-
14
- const index = pathArrValue[ 0 ]
15
- if (pathArrValue.length > 1){
16
- const condition =
17
- typeof input !== 'object' ||
18
- input === null ||
19
- !input.hasOwnProperty(index)
20
-
21
- const nextInput = condition ?
22
- isIndexInteger(pathArrValue[ 1 ]) ?
23
- [] :
24
- {} :
25
- input[ index ]
26
-
27
- newValue = assocPathFn(
28
- Array.prototype.slice.call(pathArrValue, 1),
29
- newValue,
30
- nextInput
31
- )
32
- }
33
-
34
- if (isIndexInteger(index) && isArray(input)){
35
- const arr = cloneList(input)
36
- arr[ index ] = newValue
37
-
38
- return arr
39
- }
40
-
41
- return assocFn(
42
- index, newValue, input
43
- )
44
- }
45
-
46
- export const assocPath = curry(assocPathFn)
package/src/binary.js DELETED
@@ -1,5 +0,0 @@
1
- export function binary(fn){
2
- if (fn.length <= 2) return fn
3
-
4
- return (a, b) => fn(a, b)
5
- }
package/src/bind.js DELETED
@@ -1,9 +0,0 @@
1
- import { curryN } from './curryN.js'
2
-
3
- export function bind(fn, thisObj){
4
- if (arguments.length === 1){
5
- return _thisObj => bind(fn, _thisObj)
6
- }
7
-
8
- return curryN(fn.length, (...args) => fn.apply(thisObj, args))
9
- }
package/src/both.js DELETED
@@ -1,5 +0,0 @@
1
- export function both(f, g){
2
- if (arguments.length === 1) return _g => both(f, _g)
3
-
4
- return (...input) => f(...input) && g(...input)
5
- }
package/src/call.js DELETED
@@ -1 +0,0 @@
1
- export const call = (fn, ...inputs) => fn(...inputs)
package/src/chain.js DELETED
@@ -1,7 +0,0 @@
1
- export function chain(fn, list){
2
- if (arguments.length === 1){
3
- return _list => chain(fn, _list)
4
- }
5
-
6
- return [].concat(...list.map(fn))
7
- }
package/src/clamp.js DELETED
@@ -1,15 +0,0 @@
1
- import { curry } from './curry.js'
2
-
3
- function clampFn(
4
- min, max, input
5
- ){
6
- if (min > max){
7
- throw new Error('min must not be greater than max in clamp(min, max, value)')
8
- }
9
- if (input >= min && input <= max) return input
10
-
11
- if (input > max) return max
12
- if (input < min) return min
13
- }
14
-
15
- export const clamp = curry(clampFn)
package/src/clone.js DELETED
@@ -1,18 +0,0 @@
1
- import { isArray } from './_internals/isArray.js'
2
-
3
- export function clone(input){
4
- const out = isArray(input) ? Array(input.length) : {}
5
- if (input && input.getTime) return new Date(input.getTime())
6
-
7
- for (const key in input){
8
- const v = input[ key ]
9
- out[ key ] =
10
- typeof v === 'object' && v !== null ?
11
- v.getTime ?
12
- new Date(v.getTime()) :
13
- clone(v) :
14
- v
15
- }
16
-
17
- return out
18
- }
package/src/collectBy.js DELETED
@@ -1,27 +0,0 @@
1
- import { reduce } from './reduce.js'
2
-
3
- export function collectBy(fn, list){
4
- if (arguments.length === 1){
5
- return _list => collectBy(fn, _list)
6
- }
7
-
8
- const group = reduce(
9
- (o, x) => {
10
- const tag = fn(x)
11
- if (o[ tag ] === undefined){
12
- o[ tag ] = []
13
- }
14
- o[ tag ].push(x)
15
-
16
- return o
17
- },
18
- {},
19
- list
20
- )
21
- const newList = []
22
- for (const tag in group){
23
- newList.push(group[ tag ])
24
- }
25
-
26
- return newList
27
- }
package/src/comparator.js DELETED
@@ -1,5 +0,0 @@
1
- export function comparator(fn){
2
- return function (a, b){
3
- return fn(a, b) ? -1 : fn(b, a) ? 1 : 0
4
- }
5
- }