Files
azuredatastudio/dataprotocol-node/client/src/utils/is.ts
Anthony Dresser 0cc7c540a9 Revert "Update dataprotocol client" (#500)
* Revert "Fix #494 Connection error when connecting to an Azure SQL Server with no firewall rule (#497)"

This reverts commit edd867b6fc.

* Revert "Update dataprotocol client (#418)"

This reverts commit 7808496416.
2018-01-16 15:55:31 -08:00

55 lines
1.6 KiB
TypeScript

/* --------------------------------------------------------------------------------------------
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the Source EULA. See License.txt in the project root for license information.
* ------------------------------------------------------------------------------------------ */
'use strict';
const toString = Object.prototype.toString;
export function defined(value: any): boolean {
return typeof value !== 'undefined';
}
export function undefined(value: any): boolean {
return typeof value === 'undefined';
}
export function nil(value: any): boolean {
return value === null;
}
export function boolean(value: any): value is boolean {
return value === true || value === false;
}
export function string(value: any): value is string {
return toString.call(value) === '[object String]';
}
export function number(value: any): value is number {
return toString.call(value) === '[object Number]';
}
export function error(value: any): value is Error {
return toString.call(value) === '[object Error]';
}
export function func(value: any): value is Function {
return toString.call(value) === '[object Function]';
}
export function array<T>(value: any): value is T[] {
return Array.isArray(value);
}
export function stringArray(value: any): value is string[] {
return array(value) && (<any[]>value).every(elem => string(elem));
}
export function typedArray<T>(value: any, check: (value: any) => boolean): value is T[] {
return Array.isArray(value) && (<any[]>value).every(check);
}
export function thenable<T>(value: any): value is Thenable<T> {
return value && func(value.then);
}