function defer() {
  let resolve;
  let reject;
  const promise = new Promise(function (res, rej) {
    resolve = res;
    reject = rej;
  });

  return {
    resolve: resolve,
    reject: reject,
    promise: promise,
  };
}
Creates a deferred object, containing a promise object, and functions to resolve or reject the promise.
@returns {defer.deferred}
@private