rambda 7.2.1 → 7.3.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 +12 -0
- package/README.md +1597 -1458
- package/dist/rambda.js +82 -68
- package/dist/rambda.mjs +81 -69
- package/dist/rambda.umd.js +1 -1
- package/immutable.d.ts +15 -1
- package/index.d.ts +15 -1
- package/package.json +16 -13
- package/src/_internals/constants.js +1 -0
- package/src/_internals/isArray.js +1 -0
- package/src/_internals/isFalsy.js +2 -2
- package/src/_internals/isInteger.js +5 -0
- package/src/_internals/isIterable.js +5 -0
- package/src/_internals/isObject.js +1 -1
- package/src/_internals/isTruthy.js +2 -2
- package/src/_internals/keys.js +1 -0
- package/src/_internals/{_objectIs.js → objectIs.js} +2 -2
- package/src/applySpec.js +3 -3
- package/src/assocPath.js +7 -7
- package/src/clone.js +2 -2
- package/src/count.js +2 -2
- package/src/dropLastWhile.js +2 -2
- package/src/dropRepeats.js +2 -2
- package/src/dropRepeatsWith.js +2 -2
- package/src/dropWhile.js +2 -2
- package/src/endsWith.js +2 -2
- package/src/equals.js +3 -3
- package/src/evolve.js +1 -1
- package/src/filter.js +2 -2
- package/src/flatten.js +2 -2
- package/src/forEach.js +6 -6
- package/src/groupWith.js +2 -2
- package/src/identical.js +2 -2
- package/src/includes.js +2 -2
- package/src/isPromise.js +1 -1
- package/src/length.js +2 -2
- package/src/map.js +7 -7
- package/src/mathMod.js +2 -2
- package/src/merge.js +1 -1
- package/src/mergeDeepRight.js +2 -1
- package/src/mergeRight.js +2 -1
- package/src/modify.js +23 -0
- package/src/modifyPath.js +2 -2
- package/src/partialObject.js +1 -11
- package/src/partition.js +2 -2
- package/src/props.js +2 -2
- package/src/reduce.js +2 -3
- package/src/splitAt.js +2 -2
- package/src/startsWith.js +2 -2
- package/src/takeLastWhile.js +2 -2
- package/src/takeWhile.js +2 -2
- package/src/times.js +2 -1
- package/src/transpose.js +2 -2
- package/src/unwind.js +4 -3
- package/src/update.js +1 -1
- package/src/where.js +1 -0
- package/src/_internals/_isArray.js +0 -1
- package/src/_internals/_isInteger.js +0 -5
- package/src/_internals/_keys.js +0 -1
package/src/partialObject.js
CHANGED
|
@@ -1,15 +1,5 @@
|
|
|
1
1
|
import { mergeDeepRight } from './mergeDeepRight.js'
|
|
2
|
-
import { type } from './type.js'
|
|
3
2
|
|
|
4
3
|
export function partialObject(fn, input){
|
|
5
|
-
return
|
|
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
|
-
}
|
|
4
|
+
return nextInput => fn(mergeDeepRight(nextInput, input))
|
|
15
5
|
}
|
package/src/partition.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isArray } from './_internals/isArray.js'
|
|
2
2
|
|
|
3
3
|
export function partitionObject(predicate, iterable){
|
|
4
4
|
const yes = {}
|
|
@@ -38,7 +38,7 @@ export function partition(predicate, iterable){
|
|
|
38
38
|
if (arguments.length === 1){
|
|
39
39
|
return listHolder => partition(predicate, listHolder)
|
|
40
40
|
}
|
|
41
|
-
if (!
|
|
41
|
+
if (!isArray(iterable)) return partitionObject(predicate, iterable)
|
|
42
42
|
|
|
43
43
|
return partitionArray(predicate, iterable)
|
|
44
44
|
}
|
package/src/props.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isArray } from './_internals/isArray.js'
|
|
2
2
|
import { mapArray } from './map.js'
|
|
3
3
|
|
|
4
4
|
export function props(propsToPick, obj){
|
|
5
5
|
if (arguments.length === 1){
|
|
6
6
|
return _obj => props(propsToPick, _obj)
|
|
7
7
|
}
|
|
8
|
-
if (!
|
|
8
|
+
if (!isArray(propsToPick)){
|
|
9
9
|
throw new Error('propsToPick is not a list')
|
|
10
10
|
}
|
|
11
11
|
|
package/src/reduce.js
CHANGED
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { _keys } from './_internals/_keys.js'
|
|
1
|
+
import { isArray } from './_internals/isArray.js'
|
|
3
2
|
import { curry } from './curry.js'
|
|
4
3
|
|
|
5
4
|
class ReduceStopper{
|
|
@@ -11,7 +10,7 @@ class ReduceStopper{
|
|
|
11
10
|
export function reduceFn(
|
|
12
11
|
reducer, acc, list
|
|
13
12
|
){
|
|
14
|
-
if (!
|
|
13
|
+
if (!isArray(list)){
|
|
15
14
|
throw new TypeError('reduce: list must be array or iterable')
|
|
16
15
|
}
|
|
17
16
|
let index = 0
|
package/src/splitAt.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isArray } from './_internals/isArray.js'
|
|
2
2
|
import { drop } from './drop.js'
|
|
3
3
|
import { maybe } from './maybe.js'
|
|
4
4
|
import { take } from './take.js'
|
|
@@ -9,7 +9,7 @@ export function splitAt(index, input){
|
|
|
9
9
|
}
|
|
10
10
|
if (!input) throw new TypeError(`Cannot read property 'slice' of ${ input }`)
|
|
11
11
|
|
|
12
|
-
if (!
|
|
12
|
+
if (!isArray(input) && typeof input !== 'string') return [ [], [] ]
|
|
13
13
|
|
|
14
14
|
const correctIndex = maybe(
|
|
15
15
|
index < 0,
|
package/src/startsWith.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isArray } from './_internals/isArray.js'
|
|
2
2
|
import { equals } from './equals.js'
|
|
3
3
|
|
|
4
4
|
export function startsWith(target, iterable){
|
|
@@ -8,7 +8,7 @@ export function startsWith(target, iterable){
|
|
|
8
8
|
if (typeof iterable === 'string'){
|
|
9
9
|
return iterable.startsWith(target)
|
|
10
10
|
}
|
|
11
|
-
if (!
|
|
11
|
+
if (!isArray(target)) return false
|
|
12
12
|
|
|
13
13
|
let correct = true
|
|
14
14
|
const filtered = target.filter((x, index) => {
|
package/src/takeLastWhile.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isArray } from './_internals/isArray.js'
|
|
2
2
|
|
|
3
3
|
export function takeLastWhile(predicate, input){
|
|
4
4
|
if (arguments.length === 1){
|
|
@@ -18,5 +18,5 @@ export function takeLastWhile(predicate, input){
|
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
|
|
21
|
-
return
|
|
21
|
+
return isArray(input) ? toReturn.reverse() : toReturn.reverse().join('')
|
|
22
22
|
}
|
package/src/takeWhile.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isArray as isArrayModule } from './_internals/isArray.js'
|
|
2
2
|
|
|
3
3
|
export function takeWhile(predicate, iterable){
|
|
4
4
|
if (arguments.length === 1){
|
|
5
5
|
return _iterable => takeWhile(predicate, _iterable)
|
|
6
6
|
}
|
|
7
|
-
const isArray =
|
|
7
|
+
const isArray = isArrayModule(iterable)
|
|
8
8
|
if (!isArray && typeof iterable !== 'string'){
|
|
9
9
|
throw new Error('`iterable` is neither list nor a string')
|
|
10
10
|
}
|
package/src/times.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
+
import { isInteger } from './_internals/isInteger.js'
|
|
1
2
|
import { map } from './map.js'
|
|
2
3
|
import { range } from './range.js'
|
|
3
4
|
|
|
4
5
|
export function times(fn, howMany){
|
|
5
6
|
if (arguments.length === 1) return _howMany => times(fn, _howMany)
|
|
6
|
-
if (!
|
|
7
|
+
if (!isInteger(howMany) || howMany < 0){
|
|
7
8
|
throw new RangeError('n must be an integer')
|
|
8
9
|
}
|
|
9
10
|
|
package/src/transpose.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isArray } from './_internals/isArray.js'
|
|
2
2
|
|
|
3
3
|
export function transpose(array){
|
|
4
4
|
return array.reduce((acc, el) => {
|
|
5
5
|
el.forEach((nestedEl, i) =>
|
|
6
|
-
|
|
6
|
+
isArray(acc[ i ]) ? acc[ i ].push(nestedEl) : acc.push([ nestedEl ]))
|
|
7
7
|
|
|
8
8
|
return acc
|
|
9
9
|
}, [])
|
package/src/unwind.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isArray } from './_internals/isArray.js'
|
|
2
2
|
import { mapArray } from './map.js'
|
|
3
3
|
|
|
4
4
|
export function unwind(property, obj){
|
|
@@ -6,10 +6,11 @@ export function unwind(property, obj){
|
|
|
6
6
|
return _obj => unwind(property, _obj)
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
if (!
|
|
9
|
+
if (!isArray(obj[ property ])) return [ obj ]
|
|
10
10
|
|
|
11
11
|
return mapArray(x => ({
|
|
12
12
|
...obj,
|
|
13
13
|
[ property ] : x,
|
|
14
|
-
}),
|
|
14
|
+
}),
|
|
15
|
+
obj[ property ])
|
|
15
16
|
}
|
package/src/update.js
CHANGED
package/src/where.js
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const _isArray = Array.isArray
|
package/src/_internals/_keys.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export const _keys = Object.keys
|