aboutsummaryrefslogtreecommitdiffhomepage
path: root/node_modules/type-is
diff options
context:
space:
mode:
Diffstat (limited to 'node_modules/type-is')
-rw-r--r--node_modules/type-is/HISTORY.md218
-rw-r--r--node_modules/type-is/LICENSE23
-rw-r--r--node_modules/type-is/README.md146
-rw-r--r--node_modules/type-is/index.js262
-rw-r--r--node_modules/type-is/package.json122
5 files changed, 771 insertions, 0 deletions
diff --git a/node_modules/type-is/HISTORY.md b/node_modules/type-is/HISTORY.md
new file mode 100644
index 0000000..96bc93e
--- /dev/null
+++ b/node_modules/type-is/HISTORY.md
@@ -0,0 +1,218 @@
+1.6.15 / 2017-03-31
+===================
+
+ * deps: mime-types@~2.1.15
+ - Add new mime types
+
+1.6.14 / 2016-11-18
+===================
+
+ * deps: mime-types@~2.1.13
+ - Add new mime types
+
+1.6.13 / 2016-05-18
+===================
+
+ * deps: mime-types@~2.1.11
+ - Add new mime types
+
+1.6.12 / 2016-02-28
+===================
+
+ * deps: mime-types@~2.1.10
+ - Add new mime types
+ - Fix extension of `application/dash+xml`
+ - Update primary extension for `audio/mp4`
+
+1.6.11 / 2016-01-29
+===================
+
+ * deps: mime-types@~2.1.9
+ - Add new mime types
+
+1.6.10 / 2015-12-01
+===================
+
+ * deps: mime-types@~2.1.8
+ - Add new mime types
+
+1.6.9 / 2015-09-27
+==================
+
+ * deps: mime-types@~2.1.7
+ - Add new mime types
+
+1.6.8 / 2015-09-04
+==================
+
+ * deps: mime-types@~2.1.6
+ - Add new mime types
+
+1.6.7 / 2015-08-20
+==================
+
+ * Fix type error when given invalid type to match against
+ * deps: mime-types@~2.1.5
+ - Add new mime types
+
+1.6.6 / 2015-07-31
+==================
+
+ * deps: mime-types@~2.1.4
+ - Add new mime types
+
+1.6.5 / 2015-07-16
+==================
+
+ * deps: mime-types@~2.1.3
+ - Add new mime types
+
+1.6.4 / 2015-07-01
+==================
+
+ * deps: mime-types@~2.1.2
+ - Add new mime types
+ * perf: enable strict mode
+ * perf: remove argument reassignment
+
+1.6.3 / 2015-06-08
+==================
+
+ * deps: mime-types@~2.1.1
+ - Add new mime types
+ * perf: reduce try block size
+ * perf: remove bitwise operations
+
+1.6.2 / 2015-05-10
+==================
+
+ * deps: mime-types@~2.0.11
+ - Add new mime types
+
+1.6.1 / 2015-03-13
+==================
+
+ * deps: mime-types@~2.0.10
+ - Add new mime types
+
+1.6.0 / 2015-02-12
+==================
+
+ * fix false-positives in `hasBody` `Transfer-Encoding` check
+ * support wildcard for both type and subtype (`*/*`)
+
+1.5.7 / 2015-02-09
+==================
+
+ * fix argument reassignment
+ * deps: mime-types@~2.0.9
+ - Add new mime types
+
+1.5.6 / 2015-01-29
+==================
+
+ * deps: mime-types@~2.0.8
+ - Add new mime types
+
+1.5.5 / 2014-12-30
+==================
+
+ * deps: mime-types@~2.0.7
+ - Add new mime types
+ - Fix missing extensions
+ - Fix various invalid MIME type entries
+ - Remove example template MIME types
+ - deps: mime-db@~1.5.0
+
+1.5.4 / 2014-12-10
+==================
+
+ * deps: mime-types@~2.0.4
+ - Add new mime types
+ - deps: mime-db@~1.3.0
+
+1.5.3 / 2014-11-09
+==================
+
+ * deps: mime-types@~2.0.3
+ - Add new mime types
+ - deps: mime-db@~1.2.0
+
+1.5.2 / 2014-09-28
+==================
+
+ * deps: mime-types@~2.0.2
+ - Add new mime types
+ - deps: mime-db@~1.1.0
+
+1.5.1 / 2014-09-07
+==================
+
+ * Support Node.js 0.6
+ * deps: media-typer@0.3.0
+ * deps: mime-types@~2.0.1
+ - Support Node.js 0.6
+
+1.5.0 / 2014-09-05
+==================
+
+ * fix `hasbody` to be true for `content-length: 0`
+
+1.4.0 / 2014-09-02
+==================
+
+ * update mime-types
+
+1.3.2 / 2014-06-24
+==================
+
+ * use `~` range on mime-types
+
+1.3.1 / 2014-06-19
+==================
+
+ * fix global variable leak
+
+1.3.0 / 2014-06-19
+==================
+
+ * improve type parsing
+
+ - invalid media type never matches
+ - media type not case-sensitive
+ - extra LWS does not affect results
+
+1.2.2 / 2014-06-19
+==================
+
+ * fix behavior on unknown type argument
+
+1.2.1 / 2014-06-03
+==================
+
+ * switch dependency from `mime` to `mime-types@1.0.0`
+
+1.2.0 / 2014-05-11
+==================
+
+ * support suffix matching:
+
+ - `+json` matches `application/vnd+json`
+ - `*/vnd+json` matches `application/vnd+json`
+ - `application/*+json` matches `application/vnd+json`
+
+1.1.0 / 2014-04-12
+==================
+
+ * add non-array values support
+ * expose internal utilities:
+
+ - `.is()`
+ - `.hasBody()`
+ - `.normalize()`
+ - `.match()`
+
+1.0.1 / 2014-03-30
+==================
+
+ * add `multipart` as a shorthand
diff --git a/node_modules/type-is/LICENSE b/node_modules/type-is/LICENSE
new file mode 100644
index 0000000..386b7b6
--- /dev/null
+++ b/node_modules/type-is/LICENSE
@@ -0,0 +1,23 @@
+(The MIT License)
+
+Copyright (c) 2014 Jonathan Ong <me@jongleberry.com>
+Copyright (c) 2014-2015 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.
diff --git a/node_modules/type-is/README.md b/node_modules/type-is/README.md
new file mode 100644
index 0000000..70c47da
--- /dev/null
+++ b/node_modules/type-is/README.md
@@ -0,0 +1,146 @@
+# type-is
+
+[![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]
+
+Infer the content-type of a request.
+
+### Install
+
+This is a [Node.js](https://nodejs.org/en/) module available through the
+[npm registry](https://www.npmjs.com/). Installation is done using the
+[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):
+
+```sh
+$ npm install type-is
+```
+
+## API
+
+```js
+var http = require('http')
+var typeis = require('type-is')
+
+http.createServer(function (req, res) {
+ var istext = typeis(req, ['text/*'])
+ res.end('you ' + (istext ? 'sent' : 'did not send') + ' me text')
+})
+```
+
+### type = typeis(request, types)
+
+`request` is the node HTTP request. `types` is an array of types.
+
+<!-- eslint-disable no-undef -->
+
+```js
+// req.headers.content-type = 'application/json'
+
+typeis(req, ['json']) // 'json'
+typeis(req, ['html', 'json']) // 'json'
+typeis(req, ['application/*']) // 'application/json'
+typeis(req, ['application/json']) // 'application/json'
+
+typeis(req, ['html']) // false
+```
+
+### typeis.hasBody(request)
+
+Returns a Boolean if the given `request` has a body, regardless of the
+`Content-Type` header.
+
+Having a body has no relation to how large the body is (it may be 0 bytes).
+This is similar to how file existence works. If a body does exist, then this
+indicates that there is data to read from the Node.js request stream.
+
+<!-- eslint-disable no-undef -->
+
+```js
+if (typeis.hasBody(req)) {
+ // read the body, since there is one
+
+ req.on('data', function (chunk) {
+ // ...
+ })
+}
+```
+
+### type = typeis.is(mediaType, types)
+
+`mediaType` is the [media type](https://tools.ietf.org/html/rfc6838) string. `types` is an array of types.
+
+<!-- eslint-disable no-undef -->
+
+```js
+var mediaType = 'application/json'
+
+typeis.is(mediaType, ['json']) // 'json'
+typeis.is(mediaType, ['html', 'json']) // 'json'
+typeis.is(mediaType, ['application/*']) // 'application/json'
+typeis.is(mediaType, ['application/json']) // 'application/json'
+
+typeis.is(mediaType, ['html']) // false
+```
+
+### Each type can be:
+
+- An extension name such as `json`. This name will be returned if matched.
+- A mime type such as `application/json`.
+- A mime type with a wildcard such as `*/*` or `*/json` or `application/*`. The full mime type will be returned if matched.
+- A suffix such as `+json`. This can be combined with a wildcard such as `*/vnd+json` or `application/*+json`. The full mime type will be returned if matched.
+
+`false` will be returned if no type matches or the content type is invalid.
+
+`null` will be returned if the request does not have a body.
+
+## Examples
+
+### Example body parser
+
+```js
+var express = require('express')
+var typeis = require('type-is')
+
+var app = express()
+
+app.use(function bodyParser (req, res, next) {
+ if (!typeis.hasBody(req)) {
+ return next()
+ }
+
+ switch (typeis(req, ['urlencoded', 'json', 'multipart'])) {
+ case 'urlencoded':
+ // parse urlencoded body
+ throw new Error('implement urlencoded body parsing')
+ case 'json':
+ // parse json body
+ throw new Error('implement json body parsing')
+ case 'multipart':
+ // parse multipart body
+ throw new Error('implement multipart body parsing')
+ default:
+ // 415 error code
+ res.statusCode = 415
+ res.end()
+ break
+ }
+})
+```
+
+## License
+
+[MIT](LICENSE)
+
+[npm-image]: https://img.shields.io/npm/v/type-is.svg
+[npm-url]: https://npmjs.org/package/type-is
+[node-version-image]: https://img.shields.io/node/v/type-is.svg
+[node-version-url]: https://nodejs.org/en/download/
+[travis-image]: https://img.shields.io/travis/jshttp/type-is/master.svg
+[travis-url]: https://travis-ci.org/jshttp/type-is
+[coveralls-image]: https://img.shields.io/coveralls/jshttp/type-is/master.svg
+[coveralls-url]: https://coveralls.io/r/jshttp/type-is?branch=master
+[downloads-image]: https://img.shields.io/npm/dm/type-is.svg
+[downloads-url]: https://npmjs.org/package/type-is
diff --git a/node_modules/type-is/index.js b/node_modules/type-is/index.js
new file mode 100644
index 0000000..4da7301
--- /dev/null
+++ b/node_modules/type-is/index.js
@@ -0,0 +1,262 @@
+/*!
+ * type-is
+ * Copyright(c) 2014 Jonathan Ong
+ * Copyright(c) 2014-2015 Douglas Christopher Wilson
+ * MIT Licensed
+ */
+
+'use strict'
+
+/**
+ * Module dependencies.
+ * @private
+ */
+
+var typer = require('media-typer')
+var mime = require('mime-types')
+
+/**
+ * Module exports.
+ * @public
+ */
+
+module.exports = typeofrequest
+module.exports.is = typeis
+module.exports.hasBody = hasbody
+module.exports.normalize = normalize
+module.exports.match = mimeMatch
+
+/**
+ * Compare a `value` content-type with `types`.
+ * Each `type` can be an extension like `html`,
+ * a special shortcut like `multipart` or `urlencoded`,
+ * or a mime type.
+ *
+ * If no types match, `false` is returned.
+ * Otherwise, the first `type` that matches is returned.
+ *
+ * @param {String} value
+ * @param {Array} types
+ * @public
+ */
+
+function typeis (value, types_) {
+ var i
+ var types = types_
+
+ // remove parameters and normalize
+ var val = tryNormalizeType(value)
+
+ // no type or invalid
+ if (!val) {
+ return false
+ }
+
+ // support flattened arguments
+ if (types && !Array.isArray(types)) {
+ types = new Array(arguments.length - 1)
+ for (i = 0; i < types.length; i++) {
+ types[i] = arguments[i + 1]
+ }
+ }
+
+ // no types, return the content type
+ if (!types || !types.length) {
+ return val
+ }
+
+ var type
+ for (i = 0; i < types.length; i++) {
+ if (mimeMatch(normalize(type = types[i]), val)) {
+ return type[0] === '+' || type.indexOf('*') !== -1
+ ? val
+ : type
+ }
+ }
+
+ // no matches
+ return false
+}
+
+/**
+ * Check if a request has a request body.
+ * A request with a body __must__ either have `transfer-encoding`
+ * or `content-length` headers set.
+ * http://www.w3.org/Protocols/rfc2616/rfc2616-sec4.html#sec4.3
+ *
+ * @param {Object} request
+ * @return {Boolean}
+ * @public
+ */
+
+function hasbody (req) {
+ return req.headers['transfer-encoding'] !== undefined ||
+ !isNaN(req.headers['content-length'])
+}
+
+/**
+ * Check if the incoming request contains the "Content-Type"
+ * header field, and it contains any of the give mime `type`s.
+ * If there is no request body, `null` is returned.
+ * If there is no content type, `false` is returned.
+ * Otherwise, it returns the first `type` that matches.
+ *
+ * Examples:
+ *
+ * // With Content-Type: text/html; charset=utf-8
+ * this.is('html'); // => 'html'
+ * this.is('text/html'); // => 'text/html'
+ * this.is('text/*', 'application/json'); // => 'text/html'
+ *
+ * // When Content-Type is application/json
+ * this.is('json', 'urlencoded'); // => 'json'
+ * this.is('application/json'); // => 'application/json'
+ * this.is('html', 'application/*'); // => 'application/json'
+ *
+ * this.is('html'); // => false
+ *
+ * @param {String|Array} types...
+ * @return {String|false|null}
+ * @public
+ */
+
+function typeofrequest (req, types_) {
+ var types = types_
+
+ // no body
+ if (!hasbody(req)) {
+ return null
+ }
+
+ // support flattened arguments
+ if (arguments.length > 2) {
+ types = new Array(arguments.length - 1)
+ for (var i = 0; i < types.length; i++) {
+ types[i] = arguments[i + 1]
+ }
+ }
+
+ // request content type
+ var value = req.headers['content-type']
+
+ return typeis(value, types)
+}
+
+/**
+ * Normalize a mime type.
+ * If it's a shorthand, expand it to a valid mime type.
+ *
+ * In general, you probably want:
+ *
+ * var type = is(req, ['urlencoded', 'json', 'multipart']);
+ *
+ * Then use the appropriate body parsers.
+ * These three are the most common request body types
+ * and are thus ensured to work.
+ *
+ * @param {String} type
+ * @private
+ */
+
+function normalize (type) {
+ if (typeof type !== 'string') {
+ // invalid type
+ return false
+ }
+
+ switch (type) {
+ case 'urlencoded':
+ return 'application/x-www-form-urlencoded'
+ case 'multipart':
+ return 'multipart/*'
+ }
+
+ if (type[0] === '+') {
+ // "+json" -> "*/*+json" expando
+ return '*/*' + type
+ }
+
+ return type.indexOf('/') === -1
+ ? mime.lookup(type)
+ : type
+}
+
+/**
+ * Check if `expected` mime type
+ * matches `actual` mime type with
+ * wildcard and +suffix support.
+ *
+ * @param {String} expected
+ * @param {String} actual
+ * @return {Boolean}
+ * @private
+ */
+
+function mimeMatch (expected, actual) {
+ // invalid type
+ if (expected === false) {
+ return false
+ }
+
+ // split types
+ var actualParts = actual.split('/')
+ var expectedParts = expected.split('/')
+
+ // invalid format
+ if (actualParts.length !== 2 || expectedParts.length !== 2) {
+ return false
+ }
+
+ // validate type
+ if (expectedParts[0] !== '*' && expectedParts[0] !== actualParts[0]) {
+ return false
+ }
+
+ // validate suffix wildcard
+ if (expectedParts[1].substr(0, 2) === '*+') {
+ return expectedParts[1].length <= actualParts[1].length + 1 &&
+ expectedParts[1].substr(1) === actualParts[1].substr(1 - expectedParts[1].length)
+ }
+
+ // validate subtype
+ if (expectedParts[1] !== '*' && expectedParts[1] !== actualParts[1]) {
+ return false
+ }
+
+ return true
+}
+
+/**
+ * Normalize a type and remove parameters.
+ *
+ * @param {string} value
+ * @return {string}
+ * @private
+ */
+
+function normalizeType (value) {
+ // parse the type
+ var type = typer.parse(value)
+
+ // remove the parameters
+ type.parameters = undefined
+
+ // reformat it
+ return typer.format(type)
+}
+
+/**
+ * Try to normalize a type and remove parameters.
+ *
+ * @param {string} value
+ * @return {string}
+ * @private
+ */
+
+function tryNormalizeType (value) {
+ try {
+ return normalizeType(value)
+ } catch (err) {
+ return null
+ }
+}
diff --git a/node_modules/type-is/package.json b/node_modules/type-is/package.json
new file mode 100644
index 0000000..c106638
--- /dev/null
+++ b/node_modules/type-is/package.json
@@ -0,0 +1,122 @@
+{
+ "_args": [
+ [
+ {
+ "raw": "type-is@~1.6.15",
+ "scope": null,
+ "escapedName": "type-is",
+ "name": "type-is",
+ "rawSpec": "~1.6.15",
+ "spec": ">=1.6.15 <1.7.0",
+ "type": "range"
+ },
+ "/mnt/e/Yaroslav/Documents/Webs/nodejs/checkers/node_modules/express"
+ ]
+ ],
+ "_from": "type-is@>=1.6.15 <1.7.0",
+ "_id": "type-is@1.6.15",
+ "_inCache": true,
+ "_location": "/type-is",
+ "_nodeVersion": "4.7.3",
+ "_npmOperationalInternal": {
+ "host": "packages-18-east.internal.npmjs.com",
+ "tmp": "tmp/type-is-1.6.15.tgz_1491016789014_0.6958203655667603"
+ },
+ "_npmUser": {
+ "name": "dougwilson",
+ "email": "doug@somethingdoug.com"
+ },
+ "_npmVersion": "2.15.11",
+ "_phantomChildren": {},
+ "_requested": {
+ "raw": "type-is@~1.6.15",
+ "scope": null,
+ "escapedName": "type-is",
+ "name": "type-is",
+ "rawSpec": "~1.6.15",
+ "spec": ">=1.6.15 <1.7.0",
+ "type": "range"
+ },
+ "_requiredBy": [
+ "/body-parser",
+ "/express"
+ ],
+ "_resolved": "https://registry.npmjs.org/type-is/-/type-is-1.6.15.tgz",
+ "_shasum": "cab10fb4909e441c82842eafe1ad646c81804410",
+ "_shrinkwrap": null,
+ "_spec": "type-is@~1.6.15",
+ "_where": "/mnt/e/Yaroslav/Documents/Webs/nodejs/checkers/node_modules/express",
+ "bugs": {
+ "url": "https://github.com/jshttp/type-is/issues"
+ },
+ "contributors": [
+ {
+ "name": "Douglas Christopher Wilson",
+ "email": "doug@somethingdoug.com"
+ },
+ {
+ "name": "Jonathan Ong",
+ "email": "me@jongleberry.com",
+ "url": "http://jongleberry.com"
+ }
+ ],
+ "dependencies": {
+ "media-typer": "0.3.0",
+ "mime-types": "~2.1.15"
+ },
+ "description": "Infer the content-type of a request.",
+ "devDependencies": {
+ "eslint": "3.19.0",
+ "eslint-config-standard": "7.1.0",
+ "eslint-plugin-markdown": "1.0.0-beta.4",
+ "eslint-plugin-promise": "3.5.0",
+ "eslint-plugin-standard": "2.1.1",
+ "istanbul": "0.4.5",
+ "mocha": "1.21.5"
+ },
+ "directories": {},
+ "dist": {
+ "shasum": "cab10fb4909e441c82842eafe1ad646c81804410",
+ "tarball": "https://registry.npmjs.org/type-is/-/type-is-1.6.15.tgz"
+ },
+ "engines": {
+ "node": ">= 0.6"
+ },
+ "files": [
+ "LICENSE",
+ "HISTORY.md",
+ "index.js"
+ ],
+ "gitHead": "9e88be851cc628364ad8842433dce32437ea4e73",
+ "homepage": "https://github.com/jshttp/type-is#readme",
+ "keywords": [
+ "content",
+ "type",
+ "checking"
+ ],
+ "license": "MIT",
+ "maintainers": [
+ {
+ "name": "dougwilson",
+ "email": "doug@somethingdoug.com"
+ },
+ {
+ "name": "jongleberry",
+ "email": "jonathanrichardong@gmail.com"
+ }
+ ],
+ "name": "type-is",
+ "optionalDependencies": {},
+ "readme": "ERROR: No README data found!",
+ "repository": {
+ "type": "git",
+ "url": "git+https://github.com/jshttp/type-is.git"
+ },
+ "scripts": {
+ "lint": "eslint --plugin markdown --ext js,md .",
+ "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/"
+ },
+ "version": "1.6.15"
+}