Merge pull request #4121 from atom/format-coffee-helpers

Format leftover CoffeeScript helpers
This commit is contained in:
Cheng Zhao 2016-01-16 13:24:26 +08:00
commit 25afcf2673
7 changed files with 139 additions and 201 deletions

View file

@ -1,15 +1,16 @@
var CallbacksRegistry, v8Util,
slice = [].slice;
'use strict';
v8Util = process.atomBinding('v8_util');
var slice = [].slice;
module.exports = CallbacksRegistry = (function() {
function CallbacksRegistry() {
const v8Util = process.atomBinding('v8_util');
class CallbacksRegistry {
constructor() {
this.nextId = 0;
this.callbacks = {};
}
CallbacksRegistry.prototype.add = function(callback) {
add(callback) {
// The callback is already added.
var filenameAndLine, id, location, match, ref, regexp, stackString, x;
id = v8Util.getHiddenValue(callback, 'callbackId');
@ -37,29 +38,28 @@ module.exports = CallbacksRegistry = (function() {
v8Util.setHiddenValue(callback, 'callbackId', id);
v8Util.setHiddenValue(callback, 'location', filenameAndLine);
return id;
};
}
CallbacksRegistry.prototype.get = function(id) {
get(id) {
var ref;
return (ref = this.callbacks[id]) != null ? ref : function() {};
};
}
CallbacksRegistry.prototype.call = function() {
call() {
var args, id, ref;
id = arguments[0], args = 2 <= arguments.length ? slice.call(arguments, 1) : [];
return (ref = this.get(id)).call.apply(ref, [global].concat(slice.call(args)));
};
}
CallbacksRegistry.prototype.apply = function() {
apply() {
var args, id, ref;
id = arguments[0], args = 2 <= arguments.length ? slice.call(arguments, 1) : [];
return (ref = this.get(id)).apply.apply(ref, [global].concat(slice.call(args)));
};
}
CallbacksRegistry.prototype.remove = function(id) {
remove(id) {
return delete this.callbacks[id];
};
}
}
return CallbacksRegistry;
})();
modules.exports = CallbacksRegistry