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.
- package/CHANGELOG.md +95 -0
- package/README.md +4157 -4921
- package/dist/rambda.esm.js +336 -209
- package/dist/rambda.js +340 -209
- package/dist/rambda.mjs +336 -209
- package/dist/rambda.umd.js +1 -1
- package/immutable.d.ts +203 -284
- package/index.d.ts +194 -275
- package/package.json +119 -95
- 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 +5 -0
- package/src/_internals/isTruthy.js +5 -5
- package/src/_internals/set.js +35 -0
- 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 -22
- package/src/indexBy.js +11 -11
- package/src/indexOf.js +5 -12
- 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 +3 -3
- 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 +7 -10
- 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 +5 -5
- 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/not.js
CHANGED
package/src/nth.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export function nth(index, list){
|
|
1
|
+
export function nth(index, list) {
|
|
2
2
|
if (arguments.length === 1) return _list => nth(index, _list)
|
|
3
3
|
|
|
4
4
|
const idx = index < 0 ? list.length + index : index
|
|
5
5
|
|
|
6
|
-
return Object.prototype.toString.call(list) === '[object String]'
|
|
7
|
-
list.charAt(idx)
|
|
8
|
-
list[
|
|
6
|
+
return Object.prototype.toString.call(list) === '[object String]'
|
|
7
|
+
? list.charAt(idx)
|
|
8
|
+
: list[idx]
|
|
9
9
|
}
|
package/src/objOf.js
CHANGED
package/src/of.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export function of(value){
|
|
2
|
-
return [
|
|
1
|
+
export function of(value) {
|
|
2
|
+
return [value]
|
|
3
3
|
}
|
package/src/omit.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export function omit(propsToOmit, obj){
|
|
1
|
+
export function omit(propsToOmit, obj) {
|
|
2
2
|
if (arguments.length === 1) return _obj => omit(propsToOmit, _obj)
|
|
3
3
|
|
|
4
|
-
if (obj === null || obj === undefined){
|
|
4
|
+
if (obj === null || obj === undefined) {
|
|
5
5
|
return undefined
|
|
6
6
|
}
|
|
7
7
|
|
|
@@ -10,9 +10,9 @@ export function omit(propsToOmit, obj){
|
|
|
10
10
|
|
|
11
11
|
const willReturn = {}
|
|
12
12
|
|
|
13
|
-
for (const key in obj){
|
|
14
|
-
if (!propsToOmitValue.includes(key)){
|
|
15
|
-
willReturn[
|
|
13
|
+
for (const key in obj) {
|
|
14
|
+
if (!propsToOmitValue.includes(key)) {
|
|
15
|
+
willReturn[key] = obj[key]
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
|
package/src/once.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {curry} from './curry'
|
|
2
2
|
|
|
3
|
-
function onceFn(fn, context){
|
|
3
|
+
function onceFn(fn, context) {
|
|
4
4
|
let result
|
|
5
5
|
|
|
6
|
-
return function (){
|
|
7
|
-
if (fn){
|
|
6
|
+
return function () {
|
|
7
|
+
if (fn) {
|
|
8
8
|
result = fn.apply(context || this, arguments)
|
|
9
9
|
fn = null
|
|
10
10
|
}
|
|
@@ -13,8 +13,8 @@ function onceFn(fn, context){
|
|
|
13
13
|
}
|
|
14
14
|
}
|
|
15
15
|
|
|
16
|
-
export function once(fn, context){
|
|
17
|
-
if (arguments.length === 1){
|
|
16
|
+
export function once(fn, context) {
|
|
17
|
+
if (arguments.length === 1) {
|
|
18
18
|
const wrap = onceFn(fn, context)
|
|
19
19
|
|
|
20
20
|
return curry(wrap)
|
package/src/or.js
CHANGED
package/src/over.js
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {curry} from './curry'
|
|
2
2
|
|
|
3
3
|
const Identity = x => ({
|
|
4
4
|
x,
|
|
5
|
-
map
|
|
5
|
+
map: fn => Identity(fn(x)),
|
|
6
6
|
})
|
|
7
7
|
|
|
8
|
-
function overFn(
|
|
9
|
-
lens, fn, object
|
|
10
|
-
){
|
|
8
|
+
function overFn(lens, fn, object) {
|
|
11
9
|
return lens(x => Identity(fn(x)))(object).x
|
|
12
10
|
}
|
|
13
11
|
|
package/src/partial.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export function partial(fn, ...args){
|
|
1
|
+
export function partial(fn, ...args) {
|
|
2
2
|
const len = fn.length
|
|
3
3
|
|
|
4
4
|
return (...rest) => {
|
|
5
|
-
if (args.length + rest.length >= len){
|
|
5
|
+
if (args.length + rest.length >= len) {
|
|
6
6
|
return fn(...args, ...rest)
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
return partial(fn, ...[
|
|
9
|
+
return partial(fn, ...[...args, ...rest])
|
|
10
10
|
}
|
|
11
11
|
}
|
package/src/partition.js
CHANGED
|
@@ -1,37 +1,39 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {_isArray} from './_internals/_isArray'
|
|
2
2
|
|
|
3
|
-
export function partitionObject(predicate, iterable){
|
|
3
|
+
export function partitionObject(predicate, iterable) {
|
|
4
4
|
const yes = {}
|
|
5
5
|
const no = {}
|
|
6
|
-
Object.entries(iterable).forEach(([
|
|
7
|
-
if (predicate(value, prop)){
|
|
8
|
-
yes[
|
|
6
|
+
Object.entries(iterable).forEach(([prop, value]) => {
|
|
7
|
+
if (predicate(value, prop)) {
|
|
8
|
+
yes[prop] = value
|
|
9
9
|
} else {
|
|
10
|
-
no[
|
|
10
|
+
no[prop] = value
|
|
11
11
|
}
|
|
12
12
|
})
|
|
13
13
|
|
|
14
|
-
return [
|
|
14
|
+
return [yes, no]
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
export function partitionArray(predicate, list, indexed = false){
|
|
17
|
+
export function partitionArray(predicate, list, indexed = false) {
|
|
18
18
|
const yes = []
|
|
19
19
|
const no = []
|
|
20
20
|
let counter = -1
|
|
21
21
|
|
|
22
|
-
while (counter++ < list.length - 1){
|
|
23
|
-
if (
|
|
24
|
-
|
|
22
|
+
while (counter++ < list.length - 1) {
|
|
23
|
+
if (
|
|
24
|
+
indexed ? predicate(list[counter], counter) : predicate(list[counter])
|
|
25
|
+
) {
|
|
26
|
+
yes.push(list[counter])
|
|
25
27
|
} else {
|
|
26
|
-
no.push(list[
|
|
28
|
+
no.push(list[counter])
|
|
27
29
|
}
|
|
28
30
|
}
|
|
29
31
|
|
|
30
|
-
return [
|
|
32
|
+
return [yes, no]
|
|
31
33
|
}
|
|
32
34
|
|
|
33
|
-
export function partition(predicate, iterable){
|
|
34
|
-
if (arguments.length === 1){
|
|
35
|
+
export function partition(predicate, iterable) {
|
|
36
|
+
if (arguments.length === 1) {
|
|
35
37
|
return listHolder => partition(predicate, listHolder)
|
|
36
38
|
}
|
|
37
39
|
if (!_isArray(iterable)) return partitionObject(predicate, iterable)
|
package/src/path.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export function path(pathInput, obj){
|
|
1
|
+
export function path(pathInput, obj) {
|
|
2
2
|
if (arguments.length === 1) return _obj => path(pathInput, _obj)
|
|
3
3
|
|
|
4
|
-
if (obj === null || obj === undefined){
|
|
4
|
+
if (obj === null || obj === undefined) {
|
|
5
5
|
return undefined
|
|
6
6
|
}
|
|
7
7
|
let willReturn = obj
|
|
@@ -10,13 +10,13 @@ export function path(pathInput, obj){
|
|
|
10
10
|
const pathArrValue =
|
|
11
11
|
typeof pathInput === 'string' ? pathInput.split('.') : pathInput
|
|
12
12
|
|
|
13
|
-
while (counter < pathArrValue.length){
|
|
14
|
-
if (willReturn === null || willReturn === undefined){
|
|
13
|
+
while (counter < pathArrValue.length) {
|
|
14
|
+
if (willReturn === null || willReturn === undefined) {
|
|
15
15
|
return undefined
|
|
16
16
|
}
|
|
17
|
-
if(willReturn[
|
|
17
|
+
if (willReturn[pathArrValue[counter]] === null) return undefined
|
|
18
18
|
|
|
19
|
-
willReturn = willReturn[
|
|
19
|
+
willReturn = willReturn[pathArrValue[counter]]
|
|
20
20
|
counter++
|
|
21
21
|
}
|
|
22
22
|
|
package/src/pathEq.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import {curry} from './curry'
|
|
2
|
+
import {equals} from './equals'
|
|
3
|
+
import {path} from './path'
|
|
4
4
|
|
|
5
|
-
function pathEqFn(
|
|
6
|
-
pathToSearch, target, input
|
|
7
|
-
){
|
|
5
|
+
function pathEqFn(pathToSearch, target, input) {
|
|
8
6
|
return equals(path(pathToSearch, input), target)
|
|
9
7
|
}
|
|
10
8
|
|
package/src/pathOr.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import {curry} from './curry'
|
|
2
|
+
import {defaultTo} from './defaultTo'
|
|
3
|
+
import {path} from './path'
|
|
4
4
|
|
|
5
|
-
function pathOrFn(
|
|
6
|
-
defaultValue,
|
|
7
|
-
){
|
|
8
|
-
return defaultTo(defaultValue, path(list, obj))
|
|
5
|
+
function pathOrFn(defaultValue, pathInput, obj) {
|
|
6
|
+
return defaultTo(defaultValue, path(pathInput, obj))
|
|
9
7
|
}
|
|
10
8
|
|
|
11
9
|
export const pathOr = curry(pathOrFn)
|
package/src/paths.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {path} from './path'
|
|
2
2
|
|
|
3
|
-
export function paths(pathsToSearch, obj){
|
|
4
|
-
if (arguments.length === 1){
|
|
3
|
+
export function paths(pathsToSearch, obj) {
|
|
4
|
+
if (arguments.length === 1) {
|
|
5
5
|
return _obj => paths(pathsToSearch, _obj)
|
|
6
6
|
}
|
|
7
7
|
|
package/src/pick.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export function pick(propsToPick, input){
|
|
1
|
+
export function pick(propsToPick, input) {
|
|
2
2
|
if (arguments.length === 1) return _input => pick(propsToPick, _input)
|
|
3
3
|
|
|
4
|
-
if (input === null || input === undefined){
|
|
4
|
+
if (input === null || input === undefined) {
|
|
5
5
|
return undefined
|
|
6
6
|
}
|
|
7
7
|
const keys =
|
|
@@ -10,9 +10,9 @@ export function pick(propsToPick, input){
|
|
|
10
10
|
const willReturn = {}
|
|
11
11
|
let counter = 0
|
|
12
12
|
|
|
13
|
-
while (counter < keys.length){
|
|
14
|
-
if (keys[
|
|
15
|
-
willReturn[
|
|
13
|
+
while (counter < keys.length) {
|
|
14
|
+
if (keys[counter] in input) {
|
|
15
|
+
willReturn[keys[counter]] = input[keys[counter]]
|
|
16
16
|
}
|
|
17
17
|
counter++
|
|
18
18
|
}
|
package/src/pickAll.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export function pickAll(propsToPick, obj){
|
|
1
|
+
export function pickAll(propsToPick, obj) {
|
|
2
2
|
if (arguments.length === 1) return _obj => pickAll(propsToPick, _obj)
|
|
3
3
|
|
|
4
|
-
if (obj === null || obj === undefined){
|
|
4
|
+
if (obj === null || obj === undefined) {
|
|
5
5
|
return undefined
|
|
6
6
|
}
|
|
7
7
|
const keysValue =
|
|
@@ -10,11 +10,11 @@ export function pickAll(propsToPick, obj){
|
|
|
10
10
|
const willReturn = {}
|
|
11
11
|
let counter = 0
|
|
12
12
|
|
|
13
|
-
while (counter < keysValue.length){
|
|
14
|
-
if (keysValue[
|
|
15
|
-
willReturn[
|
|
13
|
+
while (counter < keysValue.length) {
|
|
14
|
+
if (keysValue[counter] in obj) {
|
|
15
|
+
willReturn[keysValue[counter]] = obj[keysValue[counter]]
|
|
16
16
|
} else {
|
|
17
|
-
willReturn[
|
|
17
|
+
willReturn[keysValue[counter]] = undefined
|
|
18
18
|
}
|
|
19
19
|
counter++
|
|
20
20
|
}
|
package/src/pipe.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export function pipe(...fns){
|
|
1
|
+
export function pipe(...fns) {
|
|
2
2
|
if (fns.length === 0)
|
|
3
3
|
throw new Error('pipe requires at least one argument')
|
|
4
4
|
|
|
5
5
|
return (...args) => {
|
|
6
6
|
const list = fns.slice()
|
|
7
|
-
if (list.length > 0){
|
|
7
|
+
if (list.length > 0) {
|
|
8
8
|
const fn = list.shift()
|
|
9
9
|
let result = fn(...args)
|
|
10
|
-
while (list.length > 0){
|
|
10
|
+
while (list.length > 0) {
|
|
11
11
|
result = list.shift()(result)
|
|
12
12
|
}
|
|
13
13
|
|
package/src/pluck.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {map} from './map'
|
|
2
2
|
|
|
3
|
-
export function pluck(property, list){
|
|
3
|
+
export function pluck(property, list) {
|
|
4
4
|
if (arguments.length === 1) return _list => pluck(property, _list)
|
|
5
5
|
|
|
6
6
|
const willReturn = []
|
|
7
7
|
|
|
8
8
|
map(x => {
|
|
9
|
-
if (x[
|
|
10
|
-
willReturn.push(x[
|
|
9
|
+
if (x[property] !== undefined) {
|
|
10
|
+
willReturn.push(x[property])
|
|
11
11
|
}
|
|
12
12
|
}, list)
|
|
13
13
|
|
package/src/prepend.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export function prepend(x, input){
|
|
1
|
+
export function prepend(x, input) {
|
|
2
2
|
if (arguments.length === 1) return _input => prepend(x, _input)
|
|
3
3
|
|
|
4
|
-
if (typeof input === 'string') return [
|
|
4
|
+
if (typeof input === 'string') return [x].concat(input.split(''))
|
|
5
5
|
|
|
6
|
-
return [
|
|
6
|
+
return [x].concat(input)
|
|
7
7
|
}
|
package/src/product.js
CHANGED
package/src/prop.js
CHANGED
package/src/propEq.js
CHANGED
|
@@ -1,11 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {curry} from './curry'
|
|
2
2
|
|
|
3
|
-
function propEqFn(
|
|
4
|
-
propToFind, valueToMatch, obj
|
|
5
|
-
){
|
|
3
|
+
function propEqFn(propToFind, valueToMatch, obj) {
|
|
6
4
|
if (!obj) return false
|
|
7
5
|
|
|
8
|
-
return obj[
|
|
6
|
+
return obj[propToFind] === valueToMatch
|
|
9
7
|
}
|
|
10
8
|
|
|
11
9
|
export const propEq = curry(propEqFn)
|
package/src/propIs.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import {curry} from './curry'
|
|
2
|
+
import {is} from './is'
|
|
3
3
|
|
|
4
|
-
function propIsFn(
|
|
5
|
-
targetPrototype, property
|
|
6
|
-
){
|
|
7
|
-
return is(targetPrototype, obj[ property ])
|
|
4
|
+
function propIsFn(targetPrototype, property, obj) {
|
|
5
|
+
return is(targetPrototype, obj[property])
|
|
8
6
|
}
|
|
9
7
|
|
|
10
8
|
export const propIs = curry(propIsFn)
|
package/src/propOr.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import {curry} from './curry'
|
|
2
|
+
import {defaultTo} from './defaultTo'
|
|
3
3
|
|
|
4
|
-
function propOrFn(
|
|
5
|
-
defaultValue, property, obj
|
|
6
|
-
){
|
|
4
|
+
function propOrFn(defaultValue, property, obj) {
|
|
7
5
|
if (!obj) return defaultValue
|
|
8
6
|
|
|
9
|
-
return defaultTo(defaultValue, obj[
|
|
7
|
+
return defaultTo(defaultValue, obj[property])
|
|
10
8
|
}
|
|
11
9
|
|
|
12
10
|
export const propOr = curry(propOrFn)
|
package/src/props.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import {_isArray} from './_internals/_isArray'
|
|
2
|
+
import {mapArray} from './map'
|
|
3
3
|
|
|
4
|
-
export function props(propsToPick, obj){
|
|
5
|
-
if (arguments.length === 1){
|
|
4
|
+
export function props(propsToPick, obj) {
|
|
5
|
+
if (arguments.length === 1) {
|
|
6
6
|
return _obj => props(propsToPick, _obj)
|
|
7
7
|
}
|
|
8
|
-
if (!_isArray(propsToPick)){
|
|
8
|
+
if (!_isArray(propsToPick)) {
|
|
9
9
|
throw new Error('propsToPick is not a list')
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
return mapArray(prop => obj[
|
|
12
|
+
return mapArray(prop => obj[prop], propsToPick)
|
|
13
13
|
}
|
package/src/range.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export function range(start, end){
|
|
1
|
+
export function range(start, end) {
|
|
2
2
|
if (arguments.length === 1) return _end => range(start, _end)
|
|
3
3
|
|
|
4
|
-
if (Number.isNaN(Number(start)) || Number.isNaN(Number(end))){
|
|
4
|
+
if (Number.isNaN(Number(start)) || Number.isNaN(Number(end))) {
|
|
5
5
|
throw new TypeError('Both arguments to range must be numbers')
|
|
6
6
|
}
|
|
7
7
|
|
|
@@ -10,8 +10,8 @@ export function range(start, end){
|
|
|
10
10
|
const len = end - start
|
|
11
11
|
const willReturn = Array(len)
|
|
12
12
|
|
|
13
|
-
for (let i = 0; i < len; i++){
|
|
14
|
-
willReturn[
|
|
13
|
+
for (let i = 0; i < len; i++) {
|
|
14
|
+
willReturn[i] = start + i
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
return willReturn
|
package/src/reduce.js
CHANGED
|
@@ -1,20 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import {_isArray} from './_internals/_isArray'
|
|
2
|
+
import {_keys} from './_internals/_keys'
|
|
3
|
+
import {curry} from './curry'
|
|
4
4
|
|
|
5
|
-
function reduceFn(
|
|
6
|
-
|
|
7
|
-
){
|
|
8
|
-
if (!_isArray(list)){
|
|
5
|
+
function reduceFn(reducer, acc, list) {
|
|
6
|
+
if (!_isArray(list)) {
|
|
9
7
|
throw new TypeError('reduce: list must be array or iterable')
|
|
10
8
|
}
|
|
11
9
|
let index = 0
|
|
12
10
|
const len = list.length
|
|
13
11
|
|
|
14
|
-
while (index < len){
|
|
15
|
-
acc = reducer(
|
|
16
|
-
acc, list[ index ], index, list
|
|
17
|
-
)
|
|
12
|
+
while (index < len) {
|
|
13
|
+
acc = reducer(acc, list[index], index, list)
|
|
18
14
|
index++
|
|
19
15
|
}
|
|
20
16
|
|
package/src/reject.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {filter} from './filter'
|
|
2
2
|
|
|
3
|
-
export function reject(predicate, list){
|
|
3
|
+
export function reject(predicate, list) {
|
|
4
4
|
if (arguments.length === 1) return _list => reject(predicate, _list)
|
|
5
5
|
|
|
6
6
|
return filter(x => !predicate(x), list)
|
package/src/repeat.js
CHANGED
package/src/replace.js
CHANGED
package/src/reverse.js
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
export function reverse(listOrString){
|
|
2
|
-
if (typeof listOrString === 'string'){
|
|
3
|
-
return listOrString.split('').reverse()
|
|
4
|
-
.join('')
|
|
1
|
+
export function reverse(listOrString) {
|
|
2
|
+
if (typeof listOrString === 'string') {
|
|
3
|
+
return listOrString.split('').reverse().join('')
|
|
5
4
|
}
|
|
6
5
|
|
|
7
6
|
const clone = listOrString.slice()
|
package/src/set.js
CHANGED
|
@@ -1,13 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import {always} from './always'
|
|
2
|
+
import {curry} from './curry'
|
|
3
|
+
import {over} from './over'
|
|
4
4
|
|
|
5
|
-
function setFn(
|
|
6
|
-
lens, replacer, x
|
|
7
|
-
){
|
|
8
|
-
return over(
|
|
9
|
-
lens, always(replacer), x
|
|
10
|
-
)
|
|
5
|
+
function setFn(lens, replacer, x) {
|
|
6
|
+
return over(lens, always(replacer), x)
|
|
11
7
|
}
|
|
12
8
|
|
|
13
9
|
export const set = curry(setFn)
|
package/src/slice.js
CHANGED
package/src/sort.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
if (arguments.length === 1) return _list => sort(sortFn, _list)
|
|
1
|
+
import {cloneList} from './_internals/cloneList'
|
|
3
2
|
|
|
4
|
-
|
|
3
|
+
export function sort(sortFn, list) {
|
|
4
|
+
if (arguments.length === 1) return _list => sort(sortFn, _list)
|
|
5
5
|
|
|
6
|
-
return
|
|
6
|
+
return cloneList(list).sort(sortFn)
|
|
7
7
|
}
|
package/src/sortBy.js
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
|
-
|
|
1
|
+
import {cloneList} from './_internals/cloneList'
|
|
2
|
+
|
|
3
|
+
export function sortBy(sortFn, list) {
|
|
2
4
|
if (arguments.length === 1) return _list => sortBy(sortFn, _list)
|
|
3
5
|
|
|
4
|
-
const clone = list
|
|
6
|
+
const clone = cloneList(list)
|
|
5
7
|
|
|
6
8
|
return clone.sort((a, b) => {
|
|
7
9
|
const aSortResult = sortFn(a)
|
package/src/split.js
CHANGED
package/src/splitAt.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import {_isArray} from './_internals/_isArray'
|
|
2
|
+
import {drop} from './drop'
|
|
3
|
+
import {maybe} from './maybe'
|
|
4
|
+
import {take} from './take'
|
|
5
5
|
|
|
6
|
-
export function splitAt(index, input){
|
|
7
|
-
if (arguments.length === 1){
|
|
6
|
+
export function splitAt(index, input) {
|
|
7
|
+
if (arguments.length === 1) {
|
|
8
8
|
return _list => splitAt(index, _list)
|
|
9
9
|
}
|
|
10
|
-
if (!input) throw new TypeError(`Cannot read property 'slice' of ${
|
|
10
|
+
if (!input) throw new TypeError(`Cannot read property 'slice' of ${input}`)
|
|
11
11
|
|
|
12
|
-
if (!_isArray(input) && typeof input !== 'string') return [
|
|
12
|
+
if (!_isArray(input) && typeof input !== 'string') return [[], []]
|
|
13
13
|
|
|
14
14
|
const correctIndex = maybe(
|
|
15
15
|
index < 0,
|
|
@@ -17,5 +17,5 @@ export function splitAt(index, input){
|
|
|
17
17
|
index
|
|
18
18
|
)
|
|
19
19
|
|
|
20
|
-
return [
|
|
20
|
+
return [take(correctIndex, input), drop(correctIndex, input)]
|
|
21
21
|
}
|