[cheerio] Refactor using namespace to expose internal types for callers (#46006)

* [cheerio] Export interfaces

This makes it possible to write a function like this, which accepts these internal types:

```ts
function hasSelector(parsed: CheerioSelector, selector: string) {
  return parsed(selector).length
}
```

* Rework using a combination of module and namespace

* Update related defs

* Remove obsolete comment

* CheerioOptions -> CheerioParserOptions

* Update enzyme

* Update enzyme, again

* Fix most of this

* Fix merge error

* Fix enzyme-react-intl

* Try to fix lint error

* update enzyme-to-json

* cheerio: Add missing `version` property

* Revert lint config change

* Rename CheerioRoot -> Root et al
This commit is contained in:
Paul Melnikow 2020-09-23 14:58:06 -04:00 committed by GitHub
parent fd1ac666e8
commit c9a000fa00
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
11 changed files with 318 additions and 310 deletions

View File

@ -176,7 +176,7 @@ declare namespace Chai {
declare module "chai-enzyme" {
import { ShallowWrapper, ReactWrapper } from "enzyme";
type DebugWrapper = ShallowWrapper<any,any> | Cheerio | ReactWrapper<any, any>;
type DebugWrapper = ShallowWrapper<any,any> | cheerio.Cheerio | ReactWrapper<any, any>;
function chaiEnzyMe(wrapper?: (debugWrapper: DebugWrapper) => string): Chai.ChaiPlugin;
module chaiEnzyMe {

View File

@ -21,7 +21,7 @@ cheerio('li', 'ul', html);
const $fromElement = cheerio.load($('ul').get(0));
if ($fromElement('ul > li').length !== 3) {
throw new Error('Expecting 3 elements when passing `CheerioElement` to `load()`');
throw new Error('Expecting 3 elements when passing `cheerio.Element` to `load()`');
}
$ = cheerio.load(Buffer.from(html));
@ -337,3 +337,6 @@ $.parseHTML(html, null, true);
$el.toArray();
cheerio.html($el);
// $ExpectType string
cheerio.version;

View File

@ -13,292 +13,295 @@
/// <reference types="node" />
declare type AttrFunction = (el: CheerioElement, i: number, currentValue: string) => any;
interface Cheerio {
// Document References
// Cheerio https://github.com/cheeriojs/cheerio
// JQuery http://api.jquery.com
[index: number]: CheerioElement;
cheerio: string;
length: number;
// Attributes
attr(): { [attr: string]: string };
attr(name: string): string | undefined;
attr(name: string, value: AttrFunction): Cheerio;
// `value` *can* be `any` here but:
// 1. That makes type-checking the function-type useless
// 2. It's converted to a string anyways
attr(name: string, value: string): Cheerio;
// The map's values *can* be `any` but they'll all be cast to strings
// regardless.
attr(map: { [key: string]: any }): Cheerio;
data(): any;
data(name: string): any;
data(name: string, value: any): any;
val(): string;
val(value: string): Cheerio;
removeAttr(name: string): Cheerio;
has(selector: string): Cheerio;
has(element: CheerioElement): Cheerio;
hasClass(className: string): boolean;
addClass(classNames: string): Cheerio;
removeClass(): Cheerio;
removeClass(className: string): Cheerio;
removeClass(func: (index: number, className: string) => string): Cheerio;
toggleClass(className: string): Cheerio;
toggleClass(className: string, toggleSwitch: boolean): Cheerio;
toggleClass(toggleSwitch?: boolean): Cheerio;
toggleClass(
func: (index: number, className: string, toggleSwitch: boolean) => string,
toggleSwitch?: boolean,
): Cheerio;
is(selector: string): boolean;
is(element: CheerioElement): boolean;
is(element: CheerioElement[]): boolean;
is(selection: Cheerio): boolean;
is(func: (index: number, element: CheerioElement) => boolean): boolean;
// Form
serialize(): string;
serializeArray(): { name: string; value: string }[];
// Traversing
find(selector: string): Cheerio;
find(element: Cheerio): Cheerio;
parent(selector?: string): Cheerio;
parents(selector?: string): Cheerio;
parentsUntil(selector?: string, filter?: string): Cheerio;
parentsUntil(element: CheerioElement, filter?: string): Cheerio;
parentsUntil(element: Cheerio, filter?: string): Cheerio;
prop(name: string): any;
prop(name: string, value: any): Cheerio;
closest(): Cheerio;
closest(selector: string): Cheerio;
next(selector?: string): Cheerio;
nextAll(): Cheerio;
nextAll(selector: string): Cheerio;
nextUntil(selector?: string, filter?: string): Cheerio;
nextUntil(element: CheerioElement, filter?: string): Cheerio;
nextUntil(element: Cheerio, filter?: string): Cheerio;
prev(selector?: string): Cheerio;
prevAll(): Cheerio;
prevAll(selector: string): Cheerio;
prevUntil(selector?: string, filter?: string): Cheerio;
prevUntil(element: CheerioElement, filter?: string): Cheerio;
prevUntil(element: Cheerio, filter?: string): Cheerio;
slice(start: number, end?: number): Cheerio;
siblings(selector?: string): Cheerio;
children(selector?: string): Cheerio;
contents(): Cheerio;
each(func: (index: number, element: CheerioElement) => any): Cheerio;
map(func: (index: number, element: CheerioElement) => any): Cheerio;
filter(selector: string): Cheerio;
filter(selection: Cheerio): Cheerio;
filter(element: CheerioElement): Cheerio;
filter(elements: CheerioElement[]): Cheerio;
filter(func: (index: number, element: CheerioElement) => boolean): Cheerio;
not(selector: string): Cheerio;
not(selection: Cheerio): Cheerio;
not(element: CheerioElement): Cheerio;
not(func: (index: number, element: CheerioElement) => boolean): Cheerio;
first(): Cheerio;
last(): Cheerio;
eq(index: number): Cheerio;
get(): any[];
get(index: number): any;
index(): number;
index(selector: string): number;
index(selection: Cheerio): number;
end(): Cheerio;
add(selectorOrHtml: string): Cheerio;
add(selector: string, context: Document): Cheerio;
add(element: CheerioElement): Cheerio;
add(elements: CheerioElement[]): Cheerio;
add(selection: Cheerio): Cheerio;
addBack(): Cheerio;
addBack(filter: string): Cheerio;
// Manipulation
appendTo(target: Cheerio): Cheerio;
prependTo(target: Cheerio): Cheerio;
append(content: string, ...contents: any[]): Cheerio;
append(content: Document, ...contents: any[]): Cheerio;
append(content: Document[], ...contents: any[]): Cheerio;
append(content: Cheerio, ...contents: any[]): Cheerio;
prepend(content: string, ...contents: any[]): Cheerio;
prepend(content: Document, ...contents: any[]): Cheerio;
prepend(content: Document[], ...contents: any[]): Cheerio;
prepend(content: Cheerio, ...contents: any[]): Cheerio;
after(content: string, ...contents: any[]): Cheerio;
after(content: Document, ...contents: any[]): Cheerio;
after(content: Document[], ...contents: any[]): Cheerio;
after(content: Cheerio, ...contents: any[]): Cheerio;
insertAfter(content: string): Cheerio;
insertAfter(content: Document): Cheerio;
insertAfter(content: Cheerio): Cheerio;
before(content: string, ...contents: any[]): Cheerio;
before(content: Document, ...contents: any[]): Cheerio;
before(content: Document[], ...contents: any[]): Cheerio;
before(content: Cheerio, ...contents: any[]): Cheerio;
insertBefore(content: string): Cheerio;
insertBefore(content: Document): Cheerio;
insertBefore(content: Cheerio): Cheerio;
remove(selector?: string): Cheerio;
replaceWith(content: string): Cheerio;
replaceWith(content: CheerioElement): Cheerio;
replaceWith(content: CheerioElement[]): Cheerio;
replaceWith(content: Cheerio): Cheerio;
replaceWith(content: () => Cheerio): Cheerio;
empty(): Cheerio;
html(): string | null;
html(html: string): Cheerio;
text(): string;
text(text: string): Cheerio;
wrap(content: string): Cheerio;
wrap(content: Document): Cheerio;
wrap(content: Cheerio): Cheerio;
css(propertyName: string): string;
css(propertyNames: string[]): string[];
css(propertyName: string, value: string): Cheerio;
css(propertyName: string, value: number): Cheerio;
css(propertyName: string, func: (index: number, value: string) => string): Cheerio;
css(propertyName: string, func: (index: number, value: string) => number): Cheerio;
css(properties: Object): Cheerio;
// Rendering
// Miscellaneous
clone(): Cheerio;
// Not Documented
toArray(): CheerioElement[];
}
interface CheerioOptionsInterface {
// Document References
// Cheerio https://github.com/cheeriojs/cheerio
// HTMLParser2 https://github.com/fb55/htmlparser2/wiki/Parser-options
// DomHandler https://github.com/fb55/DomHandler
xmlMode?: boolean;
decodeEntities?: boolean;
lowerCaseTags?: boolean;
lowerCaseAttributeNames?: boolean;
recognizeCDATA?: boolean;
recognizeSelfClosing?: boolean;
normalizeWhitespace?: boolean;
withStartIndices?: boolean;
withEndIndices?: boolean;
ignoreWhitespace?: boolean;
_useHtmlParser2?: boolean;
}
interface CheerioSelector {
(selector: string): Cheerio;
(selector: string, context: string): Cheerio;
(selector: string, context: CheerioElement): Cheerio;
(selector: string, context: CheerioElement[]): Cheerio;
(selector: string, context: Cheerio): Cheerio;
(selector: string, context: string, root: string): Cheerio;
(selector: string, context: CheerioElement, root: string): Cheerio;
(selector: string, context: CheerioElement[], root: string): Cheerio;
(selector: string, context: Cheerio, root: string): Cheerio;
(selector: any): Cheerio;
}
interface CheerioStatic extends CheerioSelector {
// Document References
// Cheerio https://github.com/cheeriojs/cheerio
// JQuery http://api.jquery.com
root(): Cheerio;
contains(container: CheerioElement, contained: CheerioElement): boolean;
parseHTML(data: string, context?: Document, keepScripts?: boolean): Document[];
html(options?: CheerioOptionsInterface): string;
html(dom: string | Cheerio | CheerioElement, options?: CheerioOptionsInterface): string;
xml(dom?: string | Cheerio | CheerioElement): string;
}
interface CheerioElement {
// Document References
// Node Console
tagName: string;
type: string;
name: string;
attribs: { [attr: string]: string };
children: CheerioElement[];
childNodes: CheerioElement[];
lastChild: CheerioElement;
firstChild: CheerioElement;
next: CheerioElement;
nextSibling: CheerioElement;
prev: CheerioElement;
previousSibling: CheerioElement;
parent: CheerioElement;
parentNode: CheerioElement;
nodeValue: string;
data?: string;
startIndex?: number;
}
interface CheerioAPI extends CheerioSelector, CheerioStatic {
load(html: string | Buffer, options?: CheerioOptionsInterface): CheerioStatic;
load(element: CheerioElement, options?: CheerioOptionsInterface): CheerioStatic;
}
interface Document {}
declare module 'cheerio' {
const cheerio: CheerioAPI;
export = cheerio;
declare namespace cheerio {
interface Element {
// Document References
// Node Console
tagName: string;
type: string;
name: string;
attribs: { [attr: string]: string };
children: Element[];
childNodes: Element[];
lastChild: Element;
firstChild: Element;
next: Element;
nextSibling: Element;
prev: Element;
previousSibling: Element;
parent: Element;
parentNode: Element;
nodeValue: string;
data?: string;
startIndex?: number;
}
type AttrFunction = (el: Element, i: number, currentValue: string) => any;
interface Cheerio {
// Document References
// Cheerio https://github.com/cheeriojs/cheerio
// JQuery http://api.jquery.com
[index: number]: Element;
cheerio: string;
length: number;
// Attributes
attr(): { [attr: string]: string };
attr(name: string): string | undefined;
attr(name: string, value: AttrFunction): Cheerio;
// `value` *can* be `any` here but:
// 1. That makes type-checking the function-type useless
// 2. It's converted to a string anyways
attr(name: string, value: string): Cheerio;
// The map's values *can* be `any` but they'll all be cast to strings
// regardless.
attr(map: { [key: string]: any }): Cheerio;
data(): any;
data(name: string): any;
data(name: string, value: any): any;
val(): string;
val(value: string): Cheerio;
removeAttr(name: string): Cheerio;
has(selector: string): Cheerio;
has(element: Element): Cheerio;
hasClass(className: string): boolean;
addClass(classNames: string): Cheerio;
removeClass(): Cheerio;
removeClass(className: string): Cheerio;
removeClass(func: (index: number, className: string) => string): Cheerio;
toggleClass(className: string): Cheerio;
toggleClass(className: string, toggleSwitch: boolean): Cheerio;
toggleClass(toggleSwitch?: boolean): Cheerio;
toggleClass(
func: (index: number, className: string, toggleSwitch: boolean) => string,
toggleSwitch?: boolean,
): Cheerio;
is(selector: string): boolean;
is(element: Element): boolean;
is(element: Element[]): boolean;
is(selection: Cheerio): boolean;
is(func: (index: number, element: Element) => boolean): boolean;
// Form
serialize(): string;
serializeArray(): { name: string; value: string }[];
// Traversing
find(selector: string): Cheerio;
find(element: Cheerio): Cheerio;
parent(selector?: string): Cheerio;
parents(selector?: string): Cheerio;
parentsUntil(selector?: string, filter?: string): Cheerio;
parentsUntil(element: Element, filter?: string): Cheerio;
parentsUntil(element: Cheerio, filter?: string): Cheerio;
prop(name: string): any;
prop(name: string, value: any): Cheerio;
closest(): Cheerio;
closest(selector: string): Cheerio;
next(selector?: string): Cheerio;
nextAll(): Cheerio;
nextAll(selector: string): Cheerio;
nextUntil(selector?: string, filter?: string): Cheerio;
nextUntil(element: Element, filter?: string): Cheerio;
nextUntil(element: Cheerio, filter?: string): Cheerio;
prev(selector?: string): Cheerio;
prevAll(): Cheerio;
prevAll(selector: string): Cheerio;
prevUntil(selector?: string, filter?: string): Cheerio;
prevUntil(element: Element, filter?: string): Cheerio;
prevUntil(element: Cheerio, filter?: string): Cheerio;
slice(start: number, end?: number): Cheerio;
siblings(selector?: string): Cheerio;
children(selector?: string): Cheerio;
contents(): Cheerio;
each(func: (index: number, element: Element) => any): Cheerio;
map(func: (index: number, element: Element) => any): Cheerio;
filter(selector: string): Cheerio;
filter(selection: Cheerio): Cheerio;
filter(element: Element): Cheerio;
filter(elements: Element[]): Cheerio;
filter(func: (index: number, element: Element) => boolean): Cheerio;
not(selector: string): Cheerio;
not(selection: Cheerio): Cheerio;
not(element: Element): Cheerio;
not(func: (index: number, element: Element) => boolean): Cheerio;
first(): Cheerio;
last(): Cheerio;
eq(index: number): Cheerio;
get(): any[];
get(index: number): any;
index(): number;
index(selector: string): number;
index(selection: Cheerio): number;
end(): Cheerio;
add(selectorOrHtml: string): Cheerio;
add(selector: string, context: Document): Cheerio;
add(element: Element): Cheerio;
add(elements: Element[]): Cheerio;
add(selection: Cheerio): Cheerio;
addBack(): Cheerio;
addBack(filter: string): Cheerio;
// Manipulation
appendTo(target: Cheerio): Cheerio;
prependTo(target: Cheerio): Cheerio;
append(content: string, ...contents: any[]): Cheerio;
append(content: Document, ...contents: any[]): Cheerio;
append(content: Document[], ...contents: any[]): Cheerio;
append(content: Cheerio, ...contents: any[]): Cheerio;
prepend(content: string, ...contents: any[]): Cheerio;
prepend(content: Document, ...contents: any[]): Cheerio;
prepend(content: Document[], ...contents: any[]): Cheerio;
prepend(content: Cheerio, ...contents: any[]): Cheerio;
after(content: string, ...contents: any[]): Cheerio;
after(content: Document, ...contents: any[]): Cheerio;
after(content: Document[], ...contents: any[]): Cheerio;
after(content: Cheerio, ...contents: any[]): Cheerio;
insertAfter(content: string): Cheerio;
insertAfter(content: Document): Cheerio;
insertAfter(content: Cheerio): Cheerio;
before(content: string, ...contents: any[]): Cheerio;
before(content: Document, ...contents: any[]): Cheerio;
before(content: Document[], ...contents: any[]): Cheerio;
before(content: Cheerio, ...contents: any[]): Cheerio;
insertBefore(content: string): Cheerio;
insertBefore(content: Document): Cheerio;
insertBefore(content: Cheerio): Cheerio;
remove(selector?: string): Cheerio;
replaceWith(content: string): Cheerio;
replaceWith(content: Element): Cheerio;
replaceWith(content: Element[]): Cheerio;
replaceWith(content: Cheerio): Cheerio;
replaceWith(content: () => Cheerio): Cheerio;
empty(): Cheerio;
html(): string | null;
html(html: string): Cheerio;
text(): string;
text(text: string): Cheerio;
wrap(content: string): Cheerio;
wrap(content: Document): Cheerio;
wrap(content: Cheerio): Cheerio;
css(propertyName: string): string;
css(propertyNames: string[]): string[];
css(propertyName: string, value: string): Cheerio;
css(propertyName: string, value: number): Cheerio;
css(propertyName: string, func: (index: number, value: string) => string): Cheerio;
css(propertyName: string, func: (index: number, value: string) => number): Cheerio;
css(properties: Object): Cheerio;
// Rendering
// Miscellaneous
clone(): Cheerio;
// Not Documented
toArray(): Element[];
}
interface CheerioParserOptions {
// Document References
// Cheerio https://github.com/cheeriojs/cheerio
// HTMLParser2 https://github.com/fb55/htmlparser2/wiki/Parser-options
// DomHandler https://github.com/fb55/DomHandler
xmlMode?: boolean;
decodeEntities?: boolean;
lowerCaseTags?: boolean;
lowerCaseAttributeNames?: boolean;
recognizeCDATA?: boolean;
recognizeSelfClosing?: boolean;
normalizeWhitespace?: boolean;
withStartIndices?: boolean;
withEndIndices?: boolean;
ignoreWhitespace?: boolean;
_useHtmlParser2?: boolean;
}
interface Selector {
(selector: string): Cheerio;
(selector: string, context: string): Cheerio;
(selector: string, context: Element): Cheerio;
(selector: string, context: Element[]): Cheerio;
(selector: string, context: Cheerio): Cheerio;
(selector: string, context: string, root: string): Cheerio;
(selector: string, context: Element, root: string): Cheerio;
(selector: string, context: Element[], root: string): Cheerio;
(selector: string, context: Cheerio, root: string): Cheerio;
(selector: any): Cheerio;
}
interface Root extends Selector {
// Document References
// Cheerio https://github.com/cheeriojs/cheerio
// JQuery http://api.jquery.com
root(): Cheerio;
contains(container: Element, contained: Element): boolean;
parseHTML(data: string, context?: Document, keepScripts?: boolean): Document[];
html(options?: CheerioParserOptions): string;
html(dom: string | Cheerio | Element, options?: CheerioParserOptions): string;
xml(dom?: string | Cheerio | Element): string;
}
interface CheerioAPI extends Root {
version: string;
load(html: string | Buffer, options?: CheerioParserOptions): Root;
load(element: Element, options?: CheerioParserOptions): Root;
}
}
declare module 'cheerio' {
const cheerioModule: cheerio.CheerioAPI;
export = cheerioModule;
}

View File

@ -30,7 +30,7 @@ export function mountWithIntl<P, S>(node: ReactElement<P>, options?: MountRender
// render method
// tslint:disable-next-line no-unnecessary-generics
export function renderWithIntl<P, S>(node: ReactElement<P>, options?: any): Cheerio;
export function renderWithIntl<P, S>(node: ReactElement<P>, options?: any): cheerio.Cheerio;
// other methods

View File

@ -6,4 +6,4 @@
import { ReactWrapper, ShallowWrapper } from 'enzyme';
export default function toJson<P, S>(wrapper: ShallowWrapper<P, S> | ReactWrapper<P, S> | Cheerio): object;
export default function toJson<P, S>(wrapper: ShallowWrapper<P, S> | ReactWrapper<P, S> | cheerio.Cheerio): object;

View File

@ -998,7 +998,7 @@ function ReactWrapperTest() {
// CheerioWrapper
function CheerioWrapperTest() {
const wrapper: Cheerio =
const wrapper: cheerio.Cheerio =
shallow(<div />).render() ||
mount(<div />).render();

View File

@ -381,7 +381,7 @@ export interface CommonWrapper<P = {}, S = {}, C = Component<P, S>> {
/**
* Renders the component to static markup and returns a Cheerio wrapper around the result.
*/
render(): Cheerio;
render(): cheerio.Cheerio;
/**
* Returns the type of the current node of this wrapper. If it's a composite component, this will be the
@ -727,7 +727,7 @@ export function mount<P, S>(node: ReactElement<P>, options?: MountRendererProps)
/**
* Render react components to static HTML and analyze the resulting HTML structure.
*/
export function render<P, S>(node: ReactElement<P>, options?: any): Cheerio;
export function render<P, S>(node: ReactElement<P>, options?: any): cheerio.Cheerio;
// See https://github.com/airbnb/enzyme/blob/v3.10.0/packages/enzyme/src/EnzymeAdapter.js
export class EnzymeAdapter {

View File

@ -1,4 +1,5 @@
import cheerio = require('gulp-cheerio');
import cheerio = require('cheerio');
import gulpCheerio = require('gulp-cheerio');
import gulp = require('gulp');
import Vinyl = require('vinyl');
@ -9,7 +10,7 @@ import Vinyl = require('vinyl');
gulp.task('sync', function () {
return gulp
.src(['src/*.html'])
.pipe(cheerio(function ($: CheerioStatic, file: Vinyl) {
.pipe(gulpCheerio(function ($: cheerio.Root, file: Vinyl) {
// Each file will be run through cheerio and each corresponding `$` will be passed here.
// `file` is the gulp file object
// Make all h1 tags uppercase
@ -23,7 +24,7 @@ gulp.task('sync', function () {
gulp.task('async', function () {
return gulp
.src(['src/*.html'])
.pipe(cheerio(function ($: CheerioStatic, file: Vinyl, done: Function) {
.pipe(gulpCheerio(function ($: cheerio.Root, file: Vinyl, done: Function) {
// The only difference here is the inclusion of a `done` parameter.
// Call `done` when everything is finished. `done` accepts an error if applicable.
done();
@ -41,8 +42,8 @@ gulp.task('async', function () {
gulp.task('sync', function () {
return gulp
.src(['src/*.html'])
.pipe(cheerio({
run: function ($: CheerioStatic, file: Vinyl) {
.pipe(gulpCheerio({
run: function ($: cheerio.Root, file: Vinyl) {
// Each file will be run through cheerio and each corresponding `$` will be passed here.
// `file` is the gulp file object
// Make all h1 tags uppercase
@ -58,8 +59,8 @@ gulp.task('sync', function () {
gulp.task('async', function () {
return gulp
.src(['src/*.html'])
.pipe(cheerio({
run: function ($: CheerioStatic, file: Vinyl, done: Function) {
.pipe(gulpCheerio({
run: function ($: cheerio.Root, file: Vinyl, done: Function) {
// The only difference here is the inclusion of a `done` parameter.
// Call `done` when everything is finished. `done` accepts an error if applicable.
done();
@ -84,5 +85,5 @@ cheerio({
});
cheerio({
cheerio: require('../cheerio/cheerio.d.ts') as CheerioStatic // special version of `cheerio`
cheerio: require('../cheerio/cheerio.d.ts')
});

View File

@ -8,24 +8,25 @@
/// <reference types="vinyl" />
import Vinyl = require('vinyl');
import cheerio = require('cheerio');
declare namespace cheerio {
interface Cheerio {
declare namespace gulpCheerio {
interface GulpCheerio {
(callback: Callback): NodeJS.ReadWriteStream;
(option: Option): NodeJS.ReadWriteStream;
}
interface Callback {
($: CheerioStatic, file: Vinyl, done?: Function): any;
($: cheerio.Root, file: Vinyl, done?: Function): any;
}
interface Option {
run?: Callback;
parserOptions?: CheerioOptionsInterface;
cheerio?: CheerioStatic;
parserOptions?: cheerio.CheerioParserOptions;
cheerio?: cheerio.Root;
}
}
declare var cheerio: cheerio.Cheerio;
declare var gulpCheerio: gulpCheerio.GulpCheerio;
export = cheerio;
export = gulpCheerio;

View File

@ -10,6 +10,6 @@ export type Node = string | [string, ...any[]];
export function parse(xml: string, trim?: boolean): Node[];
export function stringify(
object: Node[],
replacer?: ((node: Cheerio) => any) | null,
replacer?: ((node: cheerio.Cheerio) => any) | null,
indent?: number
): string;

View File

@ -66,7 +66,7 @@ declare namespace og {
}
function parse(websiteContent: string, options?: Options): Data;
function getHTML(url: string | Cheerio, callback: RequestCallback): void;
function getHTML(url: string | cheerio.Cheerio, callback: RequestCallback): void;
}
declare function og(url: string, callback: og.DataCallback, options?: og.Options): void;