From 4676273e8840656b3cdd6c2b966ec83a068168cb Mon Sep 17 00:00:00 2001 From: Sindre Sorhus Date: Thu, 10 Jun 2021 23:09:54 +0700 Subject: [PATCH] Minor performance improvement --- index.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/index.js b/index.js index d942eee..628f96a 100644 --- a/index.js +++ b/index.js @@ -6,7 +6,7 @@ export default function trimNewlines(string) { start++; } - while (end > 0 && (string[end - 1] === '\r' || string[end - 1] === '\n')) { + while (end > start && (string[end - 1] === '\r' || string[end - 1] === '\n')) { end--; }