Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion src/Fetch.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ var Fetch = {
#endif // ~FETCH_SUPPORT_INDEXEDDB

#if FETCH_SUPPORT_INDEXEDDB
if (typeof ENVIRONMENT_IS_FETCH_WORKER === 'undefined' || !ENVIRONMENT_IS_FETCH_WORKER) addRunDependency('library_fetch_init');
if (typeof ENVIRONMENT_IS_FETCH_WORKER == 'undefined' || !ENVIRONMENT_IS_FETCH_WORKER) addRunDependency('library_fetch_init');
#endif
}
}
Expand Down
4 changes: 2 additions & 2 deletions src/IDBStore.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@

{
indexedDB: function() {
if (typeof indexedDB !== 'undefined') return indexedDB;
if (typeof indexedDB != 'undefined') return indexedDB;
var ret = null;
if (typeof window === 'object') ret = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;
if (typeof window == 'object') ret = window.indexedDB || window.mozIndexedDB || window.webkitIndexedDB || window.msIndexedDB;
assert(ret, 'IDBStore used, but indexedDB not supported');
return ret;
},
Expand Down
2 changes: 1 addition & 1 deletion src/base64Decode.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ base64ReverseLookup[47] = 63; // '/'
/** @noinline */
function base64Decode(b64) {
#if ENVIRONMENT_MAY_BE_NODE
if (typeof ENVIRONMENT_IS_NODE !== 'undefined' && ENVIRONMENT_IS_NODE) {
if (typeof ENVIRONMENT_IS_NODE != 'undefined' && ENVIRONMENT_IS_NODE) {
var buf = Buffer.from(b64, 'base64');
return new Uint8Array(buf.buffer, buf.byteOffset, buf.byteLength);
}
Expand Down
4 changes: 2 additions & 2 deletions src/base64Utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* Decodes a base64 string.
* @param {string} input The string to decode.
*/
var decodeBase64 = typeof atob === 'function' ? atob : function (input) {
var decodeBase64 = typeof atob == 'function' ? atob : function (input) {
var keyStr = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=';

var output = '';
Expand Down Expand Up @@ -43,7 +43,7 @@ var decodeBase64 = typeof atob === 'function' ? atob : function (input) {
// Throws error on invalid input.
function intArrayFromBase64(s) {
#if ENVIRONMENT_MAY_BE_NODE
if (typeof ENVIRONMENT_IS_NODE === 'boolean' && ENVIRONMENT_IS_NODE) {
if (typeof ENVIRONMENT_IS_NODE == 'boolean' && ENVIRONMENT_IS_NODE) {
var buf = Buffer.from(s, 'base64');
return new Uint8Array(buf['buffer'], buf['byteOffset'], buf['byteLength']);
}
Expand Down
12 changes: 6 additions & 6 deletions src/cpuprofiler.js
Original file line number Diff line number Diff line change
Expand Up @@ -533,7 +533,7 @@ var emscriptenCpuProfiler = {

detectWebGLContext: function() {
if (Module['canvas'] && Module['canvas'].GLctxObject && Module['canvas'].GLctxObject.GLctx) return Module['canvas'].GLctxObject.GLctx;
else if (typeof GLctx !== 'undefined') return GLctx;
else if (typeof GLctx != 'undefined') return GLctx;
else if (Module.ctx) return Module.ctx;
return null;
},
Expand Down Expand Up @@ -570,7 +570,7 @@ var emscriptenCpuProfiler = {
document.getElementById("toggle_webgl_profile").style.background = '#E1E1E1';

for (var f in glCtx) {
if (typeof glCtx[f] !== 'function' || f.startsWith('real_')) continue;
if (typeof glCtx[f] != 'function' || f.startsWith('real_')) continue;
var realf = 'real_' + f;
glCtx[f] = glCtx[realf];
delete glCtx[realf];
Expand Down Expand Up @@ -603,8 +603,8 @@ var emscriptenCpuProfiler = {
hookWebGL: function(glCtx) {
if (!glCtx) glCtx = this.detectWebGLContext();
if (!glCtx) return;
if (!((typeof WebGLRenderingContext !== 'undefined' && glCtx instanceof WebGLRenderingContext)
|| (typeof WebGL2RenderingContext !== 'undefined' && glCtx instanceof WebGL2RenderingContext))) {
if (!((typeof WebGLRenderingContext != 'undefined' && glCtx instanceof WebGLRenderingContext)
|| (typeof WebGL2RenderingContext != 'undefined' && glCtx instanceof WebGL2RenderingContext))) {
document.getElementById("toggle_webgl_profile").disabled = true;
return;
}
Expand All @@ -619,7 +619,7 @@ var emscriptenCpuProfiler = {
this.createSection(0, 'Hot GL', this.colorHotGLFunction, /*traceable=*/true);
this.createSection(1, 'Cold GL', this.colorColdGLFunction, /*traceable=*/true);
for (var f in glCtx) {
if (typeof glCtx[f] !== 'function' || f.startsWith('real_')) continue;
if (typeof glCtx[f] != 'function' || f.startsWith('real_')) continue;
this.hookWebGLFunction(f, glCtx);
}
// The above injection won't work for texImage2D and texSubImage2D, which have multiple overloads.
Expand Down Expand Up @@ -671,4 +671,4 @@ setTimeout = (fn, delay) => {
// Backwards compatibility with previously compiled code. Don't call this anymore!
function cpuprofiler_add_hooks() { emscriptenCpuProfiler.initialize(); }

if (typeof Module !== 'undefined' && typeof document !== 'undefined') emscriptenCpuProfiler.initialize();
if (typeof Module != 'undefined' && typeof document != 'undefined') emscriptenCpuProfiler.initialize();
2 changes: 1 addition & 1 deletion src/deterministic.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ Math.random = () => {
};
var TIME = 10000;
Date.now = () => TIME++;
if (typeof performance === 'object') performance.now = Date.now;
if (typeof performance == 'object') performance.now = Date.now;
if (ENVIRONMENT_IS_NODE) process['hrtime'] = Date.now;

if (!Module) Module = {};
Expand Down
12 changes: 6 additions & 6 deletions src/embind/embind.js
Original file line number Diff line number Diff line change
Expand Up @@ -568,7 +568,7 @@ var LibraryEmbind = {
var isUnsignedType = (name.includes('unsigned'));
var checkAssertions = (value, toTypeName) => {
#if ASSERTIONS
if (typeof value !== "number" && typeof value !== "boolean") {
if (typeof value != "number" && typeof value != "boolean") {
throw new TypeError('Cannot convert "' + _embind_repr(value) + '" to ' + toTypeName);
}
if (value < minRange || value > maxRange) {
Expand Down Expand Up @@ -622,7 +622,7 @@ var LibraryEmbind = {
return value;
},
'toWireType': function (destructors, value) {
if (typeof value !== "bigint") {
if (typeof value != "bigint") {
throw new TypeError('Cannot convert "' + _embind_repr(value) + '" to ' + this.name);
}
if (value < minRange || value > maxRange) {
Expand Down Expand Up @@ -653,7 +653,7 @@ var LibraryEmbind = {
},
'toWireType': function(destructors, value) {
#if ASSERTIONS
if (typeof value !== "number" && typeof value !== "boolean") {
if (typeof value != "number" && typeof value != "boolean") {
throw new TypeError('Cannot convert "' + _embind_repr(value) + '" to ' + this.name);
}
#endif
Expand Down Expand Up @@ -726,7 +726,7 @@ var LibraryEmbind = {
}

var getLength;
var valueIsOfTypeString = (typeof value === 'string');
var valueIsOfTypeString = (typeof value == 'string');

if (!(valueIsOfTypeString || value instanceof Uint8Array || value instanceof Uint8ClampedArray || value instanceof Int8Array)) {
throwBindingError('Cannot pass non-string to std::string');
Expand Down Expand Up @@ -827,7 +827,7 @@ var LibraryEmbind = {
return str;
},
'toWireType': function(destructors, value) {
if (!(typeof value === 'string')) {
if (!(typeof value == 'string')) {
throwBindingError('Cannot pass non-string to C++ string type ' + name);
}

Expand Down Expand Up @@ -1175,7 +1175,7 @@ var LibraryEmbind = {
}

var fp = makeDynCaller();
if (typeof fp !== "function") {
if (typeof fp != "function") {
throwBindingError("unknown function pointer with signature " + signature + ": " + rawFunction);
}
return fp;
Expand Down
18 changes: 9 additions & 9 deletions src/embind/emval.js
Original file line number Diff line number Diff line change
Expand Up @@ -209,34 +209,34 @@ var LibraryEmVal = {

#if DYNAMIC_EXECUTION == 0
$emval_get_global: function() {
if (typeof globalThis === 'object') {
if (typeof globalThis == 'object') {
return globalThis;
}
function testGlobal(obj) {
obj['$$$embind_global$$$'] = obj;
var success = typeof $$$embind_global$$$ === 'object' && obj['$$$embind_global$$$'] === obj;
var success = typeof $$$embind_global$$$ == 'object' && obj['$$$embind_global$$$'] == obj;
if (!success) {
delete obj['$$$embind_global$$$'];
}
return success;
}
if (typeof $$$embind_global$$$ === 'object') {
if (typeof $$$embind_global$$$ == 'object') {
return $$$embind_global$$$;
}
if (typeof global === 'object' && testGlobal(global)) {
if (typeof global == 'object' && testGlobal(global)) {
$$$embind_global$$$ = global;
} else if (typeof self === 'object' && testGlobal(self)) {
} else if (typeof self == 'object' && testGlobal(self)) {
$$$embind_global$$$ = self; // This works for both "window" and "self" (Web Workers) global objects
}
if (typeof $$$embind_global$$$ === 'object') {
if (typeof $$$embind_global$$$ == 'object') {
return $$$embind_global$$$;
}
throw Error('unable to get global object.');
},
#else
// appease jshint (technically this code uses eval)
$emval_get_global: function() {
if (typeof globalThis === 'object') {
if (typeof globalThis == 'object') {
return globalThis;
}
return (function(){
Expand Down Expand Up @@ -491,13 +491,13 @@ var LibraryEmVal = {
_emval_is_number__deps: ['$Emval'],
_emval_is_number: function(handle) {
handle = Emval.toValue(handle);
return typeof handle === 'number';
return typeof handle == 'number';
},

_emval_is_string__deps: ['$Emval'],
_emval_is_string: function(handle) {
handle = Emval.toValue(handle);
return typeof handle === 'string';
return typeof handle == 'string';
},

_emval_in__deps: ['$Emval'],
Expand Down
4 changes: 2 additions & 2 deletions src/emrun_postjs.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
* SPDX-License-Identifier: MIT
*/

if (typeof window === "object" && (typeof ENVIRONMENT_IS_PTHREAD === 'undefined' || !ENVIRONMENT_IS_PTHREAD)) {
if (typeof window == "object" && (typeof ENVIRONMENT_IS_PTHREAD == 'undefined' || !ENVIRONMENT_IS_PTHREAD)) {
var emrun_register_handlers = function() {
// When C code exit()s, we may still have remaining stdout and stderr messages in flight. In that case, we can't close
// the browser until all those XHRs have finished, so the following state variables track that all communication is done,
Expand Down Expand Up @@ -66,5 +66,5 @@ if (typeof window === "object" && (typeof ENVIRONMENT_IS_PTHREAD === 'undefined'
http.send(data); // XXX this does not work in workers, for some odd reason (issue #2681)
};

if (typeof Module !== 'undefined' && typeof document !== 'undefined') emrun_register_handlers();
if (typeof Module != 'undefined' && typeof document != 'undefined') emrun_register_handlers();
}
2 changes: 1 addition & 1 deletion src/emrun_prejs.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/

// Route URL GET parameters to argc+argv
if (typeof window === 'object') {
if (typeof window == 'object') {
Module['arguments'] = window.location.search.substr(1).trim().split('&');
// If no args were passed arguments = [''], in which case kill the single empty string.
if (!Module['arguments'][0]) {
Expand Down
2 changes: 1 addition & 1 deletion src/headless.js
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ var screen = { // XXX these values may need to be adjusted
availWidth: 2100,
availHeight: 1283,
};
if (typeof console === "undefined") {
if (typeof console == "undefined") {
console = {
log: function(x) {
print(x);
Expand Down
24 changes: 12 additions & 12 deletions src/jsifier.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ function escapeJSONKey(x) {
}

function stringifyWithFunctions(obj) {
if (typeof obj === 'function') return obj.toString();
if (obj === null || typeof obj !== 'object') return JSON.stringify(obj);
if (typeof obj == 'function') return obj.toString();
if (obj === null || typeof obj != 'object') return JSON.stringify(obj);
if (Array.isArray(obj)) {
return '[' + obj.map(stringifyWithFunctions).join(',') + ']';
} else {
Expand Down Expand Up @@ -106,7 +106,7 @@ function ${name}(${args}) {
var ret = (function() { if (runtimeDebug) err("[library call:${finalName}: " + Array.prototype.slice.call(arguments).map(prettyPrint) + "]");
${body}
}).apply(this, arguments);
if (runtimeDebug && typeof ret !== "undefined") err(" [ return:" + prettyPrint(ret));
if (runtimeDebug && typeof ret != "undefined") err(" [ return:" + prettyPrint(ret));
return ret;
}`);
}
Expand Down Expand Up @@ -203,7 +203,7 @@ function ${name}(${args}) {
}
const isUserSymbol = LibraryManager.library[ident + '__user'];
deps.forEach((dep) => {
if (typeof snippet === 'string' && !(dep in LibraryManager.library)) {
if (typeof snippet == 'string' && !(dep in LibraryManager.library)) {
warn(`missing library dependency ${dep}, make sure you are compiling with the right options (see #if in src/library*.js)`);
}
if (isUserSymbol && LibraryManager.library[dep + '__internal']) {
Expand All @@ -212,7 +212,7 @@ function ${name}(${args}) {
});
let isFunction = false;

if (typeof snippet === 'string') {
if (typeof snippet == 'string') {
if (snippet[0] != '=') {
const target = LibraryManager.library[snippet];
if (target) {
Expand All @@ -228,9 +228,9 @@ function ${name}(${args}) {
libraryFunctions.push(finalName);
}
}
} else if (typeof snippet === 'object') {
} else if (typeof snippet == 'object') {
snippet = stringifyWithFunctions(snippet);
} else if (typeof snippet === 'function') {
} else if (typeof snippet == 'function') {
isFunction = true;
snippet = processLibraryFunction(snippet, ident, finalName);
libraryFunctions.push(finalName);
Expand All @@ -251,7 +251,7 @@ function ${name}(${args}) {
if (postset) {
// A postset is either code to run right now, or some text we should emit.
// If it's code, it may return some text to emit as well.
if (typeof postset === 'function') {
if (typeof postset == 'function') {
postset = postset();
}
if (postset && !addedLibraryItems[postsetId]) {
Expand All @@ -270,7 +270,7 @@ function ${name}(${args}) {
}
const identDependents = ident + "__deps: ['" + deps.join("','") + "']";
function addDependency(dep) {
if (typeof dep !== 'function') {
if (typeof dep != 'function') {
dep = {identOrig: dep, identMangled: mangleCSymbolName(dep)};
}
return addFromLibrary(dep, `${identDependents}, referenced by ${dependent}`);
Expand All @@ -284,7 +284,7 @@ function ${name}(${args}) {
throw new Error(`Invalid proxyingMode ${ident}__proxy: '${proxyingMode}' specified!`);
}
const sync = proxyingMode === 'sync';
assert(typeof original === 'function');
assert(typeof original == 'function');
contentText = modifyFunction(snippet, (name, args, body) => `
function ${name}(${args}) {
if (ENVIRONMENT_IS_PTHREAD)
Expand All @@ -303,7 +303,7 @@ function ${name}(${args}) {
} else {
contentText = snippet; // Regular JS function that will be executed in the context of the calling thread.
}
} else if (typeof snippet === 'string' && snippet.startsWith(';')) {
} else if (typeof snippet == 'string' && snippet.startsWith(';')) {
// In JS libraries
// foo: ';[code here verbatim]'
// emits
Expand All @@ -315,7 +315,7 @@ function ${name}(${args}) {
// foo: '=[value]'
// emits
// 'var foo = [value];'
if (typeof snippet === 'string' && snippet[0] == '=') snippet = snippet.substr(1);
if (typeof snippet == 'string' && snippet[0] == '=') snippet = snippet.substr(1);
contentText = `var ${finalName} = ${snippet};`;
}
const sig = LibraryManager.library[ident + '__sig'];
Expand Down
Loading