1
0
Fork 0
mirror of https://github.com/mozilla/pdf.js.git synced 2025-04-26 10:08:06 +02:00

Replace String.prototype.substr() occurrences with String.prototype.substring()

As outlined in https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr, which refers to the ECMA-262 specification, using the `substr` function is advised against.

Hence this PR, which replaces all remaining `substr` occurrences with `substring` instead. Please refer to https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substr#Syntax respectively https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/substring#Syntax for the differences between the two functions.

Note that in most cases in the code-base there's only one argument passed to `substr`, and those require no other changes except replacing "substr" with "substring". For the other cases, the `substr(start, length)` calls are changed to `substring(start, start + length)` instead.
This commit is contained in:
Jonas Jenwald 2018-09-28 11:41:07 +02:00
parent 54d6c2436c
commit 842e9206c0
15 changed files with 24 additions and 23 deletions

View file

@ -155,7 +155,7 @@ function parseCMap(binaryData) {
},
readHex: function (size) {
var lengthInChars = (size + 1) << 1;
var s = this.buffer.substr(this.pos, lengthInChars);
var s = this.buffer.substring(this.pos, this.pos + lengthInChars);
this.pos += lengthInChars;
return s;
},
@ -343,7 +343,7 @@ function writeNumber(n) {
s = writeByte((buffer & 0x7f) | (s.length > 0 ? 0x80 : 0)) + s;
}
while (s.indexOf('80') === 0) {
s = s.substr(2);
s = s.substring(2);
}
return s;
} else {