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

Function nextIntUnsafe

packages/effect/src/Crypto.ts:232–243  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

230 const nextDoubleUnsafe = (): number => readUint53(randomBytesUnsafe(7)) / 2 ** 53
231
232 const nextIntUnsafe = (): number => {
233 while (true) {
234 const bytes = randomBytesUnsafe(7)
235 const value = readUint53(bytes)
236 if ((bytes[0] & 0x20) === 0) {
237 return value + Number.MIN_SAFE_INTEGER
238 }
239 if (value < Number.MAX_SAFE_INTEGER) {
240 return value + 1
241 }
242 }
243 }
244
245 return Crypto.of({
246 [TypeId]: TypeId,

Callers 1

makeFunction · 0.70

Calls 1

readUint53Function · 0.85

Tested by

no test coverage detected