Version 1
[yaffs-website] / node_modules / underscore.string / truncate.js
diff --git a/node_modules/underscore.string/truncate.js b/node_modules/underscore.string/truncate.js
new file mode 100644 (file)
index 0000000..dbb8fd7
--- /dev/null
@@ -0,0 +1,8 @@
+var makeString = require('./helper/makeString');
+
+module.exports = function truncate(str, length, truncateStr) {
+  str = makeString(str);
+  truncateStr = truncateStr || '...';
+  length = ~~length;
+  return str.length > length ? str.slice(0, length) + truncateStr : str;
+};