Home > Engineering > Third Party Software > Bare Runtime > Global API
Bare Global API
The Bare global is available without import. Buffer,
console, URL, the timers, queueMicrotask and
structuredClone are global too; there is no process
global (it comes from bare-process).
Properties
Bare.platform—"linux","darwin","win32","android","ios"Bare.arch—"x64","arm64","arm","ia32","mips","mipsel","riscv64"Bare.simulator— boolean, true if compiled for simulator (deprecated)Bare.argv— command line argumentsBare.pid— process IDBare.exitCode— exit code (used ifexit()called without argument)Bare.version— version string, with a leadingvBare.versions— object with dependency versions
Methods
Bare.exit([code])— immediately terminateBare.suspend([linger])— suspend process and all threads (mobile lifecycle)Bare.wakeup([deadline])— wake during suspension for limited workBare.idle()— immediately suspend event loopBare.resume()— resume after suspension
From 1.36, a linger or deadline above 2147483647
throws a RangeError.
Events
uncaughtException— unhandled JS exceptionunhandledRejection— unhandled promise rejectionbeforeExit— loop out of work, chance to schedule moreexit— process exiting (must not schedule work)suspend— process suspending (defer/cancel work)wakeup— waking during suspensionidle— idle after suspension (loop will block)resume— resuming (restart deferred work)
Sub-namespaces
Bare.Thread
Lightweight threads with synchronous joins and SharedArrayBuffer support.
Bare.Thread.isMainThread— booleanBare.Thread.self— current thread referencenew Bare.Thread(filename, source[, options])— spawn (the form since 1.32; the callback forms andThread.createare deprecated); amountoption since 1.35thread.join()— synchronous waitthread.suspend()/thread.resume()/thread.wakeup()/thread.terminate()thread.joined,Thread.self.data
A thread cannot read its file from disk: its code is passed as source, or as a bundle for a module graph, which bare-thread builds.
Bare.Addon
Native addon loading.
new Bare.Addon(url)— load an addon (since 1.31;Addon.resolve(),Addon.load()andAddon.cacheare deprecated)Bare.Addon.loaded(url)— whether an addon is loaded (1.35)Bare.Addon.seal()/Bare.Addon.sealed— stop further addons from loading (1.32)Bare.Addon.host— platform-arch string
Bare.IPC
Optional streaming communication with embedder. Returns a Duplex stream or null if not embedded.
Source:
github.com/holepunchto/bare
(src/bare.d.ts, where the API documentation lives
since 1.35) and
docs.pears.com/bare/reference/bare/runtime