JKL

Update_Server

Showing 647 changed files with 4905 additions and 1 deletions
1 const express = require('express'); 1 const express = require('express');
2 -const cheerio = require('cheerio');
3 const fs = require('fs'); 2 const fs = require('fs');
4 const path = require('path'); 3 const path = require('path');
5 const HTTPS = require('https'); 4 const HTTPS = require('https');
......
1 +#!/bin/sh
2 +basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")
3 +
4 +case `uname` in
5 + *CYGWIN*|*MINGW*|*MSYS*) basedir=`cygpath -w "$basedir"`;;
6 +esac
7 +
8 +if [ -x "$basedir/node" ]; then
9 + exec "$basedir/node" "$basedir/../mime/cli.js" "$@"
10 +else
11 + exec node "$basedir/../mime/cli.js" "$@"
12 +fi
1 +@ECHO off
2 +GOTO start
3 +:find_dp0
4 +SET dp0=%~dp0
5 +EXIT /b
6 +:start
7 +SETLOCAL
8 +CALL :find_dp0
9 +
10 +IF EXIST "%dp0%\node.exe" (
11 + SET "_prog=%dp0%\node.exe"
12 +) ELSE (
13 + SET "_prog=node"
14 + SET PATHEXT=%PATHEXT:;.JS;=;%
15 +)
16 +
17 +endLocal & goto #_undefined_# 2>NUL || title %COMSPEC% & "%_prog%" "%dp0%\..\mime\cli.js" %*
1 +#!/usr/bin/env pwsh
2 +$basedir=Split-Path $MyInvocation.MyCommand.Definition -Parent
3 +
4 +$exe=""
5 +if ($PSVersionTable.PSVersion -lt "6.0" -or $IsWindows) {
6 + # Fix case when both the Windows and Linux builds of Node
7 + # are installed in the same directory
8 + $exe=".exe"
9 +}
10 +$ret=0
11 +if (Test-Path "$basedir/node$exe") {
12 + # Support pipeline input
13 + if ($MyInvocation.ExpectingInput) {
14 + $input | & "$basedir/node$exe" "$basedir/../mime/cli.js" $args
15 + } else {
16 + & "$basedir/node$exe" "$basedir/../mime/cli.js" $args
17 + }
18 + $ret=$LASTEXITCODE
19 +} else {
20 + # Support pipeline input
21 + if ($MyInvocation.ExpectingInput) {
22 + $input | & "node$exe" "$basedir/../mime/cli.js" $args
23 + } else {
24 + & "node$exe" "$basedir/../mime/cli.js" $args
25 + }
26 + $ret=$LASTEXITCODE
27 +}
28 +exit $ret
This diff is collapsed. Click to expand it.
1 +1.3.7 / 2019-04-29
2 +==================
3 +
4 + * deps: negotiator@0.6.2
5 + - Fix sorting charset, encoding, and language with extra parameters
6 +
7 +1.3.6 / 2019-04-28
8 +==================
9 +
10 + * deps: mime-types@~2.1.24
11 + - deps: mime-db@~1.40.0
12 +
13 +1.3.5 / 2018-02-28
14 +==================
15 +
16 + * deps: mime-types@~2.1.18
17 + - deps: mime-db@~1.33.0
18 +
19 +1.3.4 / 2017-08-22
20 +==================
21 +
22 + * deps: mime-types@~2.1.16
23 + - deps: mime-db@~1.29.0
24 +
25 +1.3.3 / 2016-05-02
26 +==================
27 +
28 + * deps: mime-types@~2.1.11
29 + - deps: mime-db@~1.23.0
30 + * deps: negotiator@0.6.1
31 + - perf: improve `Accept` parsing speed
32 + - perf: improve `Accept-Charset` parsing speed
33 + - perf: improve `Accept-Encoding` parsing speed
34 + - perf: improve `Accept-Language` parsing speed
35 +
36 +1.3.2 / 2016-03-08
37 +==================
38 +
39 + * deps: mime-types@~2.1.10
40 + - Fix extension of `application/dash+xml`
41 + - Update primary extension for `audio/mp4`
42 + - deps: mime-db@~1.22.0
43 +
44 +1.3.1 / 2016-01-19
45 +==================
46 +
47 + * deps: mime-types@~2.1.9
48 + - deps: mime-db@~1.21.0
49 +
50 +1.3.0 / 2015-09-29
51 +==================
52 +
53 + * deps: mime-types@~2.1.7
54 + - deps: mime-db@~1.19.0
55 + * deps: negotiator@0.6.0
56 + - Fix including type extensions in parameters in `Accept` parsing
57 + - Fix parsing `Accept` parameters with quoted equals
58 + - Fix parsing `Accept` parameters with quoted semicolons
59 + - Lazy-load modules from main entry point
60 + - perf: delay type concatenation until needed
61 + - perf: enable strict mode
62 + - perf: hoist regular expressions
63 + - perf: remove closures getting spec properties
64 + - perf: remove a closure from media type parsing
65 + - perf: remove property delete from media type parsing
66 +
67 +1.2.13 / 2015-09-06
68 +===================
69 +
70 + * deps: mime-types@~2.1.6
71 + - deps: mime-db@~1.18.0
72 +
73 +1.2.12 / 2015-07-30
74 +===================
75 +
76 + * deps: mime-types@~2.1.4
77 + - deps: mime-db@~1.16.0
78 +
79 +1.2.11 / 2015-07-16
80 +===================
81 +
82 + * deps: mime-types@~2.1.3
83 + - deps: mime-db@~1.15.0
84 +
85 +1.2.10 / 2015-07-01
86 +===================
87 +
88 + * deps: mime-types@~2.1.2
89 + - deps: mime-db@~1.14.0
90 +
91 +1.2.9 / 2015-06-08
92 +==================
93 +
94 + * deps: mime-types@~2.1.1
95 + - perf: fix deopt during mapping
96 +
97 +1.2.8 / 2015-06-07
98 +==================
99 +
100 + * deps: mime-types@~2.1.0
101 + - deps: mime-db@~1.13.0
102 + * perf: avoid argument reassignment & argument slice
103 + * perf: avoid negotiator recursive construction
104 + * perf: enable strict mode
105 + * perf: remove unnecessary bitwise operator
106 +
107 +1.2.7 / 2015-05-10
108 +==================
109 +
110 + * deps: negotiator@0.5.3
111 + - Fix media type parameter matching to be case-insensitive
112 +
113 +1.2.6 / 2015-05-07
114 +==================
115 +
116 + * deps: mime-types@~2.0.11
117 + - deps: mime-db@~1.9.1
118 + * deps: negotiator@0.5.2
119 + - Fix comparing media types with quoted values
120 + - Fix splitting media types with quoted commas
121 +
122 +1.2.5 / 2015-03-13
123 +==================
124 +
125 + * deps: mime-types@~2.0.10
126 + - deps: mime-db@~1.8.0
127 +
128 +1.2.4 / 2015-02-14
129 +==================
130 +
131 + * Support Node.js 0.6
132 + * deps: mime-types@~2.0.9
133 + - deps: mime-db@~1.7.0
134 + * deps: negotiator@0.5.1
135 + - Fix preference sorting to be stable for long acceptable lists
136 +
137 +1.2.3 / 2015-01-31
138 +==================
139 +
140 + * deps: mime-types@~2.0.8
141 + - deps: mime-db@~1.6.0
142 +
143 +1.2.2 / 2014-12-30
144 +==================
145 +
146 + * deps: mime-types@~2.0.7
147 + - deps: mime-db@~1.5.0
148 +
149 +1.2.1 / 2014-12-30
150 +==================
151 +
152 + * deps: mime-types@~2.0.5
153 + - deps: mime-db@~1.3.1
154 +
155 +1.2.0 / 2014-12-19
156 +==================
157 +
158 + * deps: negotiator@0.5.0
159 + - Fix list return order when large accepted list
160 + - Fix missing identity encoding when q=0 exists
161 + - Remove dynamic building of Negotiator class
162 +
163 +1.1.4 / 2014-12-10
164 +==================
165 +
166 + * deps: mime-types@~2.0.4
167 + - deps: mime-db@~1.3.0
168 +
169 +1.1.3 / 2014-11-09
170 +==================
171 +
172 + * deps: mime-types@~2.0.3
173 + - deps: mime-db@~1.2.0
174 +
175 +1.1.2 / 2014-10-14
176 +==================
177 +
178 + * deps: negotiator@0.4.9
179 + - Fix error when media type has invalid parameter
180 +
181 +1.1.1 / 2014-09-28
182 +==================
183 +
184 + * deps: mime-types@~2.0.2
185 + - deps: mime-db@~1.1.0
186 + * deps: negotiator@0.4.8
187 + - Fix all negotiations to be case-insensitive
188 + - Stable sort preferences of same quality according to client order
189 +
190 +1.1.0 / 2014-09-02
191 +==================
192 +
193 + * update `mime-types`
194 +
195 +1.0.7 / 2014-07-04
196 +==================
197 +
198 + * Fix wrong type returned from `type` when match after unknown extension
199 +
200 +1.0.6 / 2014-06-24
201 +==================
202 +
203 + * deps: negotiator@0.4.7
204 +
205 +1.0.5 / 2014-06-20
206 +==================
207 +
208 + * fix crash when unknown extension given
209 +
210 +1.0.4 / 2014-06-19
211 +==================
212 +
213 + * use `mime-types`
214 +
215 +1.0.3 / 2014-06-11
216 +==================
217 +
218 + * deps: negotiator@0.4.6
219 + - Order by specificity when quality is the same
220 +
221 +1.0.2 / 2014-05-29
222 +==================
223 +
224 + * Fix interpretation when header not in request
225 + * deps: pin negotiator@0.4.5
226 +
227 +1.0.1 / 2014-01-18
228 +==================
229 +
230 + * Identity encoding isn't always acceptable
231 + * deps: negotiator@~0.4.0
232 +
233 +1.0.0 / 2013-12-27
234 +==================
235 +
236 + * Genesis
1 +(The MIT License)
2 +
3 +Copyright (c) 2014 Jonathan Ong <me@jongleberry.com>
4 +Copyright (c) 2015 Douglas Christopher Wilson <doug@somethingdoug.com>
5 +
6 +Permission is hereby granted, free of charge, to any person obtaining
7 +a copy of this software and associated documentation files (the
8 +'Software'), to deal in the Software without restriction, including
9 +without limitation the rights to use, copy, modify, merge, publish,
10 +distribute, sublicense, and/or sell copies of the Software, and to
11 +permit persons to whom the Software is furnished to do so, subject to
12 +the following conditions:
13 +
14 +The above copyright notice and this permission notice shall be
15 +included in all copies or substantial portions of the Software.
16 +
17 +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
18 +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1 +# accepts
2 +
3 +[![NPM Version][npm-version-image]][npm-url]
4 +[![NPM Downloads][npm-downloads-image]][npm-url]
5 +[![Node.js Version][node-version-image]][node-version-url]
6 +[![Build Status][travis-image]][travis-url]
7 +[![Test Coverage][coveralls-image]][coveralls-url]
8 +
9 +Higher level content negotiation based on [negotiator](https://www.npmjs.com/package/negotiator).
10 +Extracted from [koa](https://www.npmjs.com/package/koa) for general use.
11 +
12 +In addition to negotiator, it allows:
13 +
14 +- Allows types as an array or arguments list, ie `(['text/html', 'application/json'])`
15 + as well as `('text/html', 'application/json')`.
16 +- Allows type shorthands such as `json`.
17 +- Returns `false` when no types match
18 +- Treats non-existent headers as `*`
19 +
20 +## Installation
21 +
22 +This is a [Node.js](https://nodejs.org/en/) module available through the
23 +[npm registry](https://www.npmjs.com/). Installation is done using the
24 +[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):
25 +
26 +```sh
27 +$ npm install accepts
28 +```
29 +
30 +## API
31 +
32 +<!-- eslint-disable no-unused-vars -->
33 +
34 +```js
35 +var accepts = require('accepts')
36 +```
37 +
38 +### accepts(req)
39 +
40 +Create a new `Accepts` object for the given `req`.
41 +
42 +#### .charset(charsets)
43 +
44 +Return the first accepted charset. If nothing in `charsets` is accepted,
45 +then `false` is returned.
46 +
47 +#### .charsets()
48 +
49 +Return the charsets that the request accepts, in the order of the client's
50 +preference (most preferred first).
51 +
52 +#### .encoding(encodings)
53 +
54 +Return the first accepted encoding. If nothing in `encodings` is accepted,
55 +then `false` is returned.
56 +
57 +#### .encodings()
58 +
59 +Return the encodings that the request accepts, in the order of the client's
60 +preference (most preferred first).
61 +
62 +#### .language(languages)
63 +
64 +Return the first accepted language. If nothing in `languages` is accepted,
65 +then `false` is returned.
66 +
67 +#### .languages()
68 +
69 +Return the languages that the request accepts, in the order of the client's
70 +preference (most preferred first).
71 +
72 +#### .type(types)
73 +
74 +Return the first accepted type (and it is returned as the same text as what
75 +appears in the `types` array). If nothing in `types` is accepted, then `false`
76 +is returned.
77 +
78 +The `types` array can contain full MIME types or file extensions. Any value
79 +that is not a full MIME types is passed to `require('mime-types').lookup`.
80 +
81 +#### .types()
82 +
83 +Return the types that the request accepts, in the order of the client's
84 +preference (most preferred first).
85 +
86 +## Examples
87 +
88 +### Simple type negotiation
89 +
90 +This simple example shows how to use `accepts` to return a different typed
91 +respond body based on what the client wants to accept. The server lists it's
92 +preferences in order and will get back the best match between the client and
93 +server.
94 +
95 +```js
96 +var accepts = require('accepts')
97 +var http = require('http')
98 +
99 +function app (req, res) {
100 + var accept = accepts(req)
101 +
102 + // the order of this list is significant; should be server preferred order
103 + switch (accept.type(['json', 'html'])) {
104 + case 'json':
105 + res.setHeader('Content-Type', 'application/json')
106 + res.write('{"hello":"world!"}')
107 + break
108 + case 'html':
109 + res.setHeader('Content-Type', 'text/html')
110 + res.write('<b>hello, world!</b>')
111 + break
112 + default:
113 + // the fallback is text/plain, so no need to specify it above
114 + res.setHeader('Content-Type', 'text/plain')
115 + res.write('hello, world!')
116 + break
117 + }
118 +
119 + res.end()
120 +}
121 +
122 +http.createServer(app).listen(3000)
123 +```
124 +
125 +You can test this out with the cURL program:
126 +```sh
127 +curl -I -H'Accept: text/html' http://localhost:3000/
128 +```
129 +
130 +## License
131 +
132 +[MIT](LICENSE)
133 +
134 +[coveralls-image]: https://badgen.net/coveralls/c/github/jshttp/accepts/master
135 +[coveralls-url]: https://coveralls.io/r/jshttp/accepts?branch=master
136 +[node-version-image]: https://badgen.net/npm/node/accepts
137 +[node-version-url]: https://nodejs.org/en/download
138 +[npm-downloads-image]: https://badgen.net/npm/dm/accepts
139 +[npm-url]: https://npmjs.org/package/accepts
140 +[npm-version-image]: https://badgen.net/npm/v/accepts
141 +[travis-image]: https://badgen.net/travis/jshttp/accepts/master
142 +[travis-url]: https://travis-ci.org/jshttp/accepts
1 +/*!
2 + * accepts
3 + * Copyright(c) 2014 Jonathan Ong
4 + * Copyright(c) 2015 Douglas Christopher Wilson
5 + * MIT Licensed
6 + */
7 +
8 +'use strict'
9 +
10 +/**
11 + * Module dependencies.
12 + * @private
13 + */
14 +
15 +var Negotiator = require('negotiator')
16 +var mime = require('mime-types')
17 +
18 +/**
19 + * Module exports.
20 + * @public
21 + */
22 +
23 +module.exports = Accepts
24 +
25 +/**
26 + * Create a new Accepts object for the given req.
27 + *
28 + * @param {object} req
29 + * @public
30 + */
31 +
32 +function Accepts (req) {
33 + if (!(this instanceof Accepts)) {
34 + return new Accepts(req)
35 + }
36 +
37 + this.headers = req.headers
38 + this.negotiator = new Negotiator(req)
39 +}
40 +
41 +/**
42 + * Check if the given `type(s)` is acceptable, returning
43 + * the best match when true, otherwise `undefined`, in which
44 + * case you should respond with 406 "Not Acceptable".
45 + *
46 + * The `type` value may be a single mime type string
47 + * such as "application/json", the extension name
48 + * such as "json" or an array `["json", "html", "text/plain"]`. When a list
49 + * or array is given the _best_ match, if any is returned.
50 + *
51 + * Examples:
52 + *
53 + * // Accept: text/html
54 + * this.types('html');
55 + * // => "html"
56 + *
57 + * // Accept: text/*, application/json
58 + * this.types('html');
59 + * // => "html"
60 + * this.types('text/html');
61 + * // => "text/html"
62 + * this.types('json', 'text');
63 + * // => "json"
64 + * this.types('application/json');
65 + * // => "application/json"
66 + *
67 + * // Accept: text/*, application/json
68 + * this.types('image/png');
69 + * this.types('png');
70 + * // => undefined
71 + *
72 + * // Accept: text/*;q=.5, application/json
73 + * this.types(['html', 'json']);
74 + * this.types('html', 'json');
75 + * // => "json"
76 + *
77 + * @param {String|Array} types...
78 + * @return {String|Array|Boolean}
79 + * @public
80 + */
81 +
82 +Accepts.prototype.type =
83 +Accepts.prototype.types = function (types_) {
84 + var types = types_
85 +
86 + // support flattened arguments
87 + if (types && !Array.isArray(types)) {
88 + types = new Array(arguments.length)
89 + for (var i = 0; i < types.length; i++) {
90 + types[i] = arguments[i]
91 + }
92 + }
93 +
94 + // no types, return all requested types
95 + if (!types || types.length === 0) {
96 + return this.negotiator.mediaTypes()
97 + }
98 +
99 + // no accept header, return first given type
100 + if (!this.headers.accept) {
101 + return types[0]
102 + }
103 +
104 + var mimes = types.map(extToMime)
105 + var accepts = this.negotiator.mediaTypes(mimes.filter(validMime))
106 + var first = accepts[0]
107 +
108 + return first
109 + ? types[mimes.indexOf(first)]
110 + : false
111 +}
112 +
113 +/**
114 + * Return accepted encodings or best fit based on `encodings`.
115 + *
116 + * Given `Accept-Encoding: gzip, deflate`
117 + * an array sorted by quality is returned:
118 + *
119 + * ['gzip', 'deflate']
120 + *
121 + * @param {String|Array} encodings...
122 + * @return {String|Array}
123 + * @public
124 + */
125 +
126 +Accepts.prototype.encoding =
127 +Accepts.prototype.encodings = function (encodings_) {
128 + var encodings = encodings_
129 +
130 + // support flattened arguments
131 + if (encodings && !Array.isArray(encodings)) {
132 + encodings = new Array(arguments.length)
133 + for (var i = 0; i < encodings.length; i++) {
134 + encodings[i] = arguments[i]
135 + }
136 + }
137 +
138 + // no encodings, return all requested encodings
139 + if (!encodings || encodings.length === 0) {
140 + return this.negotiator.encodings()
141 + }
142 +
143 + return this.negotiator.encodings(encodings)[0] || false
144 +}
145 +
146 +/**
147 + * Return accepted charsets or best fit based on `charsets`.
148 + *
149 + * Given `Accept-Charset: utf-8, iso-8859-1;q=0.2, utf-7;q=0.5`
150 + * an array sorted by quality is returned:
151 + *
152 + * ['utf-8', 'utf-7', 'iso-8859-1']
153 + *
154 + * @param {String|Array} charsets...
155 + * @return {String|Array}
156 + * @public
157 + */
158 +
159 +Accepts.prototype.charset =
160 +Accepts.prototype.charsets = function (charsets_) {
161 + var charsets = charsets_
162 +
163 + // support flattened arguments
164 + if (charsets && !Array.isArray(charsets)) {
165 + charsets = new Array(arguments.length)
166 + for (var i = 0; i < charsets.length; i++) {
167 + charsets[i] = arguments[i]
168 + }
169 + }
170 +
171 + // no charsets, return all requested charsets
172 + if (!charsets || charsets.length === 0) {
173 + return this.negotiator.charsets()
174 + }
175 +
176 + return this.negotiator.charsets(charsets)[0] || false
177 +}
178 +
179 +/**
180 + * Return accepted languages or best fit based on `langs`.
181 + *
182 + * Given `Accept-Language: en;q=0.8, es, pt`
183 + * an array sorted by quality is returned:
184 + *
185 + * ['es', 'pt', 'en']
186 + *
187 + * @param {String|Array} langs...
188 + * @return {Array|String}
189 + * @public
190 + */
191 +
192 +Accepts.prototype.lang =
193 +Accepts.prototype.langs =
194 +Accepts.prototype.language =
195 +Accepts.prototype.languages = function (languages_) {
196 + var languages = languages_
197 +
198 + // support flattened arguments
199 + if (languages && !Array.isArray(languages)) {
200 + languages = new Array(arguments.length)
201 + for (var i = 0; i < languages.length; i++) {
202 + languages[i] = arguments[i]
203 + }
204 + }
205 +
206 + // no languages, return all requested languages
207 + if (!languages || languages.length === 0) {
208 + return this.negotiator.languages()
209 + }
210 +
211 + return this.negotiator.languages(languages)[0] || false
212 +}
213 +
214 +/**
215 + * Convert extnames to mime.
216 + *
217 + * @param {String} type
218 + * @return {String}
219 + * @private
220 + */
221 +
222 +function extToMime (type) {
223 + return type.indexOf('/') === -1
224 + ? mime.lookup(type)
225 + : type
226 +}
227 +
228 +/**
229 + * Check if mime is valid.
230 + *
231 + * @param {String} type
232 + * @return {String}
233 + * @private
234 + */
235 +
236 +function validMime (type) {
237 + return typeof type === 'string'
238 +}
1 +{
2 + "name": "accepts",
3 + "description": "Higher-level content negotiation",
4 + "version": "1.3.7",
5 + "contributors": [
6 + "Douglas Christopher Wilson <doug@somethingdoug.com>",
7 + "Jonathan Ong <me@jongleberry.com> (http://jongleberry.com)"
8 + ],
9 + "license": "MIT",
10 + "repository": "jshttp/accepts",
11 + "dependencies": {
12 + "mime-types": "~2.1.24",
13 + "negotiator": "0.6.2"
14 + },
15 + "devDependencies": {
16 + "deep-equal": "1.0.1",
17 + "eslint": "5.16.0",
18 + "eslint-config-standard": "12.0.0",
19 + "eslint-plugin-import": "2.17.2",
20 + "eslint-plugin-markdown": "1.0.0",
21 + "eslint-plugin-node": "8.0.1",
22 + "eslint-plugin-promise": "4.1.1",
23 + "eslint-plugin-standard": "4.0.0",
24 + "mocha": "6.1.4",
25 + "nyc": "14.0.0"
26 + },
27 + "files": [
28 + "LICENSE",
29 + "HISTORY.md",
30 + "index.js"
31 + ],
32 + "engines": {
33 + "node": ">= 0.6"
34 + },
35 + "scripts": {
36 + "lint": "eslint --plugin markdown --ext js,md .",
37 + "test": "mocha --reporter spec --check-leaks --bail test/",
38 + "test-cov": "nyc --reporter=html --reporter=text npm test",
39 + "test-travis": "nyc --reporter=text npm test"
40 + },
41 + "keywords": [
42 + "content",
43 + "negotiation",
44 + "accept",
45 + "accepts"
46 + ]
47 +}
1 +The MIT License (MIT)
2 +
3 +Copyright (c) 2014 Blake Embrey (hello@blakeembrey.com)
4 +
5 +Permission is hereby granted, free of charge, to any person obtaining a copy
6 +of this software and associated documentation files (the "Software"), to deal
7 +in the Software without restriction, including without limitation the rights
8 +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 +copies of the Software, and to permit persons to whom the Software is
10 +furnished to do so, subject to the following conditions:
11 +
12 +The above copyright notice and this permission notice shall be included in
13 +all copies or substantial portions of the Software.
14 +
15 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21 +THE SOFTWARE.
1 +# Array Flatten
2 +
3 +[![NPM version][npm-image]][npm-url]
4 +[![NPM downloads][downloads-image]][downloads-url]
5 +[![Build status][travis-image]][travis-url]
6 +[![Test coverage][coveralls-image]][coveralls-url]
7 +
8 +> Flatten an array of nested arrays into a single flat array. Accepts an optional depth.
9 +
10 +## Installation
11 +
12 +```
13 +npm install array-flatten --save
14 +```
15 +
16 +## Usage
17 +
18 +```javascript
19 +var flatten = require('array-flatten')
20 +
21 +flatten([1, [2, [3, [4, [5], 6], 7], 8], 9])
22 +//=> [1, 2, 3, 4, 5, 6, 7, 8, 9]
23 +
24 +flatten([1, [2, [3, [4, [5], 6], 7], 8], 9], 2)
25 +//=> [1, 2, 3, [4, [5], 6], 7, 8, 9]
26 +
27 +(function () {
28 + flatten(arguments) //=> [1, 2, 3]
29 +})(1, [2, 3])
30 +```
31 +
32 +## License
33 +
34 +MIT
35 +
36 +[npm-image]: https://img.shields.io/npm/v/array-flatten.svg?style=flat
37 +[npm-url]: https://npmjs.org/package/array-flatten
38 +[downloads-image]: https://img.shields.io/npm/dm/array-flatten.svg?style=flat
39 +[downloads-url]: https://npmjs.org/package/array-flatten
40 +[travis-image]: https://img.shields.io/travis/blakeembrey/array-flatten.svg?style=flat
41 +[travis-url]: https://travis-ci.org/blakeembrey/array-flatten
42 +[coveralls-image]: https://img.shields.io/coveralls/blakeembrey/array-flatten.svg?style=flat
43 +[coveralls-url]: https://coveralls.io/r/blakeembrey/array-flatten?branch=master
1 +'use strict'
2 +
3 +/**
4 + * Expose `arrayFlatten`.
5 + */
6 +module.exports = arrayFlatten
7 +
8 +/**
9 + * Recursive flatten function with depth.
10 + *
11 + * @param {Array} array
12 + * @param {Array} result
13 + * @param {Number} depth
14 + * @return {Array}
15 + */
16 +function flattenWithDepth (array, result, depth) {
17 + for (var i = 0; i < array.length; i++) {
18 + var value = array[i]
19 +
20 + if (depth > 0 && Array.isArray(value)) {
21 + flattenWithDepth(value, result, depth - 1)
22 + } else {
23 + result.push(value)
24 + }
25 + }
26 +
27 + return result
28 +}
29 +
30 +/**
31 + * Recursive flatten function. Omitting depth is slightly faster.
32 + *
33 + * @param {Array} array
34 + * @param {Array} result
35 + * @return {Array}
36 + */
37 +function flattenForever (array, result) {
38 + for (var i = 0; i < array.length; i++) {
39 + var value = array[i]
40 +
41 + if (Array.isArray(value)) {
42 + flattenForever(value, result)
43 + } else {
44 + result.push(value)
45 + }
46 + }
47 +
48 + return result
49 +}
50 +
51 +/**
52 + * Flatten an array, with the ability to define a depth.
53 + *
54 + * @param {Array} array
55 + * @param {Number} depth
56 + * @return {Array}
57 + */
58 +function arrayFlatten (array, depth) {
59 + if (depth == null) {
60 + return flattenForever(array, [])
61 + }
62 +
63 + return flattenWithDepth(array, [], depth)
64 +}
1 +{
2 + "name": "array-flatten",
3 + "version": "1.1.1",
4 + "description": "Flatten an array of nested arrays into a single flat array",
5 + "main": "array-flatten.js",
6 + "files": [
7 + "array-flatten.js",
8 + "LICENSE"
9 + ],
10 + "scripts": {
11 + "test": "istanbul cover _mocha -- -R spec"
12 + },
13 + "repository": {
14 + "type": "git",
15 + "url": "git://github.com/blakeembrey/array-flatten.git"
16 + },
17 + "keywords": [
18 + "array",
19 + "flatten",
20 + "arguments",
21 + "depth"
22 + ],
23 + "author": {
24 + "name": "Blake Embrey",
25 + "email": "hello@blakeembrey.com",
26 + "url": "http://blakeembrey.me"
27 + },
28 + "license": "MIT",
29 + "bugs": {
30 + "url": "https://github.com/blakeembrey/array-flatten/issues"
31 + },
32 + "homepage": "https://github.com/blakeembrey/array-flatten",
33 + "devDependencies": {
34 + "istanbul": "^0.3.13",
35 + "mocha": "^2.2.4",
36 + "pre-commit": "^1.0.7",
37 + "standard": "^3.7.3"
38 + }
39 +}
This diff is collapsed. Click to expand it.
1 +Copyright (c) 2014-present Matt Zabriskie
2 +
3 +Permission is hereby granted, free of charge, to any person obtaining a copy
4 +of this software and associated documentation files (the "Software"), to deal
5 +in the Software without restriction, including without limitation the rights
6 +to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
7 +copies of the Software, and to permit persons to whom the Software is
8 +furnished to do so, subject to the following conditions:
9 +
10 +The above copyright notice and this permission notice shall be included in
11 +all copies or substantial portions of the Software.
12 +
13 +THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
14 +IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
15 +FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
16 +AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
17 +LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
18 +OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
19 +THE SOFTWARE.
This diff is collapsed. Click to expand it.
1 +# Security Policy
2 +
3 +## Reporting a Vulnerability
4 +
5 +Please report security issues to jasonsaayman@gmail.com
1 +# Upgrade Guide
2 +
3 +### 0.15.x -> 0.16.0
4 +
5 +#### `Promise` Type Declarations
6 +
7 +The `Promise` type declarations have been removed from the axios typings in favor of the built-in type declarations. If you use axios in a TypeScript project that targets `ES5`, please make sure to include the `es2015.promise` lib. Please see [this post](https://blog.mariusschulz.com/2016/11/25/typescript-2-0-built-in-type-declarations) for details.
8 +
9 +### 0.13.x -> 0.14.0
10 +
11 +#### TypeScript Definitions
12 +
13 +The axios TypeScript definitions have been updated to match the axios API and use the ES2015 module syntax.
14 +
15 +Please use the following `import` statement to import axios in TypeScript:
16 +
17 +```typescript
18 +import axios from 'axios';
19 +
20 +axios.get('/foo')
21 + .then(response => console.log(response))
22 + .catch(error => console.log(error));
23 +```
24 +
25 +#### `agent` Config Option
26 +
27 +The `agent` config option has been replaced with two new options: `httpAgent` and `httpsAgent`. Please use them instead.
28 +
29 +```js
30 +{
31 + // Define a custom agent for HTTP
32 + httpAgent: new http.Agent({ keepAlive: true }),
33 + // Define a custom agent for HTTPS
34 + httpsAgent: new https.Agent({ keepAlive: true })
35 +}
36 +```
37 +
38 +#### `progress` Config Option
39 +
40 +The `progress` config option has been replaced with the `onUploadProgress` and `onDownloadProgress` options.
41 +
42 +```js
43 +{
44 + // Define a handler for upload progress events
45 + onUploadProgress: function (progressEvent) {
46 + // ...
47 + },
48 +
49 + // Define a handler for download progress events
50 + onDownloadProgress: function (progressEvent) {
51 + // ...
52 + }
53 +}
54 +```
55 +
56 +### 0.12.x -> 0.13.0
57 +
58 +The `0.13.0` release contains several changes to custom adapters and error handling.
59 +
60 +#### Error Handling
61 +
62 +Previous to this release an error could either be a server response with bad status code or an actual `Error`. With this release Promise will always reject with an `Error`. In the case that a response was received, the `Error` will also include the response.
63 +
64 +```js
65 +axios.get('/user/12345')
66 + .catch((error) => {
67 + console.log(error.message);
68 + console.log(error.code); // Not always specified
69 + console.log(error.config); // The config that was used to make the request
70 + console.log(error.response); // Only available if response was received from the server
71 + });
72 +```
73 +
74 +#### Request Adapters
75 +
76 +This release changes a few things about how request adapters work. Please take note if you are using your own custom adapter.
77 +
78 +1. Response transformer is now called outside of adapter.
79 +2. Request adapter returns a `Promise`.
80 +
81 +This means that you no longer need to invoke `transformData` on response data. You will also no longer receive `resolve` and `reject` as arguments in your adapter.
82 +
83 +Previous code:
84 +
85 +```js
86 +function myAdapter(resolve, reject, config) {
87 + var response = {
88 + data: transformData(
89 + responseData,
90 + responseHeaders,
91 + config.transformResponse
92 + ),
93 + status: request.status,
94 + statusText: request.statusText,
95 + headers: responseHeaders
96 + };
97 + settle(resolve, reject, response);
98 +}
99 +```
100 +
101 +New code:
102 +
103 +```js
104 +function myAdapter(config) {
105 + return new Promise(function (resolve, reject) {
106 + var response = {
107 + data: responseData,
108 + status: request.status,
109 + statusText: request.statusText,
110 + headers: responseHeaders
111 + };
112 + settle(resolve, reject, response);
113 + });
114 +}
115 +```
116 +
117 +See the related commits for more details:
118 +- [Response transformers](https://github.com/axios/axios/commit/10eb23865101f9347570552c04e9d6211376e25e)
119 +- [Request adapter Promise](https://github.com/axios/axios/commit/157efd5615890301824e3121cc6c9d2f9b21f94a)
120 +
121 +### 0.5.x -> 0.6.0
122 +
123 +The `0.6.0` release contains mostly bug fixes, but there are a couple things to be aware of when upgrading.
124 +
125 +#### ES6 Promise Polyfill
126 +
127 +Up until the `0.6.0` release ES6 `Promise` was being polyfilled using [es6-promise](https://github.com/jakearchibald/es6-promise). With this release, the polyfill has been removed, and you will need to supply it yourself if your environment needs it.
128 +
129 +```js
130 +require('es6-promise').polyfill();
131 +var axios = require('axios');
132 +```
133 +
134 +This will polyfill the global environment, and only needs to be done once.
135 +
136 +#### `axios.success`/`axios.error`
137 +
138 +The `success`, and `error` aliases were deprecated in [0.4.0](https://github.com/axios/axios/blob/master/CHANGELOG.md#040-oct-03-2014). As of this release they have been removed entirely. Instead please use `axios.then`, and `axios.catch` respectively.
139 +
140 +```js
141 +axios.get('some/url')
142 + .then(function (res) {
143 + /* ... */
144 + })
145 + .catch(function (err) {
146 + /* ... */
147 + });
148 +```
149 +
150 +#### UMD
151 +
152 +Previous versions of axios shipped with an AMD, CommonJS, and Global build. This has all been rolled into a single UMD build.
153 +
154 +```js
155 +// AMD
156 +require(['bower_components/axios/dist/axios'], function (axios) {
157 + /* ... */
158 +});
159 +
160 +// CommonJS
161 +var axios = require('axios/dist/axios');
162 +```
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
1 +// TypeScript Version: 3.0
2 +
3 +export type AxiosRequestHeaders = Record<string, string>;
4 +
5 +export type AxiosResponseHeaders = Record<string, string> & {
6 + "set-cookie"?: string[]
7 +};
8 +
9 +export interface AxiosRequestTransformer {
10 + (data: any, headers?: AxiosRequestHeaders): any;
11 +}
12 +
13 +export interface AxiosResponseTransformer {
14 + (data: any, headers?: AxiosResponseHeaders): any;
15 +}
16 +
17 +export interface AxiosAdapter {
18 + (config: AxiosRequestConfig): AxiosPromise;
19 +}
20 +
21 +export interface AxiosBasicCredentials {
22 + username: string;
23 + password: string;
24 +}
25 +
26 +export interface AxiosProxyConfig {
27 + host: string;
28 + port: number;
29 + auth?: {
30 + username: string;
31 + password: string;
32 + };
33 + protocol?: string;
34 +}
35 +
36 +export type Method =
37 + | 'get' | 'GET'
38 + | 'delete' | 'DELETE'
39 + | 'head' | 'HEAD'
40 + | 'options' | 'OPTIONS'
41 + | 'post' | 'POST'
42 + | 'put' | 'PUT'
43 + | 'patch' | 'PATCH'
44 + | 'purge' | 'PURGE'
45 + | 'link' | 'LINK'
46 + | 'unlink' | 'UNLINK';
47 +
48 +export type ResponseType =
49 + | 'arraybuffer'
50 + | 'blob'
51 + | 'document'
52 + | 'json'
53 + | 'text'
54 + | 'stream';
55 +
56 +export interface TransitionalOptions {
57 + silentJSONParsing?: boolean;
58 + forcedJSONParsing?: boolean;
59 + clarifyTimeoutError?: boolean;
60 +}
61 +
62 +export interface AxiosRequestConfig<D = any> {
63 + url?: string;
64 + method?: Method;
65 + baseURL?: string;
66 + transformRequest?: AxiosRequestTransformer | AxiosRequestTransformer[];
67 + transformResponse?: AxiosResponseTransformer | AxiosResponseTransformer[];
68 + headers?: AxiosRequestHeaders;
69 + params?: any;
70 + paramsSerializer?: (params: any) => string;
71 + data?: D;
72 + timeout?: number;
73 + timeoutErrorMessage?: string;
74 + withCredentials?: boolean;
75 + adapter?: AxiosAdapter;
76 + auth?: AxiosBasicCredentials;
77 + responseType?: ResponseType;
78 + xsrfCookieName?: string;
79 + xsrfHeaderName?: string;
80 + onUploadProgress?: (progressEvent: any) => void;
81 + onDownloadProgress?: (progressEvent: any) => void;
82 + maxContentLength?: number;
83 + validateStatus?: ((status: number) => boolean) | null;
84 + maxBodyLength?: number;
85 + maxRedirects?: number;
86 + socketPath?: string | null;
87 + httpAgent?: any;
88 + httpsAgent?: any;
89 + proxy?: AxiosProxyConfig | false;
90 + cancelToken?: CancelToken;
91 + decompress?: boolean;
92 + transitional?: TransitionalOptions;
93 + signal?: AbortSignal;
94 + insecureHTTPParser?: boolean;
95 +}
96 +
97 +export interface HeadersDefaults {
98 + common: AxiosRequestHeaders;
99 + delete: AxiosRequestHeaders;
100 + get: AxiosRequestHeaders;
101 + head: AxiosRequestHeaders;
102 + post: AxiosRequestHeaders;
103 + put: AxiosRequestHeaders;
104 + patch: AxiosRequestHeaders;
105 + options?: AxiosRequestHeaders;
106 + purge?: AxiosRequestHeaders;
107 + link?: AxiosRequestHeaders;
108 + unlink?: AxiosRequestHeaders;
109 +}
110 +
111 +export interface AxiosDefaults<D = any> extends Omit<AxiosRequestConfig<D>, 'headers'> {
112 + headers: HeadersDefaults;
113 +}
114 +
115 +export interface AxiosResponse<T = any, D = any> {
116 + data: T;
117 + status: number;
118 + statusText: string;
119 + headers: AxiosResponseHeaders;
120 + config: AxiosRequestConfig<D>;
121 + request?: any;
122 +}
123 +
124 +export interface AxiosError<T = any, D = any> extends Error {
125 + config: AxiosRequestConfig<D>;
126 + code?: string;
127 + request?: any;
128 + response?: AxiosResponse<T, D>;
129 + isAxiosError: boolean;
130 + toJSON: () => object;
131 +}
132 +
133 +export interface AxiosPromise<T = any> extends Promise<AxiosResponse<T>> {
134 +}
135 +
136 +export interface CancelStatic {
137 + new (message?: string): Cancel;
138 +}
139 +
140 +export interface Cancel {
141 + message: string;
142 +}
143 +
144 +export interface Canceler {
145 + (message?: string): void;
146 +}
147 +
148 +export interface CancelTokenStatic {
149 + new (executor: (cancel: Canceler) => void): CancelToken;
150 + source(): CancelTokenSource;
151 +}
152 +
153 +export interface CancelToken {
154 + promise: Promise<Cancel>;
155 + reason?: Cancel;
156 + throwIfRequested(): void;
157 +}
158 +
159 +export interface CancelTokenSource {
160 + token: CancelToken;
161 + cancel: Canceler;
162 +}
163 +
164 +export interface AxiosInterceptorManager<V> {
165 + use<T = V>(onFulfilled?: (value: V) => T | Promise<T>, onRejected?: (error: any) => any): number;
166 + eject(id: number): void;
167 +}
168 +
169 +export class Axios {
170 + constructor(config?: AxiosRequestConfig);
171 + defaults: AxiosDefaults;
172 + interceptors: {
173 + request: AxiosInterceptorManager<AxiosRequestConfig>;
174 + response: AxiosInterceptorManager<AxiosResponse>;
175 + };
176 + getUri(config?: AxiosRequestConfig): string;
177 + request<T = any, R = AxiosResponse<T>, D = any>(config: AxiosRequestConfig<D>): Promise<R>;
178 + get<T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>;
179 + delete<T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>;
180 + head<T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>;
181 + options<T = any, R = AxiosResponse<T>, D = any>(url: string, config?: AxiosRequestConfig<D>): Promise<R>;
182 + post<T = any, R = AxiosResponse<T>, D = any>(url: string, data?: D, config?: AxiosRequestConfig<D>): Promise<R>;
183 + put<T = any, R = AxiosResponse<T>, D = any>(url: string, data?: D, config?: AxiosRequestConfig<D>): Promise<R>;
184 + patch<T = any, R = AxiosResponse<T>, D = any>(url: string, data?: D, config?: AxiosRequestConfig<D>): Promise<R>;
185 +}
186 +
187 +export interface AxiosInstance extends Axios {
188 + (config: AxiosRequestConfig): AxiosPromise;
189 + (url: string, config?: AxiosRequestConfig): AxiosPromise;
190 +}
191 +
192 +export interface AxiosStatic extends AxiosInstance {
193 + create(config?: AxiosRequestConfig): AxiosInstance;
194 + Cancel: CancelStatic;
195 + CancelToken: CancelTokenStatic;
196 + Axios: typeof Axios;
197 + readonly VERSION: string;
198 + isCancel(value: any): boolean;
199 + all<T>(values: Array<T | Promise<T>>): Promise<T[]>;
200 + spread<T, R>(callback: (...args: T[]) => R): (array: T[]) => R;
201 + isAxiosError(payload: any): payload is AxiosError;
202 +}
203 +
204 +declare const axios: AxiosStatic;
205 +
206 +export default axios;
1 +module.exports = require('./lib/axios');
...\ No newline at end of file ...\ No newline at end of file
1 +# axios // adapters
2 +
3 +The modules under `adapters/` are modules that handle dispatching a request and settling a returned `Promise` once a response is received.
4 +
5 +## Example
6 +
7 +```js
8 +var settle = require('./../core/settle');
9 +
10 +module.exports = function myAdapter(config) {
11 + // At this point:
12 + // - config has been merged with defaults
13 + // - request transformers have already run
14 + // - request interceptors have already run
15 +
16 + // Make the request using config provided
17 + // Upon response settle the Promise
18 +
19 + return new Promise(function(resolve, reject) {
20 +
21 + var response = {
22 + data: responseData,
23 + status: request.status,
24 + statusText: request.statusText,
25 + headers: responseHeaders,
26 + config: config,
27 + request: request
28 + };
29 +
30 + settle(resolve, reject, response);
31 +
32 + // From here:
33 + // - response transformers will run
34 + // - response interceptors will run
35 + });
36 +}
37 +```
This diff is collapsed. Click to expand it.
1 +'use strict';
2 +
3 +var utils = require('./../utils');
4 +var settle = require('./../core/settle');
5 +var cookies = require('./../helpers/cookies');
6 +var buildURL = require('./../helpers/buildURL');
7 +var buildFullPath = require('../core/buildFullPath');
8 +var parseHeaders = require('./../helpers/parseHeaders');
9 +var isURLSameOrigin = require('./../helpers/isURLSameOrigin');
10 +var createError = require('../core/createError');
11 +var defaults = require('../defaults');
12 +var Cancel = require('../cancel/Cancel');
13 +
14 +module.exports = function xhrAdapter(config) {
15 + return new Promise(function dispatchXhrRequest(resolve, reject) {
16 + var requestData = config.data;
17 + var requestHeaders = config.headers;
18 + var responseType = config.responseType;
19 + var onCanceled;
20 + function done() {
21 + if (config.cancelToken) {
22 + config.cancelToken.unsubscribe(onCanceled);
23 + }
24 +
25 + if (config.signal) {
26 + config.signal.removeEventListener('abort', onCanceled);
27 + }
28 + }
29 +
30 + if (utils.isFormData(requestData)) {
31 + delete requestHeaders['Content-Type']; // Let the browser set it
32 + }
33 +
34 + var request = new XMLHttpRequest();
35 +
36 + // HTTP basic authentication
37 + if (config.auth) {
38 + var username = config.auth.username || '';
39 + var password = config.auth.password ? unescape(encodeURIComponent(config.auth.password)) : '';
40 + requestHeaders.Authorization = 'Basic ' + btoa(username + ':' + password);
41 + }
42 +
43 + var fullPath = buildFullPath(config.baseURL, config.url);
44 + request.open(config.method.toUpperCase(), buildURL(fullPath, config.params, config.paramsSerializer), true);
45 +
46 + // Set the request timeout in MS
47 + request.timeout = config.timeout;
48 +
49 + function onloadend() {
50 + if (!request) {
51 + return;
52 + }
53 + // Prepare the response
54 + var responseHeaders = 'getAllResponseHeaders' in request ? parseHeaders(request.getAllResponseHeaders()) : null;
55 + var responseData = !responseType || responseType === 'text' || responseType === 'json' ?
56 + request.responseText : request.response;
57 + var response = {
58 + data: responseData,
59 + status: request.status,
60 + statusText: request.statusText,
61 + headers: responseHeaders,
62 + config: config,
63 + request: request
64 + };
65 +
66 + settle(function _resolve(value) {
67 + resolve(value);
68 + done();
69 + }, function _reject(err) {
70 + reject(err);
71 + done();
72 + }, response);
73 +
74 + // Clean up request
75 + request = null;
76 + }
77 +
78 + if ('onloadend' in request) {
79 + // Use onloadend if available
80 + request.onloadend = onloadend;
81 + } else {
82 + // Listen for ready state to emulate onloadend
83 + request.onreadystatechange = function handleLoad() {
84 + if (!request || request.readyState !== 4) {
85 + return;
86 + }
87 +
88 + // The request errored out and we didn't get a response, this will be
89 + // handled by onerror instead
90 + // With one exception: request that using file: protocol, most browsers
91 + // will return status as 0 even though it's a successful request
92 + if (request.status === 0 && !(request.responseURL && request.responseURL.indexOf('file:') === 0)) {
93 + return;
94 + }
95 + // readystate handler is calling before onerror or ontimeout handlers,
96 + // so we should call onloadend on the next 'tick'
97 + setTimeout(onloadend);
98 + };
99 + }
100 +
101 + // Handle browser request cancellation (as opposed to a manual cancellation)
102 + request.onabort = function handleAbort() {
103 + if (!request) {
104 + return;
105 + }
106 +
107 + reject(createError('Request aborted', config, 'ECONNABORTED', request));
108 +
109 + // Clean up request
110 + request = null;
111 + };
112 +
113 + // Handle low level network errors
114 + request.onerror = function handleError() {
115 + // Real errors are hidden from us by the browser
116 + // onerror should only fire if it's a network error
117 + reject(createError('Network Error', config, null, request));
118 +
119 + // Clean up request
120 + request = null;
121 + };
122 +
123 + // Handle timeout
124 + request.ontimeout = function handleTimeout() {
125 + var timeoutErrorMessage = config.timeout ? 'timeout of ' + config.timeout + 'ms exceeded' : 'timeout exceeded';
126 + var transitional = config.transitional || defaults.transitional;
127 + if (config.timeoutErrorMessage) {
128 + timeoutErrorMessage = config.timeoutErrorMessage;
129 + }
130 + reject(createError(
131 + timeoutErrorMessage,
132 + config,
133 + transitional.clarifyTimeoutError ? 'ETIMEDOUT' : 'ECONNABORTED',
134 + request));
135 +
136 + // Clean up request
137 + request = null;
138 + };
139 +
140 + // Add xsrf header
141 + // This is only done if running in a standard browser environment.
142 + // Specifically not if we're in a web worker, or react-native.
143 + if (utils.isStandardBrowserEnv()) {
144 + // Add xsrf header
145 + var xsrfValue = (config.withCredentials || isURLSameOrigin(fullPath)) && config.xsrfCookieName ?
146 + cookies.read(config.xsrfCookieName) :
147 + undefined;
148 +
149 + if (xsrfValue) {
150 + requestHeaders[config.xsrfHeaderName] = xsrfValue;
151 + }
152 + }
153 +
154 + // Add headers to the request
155 + if ('setRequestHeader' in request) {
156 + utils.forEach(requestHeaders, function setRequestHeader(val, key) {
157 + if (typeof requestData === 'undefined' && key.toLowerCase() === 'content-type') {
158 + // Remove Content-Type if data is undefined
159 + delete requestHeaders[key];
160 + } else {
161 + // Otherwise add header to the request
162 + request.setRequestHeader(key, val);
163 + }
164 + });
165 + }
166 +
167 + // Add withCredentials to request if needed
168 + if (!utils.isUndefined(config.withCredentials)) {
169 + request.withCredentials = !!config.withCredentials;
170 + }
171 +
172 + // Add responseType to request if needed
173 + if (responseType && responseType !== 'json') {
174 + request.responseType = config.responseType;
175 + }
176 +
177 + // Handle progress if needed
178 + if (typeof config.onDownloadProgress === 'function') {
179 + request.addEventListener('progress', config.onDownloadProgress);
180 + }
181 +
182 + // Not all browsers support upload events
183 + if (typeof config.onUploadProgress === 'function' && request.upload) {
184 + request.upload.addEventListener('progress', config.onUploadProgress);
185 + }
186 +
187 + if (config.cancelToken || config.signal) {
188 + // Handle cancellation
189 + // eslint-disable-next-line func-names
190 + onCanceled = function(cancel) {
191 + if (!request) {
192 + return;
193 + }
194 + reject(!cancel || (cancel && cancel.type) ? new Cancel('canceled') : cancel);
195 + request.abort();
196 + request = null;
197 + };
198 +
199 + config.cancelToken && config.cancelToken.subscribe(onCanceled);
200 + if (config.signal) {
201 + config.signal.aborted ? onCanceled() : config.signal.addEventListener('abort', onCanceled);
202 + }
203 + }
204 +
205 + if (!requestData) {
206 + requestData = null;
207 + }
208 +
209 + // Send the request
210 + request.send(requestData);
211 + });
212 +};
1 +'use strict';
2 +
3 +var utils = require('./utils');
4 +var bind = require('./helpers/bind');
5 +var Axios = require('./core/Axios');
6 +var mergeConfig = require('./core/mergeConfig');
7 +var defaults = require('./defaults');
8 +
9 +/**
10 + * Create an instance of Axios
11 + *
12 + * @param {Object} defaultConfig The default config for the instance
13 + * @return {Axios} A new instance of Axios
14 + */
15 +function createInstance(defaultConfig) {
16 + var context = new Axios(defaultConfig);
17 + var instance = bind(Axios.prototype.request, context);
18 +
19 + // Copy axios.prototype to instance
20 + utils.extend(instance, Axios.prototype, context);
21 +
22 + // Copy context to instance
23 + utils.extend(instance, context);
24 +
25 + // Factory for creating new instances
26 + instance.create = function create(instanceConfig) {
27 + return createInstance(mergeConfig(defaultConfig, instanceConfig));
28 + };
29 +
30 + return instance;
31 +}
32 +
33 +// Create the default instance to be exported
34 +var axios = createInstance(defaults);
35 +
36 +// Expose Axios class to allow class inheritance
37 +axios.Axios = Axios;
38 +
39 +// Expose Cancel & CancelToken
40 +axios.Cancel = require('./cancel/Cancel');
41 +axios.CancelToken = require('./cancel/CancelToken');
42 +axios.isCancel = require('./cancel/isCancel');
43 +axios.VERSION = require('./env/data').version;
44 +
45 +// Expose all/spread
46 +axios.all = function all(promises) {
47 + return Promise.all(promises);
48 +};
49 +axios.spread = require('./helpers/spread');
50 +
51 +// Expose isAxiosError
52 +axios.isAxiosError = require('./helpers/isAxiosError');
53 +
54 +module.exports = axios;
55 +
56 +// Allow use of default import syntax in TypeScript
57 +module.exports.default = axios;
1 +'use strict';
2 +
3 +/**
4 + * A `Cancel` is an object that is thrown when an operation is canceled.
5 + *
6 + * @class
7 + * @param {string=} message The message.
8 + */
9 +function Cancel(message) {
10 + this.message = message;
11 +}
12 +
13 +Cancel.prototype.toString = function toString() {
14 + return 'Cancel' + (this.message ? ': ' + this.message : '');
15 +};
16 +
17 +Cancel.prototype.__CANCEL__ = true;
18 +
19 +module.exports = Cancel;
1 +'use strict';
2 +
3 +var Cancel = require('./Cancel');
4 +
5 +/**
6 + * A `CancelToken` is an object that can be used to request cancellation of an operation.
7 + *
8 + * @class
9 + * @param {Function} executor The executor function.
10 + */
11 +function CancelToken(executor) {
12 + if (typeof executor !== 'function') {
13 + throw new TypeError('executor must be a function.');
14 + }
15 +
16 + var resolvePromise;
17 +
18 + this.promise = new Promise(function promiseExecutor(resolve) {
19 + resolvePromise = resolve;
20 + });
21 +
22 + var token = this;
23 +
24 + // eslint-disable-next-line func-names
25 + this.promise.then(function(cancel) {
26 + if (!token._listeners) return;
27 +
28 + var i;
29 + var l = token._listeners.length;
30 +
31 + for (i = 0; i < l; i++) {
32 + token._listeners[i](cancel);
33 + }
34 + token._listeners = null;
35 + });
36 +
37 + // eslint-disable-next-line func-names
38 + this.promise.then = function(onfulfilled) {
39 + var _resolve;
40 + // eslint-disable-next-line func-names
41 + var promise = new Promise(function(resolve) {
42 + token.subscribe(resolve);
43 + _resolve = resolve;
44 + }).then(onfulfilled);
45 +
46 + promise.cancel = function reject() {
47 + token.unsubscribe(_resolve);
48 + };
49 +
50 + return promise;
51 + };
52 +
53 + executor(function cancel(message) {
54 + if (token.reason) {
55 + // Cancellation has already been requested
56 + return;
57 + }
58 +
59 + token.reason = new Cancel(message);
60 + resolvePromise(token.reason);
61 + });
62 +}
63 +
64 +/**
65 + * Throws a `Cancel` if cancellation has been requested.
66 + */
67 +CancelToken.prototype.throwIfRequested = function throwIfRequested() {
68 + if (this.reason) {
69 + throw this.reason;
70 + }
71 +};
72 +
73 +/**
74 + * Subscribe to the cancel signal
75 + */
76 +
77 +CancelToken.prototype.subscribe = function subscribe(listener) {
78 + if (this.reason) {
79 + listener(this.reason);
80 + return;
81 + }
82 +
83 + if (this._listeners) {
84 + this._listeners.push(listener);
85 + } else {
86 + this._listeners = [listener];
87 + }
88 +};
89 +
90 +/**
91 + * Unsubscribe from the cancel signal
92 + */
93 +
94 +CancelToken.prototype.unsubscribe = function unsubscribe(listener) {
95 + if (!this._listeners) {
96 + return;
97 + }
98 + var index = this._listeners.indexOf(listener);
99 + if (index !== -1) {
100 + this._listeners.splice(index, 1);
101 + }
102 +};
103 +
104 +/**
105 + * Returns an object that contains a new `CancelToken` and a function that, when called,
106 + * cancels the `CancelToken`.
107 + */
108 +CancelToken.source = function source() {
109 + var cancel;
110 + var token = new CancelToken(function executor(c) {
111 + cancel = c;
112 + });
113 + return {
114 + token: token,
115 + cancel: cancel
116 + };
117 +};
118 +
119 +module.exports = CancelToken;
1 +'use strict';
2 +
3 +module.exports = function isCancel(value) {
4 + return !!(value && value.__CANCEL__);
5 +};
1 +'use strict';
2 +
3 +var utils = require('./../utils');
4 +var buildURL = require('../helpers/buildURL');
5 +var InterceptorManager = require('./InterceptorManager');
6 +var dispatchRequest = require('./dispatchRequest');
7 +var mergeConfig = require('./mergeConfig');
8 +var validator = require('../helpers/validator');
9 +
10 +var validators = validator.validators;
11 +/**
12 + * Create a new instance of Axios
13 + *
14 + * @param {Object} instanceConfig The default config for the instance
15 + */
16 +function Axios(instanceConfig) {
17 + this.defaults = instanceConfig;
18 + this.interceptors = {
19 + request: new InterceptorManager(),
20 + response: new InterceptorManager()
21 + };
22 +}
23 +
24 +/**
25 + * Dispatch a request
26 + *
27 + * @param {Object} config The config specific for this request (merged with this.defaults)
28 + */
29 +Axios.prototype.request = function request(config) {
30 + /*eslint no-param-reassign:0*/
31 + // Allow for axios('example/url'[, config]) a la fetch API
32 + if (typeof config === 'string') {
33 + config = arguments[1] || {};
34 + config.url = arguments[0];
35 + } else {
36 + config = config || {};
37 + }
38 +
39 + config = mergeConfig(this.defaults, config);
40 +
41 + // Set config.method
42 + if (config.method) {
43 + config.method = config.method.toLowerCase();
44 + } else if (this.defaults.method) {
45 + config.method = this.defaults.method.toLowerCase();
46 + } else {
47 + config.method = 'get';
48 + }
49 +
50 + var transitional = config.transitional;
51 +
52 + if (transitional !== undefined) {
53 + validator.assertOptions(transitional, {
54 + silentJSONParsing: validators.transitional(validators.boolean),
55 + forcedJSONParsing: validators.transitional(validators.boolean),
56 + clarifyTimeoutError: validators.transitional(validators.boolean)
57 + }, false);
58 + }
59 +
60 + // filter out skipped interceptors
61 + var requestInterceptorChain = [];
62 + var synchronousRequestInterceptors = true;
63 + this.interceptors.request.forEach(function unshiftRequestInterceptors(interceptor) {
64 + if (typeof interceptor.runWhen === 'function' && interceptor.runWhen(config) === false) {
65 + return;
66 + }
67 +
68 + synchronousRequestInterceptors = synchronousRequestInterceptors && interceptor.synchronous;
69 +
70 + requestInterceptorChain.unshift(interceptor.fulfilled, interceptor.rejected);
71 + });
72 +
73 + var responseInterceptorChain = [];
74 + this.interceptors.response.forEach(function pushResponseInterceptors(interceptor) {
75 + responseInterceptorChain.push(interceptor.fulfilled, interceptor.rejected);
76 + });
77 +
78 + var promise;
79 +
80 + if (!synchronousRequestInterceptors) {
81 + var chain = [dispatchRequest, undefined];
82 +
83 + Array.prototype.unshift.apply(chain, requestInterceptorChain);
84 + chain = chain.concat(responseInterceptorChain);
85 +
86 + promise = Promise.resolve(config);
87 + while (chain.length) {
88 + promise = promise.then(chain.shift(), chain.shift());
89 + }
90 +
91 + return promise;
92 + }
93 +
94 +
95 + var newConfig = config;
96 + while (requestInterceptorChain.length) {
97 + var onFulfilled = requestInterceptorChain.shift();
98 + var onRejected = requestInterceptorChain.shift();
99 + try {
100 + newConfig = onFulfilled(newConfig);
101 + } catch (error) {
102 + onRejected(error);
103 + break;
104 + }
105 + }
106 +
107 + try {
108 + promise = dispatchRequest(newConfig);
109 + } catch (error) {
110 + return Promise.reject(error);
111 + }
112 +
113 + while (responseInterceptorChain.length) {
114 + promise = promise.then(responseInterceptorChain.shift(), responseInterceptorChain.shift());
115 + }
116 +
117 + return promise;
118 +};
119 +
120 +Axios.prototype.getUri = function getUri(config) {
121 + config = mergeConfig(this.defaults, config);
122 + return buildURL(config.url, config.params, config.paramsSerializer).replace(/^\?/, '');
123 +};
124 +
125 +// Provide aliases for supported request methods
126 +utils.forEach(['delete', 'get', 'head', 'options'], function forEachMethodNoData(method) {
127 + /*eslint func-names:0*/
128 + Axios.prototype[method] = function(url, config) {
129 + return this.request(mergeConfig(config || {}, {
130 + method: method,
131 + url: url,
132 + data: (config || {}).data
133 + }));
134 + };
135 +});
136 +
137 +utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
138 + /*eslint func-names:0*/
139 + Axios.prototype[method] = function(url, data, config) {
140 + return this.request(mergeConfig(config || {}, {
141 + method: method,
142 + url: url,
143 + data: data
144 + }));
145 + };
146 +});
147 +
148 +module.exports = Axios;
1 +'use strict';
2 +
3 +var utils = require('./../utils');
4 +
5 +function InterceptorManager() {
6 + this.handlers = [];
7 +}
8 +
9 +/**
10 + * Add a new interceptor to the stack
11 + *
12 + * @param {Function} fulfilled The function to handle `then` for a `Promise`
13 + * @param {Function} rejected The function to handle `reject` for a `Promise`
14 + *
15 + * @return {Number} An ID used to remove interceptor later
16 + */
17 +InterceptorManager.prototype.use = function use(fulfilled, rejected, options) {
18 + this.handlers.push({
19 + fulfilled: fulfilled,
20 + rejected: rejected,
21 + synchronous: options ? options.synchronous : false,
22 + runWhen: options ? options.runWhen : null
23 + });
24 + return this.handlers.length - 1;
25 +};
26 +
27 +/**
28 + * Remove an interceptor from the stack
29 + *
30 + * @param {Number} id The ID that was returned by `use`
31 + */
32 +InterceptorManager.prototype.eject = function eject(id) {
33 + if (this.handlers[id]) {
34 + this.handlers[id] = null;
35 + }
36 +};
37 +
38 +/**
39 + * Iterate over all the registered interceptors
40 + *
41 + * This method is particularly useful for skipping over any
42 + * interceptors that may have become `null` calling `eject`.
43 + *
44 + * @param {Function} fn The function to call for each interceptor
45 + */
46 +InterceptorManager.prototype.forEach = function forEach(fn) {
47 + utils.forEach(this.handlers, function forEachHandler(h) {
48 + if (h !== null) {
49 + fn(h);
50 + }
51 + });
52 +};
53 +
54 +module.exports = InterceptorManager;
1 +# axios // core
2 +
3 +The modules found in `core/` should be modules that are specific to the domain logic of axios. These modules would most likely not make sense to be consumed outside of the axios module, as their logic is too specific. Some examples of core modules are:
4 +
5 +- Dispatching requests
6 + - Requests sent via `adapters/` (see lib/adapters/README.md)
7 +- Managing interceptors
8 +- Handling config
1 +'use strict';
2 +
3 +var isAbsoluteURL = require('../helpers/isAbsoluteURL');
4 +var combineURLs = require('../helpers/combineURLs');
5 +
6 +/**
7 + * Creates a new URL by combining the baseURL with the requestedURL,
8 + * only when the requestedURL is not already an absolute URL.
9 + * If the requestURL is absolute, this function returns the requestedURL untouched.
10 + *
11 + * @param {string} baseURL The base URL
12 + * @param {string} requestedURL Absolute or relative URL to combine
13 + * @returns {string} The combined full path
14 + */
15 +module.exports = function buildFullPath(baseURL, requestedURL) {
16 + if (baseURL && !isAbsoluteURL(requestedURL)) {
17 + return combineURLs(baseURL, requestedURL);
18 + }
19 + return requestedURL;
20 +};
1 +'use strict';
2 +
3 +var enhanceError = require('./enhanceError');
4 +
5 +/**
6 + * Create an Error with the specified message, config, error code, request and response.
7 + *
8 + * @param {string} message The error message.
9 + * @param {Object} config The config.
10 + * @param {string} [code] The error code (for example, 'ECONNABORTED').
11 + * @param {Object} [request] The request.
12 + * @param {Object} [response] The response.
13 + * @returns {Error} The created error.
14 + */
15 +module.exports = function createError(message, config, code, request, response) {
16 + var error = new Error(message);
17 + return enhanceError(error, config, code, request, response);
18 +};
1 +'use strict';
2 +
3 +var utils = require('./../utils');
4 +var transformData = require('./transformData');
5 +var isCancel = require('../cancel/isCancel');
6 +var defaults = require('../defaults');
7 +var Cancel = require('../cancel/Cancel');
8 +
9 +/**
10 + * Throws a `Cancel` if cancellation has been requested.
11 + */
12 +function throwIfCancellationRequested(config) {
13 + if (config.cancelToken) {
14 + config.cancelToken.throwIfRequested();
15 + }
16 +
17 + if (config.signal && config.signal.aborted) {
18 + throw new Cancel('canceled');
19 + }
20 +}
21 +
22 +/**
23 + * Dispatch a request to the server using the configured adapter.
24 + *
25 + * @param {object} config The config that is to be used for the request
26 + * @returns {Promise} The Promise to be fulfilled
27 + */
28 +module.exports = function dispatchRequest(config) {
29 + throwIfCancellationRequested(config);
30 +
31 + // Ensure headers exist
32 + config.headers = config.headers || {};
33 +
34 + // Transform request data
35 + config.data = transformData.call(
36 + config,
37 + config.data,
38 + config.headers,
39 + config.transformRequest
40 + );
41 +
42 + // Flatten headers
43 + config.headers = utils.merge(
44 + config.headers.common || {},
45 + config.headers[config.method] || {},
46 + config.headers
47 + );
48 +
49 + utils.forEach(
50 + ['delete', 'get', 'head', 'post', 'put', 'patch', 'common'],
51 + function cleanHeaderConfig(method) {
52 + delete config.headers[method];
53 + }
54 + );
55 +
56 + var adapter = config.adapter || defaults.adapter;
57 +
58 + return adapter(config).then(function onAdapterResolution(response) {
59 + throwIfCancellationRequested(config);
60 +
61 + // Transform response data
62 + response.data = transformData.call(
63 + config,
64 + response.data,
65 + response.headers,
66 + config.transformResponse
67 + );
68 +
69 + return response;
70 + }, function onAdapterRejection(reason) {
71 + if (!isCancel(reason)) {
72 + throwIfCancellationRequested(config);
73 +
74 + // Transform response data
75 + if (reason && reason.response) {
76 + reason.response.data = transformData.call(
77 + config,
78 + reason.response.data,
79 + reason.response.headers,
80 + config.transformResponse
81 + );
82 + }
83 + }
84 +
85 + return Promise.reject(reason);
86 + });
87 +};
1 +'use strict';
2 +
3 +/**
4 + * Update an Error with the specified config, error code, and response.
5 + *
6 + * @param {Error} error The error to update.
7 + * @param {Object} config The config.
8 + * @param {string} [code] The error code (for example, 'ECONNABORTED').
9 + * @param {Object} [request] The request.
10 + * @param {Object} [response] The response.
11 + * @returns {Error} The error.
12 + */
13 +module.exports = function enhanceError(error, config, code, request, response) {
14 + error.config = config;
15 + if (code) {
16 + error.code = code;
17 + }
18 +
19 + error.request = request;
20 + error.response = response;
21 + error.isAxiosError = true;
22 +
23 + error.toJSON = function toJSON() {
24 + return {
25 + // Standard
26 + message: this.message,
27 + name: this.name,
28 + // Microsoft
29 + description: this.description,
30 + number: this.number,
31 + // Mozilla
32 + fileName: this.fileName,
33 + lineNumber: this.lineNumber,
34 + columnNumber: this.columnNumber,
35 + stack: this.stack,
36 + // Axios
37 + config: this.config,
38 + code: this.code,
39 + status: this.response && this.response.status ? this.response.status : null
40 + };
41 + };
42 + return error;
43 +};
1 +'use strict';
2 +
3 +var utils = require('../utils');
4 +
5 +/**
6 + * Config-specific merge-function which creates a new config-object
7 + * by merging two configuration objects together.
8 + *
9 + * @param {Object} config1
10 + * @param {Object} config2
11 + * @returns {Object} New object resulting from merging config2 to config1
12 + */
13 +module.exports = function mergeConfig(config1, config2) {
14 + // eslint-disable-next-line no-param-reassign
15 + config2 = config2 || {};
16 + var config = {};
17 +
18 + function getMergedValue(target, source) {
19 + if (utils.isPlainObject(target) && utils.isPlainObject(source)) {
20 + return utils.merge(target, source);
21 + } else if (utils.isPlainObject(source)) {
22 + return utils.merge({}, source);
23 + } else if (utils.isArray(source)) {
24 + return source.slice();
25 + }
26 + return source;
27 + }
28 +
29 + // eslint-disable-next-line consistent-return
30 + function mergeDeepProperties(prop) {
31 + if (!utils.isUndefined(config2[prop])) {
32 + return getMergedValue(config1[prop], config2[prop]);
33 + } else if (!utils.isUndefined(config1[prop])) {
34 + return getMergedValue(undefined, config1[prop]);
35 + }
36 + }
37 +
38 + // eslint-disable-next-line consistent-return
39 + function valueFromConfig2(prop) {
40 + if (!utils.isUndefined(config2[prop])) {
41 + return getMergedValue(undefined, config2[prop]);
42 + }
43 + }
44 +
45 + // eslint-disable-next-line consistent-return
46 + function defaultToConfig2(prop) {
47 + if (!utils.isUndefined(config2[prop])) {
48 + return getMergedValue(undefined, config2[prop]);
49 + } else if (!utils.isUndefined(config1[prop])) {
50 + return getMergedValue(undefined, config1[prop]);
51 + }
52 + }
53 +
54 + // eslint-disable-next-line consistent-return
55 + function mergeDirectKeys(prop) {
56 + if (prop in config2) {
57 + return getMergedValue(config1[prop], config2[prop]);
58 + } else if (prop in config1) {
59 + return getMergedValue(undefined, config1[prop]);
60 + }
61 + }
62 +
63 + var mergeMap = {
64 + 'url': valueFromConfig2,
65 + 'method': valueFromConfig2,
66 + 'data': valueFromConfig2,
67 + 'baseURL': defaultToConfig2,
68 + 'transformRequest': defaultToConfig2,
69 + 'transformResponse': defaultToConfig2,
70 + 'paramsSerializer': defaultToConfig2,
71 + 'timeout': defaultToConfig2,
72 + 'timeoutMessage': defaultToConfig2,
73 + 'withCredentials': defaultToConfig2,
74 + 'adapter': defaultToConfig2,
75 + 'responseType': defaultToConfig2,
76 + 'xsrfCookieName': defaultToConfig2,
77 + 'xsrfHeaderName': defaultToConfig2,
78 + 'onUploadProgress': defaultToConfig2,
79 + 'onDownloadProgress': defaultToConfig2,
80 + 'decompress': defaultToConfig2,
81 + 'maxContentLength': defaultToConfig2,
82 + 'maxBodyLength': defaultToConfig2,
83 + 'transport': defaultToConfig2,
84 + 'httpAgent': defaultToConfig2,
85 + 'httpsAgent': defaultToConfig2,
86 + 'cancelToken': defaultToConfig2,
87 + 'socketPath': defaultToConfig2,
88 + 'responseEncoding': defaultToConfig2,
89 + 'validateStatus': mergeDirectKeys
90 + };
91 +
92 + utils.forEach(Object.keys(config1).concat(Object.keys(config2)), function computeConfigValue(prop) {
93 + var merge = mergeMap[prop] || mergeDeepProperties;
94 + var configValue = merge(prop);
95 + (utils.isUndefined(configValue) && merge !== mergeDirectKeys) || (config[prop] = configValue);
96 + });
97 +
98 + return config;
99 +};
1 +'use strict';
2 +
3 +var createError = require('./createError');
4 +
5 +/**
6 + * Resolve or reject a Promise based on response status.
7 + *
8 + * @param {Function} resolve A function that resolves the promise.
9 + * @param {Function} reject A function that rejects the promise.
10 + * @param {object} response The response.
11 + */
12 +module.exports = function settle(resolve, reject, response) {
13 + var validateStatus = response.config.validateStatus;
14 + if (!response.status || !validateStatus || validateStatus(response.status)) {
15 + resolve(response);
16 + } else {
17 + reject(createError(
18 + 'Request failed with status code ' + response.status,
19 + response.config,
20 + null,
21 + response.request,
22 + response
23 + ));
24 + }
25 +};
1 +'use strict';
2 +
3 +var utils = require('./../utils');
4 +var defaults = require('./../defaults');
5 +
6 +/**
7 + * Transform the data for a request or a response
8 + *
9 + * @param {Object|String} data The data to be transformed
10 + * @param {Array} headers The headers for the request or response
11 + * @param {Array|Function} fns A single function or Array of functions
12 + * @returns {*} The resulting transformed data
13 + */
14 +module.exports = function transformData(data, headers, fns) {
15 + var context = this || defaults;
16 + /*eslint no-param-reassign:0*/
17 + utils.forEach(fns, function transform(fn) {
18 + data = fn.call(context, data, headers);
19 + });
20 +
21 + return data;
22 +};
1 +'use strict';
2 +
3 +var utils = require('./utils');
4 +var normalizeHeaderName = require('./helpers/normalizeHeaderName');
5 +var enhanceError = require('./core/enhanceError');
6 +
7 +var DEFAULT_CONTENT_TYPE = {
8 + 'Content-Type': 'application/x-www-form-urlencoded'
9 +};
10 +
11 +function setContentTypeIfUnset(headers, value) {
12 + if (!utils.isUndefined(headers) && utils.isUndefined(headers['Content-Type'])) {
13 + headers['Content-Type'] = value;
14 + }
15 +}
16 +
17 +function getDefaultAdapter() {
18 + var adapter;
19 + if (typeof XMLHttpRequest !== 'undefined') {
20 + // For browsers use XHR adapter
21 + adapter = require('./adapters/xhr');
22 + } else if (typeof process !== 'undefined' && Object.prototype.toString.call(process) === '[object process]') {
23 + // For node use HTTP adapter
24 + adapter = require('./adapters/http');
25 + }
26 + return adapter;
27 +}
28 +
29 +function stringifySafely(rawValue, parser, encoder) {
30 + if (utils.isString(rawValue)) {
31 + try {
32 + (parser || JSON.parse)(rawValue);
33 + return utils.trim(rawValue);
34 + } catch (e) {
35 + if (e.name !== 'SyntaxError') {
36 + throw e;
37 + }
38 + }
39 + }
40 +
41 + return (encoder || JSON.stringify)(rawValue);
42 +}
43 +
44 +var defaults = {
45 +
46 + transitional: {
47 + silentJSONParsing: true,
48 + forcedJSONParsing: true,
49 + clarifyTimeoutError: false
50 + },
51 +
52 + adapter: getDefaultAdapter(),
53 +
54 + transformRequest: [function transformRequest(data, headers) {
55 + normalizeHeaderName(headers, 'Accept');
56 + normalizeHeaderName(headers, 'Content-Type');
57 +
58 + if (utils.isFormData(data) ||
59 + utils.isArrayBuffer(data) ||
60 + utils.isBuffer(data) ||
61 + utils.isStream(data) ||
62 + utils.isFile(data) ||
63 + utils.isBlob(data)
64 + ) {
65 + return data;
66 + }
67 + if (utils.isArrayBufferView(data)) {
68 + return data.buffer;
69 + }
70 + if (utils.isURLSearchParams(data)) {
71 + setContentTypeIfUnset(headers, 'application/x-www-form-urlencoded;charset=utf-8');
72 + return data.toString();
73 + }
74 + if (utils.isObject(data) || (headers && headers['Content-Type'] === 'application/json')) {
75 + setContentTypeIfUnset(headers, 'application/json');
76 + return stringifySafely(data);
77 + }
78 + return data;
79 + }],
80 +
81 + transformResponse: [function transformResponse(data) {
82 + var transitional = this.transitional || defaults.transitional;
83 + var silentJSONParsing = transitional && transitional.silentJSONParsing;
84 + var forcedJSONParsing = transitional && transitional.forcedJSONParsing;
85 + var strictJSONParsing = !silentJSONParsing && this.responseType === 'json';
86 +
87 + if (strictJSONParsing || (forcedJSONParsing && utils.isString(data) && data.length)) {
88 + try {
89 + return JSON.parse(data);
90 + } catch (e) {
91 + if (strictJSONParsing) {
92 + if (e.name === 'SyntaxError') {
93 + throw enhanceError(e, this, 'E_JSON_PARSE');
94 + }
95 + throw e;
96 + }
97 + }
98 + }
99 +
100 + return data;
101 + }],
102 +
103 + /**
104 + * A timeout in milliseconds to abort a request. If set to 0 (default) a
105 + * timeout is not created.
106 + */
107 + timeout: 0,
108 +
109 + xsrfCookieName: 'XSRF-TOKEN',
110 + xsrfHeaderName: 'X-XSRF-TOKEN',
111 +
112 + maxContentLength: -1,
113 + maxBodyLength: -1,
114 +
115 + validateStatus: function validateStatus(status) {
116 + return status >= 200 && status < 300;
117 + },
118 +
119 + headers: {
120 + common: {
121 + 'Accept': 'application/json, text/plain, */*'
122 + }
123 + }
124 +};
125 +
126 +utils.forEach(['delete', 'get', 'head'], function forEachMethodNoData(method) {
127 + defaults.headers[method] = {};
128 +});
129 +
130 +utils.forEach(['post', 'put', 'patch'], function forEachMethodWithData(method) {
131 + defaults.headers[method] = utils.merge(DEFAULT_CONTENT_TYPE);
132 +});
133 +
134 +module.exports = defaults;
1 +# axios // env
2 +
3 +The `data.js` file is updated automatically when the package version is upgrading. Please do not edit it manually.
1 +module.exports = {
2 + "version": "0.24.0"
3 +};
...\ No newline at end of file ...\ No newline at end of file
1 +# axios // helpers
2 +
3 +The modules found in `helpers/` should be generic modules that are _not_ specific to the domain logic of axios. These modules could theoretically be published to npm on their own and consumed by other modules or apps. Some examples of generic modules are things like:
4 +
5 +- Browser polyfills
6 +- Managing cookies
7 +- Parsing HTTP headers
1 +'use strict';
2 +
3 +module.exports = function bind(fn, thisArg) {
4 + return function wrap() {
5 + var args = new Array(arguments.length);
6 + for (var i = 0; i < args.length; i++) {
7 + args[i] = arguments[i];
8 + }
9 + return fn.apply(thisArg, args);
10 + };
11 +};
1 +'use strict';
2 +
3 +var utils = require('./../utils');
4 +
5 +function encode(val) {
6 + return encodeURIComponent(val).
7 + replace(/%3A/gi, ':').
8 + replace(/%24/g, '$').
9 + replace(/%2C/gi, ',').
10 + replace(/%20/g, '+').
11 + replace(/%5B/gi, '[').
12 + replace(/%5D/gi, ']');
13 +}
14 +
15 +/**
16 + * Build a URL by appending params to the end
17 + *
18 + * @param {string} url The base of the url (e.g., http://www.google.com)
19 + * @param {object} [params] The params to be appended
20 + * @returns {string} The formatted url
21 + */
22 +module.exports = function buildURL(url, params, paramsSerializer) {
23 + /*eslint no-param-reassign:0*/
24 + if (!params) {
25 + return url;
26 + }
27 +
28 + var serializedParams;
29 + if (paramsSerializer) {
30 + serializedParams = paramsSerializer(params);
31 + } else if (utils.isURLSearchParams(params)) {
32 + serializedParams = params.toString();
33 + } else {
34 + var parts = [];
35 +
36 + utils.forEach(params, function serialize(val, key) {
37 + if (val === null || typeof val === 'undefined') {
38 + return;
39 + }
40 +
41 + if (utils.isArray(val)) {
42 + key = key + '[]';
43 + } else {
44 + val = [val];
45 + }
46 +
47 + utils.forEach(val, function parseValue(v) {
48 + if (utils.isDate(v)) {
49 + v = v.toISOString();
50 + } else if (utils.isObject(v)) {
51 + v = JSON.stringify(v);
52 + }
53 + parts.push(encode(key) + '=' + encode(v));
54 + });
55 + });
56 +
57 + serializedParams = parts.join('&');
58 + }
59 +
60 + if (serializedParams) {
61 + var hashmarkIndex = url.indexOf('#');
62 + if (hashmarkIndex !== -1) {
63 + url = url.slice(0, hashmarkIndex);
64 + }
65 +
66 + url += (url.indexOf('?') === -1 ? '?' : '&') + serializedParams;
67 + }
68 +
69 + return url;
70 +};
1 +'use strict';
2 +
3 +/**
4 + * Creates a new URL by combining the specified URLs
5 + *
6 + * @param {string} baseURL The base URL
7 + * @param {string} relativeURL The relative URL
8 + * @returns {string} The combined URL
9 + */
10 +module.exports = function combineURLs(baseURL, relativeURL) {
11 + return relativeURL
12 + ? baseURL.replace(/\/+$/, '') + '/' + relativeURL.replace(/^\/+/, '')
13 + : baseURL;
14 +};
1 +'use strict';
2 +
3 +var utils = require('./../utils');
4 +
5 +module.exports = (
6 + utils.isStandardBrowserEnv() ?
7 +
8 + // Standard browser envs support document.cookie
9 + (function standardBrowserEnv() {
10 + return {
11 + write: function write(name, value, expires, path, domain, secure) {
12 + var cookie = [];
13 + cookie.push(name + '=' + encodeURIComponent(value));
14 +
15 + if (utils.isNumber(expires)) {
16 + cookie.push('expires=' + new Date(expires).toGMTString());
17 + }
18 +
19 + if (utils.isString(path)) {
20 + cookie.push('path=' + path);
21 + }
22 +
23 + if (utils.isString(domain)) {
24 + cookie.push('domain=' + domain);
25 + }
26 +
27 + if (secure === true) {
28 + cookie.push('secure');
29 + }
30 +
31 + document.cookie = cookie.join('; ');
32 + },
33 +
34 + read: function read(name) {
35 + var match = document.cookie.match(new RegExp('(^|;\\s*)(' + name + ')=([^;]*)'));
36 + return (match ? decodeURIComponent(match[3]) : null);
37 + },
38 +
39 + remove: function remove(name) {
40 + this.write(name, '', Date.now() - 86400000);
41 + }
42 + };
43 + })() :
44 +
45 + // Non standard browser env (web workers, react-native) lack needed support.
46 + (function nonStandardBrowserEnv() {
47 + return {
48 + write: function write() {},
49 + read: function read() { return null; },
50 + remove: function remove() {}
51 + };
52 + })()
53 +);
1 +'use strict';
2 +
3 +/*eslint no-console:0*/
4 +
5 +/**
6 + * Supply a warning to the developer that a method they are using
7 + * has been deprecated.
8 + *
9 + * @param {string} method The name of the deprecated method
10 + * @param {string} [instead] The alternate method to use if applicable
11 + * @param {string} [docs] The documentation URL to get further details
12 + */
13 +module.exports = function deprecatedMethod(method, instead, docs) {
14 + try {
15 + console.warn(
16 + 'DEPRECATED method `' + method + '`.' +
17 + (instead ? ' Use `' + instead + '` instead.' : '') +
18 + ' This method will be removed in a future release.');
19 +
20 + if (docs) {
21 + console.warn('For more information about usage see ' + docs);
22 + }
23 + } catch (e) { /* Ignore */ }
24 +};
1 +'use strict';
2 +
3 +/**
4 + * Determines whether the specified URL is absolute
5 + *
6 + * @param {string} url The URL to test
7 + * @returns {boolean} True if the specified URL is absolute, otherwise false
8 + */
9 +module.exports = function isAbsoluteURL(url) {
10 + // A URL is considered absolute if it begins with "<scheme>://" or "//" (protocol-relative URL).
11 + // RFC 3986 defines scheme name as a sequence of characters beginning with a letter and followed
12 + // by any combination of letters, digits, plus, period, or hyphen.
13 + return /^([a-z][a-z\d\+\-\.]*:)?\/\//i.test(url);
14 +};
1 +'use strict';
2 +
3 +/**
4 + * Determines whether the payload is an error thrown by Axios
5 + *
6 + * @param {*} payload The value to test
7 + * @returns {boolean} True if the payload is an error thrown by Axios, otherwise false
8 + */
9 +module.exports = function isAxiosError(payload) {
10 + return (typeof payload === 'object') && (payload.isAxiosError === true);
11 +};
1 +'use strict';
2 +
3 +var utils = require('./../utils');
4 +
5 +module.exports = (
6 + utils.isStandardBrowserEnv() ?
7 +
8 + // Standard browser envs have full support of the APIs needed to test
9 + // whether the request URL is of the same origin as current location.
10 + (function standardBrowserEnv() {
11 + var msie = /(msie|trident)/i.test(navigator.userAgent);
12 + var urlParsingNode = document.createElement('a');
13 + var originURL;
14 +
15 + /**
16 + * Parse a URL to discover it's components
17 + *
18 + * @param {String} url The URL to be parsed
19 + * @returns {Object}
20 + */
21 + function resolveURL(url) {
22 + var href = url;
23 +
24 + if (msie) {
25 + // IE needs attribute set twice to normalize properties
26 + urlParsingNode.setAttribute('href', href);
27 + href = urlParsingNode.href;
28 + }
29 +
30 + urlParsingNode.setAttribute('href', href);
31 +
32 + // urlParsingNode provides the UrlUtils interface - http://url.spec.whatwg.org/#urlutils
33 + return {
34 + href: urlParsingNode.href,
35 + protocol: urlParsingNode.protocol ? urlParsingNode.protocol.replace(/:$/, '') : '',
36 + host: urlParsingNode.host,
37 + search: urlParsingNode.search ? urlParsingNode.search.replace(/^\?/, '') : '',
38 + hash: urlParsingNode.hash ? urlParsingNode.hash.replace(/^#/, '') : '',
39 + hostname: urlParsingNode.hostname,
40 + port: urlParsingNode.port,
41 + pathname: (urlParsingNode.pathname.charAt(0) === '/') ?
42 + urlParsingNode.pathname :
43 + '/' + urlParsingNode.pathname
44 + };
45 + }
46 +
47 + originURL = resolveURL(window.location.href);
48 +
49 + /**
50 + * Determine if a URL shares the same origin as the current location
51 + *
52 + * @param {String} requestURL The URL to test
53 + * @returns {boolean} True if URL shares the same origin, otherwise false
54 + */
55 + return function isURLSameOrigin(requestURL) {
56 + var parsed = (utils.isString(requestURL)) ? resolveURL(requestURL) : requestURL;
57 + return (parsed.protocol === originURL.protocol &&
58 + parsed.host === originURL.host);
59 + };
60 + })() :
61 +
62 + // Non standard browser envs (web workers, react-native) lack needed support.
63 + (function nonStandardBrowserEnv() {
64 + return function isURLSameOrigin() {
65 + return true;
66 + };
67 + })()
68 +);
1 +'use strict';
2 +
3 +var utils = require('../utils');
4 +
5 +module.exports = function normalizeHeaderName(headers, normalizedName) {
6 + utils.forEach(headers, function processHeader(value, name) {
7 + if (name !== normalizedName && name.toUpperCase() === normalizedName.toUpperCase()) {
8 + headers[normalizedName] = value;
9 + delete headers[name];
10 + }
11 + });
12 +};
1 +'use strict';
2 +
3 +var utils = require('./../utils');
4 +
5 +// Headers whose duplicates are ignored by node
6 +// c.f. https://nodejs.org/api/http.html#http_message_headers
7 +var ignoreDuplicateOf = [
8 + 'age', 'authorization', 'content-length', 'content-type', 'etag',
9 + 'expires', 'from', 'host', 'if-modified-since', 'if-unmodified-since',
10 + 'last-modified', 'location', 'max-forwards', 'proxy-authorization',
11 + 'referer', 'retry-after', 'user-agent'
12 +];
13 +
14 +/**
15 + * Parse headers into an object
16 + *
17 + * ```
18 + * Date: Wed, 27 Aug 2014 08:58:49 GMT
19 + * Content-Type: application/json
20 + * Connection: keep-alive
21 + * Transfer-Encoding: chunked
22 + * ```
23 + *
24 + * @param {String} headers Headers needing to be parsed
25 + * @returns {Object} Headers parsed into an object
26 + */
27 +module.exports = function parseHeaders(headers) {
28 + var parsed = {};
29 + var key;
30 + var val;
31 + var i;
32 +
33 + if (!headers) { return parsed; }
34 +
35 + utils.forEach(headers.split('\n'), function parser(line) {
36 + i = line.indexOf(':');
37 + key = utils.trim(line.substr(0, i)).toLowerCase();
38 + val = utils.trim(line.substr(i + 1));
39 +
40 + if (key) {
41 + if (parsed[key] && ignoreDuplicateOf.indexOf(key) >= 0) {
42 + return;
43 + }
44 + if (key === 'set-cookie') {
45 + parsed[key] = (parsed[key] ? parsed[key] : []).concat([val]);
46 + } else {
47 + parsed[key] = parsed[key] ? parsed[key] + ', ' + val : val;
48 + }
49 + }
50 + });
51 +
52 + return parsed;
53 +};
1 +'use strict';
2 +
3 +/**
4 + * Syntactic sugar for invoking a function and expanding an array for arguments.
5 + *
6 + * Common use case would be to use `Function.prototype.apply`.
7 + *
8 + * ```js
9 + * function f(x, y, z) {}
10 + * var args = [1, 2, 3];
11 + * f.apply(null, args);
12 + * ```
13 + *
14 + * With `spread` this example can be re-written.
15 + *
16 + * ```js
17 + * spread(function(x, y, z) {})([1, 2, 3]);
18 + * ```
19 + *
20 + * @param {Function} callback
21 + * @returns {Function}
22 + */
23 +module.exports = function spread(callback) {
24 + return function wrap(arr) {
25 + return callback.apply(null, arr);
26 + };
27 +};
1 +'use strict';
2 +
3 +var VERSION = require('../env/data').version;
4 +
5 +var validators = {};
6 +
7 +// eslint-disable-next-line func-names
8 +['object', 'boolean', 'number', 'function', 'string', 'symbol'].forEach(function(type, i) {
9 + validators[type] = function validator(thing) {
10 + return typeof thing === type || 'a' + (i < 1 ? 'n ' : ' ') + type;
11 + };
12 +});
13 +
14 +var deprecatedWarnings = {};
15 +
16 +/**
17 + * Transitional option validator
18 + * @param {function|boolean?} validator - set to false if the transitional option has been removed
19 + * @param {string?} version - deprecated version / removed since version
20 + * @param {string?} message - some message with additional info
21 + * @returns {function}
22 + */
23 +validators.transitional = function transitional(validator, version, message) {
24 + function formatMessage(opt, desc) {
25 + return '[Axios v' + VERSION + '] Transitional option \'' + opt + '\'' + desc + (message ? '. ' + message : '');
26 + }
27 +
28 + // eslint-disable-next-line func-names
29 + return function(value, opt, opts) {
30 + if (validator === false) {
31 + throw new Error(formatMessage(opt, ' has been removed' + (version ? ' in ' + version : '')));
32 + }
33 +
34 + if (version && !deprecatedWarnings[opt]) {
35 + deprecatedWarnings[opt] = true;
36 + // eslint-disable-next-line no-console
37 + console.warn(
38 + formatMessage(
39 + opt,
40 + ' has been deprecated since v' + version + ' and will be removed in the near future'
41 + )
42 + );
43 + }
44 +
45 + return validator ? validator(value, opt, opts) : true;
46 + };
47 +};
48 +
49 +/**
50 + * Assert object's properties type
51 + * @param {object} options
52 + * @param {object} schema
53 + * @param {boolean?} allowUnknown
54 + */
55 +
56 +function assertOptions(options, schema, allowUnknown) {
57 + if (typeof options !== 'object') {
58 + throw new TypeError('options must be an object');
59 + }
60 + var keys = Object.keys(options);
61 + var i = keys.length;
62 + while (i-- > 0) {
63 + var opt = keys[i];
64 + var validator = schema[opt];
65 + if (validator) {
66 + var value = options[opt];
67 + var result = value === undefined || validator(value, opt, options);
68 + if (result !== true) {
69 + throw new TypeError('option ' + opt + ' must be ' + result);
70 + }
71 + continue;
72 + }
73 + if (allowUnknown !== true) {
74 + throw Error('Unknown option ' + opt);
75 + }
76 + }
77 +}
78 +
79 +module.exports = {
80 + assertOptions: assertOptions,
81 + validators: validators
82 +};
1 +'use strict';
2 +
3 +var bind = require('./helpers/bind');
4 +
5 +// utils is a library of generic helper functions non-specific to axios
6 +
7 +var toString = Object.prototype.toString;
8 +
9 +/**
10 + * Determine if a value is an Array
11 + *
12 + * @param {Object} val The value to test
13 + * @returns {boolean} True if value is an Array, otherwise false
14 + */
15 +function isArray(val) {
16 + return toString.call(val) === '[object Array]';
17 +}
18 +
19 +/**
20 + * Determine if a value is undefined
21 + *
22 + * @param {Object} val The value to test
23 + * @returns {boolean} True if the value is undefined, otherwise false
24 + */
25 +function isUndefined(val) {
26 + return typeof val === 'undefined';
27 +}
28 +
29 +/**
30 + * Determine if a value is a Buffer
31 + *
32 + * @param {Object} val The value to test
33 + * @returns {boolean} True if value is a Buffer, otherwise false
34 + */
35 +function isBuffer(val) {
36 + return val !== null && !isUndefined(val) && val.constructor !== null && !isUndefined(val.constructor)
37 + && typeof val.constructor.isBuffer === 'function' && val.constructor.isBuffer(val);
38 +}
39 +
40 +/**
41 + * Determine if a value is an ArrayBuffer
42 + *
43 + * @param {Object} val The value to test
44 + * @returns {boolean} True if value is an ArrayBuffer, otherwise false
45 + */
46 +function isArrayBuffer(val) {
47 + return toString.call(val) === '[object ArrayBuffer]';
48 +}
49 +
50 +/**
51 + * Determine if a value is a FormData
52 + *
53 + * @param {Object} val The value to test
54 + * @returns {boolean} True if value is an FormData, otherwise false
55 + */
56 +function isFormData(val) {
57 + return (typeof FormData !== 'undefined') && (val instanceof FormData);
58 +}
59 +
60 +/**
61 + * Determine if a value is a view on an ArrayBuffer
62 + *
63 + * @param {Object} val The value to test
64 + * @returns {boolean} True if value is a view on an ArrayBuffer, otherwise false
65 + */
66 +function isArrayBufferView(val) {
67 + var result;
68 + if ((typeof ArrayBuffer !== 'undefined') && (ArrayBuffer.isView)) {
69 + result = ArrayBuffer.isView(val);
70 + } else {
71 + result = (val) && (val.buffer) && (val.buffer instanceof ArrayBuffer);
72 + }
73 + return result;
74 +}
75 +
76 +/**
77 + * Determine if a value is a String
78 + *
79 + * @param {Object} val The value to test
80 + * @returns {boolean} True if value is a String, otherwise false
81 + */
82 +function isString(val) {
83 + return typeof val === 'string';
84 +}
85 +
86 +/**
87 + * Determine if a value is a Number
88 + *
89 + * @param {Object} val The value to test
90 + * @returns {boolean} True if value is a Number, otherwise false
91 + */
92 +function isNumber(val) {
93 + return typeof val === 'number';
94 +}
95 +
96 +/**
97 + * Determine if a value is an Object
98 + *
99 + * @param {Object} val The value to test
100 + * @returns {boolean} True if value is an Object, otherwise false
101 + */
102 +function isObject(val) {
103 + return val !== null && typeof val === 'object';
104 +}
105 +
106 +/**
107 + * Determine if a value is a plain Object
108 + *
109 + * @param {Object} val The value to test
110 + * @return {boolean} True if value is a plain Object, otherwise false
111 + */
112 +function isPlainObject(val) {
113 + if (toString.call(val) !== '[object Object]') {
114 + return false;
115 + }
116 +
117 + var prototype = Object.getPrototypeOf(val);
118 + return prototype === null || prototype === Object.prototype;
119 +}
120 +
121 +/**
122 + * Determine if a value is a Date
123 + *
124 + * @param {Object} val The value to test
125 + * @returns {boolean} True if value is a Date, otherwise false
126 + */
127 +function isDate(val) {
128 + return toString.call(val) === '[object Date]';
129 +}
130 +
131 +/**
132 + * Determine if a value is a File
133 + *
134 + * @param {Object} val The value to test
135 + * @returns {boolean} True if value is a File, otherwise false
136 + */
137 +function isFile(val) {
138 + return toString.call(val) === '[object File]';
139 +}
140 +
141 +/**
142 + * Determine if a value is a Blob
143 + *
144 + * @param {Object} val The value to test
145 + * @returns {boolean} True if value is a Blob, otherwise false
146 + */
147 +function isBlob(val) {
148 + return toString.call(val) === '[object Blob]';
149 +}
150 +
151 +/**
152 + * Determine if a value is a Function
153 + *
154 + * @param {Object} val The value to test
155 + * @returns {boolean} True if value is a Function, otherwise false
156 + */
157 +function isFunction(val) {
158 + return toString.call(val) === '[object Function]';
159 +}
160 +
161 +/**
162 + * Determine if a value is a Stream
163 + *
164 + * @param {Object} val The value to test
165 + * @returns {boolean} True if value is a Stream, otherwise false
166 + */
167 +function isStream(val) {
168 + return isObject(val) && isFunction(val.pipe);
169 +}
170 +
171 +/**
172 + * Determine if a value is a URLSearchParams object
173 + *
174 + * @param {Object} val The value to test
175 + * @returns {boolean} True if value is a URLSearchParams object, otherwise false
176 + */
177 +function isURLSearchParams(val) {
178 + return typeof URLSearchParams !== 'undefined' && val instanceof URLSearchParams;
179 +}
180 +
181 +/**
182 + * Trim excess whitespace off the beginning and end of a string
183 + *
184 + * @param {String} str The String to trim
185 + * @returns {String} The String freed of excess whitespace
186 + */
187 +function trim(str) {
188 + return str.trim ? str.trim() : str.replace(/^\s+|\s+$/g, '');
189 +}
190 +
191 +/**
192 + * Determine if we're running in a standard browser environment
193 + *
194 + * This allows axios to run in a web worker, and react-native.
195 + * Both environments support XMLHttpRequest, but not fully standard globals.
196 + *
197 + * web workers:
198 + * typeof window -> undefined
199 + * typeof document -> undefined
200 + *
201 + * react-native:
202 + * navigator.product -> 'ReactNative'
203 + * nativescript
204 + * navigator.product -> 'NativeScript' or 'NS'
205 + */
206 +function isStandardBrowserEnv() {
207 + if (typeof navigator !== 'undefined' && (navigator.product === 'ReactNative' ||
208 + navigator.product === 'NativeScript' ||
209 + navigator.product === 'NS')) {
210 + return false;
211 + }
212 + return (
213 + typeof window !== 'undefined' &&
214 + typeof document !== 'undefined'
215 + );
216 +}
217 +
218 +/**
219 + * Iterate over an Array or an Object invoking a function for each item.
220 + *
221 + * If `obj` is an Array callback will be called passing
222 + * the value, index, and complete array for each item.
223 + *
224 + * If 'obj' is an Object callback will be called passing
225 + * the value, key, and complete object for each property.
226 + *
227 + * @param {Object|Array} obj The object to iterate
228 + * @param {Function} fn The callback to invoke for each item
229 + */
230 +function forEach(obj, fn) {
231 + // Don't bother if no value provided
232 + if (obj === null || typeof obj === 'undefined') {
233 + return;
234 + }
235 +
236 + // Force an array if not already something iterable
237 + if (typeof obj !== 'object') {
238 + /*eslint no-param-reassign:0*/
239 + obj = [obj];
240 + }
241 +
242 + if (isArray(obj)) {
243 + // Iterate over array values
244 + for (var i = 0, l = obj.length; i < l; i++) {
245 + fn.call(null, obj[i], i, obj);
246 + }
247 + } else {
248 + // Iterate over object keys
249 + for (var key in obj) {
250 + if (Object.prototype.hasOwnProperty.call(obj, key)) {
251 + fn.call(null, obj[key], key, obj);
252 + }
253 + }
254 + }
255 +}
256 +
257 +/**
258 + * Accepts varargs expecting each argument to be an object, then
259 + * immutably merges the properties of each object and returns result.
260 + *
261 + * When multiple objects contain the same key the later object in
262 + * the arguments list will take precedence.
263 + *
264 + * Example:
265 + *
266 + * ```js
267 + * var result = merge({foo: 123}, {foo: 456});
268 + * console.log(result.foo); // outputs 456
269 + * ```
270 + *
271 + * @param {Object} obj1 Object to merge
272 + * @returns {Object} Result of all merge properties
273 + */
274 +function merge(/* obj1, obj2, obj3, ... */) {
275 + var result = {};
276 + function assignValue(val, key) {
277 + if (isPlainObject(result[key]) && isPlainObject(val)) {
278 + result[key] = merge(result[key], val);
279 + } else if (isPlainObject(val)) {
280 + result[key] = merge({}, val);
281 + } else if (isArray(val)) {
282 + result[key] = val.slice();
283 + } else {
284 + result[key] = val;
285 + }
286 + }
287 +
288 + for (var i = 0, l = arguments.length; i < l; i++) {
289 + forEach(arguments[i], assignValue);
290 + }
291 + return result;
292 +}
293 +
294 +/**
295 + * Extends object a by mutably adding to it the properties of object b.
296 + *
297 + * @param {Object} a The object to be extended
298 + * @param {Object} b The object to copy properties from
299 + * @param {Object} thisArg The object to bind function to
300 + * @return {Object} The resulting value of object a
301 + */
302 +function extend(a, b, thisArg) {
303 + forEach(b, function assignValue(val, key) {
304 + if (thisArg && typeof val === 'function') {
305 + a[key] = bind(val, thisArg);
306 + } else {
307 + a[key] = val;
308 + }
309 + });
310 + return a;
311 +}
312 +
313 +/**
314 + * Remove byte order marker. This catches EF BB BF (the UTF-8 BOM)
315 + *
316 + * @param {string} content with BOM
317 + * @return {string} content value without BOM
318 + */
319 +function stripBOM(content) {
320 + if (content.charCodeAt(0) === 0xFEFF) {
321 + content = content.slice(1);
322 + }
323 + return content;
324 +}
325 +
326 +module.exports = {
327 + isArray: isArray,
328 + isArrayBuffer: isArrayBuffer,
329 + isBuffer: isBuffer,
330 + isFormData: isFormData,
331 + isArrayBufferView: isArrayBufferView,
332 + isString: isString,
333 + isNumber: isNumber,
334 + isObject: isObject,
335 + isPlainObject: isPlainObject,
336 + isUndefined: isUndefined,
337 + isDate: isDate,
338 + isFile: isFile,
339 + isBlob: isBlob,
340 + isFunction: isFunction,
341 + isStream: isStream,
342 + isURLSearchParams: isURLSearchParams,
343 + isStandardBrowserEnv: isStandardBrowserEnv,
344 + forEach: forEach,
345 + merge: merge,
346 + extend: extend,
347 + trim: trim,
348 + stripBOM: stripBOM
349 +};
1 +{
2 + "name": "axios",
3 + "version": "0.24.0",
4 + "description": "Promise based HTTP client for the browser and node.js",
5 + "main": "index.js",
6 + "types": "index.d.ts",
7 + "scripts": {
8 + "test": "grunt test && dtslint",
9 + "start": "node ./sandbox/server.js",
10 + "build": "NODE_ENV=production grunt build",
11 + "preversion": "grunt version && npm test",
12 + "version": "npm run build && git add -A dist && git add CHANGELOG.md bower.json package.json",
13 + "postversion": "git push && git push --tags",
14 + "examples": "node ./examples/server.js",
15 + "coveralls": "cat coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js",
16 + "fix": "eslint --fix lib/**/*.js"
17 + },
18 + "repository": {
19 + "type": "git",
20 + "url": "https://github.com/axios/axios.git"
21 + },
22 + "keywords": [
23 + "xhr",
24 + "http",
25 + "ajax",
26 + "promise",
27 + "node"
28 + ],
29 + "author": "Matt Zabriskie",
30 + "license": "MIT",
31 + "bugs": {
32 + "url": "https://github.com/axios/axios/issues"
33 + },
34 + "homepage": "https://axios-http.com",
35 + "devDependencies": {
36 + "abortcontroller-polyfill": "^1.5.0",
37 + "coveralls": "^3.0.0",
38 + "dtslint": "^4.1.6",
39 + "es6-promise": "^4.2.4",
40 + "grunt": "^1.3.0",
41 + "grunt-banner": "^0.6.0",
42 + "grunt-cli": "^1.2.0",
43 + "grunt-contrib-clean": "^1.1.0",
44 + "grunt-contrib-watch": "^1.0.0",
45 + "grunt-eslint": "^23.0.0",
46 + "grunt-karma": "^4.0.0",
47 + "grunt-mocha-test": "^0.13.3",
48 + "grunt-webpack": "^4.0.2",
49 + "istanbul-instrumenter-loader": "^1.0.0",
50 + "jasmine-core": "^2.4.1",
51 + "karma": "^6.3.2",
52 + "karma-chrome-launcher": "^3.1.0",
53 + "karma-firefox-launcher": "^2.1.0",
54 + "karma-jasmine": "^1.1.1",
55 + "karma-jasmine-ajax": "^0.1.13",
56 + "karma-safari-launcher": "^1.0.0",
57 + "karma-sauce-launcher": "^4.3.6",
58 + "karma-sinon": "^1.0.5",
59 + "karma-sourcemap-loader": "^0.3.8",
60 + "karma-webpack": "^4.0.2",
61 + "load-grunt-tasks": "^3.5.2",
62 + "minimist": "^1.2.0",
63 + "mocha": "^8.2.1",
64 + "sinon": "^4.5.0",
65 + "terser-webpack-plugin": "^4.2.3",
66 + "typescript": "^4.0.5",
67 + "url-search-params": "^0.10.0",
68 + "webpack": "^4.44.2",
69 + "webpack-dev-server": "^3.11.0"
70 + },
71 + "browser": {
72 + "./lib/adapters/http.js": "./lib/adapters/xhr.js"
73 + },
74 + "jsdelivr": "dist/axios.min.js",
75 + "unpkg": "dist/axios.min.js",
76 + "typings": "./index.d.ts",
77 + "dependencies": {
78 + "follow-redirects": "^1.14.4"
79 + },
80 + "bundlesize": [
81 + {
82 + "path": "./dist/axios.min.js",
83 + "threshold": "5kB"
84 + }
85 + ]
86 +}
1 +{
2 + "compilerOptions": {
3 + "module": "es2015",
4 + "lib": ["dom", "es2015"],
5 + "types": [],
6 + "moduleResolution": "node",
7 + "strict": true,
8 + "noEmit": true,
9 + "baseUrl": ".",
10 + "paths": {
11 + "axios": ["."]
12 + }
13 + }
14 +}
1 +{
2 + "extends": "dtslint/dtslint.json",
3 + "rules": {
4 + "no-unnecessary-generics": false
5 + }
6 +}
This diff is collapsed. Click to expand it.
1 +(The MIT License)
2 +
3 +Copyright (c) 2014 Jonathan Ong <me@jongleberry.com>
4 +Copyright (c) 2014-2015 Douglas Christopher Wilson <doug@somethingdoug.com>
5 +
6 +Permission is hereby granted, free of charge, to any person obtaining
7 +a copy of this software and associated documentation files (the
8 +'Software'), to deal in the Software without restriction, including
9 +without limitation the rights to use, copy, modify, merge, publish,
10 +distribute, sublicense, and/or sell copies of the Software, and to
11 +permit persons to whom the Software is furnished to do so, subject to
12 +the following conditions:
13 +
14 +The above copyright notice and this permission notice shall be
15 +included in all copies or substantial portions of the Software.
16 +
17 +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
18 +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
This diff is collapsed. Click to expand it.
1 +/*!
2 + * body-parser
3 + * Copyright(c) 2014-2015 Douglas Christopher Wilson
4 + * MIT Licensed
5 + */
6 +
7 +'use strict'
8 +
9 +/**
10 + * Module dependencies.
11 + * @private
12 + */
13 +
14 +var deprecate = require('depd')('body-parser')
15 +
16 +/**
17 + * Cache of loaded parsers.
18 + * @private
19 + */
20 +
21 +var parsers = Object.create(null)
22 +
23 +/**
24 + * @typedef Parsers
25 + * @type {function}
26 + * @property {function} json
27 + * @property {function} raw
28 + * @property {function} text
29 + * @property {function} urlencoded
30 + */
31 +
32 +/**
33 + * Module exports.
34 + * @type {Parsers}
35 + */
36 +
37 +exports = module.exports = deprecate.function(bodyParser,
38 + 'bodyParser: use individual json/urlencoded middlewares')
39 +
40 +/**
41 + * JSON parser.
42 + * @public
43 + */
44 +
45 +Object.defineProperty(exports, 'json', {
46 + configurable: true,
47 + enumerable: true,
48 + get: createParserGetter('json')
49 +})
50 +
51 +/**
52 + * Raw parser.
53 + * @public
54 + */
55 +
56 +Object.defineProperty(exports, 'raw', {
57 + configurable: true,
58 + enumerable: true,
59 + get: createParserGetter('raw')
60 +})
61 +
62 +/**
63 + * Text parser.
64 + * @public
65 + */
66 +
67 +Object.defineProperty(exports, 'text', {
68 + configurable: true,
69 + enumerable: true,
70 + get: createParserGetter('text')
71 +})
72 +
73 +/**
74 + * URL-encoded parser.
75 + * @public
76 + */
77 +
78 +Object.defineProperty(exports, 'urlencoded', {
79 + configurable: true,
80 + enumerable: true,
81 + get: createParserGetter('urlencoded')
82 +})
83 +
84 +/**
85 + * Create a middleware to parse json and urlencoded bodies.
86 + *
87 + * @param {object} [options]
88 + * @return {function}
89 + * @deprecated
90 + * @public
91 + */
92 +
93 +function bodyParser (options) {
94 + var opts = {}
95 +
96 + // exclude type option
97 + if (options) {
98 + for (var prop in options) {
99 + if (prop !== 'type') {
100 + opts[prop] = options[prop]
101 + }
102 + }
103 + }
104 +
105 + var _urlencoded = exports.urlencoded(opts)
106 + var _json = exports.json(opts)
107 +
108 + return function bodyParser (req, res, next) {
109 + _json(req, res, function (err) {
110 + if (err) return next(err)
111 + _urlencoded(req, res, next)
112 + })
113 + }
114 +}
115 +
116 +/**
117 + * Create a getter for loading a parser.
118 + * @private
119 + */
120 +
121 +function createParserGetter (name) {
122 + return function get () {
123 + return loadParser(name)
124 + }
125 +}
126 +
127 +/**
128 + * Load a parser module.
129 + * @private
130 + */
131 +
132 +function loadParser (parserName) {
133 + var parser = parsers[parserName]
134 +
135 + if (parser !== undefined) {
136 + return parser
137 + }
138 +
139 + // this uses a switch for static require analysis
140 + switch (parserName) {
141 + case 'json':
142 + parser = require('./lib/types/json')
143 + break
144 + case 'raw':
145 + parser = require('./lib/types/raw')
146 + break
147 + case 'text':
148 + parser = require('./lib/types/text')
149 + break
150 + case 'urlencoded':
151 + parser = require('./lib/types/urlencoded')
152 + break
153 + }
154 +
155 + // store to prevent invoking require()
156 + return (parsers[parserName] = parser)
157 +}
1 +/*!
2 + * body-parser
3 + * Copyright(c) 2014-2015 Douglas Christopher Wilson
4 + * MIT Licensed
5 + */
6 +
7 +'use strict'
8 +
9 +/**
10 + * Module dependencies.
11 + * @private
12 + */
13 +
14 +var createError = require('http-errors')
15 +var getBody = require('raw-body')
16 +var iconv = require('iconv-lite')
17 +var onFinished = require('on-finished')
18 +var zlib = require('zlib')
19 +
20 +/**
21 + * Module exports.
22 + */
23 +
24 +module.exports = read
25 +
26 +/**
27 + * Read a request into a buffer and parse.
28 + *
29 + * @param {object} req
30 + * @param {object} res
31 + * @param {function} next
32 + * @param {function} parse
33 + * @param {function} debug
34 + * @param {object} options
35 + * @private
36 + */
37 +
38 +function read (req, res, next, parse, debug, options) {
39 + var length
40 + var opts = options
41 + var stream
42 +
43 + // flag as parsed
44 + req._body = true
45 +
46 + // read options
47 + var encoding = opts.encoding !== null
48 + ? opts.encoding
49 + : null
50 + var verify = opts.verify
51 +
52 + try {
53 + // get the content stream
54 + stream = contentstream(req, debug, opts.inflate)
55 + length = stream.length
56 + stream.length = undefined
57 + } catch (err) {
58 + return next(err)
59 + }
60 +
61 + // set raw-body options
62 + opts.length = length
63 + opts.encoding = verify
64 + ? null
65 + : encoding
66 +
67 + // assert charset is supported
68 + if (opts.encoding === null && encoding !== null && !iconv.encodingExists(encoding)) {
69 + return next(createError(415, 'unsupported charset "' + encoding.toUpperCase() + '"', {
70 + charset: encoding.toLowerCase(),
71 + type: 'charset.unsupported'
72 + }))
73 + }
74 +
75 + // read body
76 + debug('read body')
77 + getBody(stream, opts, function (error, body) {
78 + if (error) {
79 + var _error
80 +
81 + if (error.type === 'encoding.unsupported') {
82 + // echo back charset
83 + _error = createError(415, 'unsupported charset "' + encoding.toUpperCase() + '"', {
84 + charset: encoding.toLowerCase(),
85 + type: 'charset.unsupported'
86 + })
87 + } else {
88 + // set status code on error
89 + _error = createError(400, error)
90 + }
91 +
92 + // read off entire request
93 + stream.resume()
94 + onFinished(req, function onfinished () {
95 + next(createError(400, _error))
96 + })
97 + return
98 + }
99 +
100 + // verify
101 + if (verify) {
102 + try {
103 + debug('verify body')
104 + verify(req, res, body, encoding)
105 + } catch (err) {
106 + next(createError(403, err, {
107 + body: body,
108 + type: err.type || 'entity.verify.failed'
109 + }))
110 + return
111 + }
112 + }
113 +
114 + // parse
115 + var str = body
116 + try {
117 + debug('parse body')
118 + str = typeof body !== 'string' && encoding !== null
119 + ? iconv.decode(body, encoding)
120 + : body
121 + req.body = parse(str)
122 + } catch (err) {
123 + next(createError(400, err, {
124 + body: str,
125 + type: err.type || 'entity.parse.failed'
126 + }))
127 + return
128 + }
129 +
130 + next()
131 + })
132 +}
133 +
134 +/**
135 + * Get the content stream of the request.
136 + *
137 + * @param {object} req
138 + * @param {function} debug
139 + * @param {boolean} [inflate=true]
140 + * @return {object}
141 + * @api private
142 + */
143 +
144 +function contentstream (req, debug, inflate) {
145 + var encoding = (req.headers['content-encoding'] || 'identity').toLowerCase()
146 + var length = req.headers['content-length']
147 + var stream
148 +
149 + debug('content-encoding "%s"', encoding)
150 +
151 + if (inflate === false && encoding !== 'identity') {
152 + throw createError(415, 'content encoding unsupported', {
153 + encoding: encoding,
154 + type: 'encoding.unsupported'
155 + })
156 + }
157 +
158 + switch (encoding) {
159 + case 'deflate':
160 + stream = zlib.createInflate()
161 + debug('inflate body')
162 + req.pipe(stream)
163 + break
164 + case 'gzip':
165 + stream = zlib.createGunzip()
166 + debug('gunzip body')
167 + req.pipe(stream)
168 + break
169 + case 'identity':
170 + stream = req
171 + stream.length = length
172 + break
173 + default:
174 + throw createError(415, 'unsupported content encoding "' + encoding + '"', {
175 + encoding: encoding,
176 + type: 'encoding.unsupported'
177 + })
178 + }
179 +
180 + return stream
181 +}
1 +/*!
2 + * body-parser
3 + * Copyright(c) 2014 Jonathan Ong
4 + * Copyright(c) 2014-2015 Douglas Christopher Wilson
5 + * MIT Licensed
6 + */
7 +
8 +'use strict'
9 +
10 +/**
11 + * Module dependencies.
12 + * @private
13 + */
14 +
15 +var bytes = require('bytes')
16 +var contentType = require('content-type')
17 +var createError = require('http-errors')
18 +var debug = require('debug')('body-parser:json')
19 +var read = require('../read')
20 +var typeis = require('type-is')
21 +
22 +/**
23 + * Module exports.
24 + */
25 +
26 +module.exports = json
27 +
28 +/**
29 + * RegExp to match the first non-space in a string.
30 + *
31 + * Allowed whitespace is defined in RFC 7159:
32 + *
33 + * ws = *(
34 + * %x20 / ; Space
35 + * %x09 / ; Horizontal tab
36 + * %x0A / ; Line feed or New line
37 + * %x0D ) ; Carriage return
38 + */
39 +
40 +var FIRST_CHAR_REGEXP = /^[\x20\x09\x0a\x0d]*(.)/ // eslint-disable-line no-control-regex
41 +
42 +/**
43 + * Create a middleware to parse JSON bodies.
44 + *
45 + * @param {object} [options]
46 + * @return {function}
47 + * @public
48 + */
49 +
50 +function json (options) {
51 + var opts = options || {}
52 +
53 + var limit = typeof opts.limit !== 'number'
54 + ? bytes.parse(opts.limit || '100kb')
55 + : opts.limit
56 + var inflate = opts.inflate !== false
57 + var reviver = opts.reviver
58 + var strict = opts.strict !== false
59 + var type = opts.type || 'application/json'
60 + var verify = opts.verify || false
61 +
62 + if (verify !== false && typeof verify !== 'function') {
63 + throw new TypeError('option verify must be function')
64 + }
65 +
66 + // create the appropriate type checking function
67 + var shouldParse = typeof type !== 'function'
68 + ? typeChecker(type)
69 + : type
70 +
71 + function parse (body) {
72 + if (body.length === 0) {
73 + // special-case empty json body, as it's a common client-side mistake
74 + // TODO: maybe make this configurable or part of "strict" option
75 + return {}
76 + }
77 +
78 + if (strict) {
79 + var first = firstchar(body)
80 +
81 + if (first !== '{' && first !== '[') {
82 + debug('strict violation')
83 + throw createStrictSyntaxError(body, first)
84 + }
85 + }
86 +
87 + try {
88 + debug('parse json')
89 + return JSON.parse(body, reviver)
90 + } catch (e) {
91 + throw normalizeJsonSyntaxError(e, {
92 + message: e.message,
93 + stack: e.stack
94 + })
95 + }
96 + }
97 +
98 + return function jsonParser (req, res, next) {
99 + if (req._body) {
100 + debug('body already parsed')
101 + next()
102 + return
103 + }
104 +
105 + req.body = req.body || {}
106 +
107 + // skip requests without bodies
108 + if (!typeis.hasBody(req)) {
109 + debug('skip empty body')
110 + next()
111 + return
112 + }
113 +
114 + debug('content-type %j', req.headers['content-type'])
115 +
116 + // determine if request should be parsed
117 + if (!shouldParse(req)) {
118 + debug('skip parsing')
119 + next()
120 + return
121 + }
122 +
123 + // assert charset per RFC 7159 sec 8.1
124 + var charset = getCharset(req) || 'utf-8'
125 + if (charset.substr(0, 4) !== 'utf-') {
126 + debug('invalid charset')
127 + next(createError(415, 'unsupported charset "' + charset.toUpperCase() + '"', {
128 + charset: charset,
129 + type: 'charset.unsupported'
130 + }))
131 + return
132 + }
133 +
134 + // read
135 + read(req, res, next, parse, debug, {
136 + encoding: charset,
137 + inflate: inflate,
138 + limit: limit,
139 + verify: verify
140 + })
141 + }
142 +}
143 +
144 +/**
145 + * Create strict violation syntax error matching native error.
146 + *
147 + * @param {string} str
148 + * @param {string} char
149 + * @return {Error}
150 + * @private
151 + */
152 +
153 +function createStrictSyntaxError (str, char) {
154 + var index = str.indexOf(char)
155 + var partial = str.substring(0, index) + '#'
156 +
157 + try {
158 + JSON.parse(partial); /* istanbul ignore next */ throw new SyntaxError('strict violation')
159 + } catch (e) {
160 + return normalizeJsonSyntaxError(e, {
161 + message: e.message.replace('#', char),
162 + stack: e.stack
163 + })
164 + }
165 +}
166 +
167 +/**
168 + * Get the first non-whitespace character in a string.
169 + *
170 + * @param {string} str
171 + * @return {function}
172 + * @private
173 + */
174 +
175 +function firstchar (str) {
176 + return FIRST_CHAR_REGEXP.exec(str)[1]
177 +}
178 +
179 +/**
180 + * Get the charset of a request.
181 + *
182 + * @param {object} req
183 + * @api private
184 + */
185 +
186 +function getCharset (req) {
187 + try {
188 + return (contentType.parse(req).parameters.charset || '').toLowerCase()
189 + } catch (e) {
190 + return undefined
191 + }
192 +}
193 +
194 +/**
195 + * Normalize a SyntaxError for JSON.parse.
196 + *
197 + * @param {SyntaxError} error
198 + * @param {object} obj
199 + * @return {SyntaxError}
200 + */
201 +
202 +function normalizeJsonSyntaxError (error, obj) {
203 + var keys = Object.getOwnPropertyNames(error)
204 +
205 + for (var i = 0; i < keys.length; i++) {
206 + var key = keys[i]
207 + if (key !== 'stack' && key !== 'message') {
208 + delete error[key]
209 + }
210 + }
211 +
212 + // replace stack before message for Node.js 0.10 and below
213 + error.stack = obj.stack.replace(error.message, obj.message)
214 + error.message = obj.message
215 +
216 + return error
217 +}
218 +
219 +/**
220 + * Get the simple type checker.
221 + *
222 + * @param {string} type
223 + * @return {function}
224 + */
225 +
226 +function typeChecker (type) {
227 + return function checkType (req) {
228 + return Boolean(typeis(req, type))
229 + }
230 +}
1 +/*!
2 + * body-parser
3 + * Copyright(c) 2014-2015 Douglas Christopher Wilson
4 + * MIT Licensed
5 + */
6 +
7 +'use strict'
8 +
9 +/**
10 + * Module dependencies.
11 + */
12 +
13 +var bytes = require('bytes')
14 +var debug = require('debug')('body-parser:raw')
15 +var read = require('../read')
16 +var typeis = require('type-is')
17 +
18 +/**
19 + * Module exports.
20 + */
21 +
22 +module.exports = raw
23 +
24 +/**
25 + * Create a middleware to parse raw bodies.
26 + *
27 + * @param {object} [options]
28 + * @return {function}
29 + * @api public
30 + */
31 +
32 +function raw (options) {
33 + var opts = options || {}
34 +
35 + var inflate = opts.inflate !== false
36 + var limit = typeof opts.limit !== 'number'
37 + ? bytes.parse(opts.limit || '100kb')
38 + : opts.limit
39 + var type = opts.type || 'application/octet-stream'
40 + var verify = opts.verify || false
41 +
42 + if (verify !== false && typeof verify !== 'function') {
43 + throw new TypeError('option verify must be function')
44 + }
45 +
46 + // create the appropriate type checking function
47 + var shouldParse = typeof type !== 'function'
48 + ? typeChecker(type)
49 + : type
50 +
51 + function parse (buf) {
52 + return buf
53 + }
54 +
55 + return function rawParser (req, res, next) {
56 + if (req._body) {
57 + debug('body already parsed')
58 + next()
59 + return
60 + }
61 +
62 + req.body = req.body || {}
63 +
64 + // skip requests without bodies
65 + if (!typeis.hasBody(req)) {
66 + debug('skip empty body')
67 + next()
68 + return
69 + }
70 +
71 + debug('content-type %j', req.headers['content-type'])
72 +
73 + // determine if request should be parsed
74 + if (!shouldParse(req)) {
75 + debug('skip parsing')
76 + next()
77 + return
78 + }
79 +
80 + // read
81 + read(req, res, next, parse, debug, {
82 + encoding: null,
83 + inflate: inflate,
84 + limit: limit,
85 + verify: verify
86 + })
87 + }
88 +}
89 +
90 +/**
91 + * Get the simple type checker.
92 + *
93 + * @param {string} type
94 + * @return {function}
95 + */
96 +
97 +function typeChecker (type) {
98 + return function checkType (req) {
99 + return Boolean(typeis(req, type))
100 + }
101 +}
1 +/*!
2 + * body-parser
3 + * Copyright(c) 2014-2015 Douglas Christopher Wilson
4 + * MIT Licensed
5 + */
6 +
7 +'use strict'
8 +
9 +/**
10 + * Module dependencies.
11 + */
12 +
13 +var bytes = require('bytes')
14 +var contentType = require('content-type')
15 +var debug = require('debug')('body-parser:text')
16 +var read = require('../read')
17 +var typeis = require('type-is')
18 +
19 +/**
20 + * Module exports.
21 + */
22 +
23 +module.exports = text
24 +
25 +/**
26 + * Create a middleware to parse text bodies.
27 + *
28 + * @param {object} [options]
29 + * @return {function}
30 + * @api public
31 + */
32 +
33 +function text (options) {
34 + var opts = options || {}
35 +
36 + var defaultCharset = opts.defaultCharset || 'utf-8'
37 + var inflate = opts.inflate !== false
38 + var limit = typeof opts.limit !== 'number'
39 + ? bytes.parse(opts.limit || '100kb')
40 + : opts.limit
41 + var type = opts.type || 'text/plain'
42 + var verify = opts.verify || false
43 +
44 + if (verify !== false && typeof verify !== 'function') {
45 + throw new TypeError('option verify must be function')
46 + }
47 +
48 + // create the appropriate type checking function
49 + var shouldParse = typeof type !== 'function'
50 + ? typeChecker(type)
51 + : type
52 +
53 + function parse (buf) {
54 + return buf
55 + }
56 +
57 + return function textParser (req, res, next) {
58 + if (req._body) {
59 + debug('body already parsed')
60 + next()
61 + return
62 + }
63 +
64 + req.body = req.body || {}
65 +
66 + // skip requests without bodies
67 + if (!typeis.hasBody(req)) {
68 + debug('skip empty body')
69 + next()
70 + return
71 + }
72 +
73 + debug('content-type %j', req.headers['content-type'])
74 +
75 + // determine if request should be parsed
76 + if (!shouldParse(req)) {
77 + debug('skip parsing')
78 + next()
79 + return
80 + }
81 +
82 + // get charset
83 + var charset = getCharset(req) || defaultCharset
84 +
85 + // read
86 + read(req, res, next, parse, debug, {
87 + encoding: charset,
88 + inflate: inflate,
89 + limit: limit,
90 + verify: verify
91 + })
92 + }
93 +}
94 +
95 +/**
96 + * Get the charset of a request.
97 + *
98 + * @param {object} req
99 + * @api private
100 + */
101 +
102 +function getCharset (req) {
103 + try {
104 + return (contentType.parse(req).parameters.charset || '').toLowerCase()
105 + } catch (e) {
106 + return undefined
107 + }
108 +}
109 +
110 +/**
111 + * Get the simple type checker.
112 + *
113 + * @param {string} type
114 + * @return {function}
115 + */
116 +
117 +function typeChecker (type) {
118 + return function checkType (req) {
119 + return Boolean(typeis(req, type))
120 + }
121 +}
1 +/*!
2 + * body-parser
3 + * Copyright(c) 2014 Jonathan Ong
4 + * Copyright(c) 2014-2015 Douglas Christopher Wilson
5 + * MIT Licensed
6 + */
7 +
8 +'use strict'
9 +
10 +/**
11 + * Module dependencies.
12 + * @private
13 + */
14 +
15 +var bytes = require('bytes')
16 +var contentType = require('content-type')
17 +var createError = require('http-errors')
18 +var debug = require('debug')('body-parser:urlencoded')
19 +var deprecate = require('depd')('body-parser')
20 +var read = require('../read')
21 +var typeis = require('type-is')
22 +
23 +/**
24 + * Module exports.
25 + */
26 +
27 +module.exports = urlencoded
28 +
29 +/**
30 + * Cache of parser modules.
31 + */
32 +
33 +var parsers = Object.create(null)
34 +
35 +/**
36 + * Create a middleware to parse urlencoded bodies.
37 + *
38 + * @param {object} [options]
39 + * @return {function}
40 + * @public
41 + */
42 +
43 +function urlencoded (options) {
44 + var opts = options || {}
45 +
46 + // notice because option default will flip in next major
47 + if (opts.extended === undefined) {
48 + deprecate('undefined extended: provide extended option')
49 + }
50 +
51 + var extended = opts.extended !== false
52 + var inflate = opts.inflate !== false
53 + var limit = typeof opts.limit !== 'number'
54 + ? bytes.parse(opts.limit || '100kb')
55 + : opts.limit
56 + var type = opts.type || 'application/x-www-form-urlencoded'
57 + var verify = opts.verify || false
58 +
59 + if (verify !== false && typeof verify !== 'function') {
60 + throw new TypeError('option verify must be function')
61 + }
62 +
63 + // create the appropriate query parser
64 + var queryparse = extended
65 + ? extendedparser(opts)
66 + : simpleparser(opts)
67 +
68 + // create the appropriate type checking function
69 + var shouldParse = typeof type !== 'function'
70 + ? typeChecker(type)
71 + : type
72 +
73 + function parse (body) {
74 + return body.length
75 + ? queryparse(body)
76 + : {}
77 + }
78 +
79 + return function urlencodedParser (req, res, next) {
80 + if (req._body) {
81 + debug('body already parsed')
82 + next()
83 + return
84 + }
85 +
86 + req.body = req.body || {}
87 +
88 + // skip requests without bodies
89 + if (!typeis.hasBody(req)) {
90 + debug('skip empty body')
91 + next()
92 + return
93 + }
94 +
95 + debug('content-type %j', req.headers['content-type'])
96 +
97 + // determine if request should be parsed
98 + if (!shouldParse(req)) {
99 + debug('skip parsing')
100 + next()
101 + return
102 + }
103 +
104 + // assert charset
105 + var charset = getCharset(req) || 'utf-8'
106 + if (charset !== 'utf-8') {
107 + debug('invalid charset')
108 + next(createError(415, 'unsupported charset "' + charset.toUpperCase() + '"', {
109 + charset: charset,
110 + type: 'charset.unsupported'
111 + }))
112 + return
113 + }
114 +
115 + // read
116 + read(req, res, next, parse, debug, {
117 + debug: debug,
118 + encoding: charset,
119 + inflate: inflate,
120 + limit: limit,
121 + verify: verify
122 + })
123 + }
124 +}
125 +
126 +/**
127 + * Get the extended query parser.
128 + *
129 + * @param {object} options
130 + */
131 +
132 +function extendedparser (options) {
133 + var parameterLimit = options.parameterLimit !== undefined
134 + ? options.parameterLimit
135 + : 1000
136 + var parse = parser('qs')
137 +
138 + if (isNaN(parameterLimit) || parameterLimit < 1) {
139 + throw new TypeError('option parameterLimit must be a positive number')
140 + }
141 +
142 + if (isFinite(parameterLimit)) {
143 + parameterLimit = parameterLimit | 0
144 + }
145 +
146 + return function queryparse (body) {
147 + var paramCount = parameterCount(body, parameterLimit)
148 +
149 + if (paramCount === undefined) {
150 + debug('too many parameters')
151 + throw createError(413, 'too many parameters', {
152 + type: 'parameters.too.many'
153 + })
154 + }
155 +
156 + var arrayLimit = Math.max(100, paramCount)
157 +
158 + debug('parse extended urlencoding')
159 + return parse(body, {
160 + allowPrototypes: true,
161 + arrayLimit: arrayLimit,
162 + depth: Infinity,
163 + parameterLimit: parameterLimit
164 + })
165 + }
166 +}
167 +
168 +/**
169 + * Get the charset of a request.
170 + *
171 + * @param {object} req
172 + * @api private
173 + */
174 +
175 +function getCharset (req) {
176 + try {
177 + return (contentType.parse(req).parameters.charset || '').toLowerCase()
178 + } catch (e) {
179 + return undefined
180 + }
181 +}
182 +
183 +/**
184 + * Count the number of parameters, stopping once limit reached
185 + *
186 + * @param {string} body
187 + * @param {number} limit
188 + * @api private
189 + */
190 +
191 +function parameterCount (body, limit) {
192 + var count = 0
193 + var index = 0
194 +
195 + while ((index = body.indexOf('&', index)) !== -1) {
196 + count++
197 + index++
198 +
199 + if (count === limit) {
200 + return undefined
201 + }
202 + }
203 +
204 + return count
205 +}
206 +
207 +/**
208 + * Get parser for module name dynamically.
209 + *
210 + * @param {string} name
211 + * @return {function}
212 + * @api private
213 + */
214 +
215 +function parser (name) {
216 + var mod = parsers[name]
217 +
218 + if (mod !== undefined) {
219 + return mod.parse
220 + }
221 +
222 + // this uses a switch for static require analysis
223 + switch (name) {
224 + case 'qs':
225 + mod = require('qs')
226 + break
227 + case 'querystring':
228 + mod = require('querystring')
229 + break
230 + }
231 +
232 + // store to prevent invoking require()
233 + parsers[name] = mod
234 +
235 + return mod.parse
236 +}
237 +
238 +/**
239 + * Get the simple query parser.
240 + *
241 + * @param {object} options
242 + */
243 +
244 +function simpleparser (options) {
245 + var parameterLimit = options.parameterLimit !== undefined
246 + ? options.parameterLimit
247 + : 1000
248 + var parse = parser('querystring')
249 +
250 + if (isNaN(parameterLimit) || parameterLimit < 1) {
251 + throw new TypeError('option parameterLimit must be a positive number')
252 + }
253 +
254 + if (isFinite(parameterLimit)) {
255 + parameterLimit = parameterLimit | 0
256 + }
257 +
258 + return function queryparse (body) {
259 + var paramCount = parameterCount(body, parameterLimit)
260 +
261 + if (paramCount === undefined) {
262 + debug('too many parameters')
263 + throw createError(413, 'too many parameters', {
264 + type: 'parameters.too.many'
265 + })
266 + }
267 +
268 + debug('parse urlencoding')
269 + return parse(body, undefined, undefined, { maxKeys: parameterLimit })
270 + }
271 +}
272 +
273 +/**
274 + * Get the simple type checker.
275 + *
276 + * @param {string} type
277 + * @return {function}
278 + */
279 +
280 +function typeChecker (type) {
281 + return function checkType (req) {
282 + return Boolean(typeis(req, type))
283 + }
284 +}
1 +{
2 + "name": "body-parser",
3 + "description": "Node.js body parsing middleware",
4 + "version": "1.19.0",
5 + "contributors": [
6 + "Douglas Christopher Wilson <doug@somethingdoug.com>",
7 + "Jonathan Ong <me@jongleberry.com> (http://jongleberry.com)"
8 + ],
9 + "license": "MIT",
10 + "repository": "expressjs/body-parser",
11 + "dependencies": {
12 + "bytes": "3.1.0",
13 + "content-type": "~1.0.4",
14 + "debug": "2.6.9",
15 + "depd": "~1.1.2",
16 + "http-errors": "1.7.2",
17 + "iconv-lite": "0.4.24",
18 + "on-finished": "~2.3.0",
19 + "qs": "6.7.0",
20 + "raw-body": "2.4.0",
21 + "type-is": "~1.6.17"
22 + },
23 + "devDependencies": {
24 + "eslint": "5.16.0",
25 + "eslint-config-standard": "12.0.0",
26 + "eslint-plugin-import": "2.17.2",
27 + "eslint-plugin-markdown": "1.0.0",
28 + "eslint-plugin-node": "8.0.1",
29 + "eslint-plugin-promise": "4.1.1",
30 + "eslint-plugin-standard": "4.0.0",
31 + "istanbul": "0.4.5",
32 + "methods": "1.1.2",
33 + "mocha": "6.1.4",
34 + "safe-buffer": "5.1.2",
35 + "supertest": "4.0.2"
36 + },
37 + "files": [
38 + "lib/",
39 + "LICENSE",
40 + "HISTORY.md",
41 + "index.js"
42 + ],
43 + "engines": {
44 + "node": ">= 0.8"
45 + },
46 + "scripts": {
47 + "lint": "eslint --plugin markdown --ext js,md .",
48 + "test": "mocha --require test/support/env --reporter spec --check-leaks --bail test/",
49 + "test-cov": "istanbul cover node_modules/mocha/bin/_mocha -- --require test/support/env --reporter dot --check-leaks test/",
50 + "test-travis": "istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --require test/support/env --reporter spec --check-leaks test/"
51 + }
52 +}
1 +#boolbase
2 +This very simple module provides two basic functions, one that always returns true (`trueFunc`) and one that always returns false (`falseFunc`).
3 +
4 +###WTF?
5 +
6 +By having only a single instance of these functions around, it's possible to do some nice optimizations. Eg. [`CSSselect`](https://github.com/fb55/CSSselect) uses these functions to determine whether a selector won't match any elements. If that's the case, the DOM doesn't even have to be touched.
7 +
8 +###And why is this a separate module?
9 +
10 +I'm trying to modularize `CSSselect` and most modules depend on these functions. IMHO, having a separate module is the easiest solution to this problem.
...\ No newline at end of file ...\ No newline at end of file
1 +module.exports = {
2 + trueFunc: function trueFunc(){
3 + return true;
4 + },
5 + falseFunc: function falseFunc(){
6 + return false;
7 + }
8 +};
...\ No newline at end of file ...\ No newline at end of file
1 +{
2 + "name": "boolbase",
3 + "version": "1.0.0",
4 + "description": "two functions: One that returns true, one that returns false",
5 + "main": "index.js",
6 + "scripts": {
7 + "test": "echo \"Error: no test specified\" && exit 1"
8 + },
9 + "repository": {
10 + "type": "git",
11 + "url": "https://github.com/fb55/boolbase"
12 + },
13 + "keywords": [
14 + "boolean",
15 + "function"
16 + ],
17 + "author": "Felix Boehm <me@feedic.com>",
18 + "license": "ISC",
19 + "bugs": {
20 + "url": "https://github.com/fb55/boolbase/issues"
21 + },
22 + "homepage": "https://github.com/fb55/boolbase"
23 +}
1 +3.1.0 / 2019-01-22
2 +==================
3 +
4 + * Add petabyte (`pb`) support
5 +
6 +3.0.0 / 2017-08-31
7 +==================
8 +
9 + * Change "kB" to "KB" in format output
10 + * Remove support for Node.js 0.6
11 + * Remove support for ComponentJS
12 +
13 +2.5.0 / 2017-03-24
14 +==================
15 +
16 + * Add option "unit"
17 +
18 +2.4.0 / 2016-06-01
19 +==================
20 +
21 + * Add option "unitSeparator"
22 +
23 +2.3.0 / 2016-02-15
24 +==================
25 +
26 + * Drop partial bytes on all parsed units
27 + * Fix non-finite numbers to `.format` to return `null`
28 + * Fix parsing byte string that looks like hex
29 + * perf: hoist regular expressions
30 +
31 +2.2.0 / 2015-11-13
32 +==================
33 +
34 + * add option "decimalPlaces"
35 + * add option "fixedDecimals"
36 +
37 +2.1.0 / 2015-05-21
38 +==================
39 +
40 + * add `.format` export
41 + * add `.parse` export
42 +
43 +2.0.2 / 2015-05-20
44 +==================
45 +
46 + * remove map recreation
47 + * remove unnecessary object construction
48 +
49 +2.0.1 / 2015-05-07
50 +==================
51 +
52 + * fix browserify require
53 + * remove node.extend dependency
54 +
55 +2.0.0 / 2015-04-12
56 +==================
57 +
58 + * add option "case"
59 + * add option "thousandsSeparator"
60 + * return "null" on invalid parse input
61 + * support proper round-trip: bytes(bytes(num)) === num
62 + * units no longer case sensitive when parsing
63 +
64 +1.0.0 / 2014-05-05
65 +==================
66 +
67 + * add negative support. fixes #6
68 +
69 +0.3.0 / 2014-03-19
70 +==================
71 +
72 + * added terabyte support
73 +
74 +0.2.1 / 2013-04-01
75 +==================
76 +
77 + * add .component
78 +
79 +0.2.0 / 2012-10-28
80 +==================
81 +
82 + * bytes(200).should.eql('200b')
83 +
84 +0.1.0 / 2012-07-04
85 +==================
86 +
87 + * add bytes to string conversion [yields]
1 +(The MIT License)
2 +
3 +Copyright (c) 2012-2014 TJ Holowaychuk <tj@vision-media.ca>
4 +Copyright (c) 2015 Jed Watson <jed.watson@me.com>
5 +
6 +Permission is hereby granted, free of charge, to any person obtaining
7 +a copy of this software and associated documentation files (the
8 +'Software'), to deal in the Software without restriction, including
9 +without limitation the rights to use, copy, modify, merge, publish,
10 +distribute, sublicense, and/or sell copies of the Software, and to
11 +permit persons to whom the Software is furnished to do so, subject to
12 +the following conditions:
13 +
14 +The above copyright notice and this permission notice shall be
15 +included in all copies or substantial portions of the Software.
16 +
17 +THE SOFTWARE IS PROVIDED 'AS IS', WITHOUT WARRANTY OF ANY KIND,
18 +EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
19 +MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
20 +IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
21 +CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
22 +TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
23 +SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
1 +# Bytes utility
2 +
3 +[![NPM Version][npm-image]][npm-url]
4 +[![NPM Downloads][downloads-image]][downloads-url]
5 +[![Build Status][travis-image]][travis-url]
6 +[![Test Coverage][coveralls-image]][coveralls-url]
7 +
8 +Utility to parse a string bytes (ex: `1TB`) to bytes (`1099511627776`) and vice-versa.
9 +
10 +## Installation
11 +
12 +This is a [Node.js](https://nodejs.org/en/) module available through the
13 +[npm registry](https://www.npmjs.com/). Installation is done using the
14 +[`npm install` command](https://docs.npmjs.com/getting-started/installing-npm-packages-locally):
15 +
16 +```bash
17 +$ npm install bytes
18 +```
19 +
20 +## Usage
21 +
22 +```js
23 +var bytes = require('bytes');
24 +```
25 +
26 +#### bytes.format(number value, [options]): string|null
27 +
28 +Format the given value in bytes into a string. If the value is negative, it is kept as such. If it is a float, it is
29 + rounded.
30 +
31 +**Arguments**
32 +
33 +| Name | Type | Description |
34 +|---------|----------|--------------------|
35 +| value | `number` | Value in bytes |
36 +| options | `Object` | Conversion options |
37 +
38 +**Options**
39 +
40 +| Property | Type | Description |
41 +|-------------------|--------|-----------------------------------------------------------------------------------------|
42 +| decimalPlaces | `number``null` | Maximum number of decimal places to include in output. Default value to `2`. |
43 +| fixedDecimals | `boolean``null` | Whether to always display the maximum number of decimal places. Default value to `false` |
44 +| thousandsSeparator | `string``null` | Example of values: `' '`, `','` and `.`... Default value to `''`. |
45 +| unit | `string``null` | The unit in which the result will be returned (B/KB/MB/GB/TB). Default value to `''` (which means auto detect). |
46 +| unitSeparator | `string``null` | Separator to use between number and unit. Default value to `''`. |
47 +
48 +**Returns**
49 +
50 +| Name | Type | Description |
51 +|---------|------------------|-------------------------------------------------|
52 +| results | `string``null` | Return null upon error. String value otherwise. |
53 +
54 +**Example**
55 +
56 +```js
57 +bytes(1024);
58 +// output: '1KB'
59 +
60 +bytes(1000);
61 +// output: '1000B'
62 +
63 +bytes(1000, {thousandsSeparator: ' '});
64 +// output: '1 000B'
65 +
66 +bytes(1024 * 1.7, {decimalPlaces: 0});
67 +// output: '2KB'
68 +
69 +bytes(1024, {unitSeparator: ' '});
70 +// output: '1 KB'
71 +
72 +```
73 +
74 +#### bytes.parse(string|number value): number|null
75 +
76 +Parse the string value into an integer in bytes. If no unit is given, or `value`
77 +is a number, it is assumed the value is in bytes.
78 +
79 +Supported units and abbreviations are as follows and are case-insensitive:
80 +
81 + * `b` for bytes
82 + * `kb` for kilobytes
83 + * `mb` for megabytes
84 + * `gb` for gigabytes
85 + * `tb` for terabytes
86 + * `pb` for petabytes
87 +
88 +The units are in powers of two, not ten. This means 1kb = 1024b according to this parser.
89 +
90 +**Arguments**
91 +
92 +| Name | Type | Description |
93 +|---------------|--------|--------------------|
94 +| value | `string``number` | String to parse, or number in bytes. |
95 +
96 +**Returns**
97 +
98 +| Name | Type | Description |
99 +|---------|-------------|-------------------------|
100 +| results | `number``null` | Return null upon error. Value in bytes otherwise. |
101 +
102 +**Example**
103 +
104 +```js
105 +bytes('1KB');
106 +// output: 1024
107 +
108 +bytes('1024');
109 +// output: 1024
110 +
111 +bytes(1024);
112 +// output: 1KB
113 +```
114 +
115 +## License
116 +
117 +[MIT](LICENSE)
118 +
119 +[coveralls-image]: https://badgen.net/coveralls/c/github/visionmedia/bytes.js/master
120 +[coveralls-url]: https://coveralls.io/r/visionmedia/bytes.js?branch=master
121 +[downloads-image]: https://badgen.net/npm/dm/bytes
122 +[downloads-url]: https://npmjs.org/package/bytes
123 +[npm-image]: https://badgen.net/npm/node/bytes
124 +[npm-url]: https://npmjs.org/package/bytes
125 +[travis-image]: https://badgen.net/travis/visionmedia/bytes.js/master
126 +[travis-url]: https://travis-ci.org/visionmedia/bytes.js
1 +/*!
2 + * bytes
3 + * Copyright(c) 2012-2014 TJ Holowaychuk
4 + * Copyright(c) 2015 Jed Watson
5 + * MIT Licensed
6 + */
7 +
8 +'use strict';
9 +
10 +/**
11 + * Module exports.
12 + * @public
13 + */
14 +
15 +module.exports = bytes;
16 +module.exports.format = format;
17 +module.exports.parse = parse;
18 +
19 +/**
20 + * Module variables.
21 + * @private
22 + */
23 +
24 +var formatThousandsRegExp = /\B(?=(\d{3})+(?!\d))/g;
25 +
26 +var formatDecimalsRegExp = /(?:\.0*|(\.[^0]+)0+)$/;
27 +
28 +var map = {
29 + b: 1,
30 + kb: 1 << 10,
31 + mb: 1 << 20,
32 + gb: 1 << 30,
33 + tb: Math.pow(1024, 4),
34 + pb: Math.pow(1024, 5),
35 +};
36 +
37 +var parseRegExp = /^((-|\+)?(\d+(?:\.\d+)?)) *(kb|mb|gb|tb|pb)$/i;
38 +
39 +/**
40 + * Convert the given value in bytes into a string or parse to string to an integer in bytes.
41 + *
42 + * @param {string|number} value
43 + * @param {{
44 + * case: [string],
45 + * decimalPlaces: [number]
46 + * fixedDecimals: [boolean]
47 + * thousandsSeparator: [string]
48 + * unitSeparator: [string]
49 + * }} [options] bytes options.
50 + *
51 + * @returns {string|number|null}
52 + */
53 +
54 +function bytes(value, options) {
55 + if (typeof value === 'string') {
56 + return parse(value);
57 + }
58 +
59 + if (typeof value === 'number') {
60 + return format(value, options);
61 + }
62 +
63 + return null;
64 +}
65 +
66 +/**
67 + * Format the given value in bytes into a string.
68 + *
69 + * If the value is negative, it is kept as such. If it is a float,
70 + * it is rounded.
71 + *
72 + * @param {number} value
73 + * @param {object} [options]
74 + * @param {number} [options.decimalPlaces=2]
75 + * @param {number} [options.fixedDecimals=false]
76 + * @param {string} [options.thousandsSeparator=]
77 + * @param {string} [options.unit=]
78 + * @param {string} [options.unitSeparator=]
79 + *
80 + * @returns {string|null}
81 + * @public
82 + */
83 +
84 +function format(value, options) {
85 + if (!Number.isFinite(value)) {
86 + return null;
87 + }
88 +
89 + var mag = Math.abs(value);
90 + var thousandsSeparator = (options && options.thousandsSeparator) || '';
91 + var unitSeparator = (options && options.unitSeparator) || '';
92 + var decimalPlaces = (options && options.decimalPlaces !== undefined) ? options.decimalPlaces : 2;
93 + var fixedDecimals = Boolean(options && options.fixedDecimals);
94 + var unit = (options && options.unit) || '';
95 +
96 + if (!unit || !map[unit.toLowerCase()]) {
97 + if (mag >= map.pb) {
98 + unit = 'PB';
99 + } else if (mag >= map.tb) {
100 + unit = 'TB';
101 + } else if (mag >= map.gb) {
102 + unit = 'GB';
103 + } else if (mag >= map.mb) {
104 + unit = 'MB';
105 + } else if (mag >= map.kb) {
106 + unit = 'KB';
107 + } else {
108 + unit = 'B';
109 + }
110 + }
111 +
112 + var val = value / map[unit.toLowerCase()];
113 + var str = val.toFixed(decimalPlaces);
114 +
115 + if (!fixedDecimals) {
116 + str = str.replace(formatDecimalsRegExp, '$1');
117 + }
118 +
119 + if (thousandsSeparator) {
120 + str = str.replace(formatThousandsRegExp, thousandsSeparator);
121 + }
122 +
123 + return str + unitSeparator + unit;
124 +}
125 +
126 +/**
127 + * Parse the string value into an integer in bytes.
128 + *
129 + * If no unit is given, it is assumed the value is in bytes.
130 + *
131 + * @param {number|string} val
132 + *
133 + * @returns {number|null}
134 + * @public
135 + */
136 +
137 +function parse(val) {
138 + if (typeof val === 'number' && !isNaN(val)) {
139 + return val;
140 + }
141 +
142 + if (typeof val !== 'string') {
143 + return null;
144 + }
145 +
146 + // Test if the string passed is valid
147 + var results = parseRegExp.exec(val);
148 + var floatValue;
149 + var unit = 'b';
150 +
151 + if (!results) {
152 + // Nothing could be extracted from the given string
153 + floatValue = parseInt(val, 10);
154 + unit = 'b'
155 + } else {
156 + // Retrieve the value and the unit
157 + floatValue = parseFloat(results[1]);
158 + unit = results[4].toLowerCase();
159 + }
160 +
161 + return Math.floor(map[unit] * floatValue);
162 +}
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff could not be displayed because it is too large.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.
This diff is collapsed. Click to expand it.