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/package.json
CHANGED
|
@@ -1,100 +1,121 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
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
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
2
|
+
"name": "rambda",
|
|
3
|
+
"version": "7.0.3",
|
|
4
|
+
"scripts": {
|
|
5
|
+
"populatedocs": "cd ../rambda-scripts && yarn populate:docs",
|
|
6
|
+
"populatedocs:x": "cd ../rambda-scripts && yarn populate:docs:rambdax",
|
|
7
|
+
"populatereadme": "cd ../rambda-scripts && yarn populate:readme",
|
|
8
|
+
"populatereadme:x": "cd ../rambda-scripts && yarn populate:readme:rambdax",
|
|
9
|
+
"out": "yarn populatedocs && yarn populatereadme && yarn immutable && yarn build",
|
|
10
|
+
"x": "yarn populatedocs:x && yarn populatereadme:x && yarn immutable:x",
|
|
11
|
+
"github": "cd ../rambda-scripts && yarn github",
|
|
12
|
+
"fix-docsify": "cd ../rambda-scripts && yarn fix-docsify:rambda",
|
|
13
|
+
"immutable": "cd ../rambda-scripts && yarn immutable:rambda",
|
|
14
|
+
"immutable:x": "cd ../rambda-scripts && yarn immutable:rambdax",
|
|
15
|
+
"usedby": "cd ../rambda-scripts && yarn usedby",
|
|
16
|
+
"lint": "cd ../rambda-scripts && yarn lint",
|
|
17
|
+
"build": "yarn build:main && yarn build:web",
|
|
18
|
+
"build:web": "cross-env NODE_ENV=build rollup -c files/rollup.web.config.js",
|
|
19
|
+
"build:main": "cross-env NODE_ENV=build rollup -c files/rollup.config.js",
|
|
20
|
+
"docs": "npx docsify-cli init ./docs && yarn fix-docsify",
|
|
21
|
+
"new": "cd ../rambda-scripts && yarn new",
|
|
22
|
+
"test": "jest source -u --bail=false",
|
|
23
|
+
"test:dev": "jest source --watch",
|
|
24
|
+
"cover:spec": "jest source --coverage --no-cache -w 1",
|
|
25
|
+
"cover": "yarn typings && yarn cover:spec",
|
|
26
|
+
"build:step": "yarn populatedocs && yarn populatereadme && yarn build:main",
|
|
27
|
+
"benchmark:check:apply": "cd ../rambda-scripts && yarn check-benchmark",
|
|
28
|
+
"benchmark:check": "yarn build:step && METHOD=compose yarn benchmark:check:apply",
|
|
29
|
+
"benchmark:single": "cd ../rambda-scripts && METHOD=pipe RAMBDA_RUN_ALL=ON RAMBDA_RUN_INDEXES=ON yarn benchmark",
|
|
30
|
+
"benchmark:all": "yarn build:step && cd ../rambda-scripts && yarn benchmark:all",
|
|
31
|
+
"benchmark": "yarn build:step && yarn benchmark:single",
|
|
32
|
+
"typings": "dtslint --localTs ./node_modules/typescript/lib --expectOnly ./source",
|
|
33
|
+
"fix": "mkdir $HOME/.dts/perf -p"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {},
|
|
36
|
+
"devDependencies": {
|
|
37
|
+
"@babel/core": "7.16.0",
|
|
38
|
+
"@babel/plugin-proposal-object-rest-spread": "7.16.0",
|
|
39
|
+
"@babel/preset-env": "7.16.4",
|
|
40
|
+
"@rollup/plugin-babel": "5.3.0",
|
|
41
|
+
"@rollup/plugin-commonjs": "21.0.1",
|
|
42
|
+
"@rollup/plugin-json": "4.1.0",
|
|
43
|
+
"@rollup/plugin-node-resolve": "13.0.6",
|
|
44
|
+
"@rollup/plugin-replace": "3.0.0",
|
|
45
|
+
"@types/jest": "27.0.3",
|
|
46
|
+
"@types/ramda": "0.27.58",
|
|
47
|
+
"combinate": "1.1.7",
|
|
48
|
+
"cross-env": "7.0.3",
|
|
49
|
+
"dtslint": "4.2.1",
|
|
50
|
+
"helpers-fn": "1.6.0",
|
|
51
|
+
"is-ci": "3.0.1",
|
|
52
|
+
"jest": "27.4.3",
|
|
53
|
+
"jest-extended": "0.11.5",
|
|
54
|
+
"lodash": "4.17.21",
|
|
55
|
+
"rambdax": "7.4.1",
|
|
56
|
+
"ramda": "0.27.1",
|
|
57
|
+
"rollup": "2.60.2",
|
|
58
|
+
"rollup-plugin-cleanup": "3.2.1",
|
|
59
|
+
"rollup-plugin-sourcemaps": "0.6.3",
|
|
60
|
+
"rollup-plugin-uglify": "6.0.4",
|
|
61
|
+
"typescript": "4.5.2"
|
|
62
|
+
},
|
|
63
|
+
"depFn": [
|
|
64
|
+
"jest-extended"
|
|
65
|
+
],
|
|
66
|
+
"jest": {
|
|
67
|
+
"testEnvironment": "node",
|
|
68
|
+
"testRegex": ".*\\.spec\\.js$",
|
|
69
|
+
"setupFilesAfterEnv": [
|
|
70
|
+
"jest-extended"
|
|
71
|
+
],
|
|
72
|
+
"collectCoverageFrom": [
|
|
73
|
+
"source/*.js",
|
|
74
|
+
"!_internals",
|
|
75
|
+
"!benchmarks"
|
|
76
|
+
]
|
|
77
|
+
},
|
|
78
|
+
"files": [
|
|
79
|
+
"dist",
|
|
80
|
+
"src",
|
|
81
|
+
"README.md",
|
|
82
|
+
"CHANGELOG.md",
|
|
83
|
+
"index.d.ts",
|
|
84
|
+
"immutable.d.ts",
|
|
85
|
+
"immutable.js"
|
|
86
|
+
],
|
|
87
|
+
"repository": {
|
|
88
|
+
"type": "git",
|
|
89
|
+
"url": "git+https://github.com/selfrefactor/rambda.git"
|
|
90
|
+
},
|
|
91
|
+
"license": "MIT",
|
|
92
|
+
"author": "self_refactor",
|
|
93
|
+
"description": "Lightweight and faster alternative to Ramda with included TS definitions",
|
|
94
|
+
"sideEffects": false,
|
|
95
|
+
"main": "./dist/rambda.js",
|
|
96
|
+
"umd": "./dist/rambda.umd.js",
|
|
97
|
+
"module": "./dist/rambda.mjs",
|
|
98
|
+
"types": "./index.d.ts",
|
|
99
|
+
"exports": {
|
|
100
|
+
".": {
|
|
101
|
+
"import": "./dist/rambda.mjs",
|
|
102
|
+
"require": "./dist/rambda.js",
|
|
103
|
+
"default": "./dist/rambda.js",
|
|
104
|
+
"types": "./index.d.ts"
|
|
105
|
+
},
|
|
106
|
+
"./immutable": {
|
|
107
|
+
"import": "./immutable.js",
|
|
108
|
+
"require": "./immutable.js",
|
|
109
|
+
"default": "./immutable.js",
|
|
110
|
+
"types": "./immutable.d.ts"
|
|
111
|
+
}
|
|
112
|
+
},
|
|
113
|
+
"keywords": [
|
|
114
|
+
"ramda",
|
|
115
|
+
"fp",
|
|
116
|
+
"functional",
|
|
117
|
+
"utility",
|
|
118
|
+
"lodash"
|
|
119
|
+
],
|
|
120
|
+
"homepage": "https://github.com/selfrefactor/rambda#readme"
|
|
100
121
|
}
|
package/src/F.js
CHANGED
package/src/T.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
// @see https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/is
|
|
2
|
-
export function _objectIs(a, b){
|
|
2
|
+
export function _objectIs(a, b) {
|
|
3
3
|
// SameValue algorithm
|
|
4
|
-
if (a === b){
|
|
4
|
+
if (a === b) {
|
|
5
5
|
// Steps 1-5, 7-10
|
|
6
6
|
// Steps 6.b-6.e: +0 != -0
|
|
7
7
|
return a !== 0 || 1 / a === 1 / b
|
|
@@ -1,20 +1,18 @@
|
|
|
1
|
-
export default function baseSlice(
|
|
2
|
-
array, start, end
|
|
3
|
-
){
|
|
1
|
+
export default function baseSlice(array, start, end) {
|
|
4
2
|
let index = -1
|
|
5
|
-
let {
|
|
3
|
+
let {length} = array
|
|
6
4
|
|
|
7
5
|
end = end > length ? length : end
|
|
8
|
-
if (end < 0){
|
|
6
|
+
if (end < 0) {
|
|
9
7
|
end += length
|
|
10
8
|
}
|
|
11
|
-
length = start > end ? 0 : end - start >>> 0
|
|
9
|
+
length = start > end ? 0 : (end - start) >>> 0
|
|
12
10
|
start >>>= 0
|
|
13
11
|
|
|
14
12
|
const result = Array(length)
|
|
15
13
|
|
|
16
|
-
while (++index < length){
|
|
17
|
-
result[
|
|
14
|
+
while (++index < length) {
|
|
15
|
+
result[index] = array[index + start]
|
|
18
16
|
}
|
|
19
17
|
|
|
20
18
|
return result
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import {type} from '../type'
|
|
2
|
+
import {_isArray} from './_isArray'
|
|
3
3
|
|
|
4
|
-
export function isFalsy(x){
|
|
5
|
-
if (_isArray(x)){
|
|
4
|
+
export function isFalsy(x) {
|
|
5
|
+
if (_isArray(x)) {
|
|
6
6
|
return x.length === 0
|
|
7
7
|
}
|
|
8
|
-
if (type(x) === 'Object'){
|
|
8
|
+
if (type(x) === 'Object') {
|
|
9
9
|
return Object.keys(x).length === 0
|
|
10
10
|
}
|
|
11
11
|
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import {type} from '../type'
|
|
2
|
+
import {_isArray} from './_isArray'
|
|
3
3
|
|
|
4
|
-
export function isTruthy(x){
|
|
5
|
-
if (_isArray(x)){
|
|
4
|
+
export function isTruthy(x) {
|
|
5
|
+
if (_isArray(x)) {
|
|
6
6
|
return x.length > 0
|
|
7
7
|
}
|
|
8
|
-
if (type(x) === 'Object'){
|
|
8
|
+
if (type(x) === 'Object') {
|
|
9
9
|
return Object.keys(x).length > 0
|
|
10
10
|
}
|
|
11
11
|
|
package/src/_internals/set.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import {type as typeMethod} from '../type'
|
|
2
|
-
import {
|
|
2
|
+
import {_indexOf} from '../equals'
|
|
3
3
|
|
|
4
4
|
export class _Set {
|
|
5
5
|
constructor() {
|
|
@@ -9,13 +9,13 @@ export class _Set {
|
|
|
9
9
|
checkUniqueness(item) {
|
|
10
10
|
const type = typeMethod(item)
|
|
11
11
|
if (['Null', 'Undefined', 'NaN'].includes(type)) {
|
|
12
|
-
if(type in this.items) {
|
|
12
|
+
if (type in this.items) {
|
|
13
13
|
return false
|
|
14
|
-
}
|
|
14
|
+
}
|
|
15
15
|
this.items[type] = true
|
|
16
16
|
return true
|
|
17
17
|
}
|
|
18
|
-
if (!['Object', 'Array'].includes(
|
|
18
|
+
if (!['Object', 'Array'].includes(type)) {
|
|
19
19
|
const prevSize = this.set.size
|
|
20
20
|
this.set.add(item)
|
|
21
21
|
return this.set.size !== prevSize
|
package/src/add.js
CHANGED
package/src/adjust.js
CHANGED
|
@@ -1,13 +1,12 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {curry} from './curry'
|
|
2
|
+
import {cloneList} from './_internals/cloneList'
|
|
2
3
|
|
|
3
|
-
function adjustFn(
|
|
4
|
-
index, replaceFn, list
|
|
5
|
-
){
|
|
4
|
+
function adjustFn(index, replaceFn, list) {
|
|
6
5
|
const actualIndex = index < 0 ? list.length + index : index
|
|
7
6
|
if (index >= list.length || actualIndex < 0) return list
|
|
8
7
|
|
|
9
|
-
const clone = list
|
|
10
|
-
clone[
|
|
8
|
+
const clone = cloneList(list)
|
|
9
|
+
clone[actualIndex] = replaceFn(clone[actualIndex])
|
|
11
10
|
|
|
12
11
|
return clone
|
|
13
12
|
}
|
package/src/all.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export function all(predicate, list){
|
|
1
|
+
export function all(predicate, list) {
|
|
2
2
|
if (arguments.length === 1) return _list => all(predicate, _list)
|
|
3
3
|
|
|
4
|
-
for (let i = 0; i < list.length; i++){
|
|
5
|
-
if (!predicate(list[
|
|
4
|
+
for (let i = 0; i < list.length; i++) {
|
|
5
|
+
if (!predicate(list[i])) return false
|
|
6
6
|
}
|
|
7
7
|
|
|
8
8
|
return true
|
package/src/allPass.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export function allPass(predicates){
|
|
2
|
-
return input => {
|
|
1
|
+
export function allPass(predicates) {
|
|
2
|
+
return (...input) => {
|
|
3
3
|
let counter = 0
|
|
4
|
-
while (counter < predicates.length){
|
|
5
|
-
if (!predicates[
|
|
4
|
+
while (counter < predicates.length) {
|
|
5
|
+
if (!predicates[counter](...input)) {
|
|
6
6
|
return false
|
|
7
7
|
}
|
|
8
8
|
counter++
|
package/src/always.js
CHANGED
package/src/and.js
CHANGED
package/src/any.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
export function any(predicate, list){
|
|
1
|
+
export function any(predicate, list) {
|
|
2
2
|
if (arguments.length === 1) return _list => any(predicate, _list)
|
|
3
3
|
|
|
4
4
|
let counter = 0
|
|
5
|
-
while (counter < list.length){
|
|
6
|
-
if (predicate(list[
|
|
5
|
+
while (counter < list.length) {
|
|
6
|
+
if (predicate(list[counter], counter)) {
|
|
7
7
|
return true
|
|
8
8
|
}
|
|
9
9
|
counter++
|
package/src/anyPass.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
export function anyPass(predicates){
|
|
2
|
-
return input => {
|
|
1
|
+
export function anyPass(predicates) {
|
|
2
|
+
return (...input) => {
|
|
3
3
|
let counter = 0
|
|
4
|
-
while (counter < predicates.length){
|
|
5
|
-
if (predicates[
|
|
4
|
+
while (counter < predicates.length) {
|
|
5
|
+
if (predicates[counter](...input)) {
|
|
6
6
|
return true
|
|
7
7
|
}
|
|
8
8
|
counter++
|
package/src/append.js
CHANGED
|
@@ -1,9 +1,11 @@
|
|
|
1
|
-
|
|
1
|
+
import {cloneList} from './_internals/cloneList'
|
|
2
|
+
|
|
3
|
+
export function append(x, input) {
|
|
2
4
|
if (arguments.length === 1) return _input => append(x, _input)
|
|
3
5
|
|
|
4
6
|
if (typeof input === 'string') return input.split('').concat(x)
|
|
5
7
|
|
|
6
|
-
const clone = input
|
|
8
|
+
const clone = cloneList(input)
|
|
7
9
|
clone.push(x)
|
|
8
10
|
|
|
9
11
|
return clone
|
package/src/apply.js
ADDED
package/src/applySpec.js
CHANGED
|
@@ -1,93 +1,71 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import {_isArray} from './_internals/_isArray'
|
|
2
2
|
|
|
3
3
|
// recursively traverse the given spec object to find the highest arity function
|
|
4
|
-
function __findHighestArity(spec, max = 0){
|
|
5
|
-
for (const key in spec){
|
|
4
|
+
function __findHighestArity(spec, max = 0) {
|
|
5
|
+
for (const key in spec) {
|
|
6
6
|
if (spec.hasOwnProperty(key) === false || key === 'constructor') continue
|
|
7
7
|
|
|
8
|
-
if (typeof spec[
|
|
9
|
-
max = Math.max(max, __findHighestArity(spec[
|
|
8
|
+
if (typeof spec[key] === 'object') {
|
|
9
|
+
max = Math.max(max, __findHighestArity(spec[key]))
|
|
10
10
|
}
|
|
11
11
|
|
|
12
|
-
if (typeof spec[
|
|
13
|
-
max = Math.max(max, spec[
|
|
12
|
+
if (typeof spec[key] === 'function') {
|
|
13
|
+
max = Math.max(max, spec[key].length)
|
|
14
14
|
}
|
|
15
15
|
}
|
|
16
16
|
|
|
17
17
|
return max
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
-
function __filterUndefined(){
|
|
20
|
+
function __filterUndefined() {
|
|
21
21
|
const defined = []
|
|
22
22
|
let i = 0
|
|
23
23
|
const l = arguments.length
|
|
24
|
-
while (i < l){
|
|
25
|
-
if (typeof arguments[
|
|
26
|
-
defined[
|
|
24
|
+
while (i < l) {
|
|
25
|
+
if (typeof arguments[i] === 'undefined') break
|
|
26
|
+
defined[i] = arguments[i]
|
|
27
27
|
i++
|
|
28
28
|
}
|
|
29
29
|
|
|
30
30
|
return defined
|
|
31
31
|
}
|
|
32
32
|
|
|
33
|
-
function __applySpecWithArity(
|
|
34
|
-
spec, arity, cache
|
|
35
|
-
){
|
|
33
|
+
function __applySpecWithArity(spec, arity, cache) {
|
|
36
34
|
const remaining = arity - cache.length
|
|
37
35
|
|
|
38
36
|
if (remaining === 1)
|
|
39
37
|
return x =>
|
|
40
|
-
__applySpecWithArity(
|
|
41
|
-
spec, arity, __filterUndefined(...cache, x)
|
|
42
|
-
)
|
|
38
|
+
__applySpecWithArity(spec, arity, __filterUndefined(...cache, x))
|
|
43
39
|
if (remaining === 2)
|
|
44
40
|
return (x, y) =>
|
|
45
|
-
__applySpecWithArity(
|
|
46
|
-
spec, arity, __filterUndefined(
|
|
47
|
-
...cache, x, y
|
|
48
|
-
)
|
|
49
|
-
)
|
|
41
|
+
__applySpecWithArity(spec, arity, __filterUndefined(...cache, x, y))
|
|
50
42
|
if (remaining === 3)
|
|
51
|
-
return (
|
|
52
|
-
x, y, z
|
|
53
|
-
) =>
|
|
54
|
-
__applySpecWithArity(
|
|
55
|
-
spec, arity, __filterUndefined(
|
|
56
|
-
...cache, x, y, z
|
|
57
|
-
)
|
|
58
|
-
)
|
|
43
|
+
return (x, y, z) =>
|
|
44
|
+
__applySpecWithArity(spec, arity, __filterUndefined(...cache, x, y, z))
|
|
59
45
|
if (remaining === 4)
|
|
60
|
-
return (
|
|
61
|
-
x, y, z, a
|
|
62
|
-
) =>
|
|
46
|
+
return (x, y, z, a) =>
|
|
63
47
|
__applySpecWithArity(
|
|
64
48
|
spec,
|
|
65
49
|
arity,
|
|
66
|
-
__filterUndefined(
|
|
67
|
-
...cache, x, y, z, a
|
|
68
|
-
)
|
|
50
|
+
__filterUndefined(...cache, x, y, z, a)
|
|
69
51
|
)
|
|
70
52
|
if (remaining > 4)
|
|
71
53
|
return (...args) =>
|
|
72
|
-
__applySpecWithArity(
|
|
73
|
-
spec, arity, __filterUndefined(...cache, ...args)
|
|
74
|
-
)
|
|
54
|
+
__applySpecWithArity(spec, arity, __filterUndefined(...cache, ...args))
|
|
75
55
|
|
|
76
56
|
// handle spec as Array
|
|
77
|
-
if (_isArray(spec)){
|
|
57
|
+
if (_isArray(spec)) {
|
|
78
58
|
const ret = []
|
|
79
59
|
let i = 0
|
|
80
60
|
const l = spec.length
|
|
81
|
-
for (; i < l; i++){
|
|
61
|
+
for (; i < l; i++) {
|
|
82
62
|
// handle recursive spec inside array
|
|
83
|
-
if (typeof spec[
|
|
84
|
-
ret[
|
|
85
|
-
spec[ i ], arity, cache
|
|
86
|
-
)
|
|
63
|
+
if (typeof spec[i] === 'object' || _isArray(spec[i])) {
|
|
64
|
+
ret[i] = __applySpecWithArity(spec[i], arity, cache)
|
|
87
65
|
}
|
|
88
66
|
// apply spec to the key
|
|
89
|
-
if (typeof spec[
|
|
90
|
-
ret[
|
|
67
|
+
if (typeof spec[i] === 'function') {
|
|
68
|
+
ret[i] = spec[i](...cache)
|
|
91
69
|
}
|
|
92
70
|
}
|
|
93
71
|
|
|
@@ -97,36 +75,32 @@ function __applySpecWithArity(
|
|
|
97
75
|
// handle spec as Object
|
|
98
76
|
const ret = {}
|
|
99
77
|
// apply callbacks to each property in the spec object
|
|
100
|
-
for (const key in spec){
|
|
78
|
+
for (const key in spec) {
|
|
101
79
|
if (spec.hasOwnProperty(key) === false || key === 'constructor') continue
|
|
102
80
|
|
|
103
81
|
// apply the spec recursively
|
|
104
|
-
if (typeof spec[
|
|
105
|
-
ret[
|
|
106
|
-
spec[ key ], arity, cache
|
|
107
|
-
)
|
|
82
|
+
if (typeof spec[key] === 'object') {
|
|
83
|
+
ret[key] = __applySpecWithArity(spec[key], arity, cache)
|
|
108
84
|
continue
|
|
109
85
|
}
|
|
110
86
|
|
|
111
87
|
// apply spec to the key
|
|
112
|
-
if (typeof spec[
|
|
113
|
-
ret[
|
|
88
|
+
if (typeof spec[key] === 'function') {
|
|
89
|
+
ret[key] = spec[key](...cache)
|
|
114
90
|
}
|
|
115
91
|
}
|
|
116
92
|
|
|
117
93
|
return ret
|
|
118
94
|
}
|
|
119
95
|
|
|
120
|
-
export function applySpec(spec, ...args){
|
|
96
|
+
export function applySpec(spec, ...args) {
|
|
121
97
|
// get the highest arity spec function, cache the result and pass to __applySpecWithArity
|
|
122
98
|
const arity = __findHighestArity(spec)
|
|
123
99
|
|
|
124
|
-
if (arity === 0){
|
|
100
|
+
if (arity === 0) {
|
|
125
101
|
return () => ({})
|
|
126
102
|
}
|
|
127
|
-
const toReturn = __applySpecWithArity(
|
|
128
|
-
spec, arity, args
|
|
129
|
-
)
|
|
103
|
+
const toReturn = __applySpecWithArity(spec, arity, args)
|
|
130
104
|
|
|
131
105
|
return toReturn
|
|
132
106
|
}
|