@buff-beacon-project/curby-client • Docs
@buff-beacon-project/curby-client / ByteHelper
Interface: ByteHelper
A helper for working with randomness.
Contains methods for reading bits, shuffling arrays, and more.
Copy // BytesHelper from a randomness call
const randomness = await client . randomness ()
// Get a list of unsigned numbers formed by reading 10 bits at a time
const bits = Array . from ( randomness . bits ( 10 ))
// Get a shuffled version of an array
const array = [ 1 , 2 , 3 , 4 , 5 ]
const shuffled = randomness . shuffled (array)
// shuffled = [3, 1, 5, 2, 4] Property
Type
Description
Defined in
The maximum length an array can be for shuffling
The unix timestamp of the randomness
applyShuffle (arr): void
Applies a shuffle to an array
Parameters
Returns
void
Example
Defined in
src/byte-helper.ts:95arrow-up-right
bits (n): Generator<number, any, any>
A generator for reading unsigned numbers
Parameters
The number of bits to read at a time
Returns
Generator<number, any, any>
Example
Defined in
src/byte-helper.ts:47arrow-up-right
bytes (): Uint8Array
The bytes of the randomness
Returns
Uint8Array
Defined in
src/byte-helper.ts:33arrow-up-right
reader (): BitReader
The a BitReader for the randomness
Returns
BitReader
See
https://github.com/buff-beacon-project/rand-utilsarrow-up-right
Defined in
src/byte-helper.ts:65arrow-up-right
shuffled (arr): any[]
Shuffles an array using the randomness
Parameters
Returns
any[]
Example
Defined in
src/byte-helper.ts:82arrow-up-right
signedBits (n): Generator<number, any, any>
A generator for reading signed numbers
Parameters
Returns
Generator<number, any, any>
Defined in
src/byte-helper.ts:55arrow-up-right
stream (): BitStream
The BitStream for the randomness
Returns
BitStream
Defined in
src/byte-helper.ts:59arrow-up-right
unfold (cb): Generator<any, any, any>
Unfolds the randomness
Parameters
A function to call for each iteration
Returns
Generator<any, any, any>
Example
Defined in
src/byte-helper.ts:114arrow-up-right