Module: SecureRandom

Defined in:
opal/stdlib/securerandom.rb

Class Method Summary collapse

Class Method Details

.uuidObject



2
3
4
5
6
7
8
9
10
11
# File 'opal/stdlib/securerandom.rb', line 2

def self.uuid
  "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".gsub(/[xy]/) do |ch,|
    %x{
      var r = Math.random() * 16 | 0,
          v = ch == "x" ? r : (r & 3 | 8);

      return v.toString(16);
    }
  end
end