plain-replace.js 316 B

12345678910
  1. "use strict";
  2. var indexOf = String.prototype.indexOf, slice = String.prototype.slice;
  3. module.exports = function (search, replace) {
  4. var index = indexOf.call(this, search);
  5. if (index === -1) return String(this);
  6. return slice.call(this, 0, index) + replace +
  7. slice.call(this, index + String(search).length);
  8. };