export const mainThreadName = "main thread" ; export type Thread = LuaThread | typeof mainThreadName ; export function isThread ( val ) { return type ( val ) === "thread" ; } export const mainThread = ( ( ) => { const LUA_RIDX_MAINTHREAD = 1 ; const registryMainThread = debug . getregistry ( ) [ LUA_RIDX_MAINTHREAD ] ; return isThread ( registryMainThread ) ? registryMainThread : mainThreadName ; } ) ( ) ;