(page, emitter, opts)
| 32 | } |
| 33 | |
| 34 | async function getPage(page, emitter, opts) { |
| 35 | emitter.emit('beforePageLoad', page) |
| 36 | |
| 37 | if (opts.json) { |
| 38 | try { |
| 39 | const json = await got(page.url).json() |
| 40 | const pageCopy = Object.assign({}, page, { json }) |
| 41 | emitter.emit('page', pageCopy) |
| 42 | } catch (err) { |
| 43 | emitter.emit('error', err) |
| 44 | } |
| 45 | } else { |
| 46 | try { |
| 47 | const body = (await got(page.url)).body |
| 48 | const pageCopy = Object.assign({}, page, { body }) |
| 49 | if (opts.parseDOM) pageCopy.$ = cheerio.load(body) |
| 50 | emitter.emit('page', pageCopy) |
| 51 | } catch (err) { |
| 52 | emitter.emit('error', err) |
| 53 | } |
| 54 | } |
| 55 | } |
nothing calls this directly
no outgoing calls
no test coverage detected