-
Notifications
You must be signed in to change notification settings - Fork 2
/
ramda.d.ts
1792 lines (1436 loc) · 73.6 KB
/
ramda.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
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
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
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
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
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
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
// Type definitions for ramda
// Based on code from https://github.com/donnut/typescript-ramda
// Moved to typings format by Rich Adams <https://github.com/enriched>
declare var R: R.Static;
declare module R {
/**
* A special placeholder value used to specify "gaps" within curried functions,
* allowing partial application of any combination of arguments, regardless of their positions.
*/
interface placeholder {}
interface ListIterator<T, TResult> {
(value: T, index: number, list: T[]): TResult;
}
interface ObjectIterator<T, TResult> {
(element: T, key: string, obj: Dictionary<T>): Dictionary<TResult>;
}
interface KeyValuePair<K, V> extends Array<K | V> { 0 : K; 1 : V; }
interface ArrayLike {
nodeType: number;
}
interface Arity0Fn {
(): any;
}
interface Arity1Fn {
(a: any): any;
}
interface Arity2Fn {
(a: any, b: any): any;
}
interface ObjFunc {
[index:string]: Function;
}
interface ObjFunc2 {
[index:string]: (x: any, y: any) => boolean;
}
interface Pred {
(...a: any[]): boolean;
}
interface ObjPred {
(value: any, key: string): boolean;
}
interface Dictionary<T> {
[index: string]: T;
}
interface CharList extends String {
push(x: string): void;
}
interface Lens {
<T,U>(obj: T): U;
set<T,U>(str: string, obj: T): U;
}
// @see https://gist.github.com/donnut/fd56232da58d25ceecf1, comment by @albrow
interface CurriedFunction2<T1, T2, R> {
(t1: T1): (t2: T2) => R;
(t1: T1, t2: T2): R;
}
interface CurriedFunction3<T1, T2, T3, R> {
(t1: T1): CurriedFunction2<T2, T3, R>;
(t1: T1, t2: T2): (t3: T3) => R;
(t1: T1, t2: T2, t3: T3): R;
}
interface CurriedFunction4<T1, T2, T3, T4, R> {
(t1: T1): CurriedFunction3<T2, T3, T4, R>;
(t1: T1, t2: T2): CurriedFunction2<T3, T4, R>;
(t1: T1, t2: T2, t3: T3): (t4: T4) => R;
(t1: T1, t2: T2, t3: T3, t4: T4): R;
}
interface CurriedFunction5<T1, T2, T3, T4, T5, R> {
(t1: T1): CurriedFunction4<T2, T3, T4, T5, R>;
(t1: T1, t2: T2): CurriedFunction3<T3, T4, T5, R>;
(t1: T1, t2: T2, t3: T3): CurriedFunction2<T4, T5, R>;
(t1: T1, t2: T2, t3: T3, t4: T4): (t5: T5) => R;
(t1: T1, t2: T2, t3: T3, t4: T4, t5: T5): R;
}
interface CurriedFunction6<T1, T2, T3, T4, T5, T6, R> {
(t1: T1): CurriedFunction5<T2, T3, T4, T5, T6, R>;
(t1: T1, t2: T2): CurriedFunction4<T3, T4, T5, T6, R>;
(t1: T1, t2: T2, t3: T3): CurriedFunction3<T4, T5, T6, R>;
(t1: T1, t2: T2, t3: T3, t4: T4): CurriedFunction2<T5, T6, R>;
(t1: T1, t2: T2, t3: T3, t4: T4, t5: T5): (t6: T6) => R;
(t1: T1, t2: T2, t3: T3, t4: T4, t5: T5, t6: T6): R;
}
type AnyCurriedFunction = CurriedFunction2<any,any,any> | CurriedFunction3<any,any,any,any> | CurriedFunction4<any,any,any,any,any> | CurriedFunction5<any,any,any,any,any,any> | CurriedFunction6<any,any,any,any,any,any,any>;
interface Static {
/*
* List category
*/
/**
* Applies a function to the value at the given index of an array, returning a new copy of the array with the element at the given index replaced with the result of the function application.
*/
adjust<T>(fn: (a: T) => T, index: number, list: T[]): T[];
adjust<T>(fn: (a: T) => T, index: number): (list: T[]) => T[];
/**
* Returns true if all elements of the list match the predicate, false if there are any that don't.
*/
all<T>(fn: (a: T) => boolean, list: T[]): boolean;
all<T>(fn: (a: T) => boolean): (list: T[]) => boolean;
/**
* Returns true if at least one of elements of the list match the predicate, false otherwise.
*/
any<T>(fn: (a: T) => boolean, list: T[]): boolean;
any<T>(fn: (a: T) => boolean): (list: T[]) => boolean;
/**
* Returns a new list, composed of n-tuples of consecutive elements If n is greater than the length of the list, an empty list is returned.
*/
aperture<T>(n: number, list: T): T[][];
aperture<T>(n: number): (list: T) => T[][];
/**
* Returns a new list containing the contents of the given list, followed by the given element.
*/
// note U is required (instead of just T) to allow appending an element of a different type than the array is.
append<T>(el: T, list: T[]): T[];
append<T>(el: T): (list: T[]) => T[];
append<T, U>(el: U, list: T[]): (T & U)[];
append<T, U>(el: U): (list: T[]) => (T & U)[];
/**
* `chain` maps a function over a list and concatenates the results.
* This implementation is compatible with the Fantasy-land Chain spec
*/
chain<T, U>(fn: (n: T) => U[], list: T[]): U[];
chain<T, U>(fn: (n: T) => U[]): (list: T[]) => U[];
/**
* Turns a list of Functors into a Functor of a list.
*/
commute<T, U>(of: (x: T) => U, list: U[]): U;
commute<T, U>(of: (x: T) => U): (list: U[]) => U;
commute<T, U>(of: (x: T) => T[], list: U[]): U[]
commute<T, U>(of: (x: T) => T[]): (list: U[]) => U[]
/*
* Turns a list of Functors into a Functor of a list, applying a mapping function to the elements of the list along the way.
*/
commuteMap<T, U>(fn: (list: T[]) => U[], of: (x: T[]) => U[][], list: T[][]): U[][];
commuteMap<T, U>(fn: (list: T[]) => U[]): (of: (x: T[]) => U[][], list: T[][]) => U[][];
commuteMap<T, U>(fn: (list: T[]) => U[], of: (x: T[]) => U[][]): (list: T[][]) => U[][];
/**
* Returns a new list consisting of the elements of the first list followed by the elements
* of the second.
*/
concat<T>(list1: T[], list2: T[]): T[];
concat<T>(list1: T[]): (list2: T[]) => T[];
concat<T>(list1: string, list2: string): string;
concat<T>(list1: string): (list2: string) => string;
/**
* Returns `true` if the specified item is somewhere in the list, `false` otherwise.
* Equivalent to `indexOf(a)(list) > -1`. Uses strict (`===`) equality checking.
*/
contains(a: string, list: string): boolean;
contains<T>(a: T, list: T[]): boolean;
contains(a: string): (list: string) => boolean;
contains<T>(a: T): (list: T[]) => boolean;
/**
* Returns `true` if the `x` is found in the `list`, using `pred` as an
* equality predicate for `x`.
*/
containsWith<T>(pred: (a: T, b: T) => boolean, x: T, list: T[]): boolean;
containsWith<T>(pred: (a: T, b: T) => boolean, x: T): (list: T[]) => boolean;
/**
* Returns a new list containing all but the first n elements of the given list.
*/
drop<T>(n: number, list: T[]): T[];
drop<T>(n: number): (list: T[]) => T[];
dropLast<T>(n: number, list: T[]): T[];
dropLast<T>(n: number): (list: T[]) => T[];
dropLastWhile<T>(fn: (a: T) => boolean, list: T[]): T[];
dropLastWhile<T>(fn: (a: T) => boolean): (list: T[]) => T[];
dropRepeats<T>(list: T[]): T[];
dropRepeatsWith<T>(fn: (l: T, r: T) => boolean, list: T[]): T[];
dropRepeatsWith<T>(fn: (l: T, r: T) => boolean): (list: T[]) => T[];
/**
* Returns a new list containing the last n elements of a given list, passing each value to the supplied
* predicate function, skipping elements while the predicate function returns true.
*/
dropWhile<T>(fn: (a: T) => boolean, list: T[]): T[];
dropWhile<T>(fn: (a: T) => boolean): (list: T[]) => T[];
/**
* Returns a new list containing only those items that match a given predicate function. The predicate function is passed one argument: (value).
*/
filter<T>(fn: (value: T) => boolean): (list: T[]) => T[];
filter<T>(fn: (value: T) => boolean, list: T[]): T[];
/**
* Like filter, but passes additional parameters to the predicate function. The predicate function is passed three arguments: (value, index, list).
*/
filterIndexed<T>(fn: (value: T, index: number, list: T[]) => boolean): (list: T[]) => T[];
filterIndexed<T>(fn: (value: T, index: number, list: T[]) => boolean, list: T[]): T[];
/**
* Returns the first element of the list which matches the predicate, or `undefined` if no
* element matches.
*/
find<T>(fn: (a: T) => boolean, list: T[]): T;
find<T>(fn: (a: T) => boolean): (list: T[]) => T;
/**
* Returns the index of the first element of the list which matches the predicate, or `-1`
* if no element matches.
*/
findIndex<T>(fn: (a: T) => boolean, list: T[]): number;
findIndex<T>(fn: (a: T) => boolean): (list: T[]) => number;
/**
* Returns the last element of the list which matches the predicate, or `undefined` if no
* element matches.
*/
findLast<T>(fn: (a: T) => boolean, list: T[]): T;
findLast<T>(fn: (a: T) => boolean): (list: T[]) => T;
/**
* Returns the index of the last element of the list which matches the predicate, or
* `-1` if no element matches.
*/
findLastIndex<T>(fn: (a: T) => boolean, list: T[]): number;
findLastIndex<T>(fn: (a: T) => boolean): (list: T[]) => number;
/**
* Returns a new list by pulling every item out of it (and all its sub-arrays) and putting
* them in a new array, depth-first.
*/
flatten<T>(x: T[]): T[];
/**
* Iterate over an input list, calling a provided function fn for each element in the list.
*/
forEach<T>(fn: (x: T) => void, list: T[]): T[];
forEach<T>(fn: (x: T) => void): (list: T[]) => T[];
/**
* Like forEach, but but passes additional parameters to the predicate function.
*/
forEachIndexed<T>(fn: (x: T, idx?: number, list?: T[]) => void, list: T[]): T[];
forEachIndexed<T>(fn: (x: T, idx?: number, list?: T[]) => void): (list: T[]) => T[];
/**
* Creates a new object out of a list key-value pairs.
*/
fromPairs<V>(pairs: KeyValuePair<string, V>[]): {[index: string]: V};
fromPairs<V>(pairs: KeyValuePair<number, V>[]): {[index: number]: V};
/**
* Splits a list into sublists stored in an object, based on the result of
* calling a String-returning function
* on each element, and grouping the results according to values returned.
*/
groupBy<T>(fn: (a: T) => string, list: T[]): {[index: string]: T[]}
groupBy<T>(fn: (a: T) => string): <T>(list: T[]) => {[index: string]: T[]}
/**
* Returns the first element in a list.
* In some libraries this function is named `first`.
*/
head<T>(list: T[]): T;
/**
* Returns the position of the first occurrence of an item in an array
* (by strict equality),
* or -1 if the item is not included in the array.
*/
indexOf<T>(target: T, list: T[]): number;
indexOf<T>(target: T): (list: T[]) => number;
/**
* Returns all but the last element of a list.
*/
init<T>(list: T[]): T[];
/**
* Inserts the supplied element into the list, at index index. Note that
* this is not destructive: it returns a copy of the list with the changes.
*/
insert(index: number, elt: any, list: any[]): any[];
insert(index: number): (elt: any, list: any[]) => any[];
insert(index: number, elt: any): (list: any[]) => any[];
/**
* Inserts the sub-list into the list, at index `index`. _Note that this
* is not destructive_: it returns a copy of the list with the changes.
*/
insertAll(index: number, elts: any[], list: any[]): any[];
insertAll(index: number): (elts: any[], list: any[]) => any[];
insertAll(index: number, elts: any[]): (list: any[]) => any[];
/**
* Transforms the items of the list with the transducer and appends the transformed items to the accumulator
* using an appropriate iterator function based on the accumulator type.
*/
into<T>(acc: any, xf: Function, list: T[]): T[];
into<T>(acc: any, xf: Function): (list: T[]) => T[];
into<T>(acc: any): (xf: Function, list: T[]) => T[];
/**
* Returns `true` if all elements are unique, otherwise `false`.
* Uniqueness is determined using strict equality (`===`).
*/
isSet(list: any[]): boolean;
/**
* Returns a string made by inserting the `separator` between each
* element and concatenating all the elements into a single string.
*/
join(x: string, xs: any[]): string;
join(x: string): (xs: any[]) => string;
/**
* Returns the last element from a list.
*/
last<T>(list: T[]): T;
/**
* Returns the position of the last occurrence of an item (by strict equality) in
* an array, or -1 if the item is not included in the array.
*/
lastIndexOf<T>(target: T, list: T[]): number;
/**
* Returns the number of elements in the array by returning list.length.
*/
length(list: any[]): number;
/**
* Returns a new list, constructed by applying the supplied function to every element of the supplied list.
*/
map<T, U>(fn: (x: T) => U, list: T[]): U[];
map<T, U>(fn: (x: T) => U, obj: any): any; // used in functors
map<T, U>(fn: (x: T) => U): (list: T[]) => U[];
/**
* The mapAccum function behaves like a combination of map and reduce.
*/
mapAccum<T, U, TResult>(fn: (acc: U, value: T) => [U, TResult], acc: U, list: T[]): [U, TResult[]];
mapAccum<T, U, TResult>(fn: (acc: U, value: T) => [U, TResult]): (acc: U, list: T[]) => [U, TResult[]];
mapAccum<T, U, TResult>(fn: (acc: U, value: T) => [U, TResult], acc: U): (list: T[]) => [U, TResult[]];
/**
* The mapAccumRight function behaves like a combination of map and reduce.
*/
mapAccumRight<T, U, TResult>(fn: (acc: U, value: T) => [U, TResult], acc: U, list: T[]): [U, TResult[]];
mapAccumRight<T, U, TResult>(fn: (acc: U, value: T) => [U, TResult]): (acc: U, list: T[]) => [U, TResult[]];
mapAccumRight<T, U, TResult>(fn: (acc: U, value: T) => [U, TResult], acc: U): (list: T[]) => [U, TResult[]];
/**
* Like map, but but passes additional parameters to the mapping function.
*/
mapIndexed<T, U>(fn: (val: T, key: number, list: T[]) => U, list: T[]): U[];
mapIndexed<T, U>(fn: (val: T, key: number, list: T[]) => U): (list: T[]) => U[];
/**
* Like mapObj, but but passes additional arguments to the predicate function.
*/
mergeAll(list: any[]): any;
/**
* Returns true if no elements of the list match the predicate, false otherwise.
*/
none<T>(fn: (a: T) => boolean, list: T[]): boolean;
none<T>(fn: (a: T) => boolean): (list: T[]) => boolean;
/**
* Returns the nth element in a list.
*/
nth<T>(n: number, list: T[]): T;
nth<T>(n: number): (list: T[]) => T;
/**
* Takes a predicate and a list and returns the pair of lists of elements
* which do and do not satisfy the predicate, respectively.
*/
partition(fn: (a: string) => boolean, list: string[]): string[][];
partition<T>(fn: (a: T) => boolean, list: T[]): T[][];
partition<T>(fn: (a: T) => boolean): (list: T[]) => T[][];
partition(fn: (a: string) => boolean): (list: string[]) => string[][];
/**
* Returns a new list by plucking the same named property off all objects in the list supplied.
*/
pluck<T>(p: string|number, list: any[]): T[];
pluck<T>(p: string|number): (list: any[]) => T[];
pluck(p: string|number, list: any[]): any[];
pluck(p: string|number): (list: any[]) => any[];
/**
* Returns a new list with the given element at the front, followed by the contents of the
* list.
*/
prepend<T>(el: T, list: T[]): T[];
prepend<T>(el: T): (list: T[]) => T[];
/**
* Returns a list of numbers from `from` (inclusive) to `to`
* (exclusive). In mathematical terms, `range(a, b)` is equivalent to
* the half-open interval `[a, b)`.
*/
range(from: number, to: number): number[];
range(from: number): (to: number) => number[];
/**
* Returns a single item by iterating through the list, successively calling the iterator
* function and passing it an accumulator value and the current value from the array, and
* then passing the result to the next call.
*/
reduce<T, TResult>(fn: (acc: TResult, elem: T) => TResult, acc: TResult, list: T[]): TResult;
reduce<T, TResult>(fn: (acc: TResult, elem: T) => TResult): (acc: TResult, list: T[]) => TResult;
reduce<T, TResult>(fn: (acc: TResult, elem: T) => TResult, acc: TResult): (list: T[]) => TResult;
/**
* Like `reduce`, but passes additional parameters to the predicate function.
*/
reduceIndexed<T, TResult>(fn: (acc: TResult, elem: T, idx: number, list: T[]) => TResult, acc: TResult, list: T[]): TResult;
reduceIndexed<T, TResult>(fn: (acc: TResult, elem: T, idx: number, list: T[]) => TResult): (acc: TResult, list: T[]) => TResult;
reduceIndexed<T, TResult>(fn: (acc: TResult, elem: T, idx: number, list: T[]) => TResult, acc: TResult): (list: T[]) => TResult;
/**
* Returns a single item by iterating through the list, successively calling the iterator
* function and passing it an accumulator value and the current value from the array, and
* then passing the result to the next call.
*/
reduceRight<T, TResult>(fn: (acc: TResult, elem: T) => TResult, acc: TResult, list: T[]): TResult;
reduceRight<T, TResult>(fn: (acc: TResult, elem: T) => TResult): (acc: TResult, list: T[]) => TResult;
reduceRight<T, TResult>(fn: (acc: TResult, elem: T) => TResult, acc: TResult): (list: T[]) => TResult;
/**
* Like `reduceRight`, but passes additional parameters to the predicate function. Moves through
* the input list from the right to the left.
*/
reduceRightIndexed<T, TResult>(fn: (acc: TResult, elem: T, idx: Number, list: T[]) => TResult, acc: TResult, list: T[]): TResult;
reduceRightIndexed<T, TResult>(fn: (acc: TResult, elem: T, idx: Number, list: T[]) => TResult): (acc: TResult, list: T[]) => TResult;
reduceRightIndexed<T, TResult>(fn: (acc: TResult, elem: T, idx: Number, list: T[]) => TResult, acc: TResult): (list: T[]) => TResult;
/**
* Similar to `filter`, except that it keeps only values for which the given predicate
* function returns falsy.
*/
reject<T>(fn: (value: T) => boolean, list: T[]): T[];
reject<T>(fn: (value: T) => boolean): (list: T[]) => T[];
/**
* Like `reject`, but passes additional parameters to the predicate function.
*/
rejectIndexed<T>(fn: (value: T, index: number, list: T[]) => boolean, list: T[]): T[];
rejectIndexed<T>(fn: (value: T, index: number, list: T[]) => boolean): (list: T[]) => T[];
/**
* Removes the sub-list of `list` starting at index `start` and containing `count` elements.
*/
remove<T>(start: number, count: number, list: T[]): T[];
remove<T>(start: number): (count: number, list: T[]) => T[];
remove<T>(start: number, count: number): (list: T[]) => T[];
/**
* Returns a fixed list of size n containing a specified identical value.
*/
repeat<T>(a: T, n: number): T[];
repeat<T>(a: T): (n: number) => T[];
/**
* Returns a new list with the same elements as the original list, just in the reverse order.
*/
reverse<T>(list: T[]): T[];
/**
* Scan is similar to reduce, but returns a list of successively reduced values from the left.
*/
scan<T, TResult>(fn: (acc: TResult, elem: T) => TResult, acc: TResult, list: T[]): TResult;
scan<T, TResult>(fn: (acc: TResult, elem: T) => TResult): (acc: TResult, list: T[]) => TResult;
scan<T, TResult>(fn: (acc: TResult, elem: T) => TResult, acc: TResult): (list: T[]) => TResult;
/**
* Returns the elements from `xs` starting at `a` and ending at `b - 1`.
*/
slice(a: number, b: number, list: string): string;
slice<T>(a: number, b: number, list: T[]): T[];
slice<T>(a: number, b: number): (list: string|T[]) => string|T[];
slice<T>(a: number): (b: number, list: string|T[]) => string|T[];
/**
* Returns a copy of the list, sorted according to the comparator function, which should accept two values at a
* time and return a negative number if the first value is smaller, a positive number if it's larger, and zero
* if they are equal.
*/
sort<T>(fn: (a: T, b: T) => number, list: T[]): T[];
sort<T>(fn: (a: T, b: T) => number): (list: T[]) => T[];
/**
* Splits a collection into slices of the specified length.
*/
splitEvery<T>(a: number, list: T[]): T[][];
splitEvery<T>(a: number): (list: T[]) => T[][];
/**
* Returns all but the first element of a list.
*/
tail<T>(list: T[]): T[];
/**
* Returns a new list containing the first `n` elements of the given list. If
* `n > * list.length`, returns a list of `list.length` elements.
*/
take<T>(n: number, list: T[]): T[];
take<T>(n: number): (list: T[]) => T[];
/**
* Returns a new list containing the first `n` elements of a given list, passing each value
* to the supplied predicate function, and terminating when the predicate function returns
* `false`.
*/
takeWhile<T>(fn: (x: T) => boolean, list: T[]): T[];
takeWhile<T>(fn: (x: T) => boolean): (list: T[]) => T[];
/**
* Calls an input function `n` times, returning an array containing the results of those
* function calls.
*/
times<T>(fn: (i: number) => T, n: number): T[];
times<T>(fn: (i: number) => T): (n: number) => T[];
/**
* Initializes a transducer using supplied iterator function. Returns a single item by iterating through the
* list, successively calling the transformed iterator function and passing it an accumulator value and the
* current value from the array, and then passing the result to the next call.
*/
transduce<T,U>(xf: (arg: T[]) => T[], fn: (acc: U[], val: U) => U[], acc: T[], list: T[]): U;
transduce<T,U>(xf: (arg: T[]) => T[]): (fn: (acc: U[], val: U) => U[], acc: T[], list: T[]) => U;
transduce<T,U>(xf: (arg: T[]) => T[], fn: (acc: U[], val: U) => U[]): (acc: T[], list: T[]) => U;
transduce<T,U>(xf: (arg: T[]) => T[], fn: (acc: U[], val: U) => U[], acc: T[]): (list: T[]) => U;
/**
* Builds a list from a seed value. Accepts an iterator function, which returns either false
* to stop iteration or an array of length 2 containing the value to add to the resulting
* list and the seed to be used in the next call to the iterator function.
*/
unfold<T, TResult>(fn: (seed: T) => TResult[]|boolean, seed: T): TResult[];
unfold<T, TResult>(fn: (seed: T) => TResult[]|boolean): (seed: T) => TResult[];
/**
* Returns a new list containing only one copy of each element in the original list.
*/
uniq<T>(list: T[]): T[];
/**
* Returns a new list containing only one copy of each element in the original list, based upon the value returned by applying the supplied function to each list element. Prefers the first item if the supplied function produces the same value on two items. R.equals is used for comparison.
*/
uniqBy<T,U>(fn: (a: T) => U, list: T[]): T[];
uniqBy<T,U>(fn: (a: T) => U): (list: T[]) => T[];
/**
* Returns a new list containing only one copy of each element in the original list, based upon the value
* returned by applying the supplied predicate to two list elements.
*/
uniqWith<T,U>(pred: (x: T, y: T) => boolean, list: T[]): T[];
uniqWith<T,U>(pred: (x: T, y: T) => boolean): (list: T[]) => T[];
/**
* Returns a new list by pulling every item at the first level of nesting out, and putting
* them in a new array.
*/
unnest<T>(x: T[][]): T[];
unnest<T>(x: T[]): T[];
/**
* Returns a new copy of the array with the element at the provided index replaced with the given value.
*/
update<T>(index: number, value: T, list: T[]): T[];
update<T>(index: number, value: T): (list: T[]) => T[];
/**
* Creates a new list out of the two supplied by creating each possible pair from the lists.
*/
xprod<K,V>(as: K[], bs: V[]): KeyValuePair<K,V>[];
xprod<K,V>(as: K[]): (bs: V[]) => KeyValuePair<K,V>[];
/**
* Creates a new list out of the two supplied by pairing up equally-positioned items from
* both lists. Note: `zip` is equivalent to `zipWith(function(a, b) { return [a, b] })`.
*/
zip<K,V>(list1: K[], list2: V[]): KeyValuePair<K,V>[];
zip<K,V>(list1: K[]): (list2: V[]) => KeyValuePair<K,V>[];
/**
* Creates a new object out of a list of keys and a list of values.
*/
// TODO: Dictionary<T> as a return value is to specific, any seems to loose
zipObj<T>(keys: string[], values: T[]): {[index:string]: T};
zipObj<T>(keys: string[]): (values: T[]) => {[index:string]: T};
/**
* Creates a new list out of the two supplied by applying the function to each
* equally-positioned pair in the lists.
*/
zipWith<T, U, TResult>(fn: (x: T, y: U) => TResult, list1: T[], list2: U[]): TResult[];
zipWith<T, U, TResult>(fn: (x: T, y: U) => TResult, list1: T[]): (list2: U[]) => TResult[];
zipWith<T, U, TResult>(fn: (x: T, y: U) => TResult): (list1: T[], list2: U[]) => TResult[];
/*
* Object category
*/
/**
* Makes a shallow clone of an object, setting or overriding the specified property with the given value.
*/
assoc(prop: string, val: any, obj: any): any;
assoc(prop: string): (val: any, obj: any) => any;
assoc(prop: string, val: any): (obj: any) => any;
/**
* Makes a shallow clone of an object, setting or overriding the nodes required to create the given path, and
* placing the specific value at the tail end of that path.
*/
assocPath(path: string[], val: any, obj: any): any;
assocPath(path: string[]): (val: any, obj: any) => any;
assocPath(path: string[], val: any): (obj: any) => any;
// assoc(prop: string, val: placeholder, obj: any): (val: any) => any;
// assoc(prop: string, val: any, obj: placeholder): (obj: any) => any;
// assoc(prop: placeholder, val: placeholder, obj: any): (prop:string, val: any) => any;
// assoc(prop: placeholder, val: any, obj: placeholder): (prop:string, obj: any) => any;
// assoc(prop: placeholder, val: any, obj: any): (prop:string) => any;
/**
* Creates a deep copy of the value which may contain (nested) Arrays and Objects, Numbers, Strings, Booleans and Dates.
*/
clone(value: any): any;
clone(value: any[]): any[];
/**
* Creates an object containing a single key:value pair.
*/
createMapEntry<T>(key: string, val: T): {[index: string]: T};
createMapEntry<T>(key: placeholder, val: T): (key: string) => {[index: string]: T};
createMapEntry<T>(key: string): (val: T) => {[index: string]: T};
/**
* Returns a new object that does not contain a `prop` property.
*/
dissoc(prop: string, obj: any): any
dissoc(prop: string): (obj: any) => any
/**
* Returns a new object that does not contain a prop property.
*/
dissoc(prop: string, obj: any): any;
dissoc(prop: placeholder, obj: any): (prop: string) => any;
dissoc(prop: string): (obj: any) => any;
/**
* Makes a shallow clone of an object, omitting the property at the given path.
*/
dissocPath(path: string[], obj: any): any;
dissocPath(path: string[]): (obj: any) => any;
/**
* Reports whether two functions have the same value for the specified property.
*/
eqProps(prop: string, obj1: any, obj2: any): boolean;
eqProps(prop: string): (obj1: any, obj2: any) => boolean;
eqProps(prop: string, obj1: any): (obj2: any) => boolean;
/**
* Creates a new object by evolving a shallow copy of object, according to the transformation functions.
*/
evolve(transformations: {[index: string]: (value: any) => any}, obj: any): any;
evolve(transformations: {[index: string]: (value: any) => any}): (obj: any) => any;
/**
* Returns a list of function names of object's own functions
*/
functions(obj: any): string[];
/**
* Returns a list of function names of object's own and prototype functions
*/
functionsIn(obj: any): string[];
/**
* Returns whether or not an object has an own property with the specified name.
*/
has(s: string, obj: any): boolean;
has(s: string): (obj: any) => boolean;
has(s: placeholder, obj: any): (a: string) => boolean;
/**
* Returns whether or not an object or its prototype chain has a property with the specified name
*/
hasIn(s: string, obj: any): boolean;
hasIn(s: string): (obj: any) => boolean;
hasIn(s: placeholder, obj: any): (a: string) => boolean;
/**
* Same as R.invertObj, however this accounts for objects with duplicate values by putting the values into an array.
*/
invert(obj: any): {[index:string]: string[]};
/**
* Returns a new object with the keys of the given object as values, and the values of the given object as keys.
*/
invertObj(obj: any): {[index:string]: string};
invertObj(obj: {[index: number]: string}): {[index:string]: string};
/**
* Returns a list containing the names of all the enumerable own
* properties of the supplied object.
*/
keys(x: any): string[];
/**
* Returns a list containing the names of all the
* properties of the supplied object, including prototype properties.
*/
keysIn(obj: any): string[];
/**
* Returns a lens for the given getter and setter functions. The getter
* "gets" the value of the focus; the setter "sets" the value of the focus.
* The setter should not mutate the data structure.
*/
lens<T,U,V>(getter: (s: T) => U, setter: (a: U, s: T) => V): Lens;
/**
* Creates a lens that will focus on index n of the source array.
*/
lensIndex(n: number): Lens;
/**
* lensProp creates a lens that will focus on property k of the source object.
*/
lensProp(str: string): Lens;
/**
* lensPath Returns a lens whose focus is the specified path.
*/
lensPath(path: string[]): Lens;
mapObj<T, TResult>(fn: (value: T) => TResult, obj: any): {[index: string]: TResult};
mapObj<T, TResult>(fn: (value: T) => TResult): (obj: any) => {[index: string]: TResult};
/**
* Like mapObj, but but passes additional arguments to the predicate function.
*/
mapObjIndexed<T, TResult>(fn: (value: T, key: string, obj?: any) => TResult, obj: any): {[index:string]: TResult};
mapObjIndexed<T, TResult>(fn: (value: T, key: string, obj?: any) => TResult): (obj: any) => {[index:string]: TResult};
/**
* Create a new object with the own properties of a
* merged with the own properties of object b.
* This function will *not* mutate passed-in objects.
*/
merge(a: any, b: any): any;
merge(a: any): (b: any) => any;
/**
* Creates a new object with the own properties of the
* two provided objects. If a key exists in both objects,
* the provided function is applied to the values associated
* with the key in each object, with the result being used as
* the value associated with the key in the returned object.
* The key will be excluded from the returned object if the
* resulting value is undefined.
*/
mergeWith: CurriedFunction3<(l:any, r:any) => any, any, any, any>;
mergeWithKey: CurriedFunction3<(k:any, l:any, r:any) => any, any, any, any>;
/**
* Returns a partial copy of an object omitting the keys specified.
*/
omit<T>(names: string[], obj: T): T;
omit<T>(names: string[]): (obj: T) => T;
/**
* Returns the result of "setting" the portion of the given data structure
* focused by the given lens to the given value.
*/
over<T>(lens: Lens, fn: Arity1Fn, value: T|T[]): T|T[];
over<T>(lens: Lens, fn: Arity1Fn): (value: T|T[]) => T|T[];
over<T>(lens: Lens): (fn: Arity1Fn, value: T|T[]) => T|T[];
/**
* Retrieve the value at a given path.
*/
path<T>(path: string[], obj: any): T;
path<T>(path: placeholder, obj: any): (path: string[]) => T;
path<T>(path: string[]): (obj: any) => T;
/**
* Get the path or the default value
*/
pathOr: CurriedFunction3<any, Array<string>, Object, any>;
/**
* Returns a partial copy of an object containing only the keys specified. If the key does not exist, the
* property is ignored.
*/
pick<T>(names: string[], obj: T): T;
pick<T>(names: string[]): (obj: T) => T;
/**
* Similar to `pick` except that this one includes a `key: undefined` pair for properties that don't exist.
*/
pickAll<T, U>(names: string[], obj: T): U;
pickAll<T, U>(names: string[]): (obj: T) => U;
/**
* Returns a partial copy of an object containing only the keys that satisfy the supplied predicate.
*/
pickBy<T,U>(pred: ObjPred, obj: T): U;
pickBy<T,U>(pred: ObjPred): (obj: T) => U;
/**
* Reasonable analog to SQL `select` statement.
*/
project<T,U>(props: string[], objs: T[]): U[];
/**
* Returns a function that when supplied an object returns the indicated property of that object, if it exists.
*/
prop: CurriedFunction2<string, any, any>;
//prop(p: string, obj: any): any;
//prop(p: string): (obj: any) => any;
/**
* If the given, non-null object has an own property with the specified name, returns the value of that property.
* Otherwise returns the provided default value.
*/
propOr<T,U,V>(val: T, p: string, obj: U): V;
propOr<T,U,V>(val: T, p: string): (obj: U) => V;
propOr<T,U,V>(val: T): (p: string, obj: U) => V;
/**
* Returns the value at the specified property.
* The only difference from `prop` is the parameter order.
*/
props<T>(ps: string[], obj: Dictionary<T>): T[];
props<T>(ps: string[]): (obj: Dictionary<T>) => T[];
/**
* Returns the result of "setting" the portion of the given data structure focused by the given lens to the
* given value.
*/
set<T,U>(lens: Lens, a: U, obj: T): T;
set<T,U>(lens: Lens, a: U): (obj: T) => T;
set<T,U>(lens: Lens): (a: U, obj: T) => T;
/**
* Converts an object into an array of key, value arrays.
* Only the object's own properties are used.
* Note that the order of the output array is not guaranteed to be
* consistent across different JS platforms.
*/
toPairs(obj: any): any[][];
/**
* Converts an object into an array of key, value arrays.
* The object's own properties and prototype properties are used.
* Note that the order of the output array is not guaranteed to be
* consistent across different JS platforms.
*/
toPairsIn(obj: any): any[][];
/**
* Returns a list of all the enumerable own properties of the supplied object.
* Note that the order of the output array is not guaranteed across
* different JS platforms.
*/
values<T>(obj: {[index: string]: T}): T[];
values(obj: any): any[];
/**
* Returns a list of all the properties, including prototype properties, of the supplied
* object. Note that the order of the output array is not guaranteed to be consistent across different JS platforms.
*/
valuesIn(obj: any): any[];
/**
* Returns a "view" of the given data structure, determined by the given lens. The lens's focus determines which
* portion of the data structure is visible.
*/
view<T,U>(lens: Lens, obj: T): U;
/**
* Takes a spec object and a test object and returns true if the test satisfies the spec.
* Any property on the spec that is not a function is interpreted as an equality
* relation.
*
* If the spec has a property mapped to a function, then `where` evaluates the function, passing in
* the test object's value for the property in question, as well as the whole test object.
*
* `where` is well suited to declarativley expressing constraints for other functions, e.g.,
* `filter`, `find`, `pickWith`, etc.
*/
where<T,U>(spec: T, testObj: U): boolean;
where<T,U>(spec: T): (testObj: U) => boolean;
where<ObjFunc2,U>(spec: ObjFunc2, testObj: U): boolean;
where<ObjFunc2,U>(spec: ObjFunc2): (testObj: U) => boolean;
/**
* Takes a spec object and a test object; returns true if the test satisfies the spec,
* false otherwise. An object satisfies the spec if, for each of the spec's own properties,
* accessing that property of the object gives the same value (in R.eq terms) as accessing
* that property of the spec.
*/
whereEq<T,U>(spec: T, obj: U): boolean;
whereEq<T,U>(spec: T): (obj: U) => boolean;
/*
* Function category
* -----------------
*/
__: placeholder;
/**
* Creates a new list iteration function from an existing one by adding two new parameters to its callback
* function: the current index, and the entire list.
*/
addIndex<T, U>(fn: (f: (item: T) => U, list: T[]) => U[])
: CurriedFunction2<(item: T, idx: number, list?: T[]) => U, T[], U[]>;
/**
* Returns a function that always returns the given value.
*/
always<T>(val: T): () => T;
/**
* ap applies a list of functions to a list of values.
*/
ap<T,U>(fns: ((a: T) => U)[], vs: T[]): U[];
ap<T,U>(fns: ((a: T) => U)[]): (vs: T[]) => U[];
/**
* Applies function fn to the argument list args. This is useful for creating a fixed-arity function from
* a variadic function. fn should be a bound function if context is significant.
*/
apply<T, U, TResult>(fn: (arg0: T, ...args: T[]) => TResult, args: U[]): TResult;
apply<T, U, TResult>(fn: (arg0: T, ...args: T[]) => TResult): (args: U[]) => TResult;
/**
* Wraps a function of any arity (including nullary) in a function that accepts exactly 2
* parameters. Any extraneous parameters will not be passed to the supplied function.
*/
binary(fn: (...args: any[]) => any): Function;
/**
* Creates a function that is bound to a context. Note: R.bind does not provide the additional argument-binding
* capabilities of Function.prototype.bind.
*/
bind<T>(thisObj: T, fn: (...args: any[]) => any): (...args: any[]) => any;
/**
* Returns the result of calling its first argument with the remaining arguments. This is occasionally useful