code: function Q(resolver) {
            if (!angular.isFunction(resolver)) {
              throw new Error('missing resolver function');
            }
  
            var deferred = $q.defer();
  
            function resolveFn(value) {
              deferred.resolve(value);
            }
  
            function rejectFn(reason) {
              deferred.reject(reason);
            }
  
            resolver(resolveFn, rejectFn);
  
            return deferred.promise;
          }
docs: ES6 style promises polyfill for angular 1.2.x Copied from angular 1.3.x implementation: https://github.com/angular/angular.js/blob/v1.3.5/src/ng/q.js#L539