You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
11 lines
320 B
11 lines
320 B
5 months ago
|
'use strict';
|
||
|
var escapeStringRegexp = require('escape-string-regexp');
|
||
|
|
||
|
module.exports = function (str, target) {
|
||
|
if (typeof str !== 'string' || typeof target !== 'string') {
|
||
|
throw new TypeError('Expected a string');
|
||
|
}
|
||
|
|
||
|
return str.replace(new RegExp('(?:' + escapeStringRegexp(target) + '){2,}', 'g'), target);
|
||
|
};
|