File tree 2 files changed +32
-3
lines changed
lib/node_modules/@stdlib/iter/map/docs/types
2 files changed +32
-3
lines changed Original file line number Diff line number Diff line change @@ -25,14 +25,38 @@ import { Iterator as Iter, IterableIterator } from '@stdlib/types/iter';
25
25
// Define a union type representing both iterable and non-iterable iterators:
26
26
type Iterator = Iter | IterableIterator ;
27
27
28
+ /**
29
+ * Callback function which transforms an iterated value.
30
+ *
31
+ * @returns callback result
32
+ */
33
+ type Nullary = ( ) => any ;
34
+
35
+ /**
36
+ * Callback function which transforms an iterated value.
37
+ *
38
+ * @param value - iterated value
39
+ * @returns callback result
40
+ */
41
+ type Unary = ( value : any ) => any ;
42
+
43
+ /**
44
+ * Callback function which transforms an iterated value.
45
+ *
46
+ * @param value - iterated value
47
+ * @param i - iteration index
48
+ * @returns callback result
49
+ */
50
+ type Binary = ( value : any , i : number ) => any ;
51
+
28
52
/**
29
53
* Callback function which transforms an iterated value.
30
54
*
31
55
* @param value - iterated value
32
56
* @param i - iteration index
33
57
* @returns callback result
34
58
*/
35
- type Callback = ( value ?: any , i ?: number ) => any ;
59
+ type Callback = Nullary | Unary | Binary ;
36
60
37
61
/**
38
62
* Returns an iterator which invokes a function for each iterated value.
Original file line number Diff line number Diff line change @@ -44,10 +44,15 @@ function iterator() {
44
44
/**
45
45
* Callback function.
46
46
*
47
+ * @param v - iterated value
48
+ * @param i - iteration index
47
49
* @returns callback result
48
50
*/
49
- function fcn ( ) {
50
- return 'beep' ;
51
+ function fcn ( v : any , i : number ) : any {
52
+ if ( i !== i ) {
53
+ throw new Error ( 'something went wrong' ) ;
54
+ }
55
+ return v ;
51
56
}
52
57
53
58
You can’t perform that action at this time.
0 commit comments