Skip to content

Commit

Permalink
lint: use standard style in readme
Browse files Browse the repository at this point in the history
  • Loading branch information
dougwilson committed Mar 7, 2017
1 parent cce7677 commit 70084f8
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 5 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ before_install:
# Setup Node.js version-specific dependencies
- "test $TRAVIS_NODE_VERSION != '0.6' || npm rm --save-dev istanbul"
- "test $TRAVIS_NODE_VERSION != '0.8' || npm rm --save-dev istanbul"
- "test $(echo $TRAVIS_NODE_VERSION | cut -d'.' -f1) -ge 4 || npm rm --save-dev eslint eslint-config-standard eslint-plugin-promise eslint-plugin-standard"
- "test $(echo $TRAVIS_NODE_VERSION | cut -d'.' -f1) -ge 4 || npm rm --save-dev eslint eslint-config-standard eslint-plugin-markdown eslint-plugin-promise eslint-plugin-standard"
# Update Node.js modules
- "test ! -d node_modules || npm prune"
- "test ! -d node_modules || npm rebuild"
Expand Down
13 changes: 10 additions & 3 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ $ npm install content-disposition

## API

<!-- eslint-disable no-unused-vars -->

```js
var contentDisposition = require('content-disposition')
```
Expand All @@ -26,6 +28,8 @@ Create an attachment `Content-Disposition` header value using the given file nam
if supplied. The `filename` is optional and if no file name is desired, but you
want to specify `options`, set `filename` to `undefined`.

<!-- eslint-disable no-undef -->

```js
res.setHeader('Content-Disposition', contentDisposition('∫ maths.pdf'))
```
Expand Down Expand Up @@ -66,8 +70,10 @@ it). The type is normalized to lower-case.

### contentDisposition.parse(string)

<!-- eslint-disable no-undef, no-unused-vars -->

```js
var disposition = contentDisposition.parse('attachment; filename="EURO rates.txt"; filename*=UTF-8\'\'%e2%82%ac%20rates.txt');
var disposition = contentDisposition.parse('attachment; filename="EURO rates.txt"; filename*=UTF-8\'\'%e2%82%ac%20rates.txt')
```

Parse a `Content-Disposition` header string. This automatically handles extended
Expand All @@ -88,20 +94,21 @@ are shown for the string `'attachment; filename="EURO rates.txt"; filename*=UTF-
```js
var contentDisposition = require('content-disposition')
var destroy = require('destroy')
var fs = require('fs')
var http = require('http')
var onFinished = require('on-finished')

var filePath = '/path/to/public/plans.pdf'

http.createServer(function onRequest(req, res) {
http.createServer(function onRequest (req, res) {
// set headers
res.setHeader('Content-Type', 'application/pdf')
res.setHeader('Content-Disposition', contentDisposition(filePath))

// send file
var stream = fs.createReadStream(filePath)
stream.pipe(res)
onFinished(res, function (err) {
onFinished(res, function () {
destroy(stream)
})
})
Expand Down
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
"devDependencies": {
"eslint": "3.17.1",
"eslint-config-standard": "7.0.0",
"eslint-plugin-markdown": "1.0.0-beta.4",
"eslint-plugin-promise": "3.5.0",
"eslint-plugin-standard": "2.1.1",
"istanbul": "0.4.5",
Expand All @@ -29,7 +30,7 @@
"node": ">= 0.6"
},
"scripts": {
"lint": "eslint .",
"lint": "eslint --plugin markdown --ext js,md .",
"test": "mocha --reporter spec --bail --check-leaks test/",
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --check-leaks test/",
"test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --check-leaks test/"
Expand Down

0 comments on commit 70084f8

Please sign in to comment.