update readme with install instructions

[skip ci]
This commit is contained in:
Nolan Lawson 2018-10-28 16:00:41 -07:00
parent fbe16e845b
commit 99c06472d1

View File

@ -27,20 +27,36 @@ It's also a good pairing with the attachment API in [PouchDB](http://pouchdb.com
Install Install
------ ------
Via npm: ### Using Webpack/Rollup/Babel/TypeScript/etc.
Install via npm:
```bash ```bash
npm install blob-util npm install blob-util
``` ```
ES modules are supported: ES module format:
```js
import * as blobUtil from 'blob-util'
blobUtil.canvasToBlob(canvas, 'image/png').then(/* ... */)
```
Or:
```js ```js
import { canvasToBlob } from 'blob-util' import { canvasToBlob } from 'blob-util'
canvasToBlob(canvas, 'image/png').then(/* ... */) canvasToBlob(canvas, 'image/png').then(/* ... */)
``` ```
Or as a script tag: CommonJS format:
```js
var blobUtil = require('blob-util')
blobUtil.canvasToBlob(canvas, 'image/png').then(/* ... */)
```
### As a script tag
```html ```html
<script src="https://unpkg.com/blob-util/dist/blob-util.min.js"></script> <script src="https://unpkg.com/blob-util/dist/blob-util.min.js"></script>
@ -620,4 +636,4 @@ Or to test locally in your browser of choice:
To build the API docs and insert them in the README: To build the API docs and insert them in the README:
npm run doc npm run doc