Skip to content

Commit

Permalink
__bind helper: caching ctor
Browse files Browse the repository at this point in the history
  • Loading branch information
michaelficarra committed May 27, 2011
1 parent 6a40807 commit 9cbf2a8
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 14 deletions.
22 changes: 11 additions & 11 deletions lib/nodes.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions src/nodes.coffee
Expand Up @@ -1770,12 +1770,12 @@ UTILITIES =
# Create a function bound to the current value of "this".
bind: '''
(Function.prototype.bind ? Function.prototype.call.bind(Function.prototype.bind) : function(fn, me){
var ctor = function(){};
ctor.prototype = fn.prototype;
return function bound(){
if (!(this instanceof bound))
return fn.apply(me, arguments);
var ctor = function(){};
ctor.prototype = fn.prototype;
var obj = new ctor();
var obj = new ctor;
fn.apply(obj, arguments);
return obj;
};
Expand Down

0 comments on commit 9cbf2a8

Please sign in to comment.