Skip to content

Instantly share code, notes, and snippets.

@dylanmcdiarmid
Created November 19, 2013 15:16

Revisions

  1. @Littleloops Littleloops created this gist Nov 19, 2013.
    40 changes: 40 additions & 0 deletions iced.js
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,40 @@
    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();
    }
    };