repo
stringlengths
5
92
file_url
stringlengths
80
287
file_path
stringlengths
5
197
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 15:37:27
2026-01-04 17:58:21
truncated
bool
2 classes
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/corelib/binding.rb
opal/corelib/binding.rb
# backtick_javascript: true class ::Binding # @private def initialize(jseval, scope_variables = [], receiver = undefined, source_location = nil) @jseval, @scope_variables, @receiver, @source_location = \ jseval, scope_variables, receiver, source_location receiver = js_eval('self') if `typeof receive...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/corelib/kernel.rb
opal/corelib/kernel.rb
# helpers: truthy, coerce_to, respond_to, Opal, deny_frozen_access, freeze, freeze_props, jsid, each_ivar, slice # use_strict: true # backtick_javascript: true module ::Kernel def =~(obj) false end def !~(obj) !(self =~ obj) end def ===(other) object_id == other.object_id || self == other end...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/corelib/enumerator.rb
opal/corelib/enumerator.rb
# helpers: slice, coerce_to, deny_frozen_access # backtick_javascript: true # use_strict: true require 'corelib/enumerable' class ::Enumerator include ::Enumerable `self.$$prototype.$$is_enumerator = true` def self.for(object, method = :each, *args, &block) %x{ var obj = #{allocate}; obj.obje...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/corelib/dir.rb
opal/corelib/dir.rb
# backtick_javascript: true class ::Dir class << self def chdir(dir) prev_cwd = `Opal.current_dir` `Opal.current_dir = #{dir}` yield ensure `Opal.current_dir = #{prev_cwd}` end def pwd `Opal.current_dir || '.'` end def home ::ENV['HOME'] || '.' end ...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/corelib/number.rb
opal/corelib/number.rb
# backtick_javascript: true # use_strict: true require 'corelib/numeric' class ::Number < ::Numeric ::Opal.bridge(`Number`, self) `Opal.prop(self.$$prototype, '$$is_number', true)` `self.$$is_number_class = true` `var number_id_map = new Map()` class << self def allocate ::Kernel.raise ::TypeErro...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/corelib/class.rb
opal/corelib/class.rb
# backtick_javascript: true # use_strict: true require 'corelib/module' class ::Class def self.new(superclass = Object, &block) %x{ if (!superclass.$$is_class) { throw Opal.TypeError.$new("superclass must be a Class"); } var klass = Opal.allocate_class(nil, superclass); supercla...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/corelib/string.rb
opal/corelib/string.rb
# helpers: coerce_to, respond_to, global_regexp, prop, opal32_init, opal32_add, transform_regexp, str # backtick_javascript: true # depends on: # require 'corelib/comparable' # required by mini # require 'corelib/regexp' # required by mini class ::String < `String` include ::Comparable attr_reader :encoding,...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
true
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/corelib/process.rb
opal/corelib/process.rb
# backtick_javascript: true module ::Process @__clocks__ = [] def self.__register_clock__(name, func) const_set name, @__clocks__.size @__clocks__ << func end __register_clock__ :CLOCK_REALTIME, `function() { return Date.now() }` monotonic = false %x{ if (Opal.global.performance) { mon...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/corelib/complex.rb
opal/corelib/complex.rb
# backtick_javascript: true require 'corelib/numeric' require 'corelib/complex/base' class ::Complex < ::Numeric def self.rect(real, imag = 0) unless ::Numeric === real && real.real? && ::Numeric === imag && imag.real? ::Kernel.raise ::TypeError, 'not a real' end new(real, imag) end def self...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/corelib/trace_point.rb
opal/corelib/trace_point.rb
# backtick_javascript: true class ::TracePoint # partial implementation of TracePoint # supports :class and :end events def self.trace(event, &block) new(event, &block).enable end attr_reader :event def initialize(event, &block) unless event == :class || event == :end ::Kernel.raise 'Only t...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/corelib/random.rb
opal/corelib/random.rb
# helpers: truthy # backtick_javascript: true # use_strict: true require 'corelib/random/formatter' class ::Random attr_reader :seed, :state def self._verify_count(count) %x{ if (!$truthy(count)) count = 16; if (typeof count !== "number") count = #{`count`.to_int}; if (count < 0) #{::Kernel...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/corelib/enumerable.rb
opal/corelib/enumerable.rb
# helpers: truthy, coerce_to, yield1, yieldX, deny_frozen_access # backtick_javascript: true # use_strict: true module ::Enumerable %x{ function comparableForPattern(value) { if (value.length === 0) { value = [nil]; } if (value.length > 1) { value = [value]; } retu...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/corelib/runtime.rb
opal/corelib/runtime.rb
require 'runtime/runtime'
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/corelib/nil.rb
opal/corelib/nil.rb
# backtick_javascript: true # use_strict: true class ::NilClass `self.$$prototype.$$meta = #{self}` class << self def allocate ::Kernel.raise ::TypeError, "allocator undefined for #{name}" end undef :new end def ! true end def &(other) false end def |(other) `other !=...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/corelib/regexp.rb
opal/corelib/regexp.rb
# helpers: coerce_to, prop, freeze, annotate_regexp, escape_metacharacters # backtick_javascript: true # use_strict: true class ::RegexpError < ::StandardError; end class ::Regexp < `RegExp` self::IGNORECASE = 1 self::EXTENDED = 2 self::MULTILINE = 4 # Not supported: self::FIXEDENCODING = 16 self::NOENCOD...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/corelib/rational.rb
opal/corelib/rational.rb
# backtick_javascript: true require 'corelib/numeric' require 'corelib/rational/base' class ::Rational < ::Numeric def self.reduce(num, den) num = num.to_i den = den.to_i if den == 0 ::Kernel.raise ::ZeroDivisionError, 'divided by 0' elsif den < 0 num = -num den = -den elsif d...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/corelib/unsupported.rb
opal/corelib/unsupported.rb
# backtick_javascript: true # use_strict: true class ::String `var ERROR = "String#%s not supported. Mutable String methods are currently not supported in Opal."` %i[ << []= append_as_bytes bytesplice capitalize! chomp! chop! clear concat delete! delete_prefix! delete_suffix! downcase! encode! gsub! inser...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/corelib/module.rb
opal/corelib/module.rb
# helpers: truthy, coerce_to, const_set, Object, return_ivar, assign_ivar, ivar, deny_frozen_access, freeze, prop, jsid, each_ivar # backtick_javascript: true # use_strict: true class ::Module %x{ function ensure_symbol_or_string(name) { if (name.$$is_string) { return name; }; var conve...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/corelib/basic_object.rb
opal/corelib/basic_object.rb
# use_strict: true # backtick_javascript: true class ::BasicObject def initialize(*) end def ==(other) `self === other` end def eql?(other) self == other end alias equal? == def __id__ %x{ if (self.$$id != null) { return self.$$id; } Opal.prop(self, '$$id', Opa...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/corelib/marshal.rb
opal/corelib/marshal.rb
require 'corelib/marshal/read_buffer' require 'corelib/marshal/write_buffer' module ::Marshal MAJOR_VERSION = 4 MINOR_VERSION = 8 class << self def dump(object) self::WriteBuffer.new(object).write end def load(marshaled) self::ReadBuffer.new(marshaled).read end alias restore lo...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/corelib/hash.rb
opal/corelib/hash.rb
# helpers: yield1, hash_clone, hash_delete, hash_each, hash_get, hash_put, deny_frozen_access, freeze, opal32_init, opal32_add # backtick_javascript: true # use_strict: true require 'corelib/enumerable' # --- # Internal properties: # # - $$keys [Map<key-array>] optional Map of key arrays, used when objects are us...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/corelib/error.rb
opal/corelib/error.rb
# backtick_javascript: true # use_strict: true class ::Exception < `Error` `Opal.prop(self.$$prototype, '$$is_exception', true)` `var stack_trace_limit` `Error.stackTraceLimit = 100` def self.new(*args) %x{ var message = (args.length > 0) ? args[0] : nil; var error = new self.$$construc...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/corelib/pattern_matching.rb
opal/corelib/pattern_matching.rb
require 'corelib/pattern_matching/base' # A "userland" implementation of pattern matching for Opal class ::PatternMatching def self.call(from, pattern) pm = new(from, pattern) pm.match || (return nil) pm.returns end def initialize(from, pattern) @from, @pattern = from, pattern @returns = []...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/corelib/numeric.rb
opal/corelib/numeric.rb
# backtick_javascript: true # use_strict: true require 'corelib/comparable' class ::Numeric include ::Comparable def coerce(other) if other.instance_of? self.class return [other, self] end [::Kernel.Float(other), ::Kernel.Float(self)] end def __coerced__(method, other) if other.respon...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/corelib/string/encoding.rb
opal/corelib/string/encoding.rb
# backtick_javascript: true # helpers: str class ::Encoding class << self def register(name, options = {}, &block) names = [name] + (options[:aliases] || []) ascii = options[:ascii] || false dummy = options[:dummy] || false if options[:inherits] encoding = options[:inherits].clon...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/corelib/string/unpack.rb
opal/corelib/string/unpack.rb
# backtick_javascript: true require 'base64' require 'corelib/pack_unpack/format_string_parser' class ::String %x{ // Format Parser var eachDirectiveAndCount = Opal.PackUnpack.eachDirectiveAndCount; function flattenArray(callback) { return function(data) { var array = callback(data); ...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/corelib/string/encoding/sjis.rb
opal/corelib/string/encoding/sjis.rb
# backtick_javascript: true # helpers: str # inspired by # Jconv # Copyright (c) 2013-2014 narirou # MIT Licensed # https://github.com/narirou/jconv # modified for Opal: # https://github.com/janbiedermann/jconv/tree/for_opal # only converts UCS2/UTF16 string to JIS/SJIS/EUCJP byte buffer # performance: # https://githu...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/corelib/string/encoding/dummy.rb
opal/corelib/string/encoding/dummy.rb
# backtick_javascript: true require 'corelib/string/encoding' # these encodings are required for some ruby specs, make them dummy for now # their existence is often enough, like specs checking if a method returns # a new string in the same encoding it was orginally encoded in ::Encoding.register 'IBM437', inherits: :...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/corelib/string/encoding/jis.rb
opal/corelib/string/encoding/jis.rb
# backtick_javascript: true # helpers: str # inspired by # Jconv # Copyright (c) 2013-2014 narirou # MIT Licensed # https://github.com/narirou/jconv # modified for Opal: # https://github.com/janbiedermann/jconv/tree/for_opal # only converts UCS2/UTF16 string to JIS/SJIS/EUCJP byte buffer # performance: # https://githu...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/corelib/string/encoding/eucjp.rb
opal/corelib/string/encoding/eucjp.rb
# backtick_javascript: true # helpers: str # inspired by # Jconv # Copyright (c) 2013-2014 narirou # MIT Licensed # https://github.com/narirou/jconv # modified for Opal: # https://github.com/janbiedermann/jconv/tree/for_opal # only converts UCS2/UTF16 string to JIS/SJIS/EUCJP byte buffer # performance: # https://githu...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/corelib/string/encoding/tables/jis_inverted.rb
opal/corelib/string/encoding/tables/jis_inverted.rb
# backtick_javascript: true
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
true
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/corelib/string/encoding/tables/jis_ext_inverted.rb
opal/corelib/string/encoding/tables/jis_ext_inverted.rb
# backtick_javascript: true
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
true
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/corelib/string/encoding/tables/sjis_inverted.rb
opal/corelib/string/encoding/tables/sjis_inverted.rb
# backtick_javascript: true
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
true
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/corelib/process/base.rb
opal/corelib/process/base.rb
class ::Signal def self.trap(*) end end class ::GC def self.start end end
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/corelib/process/status.rb
opal/corelib/process/status.rb
module ::Process class Status def initialize(status, pid) @status, @pid = status, pid end def exitstatus @status end attr_reader :pid def success? @status == 0 end def inspect "#<Process::Status: pid #{@pid} exit #{@status}>" end end end
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/corelib/error/errno.rb
opal/corelib/error/errno.rb
# backtick_javascript: true # use_strict: true module ::Errno errors = [ [:EINVAL, 'Invalid argument', 22], [:EEXIST, 'File exists', 17], [:EISDIR, 'Is a directory', 21], [:EMFILE, 'Too many open files', 24], [:ESPIPE, 'Illegal seek', 29], [:EACCES, 'Permission denied', 13], [:EPERM, 'Ope...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/corelib/math/polyfills.rb
opal/corelib/math/polyfills.rb
# backtick_javascript: true # Polyfills for browsers in the age of IE11 unless defined?(`Math.acosh`) %x{ Math.acosh = function(x) { return Math.log(x + Math.sqrt(x * x - 1)); } } end unless defined?(`Math.asinh`) %x{ Math.asinh = function(x) { return Math.log(x + Math.sqrt(x * x + 1)) ...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/corelib/kernel/format.rb
opal/corelib/kernel/format.rb
# helpers: coerce_to # backtick_javascript: true module ::Kernel def format(format_string, *args) if args.length == 1 && args[0].respond_to?(:to_ary) ary = ::Opal.coerce_to?(args[0], ::Array, :to_ary) args = ary.to_a unless ary.nil? end %x{ var result = '', //used for slicing...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/corelib/enumerator/chain.rb
opal/corelib/enumerator/chain.rb
# helpers: deny_frozen_access # backtick_javascript: true # use_strict: true class ::Enumerator class self::Chain < self def initialize(*enums) `$deny_frozen_access(self)` @enums = enums @iterated = [] @object = self end def each(*args, &block) return to_enum(:each, *args)...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/corelib/enumerator/lazy.rb
opal/corelib/enumerator/lazy.rb
# helpers: truthy, coerce_to, yield1, yieldX, deny_frozen_access # backtick_javascript: true # use_strict: true class ::Enumerator class self::Lazy < self class self::StopLazyError < ::Exception; end def self.for(object, *) lazy = super `lazy.enumerator = object` lazy end def init...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/corelib/enumerator/generator.rb
opal/corelib/enumerator/generator.rb
# helpers: deny_frozen_access # backtick_javascript: true # use_strict: true class Enumerator class Generator include ::Enumerable def initialize(&block) `$deny_frozen_access(self)` ::Kernel.raise ::LocalJumpError, 'no block given' unless block @block = block end def each(*args,...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/corelib/enumerator/arithmetic_sequence.rb
opal/corelib/enumerator/arithmetic_sequence.rb
# backtick_javascript: true # use_strict: true class ::Enumerator class self::ArithmeticSequence < self `Opal.prop(self.$$prototype, '$$is_arithmetic_seq', true)` `var inf = Infinity` # @private def initialize(range, step = undefined, creation_method = :step) @creation_method = creation_metho...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/corelib/enumerator/yielder.rb
opal/corelib/enumerator/yielder.rb
# backtick_javascript: true # use_strict: true class Enumerator class Yielder def initialize(&block) @block = block # rubocop:disable Lint/Void self # rubocop:enable Lint/Void end def yield(*values) %x{ var value = Opal.yieldX(#{@block}, values); if (value ...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/corelib/pattern_matching/base.rb
opal/corelib/pattern_matching/base.rb
class ::Array def deconstruct self end end class ::Hash def deconstruct_keys(_) self end end class ::Struct alias deconstruct to_a # This function is specified in a very weird way... def deconstruct_keys(keys) return to_h if keys.nil? ::Kernel.raise ::TypeError, 'expected Array or nil' u...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/corelib/complex/base.rb
opal/corelib/complex/base.rb
module ::Kernel def Complex(real, imag = nil) if imag Complex.new(real, imag) else Complex.new(real, 0) end end end class ::String def to_c Complex.from_string(self) end end
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/corelib/marshal/read_buffer.rb
opal/corelib/marshal/read_buffer.rb
# backtick_javascript: true # https://github.com/ruby/ruby/blob/trunk/doc/marshal.rdoc # https://github.com/ruby/ruby/blob/trunk/marshal.c module ::Marshal class self::ReadBuffer %x{ function stringToBytes(string) { var i, singleByte, l = string.length, result =...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/corelib/marshal/write_buffer.rb
opal/corelib/marshal/write_buffer.rb
# backtick_javascript: true class ::NilClass def __marshal__(buffer) buffer.append('0') end end class ::Boolean def __marshal__(buffer) if `self == true` buffer.append('T') else buffer.append('F') end end end class ::Integer def __marshal__(buffer) if self >= -0x40000000 && ...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/corelib/array/pack.rb
opal/corelib/array/pack.rb
# helpers: coerce_to # backtick_javascript: true require 'corelib/pack_unpack/format_string_parser' class ::Array %x{ // Format Parser var eachDirectiveAndCount = Opal.PackUnpack.eachDirectiveAndCount; function identityFunction(value) { return value; } function utf8BytesToUtf16LEString(bytes) { ...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/corelib/rational/base.rb
opal/corelib/rational/base.rb
module ::Kernel def Rational(numerator, denominator = 1) ::Rational.convert(numerator, denominator) end end class ::String def to_r ::Rational.from_string(self) end end
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/corelib/io/buffer.rb
opal/corelib/io/buffer.rb
# backtick_javascript: true require 'corelib/string/encoding' class ::IO class Buffer # Types that can be requested from the buffer: # # :U8: unsigned integer, 1 byte # :S8: signed integer, 1 byte # :u16: unsigned integer, 2 bytes, little-endian # :U16: unsigned integer, 2 bytes, big-endian ...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/corelib/random/seedrandom.js.rb
opal/corelib/random/seedrandom.js.rb
# backtick_javascript: true # use_strict: true class ::Random %x{ var module = { exports: {} }; /* eslint-disable */ /* seedrandom.min.js 2.4.1 (original source: https://github.com/davidbau/seedrandom/blob/2.4.1/seedrandom.min.js) How to update: . Chekout the latest release from GitHub: htt...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/corelib/random/mersenne_twister.rb
opal/corelib/random/mersenne_twister.rb
# backtick_javascript: true # use_strict: true # This is based on an adaptation of Makoto Matsumoto and Takuji Nishimura's code # done by Sean McCullough <banksean@gmail.com> and Dave Heitzman # <daveheitzman@yahoo.com>, subsequently readapted from an updated version of # ruby's random.c (rev c38a183032a7826df1adabd8a...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/corelib/random/math_random.js.rb
opal/corelib/random/math_random.js.rb
# backtick_javascript: true # use_strict: true class ::Random MATH_RANDOM_GENERATOR = `{ new_seed: function() { return 0; }, reseed: function(seed) { return {}; }, rand: function($rng) { return Math.random(); } }` self.generator = MATH_RANDOM_GENERATOR end
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/corelib/random/formatter.rb
opal/corelib/random/formatter.rb
# backtick_javascript: true # use_strict: true class ::Random module self::Formatter def hex(count = nil) count = ::Random._verify_count(count) %x{ var bytes = #{bytes(count)}; var out = ""; for (var i = 0; i < #{count}; i++) { out += bytes.charCodeAt(i).toString(16)...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/corelib/pack_unpack/format_string_parser.rb
opal/corelib/pack_unpack/format_string_parser.rb
# backtick_javascript: true module ::PackUnpack %x{ var directives = [ // Integer 'C', 'S', 'L', 'Q', 'J', 'c', 's', 'l', 'q', 'j', 'n', 'N', 'v', 'V', 'U', 'w', // Float 'D', 'd', 'F...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/opal/full.rb
opal/opal/full.rb
::Object.autoload :Marshal, 'corelib/marshal' ::Object.require 'corelib/string/encoding/dummy' ::Object.require 'corelib/string/encoding/eucjp' ::Object.require 'corelib/string/encoding/jis' ::Object.require 'corelib/string/encoding/sjis' ::Object.require 'corelib/string/unpack' ::Object.require 'corelib/array/pack' ::...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/opal/base.rb
opal/opal/base.rb
::Object.require 'runtime/runtime' ::Object.require 'corelib/module' ::Object.require 'corelib/class' ::Object.require 'corelib/basic_object' ::Object.require 'corelib/kernel' ::Object.require 'corelib/main' ::Object.require 'corelib/error' ::Object.require 'corelib/constants'
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/opal/mini.rb
opal/opal/mini.rb
::Object.require 'opal/base' ::Object.require 'corelib/nil' ::Object.require 'corelib/boolean' ::Object.require 'corelib/comparable' ::Object.require 'corelib/regexp' ::Object.require 'corelib/string' ::Object.require 'corelib/enumerable' ::Object.require 'corelib/enumerator' ::Object.require 'corelib/array' ::Object....
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/runtime/proc.rb
opal/runtime/proc.rb
# backtick_javascript: true # use_strict: true # opal_runtime_mode: true # helpers: apply_blockopts, raise module ::Opal %x{ function call_lambda(block, arg, ret) { try { block(arg); } catch (e) { if (e === ret) { return ret.$v; } throw e; } } } ...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/runtime/method.rb
opal/runtime/method.rb
# backtick_javascript: true # use_strict: true # opal_runtime_mode: true # helpers: deny_frozen_access, prop, has_own, jsid, raise, ancestors, get_ancestors module ::Opal # Method creation/deletion # ------------------------ # Used to define methods on an object. This is a helper method, used by the # compile...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/runtime/const.rb
opal/runtime/const.rb
# backtick_javascript: true # use_strict: true # opal_runtime_mode: true # helpers: prop, raise, Object, has_own module ::Opal # Walk up the nesting array looking for the constant def self.const_lookup_nesting(nesting, name) %x{ var i, ii, constant; if (nesting.length === 0) return; // If t...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/runtime/variables.rb
opal/runtime/variables.rb
# backtick_javascript: true # use_strict: true # opal_runtime_mode: true module ::Opal # Instance variables # ------------------ %x{ var reserved_ivar_names = [ // properties "constructor", "displayName", "__count__", "__noSuchMethod__", "__parent__", "__proto__", // methods "h...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/runtime/array.rb
opal/runtime/array.rb
# backtick_javascript: true # use_strict: true # opal_runtime_mode: true # helpers: raise module ::Opal # Helpers for implementing multiple assignment # Our code for extracting the values and assigning them only works if the # return value is a JS array. # So if we get an Array subclass, extract the wrapped JS...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/runtime/bridge.rb
opal/runtime/bridge.rb
# backtick_javascript: true # use_strict: true # opal_runtime_mode: true # helpers: raise, prop, set_proto module ::Opal # For performance, some core Ruby classes are toll-free bridged to their # native JavaScript counterparts (e.g. a Ruby Array is a JavaScript Array). # # This method is used to setup a native...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/runtime/irb.rb
opal/runtime/irb.rb
# backtick_javascript: true # use_strict: true # opal_runtime_mode: true # helpers: raise, slice, splice, has_own module ::Opal # Run in WebTools console with: Opal.irb(c => eval(c)) def self.irb(fun) ::Binding.new(fun).irb end def self.load_parser ::Opal::IRB.ensure_loaded('opal-parser') end %x{...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/runtime/helpers.rb
opal/runtime/helpers.rb
# helpers: type_error, coerce_to # backtick_javascript: true # use_strict: true module ::Opal def self.coerce_to!(object, type, method, *args) coerced = `$coerce_to(object, type, method, args)` unless type === coerced ::Kernel.raise `$type_error(object, type, method, coerced)` end coerced e...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/runtime/freeze.rb
opal/runtime/freeze.rb
# backtick_javascript: true # use_strict: true # opal_runtime_mode: true # helpers: prop, raise, uid, return_val module ::Opal # Support for #freeze # ------------------- # Common #freeze runtime support def self.freeze(obj) %x{ $prop(obj, "$$frozen", true); // set $$id if (!obj.hasOwnP...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/runtime/send.rb
opal/runtime/send.rb
# backtick_javascript: true # use_strict: true # opal_runtime_mode: true # helpers: apply_blockopts, jsid, raise, prepend_ary, get_ancestors module ::Opal # Calls passed method on a ruby object with arguments and block: # # Can take a method or a method name. # # 1. When method name gets passed it invokes it...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/runtime/exception.rb
opal/runtime/exception.rb
# backtick_javascript: true # use_strict: true # opal_runtime_mode: true # helpers: gvars, Kernel, slice, truthy module ::Opal # A helper function for raising things, that gracefully degrades if necessary # functionality is not yet loaded. def self.raise(klass, message) %x{ // Raise Exception, so we ca...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/runtime/class.rb
opal/runtime/class.rb
# backtick_javascript: true # use_strict: true # opal_runtime_mode: true # helpers: raise, prop, Object, BasicObject, Class, Module, set_proto, allocate_class, const_get_name, const_set, has_own, ancestors, jsid module ::Opal def self.find_existing_class(scope, name) %x{ // Try to find the class in the cur...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/runtime/string.rb
opal/runtime/string.rb
# backtick_javascript: true # use_strict: true # opal_runtime_mode: true # helpers: raise, prop, Object module ::Opal # We use a helper to create new Strings, globally, so that it # will be easer to change that later on to a mutable string class. # Also this helper always sets a encoding. If encoding is not # ...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/runtime/op_helpers.rb
opal/runtime/op_helpers.rb
# backtick_javascript: true # use_strict: true # opal_runtime_mode: true # helpers: truthy, deny_frozen_access # rubocop:disable Layout/EmptyLineBetweenDefs module ::Opal # Operator helpers # ---------------- %x{ function are_both_numbers(l,r) { return typeof(l) === 'number' && typeof(r) === 'number'...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/runtime/misc.rb
opal/runtime/misc.rb
# backtick_javascript: true # use_strict: true # opal_runtime_mode: true # helpers: return_val, Object, gvars module ::Opal # Create a new range instance with first and last values, and whether the # range excludes the last value. def self.range(first, last, exc) %x{ var range = new Opal.Range(...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/runtime/runtime.rb
opal/runtime/runtime.rb
require 'runtime/boot' require 'runtime/variables' require 'runtime/exception' require 'runtime/freeze' require 'runtime/op_helpers' require 'runtime/method_missing' require 'runtime/const' require 'runtime/module' require 'runtime/class' require 'runtime/method' require 'runtime/proc' require 'runtime/send' requir...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/runtime/regexp.rb
opal/runtime/regexp.rb
# backtick_javascript: true # use_strict: true # opal_runtime_mode: true module ::Opal # Escape Regexp special chars letting the resulting string be used to build # a new Regexp. def self.escape_regexp(str) `Opal.escape_metacharacters(str.replace(/([-[\]\/{}()*+?.^$\\| ])/g, '\\$1'))` end def self.escap...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/runtime/module.rb
opal/runtime/module.rb
# backtick_javascript: true # use_strict: true # opal_runtime_mode: true # helpers: prop, raise, Object, allocate_module, const_get_name, const_lookup_ancestors, ancestors, const_set, set_proto, has_own module ::Opal %x{ // TracePoint support // ------------------ // // Support for `TracePoint.trace(...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/runtime/method_missing.rb
opal/runtime/method_missing.rb
# backtick_javascript: true # use_strict: true # opal_runtime_mode: true # helpers: BasicObject, jsid, prop, prepend_ary module ::Opal # Method Missing # -------------- # Methods stubs are used to facilitate method_missing in opal. A stub is a # placeholder function which just calls `method_missing` on the re...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/opal/runtime/hash.rb
opal/runtime/hash.rb
# backtick_javascript: true # use_strict: true # opal_runtime_mode: true # helpers: raise, slice, splice, has_own module ::Opal # Hashes # ------ # Experiments have shown, that using new Map([[1,2]]) inline is rather slow # compared to using new Map() in combination with .set(1,2), because the former # crea...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/benchmark-ips/bm_slice_or_not.rb
benchmark-ips/bm_slice_or_not.rb
%x{ // Minify common function calls var $call = Function.prototype.call; var $bind = Function.prototype.bind; var $has_own = Object.hasOwn || $call.bind(Object.prototype.hasOwnProperty); var $set_proto = Object.setPrototypeOf; var $slice = $call.bind(Array.prototype.slice); var $splice ...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/benchmark-ips/bm_js_symbols_vs_strings.rb
benchmark-ips/bm_js_symbols_vs_strings.rb
Benchmark.ips do |x| %x{ const c_foo = 'foo' const v_foo = 'foo' const cfoo = Symbol('foo') var vfoo = Symbol('foo') const cgfoo = Symbol.for('foo') var vgfoo = Symbol.for('foo') var o = {} o[cfoo] = 1 o[cgfoo] = 1 o[c_foo] = 1 o[vfoo] = 1 let a1 = 0, a2 = 0, a3 = 0, ...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/benchmark-ips/class_shovel_vs_singleton_class.rb
benchmark-ips/class_shovel_vs_singleton_class.rb
o = nil Benchmark.ips do |x| x.report('shovel') do o = Object.new class << o attr_accessor :foo end end x.report('singleton_class') do o2 = Object.new o2.singleton_class.attr_accessor :foo end x.compare! end
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/benchmark-ips/bm_u_string.rb
benchmark-ips/bm_u_string.rb
# helpers: coerce_to, opal32_init, opal32_add # backtick_javascript: true require 'benchmark/ips' class String %x{ function find_index(str, search_s, search_l, search) { let search_f = search_s[0]; return str.findIndex((c, i, s) => { return (c === search_f && (search_l === 1 || s.slice(i, i +...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/benchmark-ips/bm_case.rb
benchmark-ips/bm_case.rb
Benchmark.ips do |x| obj = Object.new x.report("numeric statement") do case 1 when 4 then 4 when 3 then 3 when 2 then 2 when 1 then 1 end nil end x.report("statement") do case 1 when 4 then 4 when 3 then 3 when 2 then 2 when obj then :obj when 1 then 1 end...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/benchmark-ips/bm_symbol_to_proc.rb
benchmark-ips/bm_symbol_to_proc.rb
# https://github.com/opal/opal/issues/1659#issuecomment-298222232 Benchmark.ips do |x| a = [] 50.times do |i| a << %(#{i}\n) end x.report('map block') do a.map {|it| it.chomp } end x.report('map symbol') do a.map(&:chomp) end x.compare! end
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/benchmark-ips/bm_block_vs_yield.rb
benchmark-ips/bm_block_vs_yield.rb
module BmBlockVsYield def self._block(&block) block.call end def self._yield yield end end Benchmark.ips do |x| x.warmup = 10 x.time = 60 x.report('block') do BmBlockVsYield._block { 1+1 } end x.report('yield') do BmBlockVsYield._yield { 1+1 } end x.compare! end
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/benchmark-ips/bm_array_pop_1.rb
benchmark-ips/bm_array_pop_1.rb
Benchmark.ips do |x| x.report('pop(1)') do a = ['4768', '4964', '4266', '4872', '4231', '4017', '4565', '4793', '4298', '4135', '4639', '4780', '4237', '4548', '4655', '4153', '4654', '4922', '4563', '4042', '4329', '4699', '4352', '4127', '4544', '4906', '4814', '4948', '4977', '4830', '4405', '4642', '4666', '4...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/benchmark-ips/bm_array_shift.rb
benchmark-ips/bm_array_shift.rb
Benchmark.ips do |x| x.report("shift no arg") do a = ['4768', '4964', '4266', '4872', '4231', '4017', '4565', '4793', '4298', '4135', '4639', '4780', '4237', '4548', '4655', '4153', '4654', '4922', '4563', '4042', '4329', '4699', '4352', '4127', '4544', '4906', '4814', '4948', '4977', '4830', '4405', '4642', '466...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/benchmark-ips/bm_array_unshift.rb
benchmark-ips/bm_array_unshift.rb
Benchmark.ips do |x| x.report("unshift") do a = ['4768', '4964', '4266', '4872', '4231', '4017', '4565', '4793', '4298', '4135', '4639', '4780', '4237', '4548', '4655', '4153', '4654', '4922', '4563', '4042', '4329', '4699', '4352', '4127', '4544', '4906', '4814', '4948', '4977', '4830', '4405', '4642', '4666', '...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/benchmark-ips/bm_is_number.rb
benchmark-ips/bm_is_number.rb
# Why .$$is_number is better than isNaN: # # # Warming up -------------------------------------- # .$$is_number 106.722k i/100ms # isNaN() 105.040k i/100ms # obj.$$is_number 106.864k i/100ms # isNaN(obj) 89.287k i/100ms # Calculating ------------------------------------- # ...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/benchmark-ips/bm_constants_lookup.rb
benchmark-ips/bm_constants_lookup.rb
module A module B module C Benchmark.ips do |x| x.report("Kernel") { Kernel } x.report("::Kernel") { ::Kernel } x.report("B") { B } x.report("B::C") { B::C } x.compare! end end end end
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/benchmark-ips/bm_while_true_vs_loop.rb
benchmark-ips/bm_while_true_vs_loop.rb
Benchmark.ips do |x| x.report('while true') do n = 0 while true n += 1 break if n == 10000 end end x.report('loop') do n = 0 loop do n += 1 break if n == 10000 end end x.compare! end
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/benchmark-ips/bm_truthy.rb
benchmark-ips/bm_truthy.rb
Benchmark.ips do |x| %x{ // Old version truthy logic var old_version = function(x) { return x !== nil && x != null && (!x.$$is_boolean || x == true); } // New version truthy logic var new_version_1 = function(val) { return undefined !== val && null !== val && false !== val && nil !== val && (!(val ...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/benchmark/bm_hash_has_key_string.rb
benchmark/bm_hash_has_key_string.rb
h = {} 10_000.times do |i| h[i.to_s] = nil end 10_000.times do |i| h.has_key?(i.to_s) end
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/benchmark/bm_hash_has_value_object.rb
benchmark/bm_hash_has_value_object.rb
h = {} 10_000.times do |i| h[Object.new] = i * 2 end 1_000.times do |i| h.has_value?(i * 2) end
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/benchmark/bm_array_uniq_bang_numbers.rb
benchmark/bm_array_uniq_bang_numbers.rb
a = [4768, 4964, 4266, 4872, 4231, 4017, 4565, 4793, 4298, 4135, 4639, 4780, 4237, 4548, 4655, 4153, 4654, 4922, 4563, 4042, 4329, 4699, 4352, 4127, 4544, 4906, 4814, 4948, 4977, 4830, 4405, 4642, 4666, 4402, 4679, 4465, 4401, 4155, 4767, 4510, 4747, 4993, 4508, 4697, 4758, 4133, 4348, 4200, 4442, 4970, 4452, 4041, 410...
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/benchmark/bm_hash_assoc_object.rb
benchmark/bm_hash_assoc_object.rb
h = {} a = [] 10_000.times do |i| a[i] = Object.new h[a[i]] = nil end 10_000.times do |i| k, v = h.assoc(a[i]) end
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/benchmark/bm_hash_reject_bang_object.rb
benchmark/bm_hash_reject_bang_object.rb
h = {} 10_000.times do |i| h[Object.new] = i end 10_000.times do |i| h.reject!{|k, v| v <= i} end
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/benchmark/bm_hash_shift_object.rb
benchmark/bm_hash_shift_object.rb
h = {} 10_000.times do |i| h[Object.new] = nil end 1_000_000.times do k, v = h.shift h[k] = v end
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/benchmark/bm_hash_literal_string_small.rb
benchmark/bm_hash_literal_string_small.rb
100_000.times do h = {'a' => 'b', 'c' => 'd', 'e' => 'f', 'g' => 'h', 'i' => 'j', 'k' => 'l', 'm' => 'n', 'o' => 'p'} end
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false
opal/opal
https://github.com/opal/opal/blob/b4e228990534515b83cd509a9297beca59bf8733/benchmark/bm_hash_has_key_object.rb
benchmark/bm_hash_has_key_object.rb
h = {} a = [] 10_000.times do |i| a[i] = Object.new h[a[i]] = nil end 10_000.times do |i| h.has_key?(a[i]) end
ruby
MIT
b4e228990534515b83cd509a9297beca59bf8733
2026-01-04T15:44:44.154940Z
false