From d27905cb9ad9f746ba3ccef504950bf1c01a2499 Mon Sep 17 00:00:00 2001 From: Tobias Speicher Date: Sun, 27 Mar 2022 17:43:57 +0200 Subject: [PATCH] refactor: replace deprecated String.prototype.substr() .substr() is deprecated so we replace it with .slice() which works similarily but isn't deprecated Signed-off-by: Tobias Speicher --- source/utilities.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/source/utilities.js b/source/utilities.js index 5d49dad..4366dee 100644 --- a/source/utilities.js +++ b/source/utilities.js @@ -9,7 +9,7 @@ export function stringReplaceAll(string, substring, replacer) { let endIndex = 0; let returnValue = ''; do { - returnValue += string.substr(endIndex, index - endIndex) + substring + replacer; + returnValue += string.slice(endIndex, index) + substring + replacer; endIndex = index + substringLength; index = string.indexOf(substring, endIndex); } while (index !== -1); @@ -23,7 +23,7 @@ export function stringEncaseCRLFWithFirstIndex(string, prefix, postfix, index) { let returnValue = ''; do { const gotCR = string[index - 1] === '\r'; - returnValue += string.substr(endIndex, (gotCR ? index - 1 : index) - endIndex) + prefix + (gotCR ? '\r\n' : '\n') + postfix; + returnValue += string.slice(endIndex, (gotCR ? index - 1 : index)) + prefix + (gotCR ? '\r\n' : '\n') + postfix; endIndex = index + 1; index = string.indexOf('\n', endIndex); } while (index !== -1);