Module: Ruby2JS::Filter::MatchAll
- Includes:
- SEXP
- Defined in:
- lib/ruby2js/filter/matchAll.rb
Class Method Summary collapse
-
.reorder(filters) ⇒ Object
ensure matchAll is before Functions in the filter list.
Instance Method Summary collapse
Methods included from SEXP
Class Method Details
.reorder(filters) ⇒ Object
ensure matchAll is before Functions in the filter list
11 12 13 14 15 16 17 18 19 20 21 22 |
# File 'lib/ruby2js/filter/matchAll.rb', line 11 def self.reorder(filters) if \ defined? Ruby2JS::Filter::Functions and filters.include? Ruby2JS::Filter::Functions then filters = filters.dup matchAll = filters.delete(Ruby2JS::Filter::MatchAll) filters.insert filters.index(Ruby2JS::Filter::Functions), matchAll else filters end end |
Instance Method Details
#on_block(node) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/ruby2js/filter/matchAll.rb', line 24 def on_block(node) return super if es2020 # only process each/forEach blocks call = node.children.first return super unless [:each, :forEach].include? call.children[1] and call.children.first.type == :send and node.children[1].children.length == 1 # only process matchAll requests with simple expressions call = call.children.first return super unless call.children[1] == :matchAll and call.children[2].type == :send and call.children[2].children.first == nil and call.children[2].children.length == 2 process s(:while, s(:lvasgn, node.children[1].children[0].children[0], s(:send, call.children[2], :exec, call.children.first)), node.children[2]) end |