text-stream-search

5.0.1 • Public • Published

Text Search in Node.JS Streams

tests Code Coverage 0 dependencies install size

This micro-library (no dependencies) searches for occurrences of a given search term (string or Regex) in a Node.js stream, i.e. anything that emits data events with Buffers or strings.

import TextStreamSearch from "text-stream-search"

const streamSearch = new TextStreamSearch(myStream)

// wait until myStream contains "hello"
await streamSearch.waitForText("hello")

// capture data from the stream
const matchText = await streamSearch.waitForRegex("listening at port \\d+.")
// matchingText contains something like "listening at port 3000."

// access the captured stream content
const text = streamSearch.fullText()

For a working example see the end-to-end test.

Related projects

  • StreamSnitch: does the same thing with regular expressions, but is buggy and blocks the event queue

Readme

Keywords

none

Package Sidebar

Install

npm i text-stream-search

Weekly Downloads

1,860

Version

5.0.1

License

ISC

Unpacked Size

18.8 kB

Total Files

30

Last publish

Collaborators

  • originate-owner
  • hallettj
  • kevingoslar