UNPKG

get-random-values-esm

Version:

A wrapper that rebundles [`get-random-values`](https://www.npmjs.com/package/get-random-values) into ESM, so you can use it in your `vite`, `skypack`, or wherever you need ESM.

15 lines (11 loc) 443 B
// Strict ESM env, designed to run outside Node.js in envs that provide WebCrypto (deno, browsers, etc) export default function getRandomValues(typedArray) { const crypto = typeof window !== 'undefined' && 'crypto' in window ? window.crypto : globalThis.crypto if (!crypto || !crypto.getRandomValues) { throw new Error('WebCrypto not available in this environment') } return crypto.getRandomValues(typedArray) }