Skip to content

Commit ba81258

Browse files
chore: replace deprecated String.prototype.substr() (#4918)
String.prototype.substr() is deprecated so we replace it with functions which work similarily but aren't deprecated Signed-off-by: Tobias Speicher <[email protected]>
1 parent f4a5f04 commit ba81258

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

lib/plugins/helper/number_format.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,10 +13,10 @@ function numberFormatHelper(num, options = {}) {
1313
const beforeLength = before.length;
1414
const beforeFirst = beforeLength % 3;
1515

16-
if (beforeFirst) beforeArr.push(before.substr(0, beforeFirst));
16+
if (beforeFirst) beforeArr.push(before.slice(0, beforeFirst));
1717

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

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

33-
afterResult = after.substr(0, precision - 1) + (afterLast < 5 ? last : last + 1);
33+
afterResult = after.substring(0, precision - 1) + (afterLast < 5 ? last : last + 1);
3434
} else {
3535
afterResult = after;
3636
for (let i = 0, len = precision - afterLength; i < len; i++) {

lib/plugins/tag/code.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ function parseArgs(args) {
6868
for (const cur of value.split(',')) {
6969
const hyphen = cur.indexOf('-');
7070
if (hyphen !== -1) {
71-
let a = +cur.substr(0, hyphen);
72-
let b = +cur.substr(hyphen + 1);
71+
let a = +cur.slice(0, hyphen);
72+
let b = +cur.slice(hyphen + 1);
7373
if (Number.isNaN(a) || Number.isNaN(b)) continue;
7474
if (b < a) { // switch a & b
7575
const temp = a;

0 commit comments

Comments
 (0)