function defer() {

  const deferred = {};

  deferred.promise = new Promise((resolve, reject) => {
    deferred.resolve = resolve;
    deferred.reject = reject;
  });

  return deferred;
}
@return { {
  promise: Promise,
  resolve: Function,
  reject: Function
} }