Sha256: 2d8a079e166e4b29fb2c1eb48f78557d9fa183e692c9735acf8b1cc24bf567ab
Contents?: true
Size: 541 Bytes
Versions: 6
Compression:
Stored size: 541 Bytes
Contents
module Enumerable def index_by(&block) return enum_for :index_by unless block_given? hash = Hash.new %x{ var result; self.$each._p = function() { var param = #{Opal.destructure(`arguments`)}, value = $opal.$yield1(block, param); if (value === $breaker) { result = $breaker.$v; return $breaker; } #{hash[`value`] = `param`}; } self.$each(); if (result !== undefined) { return result; } } hash end end
Version data entries
6 entries across 6 versions & 1 rubygems