rambda 7.2.1 → 7.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +22 -0
- package/README.md +1431 -3264
- package/dist/rambda.js +83 -422
- package/dist/rambda.mjs +89 -433
- package/dist/rambda.umd.js +1 -1
- package/immutable.d.ts +290 -229
- package/index.d.ts +290 -229
- package/package.json +38 -33
- package/rambda.js +187 -0
- package/src/_internals/constants.js +1 -0
- package/src/_internals/isArray.js +1 -0
- package/src/_internals/isFalsy.js +2 -2
- package/src/_internals/isInteger.js +5 -0
- package/src/_internals/isIterable.js +5 -0
- package/src/_internals/isObject.js +1 -1
- package/src/_internals/isTruthy.js +2 -2
- package/src/_internals/keys.js +1 -0
- package/src/_internals/{_objectIs.js → objectIs.js} +2 -2
- package/src/applySpec.js +3 -3
- package/src/assocPath.js +7 -7
- package/src/clone.js +2 -2
- package/src/count.js +2 -2
- package/src/dropLastWhile.js +2 -2
- package/src/dropRepeats.js +2 -2
- package/src/dropRepeatsWith.js +2 -2
- package/src/dropWhile.js +2 -2
- package/src/endsWith.js +2 -2
- package/src/equals.js +3 -15
- package/src/evolve.js +1 -1
- package/src/filter.js +2 -2
- package/src/flatten.js +2 -2
- package/src/forEach.js +6 -6
- package/src/groupWith.js +2 -2
- package/src/identical.js +2 -2
- package/src/includes.js +2 -2
- package/src/isPromise.js +1 -1
- package/src/length.js +2 -2
- package/src/map.js +8 -7
- package/src/mathMod.js +2 -2
- package/src/merge.js +1 -1
- package/src/mergeDeepRight.js +2 -1
- package/src/mergeRight.js +2 -1
- package/src/modify.js +23 -0
- package/src/modifyPath.js +2 -2
- package/src/nop.js +1 -0
- package/src/partialObject.js +1 -11
- package/src/partition.js +2 -2
- package/src/props.js +2 -2
- package/src/reduce.js +2 -3
- package/src/splitAt.js +2 -2
- package/src/startsWith.js +2 -2
- package/src/takeLastWhile.js +2 -2
- package/src/takeWhile.js +2 -2
- package/src/test.js +1 -1
- package/src/times.js +2 -1
- package/src/transpose.js +2 -2
- package/src/unwind.js +4 -3
- package/src/update.js +1 -1
- package/src/where.js +1 -0
- package/src/_internals/_isArray.js +0 -1
- package/src/_internals/_isInteger.js +0 -5
- package/src/_internals/_keys.js +0 -1
package/package.json
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "rambda",
|
|
3
|
-
"version": "7.
|
|
3
|
+
"version": "7.4.0",
|
|
4
4
|
"scripts": {
|
|
5
|
+
"publishx": "node files/publish",
|
|
5
6
|
"populatedocs": "cd ../rambda-scripts && yarn populate:docs",
|
|
6
7
|
"populatedocs:x": "cd ../rambda-scripts && yarn populate:docs:rambdax",
|
|
7
8
|
"populatereadme": "cd ../rambda-scripts && yarn populate:readme",
|
|
@@ -13,63 +14,65 @@
|
|
|
13
14
|
"github": "cd ../rambda-scripts && yarn github",
|
|
14
15
|
"fix-docsify": "cd ../rambda-scripts && yarn fix-docsify:rambda",
|
|
15
16
|
"immutable": "cd ../rambda-scripts && yarn immutable:rambda",
|
|
16
|
-
"immutable:x": "cd ../rambda-scripts && yarn immutable:rambdax",
|
|
17
17
|
"usedby": "cd ../rambda-scripts && yarn usedby",
|
|
18
18
|
"lint:all": "cd ../rambda-scripts && yarn lint",
|
|
19
19
|
"lint:staged": "cd ../rambda-scripts && yarn lint:staged",
|
|
20
20
|
"lint": "yarn git:add && yarn lint:staged && yarn git:add",
|
|
21
21
|
"git:add": "git add -A",
|
|
22
22
|
"build": "yarn build:main && yarn build:web",
|
|
23
|
-
"build:web": "cross-env NODE_ENV=build rollup -c files/rollup.web.config.
|
|
24
|
-
"build:main": "cross-env NODE_ENV=build rollup -c files/rollup.config.
|
|
23
|
+
"build:web": "cross-env NODE_ENV=build rollup -c files/rollup.web.config.mjs",
|
|
24
|
+
"build:main": "cross-env NODE_ENV=build rollup -c files/rollup.config.mjs",
|
|
25
25
|
"docs": "npx docsify-cli init ./docs && yarn fix-docsify",
|
|
26
26
|
"new": "cd ../rambda-scripts && yarn new",
|
|
27
|
-
"test
|
|
28
|
-
"
|
|
29
|
-
"
|
|
30
|
-
"
|
|
27
|
+
"run:ramda:test": "cd ../rambda-scripts && yarn run:ramda:test",
|
|
28
|
+
"consume-typings:clone": "cd .. && git clone --depth 1 https://github.com/selfrefactor/rambda-scripts.git rambda-scripts-clone",
|
|
29
|
+
"consume-typings:execute": "cd ../rambda-scripts-clone/scripts/consume-typings && yarn start",
|
|
30
|
+
"consume-typings": "yarn consume-typings:clone && yarn consume-typings:execute",
|
|
31
|
+
"test:consume-typings": "jest source/_consumeTypings.test.js",
|
|
32
|
+
"test:typings": "dtslint --localTs ./node_modules/typescript/lib --expectOnly ./source",
|
|
33
|
+
"t": "yarn test:typings",
|
|
34
|
+
"test:all": "jest source/*.spec.js -u --bail=false",
|
|
35
|
+
"test": "jest -o -u --watch",
|
|
36
|
+
"test:ci": "jest source/*.spec.js --coverage --no-cache -w 1",
|
|
31
37
|
"build:step": "yarn populatedocs && yarn populatereadme && yarn build:main",
|
|
32
|
-
"benchmark:check:apply": "cd ../rambda-scripts && yarn check-benchmark",
|
|
33
|
-
"benchmark:check": "yarn build:step && METHOD=compose yarn benchmark:check:apply",
|
|
34
|
-
"benchmark:single": "cd ../rambda-scripts && METHOD=uniqWith RAMBDA_RUN_ALL=ON RAMBDA_RUN_INDEXES=ON yarn benchmark",
|
|
35
38
|
"benchmark:all": "yarn build:step && cd ../rambda-scripts && yarn benchmark:all",
|
|
36
|
-
"benchmark": "yarn build:step && yarn benchmark:
|
|
37
|
-
"
|
|
39
|
+
"benchmark:check": "yarn build:step && METHOD=compose yarn benchmark:check:apply",
|
|
40
|
+
"benchmark:check:apply": "cd ../rambda-scripts && yarn check-benchmark",
|
|
41
|
+
"benchmark": "cd ../rambda-scripts && RAMBDA_RUN_ALL=ON RAMBDA_RUN_INDEXES=ON yarn benchmark",
|
|
38
42
|
"d:rambda-scripts": "cd ../rambda-scripts && run d",
|
|
39
|
-
"d": "yarn out && yarn lint && run d && yarn d:rambda-scripts"
|
|
40
|
-
"fix": "mkdir $HOME/.dts/perf -p"
|
|
43
|
+
"d": "yarn out && yarn lint && run d && yarn d:rambda-scripts"
|
|
41
44
|
},
|
|
42
45
|
"dependencies": {},
|
|
43
46
|
"devDependencies": {
|
|
44
|
-
"@babel/core": "7.
|
|
45
|
-
"@babel/plugin-proposal-object-rest-spread": "7.
|
|
46
|
-
"@babel/preset-env": "7.
|
|
47
|
-
"@rollup/plugin-babel": "
|
|
48
|
-
"@rollup/plugin-commonjs": "
|
|
49
|
-
"@rollup/plugin-
|
|
50
|
-
"@rollup/plugin-
|
|
51
|
-
"@
|
|
52
|
-
"@types/
|
|
53
|
-
"@types/ramda": "0.28.15",
|
|
47
|
+
"@babel/core": "7.20.2",
|
|
48
|
+
"@babel/plugin-proposal-object-rest-spread": "7.20.2",
|
|
49
|
+
"@babel/preset-env": "7.20.2",
|
|
50
|
+
"@rollup/plugin-babel": "6.0.2",
|
|
51
|
+
"@rollup/plugin-commonjs": "23.0.2",
|
|
52
|
+
"@rollup/plugin-node-resolve": "15.0.1",
|
|
53
|
+
"@rollup/plugin-replace": "5.0.1",
|
|
54
|
+
"@types/jest": "29.2.2",
|
|
55
|
+
"@types/ramda": "0.28.18",
|
|
54
56
|
"combinate": "1.1.11",
|
|
55
57
|
"cross-env": "7.0.3",
|
|
56
58
|
"dtslint": "4.2.1",
|
|
57
59
|
"helpers-fn": "1.6.0",
|
|
58
60
|
"is-ci": "3.0.1",
|
|
59
|
-
"jest": "
|
|
60
|
-
"jest-extended": "3.0
|
|
61
|
+
"jest": "29.2.2",
|
|
62
|
+
"jest-extended": "3.1.0",
|
|
61
63
|
"lodash": "4.17.21",
|
|
62
|
-
"rambdax": "8.0
|
|
64
|
+
"rambdax": "8.1.0",
|
|
63
65
|
"ramda": "0.28.0",
|
|
64
|
-
"
|
|
66
|
+
"remeda": "1.2.0",
|
|
67
|
+
"rollup": "3.2.5",
|
|
65
68
|
"rollup-plugin-cleanup": "3.2.1",
|
|
66
69
|
"rollup-plugin-sourcemaps": "0.6.3",
|
|
67
70
|
"rollup-plugin-uglify": "6.0.4",
|
|
68
|
-
"typescript": "4.
|
|
71
|
+
"typescript": "4.8.4"
|
|
69
72
|
},
|
|
70
73
|
"jest": {
|
|
71
74
|
"testEnvironment": "node",
|
|
72
|
-
"testRegex": ".*\\.spec\\.js$",
|
|
75
|
+
"testRegex": ".*\\.(spec|test)\\.js$",
|
|
73
76
|
"setupFilesAfterEnv": [
|
|
74
77
|
"./files/testSetup.js"
|
|
75
78
|
],
|
|
@@ -86,6 +89,8 @@
|
|
|
86
89
|
"CHANGELOG.md",
|
|
87
90
|
"index.d.ts",
|
|
88
91
|
"immutable.d.ts",
|
|
92
|
+
"rambda.js",
|
|
93
|
+
"rambda.js",
|
|
89
94
|
"immutable.js"
|
|
90
95
|
],
|
|
91
96
|
"repository": {
|
|
@@ -98,11 +103,11 @@
|
|
|
98
103
|
"sideEffects": false,
|
|
99
104
|
"main": "./dist/rambda.js",
|
|
100
105
|
"umd": "./dist/rambda.umd.js",
|
|
101
|
-
"module": "./
|
|
106
|
+
"module": "./rambda.js",
|
|
102
107
|
"types": "./index.d.ts",
|
|
103
108
|
"exports": {
|
|
104
109
|
".": {
|
|
105
|
-
"import": "./
|
|
110
|
+
"import": "./rambda.js",
|
|
106
111
|
"require": "./dist/rambda.js",
|
|
107
112
|
"default": "./dist/rambda.js",
|
|
108
113
|
"types": "./index.d.ts"
|
package/rambda.js
ADDED
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
/// <reference types="./index.d.ts" />
|
|
2
|
+
export * from './src/F.js'
|
|
3
|
+
export * from './src/T.js'
|
|
4
|
+
export * from './src/add.js'
|
|
5
|
+
export * from './src/adjust.js'
|
|
6
|
+
export * from './src/all.js'
|
|
7
|
+
export * from './src/allPass.js'
|
|
8
|
+
export * from './src/always.js'
|
|
9
|
+
export * from './src/and.js'
|
|
10
|
+
export * from './src/any.js'
|
|
11
|
+
export * from './src/anyPass.js'
|
|
12
|
+
export * from './src/append.js'
|
|
13
|
+
export * from './src/apply.js'
|
|
14
|
+
export * from './src/applySpec.js'
|
|
15
|
+
export * from './src/assoc.js'
|
|
16
|
+
export * from './src/assocPath.js'
|
|
17
|
+
export * from './src/bind.js'
|
|
18
|
+
export * from './src/both.js'
|
|
19
|
+
export * from './src/chain.js'
|
|
20
|
+
export * from './src/clamp.js'
|
|
21
|
+
export * from './src/clone.js'
|
|
22
|
+
export * from './src/complement.js'
|
|
23
|
+
export * from './src/compose.js'
|
|
24
|
+
export * from './src/concat.js'
|
|
25
|
+
export * from './src/cond.js'
|
|
26
|
+
export * from './src/converge.js'
|
|
27
|
+
export * from './src/count.js'
|
|
28
|
+
export * from './src/countBy.js'
|
|
29
|
+
export * from './src/curry.js'
|
|
30
|
+
export * from './src/curryN.js'
|
|
31
|
+
export * from './src/dec.js'
|
|
32
|
+
export * from './src/defaultTo.js'
|
|
33
|
+
export * from './src/difference.js'
|
|
34
|
+
export * from './src/dissoc.js'
|
|
35
|
+
export * from './src/divide.js'
|
|
36
|
+
export * from './src/drop.js'
|
|
37
|
+
export * from './src/dropLast.js'
|
|
38
|
+
export * from './src/dropLastWhile.js'
|
|
39
|
+
export * from './src/dropRepeats.js'
|
|
40
|
+
export * from './src/dropRepeatsWith.js'
|
|
41
|
+
export * from './src/dropWhile.js'
|
|
42
|
+
export * from './src/either.js'
|
|
43
|
+
export * from './src/endsWith.js'
|
|
44
|
+
export * from './src/eqProps.js'
|
|
45
|
+
export * from './src/equals.js'
|
|
46
|
+
export * from './src/evolve.js'
|
|
47
|
+
export * from './src/filter.js'
|
|
48
|
+
export * from './src/find.js'
|
|
49
|
+
export * from './src/findIndex.js'
|
|
50
|
+
export * from './src/findLast.js'
|
|
51
|
+
export * from './src/findLastIndex.js'
|
|
52
|
+
export * from './src/flatten.js'
|
|
53
|
+
export * from './src/flip.js'
|
|
54
|
+
export * from './src/forEach.js'
|
|
55
|
+
export * from './src/fromPairs.js'
|
|
56
|
+
export * from './src/groupBy.js'
|
|
57
|
+
export * from './src/groupWith.js'
|
|
58
|
+
export * from './src/has.js'
|
|
59
|
+
export * from './src/hasPath.js'
|
|
60
|
+
export * from './src/head.js'
|
|
61
|
+
export * from './src/identical.js'
|
|
62
|
+
export * from './src/identity.js'
|
|
63
|
+
export * from './src/ifElse.js'
|
|
64
|
+
export * from './src/inc.js'
|
|
65
|
+
export * from './src/includes.js'
|
|
66
|
+
export * from './src/indexBy.js'
|
|
67
|
+
export * from './src/indexOf.js'
|
|
68
|
+
export * from './src/init.js'
|
|
69
|
+
export * from './src/intersection.js'
|
|
70
|
+
export * from './src/intersperse.js'
|
|
71
|
+
export * from './src/is.js'
|
|
72
|
+
export * from './src/isEmpty.js'
|
|
73
|
+
export * from './src/isNil.js'
|
|
74
|
+
export * from './src/join.js'
|
|
75
|
+
export * from './src/juxt.js'
|
|
76
|
+
export * from './src/keys.js'
|
|
77
|
+
export * from './src/last.js'
|
|
78
|
+
export * from './src/lastIndexOf.js'
|
|
79
|
+
export * from './src/length.js'
|
|
80
|
+
export * from './src/lens.js'
|
|
81
|
+
export * from './src/lensIndex.js'
|
|
82
|
+
export * from './src/lensPath.js'
|
|
83
|
+
export * from './src/lensProp.js'
|
|
84
|
+
export * from './src/map.js'
|
|
85
|
+
export * from './src/match.js'
|
|
86
|
+
export * from './src/mathMod.js'
|
|
87
|
+
export * from './src/max.js'
|
|
88
|
+
export * from './src/maxBy.js'
|
|
89
|
+
export * from './src/mean.js'
|
|
90
|
+
export * from './src/median.js'
|
|
91
|
+
export * from './src/merge.js'
|
|
92
|
+
export * from './src/mergeAll.js'
|
|
93
|
+
export * from './src/mergeDeepRight.js'
|
|
94
|
+
export * from './src/mergeLeft.js'
|
|
95
|
+
export * from './src/mergeRight.js'
|
|
96
|
+
export * from './src/mergeWith.js'
|
|
97
|
+
export * from './src/min.js'
|
|
98
|
+
export * from './src/minBy.js'
|
|
99
|
+
export * from './src/modify.js'
|
|
100
|
+
export * from './src/modifyPath.js'
|
|
101
|
+
export * from './src/modulo.js'
|
|
102
|
+
export * from './src/move.js'
|
|
103
|
+
export * from './src/multiply.js'
|
|
104
|
+
export * from './src/negate.js'
|
|
105
|
+
export * from './src/none.js'
|
|
106
|
+
export * from './src/nop.js'
|
|
107
|
+
export * from './src/not.js'
|
|
108
|
+
export * from './src/nth.js'
|
|
109
|
+
export * from './src/objOf.js'
|
|
110
|
+
export * from './src/of.js'
|
|
111
|
+
export * from './src/omit.js'
|
|
112
|
+
export * from './src/on.js'
|
|
113
|
+
export * from './src/once.js'
|
|
114
|
+
export * from './src/or.js'
|
|
115
|
+
export * from './src/over.js'
|
|
116
|
+
export * from './src/partial.js'
|
|
117
|
+
export * from './src/partialObject.js'
|
|
118
|
+
export * from './src/partition.js'
|
|
119
|
+
export * from './src/path.js'
|
|
120
|
+
export * from './src/pathEq.js'
|
|
121
|
+
export * from './src/pathOr.js'
|
|
122
|
+
export * from './src/paths.js'
|
|
123
|
+
export * from './src/pick.js'
|
|
124
|
+
export * from './src/pickAll.js'
|
|
125
|
+
export * from './src/pipe.js'
|
|
126
|
+
export * from './src/pluck.js'
|
|
127
|
+
export * from './src/prepend.js'
|
|
128
|
+
export * from './src/product.js'
|
|
129
|
+
export * from './src/prop.js'
|
|
130
|
+
export * from './src/propEq.js'
|
|
131
|
+
export * from './src/propIs.js'
|
|
132
|
+
export * from './src/propOr.js'
|
|
133
|
+
export * from './src/propSatisfies.js'
|
|
134
|
+
export * from './src/props.js'
|
|
135
|
+
export * from './src/range.js'
|
|
136
|
+
export * from './src/reduce.js'
|
|
137
|
+
export * from './src/reject.js'
|
|
138
|
+
export * from './src/repeat.js'
|
|
139
|
+
export * from './src/replace.js'
|
|
140
|
+
export * from './src/reverse.js'
|
|
141
|
+
export * from './src/set.js'
|
|
142
|
+
export * from './src/slice.js'
|
|
143
|
+
export * from './src/sort.js'
|
|
144
|
+
export * from './src/sortBy.js'
|
|
145
|
+
export * from './src/split.js'
|
|
146
|
+
export * from './src/splitAt.js'
|
|
147
|
+
export * from './src/splitEvery.js'
|
|
148
|
+
export * from './src/splitWhen.js'
|
|
149
|
+
export * from './src/startsWith.js'
|
|
150
|
+
export * from './src/subtract.js'
|
|
151
|
+
export * from './src/sum.js'
|
|
152
|
+
export * from './src/symmetricDifference.js'
|
|
153
|
+
export * from './src/tail.js'
|
|
154
|
+
export * from './src/take.js'
|
|
155
|
+
export * from './src/takeLast.js'
|
|
156
|
+
export * from './src/takeLastWhile.js'
|
|
157
|
+
export * from './src/takeWhile.js'
|
|
158
|
+
export * from './src/tap.js'
|
|
159
|
+
export * from './src/test.js'
|
|
160
|
+
export * from './src/times.js'
|
|
161
|
+
export * from './src/toLower.js'
|
|
162
|
+
export * from './src/toPairs.js'
|
|
163
|
+
export * from './src/toString.js'
|
|
164
|
+
export * from './src/toUpper.js'
|
|
165
|
+
export * from './src/transpose.js'
|
|
166
|
+
export * from './src/trim.js'
|
|
167
|
+
export * from './src/tryCatch.js'
|
|
168
|
+
export * from './src/type.js'
|
|
169
|
+
export * from './src/unapply.js'
|
|
170
|
+
export * from './src/union.js'
|
|
171
|
+
export * from './src/uniq.js'
|
|
172
|
+
export * from './src/uniqBy.js'
|
|
173
|
+
export * from './src/uniqWith.js'
|
|
174
|
+
export * from './src/unless.js'
|
|
175
|
+
export * from './src/unwind.js'
|
|
176
|
+
export * from './src/update.js'
|
|
177
|
+
export * from './src/values.js'
|
|
178
|
+
export * from './src/view.js'
|
|
179
|
+
export * from './src/when.js'
|
|
180
|
+
export * from './src/where.js'
|
|
181
|
+
export * from './src/whereAny.js'
|
|
182
|
+
export * from './src/whereEq.js'
|
|
183
|
+
export * from './src/without.js'
|
|
184
|
+
export * from './src/xor.js'
|
|
185
|
+
export * from './src/zip.js'
|
|
186
|
+
export * from './src/zipObj.js'
|
|
187
|
+
export * from './src/zipWith.js'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const INCORRECT_ITERABLE_INPUT = 'Incorrect iterable input'
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const { isArray } = Array
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export const { keys } = Object
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
|
|
1
|
+
function _objectIs(a, b){
|
|
2
2
|
if (a === b){
|
|
3
3
|
return a !== 0 || 1 / a === 1 / b
|
|
4
4
|
}
|
|
@@ -6,4 +6,4 @@ export function _objectIs(a, b){
|
|
|
6
6
|
return a !== a && b !== b
|
|
7
7
|
}
|
|
8
8
|
|
|
9
|
-
export
|
|
9
|
+
export const objectIs = Object.is || _objectIs
|
package/src/applySpec.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isArray } from './_internals/isArray.js'
|
|
2
2
|
|
|
3
3
|
// recursively traverse the given spec object to find the highest arity function
|
|
4
4
|
export function __findHighestArity(spec, max = 0){
|
|
@@ -74,13 +74,13 @@ function __applySpecWithArity(
|
|
|
74
74
|
)
|
|
75
75
|
|
|
76
76
|
// handle spec as Array
|
|
77
|
-
if (
|
|
77
|
+
if (isArray(spec)){
|
|
78
78
|
const ret = []
|
|
79
79
|
let i = 0
|
|
80
80
|
const l = spec.length
|
|
81
81
|
for (; i < l; i++){
|
|
82
82
|
// handle recursive spec inside array
|
|
83
|
-
if (typeof spec[ i ] === 'object' ||
|
|
83
|
+
if (typeof spec[ i ] === 'object' || isArray(spec[ i ])){
|
|
84
84
|
ret[ i ] = __applySpecWithArity(
|
|
85
85
|
spec[ i ], arity, cache
|
|
86
86
|
)
|
package/src/assocPath.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { _isArray } from './_internals/_isArray.js'
|
|
2
|
-
import { _isInteger } from './_internals/_isInteger.js'
|
|
3
1
|
import { cloneList } from './_internals/cloneList.js'
|
|
2
|
+
import { isArray } from './_internals/isArray.js'
|
|
3
|
+
import { isInteger } from './_internals/isInteger.js'
|
|
4
4
|
import { assoc } from './assoc.js'
|
|
5
5
|
import { curry } from './curry.js'
|
|
6
6
|
|
|
@@ -9,7 +9,7 @@ function assocPathFn(
|
|
|
9
9
|
){
|
|
10
10
|
const pathArrValue =
|
|
11
11
|
typeof path === 'string' ?
|
|
12
|
-
path.split('.').map(x =>
|
|
12
|
+
path.split('.').map(x => isInteger(Number(x)) ? Number(x) : x) :
|
|
13
13
|
path
|
|
14
14
|
if (pathArrValue.length === 0){
|
|
15
15
|
return newValue
|
|
@@ -22,8 +22,8 @@ function assocPathFn(
|
|
|
22
22
|
input === null ||
|
|
23
23
|
!input.hasOwnProperty(index)
|
|
24
24
|
|
|
25
|
-
const
|
|
26
|
-
|
|
25
|
+
const nextInput = condition ?
|
|
26
|
+
isInteger(pathArrValue[ 1 ]) ?
|
|
27
27
|
[] :
|
|
28
28
|
{} :
|
|
29
29
|
input[ index ]
|
|
@@ -31,11 +31,11 @@ function assocPathFn(
|
|
|
31
31
|
newValue = assocPathFn(
|
|
32
32
|
Array.prototype.slice.call(pathArrValue, 1),
|
|
33
33
|
newValue,
|
|
34
|
-
|
|
34
|
+
nextInput
|
|
35
35
|
)
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
if (
|
|
38
|
+
if (isInteger(index) && isArray(input)){
|
|
39
39
|
const arr = cloneList(input)
|
|
40
40
|
arr[ index ] = newValue
|
|
41
41
|
|
package/src/clone.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isArray } from './_internals/isArray.js'
|
|
2
2
|
|
|
3
3
|
export function clone(input){
|
|
4
|
-
const out =
|
|
4
|
+
const out = isArray(input) ? Array(input.length) : {}
|
|
5
5
|
if (input && input.getTime) return new Date(input.getTime())
|
|
6
6
|
|
|
7
7
|
for (const key in input){
|
package/src/count.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isArray } from './_internals/isArray.js'
|
|
2
2
|
|
|
3
3
|
export function count(predicate, list){
|
|
4
4
|
if (arguments.length === 1){
|
|
5
5
|
return _list => count(predicate, _list)
|
|
6
6
|
}
|
|
7
|
-
if (!
|
|
7
|
+
if (!isArray(list)) return 0
|
|
8
8
|
|
|
9
9
|
return list.filter(x => predicate(x)).length
|
|
10
10
|
}
|
package/src/dropLastWhile.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isArray as isArrayMethod } from './_internals/isArray.js'
|
|
2
2
|
|
|
3
3
|
export function dropLastWhile(predicate, iterable){
|
|
4
4
|
if (arguments.length === 1){
|
|
5
5
|
return _iterable => dropLastWhile(predicate, _iterable)
|
|
6
6
|
}
|
|
7
7
|
if (iterable.length === 0) return iterable
|
|
8
|
-
const isArray =
|
|
8
|
+
const isArray = isArrayMethod(iterable)
|
|
9
9
|
|
|
10
10
|
if (typeof predicate !== 'function'){
|
|
11
11
|
throw new Error(`'predicate' is from wrong type ${ typeof predicate }`)
|
package/src/dropRepeats.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isArray } from './_internals/isArray.js'
|
|
2
2
|
import { equals } from './equals.js'
|
|
3
3
|
|
|
4
4
|
export function dropRepeats(list){
|
|
5
|
-
if (!
|
|
5
|
+
if (!isArray(list)){
|
|
6
6
|
throw new Error(`${ list } is not a list`)
|
|
7
7
|
}
|
|
8
8
|
|
package/src/dropRepeatsWith.js
CHANGED
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isArray } from './_internals/isArray.js'
|
|
2
2
|
|
|
3
3
|
export function dropRepeatsWith(predicate, list){
|
|
4
4
|
if (arguments.length === 1){
|
|
5
5
|
return _iterable => dropRepeatsWith(predicate, _iterable)
|
|
6
6
|
}
|
|
7
7
|
|
|
8
|
-
if (!
|
|
8
|
+
if (!isArray(list)){
|
|
9
9
|
throw new Error(`${ list } is not a list`)
|
|
10
10
|
}
|
|
11
11
|
|
package/src/dropWhile.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isArray as isArrayMethod } from './_internals/isArray.js'
|
|
2
2
|
|
|
3
3
|
export function dropWhile(predicate, iterable){
|
|
4
4
|
if (arguments.length === 1){
|
|
5
5
|
return _iterable => dropWhile(predicate, _iterable)
|
|
6
6
|
}
|
|
7
|
-
const isArray =
|
|
7
|
+
const isArray = isArrayMethod(iterable)
|
|
8
8
|
if (!isArray && typeof iterable !== 'string'){
|
|
9
9
|
throw new Error('`iterable` is neither list nor a string')
|
|
10
10
|
}
|
package/src/endsWith.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isArray } from './_internals/isArray.js'
|
|
2
2
|
import { equals } from './equals.js'
|
|
3
3
|
|
|
4
4
|
export function endsWith(target, iterable){
|
|
@@ -7,7 +7,7 @@ export function endsWith(target, iterable){
|
|
|
7
7
|
if (typeof iterable === 'string'){
|
|
8
8
|
return iterable.endsWith(target)
|
|
9
9
|
}
|
|
10
|
-
if (!
|
|
10
|
+
if (!isArray(target)) return false
|
|
11
11
|
|
|
12
12
|
const diff = iterable.length - target.length
|
|
13
13
|
let correct = true
|
package/src/equals.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isArray } from './_internals/isArray.js'
|
|
2
2
|
import { type } from './type.js'
|
|
3
3
|
|
|
4
4
|
export function _lastIndexOf(valueToFind, list){
|
|
5
|
-
if (!
|
|
5
|
+
if (!isArray(list)){
|
|
6
6
|
throw new Error(`Cannot read property 'indexOf' of ${ list }`)
|
|
7
7
|
}
|
|
8
8
|
const typeOfValue = type(valueToFind)
|
|
@@ -23,7 +23,7 @@ export function _lastIndexOf(valueToFind, list){
|
|
|
23
23
|
}
|
|
24
24
|
|
|
25
25
|
export function _indexOf(valueToFind, list){
|
|
26
|
-
if (!
|
|
26
|
+
if (!isArray(list)){
|
|
27
27
|
throw new Error(`Cannot read property 'indexOf' of ${ list }`)
|
|
28
28
|
}
|
|
29
29
|
const typeOfValue = type(valueToFind)
|
|
@@ -84,18 +84,6 @@ function parseRegex(maybeRegex){
|
|
|
84
84
|
return [ true, maybeRegex.toString() ]
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
function equalsSets(a, b){
|
|
88
|
-
if (a.size !== b.size){
|
|
89
|
-
return false
|
|
90
|
-
}
|
|
91
|
-
const aList = _arrayFromIterator(a.values())
|
|
92
|
-
const bList = _arrayFromIterator(b.values())
|
|
93
|
-
|
|
94
|
-
const filtered = aList.filter(aInstance => _indexOf(aInstance, bList) === -1)
|
|
95
|
-
|
|
96
|
-
return filtered.length === 0
|
|
97
|
-
}
|
|
98
|
-
|
|
99
87
|
export function equals(a, b){
|
|
100
88
|
if (arguments.length === 1) return _b => equals(a, _b)
|
|
101
89
|
|
package/src/evolve.js
CHANGED
package/src/filter.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isArray } from './_internals/isArray.js'
|
|
2
2
|
|
|
3
3
|
export function filterObject(predicate, obj){
|
|
4
4
|
const willReturn = {}
|
|
@@ -42,7 +42,7 @@ export function filter(predicate, iterable){
|
|
|
42
42
|
throw new Error('Incorrect iterable input')
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
-
if (
|
|
45
|
+
if (isArray(iterable)) return filterArray(
|
|
46
46
|
predicate, iterable, false
|
|
47
47
|
)
|
|
48
48
|
|
package/src/flatten.js
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { isArray } from './_internals/isArray.js'
|
|
2
2
|
|
|
3
3
|
export function flatten(list, input){
|
|
4
4
|
const willReturn = input === undefined ? [] : input
|
|
5
5
|
|
|
6
6
|
for (let i = 0; i < list.length; i++){
|
|
7
|
-
if (
|
|
7
|
+
if (isArray(list[ i ])){
|
|
8
8
|
flatten(list[ i ], willReturn)
|
|
9
9
|
} else {
|
|
10
10
|
willReturn.push(list[ i ])
|
package/src/forEach.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import {
|
|
1
|
+
import { isArray } from './_internals/isArray.js'
|
|
2
|
+
import { keys } from './_internals/keys.js'
|
|
3
3
|
|
|
4
4
|
export function forEach(fn, list){
|
|
5
5
|
if (arguments.length === 1) return _list => forEach(fn, _list)
|
|
@@ -8,7 +8,7 @@ export function forEach(fn, list){
|
|
|
8
8
|
return
|
|
9
9
|
}
|
|
10
10
|
|
|
11
|
-
if (
|
|
11
|
+
if (isArray(list)){
|
|
12
12
|
let index = 0
|
|
13
13
|
const len = list.length
|
|
14
14
|
|
|
@@ -18,11 +18,11 @@ export function forEach(fn, list){
|
|
|
18
18
|
}
|
|
19
19
|
} else {
|
|
20
20
|
let index = 0
|
|
21
|
-
const
|
|
22
|
-
const len =
|
|
21
|
+
const listKeys = keys(list)
|
|
22
|
+
const len = listKeys.length
|
|
23
23
|
|
|
24
24
|
while (index < len){
|
|
25
|
-
const key =
|
|
25
|
+
const key = listKeys[ index ]
|
|
26
26
|
fn(
|
|
27
27
|
list[ key ], key, list
|
|
28
28
|
)
|