Documentation for automated readers
A curated documentation index is available at: https://grafana.com/llms.txt
A complete documentation index is available at: https://grafana.com/llms-full.txt
These indexes can help with page discovery before fetching individual documents.
This page is also available in Markdown, which may be easier for automated readers and AI tools to parse than HTML. The Markdown version is available at https://grafana.com/docs/k6/next/javascript-api/crypto/getrandomvalues.md, or by sending Accept: text/markdown to https://grafana.com/docs/k6/next/javascript-api/crypto/getrandomvalues/. For broader documentation discovery, the curated index is available at https://grafana.com/llms.txt and the complete index is available at https://grafana.com/llms-full.txt.
This is documentation for the next version of Grafana k6 documentation. For the latest stable release, go to the latest version.
getRandomValues
The getRandomValues() method fills the passed TypedArray with cryptographically sound random values.
Usage
getRandomValues(typedArray)Parameters
| Name | Type | Description |
|---|---|---|
typedArray | TypedArray | An integer-based TypedArray to fill with random values. Accepted TypedArray specific types are: Int8Array, Uint8Array, Uint8ClampedArray, Int16Array, Uint16Array, Int32Array, or Uint32Array. |
Return Value
The same array is passed as the typedArray parameter with its contents replaced with the newly generated random numbers. The typedArray parameter is modified in place, and no copy is made.
Throws
| Type | Description |
|---|---|
QuotaExceededError | Thrown when typedArray is too large and its byteLength exceeds 65536. |
Example
export default function () {
const array = new Uint32Array(10);
crypto.getRandomValues(array);
for (const num of array) {
console.log(num);
}
}Was this page helpful?
Related resources from Grafana Labs

