File tree 1 file changed +9
-4
lines changed
1 file changed +9
-4
lines changed Original file line number Diff line number Diff line change @@ -76,7 +76,7 @@ fn getrandom_init() -> Result<RngSource, Error> {
76
76
return Ok ( RngSource :: Browser ( crypto) ) ;
77
77
}
78
78
79
- return Ok ( RngSource :: Node ( node_require ( "crypto" ) ) ) ;
79
+ return Ok ( RngSource :: Node ( MODULE . require ( "crypto" ) ) ) ;
80
80
}
81
81
82
82
#[ wasm_bindgen]
@@ -102,12 +102,17 @@ extern "C" {
102
102
#[ wasm_bindgen( method, js_name = getRandomValues, structural) ]
103
103
fn get_random_values ( me : & BrowserCrypto , buf : & mut [ u8 ] ) ;
104
104
105
- #[ wasm_bindgen( js_name = require) ]
106
- fn node_require ( s : & str ) -> NodeCrypto ;
107
-
108
105
#[ derive( Clone , Debug ) ]
109
106
type NodeCrypto ;
110
107
111
108
#[ wasm_bindgen( method, js_name = randomFillSync, structural) ]
112
109
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 ;
113
118
}
You can’t perform that action at this time.
0 commit comments