Trilium Backend API
    Preparing search index...
    • Creates a stream that parses a sequence of strings into a document.

      The stream is a Writable stream that accepts strings. When the stream is finished, the callback is called with the loaded document.

      Parameters

      • options: CheerioOptions

        The options to pass to Cheerio.

      • cb: (err: Error, $: CheerioAPI) => void

        The callback to call when the stream is finished.

      Returns Writable

      The writable stream.

      import * as cheerio from 'cheerio';
      import * as fs from 'fs';

      const writeStream = cheerio.stringStream({}, (err, $) => {
      if (err) {
      // Handle error
      }

      console.log($('h1').text());
      // Output: Hello, world!
      });

      fs.createReadStream('my-document.html', { encoding: 'utf8' }).pipe(
      writeStream,
      );