Sha256: ec6438d31c093b1e32476ec1a2c55c4dfa47a30e9b916b279aaf52eaf0b1e095
Contents?: true
Size: 834 Bytes
Versions: 7
Compression:
Stored size: 834 Bytes
Contents
# frozen_string_literal: true require 'opal/nodes/args/initialize_kwargs' module Opal module Nodes # A node responsible for extracting a # keyword splat argument # # def m(**kwrest) # def m(**) # class KwrestArgNode < InitializeKwargsNode handle :kwrestarg children :name def compile initialize_kw_args_if_needed extract_code = "Opal.kwrestargs($kwargs, #{used_kwargs});" # kwrestarg can be blank def m(**) end # we need to perform assignment only for named kwrestarg if name add_temp name line "#{name} = #{extract_code}" end end def used_kwargs args = scope.used_kwargs.map do |arg_name| "'#{arg_name}': true" end "{#{args.join ','}}" end end end end
Version data entries
7 entries across 7 versions & 1 rubygems