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 · Runtime · all subjects

bun apis/random & uuid

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

Random UUID generation: Bun.randomUUIDv7

Bun provides Bun.randomUUIDv7() for generating version 7 UUIDs.

Bun.randomUUIDv7() generates monotonic UUID v7

Bun.randomUUIDv7() returns a UUID v7 string, which is monotonic and suitable for sorting and databases. The timestamp parameter defaults to the current time in milliseconds. UUID v7 is a 128-bit value that encodes the current timestamp, a random value, and a counter. The counter is atomic and threadsafe. Pass "buffer" as the encoding to get a 16-byte buffer instead of a string. base64 and base64url encodings are also supported.

Bun.randomUUIDv7() signature and encodings

Bun.randomUUIDv7 has these overloads: function randomUUIDv7(encoding?: "hex" | "base64" | "base64url" = "hex", timestamp?: number = Date.now()): string; function randomUUIDv7(encoding: "buffer", timestamp?: number = Date.now()): Buffer; function randomUUIDv7(timestamp?: number = Date.now()): string;

Example: Bun.randomUUIDv7 basic usage

import { randomUUIDv7 } from "bun"; const id = randomUUIDv7(); // => "0192ce11-26d5-7dc3-9305-1426de888c5a"

Give your agent this brain