rambda 6.8.2 → 7.0.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 +93 -0
- package/README.md +4108 -5600
- package/dist/rambda.esm.js +340 -212
- package/dist/rambda.js +345 -212
- package/dist/rambda.mjs +340 -212
- package/dist/rambda.umd.js +1 -1
- package/immutable.d.ts +202 -275
- package/immutable.js +1 -0
- package/index.d.ts +202 -275
- package/package.json +111 -95
- 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 +5 -0
- package/src/_internals/isTruthy.js +5 -5
- package/src/_internals/set.js +35 -0
- 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 +17 -19
- 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 -22
- package/src/indexBy.js +11 -11
- package/src/indexOf.js +5 -12
- 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 +19 -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 +3 -3
- 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 +7 -10
- 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 +5 -5
- 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/splitEvery.js
CHANGED
|
@@ -1,17 +1,19 @@
|
|
|
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(
|
|
6
|
+
if (sliceLength < 1) {
|
|
7
|
+
throw new Error(
|
|
8
|
+
'First argument to splitEvery must be a positive integer'
|
|
9
|
+
)
|
|
8
10
|
}
|
|
9
11
|
|
|
10
12
|
const willReturn = []
|
|
11
13
|
let counter = 0
|
|
12
14
|
|
|
13
|
-
while (counter < listOrString.length){
|
|
14
|
-
willReturn.push(listOrString.slice(counter, counter += sliceLength))
|
|
15
|
+
while (counter < listOrString.length) {
|
|
16
|
+
willReturn.push(listOrString.slice(counter, (counter += sliceLength)))
|
|
15
17
|
}
|
|
16
18
|
|
|
17
19
|
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 ${
|
|
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[
|
|
16
|
-
} else if (predicate(input[
|
|
17
|
-
postFound.push(input[
|
|
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[
|
|
20
|
+
preFound.push(input[counter])
|
|
21
21
|
}
|
|
22
22
|
}
|
|
23
23
|
|
|
24
|
-
return [
|
|
24
|
+
return [preFound, postFound]
|
|
25
25
|
}
|
package/src/startsWith.js
CHANGED
|
@@ -1,5 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
import {equals} from './equals.js'
|
|
2
|
+
import {_isArray} from './_internals/_isArray.js'
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
export function startsWith(target, iterable) {
|
|
5
|
+
if (arguments.length === 1)
|
|
6
|
+
return _iterable => startsWith(target, _iterable)
|
|
7
|
+
|
|
8
|
+
if (typeof iterable === 'string') {
|
|
9
|
+
return iterable.startsWith(target)
|
|
10
|
+
}
|
|
11
|
+
if (!_isArray(target)) return false
|
|
12
|
+
|
|
13
|
+
let correct = true
|
|
14
|
+
const filtered = target.filter((x, index) => {
|
|
15
|
+
if (!correct) return false
|
|
16
|
+
const result = equals(x, iterable[index])
|
|
17
|
+
if (!result) correct = false
|
|
18
|
+
return result
|
|
19
|
+
})
|
|
20
|
+
|
|
21
|
+
return filtered.length === target.length
|
|
5
22
|
}
|
package/src/subtract.js
CHANGED
package/src/sum.js
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
3
|
-
import {
|
|
1
|
+
import {concat} from './concat'
|
|
2
|
+
import {filter} from './filter'
|
|
3
|
+
import {includes} from './includes'
|
|
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,
|
|
10
|
+
return concat(
|
|
11
|
+
filter(value => !includes(value, y), x),
|
|
12
|
+
filter(value => !includes(value, x), y)
|
|
13
|
+
)
|
|
12
14
|
}
|
package/src/tail.js
CHANGED
package/src/take.js
CHANGED
|
@@ -1,12 +1,10 @@
|
|
|
1
1
|
import baseSlice from './_internals/baseSlice'
|
|
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(
|
|
10
|
-
listOrString, 0, howMany
|
|
11
|
-
)
|
|
9
|
+
return baseSlice(listOrString, 0, howMany)
|
|
12
10
|
}
|
package/src/takeLast.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import baseSlice from './_internals/baseSlice'
|
|
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,7 +13,5 @@ export function takeLast(howMany, listOrString){
|
|
|
13
13
|
|
|
14
14
|
numValue = len - numValue
|
|
15
15
|
|
|
16
|
-
return baseSlice(
|
|
17
|
-
listOrString, numValue, len
|
|
18
|
-
)
|
|
16
|
+
return baseSlice(listOrString, numValue, len)
|
|
19
17
|
}
|
package/src/takeLastWhile.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {_isArray} from './_internals/_isArray'
|
|
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[
|
|
14
|
+
if (predicate(input[counter]) === false) {
|
|
15
15
|
found = true
|
|
16
|
-
} else if (!found){
|
|
17
|
-
toReturn.push(input[
|
|
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 {
|
|
1
|
+
import {_isArray} from '../src/_internals/_isArray'
|
|
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[
|
|
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[
|
|
18
|
+
} else if (flag) {
|
|
19
|
+
holder.push(iterable[counter])
|
|
20
20
|
}
|
|
21
21
|
}
|
|
22
22
|
holder
|
package/src/tap.js
CHANGED
package/src/test.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
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(
|
|
4
|
+
if (typeof pattern === 'string') {
|
|
5
|
+
throw new TypeError(
|
|
6
|
+
`‘test’ requires a value of type RegExp as its first argument; received "${pattern}"`
|
|
7
|
+
)
|
|
6
8
|
}
|
|
7
9
|
|
|
8
10
|
return str.search(pattern) !== -1
|
package/src/times.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import {map} from './map'
|
|
2
|
+
import {range} from './range'
|
|
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,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {_isArray} from './_internals/_isArray'
|
|
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[
|
|
6
|
+
_isArray(acc[i]) ? acc[i].push(nestedEl) : acc.push([nestedEl])
|
|
7
|
+
)
|
|
7
8
|
|
|
8
9
|
return acc
|
|
9
10
|
}, [])
|
package/src/trim.js
CHANGED
package/src/tryCatch.js
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {isFunction} from './isFunction'
|
|
2
2
|
|
|
3
|
-
export function tryCatch(fn, fallback){
|
|
4
|
-
if (!isFunction(fn)){
|
|
5
|
-
throw new Error(`R.tryCatch | fn '${
|
|
3
|
+
export function tryCatch(fn, fallback) {
|
|
4
|
+
if (!isFunction(fn)) {
|
|
5
|
+
throw new Error(`R.tryCatch | fn '${fn}'`)
|
|
6
6
|
}
|
|
7
7
|
const passFallback = isFunction(fallback)
|
|
8
8
|
|
|
9
9
|
return (...inputs) => {
|
|
10
10
|
try {
|
|
11
11
|
return fn(...inputs)
|
|
12
|
-
} catch (e){
|
|
12
|
+
} catch (e) {
|
|
13
13
|
return passFallback ? fallback(e, ...inputs) : fallback
|
|
14
14
|
}
|
|
15
15
|
}
|
package/src/type.js
CHANGED
|
@@ -1,34 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export function type(input){
|
|
4
|
-
const typeOf = typeof input
|
|
5
|
-
|
|
6
|
-
if (input === null){
|
|
1
|
+
export function type(input) {
|
|
2
|
+
if (input === null) {
|
|
7
3
|
return 'Null'
|
|
8
|
-
} else if (input === undefined){
|
|
4
|
+
} else if (input === undefined) {
|
|
9
5
|
return 'Undefined'
|
|
10
|
-
} else if (
|
|
11
|
-
return '
|
|
12
|
-
} else if (typeOf === 'number'){
|
|
13
|
-
return Number.isNaN(input) ? 'NaN' : 'Number'
|
|
14
|
-
} else if (typeOf === 'string'){
|
|
15
|
-
return 'String'
|
|
16
|
-
} else if (_isArray(input)){
|
|
17
|
-
return 'Array'
|
|
18
|
-
} else if (typeOf === 'symbol'){
|
|
19
|
-
return 'Symbol'
|
|
20
|
-
} else if (input instanceof RegExp){
|
|
21
|
-
return 'RegExp'
|
|
6
|
+
} else if (Number.isNaN(input)) {
|
|
7
|
+
return 'NaN'
|
|
22
8
|
}
|
|
9
|
+
const typeResult = Object.prototype.toString.call(input).slice(8, -1)
|
|
23
10
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
if ([ 'true', 'false' ].includes(asStr)) return 'Boolean'
|
|
27
|
-
if (!Number.isNaN(Number(asStr))) return 'Number'
|
|
28
|
-
if (asStr.startsWith('async')) return 'Async'
|
|
29
|
-
if (asStr === '[object Promise]') return 'Promise'
|
|
30
|
-
if (typeOf === 'function') return 'Function'
|
|
31
|
-
if (input instanceof String) return 'String'
|
|
32
|
-
|
|
33
|
-
return 'Object'
|
|
11
|
+
return typeResult === 'AsyncFunction' ? 'Async' : typeResult
|
|
34
12
|
}
|
package/src/unapply.js
ADDED
package/src/union.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {includes} from './includes'
|
|
2
|
+
import {cloneList} from './_internals/cloneList'
|
|
2
3
|
|
|
3
|
-
export function union(x, y){
|
|
4
|
+
export function union(x, y) {
|
|
4
5
|
if (arguments.length === 1) return _y => union(x, _y)
|
|
5
6
|
|
|
6
|
-
const toReturn = x
|
|
7
|
+
const toReturn = cloneList(x)
|
|
7
8
|
|
|
8
9
|
y.forEach(yInstance => {
|
|
9
10
|
if (!includes(yInstance, x)) toReturn.push(yInstance)
|
package/src/uniq.js
CHANGED
|
@@ -1,16 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {_Set} from './_internals/set'
|
|
2
2
|
|
|
3
|
-
export function uniq(list){
|
|
4
|
-
|
|
3
|
+
export function uniq(list) {
|
|
4
|
+
const set = new _Set()
|
|
5
5
|
const willReturn = []
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
if (!includes(value, willReturn)){
|
|
11
|
-
willReturn.push(value)
|
|
6
|
+
list.forEach(item => {
|
|
7
|
+
if (set.checkUniqueness(item)) {
|
|
8
|
+
willReturn.push(item)
|
|
12
9
|
}
|
|
13
|
-
}
|
|
10
|
+
})
|
|
14
11
|
|
|
15
12
|
return willReturn
|
|
16
13
|
}
|
package/src/uniqWith.js
CHANGED
|
@@ -1,17 +1,28 @@
|
|
|
1
|
-
|
|
1
|
+
function includesWith(predicate, target, list) {
|
|
2
|
+
let willReturn = false
|
|
3
|
+
let index = -1
|
|
4
|
+
|
|
5
|
+
while (++index < list.length && !willReturn) {
|
|
6
|
+
const value = list[index]
|
|
7
|
+
|
|
8
|
+
if (predicate(target, value)) {
|
|
9
|
+
willReturn = true
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
return willReturn
|
|
14
|
+
}
|
|
2
15
|
|
|
3
|
-
export function uniqWith(predicate, list){
|
|
16
|
+
export function uniqWith(predicate, list) {
|
|
4
17
|
if (arguments.length === 1) return _list => uniqWith(predicate, _list)
|
|
5
18
|
|
|
6
19
|
let index = -1
|
|
7
20
|
const willReturn = []
|
|
8
21
|
|
|
9
|
-
while (++index < list.length){
|
|
10
|
-
const value = list[
|
|
11
|
-
const flag = any(x => predicate(value, x),
|
|
12
|
-
willReturn)
|
|
22
|
+
while (++index < list.length) {
|
|
23
|
+
const value = list[index]
|
|
13
24
|
|
|
14
|
-
if (!
|
|
25
|
+
if (!includesWith(predicate, value, willReturn)) {
|
|
15
26
|
willReturn.push(value)
|
|
16
27
|
}
|
|
17
28
|
}
|
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 => predicate(input) ? input : whenFalse(input)
|
|
6
|
+
return input => (predicate(input) ? input : whenFalse(input))
|
|
7
7
|
}
|
package/src/update.js
CHANGED
|
@@ -1,13 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {curry} from './curry'
|
|
2
|
+
import {cloneList} from './_internals/cloneList'
|
|
2
3
|
|
|
3
|
-
function updateFn(
|
|
4
|
-
|
|
5
|
-
)
|
|
6
|
-
const arrClone = list.slice()
|
|
4
|
+
function updateFn(index, newValue, list) {
|
|
5
|
+
const clone = cloneList(list)
|
|
6
|
+
if (index === -1) return clone.fill(newValue, index)
|
|
7
7
|
|
|
8
|
-
return
|
|
9
|
-
newValue, index, index + 1
|
|
10
|
-
)
|
|
8
|
+
return clone.fill(newValue, index, index + 1)
|
|
11
9
|
}
|
|
12
10
|
|
|
13
11
|
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[
|
|
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/whereEq.js
CHANGED
|
@@ -1,14 +1,16 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import {equals} from './equals'
|
|
2
|
+
import {filter} from './filter'
|
|
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
|
-
|
|
11
|
-
|
|
9
|
+
const result = filter(
|
|
10
|
+
(conditionValue, conditionProp) =>
|
|
11
|
+
equals(conditionValue, input[conditionProp]),
|
|
12
|
+
condition
|
|
13
|
+
)
|
|
12
14
|
|
|
13
15
|
return Object.keys(result).length === Object.keys(condition).length
|
|
14
16
|
}
|
package/src/without.js
CHANGED
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import {reduce} from './reduce'
|
|
2
|
+
import {_indexOf} from './equals'
|
|
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
|
|
|
9
9
|
return reduce(
|
|
10
10
|
(prev, current) =>
|
|
11
|
-
|
|
11
|
+
_indexOf(current, matchAgainst) > -1 ? prev : prev.concat(current),
|
|
12
12
|
[],
|
|
13
13
|
source
|
|
14
14
|
)
|
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[
|
|
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,12 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {take} from './take'
|
|
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
|
|
8
|
-
) => {
|
|
9
|
-
prev[ xInstance ] = values[ i ]
|
|
6
|
+
return take(values.length, keys).reduce((prev, xInstance, i) => {
|
|
7
|
+
prev[xInstance] = values[i]
|
|
10
8
|
|
|
11
9
|
return prev
|
|
12
10
|
}, {})
|
package/src/zipWith.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import {curry} from './curry'
|
|
2
|
+
import {take} from './take'
|
|
3
3
|
|
|
4
|
-
function zipWithFn(
|
|
5
|
-
|
|
6
|
-
)
|
|
7
|
-
|
|
8
|
-
x).map((xInstance, i) => fn(xInstance, y[ i ]))
|
|
4
|
+
function zipWithFn(fn, x, y) {
|
|
5
|
+
return take(x.length > y.length ? y.length : x.length, x).map(
|
|
6
|
+
(xInstance, i) => fn(xInstance, y[i])
|
|
7
|
+
)
|
|
9
8
|
}
|
|
10
9
|
|
|
11
10
|
export const zipWith = curry(zipWithFn)
|