(promises, fn, options, _filter)
| 6509 | }; |
| 6510 | |
| 6511 | function map(promises, fn, options, _filter) { |
| 6512 | if (typeof fn !== "function") { |
| 6513 | return apiRejection("expecting a function but got " + util.classString(fn)); |
| 6514 | } |
| 6515 | |
| 6516 | var limit = 0; |
| 6517 | if (options !== undefined) { |
| 6518 | if (typeof options === "object" && options !== null) { |
| 6519 | if (typeof options.concurrency !== "number") { |
| 6520 | return Promise.reject( |
| 6521 | new TypeError("'concurrency' must be a number but it is " + |
| 6522 | util.classString(options.concurrency))); |
| 6523 | } |
| 6524 | limit = options.concurrency; |
| 6525 | } else { |
| 6526 | return Promise.reject(new TypeError( |
| 6527 | "options argument must be an object but it is " + |
| 6528 | util.classString(options))); |
| 6529 | } |
| 6530 | } |
| 6531 | limit = typeof limit === "number" && |
| 6532 | isFinite(limit) && limit >= 1 ? limit : 0; |
| 6533 | return new MappingPromiseArray(promises, fn, limit, _filter).promise(); |
| 6534 | } |
| 6535 | |
| 6536 | Promise.prototype.map = function (fn, options) { |
| 6537 | return map(this, fn, options, null); |
no test coverage detected