rambda 6.8.3 → 7.0.2

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 (188) hide show
  1. package/CHANGELOG.md +95 -0
  2. package/README.md +4157 -4921
  3. package/dist/rambda.esm.js +336 -209
  4. package/dist/rambda.js +340 -209
  5. package/dist/rambda.mjs +336 -209
  6. package/dist/rambda.umd.js +1 -1
  7. package/immutable.d.ts +203 -284
  8. package/index.d.ts +194 -275
  9. package/package.json +119 -95
  10. package/src/F.js +1 -1
  11. package/src/T.js +1 -1
  12. package/src/_internals/_isInteger.js +1 -1
  13. package/src/_internals/_objectIs.js +2 -2
  14. package/src/_internals/baseSlice.js +6 -8
  15. package/src/_internals/cloneList.js +3 -0
  16. package/src/_internals/isFalsy.js +5 -5
  17. package/src/_internals/isObject.js +5 -0
  18. package/src/_internals/isTruthy.js +5 -5
  19. package/src/_internals/set.js +35 -0
  20. package/src/add.js +1 -1
  21. package/src/adjust.js +5 -6
  22. package/src/all.js +3 -3
  23. package/src/allPass.js +4 -4
  24. package/src/always.js +1 -1
  25. package/src/and.js +1 -1
  26. package/src/any.js +3 -3
  27. package/src/anyPass.js +4 -4
  28. package/src/append.js +4 -2
  29. package/src/apply.js +7 -0
  30. package/src/applySpec.js +33 -59
  31. package/src/assoc.js +3 -7
  32. package/src/assocPath.js +22 -25
  33. package/src/bind.js +9 -0
  34. package/src/both.js +1 -1
  35. package/src/chain.js +2 -2
  36. package/src/clamp.js +6 -6
  37. package/src/clone.js +10 -10
  38. package/src/complement.js +1 -1
  39. package/src/compose.js +6 -6
  40. package/src/concat.js +2 -2
  41. package/src/cond.js +3 -3
  42. package/src/converge.js +11 -11
  43. package/src/curry.js +2 -2
  44. package/src/curryN.js +61 -81
  45. package/src/defaultTo.js +5 -8
  46. package/src/difference.js +3 -3
  47. package/src/dissoc.js +4 -4
  48. package/src/divide.js +1 -1
  49. package/src/drop.js +1 -1
  50. package/src/dropLast.js +5 -5
  51. package/src/dropLastWhile.js +12 -12
  52. package/src/dropRepeats.js +6 -6
  53. package/src/dropRepeatsWith.js +7 -7
  54. package/src/dropWhile.js +9 -9
  55. package/src/either.js +2 -2
  56. package/src/endsWith.js +20 -3
  57. package/src/eqProps.js +5 -10
  58. package/src/equals.js +119 -38
  59. package/src/evolve.js +23 -21
  60. package/src/filter.js +18 -18
  61. package/src/find.js +4 -4
  62. package/src/findIndex.js +3 -3
  63. package/src/findLast.js +4 -4
  64. package/src/findLastIndex.js +3 -3
  65. package/src/flatten.js +6 -6
  66. package/src/flip.js +11 -15
  67. package/src/forEach.js +10 -12
  68. package/src/fromPairs.js +2 -2
  69. package/src/groupBy.js +6 -6
  70. package/src/groupWith.js +11 -12
  71. package/src/hasPath.js +5 -5
  72. package/src/head.js +3 -3
  73. package/src/identical.js +1 -1
  74. package/src/identity.js +2 -2
  75. package/src/ifElse.js +3 -5
  76. package/src/includes.js +11 -22
  77. package/src/indexBy.js +11 -11
  78. package/src/indexOf.js +5 -12
  79. package/src/init.js +2 -4
  80. package/src/intersection.js +3 -3
  81. package/src/intersperse.js +5 -5
  82. package/src/is.js +2 -2
  83. package/src/isEmpty.js +5 -5
  84. package/src/isFunction.js +3 -3
  85. package/src/isNil.js +1 -1
  86. package/src/isPromise.js +3 -3
  87. package/src/join.js +1 -1
  88. package/src/keys.js +1 -1
  89. package/src/last.js +4 -4
  90. package/src/lastIndexOf.js +5 -11
  91. package/src/length.js +6 -5
  92. package/src/lens.js +3 -3
  93. package/src/lensIndex.js +4 -4
  94. package/src/lensProp.js +4 -4
  95. package/src/map.js +17 -18
  96. package/src/match.js +1 -1
  97. package/src/mathMod.js +2 -2
  98. package/src/max.js +1 -1
  99. package/src/maxBy.js +2 -4
  100. package/src/maybe.js +2 -4
  101. package/src/mean.js +2 -2
  102. package/src/median.js +12 -10
  103. package/src/merge.js +2 -4
  104. package/src/mergeAll.js +3 -3
  105. package/src/mergeDeepRight.js +8 -8
  106. package/src/mergeLeft.js +2 -2
  107. package/src/min.js +1 -1
  108. package/src/minBy.js +2 -4
  109. package/src/modulo.js +1 -1
  110. package/src/move.js +7 -8
  111. package/src/multiply.js +1 -1
  112. package/src/negate.js +1 -1
  113. package/src/none.js +3 -3
  114. package/src/not.js +1 -1
  115. package/src/nth.js +4 -4
  116. package/src/objOf.js +3 -3
  117. package/src/of.js +2 -2
  118. package/src/omit.js +5 -5
  119. package/src/once.js +6 -6
  120. package/src/or.js +1 -1
  121. package/src/over.js +3 -5
  122. package/src/partial.js +3 -3
  123. package/src/partition.js +17 -15
  124. package/src/path.js +6 -6
  125. package/src/pathEq.js +4 -6
  126. package/src/pathOr.js +5 -7
  127. package/src/paths.js +3 -3
  128. package/src/pick.js +5 -5
  129. package/src/pickAll.js +6 -6
  130. package/src/pipe.js +3 -3
  131. package/src/pluck.js +4 -4
  132. package/src/prepend.js +3 -3
  133. package/src/product.js +2 -2
  134. package/src/prop.js +2 -2
  135. package/src/propEq.js +3 -5
  136. package/src/propIs.js +4 -6
  137. package/src/propOr.js +4 -6
  138. package/src/props.js +6 -6
  139. package/src/range.js +4 -4
  140. package/src/reduce.js +7 -11
  141. package/src/reject.js +2 -2
  142. package/src/repeat.js +2 -2
  143. package/src/replace.js +2 -4
  144. package/src/reverse.js +3 -4
  145. package/src/set.js +5 -9
  146. package/src/slice.js +2 -4
  147. package/src/sort.js +4 -4
  148. package/src/sortBy.js +4 -2
  149. package/src/split.js +1 -1
  150. package/src/splitAt.js +9 -9
  151. package/src/splitEvery.js +8 -6
  152. package/src/splitWhen.js +10 -10
  153. package/src/startsWith.js +20 -3
  154. package/src/subtract.js +1 -1
  155. package/src/sum.js +1 -1
  156. package/src/symmetricDifference.js +9 -7
  157. package/src/tail.js +2 -2
  158. package/src/take.js +2 -4
  159. package/src/takeLast.js +2 -4
  160. package/src/takeLastWhile.js +7 -7
  161. package/src/takeWhile.js +8 -8
  162. package/src/tap.js +1 -1
  163. package/src/test.js +5 -3
  164. package/src/times.js +4 -4
  165. package/src/toLower.js +1 -1
  166. package/src/toPairs.js +1 -1
  167. package/src/toString.js +1 -1
  168. package/src/toUpper.js +1 -1
  169. package/src/transpose.js +4 -3
  170. package/src/trim.js +1 -1
  171. package/src/tryCatch.js +5 -5
  172. package/src/type.js +7 -29
  173. package/src/unapply.js +5 -0
  174. package/src/union.js +4 -3
  175. package/src/uniq.js +7 -10
  176. package/src/uniqWith.js +18 -7
  177. package/src/unless.js +3 -3
  178. package/src/update.js +6 -8
  179. package/src/values.js +2 -2
  180. package/src/view.js +2 -2
  181. package/src/when.js +2 -4
  182. package/src/where.js +5 -5
  183. package/src/whereEq.js +9 -7
  184. package/src/without.js +5 -5
  185. package/src/xor.js +2 -2
  186. package/src/zip.js +3 -3
  187. package/src/zipObj.js +4 -6
  188. package/src/zipWith.js +6 -7
package/src/splitEvery.js CHANGED
@@ -1,17 +1,19 @@
1
- export function splitEvery(sliceLength, listOrString){
2
- if (arguments.length === 1){
1
+ export function splitEvery(sliceLength, listOrString) {
2
+ if (arguments.length === 1) {
3
3
  return _listOrString => splitEvery(sliceLength, _listOrString)
4
4
  }
5
5
 
6
- if (sliceLength < 1){
7
- throw new Error('First argument to splitEvery must be a positive integer')
6
+ if (sliceLength < 1) {
7
+ throw new Error(
8
+ 'First argument to splitEvery must be a positive integer'
9
+ )
8
10
  }
9
11
 
10
12
  const willReturn = []
11
13
  let counter = 0
12
14
 
13
- while (counter < listOrString.length){
14
- willReturn.push(listOrString.slice(counter, counter += sliceLength))
15
+ while (counter < listOrString.length) {
16
+ willReturn.push(listOrString.slice(counter, (counter += sliceLength)))
15
17
  }
16
18
 
17
19
  return willReturn
package/src/splitWhen.js CHANGED
@@ -1,25 +1,25 @@
1
- export function splitWhen(predicate, input){
2
- if (arguments.length === 1){
1
+ export function splitWhen(predicate, input) {
2
+ if (arguments.length === 1) {
3
3
  return _input => splitWhen(predicate, _input)
4
4
  }
5
5
  if (!input)
6
- throw new TypeError(`Cannot read property 'length' of ${ input }`)
6
+ throw new TypeError(`Cannot read property 'length' of ${input}`)
7
7
 
8
8
  const preFound = []
9
9
  const postFound = []
10
10
  let found = false
11
11
  let counter = -1
12
12
 
13
- while (counter++ < input.length - 1){
14
- if (found){
15
- postFound.push(input[ counter ])
16
- } else if (predicate(input[ counter ])){
17
- postFound.push(input[ counter ])
13
+ while (counter++ < input.length - 1) {
14
+ if (found) {
15
+ postFound.push(input[counter])
16
+ } else if (predicate(input[counter])) {
17
+ postFound.push(input[counter])
18
18
  found = true
19
19
  } else {
20
- preFound.push(input[ counter ])
20
+ preFound.push(input[counter])
21
21
  }
22
22
  }
23
23
 
24
- return [ preFound, postFound ]
24
+ return [preFound, postFound]
25
25
  }
package/src/startsWith.js CHANGED
@@ -1,5 +1,22 @@
1
- export function startsWith(target, str){
2
- if (arguments.length === 1) return _str => startsWith(target, _str)
1
+ import {equals} from './equals.js'
2
+ import {_isArray} from './_internals/_isArray.js'
3
3
 
4
- return str.startsWith(target)
4
+ export function startsWith(target, iterable) {
5
+ if (arguments.length === 1)
6
+ return _iterable => startsWith(target, _iterable)
7
+
8
+ if (typeof iterable === 'string') {
9
+ return iterable.startsWith(target)
10
+ }
11
+ if (!_isArray(target)) return false
12
+
13
+ let correct = true
14
+ const filtered = target.filter((x, index) => {
15
+ if (!correct) return false
16
+ const result = equals(x, iterable[index])
17
+ if (!result) correct = false
18
+ return result
19
+ })
20
+
21
+ return filtered.length === target.length
5
22
  }
package/src/subtract.js CHANGED
@@ -1,4 +1,4 @@
1
- export function subtract(a, b){
1
+ export function subtract(a, b) {
2
2
  if (arguments.length === 1) return _b => subtract(a, _b)
3
3
 
4
4
  return a - b
package/src/sum.js CHANGED
@@ -1,3 +1,3 @@
1
- export function sum(list){
1
+ export function sum(list) {
2
2
  return list.reduce((prev, current) => prev + current, 0)
3
3
  }
@@ -1,12 +1,14 @@
1
- import { concat } from './concat'
2
- import { filter } from './filter'
3
- import { includes } from './includes'
1
+ import {concat} from './concat'
2
+ import {filter} from './filter'
3
+ import {includes} from './includes'
4
4
 
5
- export function symmetricDifference(x, y){
6
- if (arguments.length === 1){
5
+ export function symmetricDifference(x, y) {
6
+ if (arguments.length === 1) {
7
7
  return _y => symmetricDifference(x, _y)
8
8
  }
9
9
 
10
- return concat(filter(value => !includes(value, y), x),
11
- filter(value => !includes(value, x), y))
10
+ return concat(
11
+ filter(value => !includes(value, y), x),
12
+ filter(value => !includes(value, x), y)
13
+ )
12
14
  }
package/src/tail.js CHANGED
@@ -1,5 +1,5 @@
1
- import { drop } from './drop'
1
+ import {drop} from './drop'
2
2
 
3
- export function tail(listOrString){
3
+ export function tail(listOrString) {
4
4
  return drop(1, listOrString)
5
5
  }
package/src/take.js CHANGED
@@ -1,12 +1,10 @@
1
1
  import baseSlice from './_internals/baseSlice'
2
2
 
3
- export function take(howMany, listOrString){
3
+ export function take(howMany, listOrString) {
4
4
  if (arguments.length === 1)
5
5
  return _listOrString => take(howMany, _listOrString)
6
6
  if (howMany < 0) return listOrString.slice()
7
7
  if (typeof listOrString === 'string') return listOrString.slice(0, howMany)
8
8
 
9
- return baseSlice(
10
- listOrString, 0, howMany
11
- )
9
+ return baseSlice(listOrString, 0, howMany)
12
10
  }
package/src/takeLast.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import baseSlice from './_internals/baseSlice'
2
2
 
3
- export function takeLast(howMany, listOrString){
3
+ export function takeLast(howMany, listOrString) {
4
4
  if (arguments.length === 1)
5
5
  return _listOrString => takeLast(howMany, _listOrString)
6
6
 
@@ -13,7 +13,5 @@ export function takeLast(howMany, listOrString){
13
13
 
14
14
  numValue = len - numValue
15
15
 
16
- return baseSlice(
17
- listOrString, numValue, len
18
- )
16
+ return baseSlice(listOrString, numValue, len)
19
17
  }
@@ -1,7 +1,7 @@
1
- import { _isArray } from './_internals/_isArray'
1
+ import {_isArray} from './_internals/_isArray'
2
2
 
3
- export function takeLastWhile(predicate, input){
4
- if (arguments.length === 1){
3
+ export function takeLastWhile(predicate, input) {
4
+ if (arguments.length === 1) {
5
5
  return _input => takeLastWhile(predicate, _input)
6
6
  }
7
7
  if (input.length === 0) return input
@@ -9,12 +9,12 @@ export function takeLastWhile(predicate, input){
9
9
  const toReturn = []
10
10
  let counter = input.length
11
11
 
12
- while (!found || counter === 0){
12
+ while (!found || counter === 0) {
13
13
  counter--
14
- if (predicate(input[ counter ]) === false){
14
+ if (predicate(input[counter]) === false) {
15
15
  found = true
16
- } else if (!found){
17
- toReturn.push(input[ counter ])
16
+ } else if (!found) {
17
+ toReturn.push(input[counter])
18
18
  }
19
19
  }
20
20
 
package/src/takeWhile.js CHANGED
@@ -1,22 +1,22 @@
1
- import { _isArray } from '../src/_internals/_isArray'
1
+ import {_isArray} from '../src/_internals/_isArray'
2
2
 
3
- export function takeWhile(predicate, iterable){
4
- if (arguments.length === 1){
3
+ export function takeWhile(predicate, iterable) {
4
+ if (arguments.length === 1) {
5
5
  return _iterable => takeWhile(predicate, _iterable)
6
6
  }
7
7
  const isArray = _isArray(iterable)
8
- if (!isArray && typeof iterable !== 'string'){
8
+ if (!isArray && typeof iterable !== 'string') {
9
9
  throw new Error('`iterable` is neither list nor a string')
10
10
  }
11
11
  let flag = true
12
12
  const holder = []
13
13
  let counter = -1
14
14
 
15
- while (counter++ < iterable.length - 1){
16
- if (!predicate(iterable[ counter ])){
15
+ while (counter++ < iterable.length - 1) {
16
+ if (!predicate(iterable[counter])) {
17
17
  if (flag) flag = false
18
- } else if (flag){
19
- holder.push(iterable[ counter ])
18
+ } else if (flag) {
19
+ holder.push(iterable[counter])
20
20
  }
21
21
  }
22
22
  holder
package/src/tap.js CHANGED
@@ -1,4 +1,4 @@
1
- export function tap(fn, x){
1
+ export function tap(fn, x) {
2
2
  if (arguments.length === 1) return _x => tap(fn, _x)
3
3
 
4
4
  fn(x)
package/src/test.js CHANGED
@@ -1,8 +1,10 @@
1
- export function test(pattern, str){
1
+ export function test(pattern, str) {
2
2
  if (arguments.length === 1) return _str => test(pattern, _str)
3
3
 
4
- if (typeof pattern === 'string'){
5
- throw new TypeError(`‘test’ requires a value of type RegExp as its first argument; received "${ pattern }"`)
4
+ if (typeof pattern === 'string') {
5
+ throw new TypeError(
6
+ `‘test’ requires a value of type RegExp as its first argument; received "${pattern}"`
7
+ )
6
8
  }
7
9
 
8
10
  return str.search(pattern) !== -1
package/src/times.js CHANGED
@@ -1,9 +1,9 @@
1
- import { map } from './map'
2
- import { range } from './range'
1
+ import {map} from './map'
2
+ import {range} from './range'
3
3
 
4
- export function times(fn, howMany){
4
+ export function times(fn, howMany) {
5
5
  if (arguments.length === 1) return _howMany => times(fn, _howMany)
6
- if (!Number.isInteger(howMany) || howMany < 0){
6
+ if (!Number.isInteger(howMany) || howMany < 0) {
7
7
  throw new RangeError('n must be an integer')
8
8
  }
9
9
 
package/src/toLower.js CHANGED
@@ -1,3 +1,3 @@
1
- export function toLower(str){
1
+ export function toLower(str) {
2
2
  return str.toLowerCase()
3
3
  }
package/src/toPairs.js CHANGED
@@ -1,3 +1,3 @@
1
- export function toPairs(obj){
1
+ export function toPairs(obj) {
2
2
  return Object.entries(obj)
3
3
  }
package/src/toString.js CHANGED
@@ -1,3 +1,3 @@
1
- export function toString(x){
1
+ export function toString(x) {
2
2
  return x.toString()
3
3
  }
package/src/toUpper.js CHANGED
@@ -1,3 +1,3 @@
1
- export function toUpper(str){
1
+ export function toUpper(str) {
2
2
  return str.toUpperCase()
3
3
  }
package/src/transpose.js CHANGED
@@ -1,9 +1,10 @@
1
- import { _isArray } from './_internals/_isArray'
1
+ import {_isArray} from './_internals/_isArray'
2
2
 
3
- export function transpose(array){
3
+ export function transpose(array) {
4
4
  return array.reduce((acc, el) => {
5
5
  el.forEach((nestedEl, i) =>
6
- _isArray(acc[ i ]) ? acc[ i ].push(nestedEl) : acc.push([ nestedEl ]))
6
+ _isArray(acc[i]) ? acc[i].push(nestedEl) : acc.push([nestedEl])
7
+ )
7
8
 
8
9
  return acc
9
10
  }, [])
package/src/trim.js CHANGED
@@ -1,3 +1,3 @@
1
- export function trim(str){
1
+ export function trim(str) {
2
2
  return str.trim()
3
3
  }
package/src/tryCatch.js CHANGED
@@ -1,15 +1,15 @@
1
- import { isFunction } from './isFunction'
1
+ import {isFunction} from './isFunction'
2
2
 
3
- export function tryCatch(fn, fallback){
4
- if (!isFunction(fn)){
5
- throw new Error(`R.tryCatch | fn '${ fn }'`)
3
+ export function tryCatch(fn, fallback) {
4
+ if (!isFunction(fn)) {
5
+ throw new Error(`R.tryCatch | fn '${fn}'`)
6
6
  }
7
7
  const passFallback = isFunction(fallback)
8
8
 
9
9
  return (...inputs) => {
10
10
  try {
11
11
  return fn(...inputs)
12
- } catch (e){
12
+ } catch (e) {
13
13
  return passFallback ? fallback(e, ...inputs) : fallback
14
14
  }
15
15
  }
package/src/type.js CHANGED
@@ -1,34 +1,12 @@
1
- import { _isArray } from './_internals/_isArray'
2
-
3
- export function type(input){
4
- const typeOf = typeof input
5
-
6
- if (input === null){
1
+ export function type(input) {
2
+ if (input === null) {
7
3
  return 'Null'
8
- } else if (input === undefined){
4
+ } else if (input === undefined) {
9
5
  return 'Undefined'
10
- } else if (typeOf === 'boolean'){
11
- return 'Boolean'
12
- } else if (typeOf === 'number'){
13
- return Number.isNaN(input) ? 'NaN' : 'Number'
14
- } else if (typeOf === 'string'){
15
- return 'String'
16
- } else if (_isArray(input)){
17
- return 'Array'
18
- } else if (typeOf === 'symbol'){
19
- return 'Symbol'
20
- } else if (input instanceof RegExp){
21
- return 'RegExp'
6
+ } else if (Number.isNaN(input)) {
7
+ return 'NaN'
22
8
  }
9
+ const typeResult = Object.prototype.toString.call(input).slice(8, -1)
23
10
 
24
- const asStr = input && input.toString ? input.toString() : ''
25
-
26
- if ([ 'true', 'false' ].includes(asStr)) return 'Boolean'
27
- if (!Number.isNaN(Number(asStr))) return 'Number'
28
- if (asStr.startsWith('async')) return 'Async'
29
- if (asStr === '[object Promise]') return 'Promise'
30
- if (typeOf === 'function') return 'Function'
31
- if (input instanceof String) return 'String'
32
-
33
- return 'Object'
11
+ return typeResult === 'AsyncFunction' ? 'Async' : typeResult
34
12
  }
package/src/unapply.js ADDED
@@ -0,0 +1,5 @@
1
+ export function unapply(fn) {
2
+ return function (...args) {
3
+ return fn.call(this, args)
4
+ }
5
+ }
package/src/union.js CHANGED
@@ -1,9 +1,10 @@
1
- import { includes } from './includes'
1
+ import {includes} from './includes'
2
+ import {cloneList} from './_internals/cloneList'
2
3
 
3
- export function union(x, y){
4
+ export function union(x, y) {
4
5
  if (arguments.length === 1) return _y => union(x, _y)
5
6
 
6
- const toReturn = x.slice()
7
+ const toReturn = cloneList(x)
7
8
 
8
9
  y.forEach(yInstance => {
9
10
  if (!includes(yInstance, x)) toReturn.push(yInstance)
package/src/uniq.js CHANGED
@@ -1,16 +1,13 @@
1
- import { includes } from './includes'
1
+ import {_Set} from './_internals/set'
2
2
 
3
- export function uniq(list){
4
- let index = -1
3
+ export function uniq(list) {
4
+ const set = new _Set()
5
5
  const willReturn = []
6
-
7
- while (++index < list.length){
8
- const value = list[ index ]
9
-
10
- if (!includes(value, willReturn)){
11
- willReturn.push(value)
6
+ list.forEach(item => {
7
+ if (set.checkUniqueness(item)) {
8
+ willReturn.push(item)
12
9
  }
13
- }
10
+ })
14
11
 
15
12
  return willReturn
16
13
  }
package/src/uniqWith.js CHANGED
@@ -1,17 +1,28 @@
1
- import { any } from './any'
1
+ function includesWith(predicate, target, list) {
2
+ let willReturn = false
3
+ let index = -1
4
+
5
+ while (++index < list.length && !willReturn) {
6
+ const value = list[index]
7
+
8
+ if (predicate(target, value)) {
9
+ willReturn = true
10
+ }
11
+ }
12
+
13
+ return willReturn
14
+ }
2
15
 
3
- export function uniqWith(predicate, list){
16
+ export function uniqWith(predicate, list) {
4
17
  if (arguments.length === 1) return _list => uniqWith(predicate, _list)
5
18
 
6
19
  let index = -1
7
20
  const willReturn = []
8
21
 
9
- while (++index < list.length){
10
- const value = list[ index ]
11
- const flag = any(x => predicate(value, x),
12
- willReturn)
22
+ while (++index < list.length) {
23
+ const value = list[index]
13
24
 
14
- if (!flag){
25
+ if (!includesWith(predicate, value, willReturn)) {
15
26
  willReturn.push(value)
16
27
  }
17
28
  }
package/src/unless.js CHANGED
@@ -1,7 +1,7 @@
1
- export function unless(predicate, whenFalse){
2
- if (arguments.length === 1){
1
+ export function unless(predicate, whenFalse) {
2
+ if (arguments.length === 1) {
3
3
  return _whenFalse => unless(predicate, _whenFalse)
4
4
  }
5
5
 
6
- return input => predicate(input) ? input : whenFalse(input)
6
+ return input => (predicate(input) ? input : whenFalse(input))
7
7
  }
package/src/update.js CHANGED
@@ -1,13 +1,11 @@
1
- import { curry } from './curry'
1
+ import {curry} from './curry'
2
+ import {cloneList} from './_internals/cloneList'
2
3
 
3
- function updateFn(
4
- index, newValue, list
5
- ){
6
- const arrClone = list.slice()
4
+ function updateFn(index, newValue, list) {
5
+ const clone = cloneList(list)
6
+ if (index === -1) return clone.fill(newValue, index)
7
7
 
8
- return arrClone.fill(
9
- newValue, index, index + 1
10
- )
8
+ return clone.fill(newValue, index, index + 1)
11
9
  }
12
10
 
13
11
  export const update = curry(updateFn)
package/src/values.js CHANGED
@@ -1,6 +1,6 @@
1
- import { type } from './type'
1
+ import {type} from './type'
2
2
 
3
- export function values(obj){
3
+ export function values(obj) {
4
4
  if (type(obj) !== 'Object') return []
5
5
 
6
6
  return Object.values(obj)
package/src/view.js CHANGED
@@ -1,9 +1,9 @@
1
1
  const Const = x => ({
2
2
  x,
3
- map : fn => Const(x),
3
+ map: fn => Const(x),
4
4
  })
5
5
 
6
- export function view(lens, target){
6
+ export function view(lens, target) {
7
7
  if (arguments.length === 1) return _target => view(lens, _target)
8
8
 
9
9
  return lens(Const)(target).x
package/src/when.js CHANGED
@@ -1,8 +1,6 @@
1
- import { curry } from './curry'
1
+ import {curry} from './curry'
2
2
 
3
- function whenFn(
4
- predicate, whenTrueFn, input
5
- ){
3
+ function whenFn(predicate, whenTrueFn, input) {
6
4
  if (!predicate(input)) return input
7
5
 
8
6
  return whenTrueFn(input)
package/src/where.js CHANGED
@@ -1,11 +1,11 @@
1
- export function where(conditions, input){
2
- if (input === undefined){
1
+ export function where(conditions, input) {
2
+ if (input === undefined) {
3
3
  return _input => where(conditions, _input)
4
4
  }
5
5
  let flag = true
6
- for (const prop in conditions){
7
- const result = conditions[ prop ](input[ prop ])
8
- if (flag && result === false){
6
+ for (const prop in conditions) {
7
+ const result = conditions[prop](input[prop])
8
+ if (flag && result === false) {
9
9
  flag = false
10
10
  }
11
11
  }
package/src/whereEq.js CHANGED
@@ -1,14 +1,16 @@
1
- import { equals } from './equals'
2
- import { filter } from './filter'
1
+ import {equals} from './equals'
2
+ import {filter} from './filter'
3
3
 
4
- export function whereEq(condition, input){
5
- if (arguments.length === 1){
4
+ export function whereEq(condition, input) {
5
+ if (arguments.length === 1) {
6
6
  return _input => whereEq(condition, _input)
7
7
  }
8
8
 
9
- const result = filter((conditionValue, conditionProp) =>
10
- equals(conditionValue, input[ conditionProp ]),
11
- condition)
9
+ const result = filter(
10
+ (conditionValue, conditionProp) =>
11
+ equals(conditionValue, input[conditionProp]),
12
+ condition
13
+ )
12
14
 
13
15
  return Object.keys(result).length === Object.keys(condition).length
14
16
  }
package/src/without.js CHANGED
@@ -1,14 +1,14 @@
1
- import { includesArray } from './includes'
2
- import { reduce } from './reduce'
1
+ import {reduce} from './reduce'
2
+ import {_indexOf} from './equals'
3
3
 
4
- export function without(matchAgainst, source){
5
- if (source === undefined){
4
+ export function without(matchAgainst, source) {
5
+ if (source === undefined) {
6
6
  return _source => without(matchAgainst, _source)
7
7
  }
8
8
 
9
9
  return reduce(
10
10
  (prev, current) =>
11
- includesArray(current, matchAgainst) ? prev : prev.concat(current),
11
+ _indexOf(current, matchAgainst) > -1 ? prev : prev.concat(current),
12
12
  [],
13
13
  source
14
14
  )
package/src/xor.js CHANGED
@@ -1,5 +1,5 @@
1
- export function xor(a, b){
1
+ export function xor(a, b) {
2
2
  if (arguments.length === 1) return _b => xor(a, _b)
3
3
 
4
- return Boolean(a) && !b || Boolean(b) && !a
4
+ return (Boolean(a) && !b) || (Boolean(b) && !a)
5
5
  }
package/src/zip.js CHANGED
@@ -1,11 +1,11 @@
1
- export function zip(left, right){
1
+ export function zip(left, right) {
2
2
  if (arguments.length === 1) return _right => zip(left, _right)
3
3
 
4
4
  const result = []
5
5
  const length = Math.min(left.length, right.length)
6
6
 
7
- for (let i = 0; i < length; i++){
8
- result[ i ] = [ left[ i ], right[ i ] ]
7
+ for (let i = 0; i < length; i++) {
8
+ result[i] = [left[i], right[i]]
9
9
  }
10
10
 
11
11
  return result
package/src/zipObj.js CHANGED
@@ -1,12 +1,10 @@
1
- import { take } from './take'
1
+ import {take} from './take'
2
2
 
3
- export function zipObj(keys, values){
3
+ export function zipObj(keys, values) {
4
4
  if (arguments.length === 1) return yHolder => zipObj(keys, yHolder)
5
5
 
6
- return take(values.length, keys).reduce((
7
- prev, xInstance, i
8
- ) => {
9
- prev[ xInstance ] = values[ i ]
6
+ return take(values.length, keys).reduce((prev, xInstance, i) => {
7
+ prev[xInstance] = values[i]
10
8
 
11
9
  return prev
12
10
  }, {})
package/src/zipWith.js CHANGED
@@ -1,11 +1,10 @@
1
- import { curry } from './curry'
2
- import { take } from './take'
1
+ import {curry} from './curry'
2
+ import {take} from './take'
3
3
 
4
- function zipWithFn(
5
- fn, x, y
6
- ){
7
- return take(x.length > y.length ? y.length : x.length,
8
- x).map((xInstance, i) => fn(xInstance, y[ i ]))
4
+ function zipWithFn(fn, x, y) {
5
+ return take(x.length > y.length ? y.length : x.length, x).map(
6
+ (xInstance, i) => fn(xInstance, y[i])
7
+ )
9
8
  }
10
9
 
11
10
  export const zipWith = curry(zipWithFn)