From 3cbfd6da0840065c4cebaf26f3edd55a1137b33a Mon Sep 17 00:00:00 2001 From: Michael Mclaughlin Date: Sat, 9 Sep 2017 18:47:57 +0100 Subject: [PATCH] Update docs re global.crypto --- doc/API.html | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/doc/API.html b/doc/API.html index 27b0b50..e9af614 100644 --- a/doc/API.html +++ b/doc/API.html @@ -672,12 +672,14 @@ a.equals(b) // true

If the value of this Decimal constructor's crypto property is true, and the - crypto object is available in the host environment, the random digits of the - return value are generated by either crypto.getRandomValues (Web Cryptography API - in modern browsers) or crypto.randomBytes (Node.js), otherwise, if the the value - of the property is false the return value is generated by + crypto object is available globally in the host environment, the random digits of + the return value are generated by either crypto.getRandomValues (Web Cryptography + API in modern browsers) or crypto.randomBytes (Node.js), otherwise, if the the + value of the property is false the return value is generated by Math.random (fastest).

+

To make the crypto object available globally in Node.js use

+
global.crypto = require('crypto')

If the value of this Decimal constructor's crypto property is set true and the @@ -693,7 +695,6 @@ Decimal.random() // '0.4117936847' Decimal.random(20) // '0.78193327636914089009' -

round.round(x) ⇒ Decimal

x: number|string|Decimal

See round.

@@ -1097,7 +1098,11 @@ Decimal.modulo // 9 used.

See random.

-
Decimal.crypto                     // false
+    
+// Node.js
+global.crypto = require('crypto')
+
+Decimal.crypto                     // false
 Decimal.set({ crypto: true })
 Decimal.crypto                     // true