[API reference](https://jsprismarine.dev/api/index.md) / [@jsprismarine/prismarine](https://jsprismarine.dev/api/@jsprismarine/prismarine/index.md) / utils/Random

# utils/Random

## Type Aliases

### Random

> **Random** = () => `number`

Defined in: [packages/prismarine/src/utils/Random.ts:10](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/utils/Random.ts#L10)

A source of chance: a number in `[0, 1)`, the way `Math.random` gives one.

#### Returns

`number`

## Functions

### randomOf()

> **randomOf**(`server`): [`Random`](#random)

Defined in: [packages/prismarine/src/utils/Random.ts:21](https://github.com/JSPrismarine/JSPrismarine/blob/e928b08f56694af6821b757ce6b196faebd3199c/packages/prismarine/src/utils/Random.ts#L21)

The server's own source of chance, or the global one when it has none.

Written against the one method it needs rather than against `Server`, so a
stand-in server in a test satisfies it without being one.

#### Parameters

##### server

\{ `getRandom?`: () => [`Random`](#random); \} \| `null` \| `undefined`

The server the roll happened on.

#### Returns

[`Random`](#random)

The source of chance.
