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/takeWhile.js CHANGED
@@ -1,24 +1,15 @@
1
- import { isArray as isArrayModule } from './_internals/isArray.js'
2
-
3
- export function takeWhile(predicate, iterable){
4
- if (arguments.length === 1){
5
- return _iterable => takeWhile(predicate, _iterable)
6
- }
7
- const isArray = isArrayModule(iterable)
8
- if (!isArray && typeof iterable !== 'string'){
9
- throw new Error('`iterable` is neither list nor a string')
10
- }
11
-
12
- const toReturn = []
13
- let counter = 0
14
-
15
- while (counter < iterable.length){
16
- const item = iterable[ counter++ ]
17
- if (!predicate(item)){
18
- break
1
+ export function takeWhile(predicate) {
2
+ return iterable => {
3
+ const toReturn = []
4
+ let counter = 0
5
+
6
+ while (counter < iterable.length) {
7
+ const item = iterable[counter++]
8
+ if (!predicate(item)) {
9
+ break
10
+ }
11
+ toReturn.push(item)
19
12
  }
20
- toReturn.push(item)
13
+ return toReturn
21
14
  }
22
-
23
- return isArray ? toReturn : toReturn.join('')
24
15
  }
package/src/tap.js CHANGED
@@ -1,7 +1,7 @@
1
- export function tap(fn, x){
2
- if (arguments.length === 1) return _x => tap(fn, _x)
3
-
1
+ export function tap(fn) {
2
+ return x => {
4
3
  fn(x)
5
4
 
6
5
  return x
7
6
  }
7
+ }
package/src/test.js CHANGED
@@ -1,9 +1,3 @@
1
- export function test(pattern, str){
2
- if (arguments.length === 1) return _str => test(pattern, _str)
3
-
4
- if (typeof pattern === 'string'){
5
- throw new TypeError(`R.test requires a value of type RegExp as its first argument; received "${ pattern }"`)
6
- }
7
-
8
- return str.search(pattern) !== -1
1
+ export function test(pattern) {
2
+ return str => str.search(pattern) !== -1
9
3
  }
package/src/tryCatch.js CHANGED
@@ -1,18 +1,9 @@
1
- import { type } from './type.js'
2
-
3
- const isFunction = x => [ 'Promise', 'Function' ].includes(type(x))
4
-
5
- export function tryCatch(fn, fallback){
6
- if (!isFunction(fn)){
7
- throw new Error(`R.tryCatch | fn '${ fn }'`)
8
- }
9
- const passFallback = isFunction(fallback)
10
-
11
- return (...inputs) => {
1
+ export function tryCatch(fn, fallback) {
2
+ return input => {
12
3
  try {
13
- return fn(...inputs)
14
- } catch (e){
15
- return passFallback ? fallback(e, ...inputs) : fallback
4
+ return fn(input)
5
+ } catch (e) {
6
+ return fallback
16
7
  }
17
8
  }
18
9
  }
package/src/type.js CHANGED
@@ -1,12 +1,13 @@
1
- export function type(input){
2
- if (input === null){
1
+ export function type(input) {
2
+ if (input === null) {
3
3
  return 'Null'
4
- } else if (input === undefined){
4
+ }
5
+ if (input === undefined) {
5
6
  return 'Undefined'
6
- } else if (Number.isNaN(input)){
7
+ }
8
+ if (Number.isNaN(input)) {
7
9
  return 'NaN'
8
10
  }
9
11
  const typeResult = Object.prototype.toString.call(input).slice(8, -1)
10
-
11
12
  return typeResult === 'AsyncFunction' ? 'Promise' : typeResult
12
13
  }
package/src/union.js CHANGED
@@ -1,14 +1,16 @@
1
1
  import { cloneList } from './_internals/cloneList.js'
2
2
  import { includes } from './includes.js'
3
3
 
4
- export function union(x, y){
5
- if (arguments.length === 1) return _y => union(x, _y)
4
+ export function union(x) {
5
+ return y => {
6
+ const toReturn = cloneList(x)
6
7
 
7
- const toReturn = cloneList(x)
8
+ y.forEach(yInstance => {
9
+ if (!includes(yInstance)(x)) {
10
+ toReturn.push(yInstance)
11
+ }
12
+ })
8
13
 
9
- y.forEach(yInstance => {
10
- if (!includes(yInstance, x)) toReturn.push(yInstance)
11
- })
12
-
13
- return toReturn
14
+ return toReturn
15
+ }
14
16
  }
package/src/uniq.js CHANGED
@@ -1,10 +1,10 @@
1
1
  import { _Set } from './_internals/set.js'
2
2
 
3
- export function uniq(list){
3
+ export function uniq(list) {
4
4
  const set = new _Set()
5
5
  const willReturn = []
6
6
  list.forEach(item => {
7
- if (set.checkUniqueness(item)){
7
+ if (set.checkUniqueness(item)) {
8
8
  willReturn.push(item)
9
9
  }
10
10
  })
package/src/uniqBy.js CHANGED
@@ -1,10 +1,9 @@
1
1
  import { _Set } from '../src/_internals/set.js'
2
2
 
3
- export function uniqBy(fn, list){
4
- if (arguments.length === 1){
5
- return _list => uniqBy(fn, _list)
6
- }
7
- const set = new _Set()
3
+ export function uniqBy(fn) {
4
+ return list => {
5
+ const set = new _Set()
8
6
 
9
- return list.filter(item => set.checkUniqueness(fn(item)))
7
+ return list.filter(item => set.checkUniqueness(fn(item)))
8
+ }
10
9
  }
package/src/uniqWith.js CHANGED
@@ -1,13 +1,11 @@
1
- function includesWith(
2
- predicate, target, list
3
- ){
1
+ function includesWith(predicate, target, list) {
4
2
  let willReturn = false
5
3
  let index = -1
6
4
 
7
- while (++index < list.length && !willReturn){
8
- const value = list[ index ]
5
+ while (++index < list.length && !willReturn) {
6
+ const value = list[index]
9
7
 
10
- if (predicate(target, value)){
8
+ if (predicate(target, value)) {
11
9
  willReturn = true
12
10
  }
13
11
  }
@@ -15,21 +13,19 @@ function includesWith(
15
13
  return willReturn
16
14
  }
17
15
 
18
- export function uniqWith(predicate, list){
19
- if (arguments.length === 1) return _list => uniqWith(predicate, _list)
20
-
16
+ export function uniqWith(predicate) {
17
+ return list => {
21
18
  let index = -1
22
19
  const willReturn = []
23
20
 
24
- while (++index < list.length){
25
- const value = list[ index ]
21
+ while (++index < list.length) {
22
+ const value = list[index]
26
23
 
27
- if (!includesWith(
28
- predicate, value, willReturn
29
- )){
24
+ if (!includesWith(predicate, value, willReturn)) {
30
25
  willReturn.push(value)
31
26
  }
32
27
  }
33
28
 
34
29
  return willReturn
35
30
  }
31
+ }
package/src/unless.js CHANGED
@@ -1,11 +1,9 @@
1
- import { curry } from './curry.js'
1
+ export function unless(predicate, whenFalseFn) {
2
+ return input => {
3
+ if (predicate(input)) {
4
+ return input
5
+ }
2
6
 
3
- function unlessFn(
4
- predicate, whenFalseFn, input
5
- ){
6
- if (predicate(input)) return input
7
-
8
- return whenFalseFn(input)
7
+ return whenFalseFn(input)
8
+ }
9
9
  }
10
-
11
- export const unless = curry(unlessFn)
package/src/unwind.js CHANGED
@@ -1,16 +1,8 @@
1
- import { isArray } from './_internals/isArray.js'
2
- import { mapArray } from './map.js'
3
-
4
- export function unwind(property, obj){
5
- if (arguments.length === 1){
6
- return _obj => unwind(property, _obj)
1
+ export function unwind(property) {
2
+ return obj => {
3
+ return obj[property].map(x => ({
4
+ ...obj,
5
+ [property]: x,
6
+ }))
7
7
  }
8
-
9
- if (!isArray(obj[ property ])) return [ obj ]
10
-
11
- return mapArray(x => ({
12
- ...obj,
13
- [ property ] : x,
14
- }),
15
- obj[ property ])
16
8
  }
package/src/update.js CHANGED
@@ -1,15 +1,12 @@
1
1
  import { cloneList } from './_internals/cloneList.js'
2
- import { curry } from './curry.js'
3
2
 
4
- export function updateFn(
5
- index, newValue, list
6
- ){
7
- const clone = cloneList(list)
8
- if (index === -1) return clone.fill(newValue, index)
3
+ export function update(index, newValue) {
4
+ return list => {
5
+ const clone = cloneList(list)
6
+ if (index === -1) {
7
+ return clone.fill(newValue, index)
8
+ }
9
9
 
10
- return clone.fill(
11
- newValue, index, index + 1
12
- )
10
+ return clone.fill(newValue, index, index + 1)
11
+ }
13
12
  }
14
-
15
- export const update = curry(updateFn)
package/src/when.js CHANGED
@@ -1,11 +1,9 @@
1
- import { curry } from './curry.js'
1
+ export function when(predicate, whenTrueFn) {
2
+ return input => {
3
+ if (!predicate(input)) {
4
+ return input
5
+ }
2
6
 
3
- function whenFn(
4
- predicate, whenTrueFn, input
5
- ){
6
- if (!predicate(input)) return input
7
-
8
- return whenTrueFn(input)
7
+ return whenTrueFn(input)
8
+ }
9
9
  }
10
-
11
- export const when = curry(whenFn)
package/src/zip.js CHANGED
@@ -1,12 +1,12 @@
1
- export function zip(left, right){
2
- if (arguments.length === 1) return _right => zip(left, _right)
1
+ export function zip(left) {
2
+ return right => {
3
+ const result = []
4
+ const length = Math.min(left.length, right.length)
3
5
 
4
- const result = []
5
- const length = Math.min(left.length, right.length)
6
+ for (let i = 0; i < length; i++) {
7
+ result[i] = [left[i], right[i]]
8
+ }
6
9
 
7
- for (let i = 0; i < length; i++){
8
- result[ i ] = [ left[ i ], right[ i ] ]
10
+ return result
9
11
  }
10
-
11
- return result
12
12
  }
package/src/zipWith.js CHANGED
@@ -1,10 +1,8 @@
1
- import { curry } from './curry.js'
2
1
  import { take } from './take.js'
3
2
 
4
- function zipWithFn(
5
- fn, x, y
6
- ){
7
- return take(x.length > y.length ? y.length : x.length, x).map((xInstance, i) => fn(xInstance, y[ i ]))
3
+ export function zipWith(fn, x) {
4
+ return y =>
5
+ take(x.length > y.length ? y.length : x.length)(x).map((xInstance, i) =>
6
+ fn(xInstance, y[i]),
7
+ )
8
8
  }
9
-
10
- export const zipWith = curry(zipWithFn)
package/src/F.js DELETED
@@ -1,3 +0,0 @@
1
- export function F(){
2
- return false
3
- }
package/src/T.js DELETED
@@ -1,3 +0,0 @@
1
- export function T(){
2
- return true
3
- }
@@ -1,64 +0,0 @@
1
- export function _arity(n, fn){
2
- switch (n){
3
- case 0:
4
- return function (){
5
- return fn.apply(this, arguments)
6
- }
7
- case 1:
8
- return function (_1){
9
- return fn.apply(this, arguments)
10
- }
11
- case 2:
12
- return function (_1, _2){
13
- return fn.apply(this, arguments)
14
- }
15
- case 3:
16
- return function (
17
- _1, _2, _3
18
- ){
19
- return fn.apply(this, arguments)
20
- }
21
- case 4:
22
- return function (
23
- _1, _2, _3, _4
24
- ){
25
- return fn.apply(this, arguments)
26
- }
27
- case 5:
28
- return function (
29
- _1, _2, _3, _4, _5
30
- ){
31
- return fn.apply(this, arguments)
32
- }
33
- case 6:
34
- return function (
35
- _1, _2, _3, _4, _5, _6
36
- ){
37
- return fn.apply(this, arguments)
38
- }
39
- case 7:
40
- return function (
41
- _1, _2, _3, _4, _5, _6, _7
42
- ){
43
- return fn.apply(this, arguments)
44
- }
45
- case 8:
46
- return function (
47
- _1, _2, _3, _4, _5, _6, _7, _8
48
- ){
49
- return fn.apply(this, arguments)
50
- }
51
- case 9:
52
- return function (
53
- _1, _2, _3, _4, _5, _6, _7, _8, _9
54
- ){
55
- return fn.apply(this, arguments)
56
- }
57
- default:
58
- return function (
59
- _1, _2, _3, _4, _5, _6, _7, _8, _9, _10
60
- ){
61
- return fn.apply(this, arguments)
62
- }
63
- }
64
- }
@@ -1,3 +0,0 @@
1
- export function compare(a, b){
2
- return String(a) === String(b)
3
- }
@@ -1 +0,0 @@
1
- export const INCORRECT_ITERABLE_INPUT = 'Incorrect iterable input'
@@ -1,7 +0,0 @@
1
- import { isInteger } from './isInteger.js'
2
-
3
- export function createPathInput(path){
4
- return typeof path === 'string' ?
5
- path.split('.').map(x => isInteger(Number(x)) ? Number(x) : x) :
6
- path
7
- }
@@ -1,13 +0,0 @@
1
- import { type } from '../type.js'
2
- import { isArray } from './isArray.js'
3
-
4
- export function isFalsy(x){
5
- if (isArray(x)){
6
- return x.length === 0
7
- }
8
- if (type(x) === 'Object'){
9
- return Object.keys(x).length === 0
10
- }
11
-
12
- return !x
13
- }
@@ -1,10 +0,0 @@
1
- function _isInteger(n){
2
- return n << 0 === n
3
- }
4
-
5
- export const isInteger = Number.isInteger || _isInteger
6
-
7
- /**
8
- * Check if `index` is integer even if it is a string.
9
- */
10
- export const isIndexInteger = index => Number.isInteger(Number(index))
@@ -1,5 +0,0 @@
1
- import { type } from '../type.js'
2
-
3
- export function isIterable(input){
4
- return Array.isArray(input) || type(input) === 'Object'
5
- }
@@ -1,5 +0,0 @@
1
- import { type } from '../type.js'
2
-
3
- export function isObject(input){
4
- return type(input) === 'Object'
5
- }
@@ -1,13 +0,0 @@
1
- import { type } from '../type.js'
2
- import { isArray } from './isArray.js'
3
-
4
- export function isTruthy(x){
5
- if (isArray(x)){
6
- return x.length > 0
7
- }
8
- if (type(x) === 'Object'){
9
- return Object.keys(x).length > 0
10
- }
11
-
12
- return Boolean(x)
13
- }
@@ -1,9 +0,0 @@
1
- function _objectIs(a, b){
2
- if (a === b){
3
- return a !== 0 || 1 / a === 1 / b
4
- }
5
-
6
- return a !== a && b !== b
7
- }
8
-
9
- export const objectIs = Object.is || _objectIs
@@ -1,21 +0,0 @@
1
- export function _concat(set1, set2){
2
- set1 = set1 || []
3
- set2 = set2 || []
4
- let idx
5
- const len1 = set1.length
6
- const len2 = set2.length
7
- const result = []
8
-
9
- idx = 0
10
- while (idx < len1){
11
- result[ result.length ] = set1[ idx ]
12
- idx += 1
13
- }
14
- idx = 0
15
- while (idx < len2){
16
- result[ result.length ] = set2[ idx ]
17
- idx += 1
18
- }
19
-
20
- return result
21
- }
package/src/add.js DELETED
@@ -1,5 +0,0 @@
1
- export function add(a, b){
2
- if (arguments.length === 1) return _b => add(a, _b)
3
-
4
- return Number(a) + Number(b)
5
- }
package/src/addIndex.js DELETED
@@ -1,23 +0,0 @@
1
- import { _concat } from './_internals/utils.js'
2
- import { curryN } from './curryN.js'
3
-
4
- export function addIndex(
5
- originalFunction,
6
- initialIndexFn = () => 0,
7
- loopIndexChange = x => x + 1
8
- ){
9
- return curryN(originalFunction.length, function (){
10
- const origFn = arguments[ 0 ]
11
- const list = arguments[ arguments.length - 1 ]
12
- let idx = initialIndexFn(list.length)
13
- const args = Array.prototype.slice.call(arguments, 0)
14
- args[ 0 ] = function (){
15
- const result = origFn.apply(this, _concat(arguments, [ idx, list ]))
16
- idx = loopIndexChange(idx)
17
-
18
- return result
19
- }
20
-
21
- return originalFunction.apply(this, args)
22
- })
23
- }
@@ -1,9 +0,0 @@
1
- import { addIndex } from './addIndex.js'
2
-
3
- export function addIndexRight(originalFunction){
4
- return addIndex(
5
- originalFunction,
6
- listLength => listLength - 1,
7
- x => x - 1
8
- )
9
- }
package/src/adjust.js DELETED
@@ -1,16 +0,0 @@
1
- import { cloneList } from './_internals/cloneList.js'
2
- import { curry } from './curry.js'
3
-
4
- function adjustFn(
5
- index, replaceFn, list
6
- ){
7
- const actualIndex = index < 0 ? list.length + index : index
8
- if (index >= list.length || actualIndex < 0) return list
9
-
10
- const clone = cloneList(list)
11
- clone[ actualIndex ] = replaceFn(clone[ actualIndex ])
12
-
13
- return clone
14
- }
15
-
16
- export const adjust = curry(adjustFn)
package/src/always.js DELETED
@@ -1,3 +0,0 @@
1
- export function always(x){
2
- return _ => x
3
- }
package/src/and.js DELETED
@@ -1,5 +0,0 @@
1
- export function and(a, b){
2
- if (arguments.length === 1) return _b => and(a, _b)
3
-
4
- return a && b
5
- }
package/src/ap.js DELETED
@@ -1,7 +0,0 @@
1
- export function ap(functions, input){
2
- if (arguments.length === 1){
3
- return _inputs => ap(functions, _inputs)
4
- }
5
-
6
- return functions.reduce((acc, fn) => [ ...acc, ...input.map(fn) ], [])
7
- }
package/src/aperture.js DELETED
@@ -1,15 +0,0 @@
1
- export function aperture(step, list){
2
- if (arguments.length === 1){
3
- return _list => aperture(step, _list)
4
- }
5
- if (step > list.length) return []
6
- let idx = 0
7
- const limit = list.length - (step - 1)
8
- const acc = new Array(limit)
9
- while (idx < limit){
10
- acc[ idx ] = list.slice(idx, idx + step)
11
- idx += 1
12
- }
13
-
14
- return acc
15
- }
package/src/apply.js DELETED
@@ -1,7 +0,0 @@
1
- export function apply(fn, args){
2
- if (arguments.length === 1){
3
- return _args => apply(fn, _args)
4
- }
5
-
6
- return fn.apply(this, args)
7
- }