Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

replacestream

Package Overview
Dependencies
Maintainers
2
Versions
22
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

replacestream

A node.js through stream that does basic streaming text search and replace and is chunk boundary friendly

  • 1.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
432K
increased by2.13%
Maintainers
2
Weekly downloads
 
Created

What is replacestream?

The replacestream npm package allows you to perform stream-based search and replace operations on text. It is particularly useful for processing large files or streams of data where you want to replace specific patterns or strings efficiently.

What are replacestream's main functionalities?

Basic String Replacement

This feature allows you to replace occurrences of a specific string with another string in a stream. In this example, 'oldString' in 'input.txt' is replaced with 'newString' and the result is written to 'output.txt'.

const fs = require('fs');
const replaceStream = require('replacestream');

fs.createReadStream('input.txt')
  .pipe(replaceStream('oldString', 'newString'))
  .pipe(fs.createWriteStream('output.txt'));

Regex Replacement

This feature allows you to use regular expressions for more complex search and replace operations. In this example, all sequences of digits in 'input.txt' are replaced with the string 'number' and the result is written to 'output.txt'.

const fs = require('fs');
const replaceStream = require('replacestream');

fs.createReadStream('input.txt')
  .pipe(replaceStream(/\d+/g, 'number'))
  .pipe(fs.createWriteStream('output.txt'));

Function-based Replacement

This feature allows you to use a function to determine the replacement value. In this example, every occurrence of 'foo' in 'input.txt' is replaced with its uppercase version 'FOO' and the result is written to 'output.txt'.

const fs = require('fs');
const replaceStream = require('replacestream');

fs.createReadStream('input.txt')
  .pipe(replaceStream('foo', (match) => match.toUpperCase()))
  .pipe(fs.createWriteStream('output.txt'));

Other packages similar to replacestream

Keywords

FAQs

Package last updated on 05 Nov 2014

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc