File tree Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Expand file tree Collapse file tree 2 files changed +19
-2
lines changed Original file line number Diff line number Diff line change 1+ import './polyfill' ;
2+
13/**
24 * Next function which returns `undefined` or a value of type `T`.
35 * This is used in iterators that can end with an `undefined` value, which
46 * indicates the end of iteration.
5- *
6- * @todo Rename to `UndEndNext`.
77 */
88export type UndEndNext < T > = ( ) => undefined | T ;
99
Original file line number Diff line number Diff line change 1+ if ( typeof Iterator === 'undefined' && typeof globalThis === 'object' ) {
2+ class Iterator < T > {
3+ [ Symbol . iterator ] ( ) {
4+ return this ;
5+ }
6+
7+ public find ( predicate : ( value : unknown ) => boolean ) : T | undefined {
8+ for ( const value of this as any ) if ( predicate ( value ) ) return value ;
9+ return ;
10+ }
11+ }
12+
13+ /**
14+ * The `Iterator` global class is new, so we need to check if it exists.
15+ */
16+ ( globalThis as any ) . Iterator = Iterator ;
17+ }
You can’t perform that action at this time.
0 commit comments