Skip to content

Commit 743dd34

Browse files
committed
Import destructuring
Signed-off-by: Richie Bendall <[email protected]>
1 parent 4f69e0b commit 743dd34

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

index.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
// TODO: When targeting Node.js 16, use `crypto.webcrypto.getRandomValues` to interop with the browser code and when targeting Node.js 18, only use the browser code
22
import {promisify} from 'node:util';
3-
import crypto from 'node:crypto';
3+
import {randomBytes} from 'node:crypto';
44
import {createStringGenerator, createAsyncStringGenerator} from './core.js';
55

6-
const randomBytesAsync = promisify(crypto.randomBytes);
6+
const randomBytesAsync = promisify(randomBytes);
77

8-
export default createStringGenerator((byteLength, type, length) => crypto.randomBytes(byteLength).toString(type).slice(0, length), size => new Uint8Array(crypto.randomBytes(size)));
8+
export default createStringGenerator((byteLength, type, length) => crypto.randomBytes(byteLength).toString(type).slice(0, length), size => new Uint8Array(randomBytes(size)));
99
export const cryptoRandomStringAsync = createAsyncStringGenerator(async (byteLength, type, length) => {
1010
const buffer = await randomBytesAsync(byteLength);
1111
return buffer.toString(type).slice(0, length);

0 commit comments

Comments
 (0)