Skip to content

Commit

Permalink
chore: replace deprecated String.prototype.substr() (#4918)
Browse files Browse the repository at this point in the history
String.prototype.substr() is deprecated so we replace it with functions which work similarily but aren't deprecated
Signed-off-by: Tobias Speicher <rootcommander@gmail.com>
  • Loading branch information
CommanderRoot committed Mar 24, 2022
1 parent f4a5f04 commit ba81258
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 3 additions & 3 deletions lib/plugins/helper/number_format.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ function numberFormatHelper(num, options = {}) {
const beforeLength = before.length;
const beforeFirst = beforeLength % 3;

if (beforeFirst) beforeArr.push(before.substr(0, beforeFirst));
if (beforeFirst) beforeArr.push(before.slice(0, beforeFirst));

for (let i = beforeFirst; i < beforeLength; i += 3) {
beforeArr.push(before.substr(i, 3));
beforeArr.push(before.slice(i, i + 3));
}

before = beforeArr.join(delimiter);
Expand All @@ -30,7 +30,7 @@ function numberFormatHelper(num, options = {}) {
const afterLast = after[precision];
const last = parseInt(after[precision - 1], 10);

afterResult = after.substr(0, precision - 1) + (afterLast < 5 ? last : last + 1);
afterResult = after.substring(0, precision - 1) + (afterLast < 5 ? last : last + 1);
} else {
afterResult = after;
for (let i = 0, len = precision - afterLength; i < len; i++) {
Expand Down
4 changes: 2 additions & 2 deletions lib/plugins/tag/code.js
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ function parseArgs(args) {
for (const cur of value.split(',')) {
const hyphen = cur.indexOf('-');
if (hyphen !== -1) {
let a = +cur.substr(0, hyphen);
let b = +cur.substr(hyphen + 1);
let a = +cur.slice(0, hyphen);
let b = +cur.slice(hyphen + 1);
if (Number.isNaN(a) || Number.isNaN(b)) continue;
if (b < a) { // switch a & b
const temp = a;
Expand Down

0 comments on commit ba81258

Please sign in to comment.