* @param {?Object|?Array<!string>|?string} options * @return {!Promise}
(options)
| 154 | * @return {!Promise} |
| 155 | */ |
| 156 | async queue(options) { |
| 157 | await Promise.all(map(isArray(options) ? options : [options], async _options => { |
| 158 | const queueOptions = isString(_options) ? { url: _options } : _options; |
| 159 | each(CONSTRUCTOR_OPTIONS, option => { |
| 160 | if (queueOptions && queueOptions[option]) throw new Error(`Overriding ${option} is not allowed!`); |
| 161 | }); |
| 162 | const mergedOptions = extend({}, this._options, queueOptions); |
| 163 | if (mergedOptions.evaluatePage) mergedOptions.evaluatePage = `(${mergedOptions.evaluatePage})()`; |
| 164 | if (!mergedOptions.url) throw new Error('Url must be defined!'); |
| 165 | if (mergedOptions.device && !includes(deviceNames, mergedOptions.device)) throw new Error('Specified device is not supported!'); |
| 166 | if (mergedOptions.delay > 0 && mergedOptions.maxConcurrency !== 1) throw new Error('Max concurrency must be 1 when delay is set!'); |
| 167 | mergedOptions.url = parse(mergedOptions.url).href; |
| 168 | await this._push(omit(mergedOptions, CONSTRUCTOR_OPTIONS), 1, null); |
| 169 | })); |
| 170 | } |
| 171 | |
| 172 | /** |
| 173 | * @return {!Promise} |
no test coverage detected