New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

regexp-sourcemaps

Package Overview
Dependencies
Maintainers
2
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

regexp-sourcemaps

Similar to str.replace(regex, replace) but with sourcemap support

  • 1.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
2
Created
Source

regexp-sourcemaps

Apply regexp replaces on a string & get the replaced string & sourcemap as a result.

Usage

The package is rather easy to use:

var Replacer = require('regexp-sourcemaps');

var someReplacer = new Replacer(/some(.*?)content/, 'my $1 result', 'regexpName');

var res = someReplacer.replace('somesupercontent', '/path/to/file');
// res.code === 'my super result'
// res.map contain the sourcemap to map the content properly
Replacer(regexp, replace [, regexpName = null])

regexp: the regexp to match in the content with or without capturing groups

replace: the pattern to replace the match with (everything matching is replaced), can contain referencies to capturing groups using $nn with:

  • $0 or ${0}: the whole matching text
  • $n or ${n}: the nth capturing group (n ≥ 1)

regexpName: the name to give the regexp replace in the sourcemap, useful to have more info in the sourcemaps but optional

Replacer.prototype.replace(content [, file = 'content'])

content: the content on which to apply the transformation

file: the path to the file on which the transformation is applied to insert in the resulting sourcemap

Keywords

FAQs

Package last updated on 30 Apr 2015

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