Sha256: 91c86b0862c4f80e39882ac77fbdb91993408a3acb1d0c54fb44e6cc4a86be1b

Contents?: true

Size: 699 Bytes

Versions: 30

Compression:

Stored size: 699 Bytes

Contents

require "jsduck/js/node"

module JsDuck
  module Js

    # Wraps around array of AST nodes.
    class NodeArray
      # Initialized with array of AST Hashes from Esprima.
      def initialize(nodes)
        @nodes = nodes || []
      end

      # Returns a child AST node as AstNode class.
      def [](i)
        Js::Node.create(@nodes[i])
      end

      # The length of array
      def length
        @nodes.length
      end

      # Iterates over all the AstNodes in array.
      def each
        @nodes.each {|p| yield(Js::Node.create(p)) }
      end

      # Maps over all the AstNodes in array.
      def map
        @nodes.map {|p| yield(Js::Node.create(p)) }
      end

    end

  end
end

Version data entries

30 entries across 30 versions & 3 rubygems

Version Path
solvas-jsduck-6.0.0.30539 lib/jsduck/js/node_array.rb
solvas-jsduck-6.0.0.9571 lib/jsduck/js/node_array.rb
solvas-jsduck-6.0.0.6154 lib/jsduck/js/node_array.rb
solvas-jsduck-6.0.0.4021 lib/jsduck/js/node_array.rb
solvas-jsduck-6.0.0.2554 lib/jsduck/js/node_array.rb
solvas-jsduck-6.0.0.1891 lib/jsduck/js/node_array.rb
solvas-jsduck-6.0.0.beta.1888 lib/jsduck/js/node_array.rb
jsduck-troopjs-0.0.10 lib/jsduck/js/node_array.rb
jsduck-troopjs-0.0.9 lib/jsduck/js/node_array.rb
jsduck-troopjs-0.0.8 lib/jsduck/js/node_array.rb
jsduck-troopjs-0.0.7 lib/jsduck/js/node_array.rb
jsduck-troopjs-0.0.5 lib/jsduck/js/node_array.rb
jsduck-troopjs-0.0.4 lib/jsduck/js/node_array.rb
jsduck-troopjs-0.0.3 lib/jsduck/js/node_array.rb
jsduck-troopjs-0.0.1 lib/jsduck/js/node_array.rb
jsduck-6.0.0beta lib/jsduck/js/node_array.rb
jsduck-5.3.4 lib/jsduck/js/node_array.rb
jsduck-5.3.3 lib/jsduck/js/node_array.rb
jsduck-5.3.2 lib/jsduck/js/node_array.rb
jsduck-5.3.1 lib/jsduck/js/node_array.rb