face-api/src/env/isBrowser.ts

9 lines
352 B
TypeScript
Raw Normal View History

2020-08-18 13:54:53 +02:00
export function isBrowser(): boolean {
return typeof window === 'object'
&& typeof document !== 'undefined'
&& typeof HTMLImageElement !== 'undefined'
&& typeof HTMLCanvasElement !== 'undefined'
&& typeof HTMLVideoElement !== 'undefined'
&& typeof ImageData !== 'undefined'
&& typeof CanvasRenderingContext2D !== 'undefined'
}