I get asked a lot, "do you even test your code?"
No. No, the answer is no.
This commit is contained in:
parent
f067d990c6
commit
31e409f361
@ -813,7 +813,7 @@
|
||||
Callbacks.prototype.push = function(_arg) {
|
||||
var cb, name;
|
||||
name = _arg.name, cb = _arg.cb;
|
||||
return this.name = cb;
|
||||
return this[name] = cb;
|
||||
};
|
||||
|
||||
Callbacks.prototype.clean = function() {
|
||||
@ -826,16 +826,15 @@
|
||||
};
|
||||
|
||||
Callbacks.prototype.rm = function(name) {
|
||||
return delete this.name;
|
||||
return delete this[name];
|
||||
};
|
||||
|
||||
Callbacks.prototype.execute = function(target) {
|
||||
var cb, err, errors, name;
|
||||
Callbacks.prototype.execute = function(node) {
|
||||
var err, errors, name;
|
||||
for (name in this) {
|
||||
cb = this[name];
|
||||
if (this.hasOwnProperty(name)) {
|
||||
try {
|
||||
cb.call(target);
|
||||
this[name].call(node);
|
||||
} catch (_error) {
|
||||
err = _error;
|
||||
if (!errors) {
|
||||
@ -12571,43 +12570,32 @@
|
||||
}
|
||||
},
|
||||
callbackNodes: function(klass, nodes) {
|
||||
var len, node;
|
||||
len = nodes.length;
|
||||
var cb, i, node;
|
||||
i = 0;
|
||||
cb = klass.callbacks;
|
||||
while (node = nodes[i++]) {
|
||||
klass.callback.execute(node);
|
||||
cb.execute(node);
|
||||
}
|
||||
},
|
||||
callbackNodesDB: function(klass, nodes, cb) {
|
||||
var errors, func, i, len, node, queue, softTask;
|
||||
queue = [];
|
||||
var callbacks, errors, len, softTask;
|
||||
errors = null;
|
||||
func = function(node) {
|
||||
klass.callback.execute(node);
|
||||
if (!queue.length) {
|
||||
if (cb) {
|
||||
return cb();
|
||||
}
|
||||
}
|
||||
};
|
||||
len = 0;
|
||||
callbacks = klass.callbacks;
|
||||
softTask = function() {
|
||||
var node;
|
||||
node = queue.shift();
|
||||
func(node);
|
||||
if (!queue.length) {
|
||||
return;
|
||||
node = nodes.shift();
|
||||
callbacks.execute(node);
|
||||
if (!--len && cb) {
|
||||
return cb();
|
||||
}
|
||||
if (!(queue.length % 7)) {
|
||||
if (!(len % 7)) {
|
||||
return setTimeout(softTask, 0);
|
||||
} else {
|
||||
return softTask();
|
||||
}
|
||||
};
|
||||
len = nodes.length;
|
||||
i = 0;
|
||||
while (i < len) {
|
||||
node = nodes[i++];
|
||||
queue.push(node);
|
||||
}
|
||||
return softTask();
|
||||
},
|
||||
addCallback: function(e) {
|
||||
|
||||
@ -818,7 +818,7 @@
|
||||
Callbacks.prototype.push = function(_arg) {
|
||||
var cb, name;
|
||||
name = _arg.name, cb = _arg.cb;
|
||||
return this.name = cb;
|
||||
return this[name] = cb;
|
||||
};
|
||||
|
||||
Callbacks.prototype.clean = function() {
|
||||
@ -831,16 +831,15 @@
|
||||
};
|
||||
|
||||
Callbacks.prototype.rm = function(name) {
|
||||
return delete this.name;
|
||||
return delete this[name];
|
||||
};
|
||||
|
||||
Callbacks.prototype.execute = function(target) {
|
||||
var cb, err, errors, name;
|
||||
Callbacks.prototype.execute = function(node) {
|
||||
var err, errors, name;
|
||||
for (name in this) {
|
||||
cb = this[name];
|
||||
if (this.hasOwnProperty(name)) {
|
||||
try {
|
||||
cb.call(target);
|
||||
this[name].call(node);
|
||||
} catch (_error) {
|
||||
err = _error;
|
||||
if (!errors) {
|
||||
@ -12545,43 +12544,32 @@
|
||||
}
|
||||
},
|
||||
callbackNodes: function(klass, nodes) {
|
||||
var len, node;
|
||||
len = nodes.length;
|
||||
var cb, i, node;
|
||||
i = 0;
|
||||
cb = klass.callbacks;
|
||||
while (node = nodes[i++]) {
|
||||
klass.callback.execute(node);
|
||||
cb.execute(node);
|
||||
}
|
||||
},
|
||||
callbackNodesDB: function(klass, nodes, cb) {
|
||||
var errors, func, i, len, node, queue, softTask;
|
||||
queue = [];
|
||||
var callbacks, errors, len, softTask;
|
||||
errors = null;
|
||||
func = function(node) {
|
||||
klass.callback.execute(node);
|
||||
if (!queue.length) {
|
||||
if (cb) {
|
||||
return cb();
|
||||
}
|
||||
}
|
||||
};
|
||||
len = 0;
|
||||
callbacks = klass.callbacks;
|
||||
softTask = function() {
|
||||
var node;
|
||||
node = queue.shift();
|
||||
func(node);
|
||||
if (!queue.length) {
|
||||
return;
|
||||
node = nodes.shift();
|
||||
callbacks.execute(node);
|
||||
if (!--len && cb) {
|
||||
return cb();
|
||||
}
|
||||
if (!(queue.length % 7)) {
|
||||
if (!(len % 7)) {
|
||||
return setTimeout(softTask, 0);
|
||||
} else {
|
||||
return softTask();
|
||||
}
|
||||
};
|
||||
len = nodes.length;
|
||||
i = 0;
|
||||
while (i < len) {
|
||||
node = nodes[i++];
|
||||
queue.push(node);
|
||||
}
|
||||
return softTask();
|
||||
},
|
||||
addCallback: function(e) {
|
||||
|
||||
@ -229,40 +229,28 @@ Main =
|
||||
new Notice 'warning', 'Cookies need to be enabled on 4chan for <%= meta.name %> to operate properly.', 30
|
||||
|
||||
callbackNodes: (klass, nodes) ->
|
||||
# get the nodes' length only once
|
||||
len = nodes.length
|
||||
i = 0
|
||||
cb = klass.callbacks
|
||||
while node = nodes[i++]
|
||||
klass.callback.execute node
|
||||
cb.execute node
|
||||
return
|
||||
|
||||
callbackNodesDB: (klass, nodes, cb) ->
|
||||
queue = []
|
||||
errors = null
|
||||
len = 0
|
||||
|
||||
func = (node) ->
|
||||
klass.callback.execute node
|
||||
|
||||
# finish
|
||||
unless queue.length
|
||||
cb() if cb
|
||||
{callbacks} = klass
|
||||
|
||||
softTask = ->
|
||||
node = queue.shift()
|
||||
func node
|
||||
return unless queue.length
|
||||
unless queue.length % 7
|
||||
node = nodes.shift()
|
||||
callbacks.execute node
|
||||
return cb() if not --len and cb
|
||||
unless len % 7
|
||||
setTimeout softTask, 0
|
||||
else
|
||||
softTask()
|
||||
|
||||
# get the nodes' length only once
|
||||
len = nodes.length
|
||||
i = 0
|
||||
|
||||
while i < len
|
||||
node = nodes[i++]
|
||||
queue.push node
|
||||
|
||||
len = nodes.length
|
||||
softTask()
|
||||
|
||||
addCallback: (e) ->
|
||||
|
||||
@ -1,16 +1,16 @@
|
||||
class Callbacks
|
||||
push: ({name, cb}) -> @name = cb
|
||||
push: ({name, cb}) -> @[name] = cb
|
||||
|
||||
clean: ->
|
||||
@rm name for name of @ when @hasOwnProperty name
|
||||
return
|
||||
|
||||
rm: (name) -> delete @name
|
||||
rm: (name) -> delete @[name]
|
||||
|
||||
execute: (target) ->
|
||||
for name, cb of @ when @hasOwnProperty name
|
||||
execute: (node) ->
|
||||
for name of @ when @hasOwnProperty name
|
||||
try
|
||||
cb.call target
|
||||
@[name].call node
|
||||
catch err
|
||||
errors = [] unless errors
|
||||
errors.push
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user