From 5385377d3f1d364f1ed8331b67de1b5bfe68c043 Mon Sep 17 00:00:00 2001 From: Stephen Hazleton Date: Thu, 19 Nov 2015 17:51:11 +1300 Subject: [PATCH] Do not allow a negative indentLevel to throw RangeError: Invalid array length - force count to zero if negative --- lib/formatter.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/formatter.js b/lib/formatter.js index e6e2726..04719e5 100644 --- a/lib/formatter.js +++ b/lib/formatter.js @@ -13,6 +13,7 @@ var formatter = (function () { function repeat(s, count) { + count = count < 0 ? 0 : count; return new Array(count + 1).join(s); } @@ -89,4 +90,4 @@ var formatter = (function () { if (typeof require !== 'undefined' && typeof exports !== 'undefined') { exports.formatter = formatter; -} \ No newline at end of file +}