web-stream-replace
TypeScript icon, indicating that this package has built-in type declarations

0.1.2 • Public • Published

web-stream-replace

Search & replace strings in a Web Streams API TransformStream.

Outputs either strings or UTF-8 encoded Uint8Arrays.

Installation

npm install --save web-stream-replace

Example

import { replace } from "web-stream-replace";

const greet = (name: string) => replace("World", name, { output: "string" });

const output = () => {
  let buf = "";
  return new WritableStream<string>({
    write(chunk) {
      buf += chunk;
    },
    close() {
      console.log(buf);
    },
  });
};

const hello = new ReadableStream({
  start(controller) {
    controller.enqueue("Hello, World!");
    controller.close();
  },
});

const transformed = hello.pipeThrough(greet("Netlify"));
await transformed.pipeTo(output());

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 0.1.2
    17
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 0.1.2
    17
  • 0.1.1
    16
  • 0.1.0
    16

Package Sidebar

Install

npm i web-stream-replace

Weekly Downloads

49

Version

0.1.2

License

MIT

Unpacked Size

20 kB

Total Files

12

Last publish

Collaborators

  • neolegends