Skip to content

Commit 30308ae

Browse files
authored
js: Explictly list all dependancies used with the "js" feature (#220)
This makes it easier to tell at a glance what parts of `wasm-bindgen` are needed for `getrandom`. See: tkaitchuck/aHash#95 (comment) Signed-off-by: Joe Richey <[email protected]>
1 parent dcf452b commit 30308ae

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

src/js.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@ use crate::Error;
1010
extern crate std;
1111
use std::thread_local;
1212

13-
use js_sys::Uint8Array;
14-
use wasm_bindgen::{prelude::*, JsCast};
13+
use js_sys::{global, Uint8Array};
14+
use wasm_bindgen::{prelude::wasm_bindgen, JsCast, JsValue};
1515

1616
// Maximum is 65536 bytes see https://developer.mozilla.org/en-US/docs/Web/API/Crypto/getRandomValues
1717
const BROWSER_CRYPTO_BUFFER_SIZE: usize = 256;
@@ -57,7 +57,7 @@ pub(crate) fn getrandom_inner(dest: &mut [u8]) -> Result<(), Error> {
5757
}
5858

5959
fn getrandom_init() -> Result<RngSource, Error> {
60-
let global: Global = js_sys::global().unchecked_into();
60+
let global: Global = global().unchecked_into();
6161
if is_node(&global) {
6262
let crypto = require("crypto").map_err(|_| Error::NODE_CRYPTO)?;
6363
return Ok(RngSource::Node(crypto));

0 commit comments

Comments
 (0)