new·The score now tells you which way it movedA brain's exam only ever grows: its own material writes questions, and so does every question a real caller asked and did not get answered. The score is a percentage over that growing set, so a brain that learned more could post a smaller number — and this week three did. One of them answered two MORE questions than the week before and showed eighteen points less. Printed as a single percentage, that reads as decline to a reader and as punishment to anyone who contributes material.all news →
mozg.beta
Sign in

Bun · all subjects

node.js compatibility

9 notes, read out of this brain and free to use. Each one was extracted from a source and is re-checked against its exam.

Remix HMR script limitation with Bun

The generated `hmr.ts` script loads `remix/node-tsx`, which relies on `module.registerHooks()`. Bun does not implement that API yet, so the script fails under Bun. Use `bun --watch` to restart the server on changes instead.

JSON serialization for Node.js process IPC

To communicate with a Node.js process using IPC, set serialization: 'json' in the options passed to Bun.spawn().

Bun implements fs.watch from node:fs module

Bun implements the node:fs module, including the fs.watch function for listening for file system changes.

Buffer.toBase64() for base64 encoding

Node.js Buffer extends Uint8Array, so you can encode buffers using toBase64(). Example: Buffer.from("hello world").toBase64() returns "aGVsbG8gd29ybGQ=".

Buffer.from() with base64 encoding for decoding

Node.js compatible base64 decoding is available using Buffer.from(encoded, "base64"). The resulting Buffer is an instance of Uint8Array. Example: Buffer.from("aGVsbG8gd29ybGQ=", "base64").toString("utf8") returns "hello world".

Bun is a drop-in replacement for Node.js

Bun is designed as a drop-in replacement for Node.js. It is a fast JavaScript runtime written in Rust and powered by JavaScriptCore, reducing startup time and memory usage.

Bun processes start 4x faster than Node.js

Bun processes start approximately 4 times faster than Node.js, as stated in the design goals.

Bun supports Node.js globals and modules

Bun supports Node.js-compatible globals like `process`, `Buffer`, and `__dirname`, as well as built-in modules for OS-level tasks such as `node:fs` for reading/writing files and `node:http` and `node:net` for networking. Node.js compatibility is an ongoing effort.

@types/bun package for TypeScript support

Install `@types/bun` as a dev dependency to get TypeScript type declarations for Bun. Use `bun add -d @types/bun`. This fixes TypeScript errors on the Bun global in existing projects.

Give your agent this brain