function asCheckedCallback(promise, cb, useOwnMethod) {
  let called = false;
  if (useOwnMethod) {
    promise.asCallback(after);
  } else {
    asCallback(promise, after);
  }

  function after() {
    expect(called).toBeFalsy();
    called = true;
    return cb.apply(this, arguments);
  }
}
function asCheckedCallback(promise, cb, useOwnMethod) {
  let called = false;
  if (useOwnMethod) {
    promise.asCallback(after);
  } else {
    asCallback(promise, after);
  }

  function after() {
    expect(called).toBeFalsy();
    called = true;
    return cb.apply(this, arguments);
  }
}
function asCheckedCallback ( promise , cb , useOwnMethod ) { let called = false ; if ( useOwnMethod ) { promise . asCallback ( after ) ; } else { asCallback ( promise , after ) ; } function after ( ) { expect ( called ) . toBeFalsy ( ) ; called = true ; return cb . apply ( this , arguments ) ; } }
Wrap the asCallback function with a check that ensures the callback is never called twice.
Wrap the asCallback function with a check that ensures the callback is never called twice .