MCPcopy Create free account
hub / github.com/Effect-TS/effect / fillRandom

Function fillRandom

packages/effect/src/crypto/SecureRandom.ts:260–266  ·  view source on GitHub ↗
(crypto: Crypto, size: number)

Source from the content-addressed store, hash-verified

258
259// `getRandomValues` throws a `QuotaExceededError` above 65,536 bytes.
260const fillRandom = (crypto: Crypto, size: number): Uint8Array => {
261 const bytes = new Uint8Array(size)
262 for (let offset = 0; offset < size; offset += 65_536) {
263 crypto.getRandomValues(bytes.subarray(offset, offset + 65_536))
264 }
265 return bytes
266}
267
268/**
269 * Layer that provides `SecureRandom` from `getRandomValues` on the `WebCrypto`

Callers 2

SecureRandom.tsFile · 0.85
randomBytesUnsafeFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected