forked from microsoft/vscode-python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathiterableTextRange.ts
More file actions
30 lines (26 loc) · 963 Bytes
/
iterableTextRange.ts
File metadata and controls
30 lines (26 loc) · 963 Bytes
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
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
'use strict';
import { ITextRange, ITextRangeCollection } from './types';
export class IterableTextRange<T extends ITextRange> implements Iterable<T> {
constructor(private textRangeCollection: ITextRangeCollection<T>) {}
public [Symbol.iterator](): Iterator<T> {
let index = -1;
return {
next: (): IteratorResult<T> => {
if (index < this.textRangeCollection.count - 1) {
return {
done: false,
value: this.textRangeCollection.getItemAt((index += 1))
};
} else {
return {
done: true,
// tslint:disable-next-line:no-any
value: undefined as any
};
}
}
};
}
}