1. Mar 03, 2013
  2. Mar 02, 2013
  3. Mar 01, 2013
    • Ben Noordhuis's avatar
      http: use socket.once, not socket.on · f26362e9
      Ben Noordhuis authored
      Register the 'close' event listener with .once(), not .on().
      
      It doesn't matter in the grand scheme of things because the listener
      doesn't keep references to any heavy-weight objects but using .once()
      for a oneshot listener is something of a best practice.
      f26362e9
    • Timothy J Fontaine's avatar
      f0f87d8a
    • isaacs's avatar
      doc: Provide 2 examples of SimpleProtocol parser · 4926ffd1
      isaacs authored
      The first example uses Readable, and shows the use of
      readable.unshift().  The second uses the Transform class, showing that
      it's much simpler in this case.
      4926ffd1
    • isaacs's avatar
      stream: There is no _read cb, there is only push · 88644eaa
      isaacs authored
      This makes it so that `stream.push(chunk)` is the only way to signal the
      end of reading, removing the confusing disparity between the
      callback-style _read method, and the fact that most real-world streams
      do not have a 1:1 corollation between the "please give me data" event,
      and the actual arrival of a chunk of data.
      
      It is still possible, of course, to implement a `CallbackReadable` on
      top of this.  Simply provide a method like this as the callback:
      
          function readCallback(er, chunk) {
            if (er)
              stream.emit('error', er);
            else
              stream.push(chunk);
          }
      
      However, *only* fs streams actually would behave in this way, so it
      makes not a lot of sense to make TCP, TLS, HTTP, and all the rest have
      to bend into this uncomfortable paradigm.
      88644eaa
    • isaacs's avatar
      stream: Add stream.unshift(chunk) · 4b67f0be
      isaacs authored
      4b67f0be
    • isaacs's avatar
      stream: Break up the onread function · 7764b842
      isaacs authored
      A primary motivation of this is to make the onread function more
      inline-friendly, but also to make it more easy to explore not having
      onread at all, in favor of always using push() to signal the end of
      reading.
      7764b842