function some(promisesOrValues, howMany, onFulfilled, onRejected, onProgress) {

		return when(promisesOrValues, function(promisesOrValues) {

			return promise(resolveSome).then(onFulfilled, onRejected, onProgress);

			function resolveSome(resolve, reject, notify) {
				var toResolve, toReject, values, reasons, fulfillOne, rejectOne, len, i;

				len = promisesOrValues.length >>> 0;

				toResolve = Math.max(0, Math.min(howMany, len));
				values = [];

				toReject = (len - toResolve) + 1;
				reasons = [];

				// No items in the input, resolve immediately
				if (!toResolve) {
					resolve(values);

				} else {
					rejectOne = function(reason) {
						reasons.push(reason);
						if(!--toReject) {
							fulfillOne = rejectOne = identity;
							reject(reasons);
						}
					};

					fulfillOne = function(val) {
						// This orders the values based on promise resolution order
						values.push(val);
						if (!--toResolve) {
							fulfillOne = rejectOne = identity;
							resolve(values);
						}
					};

					for(i = 0; i < len; ++i) {
						if(i in promisesOrValues) {
							when(promisesOrValues[i], fulfiller, rejecter, notify);
						}
					}
				}

				function rejecter(reason) {
					rejectOne(reason);
				}

				function fulfiller(val) {
					fulfillOne(val);
				}
			}
		});
	}
Initiates a competitive race, returning a promise that will resolve when
howMany of the supplied promisesOrValues have resolved, or will reject when
it becomes impossible for howMany to resolve, for example, when
(promisesOrValues.length - howMany) + 1 input promises reject.

@param {Array} promisesOrValues array of anything, may contain a mix
     of promises and values
@param howMany {number} number of promisesOrValues to resolve
@param {function?} [onFulfilled] DEPRECATED, use returnedPromise.then()
@param {function?} [onRejected] DEPRECATED, use returnedPromise.then()
@param {function?} [onProgress] DEPRECATED, use returnedPromise.then()
@returns {Promise} promise that will resolve to an array of howMany values that
 resolved first, or will reject with an array of
 (promisesOrValues.length - howMany) + 1 rejection reasons.