code: function Future(f, args) {
    var self = this;
  
    function run() {
      args[args.length] = function cb() {
        switch (arguments.length) {
        case 0:
          self.result = null;
          break;
        case 1:
          if (arguments[0] instanceof Error) {
            self.err = arguments[0];
          } else {
            self.result = arguments[0];
          }
          break;
        default:
          self.err = arguments[0];
          if (arguments.length === 2) {
            self.result = arguments[1];
          } else {
            self.result = Array.prototype.slice.call(arguments, 1);
          }
          break;
        }
        if (self.flow_) self.flow_.futureFinished();
        var caller = self.caller;
        if (caller) caller.run();
      };
      args.length++;
      f.apply(undefined, args);
    }
    this.run = run;
  
    var flow = Fiber.current.flow;
    if (flow) {
      Object.defineProperty(this, "flow_", {
        enumerable: false,
        writable: true,
        value: flow
      });
      flow.registerFuture(this);
    } else {
      run();
    }
  }
docs: Future class.