 ieee754 = require "./ieee754"
 stream = require "stream"
 
-# Convert an array of bytes into an hex string, two characters for each byte.
+# Convert an array of bytes into an hex string, two characters for each byte. #
+# FIXME Why less than 10 when we're doing hex?
 hex = (bytes) ->
-  h = bytes.map (b) ->
-    if b < 10
-      "0" + b.toString(16)
-    else
-      b.toString(16)
+  h = bytes.map (b) -> if b < 10 then "0" + b.toString(16) else b.toString(16)
   h.join("")
 
 # Default callback, when no callback is provided.

        @_buffer[i] = fill
      @_write @_buffer.slice 0, size

  serialize: (shiftable...) ->
    if typeof shiftable[shiftable.length - 1] == 'function'
      callback = shiftable.pop()

    nameOrPattern = shiftable.shift()
    packet        = @packets[nameOrPattern] or {}
    pattern       = packet.pattern or parsePattern(nameOrPattern)
    callback    or= packet.callback or noop

    if not packet.pattern
      for part in pattern
        if part.transforms
          part.transforms.reverse()

    @pattern      = pattern
    @callback     = callback
    @patternIndex = 0
    @outgoing     = shiftable

    for value, i in @outgoing
      @outgoing[i] = @pipeline(pattern[i], value)

    @nextField()
    @nextValue()

    # Implementing pause requires callbacks.
    if @streaming
      while @pattern
        read = @write(@_buffer, 0, @_buffer.length)
        @_write @_buffer.slice 0, read

  _write: (slice) ->
    if @_decoder

      # because the callback may specify a subsequent packet to parse.
      else if ++@patternIndex is @pattern.length
        @pattern = null
        @callback.call @self, this

      else

