From ca9ed199b61bb4cc1235a592351369dddfaca838 Mon Sep 17 00:00:00 2001 From: Joe Richey Date: Fri, 16 Jul 2021 00:08:35 -0700 Subject: [PATCH] js: Explictly list all dependancies used with the "js" feature This makes it easier to tell at a glance what parts of `wasm-bindgen` are needed for `getrandom`. See: https://github.com/tkaitchuck/aHash/issues/95#issuecomment-881152315 Signed-off-by: Joe Richey --- src/js.rs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/js.rs b/src/js.rs index 657d2ac8..6b4c8cc2 100644 --- a/src/js.rs +++ b/src/js.rs @@ -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; @@ -57,7 +57,7 @@ pub(crate) fn getrandom_inner(dest: &mut [u8]) -> Result<(), Error> { } fn getrandom_init() -> Result { - 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));