This commit is contained in:
2019-02-17 18:07:28 +01:00
parent c69ffb9752
commit 95cff6f702
2301 changed files with 307810 additions and 5 deletions

View File

@@ -0,0 +1,9 @@
export declare function boolean(value: any): value is boolean;
export declare function string(value: any): value is string;
export declare function number(value: any): value is number;
export declare function error(value: any): value is Error;
export declare function func(value: any): value is Function;
export declare function array<T>(value: any): value is T[];
export declare function stringArray(value: any): value is string[];
export declare function typedArray<T>(value: any, check: (value: any) => boolean): value is T[];
export declare function thenable<T>(value: any): value is Thenable<T>;

View File

@@ -0,0 +1,42 @@
/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
'use strict';
Object.defineProperty(exports, "__esModule", { value: true });
function boolean(value) {
return value === true || value === false;
}
exports.boolean = boolean;
function string(value) {
return typeof value === 'string' || value instanceof String;
}
exports.string = string;
function number(value) {
return typeof value === 'number' || value instanceof Number;
}
exports.number = number;
function error(value) {
return value instanceof Error;
}
exports.error = error;
function func(value) {
return typeof value === 'function';
}
exports.func = func;
function array(value) {
return Array.isArray(value);
}
exports.array = array;
function stringArray(value) {
return array(value) && value.every(elem => string(elem));
}
exports.stringArray = stringArray;
function typedArray(value, check) {
return Array.isArray(value) && value.every(check);
}
exports.typedArray = typedArray;
function thenable(value) {
return value && func(value.then);
}
exports.thenable = thenable;