OverviewFilesCommitsIssuesDocsReleasesPeers

holepunchto-kb / skills / bare / api-extract.json

31 lines · json ref:
{
  "repo": "bare",
  "timestamp": "2026-01-16T23:39:31.180Z",
  "entryPoint": "index.js",
  "exports": {
    "packageJson": {}
  },
  "api": {},
  "readme": {
    "content": "<h1>\n  <picture>\n    <source media=\"(prefers-color-scheme: dark)\" srcset=\"./media/logo-light.svg\">\n    <img alt=\"Bare\" src=\"./media/logo-dark.svg\" height=\"80\">\n  </picture>\n</h1>\n\nSmall and modular JavaScript runtime for desktop and mobile. Like Node.js, it provides an asynchronous, event-driven architecture for writing applications in the lingua franca of modern software. Unlike Node.js, it makes embedding and cross-device support core use cases, aiming to run just as well on your phone as on your laptop. The result is a runtime ideal for networked, peer-to-peer applications that can run on a wide selection of hardware.\n\n```sh\nnpm i -g bare\n```\n\n## Usage\n\n```console\nbare [flags] <filename> [...args]\n\nEvaluate a script or start a REPL session if no script is provided.\n\nArguments:\n  <filename>            The name of a script to evaluate\n  [...args]             Additional arguments made available to the script\n\nFlags:\n  --version|-v          Print the Bare version\n  --eval|-e <script>   ",
    "sections": [
      "intro",
      "usage",
      "architecture",
      "api",
      "building",
      "platform support",
      "modules",
      "license"
    ],
    "hasApi": true,
    "hasExamples": true,
    "exampleCount": 9,
    "examples": [
      "## Usage",
      "The specified `<script>` or `<filename>` is run using `Module.load()`. For more information on the module system and the supported formats, see <https://github.com/holepunchto/bare-module>.\n\n## Architecture\n\nBare is built on top of <https://github.com/holepunchto/libjs>, which provides low-level bindings to V8 in an engine independent manner, and <https://github.com/libuv/libuv>, which provides an asynchronous I/O event loop. Bare itself only adds a few missing pieces on top to support a wider ecosystem of modules:\n\n1. A module system supporting both CJS and ESM with bidirectional interoperability between the two.\n2. A native addon system supporting both statically and dynamically linked addons.\n3. Light-weight thread support with synchronous joins and shared array buffer support.\n\nEverything else if left to userland modules to implement using these primitives, keeping the runtime itself succinct and _bare_. By abstracting over both the underlying JavaScript engine using `libjs` and platform I/O operations using `libuv`, Bare allows module authors to implement native addons that can run on any JavaScript engine that implements the `libjs` ABI and any system that `libuv` supports.\n\n## API\n\n### `Bare`\n\nThe core JavaScript API of Bare is available through the global `Bare` namespace.\n\n#### `Bare.platform`\n\nThe identifier of the operating system for which Bare was compiled. The possible values are `android`, `darwin`, `ios`, `linux`, and `win32`.\n\n#### `Bare.arch`\n\nThe identifier of the processor architecture for which Bare was compiled. The possible values are `arm`, `arm64`, `ia32`, `mips`, `mipsel`, and `x64`.\n\n#### `Bare.argv`\n\nThe command line arguments passed to the process when launched.\n\n#### `Bare.pid`\n\nThe ID of the current process.\n\n#### `Bare.exitCode`\n\nThe code that will be returned once the process exits. If the process is exited using `Bare.exit()` without specifying a code, `Bare.exitCode` is used.\n\n#### `Bare.version`\n\nThe Bare version string.\n\n#### `Bare.versions`\n\nAn object containing the version strings of Bare and its dependencies.\n\n#### `Bare.exit([code])`\n\nImmediately terminate the process or current thread with an exit status of `code` which defaults to `Bare.exitCode`.\n\n#### `Bare.suspend([linger])`\n\nSuspend the process and all threads. This will emit a `suspend` event signalling that all work should stop immediately. When all work has stopped and the process would otherwise exit, an `idle` event will be emitted. If the process is not resumed from an `idle` event listener, the loop will block until the process is resumed.\n\n#### `Bare.wakeup([deadline])`\n\nWake the process and all threads during suspension. This will emit a `wakeup` event signalling that work may be performed until `deadline` is reached.\n\n#### `Bare.idle()`\n\nImmediately suspend the event loop and trigger the `idle` event.\n\n#### `Bare.resume()`\n\nResume the process and all threads after suspension. This can be used to cancel suspension after the `suspend` event has been emitted and up until all `idle` event listeners have run.\n\n#### `Bare.on('uncaughtException', err)`\n\nEmitted when a JavaScript exception is thrown within an execution context without being caught by any exception handlers within that execution context. By default, uncaught exceptions are printed to `stderr` and the processes aborted. Adding an event listener for the `uncaughtException` event overrides the default behavior.\n\n#### `Bare.on('unhandledRejection', reason, promise)`\n\nEmitted when a JavaScript promise is rejected within an execution context without that rejection being handled within that execution context. By default, unhandled rejections are printed to `stderr` and the process aborted. Adding an event listener for the `unhandledRejection` event overrides the default behavior.\n\n#### `Bare.on('beforeExit', code)`\n\nEmitted when the loop runs out of work and before the process or current thread exits. This provides a chance to schedule additional work and keep the process from exiting. If additional work is scheduled, `beforeExit` will be emitted again once the loop runs out of work.\n\nIf the process is exited explicitly, such as by calling `Bare.exit()` or as the result of an uncaught exception, the `beforeExit` event will not be emitted.\n\n#### `Bare.on('exit', code)`\n\nEmitted when the process or current thread exits. If the process is forcefully terminated from an `exit` event listener, the remaining listeners will not run.\n\n> [!CAUTION]  \n> Additional work **MUST NOT** be scheduled from an `exit` event listener.\n\n#### `Bare.on('suspend', linger)`\n\nEmitted when the process or current thread is suspended. Any in-progress or outstanding work, such as network activity or file system access, should be deferred, cancelled, or paused when the `suspend` event is emitted and no additional work should be scheduled. A `suspend` event listener may call `Bare.resume()` to cancel the suspension.\n\n#### `Bare.on('wakeup', deadline)`\n\nEmitted when the process or current thread wakes up during suspension. Once the process becomes idle, or if the process is not idle by the time `deadline` has passed, the process will suspend itself again and an `idle` event be emitted. A `wakeup` event listener may call `Bare.resume()` to resume the process.\n\n#### `Bare.on('idle')`\n\nEmitted when the process or current thread becomes idle after suspension. After all handlers have run, the event loop will block and no additional work be performed until the process is resumed. An `idle` event listener may call `Bare.resume()` to cancel the suspension.\n\n#### `Bare.on('resume')`\n\nEmitted when the process or current thread resumes after suspension. Deferred and paused work should be continued when the `resume` event is emitted and new work may again be scheduled.\n\n### Lifecycle",
      "### `Bare.Addon`\n\nThe `Bare.Addon` namespace provides support for loading native addons, which are typically written in C/C++ and distributed as shared libraries.\n\n> [!NOTE]  \n> This is an advanced API that users should never have to interact with directly.\n\n#### `Addon.cache`\n\nThe global cache of loaded addons.\n\n#### `Addon.host`\n\nThe target triplet identifying the current addon host.\n\n#### `const url = Addon.resolve(specifier, parentURL[, options])`\n\nResolve a native addon specifier by searching for a static native addon or dynamic object library matching `specifier` imported from `parentURL`.\n\nOptions are reserved.\n\n#### `const addon = Addon.load(url[, options])`\n\nLoad a static or dynamic native addon identified by `url`. If `url` is not a static native addon, Bare will instead look for a matching dynamic object library.\n\nOptions are reserved.\n\n#### `addon.url`\n\nThe WHATWG `URL` identifier of the addon.\n\n#### `addon.exports`\n\nThe exports of the addon.\n\n### `Bare.Thread`\n\nThe `Bare.Thread` namespace provides support for lightweight threads. Threads are similar to workers in Node.js, but provide only minimal API surface for creating and joining threads.\n\n> [!NOTE]  \n> This is an advanced API that users should never have to interact with directly.\n\n#### `Thread.isMainThread`\n\n`true` if the current thread is the main thread.\n\n#### `Thread.self`\n\nA reference to the current thread as a `ThreadProxy` object. Will be `null` on the main thread.\n\n#### `Thread.self.data`\n\nThe data that was passed to the current thread on creation. Will be `null` if no data was passed.\n\n#### `const thread = new Thread([filename][, options][, callback])`\n\nStart a new thread that will run the contents of `filename`. If `callback` is provided, its function body will be treated as the contents of `filename` and invoked on the new thread with `Thread.self.data` passed as an argument.\n\nOptions include:"
    ]
  },
  "patterns": []
}