Skip to content

Latest commit

 

History

History
31 lines (22 loc) · 628 Bytes

readme.md

File metadata and controls

31 lines (22 loc) · 628 Bytes

rplace npm

Transform stream by replacing strings.

Install

$ yarn add rplace

Usage

const replaceStream: (searchValue: RegExp | string, replaceValue: string) => Transform

Note: don't forget g flag for RegExp

import { createReadStream, createWriteStream } from 'fs'
import { lineStream } from 'stroki'
import { replaceStream } from 'rplace'

const readStream = createReadStream('./from.txt')
const writeStream = createWriteStream('./to.txt')

readStream
  .pipe(lineStream())
  .pipe(replaceStream(/Hi (\S+)/g, 'Hey $1'))
  .pipe(writeStream)