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/endsWith.js DELETED
@@ -1,23 +0,0 @@
1
- import { isArray } from './_internals/isArray.js'
2
- import { equals } from './equals.js'
3
-
4
- export function endsWith(target, iterable){
5
- if (arguments.length === 1) return _iterable => endsWith(target, _iterable)
6
-
7
- if (typeof iterable === 'string'){
8
- return iterable.endsWith(target)
9
- }
10
- if (!isArray(target)) return false
11
-
12
- const diff = iterable.length - target.length
13
- let correct = true
14
- const filtered = target.filter((x, index) => {
15
- if (!correct) return false
16
- const result = equals(x, iterable[ index + diff ])
17
- if (!result) correct = false
18
-
19
- return result
20
- })
21
-
22
- return filtered.length === target.length
23
- }
package/src/flip.js DELETED
@@ -1,23 +0,0 @@
1
- function flipFn(fn){
2
- return (...input) => {
3
- if (input.length === 1){
4
- return holder => fn(holder, input[ 0 ])
5
- } else if (input.length === 2){
6
- return fn(input[ 1 ], input[ 0 ])
7
- } else if (input.length === 3){
8
- return fn(
9
- input[ 1 ], input[ 0 ], input[ 2 ]
10
- )
11
- } else if (input.length === 4){
12
- return fn(
13
- input[ 1 ], input[ 0 ], input[ 2 ], input[ 3 ]
14
- )
15
- }
16
-
17
- throw new Error('R.flip doesn\'t work with arity > 4')
18
- }
19
- }
20
-
21
- export function flip(fn){
22
- return flipFn(fn)
23
- }
package/src/forEach.js DELETED
@@ -1,19 +0,0 @@
1
- import { isArray } from './_internals/isArray.js'
2
- import { forEachObjIndexedFn } from './forEachObjIndexed.js'
3
-
4
- export function forEach(fn, iterable){
5
- if (arguments.length === 1) return _list => forEach(fn, _list)
6
- if (iterable === undefined) return
7
-
8
- if (isArray(iterable)){
9
- let index = 0
10
- const len = iterable.length
11
-
12
- while (index < len){
13
- fn(iterable[ index ])
14
- index++
15
- }
16
- } else return forEachObjIndexedFn(fn, iterable)
17
-
18
- return iterable
19
- }
@@ -1,24 +0,0 @@
1
- import { keys } from './_internals/keys.js'
2
-
3
- export function forEachObjIndexedFn(fn, obj){
4
- let index = 0
5
- const listKeys = keys(obj)
6
- const len = listKeys.length
7
-
8
- while (index < len){
9
- const key = listKeys[ index ]
10
- fn(
11
- obj[ key ], key, obj
12
- )
13
- index++
14
- }
15
-
16
- return obj
17
- }
18
-
19
- export function forEachObjIndexed(fn, list){
20
- if (arguments.length === 1) return _list => forEachObjIndexed(fn, _list)
21
- if (list === undefined) return
22
-
23
- return forEachObjIndexedFn(fn, list)
24
- }
package/src/fromPairs.js DELETED
@@ -1,6 +0,0 @@
1
- export function fromPairs(listOfPairs){
2
- const toReturn = {}
3
- listOfPairs.forEach(([ prop, value ]) => toReturn[ prop ] = value)
4
-
5
- return toReturn
6
- }
package/src/groupWith.js DELETED
@@ -1,46 +0,0 @@
1
- import { cloneList } from './_internals/cloneList.js'
2
- import { isArray } from './_internals/isArray.js'
3
-
4
- export function groupWith(compareFn, list){
5
- if (!isArray(list)) throw new TypeError('list.reduce is not a function')
6
-
7
- const clone = cloneList(list)
8
-
9
- if (list.length === 1) return [ clone ]
10
-
11
- const toReturn = []
12
- let holder = []
13
-
14
- clone.reduce((
15
- prev, current, i
16
- ) => {
17
- if (i === 0) return current
18
-
19
- const okCompare = compareFn(prev, current)
20
- const holderIsEmpty = holder.length === 0
21
- const lastCall = i === list.length - 1
22
-
23
- if (okCompare){
24
- if (holderIsEmpty) holder.push(prev)
25
- holder.push(current)
26
- if (lastCall) toReturn.push(holder)
27
-
28
- return current
29
- }
30
-
31
- if (holderIsEmpty){
32
- toReturn.push([ prev ])
33
- if (lastCall) toReturn.push([ current ])
34
-
35
- return current
36
- }
37
-
38
- toReturn.push(holder)
39
- if (lastCall) toReturn.push([ current ])
40
- holder = []
41
-
42
- return current
43
- }, undefined)
44
-
45
- return toReturn
46
- }
package/src/gt.js DELETED
@@ -1,6 +0,0 @@
1
- export function gt(a, b){
2
- if (arguments.length === 1)
3
- return _b => gt(a, _b)
4
-
5
- return a > b
6
- }
package/src/gte.js DELETED
@@ -1,6 +0,0 @@
1
- export function gte(a, b){
2
- if (arguments.length === 1)
3
- return _b => gte(a, _b)
4
-
5
- return a >= b
6
- }
package/src/has.js DELETED
@@ -1,7 +0,0 @@
1
- export function has(prop, obj){
2
- if (arguments.length === 1) return _obj => has(prop, _obj)
3
-
4
- if (!obj) return false
5
-
6
- return obj.hasOwnProperty(prop)
7
- }
package/src/hasIn.js DELETED
@@ -1,9 +0,0 @@
1
- import { propFn } from './prop.js';
2
-
3
- export function hasIn(searchProperty, obj) {
4
- if (arguments.length === 1) {
5
- return (_obj) => hasIn(searchProperty, _obj);
6
- }
7
-
8
- return propFn(searchProperty, obj) !== undefined;
9
- }
package/src/hasPath.js DELETED
@@ -1,9 +0,0 @@
1
- import { path } from './path.js'
2
-
3
- export function hasPath(pathInput, obj){
4
- if (arguments.length === 1){
5
- return objHolder => hasPath(pathInput, objHolder)
6
- }
7
-
8
- return path(pathInput, obj) !== undefined
9
- }
package/src/identical.js DELETED
@@ -1,7 +0,0 @@
1
- import { objectIs } from './_internals/objectIs.js'
2
-
3
- export function identical(a, b){
4
- if (arguments.length === 1) return _b => identical(a, _b)
5
-
6
- return objectIs(a, b)
7
- }
package/src/identity.js DELETED
@@ -1,3 +0,0 @@
1
- export function identity(x){
2
- return x
3
- }
package/src/ifElse.js DELETED
@@ -1,17 +0,0 @@
1
- import { curry } from './curry.js'
2
-
3
- function ifElseFn(
4
- condition, onTrue, onFalse
5
- ){
6
- return (...input) => {
7
- const conditionResult =
8
- typeof condition === 'boolean' ? condition : condition(...input)
9
- if (Boolean(conditionResult) ){
10
- return onTrue(...input)
11
- }
12
-
13
- return onFalse(...input)
14
- }
15
- }
16
-
17
- export const ifElse = curry(ifElseFn)
package/src/inc.js DELETED
@@ -1 +0,0 @@
1
- export const inc = x => x + 1
package/src/indexBy.js DELETED
@@ -1,29 +0,0 @@
1
- import { path } from './path.js'
2
-
3
- function indexByPath(pathInput, list){
4
- const toReturn = {}
5
- for (let i = 0; i < list.length; i++){
6
- const item = list[ i ]
7
- toReturn[ path(pathInput, item) ] = item
8
- }
9
-
10
- return toReturn
11
- }
12
-
13
- export function indexBy(condition, list){
14
- if (arguments.length === 1){
15
- return _list => indexBy(condition, _list)
16
- }
17
-
18
- if (typeof condition === 'string'){
19
- return indexByPath(condition, list)
20
- }
21
-
22
- const toReturn = {}
23
- for (let i = 0; i < list.length; i++){
24
- const item = list[ i ]
25
- toReturn[ condition(item) ] = item
26
- }
27
-
28
- return toReturn
29
- }
package/src/insert.js DELETED
@@ -1,11 +0,0 @@
1
- import { curry } from './curry.js'
2
-
3
- export function insertFn(indexToInsert, valueToInsert, array) {
4
- return [
5
- ...array.slice(0, indexToInsert),
6
- valueToInsert,
7
- ...array.slice(indexToInsert),
8
- ]
9
- }
10
-
11
- export const insert = curry(insertFn)
package/src/insertAll.js DELETED
@@ -1,7 +0,0 @@
1
- import { curry } from './curry.js';
2
-
3
- export function insertAllFn(index, listToInsert, list) {
4
- return [...list.slice(0, index), ...listToInsert, ...list.slice(index)];
5
- }
6
-
7
- export const insertAll = curry(insertAllFn);
package/src/is.js DELETED
@@ -1,8 +0,0 @@
1
- export function is(targetPrototype, x){
2
- if (arguments.length === 1) return _x => is(targetPrototype, _x)
3
-
4
- return (
5
- x != null && x.constructor === targetPrototype ||
6
- x instanceof targetPrototype
7
- )
8
- }
package/src/isEmpty.js DELETED
@@ -1,18 +0,0 @@
1
- import { type } from './type.js'
2
-
3
- export function isEmpty(input){
4
- const inputType = type(input)
5
- if ([ 'Undefined', 'NaN', 'Number', 'Null' ].includes(inputType))
6
- return false
7
- if (!input) return true
8
-
9
- if (inputType === 'Object'){
10
- return Object.keys(input).length === 0
11
- }
12
-
13
- if (inputType === 'Array'){
14
- return input.length === 0
15
- }
16
-
17
- return false
18
- }
package/src/isNil.js DELETED
@@ -1,3 +0,0 @@
1
- export function isNil(x){
2
- return x === undefined || x === null
3
- }
package/src/isNotEmpty.js DELETED
@@ -1,5 +0,0 @@
1
- import { isEmpty } from './isEmpty.js';
2
-
3
- export function isNotEmpty(input) {
4
- return !isEmpty(input);
5
- }
package/src/isNotNil.js DELETED
@@ -1,3 +0,0 @@
1
- export function isNotNil(input) {
2
- return input != null
3
- }
package/src/isPromise.js DELETED
@@ -1,5 +0,0 @@
1
- import { type } from './type.js'
2
-
3
- export function isPromise(x){
4
- return type(x) === 'Promise'
5
- }
package/src/juxt.js DELETED
@@ -1,3 +0,0 @@
1
- export function juxt(listOfFunctions){
2
- return (...args) => listOfFunctions.map(fn => fn(...args))
3
- }
package/src/keys.js DELETED
@@ -1,3 +0,0 @@
1
- export function keys(x){
2
- return Object.keys(x)
3
- }
package/src/length.js DELETED
@@ -1,8 +0,0 @@
1
- import { isArray } from './_internals/isArray.js'
2
-
3
- export function length(x){
4
- if (isArray(x)) return x.length
5
- if (typeof x === 'string') return x.length
6
-
7
- return NaN
8
- }
package/src/lens.js DELETED
@@ -1,7 +0,0 @@
1
- export function lens(getter, setter){
2
- return function (functor){
3
- return function (target){
4
- return functor(getter(target)).map(focus => setter(focus, target))
5
- }
6
- }
7
- }
package/src/lensIndex.js DELETED
@@ -1,7 +0,0 @@
1
- import { lens } from './lens.js'
2
- import { nth } from './nth.js'
3
- import { update } from './update.js'
4
-
5
- export function lensIndex(index){
6
- return lens(nth(index), update(index))
7
- }
package/src/lensPath.js DELETED
@@ -1,7 +0,0 @@
1
- import { assocPath } from './assocPath.js'
2
- import { lens } from './lens.js'
3
- import { path } from './path.js'
4
-
5
- export function lensPath(key){
6
- return lens(path(key), assocPath(key))
7
- }
package/src/lensProp.js DELETED
@@ -1,7 +0,0 @@
1
- import { assoc } from './assoc.js'
2
- import { lens } from './lens.js'
3
- import { prop } from './prop.js'
4
-
5
- export function lensProp(key){
6
- return lens(prop(key), assoc(key))
7
- }
package/src/lt.js DELETED
@@ -1,6 +0,0 @@
1
- export function lt(a, b){
2
- if (arguments.length === 1)
3
- return _b => lt(a, _b)
4
-
5
- return a < b
6
- }
package/src/lte.js DELETED
@@ -1,6 +0,0 @@
1
- export function lte(a, b){
2
- if (arguments.length === 1)
3
- return _b => lte(a, _b)
4
-
5
- return a <= b
6
- }
package/src/mathMod.js DELETED
@@ -1,8 +0,0 @@
1
- import { isInteger } from './_internals/isInteger.js'
2
-
3
- export function mathMod(x, y){
4
- if (arguments.length === 1) return _y => mathMod(x, _y)
5
- if (!isInteger(x) || !isInteger(y) || y < 1) return NaN
6
-
7
- return (x % y + y) % y
8
- }
package/src/max.js DELETED
@@ -1,5 +0,0 @@
1
- export function max(x, y){
2
- if (arguments.length === 1) return _y => max(x, _y)
3
-
4
- return y > x ? y : x
5
- }
package/src/maybe.js DELETED
@@ -1,13 +0,0 @@
1
- import { type } from './type.js'
2
-
3
- export function maybe(
4
- ifRule, whenIf, whenElse
5
- ){
6
- const whenIfInput =
7
- ifRule && type(whenIf) === 'Function' ? whenIf() : whenIf
8
-
9
- const whenElseInput =
10
- !ifRule && type(whenElse) === 'Function' ? whenElse() : whenElse
11
-
12
- return ifRule ? whenIfInput : whenElseInput
13
- }
package/src/mean.js DELETED
@@ -1,5 +0,0 @@
1
- import { sum } from './sum.js'
2
-
3
- export function mean(list){
4
- return sum(list) / list.length
5
- }
package/src/median.js DELETED
@@ -1,17 +0,0 @@
1
- import { mean } from './mean.js'
2
-
3
- export function median(list){
4
- const len = list.length
5
- if (len === 0) return NaN
6
- const width = 2 - len % 2
7
- const idx = (len - width) / 2
8
-
9
- return mean(Array.prototype.slice
10
- .call(list, 0)
11
- .sort((a, b) => {
12
- if (a === b) return 0
13
-
14
- return a < b ? -1 : 1
15
- })
16
- .slice(idx, idx + width))
17
- }
package/src/mergeAll.js DELETED
@@ -1,11 +0,0 @@
1
- import { map } from './map.js'
2
- import { mergeRight } from './mergeRight.js'
3
-
4
- export function mergeAll(arr){
5
- let willReturn = {}
6
- map(val => {
7
- willReturn = mergeRight(willReturn, val)
8
- }, arr)
9
-
10
- return willReturn
11
- }
@@ -1,5 +0,0 @@
1
- import { mergeDeepRight } from './mergeDeepRight.js';
2
-
3
- export function mergeDeepLeft(newProps, target) {
4
- return mergeDeepRight(target, newProps);
5
- }
@@ -1,24 +0,0 @@
1
- import { clone } from './clone.js'
2
- import { type } from './type.js'
3
-
4
- export function mergeDeepRight(target, source){
5
- if (arguments.length === 1){
6
- return sourceHolder => mergeDeepRight(target, sourceHolder)
7
- }
8
-
9
- const willReturn = clone(target)
10
-
11
- Object.keys(source).forEach(key => {
12
- if (type(source[ key ]) === 'Object'){
13
- if (type(target[ key ]) === 'Object'){
14
- willReturn[ key ] = mergeDeepRight(target[ key ], source[ key ])
15
- } else {
16
- willReturn[ key ] = source[ key ]
17
- }
18
- } else {
19
- willReturn[ key ] = source[ key ]
20
- }
21
- })
22
-
23
- return willReturn
24
- }
package/src/mergeLeft.js DELETED
@@ -1,7 +0,0 @@
1
- import { mergeRight } from './mergeRight.js'
2
-
3
- export function mergeLeft(x, y){
4
- if (arguments.length === 1) return _y => mergeLeft(x, _y)
5
-
6
- return mergeRight(y, x)
7
- }
package/src/mergeRight.js DELETED
@@ -1,8 +0,0 @@
1
- export function mergeRight(target, newProps){
2
- if (arguments.length === 1)
3
- return _newProps => mergeRight(target, _newProps)
4
-
5
- return Object.assign(
6
- {}, target || {}, newProps || {}
7
- )
8
- }
package/src/mergeWith.js DELETED
@@ -1,25 +0,0 @@
1
- import { curry } from './curry.js'
2
-
3
- export function mergeWithFn(
4
- mergeFn, aInput, bInput
5
- ){
6
- const a = aInput ?? {}
7
- const b = bInput ?? {}
8
- const willReturn = {}
9
-
10
- Object.keys(a).forEach(key => {
11
- if (b[ key ] === undefined) willReturn[ key ] = a[ key ]
12
- else willReturn[ key ] = mergeFn(a[ key ], b[ key ])
13
- })
14
-
15
- Object.keys(b).forEach(key => {
16
- if (willReturn[ key ] !== undefined) return
17
-
18
- if (a[ key ] === undefined) willReturn[ key ] = b[ key ]
19
- else willReturn[ key ] = mergeFn(a[ key ], b[ key ])
20
- })
21
-
22
- return willReturn
23
- }
24
-
25
- export const mergeWith = curry(mergeWithFn)
package/src/min.js DELETED
@@ -1,5 +0,0 @@
1
- export function min(x, y){
2
- if (arguments.length === 1) return _y => min(x, _y)
3
-
4
- return y < x ? y : x
5
- }
package/src/modify.js DELETED
@@ -1,23 +0,0 @@
1
- import { isArray } from './_internals/isArray.js'
2
- import { isIterable } from './_internals/isIterable.js'
3
- import { curry } from './curry.js'
4
- import { updateFn } from './update.js'
5
-
6
- function modifyFn(
7
- property, fn, iterable
8
- ){
9
- if (!isIterable(iterable)) return iterable
10
- if (iterable[ property ] === undefined) return iterable
11
- if (isArray(iterable)){
12
- return updateFn(
13
- property, fn(iterable[ property ]), iterable
14
- )
15
- }
16
-
17
- return {
18
- ...iterable,
19
- [ property ] : fn(iterable[ property ]),
20
- }
21
- }
22
-
23
- export const modify = curry(modifyFn)
package/src/modulo.js DELETED
@@ -1,5 +0,0 @@
1
- export function modulo(x, y){
2
- if (arguments.length === 1) return _y => modulo(x, _y)
3
-
4
- return x % y
5
- }
package/src/move.js DELETED
@@ -1,19 +0,0 @@
1
- import { cloneList } from './_internals/cloneList.js'
2
- import { curry } from './curry.js'
3
-
4
- function moveFn(
5
- fromIndex, toIndex, list
6
- ){
7
- if (fromIndex < 0 || toIndex < 0){
8
- throw new Error('Rambda.move does not support negative indexes')
9
- }
10
- if (fromIndex > list.length - 1 || toIndex > list.length - 1) return list
11
-
12
- const clone = cloneList(list)
13
- clone[ fromIndex ] = list[ toIndex ]
14
- clone[ toIndex ] = list[ fromIndex ]
15
-
16
- return clone
17
- }
18
-
19
- export const move = curry(moveFn)
package/src/multiply.js DELETED
@@ -1,5 +0,0 @@
1
- export function multiply(x, y){
2
- if (arguments.length === 1) return _y => multiply(x, _y)
3
-
4
- return x * y
5
- }
package/src/negate.js DELETED
@@ -1,3 +0,0 @@
1
- export function negate(x){
2
- return -x
3
- }
package/src/not.js DELETED
@@ -1,3 +0,0 @@
1
- export function not(input){
2
- return !input
3
- }
package/src/nth.js DELETED
@@ -1,9 +0,0 @@
1
- export function nth(index, input){
2
- if (arguments.length === 1) return _input => nth(index, _input)
3
-
4
- const idx = index < 0 ? input.length + index : index
5
-
6
- return Object.prototype.toString.call(input) === '[object String]' ?
7
- input.charAt(idx) :
8
- input[ idx ]
9
- }
package/src/of.js DELETED
@@ -1,3 +0,0 @@
1
- export function of(value){
2
- return [ value ]
3
- }
package/src/on.js DELETED
@@ -1,16 +0,0 @@
1
- export function on(
2
- binaryFn, unaryFn, a, b
3
- ){
4
- if (arguments.length === 3){
5
- return _b => on(
6
- binaryFn, unaryFn, a, _b
7
- )
8
- }
9
- if (arguments.length === 2){
10
- return (_a, _b) => on(
11
- binaryFn, unaryFn, _a, _b
12
- )
13
- }
14
-
15
- return binaryFn(unaryFn(a), unaryFn(b))
16
- }