rambda 6.8.1 → 7.0.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 (189) hide show
  1. package/CHANGELOG.md +93 -0
  2. package/README.md +4108 -5600
  3. package/dist/rambda.esm.js +340 -212
  4. package/dist/rambda.js +345 -212
  5. package/dist/rambda.mjs +340 -212
  6. package/dist/rambda.umd.js +1 -1
  7. package/immutable.d.ts +202 -275
  8. package/immutable.js +1 -0
  9. package/index.d.ts +202 -275
  10. package/package.json +111 -94
  11. package/src/F.js +1 -1
  12. package/src/T.js +1 -1
  13. package/src/_internals/_isInteger.js +1 -1
  14. package/src/_internals/_objectIs.js +2 -2
  15. package/src/_internals/baseSlice.js +6 -8
  16. package/src/_internals/cloneList.js +3 -0
  17. package/src/_internals/isFalsy.js +5 -5
  18. package/src/_internals/isObject.js +5 -0
  19. package/src/_internals/isTruthy.js +5 -5
  20. package/src/_internals/set.js +35 -0
  21. package/src/add.js +1 -1
  22. package/src/adjust.js +5 -6
  23. package/src/all.js +3 -3
  24. package/src/allPass.js +4 -4
  25. package/src/always.js +1 -1
  26. package/src/and.js +1 -1
  27. package/src/any.js +3 -3
  28. package/src/anyPass.js +4 -4
  29. package/src/append.js +4 -2
  30. package/src/apply.js +7 -0
  31. package/src/applySpec.js +33 -59
  32. package/src/assoc.js +3 -7
  33. package/src/assocPath.js +22 -25
  34. package/src/bind.js +9 -0
  35. package/src/both.js +1 -1
  36. package/src/chain.js +2 -2
  37. package/src/clamp.js +6 -6
  38. package/src/clone.js +10 -10
  39. package/src/complement.js +1 -1
  40. package/src/compose.js +6 -6
  41. package/src/concat.js +2 -2
  42. package/src/cond.js +3 -3
  43. package/src/converge.js +11 -11
  44. package/src/curry.js +2 -2
  45. package/src/curryN.js +61 -81
  46. package/src/defaultTo.js +5 -8
  47. package/src/difference.js +3 -3
  48. package/src/dissoc.js +4 -4
  49. package/src/divide.js +1 -1
  50. package/src/drop.js +1 -1
  51. package/src/dropLast.js +5 -5
  52. package/src/dropLastWhile.js +12 -12
  53. package/src/dropRepeats.js +6 -6
  54. package/src/dropRepeatsWith.js +7 -7
  55. package/src/dropWhile.js +9 -9
  56. package/src/either.js +2 -2
  57. package/src/endsWith.js +20 -3
  58. package/src/eqProps.js +5 -10
  59. package/src/equals.js +119 -38
  60. package/src/evolve.js +23 -21
  61. package/src/filter.js +17 -19
  62. package/src/find.js +4 -4
  63. package/src/findIndex.js +3 -3
  64. package/src/findLast.js +4 -4
  65. package/src/findLastIndex.js +3 -3
  66. package/src/flatten.js +6 -6
  67. package/src/flip.js +11 -15
  68. package/src/forEach.js +10 -12
  69. package/src/fromPairs.js +2 -2
  70. package/src/groupBy.js +6 -6
  71. package/src/groupWith.js +11 -12
  72. package/src/hasPath.js +5 -5
  73. package/src/head.js +3 -3
  74. package/src/identical.js +1 -1
  75. package/src/identity.js +2 -2
  76. package/src/ifElse.js +3 -5
  77. package/src/includes.js +11 -22
  78. package/src/indexBy.js +11 -11
  79. package/src/indexOf.js +5 -12
  80. package/src/init.js +2 -4
  81. package/src/intersection.js +3 -3
  82. package/src/intersperse.js +5 -5
  83. package/src/is.js +2 -2
  84. package/src/isEmpty.js +5 -5
  85. package/src/isFunction.js +3 -3
  86. package/src/isNil.js +1 -1
  87. package/src/isPromise.js +3 -3
  88. package/src/join.js +1 -1
  89. package/src/keys.js +1 -1
  90. package/src/last.js +4 -4
  91. package/src/lastIndexOf.js +5 -11
  92. package/src/length.js +6 -5
  93. package/src/lens.js +3 -3
  94. package/src/lensIndex.js +4 -4
  95. package/src/lensProp.js +4 -4
  96. package/src/map.js +19 -18
  97. package/src/match.js +1 -1
  98. package/src/mathMod.js +2 -2
  99. package/src/max.js +1 -1
  100. package/src/maxBy.js +2 -4
  101. package/src/maybe.js +2 -4
  102. package/src/mean.js +2 -2
  103. package/src/median.js +12 -10
  104. package/src/merge.js +2 -4
  105. package/src/mergeAll.js +3 -3
  106. package/src/mergeDeepRight.js +8 -8
  107. package/src/mergeLeft.js +2 -2
  108. package/src/min.js +1 -1
  109. package/src/minBy.js +2 -4
  110. package/src/modulo.js +1 -1
  111. package/src/move.js +7 -8
  112. package/src/multiply.js +1 -1
  113. package/src/negate.js +1 -1
  114. package/src/none.js +3 -3
  115. package/src/not.js +1 -1
  116. package/src/nth.js +4 -4
  117. package/src/objOf.js +3 -3
  118. package/src/of.js +2 -2
  119. package/src/omit.js +5 -5
  120. package/src/once.js +6 -6
  121. package/src/or.js +1 -1
  122. package/src/over.js +3 -5
  123. package/src/partial.js +3 -3
  124. package/src/partition.js +17 -15
  125. package/src/path.js +6 -6
  126. package/src/pathEq.js +4 -6
  127. package/src/pathOr.js +5 -7
  128. package/src/paths.js +3 -3
  129. package/src/pick.js +5 -5
  130. package/src/pickAll.js +6 -6
  131. package/src/pipe.js +3 -3
  132. package/src/pluck.js +4 -4
  133. package/src/prepend.js +3 -3
  134. package/src/product.js +2 -2
  135. package/src/prop.js +2 -2
  136. package/src/propEq.js +3 -5
  137. package/src/propIs.js +4 -6
  138. package/src/propOr.js +4 -6
  139. package/src/props.js +6 -6
  140. package/src/range.js +4 -4
  141. package/src/reduce.js +7 -11
  142. package/src/reject.js +2 -2
  143. package/src/repeat.js +2 -2
  144. package/src/replace.js +2 -4
  145. package/src/reverse.js +3 -4
  146. package/src/set.js +5 -9
  147. package/src/slice.js +2 -4
  148. package/src/sort.js +4 -4
  149. package/src/sortBy.js +4 -2
  150. package/src/split.js +1 -1
  151. package/src/splitAt.js +9 -9
  152. package/src/splitEvery.js +8 -6
  153. package/src/splitWhen.js +10 -10
  154. package/src/startsWith.js +20 -3
  155. package/src/subtract.js +1 -1
  156. package/src/sum.js +1 -1
  157. package/src/symmetricDifference.js +9 -7
  158. package/src/tail.js +2 -2
  159. package/src/take.js +2 -4
  160. package/src/takeLast.js +2 -4
  161. package/src/takeLastWhile.js +7 -7
  162. package/src/takeWhile.js +8 -8
  163. package/src/tap.js +1 -1
  164. package/src/test.js +5 -3
  165. package/src/times.js +4 -4
  166. package/src/toLower.js +1 -1
  167. package/src/toPairs.js +1 -1
  168. package/src/toString.js +1 -1
  169. package/src/toUpper.js +1 -1
  170. package/src/transpose.js +4 -3
  171. package/src/trim.js +1 -1
  172. package/src/tryCatch.js +5 -5
  173. package/src/type.js +7 -29
  174. package/src/unapply.js +5 -0
  175. package/src/union.js +4 -3
  176. package/src/uniq.js +7 -10
  177. package/src/uniqWith.js +18 -7
  178. package/src/unless.js +3 -3
  179. package/src/update.js +6 -8
  180. package/src/values.js +2 -2
  181. package/src/view.js +2 -2
  182. package/src/when.js +2 -4
  183. package/src/where.js +5 -5
  184. package/src/whereEq.js +9 -7
  185. package/src/without.js +5 -5
  186. package/src/xor.js +2 -2
  187. package/src/zip.js +3 -3
  188. package/src/zipObj.js +4 -6
  189. package/src/zipWith.js +6 -7
package/src/head.js CHANGED
@@ -1,5 +1,5 @@
1
- export function head(listOrString){
2
- if (typeof listOrString === 'string') return listOrString[ 0 ] || ''
1
+ export function head(listOrString) {
2
+ if (typeof listOrString === 'string') return listOrString[0] || ''
3
3
 
4
- return listOrString[ 0 ]
4
+ return listOrString[0]
5
5
  }
package/src/identical.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import _objectIs from './_internals/_objectIs'
2
2
 
3
- export function identical(a, b){
3
+ export function identical(a, b) {
4
4
  if (arguments.length === 1) return _b => identical(a, _b)
5
5
 
6
6
  return _objectIs(a, b)
package/src/identity.js CHANGED
@@ -1,3 +1,3 @@
1
- export function identity(input){
2
- return input
1
+ export function identity(x) {
2
+ return x
3
3
  }
package/src/ifElse.js CHANGED
@@ -1,13 +1,11 @@
1
- import { curry } from './curry'
1
+ import {curry} from './curry'
2
2
 
3
- function ifElseFn(
4
- condition, onTrue, onFalse
5
- ){
3
+ function ifElseFn(condition, onTrue, onFalse) {
6
4
  return (...input) => {
7
5
  const conditionResult =
8
6
  typeof condition === 'boolean' ? condition : condition(...input)
9
7
 
10
- if (conditionResult === true){
8
+ if (conditionResult === true) {
11
9
  return onTrue(...input)
12
10
  }
13
11
 
package/src/includes.js CHANGED
@@ -1,27 +1,16 @@
1
- import { _isArray } from './_internals/_isArray'
2
- import { equals } from './equals'
1
+ import {_isArray} from './_internals/_isArray'
2
+ import {_indexOf} from './equals'
3
3
 
4
- export function includesArray(valueToFind, input){
5
- let index = -1
6
-
7
- while (++index < input.length){
8
- if (equals(input[ index ], valueToFind)){
9
- return true
10
- }
11
- }
12
-
13
- return false
14
- }
15
-
16
- export function includes(valueToFind, input){
17
- if (arguments.length === 1) return _input => includes(valueToFind, _input)
18
- if (typeof input === 'string'){
19
- return input.includes(valueToFind)
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)
20
9
  }
21
- if (!input){
22
- throw new TypeError(`Cannot read property \'indexOf\' of ${ input }`)
10
+ if (!iterable) {
11
+ throw new TypeError(`Cannot read property \'indexOf\' of ${iterable}`)
23
12
  }
24
- if (!_isArray(input)) return false
13
+ if (!_isArray(iterable)) return false
25
14
 
26
- return includesArray(valueToFind, input)
15
+ return _indexOf(valueToFind, iterable) > -1
27
16
  }
package/src/indexBy.js CHANGED
@@ -1,28 +1,28 @@
1
- import { path } from './path'
1
+ import {path} from './path'
2
2
 
3
- function indexByPath(pathInput, list){
3
+ function indexByPath(pathInput, list) {
4
4
  const toReturn = {}
5
- for (let i = 0; i < list.length; i++){
6
- const item = list[ i ]
7
- toReturn[ path(pathInput, item) ] = item
5
+ for (let i = 0; i < list.length; i++) {
6
+ const item = list[i]
7
+ toReturn[path(pathInput, item)] = item
8
8
  }
9
9
 
10
10
  return toReturn
11
11
  }
12
12
 
13
- export function indexBy(condition, list){
14
- if (arguments.length === 1){
13
+ export function indexBy(condition, list) {
14
+ if (arguments.length === 1) {
15
15
  return _list => indexBy(condition, _list)
16
16
  }
17
17
 
18
- if (typeof condition === 'string'){
18
+ if (typeof condition === 'string') {
19
19
  return indexByPath(condition, list)
20
20
  }
21
21
 
22
22
  const toReturn = {}
23
- for (let i = 0; i < list.length; i++){
24
- const item = list[ i ]
25
- toReturn[ condition(item) ] = item
23
+ for (let i = 0; i < list.length; i++) {
24
+ const item = list[i]
25
+ toReturn[condition(item)] = item
26
26
  }
27
27
 
28
28
  return toReturn
package/src/indexOf.js CHANGED
@@ -1,16 +1,9 @@
1
- export function indexOf(valueToFind, list){
2
- if (arguments.length === 1){
3
- return _list => indexOf(valueToFind, _list)
4
- }
5
-
6
- let index = -1
7
- const { length } = list
1
+ import {_indexOf} from './equals'
8
2
 
9
- while (++index < length){
10
- if (list[ index ] === valueToFind){
11
- return index
12
- }
3
+ export function indexOf(valueToFind, list) {
4
+ if (arguments.length === 1) {
5
+ return _list => _indexOf(valueToFind, _list)
13
6
  }
14
7
 
15
- return -1
8
+ return _indexOf(valueToFind, list)
16
9
  }
package/src/init.js CHANGED
@@ -1,9 +1,7 @@
1
1
  import baseSlice from './_internals/baseSlice'
2
2
 
3
- export function init(listOrString){
3
+ export function init(listOrString) {
4
4
  if (typeof listOrString === 'string') return listOrString.slice(0, -1)
5
5
 
6
- return listOrString.length ? baseSlice(
7
- listOrString, 0, -1
8
- ) : []
6
+ return listOrString.length ? baseSlice(listOrString, 0, -1) : []
9
7
  }
@@ -1,7 +1,7 @@
1
- import { filter } from './filter'
2
- import { includes } from './includes'
1
+ import {filter} from './filter'
2
+ import {includes} from './includes'
3
3
 
4
- export function intersection(listA, listB){
4
+ export function intersection(listA, listB) {
5
5
  if (arguments.length === 1) return _list => intersection(listA, _list)
6
6
 
7
7
  return filter(x => includes(x, listA), listB)
@@ -1,15 +1,15 @@
1
- export function intersperse(separator, list){
1
+ export function intersperse(separator, list) {
2
2
  if (arguments.length === 1) return _list => intersperse(separator, _list)
3
3
 
4
4
  let index = -1
5
5
  const len = list.length
6
6
  const willReturn = []
7
7
 
8
- while (++index < len){
9
- if (index === len - 1){
10
- willReturn.push(list[ index ])
8
+ while (++index < len) {
9
+ if (index === len - 1) {
10
+ willReturn.push(list[index])
11
11
  } else {
12
- willReturn.push(list[ index ], separator)
12
+ willReturn.push(list[index], separator)
13
13
  }
14
14
  }
15
15
 
package/src/is.js CHANGED
@@ -1,8 +1,8 @@
1
- export function is(targetPrototype, x){
1
+ export function is(targetPrototype, x) {
2
2
  if (arguments.length === 1) return _x => is(targetPrototype, _x)
3
3
 
4
4
  return (
5
- x != null && x.constructor === targetPrototype ||
5
+ (x != null && x.constructor === targetPrototype) ||
6
6
  x instanceof targetPrototype
7
7
  )
8
8
  }
package/src/isEmpty.js CHANGED
@@ -1,16 +1,16 @@
1
- import { type } from './type'
1
+ import {type} from './type'
2
2
 
3
- export function isEmpty(input){
3
+ export function isEmpty(input) {
4
4
  const inputType = type(input)
5
- if ([ 'Undefined', 'NaN', 'Number', 'Null' ].includes(inputType))
5
+ if (['Undefined', 'NaN', 'Number', 'Null'].includes(inputType))
6
6
  return false
7
7
  if (!input) return true
8
8
 
9
- if (inputType === 'Object'){
9
+ if (inputType === 'Object') {
10
10
  return Object.keys(input).length === 0
11
11
  }
12
12
 
13
- if (inputType === 'Array'){
13
+ if (inputType === 'Array') {
14
14
  return input.length === 0
15
15
  }
16
16
 
package/src/isFunction.js CHANGED
@@ -1,5 +1,5 @@
1
- import { type } from './type'
1
+ import {type} from './type'
2
2
 
3
- export function isFunction(fn){
4
- return [ 'Async', 'Function' ].includes(type(fn))
3
+ export function isFunction(fn) {
4
+ return ['Async', 'Function'].includes(type(fn))
5
5
  }
package/src/isNil.js CHANGED
@@ -1,3 +1,3 @@
1
- export function isNil(x){
1
+ export function isNil(x) {
2
2
  return x === undefined || x === null
3
3
  }
package/src/isPromise.js CHANGED
@@ -1,5 +1,5 @@
1
- import { type } from './type'
1
+ import {type} from './type'
2
2
 
3
- export function isPromise(x){
4
- return [ 'Async', 'Promise' ].includes(type(x))
3
+ export function isPromise(x) {
4
+ return ['Async', 'Promise'].includes(type(x))
5
5
  }
package/src/join.js CHANGED
@@ -1,4 +1,4 @@
1
- export function join(glue, list){
1
+ export function join(glue, list) {
2
2
  if (arguments.length === 1) return _list => join(glue, _list)
3
3
 
4
4
  return list.join(glue)
package/src/keys.js CHANGED
@@ -1,3 +1,3 @@
1
- export function keys(x){
1
+ export function keys(x) {
2
2
  return Object.keys(x)
3
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,15 +1,9 @@
1
- import { equals } from './equals'
1
+ import {_lastIndexOf} from './equals'
2
2
 
3
- export function lastIndexOf(target, list){
4
- if (arguments.length === 1) return _list => lastIndexOf(target, _list)
5
-
6
- let index = list.length
7
-
8
- while (--index > 0){
9
- if (equals(list[ index ], target)){
10
- return index
11
- }
3
+ export function lastIndexOf(valueToFind, list) {
4
+ if (arguments.length === 1) {
5
+ return _list => _lastIndexOf(valueToFind, _list)
12
6
  }
13
7
 
14
- return -1
8
+ return _lastIndexOf(valueToFind, list)
15
9
  }
package/src/length.js CHANGED
@@ -1,7 +1,8 @@
1
- export function length(x){
2
- if (!x && x !== '' || x.length === undefined){
3
- return NaN
4
- }
1
+ import {_isArray} from './_internals/_isArray'
5
2
 
6
- return x.length
3
+ export function length(x) {
4
+ if (_isArray(x)) return x.length
5
+ if (typeof x === 'string') return x.length
6
+
7
+ return NaN
7
8
  }
package/src/lens.js CHANGED
@@ -1,6 +1,6 @@
1
- export function lens(getter, setter){
2
- return function (functor){
3
- return function (target){
1
+ export function lens(getter, setter) {
2
+ return function (functor) {
3
+ return function (target) {
4
4
  return functor(getter(target)).map(focus => setter(focus, target))
5
5
  }
6
6
  }
package/src/lensIndex.js CHANGED
@@ -1,7 +1,7 @@
1
- import { lens } from './lens'
2
- import { nth } from './nth'
3
- import { update } from './update'
1
+ import {lens} from './lens'
2
+ import {nth} from './nth'
3
+ import {update} from './update'
4
4
 
5
- export function lensIndex(index){
5
+ export function lensIndex(index) {
6
6
  return lens(nth(index), update(index))
7
7
  }
package/src/lensProp.js CHANGED
@@ -1,7 +1,7 @@
1
- import { assoc } from './assoc'
2
- import { lens } from './lens'
3
- import { prop } from './prop'
1
+ import {assoc} from './assoc'
2
+ import {lens} from './lens'
3
+ import {prop} from './prop'
4
4
 
5
- export function lensProp(key){
5
+ export function lensProp(key) {
6
6
  return lens(prop(key), assoc(key))
7
7
  }
package/src/map.js CHANGED
@@ -1,14 +1,12 @@
1
- import { _isArray } from './_internals/_isArray'
2
- import { _keys } from './_internals/_keys'
1
+ import {_isArray} from './_internals/_isArray'
2
+ import {_keys} from './_internals/_keys'
3
3
 
4
- export function mapArray(
5
- fn, list, isIndexed = false
6
- ){
4
+ export function mapArray(fn, list, isIndexed = false) {
7
5
  let index = 0
8
6
  const willReturn = Array(list.length)
9
7
 
10
- while (index < list.length){
11
- willReturn[ index ] = isIndexed ? fn(list[ index ], index) : fn(list[ index ])
8
+ while (index < list.length) {
9
+ willReturn[index] = isIndexed ? fn(list[index], index) : fn(list[index])
12
10
 
13
11
  index++
14
12
  }
@@ -16,27 +14,30 @@ export function mapArray(
16
14
  return willReturn
17
15
  }
18
16
 
19
- export function mapObject(fn, obj){
17
+ export function mapObject(fn, obj) {
20
18
  let index = 0
21
19
  const keys = _keys(obj)
22
20
  const len = keys.length
23
21
  const willReturn = {}
24
22
 
25
- while (index < len){
26
- const key = keys[ index ]
27
- willReturn[ key ] = fn(
28
- obj[ key ], key, obj
29
- )
23
+ while (index < len) {
24
+ const key = keys[index]
25
+ willReturn[key] = fn(obj[key], key, obj)
30
26
  index++
31
27
  }
32
28
 
33
29
  return willReturn
34
30
  }
35
31
 
36
- export function map(fn, list){
37
- if (arguments.length === 1) return _list => map(fn, _list)
38
- if (list === undefined) return []
39
- if (_isArray(list)) return mapArray(fn, list)
32
+ export const mapObjIndexed = mapObject
40
33
 
41
- return mapObject(fn, list)
34
+ export function map(fn, iterable) {
35
+ if (arguments.length === 1) return _iterable => map(fn, _iterable)
36
+ if (!iterable) {
37
+ throw new Error('Incorrect iterable input')
38
+ }
39
+
40
+ if (_isArray(iterable)) return mapArray(fn, iterable)
41
+
42
+ return mapObject(fn, iterable)
42
43
  }
package/src/match.js CHANGED
@@ -1,4 +1,4 @@
1
- export function match(pattern, input){
1
+ export function match(pattern, input) {
2
2
  if (arguments.length === 1) return _input => match(pattern, _input)
3
3
 
4
4
  const willReturn = input.match(pattern)
package/src/mathMod.js CHANGED
@@ -1,8 +1,8 @@
1
1
  import _isInteger from './_internals/_isInteger'
2
2
 
3
- export function mathMod(x, y){
3
+ export function mathMod(x, y) {
4
4
  if (arguments.length === 1) return _y => mathMod(x, _y)
5
5
  if (!_isInteger(x) || !_isInteger(y) || y < 1) return NaN
6
6
 
7
- return (x % y + y) % y
7
+ return ((x % y) + y) % y
8
8
  }
package/src/max.js CHANGED
@@ -1,4 +1,4 @@
1
- export function max(x, y){
1
+ export function max(x, y) {
2
2
  if (arguments.length === 1) return _y => max(x, _y)
3
3
 
4
4
  return y > x ? y : x
package/src/maxBy.js CHANGED
@@ -1,8 +1,6 @@
1
- import { curry } from './curry'
1
+ import {curry} from './curry'
2
2
 
3
- export function maxByFn(
4
- compareFn, x, y
5
- ){
3
+ export function maxByFn(compareFn, x, y) {
6
4
  return compareFn(y) > compareFn(x) ? y : x
7
5
  }
8
6
 
package/src/maybe.js CHANGED
@@ -1,8 +1,6 @@
1
- import { type } from './type'
1
+ import {type} from './type'
2
2
 
3
- export function maybe(
4
- ifRule, whenIf, whenElse
5
- ){
3
+ export function maybe(ifRule, whenIf, whenElse) {
6
4
  const whenIfInput =
7
5
  ifRule && type(whenIf) === 'Function' ? whenIf() : whenIf
8
6
 
package/src/mean.js CHANGED
@@ -1,5 +1,5 @@
1
- import { sum } from './sum'
1
+ import {sum} from './sum'
2
2
 
3
- export function mean(list){
3
+ export function mean(list) {
4
4
  return sum(list) / list.length
5
5
  }
package/src/median.js CHANGED
@@ -1,17 +1,19 @@
1
- import { mean } from './mean'
1
+ import {mean} from './mean'
2
2
 
3
- export function median(list){
3
+ export function median(list) {
4
4
  const len = list.length
5
5
  if (len === 0) return NaN
6
- const width = 2 - len % 2
6
+ const width = 2 - (len % 2)
7
7
  const idx = (len - width) / 2
8
8
 
9
- return mean(Array.prototype.slice
10
- .call(list, 0)
11
- .sort((a, b) => {
12
- if (a === b) return 0
9
+ return mean(
10
+ Array.prototype.slice
11
+ .call(list, 0)
12
+ .sort((a, b) => {
13
+ if (a === b) return 0
13
14
 
14
- return a < b ? -1 : 1
15
- })
16
- .slice(idx, idx + width))
15
+ return a < b ? -1 : 1
16
+ })
17
+ .slice(idx, idx + width)
18
+ )
17
19
  }
package/src/merge.js CHANGED
@@ -1,7 +1,5 @@
1
- export function merge(target, newProps){
1
+ export function merge(target, newProps) {
2
2
  if (arguments.length === 1) return _newProps => merge(target, _newProps)
3
3
 
4
- return Object.assign(
5
- {}, target || {}, newProps || {}
6
- )
4
+ return Object.assign({}, target || {}, newProps || {})
7
5
  }
package/src/mergeAll.js CHANGED
@@ -1,7 +1,7 @@
1
- import { map } from './map'
2
- import { merge } from './merge'
1
+ import {map} from './map'
2
+ import {merge} from './merge'
3
3
 
4
- export function mergeAll(arr){
4
+ export function mergeAll(arr) {
5
5
  let willReturn = {}
6
6
  map(val => {
7
7
  willReturn = merge(willReturn, val)
@@ -1,21 +1,21 @@
1
- import { type } from './type'
1
+ import {type} from './type'
2
2
 
3
- export function mergeDeepRight(target, source){
4
- if (arguments.length === 1){
3
+ export function mergeDeepRight(target, source) {
4
+ if (arguments.length === 1) {
5
5
  return sourceHolder => mergeDeepRight(target, sourceHolder)
6
6
  }
7
7
 
8
8
  const willReturn = JSON.parse(JSON.stringify(target))
9
9
 
10
10
  Object.keys(source).forEach(key => {
11
- if (type(source[ key ]) === 'Object'){
12
- if (type(target[ key ]) === 'Object'){
13
- willReturn[ key ] = mergeDeepRight(target[ key ], source[ key ])
11
+ if (type(source[key]) === 'Object') {
12
+ if (type(target[key]) === 'Object') {
13
+ willReturn[key] = mergeDeepRight(target[key], source[key])
14
14
  } else {
15
- willReturn[ key ] = source[ key ]
15
+ willReturn[key] = source[key]
16
16
  }
17
17
  } else {
18
- willReturn[ key ] = source[ key ]
18
+ willReturn[key] = source[key]
19
19
  }
20
20
  })
21
21
 
package/src/mergeLeft.js CHANGED
@@ -1,6 +1,6 @@
1
- import { merge } from './merge'
1
+ import {merge} from './merge'
2
2
 
3
- export function mergeLeft(x, y){
3
+ export function mergeLeft(x, y) {
4
4
  if (arguments.length === 1) return _y => mergeLeft(x, _y)
5
5
 
6
6
  return merge(y, x)
package/src/min.js CHANGED
@@ -1,4 +1,4 @@
1
- export function min(x, y){
1
+ export function min(x, y) {
2
2
  if (arguments.length === 1) return _y => min(x, _y)
3
3
 
4
4
  return y < x ? y : x
package/src/minBy.js CHANGED
@@ -1,8 +1,6 @@
1
- import { curry } from './curry'
1
+ import {curry} from './curry'
2
2
 
3
- export function minByFn(
4
- compareFn, x, y
5
- ){
3
+ export function minByFn(compareFn, x, y) {
6
4
  return compareFn(y) < compareFn(x) ? y : x
7
5
  }
8
6
 
package/src/modulo.js CHANGED
@@ -1,4 +1,4 @@
1
- export function modulo(x, y){
1
+ export function modulo(x, y) {
2
2
  if (arguments.length === 1) return _y => modulo(x, _y)
3
3
 
4
4
  return x % y
package/src/move.js CHANGED
@@ -1,16 +1,15 @@
1
- import { curry } from './curry'
1
+ import {curry} from './curry'
2
+ import {cloneList} from './_internals/cloneList'
2
3
 
3
- function moveFn(
4
- fromIndex, toIndex, list
5
- ){
6
- if (fromIndex < 0 || toIndex < 0){
4
+ function moveFn(fromIndex, toIndex, list) {
5
+ if (fromIndex < 0 || toIndex < 0) {
7
6
  throw new Error('Rambda.move does not support negative indexes')
8
7
  }
9
8
  if (fromIndex > list.length - 1 || toIndex > list.length - 1) return list
10
9
 
11
- const clone = list.slice()
12
- clone[ fromIndex ] = list[ toIndex ]
13
- clone[ toIndex ] = list[ fromIndex ]
10
+ const clone = cloneList(list)
11
+ clone[fromIndex] = list[toIndex]
12
+ clone[toIndex] = list[fromIndex]
14
13
 
15
14
  return clone
16
15
  }
package/src/multiply.js CHANGED
@@ -1,4 +1,4 @@
1
- export function multiply(x, y){
1
+ export function multiply(x, y) {
2
2
  if (arguments.length === 1) return _y => multiply(x, _y)
3
3
 
4
4
  return x * y
package/src/negate.js CHANGED
@@ -1,3 +1,3 @@
1
- export function negate(x){
1
+ export function negate(x) {
2
2
  return -x
3
3
  }
package/src/none.js CHANGED
@@ -1,8 +1,8 @@
1
- export function none(predicate, list){
1
+ export function none(predicate, list) {
2
2
  if (arguments.length === 1) return _list => none(predicate, _list)
3
3
 
4
- for (let i = 0; i < list.length; i++){
5
- if (!predicate(list[ i ])) return true
4
+ for (let i = 0; i < list.length; i++) {
5
+ if (!predicate(list[i])) return true
6
6
  }
7
7
 
8
8
  return false