Skip to content

armgit / mocha

Public Imported from GitHub
0

☕️ Classic, reliable, trusted test framework for Node.js and the browser

add .trim() util

TJ Holowaychuk453385e3ceb8
diff --git a/lib/utils.js b/lib/utils.js
index 1780d6b2..87ec1c71 100644
--- a/lib/utils.js
+++ b/lib/utils.js
@@ -217,4 +217,16 @@ exports.clean = function(str) {
exports.escapeRegexp = function(str){
return str.replace(/[-\\^$*+?.()|[\]{}]/g, "\\$&");
+};
+
+/**
+ * Trim the given `str`.
+ *
+ * @param {String} str
+ * @return {String}
+ * @api private
+ */
+
+exports.trim = function(str){
+ return str.replace(/^\s+|\s+$/g, '');
};
\ No newline at end of file