Skip to content

Commit

Permalink
js: Explictly list all dependancies used with the "js" feature (#220)
Browse files Browse the repository at this point in the history
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 <joerichey@google.com>
  • Loading branch information
josephlr authored Jul 16, 2021
1 parent dcf452b commit 30308ae
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions src/js.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@ use crate::Error;
extern crate std;
use std::thread_local;

use js_sys::Uint8Array;
use wasm_bindgen::{prelude::*, JsCast};
use js_sys::{global, Uint8Array};
use wasm_bindgen::{prelude::wasm_bindgen, JsCast, JsValue};

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

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

0 comments on commit 30308ae

Please sign in to comment.