From 8fd05ac298072a08f5d984691f156fb94a1d253f Mon Sep 17 00:00:00 2001 From: karissa Date: Thu, 16 Mar 2017 10:58:48 +0100 Subject: add dat.min.js script --- docs/cookbook/browser.md | 28 +++++++++++++++++++++++++--- 1 file changed, 25 insertions(+), 3 deletions(-) (limited to 'docs') diff --git a/docs/cookbook/browser.md b/docs/cookbook/browser.md index b1853e8..62835f6 100644 --- a/docs/cookbook/browser.md +++ b/docs/cookbook/browser.md @@ -8,11 +8,33 @@ Because dat-js uses webrtc, it can only connect to other browser clients. It is OK, now for the goods. -## Creating a dat +## Install -```js +Embed the following script [dat.min.js](https://raw.githubusercontent.com/datproject/dat-js/master/dat.min.js) on the page: +``` + +``` +This provides a `Dat` prototype on the `window` object. + +### Browserify + +Or use Node.js in the browser with [browserify](http://github.com/substack/node-browserify), which lets you use node.js style require() to organize your browser code using npm. + +``` +npm install dat-js +``` + +Then use `dat-js` like this: + +``` var Dat = require('dat-js') +``` +## Quick Examples + +### Sharing data + +```js var dat = Dat() dat.add(function (repo) { var writer = repo.archive.createFileWriteStream('hello.txt') @@ -21,7 +43,7 @@ dat.add(function (repo) { }) ``` -## Downloading data +### Downloading data ```js var Dat = require('dat-js') -- cgit v1.2.3