<commit_before># Dynamic Service Worker
![Dynamic Service Worker](https://github.com/NascHQ/dsw/blob/master/docs/images/worker-person.png)

[![Version](https://img.shields.io/npm/v/dsw.svg?label=Version&maxAge=2592000)](https://www.npmjs.com/package/dsw)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/bb589aedc04b445d9633ddf66b55da06)](https://www.codacy.com/app/felipenmoura/dsw?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=NascHQ/dsw/&amp;utm_campaign=Badge_Grade) 
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/NascHQ/dsw/master/license.txt) 
[![GitHub issues](https://img.shields.io/github/issues/NascHQ/dsw.svg)](https://github.com/NascHQ/dsw/issues) 
[![Build Status](https://travis-ci.org/NascHQ/dsw.svg)](https://travis-ci.org/NascHQ/dsw) 

DSW allows you to enable and use Service Workers in a much easier way, also helping you to create and maintain your Progressive Web Apps working offline.<br/>
You will simply have to create setup in a JSON file how your service worker is supposed to deal with requests. Read the [commented JSON example](https://naschq.github.io/dsw/config-example.html) or the documentation and examples below.

#### Advantages

- use of variables
- decision over cache naming and versioning for each matching request
- many named rules (for future debugging tooling...I imagine we can have a lighthouse-like page for debugging your service workers and your rules)
- support for indexedDB (under development)
- support for messaging and syncing events (under development)
- quite simple json configuration and easy to start with the basic, or go further for more complex cases
- client api with many possibilities (kinda connecting the browser and sw scopes via events)

## Installing it

It's node program which you may install globally:

```npm install -g dsw```

Or locally:

```npm install dsw --save-dev```

## TL;DL
<commit_msg>Added link for live demo<commit_after># Dynamic Service Worker
![Dynamic Service Worker](https://github.com/NascHQ/dsw/blob/master/docs/images/worker-person.png)

[![Version](https://img.shields.io/npm/v/dsw.svg?label=Version&maxAge=2592000)](https://www.npmjs.com/package/dsw)
[![Codacy Badge](https://api.codacy.com/project/badge/Grade/bb589aedc04b445d9633ddf66b55da06)](https://www.codacy.com/app/felipenmoura/dsw?utm_source=github.com&amp;utm_medium=referral&amp;utm_content=NascHQ/dsw/&amp;utm_campaign=Badge_Grade) 
[![GitHub license](https://img.shields.io/badge/license-MIT-blue.svg)](https://raw.githubusercontent.com/NascHQ/dsw/master/license.txt) 
[![GitHub issues](https://img.shields.io/github/issues/NascHQ/dsw.svg)](https://github.com/NascHQ/dsw/issues) 
[![Build Status](https://travis-ci.org/NascHQ/dsw.svg)](https://travis-ci.org/NascHQ/dsw) 

DSW allows you to enable and use Service Workers in a much easier way, also helping you to create and maintain your Progressive Web Apps working offline.<br/>
You will simply have to create setup in a JSON file how your service worker is supposed to deal with requests. Read the [commented JSON example](https://naschq.github.io/dsw/config-example.html) or the documentation and examples below.

## Live Demo

You can access this page and see a live demo of DSW working.
After loading the page the first time, it will install the service worker. When opening it the second time, it will cache everything following its rules (described in each block and link).
You can then go offline and reload the page to validate it.
[Dynamic Service Worker demo](https://dsw-demo-atdnhdbdgt.now.sh/)

## Advantages

- use of variables
- decision over cache naming and versioning for each matching request
- many named rules (for future debugging tooling...I imagine we can have a lighthouse-like page for debugging your service workers and your rules)
- support for indexedDB (under development)
- support for messaging and syncing events (under development)
- quite simple json configuration and easy to start with the basic, or go further for more complex cases
- client api with many possibilities (kinda connecting the browser and sw scopes via events)

## Installing it

It's node program which you may install globally:

```npm install -g dsw```

Or locally:

```npm install dsw --save-dev```

## TL;DL

{'fraction_non_alphanumeric': 0.1149478563151796, 'fraction_numerical': 0.011587485515643106, 'mean_word_length': 5.011142061281337, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 25, 'lorem ipsum': 0, 'www.': 4, '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': '1236591', 'n_tokens_mistral': 1439, 'n_tokens_neox': 1323, 'n_words': 421}