benchmarks/scenarios/ember.js
function isolate(fn, val) {
    var value, lastPromise;

    // Reset lastPromise for nested helpers
    Test.lastPromise = null;

    value = fn(val);

    lastPromise = Test.lastPromise;
    Test.lastPromise = null;

    // If the method returned a promise
    // return that promise. If not,
    // return the last async helper's promise
    if (value && value instanceof Test.Promise || !lastPromise) {
      return value;
    } else {
      return run(function () {
        return Test.resolve(lastPromise).then(function () {
          return value;
        });
      });
    }
  }
function isolate(fn, val) {
    var value, lastPromise;

    // Reset lastPromise for nested helpers
    Test.lastPromise = null;

    value = fn(val);

    lastPromise = Test.lastPromise;
    Test.lastPromise = null;

    // If the method returned a promise
    // return that promise. If not,
    // return the last async helper's promise
    if (value && value instanceof Test.Promise || !lastPromise) {
      return value;
    } else {
      return run(function () {
        return Test.resolve(lastPromise).then(function () {
          return value;
        });
      });
    }
  }
function isolate ( fn , val ) { var value , lastPromise ; // Reset lastPromise for nested helpers Test . lastPromise = null ; value = fn ( val ) ; lastPromise = Test . lastPromise ; Test . lastPromise = null ; // If the method returned a promise // return that promise. If not, // return the last async helper's promise if ( value && value instanceof Test . Promise || ! lastPromise ) { return value ; } else { return run ( function ( ) { return Test . resolve ( lastPromise ) . then ( function ( ) { return value ; } ) ; } ) ; } }
This method isolates nested async methods so that they don't conflict with other last promises.  1. Set `Ember.Test.lastPromise` to null 2. Invoke method 3. Return the last promise created during method
This method isolates nested async methods so that they don t conflict with other last promises . 1 . Set Ember . Test . lastPromise to null 2 . Invoke method 3 . Return the last promise created during method