|
@ -111,16 +111,16 @@ export namespace Functions { |
|
|
: []; |
|
|
: []; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
export function is<T extends object>(o: T | null | undefined): o is T; |
|
|
export function is<T extends object>(o: object, prop: keyof T, value?: any): o is T; |
|
|
export function is<T extends object>(o: object, prop: keyof T, value?: any): o is T; |
|
|
export function is<T extends object>(o: object, matcher: (o: object) => boolean): o is T; |
|
|
export function is<T extends object>(o: object, matcher: (o: object) => boolean): o is T; |
|
|
export function is<T extends object>( |
|
|
export function is<T extends object>( |
|
|
o: object, |
|
|
o: object, |
|
|
propOrMatcher: keyof T | ((o: any) => boolean), |
|
|
|
|
|
|
|
|
propOrMatcher?: keyof T | ((o: any) => boolean), |
|
|
value?: any |
|
|
value?: any |
|
|
): o is T { |
|
|
): o is T { |
|
|
if (typeof propOrMatcher === 'function') { |
|
|
|
|
|
return propOrMatcher(o); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
if (propOrMatcher == null) return o != null; |
|
|
|
|
|
if (typeof propOrMatcher === 'function') return propOrMatcher(o); |
|
|
|
|
|
|
|
|
return value === undefined ? (o as any)[propOrMatcher] !== undefined : (o as any)[propOrMatcher] === value; |
|
|
return value === undefined ? (o as any)[propOrMatcher] !== undefined : (o as any)[propOrMatcher] === value; |
|
|
} |
|
|
} |
|
|