Merge pull request #33564 from nwtgck/cheerio-buffer-load

[cheerio] Allow user to use Buffer in load()
This commit is contained in:
Gabriela Britto
2019-03-06 10:07:31 -08:00
committed by GitHub
2 changed files with 6 additions and 2 deletions
+2
View File
@@ -24,6 +24,8 @@ if ($fromElement("ul > li").length !== 3) {
throw new Error("Expecting 3 elements when passing `CheerioElement` to `load()`");
}
$ = cheerio.load(Buffer.from(html));
$ = cheerio.load(html, {
normalizeWhitespace: true,
xmlMode: true
+4 -2
View File
@@ -1,8 +1,10 @@
// Type definitions for Cheerio v0.22.0
// Project: https://github.com/cheeriojs/cheerio
// Definitions by: Bret Little <https://github.com/blittle>, VILIC VANE <http://vilic.info>, Wayne Maurer <https://github.com/wmaurer>, Umar Nizamani <https://github.com/umarniz>, LiJinyao <https://github.com/LiJinyao>, Chennakrishna <https://github.com/chennakrishna8>, AzSiAz <https://github.com/AzSiAz>
// Definitions by: Bret Little <https://github.com/blittle>, VILIC VANE <http://vilic.info>, Wayne Maurer <https://github.com/wmaurer>, Umar Nizamani <https://github.com/umarniz>, LiJinyao <https://github.com/LiJinyao>, Chennakrishna <https://github.com/chennakrishna8>, AzSiAz <https://github.com/AzSiAz>, Ryo Ota <https://github.com/nwtgck>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
/// <reference types="node" />
interface Cheerio {
// Document References
// Cheerio https://github.com/cheeriojs/cheerio
@@ -266,7 +268,7 @@ interface CheerioElement {
}
interface CheerioAPI extends CheerioSelector, CheerioStatic {
load(html: string, options?: CheerioOptionsInterface): CheerioStatic;
load(html: string | Buffer, options?: CheerioOptionsInterface): CheerioStatic;
load(element: CheerioElement, options?: CheerioOptionsInterface): CheerioStatic;
}