Skip to content

Commit 95c6783

Browse files
committed
Consistent use of typeof operator in JS library code. NFC
1 parent 74af917 commit 95c6783

15 files changed

+35
-35
lines changed

src/library_browser.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -747,22 +747,22 @@ var LibraryBrowser = {
747747
}
748748
if (((document['fullscreenElement'] || document['mozFullScreenElement'] ||
749749
document['msFullscreenElement'] || document['webkitFullscreenElement'] ||
750-
document['webkitCurrentFullScreenElement']) === canvas.parentNode) && (typeof screen != 'undefined')) {
750+
document['webkitCurrentFullScreenElement']) === canvas.parentNode) && (typeof screen !== 'undefined')) {
751751
var factor = Math.min(screen.width / w, screen.height / h);
752752
w = Math.round(w * factor);
753753
h = Math.round(h * factor);
754754
}
755755
if (Browser.resizeCanvas) {
756756
if (canvas.width != w) canvas.width = w;
757757
if (canvas.height != h) canvas.height = h;
758-
if (typeof canvas.style != 'undefined') {
758+
if (typeof canvas.style !== 'undefined') {
759759
canvas.style.removeProperty( "width");
760760
canvas.style.removeProperty("height");
761761
}
762762
} else {
763763
if (canvas.width != wNative) canvas.width = wNative;
764764
if (canvas.height != hNative) canvas.height = hNative;
765-
if (typeof canvas.style != 'undefined') {
765+
if (typeof canvas.style !== 'undefined') {
766766
if (w != wNative || h != hNative) {
767767
canvas.style.setProperty( "width", w + "px", "important");
768768
canvas.style.setProperty("height", h + "px", "important");

src/library_c_preprocessor.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -150,7 +150,7 @@ mergeInto(LibraryManager.library, {
150150
function buildExprTree(tokens) {
151151
// Consume tokens array into a function tree until the tokens array is exhausted
152152
// to a single root node that evaluates it.
153-
while(tokens.length > 1 || typeof(tokens[0]) != 'function') {
153+
while (tokens.length > 1 || typeof tokens[0] !== 'function') {
154154
tokens = (function(tokens) {
155155
// Find the index 'i' of the operator we should evaluate next:
156156
var i, j, p, operatorAndPriority = -2;

src/library_fs.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -481,7 +481,7 @@ FS.staticInit();` +
481481
return mounts;
482482
},
483483
syncfs: (populate, callback) => {
484-
if (typeof(populate) === 'function') {
484+
if (typeof populate === 'function') {
485485
callback = populate;
486486
populate = false;
487487
}
@@ -668,7 +668,7 @@ FS.staticInit();` +
668668
}
669669
},
670670
mkdev: (path, mode, dev) => {
671-
if (typeof(dev) === 'undefined') {
671+
if (typeof dev === 'undefined') {
672672
dev = mode;
673673
mode = 438 /* 0666 */;
674674
}
@@ -1733,10 +1733,10 @@ FS.staticInit();` +
17331733
var start = chunkNum * chunkSize;
17341734
var end = (chunkNum+1) * chunkSize - 1; // including this byte
17351735
end = Math.min(end, datalength-1); // if datalength-1 is selected, this is the last block
1736-
if (typeof(lazyArray.chunks[chunkNum]) === "undefined") {
1736+
if (typeof lazyArray.chunks[chunkNum] === 'undefined') {
17371737
lazyArray.chunks[chunkNum] = doXHR(start, end);
17381738
}
1739-
if (typeof(lazyArray.chunks[chunkNum]) === "undefined") throw new Error("doXHR failed!");
1739+
if (typeof lazyArray.chunks[chunkNum] === 'undefined') throw new Error('doXHR failed!');
17401740
return lazyArray.chunks[chunkNum];
17411741
});
17421742

src/library_glemu.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2814,7 +2814,7 @@ var LibraryGLEmulation = {
28142814
};
28152815
{{{ updateExport('glDisable') }}}
28162816

2817-
var glTexEnvf = (typeof(_glTexEnvf) != 'undefined') ? _glTexEnvf : () => {};
2817+
var glTexEnvf = (typeof _glTexEnvf !== 'undefined') ? _glTexEnvf : () => {};
28182818
/** @suppress {checkTypes} */
28192819
_glTexEnvf = _emscripten_glTexEnvf = (target, pname, param) => {
28202820
GLImmediate.TexEnvJIT.hook_texEnvf(target, pname, param);
@@ -2823,7 +2823,7 @@ var LibraryGLEmulation = {
28232823
};
28242824
{{{ updateExport('glTexEnvf') }}}
28252825

2826-
var glTexEnvi = (typeof(_glTexEnvi) != 'undefined') ? _glTexEnvi : () => {};
2826+
var glTexEnvi = (typeof _glTexEnvi !== 'undefined') ? _glTexEnvi : () => {};
28272827
/** @suppress {checkTypes} */
28282828
_glTexEnvi = _emscripten_glTexEnvi = (target, pname, param) => {
28292829
GLImmediate.TexEnvJIT.hook_texEnvi(target, pname, param);
@@ -2832,7 +2832,7 @@ var LibraryGLEmulation = {
28322832
};
28332833
{{{ updateExport('glTexEnvi') }}}
28342834

2835-
var glTexEnvfv = (typeof(_glTexEnvfv) != 'undefined') ? _glTexEnvfv : () => {};
2835+
var glTexEnvfv = (typeof _glTexEnvfv !== 'undefined') ? _glTexEnvfv : () => {};
28362836
/** @suppress {checkTypes} */
28372837
_glTexEnvfv = _emscripten_glTexEnvfv = (target, pname, param) => {
28382838
GLImmediate.TexEnvJIT.hook_texEnvfv(target, pname, param);

src/library_html5.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2176,14 +2176,14 @@ var LibraryHTML5 = {
21762176
{{{ makeSetValue('eventStruct+i*8', C_STRUCTS.EmscriptenGamepadEvent.axis, 'e.axes[i]', 'double') }}};
21772177
}
21782178
for (var i = 0; i < e.buttons.length; ++i) {
2179-
if (typeof(e.buttons[i]) === 'object') {
2179+
if (typeof e.buttons[i] === 'object') {
21802180
{{{ makeSetValue('eventStruct+i*8', C_STRUCTS.EmscriptenGamepadEvent.analogButton, 'e.buttons[i].value', 'double') }}};
21812181
} else {
21822182
{{{ makeSetValue('eventStruct+i*8', C_STRUCTS.EmscriptenGamepadEvent.analogButton, 'e.buttons[i]', 'double') }}};
21832183
}
21842184
}
21852185
for (var i = 0; i < e.buttons.length; ++i) {
2186-
if (typeof(e.buttons[i]) === 'object') {
2186+
if (typeof e.buttons[i] === 'object') {
21872187
{{{ makeSetValue('eventStruct+i*4', C_STRUCTS.EmscriptenGamepadEvent.digitalButton, 'e.buttons[i].pressed', 'i32') }}};
21882188
} else {
21892189
// Assigning a boolean to HEAP32, that's ok, but Closure would like to warn about it:

src/library_openal.js

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -181,11 +181,11 @@ var LibraryOpenAL = {
181181

182182
audioSrc.connect(src.gain);
183183

184-
if (typeof(audioSrc.start) !== 'undefined') {
184+
if (typeof audioSrc.start !== 'undefined') {
185185
// Sample the current time as late as possible to mitigate drift
186186
startTime = Math.max(startTime, src.context.audioCtx.currentTime);
187187
audioSrc.start(startTime, startOffset);
188-
} else if (typeof(audioSrc.noteOn) !== 'undefined') {
188+
} else if (typeof audioSrc.noteOn !== 'undefined') {
189189
startTime = Math.max(startTime, src.context.audioCtx.currentTime);
190190
audioSrc.noteOn(startTime);
191191
#if OPENAL_DEBUG
@@ -2079,7 +2079,7 @@ var LibraryOpenAL = {
20792079
}
20802080
}
20812081

2082-
if (typeof(AudioContext) !== 'undefined' || typeof(webkitAudioContext) !== 'undefined') {
2082+
if (typeof AudioContext !== 'undefined' || typeof webkitAudioContext !== 'undefined') {
20832083
var deviceId = AL.newId();
20842084
AL.deviceRefCounts[deviceId] = 0;
20852085
return deviceId;
@@ -2202,7 +2202,7 @@ var LibraryOpenAL = {
22022202
autoResumeAudioContext(ac);
22032203

22042204
// Old Web Audio API (e.g. Safari 6.0.5) had an inconsistently named createGainNode function.
2205-
if (typeof(ac.createGain) === 'undefined') {
2205+
if (typeof ac.createGain === 'undefined') {
22062206
ac.createGain = ac.createGainNode;
22072207
}
22082208

@@ -2428,16 +2428,16 @@ var LibraryOpenAL = {
24282428
ret = 'Out of Memory';
24292429
break;
24302430
case 0x1004 /* ALC_DEFAULT_DEVICE_SPECIFIER */:
2431-
if (typeof(AudioContext) !== 'undefined' ||
2432-
typeof(webkitAudioContext) !== 'undefined') {
2431+
if (typeof AudioContext !== 'undefined' ||
2432+
typeof webkitAudioContext !== 'undefined') {
24332433
ret = AL.DEVICE_NAME;
24342434
} else {
24352435
return 0;
24362436
}
24372437
break;
24382438
case 0x1005 /* ALC_DEVICE_SPECIFIER */:
2439-
if (typeof(AudioContext) !== 'undefined' ||
2440-
typeof(webkitAudioContext) !== 'undefined') {
2439+
if (typeof AudioContext !== 'undefined' ||
2440+
typeof webkitAudioContext !== 'undefined') {
24412441
ret = AL.DEVICE_NAME.concat('\0');
24422442
} else {
24432443
ret = '\0';

src/library_sdl.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1177,8 +1177,8 @@ var LibrarySDL = {
11771177
// Initialize Web Audio API if we haven't done so yet. Note: Only initialize Web Audio context ever once on the web page,
11781178
// since initializing multiple times fails on Chrome saying 'audio resources have been exhausted'.
11791179
if (!SDL.audioContext) {
1180-
if (typeof(AudioContext) !== 'undefined') SDL.audioContext = new AudioContext();
1181-
else if (typeof(webkitAudioContext) !== 'undefined') SDL.audioContext = new webkitAudioContext();
1180+
if (typeof AudioContext !== 'undefined') SDL.audioContext = new AudioContext();
1181+
else if (typeof webkitAudioContext !== 'undefined') SDL.audioContext = new webkitAudioContext();
11821182
}
11831183
},
11841184

src/library_trace.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -277,7 +277,7 @@ var LibraryTracing = {
277277

278278
emscripten_trace_report_off_heap_data: function () {
279279
function openal_audiodata_size() {
280-
if (typeof AL == 'undefined' || !AL.currentContext) {
280+
if (typeof AL === 'undefined' || !AL.currentContext) {
281281
return 0;
282282
}
283283
var totalMemory = 0;

src/library_tty.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,7 +127,7 @@ mergeInto(LibraryManager.library, {
127127
}
128128
} else
129129
#endif
130-
if (typeof window != 'undefined' &&
130+
if (typeof window !== 'undefined' &&
131131
typeof window.prompt == 'function') {
132132
// Browser.
133133
result = window.prompt('Input: '); // returns null on cancel

src/library_uuid.js

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -45,8 +45,8 @@ mergeInto(LibraryManager.library, {
4545
} catch(e) {}
4646
#endif // ENVIRONMENT_MAY_BE_NODE
4747
} else if (ENVIRONMENT_IS_WEB &&
48-
typeof(window.crypto) !== 'undefined' &&
49-
typeof(window.crypto.getRandomValues) !== 'undefined') {
48+
typeof window.crypto !== 'undefined' &&
49+
typeof window.crypto.getRandomValues !== 'undefined') {
5050
// If crypto.getRandomValues is available try to use it.
5151
uuid = new Uint8Array(16);
5252
window.crypto.getRandomValues(uuid);

0 commit comments

Comments
 (0)