diff --git a/docs/demo/demo.js b/docs/demo/demo.js index ec3aba0e..99e327ad 100644 --- a/docs/demo/demo.js +++ b/docs/demo/demo.js @@ -500,7 +500,7 @@ load.data = function (dataArg) { const data = dataArg || {}; dom.text(document.getElementById('description'), data.description || ''); - if (data.url && trim(data.url).substr(0, 10) !== 'javascript') { + if (data.url && trim(data.url).substring(0, 10) !== 'javascript') { document.getElementById('external-link').setAttribute('href', data.url); document.getElementById('external-link').style.display = ''; } else { diff --git a/src/filters/arrays.js b/src/filters/arrays.js index 477d26f9..18508e13 100644 --- a/src/filters/arrays.js +++ b/src/filters/arrays.js @@ -393,7 +393,7 @@ export const reverseFilter = function arraysReverseFilter(context) { context .setResult([ context.delta[0], - parseInt(context.childName.substr(1), 10), + parseInt(context.childName.substring(1), 10), ARRAY_MOVE, ]) .exit(); @@ -418,7 +418,7 @@ reverseFilter.filterName = 'arrays'; const reverseArrayDeltaIndex = (delta, index, itemDelta) => { if (typeof index === 'string' && index[0] === '_') { - return parseInt(index.substr(1), 10); + return parseInt(index.substring(1), 10); } else if (isArray(itemDelta) && itemDelta[2] === 0) { return `_${index}`; } @@ -428,7 +428,7 @@ const reverseArrayDeltaIndex = (delta, index, itemDelta) => { const deltaItem = delta[deltaIndex]; if (isArray(deltaItem)) { if (deltaItem[2] === ARRAY_MOVE) { - const moveFromIndex = parseInt(deltaIndex.substr(1), 10); + const moveFromIndex = parseInt(deltaIndex.substring(1), 10); const moveToIndex = deltaItem[1]; if (moveToIndex === +index) { return moveFromIndex; @@ -442,7 +442,7 @@ const reverseArrayDeltaIndex = (delta, index, itemDelta) => { reverseIndex--; } } else if (deltaItem[2] === 0) { - const deleteIndex = parseInt(deltaIndex.substr(1), 10); + const deleteIndex = parseInt(deltaIndex.substring(1), 10); if (deleteIndex <= reverseIndex) { reverseIndex++; } diff --git a/src/formatters/base.js b/src/formatters/base.js index abf90028..5c7145d4 100644 --- a/src/formatters/base.js +++ b/src/formatters/base.js @@ -17,7 +17,7 @@ const getObjectKeys = }; const trimUnderscore = (str) => { - if (str.substr(0, 1) === '_') { + if (str.substring(0, 1) === '_') { return str.slice(1); } return str; @@ -27,7 +27,7 @@ const arrayKeyToSortNumber = (key) => { if (key === '_t') { return -1; } else { - if (key.substr(0, 1) === '_') { + if (key.substring(0, 1) === '_') { return parseInt(key.slice(1), 10); } else { return parseInt(key, 10) + 0.1; @@ -159,7 +159,7 @@ class BaseFormatter { if (isArray(value) && value[2] === 3) { moveDestinations[value[1].toString()] = { key: name, - value: left && left[parseInt(name.substr(1))], + value: left && left[parseInt(name.substring(1))], }; if (this.includeMoveDestinations !== false) { if ( @@ -247,9 +247,9 @@ class BaseFormatter { const pieceOutput = { type: 'context', }; - if (piece.substr(0, 1) === '+') { + if (piece.substring(0, 1) === '+') { pieceOutput.type = 'added'; - } else if (piece.substr(0, 1) === '-') { + } else if (piece.substring(0, 1) === '-') { pieceOutput.type = 'deleted'; } pieceOutput.text = piece.slice(1); diff --git a/test/examples/diffpatch.js b/test/examples/diffpatch.js index 7af25870..c35a5193 100644 --- a/test/examples/diffpatch.js +++ b/test/examples/diffpatch.js @@ -596,8 +596,8 @@ examples.text = [ minLength: 10, }, }, - left: largeText.substr(0, 10), - right: largeText.substr(0, 11).replace(/Madre/g, 'Padre'), + left: largeText.substring(0, 10), + right: largeText.substring(0, 11).replace(/Madre/g, 'Padre'), delta: ['@@ -1,10 +1,11 @@\n -\n-M\n+P\n adre,%0Acu\n+a\n', 0, 2], reverse: ['@@ -1,11 +1,10 @@\n -\n-P\n+M\n adre,%0Acu\n-a\n', 0, 2], exactReverse: false, @@ -609,8 +609,8 @@ examples.text = [ minLength: 10, }, }, - left: largeText.substr(0, 9), - right: largeText.substr(0, 11).replace(/Madre/g, 'Padre'), + left: largeText.substring(0, 9), + right: largeText.substring(0, 11).replace(/Madre/g, 'Padre'), delta: ['-Madre,\nc', '-Padre,\ncua'], reverse: ['-Padre,\ncua', '-Madre,\nc'], exactReverse: false,