diff --git a/README.md b/README.md index 99ac0c3..21d341d 100644 --- a/README.md +++ b/README.md @@ -1,4 +1,4 @@ -# isaac.js +# isaac.js - NodeJS compatibility version *isaac.js* is a JavaScript implementation of the [ISAAC](http://www.burtleburtle.net/bob/rand/isaac.html) random number generator. ISAAC is a [CSPRNG](http://en.wikipedia.org/wiki/CSPRNG) designed by [Robert J. Jenkins Jr.](http://burtleburtle.net/bob/) in 1996 and based on RC4. It is designed to be fast and secure. @@ -6,9 +6,14 @@ ISAAC is a [CSPRNG](http://en.wikipedia.org/wiki/CSPRNG) designed by [Robert J. *isaac.js* is fully compatible with the other *32-bit integer arithmetic* implementations of ISAAC and can be used as a good alternative to the default javascript `Math.random()` function. ##Use -Include isaac.js into your html file: ``. Then just call `isaac.random()` to get a random real number between 0.0 and 1.0 : +` +npm install isaac +` -`var random_number = isaac.random();` +`var isaac = require( 'isaac' );` + +Then just call `isaac.random()` to get a random real number between 0.0 and 1.0 : +`var random_number = isaac.random( );` If you want a little more control over the PRNG you can reset isaac (all internals to zero) using `isaac.reset()` or use a new seed using `isaac.seed(s)` (*s* can be a string, a number or an array of number). You can also run the PRNG an arbitrary number of time before querying a new random output using `isaac.prng(n)`, where *n* (optional) is the number of run. `isaac.rand()` allow you to get a random 32-bit integer between -2147483648 (0x00000000) and 2147483647 (0xFFFFFFFF). diff --git a/isaac-test.htm b/isaac-test.htm deleted file mode 100644 index 9ae06fd..0000000 --- a/isaac-test.htm +++ /dev/null @@ -1,136 +0,0 @@ - - - - - A javascript implementation of ISAAC - - - - -

-  
-  
-  
-
diff --git a/isaac.js b/isaac.js
index a5f804f..b2d07a8 100644
--- a/isaac.js
+++ b/isaac.js
@@ -221,17 +221,19 @@ var isaac = (function(){
     return {a: acc, b: brs, c: cnt, m: m, r: r};
   }
 
+  function random(){
+    return 0.5 + this.rand() * 2.3283064365386963e-10; // 2^-32
+  }
+
   /* return class object */
   return {
     'reset': reset,
     'seed':  seed,
     'prng':  prng,
     'rand':  rand,
+    'random': random,
     'internals': internals
   };
 })(); /* declare and execute */
 
-/* public: output*/
-isaac.random = function() {
-  return 0.5 + this.rand() * 2.3283064365386963e-10; // 2^-32
-}
+( "undefined" !== ( typeof( module ) ) ) && module.exports && ( module.exports = isaac );
diff --git a/package.json b/package.json
new file mode 100644
index 0000000..f0c595c
--- /dev/null
+++ b/package.json
@@ -0,0 +1,20 @@
+{
+	"author": "Yves-Marie K. Rinquin",
+	"name": "isaac",
+	"description": "ISAAC is a CSPRNG designed by Robert J. Jenkins Jr. in 1996 and based on RC4. It is designed to be fast and secure.",
+	"version": "0.0.5",
+	"repository":
+	{
+		"type": "git",
+		"url": "git://github.com/StefanoBalocco/isaac.js.git"
+	},
+	"keywords":
+	[
+		"prng",
+		"cprng",
+		"csprng",
+		"isaac"
+	],
+	"main": "./isaac.js",
+	"license": "MIT"
+}