Skip to content

Commit b39f169

Browse files
committed
Use overloads to describe predicate function
1 parent f0d4bea commit b39f169

File tree

2 files changed

+32
-5
lines changed

2 files changed

+32
-5
lines changed

lib/node_modules/@stdlib/iter/none-by/docs/types/index.d.ts

Lines changed: 25 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,14 +22,38 @@
2222

2323
import { Iterator } from '@stdlib/types/iter';
2424

25+
/**
26+
* Checks whether an iterated value passes a test.
27+
*
28+
* @returns boolean indicating whether an iterated value passes a test
29+
*/
30+
type Nullary = () => boolean;
31+
32+
/**
33+
* Checks whether an iterated value passes a test.
34+
*
35+
* @param value - iterated value
36+
* @returns boolean indicating whether an iterated value passes a test
37+
*/
38+
type Unary = ( value: any ) => boolean;
39+
40+
/**
41+
* Checks whether an iterated value passes a test.
42+
*
43+
* @param value - iterated value
44+
* @param i - iteration index
45+
* @returns boolean indicating whether an iterated value passes a test
46+
*/
47+
type Binary = ( value: any, i: number ) => boolean;
48+
2549
/**
2650
* Checks whether an iterated value passes a test.
2751
*
2852
* @param value - iterated value
2953
* @param i - iteration index
3054
* @returns boolean indicating whether an iterated value passes a test
3155
*/
32-
type Predicate = ( value?: any, i?: number ) => boolean;
56+
type Predicate = Nullary | Unary | Binary;
3357

3458
/**
3559
* Tests whether every iterated value fails a test implemented by a predicate function.

lib/node_modules/@stdlib/iter/none-by/docs/types/test.ts

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -44,19 +44,22 @@ function iterator() {
4444
/**
4545
* Predicate function.
4646
*
47+
* @param _v - iterated value
48+
* @param i - iteration index
4749
* @returns a boolean
4850
*/
49-
function predicate1() {
50-
return false;
51+
function predicate1( _v: any, i: number ): boolean { // tslint:disable-line:variable-name
52+
return ( i > 5 );
5153
}
5254

5355
/**
5456
* Predicate function.
5557
*
58+
* @param v - iterated value
5659
* @returns a boolean
5760
*/
58-
function predicate2() {
59-
return true;
61+
function predicate2( v: any ): boolean {
62+
return ( v !== v );
6063
}
6164

6265

0 commit comments

Comments
 (0)