bun-specific js bindings
| Category | API | Status | Note |
|---|---|---|---|
| Entry point | |||
| Bun global | bun(), is_bun() | 🧪 Tested | is_bun() guards non-Bun runtimes |
| Process | |||
| Process info | argv(), cwd(), main_(), version() | 🧪 Tested | |
| Environment | env(), env_get() | 🚧 Partially | |
| Build info | revision() | 🚧 Partially | |
| Exit | exit(code?) | 🚧 Partially | |
| File I/O | |||
| Read | file_text(), file_arrayBuffer() | 🧪 Tested | Bun.file(path).text() / .arrayBuffer() |
| Write | write(path, data) | 🧪 Tested | Returns bytes written |
| Delete | unlink_sync(path) | 🧪 Tested | |
| Subprocess | |||
| Spawn | spawn(SpawnOptions) | 🧪 Tested | Subprocess exposes pid, exitCode, exited(), kill(), stdio |
| Spawn (sync) | spawnSync() | 🚧 Partially | |
| Lookup | which(cmd) | 🧪 Tested | |
| HTTP server | |||
| Serve | serve(port?, hostname?, handler) | 🚧 Partially | Server exposes port, hostname, stop() |
| Hashing / crypto | |||
| Hash | hash_(data, algorithm?) | 🧪 Tested | |
| Passwords | password_hash(), password_verify() | 🧪 Tested | Argon2 by default |
| UUID | random_uuid_v7() | 🧪 Tested | |
| CryptoHasher | new(), update(), digest_hex/base64/buffer() | 🚧 Partially | |
| Glob | |||
| Matching | Glob(), match_(), scan(cwd?) | 🚧 Partially | |
| Test runner | |||
| Define | test_(), test_async() | 🧪 Tested | bun test; this module's own suite uses them |
| Assert | expect() → toBe, toEqual, toContain, toBeTruthy, toBeFalsy, toBeNull, toBeDefined, toBeUndefined | 🧪 Tested | |
| Misc | |||
| Timing | nanoseconds(), sleep(ms) | 🧪 Tested | |
| Strings | escapeHTML(), stringWidth() | 🧪 Tested | |
| Lazy promises | peek(v) | 🚧 Partially |
# moon.mod
import {
"mizchi/js_core@0.13.0",
"mizchi/js_bun@0.13.0",
}# moon.pkg
import {
"mizchi/js_core" @core,
"mizchi/js_bun" @bun,
}///|
pub async fn read_config() -> String {
@bun.bun().file_text("config.json")
}#external
pub type Bunfn[E : Show + Error] Bun::test_(self : Bun, name : String, f : (TestContext) -> Unit raise E) -> Unit#external
pub type CryptoHasher#deprecated("use `CryptoHasher(..)` instead")
fn CryptoHasher::new(algorithm : String) -> CryptoHasher#external
pub type Expectation#external
pub type Glob#external
pub type Server#deprecated("use `SpawnOptions(..)` instead")
fn SpawnOptions::new(cmd : Array[String]) -> SpawnOptions#external
pub type Subprocess#external
pub type TestContextfn unlink_sync(path : String) -> Unit