Skip to content

Commit

Permalink
Refactor: Replace deprecated String#substr() (#541)
Browse files Browse the repository at this point in the history
  • Loading branch information
CommanderRoot committed Mar 27, 2022
1 parent bccde97 commit d28690e
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions source/utilities.js
Expand Up @@ -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);
Expand All @@ -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);
Expand Down

0 comments on commit d28690e

Please sign in to comment.