tiptoeing along, keeping the suite passing

This commit is contained in:
Zeke Sikelianos 2016-03-25 12:41:24 -07:00 committed by Kevin Sawicki
parent ee181294b3
commit ca7b492b97
3 changed files with 90 additions and 85 deletions

View file

@ -1,62 +1,62 @@
'use strict';
'use strict'
const v8Util = process.atomBinding('v8_util');
const v8Util = process.atomBinding('v8_util')
class CallbacksRegistry {
constructor() {
this.nextId = 0;
this.callbacks = {};
constructor () {
this.nextId = 0
this.callbacks = {}
}
add(callback) {
add (callback) {
// The callback is already added.
var filenameAndLine, id, location, match, ref, regexp, stackString;
id = v8Util.getHiddenValue(callback, 'callbackId');
var filenameAndLine, id, location, match, ref, regexp, stackString
id = v8Util.getHiddenValue(callback, 'callbackId')
if (id != null) {
return id;
return id
}
id = ++this.nextId;
id = ++this.nextId
// Capture the location of the function and put it in the ID string,
// so that release errors can be tracked down easily.
regexp = /at (.*)/gi;
stackString = (new Error).stack;
regexp = /at (.*)/gi
stackString = (new Error).stack
while ((match = regexp.exec(stackString)) !== null) {
location = match[1];
location = match[1]
if (location.indexOf('(native)') !== -1) {
continue;
continue
}
if (location.indexOf('atom.asar') !== -1) {
continue;
continue
}
ref = /([^\/^\)]*)\)?$/gi.exec(location);
filenameAndLine = ref[1];
break;
ref = /([^\/^\)]*)\)?$/gi.exec(location)
filenameAndLine = ref[1]
break
}
this.callbacks[id] = callback;
v8Util.setHiddenValue(callback, 'callbackId', id);
v8Util.setHiddenValue(callback, 'location', filenameAndLine);
return id;
this.callbacks[id] = callback
v8Util.setHiddenValue(callback, 'callbackId', id)
v8Util.setHiddenValue(callback, 'location', filenameAndLine)
return id
}
get(id) {
var ref;
return (ref = this.callbacks[id]) != null ? ref : function() {};
get (id) {
var ref
return (ref = this.callbacks[id]) != null ? ref : function () {}
}
call(id, ...args) {
var ref;
return (ref = this.get(id)).call.apply(ref, [global].concat(args));
call (id, ...args) {
var ref
return (ref = this.get(id)).call.apply(ref, [global].concat(args))
}
apply(id, ...args) {
var ref;
return (ref = this.get(id)).apply.apply(ref, [global].concat(args));
apply (id, ...args) {
var ref
return (ref = this.get(id)).apply.apply(ref, [global].concat(args))
}
remove(id) {
return delete this.callbacks[id];
remove (id) {
return delete this.callbacks[id]
}
}
module.exports = CallbacksRegistry;
module.exports = CallbacksRegistry