lix-website/themes/lix/assets/bootstrap/node_modules/trim-repeated/index.js

11 lines
320 B
JavaScript
Raw Normal View History

2024-04-27 03:39:10 +00:00
'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);
};