build: enable JS semicolons (#22783)

This commit is contained in:
Samuel Attard 2020-03-20 13:28:31 -07:00 committed by GitHub
parent 24e21467b9
commit 5d657dece4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
354 changed files with 21512 additions and 21510 deletions

View file

@ -1,4 +1,4 @@
const v8Util = process.electronBinding('v8_util')
const v8Util = process.electronBinding('v8_util');
export class CallbacksRegistry {
private nextId: number = 0
@ -6,50 +6,50 @@ export class CallbacksRegistry {
add (callback: Function) {
// The callback is already added.
let id = v8Util.getHiddenValue<number>(callback, 'callbackId')
if (id != null) return id
let id = v8Util.getHiddenValue<number>(callback, 'callbackId');
if (id != null) return id;
id = this.nextId += 1
id = this.nextId += 1;
// Capture the location of the function and put it in the ID string,
// so that release errors can be tracked down easily.
const regexp = /at (.*)/gi
const stackString = (new Error()).stack
if (!stackString) return
const regexp = /at (.*)/gi;
const stackString = (new Error()).stack;
if (!stackString) return;
let filenameAndLine
let match
let filenameAndLine;
let match;
while ((match = regexp.exec(stackString)) !== null) {
const location = match[1]
if (location.includes('(native)')) continue
if (location.includes('(<anonymous>)')) continue
if (location.includes('electron/js2c')) continue
const location = match[1];
if (location.includes('(native)')) continue;
if (location.includes('(<anonymous>)')) continue;
if (location.includes('electron/js2c')) continue;
const ref = /([^/^)]*)\)?$/gi.exec(location)
if (ref) filenameAndLine = ref![1]
break
const ref = /([^/^)]*)\)?$/gi.exec(location);
if (ref) filenameAndLine = ref![1];
break;
}
this.callbacks.set(id, callback)
v8Util.setHiddenValue(callback, 'callbackId', id)
v8Util.setHiddenValue(callback, 'location', filenameAndLine)
return id
this.callbacks.set(id, callback);
v8Util.setHiddenValue(callback, 'callbackId', id);
v8Util.setHiddenValue(callback, 'location', filenameAndLine);
return id;
}
get (id: number) {
return this.callbacks.get(id) || function () {}
return this.callbacks.get(id) || function () {};
}
apply (id: number, ...args: any[]) {
return this.get(id).apply(global, ...args)
return this.get(id).apply(global, ...args);
}
remove (id: number) {
const callback = this.callbacks.get(id)
const callback = this.callbacks.get(id);
if (callback) {
v8Util.deleteHiddenValue(callback, 'callbackId')
this.callbacks.delete(id)
v8Util.deleteHiddenValue(callback, 'callbackId');
this.callbacks.delete(id);
}
}
}