question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

`.stream(cb)` method

See original GitHub issue

Just as an idea: The parser could do much more when it would actually get a stream of data. This would allow the creation of the DOM while IO is happening, which will speed up initial loading (and more stuff could be done inside of DomHandler).

There is already a WritableStream.js file shipped with htmlparser2 (it’s accessible via require("htmlparser2").WritableStream) that pretty much solves all problems. The implementation of the cheerio method could look like this:

cheerio.createWritableStream = function(cb, options){
  var handler = new DomHandler(function(dom){ cb(cheerio(dom)); }, options);
  return new WritableStream(handler, options);
};

Issue Analytics

  • State:closed
  • Created 11 years ago
  • Comments:9 (9 by maintainers)

github_iconTop GitHub Comments

1reaction
matthewmuellercommented, Jun 9, 2013

looking back at my example, I kind of think adding URL fetching functionality is a bit leaky (do we then support headers, what kind of request methods, etc).

It would be nice to add a streaming interface though, as @fb55 did with cornet. Perhaps more along the lines of:

var $ = cheerio.stream();
minreq.get("http://github.com/fb55").pipe($)
$.on(...)
0reactions
fb55commented, May 11, 2022

Closing in favour of #2051.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Stream | Node.js v19.3.0 Documentation
A key goal of the stream API, particularly the stream.pipe() method, is to limit the buffering of data to acceptable levels such that...
Read more >
Kelas CB Method LIVE - YouTube
Kelas CB Method : https://cbmethod.onpay.my/order/form/cbkelasPelajari buat duit USD dengan Clickbank.#clickbank #USD.
Read more >
JPA 2.2's new getResultStream() method and how you ...
JPA 2.2's getResultStream() method returns the result set as a Stream, which can help to process it efficiently. But there are some things...
Read more >
The Definitive Guide to Object Streams in Node.js
Node.js Streams come with a great power. This post walks you through the theory, and teaches how to use object stream transformables, ...
Read more >
How to use the binary.stream function in binary
function session (stream, cb) { Binary.stream(stream) .word8('ver') .word8('nmethods') ... username + password only //var method = methods[2] ?
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found