mirror of
https://github.com/vercel-labs/scriptc.git
synced 2026-11-07 08:33:50 +08:00
randomFillSync accepts every TypedArray, DataView, Buffer, ArrayBuffer and SharedArrayBuffer and returns its argument at its own type. Offsets and sizes count elements and are checked in bytes with Node 24.22's ERR_OUT_OF_RANGE and ERR_INVALID_ARG_TYPE errors. randomFill fills the same buffers and calls back in a later macrotask, or synchronously when nothing is filled, as Node does. randomInt takes a callback in both forms, and its errors carry Node's received values and the max or "max - min" label. Values come from a 6 KiB cache, as in Node, so a callback runs on the next tick while the cache has data and after an asynchronous refill when it is empty. randomUUID and the new randomUUIDv7 validate options.disableEntropyCache and draw from a 128-UUID batch unless it is set. A non-u8 view passed to randomFillSync no longer needs a Uint8Array type, and the bytes callback adapters pass views of any element kind and dyn values through.