Skip to content

Commit

Permalink
Lazy browserless initialization
Browse files Browse the repository at this point in the history
  • Loading branch information
Kikobeats committed Jun 29, 2018
1 parent 184ae17 commit 47f69da
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions src/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ const PUPPETEER_CONFIG = {
]
}

const createBrowserless = opts => browserless({ ...PUPPETEER_CONFIG, ...opts })
const createBrowserless = () => browserless(PUPPETEER_CONFIG)

const fetch = async (url, { toEncode, ...opts }) => {
const res = await got(url, { encoding: null, ...opts })
Expand All @@ -37,12 +37,7 @@ const fetch = async (url, { toEncode, ...opts }) => {

const prerender = async (
url,
{
browserless = createBrowserless(PUPPETEER_CONFIG),
gotOptions,
toEncode,
...opts
}
{ getBrowserless = createBrowserless, gotOptions, toEncode, ...opts }
) => {
const fetchData = fetch(url, { toEncode, ...gotOptions })
let html
Expand Down

0 comments on commit 47f69da

Please sign in to comment.