Created
November 19, 2013 15:16
-
-
Save dylanmcdiarmid/7546859 to your computer and use it in GitHub Desktop.
Iced Coffee Script client side usage. This sets `iced` up as a global so your await/defer statements can work in the browser. I ripped this from the server side code, so it may not be entirely correct, but I do have it running and working in production.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
window.iced = { | |
Deferrals: (function() { | |
__slice = [].slice | |
function _Class(_arg) { | |
this.continuation = _arg; | |
this.count = 1; | |
this.ret = null; | |
} | |
_Class.prototype._fulfill = function() { | |
if (!--this.count) return this.continuation(this.ret); | |
}; | |
_Class.prototype.defer = function(defer_params) { | |
var _this = this; | |
++this.count; | |
return function() { | |
var inner_params, _ref; | |
inner_params = 1 <= arguments.length ? __slice.call(arguments, 0) : []; | |
if (defer_params != null) { | |
if ((_ref = defer_params.assign_fn) != null) { | |
_ref.apply(null, inner_params); | |
} | |
} | |
return _this._fulfill(); | |
}; | |
}; | |
return _Class; | |
})(), | |
findDeferral: function() { | |
return null; | |
}, | |
trampoline: function(_fn) { | |
return _fn(); | |
} | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
my broser (chorme v39) cannot recognize keyword "await"