export function isString(value: any): value is string { return value != null && typeof value === 'string'; } export function isFunction(value: any): value is Function { return typeof value === 'function'; } export function isThenable(value: any): value is Promise{ return isObject(value) && isFunction(value.then); } export function isObject(value: any): value is Object { return typeof value === 'object'; } export function get(obj: any, path: string|Array): T { if (isString(path)) { path = path.replace(/\[|\]/, '.').split('.'); } return path.reduce((result, key) => { if (isObject(result) && key) { return result[key.toString()]; } return undefined; }, obj); }