☕️ Classic, reliable, trusted test framework for Node.js and the browser
Added utils.clean()
TJ Holowaychuk8ec1434f09bf
diff --git a/lib/utils.js b/lib/utils.jsindex 19600def..6ed9ccf1 100644--- a/lib/utils.js+++ b/lib/utils.js@@ -189,6 +189,24 @@ exports.slug = function(str){.replace(/[^-\w]/g, '');};+/**+ * Strip the function definition from `str`,+ * and re-indent for pre whitespace.+ */++exports.clean = function(str) {+ str = str+ .replace(/^function *\(.*\) *{/, '')+ .replace(/\s+\}$/, '');++ var spaces = str.match(/^\n?( *)/)[1].length+ , re = new RegExp('^ {' + spaces + '}', 'gm');++ str = str.replace(re, '');++ return str;+};+/*** Escape regular expression characters in `str`.*