Skip to content

Commit 522c71a

Browse files
committed
Ebynerator, VBArray
1 parent 1df3684 commit 522c71a

1 file changed

Lines changed: 61 additions & 0 deletions

File tree

src/lib/scriptHost.d.ts

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -170,3 +170,64 @@ declare var WScript: {
170170
*/
171171
Sleep(intTime: number): void;
172172
};
173+
174+
/*
175+
* Allows enumerating over a COM collection, which may not have indexed item access
176+
*/
177+
interface Enumerator<T> {
178+
/*
179+
* Returns true if the current item is the last one in the collection, or the collection is empty, or the current item is undefined
180+
*/
181+
atEnd(): boolean;
182+
/*
183+
* Returns the current item in the collection
184+
*/
185+
item(): T;
186+
/*
187+
* Resets the current item in the collection to the first item. If there are no items in the collection, the current item is set to undefined.
188+
*/
189+
moveFirst(): void;
190+
/*
191+
* Moves the current item to the next item in the collection. If the enumerator is at the end of the collection or the collection is empty, the current item is set to undefined.
192+
*/
193+
moveNext(): void;
194+
}
195+
interface EnumeratorConstructor {
196+
new <T>(collection: any): Enumerator<T>;
197+
new (collection: any): Enumerator<any>;
198+
}
199+
declare var Enumerator: EnumeratorConstructor;
200+
201+
/*
202+
* Enables reading from a COM safe array, which might have an alternate lower bound, or multiple dimensions
203+
*/
204+
interface VBArray<T> {
205+
/*
206+
* Returns the number of dimensions (1-based).
207+
*/
208+
dimensions(): number;
209+
/*
210+
* Takes an index for each dimension in the array, and returns the item at the corresponding location.
211+
*/
212+
getItem(dimension1Index: number, ...dimensionNIndexes: number[]): T;
213+
/*
214+
* Returns the smallest available index for a given dimension
215+
* @param dimension 1-based dimension (defaults to 1)
216+
*/
217+
lbound(dimension?: number): number;
218+
/*
219+
* Returns the largest available index for a given dimension
220+
* @param dimension 1-based dimension (defaults to 1)
221+
*/
222+
ubound(dimension?: number): number;
223+
/*
224+
* Returns a Javascript array with all the elements in the VBArray. If there are multiple dimensions, each successive dimension is appended to the end of the array.
225+
* [[1,2,3],[4,5,6]] => [1,2,3,4,5,6]
226+
*/
227+
toArray(): T[];
228+
}
229+
interface VBArrayConstructor {
230+
new <T>(safeArray: any): VBArray<T>;
231+
new (safeArray: any): VBArray<any>;
232+
}
233+
declare var VBArray: VBArrayConstructor;

0 commit comments

Comments
 (0)