async-regexp-replace
v1.1.0
Published
String.replace with asynchronous replacer function
Downloads
24
Readme
Async Regexp Replace
import { asyncRegexpReplace } from 'async-regexp-replace';
const source = 'The quick brown fox jumps over the lazy dog';
const result = await asyncRegexpReplace(source, /(brown|lazy)\s/g, async m => {
// The replacer function can be asynchronous
await new Promise(r => setTimeout(r, 0));
return '';
});
// 'The quick fox jumps over the dog'