utils.js optimization of isFOO methods

This commit is contained in:
p01 2014-06-02 12:16:15 +02:00
parent 37c9765ab4
commit 0a51b1e616

View File

@ -911,15 +911,15 @@ function isBool(v) {
} }
function isInt(v) { function isInt(v) {
return typeof v == 'number' && ((v | 0) == v); return typeof v === 'number' && ((v | 0) === v);
} }
function isNum(v) { function isNum(v) {
return typeof v == 'number'; return typeof v === 'number';
} }
function isString(v) { function isString(v) {
return typeof v == 'string'; return typeof v === 'string';
} }
function isNull(v) { function isNull(v) {
@ -931,7 +931,7 @@ function isName(v) {
} }
function isCmd(v, cmd) { function isCmd(v, cmd) {
return v instanceof Cmd && (!cmd || v.cmd == cmd); return v instanceof Cmd && (cmd === undefined || v.cmd === cmd);
} }
function isDict(v, type) { function isDict(v, type) {
@ -942,7 +942,7 @@ function isDict(v, type) {
return true; return true;
} }
var dictType = v.get('Type'); var dictType = v.get('Type');
return isName(dictType) && dictType.name == type; return isName(dictType) && dictType.name === type;
} }
function isArray(v) { function isArray(v) {
@ -950,13 +950,11 @@ function isArray(v) {
} }
function isStream(v) { function isStream(v) {
return typeof v == 'object' && v !== null && v !== undefined && return typeof v === 'object' && v !== null && v.getBytes !== undefined;
('getBytes' in v);
} }
function isArrayBuffer(v) { function isArrayBuffer(v) {
return typeof v == 'object' && v !== null && v !== undefined && return typeof v === 'object' && v !== null && v.byteLength !== undefined;
('byteLength' in v);
} }
function isRef(v) { function isRef(v) {
@ -1298,7 +1296,7 @@ PDFJS.createPromiseCapability = createPromiseCapability;
HandlerManager.scheduleHandlers(this); HandlerManager.scheduleHandlers(this);
return nextPromise; return nextPromise;
}, },
catch: function Promise_catch(onReject) { catch: function Promise_catch(onReject) {
return this.then(undefined, onReject); return this.then(undefined, onReject);
} }