-
Notifications
You must be signed in to change notification settings - Fork 113
/
index.d.ts
140 lines (126 loc) · 3.47 KB
/
index.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
/**
* Fast API interface
*/
export interface Fast<T> {
/**
* Concatenate multiple arrays.
*
* @param {Array|mixed} items, ... The item(s) to concatenate.
* @return A new Fast object, containing the results.
*/
concat (...items: T[]): Fast<T>
/**
* Fast Map
*
* @param {Function} fn The visitor function.
* @param {Object} thisContext The context for the visitor, if any.
* @return A new Fast object, containing the results.
*/
map (fn: Function, thisContext?: object): Fast<T>
/**
* Fast Filter
*
* @param {Function} fn The filter function.
* @param {Object} thisContext The context for the filter function, if any.
* @return A new Fast object, containing the results.
*/
filter (fn: Function, thisContext?: object): Fast<T>
/**
* Fast Reduce
*
* @param {Function} fn The reducer function.
* @param {mixed} initialValue The initial value, if any.
* @param {Object} thisContext The context for the reducer, if any.
* @return The final result.
*/
reduce (fn: Function, initialValue: T, thisContext?: object): T
/**
* Fast Reduce Right
*
* @param {Function} fn The reducer function.
* @param {any} initialValue The initial value, if any.
* @param {Object} thisContext The context for the reducer, if any.
* @return The final result.
*/
reduceRight (fn: Function, initialValue: T, thisContext?: object): T
/**
* Fast For Each
*
* @param {Function} fn The visitor function.
* @param {Object} thisContext The context for the visitor, if any.
* @return {Fast} The Fast instance.
*/
forEach (fn: Function, thisContext?: object): Fast<T>
/**
* Fast Some
*
* @param {Function} fn The matcher predicate.
* @param {Object} thisContext The context for the matcher, if any.
* @return {Boolean} True if at least one element matches.
*/
some (fn: Function, thisContext?: object): boolean
/**
* Fast Every
*
* @param {Function} fn The matcher predicate.
* @param {Object} thisContext The context for the matcher, if any.
* @return {Boolean} True if at all elements match.
*/
every (fn: Function, thisContext?: object): boolean
/**
* Fast Index Of
*
* @param {any} target The target to lookup.
* @param {Number} fromIndex The index to start searching from, if known.
* @return {Number} The index of the item, or -1 if no match found.
*/
indexOf (target: any, fromIndex: number): number
/**
* Fast Last Index Of
*
* @param {any} target The target to lookup.
* @param {Number} fromIndex The index to start searching from, if known.
* @return {Number} The last index of the item, or -1 if no match found.
*/
lastIndexOf (target: any, fromIndex: number): number
/**
* Reverse
*
* @return A new Fast instance, with the contents reversed.
*/
reverse (): Fast<T>
/**
* Value Of
*
* @return {Array} The wrapped value.
*/
valueOf (): Array<T>
/**
* To JSON
*
* @return {Array} The wrapped value.
*/
toJSON (): Array<T>
/**
* Item length
*/
readonly length: number
}
/**
* Provided as a convenient wrapper around `Fast` functions.
*
* ```js
* var arr = fast([1,2,3,4,5,6]);
*
* var result = arr.filter(function (item) {
* return item % 2 === 0;
* });
*
* result instanceof Fast; // true
* result.length; // 3
* ```
*
* @param {Array} value The value to wrap
* @return Fast instance
*/
export default function Fast<T> (value: Array<T>): Fast<T>