EventEmitter = (require 'events').EventEmitter

# This class is the base for all other iterables.
class ByteIterable extends EventEmitter
  # This iterator is kind of 0.
  @EMPTY_ITERATOR =
    hasNext$emit: () ->
      return false

    next$emit: () ->
      return 0

    skip$int: (length) ->
      return 0

  # This iterable is kind of 0.
  @EMPTY =
    # @private
    emptyBytes: new Buffer 0

    iterator: () ->
      return ByteIterable.EMPTY_ITERATOR

    compareTo$ByteIterable$emit: (right) ->
      return right.iterator.hasNext() ? -1 : 0

    getBytesUnsafe: () ->
      return @emptyBytes

    getLength: () ->
      return 0

    toString: () ->
      return "[ByteIterable.EMPTY]"

exports.ByteIterable = ByteIterable