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

Enable the object-shorthand ESLint rule in src/shared

Please see http://eslint.org/docs/rules/object-shorthand.

For the most part, these changes are of the search-and-replace kind, and the previously enabled `no-undef` rule should complement the tests in helping ensure that no stupid errors crept into to the patch.
This commit is contained in:
Jonas Jenwald 2017-04-27 12:58:44 +02:00
parent f91d01cad3
commit afc74b0178
22 changed files with 195 additions and 198 deletions

View file

@ -235,18 +235,18 @@ var CMap = (function CMapClosure() {
this.builtInCMap = builtInCMap;
}
CMap.prototype = {
addCodespaceRange: function(n, low, high) {
addCodespaceRange(n, low, high) {
this.codespaceRanges[n - 1].push(low, high);
this.numCodespaceRanges++;
},
mapCidRange: function(low, high, dstLow) {
mapCidRange(low, high, dstLow) {
while (low <= high) {
this._map[low++] = dstLow++;
}
},
mapBfRange: function(low, high, dstLow) {
mapBfRange(low, high, dstLow) {
var lastByte = dstLow.length - 1;
while (low <= high) {
this._map[low++] = dstLow;
@ -256,7 +256,7 @@ var CMap = (function CMapClosure() {
}
},
mapBfRangeToArray: function(low, high, array) {
mapBfRangeToArray(low, high, array) {
var i = 0, ii = array.length;
while (low <= high && i < ii) {
this._map[low] = array[i++];
@ -265,19 +265,19 @@ var CMap = (function CMapClosure() {
},
// This is used for both bf and cid chars.
mapOne: function(src, dst) {
mapOne(src, dst) {
this._map[src] = dst;
},
lookup: function(code) {
lookup(code) {
return this._map[code];
},
contains: function(code) {
contains(code) {
return this._map[code] !== undefined;
},
forEach: function(callback) {
forEach(callback) {
// Most maps have fewer than 65536 entries, and for those we use normal
// array iteration. But really sparse tables are possible -- e.g. with
// indices in the *billions*. For such tables we use for..in, which isn't
@ -299,15 +299,15 @@ var CMap = (function CMapClosure() {
}
},
charCodeOf: function(value) {
charCodeOf(value) {
return this._map.indexOf(value);
},
getMap: function() {
getMap() {
return this._map;
},
readCharCode: function(str, offset, out) {
readCharCode(str, offset, out) {
var c = 0;
var codespaceRanges = this.codespaceRanges;
var codespaceRangesLen = this.codespaceRanges.length;
@ -366,41 +366,41 @@ var IdentityCMap = (function IdentityCMapClosure() {
IdentityCMap.prototype = {
addCodespaceRange: CMap.prototype.addCodespaceRange,
mapCidRange: function(low, high, dstLow) {
mapCidRange(low, high, dstLow) {
error('should not call mapCidRange');
},
mapBfRange: function(low, high, dstLow) {
mapBfRange(low, high, dstLow) {
error('should not call mapBfRange');
},
mapBfRangeToArray: function(low, high, array) {
mapBfRangeToArray(low, high, array) {
error('should not call mapBfRangeToArray');
},
mapOne: function(src, dst) {
mapOne(src, dst) {
error('should not call mapCidOne');
},
lookup: function(code) {
lookup(code) {
return (isInt(code) && code <= 0xffff) ? code : undefined;
},
contains: function(code) {
contains(code) {
return isInt(code) && code <= 0xffff;
},
forEach: function(callback) {
forEach(callback) {
for (var i = 0; i <= 0xffff; i++) {
callback(i, i);
}
},
charCodeOf: function(value) {
charCodeOf(value) {
return (isInt(value) && value <= 0xffff) ? value : -1;
},
getMap: function() {
getMap() {
// Sometimes identity maps must be instantiated, but it's rare.
var map = new Array(0x10000);
for (var i = 0; i <= 0xffff; i++) {
@ -473,13 +473,13 @@ var BinaryCMapReader = (function BinaryCMapReaderClosure() {
}
BinaryCMapStream.prototype = {
readByte: function () {
readByte() {
if (this.pos >= this.end) {
return -1;
}
return this.buffer[this.pos++];
},
readNumber: function () {
readNumber() {
var n = 0;
var last;
do {
@ -492,16 +492,16 @@ var BinaryCMapReader = (function BinaryCMapReaderClosure() {
} while (!last);
return n;
},
readSigned: function () {
readSigned() {
var n = this.readNumber();
return (n & 1) ? ~(n >>> 1) : n >>> 1;
},
readHex: function (num, size) {
readHex(num, size) {
num.set(this.buffer.subarray(this.pos,
this.pos + size + 1));
this.pos += size + 1;
},
readHexNumber: function (num, size) {
readHexNumber(num, size) {
var last;
var stack = this.tmpBuf, sp = 0;
do {
@ -524,7 +524,7 @@ var BinaryCMapReader = (function BinaryCMapReaderClosure() {
bufferSize -= 8;
}
},
readHexSigned: function (num, size) {
readHexSigned(num, size) {
this.readHexNumber(num, size);
var sign = num[size] & 1 ? 255 : 0;
var c = 0;
@ -533,7 +533,7 @@ var BinaryCMapReader = (function BinaryCMapReaderClosure() {
num[i] = (c >> 1) ^ sign;
}
},
readString: function () {
readString() {
var len = this.readNumber();
var s = '';
for (var i = 0; i < len; i++) {
@ -977,7 +977,7 @@ var CMapFactory = (function CMapFactoryClosure() {
}
return {
create: function (params) {
create(params) {
var encoding = params.encoding;
var fetchBuiltInCMap = params.fetchBuiltInCMap;
var useCMap = params.useCMap;