aboutsummaryrefslogtreecommitdiff
path: root/node_modules/es5-ext/string/#/plain-replace.js
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/es5-ext/string/#/plain-replace.js')
-rw-r--r--node_modules/es5-ext/string/#/plain-replace.js10
1 files changed, 10 insertions, 0 deletions
diff --git a/node_modules/es5-ext/string/#/plain-replace.js b/node_modules/es5-ext/string/#/plain-replace.js
new file mode 100644
index 000000000..f24f5215c
--- /dev/null
+++ b/node_modules/es5-ext/string/#/plain-replace.js
@@ -0,0 +1,10 @@
+"use strict";
+
+var indexOf = String.prototype.indexOf, slice = String.prototype.slice;
+
+module.exports = function (search, replace) {
+ var index = indexOf.call(this, search);
+ if (index === -1) return String(this);
+ return slice.call(this, 0, index) + replace +
+ slice.call(this, index + String(search).length);
+};