Neutron Polarization Manipulator

    text-stream-search
    TypeScript icon, indicating that this package has built-in type declarations

    4.0.3 • Public • Published

    Text Search in Node.JS Streams

    Circle CI Code Coverage 0 dependencies install size Language grade: JavaScript

    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()

    Related projects

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

    Development

    All contributions and feedback, no matter how big or small, is welcome. Please submit bugs, ideas, or improvements via an issue or pull request.

    • run all tests: make test
    • run unit tests: make unit
    • run linters: make lint
    • fix formatting issues: make lint
    • see all available make commands: make help

    Deploy a new version

    • update the version in package.json and commit to master
    • run npm publish

    Keywords

    none

    Install

    npm i text-stream-search

    DownloadsWeekly Downloads

    2,198

    Version

    4.0.3

    License

    ISC

    Unpacked Size

    14.6 kB

    Total Files

    21

    Last publish

    Collaborators

    • hallettj
    • originate-owner
    • kevingoslar