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.
10 lines (8 loc) • 365 B
JavaScript
const { webcrypto } = require('crypto')
// node v15 and later adds support for WebCrypto, so we load it using a conditional export that is only supported by v14 and later
module.exports =
typeof webcrypto === 'undefined'
? require('get-random-values')
: function getRandomValues(typedArray) {
return webcrypto.getRandomValues(typedArray)
}