Socket
Socket
Sign inDemoInstall

sim-replace

Package Overview
Dependencies
0
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    sim-replace

A small utility to execute multiple replaces simultaneously


Version published
Weekly downloads
2
Maintainers
1
Created
Weekly downloads
 

Readme

Source

sim-replace

A small utility to execute multiple replaces simultaneously

NPM Version Downloads Stats

About

sim-replace, or Simultaneous Replace, is a small utilty that will execute mutliple regex replaces simultaneously.

Installation

Install via Yarn (recommended):

yarn add sim-replace -D

Install via NPM:

npm install sim-replace --save-dev

Usage

Note that we're using ES6 import statements here. Usage with require works just as well.

import simReplace from 'sim-replace'

let text = 'There was a cow and a cat'

let result = simReplace(text, [
  [/cow/g, 'cat'],
  [/cat/g, 'cow']
])

result === 'There was a cat and a cow' // true

It also supports capturing group placeholders

import simReplace from 'sim-replace'

let text = 'This is my sister'

let result = simReplace(text, [
  [/(my sister)/g, 'Fanny, $1']
])

result === 'This is Fanny, my sister' // true

Contributing

  1. Fork it (https://github.com/scriptcoded/sim-replace/fork)
  2. Create your feature branch (git checkout -b feature/fooBar)
  3. Commit your changes (git commit -am 'Add some fooBar')
  4. Push to the branch (git push origin feature/fooBar)
  5. Create a new Pull Request

Additional information

Malcolm Nihlén - malcolm.nihlen@gmail.com

Distributed under the MIT licence. See LICENCE for more information.

https://github.com/scriptcoded

Keywords

FAQs

Last updated on 05 Sep 2018

Did you know?

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

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc