UNPKG

@dandre3000/is-main-thread

Version:

Check if javascript code is running in the main thread or in a worker thread. This module is compatible with web browsers, bun, deno and node.js.

2 lines 186 B
/** True if the current global scope is the main thread or false otherwise. */ export const isMainThread = typeof WorkerGlobalScope !== 'function' || !(self instanceof WorkerGlobalScope)