aboutsummaryrefslogtreecommitdiff
path: root/node_modules/es5-ext/string/#/ends-with
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/es5-ext/string/#/ends-with')
-rw-r--r--node_modules/es5-ext/string/#/ends-with/implement.js9
-rw-r--r--node_modules/es5-ext/string/#/ends-with/index.js5
-rw-r--r--node_modules/es5-ext/string/#/ends-with/is-implemented.js8
-rw-r--r--node_modules/es5-ext/string/#/ends-with/shim.js18
4 files changed, 40 insertions, 0 deletions
diff --git a/node_modules/es5-ext/string/#/ends-with/implement.js b/node_modules/es5-ext/string/#/ends-with/implement.js
new file mode 100644
index 000000000..19e5b86b8
--- /dev/null
+++ b/node_modules/es5-ext/string/#/ends-with/implement.js
@@ -0,0 +1,9 @@
+"use strict";
+
+if (!require("./is-implemented")()) {
+ Object.defineProperty(String.prototype, "endsWith",
+ { value: require("./shim"),
+configurable: true,
+enumerable: false,
+ writable: true });
+}
diff --git a/node_modules/es5-ext/string/#/ends-with/index.js b/node_modules/es5-ext/string/#/ends-with/index.js
new file mode 100644
index 000000000..952ed0ce1
--- /dev/null
+++ b/node_modules/es5-ext/string/#/ends-with/index.js
@@ -0,0 +1,5 @@
+"use strict";
+
+module.exports = require("./is-implemented")()
+ ? String.prototype.endsWith
+ : require("./shim");
diff --git a/node_modules/es5-ext/string/#/ends-with/is-implemented.js b/node_modules/es5-ext/string/#/ends-with/is-implemented.js
new file mode 100644
index 000000000..fce38eb8e
--- /dev/null
+++ b/node_modules/es5-ext/string/#/ends-with/is-implemented.js
@@ -0,0 +1,8 @@
+"use strict";
+
+var str = "razdwatrzy";
+
+module.exports = function () {
+ if (typeof str.endsWith !== "function") return false;
+ return (str.endsWith("trzy") === true) && (str.endsWith("raz") === false);
+};
diff --git a/node_modules/es5-ext/string/#/ends-with/shim.js b/node_modules/es5-ext/string/#/ends-with/shim.js
new file mode 100644
index 000000000..c5371aa93
--- /dev/null
+++ b/node_modules/es5-ext/string/#/ends-with/shim.js
@@ -0,0 +1,18 @@
+"use strict";
+
+var toInteger = require("../../../number/to-integer")
+ , value = require("../../../object/valid-value")
+ , isValue = require("../../../object/is-value")
+ , min = Math.min
+ , max = Math.max;
+
+module.exports = function (searchString /*, endPosition*/) {
+ var self, start, endPos;
+ self = String(value(this));
+ searchString = String(searchString);
+ endPos = arguments[1];
+ start =
+ (isValue(endPos) ? min(max(toInteger(endPos), 0), self.length) : self.length) -
+ searchString.length;
+ return start < 0 ? false : self.indexOf(searchString, start) === start;
+};