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

cURL Example Fails #3

Description

@joemccann

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...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions