rambda 9.4.2 → 10.0.0-alpha.0

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 (257) hide show
  1. package/CHANGELOG.md +69 -1
  2. package/README.md +4637 -13433
  3. package/dist/rambda.esm.js +1487 -0
  4. package/dist/rambda.js +952 -2113
  5. package/dist/rambda.umd.js +1595 -1
  6. package/immutable.d.ts +1066 -1293
  7. package/index.d.ts +1066 -1293
  8. package/package.json +95 -94
  9. package/rambda.js +10 -138
  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/all.js +8 -6
  15. package/src/allPass.js +4 -4
  16. package/src/any.js +10 -10
  17. package/src/anyPass.js +4 -4
  18. package/src/append.js +4 -6
  19. package/src/checkObjectWithSpec.js +16 -0
  20. package/src/complement.js +1 -1
  21. package/src/concat.js +2 -4
  22. package/src/count.js +5 -4
  23. package/src/countBy.js +6 -7
  24. package/src/defaultTo.js +4 -6
  25. package/src/drop.js +4 -2
  26. package/src/dropLast.js +4 -8
  27. package/src/dropLastWhile.js +17 -26
  28. package/src/dropWhile.js +14 -22
  29. package/src/eqBy.js +3 -8
  30. package/src/eqProps.js +3 -8
  31. package/src/equals.js +99 -58
  32. package/src/evolve.js +19 -52
  33. package/src/excludes.js +5 -0
  34. package/src/filter.js +10 -40
  35. package/src/filterObject.js +13 -0
  36. package/src/find.js +6 -6
  37. package/src/findIndex.js +5 -5
  38. package/src/findLast.js +6 -6
  39. package/src/findLastIndex.js +5 -5
  40. package/src/flatMap.js +3 -0
  41. package/src/flatten.js +5 -5
  42. package/src/groupBy.js +9 -7
  43. package/src/head.js +5 -3
  44. package/src/includes.js +10 -7
  45. package/src/indexOf.js +2 -6
  46. package/src/init.js +6 -8
  47. package/src/innerJoin.js +11 -19
  48. package/src/intersection.js +2 -4
  49. package/src/intersperse.js +7 -7
  50. package/src/join.js +2 -4
  51. package/src/last.js +4 -4
  52. package/src/lastIndexOf.js +2 -6
  53. package/src/map.js +9 -49
  54. package/src/mapAsync.js +11 -0
  55. package/src/mapObject.js +18 -0
  56. package/src/mapObjectAsync.js +10 -0
  57. package/src/match.js +6 -6
  58. package/src/maxBy.js +2 -8
  59. package/src/merge.js +4 -1
  60. package/src/mergeTypes.js +3 -0
  61. package/src/minBy.js +2 -8
  62. package/src/modifyPath.js +22 -25
  63. package/src/none.js +8 -6
  64. package/src/objOf.js +2 -6
  65. package/src/omit.js +26 -11
  66. package/src/partition.js +20 -23
  67. package/src/path.js +14 -15
  68. package/src/pick.js +15 -15
  69. package/src/pipe.js +70 -13
  70. package/src/pipeAsync.js +10 -0
  71. package/src/pluck.js +7 -9
  72. package/src/prepend.js +2 -6
  73. package/src/prop.js +2 -10
  74. package/src/propEq.js +8 -10
  75. package/src/propOr.js +7 -8
  76. package/src/propSatisfies.js +2 -7
  77. package/src/range.js +3 -3
  78. package/src/reduce.js +15 -30
  79. package/src/reject.js +2 -4
  80. package/src/replace.js +2 -8
  81. package/src/replaceItemAtIndex.js +15 -0
  82. package/src/sort.js +2 -4
  83. package/src/sortBy.js +3 -3
  84. package/src/sortWith.js +9 -13
  85. package/src/split.js +2 -4
  86. package/src/splitEvery.js +6 -8
  87. package/src/symmetricDifference.js +5 -8
  88. package/src/tail.js +2 -2
  89. package/src/take.js +11 -9
  90. package/src/takeLast.js +14 -14
  91. package/src/takeLastWhile.js +19 -20
  92. package/src/takeWhile.js +12 -21
  93. package/src/tap.js +3 -3
  94. package/src/test.js +2 -8
  95. package/src/tryCatch.js +5 -14
  96. package/src/type.js +6 -5
  97. package/src/union.js +10 -8
  98. package/src/uniq.js +2 -2
  99. package/src/uniqBy.js +5 -6
  100. package/src/uniqWith.js +10 -14
  101. package/src/unless.js +7 -9
  102. package/src/unwind.js +6 -14
  103. package/src/update.js +8 -11
  104. package/src/when.js +7 -9
  105. package/src/zip.js +8 -8
  106. package/src/zipWith.js +5 -7
  107. package/src/F.js +0 -3
  108. package/src/T.js +0 -3
  109. package/src/_internals/_arity.js +0 -64
  110. package/src/_internals/compare.js +0 -3
  111. package/src/_internals/constants.js +0 -1
  112. package/src/_internals/createPathInput.js +0 -7
  113. package/src/_internals/isFalsy.js +0 -13
  114. package/src/_internals/isInteger.js +0 -10
  115. package/src/_internals/isIterable.js +0 -5
  116. package/src/_internals/isObject.js +0 -5
  117. package/src/_internals/isTruthy.js +0 -13
  118. package/src/_internals/objectIs.js +0 -9
  119. package/src/_internals/utils.js +0 -21
  120. package/src/add.js +0 -5
  121. package/src/addIndex.js +0 -23
  122. package/src/addIndexRight.js +0 -9
  123. package/src/adjust.js +0 -16
  124. package/src/always.js +0 -3
  125. package/src/and.js +0 -5
  126. package/src/ap.js +0 -7
  127. package/src/aperture.js +0 -15
  128. package/src/apply.js +0 -7
  129. package/src/applySpec.js +0 -132
  130. package/src/applyTo.js +0 -7
  131. package/src/ascend.js +0 -23
  132. package/src/assoc.js +0 -11
  133. package/src/assocPath.js +0 -46
  134. package/src/binary.js +0 -5
  135. package/src/bind.js +0 -9
  136. package/src/both.js +0 -5
  137. package/src/call.js +0 -1
  138. package/src/chain.js +0 -7
  139. package/src/clamp.js +0 -15
  140. package/src/clone.js +0 -18
  141. package/src/collectBy.js +0 -27
  142. package/src/comparator.js +0 -5
  143. package/src/compose.js +0 -9
  144. package/src/composeWith.js +0 -33
  145. package/src/cond.js +0 -14
  146. package/src/converge.js +0 -18
  147. package/src/curry.js +0 -7
  148. package/src/curryN.js +0 -40
  149. package/src/dec.js +0 -1
  150. package/src/descend.js +0 -17
  151. package/src/difference.js +0 -8
  152. package/src/differenceWith.js +0 -20
  153. package/src/dissoc.js +0 -13
  154. package/src/dissocPath.js +0 -47
  155. package/src/divide.js +0 -5
  156. package/src/dropRepeats.js +0 -20
  157. package/src/dropRepeatsBy.js +0 -21
  158. package/src/dropRepeatsWith.js +0 -28
  159. package/src/either.js +0 -8
  160. package/src/empty.js +0 -15
  161. package/src/endsWith.js +0 -23
  162. package/src/flip.js +0 -23
  163. package/src/forEach.js +0 -19
  164. package/src/forEachObjIndexed.js +0 -24
  165. package/src/fromPairs.js +0 -6
  166. package/src/groupWith.js +0 -46
  167. package/src/gt.js +0 -6
  168. package/src/gte.js +0 -6
  169. package/src/has.js +0 -7
  170. package/src/hasIn.js +0 -9
  171. package/src/hasPath.js +0 -9
  172. package/src/identical.js +0 -7
  173. package/src/identity.js +0 -3
  174. package/src/ifElse.js +0 -17
  175. package/src/inc.js +0 -1
  176. package/src/indexBy.js +0 -29
  177. package/src/insert.js +0 -11
  178. package/src/insertAll.js +0 -7
  179. package/src/is.js +0 -8
  180. package/src/isEmpty.js +0 -18
  181. package/src/isNil.js +0 -3
  182. package/src/isNotEmpty.js +0 -5
  183. package/src/isNotNil.js +0 -3
  184. package/src/isPromise.js +0 -5
  185. package/src/juxt.js +0 -3
  186. package/src/keys.js +0 -3
  187. package/src/length.js +0 -8
  188. package/src/lens.js +0 -7
  189. package/src/lensIndex.js +0 -7
  190. package/src/lensPath.js +0 -7
  191. package/src/lensProp.js +0 -7
  192. package/src/lt.js +0 -6
  193. package/src/lte.js +0 -6
  194. package/src/mathMod.js +0 -8
  195. package/src/max.js +0 -5
  196. package/src/maybe.js +0 -13
  197. package/src/mean.js +0 -5
  198. package/src/median.js +0 -17
  199. package/src/mergeAll.js +0 -11
  200. package/src/mergeDeepLeft.js +0 -5
  201. package/src/mergeDeepRight.js +0 -24
  202. package/src/mergeLeft.js +0 -7
  203. package/src/mergeRight.js +0 -8
  204. package/src/mergeWith.js +0 -25
  205. package/src/min.js +0 -5
  206. package/src/modify.js +0 -23
  207. package/src/modulo.js +0 -5
  208. package/src/move.js +0 -19
  209. package/src/multiply.js +0 -5
  210. package/src/negate.js +0 -3
  211. package/src/not.js +0 -3
  212. package/src/nth.js +0 -9
  213. package/src/of.js +0 -3
  214. package/src/on.js +0 -16
  215. package/src/once.js +0 -24
  216. package/src/or.js +0 -5
  217. package/src/over.js +0 -14
  218. package/src/partial.js +0 -17
  219. package/src/partialObject.js +0 -5
  220. package/src/pathEq.js +0 -11
  221. package/src/pathOr.js +0 -11
  222. package/src/pathSatisfies.js +0 -9
  223. package/src/paths.js +0 -9
  224. package/src/pickAll.js +0 -23
  225. package/src/pickBy.js +0 -11
  226. package/src/product.js +0 -4
  227. package/src/propIs.js +0 -10
  228. package/src/props.js +0 -13
  229. package/src/reduceBy.js +0 -29
  230. package/src/removeIndex.js +0 -7
  231. package/src/repeat.js +0 -7
  232. package/src/reverse.js +0 -9
  233. package/src/set.js +0 -9
  234. package/src/slice.js +0 -9
  235. package/src/splitAt.js +0 -21
  236. package/src/splitWhen.js +0 -25
  237. package/src/startsWith.js +0 -23
  238. package/src/subtract.js +0 -5
  239. package/src/sum.js +0 -3
  240. package/src/swap.js +0 -42
  241. package/src/times.js +0 -12
  242. package/src/toLower.js +0 -3
  243. package/src/toPairs.js +0 -3
  244. package/src/toString.js +0 -3
  245. package/src/toUpper.js +0 -3
  246. package/src/transpose.js +0 -10
  247. package/src/trim.js +0 -3
  248. package/src/unapply.js +0 -5
  249. package/src/unnest.js +0 -9
  250. package/src/values.js +0 -6
  251. package/src/view.js +0 -10
  252. package/src/where.js +0 -15
  253. package/src/whereAny.js +0 -12
  254. package/src/whereEq.js +0 -14
  255. package/src/without.js +0 -15
  256. package/src/xor.js +0 -5
  257. package/src/zipObj.js +0 -13
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/ascend.js DELETED
@@ -1,23 +0,0 @@
1
- export function createCompareFunction(
2
- a, b, winner, loser
3
- ){
4
- if (a === b) return 0
5
-
6
- return a < b ? winner : loser
7
- }
8
-
9
- export function ascend(
10
- getFunction, a, b
11
- ){
12
- if (arguments.length === 1){
13
- return (_a, _b) => ascend(
14
- getFunction, _a, _b
15
- )
16
- }
17
- const aValue = getFunction(a)
18
- const bValue = getFunction(b)
19
-
20
- return createCompareFunction(
21
- aValue, bValue, -1, 1
22
- )
23
- }
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
- }
package/src/compose.js DELETED
@@ -1,9 +0,0 @@
1
- import { pipe } from './pipe.js'
2
-
3
- export function compose(){
4
- if (arguments.length === 0){
5
- throw new Error('compose requires at least one argument')
6
- }
7
-
8
- return pipe.apply(this, Array.prototype.slice.call(arguments, 0).reverse())
9
- }
@@ -1,33 +0,0 @@
1
- import { _arity } from './_internals/_arity.js'
2
- import { head } from './head.js'
3
- import { identity } from './identity.js'
4
- import { reduce } from './reduce.js'
5
- import { reverse } from './reverse.js'
6
- import { tail } from './tail.js'
7
-
8
- export function pipeWith(xf, list){
9
- if (list.length <= 0){
10
- return identity
11
- }
12
-
13
- const headList = head(list)
14
- const tailList = tail(list)
15
-
16
- return _arity(headList.length, function (){
17
- return reduce(
18
- function (result, f){
19
- return xf.call(
20
- this, f, result
21
- )
22
- },
23
- headList.apply(this, arguments),
24
- tailList
25
- )
26
- })
27
- }
28
-
29
- export function composeWith(xf, list){
30
- if (arguments.length === 1) return _list => composeWith(xf, _list)
31
-
32
- return pipeWith.apply(this, [ xf, reverse(list) ])
33
- }
package/src/cond.js DELETED
@@ -1,14 +0,0 @@
1
- export function cond(conditions){
2
- return (...input) => {
3
- let done = false
4
- let toReturn
5
- conditions.forEach(([ predicate, getResult ]) => {
6
- if (!done && predicate(...input)){
7
- done = true
8
- toReturn = getResult(...input)
9
- }
10
- })
11
-
12
- return toReturn
13
- }
14
- }
package/src/converge.js DELETED
@@ -1,18 +0,0 @@
1
- import { curryN } from './curryN.js'
2
- import { map } from './map.js'
3
- import { max } from './max.js'
4
- import { reduce } from './reduce.js'
5
-
6
- export function converge(fn, transformers){
7
- if (arguments.length === 1)
8
- return _transformers => converge(fn, _transformers)
9
-
10
- const highestArity = reduce(
11
- (a, b) => max(a, b.length), 0, transformers
12
- )
13
-
14
- return curryN(highestArity, function (){
15
- return fn.apply(this,
16
- map(g => g.apply(this, arguments), transformers))
17
- })
18
- }
package/src/curry.js DELETED
@@ -1,7 +0,0 @@
1
- export function curry(fn, args = []){
2
- return (..._args) =>
3
- (rest => rest.length >= fn.length ? fn(...rest) : curry(fn, rest))([
4
- ...args,
5
- ..._args,
6
- ])
7
- }
package/src/curryN.js DELETED
@@ -1,40 +0,0 @@
1
- import { _arity } from './_internals/_arity.js'
2
-
3
- function _curryN(
4
- n, cache, fn
5
- ){
6
- return function (){
7
- let ci = 0
8
- let ai = 0
9
- const cl = cache.length
10
- const al = arguments.length
11
- const args = new Array(cl + al)
12
- while (ci < cl){
13
- args[ ci ] = cache[ ci ]
14
- ci++
15
- }
16
- while (ai < al){
17
- args[ cl + ai ] = arguments[ ai ]
18
- ai++
19
- }
20
- const remaining = n - args.length
21
-
22
- return args.length >= n ?
23
- fn.apply(this, args) :
24
- _arity(remaining, _curryN(
25
- n, args, fn
26
- ))
27
- }
28
- }
29
-
30
- export function curryN(n, fn){
31
- if (arguments.length === 1) return _fn => curryN(n, _fn)
32
-
33
- if (n > 10){
34
- throw new Error('First argument to _arity must be a non-negative integer no greater than ten')
35
- }
36
-
37
- return _arity(n, _curryN(
38
- n, [], fn
39
- ))
40
- }
package/src/dec.js DELETED
@@ -1 +0,0 @@
1
- export const dec = x => x - 1
package/src/descend.js DELETED
@@ -1,17 +0,0 @@
1
- import { createCompareFunction } from './ascend.js'
2
-
3
- export function descend(
4
- getFunction, a, b
5
- ){
6
- if (arguments.length === 1){
7
- return (_a, _b) => descend(
8
- getFunction, _a, _b
9
- )
10
- }
11
- const aValue = getFunction(a)
12
- const bValue = getFunction(b)
13
-
14
- return createCompareFunction(
15
- aValue, bValue, 1, -1
16
- )
17
- }
package/src/difference.js DELETED
@@ -1,8 +0,0 @@
1
- import { includes } from './includes.js'
2
- import { uniq } from './uniq.js'
3
-
4
- export function difference(a, b){
5
- if (arguments.length === 1) return _b => difference(a, _b)
6
-
7
- return uniq(a).filter(aInstance => !includes(aInstance, b))
8
- }
@@ -1,20 +0,0 @@
1
- import { curry } from './curry.js'
2
- import { _indexOf } from './equals.js'
3
-
4
- export function differenceWithFn(
5
- fn, a, b
6
- ){
7
- const willReturn = []
8
- const [ first, second ] = a.length >= b.length ? [ a, b ] : [ b, a ]
9
-
10
- first.forEach(item => {
11
- const hasItem = second.some(secondItem => fn(item, secondItem))
12
- if (!hasItem && _indexOf(item, willReturn) === -1){
13
- willReturn.push(item)
14
- }
15
- })
16
-
17
- return willReturn
18
- }
19
-
20
- export const differenceWith = curry(differenceWithFn)
package/src/dissoc.js DELETED
@@ -1,13 +0,0 @@
1
- export function dissoc(prop, obj){
2
- if (arguments.length === 1) return _obj => dissoc(prop, _obj)
3
-
4
- if (obj === null || obj === undefined) return {}
5
-
6
- const willReturn = {}
7
- for (const p in obj){
8
- willReturn[ p ] = obj[ p ]
9
- }
10
- delete willReturn[ prop ]
11
-
12
- return willReturn
13
- }
package/src/dissocPath.js DELETED
@@ -1,47 +0,0 @@
1
- import { createPath } from '../src/_internals/createPath.js'
2
- import { isArray } from './_internals/isArray.js'
3
- import { isIndexInteger } from './_internals/isInteger.js'
4
- import { omit } from './omit.js'
5
- import { path } from './path.js'
6
- import { removeIndex } from './removeIndex.js'
7
- import { update } from './update.js'
8
-
9
- export function dissocPath(pathInput, input){
10
- if (arguments.length === 1) return _obj => dissocPath(pathInput, _obj)
11
-
12
- const pathArrValue = createPath(pathInput)
13
- // this {...input} spread could be done to satisfy ramda specs, but this is done on so many places
14
- // TODO: add warning that Rambda simply returns input if path is empty
15
- if (pathArrValue.length === 0) return input
16
-
17
- const pathResult = path(pathArrValue, input)
18
- if (pathResult === undefined) return input
19
-
20
- const index = pathArrValue[ 0 ]
21
- const condition =
22
- typeof input !== 'object' ||
23
- input === null ||
24
- !input.hasOwnProperty(index)
25
- if (pathArrValue.length > 1){
26
- const nextInput = condition ?
27
- isIndexInteger(pathArrValue[ 1 ]) ?
28
- [] :
29
- {} :
30
- input[ index ]
31
- const nextPathInput = Array.prototype.slice.call(pathArrValue, 1)
32
- const intermediateResult = dissocPath(
33
- nextPathInput, nextInput, input
34
- )
35
- if (isArray(input)) return update(
36
- index, intermediateResult, input
37
- )
38
-
39
- return {
40
- ...input,
41
- [ index ] : intermediateResult,
42
- }
43
- }
44
- if (isArray(input)) return removeIndex(index, input)
45
-
46
- return omit([ index ], input)
47
- }
package/src/divide.js DELETED
@@ -1,5 +0,0 @@
1
- export function divide(a, b){
2
- if (arguments.length === 1) return _b => divide(a, _b)
3
-
4
- return a / b
5
- }
@@ -1,20 +0,0 @@
1
- import { isArray } from './_internals/isArray.js'
2
- import { equals } from './equals.js'
3
-
4
- export function dropRepeats(list){
5
- if (!isArray(list)){
6
- throw new Error(`${ list } is not a list`)
7
- }
8
-
9
- const toReturn = []
10
-
11
- list.reduce((prev, current) => {
12
- if (!equals(prev, current)){
13
- toReturn.push(current)
14
- }
15
-
16
- return current
17
- }, undefined)
18
-
19
- return toReturn
20
- }
@@ -1,21 +0,0 @@
1
- import { equals } from './equals.js'
2
-
3
- export function dropRepeatsBy(fn, list){
4
- if (arguments.length === 1) return _list => dropRepeatsBy(fn, _list)
5
-
6
- let lastEvaluated = null
7
-
8
- return list.slice().filter(item => {
9
- if (lastEvaluated === null){
10
- lastEvaluated = fn(item)
11
-
12
- return true
13
- }
14
- const evaluatedResult = fn(item)
15
- if (equals(lastEvaluated, evaluatedResult)) return false
16
-
17
- lastEvaluated = evaluatedResult
18
-
19
- return true
20
- })
21
- }
@@ -1,28 +0,0 @@
1
- import { isArray } from './_internals/isArray.js'
2
-
3
- export function dropRepeatsWith(predicate, list){
4
- if (arguments.length === 1){
5
- return _iterable => dropRepeatsWith(predicate, _iterable)
6
- }
7
-
8
- if (!isArray(list)){
9
- throw new Error(`${ list } is not a list`)
10
- }
11
-
12
- const toReturn = []
13
-
14
- list.reduce((prev, current) => {
15
- if (prev === undefined){
16
- toReturn.push(current)
17
-
18
- return current
19
- }
20
- if (!predicate(prev, current)){
21
- toReturn.push(current)
22
- }
23
-
24
- return current
25
- }, undefined)
26
-
27
- return toReturn
28
- }
package/src/either.js DELETED
@@ -1,8 +0,0 @@
1
- export function either(firstPredicate, secondPredicate){
2
- if (arguments.length === 1){
3
- return _secondPredicate => either(firstPredicate, _secondPredicate)
4
- }
5
-
6
- return (...input) =>
7
- Boolean(firstPredicate(...input) || secondPredicate(...input))
8
- }
package/src/empty.js DELETED
@@ -1,15 +0,0 @@
1
- import { type } from './type.js'
2
-
3
- export function empty(list){
4
- if (typeof list === 'string') return ''
5
-
6
- if (Array.isArray(list)){
7
- const { name } = list.constructor
8
- if (name === 'Uint8Array') return Uint8Array.from('')
9
-
10
- if (name === 'Float32Array') return new Float32Array([])
11
-
12
- return []
13
- }
14
- if (type(list) === 'Object') return {}
15
- }