rambda 7.0.3 → 7.1.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.
- package/CHANGELOG.md +18 -2
- package/README.md +3541 -2696
- package/dist/rambda.js +282 -76
- package/dist/rambda.mjs +268 -76
- package/dist/rambda.umd.js +1 -1
- package/immutable.d.ts +91 -10
- package/index.d.ts +91 -10
- 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 +3 -3
- 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/test.js
CHANGED
|
@@ -1,10 +1,8 @@
|
|
|
1
|
-
export function test(pattern, str)
|
|
1
|
+
export function test(pattern, str){
|
|
2
2
|
if (arguments.length === 1) return _str => test(pattern, _str)
|
|
3
3
|
|
|
4
|
-
if (typeof pattern === 'string')
|
|
5
|
-
throw new TypeError(
|
|
6
|
-
`‘test’ requires a value of type RegExp as its first argument; received "${pattern}"`
|
|
7
|
-
)
|
|
4
|
+
if (typeof pattern === 'string'){
|
|
5
|
+
throw new TypeError(`‘test’ requires a value of type RegExp as its first argument; received "${ pattern }"`)
|
|
8
6
|
}
|
|
9
7
|
|
|
10
8
|
return str.search(pattern) !== -1
|
package/src/times.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {map} from './map'
|
|
2
|
-
import {range} from './range'
|
|
1
|
+
import { map } from './map.js'
|
|
2
|
+
import { range } from './range.js'
|
|
3
3
|
|
|
4
|
-
export function times(fn, howMany)
|
|
4
|
+
export function times(fn, howMany){
|
|
5
5
|
if (arguments.length === 1) return _howMany => times(fn, _howMany)
|
|
6
|
-
if (!Number.isInteger(howMany) || howMany < 0)
|
|
6
|
+
if (!Number.isInteger(howMany) || howMany < 0){
|
|
7
7
|
throw new RangeError('n must be an integer')
|
|
8
8
|
}
|
|
9
9
|
|
package/src/toLower.js
CHANGED
package/src/toPairs.js
CHANGED
package/src/toString.js
CHANGED
package/src/toUpper.js
CHANGED
package/src/transpose.js
CHANGED
|
@@ -1,10 +1,9 @@
|
|
|
1
|
-
import {_isArray} from './_internals/_isArray'
|
|
1
|
+
import { _isArray } from './_internals/_isArray.js'
|
|
2
2
|
|
|
3
|
-
export function transpose(array)
|
|
3
|
+
export function transpose(array){
|
|
4
4
|
return array.reduce((acc, el) => {
|
|
5
5
|
el.forEach((nestedEl, i) =>
|
|
6
|
-
_isArray(acc[i]) ? acc[i].push(nestedEl) : acc.push([nestedEl])
|
|
7
|
-
)
|
|
6
|
+
_isArray(acc[ i ]) ? acc[ i ].push(nestedEl) : acc.push([ nestedEl ]))
|
|
8
7
|
|
|
9
8
|
return acc
|
|
10
9
|
}, [])
|
package/src/trim.js
CHANGED
package/src/tryCatch.js
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { type } from './type.js'
|
|
2
2
|
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
3
|
+
const isFunction = x => [ 'Promise', 'Function' ].includes(type(x))
|
|
4
|
+
|
|
5
|
+
export function tryCatch(fn, fallback){
|
|
6
|
+
if (!isFunction(fn)){
|
|
7
|
+
throw new Error(`R.tryCatch | fn '${ fn }'`)
|
|
6
8
|
}
|
|
7
9
|
const passFallback = isFunction(fallback)
|
|
8
10
|
|
|
9
11
|
return (...inputs) => {
|
|
10
12
|
try {
|
|
11
13
|
return fn(...inputs)
|
|
12
|
-
} catch (e)
|
|
14
|
+
} catch (e){
|
|
13
15
|
return passFallback ? fallback(e, ...inputs) : fallback
|
|
14
16
|
}
|
|
15
17
|
}
|
package/src/type.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
|
-
export function type(input)
|
|
2
|
-
if (input === null)
|
|
1
|
+
export function type(input){
|
|
2
|
+
if (input === null){
|
|
3
3
|
return 'Null'
|
|
4
|
-
} else if (input === undefined)
|
|
4
|
+
} else if (input === undefined){
|
|
5
5
|
return 'Undefined'
|
|
6
|
-
} else if (Number.isNaN(input))
|
|
6
|
+
} else if (Number.isNaN(input)){
|
|
7
7
|
return 'NaN'
|
|
8
8
|
}
|
|
9
9
|
const typeResult = Object.prototype.toString.call(input).slice(8, -1)
|
|
10
10
|
|
|
11
|
-
return typeResult === 'AsyncFunction' ? '
|
|
11
|
+
return typeResult === 'AsyncFunction' ? 'Promise' : typeResult
|
|
12
12
|
}
|
package/src/unapply.js
CHANGED
package/src/union.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { cloneList } from './_internals/cloneList.js'
|
|
2
|
+
import { includes } from './includes.js'
|
|
3
3
|
|
|
4
|
-
export function union(x, y)
|
|
4
|
+
export function union(x, y){
|
|
5
5
|
if (arguments.length === 1) return _y => union(x, _y)
|
|
6
6
|
|
|
7
7
|
const toReturn = cloneList(x)
|
package/src/uniq.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {_Set} from './_internals/set'
|
|
1
|
+
import { _Set } from './_internals/set.js'
|
|
2
2
|
|
|
3
|
-
export function uniq(list)
|
|
3
|
+
export function uniq(list){
|
|
4
4
|
const set = new _Set()
|
|
5
5
|
const willReturn = []
|
|
6
6
|
list.forEach(item => {
|
|
7
|
-
if (set.checkUniqueness(item))
|
|
7
|
+
if (set.checkUniqueness(item)){
|
|
8
8
|
willReturn.push(item)
|
|
9
9
|
}
|
|
10
10
|
})
|
package/src/uniqWith.js
CHANGED
|
@@ -1,11 +1,13 @@
|
|
|
1
|
-
function includesWith(
|
|
1
|
+
function includesWith(
|
|
2
|
+
predicate, target, list
|
|
3
|
+
){
|
|
2
4
|
let willReturn = false
|
|
3
5
|
let index = -1
|
|
4
6
|
|
|
5
|
-
while (++index < list.length && !willReturn)
|
|
6
|
-
const value = list[index]
|
|
7
|
+
while (++index < list.length && !willReturn){
|
|
8
|
+
const value = list[ index ]
|
|
7
9
|
|
|
8
|
-
if (predicate(target, value))
|
|
10
|
+
if (predicate(target, value)){
|
|
9
11
|
willReturn = true
|
|
10
12
|
}
|
|
11
13
|
}
|
|
@@ -13,16 +15,18 @@ function includesWith(predicate, target, list) {
|
|
|
13
15
|
return willReturn
|
|
14
16
|
}
|
|
15
17
|
|
|
16
|
-
export function uniqWith(predicate, list)
|
|
18
|
+
export function uniqWith(predicate, list){
|
|
17
19
|
if (arguments.length === 1) return _list => uniqWith(predicate, _list)
|
|
18
20
|
|
|
19
21
|
let index = -1
|
|
20
22
|
const willReturn = []
|
|
21
23
|
|
|
22
|
-
while (++index < list.length)
|
|
23
|
-
const value = list[index]
|
|
24
|
+
while (++index < list.length){
|
|
25
|
+
const value = list[ index ]
|
|
24
26
|
|
|
25
|
-
if (!includesWith(
|
|
27
|
+
if (!includesWith(
|
|
28
|
+
predicate, value, willReturn
|
|
29
|
+
)){
|
|
26
30
|
willReturn.push(value)
|
|
27
31
|
}
|
|
28
32
|
}
|
package/src/unless.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
export function unless(predicate, whenFalse)
|
|
2
|
-
if (arguments.length === 1)
|
|
1
|
+
export function unless(predicate, whenFalse){
|
|
2
|
+
if (arguments.length === 1){
|
|
3
3
|
return _whenFalse => unless(predicate, _whenFalse)
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
-
return input =>
|
|
6
|
+
return input => predicate(input) ? input : whenFalse(input)
|
|
7
7
|
}
|
package/src/unwind.js
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
import { _isArray } from './_internals/_isArray.js'
|
|
2
|
+
import { mapArray } from './map.js'
|
|
3
|
+
|
|
4
|
+
export function unwind(property, obj){
|
|
5
|
+
if (arguments.length === 1){
|
|
6
|
+
return _obj => unwind(property, _obj)
|
|
7
|
+
}
|
|
8
|
+
|
|
9
|
+
if (!_isArray(obj[ property ])) return [ obj ]
|
|
10
|
+
|
|
11
|
+
return mapArray(x => ({
|
|
12
|
+
...obj,
|
|
13
|
+
[ property ] : x,
|
|
14
|
+
}), obj[ property ])
|
|
15
|
+
}
|
package/src/update.js
CHANGED
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { cloneList } from './_internals/cloneList.js'
|
|
2
|
+
import { curry } from './curry.js'
|
|
3
3
|
|
|
4
|
-
function updateFn(
|
|
4
|
+
function updateFn(
|
|
5
|
+
index, newValue, list
|
|
6
|
+
){
|
|
5
7
|
const clone = cloneList(list)
|
|
6
8
|
if (index === -1) return clone.fill(newValue, index)
|
|
7
9
|
|
|
8
|
-
return clone.fill(
|
|
10
|
+
return clone.fill(
|
|
11
|
+
newValue, index, index + 1
|
|
12
|
+
)
|
|
9
13
|
}
|
|
10
14
|
|
|
11
15
|
export const update = curry(updateFn)
|
package/src/values.js
CHANGED
package/src/view.js
CHANGED
package/src/when.js
CHANGED
package/src/where.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export function where(conditions, input)
|
|
2
|
-
if (input === undefined)
|
|
1
|
+
export function where(conditions, input){
|
|
2
|
+
if (input === undefined){
|
|
3
3
|
return _input => where(conditions, _input)
|
|
4
4
|
}
|
|
5
5
|
let flag = true
|
|
6
|
-
for (const prop in conditions)
|
|
7
|
-
const result = conditions[prop](input[prop])
|
|
8
|
-
if (flag && result === false)
|
|
6
|
+
for (const prop in conditions){
|
|
7
|
+
const result = conditions[ prop ](input[ prop ])
|
|
8
|
+
if (flag && result === false){
|
|
9
9
|
flag = false
|
|
10
10
|
}
|
|
11
11
|
}
|
package/src/whereAny.js
ADDED
package/src/whereEq.js
CHANGED
|
@@ -1,16 +1,14 @@
|
|
|
1
|
-
import {equals} from './equals'
|
|
2
|
-
import {filter} from './filter'
|
|
1
|
+
import { equals } from './equals.js'
|
|
2
|
+
import { filter } from './filter.js'
|
|
3
3
|
|
|
4
|
-
export function whereEq(condition, input)
|
|
5
|
-
if (arguments.length === 1)
|
|
4
|
+
export function whereEq(condition, input){
|
|
5
|
+
if (arguments.length === 1){
|
|
6
6
|
return _input => whereEq(condition, _input)
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
const result = filter(
|
|
10
|
-
(conditionValue, conditionProp)
|
|
11
|
-
|
|
12
|
-
condition
|
|
13
|
-
)
|
|
9
|
+
const result = filter((conditionValue, conditionProp) =>
|
|
10
|
+
equals(conditionValue, input[ conditionProp ]),
|
|
11
|
+
condition)
|
|
14
12
|
|
|
15
13
|
return Object.keys(result).length === Object.keys(condition).length
|
|
16
14
|
}
|
package/src/without.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { _indexOf } from './equals.js'
|
|
2
|
+
import { reduce } from './reduce.js'
|
|
3
3
|
|
|
4
|
-
export function without(matchAgainst, source)
|
|
5
|
-
if (source === undefined)
|
|
4
|
+
export function without(matchAgainst, source){
|
|
5
|
+
if (source === undefined){
|
|
6
6
|
return _source => without(matchAgainst, _source)
|
|
7
7
|
}
|
|
8
8
|
|
package/src/xor.js
CHANGED
package/src/zip.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
export function zip(left, right)
|
|
1
|
+
export function zip(left, right){
|
|
2
2
|
if (arguments.length === 1) return _right => zip(left, _right)
|
|
3
3
|
|
|
4
4
|
const result = []
|
|
5
5
|
const length = Math.min(left.length, right.length)
|
|
6
6
|
|
|
7
|
-
for (let i = 0; i < length; i++)
|
|
8
|
-
result[i] = [left[i], right[i]]
|
|
7
|
+
for (let i = 0; i < length; i++){
|
|
8
|
+
result[ i ] = [ left[ i ], right[ i ] ]
|
|
9
9
|
}
|
|
10
10
|
|
|
11
11
|
return result
|
package/src/zipObj.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import {take} from './take'
|
|
1
|
+
import { take } from './take.js'
|
|
2
2
|
|
|
3
|
-
export function zipObj(keys, values)
|
|
3
|
+
export function zipObj(keys, values){
|
|
4
4
|
if (arguments.length === 1) return yHolder => zipObj(keys, yHolder)
|
|
5
5
|
|
|
6
|
-
return take(values.length, keys).reduce((
|
|
7
|
-
prev
|
|
6
|
+
return take(values.length, keys).reduce((
|
|
7
|
+
prev, xInstance, i
|
|
8
|
+
) => {
|
|
9
|
+
prev[ xInstance ] = values[ i ]
|
|
8
10
|
|
|
9
11
|
return prev
|
|
10
12
|
}, {})
|
package/src/zipWith.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {curry} from './curry'
|
|
2
|
-
import {take} from './take'
|
|
1
|
+
import { curry } from './curry.js'
|
|
2
|
+
import { take } from './take.js'
|
|
3
3
|
|
|
4
|
-
function zipWithFn(
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
)
|
|
4
|
+
function zipWithFn(
|
|
5
|
+
fn, x, y
|
|
6
|
+
){
|
|
7
|
+
return take(x.length > y.length ? y.length : x.length, x).map((xInstance, i) => fn(xInstance, y[ i ]))
|
|
8
8
|
}
|
|
9
9
|
|
|
10
10
|
export const zipWith = curry(zipWithFn)
|