Skip to content

Commit b400d2b

Browse files
authored
Replace usages of substr with substring (#343)
1 parent 371ab1a commit b400d2b

File tree

4 files changed

+14
-14
lines changed

4 files changed

+14
-14
lines changed

docs/demo/demo.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -500,7 +500,7 @@
500500
load.data = function (dataArg) {
501501
const data = dataArg || {};
502502
dom.text(document.getElementById('description'), data.description || '');
503-
if (data.url && trim(data.url).substr(0, 10) !== 'javascript') {
503+
if (data.url && trim(data.url).substring(0, 10) !== 'javascript') {
504504
document.getElementById('external-link').setAttribute('href', data.url);
505505
document.getElementById('external-link').style.display = '';
506506
} else {

src/filters/arrays.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -393,7 +393,7 @@ export const reverseFilter = function arraysReverseFilter(context) {
393393
context
394394
.setResult([
395395
context.delta[0],
396-
parseInt(context.childName.substr(1), 10),
396+
parseInt(context.childName.substring(1), 10),
397397
ARRAY_MOVE,
398398
])
399399
.exit();
@@ -418,7 +418,7 @@ reverseFilter.filterName = 'arrays';
418418

419419
const reverseArrayDeltaIndex = (delta, index, itemDelta) => {
420420
if (typeof index === 'string' && index[0] === '_') {
421-
return parseInt(index.substr(1), 10);
421+
return parseInt(index.substring(1), 10);
422422
} else if (isArray(itemDelta) && itemDelta[2] === 0) {
423423
return `_${index}`;
424424
}
@@ -428,7 +428,7 @@ const reverseArrayDeltaIndex = (delta, index, itemDelta) => {
428428
const deltaItem = delta[deltaIndex];
429429
if (isArray(deltaItem)) {
430430
if (deltaItem[2] === ARRAY_MOVE) {
431-
const moveFromIndex = parseInt(deltaIndex.substr(1), 10);
431+
const moveFromIndex = parseInt(deltaIndex.substring(1), 10);
432432
const moveToIndex = deltaItem[1];
433433
if (moveToIndex === +index) {
434434
return moveFromIndex;
@@ -442,7 +442,7 @@ const reverseArrayDeltaIndex = (delta, index, itemDelta) => {
442442
reverseIndex--;
443443
}
444444
} else if (deltaItem[2] === 0) {
445-
const deleteIndex = parseInt(deltaIndex.substr(1), 10);
445+
const deleteIndex = parseInt(deltaIndex.substring(1), 10);
446446
if (deleteIndex <= reverseIndex) {
447447
reverseIndex++;
448448
}

src/formatters/base.js

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ const getObjectKeys =
1717
};
1818

1919
const trimUnderscore = (str) => {
20-
if (str.substr(0, 1) === '_') {
20+
if (str.substring(0, 1) === '_') {
2121
return str.slice(1);
2222
}
2323
return str;
@@ -27,7 +27,7 @@ const arrayKeyToSortNumber = (key) => {
2727
if (key === '_t') {
2828
return -1;
2929
} else {
30-
if (key.substr(0, 1) === '_') {
30+
if (key.substring(0, 1) === '_') {
3131
return parseInt(key.slice(1), 10);
3232
} else {
3333
return parseInt(key, 10) + 0.1;
@@ -159,7 +159,7 @@ class BaseFormatter {
159159
if (isArray(value) && value[2] === 3) {
160160
moveDestinations[value[1].toString()] = {
161161
key: name,
162-
value: left && left[parseInt(name.substr(1))],
162+
value: left && left[parseInt(name.substring(1))],
163163
};
164164
if (this.includeMoveDestinations !== false) {
165165
if (
@@ -247,9 +247,9 @@ class BaseFormatter {
247247
const pieceOutput = {
248248
type: 'context',
249249
};
250-
if (piece.substr(0, 1) === '+') {
250+
if (piece.substring(0, 1) === '+') {
251251
pieceOutput.type = 'added';
252-
} else if (piece.substr(0, 1) === '-') {
252+
} else if (piece.substring(0, 1) === '-') {
253253
pieceOutput.type = 'deleted';
254254
}
255255
pieceOutput.text = piece.slice(1);

test/examples/diffpatch.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -596,8 +596,8 @@ examples.text = [
596596
minLength: 10,
597597
},
598598
},
599-
left: largeText.substr(0, 10),
600-
right: largeText.substr(0, 11).replace(/Madre/g, 'Padre'),
599+
left: largeText.substring(0, 10),
600+
right: largeText.substring(0, 11).replace(/Madre/g, 'Padre'),
601601
delta: ['@@ -1,10 +1,11 @@\n -\n-M\n+P\n adre,%0Acu\n+a\n', 0, 2],
602602
reverse: ['@@ -1,11 +1,10 @@\n -\n-P\n+M\n adre,%0Acu\n-a\n', 0, 2],
603603
exactReverse: false,
@@ -609,8 +609,8 @@ examples.text = [
609609
minLength: 10,
610610
},
611611
},
612-
left: largeText.substr(0, 9),
613-
right: largeText.substr(0, 11).replace(/Madre/g, 'Padre'),
612+
left: largeText.substring(0, 9),
613+
right: largeText.substring(0, 11).replace(/Madre/g, 'Padre'),
614614
delta: ['-Madre,\nc', '-Padre,\ncua'],
615615
reverse: ['-Padre,\ncua', '-Madre,\nc'],
616616
exactReverse: false,

0 commit comments

Comments
 (0)