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/assoc.js
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {curry} from './curry'
|
|
2
2
|
|
|
3
|
-
function assocFn(
|
|
4
|
-
|
|
5
|
-
){
|
|
6
|
-
return Object.assign(
|
|
7
|
-
{}, obj, { [ prop ] : newValue }
|
|
8
|
-
)
|
|
3
|
+
function assocFn(prop, newValue, obj) {
|
|
4
|
+
return Object.assign({}, obj, {[prop]: newValue})
|
|
9
5
|
}
|
|
10
6
|
|
|
11
7
|
export const assoc = curry(assocFn)
|
package/src/assocPath.js
CHANGED
|
@@ -1,31 +1,30 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
){
|
|
1
|
+
import {_isArray} from './_internals/_isArray'
|
|
2
|
+
import {_isInteger} from './_internals/_isInteger'
|
|
3
|
+
import {assoc} from './assoc'
|
|
4
|
+
import {curry} from './curry'
|
|
5
|
+
import {cloneList} from './_internals/cloneList'
|
|
6
|
+
|
|
7
|
+
function assocPathFn(path, newValue, input) {
|
|
9
8
|
const pathArrValue =
|
|
10
|
-
typeof path === 'string'
|
|
11
|
-
path.split('.').map(x => _isInteger(Number(x)) ? Number(x) : x)
|
|
12
|
-
path
|
|
13
|
-
if (pathArrValue.length === 0){
|
|
9
|
+
typeof path === 'string'
|
|
10
|
+
? path.split('.').map(x => (_isInteger(Number(x)) ? Number(x) : x))
|
|
11
|
+
: path
|
|
12
|
+
if (pathArrValue.length === 0) {
|
|
14
13
|
return newValue
|
|
15
14
|
}
|
|
16
15
|
|
|
17
|
-
const index = pathArrValue[
|
|
18
|
-
if (pathArrValue.length > 1){
|
|
16
|
+
const index = pathArrValue[0]
|
|
17
|
+
if (pathArrValue.length > 1) {
|
|
19
18
|
const condition =
|
|
20
19
|
typeof input !== 'object' ||
|
|
21
20
|
input === null ||
|
|
22
21
|
!input.hasOwnProperty(index)
|
|
23
22
|
|
|
24
|
-
const nextinput = condition
|
|
25
|
-
_isInteger(pathArrValue[
|
|
26
|
-
[]
|
|
27
|
-
{}
|
|
28
|
-
input[
|
|
23
|
+
const nextinput = condition
|
|
24
|
+
? _isInteger(pathArrValue[1])
|
|
25
|
+
? []
|
|
26
|
+
: {}
|
|
27
|
+
: input[index]
|
|
29
28
|
|
|
30
29
|
newValue = assocPathFn(
|
|
31
30
|
Array.prototype.slice.call(pathArrValue, 1),
|
|
@@ -34,16 +33,14 @@ function assocPathFn(
|
|
|
34
33
|
)
|
|
35
34
|
}
|
|
36
35
|
|
|
37
|
-
if (_isInteger(index) && _isArray(input)){
|
|
38
|
-
const arr = input
|
|
39
|
-
arr[
|
|
36
|
+
if (_isInteger(index) && _isArray(input)) {
|
|
37
|
+
const arr = cloneList(input)
|
|
38
|
+
arr[index] = newValue
|
|
40
39
|
|
|
41
40
|
return arr
|
|
42
41
|
}
|
|
43
42
|
|
|
44
|
-
return assoc(
|
|
45
|
-
index, newValue, input
|
|
46
|
-
)
|
|
43
|
+
return assoc(index, newValue, input)
|
|
47
44
|
}
|
|
48
45
|
|
|
49
46
|
export const assocPath = curry(assocPathFn)
|
package/src/bind.js
ADDED
package/src/both.js
CHANGED
package/src/chain.js
CHANGED
package/src/clamp.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {curry} from './curry'
|
|
2
2
|
|
|
3
|
-
function clampFn(
|
|
4
|
-
min
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
3
|
+
function clampFn(min, max, input) {
|
|
4
|
+
if (min > max) {
|
|
5
|
+
throw new Error(
|
|
6
|
+
'min must not be greater than max in clamp(min, max, value)'
|
|
7
|
+
)
|
|
8
8
|
}
|
|
9
9
|
if (input >= min && input <= max) return input
|
|
10
10
|
|
package/src/clone.js
CHANGED
|
@@ -1,17 +1,17 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {_isArray} from './_internals/_isArray'
|
|
2
2
|
|
|
3
|
-
export function clone(input){
|
|
3
|
+
export function clone(input) {
|
|
4
4
|
const out = _isArray(input) ? Array(input.length) : {}
|
|
5
5
|
if (input && input.getTime) return new Date(input.getTime())
|
|
6
6
|
|
|
7
|
-
for (const key in input){
|
|
8
|
-
const v = input[
|
|
9
|
-
out[
|
|
10
|
-
typeof v === 'object' && v !== null
|
|
11
|
-
v.getTime
|
|
12
|
-
new Date(v.getTime())
|
|
13
|
-
clone(v)
|
|
14
|
-
v
|
|
7
|
+
for (const key in input) {
|
|
8
|
+
const v = input[key]
|
|
9
|
+
out[key] =
|
|
10
|
+
typeof v === 'object' && v !== null
|
|
11
|
+
? v.getTime
|
|
12
|
+
? new Date(v.getTime())
|
|
13
|
+
: clone(v)
|
|
14
|
+
: v
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
return out
|
package/src/complement.js
CHANGED
package/src/compose.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
export function compose(...fns){
|
|
2
|
-
if (fns.length === 0){
|
|
1
|
+
export function compose(...fns) {
|
|
2
|
+
if (fns.length === 0) {
|
|
3
3
|
throw new Error('compose requires at least one argument')
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
-
return (...args)
|
|
6
|
+
return function (...args) {
|
|
7
7
|
const list = fns.slice()
|
|
8
|
-
if (list.length > 0){
|
|
8
|
+
if (list.length > 0) {
|
|
9
9
|
const fn = list.pop()
|
|
10
|
-
let result = fn(
|
|
11
|
-
while (list.length > 0){
|
|
10
|
+
let result = fn.apply(this, args)
|
|
11
|
+
while (list.length > 0) {
|
|
12
12
|
result = list.pop()(result)
|
|
13
13
|
}
|
|
14
14
|
|
package/src/concat.js
CHANGED
package/src/cond.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export function cond(conditions){
|
|
1
|
+
export function cond(conditions) {
|
|
2
2
|
return input => {
|
|
3
3
|
let done = false
|
|
4
4
|
let toReturn
|
|
5
|
-
conditions.forEach(([
|
|
6
|
-
if (!done && predicate(input)){
|
|
5
|
+
conditions.forEach(([predicate, resultClosure]) => {
|
|
6
|
+
if (!done && predicate(input)) {
|
|
7
7
|
done = true
|
|
8
8
|
toReturn = resultClosure(input)
|
|
9
9
|
}
|
package/src/converge.js
CHANGED
|
@@ -1,18 +1,18 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
1
|
+
import {curryN} from './curryN'
|
|
2
|
+
import {map} from './map'
|
|
3
|
+
import {max} from './max'
|
|
4
|
+
import {reduce} from './reduce'
|
|
5
5
|
|
|
6
|
-
export function converge(fn, transformers){
|
|
6
|
+
export function converge(fn, transformers) {
|
|
7
7
|
if (arguments.length === 1)
|
|
8
8
|
return _transformers => converge(fn, _transformers)
|
|
9
9
|
|
|
10
|
-
const highestArity = reduce(
|
|
11
|
-
(a, b) => max(a, b.length), 0, transformers
|
|
12
|
-
)
|
|
10
|
+
const highestArity = reduce((a, b) => max(a, b.length), 0, transformers)
|
|
13
11
|
|
|
14
|
-
return curryN(highestArity, function (){
|
|
15
|
-
return fn.apply(
|
|
16
|
-
|
|
12
|
+
return curryN(highestArity, function () {
|
|
13
|
+
return fn.apply(
|
|
14
|
+
this,
|
|
15
|
+
map(g => g.apply(this, arguments), transformers)
|
|
16
|
+
)
|
|
17
17
|
})
|
|
18
18
|
}
|
package/src/curry.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export function curry(fn, args = []){
|
|
1
|
+
export function curry(fn, args = []) {
|
|
2
2
|
return (..._args) =>
|
|
3
|
-
(rest => rest.length >= fn.length ? fn(...rest) : curry(fn, rest))([
|
|
3
|
+
(rest => (rest.length >= fn.length ? fn(...rest) : curry(fn, rest)))([
|
|
4
4
|
...args,
|
|
5
5
|
..._args,
|
|
6
6
|
])
|
package/src/curryN.js
CHANGED
|
@@ -1,103 +1,83 @@
|
|
|
1
|
-
function _curryN(
|
|
2
|
-
|
|
3
|
-
){
|
|
4
|
-
return function (){
|
|
1
|
+
function _curryN(n, cache, fn) {
|
|
2
|
+
return function () {
|
|
5
3
|
let ci = 0
|
|
6
4
|
let ai = 0
|
|
7
5
|
const cl = cache.length
|
|
8
6
|
const al = arguments.length
|
|
9
7
|
const args = new Array(cl + al)
|
|
10
|
-
while (ci < cl){
|
|
11
|
-
args[
|
|
8
|
+
while (ci < cl) {
|
|
9
|
+
args[ci] = cache[ci]
|
|
12
10
|
ci++
|
|
13
11
|
}
|
|
14
|
-
while (ai < al){
|
|
15
|
-
args[
|
|
12
|
+
while (ai < al) {
|
|
13
|
+
args[cl + ai] = arguments[ai]
|
|
16
14
|
ai++
|
|
17
15
|
}
|
|
18
16
|
const remaining = n - args.length
|
|
19
17
|
|
|
20
|
-
return args.length >= n
|
|
21
|
-
fn.apply(this, args)
|
|
22
|
-
_arity(remaining, _curryN(
|
|
23
|
-
n, args, fn
|
|
24
|
-
))
|
|
18
|
+
return args.length >= n
|
|
19
|
+
? fn.apply(this, args)
|
|
20
|
+
: _arity(remaining, _curryN(n, args, fn))
|
|
25
21
|
}
|
|
26
22
|
}
|
|
27
23
|
|
|
28
|
-
function _arity(n, fn){
|
|
29
|
-
switch (n){
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
_1, _2, _3, _4, _5, _6, _7, _8
|
|
75
|
-
){
|
|
76
|
-
return fn.apply(this, arguments)
|
|
77
|
-
}
|
|
78
|
-
case 9:
|
|
79
|
-
return function (
|
|
80
|
-
_1, _2, _3, _4, _5, _6, _7, _8, _9
|
|
81
|
-
){
|
|
82
|
-
return fn.apply(this, arguments)
|
|
83
|
-
}
|
|
84
|
-
default:
|
|
85
|
-
return function (
|
|
86
|
-
_1, _2, _3, _4, _5, _6, _7, _8, _9, _10
|
|
87
|
-
){
|
|
88
|
-
return fn.apply(this, arguments)
|
|
89
|
-
}
|
|
24
|
+
function _arity(n, fn) {
|
|
25
|
+
switch (n) {
|
|
26
|
+
case 0:
|
|
27
|
+
return function () {
|
|
28
|
+
return fn.apply(this, arguments)
|
|
29
|
+
}
|
|
30
|
+
case 1:
|
|
31
|
+
return function (_1) {
|
|
32
|
+
return fn.apply(this, arguments)
|
|
33
|
+
}
|
|
34
|
+
case 2:
|
|
35
|
+
return function (_1, _2) {
|
|
36
|
+
return fn.apply(this, arguments)
|
|
37
|
+
}
|
|
38
|
+
case 3:
|
|
39
|
+
return function (_1, _2, _3) {
|
|
40
|
+
return fn.apply(this, arguments)
|
|
41
|
+
}
|
|
42
|
+
case 4:
|
|
43
|
+
return function (_1, _2, _3, _4) {
|
|
44
|
+
return fn.apply(this, arguments)
|
|
45
|
+
}
|
|
46
|
+
case 5:
|
|
47
|
+
return function (_1, _2, _3, _4, _5) {
|
|
48
|
+
return fn.apply(this, arguments)
|
|
49
|
+
}
|
|
50
|
+
case 6:
|
|
51
|
+
return function (_1, _2, _3, _4, _5, _6) {
|
|
52
|
+
return fn.apply(this, arguments)
|
|
53
|
+
}
|
|
54
|
+
case 7:
|
|
55
|
+
return function (_1, _2, _3, _4, _5, _6, _7) {
|
|
56
|
+
return fn.apply(this, arguments)
|
|
57
|
+
}
|
|
58
|
+
case 8:
|
|
59
|
+
return function (_1, _2, _3, _4, _5, _6, _7, _8) {
|
|
60
|
+
return fn.apply(this, arguments)
|
|
61
|
+
}
|
|
62
|
+
case 9:
|
|
63
|
+
return function (_1, _2, _3, _4, _5, _6, _7, _8, _9) {
|
|
64
|
+
return fn.apply(this, arguments)
|
|
65
|
+
}
|
|
66
|
+
default:
|
|
67
|
+
return function (_1, _2, _3, _4, _5, _6, _7, _8, _9, _10) {
|
|
68
|
+
return fn.apply(this, arguments)
|
|
69
|
+
}
|
|
90
70
|
}
|
|
91
71
|
}
|
|
92
72
|
|
|
93
|
-
export function curryN(n, fn){
|
|
73
|
+
export function curryN(n, fn) {
|
|
94
74
|
if (arguments.length === 1) return _fn => curryN(n, _fn)
|
|
95
75
|
|
|
96
|
-
if (n > 10){
|
|
97
|
-
throw new Error(
|
|
76
|
+
if (n > 10) {
|
|
77
|
+
throw new Error(
|
|
78
|
+
'First argument to _arity must be a non-negative integer no greater than ten'
|
|
79
|
+
)
|
|
98
80
|
}
|
|
99
81
|
|
|
100
|
-
return _arity(n, _curryN(
|
|
101
|
-
n, [], fn
|
|
102
|
-
))
|
|
82
|
+
return _arity(n, _curryN(n, [], fn))
|
|
103
83
|
}
|
package/src/defaultTo.js
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
function isFalsy(input){
|
|
1
|
+
function isFalsy(input) {
|
|
2
2
|
return (
|
|
3
|
-
input === undefined ||
|
|
4
|
-
input === null ||
|
|
5
|
-
Number.isNaN(input) === true
|
|
3
|
+
input === undefined || input === null || Number.isNaN(input) === true
|
|
6
4
|
)
|
|
7
5
|
}
|
|
8
6
|
|
|
9
|
-
export function defaultTo(defaultArgument, input){
|
|
10
|
-
if (arguments.length === 1){
|
|
11
|
-
return _input =>
|
|
12
|
-
defaultTo(defaultArgument, _input)
|
|
7
|
+
export function defaultTo(defaultArgument, input) {
|
|
8
|
+
if (arguments.length === 1) {
|
|
9
|
+
return _input => defaultTo(defaultArgument, _input)
|
|
13
10
|
}
|
|
14
11
|
|
|
15
12
|
return isFalsy(input) ? defaultArgument : input
|
package/src/difference.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import {includes} from './includes'
|
|
2
|
+
import {uniq} from './uniq'
|
|
3
3
|
|
|
4
|
-
export function difference(a, b){
|
|
4
|
+
export function difference(a, b) {
|
|
5
5
|
if (arguments.length === 1) return _b => difference(a, _b)
|
|
6
6
|
|
|
7
7
|
return uniq(a).filter(aInstance => !includes(aInstance, b))
|
package/src/dissoc.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export function dissoc(prop, obj){
|
|
1
|
+
export function dissoc(prop, obj) {
|
|
2
2
|
if (arguments.length === 1) return _obj => dissoc(prop, _obj)
|
|
3
3
|
|
|
4
4
|
if (obj === null || obj === undefined) return {}
|
|
5
5
|
|
|
6
6
|
const willReturn = {}
|
|
7
|
-
for (const p in obj){
|
|
8
|
-
willReturn[
|
|
7
|
+
for (const p in obj) {
|
|
8
|
+
willReturn[p] = obj[p]
|
|
9
9
|
}
|
|
10
|
-
delete willReturn[
|
|
10
|
+
delete willReturn[prop]
|
|
11
11
|
|
|
12
12
|
return willReturn
|
|
13
13
|
}
|
package/src/divide.js
CHANGED
package/src/drop.js
CHANGED
package/src/dropLast.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export function dropLast(howManyToDrop, listOrString){
|
|
2
|
-
if (arguments.length === 1){
|
|
1
|
+
export function dropLast(howManyToDrop, listOrString) {
|
|
2
|
+
if (arguments.length === 1) {
|
|
3
3
|
return _listOrString => dropLast(howManyToDrop, _listOrString)
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
-
return howManyToDrop > 0
|
|
7
|
-
listOrString.slice(0, -howManyToDrop)
|
|
8
|
-
listOrString.slice()
|
|
6
|
+
return howManyToDrop > 0
|
|
7
|
+
? listOrString.slice(0, -howManyToDrop)
|
|
8
|
+
: listOrString.slice()
|
|
9
9
|
}
|
package/src/dropLastWhile.js
CHANGED
|
@@ -1,30 +1,30 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {_isArray} from './_internals/_isArray'
|
|
2
2
|
|
|
3
|
-
export function dropLastWhile(predicate, iterable){
|
|
4
|
-
if (arguments.length === 1){
|
|
3
|
+
export function dropLastWhile(predicate, iterable) {
|
|
4
|
+
if (arguments.length === 1) {
|
|
5
5
|
return _iterable => dropLastWhile(predicate, _iterable)
|
|
6
6
|
}
|
|
7
7
|
if (iterable.length === 0) return iterable
|
|
8
8
|
const isArray = _isArray(iterable)
|
|
9
9
|
|
|
10
|
-
if (typeof predicate !== 'function'){
|
|
11
|
-
throw new Error(`'predicate' is from wrong type ${
|
|
10
|
+
if (typeof predicate !== 'function') {
|
|
11
|
+
throw new Error(`'predicate' is from wrong type ${typeof predicate}`)
|
|
12
12
|
}
|
|
13
|
-
if (!isArray && typeof iterable !== 'string'){
|
|
14
|
-
throw new Error(`'iterable' is from wrong type ${
|
|
13
|
+
if (!isArray && typeof iterable !== 'string') {
|
|
14
|
+
throw new Error(`'iterable' is from wrong type ${typeof iterable}`)
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
let found = false
|
|
18
18
|
const toReturn = []
|
|
19
19
|
let counter = iterable.length
|
|
20
20
|
|
|
21
|
-
while (counter > 0){
|
|
21
|
+
while (counter > 0) {
|
|
22
22
|
counter--
|
|
23
|
-
if (!found && predicate(iterable[
|
|
23
|
+
if (!found && predicate(iterable[counter]) === false) {
|
|
24
24
|
found = true
|
|
25
|
-
toReturn.push(iterable[
|
|
26
|
-
} else if (found){
|
|
27
|
-
toReturn.push(iterable[
|
|
25
|
+
toReturn.push(iterable[counter])
|
|
26
|
+
} else if (found) {
|
|
27
|
+
toReturn.push(iterable[counter])
|
|
28
28
|
}
|
|
29
29
|
}
|
|
30
30
|
|
package/src/dropRepeats.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import {_isArray} from './_internals/_isArray'
|
|
2
|
+
import {equals} from './equals'
|
|
3
3
|
|
|
4
|
-
export function dropRepeats(list){
|
|
5
|
-
if (!_isArray(list)){
|
|
6
|
-
throw new Error(`${
|
|
4
|
+
export function dropRepeats(list) {
|
|
5
|
+
if (!_isArray(list)) {
|
|
6
|
+
throw new Error(`${list} is not a list`)
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
const toReturn = []
|
|
10
10
|
|
|
11
11
|
list.reduce((prev, current) => {
|
|
12
|
-
if (!equals(prev, current)){
|
|
12
|
+
if (!equals(prev, current)) {
|
|
13
13
|
toReturn.push(current)
|
|
14
14
|
}
|
|
15
15
|
|
package/src/dropRepeatsWith.js
CHANGED
|
@@ -1,23 +1,23 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {_isArray} from './_internals/_isArray'
|
|
2
2
|
|
|
3
|
-
export function dropRepeatsWith(predicate, list){
|
|
4
|
-
if (arguments.length === 1){
|
|
3
|
+
export function dropRepeatsWith(predicate, list) {
|
|
4
|
+
if (arguments.length === 1) {
|
|
5
5
|
return _iterable => dropRepeatsWith(predicate, _iterable)
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
if (!_isArray(list)){
|
|
9
|
-
throw new Error(`${
|
|
8
|
+
if (!_isArray(list)) {
|
|
9
|
+
throw new Error(`${list} is not a list`)
|
|
10
10
|
}
|
|
11
11
|
|
|
12
12
|
const toReturn = []
|
|
13
13
|
|
|
14
14
|
list.reduce((prev, current) => {
|
|
15
|
-
if (prev === undefined){
|
|
15
|
+
if (prev === undefined) {
|
|
16
16
|
toReturn.push(current)
|
|
17
17
|
|
|
18
18
|
return current
|
|
19
19
|
}
|
|
20
|
-
if (!predicate(prev, current)){
|
|
20
|
+
if (!predicate(prev, current)) {
|
|
21
21
|
toReturn.push(current)
|
|
22
22
|
}
|
|
23
23
|
|
package/src/dropWhile.js
CHANGED
|
@@ -1,24 +1,24 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {_isArray} from '../src/_internals/_isArray'
|
|
2
2
|
|
|
3
|
-
export function dropWhile(predicate, iterable){
|
|
4
|
-
if (arguments.length === 1){
|
|
3
|
+
export function dropWhile(predicate, iterable) {
|
|
4
|
+
if (arguments.length === 1) {
|
|
5
5
|
return _iterable => dropWhile(predicate, _iterable)
|
|
6
6
|
}
|
|
7
7
|
const isArray = _isArray(iterable)
|
|
8
|
-
if (!isArray && typeof iterable !== 'string'){
|
|
8
|
+
if (!isArray && typeof iterable !== 'string') {
|
|
9
9
|
throw new Error('`iterable` is neither list nor a string')
|
|
10
10
|
}
|
|
11
11
|
let flag = false
|
|
12
12
|
const holder = []
|
|
13
13
|
let counter = -1
|
|
14
14
|
|
|
15
|
-
while (counter++ < iterable.length - 1){
|
|
16
|
-
if (flag){
|
|
17
|
-
holder.push(iterable[
|
|
18
|
-
} else if (!predicate(iterable[
|
|
15
|
+
while (counter++ < iterable.length - 1) {
|
|
16
|
+
if (flag) {
|
|
17
|
+
holder.push(iterable[counter])
|
|
18
|
+
} else if (!predicate(iterable[counter])) {
|
|
19
19
|
if (!flag) flag = true
|
|
20
20
|
|
|
21
|
-
holder.push(iterable[
|
|
21
|
+
holder.push(iterable[counter])
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
|
package/src/either.js
CHANGED