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/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/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
- }
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
- }