# dat-archive-web

> DatArchive implementation for borwsers that uses dat-gateway

Latest version **2.0.5** (published 2019-08-06) · MIT license · 0 weekly downloads

## Install

```sh
npm install dat-archive-web
pnpm add dat-archive-web
yarn add dat-archive-web
bun add dat-archive-web
```

## 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 | 2.0.5 |
| Published | 2019-08-06 |
| First published | 2018-04-22 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 8 |
| Unpacked size | 1.5 MB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 29 |
| Author | rangermauve |
| Maintainers | rangermauve |
| Keywords | dat, archive, web, beaker |

## Links

- npm: https://www.npmjs.com/package/dat-archive-web
- Repository: https://github.com/RangerMauve/dat-archive-web
- Homepage: https://github.com/RangerMauve/dat-archive-web#readme
- Issues: https://github.com/RangerMauve/dat-archive-web/issues
- npm.io page: https://npm.io/package/dat-archive-web

## Dependencies (8)

- [dat-js](https://npm.io/package/dat-js.md) ^8.0.0
- [hex-to-32](https://npm.io/package/hex-to-32.md) ^1.0.0
- [url-parse](https://npm.io/package/url-parse.md) ^1.4.0
- [concat-stream](https://npm.io/package/concat-stream.md) ^1.6.2
- [pauls-dat-api](https://npm.io/package/pauls-dat-api.md) ^7.0.1
- [dom-event-target](https://npm.io/package/dom-event-target.md) ^1.0.0
- [node-dat-archive](https://npm.io/package/node-dat-archive.md) ^2.0.1
- [beaker-error-constants](https://npm.io/package/beaker-error-constants.md) ^1.4.0

## Alternatives

- [@regle/core](https://npm.io/package/@regle/core.md) — 47.0K weekly downloads
- [typeof-arguments](https://npm.io/package/typeof-arguments.md) — 12.5K weekly downloads
- [@lokalise/projects-engine-contracts](https://npm.io/package/@lokalise/projects-engine-contracts.md) — 978 weekly downloads
- [@osjwnpm/nam-laboriosam-quibusdam](https://npm.io/package/@osjwnpm/nam-laboriosam-quibusdam.md) — 70 weekly downloads
- [@oridune/validator](https://npm.io/package/@oridune/validator.md) — 16 weekly downloads

## Recent versions

- 2.0.5 (latest) — 2019-08-06
- 2.0.4 — 2019-07-07
- 2.0.3 — 2019-07-05
- 2.0.2 — 2019-07-01
- 2.0.1 — 2019-04-24
- 2.0.0 — 2019-04-24
- 1.1.0 — 2018-05-07
- 1.0.0 — 2018-04-22

## README

# dat-archive-web
DatArchive implementation for browsers using [dat-js](https://github.com/datproject/dat-js#readme)

```
npm install --save dat-archive-web
```

Or

```html
<script src="//unpkg.com/dat-archive-web/bundle.js"></script>
```

## Example

```javascript
// After including the bundle in a script tag, or requiring it

const archive = new DatArchive('dat://87ed2e3b160f261a032af03921a3bd09227d0a4cde73466c17114816cae43336')

// Subscribe to network events
archive.addEventListener("download", ({bytes}) => console.log(`Downloaded ${bytes} bytes`))

// Subscribe to file events
const emitter = archive.watch("/path/to/watch")
emitter.addEventListener("change", ({path}) => console.log(`file at path: ${path} changed!`))

archive.readFile('/index.html')
  .then((html) => console.log(html))
```

## API

Implements the same interface as [DatArchive](https://beakerbrowser.com/docs/apis/dat.html) in Beaker with the following exceptions:

- `archive.diff()`, `archive.commit()`, and `archive.revert()` are not supported
- `DatArchive.selectArchive()` doesn't do filtering and looks crappy. Uses [window.prompt](https://developer.mozilla.org/en-US/docs/Web/API/Window/prompt) API
- `DatArchive.resolveName()` doesn't work and DNS based urls aren't supported. Waiting for dat-js support

# Features

- [x] Support most DatArchive methods
- [x] Public bridges used to replicate with non-browser network
- [x] Detect HTTP/HTTPS in gateway URL
- [x] Data stored in memory by default, unless it was created locally.
- [] Functional DatDNS support (via gateway)
- [x] Full support for versions (Needs testing, but code is there)
- [x] Forking (without preserving change feed)
- [x] DatArchive.selectArchive() Really rudimentary

## Development

- This project uses the `standard` code style
- Run the example in node with `npm install && npm run example`
- Build the browserify bundle with `npm run build`

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