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/evolve.js CHANGED
@@ -1,60 +1,6 @@
1
- import { isArray } from './_internals/isArray.js'
2
- import { mapArray, mapObject } from './map.js'
1
+ import { mapObject } from './mapObject.js'
3
2
  import { type } from './type.js'
4
3
 
5
- export function evolveArray(rules, list){
6
- return mapArray(
7
- (x, i) => {
8
- if (type(rules[ i ]) === 'Function'){
9
- return rules[ i ](x)
10
- }
11
-
12
- return x
13
- },
14
- list,
15
- true
16
- )
17
- }
18
-
19
- export function evolveObject(rules, iterable){
20
- return mapObject((x, prop) => {
21
- if (type(x) === 'Object'){
22
- const typeRule = type(rules[ prop ])
23
- if (typeRule === 'Function'){
24
- return rules[ prop ](x)
25
- }
26
- if (typeRule === 'Object'){
27
- return evolve(rules[ prop ], x)
28
- }
29
-
30
- return x
31
- }
32
- if (type(rules[ prop ]) === 'Function'){
33
- return rules[ prop ](x)
34
- }
35
-
36
- return x
37
- }, iterable)
38
- }
39
-
40
- export function evolve(rules, iterable){
41
- if (arguments.length === 1){
42
- return _iterable => evolve(rules, _iterable)
43
- }
44
- const rulesType = type(rules)
45
- const iterableType = type(iterable)
46
-
47
- if (iterableType !== rulesType){
48
- throw new Error('iterableType !== rulesType')
49
- }
50
-
51
- if (![ 'Object', 'Array' ].includes(rulesType)){
52
- throw new Error(`'iterable' and 'rules' are from wrong type ${ rulesType }`)
53
- }
54
-
55
- if (iterableType === 'Object'){
56
- return evolveObject(rules, iterable)
57
- }
58
-
59
- return evolveArray(rules, iterable)
4
+ export function evolve(rules) {
5
+ return mapObject((x, prop) => type(rules[prop]) === 'Function' ? rules[prop](x): x)
60
6
  }
@@ -0,0 +1,5 @@
1
+ import { includes } from './includes.js'
2
+
3
+ export function excludes(valueToFind) {
4
+ return iterable => !includes(valueToFind)(iterable)
5
+ }
package/src/filter.js CHANGED
@@ -1,50 +1,20 @@
1
- import { isArray } from './_internals/isArray.js'
2
-
3
- export function filterObject(predicate, obj){
4
- const willReturn = {}
5
-
6
- for (const prop in obj){
7
- if (predicate(
8
- obj[ prop ], prop, obj
9
- )){
10
- willReturn[ prop ] = obj[ prop ]
1
+ export function filter(predicate) {
2
+ return list => {
3
+ if (!list) {
4
+ throw new Error('Incorrect iterable input')
11
5
  }
12
- }
6
+ let index = 0
7
+ const len = list.length
8
+ const willReturn = []
13
9
 
14
- return willReturn
15
- }
16
-
17
- export function filterArray(
18
- predicate, list, indexed = false
19
- ){
20
- let index = 0
21
- const len = list.length
22
- const willReturn = []
10
+ while (index < len) {
11
+ if (predicate(list[index], index)) {
12
+ willReturn.push(list[index])
13
+ }
23
14
 
24
- while (index < len){
25
- const predicateResult = indexed ?
26
- predicate(list[ index ], index) :
27
- predicate(list[ index ])
28
- if (predicateResult){
29
- willReturn.push(list[ index ])
15
+ index++
30
16
  }
31
17
 
32
- index++
18
+ return willReturn
33
19
  }
34
-
35
- return willReturn
36
- }
37
-
38
- export function filter(predicate, iterable){
39
- if (arguments.length === 1)
40
- return _iterable => filter(predicate, _iterable)
41
- if (!iterable){
42
- throw new Error('Incorrect iterable input')
43
- }
44
-
45
- if (isArray(iterable)) return filterArray(
46
- predicate, iterable, false
47
- )
48
-
49
- return filterObject(predicate, iterable)
50
20
  }
@@ -0,0 +1,13 @@
1
+ export function filterObject(predicate) {
2
+ return obj => {
3
+ const willReturn = {}
4
+
5
+ for (const prop in obj) {
6
+ if (predicate(obj[prop], prop, obj)) {
7
+ willReturn[prop] = obj[prop]
8
+ }
9
+ }
10
+
11
+ return willReturn
12
+ }
13
+ }
package/src/find.js CHANGED
@@ -1,15 +1,15 @@
1
- export function find(predicate, list){
2
- if (arguments.length === 1) return _list => find(predicate, _list)
1
+ export function find(predicate) {
2
+ return list => {
3
+ let index = 0
4
+ const len = list.length
3
5
 
4
- let index = 0
5
- const len = list.length
6
+ while (index < len) {
7
+ const x = list[index]
8
+ if (predicate(x)) {
9
+ return x
10
+ }
6
11
 
7
- while (index < len){
8
- const x = list[ index ]
9
- if (predicate(x)){
10
- return x
12
+ index++
11
13
  }
12
-
13
- index++
14
14
  }
15
15
  }
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)
1
+ export function findIndex(predicate) {
2
+ return list => {
3
+ const len = list.length
4
+ let index = -1
3
5
 
4
- const len = list.length
5
- let index = -1
6
-
7
- while (++index < len){
8
- if (predicate(list[ index ])){
9
- return index
6
+ while (++index < len) {
7
+ if (predicate(list[index])) {
8
+ return index
9
+ }
10
10
  }
11
- }
12
11
 
13
- return -1
12
+ return -1
13
+ }
14
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)
1
+ export function findLast(predicate) {
2
+ return list => {
3
+ let index = list.length
3
4
 
4
- let index = list.length
5
-
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]
8
+ }
9
9
  }
10
- }
11
10
 
12
- return undefined
11
+ return undefined
12
+ }
13
13
  }
@@ -1,13 +1,13 @@
1
- export function findLastIndex(fn, list){
2
- if (arguments.length === 1) return _list => findLastIndex(fn, _list)
1
+ export function findLastIndex(fn) {
2
+ return list => {
3
+ let index = list.length
3
4
 
4
- let index = list.length
5
-
6
- while (--index >= 0){
7
- if (fn(list[ index ])){
8
- return index
5
+ while (--index >= 0) {
6
+ if (fn(list[index])) {
7
+ return index
8
+ }
9
9
  }
10
- }
11
10
 
12
- return -1
11
+ return -1
12
+ }
13
13
  }
package/src/findNth.js ADDED
@@ -0,0 +1,16 @@
1
+ export function findNth(predicate, nth) {
2
+ return list => {
3
+ let index = 0
4
+ const len = list.length
5
+
6
+ while (index < len) {
7
+ const x = list[index]
8
+ if (predicate(x)) {
9
+ if (nth === 0) return x
10
+ nth--
11
+ }
12
+
13
+ index++
14
+ }
15
+ }
16
+ }
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,17 +1,20 @@
1
- export function groupBy(groupFn, list){
2
- if (arguments.length === 1) return _list => groupBy(groupFn, _list)
1
+ export function groupByFallback(groupFn, list) {
2
+ const result = {}
3
+ for (let i = 0; i < list.length; i++) {
4
+ const item = list[i]
5
+ const key = groupFn(item)
3
6
 
4
- const result = {}
5
- for (let i = 0; i < list.length; i++){
6
- const item = list[ i ]
7
- const key = groupFn(item)
7
+ if (!result[key]) {
8
+ result[key] = []
9
+ }
8
10
 
9
- if (!result[ key ]){
10
- result[ key ] = []
11
+ result[key].push(item)
11
12
  }
12
13
 
13
- result[ key ].push(item)
14
- }
14
+ return result
15
+ }
16
+
15
17
 
16
- return result
18
+ export function groupBy(groupFn) {
19
+ return iterable => Object.groupBy ? Object.groupBy(iterable,groupFn) : groupByFallback(groupFn, iterable)
17
20
  }
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,18 @@
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'){
8
- return iterable.includes(valueToFind)
9
- }
10
- if (!iterable){
11
- throw new TypeError(`Cannot read property \'indexOf\' of ${ iterable }`)
12
- }
13
- if (!isArray(iterable)) return false
4
+ export function includes(valueToFind) {
5
+ return iterable => {
6
+ if (typeof iterable === 'string') {
7
+ return iterable.includes(valueToFind)
8
+ }
9
+ if (!iterable) {
10
+ throw new TypeError(`Cannot read property \'indexOf\' of ${iterable}`)
11
+ }
12
+ if (!isArray(iterable)) {
13
+ return false
14
+ }
14
15
 
15
- return _indexOf(valueToFind, iterable) > -1
16
+ return _indexOf(valueToFind, iterable) > -1
17
+ }
16
18
  }
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)
@@ -0,0 +1,29 @@
1
+ const getOccurrences = input => input.match(/{{\s*.+?\s*}}/g)
2
+ const getOccurrenceProp = occurrence => occurrence.replace(/{{\s*|\s*}}/g, '')
3
+
4
+ const replace = ({ inputHolder, prop, replacer }) => {
5
+ const regexBase = `{{${prop}}}`
6
+ const regex = new RegExp(regexBase, 'g')
7
+ return inputHolder.replace(regex, replacer)
8
+ }
9
+
10
+ export function interpolate(input) {
11
+ return templateInput => {
12
+ const occurrences = getOccurrences(input)
13
+ if (occurrences === null) {
14
+ return input
15
+ }
16
+ let inputHolder = input
17
+
18
+ for (const occurrence of occurrences) {
19
+ const prop = getOccurrenceProp(occurrence)
20
+ inputHolder = replace({
21
+ inputHolder,
22
+ prop,
23
+ replacer: templateInput[prop],
24
+ })
25
+ }
26
+
27
+ return inputHolder
28
+ }
29
+ }
@@ -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)
1
+ export function intersperse(separator) {
2
+ return list => {
3
+ let index = -1
4
+ const len = list.length
5
+ const willReturn = []
3
6
 
4
- let index = -1
5
- const len = list.length
6
- const willReturn = []
7
-
8
- while (++index < len){
9
- if (index === len - 1){
10
- willReturn.push(list[ index ])
11
- } else {
12
- willReturn.push(list[ index ], separator)
7
+ while (++index < len) {
8
+ if (index === len - 1) {
9
+ willReturn.push(list[index])
10
+ } else {
11
+ willReturn.push(list[index], separator)
12
+ }
13
13
  }
14
- }
15
14
 
16
- return willReturn
15
+ return willReturn
16
+ }
17
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
+ }
package/src/mapKeys.js ADDED
@@ -0,0 +1,11 @@
1
+ export function mapKeys(fn) {
2
+ return obj => {
3
+ const willReturn = {}
4
+
5
+ Object.keys(obj).forEach(key => {
6
+ willReturn[fn(key, obj[key])] = obj[key]
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
+ }