Sha256: 2123d6d40918deb461f091938a84f51cade527be6a60fb1fb8188db45c71c0f6

Contents?: true

Size: 656 Bytes

Versions: 24

Compression:

Stored size: 656 Bytes

Contents

# frozen_string_literal: true

require 'opal/nodes/base'

module Opal
  module Nodes
    module Args
      # A utility node responsible for compiling
      # a runtime validation for kwargs.
      #
      # This node is used for both inline and post-kwargs
      #
      class EnsureKwargsAreKwargs < Base
        handle :ensure_kwargs_are_kwargs

        def compile
          helper :hash2

          line 'if ($kwargs == null) {'
          line '  $kwargs = $hash2([], {});'
          line '} else if (!$kwargs.$$is_hash) {'
          line "  throw Opal.ArgumentError.$new('expected kwargs');"
          line '}'
        end
      end
    end
  end
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
opal-1.5.1 lib/opal/nodes/args/ensure_kwargs_are_kwargs.rb
opal-1.5.0 lib/opal/nodes/args/ensure_kwargs_are_kwargs.rb
opal-1.5.0.rc1 lib/opal/nodes/args/ensure_kwargs_are_kwargs.rb
opal-1.4.1 lib/opal/nodes/args/ensure_kwargs_are_kwargs.rb
opal-1.4.0 lib/opal/nodes/args/ensure_kwargs_are_kwargs.rb
opal-1.4.0.alpha1 lib/opal/nodes/args/ensure_kwargs_are_kwargs.rb
opal-1.3.2 lib/opal/nodes/args/ensure_kwargs_are_kwargs.rb
opal-1.3.1 lib/opal/nodes/args/ensure_kwargs_are_kwargs.rb
opal-1.3.0 lib/opal/nodes/args/ensure_kwargs_are_kwargs.rb
opal-1.3.0.rc1 lib/opal/nodes/args/ensure_kwargs_are_kwargs.rb
opal-1.3.0.alpha1 lib/opal/nodes/args/ensure_kwargs_are_kwargs.rb
opal-1.2.0 lib/opal/nodes/args/ensure_kwargs_are_kwargs.rb
opal-1.2.0.beta1 lib/opal/nodes/args/ensure_kwargs_are_kwargs.rb
opal-1.1.1 lib/opal/nodes/args/ensure_kwargs_are_kwargs.rb
opal-1.1.1.rc1 lib/opal/nodes/args/ensure_kwargs_are_kwargs.rb
opal-1.1.0 lib/opal/nodes/args/ensure_kwargs_are_kwargs.rb
opal-1.1.0.rc1 lib/opal/nodes/args/ensure_kwargs_are_kwargs.rb
opal-1.0.5 lib/opal/nodes/args/ensure_kwargs_are_kwargs.rb
opal-1.0.4 lib/opal/nodes/args/ensure_kwargs_are_kwargs.rb
opal-1.0.3 lib/opal/nodes/args/ensure_kwargs_are_kwargs.rb