<commit_before># browser-notification

Small library built around browsers native [Notification-API](https://developer.mozilla.org/en-US/docs/Web/API/Notification) with some useful default behavior.
(A particular good fit for chat/messaging -type applications)

**browser-notification does just a few things**
- Look for [browser support](http://caniuse.com/#feat=notifications) and ask for user permission when initialized.
- Clicking a notification will focus the browser tab that fired the notification.
- `ignoreFocused` - If browser tab is already focused `notify()` -call will be ignored. **optional, default: true**
- For API simplicity one can always fire `notify()` since in case Notifications are not available it's just a no-op.
- Optional `cooldown` - milliseconds before consecutive notification can be fired. (Disabled by default)
- Optional `timeout` - milliseconds to wait before auto-closing notifications. (Disabled by default)

### Install
```
yarn add browser-notificaiton
```
or
```
npm install browser-notification --save
```
The library has no dependencies and size is less than 1kB (minified + gzipped).
A UMD build is available in `/dist` of the npm package.

### Usage

```
import {BrowserNotification} from 'browser-notification';

// Check browser support, ask permission, initialize
const notifier = BrowserNotification();
...
// Notify
notifier.notify('This is the title.', {body: '...and this is the body'});
```

**Note** - The underlying Notifications API for permission is async so if you want to initialize `BrowserNotification` at the same time as firing `notify`, you must first resolve `BrowserNotification.availablePromise` to ensure initialization is complete, see API and example below.

### API
`BrowserNotification({options})`
Create and setup the notifier object, asking for permission<commit_msg>Readme update<commit_after># browser-notification

Small library built around browsers native [Notification-API](https://developer.mozilla.org/en-US/docs/Web/API/Notification) with some useful default behavior.
(A particular good fit for chat/messaging -type applications)

**browser-notification does just a few things**
- Look for [browser support](http://caniuse.com/#feat=notifications) and ask for user permission when initialized.
- Clicking a notification will focus the browser tab that fired the notification.
- `ignoreFocused` - If browser tab is already focused `notify()` -call will be ignored. **optional, default: true**
- For API simplicity one can always fire `notify()` since in case Notifications are not available it's just a no-op.
- `cooldown` - milliseconds before consecutive notification can be fired. **optional, default: 0**
- `timeout` - milliseconds to wait before auto-closing notifications. **optional, default: 0 (disabled)**

### Install
```
yarn add browser-notificaiton
```
or
```
npm install browser-notification --save
```
The library has no dependencies and size is less than 1kB (minified + gzipped).
A UMD build is available in `/dist` of the npm package.

### Usage

```
import {BrowserNotification} from 'browser-notification';

// Check browser support, ask permission, initialize
const notifier = BrowserNotification();
...
// Notify
notifier.notify('This is the title.', {body: '...and this is the body'});
```

**Note** - The underlying Notifications API for permission is async so if you want to initialize `BrowserNotification` at the same time as firing `notify`, you must first resolve `BrowserNotification.availablePromise` to ensure initialization is complete, see API and example below.

### API
`BrowserNotification({options})`
Create and setup the notifier object, asking for permission
{'fraction_non_alphanumeric': 0.10105949470252648, 'fraction_numerical': 0.0010866612333604998, 'mean_word_length': 4.9869918699186995, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 2, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '432284', 'n_tokens_mistral': 943, 'n_tokens_neox': 896, 'n_words': 429}