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/pipe.js
CHANGED
|
@@ -1,17 +1,89 @@
|
|
|
1
|
-
|
|
2
|
-
if (fns.length === 0)
|
|
3
|
-
throw new Error('pipe requires at least one argument')
|
|
4
|
-
|
|
5
|
-
return (...args) => {
|
|
6
|
-
const list = fns.slice()
|
|
7
|
-
if (list.length > 0) {
|
|
8
|
-
const fn = list.shift()
|
|
9
|
-
let result = fn(...args)
|
|
10
|
-
while (list.length > 0) {
|
|
11
|
-
result = list.shift()(result)
|
|
12
|
-
}
|
|
1
|
+
import { reduceFn } from './reduce.js'
|
|
13
2
|
|
|
14
|
-
|
|
3
|
+
export function _arity(n, fn){
|
|
4
|
+
switch (n){
|
|
5
|
+
case 0:
|
|
6
|
+
return function (){
|
|
7
|
+
return fn.apply(this, arguments)
|
|
8
|
+
}
|
|
9
|
+
case 1:
|
|
10
|
+
return function (a0){
|
|
11
|
+
return fn.apply(this, arguments)
|
|
12
|
+
}
|
|
13
|
+
case 2:
|
|
14
|
+
return function (a0, a1){
|
|
15
|
+
return fn.apply(this, arguments)
|
|
16
|
+
}
|
|
17
|
+
case 3:
|
|
18
|
+
return function (
|
|
19
|
+
a0, a1, a2
|
|
20
|
+
){
|
|
21
|
+
return fn.apply(this, arguments)
|
|
22
|
+
}
|
|
23
|
+
case 4:
|
|
24
|
+
return function (
|
|
25
|
+
a0, a1, a2, a3
|
|
26
|
+
){
|
|
27
|
+
return fn.apply(this, arguments)
|
|
28
|
+
}
|
|
29
|
+
case 5:
|
|
30
|
+
return function (
|
|
31
|
+
a0, a1, a2, a3, a4
|
|
32
|
+
){
|
|
33
|
+
return fn.apply(this, arguments)
|
|
34
|
+
}
|
|
35
|
+
case 6:
|
|
36
|
+
return function (
|
|
37
|
+
a0, a1, a2, a3, a4, a5
|
|
38
|
+
){
|
|
39
|
+
return fn.apply(this, arguments)
|
|
40
|
+
}
|
|
41
|
+
case 7:
|
|
42
|
+
return function (
|
|
43
|
+
a0, a1, a2, a3, a4, a5, a6
|
|
44
|
+
){
|
|
45
|
+
return fn.apply(this, arguments)
|
|
46
|
+
}
|
|
47
|
+
case 8:
|
|
48
|
+
return function (
|
|
49
|
+
a0, a1, a2, a3, a4, a5, a6, a7
|
|
50
|
+
){
|
|
51
|
+
return fn.apply(this, arguments)
|
|
15
52
|
}
|
|
53
|
+
case 9:
|
|
54
|
+
return function (
|
|
55
|
+
a0, a1, a2, a3, a4, a5, a6, a7, a8
|
|
56
|
+
){
|
|
57
|
+
return fn.apply(this, arguments)
|
|
58
|
+
}
|
|
59
|
+
case 10:
|
|
60
|
+
return function (
|
|
61
|
+
a0, a1, a2, a3, a4, a5, a6, a7, a8, a9
|
|
62
|
+
){
|
|
63
|
+
return fn.apply(this, arguments)
|
|
64
|
+
}
|
|
65
|
+
default:
|
|
66
|
+
throw new Error('First argument to _arity must be a non-negative integer no greater than ten')
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
export function _pipe(f, g){
|
|
71
|
+
return function (){
|
|
72
|
+
return g.call(this, f.apply(this, arguments))
|
|
16
73
|
}
|
|
17
74
|
}
|
|
75
|
+
|
|
76
|
+
export function pipe(){
|
|
77
|
+
if (arguments.length === 0){
|
|
78
|
+
throw new Error('pipe requires at least one argument')
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
return _arity(arguments[ 0 ].length,
|
|
82
|
+
reduceFn(
|
|
83
|
+
_pipe,
|
|
84
|
+
arguments[ 0 ],
|
|
85
|
+
Array.prototype.slice.call(
|
|
86
|
+
arguments, 1, Infinity
|
|
87
|
+
)
|
|
88
|
+
))
|
|
89
|
+
}
|
package/src/pluck.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {map} from './map'
|
|
1
|
+
import { map } from './map.js'
|
|
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[property] !== undefined)
|
|
10
|
-
willReturn.push(x[property])
|
|
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 [x].concat(input.split(''))
|
|
4
|
+
if (typeof input === 'string') return [ x ].concat(input.split(''))
|
|
5
5
|
|
|
6
|
-
return [x].concat(input)
|
|
6
|
+
return [ x ].concat(input)
|
|
7
7
|
}
|
package/src/product.js
CHANGED
package/src/prop.js
CHANGED
package/src/propEq.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
import {curry} from './curry'
|
|
1
|
+
import { curry } from './curry.js'
|
|
2
2
|
|
|
3
|
-
function propEqFn(
|
|
3
|
+
function propEqFn(
|
|
4
|
+
propToFind, valueToMatch, obj
|
|
5
|
+
){
|
|
4
6
|
if (!obj) return false
|
|
5
7
|
|
|
6
|
-
return obj[propToFind] === valueToMatch
|
|
8
|
+
return obj[ propToFind ] === valueToMatch
|
|
7
9
|
}
|
|
8
10
|
|
|
9
11
|
export const propEq = curry(propEqFn)
|
package/src/propIs.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
|
-
import {curry} from './curry'
|
|
2
|
-
import {is} from './is'
|
|
1
|
+
import { curry } from './curry.js'
|
|
2
|
+
import { is } from './is.js'
|
|
3
3
|
|
|
4
|
-
function propIsFn(
|
|
5
|
-
|
|
4
|
+
function propIsFn(
|
|
5
|
+
targetPrototype, property, obj
|
|
6
|
+
){
|
|
7
|
+
return is(targetPrototype, obj[ property ])
|
|
6
8
|
}
|
|
7
9
|
|
|
8
10
|
export const propIs = curry(propIsFn)
|
package/src/propOr.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import {curry} from './curry'
|
|
2
|
-
import {defaultTo} from './defaultTo'
|
|
1
|
+
import { curry } from './curry.js'
|
|
2
|
+
import { defaultTo } from './defaultTo.js'
|
|
3
3
|
|
|
4
|
-
function propOrFn(
|
|
4
|
+
function propOrFn(
|
|
5
|
+
defaultValue, property, obj
|
|
6
|
+
){
|
|
5
7
|
if (!obj) return defaultValue
|
|
6
8
|
|
|
7
|
-
return defaultTo(defaultValue, obj[property])
|
|
9
|
+
return defaultTo(defaultValue, obj[ property ])
|
|
8
10
|
}
|
|
9
11
|
|
|
10
12
|
export const propOr = curry(propOrFn)
|
package/src/props.js
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {_isArray} from './_internals/_isArray'
|
|
2
|
-
import {mapArray} from './map'
|
|
1
|
+
import { _isArray } from './_internals/_isArray.js'
|
|
2
|
+
import { mapArray } from './map.js'
|
|
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[prop], propsToPick)
|
|
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[i] = start + i
|
|
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,16 +1,20 @@
|
|
|
1
|
-
import {_isArray} from './_internals/_isArray'
|
|
2
|
-
import {_keys} from './_internals/_keys'
|
|
3
|
-
import {curry} from './curry'
|
|
1
|
+
import { _isArray } from './_internals/_isArray.js'
|
|
2
|
+
import { _keys } from './_internals/_keys.js'
|
|
3
|
+
import { curry } from './curry.js'
|
|
4
4
|
|
|
5
|
-
function reduceFn(
|
|
6
|
-
|
|
5
|
+
export function reduceFn(
|
|
6
|
+
reducer, acc, list
|
|
7
|
+
){
|
|
8
|
+
if (!_isArray(list)){
|
|
7
9
|
throw new TypeError('reduce: list must be array or iterable')
|
|
8
10
|
}
|
|
9
11
|
let index = 0
|
|
10
12
|
const len = list.length
|
|
11
13
|
|
|
12
|
-
while (index < len)
|
|
13
|
-
acc = reducer(
|
|
14
|
+
while (index < len){
|
|
15
|
+
acc = reducer(
|
|
16
|
+
acc, list[ index ], index, list
|
|
17
|
+
)
|
|
14
18
|
index++
|
|
15
19
|
}
|
|
16
20
|
|
package/src/reject.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {filter} from './filter'
|
|
1
|
+
import { filter } from './filter.js'
|
|
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,6 +1,7 @@
|
|
|
1
|
-
export function reverse(listOrString)
|
|
2
|
-
if (typeof listOrString === 'string')
|
|
3
|
-
return listOrString.split('').reverse()
|
|
1
|
+
export function reverse(listOrString){
|
|
2
|
+
if (typeof listOrString === 'string'){
|
|
3
|
+
return listOrString.split('').reverse()
|
|
4
|
+
.join('')
|
|
4
5
|
}
|
|
5
6
|
|
|
6
7
|
const clone = listOrString.slice()
|
package/src/set.js
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
|
-
import {always} from './always'
|
|
2
|
-
import {curry} from './curry'
|
|
3
|
-
import {over} from './over'
|
|
1
|
+
import { always } from './always.js'
|
|
2
|
+
import { curry } from './curry.js'
|
|
3
|
+
import { over } from './over.js'
|
|
4
4
|
|
|
5
|
-
function setFn(
|
|
6
|
-
|
|
5
|
+
function setFn(
|
|
6
|
+
lens, replacer, x
|
|
7
|
+
){
|
|
8
|
+
return over(
|
|
9
|
+
lens, always(replacer), x
|
|
10
|
+
)
|
|
7
11
|
}
|
|
8
12
|
|
|
9
13
|
export const set = curry(setFn)
|
package/src/slice.js
CHANGED
package/src/sort.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {cloneList} from './_internals/cloneList'
|
|
1
|
+
import { cloneList } from './_internals/cloneList.js'
|
|
2
2
|
|
|
3
|
-
export function sort(sortFn, list)
|
|
3
|
+
export function sort(sortFn, list){
|
|
4
4
|
if (arguments.length === 1) return _list => sort(sortFn, _list)
|
|
5
5
|
|
|
6
6
|
return cloneList(list).sort(sortFn)
|
package/src/sortBy.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {cloneList} from './_internals/cloneList'
|
|
1
|
+
import { cloneList } from './_internals/cloneList.js'
|
|
2
2
|
|
|
3
|
-
export function sortBy(sortFn, list)
|
|
3
|
+
export function sortBy(sortFn, list){
|
|
4
4
|
if (arguments.length === 1) return _list => sortBy(sortFn, _list)
|
|
5
5
|
|
|
6
6
|
const clone = cloneList(list)
|
package/src/split.js
CHANGED
package/src/splitAt.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import {_isArray} from './_internals/_isArray'
|
|
2
|
-
import {drop} from './drop'
|
|
3
|
-
import {maybe} from './maybe'
|
|
4
|
-
import {take} from './take'
|
|
1
|
+
import { _isArray } from './_internals/_isArray.js'
|
|
2
|
+
import { drop } from './drop.js'
|
|
3
|
+
import { maybe } from './maybe.js'
|
|
4
|
+
import { take } from './take.js'
|
|
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 ${input}`)
|
|
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 [take(correctIndex, input), drop(correctIndex, input)]
|
|
20
|
+
return [ take(correctIndex, input), drop(correctIndex, input) ]
|
|
21
21
|
}
|
package/src/splitEvery.js
CHANGED
|
@@ -1,19 +1,17 @@
|
|
|
1
|
-
export function splitEvery(sliceLength, listOrString)
|
|
2
|
-
if (arguments.length === 1)
|
|
1
|
+
export function splitEvery(sliceLength, listOrString){
|
|
2
|
+
if (arguments.length === 1){
|
|
3
3
|
return _listOrString => splitEvery(sliceLength, _listOrString)
|
|
4
4
|
}
|
|
5
5
|
|
|
6
|
-
if (sliceLength < 1)
|
|
7
|
-
throw new Error(
|
|
8
|
-
'First argument to splitEvery must be a positive integer'
|
|
9
|
-
)
|
|
6
|
+
if (sliceLength < 1){
|
|
7
|
+
throw new Error('First argument to splitEvery must be a positive integer')
|
|
10
8
|
}
|
|
11
9
|
|
|
12
10
|
const willReturn = []
|
|
13
11
|
let counter = 0
|
|
14
12
|
|
|
15
|
-
while (counter < listOrString.length)
|
|
16
|
-
willReturn.push(listOrString.slice(counter,
|
|
13
|
+
while (counter < listOrString.length){
|
|
14
|
+
willReturn.push(listOrString.slice(counter, counter += sliceLength))
|
|
17
15
|
}
|
|
18
16
|
|
|
19
17
|
return willReturn
|
package/src/splitWhen.js
CHANGED
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
export function splitWhen(predicate, input)
|
|
2
|
-
if (arguments.length === 1)
|
|
1
|
+
export function splitWhen(predicate, input){
|
|
2
|
+
if (arguments.length === 1){
|
|
3
3
|
return _input => splitWhen(predicate, _input)
|
|
4
4
|
}
|
|
5
5
|
if (!input)
|
|
6
|
-
throw new TypeError(`Cannot read property 'length' of ${input}`)
|
|
6
|
+
throw new TypeError(`Cannot read property 'length' of ${ input }`)
|
|
7
7
|
|
|
8
8
|
const preFound = []
|
|
9
9
|
const postFound = []
|
|
10
10
|
let found = false
|
|
11
11
|
let counter = -1
|
|
12
12
|
|
|
13
|
-
while (counter++ < input.length - 1)
|
|
14
|
-
if (found)
|
|
15
|
-
postFound.push(input[counter])
|
|
16
|
-
} else if (predicate(input[counter]))
|
|
17
|
-
postFound.push(input[counter])
|
|
13
|
+
while (counter++ < input.length - 1){
|
|
14
|
+
if (found){
|
|
15
|
+
postFound.push(input[ counter ])
|
|
16
|
+
} else if (predicate(input[ counter ])){
|
|
17
|
+
postFound.push(input[ counter ])
|
|
18
18
|
found = true
|
|
19
19
|
} else {
|
|
20
|
-
preFound.push(input[counter])
|
|
20
|
+
preFound.push(input[ counter ])
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
return [preFound, postFound]
|
|
24
|
+
return [ preFound, postFound ]
|
|
25
25
|
}
|
package/src/startsWith.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { _isArray } from './_internals/_isArray.js'
|
|
2
|
+
import { equals } from './equals.js'
|
|
3
3
|
|
|
4
|
-
export function startsWith(target, iterable)
|
|
4
|
+
export function startsWith(target, iterable){
|
|
5
5
|
if (arguments.length === 1)
|
|
6
6
|
return _iterable => startsWith(target, _iterable)
|
|
7
7
|
|
|
8
|
-
if (typeof iterable === 'string')
|
|
8
|
+
if (typeof iterable === 'string'){
|
|
9
9
|
return iterable.startsWith(target)
|
|
10
10
|
}
|
|
11
11
|
if (!_isArray(target)) return false
|
|
@@ -13,8 +13,9 @@ export function startsWith(target, iterable) {
|
|
|
13
13
|
let correct = true
|
|
14
14
|
const filtered = target.filter((x, index) => {
|
|
15
15
|
if (!correct) return false
|
|
16
|
-
const result = equals(x, iterable[index])
|
|
16
|
+
const result = equals(x, iterable[ index ])
|
|
17
17
|
if (!result) correct = false
|
|
18
|
+
|
|
18
19
|
return result
|
|
19
20
|
})
|
|
20
21
|
|
package/src/subtract.js
CHANGED
package/src/sum.js
CHANGED
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import {concat} from './concat'
|
|
2
|
-
import {filter} from './filter'
|
|
3
|
-
import {includes} from './includes'
|
|
1
|
+
import { concat } from './concat.js'
|
|
2
|
+
import { filter } from './filter.js'
|
|
3
|
+
import { includes } from './includes.js'
|
|
4
4
|
|
|
5
|
-
export function symmetricDifference(x, y)
|
|
6
|
-
if (arguments.length === 1)
|
|
5
|
+
export function symmetricDifference(x, y){
|
|
6
|
+
if (arguments.length === 1){
|
|
7
7
|
return _y => symmetricDifference(x, _y)
|
|
8
8
|
}
|
|
9
9
|
|
|
10
|
-
return concat(
|
|
11
|
-
filter(value => !includes(value,
|
|
12
|
-
filter(value => !includes(value, x), y)
|
|
13
|
-
)
|
|
10
|
+
return concat(filter(value => !includes(value, y), x),
|
|
11
|
+
filter(value => !includes(value, x), y))
|
|
14
12
|
}
|
package/src/tail.js
CHANGED
package/src/take.js
CHANGED
|
@@ -1,10 +1,12 @@
|
|
|
1
|
-
import baseSlice from './_internals/baseSlice'
|
|
1
|
+
import baseSlice from './_internals/baseSlice.js'
|
|
2
2
|
|
|
3
|
-
export function take(howMany, listOrString)
|
|
3
|
+
export function take(howMany, listOrString){
|
|
4
4
|
if (arguments.length === 1)
|
|
5
5
|
return _listOrString => take(howMany, _listOrString)
|
|
6
6
|
if (howMany < 0) return listOrString.slice()
|
|
7
7
|
if (typeof listOrString === 'string') return listOrString.slice(0, howMany)
|
|
8
8
|
|
|
9
|
-
return baseSlice(
|
|
9
|
+
return baseSlice(
|
|
10
|
+
listOrString, 0, howMany
|
|
11
|
+
)
|
|
10
12
|
}
|
package/src/takeLast.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import baseSlice from './_internals/baseSlice'
|
|
1
|
+
import baseSlice from './_internals/baseSlice.js'
|
|
2
2
|
|
|
3
|
-
export function takeLast(howMany, listOrString)
|
|
3
|
+
export function takeLast(howMany, listOrString){
|
|
4
4
|
if (arguments.length === 1)
|
|
5
5
|
return _listOrString => takeLast(howMany, _listOrString)
|
|
6
6
|
|
|
@@ -13,5 +13,7 @@ export function takeLast(howMany, listOrString) {
|
|
|
13
13
|
|
|
14
14
|
numValue = len - numValue
|
|
15
15
|
|
|
16
|
-
return baseSlice(
|
|
16
|
+
return baseSlice(
|
|
17
|
+
listOrString, numValue, len
|
|
18
|
+
)
|
|
17
19
|
}
|
package/src/takeLastWhile.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {_isArray} from './_internals/_isArray'
|
|
1
|
+
import { _isArray } from './_internals/_isArray.js'
|
|
2
2
|
|
|
3
|
-
export function takeLastWhile(predicate, input)
|
|
4
|
-
if (arguments.length === 1)
|
|
3
|
+
export function takeLastWhile(predicate, input){
|
|
4
|
+
if (arguments.length === 1){
|
|
5
5
|
return _input => takeLastWhile(predicate, _input)
|
|
6
6
|
}
|
|
7
7
|
if (input.length === 0) return input
|
|
@@ -9,12 +9,12 @@ export function takeLastWhile(predicate, input) {
|
|
|
9
9
|
const toReturn = []
|
|
10
10
|
let counter = input.length
|
|
11
11
|
|
|
12
|
-
while (!found || counter === 0)
|
|
12
|
+
while (!found || counter === 0){
|
|
13
13
|
counter--
|
|
14
|
-
if (predicate(input[counter]) === false)
|
|
14
|
+
if (predicate(input[ counter ]) === false){
|
|
15
15
|
found = true
|
|
16
|
-
} else if (!found)
|
|
17
|
-
toReturn.push(input[counter])
|
|
16
|
+
} else if (!found){
|
|
17
|
+
toReturn.push(input[ counter ])
|
|
18
18
|
}
|
|
19
19
|
}
|
|
20
20
|
|
package/src/takeWhile.js
CHANGED
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import {_isArray} from '../src/_internals/_isArray'
|
|
1
|
+
import { _isArray } from '../src/_internals/_isArray.js'
|
|
2
2
|
|
|
3
|
-
export function takeWhile(predicate, iterable)
|
|
4
|
-
if (arguments.length === 1)
|
|
3
|
+
export function takeWhile(predicate, iterable){
|
|
4
|
+
if (arguments.length === 1){
|
|
5
5
|
return _iterable => takeWhile(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 = true
|
|
12
12
|
const holder = []
|
|
13
13
|
let counter = -1
|
|
14
14
|
|
|
15
|
-
while (counter++ < iterable.length - 1)
|
|
16
|
-
if (!predicate(iterable[counter]))
|
|
15
|
+
while (counter++ < iterable.length - 1){
|
|
16
|
+
if (!predicate(iterable[ counter ])){
|
|
17
17
|
if (flag) flag = false
|
|
18
|
-
} else if (flag)
|
|
19
|
-
holder.push(iterable[counter])
|
|
18
|
+
} else if (flag){
|
|
19
|
+
holder.push(iterable[ counter ])
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
holder
|
package/src/tap.js
CHANGED