Skip to content

Commit

Permalink
Add ES module global crypto example
Browse files Browse the repository at this point in the history
  • Loading branch information
MikeMcl committed May 29, 2022
1 parent d4291cb commit 8ddf11e
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions doc/API.html
Expand Up @@ -482,7 +482,10 @@ <h5 id="config">config<code class='inset'>set([object]) <i>&rArr; object</i></co
<dd>
<pre>
// Node.js
global.crypto = require('crypto')
const crypto = require('crypto'); // CommonJS
import * as crypto from 'crypto'; // ES module

global.crypto = crypto;

BigNumber.config({ CRYPTO: true })
BigNumber.config().CRYPTO // true
Expand Down Expand Up @@ -776,7 +779,10 @@ <h5 id="random">
To be able to set <a href='#crypto'><code>CRYPTO</code></a> to <code>true</code> when using
Node.js, the <code>crypto</code> object must be available globally:
</p>
<pre>global.crypto = require('crypto')</pre>
<pre>// Node.js
const crypto = require('crypto'); // CommonJS
import * as crypto from 'crypto'; // ES module
global.crypto = crypto;</pre>
<p>
If <a href='#crypto'><code>CRYPTO</code></a> is <code>true</code>, i.e. one of the
<code>crypto</code> methods is to be used, the value of a returned BigNumber should be
Expand Down

0 comments on commit 8ddf11e

Please sign in to comment.