File tree Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Expand file tree Collapse file tree 1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -78,7 +78,7 @@ fn getrandom_init() -> Result<RngSource, Error> {
7878 return Ok ( RngSource :: Browser ( crypto) ) ;
7979 }
8080
81- return Ok ( RngSource :: Node ( node_require ( "crypto" ) ) ) ;
81+ return Ok ( RngSource :: Node ( MODULE . require ( "crypto" ) ) ) ;
8282}
8383
8484#[ wasm_bindgen]
@@ -102,12 +102,17 @@ extern "C" {
102102 #[ wasm_bindgen( method, js_name = getRandomValues, structural) ]
103103 fn get_random_values ( me : & BrowserCrypto , buf : & mut [ u8 ] ) ;
104104
105- #[ wasm_bindgen( js_name = require) ]
106- fn node_require ( s : & str ) -> NodeCrypto ;
107-
108105 #[ derive( Clone , Debug ) ]
109106 type NodeCrypto ;
110107
111108 #[ wasm_bindgen( method, js_name = randomFillSync, structural) ]
112109 fn random_fill_sync ( me : & NodeCrypto , buf : & mut [ u8 ] ) ;
110+
111+ type NodeModule ;
112+
113+ #[ wasm_bindgen( js_name = module) ]
114+ static MODULE : NodeModule ;
115+
116+ #[ wasm_bindgen( method) ]
117+ fn require ( this : & NodeModule , s : & str ) -> NodeCrypto ;
113118}
You can’t perform that action at this time.
0 commit comments