1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 |
|
7 |
|
8 |
|
9 |
|
10 |
|
11 |
|
12 |
|
13 |
|
14 |
|
15 |
|
16 |
|
17 |
|
18 |
|
19 |
|
20 |
|
21 |
|
22 |
|
23 |
|
24 |
|
25 |
|
26 |
|
27 |
|
28 |
|
29 |
|
30 |
|
31 |
|
32 |
|
33 |
|
34 |
|
35 |
|
36 | import * as _ from 'ts-toolbelt';
|
37 | import {
|
38 | AnyConstructor,
|
39 | AnyFunction,
|
40 | AtLeastOneFunctionsFlow,
|
41 | AtLeastOneFunctionsFlowFromRightToLeft,
|
42 | AssocPartialOne,
|
43 | CondPair,
|
44 | CondPairTypeguard,
|
45 | Dictionary,
|
46 | Evolvable,
|
47 | Evolve,
|
48 | Evolver,
|
49 | Falsy,
|
50 | Find,
|
51 | Functor,
|
52 | InputTypesOfFns,
|
53 | KeyValuePair,
|
54 | Lens,
|
55 | Merge,
|
56 | MergeAll,
|
57 | ObjectHavingSome,
|
58 | ObjPred,
|
59 | Ord,
|
60 | Ordering,
|
61 | Path,
|
62 | Placeholder,
|
63 | Pred,
|
64 | PredTypeguard,
|
65 | Reduced,
|
66 | ReturnTypesOfFns,
|
67 | ValueOfUnion,
|
68 | Take,
|
69 | ToTupleOfArray,
|
70 | ToTupleOfFunction,
|
71 | Tuple,
|
72 | Fn,
|
73 | IfFunctionsArgumentsDoNotOverlap,
|
74 | LargestArgumentsList,
|
75 | mergeArrWithLeft,
|
76 | Prop,
|
77 | } from './tools';
|
78 |
|
79 | export * from './tools';
|
80 |
|
81 |
|
82 |
|
83 |
|
84 |
|
85 |
|
86 |
|
87 |
|
88 |
|
89 |
|
90 |
|
91 |
|
92 |
|
93 |
|
94 |
|
95 |
|
96 |
|
97 |
|
98 |
|
99 |
|
100 |
|
101 |
|
102 | export const __: Placeholder;
|
103 |
|
104 |
|
105 |
|
106 |
|
107 |
|
108 |
|
109 |
|
110 |
|
111 |
|
112 |
|
113 | export function add(a: number, b: number): number;
|
114 | export function add(a: number): (b: number) => number;
|
115 |
|
116 |
|
117 |
|
118 |
|
119 |
|
120 |
|
121 |
|
122 |
|
123 |
|
124 |
|
125 |
|
126 |
|
127 |
|
128 |
|
129 |
|
130 |
|
131 |
|
132 |
|
133 |
|
134 |
|
135 |
|
136 | export function addIndex<T>(
|
137 | fn: (f: (item: T) => void, list: readonly T[]) => T[],
|
138 | ): _.F.Curry<(a: (item: T, idx: number, list: T[]) => void, b: readonly T[]) => T[]>;
|
139 |
|
140 | export function addIndex<T>(
|
141 | fn: (f: (item: T) => boolean, list: readonly T[]) => T[],
|
142 | ): _.F.Curry<(a: (item: T, idx: number, list: T[]) => boolean, b: readonly T[]) => T[]>;
|
143 |
|
144 | export function addIndex<T, U>(
|
145 | fn: (f: (item: T) => U, list: readonly T[]) => U[],
|
146 | ): _.F.Curry<(a: (item: T, idx: number, list: T[]) => U, b: readonly T[]) => U[]>;
|
147 |
|
148 | export function addIndex<T, U>(
|
149 | fn: (f: (acc: U, item: T) => U, aci: U, list: readonly T[]) => U,
|
150 | ): _.F.Curry<(a: (acc: U, item: T, idx: number, list: T[]) => U, b: U, c: readonly T[]) => U>;
|
151 |
|
152 |
|
153 |
|
154 |
|
155 |
|
156 |
|
157 |
|
158 |
|
159 |
|
160 |
|
161 |
|
162 |
|
163 |
|
164 | export function adjust<T>(index: number, fn: (a: T) => T, list: readonly T[]): T[];
|
165 | export function adjust<T>(index: number, fn: (a: T) => T): (list: readonly T[]) => T[];
|
166 |
|
167 |
|
168 |
|
169 |
|
170 |
|
171 |
|
172 |
|
173 |
|
174 |
|
175 |
|
176 |
|
177 |
|
178 |
|
179 |
|
180 |
|
181 |
|
182 |
|
183 | export function all<T>(fn: (a: T) => boolean, list: readonly T[]): boolean;
|
184 | export function all<T>(fn: (a: T) => boolean): (list: readonly T[]) => boolean;
|
185 |
|
186 |
|
187 |
|
188 |
|
189 |
|
190 |
|
191 |
|
192 |
|
193 |
|
194 |
|
195 |
|
196 |
|
197 |
|
198 |
|
199 |
|
200 |
|
201 |
|
202 |
|
203 |
|
204 |
|
205 |
|
206 | export function allPass<T, TF1 extends T, TF2 extends T>(
|
207 | preds: [PredTypeguard<T, TF1>, PredTypeguard<T, TF2>],
|
208 | ): (a: T) => a is TF1 & TF2;
|
209 | export function allPass<T, TF1 extends T, TF2 extends T, TF3 extends T>(
|
210 | preds: [PredTypeguard<T, TF1>, PredTypeguard<T, TF2>, PredTypeguard<T, TF3>],
|
211 | ): (a: T) => a is TF1 & TF2 & TF3;
|
212 | export function allPass<T, TF1 extends T, TF2 extends T, TF3 extends T>(
|
213 | preds: [PredTypeguard<T, TF1>, PredTypeguard<T, TF2>, PredTypeguard<T, TF3>],
|
214 | ): (a: T) => a is TF1 & TF2 & TF3;
|
215 | export function allPass<T, TF1 extends T, TF2 extends T, TF3 extends T, TF4 extends T>(
|
216 | preds: [PredTypeguard<T, TF1>, PredTypeguard<T, TF2>, PredTypeguard<T, TF3>, PredTypeguard<T, TF4>],
|
217 | ): (a: T) => a is TF1 & TF2 & TF3 & TF4;
|
218 | export function allPass<T, TF1 extends T, TF2 extends T, TF3 extends T, TF4 extends T, TF5 extends T>(
|
219 | preds: [
|
220 | PredTypeguard<T, TF1>,
|
221 | PredTypeguard<T, TF2>,
|
222 | PredTypeguard<T, TF3>,
|
223 | PredTypeguard<T, TF4>,
|
224 | PredTypeguard<T, TF5>,
|
225 | ],
|
226 | ): PredTypeguard<T, TF1 & TF2 & TF3 & TF4 & TF5>;
|
227 | export function allPass<T, TF1 extends T, TF2 extends T, TF3 extends T, TF4 extends T, TF5 extends T, TF6 extends T>(
|
228 | preds: [
|
229 | PredTypeguard<T, TF1>,
|
230 | PredTypeguard<T, TF2>,
|
231 | PredTypeguard<T, TF3>,
|
232 | PredTypeguard<T, TF4>,
|
233 | PredTypeguard<T, TF5>,
|
234 | PredTypeguard<T, TF6>,
|
235 | ],
|
236 | ): PredTypeguard<T, TF1 & TF2 & TF3 & TF4 & TF5 & TF6>;
|
237 | export function allPass<F extends Pred>(preds: readonly F[]): F;
|
238 |
|
239 |
|
240 |
|
241 |
|
242 |
|
243 |
|
244 |
|
245 |
|
246 |
|
247 |
|
248 |
|
249 |
|
250 |
|
251 |
|
252 | export function always<T>(val: T): (...args: unknown[]) => T;
|
253 |
|
254 |
|
255 |
|
256 |
|
257 |
|
258 |
|
259 |
|
260 |
|
261 |
|
262 |
|
263 |
|
264 |
|
265 |
|
266 |
|
267 |
|
268 |
|
269 | export function and<T, U>(a: T, b: U): T | U;
|
270 | export function and<T>(a: T): <U>(b: U) => T | U;
|
271 |
|
272 |
|
273 |
|
274 |
|
275 |
|
276 |
|
277 |
|
278 |
|
279 |
|
280 |
|
281 |
|
282 |
|
283 |
|
284 |
|
285 |
|
286 |
|
287 |
|
288 |
|
289 |
|
290 |
|
291 |
|
292 |
|
293 |
|
294 |
|
295 |
|
296 | export function andThen<A, B>(onSuccess: (a: A) => B | Promise<B>, promise: Promise<A>): Promise<B>;
|
297 | export function andThen<A, B>(onSuccess: (a: A) => B | Promise<B>): (promise: Promise<A>) => Promise<B>;
|
298 |
|
299 |
|
300 |
|
301 |
|
302 |
|
303 |
|
304 |
|
305 |
|
306 |
|
307 |
|
308 |
|
309 |
|
310 |
|
311 |
|
312 |
|
313 |
|
314 |
|
315 |
|
316 | export function any<T>(fn: (a: T) => boolean, list: readonly T[]): boolean;
|
317 | export function any<T>(fn: (a: T) => boolean): (list: readonly T[]) => boolean;
|
318 |
|
319 |
|
320 |
|
321 |
|
322 |
|
323 |
|
324 |
|
325 |
|
326 |
|
327 |
|
328 |
|
329 |
|
330 |
|
331 |
|
332 |
|
333 |
|
334 |
|
335 |
|
336 |
|
337 |
|
338 |
|
339 |
|
340 |
|
341 |
|
342 | export function anyPass<T, TF1 extends T, TF2 extends T>(
|
343 | preds: [PredTypeguard<T, TF1>, PredTypeguard<T, TF2>],
|
344 | ): (a: T) => a is TF1 | TF2;
|
345 | export function anyPass<T, TF1 extends T, TF2 extends T, TF3 extends T>(
|
346 | preds: [PredTypeguard<T, TF1>, PredTypeguard<T, TF2>, PredTypeguard<T, TF3>],
|
347 | ): (a: T) => a is TF1 | TF2 | TF3;
|
348 | export function anyPass<T, TF1 extends T, TF2 extends T, TF3 extends T>(
|
349 | preds: [PredTypeguard<T, TF1>, PredTypeguard<T, TF2>, PredTypeguard<T, TF3>],
|
350 | ): (a: T) => a is TF1 | TF2 | TF3;
|
351 | export function anyPass<T, TF1 extends T, TF2 extends T, TF3 extends T, TF4 extends T>(
|
352 | preds: [PredTypeguard<T, TF1>, PredTypeguard<T, TF2>, PredTypeguard<T, TF3>, PredTypeguard<T, TF4>],
|
353 | ): (a: T) => a is TF1 | TF2 | TF3 | TF4;
|
354 | export function anyPass<T, TF1 extends T, TF2 extends T, TF3 extends T, TF4 extends T, TF5 extends T>(
|
355 | preds: [
|
356 | PredTypeguard<T, TF1>,
|
357 | PredTypeguard<T, TF2>,
|
358 | PredTypeguard<T, TF3>,
|
359 | PredTypeguard<T, TF4>,
|
360 | PredTypeguard<T, TF5>,
|
361 | ],
|
362 | ): PredTypeguard<T, TF1 | TF2 | TF3 | TF4 | TF5>;
|
363 | export function anyPass<T, TF1 extends T, TF2 extends T, TF3 extends T, TF4 extends T, TF5 extends T, TF6 extends T>(
|
364 | preds: [
|
365 | PredTypeguard<T, TF1>,
|
366 | PredTypeguard<T, TF2>,
|
367 | PredTypeguard<T, TF3>,
|
368 | PredTypeguard<T, TF4>,
|
369 | PredTypeguard<T, TF5>,
|
370 | PredTypeguard<T, TF6>,
|
371 | ],
|
372 | ): PredTypeguard<T, TF1 | TF2 | TF3 | TF4 | TF5 | TF6>;
|
373 | export function anyPass<F extends Pred>(preds: readonly F[]): F;
|
374 |
|
375 |
|
376 |
|
377 |
|
378 |
|
379 |
|
380 |
|
381 |
|
382 |
|
383 |
|
384 |
|
385 |
|
386 |
|
387 |
|
388 |
|
389 |
|
390 |
|
391 | export function ap<T, U>(fns: ReadonlyArray<(a: T) => U>, vs: readonly T[]): U[];
|
392 | export function ap<T, U>(fns: ReadonlyArray<(a: T) => U>): (vs: readonly T[]) => U[];
|
393 | export function ap<R, A, B>(fn: (r: R, a: A) => B, fn1: (r: R) => A): (r: R) => B;
|
394 |
|
395 |
|
396 |
|
397 |
|
398 |
|
399 |
|
400 |
|
401 |
|
402 |
|
403 |
|
404 |
|
405 |
|
406 |
|
407 |
|
408 |
|
409 |
|
410 | export function aperture<N extends number, T>(n: N, list: readonly T[]): Array<Tuple<T, N>> | [];
|
411 | export function aperture<N extends number>(n: N): <T>(list: readonly T[]) => Array<Tuple<T, N>> | [];
|
412 |
|
413 |
|
414 |
|
415 |
|
416 |
|
417 |
|
418 |
|
419 |
|
420 |
|
421 |
|
422 |
|
423 |
|
424 |
|
425 | export function append<T>(el: T, list: readonly T[]): T[];
|
426 | export function append<T>(el: T): (list: readonly T[]) => T[];
|
427 |
|
428 |
|
429 |
|
430 |
|
431 |
|
432 |
|
433 |
|
434 |
|
435 | export function apply<F extends AnyFunction>(fn: F, args: Parameters<F>): ReturnType<F>;
|
436 | export function apply<F extends AnyFunction>(fn: F): (args: Parameters<F>) => ReturnType<F>;
|
437 |
|
438 |
|
439 |
|
440 |
|
441 |
|
442 |
|
443 |
|
444 |
|
445 |
|
446 |
|
447 |
|
448 |
|
449 |
|
450 |
|
451 |
|
452 |
|
453 |
|
454 | export function applySpec<Obj extends Record<string, AnyFunction>>(
|
455 | obj: Obj,
|
456 | ): (...args: Parameters<Obj[keyof Obj]>) => { [Key in keyof Obj]: ReturnType<Obj[Key]> };
|
457 | export function applySpec<T>(obj: any): (...args: unknown[]) => T;
|
458 |
|
459 |
|
460 |
|
461 |
|
462 |
|
463 |
|
464 |
|
465 |
|
466 |
|
467 |
|
468 |
|
469 |
|
470 |
|
471 | export function applyTo<T, U>(el: T, fn: (t: T) => U): U;
|
472 | export function applyTo<T>(el: T): <U>(fn: (t: T) => U) => U;
|
473 |
|
474 |
|
475 |
|
476 |
|
477 |
|
478 |
|
479 |
|
480 |
|
481 |
|
482 |
|
483 |
|
484 |
|
485 |
|
486 |
|
487 |
|
488 |
|
489 |
|
490 |
|
491 | export function ascend<T>(fn: (obj: T) => Ord, a: T, b: T): Ordering;
|
492 | export function ascend<T>(fn: (obj: T) => Ord): (a: T, b: T) => Ordering;
|
493 |
|
494 |
|
495 |
|
496 |
|
497 |
|
498 |
|
499 |
|
500 |
|
501 |
|
502 |
|
503 |
|
504 |
|
505 |
|
506 |
|
507 | export function assoc<T, U>(__: Placeholder, val: T, obj: U): <K extends string>(prop: K) => K extends keyof U ? T extends U[K] ? U : Record<K, T> & Omit<U, K> : Record<K, T> & Omit<U, K>;
|
508 | export function assoc<U, K extends keyof U>(prop: K, __: Placeholder, obj: U): <T>(val: T) => T extends U[K] ? U : Record<K, T> & Omit<U, K>;
|
509 | export function assoc<U, K extends string>(prop: K, __: Placeholder, obj: U): <T>(val: T) => Record<K, T> & Omit<U, K>;
|
510 | export function assoc<K extends keyof U, U>(prop: K, val: U[K], obj: U): U;
|
511 | export function assoc<T, U, K extends string>(prop: K, val: T, obj: U): Record<K, T> & Omit<U, K>;
|
512 | export function assoc<T, K extends string>(prop: K, val: T): <U>(obj: U) => Record<K, T> & Omit<U, K>;
|
513 | export function assoc<K extends string>(prop: K): AssocPartialOne<K>;
|
514 |
|
515 |
|
516 |
|
517 |
|
518 |
|
519 |
|
520 |
|
521 |
|
522 |
|
523 |
|
524 |
|
525 |
|
526 |
|
527 |
|
528 |
|
529 |
|
530 |
|
531 |
|
532 |
|
533 | export function assocPath<T, U>(__: Placeholder, val: T, obj: U): (path: Path) => U;
|
534 | export function assocPath<T, U>(path: Path, __: Placeholder, obj: U): (val: T) => U;
|
535 | export function assocPath<T, U>(path: Path, val: T, obj: U): U;
|
536 | export function assocPath<T, U>(path: Path, val: T): (obj: U) => U;
|
537 | export function assocPath<T, U>(path: Path): _.F.Curry<(a: T, b: U) => U>;
|
538 |
|
539 |
|
540 |
|
541 |
|
542 |
|
543 |
|
544 |
|
545 |
|
546 |
|
547 |
|
548 |
|
549 |
|
550 |
|
551 |
|
552 |
|
553 |
|
554 |
|
555 |
|
556 |
|
557 |
|
558 |
|
559 |
|
560 | export function binary<T extends AnyFunction>(fn: T): (...arg: _.T.Take<Parameters<T>, '2'>) => ReturnType<T>;
|
561 |
|
562 |
|
563 |
|
564 |
|
565 |
|
566 |
|
567 |
|
568 |
|
569 |
|
570 |
|
571 |
|
572 |
|
573 |
|
574 | export function bind<F extends AnyFunction, T>(fn: F, thisObj: T): (...args: Parameters<F>) => ReturnType<F>;
|
575 | export function bind<F extends AnyFunction, T>(fn: F): (thisObj: T) => (...args: Parameters<F>) => ReturnType<F>;
|
576 |
|
577 |
|
578 |
|
579 |
|
580 |
|
581 |
|
582 |
|
583 |
|
584 |
|
585 |
|
586 |
|
587 |
|
588 |
|
589 |
|
590 |
|
591 |
|
592 |
|
593 |
|
594 |
|
595 |
|
596 |
|
597 |
|
598 | export function both<T, TF1 extends T, TF2 extends T>(
|
599 | pred1: PredTypeguard<T, TF1>,
|
600 | pred2: PredTypeguard<T, TF2>,
|
601 | ): (a: T) => a is TF1 & TF2;
|
602 | export function both<T extends Pred>(pred1: T, pred2: T): T;
|
603 | export function both<T extends Pred>(pred1: T): (pred2: T) => T;
|
604 |
|
605 |
|
606 |
|
607 |
|
608 |
|
609 |
|
610 |
|
611 |
|
612 |
|
613 |
|
614 |
|
615 |
|
616 |
|
617 |
|
618 |
|
619 |
|
620 |
|
621 |
|
622 |
|
623 |
|
624 |
|
625 | export function call<T extends AnyFunction>(fn: T, ...args: Parameters<T>): ReturnType<T>;
|
626 |
|
627 |
|
628 |
|
629 |
|
630 |
|
631 |
|
632 |
|
633 |
|
634 |
|
635 |
|
636 |
|
637 |
|
638 |
|
639 |
|
640 |
|
641 |
|
642 |
|
643 |
|
644 |
|
645 |
|
646 | export function chain<A, B, T = never>(fn: (n: A) => readonly B[], list: readonly A[]): B[];
|
647 | export function chain<A, B, T = never>(fn: (n: A) => readonly B[]): (list: readonly A[]) => B[];
|
648 |
|
649 | export function chain<A, Ma extends { chain: (fn: (a: A) => Mb) => Mb }, Mb>(fn: (a: A) => Mb, monad: Ma): Mb;
|
650 | export function chain<A, Ma extends { chain: (fn: (a: A) => Mb) => Mb }, Mb>(fn: (a: A) => Mb): (monad: Ma) => Mb;
|
651 |
|
652 | export function chain<A, B, R>(aToMb: (a: A, r: R) => B, Ma: (r: R) => A): (r: R) => B;
|
653 | export function chain<A, B, R>(aToMb: (a: A, r: R) => B): (Ma: (r: R) => A) => (r: R) => B;
|
654 |
|
655 |
|
656 |
|
657 |
|
658 |
|
659 |
|
660 |
|
661 |
|
662 |
|
663 |
|
664 |
|
665 |
|
666 | export function clamp<T>(min: T, max: T, value: T): T;
|
667 | export function clamp<T>(min: T, max: T): (value: T) => T;
|
668 | export function clamp<T>(min: T): (max: T, value: T) => T;
|
669 | export function clamp<T>(min: T): (max: T) => (value: T) => T;
|
670 |
|
671 |
|
672 |
|
673 |
|
674 |
|
675 |
|
676 |
|
677 |
|
678 |
|
679 |
|
680 |
|
681 |
|
682 |
|
683 |
|
684 |
|
685 |
|
686 |
|
687 |
|
688 |
|
689 |
|
690 | export function clone<T>(value: T): T;
|
691 | export function clone<T>(value: readonly T[]): T[];
|
692 |
|
693 |
|
694 |
|
695 |
|
696 |
|
697 |
|
698 |
|
699 |
|
700 |
|
701 |
|
702 |
|
703 |
|
704 |
|
705 |
|
706 |
|
707 |
|
708 |
|
709 |
|
710 |
|
711 |
|
712 |
|
713 |
|
714 |
|
715 |
|
716 |
|
717 | export function collectBy<T, K extends PropertyKey>(keyFn: (value: T) => K, list: readonly T[]): T[][];
|
718 | export function collectBy<T, K extends PropertyKey>(keyFn: (value: T) => K): (list: readonly T[]) => T[][];
|
719 |
|
720 |
|
721 |
|
722 |
|
723 |
|
724 |
|
725 |
|
726 |
|
727 |
|
728 |
|
729 |
|
730 |
|
731 |
|
732 |
|
733 |
|
734 |
|
735 |
|
736 |
|
737 | export function comparator<T>(pred: (a: T, b: T) => boolean): (x: T, y: T) => Ordering;
|
738 |
|
739 |
|
740 |
|
741 |
|
742 |
|
743 |
|
744 |
|
745 |
|
746 |
|
747 |
|
748 |
|
749 |
|
750 |
|
751 |
|
752 |
|
753 |
|
754 |
|
755 |
|
756 |
|
757 |
|
758 | export function complement<T, TFiltered extends T>(
|
759 | pred: (value: T) => value is TFiltered,
|
760 | ): (value: T) => value is Exclude<T, TFiltered>;
|
761 | export function complement<TArgs extends any[]>(pred: (...args: TArgs) => unknown): (...args: TArgs) => boolean;
|
762 |
|
763 |
|
764 |
|
765 |
|
766 |
|
767 |
|
768 |
|
769 |
|
770 |
|
771 |
|
772 |
|
773 |
|
774 |
|
775 |
|
776 |
|
777 |
|
778 |
|
779 |
|
780 |
|
781 | export function compose<TArgs extends any[], R1, R2, R3, R4, R5, R6, R7, TResult>(
|
782 | ...func: [
|
783 | fnLast: (a: any) => TResult,
|
784 | ...func: Array<(a: any) => any>,
|
785 | f7: (a: R6) => R7,
|
786 | f6: (a: R5) => R6,
|
787 | f5: (a: R4) => R5,
|
788 | f4: (a: R3) => R4,
|
789 | f3: (a: R2) => R3,
|
790 | f2: (a: R1) => R2,
|
791 | f1: (...args: TArgs) => R1,
|
792 | ]
|
793 | ): (...args: TArgs) => TResult;
|
794 | export function compose<TArgs extends any[], R1, R2, R3, R4, R5, R6, R7>(
|
795 | f7: (a: R6) => R7,
|
796 | f6: (a: R5) => R6,
|
797 | f5: (a: R4) => R5,
|
798 | f4: (a: R3) => R4,
|
799 | f3: (a: R2) => R3,
|
800 | f2: (a: R1) => R2,
|
801 | f1: (...args: TArgs) => R1,
|
802 | ): (...args: TArgs) => R7;
|
803 | export function compose<TArgs extends any[], R1, R2, R3, R4, R5, R6, R7>(
|
804 | f7: (a: R6) => R7,
|
805 | f6: (a: R5) => R6,
|
806 | f5: (a: R4) => R5,
|
807 | f4: (a: R3) => R4,
|
808 | f3: (a: R2) => R3,
|
809 | f2: (a: R1) => R2,
|
810 | f1: (...args: TArgs) => R1,
|
811 | ): (...args: TArgs) => R7;
|
812 | export function compose<TArgs extends any[], R1, R2, R3, R4, R5, R6>(
|
813 | f6: (a: R5) => R6,
|
814 | f5: (a: R4) => R5,
|
815 | f4: (a: R3) => R4,
|
816 | f3: (a: R2) => R3,
|
817 | f2: (a: R1) => R2,
|
818 | f1: (...args: TArgs) => R1,
|
819 | ): (...args: TArgs) => R6;
|
820 | export function compose<TArgs extends any[], R1, R2, R3, R4, R5>(
|
821 | f5: (a: R4) => R5,
|
822 | f4: (a: R3) => R4,
|
823 | f3: (a: R2) => R3,
|
824 | f2: (a: R1) => R2,
|
825 | f1: (...args: TArgs) => R1,
|
826 | ): (...args: TArgs) => R5;
|
827 | export function compose<TArgs extends any[], R1, R2, R3, R4>(
|
828 | f4: (a: R3) => R4,
|
829 | f3: (a: R2) => R3,
|
830 | f2: (a: R1) => R2,
|
831 | f1: (...args: TArgs) => R1,
|
832 | ): (...args: TArgs) => R4;
|
833 | export function compose<TArgs extends any[], R1, R2, R3>(
|
834 | f3: (a: R2) => R3,
|
835 | f2: (a: R1) => R2,
|
836 | f1: (...args: TArgs) => R1,
|
837 | ): (...args: TArgs) => R3;
|
838 | export function compose<TArgs extends any[], R1, R2>(
|
839 | f2: (a: R1) => R2,
|
840 | f1: (...args: TArgs) => R1,
|
841 | ): (...args: TArgs) => R2;
|
842 | export function compose<TArgs extends any[], R1>(f1: (...args: TArgs) => R1): (...args: TArgs) => R1;
|
843 |
|
844 |
|
845 |
|
846 |
|
847 |
|
848 |
|
849 |
|
850 |
|
851 |
|
852 |
|
853 |
|
854 |
|
855 |
|
856 |
|
857 |
|
858 |
|
859 |
|
860 | export function composeWith<TArgs extends any[], TResult>(
|
861 | transformer: (fn: AnyFunction, intermediatResult: any) => any,
|
862 | fns: AtLeastOneFunctionsFlowFromRightToLeft<TArgs, TResult>,
|
863 | ): (...args: TArgs) => TResult;
|
864 | export function composeWith(
|
865 | transformer: (fn: AnyFunction, intermediatResult: any) => any,
|
866 | ): <TArgs extends any[], TResult>(
|
867 | fns: AtLeastOneFunctionsFlowFromRightToLeft<TArgs, TResult>,
|
868 | ) => (...args: TArgs) => TResult;
|
869 |
|
870 |
|
871 |
|
872 |
|
873 |
|
874 |
|
875 |
|
876 |
|
877 |
|
878 |
|
879 |
|
880 |
|
881 |
|
882 |
|
883 |
|
884 |
|
885 |
|
886 |
|
887 | export function concat(
|
888 | placeholder: Placeholder,
|
889 | ): (<L1 extends any[], L2 extends any[]>(list1: L1, list2: L2) => [...L1, ...L2]) &
|
890 | (<S1 extends string, S2 extends string>(s1: S1, s2: S2) => `${S1}${S2}`);
|
891 | export function concat<L2 extends any[]>(
|
892 | placeholder: Placeholder,
|
893 | list2: L2,
|
894 | ): <L1 extends any[]>(list1: L1) => [...L1, ...L2];
|
895 | export function concat<S2 extends string>(
|
896 | placeholder: Placeholder,
|
897 | s2: S2,
|
898 | ): <S1 extends string>(s1: S1) => `${S1}${S2}`;
|
899 | export function concat<L1 extends any[]>(list1: L1): <L2 extends any[]>(list2: L2) => [...L1, ...L2];
|
900 | export function concat<S1 extends string>(s1: S1): <S2 extends string>(s2: S2) => `${S1}${S2}`;
|
901 | export function concat<L1 extends any[], L2 extends any[]>(list1: L1, list2: L2): [...L1, ...L2];
|
902 | export function concat<S1 extends string, S2 extends string>(s1: S1, s2: S2): `${S1}${S2}`;
|
903 | export function concat(s1: string, s2: string): string;
|
904 | export function concat(s1: string): (s2: string) => string;
|
905 |
|
906 | /**
|
907 | * Returns a function, `fn`, which encapsulates `if/else, if/else, ...` logic.
|
908 | * `R.cond` takes a list of [predicate, transformer] pairs. All of the arguments
|
909 | * to `fn` are applied to each of the predicates in turn until one returns a
|
910 | * "truthy" value, at which point `fn` returns the result of applying its
|
911 | * arguments to the corresponding transformer. If none of the predicates
|
912 | * matches, `fn` returns undefined.
|
913 | *
|
914 | * @note This is not a direct substitute for a `switch` statement.
|
915 | * Remember that both elements of every pair passed to `cond` are *functions*,
|
916 | * and `cond` returns a function.
|
917 | *
|
918 | * @note When using this function with a typeguard as predicate,
|
919 | * **all** predicates in all pairs must be typeguards.
|
920 | *
|
921 | * See also {@link ifElse}, {@link unless}, {@link when}.
|
922 | *
|
923 | * @example
|
924 | * ```typescript
|
925 | * const fn = R.cond([
|
926 | * [R.equals(0), R.always('water freezes at 0°C')],
|
927 | * [R.equals(100), R.always('water boils at 100°C')],
|
928 | * [R.T, temp => 'nothing special happens at ' + temp + '°C']
|
929 | * ]);
|
930 | * fn(0);
|
931 | * fn(50);
|
932 | * fn(100);
|
933 | * ```
|
934 | */
|
935 | export function cond<T, TF1 extends T, R>(pairs: [CondPairTypeguard<T, TF1, R>]): (value: T) => R;
|
936 | export function cond<T, TF1 extends T, TF2 extends T, R>(
|
937 | pairs: [CondPairTypeguard<T, TF1, R>, CondPairTypeguard<T, TF2, R>],
|
938 | ): (value: T) => R;
|
939 | export function cond<T, TF1 extends T, TF2 extends T, TF3 extends T, R>(
|
940 | pairs: [CondPairTypeguard<T, TF1, R>, CondPairTypeguard<T, TF2, R>, CondPairTypeguard<T, TF3, R>],
|
941 | ): (value: T) => R;
|
942 | export function cond<T, TF1 extends T, TF2 extends T, TF3 extends T, TF4 extends T, R>(
|
943 | pairs: [
|
944 | CondPairTypeguard<T, TF1, R>,
|
945 | CondPairTypeguard<T, TF2, R>,
|
946 | CondPairTypeguard<T, TF3, R>,
|
947 | CondPairTypeguard<T, TF4, R>,
|
948 | ],
|
949 | ): (value: T) => R;
|
950 | export function cond<T, TF1 extends T, TF2 extends T, TF3 extends T, TF4 extends T, TF5 extends T, R>(
|
951 | pairs: [
|
952 | CondPairTypeguard<T, TF1, R>,
|
953 | CondPairTypeguard<T, TF2, R>,
|
954 | CondPairTypeguard<T, TF3, R>,
|
955 | CondPairTypeguard<T, TF4, R>,
|
956 | CondPairTypeguard<T, TF5, R>,
|
957 | ],
|
958 | ): (value: T) => R;
|
959 | export function cond<T, TF1 extends T, TF2 extends T, TF3 extends T, TF4 extends T, TF5 extends T, TF6 extends T, R>(
|
960 | pairs: [
|
961 | CondPairTypeguard<T, TF1, R>,
|
962 | CondPairTypeguard<T, TF2, R>,
|
963 | CondPairTypeguard<T, TF3, R>,
|
964 | CondPairTypeguard<T, TF4, R>,
|
965 | CondPairTypeguard<T, TF5, R>,
|
966 | CondPairTypeguard<T, TF6, R>,
|
967 | ],
|
968 | ): (value: T) => R;
|
969 | export function cond<
|
970 | T,
|
971 | TF1 extends T,
|
972 | TF2 extends T,
|
973 | TF3 extends T,
|
974 | TF4 extends T,
|
975 | TF5 extends T,
|
976 | TF6 extends T,
|
977 | TF7 extends T,
|
978 | R,
|
979 | >(
|
980 | pairs: [
|
981 | CondPairTypeguard<T, TF1, R>,
|
982 | CondPairTypeguard<T, TF2, R>,
|
983 | CondPairTypeguard<T, TF3, R>,
|
984 | CondPairTypeguard<T, TF4, R>,
|
985 | CondPairTypeguard<T, TF5, R>,
|
986 | CondPairTypeguard<T, TF6, R>,
|
987 | CondPairTypeguard<T, TF7, R>,
|
988 | ],
|
989 | ): (value: T) => R;
|
990 | export function cond<
|
991 | T,
|
992 | TF1 extends T,
|
993 | TF2 extends T,
|
994 | TF3 extends T,
|
995 | TF4 extends T,
|
996 | TF5 extends T,
|
997 | TF6 extends T,
|
998 | TF7 extends T,
|
999 | TF8 extends T,
|
1000 | R,
|
1001 | >(
|
1002 | pairs: [
|
1003 | CondPairTypeguard<T, TF1, R>,
|
1004 | CondPairTypeguard<T, TF2, R>,
|
1005 | CondPairTypeguard<T, TF3, R>,
|
1006 | CondPairTypeguard<T, TF4, R>,
|
1007 | CondPairTypeguard<T, TF5, R>,
|
1008 | CondPairTypeguard<T, TF6, R>,
|
1009 | CondPairTypeguard<T, TF7, R>,
|
1010 | CondPairTypeguard<T, TF8, R>,
|
1011 | ],
|
1012 | ): (value: T) => R;
|
1013 | export function cond<
|
1014 | T,
|
1015 | TF1 extends T,
|
1016 | TF2 extends T,
|
1017 | TF3 extends T,
|
1018 | TF4 extends T,
|
1019 | TF5 extends T,
|
1020 | TF6 extends T,
|
1021 | TF7 extends T,
|
1022 | TF8 extends T,
|
1023 | TF9 extends T,
|
1024 | R,
|
1025 | >(
|
1026 | pairs: [
|
1027 | CondPairTypeguard<T, TF1, R>,
|
1028 | CondPairTypeguard<T, TF2, R>,
|
1029 | CondPairTypeguard<T, TF3, R>,
|
1030 | CondPairTypeguard<T, TF4, R>,
|
1031 | CondPairTypeguard<T, TF5, R>,
|
1032 | CondPairTypeguard<T, TF6, R>,
|
1033 | CondPairTypeguard<T, TF7, R>,
|
1034 | CondPairTypeguard<T, TF8, R>,
|
1035 | CondPairTypeguard<T, TF9, R>,
|
1036 | ],
|
1037 | ): (value: T) => R;
|
1038 | export function cond<
|
1039 | T,
|
1040 | TF1 extends T,
|
1041 | TF2 extends T,
|
1042 | TF3 extends T,
|
1043 | TF4 extends T,
|
1044 | TF5 extends T,
|
1045 | TF6 extends T,
|
1046 | TF7 extends T,
|
1047 | TF8 extends T,
|
1048 | TF9 extends T,
|
1049 | TF10 extends T,
|
1050 | R,
|
1051 | >(
|
1052 | pairs: [
|
1053 | CondPairTypeguard<T, TF1, R>,
|
1054 | CondPairTypeguard<T, TF2, R>,
|
1055 | CondPairTypeguard<T, TF3, R>,
|
1056 | CondPairTypeguard<T, TF4, R>,
|
1057 | CondPairTypeguard<T, TF5, R>,
|
1058 | CondPairTypeguard<T, TF6, R>,
|
1059 | CondPairTypeguard<T, TF7, R>,
|
1060 | CondPairTypeguard<T, TF8, R>,
|
1061 | CondPairTypeguard<T, TF9, R>,
|
1062 | CondPairTypeguard<T, TF10, R>,
|
1063 | ],
|
1064 | ): (value: T) => R;
|
1065 | export function cond<T extends any[], R>(pairs: ReadonlyArray<CondPair<T, R>>): (...args: T) => R;
|
1066 |
|
1067 | /**
|
1068 | * Wraps a constructor function inside a curried function that can be called with the same arguments and returns the same type.
|
1069 | *
|
1070 | * See also {@link invoker}.
|
1071 | *
|
1072 | * @example
|
1073 | * ```typescript
|
1074 | *
|
1075 | * class Animal {
|
1076 | * constructor(public kind: string) {}
|
1077 | *
|
1078 | * sighting() {
|
1079 | * return "It's a " + this.kind + "!";
|
1080 | * }
|
1081 | * }
|
1082 | *
|
1083 | * const AnimalConstructor = R.construct(Animal)
|
1084 | *
|
1085 | *
|
1086 | * AnimalConstructor('Pig');
|
1087 | *
|
1088 | * const animalTypes = ["Lion", "Tiger", "Bear"];
|
1089 | * const animalSighting = R.invoker(0, 'sighting');
|
1090 | * const sightNewAnimal = R.compose(animalSighting, AnimalConstructor);
|
1091 | * R.map(sightNewAnimal, animalTypes);
|
1092 | * ```
|
1093 | */
|
1094 | export function construct<A extends any[], T>(
|
1095 | constructor: { new (...args: A): T } | ((...args: A) => T),
|
1096 | ): _.F.Curry<(...args: A) => T>;
|
1097 |
|
1098 | // NOTE: Example doesn't work with this typing
|
1099 | /**
|
1100 | * Wraps a constructor function inside a curried function that can be called with the same arguments and returns the same type.
|
1101 | * The arity of the function returned is specified to allow using variadic constructor functions.
|
1102 | */
|
1103 | export function constructN<A extends any[], T, N extends number>(
|
1104 | n: N,
|
1105 | constructor: { new (...args: A): T } | ((...args: A) => T),
|
1106 | ): _.F.Curry<(...args: mergeArrWithLeft<Tuple<any, N>, A>) => T>;
|
1107 |
|
1108 | // NOTE: Example doesn't work with this typing
|
1109 | /**
|
1110 | * Accepts a converging function and a list of branching functions and returns a new function.
|
1111 | * When invoked, this new function is applied to some arguments,
|
1112 | * each branching function is applied to those same arguments.
|
1113 | * The results of each branching function are passed as arguments to the converging function
|
1114 | * to produce the return value.
|
1115 | *
|
1116 | * See also {@link useWith}.
|
1117 | */
|
1118 | export function converge<
|
1119 | TResult,
|
1120 | FunctionsList extends ReadonlyArray<Fn> &
|
1121 | IfFunctionsArgumentsDoNotOverlap<_Fns, 'Functions arguments types must overlap'>,
|
1122 | _Fns extends ReadonlyArray<Fn> = FunctionsList,
|
1123 | >(
|
1124 | converging: (...args: ReturnTypesOfFns<FunctionsList>) => TResult,
|
1125 | branches: FunctionsList,
|
1126 | ): _.F.Curry<(...args: LargestArgumentsList<FunctionsList>) => TResult>;
|
1127 | export function converge<
|
1128 | CArgs extends ReadonlyArray<any>,
|
1129 | TResult,
|
1130 | FunctionsList extends readonly [
|
1131 | ...{
|
1132 | [Index in keyof CArgs]: (...args: ReadonlyArray<any>) => CArgs[Index];
|
1133 | },
|
1134 | ] &
|
1135 | IfFunctionsArgumentsDoNotOverlap<_Fns, 'Functions arguments types must overlap'>,
|
1136 | _Fns extends ReadonlyArray<Fn> = FunctionsList,
|
1137 | >(
|
1138 | converging: (...args: CArgs) => TResult,
|
1139 | branches: FunctionsList,
|
1140 | ): _.F.Curry<(...args: LargestArgumentsList<FunctionsList>) => TResult>;
|
1141 |
|
1142 | /**
|
1143 | * Returns the number of items in a given `list` matching the predicate `f`.
|
1144 | *
|
1145 | * @example
|
1146 | * ```typescript
|
1147 | * const even = (x: number) => x % 2 == 0;
|
1148 | *
|
1149 | * R.count(even, [1, 2, 3, 4, 5]);
|
1150 | * R.map(R.count(even), [[1, 1, 1], [2, 3, 4, 5], [6]]);
|
1151 | * ```
|
1152 | */
|
1153 | export function count<T>(fn: (a: T) => boolean, list: readonly T[]): number;
|
1154 | export function count<T>(fn: (a: T) => boolean): (list: readonly T[]) => number;
|
1155 |
|
1156 | /**
|
1157 | * Counts the elements of a list according to how many match each value of a key generated by the supplied function.
|
1158 | * Returns an object mapping the keys produced by `fn` to the number of occurrences in the list.
|
1159 | * Note that all keys are coerced to strings because of how JavaScript objects work.
|
1160 | *
|
1161 | * Acts as a transducer if a transformer is given in list position.
|
1162 | *
|
1163 | * See also {@link transduce}.
|
1164 | *
|
1165 | * @example
|
1166 | * ```typescript
|
1167 | * const numbers = [1.0, 1.1, 1.2, 2.0, 3.0, 2.2];
|
1168 | * R.countBy(Math.floor)(numbers);
|
1169 | *
|
1170 | * const letters = ['a', 'b', 'A', 'a', 'B', 'c'];
|
1171 | * R.countBy(R.toLower)(letters);
|
1172 | * ```
|
1173 | */
|
1174 | export function countBy<T>(fn: (a: T) => string | number, list: readonly T[]): { [index: string]: number };
|
1175 | export function countBy<T>(fn: (a: T) => string | number): (list: readonly T[]) => { [index: string]: number };
|
1176 |
|
1177 | /**
|
1178 | * Returns a curried equivalent of the provided function.
|
1179 | *
|
1180 | * See also {@link curryN}, {@link partial}.
|
1181 | *
|
1182 | * The curried function has two unusual capabilities.
|
1183 | *
|
1184 | * First, its arguments needn't be provided one at a time.
|
1185 | * If `f` is a ternary function and `g` is `R.curry(f)`, the following are equivalent:
|
1186 | * - `g(1)(2)(3)`
|
1187 | * - `g(1)(2, 3)`
|
1188 | * - `g(1, 2)(3)`
|
1189 | * - `g(1, 2, 3)`
|
1190 | *
|
1191 | * Secondly, the special placeholder value `R.__` may be used to specify "gaps",
|
1192 | * allowing partial application of any combination of arguments,
|
1193 | * regardless of their positions.
|
1194 | * If `g` is as above and `_` is `R.__`, the following are equivalent:
|
1195 | * - `g(1, 2, 3)`
|
1196 | * - `g(_, 2, 3)(1)`
|
1197 | * - `g(_, _, 3)(1)(2)`
|
1198 | * - `g(_, _, 3)(1, 2)`
|
1199 | * - `g(_, 2)(1)(3)`
|
1200 | * - `g(_, 2)(1, 3)`
|
1201 | * - `g(_, 2)(_, 3)(1)`
|
1202 | *
|
1203 | * @example
|
1204 | * ```typescript
|
1205 | * const addFourNumbers = (a: number, b: number, c: number, d: number) => a + b + c + d;
|
1206 | *
|
1207 | * const curriedAddFourNumbers = R.curry(addFourNumbers);
|
1208 | * const f = curriedAddFourNumbers(1, 2);
|
1209 | * const g = f(3);
|
1210 | * g(4);
|
1211 | * ```
|
1212 | */
|
1213 | export function curry<F extends AnyFunction>(f: F): _.F.Curry<F>;
|
1214 |
|
1215 | /**
|
1216 | * Returns a curried equivalent of the provided function, with the specified arity.
|
1217 | *
|
1218 | * See also {@link curry}.
|
1219 | *
|
1220 | * The curried function has two unusual capabilities.
|
1221 | *
|
1222 | * First, its arguments needn't be provided one at a time.
|
1223 | * If `f` is a ternary function and `g` is `R.curry(f)`, the following are equivalent:
|
1224 | * - `g(1)(2)(3)`
|
1225 | * - `g(1)(2, 3)`
|
1226 | * - `g(1, 2)(3)`
|
1227 | * - `g(1, 2, 3)`
|
1228 | *
|
1229 | * Secondly, the special placeholder value `R.__` may be used to specify "gaps",
|
1230 | * allowing partial application of any combination of arguments,
|
1231 | * regardless of their positions.
|
1232 | * If `g` is as above and `_` is `R.__`, the following are equivalent:
|
1233 | * - `g(1, 2, 3)`
|
1234 | * - `g(_, 2, 3)(1)`
|
1235 | * - `g(_, _, 3)(1)(2)`
|
1236 | * - `g(_, _, 3)(1, 2)`
|
1237 | * - `g(_, 2)(1)(3)`
|
1238 | * - `g(_, 2)(1, 3)`
|
1239 | * - `g(_, 2)(_, 3)(1)`
|
1240 | *
|
1241 | * @example
|
1242 | * ```typescript
|
1243 | * const sumArgs = (...args: number[]) => R.sum(args);
|
1244 | *
|
1245 | * const curriedAddFourNumbers = R.curryN(4, sumArgs);
|
1246 | * const f = curriedAddFourNumbers(1, 2);
|
1247 | * const g = f(3);
|
1248 | * g(4);
|
1249 | * ```
|
1250 | */
|
1251 | export function curryN<N extends number, F extends AnyFunction>(
|
1252 | length: N,
|
1253 | fn: F,
|
1254 | ): _.F.Curry<(...args: _.T.Take<Parameters<F>, _.N.NumberOf<N>>) => ReturnType<F>>;
|
1255 | export function curryN<N extends number>(
|
1256 | length: N,
|
1257 | ): <F extends AnyFunction>(fn: F) => _.F.Curry<(...args: _.T.Take<Parameters<F>, _.N.NumberOf<N>>) => ReturnType<F>>;
|
1258 |
|
1259 | /**
|
1260 | * Decrements its argument.
|
1261 | *
|
1262 | * See also {@link inc}.
|
1263 | *
|
1264 | * @example
|
1265 | * ```typescript
|
1266 | * R.dec(42);
|
1267 | * ```
|
1268 | */
|
1269 | export function dec(n: number): number;
|
1270 |
|
1271 | /**
|
1272 | * Returns the second argument if it is not `null`, `undefined` or `NaN`; otherwise the first argument is returned.
|
1273 | *
|
1274 | * @example
|
1275 | * ```typescript
|
1276 | * const defaultTo42 = R.defaultTo(42);
|
1277 | *
|
1278 | * defaultTo42(null);
|
1279 | * defaultTo42(undefined);
|
1280 | * defaultTo42(false);
|
1281 | * defaultTo42('Ramda');
|
1282 | *
|
1283 | * defaultTo42(parseInt('string'));
|
1284 | * ```
|
1285 | */
|
1286 | export function defaultTo<T, U>(a: T, b: U | null | undefined): T | U;
|
1287 | export function defaultTo<T>(a: T): <U>(b: U | null | undefined) => T | U;
|
1288 |
|
1289 | /**
|
1290 | * Makes a descending comparator function out of a function that returns a value that can be compared with `<` and `>`.
|
1291 | *
|
1292 | * See also {@link ascend}.
|
1293 | *
|
1294 | * @example
|
1295 | * ```typescript
|
1296 | * type Person = { name: string; age: number; };
|
1297 | *
|
1298 | * const byAge = R.descend<Person>(R.prop('age'));
|
1299 | * const people = [
|
1300 | * { name: 'Emma', age: 70 },
|
1301 | * { name: 'Peter', age: 78 },
|
1302 | * { name: 'Mikhail', age: 62 },
|
1303 | * ];
|
1304 | * const peopleByOldestFirst = R.sort(byAge, people);
|
1305 | *
|
1306 | * ```
|
1307 | */
|
1308 | export function descend<T>(fn: (obj: T) => Ord, a: T, b: T): Ordering;
|
1309 | export function descend<T>(fn: (obj: T) => Ord): (a: T, b: T) => Ordering;
|
1310 |
|
1311 | /**
|
1312 | * Finds the set (i.e. no duplicates) of all elements in the first list not contained in the second list.
|
1313 | * `Object`s and `Array`s are compared in terms of value equality, not reference equality.
|
1314 | *
|
1315 | * See also {@link differenceWith}, {@link symmetricDifference}, {@link symmetricDifferenceWith}, {@link without}.
|
1316 | *
|
1317 | * @example
|
1318 | * ```typescript
|
1319 | * R.difference([1,2,3,4], [7,6,5,4,3]);
|
1320 | * R.difference([7,6,5,4,3], [1,2,3,4]);
|
1321 | * R.difference<{ a: number; } | { b: number; } | { c: number; }>([{a: 1}, {b: 2}], [{a: 1}, {c: 3}])
|
1322 | * ```
|
1323 | */
|
1324 | export function difference<T>(list1: readonly T[], list2: readonly T[]): T[];
|
1325 | export function difference<T>(list1: readonly T[]): (list2: readonly T[]) => T[];
|
1326 |
|
1327 | /**
|
1328 | * Finds the set (i.e. no duplicates) of all elements in the first list not contained in the second list.
|
1329 | * Duplication is determined according to the value returned
|
1330 | * by applying the supplied predicate to two list elements.
|
1331 | *
|
1332 | * See also See also {@link difference}, {@link symmetricDifference}, {@link symmetricDifferenceWith}.
|
1333 | *
|
1334 | * @example
|
1335 | * ```typescript
|
1336 | * const cmp = (x: { a: number; }, y: { a: number; }) => x.a === y.a;
|
1337 | * const l1 = [{a: 1}, {a: 2}, {a: 3}];
|
1338 | * const l2 = [{a: 3}, {a: 4}];
|
1339 | * R.differenceWith(cmp, l1, l2);
|
1340 | * ```
|
1341 | */
|
1342 | export function differenceWith<T1, T2>(
|
1343 | pred: (a: T1, b: T2) => boolean,
|
1344 | list1: readonly T1[],
|
1345 | list2: readonly T2[],
|
1346 | ): T1[];
|
1347 | export function differenceWith<T1, T2>(
|
1348 | pred: (a: T1, b: T2) => boolean,
|
1349 | ): (list1: readonly T1[], list2: readonly T2[]) => T1[];
|
1350 | export function differenceWith<T1, T2>(
|
1351 | pred: (a: T1, b: T2) => boolean,
|
1352 | list1: readonly T1[],
|
1353 | ): (list2: readonly T2[]) => T1[];
|
1354 |
|
1355 | /**
|
1356 | * Returns a new object that does not contain the given property.
|
1357 | *
|
1358 | * See also {@link assoc}, {@link omit}.
|
1359 | *
|
1360 | * @example
|
1361 | * ```typescript
|
1362 | * R.dissoc('b', {a: 1, b: 2, c: 3});
|
1363 | * ```
|
1364 | */
|
1365 | export function dissoc<T extends object, K extends keyof T>(prop: K, obj: T): Omit<T, K>;
|
1366 | export function dissoc<K extends string | number>(prop: K): <T extends object>(obj: T) => Omit<T, K>;
|
1367 |
|
1368 | /**
|
1369 | * Makes a shallow clone of an object, omitting the property at the given path.
|
1370 | *
|
1371 | * @note This copies and flattens prototype properties onto the new object as well.
|
1372 | * All non-primitive properties are copied by reference.
|
1373 | *
|
1374 | * @example
|
1375 | * ```typescript
|
1376 | * R.dissocPath(['a', 'b', 'c'], {a: {b: {c: 42}}});
|
1377 | * ```
|
1378 | */
|
1379 | export function dissocPath<T>(path: Path, obj: any): T;
|
1380 | export function dissocPath<T>(path: Path): (obj: any) => T;
|
1381 |
|
1382 | /**
|
1383 | * Divides two numbers. Equivalent to `a / b` but curried.
|
1384 | *
|
1385 | * See also {@link multiply}.
|
1386 | *
|
1387 | * @example
|
1388 | * ```typescript
|
1389 | * R.divide(71, 100);
|
1390 | *
|
1391 | * const half = R.divide(R.__, 2);
|
1392 | * half(42);
|
1393 | *
|
1394 | * const reciprocal = R.divide(1);
|
1395 | * reciprocal(4);
|
1396 | * ```
|
1397 | */
|
1398 | export function divide(__: Placeholder, b: number): (a: number) => number;
|
1399 | export function divide(__: Placeholder): (b: number, a: number) => number;
|
1400 | export function divide(a: number, b: number): number;
|
1401 | export function divide(a: number): (b: number) => number;
|
1402 |
|
1403 | /**
|
1404 | * Returns all but the first `n` elements of the given list, string, or transducer/transformer.
|
1405 | *
|
1406 | * Dispatches to the `drop` method of the second argument, if present.
|
1407 | *
|
1408 | * See also {@link take}, {@link transduce}, {@link dropLast}, {@link dropWhile}.
|
1409 | *
|
1410 | * @example
|
1411 | * ```typescript
|
1412 | * R.drop(1, ['foo', 'bar', 'baz']);
|
1413 | * R.drop(2, ['foo', 'bar', 'baz']);
|
1414 | * R.drop(3, ['foo', 'bar', 'baz']);
|
1415 | * R.drop(4, ['foo', 'bar', 'baz']);
|
1416 | * R.drop(3, 'ramda');
|
1417 | * ```
|
1418 | */
|
1419 | export function drop<T>(n: number, xs: readonly T[]): T[];
|
1420 | export function drop(n: number, xs: string): string;
|
1421 | export function drop<T>(n: number): {
|
1422 | (xs: string): string;
|
1423 | (xs: readonly T[]): T[];
|
1424 | };
|
1425 |
|
1426 | /**
|
1427 | * Returns a list containing all but the last `n` elements of the given list.
|
1428 | *
|
1429 | * Acts as a transducer if a transformer is given in list position.
|
1430 | *
|
1431 | * See also {@link takeLast}, {@link drop}, {@link dropWhile}, {@link dropLastWhile}, {@link transduce}.
|
1432 | *
|
1433 | * @example
|
1434 | * ```typescript
|
1435 | * R.dropLast(1, ['foo', 'bar', 'baz']);
|
1436 | * R.dropLast(2, ['foo', 'bar', 'baz']);
|
1437 | * R.dropLast(3, ['foo', 'bar', 'baz']);
|
1438 | * R.dropLast(4, ['foo', 'bar', 'baz']);
|
1439 | * R.dropLast(3, 'ramda');
|
1440 | * ```
|
1441 | */
|
1442 | export function dropLast<T>(n: number, xs: readonly T[]): T[];
|
1443 | export function dropLast(n: number, xs: string): string;
|
1444 | export function dropLast<T>(n: number): {
|
1445 | (xs: readonly T[]): T[];
|
1446 | (xs: string): string;
|
1447 | };
|
1448 |
|
1449 | /**
|
1450 | * Returns a new list excluding all the tailing elements of a given list which satisfy the supplied predicate function.
|
1451 | * It passes each value from the right to the supplied predicate function,
|
1452 | * skipping elements until the predicate function returns a falsy value.
|
1453 | *
|
1454 | * Acts as a transducer if a transformer is given in list position.
|
1455 | *
|
1456 | * See also {@link takeLastWhile}, {@link addIndex}, {@link drop}, {@link dropWhile}, {@link transduce}.
|
1457 | *
|
1458 | * @example
|
1459 | * ```typescript
|
1460 | * const lteThree = (x: number) => x <= 3;
|
1461 | *
|
1462 | * R.dropLastWhile(lteThree, [1, 2, 3, 4, 3, 2, 1]);
|
1463 | *
|
1464 | * R.dropLastWhile(x => x !== 'd', 'Ramda');
|
1465 | * ```
|
1466 | */
|
1467 | export function dropLastWhile<T>(fn: (a: T) => boolean, list: readonly T[]): T[];
|
1468 | export function dropLastWhile<T>(fn: (a: T) => boolean): (list: readonly T[]) => T[];
|
1469 |
|
1470 | /**
|
1471 | * Returns a new list without any consecutively repeating elements.
|
1472 | * {@link equals `R.equals`} is used to determine equality.
|
1473 | *
|
1474 | * Acts as a transducer if a transformer is given in list position.
|
1475 | *
|
1476 | * See also {@link transduce}.
|
1477 | *
|
1478 | * @example
|
1479 | * ```typescript
|
1480 | * R.dropRepeats([1, 1, 1, 2, 3, 4, 4, 2, 2]);
|
1481 | * ```
|
1482 | */
|
1483 | export function dropRepeats<T>(list: readonly T[]): T[];
|
1484 |
|
1485 | /**
|
1486 | * Returns a new list without any consecutively repeating elements.
|
1487 | * Equality is determi |