Function: loadBuffer()

Function: loadBuffer()

function loadBuffer(buffer, options?): CheerioAPI;

Defined in: index.ts

Sniffs the encoding of a buffer, then creates a querying function bound to a document created from the buffer.

Parameters

ParameterTypeDescription
bufferBufferThe buffer to sniff the encoding of.
optionsDecodeStreamOptionsThe options to pass to Cheerio.

Returns

CheerioAPI

The loaded document.

Example

import * as cheerio from 'cheerio';

const buffer = fs.readFileSync('index.html');
const $ = cheerio.loadBuffer(buffer);