]> git.r.bdr.sh - rbdr/dotfiles/blob
678b1cbcff4b8d5a919746c77b5dd00375cc3860
[rbdr/dotfiles] /
1 'use strict';
2
3 var value = require('../../object/valid-value');
4
5 module.exports = function (search, replace) {
6 var index, pos = 0, str = String(value(this)), sl, rl;
7 search = String(search);
8 replace = String(replace);
9 sl = search.length;
10 rl = replace.length;
11 while ((index = str.indexOf(search, pos)) !== -1) {
12 str = str.slice(0, index) + replace + str.slice(index + sl);
13 pos = index + rl;
14 }
15 return str;
16 };