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/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/modifyPath.js DELETED
@@ -1,33 +0,0 @@
1
- import { createPath } from './_internals/createPath.js'
2
- import { isArray } from './_internals/isArray.js'
3
- import { assoc } from './assoc.js'
4
- import { curry } from './curry.js'
5
- import { path as pathModule } from './path.js'
6
-
7
- export function modifyPathFn(
8
- pathInput, fn, object
9
- ){
10
- const path = createPath(pathInput)
11
- if (path.length === 1){
12
- return {
13
- ...object,
14
- [ path[ 0 ] ] : fn(object[ path[ 0 ] ]),
15
- }
16
- }
17
- if (pathModule(path, object) === undefined) return object
18
-
19
- const val = modifyPath(
20
- Array.prototype.slice.call(path, 1),
21
- fn,
22
- object[ path[ 0 ] ]
23
- )
24
- if (val === object[ path[ 0 ] ]){
25
- return object
26
- }
27
-
28
- return assoc(
29
- path[ 0 ], val, object
30
- )
31
- }
32
-
33
- export const modifyPath = curry(modifyPathFn)
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
- }
package/src/once.js DELETED
@@ -1,24 +0,0 @@
1
- import { curry } from './curry.js'
2
-
3
- function onceFn(fn, context){
4
- let result
5
-
6
- return function (){
7
- if (fn){
8
- result = fn.apply(context || this, arguments)
9
- fn = null
10
- }
11
-
12
- return result
13
- }
14
- }
15
-
16
- export function once(fn, context){
17
- if (arguments.length === 1){
18
- const wrap = onceFn(fn, context)
19
-
20
- return curry(wrap)
21
- }
22
-
23
- return onceFn(fn, context)
24
- }
package/src/or.js DELETED
@@ -1,5 +0,0 @@
1
- export function or(a, b){
2
- if (arguments.length === 1) return _b => or(a, _b)
3
-
4
- return a || b
5
- }
package/src/over.js DELETED
@@ -1,14 +0,0 @@
1
- import { curry } from './curry.js'
2
-
3
- const Identity = x => ({
4
- x,
5
- map : fn => Identity(fn(x)),
6
- })
7
-
8
- function overFn(
9
- lens, fn, object
10
- ){
11
- return lens(x => Identity(fn(x)))(object).x
12
- }
13
-
14
- export const over = curry(overFn)
package/src/partial.js DELETED
@@ -1,17 +0,0 @@
1
- import { isArray } from './_internals/isArray.js'
2
-
3
- export function partial(fn, ...args){
4
- const len = fn.length
5
-
6
- // If a single array argument is given, those are the args (a la Ramda).
7
- // Otherwise, the variadic arguments are the args.
8
- const argList = args.length === 1 && isArray(args[0]) ? args[0] : args
9
-
10
- return (...rest) => {
11
- if (argList.length + rest.length >= len){
12
- return fn(...argList, ...rest)
13
- }
14
-
15
- return partial(fn, ...[ ...argList, ...rest ])
16
- }
17
- }
@@ -1,5 +0,0 @@
1
- import { mergeDeepRight } from './mergeDeepRight.js'
2
-
3
- export function partialObject(fn, input){
4
- return nextInput => fn(mergeDeepRight(nextInput, input))
5
- }
package/src/pathEq.js DELETED
@@ -1,11 +0,0 @@
1
- import { curry } from './curry.js'
2
- import { equals } from './equals.js'
3
- import { path } from './path.js'
4
-
5
- function pathEqFn(
6
- pathToSearch, target, input
7
- ){
8
- return equals(path(pathToSearch, input), target)
9
- }
10
-
11
- export const pathEq = curry(pathEqFn)
package/src/pathOr.js DELETED
@@ -1,11 +0,0 @@
1
- import { curry } from './curry.js'
2
- import { defaultTo } from './defaultTo.js'
3
- import { path } from './path.js'
4
-
5
- function pathOrFn(
6
- defaultValue, pathInput, obj
7
- ){
8
- return defaultTo(defaultValue, path(pathInput, obj))
9
- }
10
-
11
- export const pathOr = curry(pathOrFn)
@@ -1,9 +0,0 @@
1
- import { path } from "./path.js";
2
- import { curry } from "./curry.js";
3
-
4
- export function pathSatisfiesFn(fn, pathInput, obj) {
5
- if(pathInput.length === 0) throw new Error("R.pathSatisfies received an empty path")
6
- return Boolean(fn(path(pathInput, obj)))
7
- }
8
-
9
- export const pathSatisfies = curry(pathSatisfiesFn)
package/src/paths.js DELETED
@@ -1,9 +0,0 @@
1
- import { path } from './path.js'
2
-
3
- export function paths(pathsToSearch, obj){
4
- if (arguments.length === 1){
5
- return _obj => paths(pathsToSearch, _obj)
6
- }
7
-
8
- return pathsToSearch.map(singlePath => path(singlePath, obj))
9
- }
package/src/pickAll.js DELETED
@@ -1,23 +0,0 @@
1
- import { createPath } from './_internals/createPath.js'
2
-
3
- export function pickAll(propsToPick, obj){
4
- if (arguments.length === 1) return _obj => pickAll(propsToPick, _obj)
5
-
6
- if (obj === null || obj === undefined){
7
- return undefined
8
- }
9
- const keysValue = createPath(propsToPick, ',')
10
- const willReturn = {}
11
- let counter = 0
12
-
13
- while (counter < keysValue.length){
14
- if (keysValue[ counter ] in obj){
15
- willReturn[ keysValue[ counter ] ] = obj[ keysValue[ counter ] ]
16
- } else {
17
- willReturn[ keysValue[ counter ] ] = undefined
18
- }
19
- counter++
20
- }
21
-
22
- return willReturn
23
- }
package/src/pickBy.js DELETED
@@ -1,11 +0,0 @@
1
- export function pickBy(predicate, obj) {
2
- if (arguments.length === 1){
3
- return (_obj) => pickBy(predicate, _obj);
4
- }
5
- return Object.keys(obj).reduce((accum, key) => {
6
- if (predicate(obj[ key ], key, obj)){
7
- accum[ key ] = obj[ key ];
8
- }
9
- return accum;
10
- }, {});
11
- }
package/src/product.js DELETED
@@ -1,4 +0,0 @@
1
- import { multiply } from './multiply.js'
2
- import { reduce } from './reduce.js'
3
-
4
- export const product = reduce(multiply, 1)
package/src/propIs.js DELETED
@@ -1,10 +0,0 @@
1
- import { curry } from './curry.js'
2
- import { is } from './is.js'
3
-
4
- function propIsFn(
5
- targetPrototype, property, obj
6
- ){
7
- return is(targetPrototype, obj[ property ])
8
- }
9
-
10
- export const propIs = curry(propIsFn)
package/src/props.js DELETED
@@ -1,13 +0,0 @@
1
- import { isArray } from './_internals/isArray.js'
2
- import { mapArray } from './map.js'
3
-
4
- export function props(propsToPick, obj){
5
- if (arguments.length === 1){
6
- return _obj => props(propsToPick, _obj)
7
- }
8
- if (!isArray(propsToPick)){
9
- throw new Error('propsToPick is not a list')
10
- }
11
-
12
- return mapArray(prop => obj[ prop ], propsToPick)
13
- }
package/src/reduceBy.js DELETED
@@ -1,29 +0,0 @@
1
- import { clone } from './clone.js'
2
- import { curry } from './curry.js'
3
- import { has } from './has.js'
4
- import { reduce } from './reduce.js'
5
-
6
- function reduceByFunction(
7
- valueFn, valueAcc, keyFn, acc, elt
8
- ){
9
- const key = keyFn(elt)
10
- const value = valueFn(has(key, acc) ? acc[ key ] : clone(valueAcc), elt)
11
-
12
- acc[ key ] = value
13
-
14
- return acc
15
- }
16
-
17
- export function reduceByFn(
18
- valueFn, valueAcc, keyFn, list
19
- ){
20
- return reduce(
21
- (acc, elt) => reduceByFunction(
22
- valueFn, valueAcc, keyFn, acc, elt
23
- ),
24
- {},
25
- list
26
- )
27
- }
28
-
29
- export const reduceBy = curry(reduceByFn)
@@ -1,7 +0,0 @@
1
- export function removeIndex(index, list){
2
- if (arguments.length === 1) return _list => removeIndex(index, _list)
3
- if (index <= 0) return list.slice(1)
4
- if (index >= list.length - 1) return list.slice(0, list.length - 1)
5
-
6
- return [ ...list.slice(0, index), ...list.slice(index + 1) ]
7
- }
package/src/repeat.js DELETED
@@ -1,7 +0,0 @@
1
- export function repeat(x, timesToRepeat){
2
- if (arguments.length === 1){
3
- return _timesToRepeat => repeat(x, _timesToRepeat)
4
- }
5
-
6
- return Array(timesToRepeat).fill(x)
7
- }
package/src/reverse.js DELETED
@@ -1,9 +0,0 @@
1
- export function reverse(listOrString) {
2
- if (typeof listOrString === 'string') {
3
- return listOrString.split('').reverse().join('')
4
- }
5
-
6
- const clone = listOrString.slice()
7
-
8
- return clone.reverse()
9
- }
package/src/set.js DELETED
@@ -1,9 +0,0 @@
1
- import {always} from './always.js'
2
- import {curry} from './curry.js'
3
- import {over} from './over.js'
4
-
5
- function setFn(lens, replacer, x) {
6
- return over(lens, always(replacer), x)
7
- }
8
-
9
- export const set = curry(setFn)
package/src/slice.js DELETED
@@ -1,9 +0,0 @@
1
- import { curry } from './curry.js'
2
-
3
- function sliceFn(
4
- from, to, list
5
- ){
6
- return list.slice(from, to)
7
- }
8
-
9
- export const slice = curry(sliceFn)
package/src/splitAt.js DELETED
@@ -1,21 +0,0 @@
1
- import { isArray } from './_internals/isArray.js'
2
- import { drop } from './drop.js'
3
- import { maybe } from './maybe.js'
4
- import { take } from './take.js'
5
-
6
- export function splitAt(index, input){
7
- if (arguments.length === 1){
8
- return _list => splitAt(index, _list)
9
- }
10
- if (!input) throw new TypeError(`Cannot read property 'slice' of ${ input }`)
11
-
12
- if (!isArray(input) && typeof input !== 'string') return [ [], [] ]
13
-
14
- const correctIndex = maybe(
15
- index < 0,
16
- input.length + index < 0 ? 0 : input.length + index,
17
- index
18
- )
19
-
20
- return [ take(correctIndex, input), drop(correctIndex, input) ]
21
- }