Permalink
Browse files

Hack to clean up anonymous functions passed through dnode.

Permanent functions should be named; references to anonymous functions will be deleted after they're called.
  • Loading branch information...
1 parent 588990c commit d4d5dea2ecc0cd1463e825da006b8d3d4084f4d4 @bog bog committed Aug 11, 2011
Showing with 9 additions and 1 deletion.
  1. +9 −1 index.js
View
10 index.js
@@ -154,7 +154,15 @@ var Scrubber = exports.Scrubber = function () {
paths[i] = this.path;
}
else {
- self.callbacks[cbId] = node;
+ var id = cbId;
+ self.callbacks[id] = function() {
+ node.apply(this, [].slice.call(arguments));
+ if (node.name == '') {
+ // HACK: function was anonymous, delete our references to it
+ delete self.callbacks[id];
+ delete wrapped[wrapped.indexOf(node)];
+ }
+ };;
wrapped.push(node);
paths[cbId] = this.path;
cbId++;

0 comments on commit d4d5dea

Please sign in to comment.