Add is.urlInstance (#60)
This commit is contained in:
parent
c8736c2972
commit
3bdaf21475
3 changed files with 23 additions and 1 deletions
|
|
@ -48,7 +48,8 @@ export const enum TypeName {
|
|||
ArrayBuffer = 'ArrayBuffer',
|
||||
SharedArrayBuffer = 'SharedArrayBuffer',
|
||||
DataView = 'DataView',
|
||||
Promise = 'Promise'
|
||||
Promise = 'Promise',
|
||||
URL = 'URL'
|
||||
}
|
||||
|
||||
const toString = Object.prototype.toString;
|
||||
|
|
@ -177,6 +178,7 @@ namespace is { // tslint:disable-line:no-namespace
|
|||
export const dataView = isObjectOfType<DataView>(TypeName.DataView);
|
||||
|
||||
export const directInstanceOf = <T>(instance: any, klass: Class<T>): instance is T => Object.getPrototypeOf(instance) === klass.prototype;
|
||||
export const urlInstance = (value: any): value is URL => isObjectOfType<URL>(TypeName.URL)(value);
|
||||
|
||||
export const truthy = (value: any) => Boolean(value);
|
||||
export const falsy = (value: any) => !value;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue