mirror of https://github.com/jumpserver/jumpserver
remove node module from repo
parent
4e0cd4cddf
commit
795183c7ab
|
@ -1 +0,0 @@
|
|||
../node-tail/bin/node-tail
|
File diff suppressed because it is too large
Load Diff
|
@ -1,22 +0,0 @@
|
|||
(The MIT License)
|
||||
|
||||
Copyright (c) 2009-2014 TJ Holowaychuk <tj@vision-media.ca>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
'Software'), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@ -1,135 +0,0 @@
|
|||
[![Express Logo](https://i.cloudup.com/zfY6lL7eFa-3000x3000.png)](http://expressjs.com/)
|
||||
|
||||
Fast, unopinionated, minimalist web framework for [node](http://nodejs.org).
|
||||
|
||||
[![NPM Version][npm-image]][npm-url]
|
||||
[![NPM Downloads][downloads-image]][downloads-url]
|
||||
[![Build Status][travis-image]][travis-url]
|
||||
[![Test Coverage][coveralls-image]][coveralls-url]
|
||||
|
||||
```js
|
||||
var express = require('express')
|
||||
var app = express()
|
||||
|
||||
app.get('/', function (req, res) {
|
||||
res.send('Hello World')
|
||||
})
|
||||
|
||||
app.listen(3000)
|
||||
```
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
$ npm install express
|
||||
```
|
||||
|
||||
## Features
|
||||
|
||||
* Robust routing
|
||||
* Focus on high performance
|
||||
* Super-high test coverage
|
||||
* HTTP helpers (redirection, caching, etc)
|
||||
* View system supporting 14+ template engines
|
||||
* Content negotiation
|
||||
* Executable for generating applications quickly
|
||||
|
||||
## Docs & Community
|
||||
|
||||
* [Website and Documentation](http://expressjs.com/) - [[website repo](https://github.com/strongloop/expressjs.com)]
|
||||
* [#express](https://webchat.freenode.net/?channels=express) on freenode IRC
|
||||
* [Github Organization](https://github.com/expressjs) for Official Middleware & Modules
|
||||
* Visit the [Wiki](https://github.com/strongloop/express/wiki)
|
||||
* [Google Group](https://groups.google.com/group/express-js) for discussion
|
||||
* [Русскоязычная документация](http://jsman.ru/express/)
|
||||
* [한국어 문서](http://expressjs.kr) - [[website repo](https://github.com/Hanul/expressjs.kr)]
|
||||
|
||||
**PROTIP** Be sure to read [Migrating from 3.x to 4.x](https://github.com/strongloop/express/wiki/Migrating-from-3.x-to-4.x) as well as [New features in 4.x](https://github.com/strongloop/express/wiki/New-features-in-4.x).
|
||||
|
||||
## Quick Start
|
||||
|
||||
The quickest way to get started with express is to utilize the executable [`express(1)`](https://github.com/expressjs/generator) to generate an application as shown below:
|
||||
|
||||
Install the executable. The executable's major version will match Express's:
|
||||
|
||||
```bash
|
||||
$ npm install -g express-generator@4
|
||||
```
|
||||
|
||||
Create the app:
|
||||
|
||||
```bash
|
||||
$ express /tmp/foo && cd /tmp/foo
|
||||
```
|
||||
|
||||
Install dependencies:
|
||||
|
||||
```bash
|
||||
$ npm install
|
||||
```
|
||||
|
||||
Start the server:
|
||||
|
||||
```bash
|
||||
$ npm start
|
||||
```
|
||||
|
||||
## Philosophy
|
||||
|
||||
The Express philosophy is to provide small, robust tooling for HTTP servers, making
|
||||
it a great solution for single page applications, web sites, hybrids, or public
|
||||
HTTP APIs.
|
||||
|
||||
Express does not force you to use any specific ORM or template engine. With support for over
|
||||
14 template engines via [Consolidate.js](https://github.com/tj/consolidate.js),
|
||||
you can quickly craft your perfect framework.
|
||||
|
||||
## Examples
|
||||
|
||||
To view the examples, clone the Express repo and install the dependancies:
|
||||
|
||||
```bash
|
||||
$ git clone git://github.com/strongloop/express.git --depth 1
|
||||
$ cd express
|
||||
$ npm install
|
||||
```
|
||||
|
||||
Then run whichever example you want:
|
||||
|
||||
```bash
|
||||
$ node examples/content-negotiation
|
||||
```
|
||||
|
||||
## Tests
|
||||
|
||||
To run the test suite, first install the dependancies, then run `npm test`:
|
||||
|
||||
```bash
|
||||
$ npm install
|
||||
$ npm test
|
||||
```
|
||||
|
||||
## People
|
||||
|
||||
The original author of Express is [TJ Holowaychuk](https://github.com/tj) [![TJ's Gratipay][gratipay-image-visionmedia]][gratipay-url-visionmedia]
|
||||
|
||||
The current lead maintainer is [Douglas Christopher Wilson](https://github.com/dougwilson) [![Doug's Gratipay][gratipay-image-dougwilson]][gratipay-url-dougwilson]
|
||||
|
||||
[List of all contributors](https://github.com/strongloop/express/graphs/contributors)
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE)
|
||||
|
||||
[npm-image]: https://img.shields.io/npm/v/express.svg?style=flat
|
||||
[npm-url]: https://npmjs.org/package/express
|
||||
[downloads-image]: https://img.shields.io/npm/dm/express.svg?style=flat
|
||||
[downloads-url]: https://npmjs.org/package/express
|
||||
[travis-image]: https://img.shields.io/travis/strongloop/express.svg?style=flat
|
||||
[travis-url]: https://travis-ci.org/strongloop/express
|
||||
[coveralls-image]: https://img.shields.io/coveralls/strongloop/express.svg?style=flat
|
||||
[coveralls-url]: https://coveralls.io/r/strongloop/express?branch=master
|
||||
[gratipay-image-visionmedia]: https://img.shields.io/gratipay/visionmedia.svg?style=flat
|
||||
[gratipay-url-visionmedia]: https://gratipay.com/visionmedia/
|
||||
[gratipay-image-dougwilson]: https://img.shields.io/gratipay/dougwilson.svg?style=flat
|
||||
[gratipay-url-dougwilson]: https://gratipay.com/dougwilson/
|
|
@ -1,2 +0,0 @@
|
|||
|
||||
module.exports = require('./lib/express');
|
|
@ -1,74 +0,0 @@
|
|||
1.1.4 / 2014-12-10
|
||||
==================
|
||||
|
||||
* deps: mime-types@~2.0.4
|
||||
- deps: mime-db@~1.3.0
|
||||
|
||||
1.1.3 / 2014-11-09
|
||||
==================
|
||||
|
||||
* deps: mime-types@~2.0.3
|
||||
- deps: mime-db@~1.2.0
|
||||
|
||||
1.1.2 / 2014-10-14
|
||||
==================
|
||||
|
||||
* deps: negotiator@0.4.9
|
||||
- Fix error when media type has invalid parameter
|
||||
|
||||
1.1.1 / 2014-09-28
|
||||
==================
|
||||
|
||||
* deps: mime-types@~2.0.2
|
||||
- deps: mime-db@~1.1.0
|
||||
* deps: negotiator@0.4.8
|
||||
- Fix all negotiations to be case-insensitive
|
||||
- Stable sort preferences of same quality according to client order
|
||||
|
||||
1.1.0 / 2014-09-02
|
||||
==================
|
||||
|
||||
* update `mime-types`
|
||||
|
||||
1.0.7 / 2014-07-04
|
||||
==================
|
||||
|
||||
* Fix wrong type returned from `type` when match after unknown extension
|
||||
|
||||
1.0.6 / 2014-06-24
|
||||
==================
|
||||
|
||||
* deps: negotiator@0.4.7
|
||||
|
||||
1.0.5 / 2014-06-20
|
||||
==================
|
||||
|
||||
* fix crash when unknown extension given
|
||||
|
||||
1.0.4 / 2014-06-19
|
||||
==================
|
||||
|
||||
* use `mime-types`
|
||||
|
||||
1.0.3 / 2014-06-11
|
||||
==================
|
||||
|
||||
* deps: negotiator@0.4.6
|
||||
- Order by specificity when quality is the same
|
||||
|
||||
1.0.2 / 2014-05-29
|
||||
==================
|
||||
|
||||
* Fix interpretation when header not in request
|
||||
* deps: pin negotiator@0.4.5
|
||||
|
||||
1.0.1 / 2014-01-18
|
||||
==================
|
||||
|
||||
* Identity encoding isn't always acceptable
|
||||
* deps: negotiator@~0.4.0
|
||||
|
||||
1.0.0 / 2013-12-27
|
||||
==================
|
||||
|
||||
* Genesis
|
|
@ -1,22 +0,0 @@
|
|||
(The MIT License)
|
||||
|
||||
Copyright (c) 2014 Jonathan Ong <me@jongleberry.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
'Software'), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@ -1,94 +0,0 @@
|
|||
# accepts
|
||||
|
||||
[![NPM Version][npm-image]][npm-url]
|
||||
[![NPM Downloads][downloads-image]][downloads-url]
|
||||
[![Node.js Version][node-version-image]][node-version-url]
|
||||
[![Build Status][travis-image]][travis-url]
|
||||
[![Test Coverage][coveralls-image]][coveralls-url]
|
||||
|
||||
Higher level content negotation based on [negotiator](https://github.com/federomero/negotiator). Extracted from [koa](https://github.com/koajs/koa) for general use.
|
||||
|
||||
In addition to negotatior, it allows:
|
||||
|
||||
- Allows types as an array or arguments list, ie `(['text/html', 'application/json'])` as well as `('text/html', 'application/json')`.
|
||||
- Allows type shorthands such as `json`.
|
||||
- Returns `false` when no types match
|
||||
- Treats non-existent headers as `*`
|
||||
|
||||
## API
|
||||
|
||||
### var accept = new Accepts(req)
|
||||
|
||||
```js
|
||||
var accepts = require('accepts')
|
||||
|
||||
http.createServer(function (req, res) {
|
||||
var accept = accepts(req)
|
||||
})
|
||||
```
|
||||
|
||||
### accept\[property\]\(\)
|
||||
|
||||
Returns all the explicitly accepted content property as an array in descending priority.
|
||||
|
||||
- `accept.types()`
|
||||
- `accept.encodings()`
|
||||
- `accept.charsets()`
|
||||
- `accept.languages()`
|
||||
|
||||
They are also aliased in singular form such as `accept.type()`. `accept.languages()` is also aliased as `accept.langs()`, etc.
|
||||
|
||||
Note: you should almost never do this in a real app as it defeats the purpose of content negotiation.
|
||||
|
||||
Example:
|
||||
|
||||
```js
|
||||
// in Google Chrome
|
||||
var encodings = accept.encodings() // -> ['sdch', 'gzip', 'deflate']
|
||||
```
|
||||
|
||||
Since you probably don't support `sdch`, you should just supply the encodings you support:
|
||||
|
||||
```js
|
||||
var encoding = accept.encodings('gzip', 'deflate') // -> 'gzip', probably
|
||||
```
|
||||
|
||||
### accept\[property\]\(values, ...\)
|
||||
|
||||
You can either have `values` be an array or have an argument list of values.
|
||||
|
||||
If the client does not accept any `values`, `false` will be returned.
|
||||
If the client accepts any `values`, the preferred `value` will be return.
|
||||
|
||||
For `accept.types()`, shorthand mime types are allowed.
|
||||
|
||||
Example:
|
||||
|
||||
```js
|
||||
// req.headers.accept = 'application/json'
|
||||
|
||||
accept.types('json') // -> 'json'
|
||||
accept.types('html', 'json') // -> 'json'
|
||||
accept.types('html') // -> false
|
||||
|
||||
// req.headers.accept = ''
|
||||
// which is equivalent to `*`
|
||||
|
||||
accept.types() // -> [], no explicit types
|
||||
accept.types('text/html', 'text/json') // -> 'text/html', since it was first
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE)
|
||||
|
||||
[npm-image]: https://img.shields.io/npm/v/accepts.svg?style=flat
|
||||
[npm-url]: https://npmjs.org/package/accepts
|
||||
[node-version-image]: https://img.shields.io/node/v/accepts.svg?style=flat
|
||||
[node-version-url]: http://nodejs.org/download/
|
||||
[travis-image]: https://img.shields.io/travis/jshttp/accepts.svg?style=flat
|
||||
[travis-url]: https://travis-ci.org/jshttp/accepts
|
||||
[coveralls-image]: https://img.shields.io/coveralls/jshttp/accepts.svg?style=flat
|
||||
[coveralls-url]: https://coveralls.io/r/jshttp/accepts
|
||||
[downloads-image]: https://img.shields.io/npm/dm/accepts.svg?style=flat
|
||||
[downloads-url]: https://npmjs.org/package/accepts
|
|
@ -1,160 +0,0 @@
|
|||
var Negotiator = require('negotiator')
|
||||
var mime = require('mime-types')
|
||||
|
||||
var slice = [].slice
|
||||
|
||||
module.exports = Accepts
|
||||
|
||||
function Accepts(req) {
|
||||
if (!(this instanceof Accepts))
|
||||
return new Accepts(req)
|
||||
|
||||
this.headers = req.headers
|
||||
this.negotiator = Negotiator(req)
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the given `type(s)` is acceptable, returning
|
||||
* the best match when true, otherwise `undefined`, in which
|
||||
* case you should respond with 406 "Not Acceptable".
|
||||
*
|
||||
* The `type` value may be a single mime type string
|
||||
* such as "application/json", the extension name
|
||||
* such as "json" or an array `["json", "html", "text/plain"]`. When a list
|
||||
* or array is given the _best_ match, if any is returned.
|
||||
*
|
||||
* Examples:
|
||||
*
|
||||
* // Accept: text/html
|
||||
* this.types('html');
|
||||
* // => "html"
|
||||
*
|
||||
* // Accept: text/*, application/json
|
||||
* this.types('html');
|
||||
* // => "html"
|
||||
* this.types('text/html');
|
||||
* // => "text/html"
|
||||
* this.types('json', 'text');
|
||||
* // => "json"
|
||||
* this.types('application/json');
|
||||
* // => "application/json"
|
||||
*
|
||||
* // Accept: text/*, application/json
|
||||
* this.types('image/png');
|
||||
* this.types('png');
|
||||
* // => undefined
|
||||
*
|
||||
* // Accept: text/*;q=.5, application/json
|
||||
* this.types(['html', 'json']);
|
||||
* this.types('html', 'json');
|
||||
* // => "json"
|
||||
*
|
||||
* @param {String|Array} type(s)...
|
||||
* @return {String|Array|Boolean}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Accepts.prototype.type =
|
||||
Accepts.prototype.types = function (types) {
|
||||
if (!Array.isArray(types)) types = slice.call(arguments);
|
||||
var n = this.negotiator;
|
||||
if (!types.length) return n.mediaTypes();
|
||||
if (!this.headers.accept) return types[0];
|
||||
var mimes = types.map(extToMime);
|
||||
var accepts = n.mediaTypes(mimes.filter(validMime));
|
||||
var first = accepts[0];
|
||||
if (!first) return false;
|
||||
return types[mimes.indexOf(first)];
|
||||
}
|
||||
|
||||
/**
|
||||
* Return accepted encodings or best fit based on `encodings`.
|
||||
*
|
||||
* Given `Accept-Encoding: gzip, deflate`
|
||||
* an array sorted by quality is returned:
|
||||
*
|
||||
* ['gzip', 'deflate']
|
||||
*
|
||||
* @param {String|Array} encoding(s)...
|
||||
* @return {String|Array}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Accepts.prototype.encoding =
|
||||
Accepts.prototype.encodings = function (encodings) {
|
||||
if (!Array.isArray(encodings)) encodings = slice.call(arguments);
|
||||
var n = this.negotiator;
|
||||
if (!encodings.length) return n.encodings();
|
||||
return n.encodings(encodings)[0] || false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return accepted charsets or best fit based on `charsets`.
|
||||
*
|
||||
* Given `Accept-Charset: utf-8, iso-8859-1;q=0.2, utf-7;q=0.5`
|
||||
* an array sorted by quality is returned:
|
||||
*
|
||||
* ['utf-8', 'utf-7', 'iso-8859-1']
|
||||
*
|
||||
* @param {String|Array} charset(s)...
|
||||
* @return {String|Array}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Accepts.prototype.charset =
|
||||
Accepts.prototype.charsets = function (charsets) {
|
||||
if (!Array.isArray(charsets)) charsets = [].slice.call(arguments);
|
||||
var n = this.negotiator;
|
||||
if (!charsets.length) return n.charsets();
|
||||
if (!this.headers['accept-charset']) return charsets[0];
|
||||
return n.charsets(charsets)[0] || false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return accepted languages or best fit based on `langs`.
|
||||
*
|
||||
* Given `Accept-Language: en;q=0.8, es, pt`
|
||||
* an array sorted by quality is returned:
|
||||
*
|
||||
* ['es', 'pt', 'en']
|
||||
*
|
||||
* @param {String|Array} lang(s)...
|
||||
* @return {Array|String}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
Accepts.prototype.lang =
|
||||
Accepts.prototype.langs =
|
||||
Accepts.prototype.language =
|
||||
Accepts.prototype.languages = function (langs) {
|
||||
if (!Array.isArray(langs)) langs = slice.call(arguments);
|
||||
var n = this.negotiator;
|
||||
if (!langs.length) return n.languages();
|
||||
if (!this.headers['accept-language']) return langs[0];
|
||||
return n.languages(langs)[0] || false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert extnames to mime.
|
||||
*
|
||||
* @param {String} type
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function extToMime(type) {
|
||||
if (~type.indexOf('/')) return type;
|
||||
return mime.lookup(type);
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if mime is valid.
|
||||
*
|
||||
* @param {String} type
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function validMime(type) {
|
||||
return typeof type === 'string';
|
||||
}
|
72
websocket/node_modules/express/node_modules/accepts/node_modules/mime-types/HISTORY.md
generated
vendored
72
websocket/node_modules/express/node_modules/accepts/node_modules/mime-types/HISTORY.md
generated
vendored
|
@ -1,72 +0,0 @@
|
|||
2.0.7 / 2014-12-30
|
||||
==================
|
||||
|
||||
* deps: mime-db@~1.5.0
|
||||
- Add new mime types
|
||||
- Fix various invalid MIME type entries
|
||||
|
||||
2.0.6 / 2014-12-30
|
||||
==================
|
||||
|
||||
* deps: mime-db@~1.4.0
|
||||
- Add new mime types
|
||||
- Fix various invalid MIME type entries
|
||||
- Remove example template MIME types
|
||||
|
||||
2.0.5 / 2014-12-29
|
||||
==================
|
||||
|
||||
* deps: mime-db@~1.3.1
|
||||
- Fix missing extensions
|
||||
|
||||
2.0.4 / 2014-12-10
|
||||
==================
|
||||
|
||||
* deps: mime-db@~1.3.0
|
||||
- Add new mime types
|
||||
|
||||
2.0.3 / 2014-11-09
|
||||
==================
|
||||
|
||||
* deps: mime-db@~1.2.0
|
||||
- Add new mime types
|
||||
|
||||
2.0.2 / 2014-09-28
|
||||
==================
|
||||
|
||||
* deps: mime-db@~1.1.0
|
||||
- Add new mime types
|
||||
- Add additional compressible
|
||||
- Update charsets
|
||||
|
||||
2.0.1 / 2014-09-07
|
||||
==================
|
||||
|
||||
* Support Node.js 0.6
|
||||
|
||||
2.0.0 / 2014-09-02
|
||||
==================
|
||||
|
||||
* Use `mime-db`
|
||||
* Remove `.define()`
|
||||
|
||||
1.0.2 / 2014-08-04
|
||||
==================
|
||||
|
||||
* Set charset=utf-8 for `text/javascript`
|
||||
|
||||
1.0.1 / 2014-06-24
|
||||
==================
|
||||
|
||||
* Add `text/jsx` type
|
||||
|
||||
1.0.0 / 2014-05-12
|
||||
==================
|
||||
|
||||
* Return `false` for unknown types
|
||||
* Set charset=utf-8 for `application/json`
|
||||
|
||||
0.1.0 / 2014-05-02
|
||||
==================
|
||||
|
||||
* Initial release
|
22
websocket/node_modules/express/node_modules/accepts/node_modules/mime-types/LICENSE
generated
vendored
22
websocket/node_modules/express/node_modules/accepts/node_modules/mime-types/LICENSE
generated
vendored
|
@ -1,22 +0,0 @@
|
|||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 Jonathan Ong me@jongleberry.com
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
99
websocket/node_modules/express/node_modules/accepts/node_modules/mime-types/README.md
generated
vendored
99
websocket/node_modules/express/node_modules/accepts/node_modules/mime-types/README.md
generated
vendored
|
@ -1,99 +0,0 @@
|
|||
# mime-types
|
||||
|
||||
[![NPM Version][npm-image]][npm-url]
|
||||
[![NPM Downloads][downloads-image]][downloads-url]
|
||||
[![Node.js Version][node-version-image]][node-version-url]
|
||||
[![Build Status][travis-image]][travis-url]
|
||||
[![Test Coverage][coveralls-image]][coveralls-url]
|
||||
|
||||
The ultimate javascript content-type utility.
|
||||
|
||||
Similar to [node-mime](https://github.com/broofa/node-mime), except:
|
||||
|
||||
- __No fallbacks.__ Instead of naively returning the first available type, `mime-types` simply returns `false`,
|
||||
so do `var type = mime.lookup('unrecognized') || 'application/octet-stream'`.
|
||||
- No `new Mime()` business, so you could do `var lookup = require('mime-types').lookup`.
|
||||
- Additional mime types are added such as jade and stylus via [mime-db](https://github.com/jshttp/mime-db)
|
||||
- No `.define()` functionality
|
||||
|
||||
Otherwise, the API is compatible.
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
$ npm install mime-types
|
||||
```
|
||||
|
||||
## Adding Types
|
||||
|
||||
All mime types are based on [mime-db](https://github.com/jshttp/mime-db),
|
||||
so open a PR there if you'd like to add mime types.
|
||||
|
||||
## API
|
||||
|
||||
```js
|
||||
var mime = require('mime-types')
|
||||
```
|
||||
|
||||
All functions return `false` if input is invalid or not found.
|
||||
|
||||
### mime.lookup(path)
|
||||
|
||||
Lookup the content-type associated with a file.
|
||||
|
||||
```js
|
||||
mime.lookup('json') // 'application/json'
|
||||
mime.lookup('.md') // 'text/x-markdown'
|
||||
mime.lookup('file.html') // 'text/html'
|
||||
mime.lookup('folder/file.js') // 'application/javascript'
|
||||
|
||||
mime.lookup('cats') // false
|
||||
```
|
||||
|
||||
### mime.contentType(type)
|
||||
|
||||
Create a full content-type header given a content-type or extension.
|
||||
|
||||
```js
|
||||
mime.contentType('markdown') // 'text/x-markdown; charset=utf-8'
|
||||
mime.contentType('file.json') // 'application/json; charset=utf-8'
|
||||
```
|
||||
|
||||
### mime.extension(type)
|
||||
|
||||
Get the default extension for a content-type.
|
||||
|
||||
```js
|
||||
mime.extension('application/octet-stream') // 'bin'
|
||||
```
|
||||
|
||||
### mime.charset(type)
|
||||
|
||||
Lookup the implied default charset of a content-type.
|
||||
|
||||
```js
|
||||
mime.charset('text/x-markdown') // 'UTF-8'
|
||||
```
|
||||
|
||||
### var type = mime.types[extension]
|
||||
|
||||
A map of content-types by extension.
|
||||
|
||||
### [extensions...] = mime.extensions[type]
|
||||
|
||||
A map of extensions by content-type.
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE)
|
||||
|
||||
[npm-image]: https://img.shields.io/npm/v/mime-types.svg?style=flat
|
||||
[npm-url]: https://npmjs.org/package/mime-types
|
||||
[node-version-image]: https://img.shields.io/badge/node.js-%3E%3D_0.6-brightgreen.svg?style=flat
|
||||
[node-version-url]: http://nodejs.org/download/
|
||||
[travis-image]: https://img.shields.io/travis/jshttp/mime-types.svg?style=flat
|
||||
[travis-url]: https://travis-ci.org/jshttp/mime-types
|
||||
[coveralls-image]: https://img.shields.io/coveralls/jshttp/mime-types.svg?style=flat
|
||||
[coveralls-url]: https://coveralls.io/r/jshttp/mime-types
|
||||
[downloads-image]: https://img.shields.io/npm/dm/mime-types.svg?style=flat
|
||||
[downloads-url]: https://npmjs.org/package/mime-types
|
63
websocket/node_modules/express/node_modules/accepts/node_modules/mime-types/index.js
generated
vendored
63
websocket/node_modules/express/node_modules/accepts/node_modules/mime-types/index.js
generated
vendored
|
@ -1,63 +0,0 @@
|
|||
|
||||
var db = require('mime-db')
|
||||
|
||||
// types[extension] = type
|
||||
exports.types = Object.create(null)
|
||||
// extensions[type] = [extensions]
|
||||
exports.extensions = Object.create(null)
|
||||
|
||||
Object.keys(db).forEach(function (name) {
|
||||
var mime = db[name]
|
||||
var exts = mime.extensions
|
||||
if (!exts || !exts.length) return
|
||||
exports.extensions[name] = exts
|
||||
exts.forEach(function (ext) {
|
||||
exports.types[ext] = name
|
||||
})
|
||||
})
|
||||
|
||||
exports.lookup = function (string) {
|
||||
if (!string || typeof string !== "string") return false
|
||||
// remove any leading paths, though we should just use path.basename
|
||||
string = string.replace(/.*[\.\/\\]/, '').toLowerCase()
|
||||
if (!string) return false
|
||||
return exports.types[string] || false
|
||||
}
|
||||
|
||||
exports.extension = function (type) {
|
||||
if (!type || typeof type !== "string") return false
|
||||
// to do: use media-typer
|
||||
type = type.match(/^\s*([^;\s]*)(?:;|\s|$)/)
|
||||
if (!type) return false
|
||||
var exts = exports.extensions[type[1].toLowerCase()]
|
||||
if (!exts || !exts.length) return false
|
||||
return exts[0]
|
||||
}
|
||||
|
||||
// type has to be an exact mime type
|
||||
exports.charset = function (type) {
|
||||
var mime = db[type]
|
||||
if (mime && mime.charset) return mime.charset
|
||||
|
||||
// default text/* to utf-8
|
||||
if (/^text\//.test(type)) return 'UTF-8'
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
// backwards compatibility
|
||||
exports.charsets = {
|
||||
lookup: exports.charset
|
||||
}
|
||||
|
||||
// to do: maybe use set-type module or something
|
||||
exports.contentType = function (type) {
|
||||
if (!type || typeof type !== "string") return false
|
||||
if (!~type.indexOf('/')) type = exports.lookup(type)
|
||||
if (!type) return false
|
||||
if (!~type.indexOf('charset')) {
|
||||
var charset = exports.charset(type)
|
||||
if (charset) type += '; charset=' + charset.toLowerCase()
|
||||
}
|
||||
return type
|
||||
}
|
|
@ -1,142 +0,0 @@
|
|||
1.5.0 / 2014-12-30
|
||||
==================
|
||||
|
||||
* Add `application/vnd.oracle.resource+json`
|
||||
* Fix various invalid MIME type entries
|
||||
- `application/mbox+xml`
|
||||
- `application/oscp-response`
|
||||
- `application/vwg-multiplexed`
|
||||
- `audio/g721`
|
||||
|
||||
1.4.0 / 2014-12-21
|
||||
==================
|
||||
|
||||
* Add `application/vnd.ims.imsccv1p2`
|
||||
* Fix various invalid MIME type entries
|
||||
- `application/vnd-acucobol`
|
||||
- `application/vnd-curl`
|
||||
- `application/vnd-dart`
|
||||
- `application/vnd-dxr`
|
||||
- `application/vnd-fdf`
|
||||
- `application/vnd-mif`
|
||||
- `application/vnd-sema`
|
||||
- `application/vnd-wap-wmlc`
|
||||
- `application/vnd.adobe.flash-movie`
|
||||
- `application/vnd.dece-zip`
|
||||
- `application/vnd.dvb_service`
|
||||
- `application/vnd.micrografx-igx`
|
||||
- `application/vnd.sealed-doc`
|
||||
- `application/vnd.sealed-eml`
|
||||
- `application/vnd.sealed-mht`
|
||||
- `application/vnd.sealed-ppt`
|
||||
- `application/vnd.sealed-tiff`
|
||||
- `application/vnd.sealed-xls`
|
||||
- `application/vnd.sealedmedia.softseal-html`
|
||||
- `application/vnd.sealedmedia.softseal-pdf`
|
||||
- `application/vnd.wap-slc`
|
||||
- `application/vnd.wap-wbxml`
|
||||
- `audio/vnd.sealedmedia.softseal-mpeg`
|
||||
- `image/vnd-djvu`
|
||||
- `image/vnd-svf`
|
||||
- `image/vnd-wap-wbmp`
|
||||
- `image/vnd.sealed-png`
|
||||
- `image/vnd.sealedmedia.softseal-gif`
|
||||
- `image/vnd.sealedmedia.softseal-jpg`
|
||||
- `model/vnd-dwf`
|
||||
- `model/vnd.parasolid.transmit-binary`
|
||||
- `model/vnd.parasolid.transmit-text`
|
||||
- `text/vnd-a`
|
||||
- `text/vnd-curl`
|
||||
- `text/vnd.wap-wml`
|
||||
* Remove example template MIME types
|
||||
- `application/example`
|
||||
- `audio/example`
|
||||
- `image/example`
|
||||
- `message/example`
|
||||
- `model/example`
|
||||
- `multipart/example`
|
||||
- `text/example`
|
||||
- `video/example`
|
||||
|
||||
1.3.1 / 2014-12-16
|
||||
==================
|
||||
|
||||
* Fix missing extensions
|
||||
- `application/json5`
|
||||
- `text/hjson`
|
||||
|
||||
1.3.0 / 2014-12-07
|
||||
==================
|
||||
|
||||
* Add `application/a2l`
|
||||
* Add `application/aml`
|
||||
* Add `application/atfx`
|
||||
* Add `application/atxml`
|
||||
* Add `application/cdfx+xml`
|
||||
* Add `application/dii`
|
||||
* Add `application/json5`
|
||||
* Add `application/lxf`
|
||||
* Add `application/mf4`
|
||||
* Add `application/vnd.apache.thrift.compact`
|
||||
* Add `application/vnd.apache.thrift.json`
|
||||
* Add `application/vnd.coffeescript`
|
||||
* Add `application/vnd.enphase.envoy`
|
||||
* Add `application/vnd.ims.imsccv1p1`
|
||||
* Add `text/csv-schema`
|
||||
* Add `text/hjson`
|
||||
* Add `text/markdown`
|
||||
* Add `text/yaml`
|
||||
|
||||
1.2.0 / 2014-11-09
|
||||
==================
|
||||
|
||||
* Add `application/cea`
|
||||
* Add `application/dit`
|
||||
* Add `application/vnd.gov.sk.e-form+zip`
|
||||
* Add `application/vnd.tmd.mediaflex.api+xml`
|
||||
* Type `application/epub+zip` is now IANA-registered
|
||||
|
||||
1.1.2 / 2014-10-23
|
||||
==================
|
||||
|
||||
* Rebuild database for `application/x-www-form-urlencoded` change
|
||||
|
||||
1.1.1 / 2014-10-20
|
||||
==================
|
||||
|
||||
* Mark `application/x-www-form-urlencoded` as compressible.
|
||||
|
||||
1.1.0 / 2014-09-28
|
||||
==================
|
||||
|
||||
* Add `application/font-woff2`
|
||||
|
||||
1.0.3 / 2014-09-25
|
||||
==================
|
||||
|
||||
* Fix engine requirement in package
|
||||
|
||||
1.0.2 / 2014-09-25
|
||||
==================
|
||||
|
||||
* Add `application/coap-group+json`
|
||||
* Add `application/dcd`
|
||||
* Add `application/vnd.apache.thrift.binary`
|
||||
* Add `image/vnd.tencent.tap`
|
||||
* Mark all JSON-derived types as compressible
|
||||
* Update `text/vtt` data
|
||||
|
||||
1.0.1 / 2014-08-30
|
||||
==================
|
||||
|
||||
* Fix extension ordering
|
||||
|
||||
1.0.0 / 2014-08-30
|
||||
==================
|
||||
|
||||
* Add `application/atf`
|
||||
* Add `application/merge-patch+json`
|
||||
* Add `multipart/x-mixed-replace`
|
||||
* Add `source: 'apache'` metadata
|
||||
* Add `source: 'iana'` metadata
|
||||
* Remove badly-assumed charset data
|
|
@ -1,22 +0,0 @@
|
|||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 Jonathan Ong me@jongleberry.com
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
|
@ -1,72 +0,0 @@
|
|||
# mime-db
|
||||
|
||||
[![NPM Version][npm-version-image]][npm-url]
|
||||
[![NPM Downloads][npm-downloads-image]][npm-url]
|
||||
[![Node.js Version][node-image]][node-url]
|
||||
[![Build Status][travis-image]][travis-url]
|
||||
[![Coverage Status][coveralls-image]][coveralls-url]
|
||||
|
||||
This is a database of all mime types.
|
||||
It consistents of a single, public JSON file and does not include any logic,
|
||||
allowing it to remain as unopinionated as possible with an API.
|
||||
It aggregates data from the following sources:
|
||||
|
||||
- http://www.iana.org/assignments/media-types/media-types.xhtml
|
||||
- http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types
|
||||
|
||||
## Usage
|
||||
|
||||
```bash
|
||||
npm i mime-db
|
||||
```
|
||||
|
||||
```js
|
||||
var db = require('mime-db');
|
||||
|
||||
// grab data on .js files
|
||||
var data = db['application/javascript'];
|
||||
```
|
||||
|
||||
If you're crazy enough to use this in the browser,
|
||||
you can just grab the JSON file:
|
||||
|
||||
```
|
||||
https://cdn.rawgit.com/jshttp/mime-db/master/db.json
|
||||
```
|
||||
|
||||
## Data Structure
|
||||
|
||||
The JSON file is a map lookup for lowercased mime types.
|
||||
Each mime type has the following properties:
|
||||
|
||||
- `.source` - where the mime type is defined.
|
||||
If not set, it's probably a custom media type.
|
||||
- `apache` - [Apache common media types](http://svn.apache.org/repos/asf/httpd/httpd/trunk/docs/conf/mime.types)
|
||||
- `iana` - [IANA-defined media types](http://www.iana.org/assignments/media-types/media-types.xhtml)
|
||||
- `.extensions[]` - known extensions associated with this mime type.
|
||||
- `.compressible` - whether a file of this type is can be gzipped.
|
||||
- `.charset` - the default charset associated with this type, if any.
|
||||
|
||||
If unknown, every property could be `undefined`.
|
||||
|
||||
## Repository Structure
|
||||
|
||||
- `scripts` - these are scripts to run to build the database
|
||||
- `src/` - this is a folder of files created from remote sources like Apache and IANA
|
||||
- `lib/` - this is a folder of our own custom sources and db, which will be merged into `db.json`
|
||||
- `db.json` - the final built JSON file for end-user usage
|
||||
|
||||
## Contributing
|
||||
|
||||
To edit the database, only make PRs against files in the `lib/` folder.
|
||||
To update the build, run `npm run update`.
|
||||
|
||||
[npm-version-image]: https://img.shields.io/npm/v/mime-db.svg?style=flat
|
||||
[npm-downloads-image]: https://img.shields.io/npm/dm/mime-db.svg?style=flat
|
||||
[npm-url]: https://npmjs.org/package/mime-db
|
||||
[travis-image]: https://img.shields.io/travis/jshttp/mime-db.svg?style=flat
|
||||
[travis-url]: https://travis-ci.org/jshttp/mime-db
|
||||
[coveralls-image]: https://img.shields.io/coveralls/jshttp/mime-db.svg?style=flat
|
||||
[coveralls-url]: https://coveralls.io/r/jshttp/mime-db?branch=master
|
||||
[node-image]: https://img.shields.io/node/v/mime-db.svg?style=flat
|
||||
[node-url]: http://nodejs.org/download/
|
File diff suppressed because it is too large
Load Diff
|
@ -1,11 +0,0 @@
|
|||
/*!
|
||||
* mime-db
|
||||
* Copyright(c) 2014 Jonathan Ong
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
*/
|
||||
|
||||
module.exports = require('./db.json')
|
|
@ -1,87 +0,0 @@
|
|||
{
|
||||
"name": "mime-db",
|
||||
"description": "Media Type Database",
|
||||
"version": "1.5.0",
|
||||
"author": {
|
||||
"name": "Jonathan Ong",
|
||||
"email": "me@jongleberry.com",
|
||||
"url": "http://jongleberry.com"
|
||||
},
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Douglas Christopher Wilson",
|
||||
"email": "doug@somethingdoug.com"
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"mime",
|
||||
"db",
|
||||
"type",
|
||||
"types",
|
||||
"database",
|
||||
"charset",
|
||||
"charsets"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/jshttp/mime-db"
|
||||
},
|
||||
"devDependencies": {
|
||||
"co": "4",
|
||||
"cogent": "1",
|
||||
"csv-parse": "0",
|
||||
"gnode": "0.1.0",
|
||||
"istanbul": "0.3.5",
|
||||
"mocha": "~1.21.4",
|
||||
"raw-body": "~1.3.1",
|
||||
"stream-to-array": "2"
|
||||
},
|
||||
"files": [
|
||||
"HISTORY.md",
|
||||
"LICENSE",
|
||||
"README.md",
|
||||
"db.json",
|
||||
"index.js"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
},
|
||||
"scripts": {
|
||||
"update": "gnode scripts/extensions && gnode scripts/types && node scripts/build",
|
||||
"clean": "rm src/*",
|
||||
"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/"
|
||||
},
|
||||
"gitHead": "262fafb4a696cae208d6148c6642ee45bce07cb3",
|
||||
"bugs": {
|
||||
"url": "https://github.com/jshttp/mime-db/issues"
|
||||
},
|
||||
"homepage": "https://github.com/jshttp/mime-db",
|
||||
"_id": "mime-db@1.5.0",
|
||||
"_shasum": "bd80b576157991c3b46c71be7041fc6d5402a6ee",
|
||||
"_from": "mime-db@~1.5.0",
|
||||
"_npmVersion": "1.4.28",
|
||||
"_npmUser": {
|
||||
"name": "dougwilson",
|
||||
"email": "doug@somethingdoug.com"
|
||||
},
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "jongleberry",
|
||||
"email": "jonathanrichardong@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "dougwilson",
|
||||
"email": "doug@somethingdoug.com"
|
||||
}
|
||||
],
|
||||
"dist": {
|
||||
"shasum": "bd80b576157991c3b46c71be7041fc6d5402a6ee",
|
||||
"tarball": "http://registry.npmjs.org/mime-db/-/mime-db-1.5.0.tgz"
|
||||
},
|
||||
"directories": {},
|
||||
"_resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.5.0.tgz",
|
||||
"readme": "ERROR: No README data found!"
|
||||
}
|
84
websocket/node_modules/express/node_modules/accepts/node_modules/mime-types/package.json
generated
vendored
84
websocket/node_modules/express/node_modules/accepts/node_modules/mime-types/package.json
generated
vendored
|
@ -1,84 +0,0 @@
|
|||
{
|
||||
"name": "mime-types",
|
||||
"description": "The ultimate javascript content-type utility.",
|
||||
"version": "2.0.7",
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Douglas Christopher Wilson",
|
||||
"email": "doug@somethingdoug.com"
|
||||
},
|
||||
{
|
||||
"name": "Jeremiah Senkpiel",
|
||||
"email": "fishrock123@rocketmail.com",
|
||||
"url": "https://searchbeam.jit.su"
|
||||
},
|
||||
{
|
||||
"name": "Jonathan Ong",
|
||||
"email": "me@jongleberry.com",
|
||||
"url": "http://jongleberry.com"
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"mime",
|
||||
"types"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/jshttp/mime-types"
|
||||
},
|
||||
"dependencies": {
|
||||
"mime-db": "~1.5.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"istanbul": "0.3.5",
|
||||
"mocha": "~1.21.5"
|
||||
},
|
||||
"files": [
|
||||
"HISTORY.md",
|
||||
"LICENSE",
|
||||
"index.js"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha --reporter spec test/test.js",
|
||||
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot test/test.js",
|
||||
"test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter dot test/test.js"
|
||||
},
|
||||
"gitHead": "4216c095dcc3390c2b8f4a96a9eae94d11420f56",
|
||||
"bugs": {
|
||||
"url": "https://github.com/jshttp/mime-types/issues"
|
||||
},
|
||||
"homepage": "https://github.com/jshttp/mime-types",
|
||||
"_id": "mime-types@2.0.7",
|
||||
"_shasum": "0cb58d0403aec977357db324eea67e40c32b44b2",
|
||||
"_from": "mime-types@~2.0.4",
|
||||
"_npmVersion": "1.4.28",
|
||||
"_npmUser": {
|
||||
"name": "dougwilson",
|
||||
"email": "doug@somethingdoug.com"
|
||||
},
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "jongleberry",
|
||||
"email": "jonathanrichardong@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "fishrock123",
|
||||
"email": "fishrock123@rocketmail.com"
|
||||
},
|
||||
{
|
||||
"name": "dougwilson",
|
||||
"email": "doug@somethingdoug.com"
|
||||
}
|
||||
],
|
||||
"dist": {
|
||||
"shasum": "0cb58d0403aec977357db324eea67e40c32b44b2",
|
||||
"tarball": "http://registry.npmjs.org/mime-types/-/mime-types-2.0.7.tgz"
|
||||
},
|
||||
"directories": {},
|
||||
"_resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.0.7.tgz",
|
||||
"readme": "ERROR: No README data found!"
|
||||
}
|
23
websocket/node_modules/express/node_modules/accepts/node_modules/negotiator/LICENSE
generated
vendored
23
websocket/node_modules/express/node_modules/accepts/node_modules/negotiator/LICENSE
generated
vendored
|
@ -1,23 +0,0 @@
|
|||
(The MIT License)
|
||||
|
||||
Copyright (c) 2012 Federico Romero
|
||||
Copyright (c) 2012-2014 Isaac Z. Schlueter
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
'Software'), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
161
websocket/node_modules/express/node_modules/accepts/node_modules/negotiator/README.md
generated
vendored
161
websocket/node_modules/express/node_modules/accepts/node_modules/negotiator/README.md
generated
vendored
|
@ -1,161 +0,0 @@
|
|||
# negotiator
|
||||
|
||||
[![NPM Version][npm-image]][npm-url]
|
||||
[![NPM Downloads][downloads-image]][downloads-url]
|
||||
[![Node.js Version][node-version-image]][node-version-url]
|
||||
[![Build Status][travis-image]][travis-url]
|
||||
[![Test Coverage][coveralls-image]][coveralls-url]
|
||||
|
||||
An HTTP content negotiator for Node.js
|
||||
|
||||
## Installation
|
||||
|
||||
```sh
|
||||
$ npm install negotiator
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
```js
|
||||
var Negotiator = require('negotiator')
|
||||
```
|
||||
|
||||
### Accept Negotiation
|
||||
|
||||
```js
|
||||
availableMediaTypes = ['text/html', 'text/plain', 'application/json']
|
||||
|
||||
// The negotiator constructor receives a request object
|
||||
negotiator = new Negotiator(request)
|
||||
|
||||
// Let's say Accept header is 'text/html, application/*;q=0.2, image/jpeg;q=0.8'
|
||||
|
||||
negotiator.mediaTypes()
|
||||
// -> ['text/html', 'image/jpeg', 'application/*']
|
||||
|
||||
negotiator.mediaTypes(availableMediaTypes)
|
||||
// -> ['text/html', 'application/json']
|
||||
|
||||
negotiator.mediaType(availableMediaTypes)
|
||||
// -> 'text/html'
|
||||
```
|
||||
|
||||
You can check a working example at `examples/accept.js`.
|
||||
|
||||
#### Methods
|
||||
|
||||
##### mediaTypes(availableMediaTypes):
|
||||
|
||||
Returns an array of preferred media types ordered by priority from a list of available media types.
|
||||
|
||||
##### mediaType(availableMediaType):
|
||||
|
||||
Returns the top preferred media type from a list of available media types.
|
||||
|
||||
### Accept-Language Negotiation
|
||||
|
||||
```js
|
||||
negotiator = new Negotiator(request)
|
||||
|
||||
availableLanguages = 'en', 'es', 'fr'
|
||||
|
||||
// Let's say Accept-Language header is 'en;q=0.8, es, pt'
|
||||
|
||||
negotiator.languages()
|
||||
// -> ['es', 'pt', 'en']
|
||||
|
||||
negotiator.languages(availableLanguages)
|
||||
// -> ['es', 'en']
|
||||
|
||||
language = negotiator.language(availableLanguages)
|
||||
// -> 'es'
|
||||
```
|
||||
|
||||
You can check a working example at `examples/language.js`.
|
||||
|
||||
#### Methods
|
||||
|
||||
##### languages(availableLanguages):
|
||||
|
||||
Returns an array of preferred languages ordered by priority from a list of available languages.
|
||||
|
||||
##### language(availableLanguages):
|
||||
|
||||
Returns the top preferred language from a list of available languages.
|
||||
|
||||
### Accept-Charset Negotiation
|
||||
|
||||
```js
|
||||
availableCharsets = ['utf-8', 'iso-8859-1', 'iso-8859-5']
|
||||
|
||||
negotiator = new Negotiator(request)
|
||||
|
||||
// Let's say Accept-Charset header is 'utf-8, iso-8859-1;q=0.8, utf-7;q=0.2'
|
||||
|
||||
negotiator.charsets()
|
||||
// -> ['utf-8', 'iso-8859-1', 'utf-7']
|
||||
|
||||
negotiator.charsets(availableCharsets)
|
||||
// -> ['utf-8', 'iso-8859-1']
|
||||
|
||||
negotiator.charset(availableCharsets)
|
||||
// -> 'utf-8'
|
||||
```
|
||||
|
||||
You can check a working example at `examples/charset.js`.
|
||||
|
||||
#### Methods
|
||||
|
||||
##### charsets(availableCharsets):
|
||||
|
||||
Returns an array of preferred charsets ordered by priority from a list of available charsets.
|
||||
|
||||
##### charset(availableCharsets):
|
||||
|
||||
Returns the top preferred charset from a list of available charsets.
|
||||
|
||||
### Accept-Encoding Negotiation
|
||||
|
||||
```js
|
||||
availableEncodings = ['identity', 'gzip']
|
||||
|
||||
negotiator = new Negotiator(request)
|
||||
|
||||
// Let's say Accept-Encoding header is 'gzip, compress;q=0.2, identity;q=0.5'
|
||||
|
||||
negotiator.encodings()
|
||||
// -> ['gzip', 'identity', 'compress']
|
||||
|
||||
negotiator.encodings(availableEncodings)
|
||||
// -> ['gzip', 'identity']
|
||||
|
||||
negotiator.encoding(availableEncodings)
|
||||
// -> 'gzip'
|
||||
```
|
||||
|
||||
You can check a working example at `examples/encoding.js`.
|
||||
|
||||
#### Methods
|
||||
|
||||
##### encodings(availableEncodings):
|
||||
|
||||
Returns an array of preferred encodings ordered by priority from a list of available encodings.
|
||||
|
||||
##### encoding(availableEncodings):
|
||||
|
||||
Returns the top preferred encoding from a list of available encodings.
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE)
|
||||
|
||||
[npm-image]: https://img.shields.io/npm/v/negotiator.svg?style=flat
|
||||
[npm-url]: https://npmjs.org/package/negotiator
|
||||
[node-version-image]: https://img.shields.io/node/v/negotiator.svg?style=flat
|
||||
[node-version-url]: http://nodejs.org/download/
|
||||
[travis-image]: https://img.shields.io/travis/jshttp/negotiator.svg?style=flat
|
||||
[travis-url]: https://travis-ci.org/jshttp/negotiator
|
||||
[coveralls-image]: https://img.shields.io/coveralls/jshttp/negotiator.svg?style=flat
|
||||
[coveralls-url]: https://coveralls.io/r/jshttp/negotiator?branch=master
|
||||
[downloads-image]: https://img.shields.io/npm/dm/negotiator.svg?style=flat
|
||||
[downloads-url]: https://npmjs.org/package/negotiator
|
79
websocket/node_modules/express/node_modules/accepts/node_modules/negotiator/package.json
generated
vendored
79
websocket/node_modules/express/node_modules/accepts/node_modules/negotiator/package.json
generated
vendored
|
@ -1,79 +0,0 @@
|
|||
{
|
||||
"name": "negotiator",
|
||||
"description": "HTTP content negotiation",
|
||||
"version": "0.4.9",
|
||||
"author": {
|
||||
"name": "Federico Romero",
|
||||
"email": "federico.romero@outboxlabs.com"
|
||||
},
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Isaac Z. Schlueter",
|
||||
"email": "i@izs.me",
|
||||
"url": "http://blog.izs.me/"
|
||||
}
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/jshttp/negotiator"
|
||||
},
|
||||
"keywords": [
|
||||
"http",
|
||||
"content negotiation",
|
||||
"accept",
|
||||
"accept-language",
|
||||
"accept-encoding",
|
||||
"accept-charset"
|
||||
],
|
||||
"license": "MIT",
|
||||
"devDependencies": {
|
||||
"istanbul": "~0.3.2",
|
||||
"nodeunit": "0.8.x"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "nodeunit test",
|
||||
"test-cov": "istanbul cover ./node_modules/nodeunit/bin/nodeunit test"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
},
|
||||
"main": "lib/negotiator.js",
|
||||
"files": [
|
||||
"lib",
|
||||
"LICENSE"
|
||||
],
|
||||
"gitHead": "1e90abd710b662db80f1ea244e647cce3bd74504",
|
||||
"bugs": {
|
||||
"url": "https://github.com/jshttp/negotiator/issues"
|
||||
},
|
||||
"homepage": "https://github.com/jshttp/negotiator",
|
||||
"_id": "negotiator@0.4.9",
|
||||
"_shasum": "92e46b6db53c7e421ed64a2bc94f08be7630df3f",
|
||||
"_from": "negotiator@0.4.9",
|
||||
"_npmVersion": "1.4.21",
|
||||
"_npmUser": {
|
||||
"name": "dougwilson",
|
||||
"email": "doug@somethingdoug.com"
|
||||
},
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "federomero",
|
||||
"email": "federomero@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "dougwilson",
|
||||
"email": "doug@somethingdoug.com"
|
||||
},
|
||||
{
|
||||
"name": "jongleberry",
|
||||
"email": "jonathanrichardong@gmail.com"
|
||||
}
|
||||
],
|
||||
"dist": {
|
||||
"shasum": "92e46b6db53c7e421ed64a2bc94f08be7630df3f",
|
||||
"tarball": "http://registry.npmjs.org/negotiator/-/negotiator-0.4.9.tgz"
|
||||
},
|
||||
"directories": {},
|
||||
"_resolved": "https://registry.npmjs.org/negotiator/-/negotiator-0.4.9.tgz",
|
||||
"readme": "ERROR: No README data found!"
|
||||
}
|
|
@ -1,92 +0,0 @@
|
|||
{
|
||||
"name": "accepts",
|
||||
"description": "Higher-level content negotiation",
|
||||
"version": "1.1.4",
|
||||
"author": {
|
||||
"name": "Jonathan Ong",
|
||||
"email": "me@jongleberry.com",
|
||||
"url": "http://jongleberry.com"
|
||||
},
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/jshttp/accepts"
|
||||
},
|
||||
"dependencies": {
|
||||
"mime-types": "~2.0.4",
|
||||
"negotiator": "0.4.9"
|
||||
},
|
||||
"devDependencies": {
|
||||
"istanbul": "~0.3.4",
|
||||
"mocha": "~2.0.1"
|
||||
},
|
||||
"files": [
|
||||
"LICENSE",
|
||||
"HISTORY.md",
|
||||
"index.js"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha --reporter spec --check-leaks --bail 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/"
|
||||
},
|
||||
"keywords": [
|
||||
"content",
|
||||
"negotiation",
|
||||
"accept",
|
||||
"accepts"
|
||||
],
|
||||
"gitHead": "df66414d80f096627b28f137127fce0a851d7900",
|
||||
"bugs": {
|
||||
"url": "https://github.com/jshttp/accepts/issues"
|
||||
},
|
||||
"homepage": "https://github.com/jshttp/accepts",
|
||||
"_id": "accepts@1.1.4",
|
||||
"_shasum": "d71c96f7d41d0feda2c38cd14e8a27c04158df4a",
|
||||
"_from": "accepts@~1.1.4",
|
||||
"_npmVersion": "1.4.21",
|
||||
"_npmUser": {
|
||||
"name": "dougwilson",
|
||||
"email": "doug@somethingdoug.com"
|
||||
},
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "jongleberry",
|
||||
"email": "jonathanrichardong@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "federomero",
|
||||
"email": "federomero@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "dougwilson",
|
||||
"email": "doug@somethingdoug.com"
|
||||
},
|
||||
{
|
||||
"name": "tjholowaychuk",
|
||||
"email": "tj@vision-media.ca"
|
||||
},
|
||||
{
|
||||
"name": "shtylman",
|
||||
"email": "shtylman@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "mscdex",
|
||||
"email": "mscdex@mscdex.net"
|
||||
},
|
||||
{
|
||||
"name": "fishrock123",
|
||||
"email": "fishrock123@rocketmail.com"
|
||||
}
|
||||
],
|
||||
"dist": {
|
||||
"shasum": "d71c96f7d41d0feda2c38cd14e8a27c04158df4a",
|
||||
"tarball": "http://registry.npmjs.org/accepts/-/accepts-1.1.4.tgz"
|
||||
},
|
||||
"directories": {},
|
||||
"_resolved": "https://registry.npmjs.org/accepts/-/accepts-1.1.4.tgz",
|
||||
"readme": "ERROR: No README data found!"
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
0.5.0 / 2014-10-11
|
||||
==================
|
||||
|
||||
* Add `parse` function
|
||||
|
||||
0.4.0 / 2014-09-21
|
||||
==================
|
||||
|
||||
* Expand non-Unicode `filename` to the full ISO-8859-1 charset
|
||||
|
||||
0.3.0 / 2014-09-20
|
||||
==================
|
||||
|
||||
* Add `fallback` option
|
||||
* Add `type` option
|
||||
|
||||
0.2.0 / 2014-09-19
|
||||
==================
|
||||
|
||||
* Reduce ambiguity of file names with hex escape in buggy browsers
|
||||
|
||||
0.1.2 / 2014-09-19
|
||||
==================
|
||||
|
||||
* Fix periodic invalid Unicode filename header
|
||||
|
||||
0.1.1 / 2014-09-19
|
||||
==================
|
||||
|
||||
* Fix invalid characters appearing in `filename*` parameter
|
||||
|
||||
0.1.0 / 2014-09-18
|
||||
==================
|
||||
|
||||
* Make the `filename` argument optional
|
||||
|
||||
0.0.0 / 2014-09-18
|
||||
==================
|
||||
|
||||
* Initial release
|
|
@ -1,22 +0,0 @@
|
|||
(The MIT License)
|
||||
|
||||
Copyright (c) 2014 Douglas Christopher Wilson
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
'Software'), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@ -1,141 +0,0 @@
|
|||
# content-disposition
|
||||
|
||||
[![NPM Version][npm-image]][npm-url]
|
||||
[![NPM Downloads][downloads-image]][downloads-url]
|
||||
[![Node.js Version][node-version-image]][node-version-url]
|
||||
[![Build Status][travis-image]][travis-url]
|
||||
[![Test Coverage][coveralls-image]][coveralls-url]
|
||||
|
||||
Create and parse HTTP `Content-Disposition` header
|
||||
|
||||
## Installation
|
||||
|
||||
```sh
|
||||
$ npm install content-disposition
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
```js
|
||||
var contentDisposition = require('content-disposition')
|
||||
```
|
||||
|
||||
### contentDisposition(filename, options)
|
||||
|
||||
Create an attachment `Content-Disposition` header value using the given file name,
|
||||
if supplied. The `filename` is optional and if no file name is desired, but you
|
||||
want to specify `options`, set `filename` to `undefined`.
|
||||
|
||||
```js
|
||||
res.setHeader('Content-Disposition', contentDisposition('∫ maths.pdf'))
|
||||
```
|
||||
|
||||
**note** HTTP headers are of the ISO-8859-1 character set. If you are writing this
|
||||
header through a means different from `setHeader` in Node.js, you'll want to specify
|
||||
the `'binary'` encoding in Node.js.
|
||||
|
||||
#### Options
|
||||
|
||||
`contentDisposition` accepts these properties in the options object.
|
||||
|
||||
##### fallback
|
||||
|
||||
If the `filename` option is outside ISO-8859-1, then the file name is actually
|
||||
stored in a supplemental field for clients that support Unicode file names and
|
||||
a ISO-8859-1 version of the file name is automatically generated.
|
||||
|
||||
This specifies the ISO-8859-1 file name to override the automatic generation or
|
||||
disables the generation all together, defaults to `true`.
|
||||
|
||||
- A string will specify the ISO-8859-1 file name to use in place of automatic
|
||||
generation.
|
||||
- `false` will disable including a ISO-8859-1 file name and only include the
|
||||
Unicode version (unless the file name is already ISO-8859-1).
|
||||
- `true` will enable automatic generation if the file name is outside ISO-8859-1.
|
||||
|
||||
If the `filename` option is ISO-8859-1 and this option is specified and has a
|
||||
different value, then the `filename` option is encoded in the extended field
|
||||
and this set as the fallback field, even though they are both ISO-8859-1.
|
||||
|
||||
##### type
|
||||
|
||||
Specifies the disposition type, defaults to `"attachment"`. This can also be
|
||||
`"inline"`, or any other value (all values except inline are treated like
|
||||
`attachment`, but can convey additional information if both parties agree to
|
||||
it). The type is normalized to lower-case.
|
||||
|
||||
### contentDisposition.parse(string)
|
||||
|
||||
```js
|
||||
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
|
||||
("Unicode") parameters by decoding them and providing them under the standard
|
||||
parameter name. This will return an object with the following properties (examples
|
||||
are shown for the string `'attachment; filename="EURO rates.txt"; filename*=UTF-8\'\'%e2%82%ac%20rates.txt'`):
|
||||
|
||||
- `type`: The disposition type (always lower case). Example: `'attachment'`
|
||||
|
||||
- `parameters`: An object of the parameters in the disposition (name of parameter
|
||||
always lower case and extended versions replace non-extended versions). Example:
|
||||
`{filename: "€ rates.txt"}`
|
||||
|
||||
## Examples
|
||||
|
||||
### Send a file for download
|
||||
|
||||
```js
|
||||
var contentDisposition = require('content-disposition')
|
||||
var destroy = require('destroy')
|
||||
var http = require('http')
|
||||
var onFinished = require('on-finished')
|
||||
|
||||
var filePath = '/path/to/public/plans.pdf'
|
||||
|
||||
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) {
|
||||
destroy(stream)
|
||||
})
|
||||
})
|
||||
```
|
||||
|
||||
## Testing
|
||||
|
||||
```sh
|
||||
$ npm test
|
||||
```
|
||||
|
||||
## References
|
||||
|
||||
- [RFC 2616: Hypertext Transfer Protocol -- HTTP/1.1][rfc-2616]
|
||||
- [RFC 5987: Character Set and Language Encoding for Hypertext Transfer Protocol (HTTP) Header Field Parameters][rfc-5987]
|
||||
- [RFC 6266: Use of the Content-Disposition Header Field in the Hypertext Transfer Protocol (HTTP)][rfc-6266]
|
||||
- [Test Cases for HTTP Content-Disposition header field (RFC 6266) and the Encodings defined in RFCs 2047, 2231 and 5987][tc-2231]
|
||||
|
||||
[rfc-2616]: https://tools.ietf.org/html/rfc2616
|
||||
[rfc-5987]: https://tools.ietf.org/html/rfc5987
|
||||
[rfc-6266]: https://tools.ietf.org/html/rfc6266
|
||||
[tc-2231]: http://greenbytes.de/tech/tc2231/
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE)
|
||||
|
||||
[npm-image]: https://img.shields.io/npm/v/content-disposition.svg?style=flat
|
||||
[npm-url]: https://npmjs.org/package/content-disposition
|
||||
[node-version-image]: https://img.shields.io/node/v/content-disposition.svg?style=flat
|
||||
[node-version-url]: http://nodejs.org/download/
|
||||
[travis-image]: https://img.shields.io/travis/jshttp/content-disposition.svg?style=flat
|
||||
[travis-url]: https://travis-ci.org/jshttp/content-disposition
|
||||
[coveralls-image]: https://img.shields.io/coveralls/jshttp/content-disposition.svg?style=flat
|
||||
[coveralls-url]: https://coveralls.io/r/jshttp/content-disposition?branch=master
|
||||
[downloads-image]: https://img.shields.io/npm/dm/content-disposition.svg?style=flat
|
||||
[downloads-url]: https://npmjs.org/package/content-disposition
|
|
@ -1,443 +0,0 @@
|
|||
/*!
|
||||
* content-disposition
|
||||
* Copyright(c) 2014 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
*/
|
||||
|
||||
module.exports = contentDisposition
|
||||
module.exports.parse = parse
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var basename = require('path').basename
|
||||
|
||||
/**
|
||||
* RegExp to match non attr-char, *after* encodeURIComponent (i.e. not including "%")
|
||||
*/
|
||||
|
||||
var encodeUriAttrCharRegExp = /[\x00-\x20"'\(\)*,\/:;<=>?@\[\\\]\{\}\x7f]/g
|
||||
|
||||
/**
|
||||
* RegExp to match percent encoding escape.
|
||||
*/
|
||||
|
||||
var hexEscapeRegExp = /%[0-9A-Fa-f]{2}/
|
||||
var hexEscapeReplaceRegExp = /%([0-9A-Fa-f]{2})/g
|
||||
|
||||
/**
|
||||
* RegExp to match non-latin1 characters.
|
||||
*/
|
||||
|
||||
var nonLatin1RegExp = /[^\x20-\x7e\xa0-\xff]/g
|
||||
|
||||
/**
|
||||
* RegExp to match quoted-pair in RFC 2616
|
||||
*
|
||||
* quoted-pair = "\" CHAR
|
||||
* CHAR = <any US-ASCII character (octets 0 - 127)>
|
||||
*/
|
||||
|
||||
var qescRegExp = /\\([\u0000-\u007f])/g;
|
||||
|
||||
/**
|
||||
* RegExp to match chars that must be quoted-pair in RFC 2616
|
||||
*/
|
||||
|
||||
var quoteRegExp = /([\\"])/g
|
||||
|
||||
/**
|
||||
* RegExp for various RFC 2616 grammar
|
||||
*
|
||||
* parameter = token "=" ( token | quoted-string )
|
||||
* token = 1*<any CHAR except CTLs or separators>
|
||||
* separators = "(" | ")" | "<" | ">" | "@"
|
||||
* | "," | ";" | ":" | "\" | <">
|
||||
* | "/" | "[" | "]" | "?" | "="
|
||||
* | "{" | "}" | SP | HT
|
||||
* quoted-string = ( <"> *(qdtext | quoted-pair ) <"> )
|
||||
* qdtext = <any TEXT except <">>
|
||||
* quoted-pair = "\" CHAR
|
||||
* CHAR = <any US-ASCII character (octets 0 - 127)>
|
||||
* TEXT = <any OCTET except CTLs, but including LWS>
|
||||
* LWS = [CRLF] 1*( SP | HT )
|
||||
* CRLF = CR LF
|
||||
* CR = <US-ASCII CR, carriage return (13)>
|
||||
* LF = <US-ASCII LF, linefeed (10)>
|
||||
* SP = <US-ASCII SP, space (32)>
|
||||
* HT = <US-ASCII HT, horizontal-tab (9)>
|
||||
* CTL = <any US-ASCII control character (octets 0 - 31) and DEL (127)>
|
||||
* OCTET = <any 8-bit sequence of data>
|
||||
*/
|
||||
|
||||
var paramRegExp = /; *([!#$%&'\*\+\-\.0-9A-Z\^_`a-z\|~]+) *= *("(?:[ !\x23-\x5b\x5d-\x7e\x80-\xff]|\\[\x20-\x7e])*"|[!#$%&'\*\+\-\.0-9A-Z\^_`a-z\|~]+) */g
|
||||
var textRegExp = /^[\x20-\x7e\x80-\xff]+$/
|
||||
var tokenRegExp = /^[!#$%&'\*\+\-\.0-9A-Z\^_`a-z\|~]+$/
|
||||
|
||||
/**
|
||||
* RegExp for various RFC 5987 grammar
|
||||
*
|
||||
* ext-value = charset "'" [ language ] "'" value-chars
|
||||
* charset = "UTF-8" / "ISO-8859-1" / mime-charset
|
||||
* mime-charset = 1*mime-charsetc
|
||||
* mime-charsetc = ALPHA / DIGIT
|
||||
* / "!" / "#" / "$" / "%" / "&"
|
||||
* / "+" / "-" / "^" / "_" / "`"
|
||||
* / "{" / "}" / "~"
|
||||
* language = ( 2*3ALPHA [ extlang ] )
|
||||
* / 4ALPHA
|
||||
* / 5*8ALPHA
|
||||
* extlang = *3( "-" 3ALPHA )
|
||||
* value-chars = *( pct-encoded / attr-char )
|
||||
* pct-encoded = "%" HEXDIG HEXDIG
|
||||
* attr-char = ALPHA / DIGIT
|
||||
* / "!" / "#" / "$" / "&" / "+" / "-" / "."
|
||||
* / "^" / "_" / "`" / "|" / "~"
|
||||
*/
|
||||
|
||||
var extValueRegExp = /^([A-Za-z0-9!#$%&+\-^_`{}~]+)'(?:[A-Za-z]{2,3}(?:-[A-Za-z]{3}){0,3}|[A-Za-z]{4,8}|)'((?:%[0-9A-Fa-f]{2}|[A-Za-z0-9!#$&+\-\.^_`|~])+)$/
|
||||
|
||||
/**
|
||||
* RegExp for various RFC 6266 grammar
|
||||
*
|
||||
* disposition-type = "inline" | "attachment" | disp-ext-type
|
||||
* disp-ext-type = token
|
||||
* disposition-parm = filename-parm | disp-ext-parm
|
||||
* filename-parm = "filename" "=" value
|
||||
* | "filename*" "=" ext-value
|
||||
* disp-ext-parm = token "=" value
|
||||
* | ext-token "=" ext-value
|
||||
* ext-token = <the characters in token, followed by "*">
|
||||
*/
|
||||
|
||||
var dispositionTypeRegExp = /^([!#$%&'\*\+\-\.0-9A-Z\^_`a-z\|~]+) *(?:$|;)/
|
||||
|
||||
/**
|
||||
* Create an attachment Content-Disposition header.
|
||||
*
|
||||
* @param {string} [filename]
|
||||
* @param {object} [options]
|
||||
* @param {string} [options.type=attachment]
|
||||
* @param {string|boolean} [options.fallback=true]
|
||||
* @return {string}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function contentDisposition(filename, options) {
|
||||
var opts = options || {}
|
||||
|
||||
// get type
|
||||
var type = opts.type || 'attachment'
|
||||
|
||||
// get parameters
|
||||
var params = createparams(filename, opts.fallback)
|
||||
|
||||
// format into string
|
||||
return format(new ContentDisposition(type, params))
|
||||
}
|
||||
|
||||
/**
|
||||
* Create parameters object from filename and fallback.
|
||||
*
|
||||
* @param {string} [filename]
|
||||
* @param {string|boolean} [fallback=true]
|
||||
* @return {object}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function createparams(filename, fallback) {
|
||||
if (filename === undefined) {
|
||||
return
|
||||
}
|
||||
|
||||
var params = {}
|
||||
|
||||
if (typeof filename !== 'string') {
|
||||
throw new TypeError('filename must be a string')
|
||||
}
|
||||
|
||||
// fallback defaults to true
|
||||
if (fallback === undefined) {
|
||||
fallback = true
|
||||
}
|
||||
|
||||
if (typeof fallback !== 'string' && typeof fallback !== 'boolean') {
|
||||
throw new TypeError('fallback must be a string or boolean')
|
||||
}
|
||||
|
||||
if (typeof fallback === 'string' && nonLatin1RegExp.test(fallback)) {
|
||||
throw new TypeError('fallback must be ISO-8859-1 string')
|
||||
}
|
||||
|
||||
// restrict to file base name
|
||||
var name = basename(filename)
|
||||
|
||||
// determine if name is suitable for quoted string
|
||||
var isQuotedString = textRegExp.test(name)
|
||||
|
||||
// generate fallback name
|
||||
var fallbackName = typeof fallback !== 'string'
|
||||
? fallback && getlatin1(name)
|
||||
: basename(fallback)
|
||||
var hasFallback = typeof fallbackName === 'string' && fallbackName !== name
|
||||
|
||||
// set extended filename parameter
|
||||
if (hasFallback || !isQuotedString || hexEscapeRegExp.test(name)) {
|
||||
params['filename*'] = name
|
||||
}
|
||||
|
||||
// set filename parameter
|
||||
if (isQuotedString || hasFallback) {
|
||||
params.filename = hasFallback
|
||||
? fallbackName
|
||||
: name
|
||||
}
|
||||
|
||||
return params
|
||||
}
|
||||
|
||||
/**
|
||||
* Format object to Content-Disposition header.
|
||||
*
|
||||
* @param {object} obj
|
||||
* @param {string} obj.type
|
||||
* @param {object} [obj.parameters]
|
||||
* @return {string}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function format(obj) {
|
||||
var parameters = obj.parameters
|
||||
var type = obj.type
|
||||
|
||||
if (!type || typeof type !== 'string' || !tokenRegExp.test(type)) {
|
||||
throw new TypeError('invalid type')
|
||||
}
|
||||
|
||||
// start with normalized type
|
||||
var string = String(type).toLowerCase()
|
||||
|
||||
// append parameters
|
||||
if (parameters && typeof parameters === 'object') {
|
||||
var param
|
||||
var params = Object.keys(parameters).sort()
|
||||
|
||||
for (var i = 0; i < params.length; i++) {
|
||||
param = params[i]
|
||||
|
||||
var val = param.substr(-1) === '*'
|
||||
? ustring(parameters[param])
|
||||
: qstring(parameters[param])
|
||||
|
||||
string += '; ' + param + '=' + val
|
||||
}
|
||||
}
|
||||
|
||||
return string
|
||||
}
|
||||
|
||||
/**
|
||||
* Decode a RFC 6987 field value (gracefully).
|
||||
*
|
||||
* @param {string} str
|
||||
* @return {string}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function decodefield(str) {
|
||||
var match = extValueRegExp.exec(str)
|
||||
|
||||
if (!match) {
|
||||
throw new TypeError('invalid extended field value')
|
||||
}
|
||||
|
||||
var charset = match[1].toLowerCase()
|
||||
var encoded = match[2]
|
||||
var value
|
||||
|
||||
// to binary string
|
||||
var binary = encoded.replace(hexEscapeReplaceRegExp, pdecode)
|
||||
|
||||
switch (charset) {
|
||||
case 'iso-8859-1':
|
||||
value = getlatin1(binary)
|
||||
break
|
||||
case 'utf-8':
|
||||
value = new Buffer(binary, 'binary').toString('utf8')
|
||||
break
|
||||
default:
|
||||
throw new TypeError('unsupported charset in extended field')
|
||||
}
|
||||
|
||||
return value
|
||||
}
|
||||
|
||||
/**
|
||||
* Get ISO-8859-1 version of string.
|
||||
*
|
||||
* @param {string} val
|
||||
* @return {string}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function getlatin1(val) {
|
||||
// simple Unicode -> ISO-8859-1 transformation
|
||||
return String(val).replace(nonLatin1RegExp, '?')
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse Content-Disposition header string.
|
||||
*
|
||||
* @param {string} string
|
||||
* @return {object}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function parse(string) {
|
||||
if (!string || typeof string !== 'string') {
|
||||
throw new TypeError('argument string is required')
|
||||
}
|
||||
|
||||
var match = dispositionTypeRegExp.exec(string)
|
||||
|
||||
if (!match) {
|
||||
throw new TypeError('invalid type format')
|
||||
}
|
||||
|
||||
// normalize type
|
||||
var index = match[0].length
|
||||
var type = match[1].toLowerCase()
|
||||
|
||||
var key
|
||||
var names = []
|
||||
var params = {}
|
||||
var value
|
||||
|
||||
// calculate index to start at
|
||||
index = paramRegExp.lastIndex = match[0].substr(-1) === ';'
|
||||
? index - 1
|
||||
: index
|
||||
|
||||
// match parameters
|
||||
while (match = paramRegExp.exec(string)) {
|
||||
if (match.index !== index) {
|
||||
throw new TypeError('invalid parameter format')
|
||||
}
|
||||
|
||||
index += match[0].length
|
||||
key = match[1].toLowerCase()
|
||||
value = match[2]
|
||||
|
||||
if (names.indexOf(key) !== -1) {
|
||||
throw new TypeError('invalid duplicate parameter')
|
||||
}
|
||||
|
||||
names.push(key)
|
||||
|
||||
if (key.indexOf('*') + 1 === key.length) {
|
||||
// decode extended value
|
||||
key = key.slice(0, -1)
|
||||
value = decodefield(value)
|
||||
|
||||
// overwrite existing value
|
||||
params[key] = value
|
||||
continue
|
||||
}
|
||||
|
||||
if (typeof params[key] === 'string') {
|
||||
continue
|
||||
}
|
||||
|
||||
if (value[0] === '"') {
|
||||
// remove quotes and escapes
|
||||
value = value
|
||||
.substr(1, value.length - 2)
|
||||
.replace(qescRegExp, '$1')
|
||||
}
|
||||
|
||||
params[key] = value
|
||||
}
|
||||
|
||||
if (index !== -1 && index !== string.length) {
|
||||
throw new TypeError('invalid parameter format')
|
||||
}
|
||||
|
||||
return new ContentDisposition(type, params)
|
||||
}
|
||||
|
||||
/**
|
||||
* Percent decode a single character.
|
||||
*
|
||||
* @param {string} str
|
||||
* @param {string} hex
|
||||
* @return {string}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function pdecode(str, hex) {
|
||||
return String.fromCharCode(parseInt(hex, 16))
|
||||
}
|
||||
|
||||
/**
|
||||
* Percent encode a single character.
|
||||
*
|
||||
* @param {string} char
|
||||
* @return {string}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function pencode(char) {
|
||||
var hex = String(char)
|
||||
.charCodeAt(0)
|
||||
.toString(16)
|
||||
.toUpperCase()
|
||||
return hex.length === 1
|
||||
? '%0' + hex
|
||||
: '%' + hex
|
||||
}
|
||||
|
||||
/**
|
||||
* Quote a string for HTTP.
|
||||
*
|
||||
* @param {string} val
|
||||
* @return {string}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function qstring(val) {
|
||||
var str = String(val)
|
||||
|
||||
return '"' + str.replace(quoteRegExp, '\\$1') + '"'
|
||||
}
|
||||
|
||||
/**
|
||||
* Encode a Unicode string for HTTP (RFC 5987).
|
||||
*
|
||||
* @param {string} val
|
||||
* @return {string}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function ustring(val) {
|
||||
var str = String(val)
|
||||
|
||||
// percent encode as UTF-8
|
||||
var encoded = encodeURIComponent(str)
|
||||
.replace(encodeUriAttrCharRegExp, pencode)
|
||||
|
||||
return 'UTF-8\'\'' + encoded
|
||||
}
|
||||
|
||||
/**
|
||||
* Class for parsed Content-Disposition header for v8 optimization
|
||||
*/
|
||||
|
||||
function ContentDisposition(type, parameters) {
|
||||
this.type = type
|
||||
this.parameters = parameters
|
||||
}
|
|
@ -1,66 +0,0 @@
|
|||
{
|
||||
"name": "content-disposition",
|
||||
"description": "Create and parse Content-Disposition header",
|
||||
"version": "0.5.0",
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Douglas Christopher Wilson",
|
||||
"email": "doug@somethingdoug.com"
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"content-disposition",
|
||||
"http",
|
||||
"rfc6266",
|
||||
"res"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/jshttp/content-disposition"
|
||||
},
|
||||
"devDependencies": {
|
||||
"istanbul": "0.3.2",
|
||||
"mocha": "~1.21.4"
|
||||
},
|
||||
"files": [
|
||||
"LICENSE",
|
||||
"HISTORY.md",
|
||||
"README.md",
|
||||
"index.js"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
},
|
||||
"scripts": {
|
||||
"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/"
|
||||
},
|
||||
"gitHead": "f3c915f0c9d9f5ec79713dba24c8c6181b73305d",
|
||||
"bugs": {
|
||||
"url": "https://github.com/jshttp/content-disposition/issues"
|
||||
},
|
||||
"homepage": "https://github.com/jshttp/content-disposition",
|
||||
"_id": "content-disposition@0.5.0",
|
||||
"_shasum": "4284fe6ae0630874639e44e80a418c2934135e9e",
|
||||
"_from": "content-disposition@0.5.0",
|
||||
"_npmVersion": "1.4.21",
|
||||
"_npmUser": {
|
||||
"name": "dougwilson",
|
||||
"email": "doug@somethingdoug.com"
|
||||
},
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "dougwilson",
|
||||
"email": "doug@somethingdoug.com"
|
||||
}
|
||||
],
|
||||
"dist": {
|
||||
"shasum": "4284fe6ae0630874639e44e80a418c2934135e9e",
|
||||
"tarball": "http://registry.npmjs.org/content-disposition/-/content-disposition-0.5.0.tgz"
|
||||
},
|
||||
"directories": {},
|
||||
"_resolved": "https://registry.npmjs.org/content-disposition/-/content-disposition-0.5.0.tgz",
|
||||
"readme": "ERROR: No README data found!"
|
||||
}
|
|
@ -1,4 +0,0 @@
|
|||
support
|
||||
test
|
||||
examples
|
||||
*.sock
|
|
@ -1,27 +0,0 @@
|
|||
1.0.4 / 2014-06-25
|
||||
==================
|
||||
|
||||
* corrected avoidance of timing attacks (thanks @tenbits!)
|
||||
|
||||
|
||||
1.0.3 / 2014-01-28
|
||||
==================
|
||||
|
||||
* [incorrect] fix for timing attacks
|
||||
|
||||
1.0.2 / 2014-01-28
|
||||
==================
|
||||
|
||||
* fix missing repository warning
|
||||
* fix typo in test
|
||||
|
||||
1.0.1 / 2013-04-15
|
||||
==================
|
||||
|
||||
* Revert "Changed underlying HMAC algo. to sha512."
|
||||
* Revert "Fix for timing attacks on MAC verification."
|
||||
|
||||
0.0.1 / 2010-01-03
|
||||
==================
|
||||
|
||||
* Initial release
|
|
@ -1,7 +0,0 @@
|
|||
|
||||
test:
|
||||
@./node_modules/.bin/mocha \
|
||||
--require should \
|
||||
--reporter spec
|
||||
|
||||
.PHONY: test
|
|
@ -1,42 +0,0 @@
|
|||
|
||||
# cookie-signature
|
||||
|
||||
Sign and unsign cookies.
|
||||
|
||||
## Example
|
||||
|
||||
```js
|
||||
var cookie = require('cookie-signature');
|
||||
|
||||
var val = cookie.sign('hello', 'tobiiscool');
|
||||
val.should.equal('hello.DGDUkGlIkCzPz+C0B064FNgHdEjox7ch8tOBGslZ5QI');
|
||||
|
||||
var val = cookie.sign('hello', 'tobiiscool');
|
||||
cookie.unsign(val, 'tobiiscool').should.equal('hello');
|
||||
cookie.unsign(val, 'luna').should.be.false;
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2012 LearnBoost <tj@learnboost.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
'Software'), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@ -1,51 +0,0 @@
|
|||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var crypto = require('crypto');
|
||||
|
||||
/**
|
||||
* Sign the given `val` with `secret`.
|
||||
*
|
||||
* @param {String} val
|
||||
* @param {String} secret
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
exports.sign = function(val, secret){
|
||||
if ('string' != typeof val) throw new TypeError('cookie required');
|
||||
if ('string' != typeof secret) throw new TypeError('secret required');
|
||||
return val + '.' + crypto
|
||||
.createHmac('sha256', secret)
|
||||
.update(val)
|
||||
.digest('base64')
|
||||
.replace(/\=+$/, '');
|
||||
};
|
||||
|
||||
/**
|
||||
* Unsign and decode the given `val` with `secret`,
|
||||
* returning `false` if the signature is invalid.
|
||||
*
|
||||
* @param {String} val
|
||||
* @param {String} secret
|
||||
* @return {String|Boolean}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
exports.unsign = function(val, secret){
|
||||
if ('string' != typeof val) throw new TypeError('cookie required');
|
||||
if ('string' != typeof secret) throw new TypeError('secret required');
|
||||
var str = val.slice(0, val.lastIndexOf('.'))
|
||||
, mac = exports.sign(str, secret);
|
||||
|
||||
return sha1(mac) == sha1(val) ? str : false;
|
||||
};
|
||||
|
||||
/**
|
||||
* Private
|
||||
*/
|
||||
|
||||
function sha1(str){
|
||||
return crypto.createHash('sha1').update(str).digest('hex');
|
||||
}
|
|
@ -1,56 +0,0 @@
|
|||
{
|
||||
"name": "cookie-signature",
|
||||
"version": "1.0.5",
|
||||
"description": "Sign and unsign cookies",
|
||||
"keywords": [
|
||||
"cookie",
|
||||
"sign",
|
||||
"unsign"
|
||||
],
|
||||
"author": {
|
||||
"name": "TJ Holowaychuk",
|
||||
"email": "tj@learnboost.com"
|
||||
},
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/visionmedia/node-cookie-signature.git"
|
||||
},
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"mocha": "*",
|
||||
"should": "*"
|
||||
},
|
||||
"main": "index",
|
||||
"gitHead": "73ed69b511b3ef47555d71b4ed1deea9e5ed6e1f",
|
||||
"bugs": {
|
||||
"url": "https://github.com/visionmedia/node-cookie-signature/issues"
|
||||
},
|
||||
"homepage": "https://github.com/visionmedia/node-cookie-signature",
|
||||
"_id": "cookie-signature@1.0.5",
|
||||
"scripts": {},
|
||||
"_shasum": "a122e3f1503eca0f5355795b0711bb2368d450f9",
|
||||
"_from": "cookie-signature@1.0.5",
|
||||
"_npmVersion": "1.4.20",
|
||||
"_npmUser": {
|
||||
"name": "natevw",
|
||||
"email": "natevw@yahoo.com"
|
||||
},
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "tjholowaychuk",
|
||||
"email": "tj@vision-media.ca"
|
||||
},
|
||||
{
|
||||
"name": "natevw",
|
||||
"email": "natevw@yahoo.com"
|
||||
}
|
||||
],
|
||||
"dist": {
|
||||
"shasum": "a122e3f1503eca0f5355795b0711bb2368d450f9",
|
||||
"tarball": "http://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.5.tgz"
|
||||
},
|
||||
"directories": {},
|
||||
"_resolved": "https://registry.npmjs.org/cookie-signature/-/cookie-signature-1.0.5.tgz",
|
||||
"readme": "ERROR: No README data found!"
|
||||
}
|
|
@ -1,2 +0,0 @@
|
|||
test
|
||||
.travis.yml
|
|
@ -1,9 +0,0 @@
|
|||
// MIT License
|
||||
|
||||
Copyright (C) Roman Shtylman <shtylman@gmail.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@ -1,44 +0,0 @@
|
|||
# cookie [![Build Status](https://secure.travis-ci.org/defunctzombie/node-cookie.png?branch=master)](http://travis-ci.org/defunctzombie/node-cookie) #
|
||||
|
||||
cookie is a basic cookie parser and serializer. It doesn't make assumptions about how you are going to deal with your cookies. It basically just provides a way to read and write the HTTP cookie headers.
|
||||
|
||||
See [RFC6265](http://tools.ietf.org/html/rfc6265) for details about the http header for cookies.
|
||||
|
||||
## how?
|
||||
|
||||
```
|
||||
npm install cookie
|
||||
```
|
||||
|
||||
```javascript
|
||||
var cookie = require('cookie');
|
||||
|
||||
var hdr = cookie.serialize('foo', 'bar');
|
||||
// hdr = 'foo=bar';
|
||||
|
||||
var cookies = cookie.parse('foo=bar; cat=meow; dog=ruff');
|
||||
// cookies = { foo: 'bar', cat: 'meow', dog: 'ruff' };
|
||||
```
|
||||
|
||||
## more
|
||||
|
||||
The serialize function takes a third parameter, an object, to set cookie options. See the RFC for valid values.
|
||||
|
||||
### path
|
||||
> cookie path
|
||||
|
||||
### expires
|
||||
> absolute expiration date for the cookie (Date object)
|
||||
|
||||
### maxAge
|
||||
> relative max age of the cookie from when the client receives it (seconds)
|
||||
|
||||
### domain
|
||||
> domain for the cookie
|
||||
|
||||
### secure
|
||||
> true or false
|
||||
|
||||
### httpOnly
|
||||
> true or false
|
||||
|
|
@ -1,75 +0,0 @@
|
|||
|
||||
/// Serialize the a name value pair into a cookie string suitable for
|
||||
/// http headers. An optional options object specified cookie parameters
|
||||
///
|
||||
/// serialize('foo', 'bar', { httpOnly: true })
|
||||
/// => "foo=bar; httpOnly"
|
||||
///
|
||||
/// @param {String} name
|
||||
/// @param {String} val
|
||||
/// @param {Object} options
|
||||
/// @return {String}
|
||||
var serialize = function(name, val, opt){
|
||||
opt = opt || {};
|
||||
var enc = opt.encode || encode;
|
||||
var pairs = [name + '=' + enc(val)];
|
||||
|
||||
if (null != opt.maxAge) {
|
||||
var maxAge = opt.maxAge - 0;
|
||||
if (isNaN(maxAge)) throw new Error('maxAge should be a Number');
|
||||
pairs.push('Max-Age=' + maxAge);
|
||||
}
|
||||
|
||||
if (opt.domain) pairs.push('Domain=' + opt.domain);
|
||||
if (opt.path) pairs.push('Path=' + opt.path);
|
||||
if (opt.expires) pairs.push('Expires=' + opt.expires.toUTCString());
|
||||
if (opt.httpOnly) pairs.push('HttpOnly');
|
||||
if (opt.secure) pairs.push('Secure');
|
||||
|
||||
return pairs.join('; ');
|
||||
};
|
||||
|
||||
/// Parse the given cookie header string into an object
|
||||
/// The object has the various cookies as keys(names) => values
|
||||
/// @param {String} str
|
||||
/// @return {Object}
|
||||
var parse = function(str, opt) {
|
||||
opt = opt || {};
|
||||
var obj = {}
|
||||
var pairs = str.split(/; */);
|
||||
var dec = opt.decode || decode;
|
||||
|
||||
pairs.forEach(function(pair) {
|
||||
var eq_idx = pair.indexOf('=')
|
||||
|
||||
// skip things that don't look like key=value
|
||||
if (eq_idx < 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
var key = pair.substr(0, eq_idx).trim()
|
||||
var val = pair.substr(++eq_idx, pair.length).trim();
|
||||
|
||||
// quoted values
|
||||
if ('"' == val[0]) {
|
||||
val = val.slice(1, -1);
|
||||
}
|
||||
|
||||
// only assign once
|
||||
if (undefined == obj[key]) {
|
||||
try {
|
||||
obj[key] = dec(val);
|
||||
} catch (e) {
|
||||
obj[key] = val;
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
return obj;
|
||||
};
|
||||
|
||||
var encode = encodeURIComponent;
|
||||
var decode = decodeURIComponent;
|
||||
|
||||
module.exports.serialize = serialize;
|
||||
module.exports.parse = parse;
|
|
@ -1,54 +0,0 @@
|
|||
{
|
||||
"author": {
|
||||
"name": "Roman Shtylman",
|
||||
"email": "shtylman@gmail.com"
|
||||
},
|
||||
"name": "cookie",
|
||||
"description": "cookie parsing and serialization",
|
||||
"version": "0.1.2",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/shtylman/node-cookie.git"
|
||||
},
|
||||
"keywords": [
|
||||
"cookie",
|
||||
"cookies"
|
||||
],
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"test": "mocha"
|
||||
},
|
||||
"dependencies": {},
|
||||
"devDependencies": {
|
||||
"mocha": "1.x.x"
|
||||
},
|
||||
"optionalDependencies": {},
|
||||
"engines": {
|
||||
"node": "*"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/shtylman/node-cookie/issues"
|
||||
},
|
||||
"homepage": "https://github.com/shtylman/node-cookie",
|
||||
"_id": "cookie@0.1.2",
|
||||
"dist": {
|
||||
"shasum": "72fec3d24e48a3432073d90c12642005061004b1",
|
||||
"tarball": "http://registry.npmjs.org/cookie/-/cookie-0.1.2.tgz"
|
||||
},
|
||||
"_from": "cookie@0.1.2",
|
||||
"_npmVersion": "1.4.6",
|
||||
"_npmUser": {
|
||||
"name": "shtylman",
|
||||
"email": "shtylman@gmail.com"
|
||||
},
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "shtylman",
|
||||
"email": "shtylman@gmail.com"
|
||||
}
|
||||
],
|
||||
"directories": {},
|
||||
"_shasum": "72fec3d24e48a3432073d90c12642005061004b1",
|
||||
"_resolved": "https://registry.npmjs.org/cookie/-/cookie-0.1.2.tgz",
|
||||
"readme": "ERROR: No README data found!"
|
||||
}
|
|
@ -1,3 +0,0 @@
|
|||
{
|
||||
"laxbreak": true
|
||||
}
|
|
@ -1,6 +0,0 @@
|
|||
support
|
||||
test
|
||||
examples
|
||||
example
|
||||
*.sock
|
||||
dist
|
|
@ -1,166 +0,0 @@
|
|||
|
||||
2.1.1 / 2014-12-29
|
||||
==================
|
||||
|
||||
* browser: use `typeof` to check for `console` existence
|
||||
* browser: check for `console.log` truthiness (fix IE 8/9)
|
||||
* browser: add support for Chrome apps
|
||||
* Readme: added Windows usage remarks
|
||||
* Add `bower.json` to properly support bower install
|
||||
|
||||
2.1.0 / 2014-10-15
|
||||
==================
|
||||
|
||||
* node: implement `DEBUG_FD` env variable support
|
||||
* package: update "browserify" to v6.1.0
|
||||
* package: add "license" field to package.json (#135, @panuhorsmalahti)
|
||||
|
||||
2.0.0 / 2014-09-01
|
||||
==================
|
||||
|
||||
* package: update "browserify" to v5.11.0
|
||||
* node: use stderr rather than stdout for logging (#29, @stephenmathieson)
|
||||
|
||||
1.0.4 / 2014-07-15
|
||||
==================
|
||||
|
||||
* dist: recompile
|
||||
* example: remove `console.info()` log usage
|
||||
* example: add "Content-Type" UTF-8 header to browser example
|
||||
* browser: place %c marker after the space character
|
||||
* browser: reset the "content" color via `color: inherit`
|
||||
* browser: add colors support for Firefox >= v31
|
||||
* debug: prefer an instance `log()` function over the global one (#119)
|
||||
* Readme: update documentation about styled console logs for FF v31 (#116, @wryk)
|
||||
|
||||
1.0.3 / 2014-07-09
|
||||
==================
|
||||
|
||||
* Add support for multiple wildcards in namespaces (#122, @seegno)
|
||||
* browser: fix lint
|
||||
|
||||
1.0.2 / 2014-06-10
|
||||
==================
|
||||
|
||||
* browser: update color palette (#113, @gscottolson)
|
||||
* common: make console logging function configurable (#108, @timoxley)
|
||||
* node: fix %o colors on old node <= 0.8.x
|
||||
* Makefile: find node path using shell/which (#109, @timoxley)
|
||||
|
||||
1.0.1 / 2014-06-06
|
||||
==================
|
||||
|
||||
* browser: use `removeItem()` to clear localStorage
|
||||
* browser, node: don't set DEBUG if namespaces is undefined (#107, @leedm777)
|
||||
* package: add "contributors" section
|
||||
* node: fix comment typo
|
||||
* README: list authors
|
||||
|
||||
1.0.0 / 2014-06-04
|
||||
==================
|
||||
|
||||
* make ms diff be global, not be scope
|
||||
* debug: ignore empty strings in enable()
|
||||
* node: make DEBUG_COLORS able to disable coloring
|
||||
* *: export the `colors` array
|
||||
* npmignore: don't publish the `dist` dir
|
||||
* Makefile: refactor to use browserify
|
||||
* package: add "browserify" as a dev dependency
|
||||
* Readme: add Web Inspector Colors section
|
||||
* node: reset terminal color for the debug content
|
||||
* node: map "%o" to `util.inspect()`
|
||||
* browser: map "%j" to `JSON.stringify()`
|
||||
* debug: add custom "formatters"
|
||||
* debug: use "ms" module for humanizing the diff
|
||||
* Readme: add "bash" syntax highlighting
|
||||
* browser: add Firebug color support
|
||||
* browser: add colors for WebKit browsers
|
||||
* node: apply log to `console`
|
||||
* rewrite: abstract common logic for Node & browsers
|
||||
* add .jshintrc file
|
||||
|
||||
0.8.1 / 2014-04-14
|
||||
==================
|
||||
|
||||
* package: re-add the "component" section
|
||||
|
||||
0.8.0 / 2014-03-30
|
||||
==================
|
||||
|
||||
* add `enable()` method for nodejs. Closes #27
|
||||
* change from stderr to stdout
|
||||
* remove unnecessary index.js file
|
||||
|
||||
0.7.4 / 2013-11-13
|
||||
==================
|
||||
|
||||
* remove "browserify" key from package.json (fixes something in browserify)
|
||||
|
||||
0.7.3 / 2013-10-30
|
||||
==================
|
||||
|
||||
* fix: catch localStorage security error when cookies are blocked (Chrome)
|
||||
* add debug(err) support. Closes #46
|
||||
* add .browser prop to package.json. Closes #42
|
||||
|
||||
0.7.2 / 2013-02-06
|
||||
==================
|
||||
|
||||
* fix package.json
|
||||
* fix: Mobile Safari (private mode) is broken with debug
|
||||
* fix: Use unicode to send escape character to shell instead of octal to work with strict mode javascript
|
||||
|
||||
0.7.1 / 2013-02-05
|
||||
==================
|
||||
|
||||
* add repository URL to package.json
|
||||
* add DEBUG_COLORED to force colored output
|
||||
* add browserify support
|
||||
* fix component. Closes #24
|
||||
|
||||
0.7.0 / 2012-05-04
|
||||
==================
|
||||
|
||||
* Added .component to package.json
|
||||
* Added debug.component.js build
|
||||
|
||||
0.6.0 / 2012-03-16
|
||||
==================
|
||||
|
||||
* Added support for "-" prefix in DEBUG [Vinay Pulim]
|
||||
* Added `.enabled` flag to the node version [TooTallNate]
|
||||
|
||||
0.5.0 / 2012-02-02
|
||||
==================
|
||||
|
||||
* Added: humanize diffs. Closes #8
|
||||
* Added `debug.disable()` to the CS variant
|
||||
* Removed padding. Closes #10
|
||||
* Fixed: persist client-side variant again. Closes #9
|
||||
|
||||
0.4.0 / 2012-02-01
|
||||
==================
|
||||
|
||||
* Added browser variant support for older browsers [TooTallNate]
|
||||
* Added `debug.enable('project:*')` to browser variant [TooTallNate]
|
||||
* Added padding to diff (moved it to the right)
|
||||
|
||||
0.3.0 / 2012-01-26
|
||||
==================
|
||||
|
||||
* Added millisecond diff when isatty, otherwise UTC string
|
||||
|
||||
0.2.0 / 2012-01-22
|
||||
==================
|
||||
|
||||
* Added wildcard support
|
||||
|
||||
0.1.0 / 2011-12-02
|
||||
==================
|
||||
|
||||
* Added: remove colors unless stderr isatty [TooTallNate]
|
||||
|
||||
0.0.1 / 2010-01-03
|
||||
==================
|
||||
|
||||
* Initial release
|
|
@ -1,33 +0,0 @@
|
|||
|
||||
# get Makefile directory name: http://stackoverflow.com/a/5982798/376773
|
||||
THIS_MAKEFILE_PATH:=$(word $(words $(MAKEFILE_LIST)),$(MAKEFILE_LIST))
|
||||
THIS_DIR:=$(shell cd $(dir $(THIS_MAKEFILE_PATH));pwd)
|
||||
|
||||
# BIN directory
|
||||
BIN := $(THIS_DIR)/node_modules/.bin
|
||||
|
||||
# applications
|
||||
NODE ?= $(shell which node)
|
||||
NPM ?= $(NODE) $(shell which npm)
|
||||
BROWSERIFY ?= $(NODE) $(BIN)/browserify
|
||||
|
||||
all: dist/debug.js
|
||||
|
||||
install: node_modules
|
||||
|
||||
clean:
|
||||
@rm -rf node_modules dist
|
||||
|
||||
dist:
|
||||
@mkdir -p $@
|
||||
|
||||
dist/debug.js: node_modules browser.js debug.js dist
|
||||
@$(BROWSERIFY) \
|
||||
--standalone debug \
|
||||
. > $@
|
||||
|
||||
node_modules: package.json
|
||||
@NODE_ENV= $(NPM) install
|
||||
@touch node_modules
|
||||
|
||||
.PHONY: all install clean
|
|
@ -1,166 +0,0 @@
|
|||
# debug
|
||||
|
||||
tiny node.js debugging utility modelled after node core's debugging technique.
|
||||
|
||||
## Installation
|
||||
|
||||
```bash
|
||||
$ npm install debug
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
With `debug` you simply invoke the exported function to generate your debug function, passing it a name which will determine if a noop function is returned, or a decorated `console.error`, so all of the `console` format string goodies you're used to work fine. A unique color is selected per-function for visibility.
|
||||
|
||||
Example _app.js_:
|
||||
|
||||
```js
|
||||
var debug = require('debug')('http')
|
||||
, http = require('http')
|
||||
, name = 'My App';
|
||||
|
||||
// fake app
|
||||
|
||||
debug('booting %s', name);
|
||||
|
||||
http.createServer(function(req, res){
|
||||
debug(req.method + ' ' + req.url);
|
||||
res.end('hello\n');
|
||||
}).listen(3000, function(){
|
||||
debug('listening');
|
||||
});
|
||||
|
||||
// fake worker of some kind
|
||||
|
||||
require('./worker');
|
||||
```
|
||||
|
||||
Example _worker.js_:
|
||||
|
||||
```js
|
||||
var debug = require('debug')('worker');
|
||||
|
||||
setInterval(function(){
|
||||
debug('doing some work');
|
||||
}, 1000);
|
||||
```
|
||||
|
||||
The __DEBUG__ environment variable is then used to enable these based on space or comma-delimited names. Here are some examples:
|
||||
|
||||
![debug http and worker](http://f.cl.ly/items/18471z1H402O24072r1J/Screenshot.png)
|
||||
|
||||
![debug worker](http://f.cl.ly/items/1X413v1a3M0d3C2c1E0i/Screenshot.png)
|
||||
|
||||
#### Windows note
|
||||
|
||||
On Windows the environment variable is set using the `set` command.
|
||||
|
||||
```cmd
|
||||
set DEBUG=*,-not_this
|
||||
```
|
||||
|
||||
Then, run the program to be debugged as ususal.
|
||||
|
||||
## Millisecond diff
|
||||
|
||||
When actively developing an application it can be useful to see when the time spent between one `debug()` call and the next. Suppose for example you invoke `debug()` before requesting a resource, and after as well, the "+NNNms" will show you how much time was spent between calls.
|
||||
|
||||
![](http://f.cl.ly/items/2i3h1d3t121M2Z1A3Q0N/Screenshot.png)
|
||||
|
||||
When stdout is not a TTY, `Date#toUTCString()` is used, making it more useful for logging the debug information as shown below:
|
||||
|
||||
![](http://f.cl.ly/items/112H3i0e0o0P0a2Q2r11/Screenshot.png)
|
||||
|
||||
## Conventions
|
||||
|
||||
If you're using this in one or more of your libraries, you _should_ use the name of your library so that developers may toggle debugging as desired without guessing names. If you have more than one debuggers you _should_ prefix them with your library name and use ":" to separate features. For example "bodyParser" from Connect would then be "connect:bodyParser".
|
||||
|
||||
## Wildcards
|
||||
|
||||
The `*` character may be used as a wildcard. Suppose for example your library has debuggers named "connect:bodyParser", "connect:compress", "connect:session", instead of listing all three with `DEBUG=connect:bodyParser,connect.compress,connect:session`, you may simply do `DEBUG=connect:*`, or to run everything using this module simply use `DEBUG=*`.
|
||||
|
||||
You can also exclude specific debuggers by prefixing them with a "-" character. For example, `DEBUG=*,-connect:*` would include all debuggers except those starting with "connect:".
|
||||
|
||||
## Browser support
|
||||
|
||||
Debug works in the browser as well, currently persisted by `localStorage`. For example if you have `worker:a` and `worker:b` as shown below, and wish to debug both type `debug.enable('worker:*')` in the console and refresh the page, this will remain until you disable with `debug.disable()`.
|
||||
|
||||
```js
|
||||
a = debug('worker:a');
|
||||
b = debug('worker:b');
|
||||
|
||||
setInterval(function(){
|
||||
a('doing some work');
|
||||
}, 1000);
|
||||
|
||||
setInterval(function(){
|
||||
b('doing some work');
|
||||
}, 1200);
|
||||
```
|
||||
|
||||
#### Web Inspector Colors
|
||||
|
||||
Colors are also enabled on "Web Inspectors" that understand the `%c` formatting
|
||||
option. These are WebKit web inspectors, Firefox ([since version
|
||||
31](https://hacks.mozilla.org/2014/05/editable-box-model-multiple-selection-sublime-text-keys-much-more-firefox-developer-tools-episode-31/))
|
||||
and the Firebug plugin for Firefox (any version).
|
||||
|
||||
Colored output looks something like:
|
||||
|
||||
![](https://cloud.githubusercontent.com/assets/71256/3139768/b98c5fd8-e8ef-11e3-862a-f7253b6f47c6.png)
|
||||
|
||||
### stderr vs stdout
|
||||
|
||||
You can set an alternative logging method per-namespace by overriding the `log` method on a per-namespace or globally:
|
||||
|
||||
Example _stderr.js_:
|
||||
|
||||
```js
|
||||
var debug = require('../');
|
||||
var log = debug('app:log');
|
||||
|
||||
// by default console.log is used
|
||||
log('goes to stdout!');
|
||||
|
||||
var error = debug('app:error');
|
||||
// set this namespace to log via console.error
|
||||
error.log = console.error.bind(console); // don't forget to bind to console!
|
||||
error('goes to stderr');
|
||||
log('still goes to stdout!');
|
||||
|
||||
// set all output to go via console.warn
|
||||
// overrides all per-namespace log settings
|
||||
debug.log = console.warn.bind(console);
|
||||
log('now goes to stderr via console.warn');
|
||||
error('still goes to stderr, but via console.warn now');
|
||||
```
|
||||
|
||||
## Authors
|
||||
|
||||
- TJ Holowaychuk
|
||||
- Nathan Rajlich
|
||||
|
||||
## License
|
||||
|
||||
(The MIT License)
|
||||
|
||||
Copyright (c) 2014 TJ Holowaychuk <tj@vision-media.ca>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
'Software'), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@ -1,28 +0,0 @@
|
|||
{
|
||||
"name": "visionmedia/debug",
|
||||
"main": "dist/debug.js",
|
||||
"version": "2.1.1",
|
||||
"homepage": "https://github.com/visionmedia/debug",
|
||||
"authors": [
|
||||
"TJ Holowaychuk <tj@vision-media.ca>"
|
||||
],
|
||||
"description": "visionmedia/debug",
|
||||
"moduleType": [
|
||||
"amd",
|
||||
"es6",
|
||||
"globals",
|
||||
"node"
|
||||
],
|
||||
"keywords": [
|
||||
"visionmedia",
|
||||
"debug"
|
||||
],
|
||||
"license": "MIT",
|
||||
"ignore": [
|
||||
"**/.*",
|
||||
"node_modules",
|
||||
"bower_components",
|
||||
"test",
|
||||
"tests"
|
||||
]
|
||||
}
|
|
@ -1,158 +0,0 @@
|
|||
|
||||
/**
|
||||
* This is the web browser implementation of `debug()`.
|
||||
*
|
||||
* Expose `debug()` as the module.
|
||||
*/
|
||||
|
||||
exports = module.exports = require('./debug');
|
||||
exports.log = log;
|
||||
exports.formatArgs = formatArgs;
|
||||
exports.save = save;
|
||||
exports.load = load;
|
||||
exports.useColors = useColors;
|
||||
|
||||
/**
|
||||
* Use chrome.storage.local if we are in an app
|
||||
*/
|
||||
|
||||
var storage;
|
||||
|
||||
if (typeof chrome !== 'undefined' && typeof chrome.storage !== 'undefined')
|
||||
storage = chrome.storage.local;
|
||||
else
|
||||
storage = window.localStorage;
|
||||
|
||||
/**
|
||||
* Colors.
|
||||
*/
|
||||
|
||||
exports.colors = [
|
||||
'lightseagreen',
|
||||
'forestgreen',
|
||||
'goldenrod',
|
||||
'dodgerblue',
|
||||
'darkorchid',
|
||||
'crimson'
|
||||
];
|
||||
|
||||
/**
|
||||
* Currently only WebKit-based Web Inspectors, Firefox >= v31,
|
||||
* and the Firebug extension (any Firefox version) are known
|
||||
* to support "%c" CSS customizations.
|
||||
*
|
||||
* TODO: add a `localStorage` variable to explicitly enable/disable colors
|
||||
*/
|
||||
|
||||
function useColors() {
|
||||
// is webkit? http://stackoverflow.com/a/16459606/376773
|
||||
return ('WebkitAppearance' in document.documentElement.style) ||
|
||||
// is firebug? http://stackoverflow.com/a/398120/376773
|
||||
(window.console && (console.firebug || (console.exception && console.table))) ||
|
||||
// is firefox >= v31?
|
||||
// https://developer.mozilla.org/en-US/docs/Tools/Web_Console#Styling_messages
|
||||
(navigator.userAgent.toLowerCase().match(/firefox\/(\d+)/) && parseInt(RegExp.$1, 10) >= 31);
|
||||
}
|
||||
|
||||
/**
|
||||
* Map %j to `JSON.stringify()`, since no Web Inspectors do that by default.
|
||||
*/
|
||||
|
||||
exports.formatters.j = function(v) {
|
||||
return JSON.stringify(v);
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
* Colorize log arguments if enabled.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function formatArgs() {
|
||||
var args = arguments;
|
||||
var useColors = this.useColors;
|
||||
|
||||
args[0] = (useColors ? '%c' : '')
|
||||
+ this.namespace
|
||||
+ (useColors ? ' %c' : ' ')
|
||||
+ args[0]
|
||||
+ (useColors ? '%c ' : ' ')
|
||||
+ '+' + exports.humanize(this.diff);
|
||||
|
||||
if (!useColors) return args;
|
||||
|
||||
var c = 'color: ' + this.color;
|
||||
args = [args[0], c, 'color: inherit'].concat(Array.prototype.slice.call(args, 1));
|
||||
|
||||
// the final "%c" is somewhat tricky, because there could be other
|
||||
// arguments passed either before or after the %c, so we need to
|
||||
// figure out the correct index to insert the CSS into
|
||||
var index = 0;
|
||||
var lastC = 0;
|
||||
args[0].replace(/%[a-z%]/g, function(match) {
|
||||
if ('%%' === match) return;
|
||||
index++;
|
||||
if ('%c' === match) {
|
||||
// we only are interested in the *last* %c
|
||||
// (the user may have provided their own)
|
||||
lastC = index;
|
||||
}
|
||||
});
|
||||
|
||||
args.splice(lastC, 0, c);
|
||||
return args;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invokes `console.log()` when available.
|
||||
* No-op when `console.log` is not a "function".
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function log() {
|
||||
// this hackery is required for IE8/9, where
|
||||
// the `console.log` function doesn't have 'apply'
|
||||
return 'object' === typeof console
|
||||
&& console.log
|
||||
&& Function.prototype.apply.call(console.log, console, arguments);
|
||||
}
|
||||
|
||||
/**
|
||||
* Save `namespaces`.
|
||||
*
|
||||
* @param {String} namespaces
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function save(namespaces) {
|
||||
try {
|
||||
if (null == namespaces) {
|
||||
storage.removeItem('debug');
|
||||
} else {
|
||||
storage.debug = namespaces;
|
||||
}
|
||||
} catch(e) {}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load `namespaces`.
|
||||
*
|
||||
* @return {String} returns the previously persisted debug modes
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function load() {
|
||||
var r;
|
||||
try {
|
||||
r = storage.debug;
|
||||
} catch(e) {}
|
||||
return r;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable namespaces listed in `localStorage.debug` initially.
|
||||
*/
|
||||
|
||||
exports.enable(load());
|
|
@ -1,19 +0,0 @@
|
|||
{
|
||||
"name": "debug",
|
||||
"repo": "visionmedia/debug",
|
||||
"description": "small debugging utility",
|
||||
"version": "2.1.1",
|
||||
"keywords": [
|
||||
"debug",
|
||||
"log",
|
||||
"debugger"
|
||||
],
|
||||
"main": "browser.js",
|
||||
"scripts": [
|
||||
"browser.js",
|
||||
"debug.js"
|
||||
],
|
||||
"dependencies": {
|
||||
"guille/ms.js": "0.6.1"
|
||||
}
|
||||
}
|
|
@ -1,197 +0,0 @@
|
|||
|
||||
/**
|
||||
* This is the common logic for both the Node.js and web browser
|
||||
* implementations of `debug()`.
|
||||
*
|
||||
* Expose `debug()` as the module.
|
||||
*/
|
||||
|
||||
exports = module.exports = debug;
|
||||
exports.coerce = coerce;
|
||||
exports.disable = disable;
|
||||
exports.enable = enable;
|
||||
exports.enabled = enabled;
|
||||
exports.humanize = require('ms');
|
||||
|
||||
/**
|
||||
* The currently active debug mode names, and names to skip.
|
||||
*/
|
||||
|
||||
exports.names = [];
|
||||
exports.skips = [];
|
||||
|
||||
/**
|
||||
* Map of special "%n" handling functions, for the debug "format" argument.
|
||||
*
|
||||
* Valid key names are a single, lowercased letter, i.e. "n".
|
||||
*/
|
||||
|
||||
exports.formatters = {};
|
||||
|
||||
/**
|
||||
* Previously assigned color.
|
||||
*/
|
||||
|
||||
var prevColor = 0;
|
||||
|
||||
/**
|
||||
* Previous log timestamp.
|
||||
*/
|
||||
|
||||
var prevTime;
|
||||
|
||||
/**
|
||||
* Select a color.
|
||||
*
|
||||
* @return {Number}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function selectColor() {
|
||||
return exports.colors[prevColor++ % exports.colors.length];
|
||||
}
|
||||
|
||||
/**
|
||||
* Create a debugger with the given `namespace`.
|
||||
*
|
||||
* @param {String} namespace
|
||||
* @return {Function}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function debug(namespace) {
|
||||
|
||||
// define the `disabled` version
|
||||
function disabled() {
|
||||
}
|
||||
disabled.enabled = false;
|
||||
|
||||
// define the `enabled` version
|
||||
function enabled() {
|
||||
|
||||
var self = enabled;
|
||||
|
||||
// set `diff` timestamp
|
||||
var curr = +new Date();
|
||||
var ms = curr - (prevTime || curr);
|
||||
self.diff = ms;
|
||||
self.prev = prevTime;
|
||||
self.curr = curr;
|
||||
prevTime = curr;
|
||||
|
||||
// add the `color` if not set
|
||||
if (null == self.useColors) self.useColors = exports.useColors();
|
||||
if (null == self.color && self.useColors) self.color = selectColor();
|
||||
|
||||
var args = Array.prototype.slice.call(arguments);
|
||||
|
||||
args[0] = exports.coerce(args[0]);
|
||||
|
||||
if ('string' !== typeof args[0]) {
|
||||
// anything else let's inspect with %o
|
||||
args = ['%o'].concat(args);
|
||||
}
|
||||
|
||||
// apply any `formatters` transformations
|
||||
var index = 0;
|
||||
args[0] = args[0].replace(/%([a-z%])/g, function(match, format) {
|
||||
// if we encounter an escaped % then don't increase the array index
|
||||
if (match === '%%') return match;
|
||||
index++;
|
||||
var formatter = exports.formatters[format];
|
||||
if ('function' === typeof formatter) {
|
||||
var val = args[index];
|
||||
match = formatter.call(self, val);
|
||||
|
||||
// now we need to remove `args[index]` since it's inlined in the `format`
|
||||
args.splice(index, 1);
|
||||
index--;
|
||||
}
|
||||
return match;
|
||||
});
|
||||
|
||||
if ('function' === typeof exports.formatArgs) {
|
||||
args = exports.formatArgs.apply(self, args);
|
||||
}
|
||||
var logFn = enabled.log || exports.log || console.log.bind(console);
|
||||
logFn.apply(self, args);
|
||||
}
|
||||
enabled.enabled = true;
|
||||
|
||||
var fn = exports.enabled(namespace) ? enabled : disabled;
|
||||
|
||||
fn.namespace = namespace;
|
||||
|
||||
return fn;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enables a debug mode by namespaces. This can include modes
|
||||
* separated by a colon and wildcards.
|
||||
*
|
||||
* @param {String} namespaces
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function enable(namespaces) {
|
||||
exports.save(namespaces);
|
||||
|
||||
var split = (namespaces || '').split(/[\s,]+/);
|
||||
var len = split.length;
|
||||
|
||||
for (var i = 0; i < len; i++) {
|
||||
if (!split[i]) continue; // ignore empty strings
|
||||
namespaces = split[i].replace(/\*/g, '.*?');
|
||||
if (namespaces[0] === '-') {
|
||||
exports.skips.push(new RegExp('^' + namespaces.substr(1) + '$'));
|
||||
} else {
|
||||
exports.names.push(new RegExp('^' + namespaces + '$'));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Disable debug output.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function disable() {
|
||||
exports.enable('');
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if the given mode name is enabled, false otherwise.
|
||||
*
|
||||
* @param {String} name
|
||||
* @return {Boolean}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function enabled(name) {
|
||||
var i, len;
|
||||
for (i = 0, len = exports.skips.length; i < len; i++) {
|
||||
if (exports.skips[i].test(name)) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
for (i = 0, len = exports.names.length; i < len; i++) {
|
||||
if (exports.names[i].test(name)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Coerce `val`.
|
||||
*
|
||||
* @param {Mixed} val
|
||||
* @return {Mixed}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function coerce(val) {
|
||||
if (val instanceof Error) return val.stack || val.message;
|
||||
return val;
|
||||
}
|
|
@ -1,209 +0,0 @@
|
|||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var tty = require('tty');
|
||||
var util = require('util');
|
||||
|
||||
/**
|
||||
* This is the Node.js implementation of `debug()`.
|
||||
*
|
||||
* Expose `debug()` as the module.
|
||||
*/
|
||||
|
||||
exports = module.exports = require('./debug');
|
||||
exports.log = log;
|
||||
exports.formatArgs = formatArgs;
|
||||
exports.save = save;
|
||||
exports.load = load;
|
||||
exports.useColors = useColors;
|
||||
|
||||
/**
|
||||
* Colors.
|
||||
*/
|
||||
|
||||
exports.colors = [6, 2, 3, 4, 5, 1];
|
||||
|
||||
/**
|
||||
* The file descriptor to write the `debug()` calls to.
|
||||
* Set the `DEBUG_FD` env variable to override with another value. i.e.:
|
||||
*
|
||||
* $ DEBUG_FD=3 node script.js 3>debug.log
|
||||
*/
|
||||
|
||||
var fd = parseInt(process.env.DEBUG_FD, 10) || 2;
|
||||
var stream = 1 === fd ? process.stdout :
|
||||
2 === fd ? process.stderr :
|
||||
createWritableStdioStream(fd);
|
||||
|
||||
/**
|
||||
* Is stdout a TTY? Colored output is enabled when `true`.
|
||||
*/
|
||||
|
||||
function useColors() {
|
||||
var debugColors = (process.env.DEBUG_COLORS || '').trim().toLowerCase();
|
||||
if (0 === debugColors.length) {
|
||||
return tty.isatty(fd);
|
||||
} else {
|
||||
return '0' !== debugColors
|
||||
&& 'no' !== debugColors
|
||||
&& 'false' !== debugColors
|
||||
&& 'disabled' !== debugColors;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Map %o to `util.inspect()`, since Node doesn't do that out of the box.
|
||||
*/
|
||||
|
||||
var inspect = (4 === util.inspect.length ?
|
||||
// node <= 0.8.x
|
||||
function (v, colors) {
|
||||
return util.inspect(v, void 0, void 0, colors);
|
||||
} :
|
||||
// node > 0.8.x
|
||||
function (v, colors) {
|
||||
return util.inspect(v, { colors: colors });
|
||||
}
|
||||
);
|
||||
|
||||
exports.formatters.o = function(v) {
|
||||
return inspect(v, this.useColors)
|
||||
.replace(/\s*\n\s*/g, ' ');
|
||||
};
|
||||
|
||||
/**
|
||||
* Adds ANSI color escape codes if enabled.
|
||||
*
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function formatArgs() {
|
||||
var args = arguments;
|
||||
var useColors = this.useColors;
|
||||
var name = this.namespace;
|
||||
|
||||
if (useColors) {
|
||||
var c = this.color;
|
||||
|
||||
args[0] = ' \u001b[9' + c + 'm' + name + ' '
|
||||
+ '\u001b[0m'
|
||||
+ args[0] + '\u001b[3' + c + 'm'
|
||||
+ ' +' + exports.humanize(this.diff) + '\u001b[0m';
|
||||
} else {
|
||||
args[0] = new Date().toUTCString()
|
||||
+ ' ' + name + ' ' + args[0];
|
||||
}
|
||||
return args;
|
||||
}
|
||||
|
||||
/**
|
||||
* Invokes `console.error()` with the specified arguments.
|
||||
*/
|
||||
|
||||
function log() {
|
||||
return stream.write(util.format.apply(this, arguments) + '\n');
|
||||
}
|
||||
|
||||
/**
|
||||
* Save `namespaces`.
|
||||
*
|
||||
* @param {String} namespaces
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function save(namespaces) {
|
||||
if (null == namespaces) {
|
||||
// If you set a process.env field to null or undefined, it gets cast to the
|
||||
// string 'null' or 'undefined'. Just delete instead.
|
||||
delete process.env.DEBUG;
|
||||
} else {
|
||||
process.env.DEBUG = namespaces;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Load `namespaces`.
|
||||
*
|
||||
* @return {String} returns the previously persisted debug modes
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function load() {
|
||||
return process.env.DEBUG;
|
||||
}
|
||||
|
||||
/**
|
||||
* Copied from `node/src/node.js`.
|
||||
*
|
||||
* XXX: It's lame that node doesn't expose this API out-of-the-box. It also
|
||||
* relies on the undocumented `tty_wrap.guessHandleType()` which is also lame.
|
||||
*/
|
||||
|
||||
function createWritableStdioStream (fd) {
|
||||
var stream;
|
||||
var tty_wrap = process.binding('tty_wrap');
|
||||
|
||||
// Note stream._type is used for test-module-load-list.js
|
||||
|
||||
switch (tty_wrap.guessHandleType(fd)) {
|
||||
case 'TTY':
|
||||
stream = new tty.WriteStream(fd);
|
||||
stream._type = 'tty';
|
||||
|
||||
// Hack to have stream not keep the event loop alive.
|
||||
// See https://github.com/joyent/node/issues/1726
|
||||
if (stream._handle && stream._handle.unref) {
|
||||
stream._handle.unref();
|
||||
}
|
||||
break;
|
||||
|
||||
case 'FILE':
|
||||
var fs = require('fs');
|
||||
stream = new fs.SyncWriteStream(fd, { autoClose: false });
|
||||
stream._type = 'fs';
|
||||
break;
|
||||
|
||||
case 'PIPE':
|
||||
case 'TCP':
|
||||
var net = require('net');
|
||||
stream = new net.Socket({
|
||||
fd: fd,
|
||||
readable: false,
|
||||
writable: true
|
||||
});
|
||||
|
||||
// FIXME Should probably have an option in net.Socket to create a
|
||||
// stream from an existing fd which is writable only. But for now
|
||||
// we'll just add this hack and set the `readable` member to false.
|
||||
// Test: ./node test/fixtures/echo.js < /etc/passwd
|
||||
stream.readable = false;
|
||||
stream.read = null;
|
||||
stream._type = 'pipe';
|
||||
|
||||
// FIXME Hack to have stream not keep the event loop alive.
|
||||
// See https://github.com/joyent/node/issues/1726
|
||||
if (stream._handle && stream._handle.unref) {
|
||||
stream._handle.unref();
|
||||
}
|
||||
break;
|
||||
|
||||
default:
|
||||
// Probably an error on in uv_guess_handle()
|
||||
throw new Error('Implement me. Unknown stream file type!');
|
||||
}
|
||||
|
||||
// For supporting legacy API we put the FD here.
|
||||
stream.fd = fd;
|
||||
|
||||
stream._isStdio = true;
|
||||
|
||||
return stream;
|
||||
}
|
||||
|
||||
/**
|
||||
* Enable namespaces listed in `process.env.DEBUG` initially.
|
||||
*/
|
||||
|
||||
exports.enable(load());
|
|
@ -1,5 +0,0 @@
|
|||
node_modules
|
||||
test
|
||||
History.md
|
||||
Makefile
|
||||
component.json
|
|
@ -1,33 +0,0 @@
|
|||
# ms.js: miliseconds conversion utility
|
||||
|
||||
```js
|
||||
ms('1d') // 86400000
|
||||
ms('10h') // 36000000
|
||||
ms('2h') // 7200000
|
||||
ms('1m') // 60000
|
||||
ms('5s') // 5000
|
||||
ms('100') // 100
|
||||
```
|
||||
|
||||
```js
|
||||
ms(60000) // "1m"
|
||||
ms(2 * 60000) // "2m"
|
||||
ms(ms('10 hours')) // "10h"
|
||||
```
|
||||
|
||||
```js
|
||||
ms(60000, { long: true }) // "1 minute"
|
||||
ms(2 * 60000, { long: true }) // "2 minutes"
|
||||
ms(ms('10 hours', { long: true })) // "10 hours"
|
||||
```
|
||||
|
||||
- Node/Browser compatible. Published as `ms` in NPM.
|
||||
- If a number is supplied to `ms`, a string with a unit is returned.
|
||||
- If a string that contains the number is supplied, it returns it as
|
||||
a number (e.g: it returns `100` for `'100'`).
|
||||
- If you pass a string with a number and a valid unit, the number of
|
||||
equivalent ms is returned.
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
|
@ -1,111 +0,0 @@
|
|||
/**
|
||||
* Helpers.
|
||||
*/
|
||||
|
||||
var s = 1000;
|
||||
var m = s * 60;
|
||||
var h = m * 60;
|
||||
var d = h * 24;
|
||||
var y = d * 365.25;
|
||||
|
||||
/**
|
||||
* Parse or format the given `val`.
|
||||
*
|
||||
* Options:
|
||||
*
|
||||
* - `long` verbose formatting [false]
|
||||
*
|
||||
* @param {String|Number} val
|
||||
* @param {Object} options
|
||||
* @return {String|Number}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
module.exports = function(val, options){
|
||||
options = options || {};
|
||||
if ('string' == typeof val) return parse(val);
|
||||
return options.long
|
||||
? long(val)
|
||||
: short(val);
|
||||
};
|
||||
|
||||
/**
|
||||
* Parse the given `str` and return milliseconds.
|
||||
*
|
||||
* @param {String} str
|
||||
* @return {Number}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function parse(str) {
|
||||
var match = /^((?:\d+)?\.?\d+) *(ms|seconds?|s|minutes?|m|hours?|h|days?|d|years?|y)?$/i.exec(str);
|
||||
if (!match) return;
|
||||
var n = parseFloat(match[1]);
|
||||
var type = (match[2] || 'ms').toLowerCase();
|
||||
switch (type) {
|
||||
case 'years':
|
||||
case 'year':
|
||||
case 'y':
|
||||
return n * y;
|
||||
case 'days':
|
||||
case 'day':
|
||||
case 'd':
|
||||
return n * d;
|
||||
case 'hours':
|
||||
case 'hour':
|
||||
case 'h':
|
||||
return n * h;
|
||||
case 'minutes':
|
||||
case 'minute':
|
||||
case 'm':
|
||||
return n * m;
|
||||
case 'seconds':
|
||||
case 'second':
|
||||
case 's':
|
||||
return n * s;
|
||||
case 'ms':
|
||||
return n;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Short format for `ms`.
|
||||
*
|
||||
* @param {Number} ms
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function short(ms) {
|
||||
if (ms >= d) return Math.round(ms / d) + 'd';
|
||||
if (ms >= h) return Math.round(ms / h) + 'h';
|
||||
if (ms >= m) return Math.round(ms / m) + 'm';
|
||||
if (ms >= s) return Math.round(ms / s) + 's';
|
||||
return ms + 'ms';
|
||||
}
|
||||
|
||||
/**
|
||||
* Long format for `ms`.
|
||||
*
|
||||
* @param {Number} ms
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function long(ms) {
|
||||
return plural(ms, d, 'day')
|
||||
|| plural(ms, h, 'hour')
|
||||
|| plural(ms, m, 'minute')
|
||||
|| plural(ms, s, 'second')
|
||||
|| ms + ' ms';
|
||||
}
|
||||
|
||||
/**
|
||||
* Pluralization helper.
|
||||
*/
|
||||
|
||||
function plural(ms, n, name) {
|
||||
if (ms < n) return;
|
||||
if (ms < n * 1.5) return Math.floor(ms / n) + ' ' + name;
|
||||
return Math.ceil(ms / n) + ' ' + name + 's';
|
||||
}
|
46
websocket/node_modules/express/node_modules/debug/node_modules/ms/package.json
generated
vendored
46
websocket/node_modules/express/node_modules/debug/node_modules/ms/package.json
generated
vendored
|
@ -1,46 +0,0 @@
|
|||
{
|
||||
"name": "ms",
|
||||
"version": "0.6.2",
|
||||
"description": "Tiny ms conversion utility",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/guille/ms.js.git"
|
||||
},
|
||||
"main": "./index",
|
||||
"devDependencies": {
|
||||
"mocha": "*",
|
||||
"expect.js": "*",
|
||||
"serve": "*"
|
||||
},
|
||||
"component": {
|
||||
"scripts": {
|
||||
"ms/index.js": "index.js"
|
||||
}
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/guille/ms.js/issues"
|
||||
},
|
||||
"_id": "ms@0.6.2",
|
||||
"dist": {
|
||||
"shasum": "d89c2124c6fdc1353d65a8b77bf1aac4b193708c",
|
||||
"tarball": "http://registry.npmjs.org/ms/-/ms-0.6.2.tgz"
|
||||
},
|
||||
"_from": "ms@0.6.2",
|
||||
"_npmVersion": "1.2.30",
|
||||
"_npmUser": {
|
||||
"name": "rauchg",
|
||||
"email": "rauchg@gmail.com"
|
||||
},
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "rauchg",
|
||||
"email": "rauchg@gmail.com"
|
||||
}
|
||||
],
|
||||
"directories": {},
|
||||
"_shasum": "d89c2124c6fdc1353d65a8b77bf1aac4b193708c",
|
||||
"_resolved": "https://registry.npmjs.org/ms/-/ms-0.6.2.tgz",
|
||||
"readme": "ERROR: No README data found!",
|
||||
"homepage": "https://github.com/guille/ms.js",
|
||||
"scripts": {}
|
||||
}
|
|
@ -1,72 +0,0 @@
|
|||
{
|
||||
"name": "debug",
|
||||
"version": "2.1.1",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/visionmedia/debug.git"
|
||||
},
|
||||
"description": "small debugging utility",
|
||||
"keywords": [
|
||||
"debug",
|
||||
"log",
|
||||
"debugger"
|
||||
],
|
||||
"author": {
|
||||
"name": "TJ Holowaychuk",
|
||||
"email": "tj@vision-media.ca"
|
||||
},
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Nathan Rajlich",
|
||||
"email": "nathan@tootallnate.net",
|
||||
"url": "http://n8.io"
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"dependencies": {
|
||||
"ms": "0.6.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"browserify": "6.1.0",
|
||||
"mocha": "*"
|
||||
},
|
||||
"main": "./node.js",
|
||||
"browser": "./browser.js",
|
||||
"component": {
|
||||
"scripts": {
|
||||
"debug/index.js": "browser.js",
|
||||
"debug/debug.js": "debug.js"
|
||||
}
|
||||
},
|
||||
"gitHead": "24cc5c04fc8886fa9afcadea4db439f9a6186ca4",
|
||||
"bugs": {
|
||||
"url": "https://github.com/visionmedia/debug/issues"
|
||||
},
|
||||
"homepage": "https://github.com/visionmedia/debug",
|
||||
"_id": "debug@2.1.1",
|
||||
"scripts": {},
|
||||
"_shasum": "e0c548cc607adc22b537540dc3639c4236fdf90c",
|
||||
"_from": "debug@~2.1.1",
|
||||
"_npmVersion": "1.4.28",
|
||||
"_npmUser": {
|
||||
"name": "tootallnate",
|
||||
"email": "nathan@tootallnate.net"
|
||||
},
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "tjholowaychuk",
|
||||
"email": "tj@vision-media.ca"
|
||||
},
|
||||
{
|
||||
"name": "tootallnate",
|
||||
"email": "nathan@tootallnate.net"
|
||||
}
|
||||
],
|
||||
"dist": {
|
||||
"shasum": "e0c548cc607adc22b537540dc3639c4236fdf90c",
|
||||
"tarball": "http://registry.npmjs.org/debug/-/debug-2.1.1.tgz"
|
||||
},
|
||||
"directories": {},
|
||||
"_resolved": "https://registry.npmjs.org/debug/-/debug-2.1.1.tgz",
|
||||
"readme": "ERROR: No README data found!"
|
||||
}
|
|
@ -1,67 +0,0 @@
|
|||
1.0.0 / 2014-09-17
|
||||
==================
|
||||
|
||||
* No changes
|
||||
|
||||
0.4.5 / 2014-09-09
|
||||
==================
|
||||
|
||||
* Improve call speed to functions using the function wrapper
|
||||
* Support Node.js 0.6
|
||||
|
||||
0.4.4 / 2014-07-27
|
||||
==================
|
||||
|
||||
* Work-around v8 generating empty stack traces
|
||||
|
||||
0.4.3 / 2014-07-26
|
||||
==================
|
||||
|
||||
* Fix exception when global `Error.stackTraceLimit` is too low
|
||||
|
||||
0.4.2 / 2014-07-19
|
||||
==================
|
||||
|
||||
* Correct call site for wrapped functions and properties
|
||||
|
||||
0.4.1 / 2014-07-19
|
||||
==================
|
||||
|
||||
* Improve automatic message generation for function properties
|
||||
|
||||
0.4.0 / 2014-07-19
|
||||
==================
|
||||
|
||||
* Add `TRACE_DEPRECATION` environment variable
|
||||
* Remove non-standard grey color from color output
|
||||
* Support `--no-deprecation` argument
|
||||
* Support `--trace-deprecation` argument
|
||||
* Support `deprecate.property(fn, prop, message)`
|
||||
|
||||
0.3.0 / 2014-06-16
|
||||
==================
|
||||
|
||||
* Add `NO_DEPRECATION` environment variable
|
||||
|
||||
0.2.0 / 2014-06-15
|
||||
==================
|
||||
|
||||
* Add `deprecate.property(obj, prop, message)`
|
||||
* Remove `supports-color` dependency for node.js 0.8
|
||||
|
||||
0.1.0 / 2014-06-15
|
||||
==================
|
||||
|
||||
* Add `deprecate.function(fn, message)`
|
||||
* Add `process.on('deprecation', fn)` emitter
|
||||
* Automatically generate message when omitted from `deprecate()`
|
||||
|
||||
0.0.1 / 2014-06-15
|
||||
==================
|
||||
|
||||
* Fix warning for dynamic calls at singe call site
|
||||
|
||||
0.0.0 / 2014-06-15
|
||||
==================
|
||||
|
||||
* Initial implementation
|
|
@ -1,22 +0,0 @@
|
|||
(The MIT License)
|
||||
|
||||
Copyright (c) 2014 Douglas Christopher Wilson
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
'Software'), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@ -1,271 +0,0 @@
|
|||
# depd
|
||||
|
||||
[![NPM Version][npm-version-image]][npm-url]
|
||||
[![NPM Downloads][npm-downloads-image]][npm-url]
|
||||
[![Node.js Version][node-image]][node-url]
|
||||
[![Build Status][travis-image]][travis-url]
|
||||
[![Coverage Status][coveralls-image]][coveralls-url]
|
||||
[![Gratipay][gratipay-image]][gratipay-url]
|
||||
|
||||
Deprecate all the things
|
||||
|
||||
> With great modules comes great responsibility; mark things deprecated!
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
$ npm install depd
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
```js
|
||||
var deprecate = require('depd')('my-module')
|
||||
```
|
||||
|
||||
This library allows you to display deprecation messages to your users.
|
||||
This library goes above and beyond with deprecation warnings by
|
||||
introspection of the call stack (but only the bits that it is interested
|
||||
in).
|
||||
|
||||
Instead of just warning on the first invocation of a deprecated
|
||||
function and never again, this module will warn on the first invocation
|
||||
of a deprecated function per unique call site, making it ideal to alert
|
||||
users of all deprecated uses across the code base, rather than just
|
||||
whatever happens to execute first.
|
||||
|
||||
The deprecation warnings from this module also include the file and line
|
||||
information for the call into the module that the deprecated function was
|
||||
in.
|
||||
|
||||
**NOTE** this library has a similar interface to the `debug` module, and
|
||||
this module uses the calling file to get the boundary for the call stacks,
|
||||
so you should always create a new `deprecate` object in each file and not
|
||||
within some central file.
|
||||
|
||||
### depd(namespace)
|
||||
|
||||
Create a new deprecate function that uses the given namespace name in the
|
||||
messages and will display the call site prior to the stack entering the
|
||||
file this function was called from. It is highly suggested you use the
|
||||
name of your module as the namespace.
|
||||
|
||||
### deprecate(message)
|
||||
|
||||
Call this function from deprecated code to display a deprecation message.
|
||||
This message will appear once per unique caller site. Caller site is the
|
||||
first call site in the stack in a different file from the caller of this
|
||||
function.
|
||||
|
||||
If the message is omitted, a message is generated for you based on the site
|
||||
of the `deprecate()` call and will display the name of the function called,
|
||||
similar to the name displayed in a stack trace.
|
||||
|
||||
### deprecate.function(fn, message)
|
||||
|
||||
Call this function to wrap a given function in a deprecation message on any
|
||||
call to the function. An optional message can be supplied to provide a custom
|
||||
message.
|
||||
|
||||
### deprecate.property(obj, prop, message)
|
||||
|
||||
Call this function to wrap a given property on object in a deprecation message
|
||||
on any accessing or setting of the property. An optional message can be supplied
|
||||
to provide a custom message.
|
||||
|
||||
The method must be called on the object where the property belongs (not
|
||||
inherited from the prototype).
|
||||
|
||||
If the property is a data descriptor, it will be converted to an accessor
|
||||
descriptor in order to display the deprecation message.
|
||||
|
||||
### process.on('deprecation', fn)
|
||||
|
||||
This module will allow easy capturing of deprecation errors by emitting the
|
||||
errors as the type "deprecation" on the global `process`. If there are no
|
||||
listeners for this type, the errors are written to STDERR as normal, but if
|
||||
there are any listeners, nothing will be written to STDERR and instead only
|
||||
emitted. From there, you can write the errors in a different format or to a
|
||||
logging source.
|
||||
|
||||
The error represents the deprecation and is emitted only once with the same
|
||||
rules as writing to STDERR. The error has the following properties:
|
||||
|
||||
- `message` - This is the message given by the library
|
||||
- `name` - This is always `'DeprecationError'`
|
||||
- `namespace` - This is the namespace the deprecation came from
|
||||
- `stack` - This is the stack of the call to the deprecated thing
|
||||
|
||||
Example `error.stack` output:
|
||||
|
||||
```
|
||||
DeprecationError: my-cool-module deprecated oldfunction
|
||||
at Object.<anonymous> ([eval]-wrapper:6:22)
|
||||
at Module._compile (module.js:456:26)
|
||||
at evalScript (node.js:532:25)
|
||||
at startup (node.js:80:7)
|
||||
at node.js:902:3
|
||||
```
|
||||
|
||||
### process.env.NO_DEPRECATION
|
||||
|
||||
As a user of modules that are deprecated, the environment variable `NO_DEPRECATION`
|
||||
is provided as a quick solution to silencing deprecation warnings from being
|
||||
output. The format of this is similar to that of `DEBUG`:
|
||||
|
||||
```sh
|
||||
$ NO_DEPRECATION=my-module,othermod node app.js
|
||||
```
|
||||
|
||||
This will suppress deprecations from being output for "my-module" and "othermod".
|
||||
The value is a list of comma-separated namespaces. To suppress every warning
|
||||
across all namespaces, use the value `*` for a namespace.
|
||||
|
||||
Providing the argument `--no-deprecation` to the `node` executable will suppress
|
||||
all deprecations (only available in Node.js 0.8 or higher).
|
||||
|
||||
**NOTE** This will not suppress the deperecations given to any "deprecation"
|
||||
event listeners, just the output to STDERR.
|
||||
|
||||
### process.env.TRACE_DEPRECATION
|
||||
|
||||
As a user of modules that are deprecated, the environment variable `TRACE_DEPRECATION`
|
||||
is provided as a solution to getting more detailed location information in deprecation
|
||||
warnings by including the entire stack trace. The format of this is the same as
|
||||
`NO_DEPRECATION`:
|
||||
|
||||
```sh
|
||||
$ TRACE_DEPRECATION=my-module,othermod node app.js
|
||||
```
|
||||
|
||||
This will include stack traces for deprecations being output for "my-module" and
|
||||
"othermod". The value is a list of comma-separated namespaces. To trace every
|
||||
warning across all namespaces, use the value `*` for a namespace.
|
||||
|
||||
Providing the argument `--trace-deprecation` to the `node` executable will trace
|
||||
all deprecations (only available in Node.js 0.8 or higher).
|
||||
|
||||
**NOTE** This will not trace the deperecations silenced by `NO_DEPRECATION`.
|
||||
|
||||
## Display
|
||||
|
||||
![message](files/message.png)
|
||||
|
||||
When a user calls a function in your library that you mark deprecated, they
|
||||
will see the following written to STDERR (in the given colors, similar colors
|
||||
and layout to the `debug` module):
|
||||
|
||||
```
|
||||
bright cyan bright yellow
|
||||
| | reset cyan
|
||||
| | | |
|
||||
▼ ▼ ▼ ▼
|
||||
my-cool-module deprecated oldfunction [eval]-wrapper:6:22
|
||||
▲ ▲ ▲ ▲
|
||||
| | | |
|
||||
namespace | | location of mycoolmod.oldfunction() call
|
||||
| deprecation message
|
||||
the word "deprecated"
|
||||
```
|
||||
|
||||
If the user redirects their STDERR to a file or somewhere that does not support
|
||||
colors, they see (similar layout to the `debug` module):
|
||||
|
||||
```
|
||||
Sun, 15 Jun 2014 05:21:37 GMT my-cool-module deprecated oldfunction at [eval]-wrapper:6:22
|
||||
▲ ▲ ▲ ▲ ▲
|
||||
| | | | |
|
||||
timestamp of message namespace | | location of mycoolmod.oldfunction() call
|
||||
| deprecation message
|
||||
the word "deprecated"
|
||||
```
|
||||
|
||||
## Examples
|
||||
|
||||
### Deprecating all calls to a function
|
||||
|
||||
This will display a deprecated message about "oldfunction" being deprecated
|
||||
from "my-module" on STDERR.
|
||||
|
||||
```js
|
||||
var deprecate = require('depd')('my-cool-module')
|
||||
|
||||
// message automatically derived from function name
|
||||
// Object.oldfunction
|
||||
exports.oldfunction = deprecate.function(function oldfunction() {
|
||||
// all calls to function are deprecated
|
||||
})
|
||||
|
||||
// specific message
|
||||
exports.oldfunction = deprecate.function(function () {
|
||||
// all calls to function are deprecated
|
||||
}, 'oldfunction')
|
||||
```
|
||||
|
||||
### Conditionally deprecating a function call
|
||||
|
||||
This will display a deprecated message about "weirdfunction" being deprecated
|
||||
from "my-module" on STDERR when called with less than 2 arguments.
|
||||
|
||||
```js
|
||||
var deprecate = require('depd')('my-cool-module')
|
||||
|
||||
exports.weirdfunction = function () {
|
||||
if (arguments.length < 2) {
|
||||
// calls with 0 or 1 args are deprecated
|
||||
deprecate('weirdfunction args < 2')
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
When calling `deprecate` as a function, the warning is counted per call site
|
||||
within your own module, so you can display different deprecations depending
|
||||
on different situations and the users will still get all the warnings:
|
||||
|
||||
```js
|
||||
var deprecate = require('depd')('my-cool-module')
|
||||
|
||||
exports.weirdfunction = function () {
|
||||
if (arguments.length < 2) {
|
||||
// calls with 0 or 1 args are deprecated
|
||||
deprecate('weirdfunction args < 2')
|
||||
} else if (typeof arguments[0] !== 'string') {
|
||||
// calls with non-string first argument are deprecated
|
||||
deprecate('weirdfunction non-string first arg')
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### Deprecating property access
|
||||
|
||||
This will display a deprecated message about "oldprop" being deprecated
|
||||
from "my-module" on STDERR when accessed. A deprecation will be displayed
|
||||
when setting the value and when getting the value.
|
||||
|
||||
```js
|
||||
var deprecate = require('depd')('my-cool-module')
|
||||
|
||||
exports.oldprop = 'something'
|
||||
|
||||
// message automatically derives from property name
|
||||
deprecate.property(exports, 'oldprop')
|
||||
|
||||
// explicit message
|
||||
deprecate.property(exports, 'oldprop', 'oldprop >= 0.10')
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE)
|
||||
|
||||
[npm-version-image]: https://img.shields.io/npm/v/depd.svg?style=flat
|
||||
[npm-downloads-image]: https://img.shields.io/npm/dm/depd.svg?style=flat
|
||||
[npm-url]: https://npmjs.org/package/depd
|
||||
[travis-image]: https://img.shields.io/travis/dougwilson/nodejs-depd.svg?style=flat
|
||||
[travis-url]: https://travis-ci.org/dougwilson/nodejs-depd
|
||||
[coveralls-image]: https://img.shields.io/coveralls/dougwilson/nodejs-depd.svg?style=flat
|
||||
[coveralls-url]: https://coveralls.io/r/dougwilson/nodejs-depd?branch=master
|
||||
[node-image]: https://img.shields.io/node/v/depd.svg?style=flat
|
||||
[node-url]: http://nodejs.org/download/
|
||||
[gratipay-image]: https://img.shields.io/gratipay/dougwilson.svg?style=flat
|
||||
[gratipay-url]: https://www.gratipay.com/dougwilson/
|
|
@ -1,522 +0,0 @@
|
|||
/*!
|
||||
* depd
|
||||
* Copyright(c) 2014 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var callSiteToString = require('./lib/compat').callSiteToString
|
||||
var EventEmitter = require('events').EventEmitter
|
||||
var relative = require('path').relative
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
*/
|
||||
|
||||
module.exports = depd
|
||||
|
||||
/**
|
||||
* Get the path to base files on.
|
||||
*/
|
||||
|
||||
var basePath = process.cwd()
|
||||
|
||||
/**
|
||||
* Get listener count on event emitter.
|
||||
*/
|
||||
|
||||
/*istanbul ignore next*/
|
||||
var eventListenerCount = EventEmitter.listenerCount
|
||||
|| function (emitter, type) { return emitter.listeners(type).length }
|
||||
|
||||
/**
|
||||
* Determine if namespace is contained in the string.
|
||||
*/
|
||||
|
||||
function containsNamespace(str, namespace) {
|
||||
var val = str.split(/[ ,]+/)
|
||||
|
||||
namespace = String(namespace).toLowerCase()
|
||||
|
||||
for (var i = 0 ; i < val.length; i++) {
|
||||
if (!(str = val[i])) continue;
|
||||
|
||||
// namespace contained
|
||||
if (str === '*' || str.toLowerCase() === namespace) {
|
||||
return true
|
||||
}
|
||||
}
|
||||
|
||||
return false
|
||||
}
|
||||
|
||||
/**
|
||||
* Convert a data descriptor to accessor descriptor.
|
||||
*/
|
||||
|
||||
function convertDataDescriptorToAccessor(obj, prop, message) {
|
||||
var descriptor = Object.getOwnPropertyDescriptor(obj, prop)
|
||||
var value = descriptor.value
|
||||
|
||||
descriptor.get = function getter() { return value }
|
||||
|
||||
if (descriptor.writable) {
|
||||
descriptor.set = function setter(val) { return value = val }
|
||||
}
|
||||
|
||||
delete descriptor.value
|
||||
delete descriptor.writable
|
||||
|
||||
Object.defineProperty(obj, prop, descriptor)
|
||||
|
||||
return descriptor
|
||||
}
|
||||
|
||||
/**
|
||||
* Create arguments string to keep arity.
|
||||
*/
|
||||
|
||||
function createArgumentsString(arity) {
|
||||
var str = ''
|
||||
|
||||
for (var i = 0; i < arity; i++) {
|
||||
str += ', arg' + i
|
||||
}
|
||||
|
||||
return str.substr(2)
|
||||
}
|
||||
|
||||
/**
|
||||
* Create stack string from stack.
|
||||
*/
|
||||
|
||||
function createStackString(stack) {
|
||||
var str = this.name + ': ' + this.namespace
|
||||
|
||||
if (this.message) {
|
||||
str += ' deprecated ' + this.message
|
||||
}
|
||||
|
||||
for (var i = 0; i < stack.length; i++) {
|
||||
str += '\n at ' + callSiteToString(stack[i])
|
||||
}
|
||||
|
||||
return str
|
||||
}
|
||||
|
||||
/**
|
||||
* Create deprecate for namespace in caller.
|
||||
*/
|
||||
|
||||
function depd(namespace) {
|
||||
if (!namespace) {
|
||||
throw new TypeError('argument namespace is required')
|
||||
}
|
||||
|
||||
var stack = getStack()
|
||||
var site = callSiteLocation(stack[1])
|
||||
var file = site[0]
|
||||
|
||||
function deprecate(message) {
|
||||
// call to self as log
|
||||
log.call(deprecate, message)
|
||||
}
|
||||
|
||||
deprecate._file = file
|
||||
deprecate._ignored = isignored(namespace)
|
||||
deprecate._namespace = namespace
|
||||
deprecate._traced = istraced(namespace)
|
||||
deprecate._warned = Object.create(null)
|
||||
|
||||
deprecate.function = wrapfunction
|
||||
deprecate.property = wrapproperty
|
||||
|
||||
return deprecate
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if namespace is ignored.
|
||||
*/
|
||||
|
||||
function isignored(namespace) {
|
||||
/* istanbul ignore next: tested in a child processs */
|
||||
if (process.noDeprecation) {
|
||||
// --no-deprecation support
|
||||
return true
|
||||
}
|
||||
|
||||
var str = process.env.NO_DEPRECATION || ''
|
||||
|
||||
// namespace ignored
|
||||
return containsNamespace(str, namespace)
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if namespace is traced.
|
||||
*/
|
||||
|
||||
function istraced(namespace) {
|
||||
/* istanbul ignore next: tested in a child processs */
|
||||
if (process.traceDeprecation) {
|
||||
// --trace-deprecation support
|
||||
return true
|
||||
}
|
||||
|
||||
var str = process.env.TRACE_DEPRECATION || ''
|
||||
|
||||
// namespace traced
|
||||
return containsNamespace(str, namespace)
|
||||
}
|
||||
|
||||
/**
|
||||
* Display deprecation message.
|
||||
*/
|
||||
|
||||
function log(message, site) {
|
||||
var haslisteners = eventListenerCount(process, 'deprecation') !== 0
|
||||
|
||||
// abort early if no destination
|
||||
if (!haslisteners && this._ignored) {
|
||||
return
|
||||
}
|
||||
|
||||
var caller
|
||||
var callFile
|
||||
var callSite
|
||||
var i = 0
|
||||
var seen = false
|
||||
var stack = getStack()
|
||||
var file = this._file
|
||||
|
||||
if (site) {
|
||||
// provided site
|
||||
callSite = callSiteLocation(stack[1])
|
||||
callSite.name = site.name
|
||||
file = callSite[0]
|
||||
} else {
|
||||
// get call site
|
||||
i = 2
|
||||
site = callSiteLocation(stack[i])
|
||||
callSite = site
|
||||
}
|
||||
|
||||
// get caller of deprecated thing in relation to file
|
||||
for (; i < stack.length; i++) {
|
||||
caller = callSiteLocation(stack[i])
|
||||
callFile = caller[0]
|
||||
|
||||
if (callFile === file) {
|
||||
seen = true
|
||||
} else if (callFile === this._file) {
|
||||
file = this._file
|
||||
} else if (seen) {
|
||||
break
|
||||
}
|
||||
}
|
||||
|
||||
var key = caller
|
||||
? site.join(':') + '__' + caller.join(':')
|
||||
: undefined
|
||||
|
||||
if (key !== undefined && key in this._warned) {
|
||||
// already warned
|
||||
return
|
||||
}
|
||||
|
||||
this._warned[key] = true
|
||||
|
||||
// generate automatic message from call site
|
||||
if (!message) {
|
||||
message = callSite === site || !callSite.name
|
||||
? defaultMessage(site)
|
||||
: defaultMessage(callSite)
|
||||
}
|
||||
|
||||
// emit deprecation if listeners exist
|
||||
if (haslisteners) {
|
||||
var err = DeprecationError(this._namespace, message, stack.slice(i))
|
||||
process.emit('deprecation', err)
|
||||
return
|
||||
}
|
||||
|
||||
// format and write message
|
||||
var format = process.stderr.isTTY
|
||||
? formatColor
|
||||
: formatPlain
|
||||
var msg = format.call(this, message, caller, stack.slice(i))
|
||||
process.stderr.write(msg + '\n', 'utf8')
|
||||
|
||||
return
|
||||
}
|
||||
|
||||
/**
|
||||
* Get call site location as array.
|
||||
*/
|
||||
|
||||
function callSiteLocation(callSite) {
|
||||
var file = callSite.getFileName() || '<anonymous>'
|
||||
var line = callSite.getLineNumber()
|
||||
var colm = callSite.getColumnNumber()
|
||||
|
||||
if (callSite.isEval()) {
|
||||
file = callSite.getEvalOrigin() + ', ' + file
|
||||
}
|
||||
|
||||
var site = [file, line, colm]
|
||||
|
||||
site.callSite = callSite
|
||||
site.name = callSite.getFunctionName()
|
||||
|
||||
return site
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a default message from the site.
|
||||
*/
|
||||
|
||||
function defaultMessage(site) {
|
||||
var callSite = site.callSite
|
||||
var funcName = site.name
|
||||
var typeName = callSite.getTypeName()
|
||||
|
||||
// make useful anonymous name
|
||||
if (!funcName) {
|
||||
funcName = '<anonymous@' + formatLocation(site) + '>'
|
||||
}
|
||||
|
||||
// make useful type name
|
||||
if (typeName === 'Function') {
|
||||
typeName = callSite.getThis().name || typeName
|
||||
}
|
||||
|
||||
return callSite.getMethodName()
|
||||
? typeName + '.' + funcName
|
||||
: funcName
|
||||
}
|
||||
|
||||
/**
|
||||
* Format deprecation message without color.
|
||||
*/
|
||||
|
||||
function formatPlain(msg, caller, stack) {
|
||||
var timestamp = new Date().toUTCString()
|
||||
|
||||
var formatted = timestamp
|
||||
+ ' ' + this._namespace
|
||||
+ ' deprecated ' + msg
|
||||
|
||||
// add stack trace
|
||||
if (this._traced) {
|
||||
for (var i = 0; i < stack.length; i++) {
|
||||
formatted += '\n at ' + callSiteToString(stack[i])
|
||||
}
|
||||
|
||||
return formatted
|
||||
}
|
||||
|
||||
if (caller) {
|
||||
formatted += ' at ' + formatLocation(caller)
|
||||
}
|
||||
|
||||
return formatted
|
||||
}
|
||||
|
||||
/**
|
||||
* Format deprecation message with color.
|
||||
*/
|
||||
|
||||
function formatColor(msg, caller, stack) {
|
||||
var formatted = '\x1b[36;1m' + this._namespace + '\x1b[22;39m' // bold cyan
|
||||
+ ' \x1b[33;1mdeprecated\x1b[22;39m' // bold yellow
|
||||
+ ' \x1b[0m' + msg + '\x1b[39m' // reset
|
||||
|
||||
// add stack trace
|
||||
if (this._traced) {
|
||||
for (var i = 0; i < stack.length; i++) {
|
||||
formatted += '\n \x1b[36mat ' + callSiteToString(stack[i]) + '\x1b[39m' // cyan
|
||||
}
|
||||
|
||||
return formatted
|
||||
}
|
||||
|
||||
if (caller) {
|
||||
formatted += ' \x1b[36m' + formatLocation(caller) + '\x1b[39m' // cyan
|
||||
}
|
||||
|
||||
return formatted
|
||||
}
|
||||
|
||||
/**
|
||||
* Format call site location.
|
||||
*/
|
||||
|
||||
function formatLocation(callSite) {
|
||||
return relative(basePath, callSite[0])
|
||||
+ ':' + callSite[1]
|
||||
+ ':' + callSite[2]
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the stack as array of call sites.
|
||||
*/
|
||||
|
||||
function getStack() {
|
||||
var limit = Error.stackTraceLimit
|
||||
var obj = {}
|
||||
var prep = Error.prepareStackTrace
|
||||
|
||||
Error.prepareStackTrace = prepareObjectStackTrace
|
||||
Error.stackTraceLimit = Math.max(10, limit)
|
||||
|
||||
// capture the stack
|
||||
Error.captureStackTrace(obj)
|
||||
|
||||
// slice this function off the top
|
||||
var stack = obj.stack.slice(1)
|
||||
|
||||
Error.prepareStackTrace = prep
|
||||
Error.stackTraceLimit = limit
|
||||
|
||||
return stack
|
||||
}
|
||||
|
||||
/**
|
||||
* Capture call site stack from v8.
|
||||
*/
|
||||
|
||||
function prepareObjectStackTrace(obj, stack) {
|
||||
return stack
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a wrapped function in a deprecation message.
|
||||
*/
|
||||
|
||||
function wrapfunction(fn, message) {
|
||||
if (typeof fn !== 'function') {
|
||||
throw new TypeError('argument fn must be a function')
|
||||
}
|
||||
|
||||
var args = createArgumentsString(fn.length)
|
||||
var deprecate = this
|
||||
var stack = getStack()
|
||||
var site = callSiteLocation(stack[1])
|
||||
|
||||
site.name = fn.name
|
||||
|
||||
var deprecatedfn = eval('(function (' + args + ') {\n'
|
||||
+ '"use strict"\n'
|
||||
+ 'log.call(deprecate, message, site)\n'
|
||||
+ 'return fn.apply(this, arguments)\n'
|
||||
+ '})')
|
||||
|
||||
return deprecatedfn
|
||||
}
|
||||
|
||||
/**
|
||||
* Wrap property in a deprecation message.
|
||||
*/
|
||||
|
||||
function wrapproperty(obj, prop, message) {
|
||||
if (!obj || (typeof obj !== 'object' && typeof obj !== 'function')) {
|
||||
throw new TypeError('argument obj must be object')
|
||||
}
|
||||
|
||||
var descriptor = Object.getOwnPropertyDescriptor(obj, prop)
|
||||
|
||||
if (!descriptor) {
|
||||
throw new TypeError('must call property on owner object')
|
||||
}
|
||||
|
||||
if (!descriptor.configurable) {
|
||||
throw new TypeError('property must be configurable')
|
||||
}
|
||||
|
||||
var deprecate = this
|
||||
var stack = getStack()
|
||||
var site = callSiteLocation(stack[1])
|
||||
|
||||
// set site name
|
||||
site.name = prop
|
||||
|
||||
// convert data descriptor
|
||||
if ('value' in descriptor) {
|
||||
descriptor = convertDataDescriptorToAccessor(obj, prop, message)
|
||||
}
|
||||
|
||||
var get = descriptor.get
|
||||
var set = descriptor.set
|
||||
|
||||
// wrap getter
|
||||
if (typeof get === 'function') {
|
||||
descriptor.get = function getter() {
|
||||
log.call(deprecate, message, site)
|
||||
return get.apply(this, arguments)
|
||||
}
|
||||
}
|
||||
|
||||
// wrap setter
|
||||
if (typeof set === 'function') {
|
||||
descriptor.set = function setter() {
|
||||
log.call(deprecate, message, site)
|
||||
return set.apply(this, arguments)
|
||||
}
|
||||
}
|
||||
|
||||
Object.defineProperty(obj, prop, descriptor)
|
||||
}
|
||||
|
||||
/**
|
||||
* Create DeprecationError for deprecation
|
||||
*/
|
||||
|
||||
function DeprecationError(namespace, message, stack) {
|
||||
var error = new Error()
|
||||
var stackString
|
||||
|
||||
Object.defineProperty(error, 'constructor', {
|
||||
value: DeprecationError
|
||||
})
|
||||
|
||||
Object.defineProperty(error, 'message', {
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
value: message,
|
||||
writable: true
|
||||
})
|
||||
|
||||
Object.defineProperty(error, 'name', {
|
||||
enumerable: false,
|
||||
configurable: true,
|
||||
value: 'DeprecationError',
|
||||
writable: true
|
||||
})
|
||||
|
||||
Object.defineProperty(error, 'namespace', {
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
value: namespace,
|
||||
writable: true
|
||||
})
|
||||
|
||||
Object.defineProperty(error, 'stack', {
|
||||
configurable: true,
|
||||
enumerable: false,
|
||||
get: function () {
|
||||
if (stackString !== undefined) {
|
||||
return stackString
|
||||
}
|
||||
|
||||
// prepare stack trace
|
||||
return stackString = createStackString.call(this, stack)
|
||||
},
|
||||
set: function setter(val) {
|
||||
stackString = val
|
||||
}
|
||||
})
|
||||
|
||||
return error
|
||||
}
|
|
@ -1,67 +0,0 @@
|
|||
{
|
||||
"name": "depd",
|
||||
"description": "Deprecate all the things",
|
||||
"version": "1.0.0",
|
||||
"author": {
|
||||
"name": "Douglas Christopher Wilson",
|
||||
"email": "doug@somethingdoug.com"
|
||||
},
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"deprecate",
|
||||
"deprecated"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/dougwilson/nodejs-depd"
|
||||
},
|
||||
"devDependencies": {
|
||||
"benchmark": "1.0.0",
|
||||
"beautify-benchmark": "0.2.4",
|
||||
"istanbul": "0.3.2",
|
||||
"mocha": "~1.21.4",
|
||||
"should": "~4.0.4"
|
||||
},
|
||||
"files": [
|
||||
"lib/",
|
||||
"History.md",
|
||||
"LICENSE",
|
||||
"index.js",
|
||||
"Readme.md"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
},
|
||||
"scripts": {
|
||||
"bench": "node benchmark/index.js",
|
||||
"test": "mocha --reporter spec --bail --require should test/",
|
||||
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --require should test/",
|
||||
"test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter spec --require should test/"
|
||||
},
|
||||
"gitHead": "08b5a2182c8c1fdf7420e4ff8532bfd7e266a7b2",
|
||||
"bugs": {
|
||||
"url": "https://github.com/dougwilson/nodejs-depd/issues"
|
||||
},
|
||||
"homepage": "https://github.com/dougwilson/nodejs-depd",
|
||||
"_id": "depd@1.0.0",
|
||||
"_shasum": "2fda0d00e98aae2845d4991ab1bf1f2a199073d5",
|
||||
"_from": "depd@~1.0.0",
|
||||
"_npmVersion": "1.4.21",
|
||||
"_npmUser": {
|
||||
"name": "dougwilson",
|
||||
"email": "doug@somethingdoug.com"
|
||||
},
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "dougwilson",
|
||||
"email": "doug@somethingdoug.com"
|
||||
}
|
||||
],
|
||||
"dist": {
|
||||
"shasum": "2fda0d00e98aae2845d4991ab1bf1f2a199073d5",
|
||||
"tarball": "http://registry.npmjs.org/depd/-/depd-1.0.0.tgz"
|
||||
},
|
||||
"directories": {},
|
||||
"_resolved": "https://registry.npmjs.org/depd/-/depd-1.0.0.tgz",
|
||||
"readme": "ERROR: No README data found!"
|
||||
}
|
|
@ -1,2 +0,0 @@
|
|||
components
|
||||
build
|
|
@ -1,11 +0,0 @@
|
|||
|
||||
build: components index.js
|
||||
@component build
|
||||
|
||||
components:
|
||||
@Component install
|
||||
|
||||
clean:
|
||||
rm -fr build components template.js
|
||||
|
||||
.PHONY: clean
|
|
@ -1,15 +0,0 @@
|
|||
|
||||
# escape-html
|
||||
|
||||
Escape HTML entities
|
||||
|
||||
## Example
|
||||
|
||||
```js
|
||||
var escape = require('escape-html');
|
||||
escape(str);
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
MIT
|
|
@ -1,10 +0,0 @@
|
|||
{
|
||||
"name": "escape-html",
|
||||
"description": "Escape HTML entities",
|
||||
"version": "1.0.1",
|
||||
"keywords": ["escape", "html", "utility"],
|
||||
"dependencies": {},
|
||||
"scripts": [
|
||||
"index.js"
|
||||
]
|
||||
}
|
|
@ -1,16 +0,0 @@
|
|||
/**
|
||||
* Escape special characters in the given string of html.
|
||||
*
|
||||
* @param {String} html
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
module.exports = function(html) {
|
||||
return String(html)
|
||||
.replace(/&/g, '&')
|
||||
.replace(/"/g, '"')
|
||||
.replace(/'/g, ''')
|
||||
.replace(/</g, '<')
|
||||
.replace(/>/g, '>');
|
||||
}
|
|
@ -1,47 +0,0 @@
|
|||
{
|
||||
"name": "escape-html",
|
||||
"description": "Escape HTML entities",
|
||||
"version": "1.0.1",
|
||||
"keywords": [
|
||||
"escape",
|
||||
"html",
|
||||
"utility"
|
||||
],
|
||||
"dependencies": {},
|
||||
"main": "index.js",
|
||||
"component": {
|
||||
"scripts": {
|
||||
"escape-html/index.js": "index.js"
|
||||
}
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/component/escape-html.git"
|
||||
},
|
||||
"readme": "\n# escape-html\n\n Escape HTML entities\n\n## Example\n\n```js\nvar escape = require('escape-html');\nescape(str);\n```\n\n## License\n\n MIT",
|
||||
"readmeFilename": "Readme.md",
|
||||
"bugs": {
|
||||
"url": "https://github.com/component/escape-html/issues"
|
||||
},
|
||||
"homepage": "https://github.com/component/escape-html",
|
||||
"_id": "escape-html@1.0.1",
|
||||
"dist": {
|
||||
"shasum": "181a286ead397a39a92857cfb1d43052e356bff0",
|
||||
"tarball": "http://registry.npmjs.org/escape-html/-/escape-html-1.0.1.tgz"
|
||||
},
|
||||
"_from": "escape-html@1.0.1",
|
||||
"_npmVersion": "1.3.15",
|
||||
"_npmUser": {
|
||||
"name": "tjholowaychuk",
|
||||
"email": "tj@vision-media.ca"
|
||||
},
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "tjholowaychuk",
|
||||
"email": "tj@vision-media.ca"
|
||||
}
|
||||
],
|
||||
"directories": {},
|
||||
"_shasum": "181a286ead397a39a92857cfb1d43052e356bff0",
|
||||
"_resolved": "https://registry.npmjs.org/escape-html/-/escape-html-1.0.1.tgz"
|
||||
}
|
|
@ -1,55 +0,0 @@
|
|||
1.5.1 / 2014-11-19
|
||||
==================
|
||||
|
||||
* deps: crc@3.2.1
|
||||
- Minor fixes
|
||||
|
||||
1.5.0 / 2014-10-14
|
||||
==================
|
||||
|
||||
* Improve string performance
|
||||
* Slightly improve speed for weak ETags over 1KB
|
||||
|
||||
1.4.0 / 2014-09-21
|
||||
==================
|
||||
|
||||
* Support "fake" stats objects
|
||||
* Support Node.js 0.6
|
||||
|
||||
1.3.1 / 2014-09-14
|
||||
==================
|
||||
|
||||
* Use the (new and improved) `crc` for crc32
|
||||
|
||||
1.3.0 / 2014-08-29
|
||||
==================
|
||||
|
||||
* Default strings to strong ETags
|
||||
* Improve speed for weak ETags over 1KB
|
||||
|
||||
1.2.1 / 2014-08-29
|
||||
==================
|
||||
|
||||
* Use the (much faster) `buffer-crc32` for crc32
|
||||
|
||||
1.2.0 / 2014-08-24
|
||||
==================
|
||||
|
||||
* Add support for file stat objects
|
||||
|
||||
1.1.0 / 2014-08-24
|
||||
==================
|
||||
|
||||
* Add fast-path for empty entity
|
||||
* Add weak ETag generation
|
||||
* Shrink size of generated ETags
|
||||
|
||||
1.0.1 / 2014-08-24
|
||||
==================
|
||||
|
||||
* Fix behavior of string containing Unicode
|
||||
|
||||
1.0.0 / 2014-05-18
|
||||
==================
|
||||
|
||||
* Initial release
|
|
@ -1,22 +0,0 @@
|
|||
(The MIT License)
|
||||
|
||||
Copyright (c) 2014 Douglas Christopher Wilson
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
'Software'), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@ -1,141 +0,0 @@
|
|||
# etag
|
||||
|
||||
[![NPM Version][npm-image]][npm-url]
|
||||
[![NPM Downloads][downloads-image]][downloads-url]
|
||||
[![Node.js Version][node-version-image]][node-version-url]
|
||||
[![Build Status][travis-image]][travis-url]
|
||||
[![Test Coverage][coveralls-image]][coveralls-url]
|
||||
|
||||
Create simple ETags
|
||||
|
||||
## Installation
|
||||
|
||||
```sh
|
||||
$ npm install etag
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
```js
|
||||
var etag = require('etag')
|
||||
```
|
||||
|
||||
### etag(entity, [options])
|
||||
|
||||
Generate a strong ETag for the given entity. This should be the complete
|
||||
body of the entity. Strings, `Buffer`s, and `fs.Stats` are accepted. By
|
||||
default, a strong ETag is generated except for `fs.Stats`, which will
|
||||
generate a weak ETag (this can be overwritten by `options.weak`).
|
||||
|
||||
```js
|
||||
res.setHeader('ETag', etag(body))
|
||||
```
|
||||
|
||||
#### Options
|
||||
|
||||
`etag` accepts these properties in the options object.
|
||||
|
||||
##### weak
|
||||
|
||||
Specifies if a "strong" or a "weak" ETag will be generated. The ETag can only
|
||||
really be a strong as the given input.
|
||||
|
||||
## Testing
|
||||
|
||||
```sh
|
||||
$ npm test
|
||||
```
|
||||
|
||||
## Benchmark
|
||||
|
||||
```bash
|
||||
$ npm run-script bench
|
||||
|
||||
> etag@1.5.1 bench nodejs-etag
|
||||
> node benchmark/index.js
|
||||
|
||||
> node benchmark/body0-100b.js
|
||||
|
||||
100B body
|
||||
|
||||
1 test completed.
|
||||
2 tests completed.
|
||||
3 tests completed.
|
||||
4 tests completed.
|
||||
|
||||
buffer - strong x 425,007 ops/sec ±1.47% (184 runs sampled)
|
||||
* buffer - weak x 1,009,859 ops/sec ±0.18% (197 runs sampled)
|
||||
string - strong x 442,096 ops/sec ±1.20% (181 runs sampled)
|
||||
string - weak x 325,063 ops/sec ±0.31% (192 runs sampled)
|
||||
|
||||
> node benchmark/body1-1kb.js
|
||||
|
||||
1KB body
|
||||
|
||||
1 test completed.
|
||||
2 tests completed.
|
||||
3 tests completed.
|
||||
4 tests completed.
|
||||
|
||||
buffer - strong x 263,069 ops/sec ±1.60% (190 runs sampled)
|
||||
* buffer - weak x 295,732 ops/sec ±0.43% (199 runs sampled)
|
||||
string - strong x 274,822 ops/sec ±1.15% (191 runs sampled)
|
||||
string - weak x 169,473 ops/sec ±1.59% (194 runs sampled)
|
||||
|
||||
> node benchmark/body2-5kb.js
|
||||
|
||||
5KB body
|
||||
|
||||
1 test completed.
|
||||
2 tests completed.
|
||||
3 tests completed.
|
||||
4 tests completed.
|
||||
|
||||
buffer - strong x 104,299 ops/sec ±0.60% (193 runs sampled)
|
||||
* buffer - weak x 108,126 ops/sec ±0.65% (196 runs sampled)
|
||||
string - strong x 101,736 ops/sec ±0.78% (194 runs sampled)
|
||||
string - weak x 101,266 ops/sec ±0.85% (192 runs sampled)
|
||||
|
||||
> node benchmark/body3-10kb.js
|
||||
|
||||
10KB body
|
||||
|
||||
1 test completed.
|
||||
2 tests completed.
|
||||
3 tests completed.
|
||||
4 tests completed.
|
||||
|
||||
buffer - strong x 59,007 ops/sec ±0.29% (198 runs sampled)
|
||||
* buffer - weak x 60,968 ops/sec ±0.48% (197 runs sampled)
|
||||
string - strong x 51,873 ops/sec ±1.78% (178 runs sampled)
|
||||
string - weak x 52,307 ops/sec ±2.63% (193 runs sampled)
|
||||
|
||||
> node benchmark/body4-100kb.js
|
||||
|
||||
100KB body
|
||||
|
||||
1 test completed.
|
||||
2 tests completed.
|
||||
3 tests completed.
|
||||
4 tests completed.
|
||||
|
||||
buffer - strong x 6,712 ops/sec ±0.11% (198 runs sampled)
|
||||
* buffer - weak x 6,716 ops/sec ±0.50% (196 runs sampled)
|
||||
string - strong x 6,397 ops/sec ±0.36% (196 runs sampled)
|
||||
string - weak x 6,635 ops/sec ±0.15% (198 runs sampled)
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE)
|
||||
|
||||
[npm-image]: https://img.shields.io/npm/v/etag.svg?style=flat
|
||||
[npm-url]: https://npmjs.org/package/etag
|
||||
[node-version-image]: https://img.shields.io/node/v/etag.svg?style=flat
|
||||
[node-version-url]: http://nodejs.org/download/
|
||||
[travis-image]: https://img.shields.io/travis/jshttp/etag.svg?style=flat
|
||||
[travis-url]: https://travis-ci.org/jshttp/etag
|
||||
[coveralls-image]: https://img.shields.io/coveralls/jshttp/etag.svg?style=flat
|
||||
[coveralls-url]: https://coveralls.io/r/jshttp/etag?branch=master
|
||||
[downloads-image]: https://img.shields.io/npm/dm/etag.svg?style=flat
|
||||
[downloads-url]: https://npmjs.org/package/etag
|
|
@ -1,171 +0,0 @@
|
|||
/*!
|
||||
* etag
|
||||
* Copyright(c) 2014 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
*/
|
||||
|
||||
module.exports = etag
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var crc = require('crc').crc32
|
||||
var crypto = require('crypto')
|
||||
var Stats = require('fs').Stats
|
||||
|
||||
/**
|
||||
* Module variables.
|
||||
*/
|
||||
|
||||
var crc32threshold = 1000 // 1KB
|
||||
var NULL = new Buffer([0])
|
||||
var toString = Object.prototype.toString
|
||||
|
||||
/**
|
||||
* Create a simple ETag.
|
||||
*
|
||||
* @param {string|Buffer|Stats} entity
|
||||
* @param {object} [options]
|
||||
* @param {boolean} [options.weak]
|
||||
* @return {String}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function etag(entity, options) {
|
||||
if (entity == null) {
|
||||
throw new TypeError('argument entity is required')
|
||||
}
|
||||
|
||||
var isStats = isstats(entity)
|
||||
var weak = options && typeof options.weak === 'boolean'
|
||||
? options.weak
|
||||
: isStats
|
||||
|
||||
// support fs.Stats object
|
||||
if (isStats) {
|
||||
return stattag(entity, weak)
|
||||
}
|
||||
|
||||
if (typeof entity !== 'string' && !Buffer.isBuffer(entity)) {
|
||||
throw new TypeError('argument entity must be string, Buffer, or fs.Stats')
|
||||
}
|
||||
|
||||
var hash = weak
|
||||
? weakhash(entity)
|
||||
: stronghash(entity)
|
||||
|
||||
return weak
|
||||
? 'W/"' + hash + '"'
|
||||
: '"' + hash + '"'
|
||||
}
|
||||
|
||||
/**
|
||||
* Determine if object is a Stats object.
|
||||
*
|
||||
* @param {object} obj
|
||||
* @return {boolean}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function isstats(obj) {
|
||||
// not even an object
|
||||
if (obj === null || typeof obj !== 'object') {
|
||||
return false
|
||||
}
|
||||
|
||||
// genuine fs.Stats
|
||||
if (obj instanceof Stats) {
|
||||
return true
|
||||
}
|
||||
|
||||
// quack quack
|
||||
return 'atime' in obj && toString.call(obj.atime) === '[object Date]'
|
||||
&& 'ctime' in obj && toString.call(obj.ctime) === '[object Date]'
|
||||
&& 'mtime' in obj && toString.call(obj.mtime) === '[object Date]'
|
||||
&& 'ino' in obj && typeof obj.ino === 'number'
|
||||
&& 'size' in obj && typeof obj.size === 'number'
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a tag for a stat.
|
||||
*
|
||||
* @param {Buffer} entity
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function stattag(stat, weak) {
|
||||
var mtime = stat.mtime.toISOString()
|
||||
var size = stat.size.toString(16)
|
||||
|
||||
if (weak) {
|
||||
return 'W/"' + size + '-' + crc(mtime) + '"'
|
||||
}
|
||||
|
||||
var hash = crypto
|
||||
.createHash('md5')
|
||||
.update('file', 'utf8')
|
||||
.update(NULL)
|
||||
.update(size, 'utf8')
|
||||
.update(NULL)
|
||||
.update(mtime, 'utf8')
|
||||
.digest('base64')
|
||||
|
||||
return '"' + hash + '"'
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a strong hash.
|
||||
*
|
||||
* @param {Buffer} entity
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function stronghash(entity) {
|
||||
if (entity.length === 0) {
|
||||
// fast-path empty
|
||||
return '1B2M2Y8AsgTpgAmY7PhCfg=='
|
||||
}
|
||||
|
||||
return crypto
|
||||
.createHash('md5')
|
||||
.update(entity, 'utf8')
|
||||
.digest('base64')
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a weak hash.
|
||||
*
|
||||
* @param {Buffer} entity
|
||||
* @return {String}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function weakhash(entity) {
|
||||
if (entity.length === 0) {
|
||||
// fast-path empty
|
||||
return '0-0'
|
||||
}
|
||||
|
||||
var len = typeof entity === 'string'
|
||||
? Buffer.byteLength(entity, 'utf8')
|
||||
: entity.length
|
||||
|
||||
if (len <= crc32threshold) {
|
||||
// crc32 plus length when it's fast
|
||||
// crc(str) only accepts utf-8 encoding
|
||||
return len.toString(16) + '-' + crc(entity).toString(16)
|
||||
}
|
||||
|
||||
// use md4 for long strings
|
||||
return crypto
|
||||
.createHash('md4')
|
||||
.update(entity, 'utf8')
|
||||
.digest('base64')
|
||||
}
|
|
@ -1,5 +0,0 @@
|
|||
benchmark
|
||||
src
|
||||
test
|
||||
.travis.yml
|
||||
bitcoin.png
|
|
@ -1,22 +0,0 @@
|
|||
The MIT License (MIT)
|
||||
|
||||
Copyright 2014 Alex Gorbatchev
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
"Software"), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
||||
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
||||
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
||||
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@ -1,98 +0,0 @@
|
|||
# crc
|
||||
|
||||
[![GitTip](http://img.shields.io/gittip/alexgorbatchev.svg?style=flat)](https://www.gittip.com/alexgorbatchev/)
|
||||
[![Dependency status](http://img.shields.io/david/alexgorbatchev/node-crc.svg?style=flat)](https://david-dm.org/alexgorbatchev/node-crc)
|
||||
[![devDependency Status](http://img.shields.io/david/dev/alexgorbatchev/node-crc.svg?style=flat)](https://david-dm.org/alexgorbatchev/node-crc#info=devDependencies)
|
||||
[![Build Status](http://img.shields.io/travis/alexgorbatchev/node-crc.svg?style=flat&branch=master)](https://travis-ci.org/alexgorbatchev/node-crc)
|
||||
|
||||
[![NPM](https://nodei.co/npm/crc.svg?style=flat)](https://npmjs.org/package/node-crc)
|
||||
|
||||
Module for calculating Cyclic Redundancy Check (CRC).
|
||||
|
||||
## Features
|
||||
|
||||
* Full test suite comparing values against reference `pycrc` implementation.
|
||||
* Version 3.x is 3x to 4x faster than version 2.x.
|
||||
* Pure JavaScript implementation, no dependencies.
|
||||
* Provides CRC Tables for optimized calculations.
|
||||
* Provides support for the following CRC algorithms:
|
||||
* CRC1 `crc.crc1(…)`
|
||||
* CRC8 `crc.crc8(…)`
|
||||
* CRC8 1-Wire `crc.crc81wire(…)`
|
||||
* CRC16 `crc.crc16(…)`
|
||||
* CRC16 CCITT `crc.crc16ccitt(…)`
|
||||
* CRC16 Modbus `crc.crc16modbus(…)`
|
||||
* CRC24 `crc.crc24(…)`
|
||||
* CRC32 `crc.crc32(…)`
|
||||
|
||||
## IMPORTANT
|
||||
|
||||
If you've used `crc` module prior to version 2.x, you might have some inconsistentcies with the current implementation because it relied on very old code and wasn't checked against reference implementation. If you upgrading from 1.x, please take special care.
|
||||
|
||||
## Support
|
||||
|
||||
<a href="https://blockchain.info/address/1CZyBREeHTmy8C5zVGHZHPwqBuWFmEuUCQ"><img src="bitcoin.png" width="150" align="right"/></a> Please support me on [GitTip](https://www.gittip.com/alexgorbatchev/). I've spend days developing and grooming this module and hope to spend more time. If you have bitcoin, please use the QR code or this wallet address [`1CZyBREeHTmy8C5zVGHZHPwqBuWFmEuUCQ`](https://blockchain.info/address/1CZyBREeHTmy8C5zVGHZHPwqBuWFmEuUCQ):
|
||||
|
||||
## Installation
|
||||
|
||||
npm install crc
|
||||
|
||||
## Running tests
|
||||
|
||||
$ npm install
|
||||
$ npm test
|
||||
|
||||
## Usage Example
|
||||
|
||||
Calculate a CRC32:
|
||||
|
||||
var crc = require('crc');
|
||||
|
||||
crc.crc32('hello').toString(16);
|
||||
# => "3610a686"
|
||||
|
||||
Calculate a CRC32 of a file:
|
||||
|
||||
crc.crc32(fs.readFileSync('README.md', 'utf8')).toString(16);
|
||||
# => "127ad531"
|
||||
|
||||
Or using a `Buffer`:
|
||||
|
||||
crc.crc32(fs.readFileSync('README.md')).toString(16);
|
||||
# => "127ad531"
|
||||
|
||||
Incrementally calculate a CRC32:
|
||||
|
||||
value = crc32('one');
|
||||
value = crc32('two', value);
|
||||
value = crc32('three', value);
|
||||
value.toString(16);
|
||||
# => "09e1c092"
|
||||
|
||||
## Thanks!
|
||||
|
||||
[pycrc](http://www.tty1.net/pycrc/) library is which the source of all of the CRC tables.
|
||||
|
||||
# License
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2014 Alex Gorbatchev
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
58
websocket/node_modules/express/node_modules/etag/node_modules/crc/package.json
generated
vendored
58
websocket/node_modules/express/node_modules/etag/node_modules/crc/package.json
generated
vendored
|
@ -1,58 +0,0 @@
|
|||
{
|
||||
"name": "crc",
|
||||
"version": "3.2.1",
|
||||
"description": "Various CRC JavaScript implementations",
|
||||
"keywords": [
|
||||
"crc"
|
||||
],
|
||||
"main": "./lib/index.js",
|
||||
"scripts": {
|
||||
"test": "mocha test/*.spec.coffee",
|
||||
"pretest": "coffee --bare --output ./lib --compile ./src/*.coffee"
|
||||
},
|
||||
"author": {
|
||||
"name": "Alex Gorbatchev",
|
||||
"url": "https://github.com/alexgorbatchev"
|
||||
},
|
||||
"devDependencies": {
|
||||
"beautify-benchmark": "^0.2.4",
|
||||
"benchmark": "^1.0.0",
|
||||
"buffer-crc32": "^0.2.3",
|
||||
"chai": "~1.9.1",
|
||||
"coffee-errors": "~0.8.6",
|
||||
"coffee-script": "~1.7.1",
|
||||
"mocha": "*",
|
||||
"seedrandom": "^2.3.6"
|
||||
},
|
||||
"homepage": "https://github.com/alexgorbatchev/node-crc",
|
||||
"bugs": {
|
||||
"url": "https://github.com/alexgorbatchev/node-crc/issues"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "git://github.com/alexgorbatchev/node-crc.git"
|
||||
},
|
||||
"license": "MIT",
|
||||
"gitHead": "71caf362b061992bfe4ca8706ee264e764d2e88e",
|
||||
"_id": "crc@3.2.1",
|
||||
"_shasum": "5d9c8fb77a245cd5eca291e5d2d005334bab0082",
|
||||
"_from": "crc@3.2.1",
|
||||
"_npmVersion": "1.4.13",
|
||||
"_npmUser": {
|
||||
"name": "alexgorbatchev",
|
||||
"email": "alex.gorbatchev@gmail.com"
|
||||
},
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "alexgorbatchev",
|
||||
"email": "alex.gorbatchev@gmail.com"
|
||||
}
|
||||
],
|
||||
"dist": {
|
||||
"shasum": "5d9c8fb77a245cd5eca291e5d2d005334bab0082",
|
||||
"tarball": "http://registry.npmjs.org/crc/-/crc-3.2.1.tgz"
|
||||
},
|
||||
"directories": {},
|
||||
"_resolved": "https://registry.npmjs.org/crc/-/crc-3.2.1.tgz",
|
||||
"readme": "ERROR: No README data found!"
|
||||
}
|
|
@ -1,75 +0,0 @@
|
|||
{
|
||||
"name": "etag",
|
||||
"description": "Create simple ETags",
|
||||
"version": "1.5.1",
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Douglas Christopher Wilson",
|
||||
"email": "doug@somethingdoug.com"
|
||||
},
|
||||
{
|
||||
"name": "David Björklund",
|
||||
"email": "david.bjorklund@gmail.com"
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"etag",
|
||||
"http",
|
||||
"res"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/jshttp/etag"
|
||||
},
|
||||
"dependencies": {
|
||||
"crc": "3.2.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"benchmark": "1.0.0",
|
||||
"beautify-benchmark": "0.2.4",
|
||||
"istanbul": "0.3.2",
|
||||
"mocha": "~1.21.4",
|
||||
"seedrandom": "~2.3.6"
|
||||
},
|
||||
"files": [
|
||||
"LICENSE",
|
||||
"HISTORY.md",
|
||||
"index.js"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
},
|
||||
"scripts": {
|
||||
"bench": "node benchmark/index.js",
|
||||
"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/"
|
||||
},
|
||||
"gitHead": "27335e2265388109e50a9f037452081dc8a8260f",
|
||||
"bugs": {
|
||||
"url": "https://github.com/jshttp/etag/issues"
|
||||
},
|
||||
"homepage": "https://github.com/jshttp/etag",
|
||||
"_id": "etag@1.5.1",
|
||||
"_shasum": "54c50de04ee42695562925ac566588291be7e9ea",
|
||||
"_from": "etag@~1.5.1",
|
||||
"_npmVersion": "1.4.21",
|
||||
"_npmUser": {
|
||||
"name": "dougwilson",
|
||||
"email": "doug@somethingdoug.com"
|
||||
},
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "dougwilson",
|
||||
"email": "doug@somethingdoug.com"
|
||||
}
|
||||
],
|
||||
"dist": {
|
||||
"shasum": "54c50de04ee42695562925ac566588291be7e9ea",
|
||||
"tarball": "http://registry.npmjs.org/etag/-/etag-1.5.1.tgz"
|
||||
},
|
||||
"directories": {},
|
||||
"_resolved": "https://registry.npmjs.org/etag/-/etag-1.5.1.tgz",
|
||||
"readme": "ERROR: No README data found!"
|
||||
}
|
|
@ -1,57 +0,0 @@
|
|||
0.3.3 / 2015-01-01
|
||||
==================
|
||||
|
||||
* deps: debug@~2.1.1
|
||||
* deps: on-finished@~2.2.0
|
||||
|
||||
0.3.2 / 2014-10-22
|
||||
==================
|
||||
|
||||
* deps: on-finished@~2.1.1
|
||||
- Fix handling of pipelined requests
|
||||
|
||||
0.3.1 / 2014-10-16
|
||||
==================
|
||||
|
||||
* deps: debug@~2.1.0
|
||||
- Implement `DEBUG_FD` env variable support
|
||||
|
||||
0.3.0 / 2014-09-17
|
||||
==================
|
||||
|
||||
* Terminate in progress response only on error
|
||||
* Use `on-finished` to determine request status
|
||||
|
||||
0.2.0 / 2014-09-03
|
||||
==================
|
||||
|
||||
* Set `X-Content-Type-Options: nosniff` header
|
||||
* deps: debug@~2.0.0
|
||||
|
||||
0.1.0 / 2014-07-16
|
||||
==================
|
||||
|
||||
* Respond after request fully read
|
||||
- prevents hung responses and socket hang ups
|
||||
* deps: debug@1.0.4
|
||||
|
||||
0.0.3 / 2014-07-11
|
||||
==================
|
||||
|
||||
* deps: debug@1.0.3
|
||||
- Add support for multiple wildcards in namespaces
|
||||
|
||||
0.0.2 / 2014-06-19
|
||||
==================
|
||||
|
||||
* Handle invalid status codes
|
||||
|
||||
0.0.1 / 2014-06-05
|
||||
==================
|
||||
|
||||
* deps: debug@1.0.2
|
||||
|
||||
0.0.0 / 2014-06-05
|
||||
==================
|
||||
|
||||
* Extracted from connect/express
|
|
@ -1,22 +0,0 @@
|
|||
(The MIT License)
|
||||
|
||||
Copyright (c) 2014 Douglas Christopher Wilson <doug@somethingdoug.com>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
'Software'), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@ -1,133 +0,0 @@
|
|||
# finalhandler
|
||||
|
||||
[![NPM Version][npm-image]][npm-url]
|
||||
[![NPM Downloads][downloads-image]][downloads-url]
|
||||
[![Node.js Version][node-image]][node-url]
|
||||
[![Build Status][travis-image]][travis-url]
|
||||
[![Test Coverage][coveralls-image]][coveralls-url]
|
||||
|
||||
Node.js function to invoke as the final step to respond to HTTP request.
|
||||
|
||||
## Installation
|
||||
|
||||
```sh
|
||||
$ npm install finalhandler
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
```js
|
||||
var finalhandler = require('finalhandler')
|
||||
```
|
||||
|
||||
### finalhandler(req, res, [options])
|
||||
|
||||
Returns function to be invoked as the final step for the given `req` and `res`.
|
||||
This function is to be invoked as `fn(err)`. If `err` is falsy, the handler will
|
||||
write out a 404 response to the `res`. If it is truthy, an error response will
|
||||
be written out to the `res`, and `res.statusCode` is set from `err.status`.
|
||||
|
||||
The final handler will also unpipe anything from `req` when it is invoked.
|
||||
|
||||
#### options.env
|
||||
|
||||
By default, the environment is determined by `NODE_ENV` variable, but it can be
|
||||
overridden by this option.
|
||||
|
||||
#### options.onerror
|
||||
|
||||
Provide a function to be called with the `err` when it exists. Can be used for
|
||||
writing errors to a central location without excessive function generation. Called
|
||||
as `onerror(err, req, res)`.
|
||||
|
||||
## Examples
|
||||
|
||||
### always 404
|
||||
|
||||
```js
|
||||
var finalhandler = require('finalhandler')
|
||||
var http = require('http')
|
||||
|
||||
var server = http.createServer(function (req, res) {
|
||||
var done = finalhandler(req, res)
|
||||
done()
|
||||
})
|
||||
|
||||
server.listen(3000)
|
||||
```
|
||||
|
||||
### perform simple action
|
||||
|
||||
```js
|
||||
var finalhandler = require('finalhandler')
|
||||
var fs = require('fs')
|
||||
var http = require('http')
|
||||
|
||||
var server = http.createServer(function (req, res) {
|
||||
var done = finalhandler(req, res)
|
||||
|
||||
fs.readFile('index.html', function (err, buf) {
|
||||
if (err) return done(err)
|
||||
res.setHeader('Content-Type', 'text/html')
|
||||
res.end(buf)
|
||||
})
|
||||
})
|
||||
|
||||
server.listen(3000)
|
||||
```
|
||||
|
||||
### use with middleware-style functions
|
||||
|
||||
```js
|
||||
var finalhandler = require('finalhandler')
|
||||
var http = require('http')
|
||||
var serveStatic = require('serve-static')
|
||||
|
||||
var serve = serveStatic('public')
|
||||
|
||||
var server = http.createServer(function (req, res) {
|
||||
var done = finalhandler(req, res)
|
||||
serve(req, res, done)
|
||||
})
|
||||
|
||||
server.listen(3000)
|
||||
```
|
||||
|
||||
### keep log of all errors
|
||||
|
||||
```js
|
||||
var finalhandler = require('finalhandler')
|
||||
var fs = require('fs')
|
||||
var http = require('http')
|
||||
|
||||
var server = http.createServer(function (req, res) {
|
||||
var done = finalhandler(req, res, {onerror: logerror})
|
||||
|
||||
fs.readFile('index.html', function (err, buf) {
|
||||
if (err) return done(err)
|
||||
res.setHeader('Content-Type', 'text/html')
|
||||
res.end(buf)
|
||||
})
|
||||
})
|
||||
|
||||
server.listen(3000)
|
||||
|
||||
function logerror(err) {
|
||||
console.error(err.stack || err.toString())
|
||||
}
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE)
|
||||
|
||||
[npm-image]: https://img.shields.io/npm/v/finalhandler.svg?style=flat
|
||||
[npm-url]: https://npmjs.org/package/finalhandler
|
||||
[node-image]: https://img.shields.io/node/v/finalhandler.svg?style=flat
|
||||
[node-url]: http://nodejs.org/download/
|
||||
[travis-image]: https://img.shields.io/travis/pillarjs/finalhandler.svg?style=flat
|
||||
[travis-url]: https://travis-ci.org/pillarjs/finalhandler
|
||||
[coveralls-image]: https://img.shields.io/coveralls/pillarjs/finalhandler.svg?style=flat
|
||||
[coveralls-url]: https://coveralls.io/r/pillarjs/finalhandler?branch=master
|
||||
[downloads-image]: https://img.shields.io/npm/dm/finalhandler.svg?style=flat
|
||||
[downloads-url]: https://npmjs.org/package/finalhandler
|
|
@ -1,171 +0,0 @@
|
|||
/*!
|
||||
* finalhandler
|
||||
* Copyright(c) 2014 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* Module dependencies.
|
||||
*/
|
||||
|
||||
var debug = require('debug')('finalhandler')
|
||||
var escapeHtml = require('escape-html')
|
||||
var http = require('http')
|
||||
var onFinished = require('on-finished')
|
||||
|
||||
/**
|
||||
* Variables.
|
||||
*/
|
||||
|
||||
/* istanbul ignore next */
|
||||
var defer = typeof setImmediate === 'function'
|
||||
? setImmediate
|
||||
: function(fn){ process.nextTick(fn.bind.apply(fn, arguments)) }
|
||||
var isFinished = onFinished.isFinished
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
*/
|
||||
|
||||
module.exports = finalhandler
|
||||
|
||||
/**
|
||||
* Final handler:
|
||||
*
|
||||
* @param {Request} req
|
||||
* @param {Response} res
|
||||
* @param {Object} [options]
|
||||
* @return {Function}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function finalhandler(req, res, options) {
|
||||
options = options || {}
|
||||
|
||||
// get environment
|
||||
var env = options.env || process.env.NODE_ENV || 'development'
|
||||
|
||||
// get error callback
|
||||
var onerror = options.onerror
|
||||
|
||||
return function (err) {
|
||||
var msg
|
||||
|
||||
// ignore 404 on in-flight response
|
||||
if (!err && res._header) {
|
||||
debug('cannot 404 after headers sent')
|
||||
return
|
||||
}
|
||||
|
||||
// unhandled error
|
||||
if (err) {
|
||||
// default status code to 500
|
||||
if (!res.statusCode || res.statusCode < 400) {
|
||||
res.statusCode = 500
|
||||
}
|
||||
|
||||
// respect err.status
|
||||
if (err.status) {
|
||||
res.statusCode = err.status
|
||||
}
|
||||
|
||||
// production gets a basic error message
|
||||
var msg = env === 'production'
|
||||
? http.STATUS_CODES[res.statusCode]
|
||||
: err.stack || err.toString()
|
||||
msg = escapeHtml(msg)
|
||||
.replace(/\n/g, '<br>')
|
||||
.replace(/ /g, ' ') + '\n'
|
||||
} else {
|
||||
res.statusCode = 404
|
||||
msg = 'Cannot ' + escapeHtml(req.method) + ' ' + escapeHtml(req.originalUrl || req.url) + '\n'
|
||||
}
|
||||
|
||||
debug('default %s', res.statusCode)
|
||||
|
||||
// schedule onerror callback
|
||||
if (err && onerror) {
|
||||
defer(onerror, err, req, res)
|
||||
}
|
||||
|
||||
// cannot actually respond
|
||||
if (res._header) {
|
||||
return req.socket.destroy()
|
||||
}
|
||||
|
||||
send(req, res, res.statusCode, msg)
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Send response.
|
||||
*
|
||||
* @param {IncomingMessage} req
|
||||
* @param {OutgoingMessage} res
|
||||
* @param {number} status
|
||||
* @param {string} body
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function send(req, res, status, body) {
|
||||
function write() {
|
||||
res.statusCode = status
|
||||
|
||||
// security header for content sniffing
|
||||
res.setHeader('X-Content-Type-Options', 'nosniff')
|
||||
|
||||
// standard headers
|
||||
res.setHeader('Content-Type', 'text/html; charset=utf-8')
|
||||
res.setHeader('Content-Length', Buffer.byteLength(body, 'utf8'))
|
||||
|
||||
if (req.method === 'HEAD') {
|
||||
res.end()
|
||||
return
|
||||
}
|
||||
|
||||
res.end(body, 'utf8')
|
||||
}
|
||||
|
||||
if (isFinished(req)) {
|
||||
write()
|
||||
return
|
||||
}
|
||||
|
||||
// unpipe everything from the request
|
||||
unpipe(req)
|
||||
|
||||
// flush the request
|
||||
onFinished(req, write)
|
||||
req.resume()
|
||||
}
|
||||
|
||||
/**
|
||||
* Unpipe everything from a stream.
|
||||
*
|
||||
* @param {Object} stream
|
||||
* @api private
|
||||
*/
|
||||
|
||||
/* istanbul ignore next: implementation differs between versions */
|
||||
function unpipe(stream) {
|
||||
if (typeof stream.unpipe === 'function') {
|
||||
// new-style
|
||||
stream.unpipe()
|
||||
return
|
||||
}
|
||||
|
||||
// Node.js 0.8 hack
|
||||
var listener
|
||||
var listeners = stream.listeners('close')
|
||||
|
||||
for (var i = 0; i < listeners.length; i++) {
|
||||
listener = listeners[i]
|
||||
|
||||
if (listener.name !== 'cleanup' && listener.name !== 'onclose') {
|
||||
continue
|
||||
}
|
||||
|
||||
// invoke the listener
|
||||
listener.call(stream)
|
||||
}
|
||||
}
|
|
@ -1,80 +0,0 @@
|
|||
{
|
||||
"name": "finalhandler",
|
||||
"description": "Node.js final http responder",
|
||||
"version": "0.3.3",
|
||||
"author": {
|
||||
"name": "Douglas Christopher Wilson",
|
||||
"email": "doug@somethingdoug.com"
|
||||
},
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/pillarjs/finalhandler"
|
||||
},
|
||||
"dependencies": {
|
||||
"debug": "~2.1.1",
|
||||
"escape-html": "1.0.1",
|
||||
"on-finished": "~2.2.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"istanbul": "0.3.5",
|
||||
"mocha": "~2.1.0",
|
||||
"readable-stream": "~1.0.33",
|
||||
"supertest": "~0.15.0"
|
||||
},
|
||||
"files": [
|
||||
"LICENSE",
|
||||
"HISTORY.md",
|
||||
"index.js"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 0.8"
|
||||
},
|
||||
"scripts": {
|
||||
"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/"
|
||||
},
|
||||
"gitHead": "dfce5042f996ba93ac85b9282e6d1cae1561acc6",
|
||||
"bugs": {
|
||||
"url": "https://github.com/pillarjs/finalhandler/issues"
|
||||
},
|
||||
"homepage": "https://github.com/pillarjs/finalhandler",
|
||||
"_id": "finalhandler@0.3.3",
|
||||
"_shasum": "b1a09aa1e6a607b3541669b09bcb727f460cd426",
|
||||
"_from": "finalhandler@0.3.3",
|
||||
"_npmVersion": "1.4.28",
|
||||
"_npmUser": {
|
||||
"name": "dougwilson",
|
||||
"email": "doug@somethingdoug.com"
|
||||
},
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "dougwilson",
|
||||
"email": "doug@somethingdoug.com"
|
||||
},
|
||||
{
|
||||
"name": "jongleberry",
|
||||
"email": "jonathanrichardong@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "shtylman",
|
||||
"email": "shtylman@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "tjholowaychuk",
|
||||
"email": "tj@vision-media.ca"
|
||||
},
|
||||
{
|
||||
"name": "fishrock123",
|
||||
"email": "fishrock123@rocketmail.com"
|
||||
}
|
||||
],
|
||||
"dist": {
|
||||
"shasum": "b1a09aa1e6a607b3541669b09bcb727f460cd426",
|
||||
"tarball": "http://registry.npmjs.org/finalhandler/-/finalhandler-0.3.3.tgz"
|
||||
},
|
||||
"directories": {},
|
||||
"_resolved": "https://registry.npmjs.org/finalhandler/-/finalhandler-0.3.3.tgz",
|
||||
"readme": "ERROR: No README data found!"
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
0.2.4 / 2014-09-07
|
||||
==================
|
||||
|
||||
* Support Node.js 0.6
|
||||
|
||||
0.2.3 / 2014-09-07
|
||||
==================
|
||||
|
||||
* Move repository to jshttp
|
||||
|
||||
0.2.2 / 2014-02-19
|
||||
==================
|
||||
|
||||
* Revert "Fix for blank page on Safari reload"
|
||||
|
||||
0.2.1 / 2014-01-29
|
||||
==================
|
||||
|
||||
* fix: support max-age=0 for end-to-end revalidation
|
||||
|
||||
0.2.0 / 2013-08-11
|
||||
==================
|
||||
|
||||
* fix: return false for no-cache
|
|
@ -1,22 +0,0 @@
|
|||
(The MIT License)
|
||||
|
||||
Copyright (c) 2012 TJ Holowaychuk <tj@vision-media.ca>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
'Software'), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@ -1,58 +0,0 @@
|
|||
# fresh
|
||||
|
||||
[![NPM Version][npm-image]][npm-url]
|
||||
[![NPM Downloads][downloads-image]][downloads-url]
|
||||
[![Node.js Version][node-version-image]][node-version-url]
|
||||
[![Build Status][travis-image]][travis-url]
|
||||
[![Test Coverage][coveralls-image]][coveralls-url]
|
||||
|
||||
HTTP response freshness testing
|
||||
|
||||
## Installation
|
||||
|
||||
```
|
||||
$ npm install fresh
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
```js
|
||||
var fresh = require('fresh')
|
||||
```
|
||||
|
||||
### fresh(req, res)
|
||||
|
||||
Check freshness of `req` and `res` headers.
|
||||
|
||||
When the cache is "fresh" __true__ is returned,
|
||||
otherwise __false__ is returned to indicate that
|
||||
the cache is now stale.
|
||||
|
||||
## Example
|
||||
|
||||
```js
|
||||
var req = { 'if-none-match': 'tobi' };
|
||||
var res = { 'etag': 'luna' };
|
||||
fresh(req, res);
|
||||
// => false
|
||||
|
||||
var req = { 'if-none-match': 'tobi' };
|
||||
var res = { 'etag': 'tobi' };
|
||||
fresh(req, res);
|
||||
// => true
|
||||
```
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE)
|
||||
|
||||
[npm-image]: https://img.shields.io/npm/v/fresh.svg?style=flat
|
||||
[npm-url]: https://npmjs.org/package/fresh
|
||||
[node-version-image]: https://img.shields.io/badge/node.js-%3E%3D_0.6-brightgreen.svg?style=flat
|
||||
[node-version-url]: http://nodejs.org/download/
|
||||
[travis-image]: https://img.shields.io/travis/jshttp/fresh.svg?style=flat
|
||||
[travis-url]: https://travis-ci.org/jshttp/fresh
|
||||
[coveralls-image]: https://img.shields.io/coveralls/jshttp/fresh.svg?style=flat
|
||||
[coveralls-url]: https://coveralls.io/r/jshttp/fresh?branch=master
|
||||
[downloads-image]: https://img.shields.io/npm/dm/fresh.svg?style=flat
|
||||
[downloads-url]: https://npmjs.org/package/fresh
|
|
@ -1,53 +0,0 @@
|
|||
|
||||
/**
|
||||
* Expose `fresh()`.
|
||||
*/
|
||||
|
||||
module.exports = fresh;
|
||||
|
||||
/**
|
||||
* Check freshness of `req` and `res` headers.
|
||||
*
|
||||
* When the cache is "fresh" __true__ is returned,
|
||||
* otherwise __false__ is returned to indicate that
|
||||
* the cache is now stale.
|
||||
*
|
||||
* @param {Object} req
|
||||
* @param {Object} res
|
||||
* @return {Boolean}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function fresh(req, res) {
|
||||
// defaults
|
||||
var etagMatches = true;
|
||||
var notModified = true;
|
||||
|
||||
// fields
|
||||
var modifiedSince = req['if-modified-since'];
|
||||
var noneMatch = req['if-none-match'];
|
||||
var lastModified = res['last-modified'];
|
||||
var etag = res['etag'];
|
||||
var cc = req['cache-control'];
|
||||
|
||||
// unconditional request
|
||||
if (!modifiedSince && !noneMatch) return false;
|
||||
|
||||
// check for no-cache cache request directive
|
||||
if (cc && cc.indexOf('no-cache') !== -1) return false;
|
||||
|
||||
// parse if-none-match
|
||||
if (noneMatch) noneMatch = noneMatch.split(/ *, */);
|
||||
|
||||
// if-none-match
|
||||
if (noneMatch) etagMatches = ~noneMatch.indexOf(etag) || '*' == noneMatch[0];
|
||||
|
||||
// if-modified-since
|
||||
if (modifiedSince) {
|
||||
modifiedSince = new Date(modifiedSince);
|
||||
lastModified = new Date(lastModified);
|
||||
notModified = lastModified <= modifiedSince;
|
||||
}
|
||||
|
||||
return !! (etagMatches && notModified);
|
||||
}
|
|
@ -1,77 +0,0 @@
|
|||
{
|
||||
"name": "fresh",
|
||||
"description": "HTTP response freshness testing",
|
||||
"version": "0.2.4",
|
||||
"author": {
|
||||
"name": "TJ Holowaychuk",
|
||||
"email": "tj@vision-media.ca",
|
||||
"url": "http://tjholowaychuk.com"
|
||||
},
|
||||
"license": "MIT",
|
||||
"keywords": [
|
||||
"fresh",
|
||||
"http",
|
||||
"conditional",
|
||||
"cache"
|
||||
],
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/jshttp/fresh"
|
||||
},
|
||||
"devDependencies": {
|
||||
"istanbul": "0",
|
||||
"mocha": "1",
|
||||
"should": "3"
|
||||
},
|
||||
"files": [
|
||||
"HISTORY.md",
|
||||
"LICENSE",
|
||||
"index.js"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha --reporter spec --require should",
|
||||
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot --require should",
|
||||
"test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter dot --require should"
|
||||
},
|
||||
"gitHead": "8440a4ca75fb091dec06e88654b3b1c31d7e7164",
|
||||
"bugs": {
|
||||
"url": "https://github.com/jshttp/fresh/issues"
|
||||
},
|
||||
"homepage": "https://github.com/jshttp/fresh",
|
||||
"_id": "fresh@0.2.4",
|
||||
"_shasum": "3582499206c9723714190edd74b4604feb4a614c",
|
||||
"_from": "fresh@0.2.4",
|
||||
"_npmVersion": "1.4.21",
|
||||
"_npmUser": {
|
||||
"name": "dougwilson",
|
||||
"email": "doug@somethingdoug.com"
|
||||
},
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "tjholowaychuk",
|
||||
"email": "tj@vision-media.ca"
|
||||
},
|
||||
{
|
||||
"name": "jonathanong",
|
||||
"email": "jonathanrichardong@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "dougwilson",
|
||||
"email": "doug@somethingdoug.com"
|
||||
},
|
||||
{
|
||||
"name": "jongleberry",
|
||||
"email": "jonathanrichardong@gmail.com"
|
||||
}
|
||||
],
|
||||
"dist": {
|
||||
"shasum": "3582499206c9723714190edd74b4604feb4a614c",
|
||||
"tarball": "http://registry.npmjs.org/fresh/-/fresh-0.2.4.tgz"
|
||||
},
|
||||
"directories": {},
|
||||
"_resolved": "https://registry.npmjs.org/fresh/-/fresh-0.2.4.tgz",
|
||||
"readme": "ERROR: No README data found!"
|
||||
}
|
|
@ -1,22 +0,0 @@
|
|||
0.3.0 / 2014-09-07
|
||||
==================
|
||||
|
||||
* Support Node.js 0.6
|
||||
* Throw error when parameter format invalid on parse
|
||||
|
||||
0.2.0 / 2014-06-18
|
||||
==================
|
||||
|
||||
* Add `typer.format()` to format media types
|
||||
|
||||
0.1.0 / 2014-06-17
|
||||
==================
|
||||
|
||||
* Accept `req` as argument to `parse`
|
||||
* Accept `res` as argument to `parse`
|
||||
* Parse media type with extra LWS between type and first parameter
|
||||
|
||||
0.0.0 / 2014-06-13
|
||||
==================
|
||||
|
||||
* Initial implementation
|
|
@ -1,22 +0,0 @@
|
|||
(The MIT License)
|
||||
|
||||
Copyright (c) 2014 Douglas Christopher Wilson
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
'Software'), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
|
@ -1,81 +0,0 @@
|
|||
# media-typer
|
||||
|
||||
[![NPM Version][npm-image]][npm-url]
|
||||
[![NPM Downloads][downloads-image]][downloads-url]
|
||||
[![Node.js Version][node-version-image]][node-version-url]
|
||||
[![Build Status][travis-image]][travis-url]
|
||||
[![Test Coverage][coveralls-image]][coveralls-url]
|
||||
|
||||
Simple RFC 6838 media type parser
|
||||
|
||||
## Installation
|
||||
|
||||
```sh
|
||||
$ npm install media-typer
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
```js
|
||||
var typer = require('media-typer')
|
||||
```
|
||||
|
||||
### typer.parse(string)
|
||||
|
||||
```js
|
||||
var obj = typer.parse('image/svg+xml; charset=utf-8')
|
||||
```
|
||||
|
||||
Parse a media type string. This will return an object with the following
|
||||
properties (examples are shown for the string `'image/svg+xml; charset=utf-8'`):
|
||||
|
||||
- `type`: The type of the media type (always lower case). Example: `'image'`
|
||||
|
||||
- `subtype`: The subtype of the media type (always lower case). Example: `'svg'`
|
||||
|
||||
- `suffix`: The suffix of the media type (always lower case). Example: `'xml'`
|
||||
|
||||
- `parameters`: An object of the parameters in the media type (name of parameter always lower case). Example: `{charset: 'utf-8'}`
|
||||
|
||||
### typer.parse(req)
|
||||
|
||||
```js
|
||||
var obj = typer.parse(req)
|
||||
```
|
||||
|
||||
Parse the `content-type` header from the given `req`. Short-cut for
|
||||
`typer.parse(req.headers['content-type'])`.
|
||||
|
||||
### typer.parse(res)
|
||||
|
||||
```js
|
||||
var obj = typer.parse(res)
|
||||
```
|
||||
|
||||
Parse the `content-type` header set on the given `res`. Short-cut for
|
||||
`typer.parse(res.getHeader('content-type'))`.
|
||||
|
||||
### typer.format(obj)
|
||||
|
||||
```js
|
||||
var obj = typer.format({type: 'image', subtype: 'svg', suffix: 'xml'})
|
||||
```
|
||||
|
||||
Format an object into a media type string. This will return a string of the
|
||||
mime type for the given object. For the properties of the object, see the
|
||||
documentation for `typer.parse(string)`.
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE)
|
||||
|
||||
[npm-image]: https://img.shields.io/npm/v/media-typer.svg?style=flat
|
||||
[npm-url]: https://npmjs.org/package/media-typer
|
||||
[node-version-image]: https://img.shields.io/badge/node.js-%3E%3D_0.6-brightgreen.svg?style=flat
|
||||
[node-version-url]: http://nodejs.org/download/
|
||||
[travis-image]: https://img.shields.io/travis/jshttp/media-typer.svg?style=flat
|
||||
[travis-url]: https://travis-ci.org/jshttp/media-typer
|
||||
[coveralls-image]: https://img.shields.io/coveralls/jshttp/media-typer.svg?style=flat
|
||||
[coveralls-url]: https://coveralls.io/r/jshttp/media-typer
|
||||
[downloads-image]: https://img.shields.io/npm/dm/media-typer.svg?style=flat
|
||||
[downloads-url]: https://npmjs.org/package/media-typer
|
|
@ -1,270 +0,0 @@
|
|||
/*!
|
||||
* media-typer
|
||||
* Copyright(c) 2014 Douglas Christopher Wilson
|
||||
* MIT Licensed
|
||||
*/
|
||||
|
||||
/**
|
||||
* RegExp to match *( ";" parameter ) in RFC 2616 sec 3.7
|
||||
*
|
||||
* parameter = token "=" ( token | quoted-string )
|
||||
* token = 1*<any CHAR except CTLs or separators>
|
||||
* separators = "(" | ")" | "<" | ">" | "@"
|
||||
* | "," | ";" | ":" | "\" | <">
|
||||
* | "/" | "[" | "]" | "?" | "="
|
||||
* | "{" | "}" | SP | HT
|
||||
* quoted-string = ( <"> *(qdtext | quoted-pair ) <"> )
|
||||
* qdtext = <any TEXT except <">>
|
||||
* quoted-pair = "\" CHAR
|
||||
* CHAR = <any US-ASCII character (octets 0 - 127)>
|
||||
* TEXT = <any OCTET except CTLs, but including LWS>
|
||||
* LWS = [CRLF] 1*( SP | HT )
|
||||
* CRLF = CR LF
|
||||
* CR = <US-ASCII CR, carriage return (13)>
|
||||
* LF = <US-ASCII LF, linefeed (10)>
|
||||
* SP = <US-ASCII SP, space (32)>
|
||||
* SHT = <US-ASCII HT, horizontal-tab (9)>
|
||||
* CTL = <any US-ASCII control character (octets 0 - 31) and DEL (127)>
|
||||
* OCTET = <any 8-bit sequence of data>
|
||||
*/
|
||||
var paramRegExp = /; *([!#$%&'\*\+\-\.0-9A-Z\^_`a-z\|~]+) *= *("(?:[ !\u0023-\u005b\u005d-\u007e\u0080-\u00ff]|\\[\u0020-\u007e])*"|[!#$%&'\*\+\-\.0-9A-Z\^_`a-z\|~]+) */g;
|
||||
var textRegExp = /^[\u0020-\u007e\u0080-\u00ff]+$/
|
||||
var tokenRegExp = /^[!#$%&'\*\+\-\.0-9A-Z\^_`a-z\|~]+$/
|
||||
|
||||
/**
|
||||
* RegExp to match quoted-pair in RFC 2616
|
||||
*
|
||||
* quoted-pair = "\" CHAR
|
||||
* CHAR = <any US-ASCII character (octets 0 - 127)>
|
||||
*/
|
||||
var qescRegExp = /\\([\u0000-\u007f])/g;
|
||||
|
||||
/**
|
||||
* RegExp to match chars that must be quoted-pair in RFC 2616
|
||||
*/
|
||||
var quoteRegExp = /([\\"])/g;
|
||||
|
||||
/**
|
||||
* RegExp to match type in RFC 6838
|
||||
*
|
||||
* type-name = restricted-name
|
||||
* subtype-name = restricted-name
|
||||
* restricted-name = restricted-name-first *126restricted-name-chars
|
||||
* restricted-name-first = ALPHA / DIGIT
|
||||
* restricted-name-chars = ALPHA / DIGIT / "!" / "#" /
|
||||
* "$" / "&" / "-" / "^" / "_"
|
||||
* restricted-name-chars =/ "." ; Characters before first dot always
|
||||
* ; specify a facet name
|
||||
* restricted-name-chars =/ "+" ; Characters after last plus always
|
||||
* ; specify a structured syntax suffix
|
||||
* ALPHA = %x41-5A / %x61-7A ; A-Z / a-z
|
||||
* DIGIT = %x30-39 ; 0-9
|
||||
*/
|
||||
var subtypeNameRegExp = /^[A-Za-z0-9][A-Za-z0-9!#$&^_.-]{0,126}$/
|
||||
var typeNameRegExp = /^[A-Za-z0-9][A-Za-z0-9!#$&^_-]{0,126}$/
|
||||
var typeRegExp = /^ *([A-Za-z0-9][A-Za-z0-9!#$&^_-]{0,126})\/([A-Za-z0-9][A-Za-z0-9!#$&^_.+-]{0,126}) *$/;
|
||||
|
||||
/**
|
||||
* Module exports.
|
||||
*/
|
||||
|
||||
exports.format = format
|
||||
exports.parse = parse
|
||||
|
||||
/**
|
||||
* Format object to media type.
|
||||
*
|
||||
* @param {object} obj
|
||||
* @return {string}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function format(obj) {
|
||||
if (!obj || typeof obj !== 'object') {
|
||||
throw new TypeError('argument obj is required')
|
||||
}
|
||||
|
||||
var parameters = obj.parameters
|
||||
var subtype = obj.subtype
|
||||
var suffix = obj.suffix
|
||||
var type = obj.type
|
||||
|
||||
if (!type || !typeNameRegExp.test(type)) {
|
||||
throw new TypeError('invalid type')
|
||||
}
|
||||
|
||||
if (!subtype || !subtypeNameRegExp.test(subtype)) {
|
||||
throw new TypeError('invalid subtype')
|
||||
}
|
||||
|
||||
// format as type/subtype
|
||||
var string = type + '/' + subtype
|
||||
|
||||
// append +suffix
|
||||
if (suffix) {
|
||||
if (!typeNameRegExp.test(suffix)) {
|
||||
throw new TypeError('invalid suffix')
|
||||
}
|
||||
|
||||
string += '+' + suffix
|
||||
}
|
||||
|
||||
// append parameters
|
||||
if (parameters && typeof parameters === 'object') {
|
||||
var param
|
||||
var params = Object.keys(parameters).sort()
|
||||
|
||||
for (var i = 0; i < params.length; i++) {
|
||||
param = params[i]
|
||||
|
||||
if (!tokenRegExp.test(param)) {
|
||||
throw new TypeError('invalid parameter name')
|
||||
}
|
||||
|
||||
string += '; ' + param + '=' + qstring(parameters[param])
|
||||
}
|
||||
}
|
||||
|
||||
return string
|
||||
}
|
||||
|
||||
/**
|
||||
* Parse media type to object.
|
||||
*
|
||||
* @param {string|object} string
|
||||
* @return {Object}
|
||||
* @api public
|
||||
*/
|
||||
|
||||
function parse(string) {
|
||||
if (!string) {
|
||||
throw new TypeError('argument string is required')
|
||||
}
|
||||
|
||||
// support req/res-like objects as argument
|
||||
if (typeof string === 'object') {
|
||||
string = getcontenttype(string)
|
||||
}
|
||||
|
||||
if (typeof string !== 'string') {
|
||||
throw new TypeError('argument string is required to be a string')
|
||||
}
|
||||
|
||||
var index = string.indexOf(';')
|
||||
var type = index !== -1
|
||||
? string.substr(0, index)
|
||||
: string
|
||||
|
||||
var key
|
||||
var match
|
||||
var obj = splitType(type)
|
||||
var params = {}
|
||||
var value
|
||||
|
||||
paramRegExp.lastIndex = index
|
||||
|
||||
while (match = paramRegExp.exec(string)) {
|
||||
if (match.index !== index) {
|
||||
throw new TypeError('invalid parameter format')
|
||||
}
|
||||
|
||||
index += match[0].length
|
||||
key = match[1].toLowerCase()
|
||||
value = match[2]
|
||||
|
||||
if (value[0] === '"') {
|
||||
// remove quotes and escapes
|
||||
value = value
|
||||
.substr(1, value.length - 2)
|
||||
.replace(qescRegExp, '$1')
|
||||
}
|
||||
|
||||
params[key] = value
|
||||
}
|
||||
|
||||
if (index !== -1 && index !== string.length) {
|
||||
throw new TypeError('invalid parameter format')
|
||||
}
|
||||
|
||||
obj.parameters = params
|
||||
|
||||
return obj
|
||||
}
|
||||
|
||||
/**
|
||||
* Get content-type from req/res objects.
|
||||
*
|
||||
* @param {object}
|
||||
* @return {Object}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function getcontenttype(obj) {
|
||||
if (typeof obj.getHeader === 'function') {
|
||||
// res-like
|
||||
return obj.getHeader('content-type')
|
||||
}
|
||||
|
||||
if (typeof obj.headers === 'object') {
|
||||
// req-like
|
||||
return obj.headers && obj.headers['content-type']
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Quote a string if necessary.
|
||||
*
|
||||
* @param {string} val
|
||||
* @return {string}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function qstring(val) {
|
||||
var str = String(val)
|
||||
|
||||
// no need to quote tokens
|
||||
if (tokenRegExp.test(str)) {
|
||||
return str
|
||||
}
|
||||
|
||||
if (str.length > 0 && !textRegExp.test(str)) {
|
||||
throw new TypeError('invalid parameter value')
|
||||
}
|
||||
|
||||
return '"' + str.replace(quoteRegExp, '\\$1') + '"'
|
||||
}
|
||||
|
||||
/**
|
||||
* Simply "type/subtype+siffx" into parts.
|
||||
*
|
||||
* @param {string} string
|
||||
* @return {Object}
|
||||
* @api private
|
||||
*/
|
||||
|
||||
function splitType(string) {
|
||||
var match = typeRegExp.exec(string.toLowerCase())
|
||||
|
||||
if (!match) {
|
||||
throw new TypeError('invalid media type')
|
||||
}
|
||||
|
||||
var type = match[1]
|
||||
var subtype = match[2]
|
||||
var suffix
|
||||
|
||||
// suffix after last +
|
||||
var index = subtype.lastIndexOf('+')
|
||||
if (index !== -1) {
|
||||
suffix = subtype.substr(index + 1)
|
||||
subtype = subtype.substr(0, index)
|
||||
}
|
||||
|
||||
var obj = {
|
||||
type: type,
|
||||
subtype: subtype,
|
||||
suffix: suffix
|
||||
}
|
||||
|
||||
return obj
|
||||
}
|
|
@ -1,58 +0,0 @@
|
|||
{
|
||||
"name": "media-typer",
|
||||
"description": "Simple RFC 6838 media type parser and formatter",
|
||||
"version": "0.3.0",
|
||||
"author": {
|
||||
"name": "Douglas Christopher Wilson",
|
||||
"email": "doug@somethingdoug.com"
|
||||
},
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/jshttp/media-typer"
|
||||
},
|
||||
"devDependencies": {
|
||||
"istanbul": "0.3.2",
|
||||
"mocha": "~1.21.4",
|
||||
"should": "~4.0.4"
|
||||
},
|
||||
"files": [
|
||||
"LICENSE",
|
||||
"HISTORY.md",
|
||||
"index.js"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha --reporter spec --check-leaks --bail 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/"
|
||||
},
|
||||
"gitHead": "d49d41ffd0bb5a0655fa44a59df2ec0bfc835b16",
|
||||
"bugs": {
|
||||
"url": "https://github.com/jshttp/media-typer/issues"
|
||||
},
|
||||
"homepage": "https://github.com/jshttp/media-typer",
|
||||
"_id": "media-typer@0.3.0",
|
||||
"_shasum": "8710d7af0aa626f8fffa1ce00168545263255748",
|
||||
"_from": "media-typer@0.3.0",
|
||||
"_npmVersion": "1.4.21",
|
||||
"_npmUser": {
|
||||
"name": "dougwilson",
|
||||
"email": "doug@somethingdoug.com"
|
||||
},
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "dougwilson",
|
||||
"email": "doug@somethingdoug.com"
|
||||
}
|
||||
],
|
||||
"dist": {
|
||||
"shasum": "8710d7af0aa626f8fffa1ce00168545263255748",
|
||||
"tarball": "http://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz"
|
||||
},
|
||||
"directories": {},
|
||||
"_resolved": "https://registry.npmjs.org/media-typer/-/media-typer-0.3.0.tgz",
|
||||
"readme": "ERROR: No README data found!"
|
||||
}
|
|
@ -1,59 +0,0 @@
|
|||
# Compiled source #
|
||||
###################
|
||||
*.com
|
||||
*.class
|
||||
*.dll
|
||||
*.exe
|
||||
*.o
|
||||
*.so
|
||||
|
||||
# Packages #
|
||||
############
|
||||
# it's better to unpack these files and commit the raw source
|
||||
# git has its own built in compression methods
|
||||
*.7z
|
||||
*.dmg
|
||||
*.gz
|
||||
*.iso
|
||||
*.jar
|
||||
*.rar
|
||||
*.tar
|
||||
*.zip
|
||||
|
||||
# Logs and databases #
|
||||
######################
|
||||
*.log
|
||||
*.sql
|
||||
*.sqlite
|
||||
|
||||
# OS generated files #
|
||||
######################
|
||||
.DS_Store*
|
||||
ehthumbs.db
|
||||
Icon?
|
||||
Thumbs.db
|
||||
|
||||
# Node.js #
|
||||
###########
|
||||
lib-cov
|
||||
*.seed
|
||||
*.log
|
||||
*.csv
|
||||
*.dat
|
||||
*.out
|
||||
*.pid
|
||||
*.gz
|
||||
|
||||
pids
|
||||
logs
|
||||
results
|
||||
|
||||
node_modules
|
||||
npm-debug.log
|
||||
|
||||
# Components #
|
||||
##############
|
||||
|
||||
/build
|
||||
/components
|
||||
/vendors
|
|
@ -1,49 +0,0 @@
|
|||
# Merge Descriptors [![Build Status](https://travis-ci.org/component/merge-descriptors.png)](https://travis-ci.org/component/merge-descriptors)
|
||||
|
||||
Merge objects using descriptors.
|
||||
|
||||
```js
|
||||
var thing = {
|
||||
get name() {
|
||||
return 'jon'
|
||||
}
|
||||
}
|
||||
|
||||
var animal = {
|
||||
|
||||
}
|
||||
|
||||
merge(animal, thing)
|
||||
|
||||
animal.name === 'jon'
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
### merge(destination, source)
|
||||
|
||||
Overwrites `destination`'s descriptors with `source`'s.
|
||||
|
||||
## License
|
||||
|
||||
The MIT License (MIT)
|
||||
|
||||
Copyright (c) 2013 Jonathan Ong me@jongleberry.com
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
|
@ -1,10 +0,0 @@
|
|||
{
|
||||
"name": "merge-descriptors",
|
||||
"description": "Merge objects using descriptors",
|
||||
"version": "0.0.2",
|
||||
"scripts": [
|
||||
"index.js"
|
||||
],
|
||||
"repo": "component/merge-descriptors",
|
||||
"license": "MIT"
|
||||
}
|
|
@ -1,8 +0,0 @@
|
|||
module.exports = function (dest, src) {
|
||||
Object.getOwnPropertyNames(src).forEach(function (name) {
|
||||
var descriptor = Object.getOwnPropertyDescriptor(src, name)
|
||||
Object.defineProperty(dest, name, descriptor)
|
||||
})
|
||||
|
||||
return dest
|
||||
}
|
|
@ -1,43 +0,0 @@
|
|||
{
|
||||
"name": "merge-descriptors",
|
||||
"description": "Merge objects using descriptors",
|
||||
"version": "0.0.2",
|
||||
"author": {
|
||||
"name": "Jonathan Ong",
|
||||
"email": "me@jongleberry.com",
|
||||
"url": "http://jongleberry.com"
|
||||
},
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/component/merge-descriptors.git"
|
||||
},
|
||||
"bugs": {
|
||||
"url": "https://github.com/component/merge-descriptors/issues"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "make test;"
|
||||
},
|
||||
"homepage": "https://github.com/component/merge-descriptors",
|
||||
"_id": "merge-descriptors@0.0.2",
|
||||
"dist": {
|
||||
"shasum": "c36a52a781437513c57275f39dd9d317514ac8c7",
|
||||
"tarball": "http://registry.npmjs.org/merge-descriptors/-/merge-descriptors-0.0.2.tgz"
|
||||
},
|
||||
"_from": "merge-descriptors@0.0.2",
|
||||
"_npmVersion": "1.3.17",
|
||||
"_npmUser": {
|
||||
"name": "jongleberry",
|
||||
"email": "jonathanrichardong@gmail.com"
|
||||
},
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "jongleberry",
|
||||
"email": "jonathanrichardong@gmail.com"
|
||||
}
|
||||
],
|
||||
"directories": {},
|
||||
"_shasum": "c36a52a781437513c57275f39dd9d317514ac8c7",
|
||||
"_resolved": "https://registry.npmjs.org/merge-descriptors/-/merge-descriptors-0.0.2.tgz",
|
||||
"readme": "ERROR: No README data found!"
|
||||
}
|
|
@ -1,24 +0,0 @@
|
|||
1.1.1 / 2014-12-30
|
||||
==================
|
||||
|
||||
* Improve `browserify` support
|
||||
|
||||
1.1.0 / 2014-07-05
|
||||
==================
|
||||
|
||||
* Add `CONNECT` method
|
||||
|
||||
1.0.1 / 2014-06-02
|
||||
==================
|
||||
|
||||
* Fix module to work with harmony transform
|
||||
|
||||
1.0.0 / 2014-05-08
|
||||
==================
|
||||
|
||||
* Add `PURGE` method
|
||||
|
||||
0.1.0 / 2013-10-28
|
||||
==================
|
||||
|
||||
* Add `http.METHODS` support
|
|
@ -1,23 +0,0 @@
|
|||
(The MIT License)
|
||||
|
||||
Copyright (c) 2013-2014 TJ Holowaychuk <tj@vision-media.ca>
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining
|
||||
a copy of this software and associated documentation files (the
|
||||
'Software'), to deal in the Software without restriction, including
|
||||
without limitation the rights to use, copy, modify, merge, publish,
|
||||
distribute, sublicense, and/or sell copies of the Software, and to
|
||||
permit persons to whom the Software is furnished to do so, subject to
|
||||
the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be
|
||||
included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
|
||||
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
|
||||
IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
|
||||
CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
|
||||
TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
|
||||
SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
|
|
@ -1,41 +0,0 @@
|
|||
# Methods
|
||||
|
||||
[![NPM Version][npm-image]][npm-url]
|
||||
[![NPM Downloads][downloads-image]][downloads-url]
|
||||
[![Node.js Version][node-version-image]][node-version-url]
|
||||
[![Build Status][travis-image]][travis-url]
|
||||
[![Test Coverage][coveralls-image]][coveralls-url]
|
||||
|
||||
HTTP verbs that node core's parser supports.
|
||||
|
||||
|
||||
## Install
|
||||
|
||||
```bash
|
||||
$ npm install methods
|
||||
```
|
||||
|
||||
## API
|
||||
|
||||
```js
|
||||
var methods = require('methods')
|
||||
```
|
||||
|
||||
### methods
|
||||
|
||||
This is an array of lower-case method names that Node.js supports.
|
||||
|
||||
## License
|
||||
|
||||
[MIT](LICENSE)
|
||||
|
||||
[npm-image]: https://img.shields.io/npm/v/methods.svg?style=flat
|
||||
[npm-url]: https://npmjs.org/package/methods
|
||||
[node-version-image]: https://img.shields.io/node/v/methods.svg?style=flat
|
||||
[node-version-url]: http://nodejs.org/download/
|
||||
[travis-image]: https://img.shields.io/travis/jshttp/methods.svg?style=flat
|
||||
[travis-url]: https://travis-ci.org/jshttp/methods
|
||||
[coveralls-image]: https://img.shields.io/coveralls/jshttp/methods.svg?style=flat
|
||||
[coveralls-url]: https://coveralls.io/r/jshttp/methods?branch=master
|
||||
[downloads-image]: https://img.shields.io/npm/dm/methods.svg?style=flat
|
||||
[downloads-url]: https://npmjs.org/package/methods
|
|
@ -1,42 +0,0 @@
|
|||
|
||||
var http = require('http');
|
||||
|
||||
/* istanbul ignore next: implementation differs on version */
|
||||
if (http.METHODS) {
|
||||
|
||||
module.exports = http.METHODS.map(function(method){
|
||||
return method.toLowerCase();
|
||||
});
|
||||
|
||||
} else {
|
||||
|
||||
module.exports = [
|
||||
'get',
|
||||
'post',
|
||||
'put',
|
||||
'head',
|
||||
'delete',
|
||||
'options',
|
||||
'trace',
|
||||
'copy',
|
||||
'lock',
|
||||
'mkcol',
|
||||
'move',
|
||||
'purge',
|
||||
'propfind',
|
||||
'proppatch',
|
||||
'unlock',
|
||||
'report',
|
||||
'mkactivity',
|
||||
'checkout',
|
||||
'merge',
|
||||
'm-search',
|
||||
'notify',
|
||||
'subscribe',
|
||||
'unsubscribe',
|
||||
'patch',
|
||||
'search',
|
||||
'connect'
|
||||
];
|
||||
|
||||
}
|
|
@ -1,88 +0,0 @@
|
|||
{
|
||||
"name": "methods",
|
||||
"description": "HTTP methods that node supports",
|
||||
"version": "1.1.1",
|
||||
"contributors": [
|
||||
{
|
||||
"name": "Douglas Christopher Wilson",
|
||||
"email": "doug@somethingdoug.com"
|
||||
},
|
||||
{
|
||||
"name": "Jonathan Ong",
|
||||
"email": "me@jongleberry.com",
|
||||
"url": "http://jongleberry.com"
|
||||
},
|
||||
{
|
||||
"name": "TJ Holowaychuk",
|
||||
"email": "tj@vision-media.ca",
|
||||
"url": "http://tjholowaychuk.com"
|
||||
}
|
||||
],
|
||||
"license": "MIT",
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/jshttp/methods"
|
||||
},
|
||||
"devDependencies": {
|
||||
"istanbul": "0.3",
|
||||
"mocha": "1"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"HISTORY.md",
|
||||
"LICENSE"
|
||||
],
|
||||
"engines": {
|
||||
"node": ">= 0.6"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "mocha --reporter spec",
|
||||
"test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot",
|
||||
"test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter dot"
|
||||
},
|
||||
"browser": {
|
||||
"http": false
|
||||
},
|
||||
"keywords": [
|
||||
"http",
|
||||
"methods"
|
||||
],
|
||||
"gitHead": "6293c6b27c5fb963acf67a347af80ad2ebd7247f",
|
||||
"bugs": {
|
||||
"url": "https://github.com/jshttp/methods/issues"
|
||||
},
|
||||
"homepage": "https://github.com/jshttp/methods",
|
||||
"_id": "methods@1.1.1",
|
||||
"_shasum": "17ea6366066d00c58e375b8ec7dfd0453c89822a",
|
||||
"_from": "methods@1.1.1",
|
||||
"_npmVersion": "1.4.28",
|
||||
"_npmUser": {
|
||||
"name": "dougwilson",
|
||||
"email": "doug@somethingdoug.com"
|
||||
},
|
||||
"maintainers": [
|
||||
{
|
||||
"name": "tjholowaychuk",
|
||||
"email": "tj@vision-media.ca"
|
||||
},
|
||||
{
|
||||
"name": "jonathanong",
|
||||
"email": "jonathanrichardong@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "jongleberry",
|
||||
"email": "jonathanrichardong@gmail.com"
|
||||
},
|
||||
{
|
||||
"name": "dougwilson",
|
||||
"email": "doug@somethingdoug.com"
|
||||
}
|
||||
],
|
||||
"dist": {
|
||||
"shasum": "17ea6366066d00c58e375b8ec7dfd0453c89822a",
|
||||
"tarball": "http://registry.npmjs.org/methods/-/methods-1.1.1.tgz"
|
||||
},
|
||||
"directories": {},
|
||||
"_resolved": "https://registry.npmjs.org/methods/-/methods-1.1.1.tgz",
|
||||
"readme": "ERROR: No README data found!"
|
||||
}
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue