es2015/PromiseSync.js
function resolve(instance, newState, value) {
  if (instance[FIELDS.state] !== STATE.PENDING) {
    return
  }
  
  instance[FIELDS.state] = newState
  instance[FIELDS.value] = value
  
  let listeners
  if (newState === STATE.RESOLVED) {
    listeners = instance[FIELDS.fulfillListeners]
  } else {
    listeners = instance[FIELDS.errorListeners]
  }
  
  for (let listener of listeners) {
    listener()
  }
}
function resolve(instance, newState, value) {
  if (instance[FIELDS.state] !== STATE.PENDING) {
    return
  }
  
  instance[FIELDS.state] = newState
  instance[FIELDS.value] = value
  
  let listeners
  if (newState === STATE.RESOLVED) {
    listeners = instance[FIELDS.fulfillListeners]
  } else {
    listeners = instance[FIELDS.errorListeners]
  }
  
  for (let listener of listeners) {
    listener()
  }
}
Resolves the provided promise to the specified state and result value. This
function has no effect if the provided promise has already been resolved.

@param {PromiseSync} instance The promise to resolve.
@param {Object} newState One of the {@code STATE.*} constants representing
the new state of the promise. Must not be {@code STATE.PENDING}.
@param {(*|Error)} value The new result value of the promise.