cheeriojs / cheerio

The fast, flexible, and elegant library for parsing and manipulating HTML and XML.
https://cheerio.js.org
MIT License
28.69k stars 1.64k forks source link

Accept Uint8Array also instead of Buffer? #1844

Closed karlhorky closed 3 years ago

karlhorky commented 3 years ago

Hi @fb55 ! In 1.0.0-rc.9 I noticed that the types for cheerio.load only accept string | Node | Node[] | Buffer.

I'm trying to pass in a vfile.VFileContents (via remark.process), which is string | Uint8Array.

Would it be possible to also accept Uint8Array, the base type for Buffer?

fb55 commented 3 years ago

Happy to accept PRs for this! We currently rely on Buffer.isBuffer to see if something is a buffer; if you have a more generic approach, I'm happy to take it :)

karlhorky commented 3 years ago

Open: https://github.com/cheeriojs/cheerio/pull/1845

karlhorky commented 3 years ago

Ah, I guess this feature doesn't exist currently in Cheerio: https://github.com/cheeriojs/cheerio/pull/1845#issuecomment-833676354

fb55 commented 3 years ago

Closing this, as the change seems pretty involved.