Add isArrayLike builtin (#453)

This commit is contained in:
Max Graey
2019-02-27 22:47:52 +02:00
committed by Daniel Wirtz
parent e8b0767143
commit aad263e670
8 changed files with 327 additions and 212 deletions

View File

@ -128,6 +128,8 @@ declare function isReference<T>(value?: any): value is object | string;
declare function isString<T>(value?: any): value is string | String;
/** Tests if the specified type *or* expression can be used as an array. Compiles to a constant. */
declare function isArray<T>(value?: any): value is Array<any>;
/** Tests if the specified type *or* expression can be used as an array like object. Compiles to a constant. */
declare function isArrayLike<T>(value?: any): value is ArrayLike<any>;
/** Tests if the specified type *or* expression is of a function type. Compiles to a constant. */
declare function isFunction<T>(value?: any): value is (...args: any) => any;
/** Tests if the specified type *or* expression is of a nullable reference type. Compiles to a constant. */
@ -559,6 +561,11 @@ declare class DataView {
toString(): string;
}
interface ArrayLike<T> {
length: i32;
// [key: number]: T;
}
/** Interface for a typed view on an array buffer. */
interface ArrayBufferView<T> {
[key: number]: T;