# abstract-browser

> Interface for opening and closing a browser

Latest version **1.0.0** (published 2020-07-14) · MIT license · 0 weekly downloads

## Install

```sh
npm install abstract-browser
pnpm add abstract-browser
yarn add abstract-browser
bun add abstract-browser
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2020-07-14 |
| First published | 2020-07-14 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=10 |
| Dependencies | 3 |
| Unpacked size | 6.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 1 |
| Author | Vincent Weevers |
| Maintainers | vweevers |
| Keywords | abstract, airtap, browser |

## Links

- npm: https://www.npmjs.com/package/abstract-browser
- Repository: https://github.com/airtap/abstract-browser
- Issues: https://github.com/airtap/abstract-browser/issues
- npm.io page: https://npm.io/package/abstract-browser

## Dependencies (3)

- [catering](https://npm.io/package/catering.md) ^2.0.0
- [nanoresource](https://npm.io/package/nanoresource.md) ^1.3.0
- [browser-manifest](https://npm.io/package/browser-manifest.md) ^1.0.0

## Alternatives

- [@opentelemetry/exporter-zipkin](https://npm.io/package/@opentelemetry/exporter-zipkin.md) — 14.8M weekly downloads
- [pusher-js](https://npm.io/package/pusher-js.md) — 2.0M weekly downloads
- [browserify](https://npm.io/package/browserify.md) — 1.7M weekly downloads
- [sqs-consumer](https://npm.io/package/sqs-consumer.md) — 1.7M weekly downloads
- [@sanity/eventsource](https://npm.io/package/@sanity/eventsource.md) — 930.8K weekly downloads

## Recent versions

- 1.0.0 (latest) — 2020-07-14

## README

# abstract-browser

**Interface for opening and closing a browser.** Uses [`nanoresource`](https://github.com/mafintosh/nanoresource) for state management, [`browser-manifest`](https://github.com/airtap/browser-manifest) for metadata. Pairs well with [`browser-provider`](https://github.com/airtap/browser-provider).

[![npm status](http://img.shields.io/npm/v/abstract-browser.svg)](https://www.npmjs.org/package/abstract-browser)
[![node](https://img.shields.io/node/v/abstract-browser.svg)](https://www.npmjs.org/package/abstract-browser)
[![Travis](https://img.shields.io/travis/com/airtap/abstract-browser.svg)](https://travis-ci.com/airtap/abstract-browser)
[![JavaScript Style Guide](https://img.shields.io/badge/code_style-standard-brightgreen.svg)](https://standardjs.com)

## Usage

With promises:

```js
const Browser = require('abstract-browser').promises

class MyBrowser extends Browser {
  async _open () {
    // open the browser
    console.log('opening', this.target.url)
  }

  async _close () {
    // close the browser
  }
}
```

With callbacks:

```js
const Browser = require('abstract-browser')

class MyBrowser extends Browser {
  _open (callback) {
    // ..
  }

  _close (callback) {
    // ..
  }
}
```

## API

### `browser = new Browser(manifest, target)`

Constructor. Takes a [`browser-manifest`](https://github.com/airtap/browser-manifest) and a `target` object in the form of `{ url }`.

Implementors are free to change the signature of their constructor. User-facing options specific to an implementation should be passed in via `manifest.options`.

### `browser.open([callback])`

Open the browser. Returns a promise if no callback is provided.

### `browser.close([callback])`

Close the browser. Returns a promise if no callback is provided.

### `browser.status(ok[, callback])`

Set status by a boolean `ok`. Returns a promise if no callback is provided. Useful for remote browsers like Sauce Labs where you can set the remote job status e.g. after running tests on a browser.

### `browser.manifest`

The manifest that was passed to the constructor.

### `browser.target`

The target that was passed to the constructor.

## Events

Browsers may emit `error` events. It's recommended to only do so after `open()` has completed and not after `close()` has been called. The [`transient-error`](https://github.com/vweevers/transient-error) module may be used to signal that the error is temporary and that running (a new instance of) the browser can be retried.

## Install

With [npm](https://npmjs.org) do:

```
npm install abstract-browser
```

## License

[MIT](LICENSE.md) © 2020-present Airtap contributors

---
_Source: https://npm.io/package/abstract-browser · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
