Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add missing semi colons + Wait for page close #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 10 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ Requires Node v6+
## Usage

```javascript
const createPuppeteerPool = require('puppeteer-pool')
const createPuppeteerPool = require('puppeteer-pool');

// Returns a generic-pool instance
const pool = createPuppeteerPool({
Expand All @@ -35,25 +35,25 @@ const pool = createPuppeteerPool({
testOnBorrow: true, // default
// For all opts, see opts at https://github.com/coopernurse/node-pool#createpool
puppeteerArgs: []
})
});

// Automatically acquires a puppeteer instance and releases it back to the
// pool when the function resolves or throws
pool.use(async (browser) => {
const page = await browser.newPage()
const status = await page.goto('http://google.com')
const page = await browser.newPage();
const status = await page.goto('http://google.com');
if (!status.ok) {
throw new Error('cannot open google.com')
throw new Error('cannot open google.com');
}
const content = await page.content()
page.close()
return content
await page.close();
return content;
}).then((content) => {
console.log(content)
})
console.log(content);
});

// Destroying the pool:
pool.drain().then(() => pool.clear())
pool.drain().then(() => pool.clear());

// For more API doc, see https://github.com/coopernurse/node-pool#generic-pool
```
Expand Down