any.js 421 B

123456789101112131415161718192021
  1. "use strict";
  2. module.exports = function(Promise) {
  3. var SomePromiseArray = Promise._SomePromiseArray;
  4. function any(promises) {
  5. var ret = new SomePromiseArray(promises);
  6. var promise = ret.promise();
  7. ret.setHowMany(1);
  8. ret.setUnwrap();
  9. ret.init();
  10. return promise;
  11. }
  12. Promise.any = function (promises) {
  13. return any(promises);
  14. };
  15. Promise.prototype.any = function () {
  16. return any(this);
  17. };
  18. };