RandomOrgAPI
Library for accessing Random.org's from within your javascript application.
Can be used in both client-side and server-side applications.
Installation
Node
$ npm install random-org-api
var RandomOrgAPI = ;
Note: CreateAPI.js is a dependency. While you can find it here: https://github.com/johnhenry/CreateAPI, it should install automatically when you install RandomOrgAPI through npm. If you install it sehparately or manually, it should work fine placed either in RandomOrgAPI's node_modules folder or side-by-side with RandomOrgAPI.
Browser
<!-- CreatAPI.js is a dependency. You can find it here: https://github.com/johnhenry/CreateAPI/ --> <!--Henceforth, you may access the global RandomOrgAPI object...-->
API Description
Each API takes up to three arguments -- parameters, callback, failure
* parameters (optional) - Object containing parameters to be passed to API e.g.
* callback (optional) - Function to be called upon response
callback is passed the result as a parameter
* failure (optional) - function to be called upon response
failure is passed the error as a parameter
Each API is based on an API found here: http://www.random.org/#numbers
RandomOrgAPI.integers - creates an array of random integers
parameters
* min - the minimum possible value for the generated integers
//Default:0
* max - the maximum possible value for the generated integers
//Default:9
* base - the base in which the numbers generate is returned
//Default:10
//Note: Even though random.org will accept a base of 2,4,8,10,or 16
//Only base 10 is supported
* num - the amount of random numbers generated
//Default:10
RandomOrgAPI.sequence - creates a randomly ordered array of all integers between two numbers
parameters
* min - the smallest number included
//Default:0
* max - the largest number included
//Default:9
RandomOrgAPI.integerSet - creates an list of sets of integers
parameters
* min - the minimum possible value for the generated integers
//Default:0
* max - the maximum possible value for the generated integers
//Default:10
* num - the amount of integers per set
* sets - the amount of sets generated
//Default:10
RandomOrgAPI.decimalFractions - creates an list random numbers between 0 and 1
parameters
* dec - the decimal precision of each number
//Default:10
* num - the amount of numbers generated
//Default:10
RandomOrgAPI.gaussianDistributions - creates a list of random numbers that satisfy a given guassian distribution
parameters
* mean - the mean of the given guassian distribution
//Default:0
* stdev - the standard deviation of the given guassian distribution
//Default:1
* dec - the decimal precision of each number
//Default:10
* num - the amount of numbers generated
//Default:10
RandomOrgAPI.bytes - creates random bytes
parameters
* nbytes - the number of bytes to be generated
//Default:8
Example
The following example creates a variable named "die" and then assigns a random integer between 1 and 6 (inclusive) to it's value.
var die;RandomOrgAPI;```js ## License (The MIT License) Copyright (c) 2013 John Henry <john@iamjohnhenry.com> Permission is hereby granted, free of charge, to any person obtaininga copy of this software and associated documentation files (the'Software'), to deal in the Software without restriction, includingwithout limitation the rights to use, copy, modify, merge, publish,distribute, sublicense, and/or sell copies of the Software, and topermit persons to whom the Software is furnished to do so, subject tothe following conditions: The above copyright notice and this permission notice shall beincluded in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OFMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANYCLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THESOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.