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

string-replace-async

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

string-replace-async

Asynchronous String.prototype.replace()

  • 1.2.0
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
61K
decreased by-11.95%
Maintainers
1
Weekly downloads
 
Created
Source

string-replace-async Build Status

Asynchronous String.prototype.replace()

Install

$ npm install --save string-replace-async

Usage

const stringReplaceAsync = require('string-replace-async');
const ghUser = require('gh-user');

function replacer(match, login) {
	return ghUser(login).then(user => user.name);
}

stringReplaceAsync('Sup, {dsblv}', /{([^}]*)}/g, replacer)
	.then(console.log);
//=> 'Sup, Dimzel Sobolev'

API

The API is basically the same as String.prototype.replace(), except the first argument is a string itself.

stringReplaceAsync(string, expression, replacer)

Invokes replacers concurrently, returns a promise that resolves to processed string.

stringReplaceAsync.seq(string, expression, replacer)

Invokes replacers sequentially, returns a promise that resolves to processed string.

string

Type: string
Required

A string to be processed.

expression

Type: regexp, string
Required

An expression to match substrings to replace.

replacer

Type: function, string
Required

A function that takes several arguments and returns a promise. Resolved value will be used as replacement string.

License

MIT © Dmitriy Sobolev

Keywords

FAQs

Package last updated on 02 Feb 2016

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