Version 1
[yaffs-website] / node_modules / underscore.string / endsWith.js
diff --git a/node_modules/underscore.string/endsWith.js b/node_modules/underscore.string/endsWith.js
new file mode 100644 (file)
index 0000000..c452603
--- /dev/null
@@ -0,0 +1,13 @@
+var makeString = require('./helper/makeString');
+var toPositive = require('./helper/toPositive');
+
+module.exports = function endsWith(str, ends, position) {
+  str = makeString(str);
+  ends = '' + ends;
+  if (typeof position == 'undefined') {
+    position = str.length - ends.length;
+  } else {
+    position = Math.min(toPositive(position), str.length) - ends.length;
+  }
+  return position >= 0 && str.indexOf(ends, position) === position;
+};