rambda 6.9.0 → 7.0.3
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.
- package/CHANGELOG.md +87 -1
- package/README.md +3827 -4905
- package/dist/rambda.esm.js +301 -208
- package/dist/rambda.js +306 -209
- package/dist/rambda.mjs +303 -210
- package/dist/rambda.umd.js +1 -1
- package/immutable.d.ts +207 -285
- package/index.d.ts +198 -276
- package/package.json +119 -98
- package/src/F.js +1 -1
- package/src/T.js +1 -1
- package/src/_internals/_isInteger.js +1 -1
- package/src/_internals/_objectIs.js +2 -2
- package/src/_internals/baseSlice.js +6 -8
- package/src/_internals/cloneList.js +3 -0
- package/src/_internals/isFalsy.js +5 -5
- package/src/_internals/isObject.js +3 -3
- package/src/_internals/isTruthy.js +5 -5
- package/src/_internals/set.js +4 -4
- package/src/add.js +1 -1
- package/src/adjust.js +5 -6
- package/src/all.js +3 -3
- package/src/allPass.js +4 -4
- package/src/always.js +1 -1
- package/src/and.js +1 -1
- package/src/any.js +3 -3
- package/src/anyPass.js +4 -4
- package/src/append.js +4 -2
- package/src/apply.js +7 -0
- package/src/applySpec.js +33 -59
- package/src/assoc.js +3 -7
- package/src/assocPath.js +22 -25
- package/src/bind.js +9 -0
- package/src/both.js +1 -1
- package/src/chain.js +2 -2
- package/src/clamp.js +6 -6
- package/src/clone.js +10 -10
- package/src/complement.js +1 -1
- package/src/compose.js +6 -6
- package/src/concat.js +2 -2
- package/src/cond.js +3 -3
- package/src/converge.js +11 -11
- package/src/curry.js +2 -2
- package/src/curryN.js +61 -81
- package/src/defaultTo.js +5 -8
- package/src/difference.js +3 -3
- package/src/dissoc.js +4 -4
- package/src/divide.js +1 -1
- package/src/drop.js +1 -1
- package/src/dropLast.js +5 -5
- package/src/dropLastWhile.js +12 -12
- package/src/dropRepeats.js +6 -6
- package/src/dropRepeatsWith.js +7 -7
- package/src/dropWhile.js +9 -9
- package/src/either.js +2 -2
- package/src/endsWith.js +20 -3
- package/src/eqProps.js +5 -10
- package/src/equals.js +119 -38
- package/src/evolve.js +23 -21
- package/src/filter.js +18 -18
- package/src/find.js +4 -4
- package/src/findIndex.js +3 -3
- package/src/findLast.js +4 -4
- package/src/findLastIndex.js +3 -3
- package/src/flatten.js +6 -6
- package/src/flip.js +11 -15
- package/src/forEach.js +10 -12
- package/src/fromPairs.js +2 -2
- package/src/groupBy.js +6 -6
- package/src/groupWith.js +11 -12
- package/src/hasPath.js +5 -5
- package/src/head.js +3 -3
- package/src/identical.js +1 -1
- package/src/identity.js +2 -2
- package/src/ifElse.js +3 -5
- package/src/includes.js +11 -10
- package/src/indexBy.js +11 -11
- package/src/indexOf.js +3 -25
- package/src/init.js +2 -4
- package/src/intersection.js +3 -3
- package/src/intersperse.js +5 -5
- package/src/is.js +2 -2
- package/src/isEmpty.js +5 -5
- package/src/isFunction.js +3 -3
- package/src/isNil.js +1 -1
- package/src/isPromise.js +3 -3
- package/src/join.js +1 -1
- package/src/keys.js +1 -1
- package/src/last.js +4 -4
- package/src/lastIndexOf.js +5 -11
- package/src/length.js +6 -5
- package/src/lens.js +3 -3
- package/src/lensIndex.js +4 -4
- package/src/lensProp.js +4 -4
- package/src/map.js +17 -18
- package/src/match.js +1 -1
- package/src/mathMod.js +2 -2
- package/src/max.js +1 -1
- package/src/maxBy.js +2 -4
- package/src/maybe.js +2 -4
- package/src/mean.js +2 -2
- package/src/median.js +12 -10
- package/src/merge.js +2 -4
- package/src/mergeAll.js +3 -3
- package/src/mergeDeepRight.js +8 -8
- package/src/mergeLeft.js +2 -2
- package/src/min.js +1 -1
- package/src/minBy.js +2 -4
- package/src/modulo.js +1 -1
- package/src/move.js +7 -8
- package/src/multiply.js +1 -1
- package/src/negate.js +1 -1
- package/src/none.js +4 -4
- package/src/not.js +1 -1
- package/src/nth.js +4 -4
- package/src/objOf.js +3 -3
- package/src/of.js +2 -2
- package/src/omit.js +5 -5
- package/src/once.js +6 -6
- package/src/or.js +1 -1
- package/src/over.js +3 -5
- package/src/partial.js +3 -3
- package/src/partition.js +17 -15
- package/src/path.js +6 -6
- package/src/pathEq.js +4 -6
- package/src/pathOr.js +5 -7
- package/src/paths.js +3 -3
- package/src/pick.js +5 -5
- package/src/pickAll.js +6 -6
- package/src/pipe.js +3 -3
- package/src/pluck.js +4 -4
- package/src/prepend.js +3 -3
- package/src/product.js +2 -2
- package/src/prop.js +2 -2
- package/src/propEq.js +3 -5
- package/src/propIs.js +4 -6
- package/src/propOr.js +4 -6
- package/src/props.js +6 -6
- package/src/range.js +4 -4
- package/src/reduce.js +7 -11
- package/src/reject.js +2 -2
- package/src/repeat.js +2 -2
- package/src/replace.js +2 -4
- package/src/reverse.js +3 -4
- package/src/set.js +5 -9
- package/src/slice.js +2 -4
- package/src/sort.js +4 -4
- package/src/sortBy.js +4 -2
- package/src/split.js +1 -1
- package/src/splitAt.js +9 -9
- package/src/splitEvery.js +8 -6
- package/src/splitWhen.js +10 -10
- package/src/startsWith.js +20 -3
- package/src/subtract.js +1 -1
- package/src/sum.js +1 -1
- package/src/symmetricDifference.js +9 -7
- package/src/tail.js +2 -2
- package/src/take.js +2 -4
- package/src/takeLast.js +2 -4
- package/src/takeLastWhile.js +7 -7
- package/src/takeWhile.js +8 -8
- package/src/tap.js +1 -1
- package/src/test.js +5 -3
- package/src/times.js +4 -4
- package/src/toLower.js +1 -1
- package/src/toPairs.js +1 -1
- package/src/toString.js +1 -1
- package/src/toUpper.js +1 -1
- package/src/transpose.js +4 -3
- package/src/trim.js +1 -1
- package/src/tryCatch.js +5 -5
- package/src/type.js +7 -29
- package/src/unapply.js +5 -0
- package/src/union.js +4 -3
- package/src/uniq.js +2 -2
- package/src/uniqWith.js +18 -7
- package/src/unless.js +3 -3
- package/src/update.js +6 -8
- package/src/values.js +2 -2
- package/src/view.js +2 -2
- package/src/when.js +2 -4
- package/src/where.js +5 -5
- package/src/whereEq.js +9 -7
- package/src/without.js +1 -1
- package/src/xor.js +2 -2
- package/src/zip.js +3 -3
- package/src/zipObj.js +4 -6
- 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[
|
|
1
|
+
export function head(listOrString) {
|
|
2
|
+
if (typeof listOrString === 'string') return listOrString[0] || ''
|
|
3
3
|
|
|
4
|
-
return listOrString[
|
|
4
|
+
return listOrString[0]
|
|
5
5
|
}
|
package/src/identical.js
CHANGED
package/src/identity.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export function identity(
|
|
2
|
-
return
|
|
1
|
+
export function identity(x) {
|
|
2
|
+
return x
|
|
3
3
|
}
|
package/src/ifElse.js
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import {
|
|
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,15 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import {_isArray} from './_internals/_isArray'
|
|
2
|
+
import {_indexOf} from './equals'
|
|
3
3
|
|
|
4
|
-
export function includes(valueToFind,
|
|
5
|
-
if (arguments.length === 1)
|
|
6
|
-
|
|
7
|
-
|
|
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)
|
|
8
9
|
}
|
|
9
|
-
if (!
|
|
10
|
-
throw new TypeError(`Cannot read property \'indexOf\' of ${
|
|
10
|
+
if (!iterable) {
|
|
11
|
+
throw new TypeError(`Cannot read property \'indexOf\' of ${iterable}`)
|
|
11
12
|
}
|
|
12
|
-
if (!_isArray(
|
|
13
|
+
if (!_isArray(iterable)) return false
|
|
13
14
|
|
|
14
|
-
return _indexOf(valueToFind,
|
|
15
|
+
return _indexOf(valueToFind, iterable) > -1
|
|
15
16
|
}
|
package/src/indexBy.js
CHANGED
|
@@ -1,28 +1,28 @@
|
|
|
1
|
-
import {
|
|
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[
|
|
7
|
-
toReturn[
|
|
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[
|
|
25
|
-
toReturn[
|
|
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,29 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { type } from './type'
|
|
3
|
-
import { _isArray } from './_internals/_isArray'
|
|
1
|
+
import {_indexOf} from './equals'
|
|
4
2
|
|
|
5
|
-
export function
|
|
6
|
-
if (
|
|
7
|
-
throw new Error(`Cannot read property 'indexOf' of ${list}`)
|
|
8
|
-
}
|
|
9
|
-
const typeOfValue = type(valueToFind)
|
|
10
|
-
if (!['Object', 'Array', 'NaN', 'RegExp'].includes(typeOfValue)) return list.indexOf(valueToFind)
|
|
11
|
-
|
|
12
|
-
let index = -1
|
|
13
|
-
let foundIndex = -1
|
|
14
|
-
const { length } = list
|
|
15
|
-
|
|
16
|
-
while (++index < length && foundIndex === -1){
|
|
17
|
-
if (equals(list[index], valueToFind)){
|
|
18
|
-
foundIndex = index
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
|
|
22
|
-
return foundIndex
|
|
23
|
-
}
|
|
24
|
-
|
|
25
|
-
export function indexOf(valueToFind, list){
|
|
26
|
-
if (arguments.length === 1){
|
|
3
|
+
export function indexOf(valueToFind, list) {
|
|
4
|
+
if (arguments.length === 1) {
|
|
27
5
|
return _list => _indexOf(valueToFind, _list)
|
|
28
6
|
}
|
|
29
7
|
|
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
|
}
|
package/src/intersection.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
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)
|
package/src/intersperse.js
CHANGED
|
@@ -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[
|
|
8
|
+
while (++index < len) {
|
|
9
|
+
if (index === len - 1) {
|
|
10
|
+
willReturn.push(list[index])
|
|
11
11
|
} else {
|
|
12
|
-
willReturn.push(list[
|
|
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 {
|
|
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 ([
|
|
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
package/src/isNil.js
CHANGED
package/src/isPromise.js
CHANGED
package/src/join.js
CHANGED
package/src/keys.js
CHANGED
package/src/last.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export function last(listOrString){
|
|
2
|
-
if (typeof listOrString === 'string'){
|
|
3
|
-
return listOrString[
|
|
1
|
+
export function last(listOrString) {
|
|
2
|
+
if (typeof listOrString === 'string') {
|
|
3
|
+
return listOrString[listOrString.length - 1] || ''
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
-
return listOrString[
|
|
6
|
+
return listOrString[listOrString.length - 1]
|
|
7
7
|
}
|
package/src/lastIndexOf.js
CHANGED
|
@@ -1,15 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {_lastIndexOf} from './equals'
|
|
2
2
|
|
|
3
|
-
export function lastIndexOf(
|
|
4
|
-
if (arguments.length === 1)
|
|
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
|
|
8
|
+
return _lastIndexOf(valueToFind, list)
|
|
15
9
|
}
|
package/src/length.js
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
|
|
2
|
-
if (!x && x !== '' || x.length === undefined){
|
|
3
|
-
return NaN
|
|
4
|
-
}
|
|
1
|
+
import {_isArray} from './_internals/_isArray'
|
|
5
2
|
|
|
6
|
-
|
|
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 {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
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 {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
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 {
|
|
2
|
-
import {
|
|
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[
|
|
8
|
+
while (index < list.length) {
|
|
9
|
+
willReturn[index] = isIndexed ? fn(list[index], index) : fn(list[index])
|
|
12
10
|
|
|
13
11
|
index++
|
|
14
12
|
}
|
|
@@ -16,17 +14,15 @@ 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[
|
|
27
|
-
willReturn[
|
|
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
|
|
|
@@ -35,10 +31,13 @@ export function mapObject(fn, obj){
|
|
|
35
31
|
|
|
36
32
|
export const mapObjIndexed = mapObject
|
|
37
33
|
|
|
38
|
-
export function map(fn,
|
|
39
|
-
if (arguments.length === 1) return
|
|
40
|
-
if (
|
|
41
|
-
|
|
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)
|
|
42
41
|
|
|
43
|
-
return mapObject(fn,
|
|
42
|
+
return mapObject(fn, iterable)
|
|
44
43
|
}
|
package/src/match.js
CHANGED
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
package/src/maxBy.js
CHANGED
package/src/maybe.js
CHANGED
package/src/mean.js
CHANGED
package/src/median.js
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
1
|
-
import {
|
|
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(
|
|
10
|
-
.
|
|
11
|
-
|
|
12
|
-
|
|
9
|
+
return mean(
|
|
10
|
+
Array.prototype.slice
|
|
11
|
+
.call(list, 0)
|
|
12
|
+
.sort((a, b) => {
|
|
13
|
+
if (a === b) return 0
|
|
13
14
|
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
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 {
|
|
2
|
-
import {
|
|
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)
|
package/src/mergeDeepRight.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import {
|
|
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[
|
|
12
|
-
if (type(target[
|
|
13
|
-
willReturn[
|
|
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[
|
|
15
|
+
willReturn[key] = source[key]
|
|
16
16
|
}
|
|
17
17
|
} else {
|
|
18
|
-
willReturn[
|
|
18
|
+
willReturn[key] = source[key]
|
|
19
19
|
}
|
|
20
20
|
})
|
|
21
21
|
|
package/src/mergeLeft.js
CHANGED
package/src/min.js
CHANGED
package/src/minBy.js
CHANGED
package/src/modulo.js
CHANGED
package/src/move.js
CHANGED
|
@@ -1,16 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {curry} from './curry'
|
|
2
|
+
import {cloneList} from './_internals/cloneList'
|
|
2
3
|
|
|
3
|
-
function moveFn(
|
|
4
|
-
fromIndex
|
|
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
|
|
12
|
-
clone[
|
|
13
|
-
clone[
|
|
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
package/src/negate.js
CHANGED
package/src/none.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
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 (
|
|
4
|
+
for (let i = 0; i < list.length; i++) {
|
|
5
|
+
if (predicate(list[i])) return false
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
return
|
|
8
|
+
return true
|
|
9
9
|
}
|