rambda 7.0.2 → 7.1.1
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 +28 -2
- package/README.md +3703 -3294
- package/dist/rambda.js +284 -78
- package/dist/rambda.mjs +270 -78
- package/dist/rambda.umd.js +1 -1
- package/immutable.d.ts +95 -13
- package/index.d.ts +95 -13
- package/package.json +119 -119
- package/src/F.js +1 -1
- package/src/T.js +1 -1
- package/src/_internals/_isInteger.js +1 -1
- package/src/_internals/_keys.js +0 -1
- package/src/_internals/_objectIs.js +2 -7
- package/src/_internals/baseSlice.js +8 -6
- package/src/_internals/cloneList.js +1 -3
- package/src/_internals/createPath.js +3 -0
- package/src/_internals/isFalsy.js +5 -5
- package/src/_internals/isObject.js +2 -2
- package/src/_internals/isTruthy.js +5 -5
- package/src/_internals/set.js +19 -13
- package/src/add.js +1 -1
- package/src/adjust.js +6 -4
- package/src/all.js +3 -3
- package/src/allPass.js +3 -3
- package/src/always.js +2 -2
- package/src/and.js +1 -1
- package/src/any.js +3 -3
- package/src/anyPass.js +3 -3
- package/src/append.js +2 -2
- package/src/apply.js +2 -2
- package/src/applySpec.js +59 -33
- package/src/assoc.js +7 -3
- package/src/assocPath.js +25 -21
- package/src/bind.js +3 -3
- 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 +5 -14
- package/src/concat.js +2 -2
- package/src/cond.js +3 -3
- package/src/converge.js +11 -11
- package/src/count.js +10 -0
- package/src/countBy.js +17 -0
- package/src/curry.js +2 -2
- package/src/curryN.js +81 -61
- package/src/defaultTo.js +3 -3
- 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 +6 -5
- package/src/eqProps.js +6 -4
- package/src/equals.js +64 -65
- package/src/evolve.js +21 -23
- package/src/filter.js +21 -15
- 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 +15 -11
- package/src/forEach.js +12 -10
- package/src/fromPairs.js +2 -2
- package/src/groupBy.js +6 -6
- package/src/groupWith.js +12 -10
- package/src/has.js +1 -1
- package/src/hasPath.js +3 -3
- package/src/head.js +3 -3
- package/src/identical.js +2 -2
- package/src/identity.js +1 -1
- package/src/ifElse.js +5 -3
- package/src/includes.js +6 -6
- package/src/indexBy.js +11 -11
- package/src/indexOf.js +3 -3
- package/src/init.js +7 -3
- 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/isNil.js +1 -1
- package/src/isPromise.js +3 -3
- package/src/join.js +1 -1
- package/src/juxt.js +3 -0
- package/src/keys.js +1 -1
- package/src/last.js +4 -4
- package/src/lastIndexOf.js +3 -3
- package/src/length.js +2 -2
- package/src/lens.js +3 -3
- package/src/lensIndex.js +4 -4
- package/src/lensPath.js +4 -4
- package/src/lensProp.js +4 -4
- package/src/map.js +15 -11
- package/src/match.js +1 -1
- package/src/mathMod.js +3 -3
- package/src/max.js +1 -1
- package/src/maxBy.js +4 -2
- package/src/maybe.js +4 -2
- package/src/mean.js +2 -2
- package/src/median.js +10 -12
- package/src/merge.js +1 -5
- package/src/mergeAll.js +4 -4
- package/src/mergeDeepRight.js +8 -8
- package/src/mergeLeft.js +3 -3
- package/src/mergeRight.js +7 -0
- package/src/mergeWith.js +29 -0
- package/src/min.js +1 -1
- package/src/minBy.js +4 -2
- package/src/modulo.js +1 -1
- package/src/move.js +8 -6
- 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 +6 -6
- package/src/objOf.js +3 -5
- package/src/of.js +2 -2
- package/src/omit.js +8 -8
- package/src/on.js +16 -0
- package/src/once.js +6 -6
- package/src/or.js +1 -1
- package/src/over.js +5 -3
- package/src/partial.js +3 -3
- package/src/partialObject.js +15 -0
- package/src/partition.js +18 -16
- package/src/path.js +9 -8
- package/src/pathEq.js +6 -4
- package/src/pathOr.js +6 -4
- package/src/paths.js +3 -3
- package/src/pick.js +8 -8
- package/src/pickAll.js +9 -9
- package/src/pipe.js +85 -13
- 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 +5 -3
- package/src/propIs.js +6 -4
- package/src/propOr.js +6 -4
- package/src/propSatisfies.js +10 -0
- package/src/props.js +6 -6
- package/src/range.js +4 -4
- package/src/reduce.js +11 -7
- package/src/reject.js +2 -2
- package/src/repeat.js +2 -2
- package/src/replace.js +4 -2
- package/src/reverse.js +4 -3
- package/src/set.js +9 -5
- package/src/slice.js +4 -2
- package/src/sort.js +2 -2
- package/src/sortBy.js +2 -2
- package/src/split.js +1 -1
- package/src/splitAt.js +9 -9
- package/src/splitEvery.js +6 -8
- package/src/splitWhen.js +10 -10
- package/src/startsWith.js +6 -5
- package/src/subtract.js +1 -1
- package/src/sum.js +1 -1
- package/src/symmetricDifference.js +7 -9
- package/src/tail.js +2 -2
- package/src/take.js +5 -3
- package/src/takeLast.js +5 -3
- package/src/takeLastWhile.js +7 -7
- package/src/takeWhile.js +8 -8
- package/src/tap.js +1 -1
- package/src/test.js +3 -5
- 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 +3 -4
- package/src/trim.js +1 -1
- package/src/tryCatch.js +7 -5
- package/src/type.js +5 -5
- package/src/unapply.js +2 -2
- package/src/union.js +3 -3
- package/src/uniq.js +3 -3
- package/src/uniqWith.js +12 -8
- package/src/unless.js +3 -3
- package/src/unwind.js +15 -0
- package/src/update.js +8 -4
- package/src/values.js +2 -2
- package/src/view.js +2 -2
- package/src/when.js +4 -2
- package/src/where.js +5 -5
- package/src/whereAny.js +12 -0
- package/src/whereEq.js +7 -9
- package/src/without.js +4 -4
- package/src/xor.js +2 -2
- package/src/zip.js +3 -3
- package/src/zipObj.js +6 -4
- package/src/zipWith.js +6 -6
- package/src/isFunction.js +0 -5
package/src/median.js
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
import {mean} from './mean'
|
|
1
|
+
import { mean } from './mean.js'
|
|
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 -
|
|
6
|
+
const width = 2 - len % 2
|
|
7
7
|
const idx = (len - width) / 2
|
|
8
8
|
|
|
9
|
-
return mean(
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
if (a === b) return 0
|
|
9
|
+
return mean(Array.prototype.slice
|
|
10
|
+
.call(list, 0)
|
|
11
|
+
.sort((a, b) => {
|
|
12
|
+
if (a === b) return 0
|
|
14
13
|
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
)
|
|
14
|
+
return a < b ? -1 : 1
|
|
15
|
+
})
|
|
16
|
+
.slice(idx, idx + width))
|
|
19
17
|
}
|
package/src/merge.js
CHANGED
package/src/mergeAll.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {map} from './map'
|
|
2
|
-
import {
|
|
1
|
+
import { map } from './map.js'
|
|
2
|
+
import { mergeRight } from './mergeRight.js'
|
|
3
3
|
|
|
4
|
-
export function mergeAll(arr)
|
|
4
|
+
export function mergeAll(arr){
|
|
5
5
|
let willReturn = {}
|
|
6
6
|
map(val => {
|
|
7
|
-
willReturn =
|
|
7
|
+
willReturn = mergeRight(willReturn, val)
|
|
8
8
|
}, arr)
|
|
9
9
|
|
|
10
10
|
return willReturn
|
package/src/mergeDeepRight.js
CHANGED
|
@@ -1,21 +1,21 @@
|
|
|
1
|
-
import {type} from './type'
|
|
1
|
+
import { type } from './type.js'
|
|
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,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { mergeRight } from './mergeRight.js'
|
|
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
|
-
return
|
|
6
|
+
return mergeRight(y, x)
|
|
7
7
|
}
|
package/src/mergeWith.js
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import { curry } from './curry.js'
|
|
2
|
+
|
|
3
|
+
function mergeWithFn(
|
|
4
|
+
mergeFn, a, b
|
|
5
|
+
){
|
|
6
|
+
const willReturn = {}
|
|
7
|
+
|
|
8
|
+
Object.keys(a).forEach(key => {
|
|
9
|
+
if (b[ key ] === undefined){
|
|
10
|
+
willReturn[ key ] = a[ key ]
|
|
11
|
+
} else {
|
|
12
|
+
willReturn[ key ] = mergeFn(a[ key ], b[ key ])
|
|
13
|
+
}
|
|
14
|
+
})
|
|
15
|
+
|
|
16
|
+
Object.keys(b).forEach(key => {
|
|
17
|
+
if (willReturn[ key ] !== undefined) return
|
|
18
|
+
|
|
19
|
+
if (a[ key ] === undefined){
|
|
20
|
+
willReturn[ key ] = b[ key ]
|
|
21
|
+
} else {
|
|
22
|
+
willReturn[ key ] = mergeFn(a[ key ], b[ key ])
|
|
23
|
+
}
|
|
24
|
+
})
|
|
25
|
+
|
|
26
|
+
return willReturn
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
export const mergeWith = curry(mergeWithFn)
|
package/src/min.js
CHANGED
package/src/minBy.js
CHANGED
package/src/modulo.js
CHANGED
package/src/move.js
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { cloneList } from './_internals/cloneList.js'
|
|
2
|
+
import { curry } from './curry.js'
|
|
3
3
|
|
|
4
|
-
function moveFn(
|
|
5
|
-
|
|
4
|
+
function moveFn(
|
|
5
|
+
fromIndex, toIndex, list
|
|
6
|
+
){
|
|
7
|
+
if (fromIndex < 0 || toIndex < 0){
|
|
6
8
|
throw new Error('Rambda.move does not support negative indexes')
|
|
7
9
|
}
|
|
8
10
|
if (fromIndex > list.length - 1 || toIndex > list.length - 1) return list
|
|
9
11
|
|
|
10
12
|
const clone = cloneList(list)
|
|
11
|
-
clone[fromIndex] = list[toIndex]
|
|
12
|
-
clone[toIndex] = list[fromIndex]
|
|
13
|
+
clone[ fromIndex ] = list[ toIndex ]
|
|
14
|
+
clone[ toIndex ] = list[ fromIndex ]
|
|
13
15
|
|
|
14
16
|
return clone
|
|
15
17
|
}
|
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
|
}
|
package/src/not.js
CHANGED
package/src/nth.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export function nth(index,
|
|
2
|
-
if (arguments.length === 1) return
|
|
1
|
+
export function nth(index, input){
|
|
2
|
+
if (arguments.length === 1) return _input => nth(index, _input)
|
|
3
3
|
|
|
4
|
-
const idx = index < 0 ?
|
|
4
|
+
const idx = index < 0 ? input.length + index : index
|
|
5
5
|
|
|
6
|
-
return Object.prototype.toString.call(
|
|
7
|
-
|
|
8
|
-
|
|
6
|
+
return Object.prototype.toString.call(input) === '[object String]' ?
|
|
7
|
+
input.charAt(idx) :
|
|
8
|
+
input[ idx ]
|
|
9
9
|
}
|
package/src/objOf.js
CHANGED
package/src/of.js
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
|
-
export function of(value)
|
|
2
|
-
return [value]
|
|
1
|
+
export function of(value){
|
|
2
|
+
return [ value ]
|
|
3
3
|
}
|
package/src/omit.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
import { createPath } from './_internals/createPath.js'
|
|
2
|
+
|
|
3
|
+
export function omit(propsToOmit, obj){
|
|
2
4
|
if (arguments.length === 1) return _obj => omit(propsToOmit, _obj)
|
|
3
5
|
|
|
4
|
-
if (obj === null || obj === undefined)
|
|
6
|
+
if (obj === null || obj === undefined){
|
|
5
7
|
return undefined
|
|
6
8
|
}
|
|
7
9
|
|
|
8
|
-
const propsToOmitValue =
|
|
9
|
-
typeof propsToOmit === 'string' ? propsToOmit.split(',') : propsToOmit
|
|
10
|
-
|
|
10
|
+
const propsToOmitValue = createPath(propsToOmit, ',')
|
|
11
11
|
const willReturn = {}
|
|
12
12
|
|
|
13
|
-
for (const key in obj)
|
|
14
|
-
if (!propsToOmitValue.includes(key))
|
|
15
|
-
willReturn[key] = obj[key]
|
|
13
|
+
for (const key in obj){
|
|
14
|
+
if (!propsToOmitValue.includes(key)){
|
|
15
|
+
willReturn[ key ] = obj[ key ]
|
|
16
16
|
}
|
|
17
17
|
}
|
|
18
18
|
|
package/src/on.js
ADDED
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
export function on(
|
|
2
|
+
binaryFn, unaryFn, a, b
|
|
3
|
+
){
|
|
4
|
+
if (arguments.length === 3){
|
|
5
|
+
return _b => on(
|
|
6
|
+
binaryFn, unaryFn, a, _b
|
|
7
|
+
)
|
|
8
|
+
}
|
|
9
|
+
if (arguments.length === 2){
|
|
10
|
+
return (_a, _b) => on(
|
|
11
|
+
binaryFn, unaryFn, _a, _b
|
|
12
|
+
)
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
return binaryFn(unaryFn(a), unaryFn(b))
|
|
16
|
+
}
|
package/src/once.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {curry} from './curry'
|
|
1
|
+
import { curry } from './curry.js'
|
|
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,11 +1,13 @@
|
|
|
1
|
-
import {curry} from './curry'
|
|
1
|
+
import { curry } from './curry.js'
|
|
2
2
|
|
|
3
3
|
const Identity = x => ({
|
|
4
4
|
x,
|
|
5
|
-
map: fn => Identity(fn(x)),
|
|
5
|
+
map : fn => Identity(fn(x)),
|
|
6
6
|
})
|
|
7
7
|
|
|
8
|
-
function overFn(
|
|
8
|
+
function overFn(
|
|
9
|
+
lens, fn, object
|
|
10
|
+
){
|
|
9
11
|
return lens(x => Identity(fn(x)))(object).x
|
|
10
12
|
}
|
|
11
13
|
|
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, ...[...args, ...rest])
|
|
9
|
+
return partial(fn, ...[ ...args, ...rest ])
|
|
10
10
|
}
|
|
11
11
|
}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { mergeDeepRight } from './mergeDeepRight.js'
|
|
2
|
+
import { type } from './type.js'
|
|
3
|
+
|
|
4
|
+
export function partialObject(fn, input){
|
|
5
|
+
return rest => {
|
|
6
|
+
if (type(fn) === 'Async'){
|
|
7
|
+
return new Promise((resolve, reject) => {
|
|
8
|
+
fn(mergeDeepRight(rest, input)).then(resolve)
|
|
9
|
+
.catch(reject)
|
|
10
|
+
})
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return fn(mergeDeepRight(rest, input))
|
|
14
|
+
}
|
|
15
|
+
}
|
package/src/partition.js
CHANGED
|
@@ -1,39 +1,41 @@
|
|
|
1
|
-
import {_isArray} from './_internals/_isArray'
|
|
1
|
+
import { _isArray } from './_internals/_isArray.js'
|
|
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(([prop, value]) => {
|
|
7
|
-
if (predicate(value, prop))
|
|
8
|
-
yes[prop] = value
|
|
6
|
+
Object.entries(iterable).forEach(([ prop, value ]) => {
|
|
7
|
+
if (predicate(value, prop)){
|
|
8
|
+
yes[ prop ] = value
|
|
9
9
|
} else {
|
|
10
|
-
no[prop] = value
|
|
10
|
+
no[ prop ] = value
|
|
11
11
|
}
|
|
12
12
|
})
|
|
13
13
|
|
|
14
|
-
return [yes, no]
|
|
14
|
+
return [ yes, no ]
|
|
15
15
|
}
|
|
16
16
|
|
|
17
|
-
export function partitionArray(
|
|
17
|
+
export function partitionArray(
|
|
18
|
+
predicate, list, indexed = false
|
|
19
|
+
){
|
|
18
20
|
const yes = []
|
|
19
21
|
const no = []
|
|
20
22
|
let counter = -1
|
|
21
23
|
|
|
22
|
-
while (counter++ < list.length - 1)
|
|
24
|
+
while (counter++ < list.length - 1){
|
|
23
25
|
if (
|
|
24
|
-
indexed ? predicate(list[counter], counter) : predicate(list[counter])
|
|
25
|
-
)
|
|
26
|
-
yes.push(list[counter])
|
|
26
|
+
indexed ? predicate(list[ counter ], counter) : predicate(list[ counter ])
|
|
27
|
+
){
|
|
28
|
+
yes.push(list[ counter ])
|
|
27
29
|
} else {
|
|
28
|
-
no.push(list[counter])
|
|
30
|
+
no.push(list[ counter ])
|
|
29
31
|
}
|
|
30
32
|
}
|
|
31
33
|
|
|
32
|
-
return [yes, no]
|
|
34
|
+
return [ yes, no ]
|
|
33
35
|
}
|
|
34
36
|
|
|
35
|
-
export function partition(predicate, iterable)
|
|
36
|
-
if (arguments.length === 1)
|
|
37
|
+
export function partition(predicate, iterable){
|
|
38
|
+
if (arguments.length === 1){
|
|
37
39
|
return listHolder => partition(predicate, listHolder)
|
|
38
40
|
}
|
|
39
41
|
if (!_isArray(iterable)) return partitionObject(predicate, iterable)
|
package/src/path.js
CHANGED
|
@@ -1,22 +1,23 @@
|
|
|
1
|
-
|
|
1
|
+
import { createPath } from './_internals/createPath.js'
|
|
2
|
+
|
|
3
|
+
export function path(pathInput, obj){
|
|
2
4
|
if (arguments.length === 1) return _obj => path(pathInput, _obj)
|
|
3
5
|
|
|
4
|
-
if (obj === null || obj === undefined)
|
|
6
|
+
if (obj === null || obj === undefined){
|
|
5
7
|
return undefined
|
|
6
8
|
}
|
|
7
9
|
let willReturn = obj
|
|
8
10
|
let counter = 0
|
|
9
11
|
|
|
10
|
-
const pathArrValue =
|
|
11
|
-
typeof pathInput === 'string' ? pathInput.split('.') : pathInput
|
|
12
|
+
const pathArrValue = createPath(pathInput)
|
|
12
13
|
|
|
13
|
-
while (counter < pathArrValue.length)
|
|
14
|
-
if (willReturn === null || willReturn === undefined)
|
|
14
|
+
while (counter < pathArrValue.length){
|
|
15
|
+
if (willReturn === null || willReturn === undefined){
|
|
15
16
|
return undefined
|
|
16
17
|
}
|
|
17
|
-
if (willReturn[pathArrValue[counter]] === null) return undefined
|
|
18
|
+
if (willReturn[ pathArrValue[ counter ] ] === null) return undefined
|
|
18
19
|
|
|
19
|
-
willReturn = willReturn[pathArrValue[counter]]
|
|
20
|
+
willReturn = willReturn[ pathArrValue[ counter ] ]
|
|
20
21
|
counter++
|
|
21
22
|
}
|
|
22
23
|
|
package/src/pathEq.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import {curry} from './curry'
|
|
2
|
-
import {equals} from './equals'
|
|
3
|
-
import {path} from './path'
|
|
1
|
+
import { curry } from './curry.js'
|
|
2
|
+
import { equals } from './equals.js'
|
|
3
|
+
import { path } from './path.js'
|
|
4
4
|
|
|
5
|
-
function pathEqFn(
|
|
5
|
+
function pathEqFn(
|
|
6
|
+
pathToSearch, target, input
|
|
7
|
+
){
|
|
6
8
|
return equals(path(pathToSearch, input), target)
|
|
7
9
|
}
|
|
8
10
|
|
package/src/pathOr.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import {curry} from './curry'
|
|
2
|
-
import {defaultTo} from './defaultTo'
|
|
3
|
-
import {path} from './path'
|
|
1
|
+
import { curry } from './curry.js'
|
|
2
|
+
import { defaultTo } from './defaultTo.js'
|
|
3
|
+
import { path } from './path.js'
|
|
4
4
|
|
|
5
|
-
function pathOrFn(
|
|
5
|
+
function pathOrFn(
|
|
6
|
+
defaultValue, pathInput, obj
|
|
7
|
+
){
|
|
6
8
|
return defaultTo(defaultValue, path(pathInput, obj))
|
|
7
9
|
}
|
|
8
10
|
|
package/src/paths.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {path} from './path'
|
|
1
|
+
import { path } from './path.js'
|
|
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,18 +1,18 @@
|
|
|
1
|
-
|
|
1
|
+
import { createPath } from './_internals/createPath.js'
|
|
2
|
+
|
|
3
|
+
export function pick(propsToPick, input){
|
|
2
4
|
if (arguments.length === 1) return _input => pick(propsToPick, _input)
|
|
3
5
|
|
|
4
|
-
if (input === null || input === undefined)
|
|
6
|
+
if (input === null || input === undefined){
|
|
5
7
|
return undefined
|
|
6
8
|
}
|
|
7
|
-
const keys =
|
|
8
|
-
typeof propsToPick === 'string' ? propsToPick.split(',') : propsToPick
|
|
9
|
-
|
|
9
|
+
const keys = createPath(propsToPick, ',')
|
|
10
10
|
const willReturn = {}
|
|
11
11
|
let counter = 0
|
|
12
12
|
|
|
13
|
-
while (counter < keys.length)
|
|
14
|
-
if (keys[counter] in input)
|
|
15
|
-
willReturn[keys[counter]] = input[keys[counter]]
|
|
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,20 +1,20 @@
|
|
|
1
|
-
|
|
1
|
+
import { createPath } from './_internals/createPath.js'
|
|
2
|
+
|
|
3
|
+
export function pickAll(propsToPick, obj){
|
|
2
4
|
if (arguments.length === 1) return _obj => pickAll(propsToPick, _obj)
|
|
3
5
|
|
|
4
|
-
if (obj === null || obj === undefined)
|
|
6
|
+
if (obj === null || obj === undefined){
|
|
5
7
|
return undefined
|
|
6
8
|
}
|
|
7
|
-
const keysValue =
|
|
8
|
-
typeof propsToPick === 'string' ? propsToPick.split(',') : propsToPick
|
|
9
|
-
|
|
9
|
+
const keysValue = createPath(propsToPick, ',')
|
|
10
10
|
const willReturn = {}
|
|
11
11
|
let counter = 0
|
|
12
12
|
|
|
13
|
-
while (counter < keysValue.length)
|
|
14
|
-
if (keysValue[counter] in obj)
|
|
15
|
-
willReturn[keysValue[counter]] = obj[keysValue[counter]]
|
|
13
|
+
while (counter < keysValue.length){
|
|
14
|
+
if (keysValue[ counter ] in obj){
|
|
15
|
+
willReturn[ keysValue[ counter ] ] = obj[ keysValue[ counter ] ]
|
|
16
16
|
} else {
|
|
17
|
-
willReturn[keysValue[counter]] = undefined
|
|
17
|
+
willReturn[ keysValue[ counter ] ] = undefined
|
|
18
18
|
}
|
|
19
19
|
counter++
|
|
20
20
|
}
|