get-puppeteer-browser
TypeScript icon, indicating that this package has built-in type declarations

1.1.1 • Public • Published

get-puppeteer-browser

Get a singleton puppeteer browser instance.

npm license

Creating a puppeteer browser instance is very slow. It is usually better to reuse than to create each time.

Install

npm i get-puppeteer-browser

Example

const createBrowserGetter = require('get-puppeteer-browser')
const puppeteer = require('puppeteer')
 
const getBrowser = createBrowserGetter(puppeteer, {headless: true, devtools: true});
 
(async () => {
    const b1 = await getBrowser()
    const b2 = await getBrowser()
 
    console.log(b1 === b2) // => true
 
    await b1.close() // Not yet closed
    await b2.close() // Close now.
})()

API

createBrowserGetter(puppeteer[, launchOptions])

Create a getBrowser function.

Debounce option

Debounce without closing immediately.

const getBrowser = createBrowserGetter(puppeteer, {debounce: 1000});
 
(async () => {
    const b1 = await getBrowser()
    b1.close()
 
    delay(900).then(async () => {
        const b2 = await getBrowser()
        console.log(b1 === b2) // => true
        b2.close()
 
        delay(1000).then(async () => {
            const b3 = await getBrowser()
            console.log(b2 === b3) // => false
        })
    })
})()

License

MIT

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.1.16latest

Version History

VersionDownloads (Last 7 Days)Published
1.1.16
1.1.00
1.0.60
1.0.50
1.0.40
1.0.30
1.0.20
1.0.10
1.0.00
0.0.10

Package Sidebar

Install

npm i get-puppeteer-browser

Weekly Downloads

6

Version

1.1.1

License

MIT

Unpacked Size

5.25 kB

Total Files

6

Last publish

Collaborators

  • skt-t1-byungi