promise_server.js
function awaitPromise(promise) {
    var Promise = promise.constructor;
    var Fiber = Promise.Fiber;

    assert.strictEqual(
      typeof Fiber, "function",
      "Cannot await unless Promise.Fiber is defined"
    );

    var fiber = Fiber.current;

    assert.ok(
      fiber instanceof Fiber,
      "Cannot await without a Fiber"
    );

    var run = fiber.run;
    var throwInto = fiber.throwInto;

    if (process.domain) {
      run = process.domain.bind(run);
      throwInto = process.domain.bind(throwInto);
    }

    // The overridden es6PromiseThen function is adequate here because these
    // two callbacks do not need to run in a Fiber.
    es6PromiseThen.call(promise, function (result) {
      tryCatchNextTick(fiber, run, [result]);
    }, function (error) {
      tryCatchNextTick(fiber, throwInto, [error]);
    });

    return stackSafeYield(Fiber, awaitPromise);
  }
function awaitPromise(promise) {
    var Promise = promise.constructor;
    var Fiber = Promise.Fiber;

    assert.strictEqual(
      typeof Fiber, "function",
      "Cannot await unless Promise.Fiber is defined"
    );

    var fiber = Fiber.current;

    assert.ok(
      fiber instanceof Fiber,
      "Cannot await without a Fiber"
    );

    var run = fiber.run;
    var throwInto = fiber.throwInto;

    if (process.domain) {
      run = process.domain.bind(run);
      throwInto = process.domain.bind(throwInto);
    }

    // The overridden es6PromiseThen function is adequate here because these
    // two callbacks do not need to run in a Fiber.
    es6PromiseThen.call(promise, function (result) {
      tryCatchNextTick(fiber, run, [result]);
    }, function (error) {
      tryCatchNextTick(fiber, throwInto, [error]);
    });

    return stackSafeYield(Fiber, awaitPromise);
  }
function awaitPromise ( promise ) { var Promise = promise . constructor ; var Fiber = Promise . Fiber ; assert . strictEqual ( typeof Fiber , "function" , "Cannot await unless Promise.Fiber is defined" ) ; var fiber = Fiber . current ; assert . ok ( fiber instanceof Fiber , "Cannot await without a Fiber" ) ; var run = fiber . run ; var throwInto = fiber . throwInto ; if ( process . domain ) { run = process . domain . bind ( run ) ; throwInto = process . domain . bind ( throwInto ) ; } // The overridden es6PromiseThen function is adequate here because these // two callbacks do not need to run in a Fiber. es6PromiseThen . call ( promise , function ( result ) { tryCatchNextTick ( fiber , run , [ result ] ) ; } , function ( error ) { tryCatchNextTick ( fiber , throwInto , [ error ] ) ; } ) ; return stackSafeYield ( Fiber , awaitPromise ) ; }
Yield the current Fiber until the given Promise has been fulfilled.
Yield the current Fiber until the given Promise has been fulfilled .