export function isNotEmpty(obj: T | undefined | null): obj is T { return obj !== undefined && obj !== null } export function isEmpty(obj: any | undefined | null): obj is undefined | null { return obj === undefined || obj === null } export function isString(obj: any): obj is string { return Object.prototype.toString.call(obj) === '[object String]' } export function isPromise(obj: any): obj is Promise { return Object.prototype.toString.call(obj) === '[object Promise]' } export function isArray(obj: any | undefined | null): obj is T[] { return isNotEmpty(obj) && Array.isArray(obj) } export function urlJoin(...urls: string[]) { return ['/', ...urls] .join('/') .replace(/\/+/g, '/') .replace(/.*http:\/*/, 'http://') .replace(/.*https:\/*/, 'https://') }