Skip to content
This repository has been archived by the owner on Jul 5, 2019. It is now read-only.

cURL Example Fails #3

Open
joemccann opened this issue Apr 11, 2013 · 2 comments
Open

cURL Example Fails #3

joemccann opened this issue Apr 11, 2013 · 2 comments

Comments

@joemccann
Copy link

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
Copy link
Author

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

@dominictarr
Copy link
Owner

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)

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants