Skip to content

Latest commit

 

History

History

rplace

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 

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)