1
0
mirror of https://github.com/MikeMcl/decimal.js.git synced 2024-10-27 20:34:12 +00:00

Update docs re global.crypto

This commit is contained in:
Michael Mclaughlin 2017-09-09 18:47:57 +01:00
parent 784a38a8db
commit 3cbfd6da08

View File

@ -672,12 +672,14 @@ a.equals(b) // true</pre>
<p>
If the value of <code>this</code> Decimal constructor's
<a href='#crypto'><code>crypto</code></a> property is <code>true</code>, and the
<code>crypto</code> object is available in the host environment, the random digits of the
return value are generated by either <code>crypto.getRandomValues</code> (Web Cryptography API
in modern browsers) or <code>crypto.randomBytes</code> (Node.js), otherwise, if the the value
of the property is <code>false</code> the return value is generated by
<code>crypto</code> object is available globally in the host environment, the random digits of
the return value are generated by either <code>crypto.getRandomValues</code> (Web Cryptography
API in modern browsers) or <code>crypto.randomBytes</code> (Node.js), otherwise, if the the
value of the property is <code>false</code> the return value is generated by
<code>Math.random</code> (fastest).
</p>
<p>To make the <code>crypto</code> object available globally in Node.js use</p>
<pre>global.crypto = require('crypto')</pre>
<p>
If the value of <code>this</code> Decimal constructor's
<a href='#crypto'><code>crypto</code></a> property is set <code>true</code> and the
@ -693,7 +695,6 @@ Decimal.random() // '0.4117936847'
Decimal.random(20) // '0.78193327636914089009'</pre>
<h5 id="Dround">round<code class='inset'>.round(x) <i>&rArr; Decimal</i></code></h5>
<p><code>x</code>: <i>number|string|Decimal</i></p>
<p>See <code><a href='#round'>round</a></code>.</p>
@ -1097,7 +1098,11 @@ Decimal.modulo // 9</pre>
used.
</p>
<p>See <a href='#Drandom'><code>random</code></a>.</p>
<pre>Decimal.crypto // false
<pre>
// Node.js
global.crypto = require('crypto')
Decimal.crypto // false
Decimal.set({ crypto: true })
Decimal.crypto // true</pre>