MCPcopy Create free account
hub / github.com/aiscript-dev/aiscript / fillBufferDirect

Method fillBufferDirect

src/utils/random/seedrandom.ts:21–30  ·  view source on GitHub ↗
(buffer: Uint8Array)

Source from the content-addressed store, hash-verified

19 this.filledBuffer = this.buffer;
20 }
21 private fillBufferDirect(buffer: Uint8Array): Uint8Array {
22 if ((buffer.length % seedRandomBlockSize) !== 0) throw new Error(`SeedRandomWrapper.fillBufferDirect should always be called with the buffer with the length a multiple-of-${seedRandomBlockSize}!`);
23 const length = buffer.length / seedRandomBlockSize;
24 const dataView = new DataView(buffer.buffer);
25 let byteOffset = 0;
26 for (let index = 0; index < length; index++, byteOffset += seedRandomBlockSize) {
27 dataView.setInt32(byteOffset, this.rng.int32(), false);
28 }
29 return buffer;
30 }
31 protected generateBigUintByBytes(bytes: number): bigint {
32 let u8a: Uint8Array<ArrayBufferLike> = new Uint8Array(Math.ceil(bytes / 8) * 8);
33 if (u8a.length < 1 || !Number.isSafeInteger(bytes)) return 0n;

Callers 2

fillBufferMethod · 0.95
generateBytesMethod · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected