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