dominictarr / split

MIT License
347 stars 39 forks source link

cURL Example Fails #3

Open joemccann opened 11 years ago

joemccann commented 11 years ago

Quite possible I'm doing it wrong but:

curl -sS registry.npmjs.org/event-stream | node pretty.js

Gives the following:

/Users/joemccann/Documents/workspace/split/examples/pretty.js:8
    es.split(),                       //split stream to break on newlines
       ^
TypeError: Object function split(matcher, mapper) {
  var soFar = ''
  if('function' === typeof matcher)
    mapper = matcher, matcher = null
  if (!matcher)
    matcher = '\n'

  return through(function (buffer) {
    var stream = this
      , pieces = (soFar + buffer).split(matcher)
    soFar = pieces.pop()

    for (var i = 0; i < pieces.length; i++) {
      var piece = pieces[i]
      if(mapper) {
        piece = mapper(piece)
        if('undefined' !== typeof piece)
          stream.queue(piece)
      }
      else
        stream.queue(piece)
    }
  },
  function () {
    if(soFar)
      this.queue(soFar)
    this.queue(null)
  })
} has no method 'split'
    at Object.<anonymous> (/Users/joemccann/Documents/workspace/split/examples/pretty.js:8:8)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:901:3
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
  7  219k    7 17184    0     0  30263      0  0:00:07 --:--:--  0:00:07  186k
curl: (23) Failed writing body (0 != 1448)

This is node 0.10.2, btw...

joemccann commented 11 years ago

Just realized that this is only for node 0.6 and 0.8...

dominictarr commented 11 years ago

oooh, no... looks like there has been an error here ever since this was refactored out of event-stream

Okay, just pushed a fix try the latest (version 0.2.3)