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/findIndex.js CHANGED
@@ -1,14 +1,14 @@
1
- export function findIndex(predicate, list){
2
- if (arguments.length === 1) return _list => findIndex(predicate, _list)
3
-
1
+ export function findIndex(predicate) {
2
+ return list => {
4
3
  const len = list.length
5
4
  let index = -1
6
5
 
7
- while (++index < len){
8
- if (predicate(list[ index ])){
6
+ while (++index < len) {
7
+ if (predicate(list[index])) {
9
8
  return index
10
9
  }
11
10
  }
12
11
 
13
12
  return -1
14
13
  }
14
+ }
package/src/findLast.js CHANGED
@@ -1,13 +1,13 @@
1
- export function findLast(predicate, list){
2
- if (arguments.length === 1) return _list => findLast(predicate, _list)
3
-
1
+ export function findLast(predicate) {
2
+ return list => {
4
3
  let index = list.length
5
4
 
6
- while (--index >= 0){
7
- if (predicate(list[ index ])){
8
- return list[ index ]
5
+ while (--index >= 0) {
6
+ if (predicate(list[index])) {
7
+ return list[index]
9
8
  }
10
9
  }
11
10
 
12
11
  return undefined
13
12
  }
13
+ }
@@ -1,13 +1,13 @@
1
- export function findLastIndex(fn, list){
2
- if (arguments.length === 1) return _list => findLastIndex(fn, _list)
3
-
1
+ export function findLastIndex(fn) {
2
+ return list => {
4
3
  let index = list.length
5
4
 
6
- while (--index >= 0){
7
- if (fn(list[ index ])){
5
+ while (--index >= 0) {
6
+ if (fn(list[index])) {
8
7
  return index
9
8
  }
10
9
  }
11
10
 
12
11
  return -1
13
12
  }
13
+ }
package/src/flatMap.js ADDED
@@ -0,0 +1,3 @@
1
+ export function flatMap(fn) {
2
+ return list => [].concat(...list.map(fn))
3
+ }
package/src/flatten.js CHANGED
@@ -1,13 +1,13 @@
1
1
  import { isArray } from './_internals/isArray.js'
2
2
 
3
- export function flatten(list, input){
3
+ export function flatten(list, input) {
4
4
  const willReturn = input === undefined ? [] : input
5
5
 
6
- for (let i = 0; i < list.length; i++){
7
- if (isArray(list[ i ])){
8
- flatten(list[ i ], willReturn)
6
+ for (let i = 0; i < list.length; i++) {
7
+ if (isArray(list[i])) {
8
+ flatten(list[i], willReturn)
9
9
  } else {
10
- willReturn.push(list[ i ])
10
+ willReturn.push(list[i])
11
11
  }
12
12
  }
13
13
 
package/src/groupBy.js CHANGED
@@ -1,16 +1,18 @@
1
- export function groupBy(groupFn, list){
2
- if (arguments.length === 1) return _list => groupBy(groupFn, _list)
1
+ export function groupBy(groupFn, list) {
2
+ if (arguments.length === 1) {
3
+ return _list => groupBy(groupFn, _list)
4
+ }
3
5
 
4
6
  const result = {}
5
- for (let i = 0; i < list.length; i++){
6
- const item = list[ i ]
7
+ for (let i = 0; i < list.length; i++) {
8
+ const item = list[i]
7
9
  const key = groupFn(item)
8
10
 
9
- if (!result[ key ]){
10
- result[ key ] = []
11
+ if (!result[key]) {
12
+ result[key] = []
11
13
  }
12
14
 
13
- result[ key ].push(item)
15
+ result[key].push(item)
14
16
  }
15
17
 
16
18
  return result
package/src/head.js CHANGED
@@ -1,5 +1,7 @@
1
- export function head(listOrString){
2
- if (typeof listOrString === 'string') return listOrString[ 0 ] || ''
1
+ export function head(listOrString) {
2
+ if (typeof listOrString === 'string') {
3
+ return listOrString[0] || ''
4
+ }
3
5
 
4
- return listOrString[ 0 ]
6
+ return listOrString[0]
5
7
  }
package/src/includes.js CHANGED
@@ -1,16 +1,19 @@
1
1
  import { isArray } from './_internals/isArray.js'
2
2
  import { _indexOf } from './equals.js'
3
3
 
4
- export function includes(valueToFind, iterable){
5
- if (arguments.length === 1)
6
- return _iterable => includes(valueToFind, _iterable)
7
- if (typeof iterable === 'string'){
4
+ export function includes(valueToFind) {
5
+ return iterable =>
6
+ {
7
+ if (typeof iterable === 'string') {
8
8
  return iterable.includes(valueToFind)
9
9
  }
10
- if (!iterable){
11
- throw new TypeError(`Cannot read property \'indexOf\' of ${ iterable }`)
10
+ if (!iterable) {
11
+ throw new TypeError(`Cannot read property \'indexOf\' of ${iterable}`)
12
+ }
13
+ if (!isArray(iterable)) {
14
+ return false
12
15
  }
13
- if (!isArray(iterable)) return false
14
16
 
15
17
  return _indexOf(valueToFind, iterable) > -1
16
18
  }
19
+ }
package/src/indexOf.js CHANGED
@@ -1,9 +1,5 @@
1
1
  import { _indexOf } from './equals.js'
2
2
 
3
- export function indexOf(valueToFind, list){
4
- if (arguments.length === 1){
5
- return _list => _indexOf(valueToFind, _list)
6
- }
7
-
8
- return _indexOf(valueToFind, list)
3
+ export function indexOf(valueToFind) {
4
+ return list => _indexOf(valueToFind, list)
9
5
  }
package/src/init.js CHANGED
@@ -1,11 +1,9 @@
1
- import baseSlice from './_internals/baseSlice.js'
1
+ import { baseSlice } from './_internals/baseSlice.js'
2
2
 
3
- export function init(listOrString){
4
- if (typeof listOrString === 'string') return listOrString.slice(0, -1)
3
+ export function init(input) {
4
+ if (typeof input === 'string') {
5
+ return input.slice(0, -1)
6
+ }
5
7
 
6
- return listOrString.length ?
7
- baseSlice(
8
- listOrString, 0, -1
9
- ) :
10
- []
8
+ return input.length ? baseSlice(input, 0, -1) : []
11
9
  }
package/src/innerJoin.js CHANGED
@@ -1,28 +1,26 @@
1
- import { curry } from './curry.js'
2
-
3
- function _includesWith(
4
- pred, x, list
5
- ){
1
+ function _includesWith(pred, x, list) {
6
2
  let idx = 0
7
3
  const len = list.length
8
4
 
9
- while (idx < len){
10
- if (pred(x, list[ idx ]))
5
+ while (idx < len) {
6
+ if (pred(x, list[idx])) {
11
7
  return true
8
+ }
12
9
 
13
10
  idx += 1
14
11
  }
15
12
 
16
13
  return false
17
14
  }
18
- function _filter(fn, list){
15
+ function _filter(fn, list) {
19
16
  let idx = 0
20
17
  const len = list.length
21
18
  const result = []
22
19
 
23
- while (idx < len){
24
- if (fn(list[ idx ]))
25
- result[ result.length ] = list[ idx ]
20
+ while (idx < len) {
21
+ if (fn(list[idx])) {
22
+ result[result.length] = list[idx]
23
+ }
26
24
 
27
25
  idx += 1
28
26
  }
@@ -30,12 +28,6 @@ function _filter(fn, list){
30
28
  return result
31
29
  }
32
30
 
33
- export function innerJoinFn(
34
- pred, xs, ys
35
- ){
36
- return _filter(x => _includesWith(
37
- pred, x, ys
38
- ), xs)
31
+ export function innerJoin(pred, xs) {
32
+ return ys => _filter(x => _includesWith(pred, x, ys), xs)
39
33
  }
40
-
41
- export const innerJoin = curry(innerJoinFn)
@@ -1,8 +1,6 @@
1
1
  import { filter } from './filter.js'
2
2
  import { includes } from './includes.js'
3
3
 
4
- export function intersection(listA, listB){
5
- if (arguments.length === 1) return _list => intersection(listA, _list)
6
-
7
- return filter(x => includes(x, listA), listB)
4
+ export function intersection(listA) {
5
+ return listB =>filter(x => includes(x)(listA))(listB)
8
6
  }
@@ -1,17 +1,17 @@
1
- export function intersperse(separator, list){
2
- if (arguments.length === 1) return _list => intersperse(separator, _list)
3
-
1
+ export function intersperse(separator) {
2
+ return list => {
4
3
  let index = -1
5
4
  const len = list.length
6
5
  const willReturn = []
7
6
 
8
- while (++index < len){
9
- if (index === len - 1){
10
- willReturn.push(list[ index ])
7
+ while (++index < len) {
8
+ if (index === len - 1) {
9
+ willReturn.push(list[index])
11
10
  } else {
12
- willReturn.push(list[ index ], separator)
11
+ willReturn.push(list[index], separator)
13
12
  }
14
13
  }
15
14
 
16
15
  return willReturn
17
16
  }
17
+ }
package/src/join.js CHANGED
@@ -1,5 +1,3 @@
1
- export function join(glue, list){
2
- if (arguments.length === 1) return _list => join(glue, _list)
3
-
4
- return list.join(glue)
1
+ export function join(glue) {
2
+ return list=> list.join(glue)
5
3
  }
package/src/last.js CHANGED
@@ -1,7 +1,7 @@
1
- export function last(listOrString){
2
- if (typeof listOrString === 'string'){
3
- return listOrString[ listOrString.length - 1 ] || ''
1
+ export function last(listOrString) {
2
+ if (typeof listOrString === 'string') {
3
+ return listOrString[listOrString.length - 1] || ''
4
4
  }
5
5
 
6
- return listOrString[ listOrString.length - 1 ]
6
+ return listOrString[listOrString.length - 1]
7
7
  }
@@ -1,9 +1,5 @@
1
1
  import { _lastIndexOf } from './equals.js'
2
2
 
3
- export function lastIndexOf(valueToFind, list){
4
- if (arguments.length === 1){
5
- return _list => _lastIndexOf(valueToFind, _list)
6
- }
7
-
8
- return _lastIndexOf(valueToFind, list)
3
+ export function lastIndexOf(valueToFind) {
4
+ return list => _lastIndexOf(valueToFind, list)
9
5
  }
package/src/map.js CHANGED
@@ -1,51 +1,11 @@
1
- import { INCORRECT_ITERABLE_INPUT } from './_internals/constants.js'
2
- import { isArray } from './_internals/isArray.js'
3
- import { keys } from './_internals/keys.js'
4
-
5
- export function mapArray(
6
- fn, list, isIndexed = false
7
- ){
8
- let index = 0
9
- const willReturn = Array(list.length)
10
-
11
- while (index < list.length){
12
- willReturn[ index ] = isIndexed ? fn(list[ index ], index) : fn(list[ index ])
13
-
14
- index++
1
+ export function map(fn) {
2
+ return list => {
3
+ let index = 0
4
+ const willReturn = Array(list.length)
5
+ while (index < list.length) {
6
+ willReturn[index] = fn(list[index], index)
7
+ index++
8
+ }
9
+ return willReturn
15
10
  }
16
-
17
- return willReturn
18
- }
19
-
20
- export function mapObject(fn, obj){
21
- if (arguments.length === 1){
22
- return _obj => mapObject(fn, _obj)
23
- }
24
- let index = 0
25
- const objKeys = keys(obj)
26
- const len = objKeys.length
27
- const willReturn = {}
28
-
29
- while (index < len){
30
- const key = objKeys[ index ]
31
- willReturn[ key ] = fn(
32
- obj[ key ], key, obj
33
- )
34
- index++
35
- }
36
-
37
- return willReturn
38
- }
39
-
40
- export const mapObjIndexed = mapObject
41
-
42
- export function map(fn, iterable){
43
- if (arguments.length === 1) return _iterable => map(fn, _iterable)
44
- if (!iterable){
45
- throw new Error(INCORRECT_ITERABLE_INPUT)
46
- }
47
-
48
- if (isArray(iterable)) return mapArray(fn, iterable)
49
-
50
- return mapObject(fn, iterable)
51
11
  }
@@ -0,0 +1,11 @@
1
+ export function mapAsync(fn) {
2
+ return async list => {
3
+ const willReturn = []
4
+ let i = 0
5
+ for (const a of list) {
6
+ willReturn.push(await fn(a, i++))
7
+ }
8
+
9
+ return willReturn
10
+ }
11
+ }
@@ -0,0 +1,18 @@
1
+ import { keys } from './_internals/keys.js'
2
+
3
+ export function mapObject(fn) {
4
+ return obj => {
5
+ let index = 0
6
+ const objKeys = keys(obj)
7
+ const len = objKeys.length
8
+ const willReturn = {}
9
+
10
+ while (index < len) {
11
+ const key = objKeys[index]
12
+ willReturn[key] = fn(obj[key], key, obj)
13
+ index++
14
+ }
15
+
16
+ return willReturn
17
+ }
18
+ }
@@ -0,0 +1,10 @@
1
+ export function mapObjectAsync(fn) {
2
+ return async obj => {
3
+ const willReturn = {}
4
+ for (const prop in obj){
5
+ willReturn[ prop ] = await fn(obj[ prop ], prop)
6
+ }
7
+
8
+ return willReturn
9
+ }
10
+ }
package/src/match.js CHANGED
@@ -1,7 +1,7 @@
1
- export function match(pattern, input){
2
- if (arguments.length === 1) return _input => match(pattern, _input)
3
-
4
- const willReturn = input.match(pattern)
5
-
6
- return willReturn === null ? [] : willReturn
1
+ export function match(pattern) {
2
+ return input => {
3
+ const willReturn = input.match(pattern)
4
+
5
+ return willReturn === null ? [] : willReturn
6
+ }
7
7
  }
package/src/maxBy.js CHANGED
@@ -1,9 +1,3 @@
1
- import { curry } from './curry.js'
2
-
3
- export function maxByFn(
4
- compareFn, x, y
5
- ){
6
- return compareFn(y) > compareFn(x) ? y : x
1
+ export function maxBy(compareFn, x) {
2
+ return y => (compareFn(y) > compareFn(x) ? y : x)
7
3
  }
8
-
9
- export const maxBy = curry(maxByFn)
package/src/merge.js CHANGED
@@ -1 +1,4 @@
1
- export { mergeRight as merge } from './mergeRight.js'
1
+ export function merge(target) {
2
+ return objectWithNewProps =>
3
+ Object.assign({}, target || {}, objectWithNewProps || {})
4
+ }
@@ -0,0 +1,3 @@
1
+ export function mergeTypes(x) {
2
+ return x
3
+ }
package/src/minBy.js CHANGED
@@ -1,9 +1,3 @@
1
- import { curry } from './curry.js'
2
-
3
- export function minByFn(
4
- compareFn, x, y
5
- ){
6
- return compareFn(y) < compareFn(x) ? y : x
1
+ export function minBy(compareFn, x) {
2
+ return y => (compareFn(y) < compareFn(x) ? y : x)
7
3
  }
8
-
9
- export const minBy = curry(minByFn)
package/src/modifyPath.js CHANGED
@@ -1,33 +1,30 @@
1
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
2
  import { path as pathModule } from './path.js'
6
3
 
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 ] ]),
4
+ function assoc(prop, newValue) {
5
+ return obj => Object.assign({}, obj, { [prop]: newValue })
6
+ }
7
+
8
+ function modifyPathFn(pathInput, fn, obj) {
9
+ const path = createPath(pathInput)
10
+ if (path.length === 1) {
11
+ return {
12
+ ...obj,
13
+ [path[0]]: fn(obj[path[0]]),
14
+ }
15
+ }
16
+ if (pathModule(path)(obj) === undefined) {
17
+ return obj
15
18
  }
16
- }
17
- if (pathModule(path, object) === undefined) return object
18
19
 
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
- }
20
+ const val = modifyPathFn(Array.prototype.slice.call(path, 1), fn, obj[path[0]])
21
+ if (val === obj[path[0]]) {
22
+ return obj
23
+ }
27
24
 
28
- return assoc(
29
- path[ 0 ], val, object
30
- )
25
+ return assoc(path[0], val)(obj)
31
26
  }
32
27
 
33
- export const modifyPath = curry(modifyPathFn)
28
+ export function modifyPath(pathInput, fn) {
29
+ return obj => modifyPathFn(pathInput, fn, obj)
30
+ }
package/src/none.js CHANGED
@@ -1,9 +1,11 @@
1
- export function none(predicate, list){
2
- if (arguments.length === 1) return _list => none(predicate, _list)
1
+ export function none(predicate) {
2
+ return list => {
3
+ for (let i = 0; i < list.length; i++) {
4
+ if (predicate(list[i])) {
5
+ return false
6
+ }
7
+ }
3
8
 
4
- for (let i = 0; i < list.length; i++){
5
- if (predicate(list[ i ])) return false
9
+ return true
6
10
  }
7
-
8
- return true
9
11
  }
package/src/objOf.js CHANGED
@@ -1,7 +1,3 @@
1
- export function objOf(key, value){
2
- if (arguments.length === 1){
3
- return _value => objOf(key, _value)
4
- }
5
-
6
- return { [ key ] : value }
1
+ export function objOf(key) {
2
+ return value => ({ [key]: value })
7
3
  }
package/src/omit.js CHANGED
@@ -1,18 +1,33 @@
1
1
  import { createPath } from './_internals/createPath.js'
2
- import { includes } from './_internals/includes.js'
3
2
 
4
- export function omit(propsToOmit, obj){
5
- if (arguments.length === 1) return _obj => omit(propsToOmit, _obj)
3
+ export function _includes(x, list) {
4
+ let index = -1
5
+ const { length } = list
6
6
 
7
- if (obj === null || obj === undefined)
8
- return undefined
7
+ while (++index < length) {
8
+ if (String(list[index]) === String(x)) {
9
+ return true
10
+ }
11
+ }
9
12
 
10
- const propsToOmitValue = createPath(propsToOmit, ',')
11
- const willReturn = {}
13
+ return false
14
+ }
15
+
16
+ export function omit(propsToOmit) {
17
+ return obj => {
18
+ if (!obj) {
19
+ return undefined
20
+ }
21
+
22
+ const propsToOmitValue = createPath(propsToOmit, ',')
23
+ const willReturn = {}
12
24
 
13
- for (const key in obj)
14
- if (!includes(key, propsToOmitValue))
15
- willReturn[ key ] = obj[ key ]
25
+ for (const key in obj) {
26
+ if (!_includes(key, propsToOmitValue)) {
27
+ willReturn[key] = obj[key]
28
+ }
29
+ }
16
30
 
17
- return willReturn
31
+ return willReturn
32
+ }
18
33
  }
package/src/partition.js CHANGED
@@ -1,44 +1,41 @@
1
1
  import { isArray } from './_internals/isArray.js'
2
2
 
3
- export function partitionObject(predicate, iterable){
3
+ export function partitionObject(predicate, iterable) {
4
4
  const yes = {}
5
5
  const no = {}
6
- Object.entries(iterable).forEach(([ prop, value ]) => {
7
- if (predicate(value, prop)){
8
- yes[ prop ] = value
6
+ Object.entries(iterable).forEach(([prop, value]) => {
7
+ if (predicate(value, prop)) {
8
+ yes[prop] = value
9
9
  } else {
10
- no[ prop ] = value
10
+ no[prop] = value
11
11
  }
12
12
  })
13
13
 
14
- return [ yes, no ]
14
+ return [yes, no]
15
15
  }
16
16
 
17
- export function partitionArray(
18
- predicate, list, indexed = false
19
- ){
17
+ export function partitionArray(predicate, list, indexed = false) {
20
18
  const yes = []
21
19
  const no = []
22
20
  let counter = -1
23
21
 
24
- while (counter++ < list.length - 1){
25
- if (
26
- indexed ? predicate(list[ counter ], counter) : predicate(list[ counter ])
27
- ){
28
- yes.push(list[ counter ])
22
+ while (counter++ < list.length - 1) {
23
+ if (indexed ? predicate(list[counter], counter) : predicate(list[counter])) {
24
+ yes.push(list[counter])
29
25
  } else {
30
- no.push(list[ counter ])
26
+ no.push(list[counter])
31
27
  }
32
28
  }
33
29
 
34
- return [ yes, no ]
30
+ return [yes, no]
35
31
  }
36
32
 
37
- export function partition(predicate, iterable){
38
- if (arguments.length === 1){
39
- return listHolder => partition(predicate, listHolder)
40
- }
41
- if (!isArray(iterable)) return partitionObject(predicate, iterable)
42
-
43
- return partitionArray(predicate, iterable)
33
+ export function partition(predicate) {
34
+ return iterable => {
35
+ if (!isArray(iterable)) {
36
+ return partitionObject(predicate, iterable)
37
+ }
38
+
39
+ return partitionArray(predicate, iterable)
40
+ }
44
41
  }