Note: This is being replaced by the Dat SDK
DatArchive implementation for browsers using dat-js
npm install --save dat-archive-web
Or
<script src="https://github.com/RangerMauve/dat-archive-web/raw/master//unpkg.com/dat-archive-web/bundle.js"></script>
// 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))
Implements the same interface as DatArchive in Beaker with the following exceptions:
archive.diff()
, archive.commit()
, and archive.revert()
are not supportedDatArchive.selectArchive()
doesn't do filtering and looks crappy. Uses window.prompt APIDatArchive.resolveName()
doesn't work and DNS based urls aren't supported. Waiting for dat-js supportstandard
code stylenpm install && npm run example
npm run build