Simple.js 1.0 KB

1234567891011121314151617181920212223242526272829303132333435
  1. /*
  2. Copyright (c) 2004-2012, The Dojo Foundation All Rights Reserved.
  3. Available via Academic Free License >= 2.1 OR the modified BSD license.
  4. see: http://dojotoolkit.org/license for details
  5. */
  6. if(!dojo._hasResource["dojox.math.random.Simple"]){ //_hasResource checks added by build. Do not use _hasResource directly in your code.
  7. dojo._hasResource["dojox.math.random.Simple"] = true;
  8. dojo.provide("dojox.math.random.Simple");
  9. dojo.declare("dojox.math.random.Simple", null, {
  10. // summary:
  11. // Super simple implementation of a random number generator,
  12. // which relies on Math.random().
  13. destroy: function(){
  14. // summary:
  15. // Prepares the object for GC. (empty in this case)
  16. },
  17. nextBytes: function(/* Array */ byteArray){
  18. // summary:
  19. // Fills in an array of bytes with random numbers
  20. // byteArray: Array:
  21. // array to be filled in with random numbers, only existing
  22. // elements will be filled.
  23. for(var i = 0, l = byteArray.length; i < l; ++i){
  24. byteArray[i] = Math.floor(256 * Math.random());
  25. }
  26. }
  27. });
  28. }