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/dist/rambda.mjs
CHANGED
|
@@ -1,11 +1,3 @@
|
|
|
1
|
-
function F() {
|
|
2
|
-
return false;
|
|
3
|
-
}
|
|
4
|
-
|
|
5
|
-
function T() {
|
|
6
|
-
return true;
|
|
7
|
-
}
|
|
8
|
-
|
|
9
1
|
function add(a, b) {
|
|
10
2
|
if (arguments.length === 1) return _b => add(a, _b);
|
|
11
3
|
return Number(a) + Number(b);
|
|
@@ -24,31 +16,25 @@ function adjustFn(index, replaceFn, list) {
|
|
|
24
16
|
clone[actualIndex] = replaceFn(clone[actualIndex]);
|
|
25
17
|
return clone;
|
|
26
18
|
}
|
|
27
|
-
|
|
28
19
|
const adjust = curry(adjustFn);
|
|
29
20
|
|
|
30
21
|
function all(predicate, list) {
|
|
31
22
|
if (arguments.length === 1) return _list => all(predicate, _list);
|
|
32
|
-
|
|
33
23
|
for (let i = 0; i < list.length; i++) {
|
|
34
24
|
if (!predicate(list[i])) return false;
|
|
35
25
|
}
|
|
36
|
-
|
|
37
26
|
return true;
|
|
38
27
|
}
|
|
39
28
|
|
|
40
29
|
function allPass(predicates) {
|
|
41
30
|
return (...input) => {
|
|
42
31
|
let counter = 0;
|
|
43
|
-
|
|
44
32
|
while (counter < predicates.length) {
|
|
45
33
|
if (!predicates[counter](...input)) {
|
|
46
34
|
return false;
|
|
47
35
|
}
|
|
48
|
-
|
|
49
36
|
counter++;
|
|
50
37
|
}
|
|
51
|
-
|
|
52
38
|
return true;
|
|
53
39
|
};
|
|
54
40
|
}
|
|
@@ -65,30 +51,24 @@ function and(a, b) {
|
|
|
65
51
|
function any(predicate, list) {
|
|
66
52
|
if (arguments.length === 1) return _list => any(predicate, _list);
|
|
67
53
|
let counter = 0;
|
|
68
|
-
|
|
69
54
|
while (counter < list.length) {
|
|
70
55
|
if (predicate(list[counter], counter)) {
|
|
71
56
|
return true;
|
|
72
57
|
}
|
|
73
|
-
|
|
74
58
|
counter++;
|
|
75
59
|
}
|
|
76
|
-
|
|
77
60
|
return false;
|
|
78
61
|
}
|
|
79
62
|
|
|
80
63
|
function anyPass(predicates) {
|
|
81
64
|
return (...input) => {
|
|
82
65
|
let counter = 0;
|
|
83
|
-
|
|
84
66
|
while (counter < predicates.length) {
|
|
85
67
|
if (predicates[counter](...input)) {
|
|
86
68
|
return true;
|
|
87
69
|
}
|
|
88
|
-
|
|
89
70
|
counter++;
|
|
90
71
|
}
|
|
91
|
-
|
|
92
72
|
return false;
|
|
93
73
|
};
|
|
94
74
|
}
|
|
@@ -105,42 +85,36 @@ function apply(fn, args) {
|
|
|
105
85
|
if (arguments.length === 1) {
|
|
106
86
|
return _args => apply(fn, _args);
|
|
107
87
|
}
|
|
108
|
-
|
|
109
88
|
return fn.apply(this, args);
|
|
110
89
|
}
|
|
111
90
|
|
|
112
|
-
const
|
|
91
|
+
const {
|
|
92
|
+
isArray
|
|
93
|
+
} = Array;
|
|
113
94
|
|
|
114
95
|
function __findHighestArity(spec, max = 0) {
|
|
115
96
|
for (const key in spec) {
|
|
116
97
|
if (spec.hasOwnProperty(key) === false || key === 'constructor') continue;
|
|
117
|
-
|
|
118
98
|
if (typeof spec[key] === 'object') {
|
|
119
99
|
max = Math.max(max, __findHighestArity(spec[key]));
|
|
120
100
|
}
|
|
121
|
-
|
|
122
101
|
if (typeof spec[key] === 'function') {
|
|
123
102
|
max = Math.max(max, spec[key].length);
|
|
124
103
|
}
|
|
125
104
|
}
|
|
126
|
-
|
|
127
105
|
return max;
|
|
128
106
|
}
|
|
129
|
-
|
|
130
107
|
function __filterUndefined() {
|
|
131
108
|
const defined = [];
|
|
132
109
|
let i = 0;
|
|
133
110
|
const l = arguments.length;
|
|
134
|
-
|
|
135
111
|
while (i < l) {
|
|
136
112
|
if (typeof arguments[i] === 'undefined') break;
|
|
137
113
|
defined[i] = arguments[i];
|
|
138
114
|
i++;
|
|
139
115
|
}
|
|
140
|
-
|
|
141
116
|
return defined;
|
|
142
117
|
}
|
|
143
|
-
|
|
144
118
|
function __applySpecWithArity(spec, arity, cache) {
|
|
145
119
|
const remaining = arity - cache.length;
|
|
146
120
|
if (remaining === 1) return x => __applySpecWithArity(spec, arity, __filterUndefined(...cache, x));
|
|
@@ -148,52 +122,39 @@ function __applySpecWithArity(spec, arity, cache) {
|
|
|
148
122
|
if (remaining === 3) return (x, y, z) => __applySpecWithArity(spec, arity, __filterUndefined(...cache, x, y, z));
|
|
149
123
|
if (remaining === 4) return (x, y, z, a) => __applySpecWithArity(spec, arity, __filterUndefined(...cache, x, y, z, a));
|
|
150
124
|
if (remaining > 4) return (...args) => __applySpecWithArity(spec, arity, __filterUndefined(...cache, ...args));
|
|
151
|
-
|
|
152
|
-
if (_isArray(spec)) {
|
|
125
|
+
if (isArray(spec)) {
|
|
153
126
|
const ret = [];
|
|
154
127
|
let i = 0;
|
|
155
128
|
const l = spec.length;
|
|
156
|
-
|
|
157
129
|
for (; i < l; i++) {
|
|
158
|
-
if (typeof spec[i] === 'object' ||
|
|
130
|
+
if (typeof spec[i] === 'object' || isArray(spec[i])) {
|
|
159
131
|
ret[i] = __applySpecWithArity(spec[i], arity, cache);
|
|
160
132
|
}
|
|
161
|
-
|
|
162
133
|
if (typeof spec[i] === 'function') {
|
|
163
134
|
ret[i] = spec[i](...cache);
|
|
164
135
|
}
|
|
165
136
|
}
|
|
166
|
-
|
|
167
137
|
return ret;
|
|
168
138
|
}
|
|
169
|
-
|
|
170
139
|
const ret = {};
|
|
171
|
-
|
|
172
140
|
for (const key in spec) {
|
|
173
141
|
if (spec.hasOwnProperty(key) === false || key === 'constructor') continue;
|
|
174
|
-
|
|
175
142
|
if (typeof spec[key] === 'object') {
|
|
176
143
|
ret[key] = __applySpecWithArity(spec[key], arity, cache);
|
|
177
144
|
continue;
|
|
178
145
|
}
|
|
179
|
-
|
|
180
146
|
if (typeof spec[key] === 'function') {
|
|
181
147
|
ret[key] = spec[key](...cache);
|
|
182
148
|
}
|
|
183
149
|
}
|
|
184
|
-
|
|
185
150
|
return ret;
|
|
186
151
|
}
|
|
187
|
-
|
|
188
152
|
function applySpec(spec, ...args) {
|
|
189
153
|
const arity = __findHighestArity(spec);
|
|
190
|
-
|
|
191
154
|
if (arity === 0) {
|
|
192
155
|
return () => ({});
|
|
193
156
|
}
|
|
194
|
-
|
|
195
157
|
const toReturn = __applySpecWithArity(spec, arity, args);
|
|
196
|
-
|
|
197
158
|
return toReturn;
|
|
198
159
|
}
|
|
199
160
|
|
|
@@ -202,38 +163,31 @@ function assocFn(prop, newValue, obj) {
|
|
|
202
163
|
[prop]: newValue
|
|
203
164
|
});
|
|
204
165
|
}
|
|
205
|
-
|
|
206
166
|
const assoc = curry(assocFn);
|
|
207
167
|
|
|
208
168
|
function _isInteger(n) {
|
|
209
169
|
return n << 0 === n;
|
|
210
170
|
}
|
|
211
|
-
|
|
171
|
+
const isInteger = Number.isInteger || _isInteger;
|
|
212
172
|
|
|
213
173
|
function assocPathFn(path, newValue, input) {
|
|
214
|
-
const pathArrValue = typeof path === 'string' ? path.split('.').map(x =>
|
|
215
|
-
|
|
174
|
+
const pathArrValue = typeof path === 'string' ? path.split('.').map(x => isInteger(Number(x)) ? Number(x) : x) : path;
|
|
216
175
|
if (pathArrValue.length === 0) {
|
|
217
176
|
return newValue;
|
|
218
177
|
}
|
|
219
|
-
|
|
220
178
|
const index = pathArrValue[0];
|
|
221
|
-
|
|
222
179
|
if (pathArrValue.length > 1) {
|
|
223
180
|
const condition = typeof input !== 'object' || input === null || !input.hasOwnProperty(index);
|
|
224
|
-
const
|
|
225
|
-
newValue = assocPathFn(Array.prototype.slice.call(pathArrValue, 1), newValue,
|
|
181
|
+
const nextInput = condition ? isInteger(pathArrValue[1]) ? [] : {} : input[index];
|
|
182
|
+
newValue = assocPathFn(Array.prototype.slice.call(pathArrValue, 1), newValue, nextInput);
|
|
226
183
|
}
|
|
227
|
-
|
|
228
|
-
if (_isInteger(index) && _isArray(input)) {
|
|
184
|
+
if (isInteger(index) && isArray(input)) {
|
|
229
185
|
const arr = cloneList(input);
|
|
230
186
|
arr[index] = newValue;
|
|
231
187
|
return arr;
|
|
232
188
|
}
|
|
233
|
-
|
|
234
189
|
return assoc(index, newValue, input);
|
|
235
190
|
}
|
|
236
|
-
|
|
237
191
|
const assocPath = curry(assocPathFn);
|
|
238
192
|
|
|
239
193
|
function _curryN(n, cache, fn) {
|
|
@@ -243,88 +197,71 @@ function _curryN(n, cache, fn) {
|
|
|
243
197
|
const cl = cache.length;
|
|
244
198
|
const al = arguments.length;
|
|
245
199
|
const args = new Array(cl + al);
|
|
246
|
-
|
|
247
200
|
while (ci < cl) {
|
|
248
201
|
args[ci] = cache[ci];
|
|
249
202
|
ci++;
|
|
250
203
|
}
|
|
251
|
-
|
|
252
204
|
while (ai < al) {
|
|
253
205
|
args[cl + ai] = arguments[ai];
|
|
254
206
|
ai++;
|
|
255
207
|
}
|
|
256
|
-
|
|
257
208
|
const remaining = n - args.length;
|
|
258
209
|
return args.length >= n ? fn.apply(this, args) : _arity$1(remaining, _curryN(n, args, fn));
|
|
259
210
|
};
|
|
260
211
|
}
|
|
261
|
-
|
|
262
212
|
function _arity$1(n, fn) {
|
|
263
213
|
switch (n) {
|
|
264
214
|
case 0:
|
|
265
215
|
return function () {
|
|
266
216
|
return fn.apply(this, arguments);
|
|
267
217
|
};
|
|
268
|
-
|
|
269
218
|
case 1:
|
|
270
219
|
return function (_1) {
|
|
271
220
|
return fn.apply(this, arguments);
|
|
272
221
|
};
|
|
273
|
-
|
|
274
222
|
case 2:
|
|
275
223
|
return function (_1, _2) {
|
|
276
224
|
return fn.apply(this, arguments);
|
|
277
225
|
};
|
|
278
|
-
|
|
279
226
|
case 3:
|
|
280
227
|
return function (_1, _2, _3) {
|
|
281
228
|
return fn.apply(this, arguments);
|
|
282
229
|
};
|
|
283
|
-
|
|
284
230
|
case 4:
|
|
285
231
|
return function (_1, _2, _3, _4) {
|
|
286
232
|
return fn.apply(this, arguments);
|
|
287
233
|
};
|
|
288
|
-
|
|
289
234
|
case 5:
|
|
290
235
|
return function (_1, _2, _3, _4, _5) {
|
|
291
236
|
return fn.apply(this, arguments);
|
|
292
237
|
};
|
|
293
|
-
|
|
294
238
|
case 6:
|
|
295
239
|
return function (_1, _2, _3, _4, _5, _6) {
|
|
296
240
|
return fn.apply(this, arguments);
|
|
297
241
|
};
|
|
298
|
-
|
|
299
242
|
case 7:
|
|
300
243
|
return function (_1, _2, _3, _4, _5, _6, _7) {
|
|
301
244
|
return fn.apply(this, arguments);
|
|
302
245
|
};
|
|
303
|
-
|
|
304
246
|
case 8:
|
|
305
247
|
return function (_1, _2, _3, _4, _5, _6, _7, _8) {
|
|
306
248
|
return fn.apply(this, arguments);
|
|
307
249
|
};
|
|
308
|
-
|
|
309
250
|
case 9:
|
|
310
251
|
return function (_1, _2, _3, _4, _5, _6, _7, _8, _9) {
|
|
311
252
|
return fn.apply(this, arguments);
|
|
312
253
|
};
|
|
313
|
-
|
|
314
254
|
default:
|
|
315
255
|
return function (_1, _2, _3, _4, _5, _6, _7, _8, _9, _10) {
|
|
316
256
|
return fn.apply(this, arguments);
|
|
317
257
|
};
|
|
318
258
|
}
|
|
319
259
|
}
|
|
320
|
-
|
|
321
260
|
function curryN(n, fn) {
|
|
322
261
|
if (arguments.length === 1) return _fn => curryN(n, _fn);
|
|
323
|
-
|
|
324
262
|
if (n > 10) {
|
|
325
263
|
throw new Error('First argument to _arity must be a non-negative integer no greater than ten');
|
|
326
264
|
}
|
|
327
|
-
|
|
328
265
|
return _arity$1(n, _curryN(n, [], fn));
|
|
329
266
|
}
|
|
330
267
|
|
|
@@ -332,7 +269,6 @@ function bind(fn, thisObj) {
|
|
|
332
269
|
if (arguments.length === 1) {
|
|
333
270
|
return _thisObj => bind(fn, _thisObj);
|
|
334
271
|
}
|
|
335
|
-
|
|
336
272
|
return curryN(fn.length, (...args) => fn.apply(thisObj, args));
|
|
337
273
|
}
|
|
338
274
|
|
|
@@ -345,7 +281,6 @@ function chain(fn, list) {
|
|
|
345
281
|
if (arguments.length === 1) {
|
|
346
282
|
return _list => chain(fn, _list);
|
|
347
283
|
}
|
|
348
|
-
|
|
349
284
|
return [].concat(...list.map(fn));
|
|
350
285
|
}
|
|
351
286
|
|
|
@@ -353,23 +288,19 @@ function clampFn(min, max, input) {
|
|
|
353
288
|
if (min > max) {
|
|
354
289
|
throw new Error('min must not be greater than max in clamp(min, max, value)');
|
|
355
290
|
}
|
|
356
|
-
|
|
357
291
|
if (input >= min && input <= max) return input;
|
|
358
292
|
if (input > max) return max;
|
|
359
293
|
if (input < min) return min;
|
|
360
294
|
}
|
|
361
|
-
|
|
362
295
|
const clamp = curry(clampFn);
|
|
363
296
|
|
|
364
297
|
function clone(input) {
|
|
365
|
-
const out =
|
|
298
|
+
const out = isArray(input) ? Array(input.length) : {};
|
|
366
299
|
if (input && input.getTime) return new Date(input.getTime());
|
|
367
|
-
|
|
368
300
|
for (const key in input) {
|
|
369
301
|
const v = input[key];
|
|
370
302
|
out[key] = typeof v === 'object' && v !== null ? v.getTime ? new Date(v.getTime()) : clone(v) : v;
|
|
371
303
|
}
|
|
372
|
-
|
|
373
304
|
return out;
|
|
374
305
|
}
|
|
375
306
|
|
|
@@ -377,33 +308,24 @@ function complement(fn) {
|
|
|
377
308
|
return (...input) => !fn(...input);
|
|
378
309
|
}
|
|
379
310
|
|
|
380
|
-
const _keys = Object.keys;
|
|
381
|
-
|
|
382
311
|
class ReduceStopper {
|
|
383
312
|
constructor(value) {
|
|
384
313
|
this.value = value;
|
|
385
314
|
}
|
|
386
|
-
|
|
387
315
|
}
|
|
388
|
-
|
|
389
316
|
function reduceFn(reducer, acc, list) {
|
|
390
|
-
if (!
|
|
317
|
+
if (!isArray(list)) {
|
|
391
318
|
throw new TypeError('reduce: list must be array or iterable');
|
|
392
319
|
}
|
|
393
|
-
|
|
394
320
|
let index = 0;
|
|
395
321
|
const len = list.length;
|
|
396
|
-
|
|
397
322
|
while (index < len) {
|
|
398
323
|
acc = reducer(acc, list[index], index, list);
|
|
399
|
-
|
|
400
324
|
if (acc instanceof ReduceStopper) {
|
|
401
325
|
return acc.value;
|
|
402
326
|
}
|
|
403
|
-
|
|
404
327
|
index++;
|
|
405
328
|
}
|
|
406
|
-
|
|
407
329
|
return acc;
|
|
408
330
|
}
|
|
409
331
|
const reduce = curry(reduceFn);
|
|
@@ -415,57 +337,46 @@ function _arity(n, fn) {
|
|
|
415
337
|
return function () {
|
|
416
338
|
return fn.apply(this, arguments);
|
|
417
339
|
};
|
|
418
|
-
|
|
419
340
|
case 1:
|
|
420
341
|
return function (a0) {
|
|
421
342
|
return fn.apply(this, arguments);
|
|
422
343
|
};
|
|
423
|
-
|
|
424
344
|
case 2:
|
|
425
345
|
return function (a0, a1) {
|
|
426
346
|
return fn.apply(this, arguments);
|
|
427
347
|
};
|
|
428
|
-
|
|
429
348
|
case 3:
|
|
430
349
|
return function (a0, a1, a2) {
|
|
431
350
|
return fn.apply(this, arguments);
|
|
432
351
|
};
|
|
433
|
-
|
|
434
352
|
case 4:
|
|
435
353
|
return function (a0, a1, a2, a3) {
|
|
436
354
|
return fn.apply(this, arguments);
|
|
437
355
|
};
|
|
438
|
-
|
|
439
356
|
case 5:
|
|
440
357
|
return function (a0, a1, a2, a3, a4) {
|
|
441
358
|
return fn.apply(this, arguments);
|
|
442
359
|
};
|
|
443
|
-
|
|
444
360
|
case 6:
|
|
445
361
|
return function (a0, a1, a2, a3, a4, a5) {
|
|
446
362
|
return fn.apply(this, arguments);
|
|
447
363
|
};
|
|
448
|
-
|
|
449
364
|
case 7:
|
|
450
365
|
return function (a0, a1, a2, a3, a4, a5, a6) {
|
|
451
366
|
return fn.apply(this, arguments);
|
|
452
367
|
};
|
|
453
|
-
|
|
454
368
|
case 8:
|
|
455
369
|
return function (a0, a1, a2, a3, a4, a5, a6, a7) {
|
|
456
370
|
return fn.apply(this, arguments);
|
|
457
371
|
};
|
|
458
|
-
|
|
459
372
|
case 9:
|
|
460
373
|
return function (a0, a1, a2, a3, a4, a5, a6, a7, a8) {
|
|
461
374
|
return fn.apply(this, arguments);
|
|
462
375
|
};
|
|
463
|
-
|
|
464
376
|
case 10:
|
|
465
377
|
return function (a0, a1, a2, a3, a4, a5, a6, a7, a8, a9) {
|
|
466
378
|
return fn.apply(this, arguments);
|
|
467
379
|
};
|
|
468
|
-
|
|
469
380
|
default:
|
|
470
381
|
throw new Error('First argument to _arity must be a non-negative integer no greater than ten');
|
|
471
382
|
}
|
|
@@ -479,7 +390,6 @@ function pipe() {
|
|
|
479
390
|
if (arguments.length === 0) {
|
|
480
391
|
throw new Error('pipe requires at least one argument');
|
|
481
392
|
}
|
|
482
|
-
|
|
483
393
|
return _arity(arguments[0].length, reduceFn(_pipe, arguments[0], Array.prototype.slice.call(arguments, 1, Infinity)));
|
|
484
394
|
}
|
|
485
395
|
|
|
@@ -487,7 +397,6 @@ function compose() {
|
|
|
487
397
|
if (arguments.length === 0) {
|
|
488
398
|
throw new Error('compose requires at least one argument');
|
|
489
399
|
}
|
|
490
|
-
|
|
491
400
|
return pipe.apply(this, Array.prototype.slice.call(arguments, 0).reverse());
|
|
492
401
|
}
|
|
493
402
|
|
|
@@ -510,46 +419,41 @@ function cond(conditions) {
|
|
|
510
419
|
};
|
|
511
420
|
}
|
|
512
421
|
|
|
422
|
+
const {
|
|
423
|
+
keys: keys$1
|
|
424
|
+
} = Object;
|
|
425
|
+
|
|
513
426
|
function mapArray(fn, list, isIndexed = false) {
|
|
514
427
|
let index = 0;
|
|
515
428
|
const willReturn = Array(list.length);
|
|
516
|
-
|
|
517
429
|
while (index < list.length) {
|
|
518
430
|
willReturn[index] = isIndexed ? fn(list[index], index) : fn(list[index]);
|
|
519
431
|
index++;
|
|
520
432
|
}
|
|
521
|
-
|
|
522
433
|
return willReturn;
|
|
523
434
|
}
|
|
524
435
|
function mapObject(fn, obj) {
|
|
525
436
|
if (arguments.length === 1) {
|
|
526
437
|
return _obj => mapObject(fn, _obj);
|
|
527
438
|
}
|
|
528
|
-
|
|
529
439
|
let index = 0;
|
|
530
|
-
|
|
531
|
-
const
|
|
532
|
-
|
|
533
|
-
const len = keys.length;
|
|
440
|
+
const objKeys = keys$1(obj);
|
|
441
|
+
const len = objKeys.length;
|
|
534
442
|
const willReturn = {};
|
|
535
|
-
|
|
536
443
|
while (index < len) {
|
|
537
|
-
const key =
|
|
444
|
+
const key = objKeys[index];
|
|
538
445
|
willReturn[key] = fn(obj[key], key, obj);
|
|
539
446
|
index++;
|
|
540
447
|
}
|
|
541
|
-
|
|
542
448
|
return willReturn;
|
|
543
449
|
}
|
|
544
450
|
const mapObjIndexed = mapObject;
|
|
545
451
|
function map(fn, iterable) {
|
|
546
452
|
if (arguments.length === 1) return _iterable => map(fn, _iterable);
|
|
547
|
-
|
|
548
453
|
if (!iterable) {
|
|
549
|
-
throw new Error(
|
|
454
|
+
throw new Error(INCORRECT_ITERABLE_INPUT);
|
|
550
455
|
}
|
|
551
|
-
|
|
552
|
-
if (_isArray(iterable)) return mapArray(fn, iterable);
|
|
456
|
+
if (isArray(iterable)) return mapArray(fn, iterable);
|
|
553
457
|
return mapObject(fn, iterable);
|
|
554
458
|
}
|
|
555
459
|
|
|
@@ -570,8 +474,7 @@ function count(predicate, list) {
|
|
|
570
474
|
if (arguments.length === 1) {
|
|
571
475
|
return _list => count(predicate, _list);
|
|
572
476
|
}
|
|
573
|
-
|
|
574
|
-
if (!_isArray(list)) return 0;
|
|
477
|
+
if (!isArray(list)) return 0;
|
|
575
478
|
return list.filter(x => predicate(x)).length;
|
|
576
479
|
}
|
|
577
480
|
|
|
@@ -579,11 +482,9 @@ function countBy(fn, list) {
|
|
|
579
482
|
if (arguments.length === 1) {
|
|
580
483
|
return _list => countBy(fn, _list);
|
|
581
484
|
}
|
|
582
|
-
|
|
583
485
|
const willReturn = {};
|
|
584
486
|
list.forEach(item => {
|
|
585
487
|
const key = fn(item);
|
|
586
|
-
|
|
587
488
|
if (!willReturn[key]) {
|
|
588
489
|
willReturn[key] = 1;
|
|
589
490
|
} else {
|
|
@@ -598,12 +499,10 @@ const dec = x => x - 1;
|
|
|
598
499
|
function isFalsy(input) {
|
|
599
500
|
return input === undefined || input === null || Number.isNaN(input) === true;
|
|
600
501
|
}
|
|
601
|
-
|
|
602
502
|
function defaultTo(defaultArgument, input) {
|
|
603
503
|
if (arguments.length === 1) {
|
|
604
504
|
return _input => defaultTo(defaultArgument, _input);
|
|
605
505
|
}
|
|
606
|
-
|
|
607
506
|
return isFalsy(input) ? defaultArgument : input;
|
|
608
507
|
}
|
|
609
508
|
|
|
@@ -615,16 +514,14 @@ function type(input) {
|
|
|
615
514
|
} else if (Number.isNaN(input)) {
|
|
616
515
|
return 'NaN';
|
|
617
516
|
}
|
|
618
|
-
|
|
619
517
|
const typeResult = Object.prototype.toString.call(input).slice(8, -1);
|
|
620
518
|
return typeResult === 'AsyncFunction' ? 'Promise' : typeResult;
|
|
621
519
|
}
|
|
622
520
|
|
|
623
521
|
function _lastIndexOf(valueToFind, list) {
|
|
624
|
-
if (!
|
|
522
|
+
if (!isArray(list)) {
|
|
625
523
|
throw new Error(`Cannot read property 'indexOf' of ${list}`);
|
|
626
524
|
}
|
|
627
|
-
|
|
628
525
|
const typeOfValue = type(valueToFind);
|
|
629
526
|
if (!['Object', 'Array', 'NaN', 'RegExp'].includes(typeOfValue)) return list.lastIndexOf(valueToFind);
|
|
630
527
|
const {
|
|
@@ -632,20 +529,17 @@ function _lastIndexOf(valueToFind, list) {
|
|
|
632
529
|
} = list;
|
|
633
530
|
let index = length;
|
|
634
531
|
let foundIndex = -1;
|
|
635
|
-
|
|
636
532
|
while (--index > -1 && foundIndex === -1) {
|
|
637
533
|
if (equals(list[index], valueToFind)) {
|
|
638
534
|
foundIndex = index;
|
|
639
535
|
}
|
|
640
536
|
}
|
|
641
|
-
|
|
642
537
|
return foundIndex;
|
|
643
538
|
}
|
|
644
539
|
function _indexOf(valueToFind, list) {
|
|
645
|
-
if (!
|
|
540
|
+
if (!isArray(list)) {
|
|
646
541
|
throw new Error(`Cannot read property 'indexOf' of ${list}`);
|
|
647
542
|
}
|
|
648
|
-
|
|
649
543
|
const typeOfValue = type(valueToFind);
|
|
650
544
|
if (!['Object', 'Array', 'NaN', 'RegExp'].includes(typeOfValue)) return list.indexOf(valueToFind);
|
|
651
545
|
let index = -1;
|
|
@@ -653,85 +547,64 @@ function _indexOf(valueToFind, list) {
|
|
|
653
547
|
const {
|
|
654
548
|
length
|
|
655
549
|
} = list;
|
|
656
|
-
|
|
657
550
|
while (++index < length && foundIndex === -1) {
|
|
658
551
|
if (equals(list[index], valueToFind)) {
|
|
659
552
|
foundIndex = index;
|
|
660
553
|
}
|
|
661
554
|
}
|
|
662
|
-
|
|
663
555
|
return foundIndex;
|
|
664
556
|
}
|
|
665
|
-
|
|
666
557
|
function _arrayFromIterator(iter) {
|
|
667
558
|
const list = [];
|
|
668
559
|
let next;
|
|
669
|
-
|
|
670
560
|
while (!(next = iter.next()).done) {
|
|
671
561
|
list.push(next.value);
|
|
672
562
|
}
|
|
673
|
-
|
|
674
563
|
return list;
|
|
675
564
|
}
|
|
676
|
-
|
|
677
565
|
function _equalsSets(a, b) {
|
|
678
566
|
if (a.size !== b.size) {
|
|
679
567
|
return false;
|
|
680
568
|
}
|
|
681
|
-
|
|
682
569
|
const aList = _arrayFromIterator(a.values());
|
|
683
|
-
|
|
684
570
|
const bList = _arrayFromIterator(b.values());
|
|
685
|
-
|
|
686
571
|
const filtered = aList.filter(aInstance => _indexOf(aInstance, bList) === -1);
|
|
687
572
|
return filtered.length === 0;
|
|
688
573
|
}
|
|
689
|
-
|
|
690
574
|
function parseError(maybeError) {
|
|
691
575
|
const typeofError = maybeError.__proto__.toString();
|
|
692
|
-
|
|
693
576
|
if (!['Error', 'TypeError'].includes(typeofError)) return [];
|
|
694
577
|
return [typeofError, maybeError.message];
|
|
695
578
|
}
|
|
696
|
-
|
|
697
579
|
function parseDate(maybeDate) {
|
|
698
580
|
if (!maybeDate.toDateString) return [false];
|
|
699
581
|
return [true, maybeDate.getTime()];
|
|
700
582
|
}
|
|
701
|
-
|
|
702
583
|
function parseRegex(maybeRegex) {
|
|
703
584
|
if (maybeRegex.constructor !== RegExp) return [false];
|
|
704
585
|
return [true, maybeRegex.toString()];
|
|
705
586
|
}
|
|
706
|
-
|
|
707
587
|
function equals(a, b) {
|
|
708
588
|
if (arguments.length === 1) return _b => equals(a, _b);
|
|
709
589
|
const aType = type(a);
|
|
710
590
|
if (aType !== type(b)) return false;
|
|
711
|
-
|
|
712
591
|
if (aType === 'Function') {
|
|
713
592
|
return a.name === undefined ? false : a.name === b.name;
|
|
714
593
|
}
|
|
715
|
-
|
|
716
594
|
if (['NaN', 'Undefined', 'Null'].includes(aType)) return true;
|
|
717
|
-
|
|
718
595
|
if (aType === 'Number') {
|
|
719
596
|
if (Object.is(-0, a) !== Object.is(-0, b)) return false;
|
|
720
597
|
return a.toString() === b.toString();
|
|
721
598
|
}
|
|
722
|
-
|
|
723
599
|
if (['String', 'Boolean'].includes(aType)) {
|
|
724
600
|
return a.toString() === b.toString();
|
|
725
601
|
}
|
|
726
|
-
|
|
727
602
|
if (aType === 'Array') {
|
|
728
603
|
const aClone = Array.from(a);
|
|
729
604
|
const bClone = Array.from(b);
|
|
730
|
-
|
|
731
605
|
if (aClone.toString() !== bClone.toString()) {
|
|
732
606
|
return false;
|
|
733
607
|
}
|
|
734
|
-
|
|
735
608
|
let loopArrayFlag = true;
|
|
736
609
|
aClone.forEach((aCloneInstance, aCloneIndex) => {
|
|
737
610
|
if (loopArrayFlag) {
|
|
@@ -742,45 +615,34 @@ function equals(a, b) {
|
|
|
742
615
|
});
|
|
743
616
|
return loopArrayFlag;
|
|
744
617
|
}
|
|
745
|
-
|
|
746
618
|
const aRegex = parseRegex(a);
|
|
747
619
|
const bRegex = parseRegex(b);
|
|
748
|
-
|
|
749
620
|
if (aRegex[0]) {
|
|
750
621
|
return bRegex[0] ? aRegex[1] === bRegex[1] : false;
|
|
751
622
|
} else if (bRegex[0]) return false;
|
|
752
|
-
|
|
753
623
|
const aDate = parseDate(a);
|
|
754
624
|
const bDate = parseDate(b);
|
|
755
|
-
|
|
756
625
|
if (aDate[0]) {
|
|
757
626
|
return bDate[0] ? aDate[1] === bDate[1] : false;
|
|
758
627
|
} else if (bDate[0]) return false;
|
|
759
|
-
|
|
760
628
|
const aError = parseError(a);
|
|
761
629
|
const bError = parseError(b);
|
|
762
|
-
|
|
763
630
|
if (aError[0]) {
|
|
764
631
|
return bError[0] ? aError[0] === bError[0] && aError[1] === bError[1] : false;
|
|
765
632
|
}
|
|
766
|
-
|
|
767
633
|
if (aType === 'Set') {
|
|
768
634
|
return _equalsSets(a, b);
|
|
769
635
|
}
|
|
770
|
-
|
|
771
636
|
if (aType === 'Object') {
|
|
772
637
|
const aKeys = Object.keys(a);
|
|
773
|
-
|
|
774
638
|
if (aKeys.length !== Object.keys(b).length) {
|
|
775
639
|
return false;
|
|
776
640
|
}
|
|
777
|
-
|
|
778
641
|
let loopObjectFlag = true;
|
|
779
642
|
aKeys.forEach(aKeyInstance => {
|
|
780
643
|
if (loopObjectFlag) {
|
|
781
644
|
const aValue = a[aKeyInstance];
|
|
782
645
|
const bValue = b[aKeyInstance];
|
|
783
|
-
|
|
784
646
|
if (aValue !== bValue && !equals(aValue, bValue)) {
|
|
785
647
|
loopObjectFlag = false;
|
|
786
648
|
}
|
|
@@ -788,22 +650,18 @@ function equals(a, b) {
|
|
|
788
650
|
});
|
|
789
651
|
return loopObjectFlag;
|
|
790
652
|
}
|
|
791
|
-
|
|
792
653
|
return false;
|
|
793
654
|
}
|
|
794
655
|
|
|
795
656
|
function includes(valueToFind, iterable) {
|
|
796
657
|
if (arguments.length === 1) return _iterable => includes(valueToFind, _iterable);
|
|
797
|
-
|
|
798
658
|
if (typeof iterable === 'string') {
|
|
799
659
|
return iterable.includes(valueToFind);
|
|
800
660
|
}
|
|
801
|
-
|
|
802
661
|
if (!iterable) {
|
|
803
662
|
throw new TypeError(`Cannot read property \'indexOf\' of ${iterable}`);
|
|
804
663
|
}
|
|
805
|
-
|
|
806
|
-
if (!_isArray(iterable)) return false;
|
|
664
|
+
if (!isArray(iterable)) return false;
|
|
807
665
|
return _indexOf(valueToFind, iterable) > -1;
|
|
808
666
|
}
|
|
809
667
|
|
|
@@ -812,38 +670,30 @@ class _Set {
|
|
|
812
670
|
this.set = new Set();
|
|
813
671
|
this.items = {};
|
|
814
672
|
}
|
|
815
|
-
|
|
816
673
|
checkUniqueness(item) {
|
|
817
674
|
const type$1 = type(item);
|
|
818
|
-
|
|
819
675
|
if (['Null', 'Undefined', 'NaN'].includes(type$1)) {
|
|
820
676
|
if (type$1 in this.items) {
|
|
821
677
|
return false;
|
|
822
678
|
}
|
|
823
|
-
|
|
824
679
|
this.items[type$1] = true;
|
|
825
680
|
return true;
|
|
826
681
|
}
|
|
827
|
-
|
|
828
682
|
if (!['Object', 'Array'].includes(type$1)) {
|
|
829
683
|
const prevSize = this.set.size;
|
|
830
684
|
this.set.add(item);
|
|
831
685
|
return this.set.size !== prevSize;
|
|
832
686
|
}
|
|
833
|
-
|
|
834
687
|
if (!(type$1 in this.items)) {
|
|
835
688
|
this.items[type$1] = [item];
|
|
836
689
|
return true;
|
|
837
690
|
}
|
|
838
|
-
|
|
839
691
|
if (_indexOf(item, this.items[type$1]) === -1) {
|
|
840
692
|
this.items[type$1].push(item);
|
|
841
693
|
return true;
|
|
842
694
|
}
|
|
843
|
-
|
|
844
695
|
return false;
|
|
845
696
|
}
|
|
846
|
-
|
|
847
697
|
}
|
|
848
698
|
|
|
849
699
|
function uniq(list) {
|
|
@@ -866,11 +716,9 @@ function dissoc(prop, obj) {
|
|
|
866
716
|
if (arguments.length === 1) return _obj => dissoc(prop, _obj);
|
|
867
717
|
if (obj === null || obj === undefined) return {};
|
|
868
718
|
const willReturn = {};
|
|
869
|
-
|
|
870
719
|
for (const p in obj) {
|
|
871
720
|
willReturn[p] = obj[p];
|
|
872
721
|
}
|
|
873
|
-
|
|
874
722
|
delete willReturn[prop];
|
|
875
723
|
return willReturn;
|
|
876
724
|
}
|
|
@@ -889,7 +737,6 @@ function dropLast(howManyToDrop, listOrString) {
|
|
|
889
737
|
if (arguments.length === 1) {
|
|
890
738
|
return _listOrString => dropLast(howManyToDrop, _listOrString);
|
|
891
739
|
}
|
|
892
|
-
|
|
893
740
|
return howManyToDrop > 0 ? listOrString.slice(0, -howManyToDrop) : listOrString.slice();
|
|
894
741
|
}
|
|
895
742
|
|
|
@@ -897,26 +744,19 @@ function dropLastWhile(predicate, iterable) {
|
|
|
897
744
|
if (arguments.length === 1) {
|
|
898
745
|
return _iterable => dropLastWhile(predicate, _iterable);
|
|
899
746
|
}
|
|
900
|
-
|
|
901
747
|
if (iterable.length === 0) return iterable;
|
|
902
|
-
|
|
903
|
-
const isArray = _isArray(iterable);
|
|
904
|
-
|
|
748
|
+
const isArray$1 = isArray(iterable);
|
|
905
749
|
if (typeof predicate !== 'function') {
|
|
906
750
|
throw new Error(`'predicate' is from wrong type ${typeof predicate}`);
|
|
907
751
|
}
|
|
908
|
-
|
|
909
|
-
if (!isArray && typeof iterable !== 'string') {
|
|
752
|
+
if (!isArray$1 && typeof iterable !== 'string') {
|
|
910
753
|
throw new Error(`'iterable' is from wrong type ${typeof iterable}`);
|
|
911
754
|
}
|
|
912
|
-
|
|
913
755
|
let found = false;
|
|
914
756
|
const toReturn = [];
|
|
915
757
|
let counter = iterable.length;
|
|
916
|
-
|
|
917
758
|
while (counter > 0) {
|
|
918
759
|
counter--;
|
|
919
|
-
|
|
920
760
|
if (!found && predicate(iterable[counter]) === false) {
|
|
921
761
|
found = true;
|
|
922
762
|
toReturn.push(iterable[counter]);
|
|
@@ -924,21 +764,18 @@ function dropLastWhile(predicate, iterable) {
|
|
|
924
764
|
toReturn.push(iterable[counter]);
|
|
925
765
|
}
|
|
926
766
|
}
|
|
927
|
-
|
|
928
|
-
return isArray ? toReturn.reverse() : toReturn.reverse().join('');
|
|
767
|
+
return isArray$1 ? toReturn.reverse() : toReturn.reverse().join('');
|
|
929
768
|
}
|
|
930
769
|
|
|
931
770
|
function dropRepeats(list) {
|
|
932
|
-
if (!
|
|
771
|
+
if (!isArray(list)) {
|
|
933
772
|
throw new Error(`${list} is not a list`);
|
|
934
773
|
}
|
|
935
|
-
|
|
936
774
|
const toReturn = [];
|
|
937
775
|
list.reduce((prev, current) => {
|
|
938
776
|
if (!equals(prev, current)) {
|
|
939
777
|
toReturn.push(current);
|
|
940
778
|
}
|
|
941
|
-
|
|
942
779
|
return current;
|
|
943
780
|
}, undefined);
|
|
944
781
|
return toReturn;
|
|
@@ -948,22 +785,18 @@ function dropRepeatsWith(predicate, list) {
|
|
|
948
785
|
if (arguments.length === 1) {
|
|
949
786
|
return _iterable => dropRepeatsWith(predicate, _iterable);
|
|
950
787
|
}
|
|
951
|
-
|
|
952
|
-
if (!_isArray(list)) {
|
|
788
|
+
if (!isArray(list)) {
|
|
953
789
|
throw new Error(`${list} is not a list`);
|
|
954
790
|
}
|
|
955
|
-
|
|
956
791
|
const toReturn = [];
|
|
957
792
|
list.reduce((prev, current) => {
|
|
958
793
|
if (prev === undefined) {
|
|
959
794
|
toReturn.push(current);
|
|
960
795
|
return current;
|
|
961
796
|
}
|
|
962
|
-
|
|
963
797
|
if (!predicate(prev, current)) {
|
|
964
798
|
toReturn.push(current);
|
|
965
799
|
}
|
|
966
|
-
|
|
967
800
|
return current;
|
|
968
801
|
}, undefined);
|
|
969
802
|
return toReturn;
|
|
@@ -973,17 +806,13 @@ function dropWhile(predicate, iterable) {
|
|
|
973
806
|
if (arguments.length === 1) {
|
|
974
807
|
return _iterable => dropWhile(predicate, _iterable);
|
|
975
808
|
}
|
|
976
|
-
|
|
977
|
-
|
|
978
|
-
|
|
979
|
-
if (!isArray && typeof iterable !== 'string') {
|
|
809
|
+
const isArray$1 = isArray(iterable);
|
|
810
|
+
if (!isArray$1 && typeof iterable !== 'string') {
|
|
980
811
|
throw new Error('`iterable` is neither list nor a string');
|
|
981
812
|
}
|
|
982
|
-
|
|
983
813
|
let flag = false;
|
|
984
814
|
const holder = [];
|
|
985
815
|
let counter = -1;
|
|
986
|
-
|
|
987
816
|
while (counter++ < iterable.length - 1) {
|
|
988
817
|
if (flag) {
|
|
989
818
|
holder.push(iterable[counter]);
|
|
@@ -992,26 +821,22 @@ function dropWhile(predicate, iterable) {
|
|
|
992
821
|
holder.push(iterable[counter]);
|
|
993
822
|
}
|
|
994
823
|
}
|
|
995
|
-
|
|
996
|
-
return isArray ? holder : holder.join('');
|
|
824
|
+
return isArray$1 ? holder : holder.join('');
|
|
997
825
|
}
|
|
998
826
|
|
|
999
827
|
function either(firstPredicate, secondPredicate) {
|
|
1000
828
|
if (arguments.length === 1) {
|
|
1001
829
|
return _secondPredicate => either(firstPredicate, _secondPredicate);
|
|
1002
830
|
}
|
|
1003
|
-
|
|
1004
831
|
return (...input) => Boolean(firstPredicate(...input) || secondPredicate(...input));
|
|
1005
832
|
}
|
|
1006
833
|
|
|
1007
834
|
function endsWith(target, iterable) {
|
|
1008
835
|
if (arguments.length === 1) return _iterable => endsWith(target, _iterable);
|
|
1009
|
-
|
|
1010
836
|
if (typeof iterable === 'string') {
|
|
1011
837
|
return iterable.endsWith(target);
|
|
1012
838
|
}
|
|
1013
|
-
|
|
1014
|
-
if (!_isArray(target)) return false;
|
|
839
|
+
if (!isArray(target)) return false;
|
|
1015
840
|
const diff = iterable.length - target.length;
|
|
1016
841
|
let correct = true;
|
|
1017
842
|
const filtered = target.filter((x, index) => {
|
|
@@ -1032,7 +857,6 @@ function prop(propToFind, obj) {
|
|
|
1032
857
|
function eqPropsFn(property, objA, objB) {
|
|
1033
858
|
return equals(prop(property, objA), prop(property, objB));
|
|
1034
859
|
}
|
|
1035
|
-
|
|
1036
860
|
const eqProps = curry(eqPropsFn);
|
|
1037
861
|
|
|
1038
862
|
function evolveArray(rules, list) {
|
|
@@ -1040,7 +864,6 @@ function evolveArray(rules, list) {
|
|
|
1040
864
|
if (type(rules[i]) === 'Function') {
|
|
1041
865
|
return rules[i](x);
|
|
1042
866
|
}
|
|
1043
|
-
|
|
1044
867
|
return x;
|
|
1045
868
|
}, list, true);
|
|
1046
869
|
}
|
|
@@ -1048,22 +871,17 @@ function evolveObject(rules, iterable) {
|
|
|
1048
871
|
return mapObject((x, prop) => {
|
|
1049
872
|
if (type(x) === 'Object') {
|
|
1050
873
|
const typeRule = type(rules[prop]);
|
|
1051
|
-
|
|
1052
874
|
if (typeRule === 'Function') {
|
|
1053
875
|
return rules[prop](x);
|
|
1054
876
|
}
|
|
1055
|
-
|
|
1056
877
|
if (typeRule === 'Object') {
|
|
1057
878
|
return evolve(rules[prop], x);
|
|
1058
879
|
}
|
|
1059
|
-
|
|
1060
880
|
return x;
|
|
1061
881
|
}
|
|
1062
|
-
|
|
1063
882
|
if (type(rules[prop]) === 'Function') {
|
|
1064
883
|
return rules[prop](x);
|
|
1065
884
|
}
|
|
1066
|
-
|
|
1067
885
|
return x;
|
|
1068
886
|
}, iterable);
|
|
1069
887
|
}
|
|
@@ -1071,61 +889,52 @@ function evolve(rules, iterable) {
|
|
|
1071
889
|
if (arguments.length === 1) {
|
|
1072
890
|
return _iterable => evolve(rules, _iterable);
|
|
1073
891
|
}
|
|
1074
|
-
|
|
1075
892
|
const rulesType = type(rules);
|
|
1076
893
|
const iterableType = type(iterable);
|
|
1077
|
-
|
|
1078
894
|
if (iterableType !== rulesType) {
|
|
1079
895
|
throw new Error('iterableType !== rulesType');
|
|
1080
896
|
}
|
|
1081
|
-
|
|
1082
897
|
if (!['Object', 'Array'].includes(rulesType)) {
|
|
1083
898
|
throw new Error(`'iterable' and 'rules' are from wrong type ${rulesType}`);
|
|
1084
899
|
}
|
|
1085
|
-
|
|
1086
900
|
if (iterableType === 'Object') {
|
|
1087
901
|
return evolveObject(rules, iterable);
|
|
1088
902
|
}
|
|
1089
|
-
|
|
1090
903
|
return evolveArray(rules, iterable);
|
|
1091
904
|
}
|
|
1092
905
|
|
|
906
|
+
function F() {
|
|
907
|
+
return false;
|
|
908
|
+
}
|
|
909
|
+
|
|
1093
910
|
function filterObject(predicate, obj) {
|
|
1094
911
|
const willReturn = {};
|
|
1095
|
-
|
|
1096
912
|
for (const prop in obj) {
|
|
1097
913
|
if (predicate(obj[prop], prop, obj)) {
|
|
1098
914
|
willReturn[prop] = obj[prop];
|
|
1099
915
|
}
|
|
1100
916
|
}
|
|
1101
|
-
|
|
1102
917
|
return willReturn;
|
|
1103
918
|
}
|
|
1104
919
|
function filterArray(predicate, list, indexed = false) {
|
|
1105
920
|
let index = 0;
|
|
1106
921
|
const len = list.length;
|
|
1107
922
|
const willReturn = [];
|
|
1108
|
-
|
|
1109
923
|
while (index < len) {
|
|
1110
924
|
const predicateResult = indexed ? predicate(list[index], index) : predicate(list[index]);
|
|
1111
|
-
|
|
1112
925
|
if (predicateResult) {
|
|
1113
926
|
willReturn.push(list[index]);
|
|
1114
927
|
}
|
|
1115
|
-
|
|
1116
928
|
index++;
|
|
1117
929
|
}
|
|
1118
|
-
|
|
1119
930
|
return willReturn;
|
|
1120
931
|
}
|
|
1121
932
|
function filter(predicate, iterable) {
|
|
1122
933
|
if (arguments.length === 1) return _iterable => filter(predicate, _iterable);
|
|
1123
|
-
|
|
1124
934
|
if (!iterable) {
|
|
1125
935
|
throw new Error('Incorrect iterable input');
|
|
1126
936
|
}
|
|
1127
|
-
|
|
1128
|
-
if (_isArray(iterable)) return filterArray(predicate, iterable, false);
|
|
937
|
+
if (isArray(iterable)) return filterArray(predicate, iterable, false);
|
|
1129
938
|
return filterObject(predicate, iterable);
|
|
1130
939
|
}
|
|
1131
940
|
|
|
@@ -1133,14 +942,11 @@ function find(predicate, list) {
|
|
|
1133
942
|
if (arguments.length === 1) return _list => find(predicate, _list);
|
|
1134
943
|
let index = 0;
|
|
1135
944
|
const len = list.length;
|
|
1136
|
-
|
|
1137
945
|
while (index < len) {
|
|
1138
946
|
const x = list[index];
|
|
1139
|
-
|
|
1140
947
|
if (predicate(x)) {
|
|
1141
948
|
return x;
|
|
1142
949
|
}
|
|
1143
|
-
|
|
1144
950
|
index++;
|
|
1145
951
|
}
|
|
1146
952
|
}
|
|
@@ -1149,53 +955,45 @@ function findIndex(predicate, list) {
|
|
|
1149
955
|
if (arguments.length === 1) return _list => findIndex(predicate, _list);
|
|
1150
956
|
const len = list.length;
|
|
1151
957
|
let index = -1;
|
|
1152
|
-
|
|
1153
958
|
while (++index < len) {
|
|
1154
959
|
if (predicate(list[index])) {
|
|
1155
960
|
return index;
|
|
1156
961
|
}
|
|
1157
962
|
}
|
|
1158
|
-
|
|
1159
963
|
return -1;
|
|
1160
964
|
}
|
|
1161
965
|
|
|
1162
966
|
function findLast(predicate, list) {
|
|
1163
967
|
if (arguments.length === 1) return _list => findLast(predicate, _list);
|
|
1164
968
|
let index = list.length;
|
|
1165
|
-
|
|
1166
969
|
while (--index >= 0) {
|
|
1167
970
|
if (predicate(list[index])) {
|
|
1168
971
|
return list[index];
|
|
1169
972
|
}
|
|
1170
973
|
}
|
|
1171
|
-
|
|
1172
974
|
return undefined;
|
|
1173
975
|
}
|
|
1174
976
|
|
|
1175
977
|
function findLastIndex(fn, list) {
|
|
1176
978
|
if (arguments.length === 1) return _list => findLastIndex(fn, _list);
|
|
1177
979
|
let index = list.length;
|
|
1178
|
-
|
|
1179
980
|
while (--index >= 0) {
|
|
1180
981
|
if (fn(list[index])) {
|
|
1181
982
|
return index;
|
|
1182
983
|
}
|
|
1183
984
|
}
|
|
1184
|
-
|
|
1185
985
|
return -1;
|
|
1186
986
|
}
|
|
1187
987
|
|
|
1188
988
|
function flatten(list, input) {
|
|
1189
989
|
const willReturn = input === undefined ? [] : input;
|
|
1190
|
-
|
|
1191
990
|
for (let i = 0; i < list.length; i++) {
|
|
1192
|
-
if (
|
|
991
|
+
if (isArray(list[i])) {
|
|
1193
992
|
flatten(list[i], willReturn);
|
|
1194
993
|
} else {
|
|
1195
994
|
willReturn.push(list[i]);
|
|
1196
995
|
}
|
|
1197
996
|
}
|
|
1198
|
-
|
|
1199
997
|
return willReturn;
|
|
1200
998
|
}
|
|
1201
999
|
|
|
@@ -1210,44 +1008,35 @@ function flipFn(fn) {
|
|
|
1210
1008
|
} else if (input.length === 4) {
|
|
1211
1009
|
return fn(input[1], input[0], input[2], input[3]);
|
|
1212
1010
|
}
|
|
1213
|
-
|
|
1214
1011
|
throw new Error('R.flip doesn\'t work with arity > 4');
|
|
1215
1012
|
};
|
|
1216
1013
|
}
|
|
1217
|
-
|
|
1218
1014
|
function flip(fn) {
|
|
1219
1015
|
return flipFn(fn);
|
|
1220
1016
|
}
|
|
1221
1017
|
|
|
1222
1018
|
function forEach(fn, list) {
|
|
1223
1019
|
if (arguments.length === 1) return _list => forEach(fn, _list);
|
|
1224
|
-
|
|
1225
1020
|
if (list === undefined) {
|
|
1226
1021
|
return;
|
|
1227
1022
|
}
|
|
1228
|
-
|
|
1229
|
-
if (_isArray(list)) {
|
|
1023
|
+
if (isArray(list)) {
|
|
1230
1024
|
let index = 0;
|
|
1231
1025
|
const len = list.length;
|
|
1232
|
-
|
|
1233
1026
|
while (index < len) {
|
|
1234
1027
|
fn(list[index]);
|
|
1235
1028
|
index++;
|
|
1236
1029
|
}
|
|
1237
1030
|
} else {
|
|
1238
1031
|
let index = 0;
|
|
1239
|
-
|
|
1240
|
-
const
|
|
1241
|
-
|
|
1242
|
-
const len = keys.length;
|
|
1243
|
-
|
|
1032
|
+
const listKeys = keys$1(list);
|
|
1033
|
+
const len = listKeys.length;
|
|
1244
1034
|
while (index < len) {
|
|
1245
|
-
const key =
|
|
1035
|
+
const key = listKeys[index];
|
|
1246
1036
|
fn(list[key], key, list);
|
|
1247
1037
|
index++;
|
|
1248
1038
|
}
|
|
1249
1039
|
}
|
|
1250
|
-
|
|
1251
1040
|
return list;
|
|
1252
1041
|
}
|
|
1253
1042
|
|
|
@@ -1260,23 +1049,19 @@ function fromPairs(listOfPairs) {
|
|
|
1260
1049
|
function groupBy(groupFn, list) {
|
|
1261
1050
|
if (arguments.length === 1) return _list => groupBy(groupFn, _list);
|
|
1262
1051
|
const result = {};
|
|
1263
|
-
|
|
1264
1052
|
for (let i = 0; i < list.length; i++) {
|
|
1265
1053
|
const item = list[i];
|
|
1266
1054
|
const key = groupFn(item);
|
|
1267
|
-
|
|
1268
1055
|
if (!result[key]) {
|
|
1269
1056
|
result[key] = [];
|
|
1270
1057
|
}
|
|
1271
|
-
|
|
1272
1058
|
result[key].push(item);
|
|
1273
1059
|
}
|
|
1274
|
-
|
|
1275
1060
|
return result;
|
|
1276
1061
|
}
|
|
1277
1062
|
|
|
1278
1063
|
function groupWith(compareFn, list) {
|
|
1279
|
-
if (!
|
|
1064
|
+
if (!isArray(list)) throw new TypeError('list.reduce is not a function');
|
|
1280
1065
|
const clone = cloneList(list);
|
|
1281
1066
|
if (list.length === 1) return [clone];
|
|
1282
1067
|
const toReturn = [];
|
|
@@ -1286,20 +1071,17 @@ function groupWith(compareFn, list) {
|
|
|
1286
1071
|
const okCompare = compareFn(prev, current);
|
|
1287
1072
|
const holderIsEmpty = holder.length === 0;
|
|
1288
1073
|
const lastCall = i === list.length - 1;
|
|
1289
|
-
|
|
1290
1074
|
if (okCompare) {
|
|
1291
1075
|
if (holderIsEmpty) holder.push(prev);
|
|
1292
1076
|
holder.push(current);
|
|
1293
1077
|
if (lastCall) toReturn.push(holder);
|
|
1294
1078
|
return current;
|
|
1295
1079
|
}
|
|
1296
|
-
|
|
1297
1080
|
if (holderIsEmpty) {
|
|
1298
1081
|
toReturn.push([prev]);
|
|
1299
1082
|
if (lastCall) toReturn.push([current]);
|
|
1300
1083
|
return current;
|
|
1301
1084
|
}
|
|
1302
|
-
|
|
1303
1085
|
toReturn.push(holder);
|
|
1304
1086
|
if (lastCall) toReturn.push([current]);
|
|
1305
1087
|
holder = [];
|
|
@@ -1320,25 +1102,20 @@ function createPath(path, delimiter = '.') {
|
|
|
1320
1102
|
|
|
1321
1103
|
function path(pathInput, obj) {
|
|
1322
1104
|
if (arguments.length === 1) return _obj => path(pathInput, _obj);
|
|
1323
|
-
|
|
1324
1105
|
if (obj === null || obj === undefined) {
|
|
1325
1106
|
return undefined;
|
|
1326
1107
|
}
|
|
1327
|
-
|
|
1328
1108
|
let willReturn = obj;
|
|
1329
1109
|
let counter = 0;
|
|
1330
1110
|
const pathArrValue = createPath(pathInput);
|
|
1331
|
-
|
|
1332
1111
|
while (counter < pathArrValue.length) {
|
|
1333
1112
|
if (willReturn === null || willReturn === undefined) {
|
|
1334
1113
|
return undefined;
|
|
1335
1114
|
}
|
|
1336
|
-
|
|
1337
1115
|
if (willReturn[pathArrValue[counter]] === null) return undefined;
|
|
1338
1116
|
willReturn = willReturn[pathArrValue[counter]];
|
|
1339
1117
|
counter++;
|
|
1340
1118
|
}
|
|
1341
|
-
|
|
1342
1119
|
return willReturn;
|
|
1343
1120
|
}
|
|
1344
1121
|
|
|
@@ -1346,7 +1123,6 @@ function hasPath(pathInput, obj) {
|
|
|
1346
1123
|
if (arguments.length === 1) {
|
|
1347
1124
|
return objHolder => hasPath(pathInput, objHolder);
|
|
1348
1125
|
}
|
|
1349
|
-
|
|
1350
1126
|
return path(pathInput, obj) !== undefined;
|
|
1351
1127
|
}
|
|
1352
1128
|
|
|
@@ -1359,14 +1135,13 @@ function _objectIs(a, b) {
|
|
|
1359
1135
|
if (a === b) {
|
|
1360
1136
|
return a !== 0 || 1 / a === 1 / b;
|
|
1361
1137
|
}
|
|
1362
|
-
|
|
1363
1138
|
return a !== a && b !== b;
|
|
1364
1139
|
}
|
|
1365
|
-
|
|
1140
|
+
const objectIs = Object.is || _objectIs;
|
|
1366
1141
|
|
|
1367
1142
|
function identical(a, b) {
|
|
1368
1143
|
if (arguments.length === 1) return _b => identical(a, _b);
|
|
1369
|
-
return
|
|
1144
|
+
return objectIs(a, b);
|
|
1370
1145
|
}
|
|
1371
1146
|
|
|
1372
1147
|
function identity(x) {
|
|
@@ -1376,46 +1151,36 @@ function identity(x) {
|
|
|
1376
1151
|
function ifElseFn(condition, onTrue, onFalse) {
|
|
1377
1152
|
return (...input) => {
|
|
1378
1153
|
const conditionResult = typeof condition === 'boolean' ? condition : condition(...input);
|
|
1379
|
-
|
|
1380
1154
|
if (conditionResult === true) {
|
|
1381
1155
|
return onTrue(...input);
|
|
1382
1156
|
}
|
|
1383
|
-
|
|
1384
1157
|
return onFalse(...input);
|
|
1385
1158
|
};
|
|
1386
1159
|
}
|
|
1387
|
-
|
|
1388
1160
|
const ifElse = curry(ifElseFn);
|
|
1389
1161
|
|
|
1390
1162
|
const inc = x => x + 1;
|
|
1391
1163
|
|
|
1392
1164
|
function indexByPath(pathInput, list) {
|
|
1393
1165
|
const toReturn = {};
|
|
1394
|
-
|
|
1395
1166
|
for (let i = 0; i < list.length; i++) {
|
|
1396
1167
|
const item = list[i];
|
|
1397
1168
|
toReturn[path(pathInput, item)] = item;
|
|
1398
1169
|
}
|
|
1399
|
-
|
|
1400
1170
|
return toReturn;
|
|
1401
1171
|
}
|
|
1402
|
-
|
|
1403
1172
|
function indexBy(condition, list) {
|
|
1404
1173
|
if (arguments.length === 1) {
|
|
1405
1174
|
return _list => indexBy(condition, _list);
|
|
1406
1175
|
}
|
|
1407
|
-
|
|
1408
1176
|
if (typeof condition === 'string') {
|
|
1409
1177
|
return indexByPath(condition, list);
|
|
1410
1178
|
}
|
|
1411
|
-
|
|
1412
1179
|
const toReturn = {};
|
|
1413
|
-
|
|
1414
1180
|
for (let i = 0; i < list.length; i++) {
|
|
1415
1181
|
const item = list[i];
|
|
1416
1182
|
toReturn[condition(item)] = item;
|
|
1417
1183
|
}
|
|
1418
|
-
|
|
1419
1184
|
return toReturn;
|
|
1420
1185
|
}
|
|
1421
1186
|
|
|
@@ -1423,7 +1188,6 @@ function indexOf(valueToFind, list) {
|
|
|
1423
1188
|
if (arguments.length === 1) {
|
|
1424
1189
|
return _list => _indexOf(valueToFind, _list);
|
|
1425
1190
|
}
|
|
1426
|
-
|
|
1427
1191
|
return _indexOf(valueToFind, list);
|
|
1428
1192
|
}
|
|
1429
1193
|
|
|
@@ -1433,19 +1197,15 @@ function baseSlice(array, start, end) {
|
|
|
1433
1197
|
length
|
|
1434
1198
|
} = array;
|
|
1435
1199
|
end = end > length ? length : end;
|
|
1436
|
-
|
|
1437
1200
|
if (end < 0) {
|
|
1438
1201
|
end += length;
|
|
1439
1202
|
}
|
|
1440
|
-
|
|
1441
1203
|
length = start > end ? 0 : end - start >>> 0;
|
|
1442
1204
|
start >>>= 0;
|
|
1443
1205
|
const result = Array(length);
|
|
1444
|
-
|
|
1445
1206
|
while (++index < length) {
|
|
1446
1207
|
result[index] = array[index + start];
|
|
1447
1208
|
}
|
|
1448
|
-
|
|
1449
1209
|
return result;
|
|
1450
1210
|
}
|
|
1451
1211
|
|
|
@@ -1464,7 +1224,6 @@ function intersperse(separator, list) {
|
|
|
1464
1224
|
let index = -1;
|
|
1465
1225
|
const len = list.length;
|
|
1466
1226
|
const willReturn = [];
|
|
1467
|
-
|
|
1468
1227
|
while (++index < len) {
|
|
1469
1228
|
if (index === len - 1) {
|
|
1470
1229
|
willReturn.push(list[index]);
|
|
@@ -1472,7 +1231,6 @@ function intersperse(separator, list) {
|
|
|
1472
1231
|
willReturn.push(list[index], separator);
|
|
1473
1232
|
}
|
|
1474
1233
|
}
|
|
1475
|
-
|
|
1476
1234
|
return willReturn;
|
|
1477
1235
|
}
|
|
1478
1236
|
|
|
@@ -1485,15 +1243,12 @@ function isEmpty(input) {
|
|
|
1485
1243
|
const inputType = type(input);
|
|
1486
1244
|
if (['Undefined', 'NaN', 'Number', 'Null'].includes(inputType)) return false;
|
|
1487
1245
|
if (!input) return true;
|
|
1488
|
-
|
|
1489
1246
|
if (inputType === 'Object') {
|
|
1490
1247
|
return Object.keys(input).length === 0;
|
|
1491
1248
|
}
|
|
1492
|
-
|
|
1493
1249
|
if (inputType === 'Array') {
|
|
1494
1250
|
return input.length === 0;
|
|
1495
1251
|
}
|
|
1496
|
-
|
|
1497
1252
|
return false;
|
|
1498
1253
|
}
|
|
1499
1254
|
|
|
@@ -1518,7 +1273,6 @@ function last(listOrString) {
|
|
|
1518
1273
|
if (typeof listOrString === 'string') {
|
|
1519
1274
|
return listOrString[listOrString.length - 1] || '';
|
|
1520
1275
|
}
|
|
1521
|
-
|
|
1522
1276
|
return listOrString[listOrString.length - 1];
|
|
1523
1277
|
}
|
|
1524
1278
|
|
|
@@ -1526,12 +1280,11 @@ function lastIndexOf(valueToFind, list) {
|
|
|
1526
1280
|
if (arguments.length === 1) {
|
|
1527
1281
|
return _list => _lastIndexOf(valueToFind, _list);
|
|
1528
1282
|
}
|
|
1529
|
-
|
|
1530
1283
|
return _lastIndexOf(valueToFind, list);
|
|
1531
1284
|
}
|
|
1532
1285
|
|
|
1533
1286
|
function length(x) {
|
|
1534
|
-
if (
|
|
1287
|
+
if (isArray(x)) return x.length;
|
|
1535
1288
|
if (typeof x === 'string') return x.length;
|
|
1536
1289
|
return NaN;
|
|
1537
1290
|
}
|
|
@@ -1555,7 +1308,6 @@ function updateFn(index, newValue, list) {
|
|
|
1555
1308
|
if (index === -1) return clone.fill(newValue, index);
|
|
1556
1309
|
return clone.fill(newValue, index, index + 1);
|
|
1557
1310
|
}
|
|
1558
|
-
|
|
1559
1311
|
const update = curry(updateFn);
|
|
1560
1312
|
|
|
1561
1313
|
function lensIndex(index) {
|
|
@@ -1578,7 +1330,7 @@ function match(pattern, input) {
|
|
|
1578
1330
|
|
|
1579
1331
|
function mathMod(x, y) {
|
|
1580
1332
|
if (arguments.length === 1) return _y => mathMod(x, _y);
|
|
1581
|
-
if (!
|
|
1333
|
+
if (!isInteger(x) || !isInteger(y) || y < 1) return NaN;
|
|
1582
1334
|
return (x % y + y) % y;
|
|
1583
1335
|
}
|
|
1584
1336
|
|
|
@@ -1623,8 +1375,7 @@ function mergeDeepRight(target, source) {
|
|
|
1623
1375
|
if (arguments.length === 1) {
|
|
1624
1376
|
return sourceHolder => mergeDeepRight(target, sourceHolder);
|
|
1625
1377
|
}
|
|
1626
|
-
|
|
1627
|
-
const willReturn = JSON.parse(JSON.stringify(target));
|
|
1378
|
+
const willReturn = clone(target);
|
|
1628
1379
|
Object.keys(source).forEach(key => {
|
|
1629
1380
|
if (type(source[key]) === 'Object') {
|
|
1630
1381
|
if (type(target[key]) === 'Object') {
|
|
@@ -1655,7 +1406,6 @@ function mergeWithFn(mergeFn, a, b) {
|
|
|
1655
1406
|
});
|
|
1656
1407
|
Object.keys(b).forEach(key => {
|
|
1657
1408
|
if (willReturn[key] !== undefined) return;
|
|
1658
|
-
|
|
1659
1409
|
if (a[key] === undefined) {
|
|
1660
1410
|
willReturn[key] = b[key];
|
|
1661
1411
|
} else {
|
|
@@ -1664,7 +1414,6 @@ function mergeWithFn(mergeFn, a, b) {
|
|
|
1664
1414
|
});
|
|
1665
1415
|
return willReturn;
|
|
1666
1416
|
}
|
|
1667
|
-
|
|
1668
1417
|
const mergeWith = curry(mergeWithFn);
|
|
1669
1418
|
|
|
1670
1419
|
function min(x, y) {
|
|
@@ -1679,17 +1428,14 @@ const minBy = curry(minByFn);
|
|
|
1679
1428
|
|
|
1680
1429
|
function ownKeys(object, enumerableOnly) {
|
|
1681
1430
|
var keys = Object.keys(object);
|
|
1682
|
-
|
|
1683
1431
|
if (Object.getOwnPropertySymbols) {
|
|
1684
1432
|
var symbols = Object.getOwnPropertySymbols(object);
|
|
1685
1433
|
enumerableOnly && (symbols = symbols.filter(function (sym) {
|
|
1686
1434
|
return Object.getOwnPropertyDescriptor(object, sym).enumerable;
|
|
1687
1435
|
})), keys.push.apply(keys, symbols);
|
|
1688
1436
|
}
|
|
1689
|
-
|
|
1690
1437
|
return keys;
|
|
1691
1438
|
}
|
|
1692
|
-
|
|
1693
1439
|
function _objectSpread2(target) {
|
|
1694
1440
|
for (var i = 1; i < arguments.length; i++) {
|
|
1695
1441
|
var source = null != arguments[i] ? arguments[i] : {};
|
|
@@ -1699,10 +1445,8 @@ function _objectSpread2(target) {
|
|
|
1699
1445
|
Object.defineProperty(target, key, Object.getOwnPropertyDescriptor(source, key));
|
|
1700
1446
|
});
|
|
1701
1447
|
}
|
|
1702
|
-
|
|
1703
1448
|
return target;
|
|
1704
1449
|
}
|
|
1705
|
-
|
|
1706
1450
|
function _defineProperty(obj, key, value) {
|
|
1707
1451
|
if (key in obj) {
|
|
1708
1452
|
Object.defineProperty(obj, key, {
|
|
@@ -1714,26 +1458,37 @@ function _defineProperty(obj, key, value) {
|
|
|
1714
1458
|
} else {
|
|
1715
1459
|
obj[key] = value;
|
|
1716
1460
|
}
|
|
1717
|
-
|
|
1718
1461
|
return obj;
|
|
1719
1462
|
}
|
|
1720
1463
|
|
|
1464
|
+
function isIterable(input) {
|
|
1465
|
+
return Array.isArray(input) || type(input) === 'Object';
|
|
1466
|
+
}
|
|
1467
|
+
|
|
1468
|
+
function modifyFn(property, fn, iterable) {
|
|
1469
|
+
if (!isIterable(iterable)) return iterable;
|
|
1470
|
+
if (iterable[property] === undefined) return iterable;
|
|
1471
|
+
if (isArray(iterable)) {
|
|
1472
|
+
return updateFn(property, fn(iterable[property]), iterable);
|
|
1473
|
+
}
|
|
1474
|
+
return _objectSpread2(_objectSpread2({}, iterable), {}, {
|
|
1475
|
+
[property]: fn(iterable[property])
|
|
1476
|
+
});
|
|
1477
|
+
}
|
|
1478
|
+
const modify = curry(modifyFn);
|
|
1479
|
+
|
|
1721
1480
|
function modifyPathFn(pathInput, fn, object) {
|
|
1722
1481
|
const path$1 = createPath(pathInput);
|
|
1723
|
-
|
|
1724
1482
|
if (path$1.length === 1) {
|
|
1725
1483
|
return _objectSpread2(_objectSpread2({}, object), {}, {
|
|
1726
1484
|
[path$1[0]]: fn(object[path$1[0]])
|
|
1727
1485
|
});
|
|
1728
1486
|
}
|
|
1729
|
-
|
|
1730
1487
|
if (path(path$1, object) === undefined) return object;
|
|
1731
1488
|
const val = modifyPath(Array.prototype.slice.call(path$1, 1), fn, object[path$1[0]]);
|
|
1732
|
-
|
|
1733
1489
|
if (val === object[path$1[0]]) {
|
|
1734
1490
|
return object;
|
|
1735
1491
|
}
|
|
1736
|
-
|
|
1737
1492
|
return assoc(path$1[0], val, object);
|
|
1738
1493
|
}
|
|
1739
1494
|
const modifyPath = curry(modifyPathFn);
|
|
@@ -1747,14 +1502,12 @@ function moveFn(fromIndex, toIndex, list) {
|
|
|
1747
1502
|
if (fromIndex < 0 || toIndex < 0) {
|
|
1748
1503
|
throw new Error('Rambda.move does not support negative indexes');
|
|
1749
1504
|
}
|
|
1750
|
-
|
|
1751
1505
|
if (fromIndex > list.length - 1 || toIndex > list.length - 1) return list;
|
|
1752
1506
|
const clone = cloneList(list);
|
|
1753
1507
|
clone[fromIndex] = list[toIndex];
|
|
1754
1508
|
clone[toIndex] = list[fromIndex];
|
|
1755
1509
|
return clone;
|
|
1756
1510
|
}
|
|
1757
|
-
|
|
1758
1511
|
const move = curry(moveFn);
|
|
1759
1512
|
|
|
1760
1513
|
function multiply(x, y) {
|
|
@@ -1768,11 +1521,9 @@ function negate(x) {
|
|
|
1768
1521
|
|
|
1769
1522
|
function none(predicate, list) {
|
|
1770
1523
|
if (arguments.length === 1) return _list => none(predicate, _list);
|
|
1771
|
-
|
|
1772
1524
|
for (let i = 0; i < list.length; i++) {
|
|
1773
1525
|
if (predicate(list[i])) return false;
|
|
1774
1526
|
}
|
|
1775
|
-
|
|
1776
1527
|
return true;
|
|
1777
1528
|
}
|
|
1778
1529
|
|
|
@@ -1784,7 +1535,6 @@ function objOf(key, value) {
|
|
|
1784
1535
|
if (arguments.length === 1) {
|
|
1785
1536
|
return _value => objOf(key, _value);
|
|
1786
1537
|
}
|
|
1787
|
-
|
|
1788
1538
|
return {
|
|
1789
1539
|
[key]: value
|
|
1790
1540
|
};
|
|
@@ -1796,20 +1546,16 @@ function of(value) {
|
|
|
1796
1546
|
|
|
1797
1547
|
function omit(propsToOmit, obj) {
|
|
1798
1548
|
if (arguments.length === 1) return _obj => omit(propsToOmit, _obj);
|
|
1799
|
-
|
|
1800
1549
|
if (obj === null || obj === undefined) {
|
|
1801
1550
|
return undefined;
|
|
1802
1551
|
}
|
|
1803
|
-
|
|
1804
1552
|
const propsToOmitValue = createPath(propsToOmit, ',');
|
|
1805
1553
|
const willReturn = {};
|
|
1806
|
-
|
|
1807
1554
|
for (const key in obj) {
|
|
1808
1555
|
if (!propsToOmitValue.includes(key)) {
|
|
1809
1556
|
willReturn[key] = obj[key];
|
|
1810
1557
|
}
|
|
1811
1558
|
}
|
|
1812
|
-
|
|
1813
1559
|
return willReturn;
|
|
1814
1560
|
}
|
|
1815
1561
|
|
|
@@ -1817,11 +1563,9 @@ function on(binaryFn, unaryFn, a, b) {
|
|
|
1817
1563
|
if (arguments.length === 3) {
|
|
1818
1564
|
return _b => on(binaryFn, unaryFn, a, _b);
|
|
1819
1565
|
}
|
|
1820
|
-
|
|
1821
1566
|
if (arguments.length === 2) {
|
|
1822
1567
|
return (_a, _b) => on(binaryFn, unaryFn, _a, _b);
|
|
1823
1568
|
}
|
|
1824
|
-
|
|
1825
1569
|
return binaryFn(unaryFn(a), unaryFn(b));
|
|
1826
1570
|
}
|
|
1827
1571
|
|
|
@@ -1832,17 +1576,14 @@ function onceFn(fn, context) {
|
|
|
1832
1576
|
result = fn.apply(context || this, arguments);
|
|
1833
1577
|
fn = null;
|
|
1834
1578
|
}
|
|
1835
|
-
|
|
1836
1579
|
return result;
|
|
1837
1580
|
};
|
|
1838
1581
|
}
|
|
1839
|
-
|
|
1840
1582
|
function once(fn, context) {
|
|
1841
1583
|
if (arguments.length === 1) {
|
|
1842
1584
|
const wrap = onceFn(fn, context);
|
|
1843
1585
|
return curry(wrap);
|
|
1844
1586
|
}
|
|
1845
|
-
|
|
1846
1587
|
return onceFn(fn, context);
|
|
1847
1588
|
}
|
|
1848
1589
|
|
|
@@ -1855,11 +1596,9 @@ const Identity = x => ({
|
|
|
1855
1596
|
x,
|
|
1856
1597
|
map: fn => Identity(fn(x))
|
|
1857
1598
|
});
|
|
1858
|
-
|
|
1859
1599
|
function overFn(lens, fn, object) {
|
|
1860
1600
|
return lens(x => Identity(fn(x)))(object).x;
|
|
1861
1601
|
}
|
|
1862
|
-
|
|
1863
1602
|
const over = curry(overFn);
|
|
1864
1603
|
|
|
1865
1604
|
function partial(fn, ...args) {
|
|
@@ -1868,21 +1607,12 @@ function partial(fn, ...args) {
|
|
|
1868
1607
|
if (args.length + rest.length >= len) {
|
|
1869
1608
|
return fn(...args, ...rest);
|
|
1870
1609
|
}
|
|
1871
|
-
|
|
1872
1610
|
return partial(fn, ...[...args, ...rest]);
|
|
1873
1611
|
};
|
|
1874
1612
|
}
|
|
1875
1613
|
|
|
1876
1614
|
function partialObject(fn, input) {
|
|
1877
|
-
return
|
|
1878
|
-
if (type(fn) === 'Async') {
|
|
1879
|
-
return new Promise((resolve, reject) => {
|
|
1880
|
-
fn(mergeDeepRight(rest, input)).then(resolve).catch(reject);
|
|
1881
|
-
});
|
|
1882
|
-
}
|
|
1883
|
-
|
|
1884
|
-
return fn(mergeDeepRight(rest, input));
|
|
1885
|
-
};
|
|
1615
|
+
return nextInput => fn(mergeDeepRight(nextInput, input));
|
|
1886
1616
|
}
|
|
1887
1617
|
|
|
1888
1618
|
function partitionObject(predicate, iterable) {
|
|
@@ -1901,7 +1631,6 @@ function partitionArray(predicate, list, indexed = false) {
|
|
|
1901
1631
|
const yes = [];
|
|
1902
1632
|
const no = [];
|
|
1903
1633
|
let counter = -1;
|
|
1904
|
-
|
|
1905
1634
|
while (counter++ < list.length - 1) {
|
|
1906
1635
|
if (indexed ? predicate(list[counter], counter) : predicate(list[counter])) {
|
|
1907
1636
|
yes.push(list[counter]);
|
|
@@ -1909,81 +1638,66 @@ function partitionArray(predicate, list, indexed = false) {
|
|
|
1909
1638
|
no.push(list[counter]);
|
|
1910
1639
|
}
|
|
1911
1640
|
}
|
|
1912
|
-
|
|
1913
1641
|
return [yes, no];
|
|
1914
1642
|
}
|
|
1915
1643
|
function partition(predicate, iterable) {
|
|
1916
1644
|
if (arguments.length === 1) {
|
|
1917
1645
|
return listHolder => partition(predicate, listHolder);
|
|
1918
1646
|
}
|
|
1919
|
-
|
|
1920
|
-
if (!_isArray(iterable)) return partitionObject(predicate, iterable);
|
|
1647
|
+
if (!isArray(iterable)) return partitionObject(predicate, iterable);
|
|
1921
1648
|
return partitionArray(predicate, iterable);
|
|
1922
1649
|
}
|
|
1923
1650
|
|
|
1924
1651
|
function pathEqFn(pathToSearch, target, input) {
|
|
1925
1652
|
return equals(path(pathToSearch, input), target);
|
|
1926
1653
|
}
|
|
1927
|
-
|
|
1928
1654
|
const pathEq = curry(pathEqFn);
|
|
1929
1655
|
|
|
1930
1656
|
function pathOrFn(defaultValue, pathInput, obj) {
|
|
1931
1657
|
return defaultTo(defaultValue, path(pathInput, obj));
|
|
1932
1658
|
}
|
|
1933
|
-
|
|
1934
1659
|
const pathOr = curry(pathOrFn);
|
|
1935
1660
|
|
|
1936
1661
|
function paths(pathsToSearch, obj) {
|
|
1937
1662
|
if (arguments.length === 1) {
|
|
1938
1663
|
return _obj => paths(pathsToSearch, _obj);
|
|
1939
1664
|
}
|
|
1940
|
-
|
|
1941
1665
|
return pathsToSearch.map(singlePath => path(singlePath, obj));
|
|
1942
1666
|
}
|
|
1943
1667
|
|
|
1944
1668
|
function pick(propsToPick, input) {
|
|
1945
1669
|
if (arguments.length === 1) return _input => pick(propsToPick, _input);
|
|
1946
|
-
|
|
1947
1670
|
if (input === null || input === undefined) {
|
|
1948
1671
|
return undefined;
|
|
1949
1672
|
}
|
|
1950
|
-
|
|
1951
1673
|
const keys = createPath(propsToPick, ',');
|
|
1952
1674
|
const willReturn = {};
|
|
1953
1675
|
let counter = 0;
|
|
1954
|
-
|
|
1955
1676
|
while (counter < keys.length) {
|
|
1956
1677
|
if (keys[counter] in input) {
|
|
1957
1678
|
willReturn[keys[counter]] = input[keys[counter]];
|
|
1958
1679
|
}
|
|
1959
|
-
|
|
1960
1680
|
counter++;
|
|
1961
1681
|
}
|
|
1962
|
-
|
|
1963
1682
|
return willReturn;
|
|
1964
1683
|
}
|
|
1965
1684
|
|
|
1966
1685
|
function pickAll(propsToPick, obj) {
|
|
1967
1686
|
if (arguments.length === 1) return _obj => pickAll(propsToPick, _obj);
|
|
1968
|
-
|
|
1969
1687
|
if (obj === null || obj === undefined) {
|
|
1970
1688
|
return undefined;
|
|
1971
1689
|
}
|
|
1972
|
-
|
|
1973
1690
|
const keysValue = createPath(propsToPick, ',');
|
|
1974
1691
|
const willReturn = {};
|
|
1975
1692
|
let counter = 0;
|
|
1976
|
-
|
|
1977
1693
|
while (counter < keysValue.length) {
|
|
1978
1694
|
if (keysValue[counter] in obj) {
|
|
1979
1695
|
willReturn[keysValue[counter]] = obj[keysValue[counter]];
|
|
1980
1696
|
} else {
|
|
1981
1697
|
willReturn[keysValue[counter]] = undefined;
|
|
1982
1698
|
}
|
|
1983
|
-
|
|
1984
1699
|
counter++;
|
|
1985
1700
|
}
|
|
1986
|
-
|
|
1987
1701
|
return willReturn;
|
|
1988
1702
|
}
|
|
1989
1703
|
|
|
@@ -2010,55 +1724,45 @@ function propEqFn(propToFind, valueToMatch, obj) {
|
|
|
2010
1724
|
if (!obj) return false;
|
|
2011
1725
|
return equals(valueToMatch, prop(propToFind, obj));
|
|
2012
1726
|
}
|
|
2013
|
-
|
|
2014
1727
|
const propEq = curry(propEqFn);
|
|
2015
1728
|
|
|
2016
1729
|
function propIsFn(targetPrototype, property, obj) {
|
|
2017
1730
|
return is(targetPrototype, obj[property]);
|
|
2018
1731
|
}
|
|
2019
|
-
|
|
2020
1732
|
const propIs = curry(propIsFn);
|
|
2021
1733
|
|
|
2022
1734
|
function propOrFn(defaultValue, property, obj) {
|
|
2023
1735
|
if (!obj) return defaultValue;
|
|
2024
1736
|
return defaultTo(defaultValue, obj[property]);
|
|
2025
1737
|
}
|
|
2026
|
-
|
|
2027
1738
|
const propOr = curry(propOrFn);
|
|
2028
1739
|
|
|
2029
|
-
function propSatisfiesFn(predicate, property, obj) {
|
|
2030
|
-
return predicate(prop(property, obj));
|
|
2031
|
-
}
|
|
2032
|
-
|
|
2033
|
-
const propSatisfies = curry(propSatisfiesFn);
|
|
2034
|
-
|
|
2035
1740
|
function props(propsToPick, obj) {
|
|
2036
1741
|
if (arguments.length === 1) {
|
|
2037
1742
|
return _obj => props(propsToPick, _obj);
|
|
2038
1743
|
}
|
|
2039
|
-
|
|
2040
|
-
if (!_isArray(propsToPick)) {
|
|
1744
|
+
if (!isArray(propsToPick)) {
|
|
2041
1745
|
throw new Error('propsToPick is not a list');
|
|
2042
1746
|
}
|
|
2043
|
-
|
|
2044
1747
|
return mapArray(prop => obj[prop], propsToPick);
|
|
2045
1748
|
}
|
|
2046
1749
|
|
|
1750
|
+
function propSatisfiesFn(predicate, property, obj) {
|
|
1751
|
+
return predicate(prop(property, obj));
|
|
1752
|
+
}
|
|
1753
|
+
const propSatisfies = curry(propSatisfiesFn);
|
|
1754
|
+
|
|
2047
1755
|
function range(start, end) {
|
|
2048
1756
|
if (arguments.length === 1) return _end => range(start, _end);
|
|
2049
|
-
|
|
2050
1757
|
if (Number.isNaN(Number(start)) || Number.isNaN(Number(end))) {
|
|
2051
1758
|
throw new TypeError('Both arguments to range must be numbers');
|
|
2052
1759
|
}
|
|
2053
|
-
|
|
2054
1760
|
if (end < start) return [];
|
|
2055
1761
|
const len = end - start;
|
|
2056
1762
|
const willReturn = Array(len);
|
|
2057
|
-
|
|
2058
1763
|
for (let i = 0; i < len; i++) {
|
|
2059
1764
|
willReturn[i] = start + i;
|
|
2060
1765
|
}
|
|
2061
|
-
|
|
2062
1766
|
return willReturn;
|
|
2063
1767
|
}
|
|
2064
1768
|
|
|
@@ -2071,21 +1775,18 @@ function repeat(x, timesToRepeat) {
|
|
|
2071
1775
|
if (arguments.length === 1) {
|
|
2072
1776
|
return _timesToRepeat => repeat(x, _timesToRepeat);
|
|
2073
1777
|
}
|
|
2074
|
-
|
|
2075
1778
|
return Array(timesToRepeat).fill(x);
|
|
2076
1779
|
}
|
|
2077
1780
|
|
|
2078
1781
|
function replaceFn(pattern, replacer, str) {
|
|
2079
1782
|
return str.replace(pattern, replacer);
|
|
2080
1783
|
}
|
|
2081
|
-
|
|
2082
1784
|
const replace = curry(replaceFn);
|
|
2083
1785
|
|
|
2084
1786
|
function reverse(listOrString) {
|
|
2085
1787
|
if (typeof listOrString === 'string') {
|
|
2086
1788
|
return listOrString.split('').reverse().join('');
|
|
2087
1789
|
}
|
|
2088
|
-
|
|
2089
1790
|
const clone = listOrString.slice();
|
|
2090
1791
|
return clone.reverse();
|
|
2091
1792
|
}
|
|
@@ -2093,13 +1794,11 @@ function reverse(listOrString) {
|
|
|
2093
1794
|
function setFn(lens, replacer, x) {
|
|
2094
1795
|
return over(lens, always(replacer), x);
|
|
2095
1796
|
}
|
|
2096
|
-
|
|
2097
1797
|
const set = curry(setFn);
|
|
2098
1798
|
|
|
2099
1799
|
function sliceFn(from, to, list) {
|
|
2100
1800
|
return list.slice(from, to);
|
|
2101
1801
|
}
|
|
2102
|
-
|
|
2103
1802
|
const slice = curry(sliceFn);
|
|
2104
1803
|
|
|
2105
1804
|
function sort(sortFn, list) {
|
|
@@ -2140,9 +1839,8 @@ function splitAt(index, input) {
|
|
|
2140
1839
|
if (arguments.length === 1) {
|
|
2141
1840
|
return _list => splitAt(index, _list);
|
|
2142
1841
|
}
|
|
2143
|
-
|
|
2144
1842
|
if (!input) throw new TypeError(`Cannot read property 'slice' of ${input}`);
|
|
2145
|
-
if (!
|
|
1843
|
+
if (!isArray(input) && typeof input !== 'string') return [[], []];
|
|
2146
1844
|
const correctIndex = maybe(index < 0, input.length + index < 0 ? 0 : input.length + index, index);
|
|
2147
1845
|
return [take(correctIndex, input), drop(correctIndex, input)];
|
|
2148
1846
|
}
|
|
@@ -2151,18 +1849,14 @@ function splitEvery(sliceLength, listOrString) {
|
|
|
2151
1849
|
if (arguments.length === 1) {
|
|
2152
1850
|
return _listOrString => splitEvery(sliceLength, _listOrString);
|
|
2153
1851
|
}
|
|
2154
|
-
|
|
2155
1852
|
if (sliceLength < 1) {
|
|
2156
1853
|
throw new Error('First argument to splitEvery must be a positive integer');
|
|
2157
1854
|
}
|
|
2158
|
-
|
|
2159
1855
|
const willReturn = [];
|
|
2160
1856
|
let counter = 0;
|
|
2161
|
-
|
|
2162
1857
|
while (counter < listOrString.length) {
|
|
2163
1858
|
willReturn.push(listOrString.slice(counter, counter += sliceLength));
|
|
2164
1859
|
}
|
|
2165
|
-
|
|
2166
1860
|
return willReturn;
|
|
2167
1861
|
}
|
|
2168
1862
|
|
|
@@ -2170,13 +1864,11 @@ function splitWhen(predicate, input) {
|
|
|
2170
1864
|
if (arguments.length === 1) {
|
|
2171
1865
|
return _input => splitWhen(predicate, _input);
|
|
2172
1866
|
}
|
|
2173
|
-
|
|
2174
1867
|
if (!input) throw new TypeError(`Cannot read property 'length' of ${input}`);
|
|
2175
1868
|
const preFound = [];
|
|
2176
1869
|
const postFound = [];
|
|
2177
1870
|
let found = false;
|
|
2178
1871
|
let counter = -1;
|
|
2179
|
-
|
|
2180
1872
|
while (counter++ < input.length - 1) {
|
|
2181
1873
|
if (found) {
|
|
2182
1874
|
postFound.push(input[counter]);
|
|
@@ -2187,18 +1879,15 @@ function splitWhen(predicate, input) {
|
|
|
2187
1879
|
preFound.push(input[counter]);
|
|
2188
1880
|
}
|
|
2189
1881
|
}
|
|
2190
|
-
|
|
2191
1882
|
return [preFound, postFound];
|
|
2192
1883
|
}
|
|
2193
1884
|
|
|
2194
1885
|
function startsWith(target, iterable) {
|
|
2195
1886
|
if (arguments.length === 1) return _iterable => startsWith(target, _iterable);
|
|
2196
|
-
|
|
2197
1887
|
if (typeof iterable === 'string') {
|
|
2198
1888
|
return iterable.startsWith(target);
|
|
2199
1889
|
}
|
|
2200
|
-
|
|
2201
|
-
if (!_isArray(target)) return false;
|
|
1890
|
+
if (!isArray(target)) return false;
|
|
2202
1891
|
let correct = true;
|
|
2203
1892
|
const filtered = target.filter((x, index) => {
|
|
2204
1893
|
if (!correct) return false;
|
|
@@ -2218,10 +1907,13 @@ function symmetricDifference(x, y) {
|
|
|
2218
1907
|
if (arguments.length === 1) {
|
|
2219
1908
|
return _y => symmetricDifference(x, _y);
|
|
2220
1909
|
}
|
|
2221
|
-
|
|
2222
1910
|
return concat(filter(value => !includes(value, y), x), filter(value => !includes(value, x), y));
|
|
2223
1911
|
}
|
|
2224
1912
|
|
|
1913
|
+
function T() {
|
|
1914
|
+
return true;
|
|
1915
|
+
}
|
|
1916
|
+
|
|
2225
1917
|
function tail(listOrString) {
|
|
2226
1918
|
return drop(1, listOrString);
|
|
2227
1919
|
}
|
|
@@ -2240,40 +1932,32 @@ function takeLastWhile(predicate, input) {
|
|
|
2240
1932
|
if (arguments.length === 1) {
|
|
2241
1933
|
return _input => takeLastWhile(predicate, _input);
|
|
2242
1934
|
}
|
|
2243
|
-
|
|
2244
1935
|
if (input.length === 0) return input;
|
|
2245
1936
|
let found = false;
|
|
2246
1937
|
const toReturn = [];
|
|
2247
1938
|
let counter = input.length;
|
|
2248
|
-
|
|
2249
1939
|
while (!found || counter === 0) {
|
|
2250
1940
|
counter--;
|
|
2251
|
-
|
|
2252
1941
|
if (predicate(input[counter]) === false) {
|
|
2253
1942
|
found = true;
|
|
2254
1943
|
} else if (!found) {
|
|
2255
1944
|
toReturn.push(input[counter]);
|
|
2256
1945
|
}
|
|
2257
1946
|
}
|
|
2258
|
-
|
|
2259
|
-
return _isArray(input) ? toReturn.reverse() : toReturn.reverse().join('');
|
|
1947
|
+
return isArray(input) ? toReturn.reverse() : toReturn.reverse().join('');
|
|
2260
1948
|
}
|
|
2261
1949
|
|
|
2262
1950
|
function takeWhile(predicate, iterable) {
|
|
2263
1951
|
if (arguments.length === 1) {
|
|
2264
1952
|
return _iterable => takeWhile(predicate, _iterable);
|
|
2265
1953
|
}
|
|
2266
|
-
|
|
2267
|
-
|
|
2268
|
-
|
|
2269
|
-
if (!isArray && typeof iterable !== 'string') {
|
|
1954
|
+
const isArray$1 = isArray(iterable);
|
|
1955
|
+
if (!isArray$1 && typeof iterable !== 'string') {
|
|
2270
1956
|
throw new Error('`iterable` is neither list nor a string');
|
|
2271
1957
|
}
|
|
2272
|
-
|
|
2273
1958
|
let flag = true;
|
|
2274
1959
|
const holder = [];
|
|
2275
1960
|
let counter = -1;
|
|
2276
|
-
|
|
2277
1961
|
while (counter++ < iterable.length - 1) {
|
|
2278
1962
|
if (!predicate(iterable[counter])) {
|
|
2279
1963
|
if (flag) flag = false;
|
|
@@ -2281,7 +1965,7 @@ function takeWhile(predicate, iterable) {
|
|
|
2281
1965
|
holder.push(iterable[counter]);
|
|
2282
1966
|
}
|
|
2283
1967
|
}
|
|
2284
|
-
return isArray ? holder : holder.join('');
|
|
1968
|
+
return isArray$1 ? holder : holder.join('');
|
|
2285
1969
|
}
|
|
2286
1970
|
|
|
2287
1971
|
function tap(fn, x) {
|
|
@@ -2292,21 +1976,17 @@ function tap(fn, x) {
|
|
|
2292
1976
|
|
|
2293
1977
|
function test(pattern, str) {
|
|
2294
1978
|
if (arguments.length === 1) return _str => test(pattern, _str);
|
|
2295
|
-
|
|
2296
1979
|
if (typeof pattern === 'string') {
|
|
2297
1980
|
throw new TypeError(`‘test’ requires a value of type RegExp as its first argument; received "${pattern}"`);
|
|
2298
1981
|
}
|
|
2299
|
-
|
|
2300
1982
|
return str.search(pattern) !== -1;
|
|
2301
1983
|
}
|
|
2302
1984
|
|
|
2303
1985
|
function times(fn, howMany) {
|
|
2304
1986
|
if (arguments.length === 1) return _howMany => times(fn, _howMany);
|
|
2305
|
-
|
|
2306
|
-
if (!Number.isInteger(howMany) || howMany < 0) {
|
|
1987
|
+
if (!isInteger(howMany) || howMany < 0) {
|
|
2307
1988
|
throw new RangeError('n must be an integer');
|
|
2308
1989
|
}
|
|
2309
|
-
|
|
2310
1990
|
return map(fn, range(0, howMany));
|
|
2311
1991
|
}
|
|
2312
1992
|
|
|
@@ -2328,7 +2008,7 @@ function toUpper(str) {
|
|
|
2328
2008
|
|
|
2329
2009
|
function transpose(array) {
|
|
2330
2010
|
return array.reduce((acc, el) => {
|
|
2331
|
-
el.forEach((nestedEl, i) =>
|
|
2011
|
+
el.forEach((nestedEl, i) => isArray(acc[i]) ? acc[i].push(nestedEl) : acc.push([nestedEl]));
|
|
2332
2012
|
return acc;
|
|
2333
2013
|
}, []);
|
|
2334
2014
|
}
|
|
@@ -2338,12 +2018,10 @@ function trim(str) {
|
|
|
2338
2018
|
}
|
|
2339
2019
|
|
|
2340
2020
|
const isFunction = x => ['Promise', 'Function'].includes(type(x));
|
|
2341
|
-
|
|
2342
2021
|
function tryCatch(fn, fallback) {
|
|
2343
2022
|
if (!isFunction(fn)) {
|
|
2344
2023
|
throw new Error(`R.tryCatch | fn '${fn}'`);
|
|
2345
2024
|
}
|
|
2346
|
-
|
|
2347
2025
|
const passFallback = isFunction(fallback);
|
|
2348
2026
|
return (...inputs) => {
|
|
2349
2027
|
try {
|
|
@@ -2373,7 +2051,6 @@ function uniqBy(fn, list) {
|
|
|
2373
2051
|
if (arguments.length === 1) {
|
|
2374
2052
|
return _list => uniqBy(fn, _list);
|
|
2375
2053
|
}
|
|
2376
|
-
|
|
2377
2054
|
const set = new Set();
|
|
2378
2055
|
return list.filter(item => {
|
|
2379
2056
|
if (set.has(fn(item))) return false;
|
|
@@ -2385,31 +2062,24 @@ function uniqBy(fn, list) {
|
|
|
2385
2062
|
function includesWith(predicate, target, list) {
|
|
2386
2063
|
let willReturn = false;
|
|
2387
2064
|
let index = -1;
|
|
2388
|
-
|
|
2389
2065
|
while (++index < list.length && !willReturn) {
|
|
2390
2066
|
const value = list[index];
|
|
2391
|
-
|
|
2392
2067
|
if (predicate(target, value)) {
|
|
2393
2068
|
willReturn = true;
|
|
2394
2069
|
}
|
|
2395
2070
|
}
|
|
2396
|
-
|
|
2397
2071
|
return willReturn;
|
|
2398
2072
|
}
|
|
2399
|
-
|
|
2400
2073
|
function uniqWith(predicate, list) {
|
|
2401
2074
|
if (arguments.length === 1) return _list => uniqWith(predicate, _list);
|
|
2402
2075
|
let index = -1;
|
|
2403
2076
|
const willReturn = [];
|
|
2404
|
-
|
|
2405
2077
|
while (++index < list.length) {
|
|
2406
2078
|
const value = list[index];
|
|
2407
|
-
|
|
2408
2079
|
if (!includesWith(predicate, value, willReturn)) {
|
|
2409
2080
|
willReturn.push(value);
|
|
2410
2081
|
}
|
|
2411
2082
|
}
|
|
2412
|
-
|
|
2413
2083
|
return willReturn;
|
|
2414
2084
|
}
|
|
2415
2085
|
|
|
@@ -2417,7 +2087,6 @@ function unless(predicate, whenFalse) {
|
|
|
2417
2087
|
if (arguments.length === 1) {
|
|
2418
2088
|
return _whenFalse => unless(predicate, _whenFalse);
|
|
2419
2089
|
}
|
|
2420
|
-
|
|
2421
2090
|
return input => predicate(input) ? input : whenFalse(input);
|
|
2422
2091
|
}
|
|
2423
2092
|
|
|
@@ -2425,8 +2094,7 @@ function unwind(property, obj) {
|
|
|
2425
2094
|
if (arguments.length === 1) {
|
|
2426
2095
|
return _obj => unwind(property, _obj);
|
|
2427
2096
|
}
|
|
2428
|
-
|
|
2429
|
-
if (!_isArray(obj[property])) return [obj];
|
|
2097
|
+
if (!isArray(obj[property])) return [obj];
|
|
2430
2098
|
return mapArray(x => _objectSpread2(_objectSpread2({}, obj), {}, {
|
|
2431
2099
|
[property]: x
|
|
2432
2100
|
}), obj[property]);
|
|
@@ -2441,7 +2109,6 @@ const Const = x => ({
|
|
|
2441
2109
|
x,
|
|
2442
2110
|
map: fn => Const(x)
|
|
2443
2111
|
});
|
|
2444
|
-
|
|
2445
2112
|
function view(lens, target) {
|
|
2446
2113
|
if (arguments.length === 1) return _target => view(lens, _target);
|
|
2447
2114
|
return lens(Const)(target).x;
|
|
@@ -2451,24 +2118,20 @@ function whenFn(predicate, whenTrueFn, input) {
|
|
|
2451
2118
|
if (!predicate(input)) return input;
|
|
2452
2119
|
return whenTrueFn(input);
|
|
2453
2120
|
}
|
|
2454
|
-
|
|
2455
2121
|
const when = curry(whenFn);
|
|
2456
2122
|
|
|
2457
2123
|
function where(conditions, input) {
|
|
2458
2124
|
if (input === undefined) {
|
|
2459
2125
|
return _input => where(conditions, _input);
|
|
2460
2126
|
}
|
|
2461
|
-
|
|
2462
2127
|
let flag = true;
|
|
2463
|
-
|
|
2464
2128
|
for (const prop in conditions) {
|
|
2129
|
+
if (!flag) continue;
|
|
2465
2130
|
const result = conditions[prop](input[prop]);
|
|
2466
|
-
|
|
2467
2131
|
if (flag && result === false) {
|
|
2468
2132
|
flag = false;
|
|
2469
2133
|
}
|
|
2470
2134
|
}
|
|
2471
|
-
|
|
2472
2135
|
return flag;
|
|
2473
2136
|
}
|
|
2474
2137
|
|
|
@@ -2476,13 +2139,11 @@ function whereAny(conditions, input) {
|
|
|
2476
2139
|
if (input === undefined) {
|
|
2477
2140
|
return _input => whereAny(conditions, _input);
|
|
2478
2141
|
}
|
|
2479
|
-
|
|
2480
2142
|
for (const prop in conditions) {
|
|
2481
2143
|
if (conditions[prop](input[prop])) {
|
|
2482
2144
|
return true;
|
|
2483
2145
|
}
|
|
2484
2146
|
}
|
|
2485
|
-
|
|
2486
2147
|
return false;
|
|
2487
2148
|
}
|
|
2488
2149
|
|
|
@@ -2490,7 +2151,6 @@ function whereEq(condition, input) {
|
|
|
2490
2151
|
if (arguments.length === 1) {
|
|
2491
2152
|
return _input => whereEq(condition, _input);
|
|
2492
2153
|
}
|
|
2493
|
-
|
|
2494
2154
|
const result = filter((conditionValue, conditionProp) => equals(conditionValue, input[conditionProp]), condition);
|
|
2495
2155
|
return Object.keys(result).length === Object.keys(condition).length;
|
|
2496
2156
|
}
|
|
@@ -2499,7 +2159,6 @@ function without(matchAgainst, source) {
|
|
|
2499
2159
|
if (source === undefined) {
|
|
2500
2160
|
return _source => without(matchAgainst, _source);
|
|
2501
2161
|
}
|
|
2502
|
-
|
|
2503
2162
|
return reduce((prev, current) => _indexOf(current, matchAgainst) > -1 ? prev : prev.concat(current), [], source);
|
|
2504
2163
|
}
|
|
2505
2164
|
|
|
@@ -2512,11 +2171,9 @@ function zip(left, right) {
|
|
|
2512
2171
|
if (arguments.length === 1) return _right => zip(left, _right);
|
|
2513
2172
|
const result = [];
|
|
2514
2173
|
const length = Math.min(left.length, right.length);
|
|
2515
|
-
|
|
2516
2174
|
for (let i = 0; i < length; i++) {
|
|
2517
2175
|
result[i] = [left[i], right[i]];
|
|
2518
2176
|
}
|
|
2519
|
-
|
|
2520
2177
|
return result;
|
|
2521
2178
|
}
|
|
2522
2179
|
|
|
@@ -2531,7 +2188,6 @@ function zipObj(keys, values) {
|
|
|
2531
2188
|
function zipWithFn(fn, x, y) {
|
|
2532
2189
|
return take(x.length > y.length ? y.length : x.length, x).map((xInstance, i) => fn(xInstance, y[i]));
|
|
2533
2190
|
}
|
|
2534
|
-
|
|
2535
2191
|
const zipWith = curry(zipWithFn);
|
|
2536
2192
|
|
|
2537
|
-
export { F, T, __findHighestArity, _arity, _indexOf, _lastIndexOf, _pipe, add, adjust, all, allPass, always, and, any, anyPass, append, apply, applySpec, assoc, assocPath, bind, both, chain, clamp, clone, complement, compose, concat, cond, converge, count, countBy, curry, curryN, dec, defaultTo, difference, dissoc, divide, drop, dropLast, dropLastWhile, dropRepeats, dropRepeatsWith, dropWhile, either, endsWith, eqProps, equals, evolve, evolveArray, evolveObject, filter, filterArray, filterObject, find, findIndex, findLast, findLastIndex, flatten, flip, forEach, fromPairs, groupBy, groupWith, has, hasPath, head, identical, identity, ifElse, inc, includes, indexBy, indexOf, init, intersection, intersperse, is, isEmpty, isNil, join, juxt, keys, last, lastIndexOf, length, lens, lensIndex, lensPath, lensProp, map, mapArray, mapObjIndexed, mapObject, match, mathMod, max, maxBy, maxByFn, mean, median, mergeRight as merge, mergeAll, mergeDeepRight, mergeLeft, mergeRight, mergeWith, min, minBy, minByFn, modifyPath, modifyPathFn, modulo, move, multiply, negate, none, not, nth, objOf, of, omit, on, once, or, over, partial, partialObject, partition, partitionArray, partitionObject, path, pathEq, pathOr, paths, pick, pickAll, pipe, pluck, prepend, product, prop, propEq, propIs, propOr, propSatisfies, props, range, reduce, reduceFn, reduceStopper, reject, repeat, replace, reverse, set, slice, sort, sortBy, split, splitAt, splitEvery, splitWhen, startsWith, subtract, sum, symmetricDifference, tail, take, takeLast, takeLastWhile, takeWhile, tap, test, times, toLower, toPairs, toString, toUpper, transpose, trim, tryCatch, type, unapply, union, uniq, uniqBy, uniqWith, unless, unwind, update, values, view, when, where, whereAny, whereEq, without, xor, zip, zipObj, zipWith };
|
|
2193
|
+
export { F, T, __findHighestArity, _arity, _indexOf, _lastIndexOf, _pipe, add, adjust, all, allPass, always, and, any, anyPass, append, apply, applySpec, assoc, assocPath, bind, both, chain, clamp, clone, complement, compose, concat, cond, converge, count, countBy, curry, curryN, dec, defaultTo, difference, dissoc, divide, drop, dropLast, dropLastWhile, dropRepeats, dropRepeatsWith, dropWhile, either, endsWith, eqProps, equals, evolve, evolveArray, evolveObject, filter, filterArray, filterObject, find, findIndex, findLast, findLastIndex, flatten, flip, forEach, fromPairs, groupBy, groupWith, has, hasPath, head, identical, identity, ifElse, inc, includes, indexBy, indexOf, init, intersection, intersperse, is, isEmpty, isNil, join, juxt, keys, last, lastIndexOf, length, lens, lensIndex, lensPath, lensProp, map, mapArray, mapObjIndexed, mapObject, match, mathMod, max, maxBy, maxByFn, mean, median, mergeRight as merge, mergeAll, mergeDeepRight, mergeLeft, mergeRight, mergeWith, min, minBy, minByFn, modify, modifyPath, modifyPathFn, modulo, move, multiply, negate, none, not, nth, objOf, of, omit, on, once, or, over, partial, partialObject, partition, partitionArray, partitionObject, path, pathEq, pathOr, paths, pick, pickAll, pipe, pluck, prepend, product, prop, propEq, propIs, propOr, propSatisfies, props, range, reduce, reduceFn, reduceStopper, reject, repeat, replace, reverse, set, slice, sort, sortBy, split, splitAt, splitEvery, splitWhen, startsWith, subtract, sum, symmetricDifference, tail, take, takeLast, takeLastWhile, takeWhile, tap, test, times, toLower, toPairs, toString, toUpper, transpose, trim, tryCatch, type, unapply, union, uniq, uniqBy, uniqWith, unless, unwind, update, updateFn, values, view, when, where, whereAny, whereEq, without, xor, zip, zipObj, zipWith };
|