Sha256: ea4192fa5f6ebaf47b4153f5790f1759b49aeb53ebc1cff3cf59cb1f54dbc156

Contents?: true

Size: 700 Bytes

Versions: 25

Compression:

Stored size: 700 Bytes

Contents

require 'ruby2js'
require 'set'

# Experimental secure random support

module Ruby2JS
  module Filter
    module SecureRandom
      include SEXP
      extend SEXP

      IMPORT_BASE62_RANDOM = s(:import, ['base62-random'],
        s(:attr, nil, :base62_random))

      def on_send(node)
        target, method, *args = node.children

        if target == s(:const, nil, :SecureRandom)
          if method == :alphanumeric and args.length == 1
            prepend_list << IMPORT_BASE62_RANDOM
            node.updated(nil, [nil, :base62_random, *args])
          else
            super
          end
        else
          super
        end
      end
    end

    DEFAULTS.push SecureRandom
  end
end

Version data entries

25 entries across 25 versions & 1 rubygems

Version Path
ruby2js-5.1.1 lib/ruby2js/filter/securerandom.rb
ruby2js-5.1.0 lib/ruby2js/filter/securerandom.rb
ruby2js-5.0.1 lib/ruby2js/filter/securerandom.rb
ruby2js-5.0.0 lib/ruby2js/filter/securerandom.rb
ruby2js-4.2.2 lib/ruby2js/filter/securerandom.rb
ruby2js-4.2.1 lib/ruby2js/filter/securerandom.rb
ruby2js-4.2.0 lib/ruby2js/filter/securerandom.rb
ruby2js-4.1.7 lib/ruby2js/filter/securerandom.rb
ruby2js-4.1.6 lib/ruby2js/filter/securerandom.rb
ruby2js-4.1.5 lib/ruby2js/filter/securerandom.rb
ruby2js-4.1.4 lib/ruby2js/filter/securerandom.rb
ruby2js-4.1.3 lib/ruby2js/filter/securerandom.rb
ruby2js-4.1.2 lib/ruby2js/filter/securerandom.rb
ruby2js-4.1.1 lib/ruby2js/filter/securerandom.rb
ruby2js-4.1.0 lib/ruby2js/filter/securerandom.rb
ruby2js-4.0.5 lib/ruby2js/filter/securerandom.rb
ruby2js-4.0.4 lib/ruby2js/filter/securerandom.rb
ruby2js-4.0.3 lib/ruby2js/filter/securerandom.rb
ruby2js-4.0.2 lib/ruby2js/filter/securerandom.rb
ruby2js-4.0.1 lib/ruby2js/filter/securerandom.rb