Sha256: 1296a63a6d9b65aa2b1cb5a2fd5f7b8ce3343362d862875d9c01e9e23976cbd9
Contents?: true
Size: 907 Bytes
Versions: 50
Compression:
Stored size: 907 Bytes
Contents
module Ruby2JS class Converter # (array # (int 1) # (int 2)) handle :array do |*items| splat = items.rindex { |a| a.type == :splat } if splat and (items.length == 1 or not es2015) item = items[splat].children.first if items.length == 1 parse item elsif splat == items.length - 1 parse s(:send, s(:array, *items[0..-2]), :concat, item) elsif splat == 0 parse s(:send, item, :concat, s(:array, *items[1..-1])) else parse s(:send, s(:send, s(:array, *items[0..splat-1]), :concat, item), :concat, s(:array, *items[splat+1..-1])) end else if items.length <= 1 put '['; parse_all(*items, join: ', '); put ']' else compact { puts '['; parse_all(*items, join: ",#{@ws}"); sput ']' } end end end end end
Version data entries
50 entries across 50 versions & 1 rubygems