正在显示
31 个修改的文件
包含
3 行增加
和
3617 行删除
.gitignore
0 → 100644
node_modules/.package-lock.json
已删除
100644 → 0
1 | -{ | ||
2 | - "name": "uView", | ||
3 | - "version": "1.0.0", | ||
4 | - "lockfileVersion": 2, | ||
5 | - "requires": true, | ||
6 | - "packages": { | ||
7 | - "node_modules/asynckit": { | ||
8 | - "version": "0.4.0", | ||
9 | - "resolved": "https://registry.npmmirror.com/asynckit/-/asynckit-0.4.0.tgz", | ||
10 | - "integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==" | ||
11 | - }, | ||
12 | - "node_modules/axios": { | ||
13 | - "version": "1.6.2", | ||
14 | - "resolved": "https://registry.npmmirror.com/axios/-/axios-1.6.2.tgz", | ||
15 | - "integrity": "sha512-7i24Ri4pmDRfJTR7LDBhsOTtcm+9kjX5WiY1X3wIisx6G9So3pfMkEiU7emUBe46oceVImccTEM3k6C5dbVW8A==", | ||
16 | - "dependencies": { | ||
17 | - "follow-redirects": "^1.15.0", | ||
18 | - "form-data": "^4.0.0", | ||
19 | - "proxy-from-env": "^1.1.0" | ||
20 | - } | ||
21 | - }, | ||
22 | - "node_modules/combined-stream": { | ||
23 | - "version": "1.0.8", | ||
24 | - "resolved": "https://registry.npmmirror.com/combined-stream/-/combined-stream-1.0.8.tgz", | ||
25 | - "integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==", | ||
26 | - "dependencies": { | ||
27 | - "delayed-stream": "~1.0.0" | ||
28 | - }, | ||
29 | - "engines": { | ||
30 | - "node": ">= 0.8" | ||
31 | - } | ||
32 | - }, | ||
33 | - "node_modules/delayed-stream": { | ||
34 | - "version": "1.0.0", | ||
35 | - "resolved": "https://registry.npmmirror.com/delayed-stream/-/delayed-stream-1.0.0.tgz", | ||
36 | - "integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==", | ||
37 | - "engines": { | ||
38 | - "node": ">=0.4.0" | ||
39 | - } | ||
40 | - }, | ||
41 | - "node_modules/follow-redirects": { | ||
42 | - "version": "1.15.3", | ||
43 | - "resolved": "https://registry.npmmirror.com/follow-redirects/-/follow-redirects-1.15.3.tgz", | ||
44 | - "integrity": "sha512-1VzOtuEM8pC9SFU1E+8KfTjZyMztRsgEfwQl44z8A25uy13jSzTj6dyK2Df52iV0vgHCfBwLhDWevLn95w5v6Q==", | ||
45 | - "engines": { | ||
46 | - "node": ">=4.0" | ||
47 | - }, | ||
48 | - "peerDependenciesMeta": { | ||
49 | - "debug": { | ||
50 | - "optional": true | ||
51 | - } | ||
52 | - } | ||
53 | - }, | ||
54 | - "node_modules/form-data": { | ||
55 | - "version": "4.0.0", | ||
56 | - "resolved": "https://registry.npmmirror.com/form-data/-/form-data-4.0.0.tgz", | ||
57 | - "integrity": "sha512-ETEklSGi5t0QMZuiXoA/Q6vcnxcLQP5vdugSpuAyi6SVGi2clPPp+xgEhuMaHC+zGgn31Kd235W35f7Hykkaww==", | ||
58 | - "dependencies": { | ||
59 | - "asynckit": "^0.4.0", | ||
60 | - "combined-stream": "^1.0.8", | ||
61 | - "mime-types": "^2.1.12" | ||
62 | - }, | ||
63 | - "engines": { | ||
64 | - "node": ">= 6" | ||
65 | - } | ||
66 | - }, | ||
67 | - "node_modules/lodash": { | ||
68 | - "version": "4.17.21", | ||
69 | - "resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz", | ||
70 | - "integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==", | ||
71 | - "dev": true | ||
72 | - }, | ||
73 | - "node_modules/mime-db": { | ||
74 | - "version": "1.52.0", | ||
75 | - "resolved": "https://registry.npmmirror.com/mime-db/-/mime-db-1.52.0.tgz", | ||
76 | - "integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==", | ||
77 | - "engines": { | ||
78 | - "node": ">= 0.6" | ||
79 | - } | ||
80 | - }, | ||
81 | - "node_modules/mime-types": { | ||
82 | - "version": "2.1.35", | ||
83 | - "resolved": "https://registry.npmmirror.com/mime-types/-/mime-types-2.1.35.tgz", | ||
84 | - "integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==", | ||
85 | - "dependencies": { | ||
86 | - "mime-db": "1.52.0" | ||
87 | - }, | ||
88 | - "engines": { | ||
89 | - "node": ">= 0.6" | ||
90 | - } | ||
91 | - }, | ||
92 | - "node_modules/miment": { | ||
93 | - "version": "0.0.9", | ||
94 | - "resolved": "https://registry.npmjs.org/miment/-/miment-0.0.9.tgz", | ||
95 | - "integrity": "sha512-pfjF/jPPxCaR7swQIKbWHBfSJAw47e4iZQPM6HzuexSDiZRPj8bx3rNzP4G/oK37+skbM/9eidoX9awJJfgLAg==" | ||
96 | - }, | ||
97 | - "node_modules/proxy-from-env": { | ||
98 | - "version": "1.1.0", | ||
99 | - "resolved": "https://registry.npmmirror.com/proxy-from-env/-/proxy-from-env-1.1.0.tgz", | ||
100 | - "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg==" | ||
101 | - }, | ||
102 | - "node_modules/vue-i18n": { | ||
103 | - "version": "8.20.0", | ||
104 | - "resolved": "https://registry.npmjs.org/vue-i18n/-/vue-i18n-8.20.0.tgz", | ||
105 | - "integrity": "sha512-ZiAOoeR4d/JtKpbjipx3I80ey7cYG1ki5gQ7HwzWm4YFio9brA15BEYHjalEoBaEfzF5OBEZP+Y2MvAaWnyXXg==" | ||
106 | - } | ||
107 | - } | ||
108 | -} |
node_modules/asynckit/LICENSE
已删除
100644 → 0
1 | -The MIT License (MIT) | ||
2 | - | ||
3 | -Copyright (c) 2016 Alex Indigo | ||
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 all | ||
13 | -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 THE | ||
21 | -SOFTWARE. |
node_modules/asynckit/README.md
已删除
100644 → 0
1 | -# asynckit [![NPM Module](https://img.shields.io/npm/v/asynckit.svg?style=flat)](https://www.npmjs.com/package/asynckit) | ||
2 | - | ||
3 | -Minimal async jobs utility library, with streams support. | ||
4 | - | ||
5 | -[![PhantomJS Build](https://img.shields.io/travis/alexindigo/asynckit/v0.4.0.svg?label=browser&style=flat)](https://travis-ci.org/alexindigo/asynckit) | ||
6 | -[![Linux Build](https://img.shields.io/travis/alexindigo/asynckit/v0.4.0.svg?label=linux:0.12-6.x&style=flat)](https://travis-ci.org/alexindigo/asynckit) | ||
7 | -[![Windows Build](https://img.shields.io/appveyor/ci/alexindigo/asynckit/v0.4.0.svg?label=windows:0.12-6.x&style=flat)](https://ci.appveyor.com/project/alexindigo/asynckit) | ||
8 | - | ||
9 | -[![Coverage Status](https://img.shields.io/coveralls/alexindigo/asynckit/v0.4.0.svg?label=code+coverage&style=flat)](https://coveralls.io/github/alexindigo/asynckit?branch=master) | ||
10 | -[![Dependency Status](https://img.shields.io/david/alexindigo/asynckit/v0.4.0.svg?style=flat)](https://david-dm.org/alexindigo/asynckit) | ||
11 | -[![bitHound Overall Score](https://www.bithound.io/github/alexindigo/asynckit/badges/score.svg)](https://www.bithound.io/github/alexindigo/asynckit) | ||
12 | - | ||
13 | -<!-- [![Readme](https://img.shields.io/badge/readme-tested-brightgreen.svg?style=flat)](https://www.npmjs.com/package/reamde) --> | ||
14 | - | ||
15 | -AsyncKit provides harness for `parallel` and `serial` iterators over list of items represented by arrays or objects. | ||
16 | -Optionally it accepts abort function (should be synchronously return by iterator for each item), and terminates left over jobs upon an error event. For specific iteration order built-in (`ascending` and `descending`) and custom sort helpers also supported, via `asynckit.serialOrdered` method. | ||
17 | - | ||
18 | -It ensures async operations to keep behavior more stable and prevent `Maximum call stack size exceeded` errors, from sync iterators. | ||
19 | - | ||
20 | -| compression | size | | ||
21 | -| :----------------- | -------: | | ||
22 | -| asynckit.js | 12.34 kB | | ||
23 | -| asynckit.min.js | 4.11 kB | | ||
24 | -| asynckit.min.js.gz | 1.47 kB | | ||
25 | - | ||
26 | - | ||
27 | -## Install | ||
28 | - | ||
29 | -```sh | ||
30 | -$ npm install --save asynckit | ||
31 | -``` | ||
32 | - | ||
33 | -## Examples | ||
34 | - | ||
35 | -### Parallel Jobs | ||
36 | - | ||
37 | -Runs iterator over provided array in parallel. Stores output in the `result` array, | ||
38 | -on the matching positions. In unlikely event of an error from one of the jobs, | ||
39 | -will terminate rest of the active jobs (if abort function is provided) | ||
40 | -and return error along with salvaged data to the main callback function. | ||
41 | - | ||
42 | -#### Input Array | ||
43 | - | ||
44 | -```javascript | ||
45 | -var parallel = require('asynckit').parallel | ||
46 | - , assert = require('assert') | ||
47 | - ; | ||
48 | - | ||
49 | -var source = [ 1, 1, 4, 16, 64, 32, 8, 2 ] | ||
50 | - , expectedResult = [ 2, 2, 8, 32, 128, 64, 16, 4 ] | ||
51 | - , expectedTarget = [ 1, 1, 2, 4, 8, 16, 32, 64 ] | ||
52 | - , target = [] | ||
53 | - ; | ||
54 | - | ||
55 | -parallel(source, asyncJob, function(err, result) | ||
56 | -{ | ||
57 | - assert.deepEqual(result, expectedResult); | ||
58 | - assert.deepEqual(target, expectedTarget); | ||
59 | -}); | ||
60 | - | ||
61 | -// async job accepts one element from the array | ||
62 | -// and a callback function | ||
63 | -function asyncJob(item, cb) | ||
64 | -{ | ||
65 | - // different delays (in ms) per item | ||
66 | - var delay = item * 25; | ||
67 | - | ||
68 | - // pretend different jobs take different time to finish | ||
69 | - // and not in consequential order | ||
70 | - var timeoutId = setTimeout(function() { | ||
71 | - target.push(item); | ||
72 | - cb(null, item * 2); | ||
73 | - }, delay); | ||
74 | - | ||
75 | - // allow to cancel "leftover" jobs upon error | ||
76 | - // return function, invoking of which will abort this job | ||
77 | - return clearTimeout.bind(null, timeoutId); | ||
78 | -} | ||
79 | -``` | ||
80 | - | ||
81 | -More examples could be found in [test/test-parallel-array.js](test/test-parallel-array.js). | ||
82 | - | ||
83 | -#### Input Object | ||
84 | - | ||
85 | -Also it supports named jobs, listed via object. | ||
86 | - | ||
87 | -```javascript | ||
88 | -var parallel = require('asynckit/parallel') | ||
89 | - , assert = require('assert') | ||
90 | - ; | ||
91 | - | ||
92 | -var source = { first: 1, one: 1, four: 4, sixteen: 16, sixtyFour: 64, thirtyTwo: 32, eight: 8, two: 2 } | ||
93 | - , expectedResult = { first: 2, one: 2, four: 8, sixteen: 32, sixtyFour: 128, thirtyTwo: 64, eight: 16, two: 4 } | ||
94 | - , expectedTarget = [ 1, 1, 2, 4, 8, 16, 32, 64 ] | ||
95 | - , expectedKeys = [ 'first', 'one', 'two', 'four', 'eight', 'sixteen', 'thirtyTwo', 'sixtyFour' ] | ||
96 | - , target = [] | ||
97 | - , keys = [] | ||
98 | - ; | ||
99 | - | ||
100 | -parallel(source, asyncJob, function(err, result) | ||
101 | -{ | ||
102 | - assert.deepEqual(result, expectedResult); | ||
103 | - assert.deepEqual(target, expectedTarget); | ||
104 | - assert.deepEqual(keys, expectedKeys); | ||
105 | -}); | ||
106 | - | ||
107 | -// supports full value, key, callback (shortcut) interface | ||
108 | -function asyncJob(item, key, cb) | ||
109 | -{ | ||
110 | - // different delays (in ms) per item | ||
111 | - var delay = item * 25; | ||
112 | - | ||
113 | - // pretend different jobs take different time to finish | ||
114 | - // and not in consequential order | ||
115 | - var timeoutId = setTimeout(function() { | ||
116 | - keys.push(key); | ||
117 | - target.push(item); | ||
118 | - cb(null, item * 2); | ||
119 | - }, delay); | ||
120 | - | ||
121 | - // allow to cancel "leftover" jobs upon error | ||
122 | - // return function, invoking of which will abort this job | ||
123 | - return clearTimeout.bind(null, timeoutId); | ||
124 | -} | ||
125 | -``` | ||
126 | - | ||
127 | -More examples could be found in [test/test-parallel-object.js](test/test-parallel-object.js). | ||
128 | - | ||
129 | -### Serial Jobs | ||
130 | - | ||
131 | -Runs iterator over provided array sequentially. Stores output in the `result` array, | ||
132 | -on the matching positions. In unlikely event of an error from one of the jobs, | ||
133 | -will not proceed to the rest of the items in the list | ||
134 | -and return error along with salvaged data to the main callback function. | ||
135 | - | ||
136 | -#### Input Array | ||
137 | - | ||
138 | -```javascript | ||
139 | -var serial = require('asynckit/serial') | ||
140 | - , assert = require('assert') | ||
141 | - ; | ||
142 | - | ||
143 | -var source = [ 1, 1, 4, 16, 64, 32, 8, 2 ] | ||
144 | - , expectedResult = [ 2, 2, 8, 32, 128, 64, 16, 4 ] | ||
145 | - , expectedTarget = [ 0, 1, 2, 3, 4, 5, 6, 7 ] | ||
146 | - , target = [] | ||
147 | - ; | ||
148 | - | ||
149 | -serial(source, asyncJob, function(err, result) | ||
150 | -{ | ||
151 | - assert.deepEqual(result, expectedResult); | ||
152 | - assert.deepEqual(target, expectedTarget); | ||
153 | -}); | ||
154 | - | ||
155 | -// extended interface (item, key, callback) | ||
156 | -// also supported for arrays | ||
157 | -function asyncJob(item, key, cb) | ||
158 | -{ | ||
159 | - target.push(key); | ||
160 | - | ||
161 | - // it will be automatically made async | ||
162 | - // even it iterator "returns" in the same event loop | ||
163 | - cb(null, item * 2); | ||
164 | -} | ||
165 | -``` | ||
166 | - | ||
167 | -More examples could be found in [test/test-serial-array.js](test/test-serial-array.js). | ||
168 | - | ||
169 | -#### Input Object | ||
170 | - | ||
171 | -Also it supports named jobs, listed via object. | ||
172 | - | ||
173 | -```javascript | ||
174 | -var serial = require('asynckit').serial | ||
175 | - , assert = require('assert') | ||
176 | - ; | ||
177 | - | ||
178 | -var source = [ 1, 1, 4, 16, 64, 32, 8, 2 ] | ||
179 | - , expectedResult = [ 2, 2, 8, 32, 128, 64, 16, 4 ] | ||
180 | - , expectedTarget = [ 0, 1, 2, 3, 4, 5, 6, 7 ] | ||
181 | - , target = [] | ||
182 | - ; | ||
183 | - | ||
184 | -var source = { first: 1, one: 1, four: 4, sixteen: 16, sixtyFour: 64, thirtyTwo: 32, eight: 8, two: 2 } | ||
185 | - , expectedResult = { first: 2, one: 2, four: 8, sixteen: 32, sixtyFour: 128, thirtyTwo: 64, eight: 16, two: 4 } | ||
186 | - , expectedTarget = [ 1, 1, 4, 16, 64, 32, 8, 2 ] | ||
187 | - , target = [] | ||
188 | - ; | ||
189 | - | ||
190 | - | ||
191 | -serial(source, asyncJob, function(err, result) | ||
192 | -{ | ||
193 | - assert.deepEqual(result, expectedResult); | ||
194 | - assert.deepEqual(target, expectedTarget); | ||
195 | -}); | ||
196 | - | ||
197 | -// shortcut interface (item, callback) | ||
198 | -// works for object as well as for the arrays | ||
199 | -function asyncJob(item, cb) | ||
200 | -{ | ||
201 | - target.push(item); | ||
202 | - | ||
203 | - // it will be automatically made async | ||
204 | - // even it iterator "returns" in the same event loop | ||
205 | - cb(null, item * 2); | ||
206 | -} | ||
207 | -``` | ||
208 | - | ||
209 | -More examples could be found in [test/test-serial-object.js](test/test-serial-object.js). | ||
210 | - | ||
211 | -_Note: Since _object_ is an _unordered_ collection of properties, | ||
212 | -it may produce unexpected results with sequential iterations. | ||
213 | -Whenever order of the jobs' execution is important please use `serialOrdered` method._ | ||
214 | - | ||
215 | -### Ordered Serial Iterations | ||
216 | - | ||
217 | -TBD | ||
218 | - | ||
219 | -For example [compare-property](compare-property) package. | ||
220 | - | ||
221 | -### Streaming interface | ||
222 | - | ||
223 | -TBD | ||
224 | - | ||
225 | -## Want to Know More? | ||
226 | - | ||
227 | -More examples can be found in [test folder](test/). | ||
228 | - | ||
229 | -Or open an [issue](https://github.com/alexindigo/asynckit/issues) with questions and/or suggestions. | ||
230 | - | ||
231 | -## License | ||
232 | - | ||
233 | -AsyncKit is licensed under the MIT license. |
node_modules/asynckit/bench.js
已删除
100644 → 0
1 | -/* eslint no-console: "off" */ | ||
2 | - | ||
3 | -var asynckit = require('./') | ||
4 | - , async = require('async') | ||
5 | - , assert = require('assert') | ||
6 | - , expected = 0 | ||
7 | - ; | ||
8 | - | ||
9 | -var Benchmark = require('benchmark'); | ||
10 | -var suite = new Benchmark.Suite; | ||
11 | - | ||
12 | -var source = []; | ||
13 | -for (var z = 1; z < 100; z++) | ||
14 | -{ | ||
15 | - source.push(z); | ||
16 | - expected += z; | ||
17 | -} | ||
18 | - | ||
19 | -suite | ||
20 | -// add tests | ||
21 | - | ||
22 | -.add('async.map', function(deferred) | ||
23 | -{ | ||
24 | - var total = 0; | ||
25 | - | ||
26 | - async.map(source, | ||
27 | - function(i, cb) | ||
28 | - { | ||
29 | - setImmediate(function() | ||
30 | - { | ||
31 | - total += i; | ||
32 | - cb(null, total); | ||
33 | - }); | ||
34 | - }, | ||
35 | - function(err, result) | ||
36 | - { | ||
37 | - assert.ifError(err); | ||
38 | - assert.equal(result[result.length - 1], expected); | ||
39 | - deferred.resolve(); | ||
40 | - }); | ||
41 | -}, {'defer': true}) | ||
42 | - | ||
43 | - | ||
44 | -.add('asynckit.parallel', function(deferred) | ||
45 | -{ | ||
46 | - var total = 0; | ||
47 | - | ||
48 | - asynckit.parallel(source, | ||
49 | - function(i, cb) | ||
50 | - { | ||
51 | - setImmediate(function() | ||
52 | - { | ||
53 | - total += i; | ||
54 | - cb(null, total); | ||
55 | - }); | ||
56 | - }, | ||
57 | - function(err, result) | ||
58 | - { | ||
59 | - assert.ifError(err); | ||
60 | - assert.equal(result[result.length - 1], expected); | ||
61 | - deferred.resolve(); | ||
62 | - }); | ||
63 | -}, {'defer': true}) | ||
64 | - | ||
65 | - | ||
66 | -// add listeners | ||
67 | -.on('cycle', function(ev) | ||
68 | -{ | ||
69 | - console.log(String(ev.target)); | ||
70 | -}) | ||
71 | -.on('complete', function() | ||
72 | -{ | ||
73 | - console.log('Fastest is ' + this.filter('fastest').map('name')); | ||
74 | -}) | ||
75 | -// run async | ||
76 | -.run({ 'async': true }); |
node_modules/asynckit/index.js
已删除
100644 → 0
node_modules/asynckit/lib/abort.js
已删除
100644 → 0
1 | -// API | ||
2 | -module.exports = abort; | ||
3 | - | ||
4 | -/** | ||
5 | - * Aborts leftover active jobs | ||
6 | - * | ||
7 | - * @param {object} state - current state object | ||
8 | - */ | ||
9 | -function abort(state) | ||
10 | -{ | ||
11 | - Object.keys(state.jobs).forEach(clean.bind(state)); | ||
12 | - | ||
13 | - // reset leftover jobs | ||
14 | - state.jobs = {}; | ||
15 | -} | ||
16 | - | ||
17 | -/** | ||
18 | - * Cleans up leftover job by invoking abort function for the provided job id | ||
19 | - * | ||
20 | - * @this state | ||
21 | - * @param {string|number} key - job id to abort | ||
22 | - */ | ||
23 | -function clean(key) | ||
24 | -{ | ||
25 | - if (typeof this.jobs[key] == 'function') | ||
26 | - { | ||
27 | - this.jobs[key](); | ||
28 | - } | ||
29 | -} |
node_modules/asynckit/lib/async.js
已删除
100644 → 0
1 | -var defer = require('./defer.js'); | ||
2 | - | ||
3 | -// API | ||
4 | -module.exports = async; | ||
5 | - | ||
6 | -/** | ||
7 | - * Runs provided callback asynchronously | ||
8 | - * even if callback itself is not | ||
9 | - * | ||
10 | - * @param {function} callback - callback to invoke | ||
11 | - * @returns {function} - augmented callback | ||
12 | - */ | ||
13 | -function async(callback) | ||
14 | -{ | ||
15 | - var isAsync = false; | ||
16 | - | ||
17 | - // check if async happened | ||
18 | - defer(function() { isAsync = true; }); | ||
19 | - | ||
20 | - return function async_callback(err, result) | ||
21 | - { | ||
22 | - if (isAsync) | ||
23 | - { | ||
24 | - callback(err, result); | ||
25 | - } | ||
26 | - else | ||
27 | - { | ||
28 | - defer(function nextTick_callback() | ||
29 | - { | ||
30 | - callback(err, result); | ||
31 | - }); | ||
32 | - } | ||
33 | - }; | ||
34 | -} |
node_modules/asynckit/lib/defer.js
已删除
100644 → 0
1 | -module.exports = defer; | ||
2 | - | ||
3 | -/** | ||
4 | - * Runs provided function on next iteration of the event loop | ||
5 | - * | ||
6 | - * @param {function} fn - function to run | ||
7 | - */ | ||
8 | -function defer(fn) | ||
9 | -{ | ||
10 | - var nextTick = typeof setImmediate == 'function' | ||
11 | - ? setImmediate | ||
12 | - : ( | ||
13 | - typeof process == 'object' && typeof process.nextTick == 'function' | ||
14 | - ? process.nextTick | ||
15 | - : null | ||
16 | - ); | ||
17 | - | ||
18 | - if (nextTick) | ||
19 | - { | ||
20 | - nextTick(fn); | ||
21 | - } | ||
22 | - else | ||
23 | - { | ||
24 | - setTimeout(fn, 0); | ||
25 | - } | ||
26 | -} |
node_modules/asynckit/lib/iterate.js
已删除
100644 → 0
1 | -var async = require('./async.js') | ||
2 | - , abort = require('./abort.js') | ||
3 | - ; | ||
4 | - | ||
5 | -// API | ||
6 | -module.exports = iterate; | ||
7 | - | ||
8 | -/** | ||
9 | - * Iterates over each job object | ||
10 | - * | ||
11 | - * @param {array|object} list - array or object (named list) to iterate over | ||
12 | - * @param {function} iterator - iterator to run | ||
13 | - * @param {object} state - current job status | ||
14 | - * @param {function} callback - invoked when all elements processed | ||
15 | - */ | ||
16 | -function iterate(list, iterator, state, callback) | ||
17 | -{ | ||
18 | - // store current index | ||
19 | - var key = state['keyedList'] ? state['keyedList'][state.index] : state.index; | ||
20 | - | ||
21 | - state.jobs[key] = runJob(iterator, key, list[key], function(error, output) | ||
22 | - { | ||
23 | - // don't repeat yourself | ||
24 | - // skip secondary callbacks | ||
25 | - if (!(key in state.jobs)) | ||
26 | - { | ||
27 | - return; | ||
28 | - } | ||
29 | - | ||
30 | - // clean up jobs | ||
31 | - delete state.jobs[key]; | ||
32 | - | ||
33 | - if (error) | ||
34 | - { | ||
35 | - // don't process rest of the results | ||
36 | - // stop still active jobs | ||
37 | - // and reset the list | ||
38 | - abort(state); | ||
39 | - } | ||
40 | - else | ||
41 | - { | ||
42 | - state.results[key] = output; | ||
43 | - } | ||
44 | - | ||
45 | - // return salvaged results | ||
46 | - callback(error, state.results); | ||
47 | - }); | ||
48 | -} | ||
49 | - | ||
50 | -/** | ||
51 | - * Runs iterator over provided job element | ||
52 | - * | ||
53 | - * @param {function} iterator - iterator to invoke | ||
54 | - * @param {string|number} key - key/index of the element in the list of jobs | ||
55 | - * @param {mixed} item - job description | ||
56 | - * @param {function} callback - invoked after iterator is done with the job | ||
57 | - * @returns {function|mixed} - job abort function or something else | ||
58 | - */ | ||
59 | -function runJob(iterator, key, item, callback) | ||
60 | -{ | ||
61 | - var aborter; | ||
62 | - | ||
63 | - // allow shortcut if iterator expects only two arguments | ||
64 | - if (iterator.length == 2) | ||
65 | - { | ||
66 | - aborter = iterator(item, async(callback)); | ||
67 | - } | ||
68 | - // otherwise go with full three arguments | ||
69 | - else | ||
70 | - { | ||
71 | - aborter = iterator(item, key, async(callback)); | ||
72 | - } | ||
73 | - | ||
74 | - return aborter; | ||
75 | -} |
1 | -var streamify = require('./streamify.js') | ||
2 | - , defer = require('./defer.js') | ||
3 | - ; | ||
4 | - | ||
5 | -// API | ||
6 | -module.exports = ReadableAsyncKit; | ||
7 | - | ||
8 | -/** | ||
9 | - * Base constructor for all streams | ||
10 | - * used to hold properties/methods | ||
11 | - */ | ||
12 | -function ReadableAsyncKit() | ||
13 | -{ | ||
14 | - ReadableAsyncKit.super_.apply(this, arguments); | ||
15 | - | ||
16 | - // list of active jobs | ||
17 | - this.jobs = {}; | ||
18 | - | ||
19 | - // add stream methods | ||
20 | - this.destroy = destroy; | ||
21 | - this._start = _start; | ||
22 | - this._read = _read; | ||
23 | -} | ||
24 | - | ||
25 | -/** | ||
26 | - * Destroys readable stream, | ||
27 | - * by aborting outstanding jobs | ||
28 | - * | ||
29 | - * @returns {void} | ||
30 | - */ | ||
31 | -function destroy() | ||
32 | -{ | ||
33 | - if (this.destroyed) | ||
34 | - { | ||
35 | - return; | ||
36 | - } | ||
37 | - | ||
38 | - this.destroyed = true; | ||
39 | - | ||
40 | - if (typeof this.terminator == 'function') | ||
41 | - { | ||
42 | - this.terminator(); | ||
43 | - } | ||
44 | -} | ||
45 | - | ||
46 | -/** | ||
47 | - * Starts provided jobs in async manner | ||
48 | - * | ||
49 | - * @private | ||
50 | - */ | ||
51 | -function _start() | ||
52 | -{ | ||
53 | - // first argument – runner function | ||
54 | - var runner = arguments[0] | ||
55 | - // take away first argument | ||
56 | - , args = Array.prototype.slice.call(arguments, 1) | ||
57 | - // second argument - input data | ||
58 | - , input = args[0] | ||
59 | - // last argument - result callback | ||
60 | - , endCb = streamify.callback.call(this, args[args.length - 1]) | ||
61 | - ; | ||
62 | - | ||
63 | - args[args.length - 1] = endCb; | ||
64 | - // third argument - iterator | ||
65 | - args[1] = streamify.iterator.call(this, args[1]); | ||
66 | - | ||
67 | - // allow time for proper setup | ||
68 | - defer(function() | ||
69 | - { | ||
70 | - if (!this.destroyed) | ||
71 | - { | ||
72 | - this.terminator = runner.apply(null, args); | ||
73 | - } | ||
74 | - else | ||
75 | - { | ||
76 | - endCb(null, Array.isArray(input) ? [] : {}); | ||
77 | - } | ||
78 | - }.bind(this)); | ||
79 | -} | ||
80 | - | ||
81 | - | ||
82 | -/** | ||
83 | - * Implement _read to comply with Readable streams | ||
84 | - * Doesn't really make sense for flowing object mode | ||
85 | - * | ||
86 | - * @private | ||
87 | - */ | ||
88 | -function _read() | ||
89 | -{ | ||
90 | - | ||
91 | -} |
1 | -var parallel = require('../parallel.js'); | ||
2 | - | ||
3 | -// API | ||
4 | -module.exports = ReadableParallel; | ||
5 | - | ||
6 | -/** | ||
7 | - * Streaming wrapper to `asynckit.parallel` | ||
8 | - * | ||
9 | - * @param {array|object} list - array or object (named list) to iterate over | ||
10 | - * @param {function} iterator - iterator to run | ||
11 | - * @param {function} callback - invoked when all elements processed | ||
12 | - * @returns {stream.Readable#} | ||
13 | - */ | ||
14 | -function ReadableParallel(list, iterator, callback) | ||
15 | -{ | ||
16 | - if (!(this instanceof ReadableParallel)) | ||
17 | - { | ||
18 | - return new ReadableParallel(list, iterator, callback); | ||
19 | - } | ||
20 | - | ||
21 | - // turn on object mode | ||
22 | - ReadableParallel.super_.call(this, {objectMode: true}); | ||
23 | - | ||
24 | - this._start(parallel, list, iterator, callback); | ||
25 | -} |
1 | -var serial = require('../serial.js'); | ||
2 | - | ||
3 | -// API | ||
4 | -module.exports = ReadableSerial; | ||
5 | - | ||
6 | -/** | ||
7 | - * Streaming wrapper to `asynckit.serial` | ||
8 | - * | ||
9 | - * @param {array|object} list - array or object (named list) to iterate over | ||
10 | - * @param {function} iterator - iterator to run | ||
11 | - * @param {function} callback - invoked when all elements processed | ||
12 | - * @returns {stream.Readable#} | ||
13 | - */ | ||
14 | -function ReadableSerial(list, iterator, callback) | ||
15 | -{ | ||
16 | - if (!(this instanceof ReadableSerial)) | ||
17 | - { | ||
18 | - return new ReadableSerial(list, iterator, callback); | ||
19 | - } | ||
20 | - | ||
21 | - // turn on object mode | ||
22 | - ReadableSerial.super_.call(this, {objectMode: true}); | ||
23 | - | ||
24 | - this._start(serial, list, iterator, callback); | ||
25 | -} |
1 | -var serialOrdered = require('../serialOrdered.js'); | ||
2 | - | ||
3 | -// API | ||
4 | -module.exports = ReadableSerialOrdered; | ||
5 | -// expose sort helpers | ||
6 | -module.exports.ascending = serialOrdered.ascending; | ||
7 | -module.exports.descending = serialOrdered.descending; | ||
8 | - | ||
9 | -/** | ||
10 | - * Streaming wrapper to `asynckit.serialOrdered` | ||
11 | - * | ||
12 | - * @param {array|object} list - array or object (named list) to iterate over | ||
13 | - * @param {function} iterator - iterator to run | ||
14 | - * @param {function} sortMethod - custom sort function | ||
15 | - * @param {function} callback - invoked when all elements processed | ||
16 | - * @returns {stream.Readable#} | ||
17 | - */ | ||
18 | -function ReadableSerialOrdered(list, iterator, sortMethod, callback) | ||
19 | -{ | ||
20 | - if (!(this instanceof ReadableSerialOrdered)) | ||
21 | - { | ||
22 | - return new ReadableSerialOrdered(list, iterator, sortMethod, callback); | ||
23 | - } | ||
24 | - | ||
25 | - // turn on object mode | ||
26 | - ReadableSerialOrdered.super_.call(this, {objectMode: true}); | ||
27 | - | ||
28 | - this._start(serialOrdered, list, iterator, sortMethod, callback); | ||
29 | -} |
node_modules/asynckit/lib/state.js
已删除
100644 → 0
1 | -// API | ||
2 | -module.exports = state; | ||
3 | - | ||
4 | -/** | ||
5 | - * Creates initial state object | ||
6 | - * for iteration over list | ||
7 | - * | ||
8 | - * @param {array|object} list - list to iterate over | ||
9 | - * @param {function|null} sortMethod - function to use for keys sort, | ||
10 | - * or `null` to keep them as is | ||
11 | - * @returns {object} - initial state object | ||
12 | - */ | ||
13 | -function state(list, sortMethod) | ||
14 | -{ | ||
15 | - var isNamedList = !Array.isArray(list) | ||
16 | - , initState = | ||
17 | - { | ||
18 | - index : 0, | ||
19 | - keyedList: isNamedList || sortMethod ? Object.keys(list) : null, | ||
20 | - jobs : {}, | ||
21 | - results : isNamedList ? {} : [], | ||
22 | - size : isNamedList ? Object.keys(list).length : list.length | ||
23 | - } | ||
24 | - ; | ||
25 | - | ||
26 | - if (sortMethod) | ||
27 | - { | ||
28 | - // sort array keys based on it's values | ||
29 | - // sort object's keys just on own merit | ||
30 | - initState.keyedList.sort(isNamedList ? sortMethod : function(a, b) | ||
31 | - { | ||
32 | - return sortMethod(list[a], list[b]); | ||
33 | - }); | ||
34 | - } | ||
35 | - | ||
36 | - return initState; | ||
37 | -} |
node_modules/asynckit/lib/streamify.js
已删除
100644 → 0
1 | -var async = require('./async.js'); | ||
2 | - | ||
3 | -// API | ||
4 | -module.exports = { | ||
5 | - iterator: wrapIterator, | ||
6 | - callback: wrapCallback | ||
7 | -}; | ||
8 | - | ||
9 | -/** | ||
10 | - * Wraps iterators with long signature | ||
11 | - * | ||
12 | - * @this ReadableAsyncKit# | ||
13 | - * @param {function} iterator - function to wrap | ||
14 | - * @returns {function} - wrapped function | ||
15 | - */ | ||
16 | -function wrapIterator(iterator) | ||
17 | -{ | ||
18 | - var stream = this; | ||
19 | - | ||
20 | - return function(item, key, cb) | ||
21 | - { | ||
22 | - var aborter | ||
23 | - , wrappedCb = async(wrapIteratorCallback.call(stream, cb, key)) | ||
24 | - ; | ||
25 | - | ||
26 | - stream.jobs[key] = wrappedCb; | ||
27 | - | ||
28 | - // it's either shortcut (item, cb) | ||
29 | - if (iterator.length == 2) | ||
30 | - { | ||
31 | - aborter = iterator(item, wrappedCb); | ||
32 | - } | ||
33 | - // or long format (item, key, cb) | ||
34 | - else | ||
35 | - { | ||
36 | - aborter = iterator(item, key, wrappedCb); | ||
37 | - } | ||
38 | - | ||
39 | - return aborter; | ||
40 | - }; | ||
41 | -} | ||
42 | - | ||
43 | -/** | ||
44 | - * Wraps provided callback function | ||
45 | - * allowing to execute snitch function before | ||
46 | - * real callback | ||
47 | - * | ||
48 | - * @this ReadableAsyncKit# | ||
49 | - * @param {function} callback - function to wrap | ||
50 | - * @returns {function} - wrapped function | ||
51 | - */ | ||
52 | -function wrapCallback(callback) | ||
53 | -{ | ||
54 | - var stream = this; | ||
55 | - | ||
56 | - var wrapped = function(error, result) | ||
57 | - { | ||
58 | - return finisher.call(stream, error, result, callback); | ||
59 | - }; | ||
60 | - | ||
61 | - return wrapped; | ||
62 | -} | ||
63 | - | ||
64 | -/** | ||
65 | - * Wraps provided iterator callback function | ||
66 | - * makes sure snitch only called once, | ||
67 | - * but passes secondary calls to the original callback | ||
68 | - * | ||
69 | - * @this ReadableAsyncKit# | ||
70 | - * @param {function} callback - callback to wrap | ||
71 | - * @param {number|string} key - iteration key | ||
72 | - * @returns {function} wrapped callback | ||
73 | - */ | ||
74 | -function wrapIteratorCallback(callback, key) | ||
75 | -{ | ||
76 | - var stream = this; | ||
77 | - | ||
78 | - return function(error, output) | ||
79 | - { | ||
80 | - // don't repeat yourself | ||
81 | - if (!(key in stream.jobs)) | ||
82 | - { | ||
83 | - callback(error, output); | ||
84 | - return; | ||
85 | - } | ||
86 | - | ||
87 | - // clean up jobs | ||
88 | - delete stream.jobs[key]; | ||
89 | - | ||
90 | - return streamer.call(stream, error, {key: key, value: output}, callback); | ||
91 | - }; | ||
92 | -} | ||
93 | - | ||
94 | -/** | ||
95 | - * Stream wrapper for iterator callback | ||
96 | - * | ||
97 | - * @this ReadableAsyncKit# | ||
98 | - * @param {mixed} error - error response | ||
99 | - * @param {mixed} output - iterator output | ||
100 | - * @param {function} callback - callback that expects iterator results | ||
101 | - */ | ||
102 | -function streamer(error, output, callback) | ||
103 | -{ | ||
104 | - if (error && !this.error) | ||
105 | - { | ||
106 | - this.error = error; | ||
107 | - this.pause(); | ||
108 | - this.emit('error', error); | ||
109 | - // send back value only, as expected | ||
110 | - callback(error, output && output.value); | ||
111 | - return; | ||
112 | - } | ||
113 | - | ||
114 | - // stream stuff | ||
115 | - this.push(output); | ||
116 | - | ||
117 | - // back to original track | ||
118 | - // send back value only, as expected | ||
119 | - callback(error, output && output.value); | ||
120 | -} | ||
121 | - | ||
122 | -/** | ||
123 | - * Stream wrapper for finishing callback | ||
124 | - * | ||
125 | - * @this ReadableAsyncKit# | ||
126 | - * @param {mixed} error - error response | ||
127 | - * @param {mixed} output - iterator output | ||
128 | - * @param {function} callback - callback that expects final results | ||
129 | - */ | ||
130 | -function finisher(error, output, callback) | ||
131 | -{ | ||
132 | - // signal end of the stream | ||
133 | - // only for successfully finished streams | ||
134 | - if (!error) | ||
135 | - { | ||
136 | - this.push(null); | ||
137 | - } | ||
138 | - | ||
139 | - // back to original track | ||
140 | - callback(error, output); | ||
141 | -} |
node_modules/asynckit/lib/terminator.js
已删除
100644 → 0
1 | -var abort = require('./abort.js') | ||
2 | - , async = require('./async.js') | ||
3 | - ; | ||
4 | - | ||
5 | -// API | ||
6 | -module.exports = terminator; | ||
7 | - | ||
8 | -/** | ||
9 | - * Terminates jobs in the attached state context | ||
10 | - * | ||
11 | - * @this AsyncKitState# | ||
12 | - * @param {function} callback - final callback to invoke after termination | ||
13 | - */ | ||
14 | -function terminator(callback) | ||
15 | -{ | ||
16 | - if (!Object.keys(this.jobs).length) | ||
17 | - { | ||
18 | - return; | ||
19 | - } | ||
20 | - | ||
21 | - // fast forward iteration index | ||
22 | - this.index = this.size; | ||
23 | - | ||
24 | - // abort jobs | ||
25 | - abort(this); | ||
26 | - | ||
27 | - // send back results we have so far | ||
28 | - async(callback)(null, this.results); | ||
29 | -} |
node_modules/asynckit/package.json
已删除
100644 → 0
1 | -{ | ||
2 | - "name": "asynckit", | ||
3 | - "version": "0.4.0", | ||
4 | - "description": "Minimal async jobs utility library, with streams support", | ||
5 | - "main": "index.js", | ||
6 | - "scripts": { | ||
7 | - "clean": "rimraf coverage", | ||
8 | - "lint": "eslint *.js lib/*.js test/*.js", | ||
9 | - "test": "istanbul cover --reporter=json tape -- 'test/test-*.js' | tap-spec", | ||
10 | - "win-test": "tape test/test-*.js", | ||
11 | - "browser": "browserify -t browserify-istanbul test/lib/browserify_adjustment.js test/test-*.js | obake --coverage | tap-spec", | ||
12 | - "report": "istanbul report", | ||
13 | - "size": "browserify index.js | size-table asynckit", | ||
14 | - "debug": "tape test/test-*.js" | ||
15 | - }, | ||
16 | - "pre-commit": [ | ||
17 | - "clean", | ||
18 | - "lint", | ||
19 | - "test", | ||
20 | - "browser", | ||
21 | - "report", | ||
22 | - "size" | ||
23 | - ], | ||
24 | - "repository": { | ||
25 | - "type": "git", | ||
26 | - "url": "git+https://github.com/alexindigo/asynckit.git" | ||
27 | - }, | ||
28 | - "keywords": [ | ||
29 | - "async", | ||
30 | - "jobs", | ||
31 | - "parallel", | ||
32 | - "serial", | ||
33 | - "iterator", | ||
34 | - "array", | ||
35 | - "object", | ||
36 | - "stream", | ||
37 | - "destroy", | ||
38 | - "terminate", | ||
39 | - "abort" | ||
40 | - ], | ||
41 | - "author": "Alex Indigo <iam@alexindigo.com>", | ||
42 | - "license": "MIT", | ||
43 | - "bugs": { | ||
44 | - "url": "https://github.com/alexindigo/asynckit/issues" | ||
45 | - }, | ||
46 | - "homepage": "https://github.com/alexindigo/asynckit#readme", | ||
47 | - "devDependencies": { | ||
48 | - "browserify": "^13.0.0", | ||
49 | - "browserify-istanbul": "^2.0.0", | ||
50 | - "coveralls": "^2.11.9", | ||
51 | - "eslint": "^2.9.0", | ||
52 | - "istanbul": "^0.4.3", | ||
53 | - "obake": "^0.1.2", | ||
54 | - "phantomjs-prebuilt": "^2.1.7", | ||
55 | - "pre-commit": "^1.1.3", | ||
56 | - "reamde": "^1.1.0", | ||
57 | - "rimraf": "^2.5.2", | ||
58 | - "size-table": "^0.2.0", | ||
59 | - "tap-spec": "^4.1.1", | ||
60 | - "tape": "^4.5.1" | ||
61 | - }, | ||
62 | - "dependencies": {} | ||
63 | -} |
node_modules/asynckit/parallel.js
已删除
100644 → 0
1 | -var iterate = require('./lib/iterate.js') | ||
2 | - , initState = require('./lib/state.js') | ||
3 | - , terminator = require('./lib/terminator.js') | ||
4 | - ; | ||
5 | - | ||
6 | -// Public API | ||
7 | -module.exports = parallel; | ||
8 | - | ||
9 | -/** | ||
10 | - * Runs iterator over provided array elements in parallel | ||
11 | - * | ||
12 | - * @param {array|object} list - array or object (named list) to iterate over | ||
13 | - * @param {function} iterator - iterator to run | ||
14 | - * @param {function} callback - invoked when all elements processed | ||
15 | - * @returns {function} - jobs terminator | ||
16 | - */ | ||
17 | -function parallel(list, iterator, callback) | ||
18 | -{ | ||
19 | - var state = initState(list); | ||
20 | - | ||
21 | - while (state.index < (state['keyedList'] || list).length) | ||
22 | - { | ||
23 | - iterate(list, iterator, state, function(error, result) | ||
24 | - { | ||
25 | - if (error) | ||
26 | - { | ||
27 | - callback(error, result); | ||
28 | - return; | ||
29 | - } | ||
30 | - | ||
31 | - // looks like it's the last one | ||
32 | - if (Object.keys(state.jobs).length === 0) | ||
33 | - { | ||
34 | - callback(null, state.results); | ||
35 | - return; | ||
36 | - } | ||
37 | - }); | ||
38 | - | ||
39 | - state.index++; | ||
40 | - } | ||
41 | - | ||
42 | - return terminator.bind(state, callback); | ||
43 | -} |
node_modules/asynckit/serial.js
已删除
100644 → 0
1 | -var serialOrdered = require('./serialOrdered.js'); | ||
2 | - | ||
3 | -// Public API | ||
4 | -module.exports = serial; | ||
5 | - | ||
6 | -/** | ||
7 | - * Runs iterator over provided array elements in series | ||
8 | - * | ||
9 | - * @param {array|object} list - array or object (named list) to iterate over | ||
10 | - * @param {function} iterator - iterator to run | ||
11 | - * @param {function} callback - invoked when all elements processed | ||
12 | - * @returns {function} - jobs terminator | ||
13 | - */ | ||
14 | -function serial(list, iterator, callback) | ||
15 | -{ | ||
16 | - return serialOrdered(list, iterator, null, callback); | ||
17 | -} |
node_modules/asynckit/serialOrdered.js
已删除
100644 → 0
1 | -var iterate = require('./lib/iterate.js') | ||
2 | - , initState = require('./lib/state.js') | ||
3 | - , terminator = require('./lib/terminator.js') | ||
4 | - ; | ||
5 | - | ||
6 | -// Public API | ||
7 | -module.exports = serialOrdered; | ||
8 | -// sorting helpers | ||
9 | -module.exports.ascending = ascending; | ||
10 | -module.exports.descending = descending; | ||
11 | - | ||
12 | -/** | ||
13 | - * Runs iterator over provided sorted array elements in series | ||
14 | - * | ||
15 | - * @param {array|object} list - array or object (named list) to iterate over | ||
16 | - * @param {function} iterator - iterator to run | ||
17 | - * @param {function} sortMethod - custom sort function | ||
18 | - * @param {function} callback - invoked when all elements processed | ||
19 | - * @returns {function} - jobs terminator | ||
20 | - */ | ||
21 | -function serialOrdered(list, iterator, sortMethod, callback) | ||
22 | -{ | ||
23 | - var state = initState(list, sortMethod); | ||
24 | - | ||
25 | - iterate(list, iterator, state, function iteratorHandler(error, result) | ||
26 | - { | ||
27 | - if (error) | ||
28 | - { | ||
29 | - callback(error, result); | ||
30 | - return; | ||
31 | - } | ||
32 | - | ||
33 | - state.index++; | ||
34 | - | ||
35 | - // are we there yet? | ||
36 | - if (state.index < (state['keyedList'] || list).length) | ||
37 | - { | ||
38 | - iterate(list, iterator, state, iteratorHandler); | ||
39 | - return; | ||
40 | - } | ||
41 | - | ||
42 | - // done here | ||
43 | - callback(null, state.results); | ||
44 | - }); | ||
45 | - | ||
46 | - return terminator.bind(state, callback); | ||
47 | -} | ||
48 | - | ||
49 | -/* | ||
50 | - * -- Sort methods | ||
51 | - */ | ||
52 | - | ||
53 | -/** | ||
54 | - * sort helper to sort array elements in ascending order | ||
55 | - * | ||
56 | - * @param {mixed} a - an item to compare | ||
57 | - * @param {mixed} b - an item to compare | ||
58 | - * @returns {number} - comparison result | ||
59 | - */ | ||
60 | -function ascending(a, b) | ||
61 | -{ | ||
62 | - return a < b ? -1 : a > b ? 1 : 0; | ||
63 | -} | ||
64 | - | ||
65 | -/** | ||
66 | - * sort helper to sort array elements in descending order | ||
67 | - * | ||
68 | - * @param {mixed} a - an item to compare | ||
69 | - * @param {mixed} b - an item to compare | ||
70 | - * @returns {number} - comparison result | ||
71 | - */ | ||
72 | -function descending(a, b) | ||
73 | -{ | ||
74 | - return -1 * ascending(a, b); | ||
75 | -} |
node_modules/asynckit/stream.js
已删除
100644 → 0
1 | -var inherits = require('util').inherits | ||
2 | - , Readable = require('stream').Readable | ||
3 | - , ReadableAsyncKit = require('./lib/readable_asynckit.js') | ||
4 | - , ReadableParallel = require('./lib/readable_parallel.js') | ||
5 | - , ReadableSerial = require('./lib/readable_serial.js') | ||
6 | - , ReadableSerialOrdered = require('./lib/readable_serial_ordered.js') | ||
7 | - ; | ||
8 | - | ||
9 | -// API | ||
10 | -module.exports = | ||
11 | -{ | ||
12 | - parallel : ReadableParallel, | ||
13 | - serial : ReadableSerial, | ||
14 | - serialOrdered : ReadableSerialOrdered, | ||
15 | -}; | ||
16 | - | ||
17 | -inherits(ReadableAsyncKit, Readable); | ||
18 | - | ||
19 | -inherits(ReadableParallel, ReadableAsyncKit); | ||
20 | -inherits(ReadableSerial, ReadableAsyncKit); | ||
21 | -inherits(ReadableSerialOrdered, ReadableAsyncKit); |
node_modules/axios/CHANGELOG.md
已删除
100644 → 0
1 | -# Changelog | ||
2 | - | ||
3 | -## [1.6.2](https://github.com/axios/axios/compare/v1.6.1...v1.6.2) (2023-11-14) | ||
4 | - | ||
5 | - | ||
6 | -### Features | ||
7 | - | ||
8 | -* **withXSRFToken:** added withXSRFToken option as a workaround to achieve the old `withCredentials` behavior; ([#6046](https://github.com/axios/axios/issues/6046)) ([cff9967](https://github.com/axios/axios/commit/cff996779b272a5e94c2b52f5503ccf668bc42dc)) | ||
9 | - | ||
10 | -### PRs | ||
11 | -- feat(withXSRFToken): added withXSRFToken option as a workaround to achieve the old `withCredentials` behavior; ( [#6046](https://api.github.com/repos/axios/axios/pulls/6046) ) | ||
12 | -``` | ||
13 | - | ||
14 | -📢 This PR added 'withXSRFToken' option as a replacement for old withCredentials behaviour. | ||
15 | -You should now use withXSRFToken along with withCredential to get the old behavior. | ||
16 | -This functionality is considered as a fix. | ||
17 | -``` | ||
18 | - | ||
19 | -### Contributors to this release | ||
20 | - | ||
21 | -- <img src="https://avatars.githubusercontent.com/u/12586868?v=4&s=18" alt="avatar" width="18"/> [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+271/-146 (#6081 #6080 #6079 #6078 #6046 #6064 #6063 )") | ||
22 | -- <img src="https://avatars.githubusercontent.com/u/79681367?v=4&s=18" alt="avatar" width="18"/> [Ng Choon Khon (CK)](https://github.com/ckng0221 "+4/-4 (#6073 )") | ||
23 | -- <img src="https://avatars.githubusercontent.com/u/9162827?v=4&s=18" alt="avatar" width="18"/> [Muhammad Noman](https://github.com/mnomanmemon "+2/-2 (#6048 )") | ||
24 | - | ||
25 | -## [1.6.1](https://github.com/axios/axios/compare/v1.6.0...v1.6.1) (2023-11-08) | ||
26 | - | ||
27 | - | ||
28 | -### Bug Fixes | ||
29 | - | ||
30 | -* **formdata:** fixed content-type header normalization for non-standard browser environments; ([#6056](https://github.com/axios/axios/issues/6056)) ([dd465ab](https://github.com/axios/axios/commit/dd465ab22bbfa262c6567be6574bf46a057d5288)) | ||
31 | -* **platform:** fixed emulated browser detection in node.js environment; ([#6055](https://github.com/axios/axios/issues/6055)) ([3dc8369](https://github.com/axios/axios/commit/3dc8369e505e32a4e12c22f154c55fd63ac67fbb)) | ||
32 | - | ||
33 | -### Contributors to this release | ||
34 | - | ||
35 | -- <img src="https://avatars.githubusercontent.com/u/12586868?v=4&s=18" alt="avatar" width="18"/> [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+432/-65 (#6059 #6056 #6055 )") | ||
36 | -- <img src="https://avatars.githubusercontent.com/u/3982806?v=4&s=18" alt="avatar" width="18"/> [Fabian Meyer](https://github.com/meyfa "+5/-2 (#5835 )") | ||
37 | - | ||
38 | -### PRs | ||
39 | -- feat(withXSRFToken): added withXSRFToken option as a workaround to achieve the old `withCredentials` behavior; ( [#6046](https://api.github.com/repos/axios/axios/pulls/6046) ) | ||
40 | -``` | ||
41 | - | ||
42 | -📢 This PR added 'withXSRFToken' option as a replacement for old withCredentials behaviour. | ||
43 | -You should now use withXSRFToken along with withCredential to get the old behavior. | ||
44 | -This functionality is considered as a fix. | ||
45 | -``` | ||
46 | - | ||
47 | -# [1.6.0](https://github.com/axios/axios/compare/v1.5.1...v1.6.0) (2023-10-26) | ||
48 | - | ||
49 | - | ||
50 | -### Bug Fixes | ||
51 | - | ||
52 | -* **CSRF:** fixed CSRF vulnerability CVE-2023-45857 ([#6028](https://github.com/axios/axios/issues/6028)) ([96ee232](https://github.com/axios/axios/commit/96ee232bd3ee4de2e657333d4d2191cd389e14d0)) | ||
53 | -* **dns:** fixed lookup function decorator to work properly in node v20; ([#6011](https://github.com/axios/axios/issues/6011)) ([5aaff53](https://github.com/axios/axios/commit/5aaff532a6b820bb9ab6a8cd0f77131b47e2adb8)) | ||
54 | -* **types:** fix AxiosHeaders types; ([#5931](https://github.com/axios/axios/issues/5931)) ([a1c8ad0](https://github.com/axios/axios/commit/a1c8ad008b3c13d53e135bbd0862587fb9d3fc09)) | ||
55 | - | ||
56 | -### PRs | ||
57 | -- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) ) | ||
58 | -``` | ||
59 | - | ||
60 | -⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459 | ||
61 | -``` | ||
62 | - | ||
63 | -### Contributors to this release | ||
64 | - | ||
65 | -- <img src="https://avatars.githubusercontent.com/u/12586868?v=4&s=18" alt="avatar" width="18"/> [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+449/-114 (#6032 #6021 #6011 #5932 #5931 )") | ||
66 | -- <img src="https://avatars.githubusercontent.com/u/63700910?v=4&s=18" alt="avatar" width="18"/> [Valentin Panov](https://github.com/valentin-panov "+4/-4 (#6028 )") | ||
67 | -- <img src="https://avatars.githubusercontent.com/u/76877078?v=4&s=18" alt="avatar" width="18"/> [Rinku Chaudhari](https://github.com/therealrinku "+1/-1 (#5889 )") | ||
68 | - | ||
69 | -## [1.5.1](https://github.com/axios/axios/compare/v1.5.0...v1.5.1) (2023-09-26) | ||
70 | - | ||
71 | - | ||
72 | -### Bug Fixes | ||
73 | - | ||
74 | -* **adapters:** improved adapters loading logic to have clear error messages; ([#5919](https://github.com/axios/axios/issues/5919)) ([e410779](https://github.com/axios/axios/commit/e4107797a7a1376f6209fbecfbbce73d3faa7859)) | ||
75 | -* **formdata:** fixed automatic addition of the `Content-Type` header for FormData in non-browser environments; ([#5917](https://github.com/axios/axios/issues/5917)) ([bc9af51](https://github.com/axios/axios/commit/bc9af51b1886d1b3529617702f2a21a6c0ed5d92)) | ||
76 | -* **headers:** allow `content-encoding` header to handle case-insensitive values ([#5890](https://github.com/axios/axios/issues/5890)) ([#5892](https://github.com/axios/axios/issues/5892)) ([4c89f25](https://github.com/axios/axios/commit/4c89f25196525e90a6e75eda9cb31ae0a2e18acd)) | ||
77 | -* **types:** removed duplicated code ([9e62056](https://github.com/axios/axios/commit/9e6205630e1c9cf863adf141c0edb9e6d8d4b149)) | ||
78 | - | ||
79 | -### Contributors to this release | ||
80 | - | ||
81 | -- <img src="https://avatars.githubusercontent.com/u/12586868?v=4&s=18" alt="avatar" width="18"/> [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+89/-18 (#5919 #5917 )") | ||
82 | -- <img src="https://avatars.githubusercontent.com/u/110460234?v=4&s=18" alt="avatar" width="18"/> [David Dallas](https://github.com/DavidJDallas "+11/-5 ()") | ||
83 | -- <img src="https://avatars.githubusercontent.com/u/71556073?v=4&s=18" alt="avatar" width="18"/> [Sean Sattler](https://github.com/fb-sean "+2/-8 ()") | ||
84 | -- <img src="https://avatars.githubusercontent.com/u/4294069?v=4&s=18" alt="avatar" width="18"/> [Mustafa Ateş Uzun](https://github.com/0o001 "+4/-4 ()") | ||
85 | -- <img src="https://avatars.githubusercontent.com/u/132928043?v=4&s=18" alt="avatar" width="18"/> [Przemyslaw Motacki](https://github.com/sfc-gh-pmotacki "+2/-1 (#5892 )") | ||
86 | -- <img src="https://avatars.githubusercontent.com/u/5492927?v=4&s=18" alt="avatar" width="18"/> [Michael Di Prisco](https://github.com/Cadienvan "+1/-1 ()") | ||
87 | - | ||
88 | -### PRs | ||
89 | -- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) ) | ||
90 | -``` | ||
91 | - | ||
92 | -⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459 | ||
93 | -``` | ||
94 | - | ||
95 | -# [1.5.0](https://github.com/axios/axios/compare/v1.4.0...v1.5.0) (2023-08-26) | ||
96 | - | ||
97 | - | ||
98 | -### Bug Fixes | ||
99 | - | ||
100 | -* **adapter:** make adapter loading error more clear by using platform-specific adapters explicitly ([#5837](https://github.com/axios/axios/issues/5837)) ([9a414bb](https://github.com/axios/axios/commit/9a414bb6c81796a95c6c7fe668637825458e8b6d)) | ||
101 | -* **dns:** fixed `cacheable-lookup` integration; ([#5836](https://github.com/axios/axios/issues/5836)) ([b3e327d](https://github.com/axios/axios/commit/b3e327dcc9277bdce34c7ef57beedf644b00d628)) | ||
102 | -* **headers:** added support for setting header names that overlap with class methods; ([#5831](https://github.com/axios/axios/issues/5831)) ([d8b4ca0](https://github.com/axios/axios/commit/d8b4ca0ea5f2f05efa4edfe1e7684593f9f68273)) | ||
103 | -* **headers:** fixed common Content-Type header merging; ([#5832](https://github.com/axios/axios/issues/5832)) ([8fda276](https://github.com/axios/axios/commit/8fda2766b1e6bcb72c3fabc146223083ef13ce17)) | ||
104 | - | ||
105 | - | ||
106 | -### Features | ||
107 | - | ||
108 | -* export getAdapter function ([#5324](https://github.com/axios/axios/issues/5324)) ([ca73eb8](https://github.com/axios/axios/commit/ca73eb878df0ae2dace81fe3a7f1fb5986231bf1)) | ||
109 | -* **export:** export adapters without `unsafe` prefix ([#5839](https://github.com/axios/axios/issues/5839)) ([1601f4a](https://github.com/axios/axios/commit/1601f4a27a81ab47fea228f1e244b2c4e3ce28bf)) | ||
110 | - | ||
111 | -### Contributors to this release | ||
112 | - | ||
113 | -- <img src="https://avatars.githubusercontent.com/u/12586868?v=4&s=18" alt="avatar" width="18"/> [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+66/-29 (#5839 #5837 #5836 #5832 #5831 )") | ||
114 | -- <img src="https://avatars.githubusercontent.com/u/102841186?v=4&s=18" alt="avatar" width="18"/> [夜葬](https://github.com/geekact "+42/-0 (#5324 )") | ||
115 | -- <img src="https://avatars.githubusercontent.com/u/65978976?v=4&s=18" alt="avatar" width="18"/> [Jonathan Budiman](https://github.com/JBudiman00 "+30/-0 (#5788 )") | ||
116 | -- <img src="https://avatars.githubusercontent.com/u/5492927?v=4&s=18" alt="avatar" width="18"/> [Michael Di Prisco](https://github.com/Cadienvan "+3/-5 (#5791 )") | ||
117 | - | ||
118 | -### PRs | ||
119 | -- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) ) | ||
120 | -``` | ||
121 | - | ||
122 | -⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459 | ||
123 | -``` | ||
124 | - | ||
125 | -# [1.4.0](https://github.com/axios/axios/compare/v1.3.6...v1.4.0) (2023-04-27) | ||
126 | - | ||
127 | - | ||
128 | -### Bug Fixes | ||
129 | - | ||
130 | -* **formdata:** add `multipart/form-data` content type for FormData payload on custom client environments; ([#5678](https://github.com/axios/axios/issues/5678)) ([bbb61e7](https://github.com/axios/axios/commit/bbb61e70cb1185adfb1cbbb86eaf6652c48d89d1)) | ||
131 | -* **package:** export package internals with unsafe path prefix; ([#5677](https://github.com/axios/axios/issues/5677)) ([df38c94](https://github.com/axios/axios/commit/df38c949f26414d88ba29ec1e353c4d4f97eaf09)) | ||
132 | - | ||
133 | - | ||
134 | -### Features | ||
135 | - | ||
136 | -* **dns:** added support for a custom lookup function; ([#5339](https://github.com/axios/axios/issues/5339)) ([2701911](https://github.com/axios/axios/commit/2701911260a1faa5cc5e1afe437121b330a3b7bb)) | ||
137 | -* **types:** export `AxiosHeaderValue` type. ([#5525](https://github.com/axios/axios/issues/5525)) ([726f1c8](https://github.com/axios/axios/commit/726f1c8e00cffa0461a8813a9bdcb8f8b9d762cf)) | ||
138 | - | ||
139 | - | ||
140 | -### Performance Improvements | ||
141 | - | ||
142 | -* **merge-config:** optimize mergeConfig performance by avoiding duplicate key visits; ([#5679](https://github.com/axios/axios/issues/5679)) ([e6f7053](https://github.com/axios/axios/commit/e6f7053bf1a3e87cf1f9da8677e12e3fe829d68e)) | ||
143 | - | ||
144 | -### Contributors to this release | ||
145 | - | ||
146 | -- <img src="https://avatars.githubusercontent.com/u/12586868?v=4&s=18" alt="avatar" width="18"/> [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+151/-16 (#5684 #5339 #5679 #5678 #5677 )") | ||
147 | -- <img src="https://avatars.githubusercontent.com/u/47537704?v=4&s=18" alt="avatar" width="18"/> [Arthur Fiorette](https://github.com/arthurfiorette "+19/-19 (#5525 )") | ||
148 | -- <img src="https://avatars.githubusercontent.com/u/43876655?v=4&s=18" alt="avatar" width="18"/> [PIYUSH NEGI](https://github.com/npiyush97 "+2/-18 (#5670 )") | ||
149 | - | ||
150 | -### PRs | ||
151 | -- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) ) | ||
152 | -``` | ||
153 | - | ||
154 | -⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459 | ||
155 | -``` | ||
156 | - | ||
157 | -## [1.3.6](https://github.com/axios/axios/compare/v1.3.5...v1.3.6) (2023-04-19) | ||
158 | - | ||
159 | - | ||
160 | -### Bug Fixes | ||
161 | - | ||
162 | -* **types:** added transport to RawAxiosRequestConfig ([#5445](https://github.com/axios/axios/issues/5445)) ([6f360a2](https://github.com/axios/axios/commit/6f360a2531d8d70363fd9becef6a45a323f170e2)) | ||
163 | -* **utils:** make isFormData detection logic stricter to avoid unnecessary calling of the `toString` method on the target; ([#5661](https://github.com/axios/axios/issues/5661)) ([aa372f7](https://github.com/axios/axios/commit/aa372f7306295dfd1100c1c2c77ce95c95808e76)) | ||
164 | - | ||
165 | -### Contributors to this release | ||
166 | - | ||
167 | -- <img src="https://avatars.githubusercontent.com/u/12586868?v=4&s=18" alt="avatar" width="18"/> [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+48/-10 (#5665 #5661 #5663 )") | ||
168 | -- <img src="https://avatars.githubusercontent.com/u/5492927?v=4&s=18" alt="avatar" width="18"/> [Michael Di Prisco](https://github.com/Cadienvan "+2/-0 (#5445 )") | ||
169 | - | ||
170 | -### PRs | ||
171 | -- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) ) | ||
172 | -``` | ||
173 | - | ||
174 | -⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459 | ||
175 | -``` | ||
176 | - | ||
177 | -## [1.3.5](https://github.com/axios/axios/compare/v1.3.4...v1.3.5) (2023-04-05) | ||
178 | - | ||
179 | - | ||
180 | -### Bug Fixes | ||
181 | - | ||
182 | -* **headers:** fixed isValidHeaderName to support full list of allowed characters; ([#5584](https://github.com/axios/axios/issues/5584)) ([e7decef](https://github.com/axios/axios/commit/e7decef6a99f4627e27ed9ea5b00ce8e201c3841)) | ||
183 | -* **params:** re-added the ability to set the function as `paramsSerializer` config; ([#5633](https://github.com/axios/axios/issues/5633)) ([a56c866](https://github.com/axios/axios/commit/a56c8661209d5ce5a645a05f294a0e08a6c1f6b3)) | ||
184 | - | ||
185 | -### Contributors to this release | ||
186 | - | ||
187 | -- <img src="https://avatars.githubusercontent.com/u/12586868?v=4&s=18" alt="avatar" width="18"/> [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+28/-10 (#5633 #5584 )") | ||
188 | - | ||
189 | -### PRs | ||
190 | -- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) ) | ||
191 | -``` | ||
192 | - | ||
193 | -⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459 | ||
194 | -``` | ||
195 | - | ||
196 | -## [1.3.4](https://github.com/axios/axios/compare/v1.3.3...v1.3.4) (2023-02-22) | ||
197 | - | ||
198 | - | ||
199 | -### Bug Fixes | ||
200 | - | ||
201 | -* **blob:** added a check to make sure the Blob class is available in the browser's global scope; ([#5548](https://github.com/axios/axios/issues/5548)) ([3772c8f](https://github.com/axios/axios/commit/3772c8fe74112a56e3e9551f894d899bc3a9443a)) | ||
202 | -* **http:** fixed regression bug when handling synchronous errors inside the adapter; ([#5564](https://github.com/axios/axios/issues/5564)) ([a3b246c](https://github.com/axios/axios/commit/a3b246c9de5c3bc4b5a742e15add55b375479451)) | ||
203 | - | ||
204 | -### Contributors to this release | ||
205 | - | ||
206 | -- <img src="https://avatars.githubusercontent.com/u/12586868?v=4&s=18" alt="avatar" width="18"/> [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+38/-26 (#5564 )") | ||
207 | -- <img src="https://avatars.githubusercontent.com/u/19550000?v=4&s=18" alt="avatar" width="18"/> [lcysgsg](https://github.com/lcysgsg "+4/-0 (#5548 )") | ||
208 | -- <img src="https://avatars.githubusercontent.com/u/5492927?v=4&s=18" alt="avatar" width="18"/> [Michael Di Prisco](https://github.com/Cadienvan "+3/-0 (#5444 )") | ||
209 | - | ||
210 | -### PRs | ||
211 | -- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) ) | ||
212 | -``` | ||
213 | - | ||
214 | -⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459 | ||
215 | -``` | ||
216 | - | ||
217 | -## [1.3.3](https://github.com/axios/axios/compare/v1.3.2...v1.3.3) (2023-02-13) | ||
218 | - | ||
219 | - | ||
220 | -### Bug Fixes | ||
221 | - | ||
222 | -* **formdata:** added a check to make sure the FormData class is available in the browser's global scope; ([#5545](https://github.com/axios/axios/issues/5545)) ([a6dfa72](https://github.com/axios/axios/commit/a6dfa72010db5ad52db8bd13c0f98e537e8fd05d)) | ||
223 | -* **formdata:** fixed setting NaN as Content-Length for form payload in some cases; ([#5535](https://github.com/axios/axios/issues/5535)) ([c19f7bf](https://github.com/axios/axios/commit/c19f7bf770f90ae8307f4ea3104f227056912da1)) | ||
224 | -* **headers:** fixed the filtering logic of the clear method; ([#5542](https://github.com/axios/axios/issues/5542)) ([ea87ebf](https://github.com/axios/axios/commit/ea87ebfe6d1699af072b9e7cd40faf8f14b0ab93)) | ||
225 | - | ||
226 | -### Contributors to this release | ||
227 | - | ||
228 | -- <img src="https://avatars.githubusercontent.com/u/12586868?v=4&s=18" alt="avatar" width="18"/> [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+11/-7 (#5545 #5535 #5542 )") | ||
229 | -- <img src="https://avatars.githubusercontent.com/u/19842213?v=4&s=18" alt="avatar" width="18"/> [陈若枫](https://github.com/ruofee "+2/-2 (#5467 )") | ||
230 | - | ||
231 | -### PRs | ||
232 | -- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) ) | ||
233 | -``` | ||
234 | - | ||
235 | -⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459 | ||
236 | -``` | ||
237 | - | ||
238 | -## [1.3.2](https://github.com/axios/axios/compare/v1.3.1...v1.3.2) (2023-02-03) | ||
239 | - | ||
240 | - | ||
241 | -### Bug Fixes | ||
242 | - | ||
243 | -* **http:** treat http://localhost as base URL for relative paths to avoid `ERR_INVALID_URL` error; ([#5528](https://github.com/axios/axios/issues/5528)) ([128d56f](https://github.com/axios/axios/commit/128d56f4a0fb8f5f2ed6e0dd80bc9225fee9538c)) | ||
244 | -* **http:** use explicit import instead of TextEncoder global; ([#5530](https://github.com/axios/axios/issues/5530)) ([6b3c305](https://github.com/axios/axios/commit/6b3c305fc40c56428e0afabedc6f4d29c2830f6f)) | ||
245 | - | ||
246 | -### Contributors to this release | ||
247 | - | ||
248 | -- <img src="https://avatars.githubusercontent.com/u/12586868?v=4&s=18" alt="avatar" width="18"/> [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+2/-1 (#5530 #5528 )") | ||
249 | - | ||
250 | -### PRs | ||
251 | -- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) ) | ||
252 | -``` | ||
253 | - | ||
254 | -⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459 | ||
255 | -``` | ||
256 | - | ||
257 | -## [1.3.1](https://github.com/axios/axios/compare/v1.3.0...v1.3.1) (2023-02-01) | ||
258 | - | ||
259 | - | ||
260 | -### Bug Fixes | ||
261 | - | ||
262 | -* **formdata:** add hotfix to use the asynchronous API to compute the content-length header value; ([#5521](https://github.com/axios/axios/issues/5521)) ([96d336f](https://github.com/axios/axios/commit/96d336f527619f21da012fe1f117eeb53e5a2120)) | ||
263 | -* **serializer:** fixed serialization of array-like objects; ([#5518](https://github.com/axios/axios/issues/5518)) ([08104c0](https://github.com/axios/axios/commit/08104c028c0f9353897b1b6691d74c440fd0c32d)) | ||
264 | - | ||
265 | -### Contributors to this release | ||
266 | - | ||
267 | -- <img src="https://avatars.githubusercontent.com/u/12586868?v=4&s=18" alt="avatar" width="18"/> [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+27/-8 (#5521 #5518 )") | ||
268 | - | ||
269 | -### PRs | ||
270 | -- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) ) | ||
271 | -``` | ||
272 | - | ||
273 | -⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459 | ||
274 | -``` | ||
275 | - | ||
276 | -# [1.3.0](https://github.com/axios/axios/compare/v1.2.6...v1.3.0) (2023-01-31) | ||
277 | - | ||
278 | - | ||
279 | -### Bug Fixes | ||
280 | - | ||
281 | -* **headers:** fixed & optimized clear method; ([#5507](https://github.com/axios/axios/issues/5507)) ([9915635](https://github.com/axios/axios/commit/9915635c69d0ab70daca5738488421f67ca60959)) | ||
282 | -* **http:** add zlib headers if missing ([#5497](https://github.com/axios/axios/issues/5497)) ([65e8d1e](https://github.com/axios/axios/commit/65e8d1e28ce829f47a837e45129730e541950d3c)) | ||
283 | - | ||
284 | - | ||
285 | -### Features | ||
286 | - | ||
287 | -* **fomdata:** added support for spec-compliant FormData & Blob types; ([#5316](https://github.com/axios/axios/issues/5316)) ([6ac574e](https://github.com/axios/axios/commit/6ac574e00a06731288347acea1e8246091196953)) | ||
288 | - | ||
289 | -### Contributors to this release | ||
290 | - | ||
291 | -- <img src="https://avatars.githubusercontent.com/u/12586868?v=4&s=18" alt="avatar" width="18"/> [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+352/-67 (#5514 #5512 #5510 #5509 #5508 #5316 #5507 )") | ||
292 | -- <img src="https://avatars.githubusercontent.com/u/35015993?v=4&s=18" alt="avatar" width="18"/> [ItsNotGoodName](https://github.com/ItsNotGoodName "+43/-2 (#5497 )") | ||
293 | - | ||
294 | -### PRs | ||
295 | -- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) ) | ||
296 | -``` | ||
297 | - | ||
298 | -⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459 | ||
299 | -``` | ||
300 | - | ||
301 | -## [1.2.6](https://github.com/axios/axios/compare/v1.2.5...v1.2.6) (2023-01-28) | ||
302 | - | ||
303 | - | ||
304 | -### Bug Fixes | ||
305 | - | ||
306 | -* **headers:** added missed Authorization accessor; ([#5502](https://github.com/axios/axios/issues/5502)) ([342c0ba](https://github.com/axios/axios/commit/342c0ba9a16ea50f5ed7d2366c5c1a2c877e3f26)) | ||
307 | -* **types:** fixed `CommonRequestHeadersList` & `CommonResponseHeadersList` types to be private in commonJS; ([#5503](https://github.com/axios/axios/issues/5503)) ([5a3d0a3](https://github.com/axios/axios/commit/5a3d0a3234d77361a1bc7cedee2da1e11df08e2c)) | ||
308 | - | ||
309 | -### Contributors to this release | ||
310 | - | ||
311 | -- ![avatar](https://avatars.githubusercontent.com/u/12586868?v=4&s=16) [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+24/-9 (#5503 #5502 )") | ||
312 | - | ||
313 | -### PRs | ||
314 | -- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) ) | ||
315 | -``` | ||
316 | - | ||
317 | -⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459 | ||
318 | -``` | ||
319 | - | ||
320 | -## [1.2.5](https://github.com/axios/axios/compare/v1.2.4...v1.2.5) (2023-01-26) | ||
321 | - | ||
322 | - | ||
323 | -### Bug Fixes | ||
324 | - | ||
325 | -* **types:** fixed AxiosHeaders to handle spread syntax by making all methods non-enumerable; ([#5499](https://github.com/axios/axios/issues/5499)) ([580f1e8](https://github.com/axios/axios/commit/580f1e8033a61baa38149d59fd16019de3932c22)) | ||
326 | - | ||
327 | -### Contributors to this release | ||
328 | - | ||
329 | -- ![avatar](https://avatars.githubusercontent.com/u/12586868?v=4&s=16) [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+82/-54 (#5499 )") | ||
330 | -- ![avatar](https://avatars.githubusercontent.com/u/20516159?v=4&s=16) [Elliot Ford](https://github.com/EFord36 "+1/-1 (#5462 )") | ||
331 | - | ||
332 | -### PRs | ||
333 | -- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) ) | ||
334 | -``` | ||
335 | - | ||
336 | -⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459 | ||
337 | -``` | ||
338 | - | ||
339 | -## [1.2.4](https://github.com/axios/axios/compare/v1.2.3...v1.2.4) (2023-01-22) | ||
340 | - | ||
341 | - | ||
342 | -### Bug Fixes | ||
343 | - | ||
344 | -* **types:** renamed `RawAxiosRequestConfig` back to `AxiosRequestConfig`; ([#5486](https://github.com/axios/axios/issues/5486)) ([2a71f49](https://github.com/axios/axios/commit/2a71f49bc6c68495fa419003a3107ed8bd703ad0)) | ||
345 | -* **types:** fix `AxiosRequestConfig` generic; ([#5478](https://github.com/axios/axios/issues/5478)) ([9bce81b](https://github.com/axios/axios/commit/186ea062da8b7d578ae78b1a5c220986b9bce81b)) | ||
346 | - | ||
347 | -### Contributors to this release | ||
348 | - | ||
349 | -- ![avatar](https://avatars.githubusercontent.com/u/12586868?v=4&s=16) [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+242/-108 (#5486 #5482 )") | ||
350 | -- ![avatar](https://avatars.githubusercontent.com/u/9430821?v=4&s=16) [Daniel Hillmann](https://github.com/hilleer "+1/-1 (#5478 )") | ||
351 | - | ||
352 | -### PRs | ||
353 | -- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) ) | ||
354 | -``` | ||
355 | - | ||
356 | -⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459 | ||
357 | -``` | ||
358 | - | ||
359 | -## [1.2.3](https://github.com/axios/axios/compare/1.2.2...1.2.3) (2023-01-10) | ||
360 | - | ||
361 | - | ||
362 | -### Bug Fixes | ||
363 | - | ||
364 | -* **types:** fixed AxiosRequestConfig header interface by refactoring it to RawAxiosRequestConfig; ([#5420](https://github.com/axios/axios/issues/5420)) ([0811963](https://github.com/axios/axios/commit/08119634a22f1d5b19f5c9ea0adccb6d3eebc3bc)) | ||
365 | - | ||
366 | -### Contributors to this release | ||
367 | - | ||
368 | -- ![avatar](https://avatars.githubusercontent.com/u/12586868?v=4&s=16) [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS "+938/-442 (#5456 #5455 #5453 #5451 #5449 #5447 #5446 #5443 #5442 #5439 #5420 )") | ||
369 | - | ||
370 | -### PRs | ||
371 | -- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) ) | ||
372 | -``` | ||
373 | - | ||
374 | -⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459 | ||
375 | -``` | ||
376 | - | ||
377 | -## [1.2.2] - 2022-12-29 | ||
378 | - | ||
379 | -### Fixed | ||
380 | -- fix(ci): fix release script inputs [#5392](https://github.com/axios/axios/pull/5392) | ||
381 | -- fix(ci): prerelease scipts [#5377](https://github.com/axios/axios/pull/5377) | ||
382 | -- fix(ci): release scripts [#5376](https://github.com/axios/axios/pull/5376) | ||
383 | -- fix(ci): typescript tests [#5375](https://github.com/axios/axios/pull/5375) | ||
384 | -- fix: Brotli decompression [#5353](https://github.com/axios/axios/pull/5353) | ||
385 | -- fix: add missing HttpStatusCode [#5345](https://github.com/axios/axios/pull/5345) | ||
386 | - | ||
387 | -### Chores | ||
388 | -- chore(ci): set conventional-changelog header config [#5406](https://github.com/axios/axios/pull/5406) | ||
389 | -- chore(ci): fix automatic contributors resolving [#5403](https://github.com/axios/axios/pull/5403) | ||
390 | -- chore(ci): improved logging for the contributors list generator [#5398](https://github.com/axios/axios/pull/5398) | ||
391 | -- chore(ci): fix release action [#5397](https://github.com/axios/axios/pull/5397) | ||
392 | -- chore(ci): fix version bump script by adding bump argument for target version [#5393](https://github.com/axios/axios/pull/5393) | ||
393 | -- chore(deps): bump decode-uri-component from 0.2.0 to 0.2.2 [#5342](https://github.com/axios/axios/pull/5342) | ||
394 | -- chore(ci): GitHub Actions Release script [#5384](https://github.com/axios/axios/pull/5384) | ||
395 | -- chore(ci): release scripts [#5364](https://github.com/axios/axios/pull/5364) | ||
396 | - | ||
397 | -### Contributors to this release | ||
398 | -- ![avatar](https://avatars.githubusercontent.com/u/12586868?v=4&s=16) [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS) | ||
399 | -- ![avatar](https://avatars.githubusercontent.com/u/1652293?v=4&s=16) [Winnie](https://github.com/winniehell) | ||
400 | - | ||
401 | -## [1.2.1] - 2022-12-05 | ||
402 | - | ||
403 | -### Changed | ||
404 | -- feat(exports): export mergeConfig [#5151](https://github.com/axios/axios/pull/5151) | ||
405 | - | ||
406 | -### Fixed | ||
407 | -- fix(CancelledError): include config [#4922](https://github.com/axios/axios/pull/4922) | ||
408 | -- fix(general): removing multiple/trailing/leading whitespace [#5022](https://github.com/axios/axios/pull/5022) | ||
409 | -- fix(headers): decompression for responses without Content-Length header [#5306](https://github.com/axios/axios/pull/5306) | ||
410 | -- fix(webWorker): exception to sending form data in web worker [#5139](https://github.com/axios/axios/pull/5139) | ||
411 | - | ||
412 | -### Refactors | ||
413 | -- refactor(types): AxiosProgressEvent.event type to any [#5308](https://github.com/axios/axios/pull/5308) | ||
414 | -- refactor(types): add missing types for static AxiosError.from method [#4956](https://github.com/axios/axios/pull/4956) | ||
415 | - | ||
416 | -### Chores | ||
417 | -- chore(docs): remove README link to non-existent upgrade guide [#5307](https://github.com/axios/axios/pull/5307) | ||
418 | -- chore(docs): typo in issue template name [#5159](https://github.com/axios/axios/pull/5159) | ||
419 | - | ||
420 | -### Contributors to this release | ||
421 | - | ||
422 | -- [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS) | ||
423 | -- [Zachary Lysobey](https://github.com/zachlysobey) | ||
424 | -- [Kevin Ennis](https://github.com/kevincennis) | ||
425 | -- [Philipp Loose](https://github.com/phloose) | ||
426 | -- [secondl1ght](https://github.com/secondl1ght) | ||
427 | -- [wenzheng](https://github.com/0x30) | ||
428 | -- [Ivan Barsukov](https://github.com/ovarn) | ||
429 | -- [Arthur Fiorette](https://github.com/arthurfiorette) | ||
430 | - | ||
431 | -### PRs | ||
432 | -- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) ) | ||
433 | -``` | ||
434 | - | ||
435 | -⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459 | ||
436 | -``` | ||
437 | - | ||
438 | -## [1.2.0] - 2022-11-10 | ||
439 | - | ||
440 | -### Changed | ||
441 | - | ||
442 | -- changed: refactored module exports [#5162](https://github.com/axios/axios/pull/5162) | ||
443 | -- change: re-added support for loading Axios with require('axios').default [#5225](https://github.com/axios/axios/pull/5225) | ||
444 | - | ||
445 | -### Fixed | ||
446 | - | ||
447 | -- fix: improve AxiosHeaders class [#5224](https://github.com/axios/axios/pull/5224) | ||
448 | -- fix: TypeScript type definitions for commonjs [#5196](https://github.com/axios/axios/pull/5196) | ||
449 | -- fix: type definition of use method on AxiosInterceptorManager to match the the README [#5071](https://github.com/axios/axios/pull/5071) | ||
450 | -- fix: __dirname is not defined in the sandbox [#5269](https://github.com/axios/axios/pull/5269) | ||
451 | -- fix: AxiosError.toJSON method to avoid circular references [#5247](https://github.com/axios/axios/pull/5247) | ||
452 | -- fix: Z_BUF_ERROR when content-encoding is set but the response body is empty [#5250](https://github.com/axios/axios/pull/5250) | ||
453 | - | ||
454 | -### Refactors | ||
455 | -- refactor: allowing adapters to be loaded by name [#5277](https://github.com/axios/axios/pull/5277) | ||
456 | - | ||
457 | -### Chores | ||
458 | - | ||
459 | -- chore: force CI restart [#5243](https://github.com/axios/axios/pull/5243) | ||
460 | -- chore: update ECOSYSTEM.md [#5077](https://github.com/axios/axios/pull/5077) | ||
461 | -- chore: update get/index.html [#5116](https://github.com/axios/axios/pull/5116) | ||
462 | -- chore: update Sandbox UI/UX [#5205](https://github.com/axios/axios/pull/5205) | ||
463 | -- chore:(actions): remove git credentials after checkout [#5235](https://github.com/axios/axios/pull/5235) | ||
464 | -- chore(actions): bump actions/dependency-review-action from 2 to 3 [#5266](https://github.com/axios/axios/pull/5266) | ||
465 | -- chore(packages): bump loader-utils from 1.4.1 to 1.4.2 [#5295](https://github.com/axios/axios/pull/5295) | ||
466 | -- chore(packages): bump engine.io from 6.2.0 to 6.2.1 [#5294](https://github.com/axios/axios/pull/5294) | ||
467 | -- chore(packages): bump socket.io-parser from 4.0.4 to 4.0.5 [#5241](https://github.com/axios/axios/pull/5241) | ||
468 | -- chore(packages): bump loader-utils from 1.4.0 to 1.4.1 [#5245](https://github.com/axios/axios/pull/5245) | ||
469 | -- chore(docs): update Resources links in README [#5119](https://github.com/axios/axios/pull/5119) | ||
470 | -- chore(docs): update the link for JSON url [#5265](https://github.com/axios/axios/pull/5265) | ||
471 | -- chore(docs): fix broken links [#5218](https://github.com/axios/axios/pull/5218) | ||
472 | -- chore(docs): update and rename UPGRADE_GUIDE.md to MIGRATION_GUIDE.md [#5170](https://github.com/axios/axios/pull/5170) | ||
473 | -- chore(docs): typo fix line #856 and #920 [#5194](https://github.com/axios/axios/pull/5194) | ||
474 | -- chore(docs): typo fix #800 [#5193](https://github.com/axios/axios/pull/5193) | ||
475 | -- chore(docs): fix typos [#5184](https://github.com/axios/axios/pull/5184) | ||
476 | -- chore(docs): fix punctuation in README.md [#5197](https://github.com/axios/axios/pull/5197) | ||
477 | -- chore(docs): update readme in the Handling Errors section - issue reference #5260 [#5261](https://github.com/axios/axios/pull/5261) | ||
478 | -- chore: remove \b from filename [#5207](https://github.com/axios/axios/pull/5207) | ||
479 | -- chore(docs): update CHANGELOG.md [#5137](https://github.com/axios/axios/pull/5137) | ||
480 | -- chore: add sideEffects false to package.json [#5025](https://github.com/axios/axios/pull/5025) | ||
481 | - | ||
482 | -### Contributors to this release | ||
483 | - | ||
484 | -- [Maddy Miller](https://github.com/me4502) | ||
485 | -- [Amit Saini](https://github.com/amitsainii) | ||
486 | -- [ecyrbe](https://github.com/ecyrbe) | ||
487 | -- [Ikko Ashimine](https://github.com/eltociear) | ||
488 | -- [Geeth Gunnampalli](https://github.com/thetechie7) | ||
489 | -- [Shreem Asati](https://github.com/shreem-123) | ||
490 | -- [Frieder Bluemle](https://github.com/friederbluemle) | ||
491 | -- [윤세영](https://github.com/yunseyeong) | ||
492 | -- [Claudio Busatto](https://github.com/cjcbusatto) | ||
493 | -- [Remco Haszing](https://github.com/remcohaszing) | ||
494 | -- [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS) | ||
495 | -- [Csaba Maulis](https://github.com/om4csaba) | ||
496 | -- [MoPaMo](https://github.com/MoPaMo) | ||
497 | -- [Daniel Fjeldstad](https://github.com/w3bdesign) | ||
498 | -- [Adrien Brunet](https://github.com/adrien-may) | ||
499 | -- [Frazer Smith](https://github.com/Fdawgs) | ||
500 | -- [HaiTao](https://github.com/836334258) | ||
501 | -- [AZM](https://github.com/aziyatali) | ||
502 | -- [relbns](https://github.com/relbns) | ||
503 | - | ||
504 | -### PRs | ||
505 | -- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) ) | ||
506 | -``` | ||
507 | - | ||
508 | -⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459 | ||
509 | -``` | ||
510 | - | ||
511 | -## [1.1.3] - 2022-10-15 | ||
512 | - | ||
513 | -### Added | ||
514 | - | ||
515 | -- Added custom params serializer support [#5113](https://github.com/axios/axios/pull/5113) | ||
516 | - | ||
517 | -### Fixed | ||
518 | - | ||
519 | -- Fixed top-level export to keep them in-line with static properties [#5109](https://github.com/axios/axios/pull/5109) | ||
520 | -- Stopped including null values to query string. [#5108](https://github.com/axios/axios/pull/5108) | ||
521 | -- Restored proxy config backwards compatibility with 0.x [#5097](https://github.com/axios/axios/pull/5097) | ||
522 | -- Added back AxiosHeaders in AxiosHeaderValue [#5103](https://github.com/axios/axios/pull/5103) | ||
523 | -- Pin CDN install instructions to a specific version [#5060](https://github.com/axios/axios/pull/5060) | ||
524 | -- Handling of array values fixed for AxiosHeaders [#5085](https://github.com/axios/axios/pull/5085) | ||
525 | - | ||
526 | -### Chores | ||
527 | - | ||
528 | -- docs: match badge style, add link to them [#5046](https://github.com/axios/axios/pull/5046) | ||
529 | -- chore: fixing comments typo [#5054](https://github.com/axios/axios/pull/5054) | ||
530 | -- chore: update issue template [#5061](https://github.com/axios/axios/pull/5061) | ||
531 | -- chore: added progress capturing section to the docs; [#5084](https://github.com/axios/axios/pull/5084) | ||
532 | - | ||
533 | -### Contributors to this release | ||
534 | - | ||
535 | -- [Jason Saayman](https://github.com/jasonsaayman) | ||
536 | -- [scarf](https://github.com/scarf005) | ||
537 | -- [Lenz Weber-Tronic](https://github.com/phryneas) | ||
538 | -- [Arvindh](https://github.com/itsarvindh) | ||
539 | -- [Félix Legrelle](https://github.com/FelixLgr) | ||
540 | -- [Patrick Petrovic](https://github.com/ppati000) | ||
541 | -- [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS) | ||
542 | -- [littledian](https://github.com/littledian) | ||
543 | -- [ChronosMasterOfAllTime](https://github.com/ChronosMasterOfAllTime) | ||
544 | - | ||
545 | -### PRs | ||
546 | -- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) ) | ||
547 | -``` | ||
548 | - | ||
549 | -⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459 | ||
550 | -``` | ||
551 | - | ||
552 | -## [1.1.2] - 2022-10-07 | ||
553 | - | ||
554 | -### Fixed | ||
555 | - | ||
556 | -- Fixed broken exports for UMD builds. | ||
557 | - | ||
558 | -### Contributors to this release | ||
559 | - | ||
560 | -- [Jason Saayman](https://github.com/jasonsaayman) | ||
561 | - | ||
562 | -### PRs | ||
563 | -- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) ) | ||
564 | -``` | ||
565 | - | ||
566 | -⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459 | ||
567 | -``` | ||
568 | - | ||
569 | -## [1.1.1] - 2022-10-07 | ||
570 | - | ||
571 | -### Fixed | ||
572 | - | ||
573 | -- Fixed broken exports for common js. This fix breaks a prior fix, I will fix both issues ASAP but the commonJS use is more impactful. | ||
574 | - | ||
575 | -### Contributors to this release | ||
576 | - | ||
577 | -- [Jason Saayman](https://github.com/jasonsaayman) | ||
578 | - | ||
579 | -### PRs | ||
580 | -- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) ) | ||
581 | -``` | ||
582 | - | ||
583 | -⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459 | ||
584 | -``` | ||
585 | - | ||
586 | -## [1.1.0] - 2022-10-06 | ||
587 | - | ||
588 | -### Fixed | ||
589 | - | ||
590 | -- Fixed missing exports in type definition index.d.ts [#5003](https://github.com/axios/axios/pull/5003) | ||
591 | -- Fixed query params composing [#5018](https://github.com/axios/axios/pull/5018) | ||
592 | -- Fixed GenericAbortSignal interface by making it more generic [#5021](https://github.com/axios/axios/pull/5021) | ||
593 | -- Fixed adding "clear" to AxiosInterceptorManager [#5010](https://github.com/axios/axios/pull/5010) | ||
594 | -- Fixed commonjs & umd exports [#5030](https://github.com/axios/axios/pull/5030) | ||
595 | -- Fixed inability to access response headers when using axios 1.x with Jest [#5036](https://github.com/axios/axios/pull/5036) | ||
596 | - | ||
597 | -### Contributors to this release | ||
598 | - | ||
599 | -- [Trim21](https://github.com/trim21) | ||
600 | -- [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS) | ||
601 | -- [shingo.sasaki](https://github.com/s-sasaki-0529) | ||
602 | -- [Ivan Pepelko](https://github.com/ivanpepelko) | ||
603 | -- [Richard Kořínek](https://github.com/risa) | ||
604 | - | ||
605 | -### PRs | ||
606 | -- CVE 2023 45857 ( [#6028](https://api.github.com/repos/axios/axios/pulls/6028) ) | ||
607 | -``` | ||
608 | - | ||
609 | -⚠️ Critical vulnerability fix. See https://security.snyk.io/vuln/SNYK-JS-AXIOS-6032459 | ||
610 | -``` | ||
611 | - | ||
612 | -## [1.0.0] - 2022-10-04 | ||
613 | - | ||
614 | -### Added | ||
615 | - | ||
616 | -- Added stack trace to AxiosError [#4624](https://github.com/axios/axios/pull/4624) | ||
617 | -- Add AxiosError to AxiosStatic [#4654](https://github.com/axios/axios/pull/4654) | ||
618 | -- Replaced Rollup as our build runner [#4596](https://github.com/axios/axios/pull/4596) | ||
619 | -- Added generic TS types for the exposed toFormData helper [#4668](https://github.com/axios/axios/pull/4668) | ||
620 | -- Added listen callback function [#4096](https://github.com/axios/axios/pull/4096) | ||
621 | -- Added instructions for installing using PNPM [#4207](https://github.com/axios/axios/pull/4207) | ||
622 | -- Added generic AxiosAbortSignal TS interface to avoid importing AbortController polyfill [#4229](https://github.com/axios/axios/pull/4229) | ||
623 | -- Added axios-url-template in ECOSYSTEM.md [#4238](https://github.com/axios/axios/pull/4238) | ||
624 | -- Added a clear() function to the request and response interceptors object so a user can ensure that all interceptors have been removed from an axios instance [#4248](https://github.com/axios/axios/pull/4248) | ||
625 | -- Added react hook plugin [#4319](https://github.com/axios/axios/pull/4319) | ||
626 | -- Adding HTTP status code for transformResponse [#4580](https://github.com/axios/axios/pull/4580) | ||
627 | -- Added blob to the list of protocols supported by the browser [#4678](https://github.com/axios/axios/pull/4678) | ||
628 | -- Resolving proxy from env on redirect [#4436](https://github.com/axios/axios/pull/4436) | ||
629 | -- Added enhanced toFormData implementation with additional options [4704](https://github.com/axios/axios/pull/4704) | ||
630 | -- Adding Canceler parameters config and request [#4711](https://github.com/axios/axios/pull/4711) | ||
631 | -- Added automatic payload serialization to application/x-www-form-urlencoded [#4714](https://github.com/axios/axios/pull/4714) | ||
632 | -- Added the ability for webpack users to overwrite built-ins [#4715](https://github.com/axios/axios/pull/4715) | ||
633 | -- Added string[] to AxiosRequestHeaders type [#4322](https://github.com/axios/axios/pull/4322) | ||
634 | -- Added the ability for the url-encoded-form serializer to respect the formSerializer config [#4721](https://github.com/axios/axios/pull/4721) | ||
635 | -- Added isCancel type assert [#4293](https://github.com/axios/axios/pull/4293) | ||
636 | -- Added data URL support for node.js [#4725](https://github.com/axios/axios/pull/4725) | ||
637 | -- Adding types for progress event callbacks [#4675](https://github.com/axios/axios/pull/4675) | ||
638 | -- URL params serializer [#4734](https://github.com/axios/axios/pull/4734) | ||
639 | -- Added axios.formToJSON method [#4735](https://github.com/axios/axios/pull/4735) | ||
640 | -- Bower platform add data protocol [#4804](https://github.com/axios/axios/pull/4804) | ||
641 | -- Use WHATWG URL API instead of url.parse() [#4852](https://github.com/axios/axios/pull/4852) | ||
642 | -- Add ENUM containing Http Status Codes to typings [#4903](https://github.com/axios/axios/pull/4903) | ||
643 | -- Improve typing of timeout in index.d.ts [#4934](https://github.com/axios/axios/pull/4934) | ||
644 | - | ||
645 | -### Changed | ||
646 | - | ||
647 | -- Updated AxiosError.config to be optional in the type definition [#4665](https://github.com/axios/axios/pull/4665) | ||
648 | -- Updated README emphasizing the URLSearchParam built-in interface over other solutions [#4590](https://github.com/axios/axios/pull/4590) | ||
649 | -- Include request and config when creating a CanceledError instance [#4659](https://github.com/axios/axios/pull/4659) | ||
650 | -- Changed func-names eslint rule to as-needed [#4492](https://github.com/axios/axios/pull/4492) | ||
651 | -- Replacing deprecated substr() with slice() as substr() is deprecated [#4468](https://github.com/axios/axios/pull/4468) | ||
652 | -- Updating HTTP links in README.md to use HTTPS [#4387](https://github.com/axios/axios/pull/4387) | ||
653 | -- Updated to a better trim() polyfill [#4072](https://github.com/axios/axios/pull/4072) | ||
654 | -- Updated types to allow specifying partial default headers on instance create [#4185](https://github.com/axios/axios/pull/4185) | ||
655 | -- Expanded isAxiosError types [#4344](https://github.com/axios/axios/pull/4344) | ||
656 | -- Updated type definition for axios instance methods [#4224](https://github.com/axios/axios/pull/4224) | ||
657 | -- Updated eslint config [#4722](https://github.com/axios/axios/pull/4722) | ||
658 | -- Updated Docs [#4742](https://github.com/axios/axios/pull/4742) | ||
659 | -- Refactored Axios to use ES2017 [#4787](https://github.com/axios/axios/pull/4787) | ||
660 | - | ||
661 | - | ||
662 | -### Deprecated | ||
663 | -- There are multiple deprecations, refactors and fixes provided in this release. Please read through the full release notes to see how this may impact your project and use case. | ||
664 | - | ||
665 | -### Removed | ||
666 | - | ||
667 | -- Removed incorrect argument for NetworkError constructor [#4656](https://github.com/axios/axios/pull/4656) | ||
668 | -- Removed Webpack [#4596](https://github.com/axios/axios/pull/4596) | ||
669 | -- Removed function that transform arguments to array [#4544](https://github.com/axios/axios/pull/4544) | ||
670 | - | ||
671 | -### Fixed | ||
672 | - | ||
673 | -- Fixed grammar in README [#4649](https://github.com/axios/axios/pull/4649) | ||
674 | -- Fixed code error in README [#4599](https://github.com/axios/axios/pull/4599) | ||
675 | -- Optimized the code that checks cancellation [#4587](https://github.com/axios/axios/pull/4587) | ||
676 | -- Fix url pointing to defaults.js in README [#4532](https://github.com/axios/axios/pull/4532) | ||
677 | -- Use type alias instead of interface for AxiosPromise [#4505](https://github.com/axios/axios/pull/4505) | ||
678 | -- Fix some word spelling and lint style in code comments [#4500](https://github.com/axios/axios/pull/4500) | ||
679 | -- Edited readme with 3 updated browser icons of Chrome, FireFox and Safari [#4414](https://github.com/axios/axios/pull/4414) | ||
680 | -- Bump follow-redirects from 1.14.9 to 1.15.0 [#4673](https://github.com/axios/axios/pull/4673) | ||
681 | -- Fixing http tests to avoid hanging when assertions fail [#4435](https://github.com/axios/axios/pull/4435) | ||
682 | -- Fix TS definition for AxiosRequestTransformer [#4201](https://github.com/axios/axios/pull/4201) | ||
683 | -- Fix grammatical issues in README [#4232](https://github.com/axios/axios/pull/4232) | ||
684 | -- Fixing instance.defaults.headers type [#4557](https://github.com/axios/axios/pull/4557) | ||
685 | -- Fixed race condition on immediate requests cancellation [#4261](https://github.com/axios/axios/pull/4261) | ||
686 | -- Fixing Z_BUF_ERROR when no content [#4701](https://github.com/axios/axios/pull/4701) | ||
687 | -- Fixing proxy beforeRedirect regression [#4708](https://github.com/axios/axios/pull/4708) | ||
688 | -- Fixed AxiosError status code type [#4717](https://github.com/axios/axios/pull/4717) | ||
689 | -- Fixed AxiosError stack capturing [#4718](https://github.com/axios/axios/pull/4718) | ||
690 | -- Fixing AxiosRequestHeaders typings [#4334](https://github.com/axios/axios/pull/4334) | ||
691 | -- Fixed max body length defaults [#4731](https://github.com/axios/axios/pull/4731) | ||
692 | -- Fixed toFormData Blob issue on node>v17 [#4728](https://github.com/axios/axios/pull/4728) | ||
693 | -- Bump grunt from 1.5.2 to 1.5.3 [#4743](https://github.com/axios/axios/pull/4743) | ||
694 | -- Fixing content-type header repeated [#4745](https://github.com/axios/axios/pull/4745) | ||
695 | -- Fixed timeout error message for http [4738](https://github.com/axios/axios/pull/4738) | ||
696 | -- Request ignores false, 0 and empty string as body values [#4785](https://github.com/axios/axios/pull/4785) | ||
697 | -- Added back missing minified builds [#4805](https://github.com/axios/axios/pull/4805) | ||
698 | -- Fixed a type error [#4815](https://github.com/axios/axios/pull/4815) | ||
699 | -- Fixed a regression bug with unsubscribing from cancel token; [#4819](https://github.com/axios/axios/pull/4819) | ||
700 | -- Remove repeated compression algorithm [#4820](https://github.com/axios/axios/pull/4820) | ||
701 | -- The error of calling extend to pass parameters [#4857](https://github.com/axios/axios/pull/4857) | ||
702 | -- SerializerOptions.indexes allows boolean | null | undefined [#4862](https://github.com/axios/axios/pull/4862) | ||
703 | -- Require interceptors to return values [#4874](https://github.com/axios/axios/pull/4874) | ||
704 | -- Removed unused imports [#4949](https://github.com/axios/axios/pull/4949) | ||
705 | -- Allow null indexes on formSerializer and paramsSerializer [#4960](https://github.com/axios/axios/pull/4960) | ||
706 | - | ||
707 | -### Chores | ||
708 | -- Set permissions for GitHub actions [#4765](https://github.com/axios/axios/pull/4765) | ||
709 | -- Included githubactions in the dependabot config [#4770](https://github.com/axios/axios/pull/4770) | ||
710 | -- Included dependency review [#4771](https://github.com/axios/axios/pull/4771) | ||
711 | -- Update security.md [#4784](https://github.com/axios/axios/pull/4784) | ||
712 | -- Remove unnecessary spaces [#4854](https://github.com/axios/axios/pull/4854) | ||
713 | -- Simplify the import path of AxiosError [#4875](https://github.com/axios/axios/pull/4875) | ||
714 | -- Fix Gitpod dead link [#4941](https://github.com/axios/axios/pull/4941) | ||
715 | -- Enable syntax highlighting for a code block [#4970](https://github.com/axios/axios/pull/4970) | ||
716 | -- Using Logo Axios in Readme.md [#4993](https://github.com/axios/axios/pull/4993) | ||
717 | -- Fix markup for note in README [#4825](https://github.com/axios/axios/pull/4825) | ||
718 | -- Fix typo and formatting, add colons [#4853](https://github.com/axios/axios/pull/4853) | ||
719 | -- Fix typo in readme [#4942](https://github.com/axios/axios/pull/4942) | ||
720 | - | ||
721 | -### Security | ||
722 | - | ||
723 | -- Update SECURITY.md [#4687](https://github.com/axios/axios/pull/4687) | ||
724 | - | ||
725 | -### Contributors to this release | ||
726 | - | ||
727 | -- [Bertrand Marron](https://github.com/tusbar) | ||
728 | -- [Dmitriy Mozgovoy](https://github.com/DigitalBrainJS) | ||
729 | -- [Dan Mooney](https://github.com/danmooney) | ||
730 | -- [Michael Li](https://github.com/xiaoyu-tamu) | ||
731 | -- [aong](https://github.com/yxwzaxns) | ||
732 | -- [Des Preston](https://github.com/despreston) | ||
733 | -- [Ted Robertson](https://github.com/tredondo) | ||
734 | -- [zhoulixiang](https://github.com/zh-lx) | ||
735 | -- [Arthur Fiorette](https://github.com/arthurfiorette) | ||
736 | -- [Kumar Shanu](https://github.com/Kr-Shanu) | ||
737 | -- [JALAL](https://github.com/JLL32) | ||
738 | -- [Jingyi Lin](https://github.com/MageeLin) | ||
739 | -- [Philipp Loose](https://github.com/phloose) | ||
740 | -- [Alexander Shchukin](https://github.com/sashsvamir) | ||
741 | -- [Dave Cardwell](https://github.com/davecardwell) | ||
742 | -- [Cat Scarlet](https://github.com/catscarlet) | ||
743 | -- [Luca Pizzini](https://github.com/lpizzinidev) | ||
744 | -- [Kai](https://github.com/Schweinepriester) | ||
745 | -- [Maxime Bargiel](https://github.com/mbargiel) | ||
746 | -- [Brian Helba](https://github.com/brianhelba) | ||
747 | -- [reslear](https://github.com/reslear) | ||
748 | -- [Jamie Slome](https://github.com/JamieSlome) | ||
749 | -- [Landro3](https://github.com/Landro3) | ||
750 | -- [rafw87](https://github.com/rafw87) | ||
751 | -- [Afzal Sayed](https://github.com/afzalsayed96) | ||
752 | -- [Koki Oyatsu](https://github.com/kaishuu0123) | ||
753 | -- [Dave](https://github.com/wangcch) | ||
754 | -- [暴走老七](https://github.com/baozouai) | ||
755 | -- [Spencer](https://github.com/spalger) | ||
756 | -- [Adrian Wieprzkowicz](https://github.com/Argeento) | ||
757 | -- [Jamie Telin](https://github.com/lejahmie) | ||
758 | -- [毛呆](https://github.com/aweikalee) | ||
759 | -- [Kirill Shakirov](https://github.com/turisap) | ||
760 | -- [Rraji Abdelbari](https://github.com/estarossa0) | ||
761 | -- [Jelle Schutter](https://github.com/jelleschutter) | ||
762 | -- [Tom Ceuppens](https://github.com/KyorCode) | ||
763 | -- [Johann Cooper](https://github.com/JohannCooper) | ||
764 | -- [Dimitris Halatsis](https://github.com/mitsos1os) | ||
765 | -- [chenjigeng](https://github.com/chenjigeng) | ||
766 | -- [João Gabriel Quaresma](https://github.com/joaoGabriel55) | ||
767 | -- [Victor Augusto](https://github.com/VictorAugDB) | ||
768 | -- [neilnaveen](https://github.com/neilnaveen) | ||
769 | -- [Pavlos](https://github.com/psmoros) | ||
770 | -- [Kiryl Valkovich](https://github.com/visortelle) | ||
771 | -- [Naveen](https://github.com/naveensrinivasan) | ||
772 | -- [wenzheng](https://github.com/0x30) | ||
773 | -- [hcwhan](https://github.com/hcwhan) | ||
774 | -- [Bassel Rachid](https://github.com/basselworkforce) | ||
775 | -- [Grégoire Pineau](https://github.com/lyrixx) | ||
776 | -- [felipedamin](https://github.com/felipedamin) | ||
777 | -- [Karl Horky](https://github.com/karlhorky) | ||
778 | -- [Yue JIN](https://github.com/kingyue737) | ||
779 | -- [Usman Ali Siddiqui](https://github.com/usman250994) | ||
780 | -- [WD](https://github.com/techbirds) | ||
781 | -- [Günther Foidl](https://github.com/gfoidl) | ||
782 | -- [Stephen Jennings](https://github.com/jennings) | ||
783 | -- [C.T.Lin](https://github.com/chentsulin) | ||
784 | -- [mia-z](https://github.com/mia-z) | ||
785 | -- [Parth Banathia](https://github.com/Parth0105) | ||
786 | -- [parth0105pluang](https://github.com/parth0105pluang) | ||
787 | -- [Marco Weber](https://github.com/mrcwbr) | ||
788 | -- [Luca Pizzini](https://github.com/lpizzinidev) | ||
789 | -- [Willian Agostini](https://github.com/WillianAgostini) | ||
790 | -- [Huyen Nguyen](https://github.com/huyenltnguyen) |
node_modules/axios/LICENSE
已删除
100644 → 0
1 | -# Copyright (c) 2014-present Matt Zabriskie & Collaborators | ||
2 | - | ||
3 | -Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: | ||
4 | - | ||
5 | -The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. | ||
6 | - | ||
7 | -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. |
node_modules/axios/MIGRATION_GUIDE.md
已删除
100644 → 0
node_modules/axios/README.md
已删除
100644 → 0
1 | -<h1 align="center"> | ||
2 | - <b> | ||
3 | - <a href="https://axios-http.com"><img src="https://axios-http.com/assets/logo.svg" /></a><br> | ||
4 | - </b> | ||
5 | -</h1> | ||
6 | - | ||
7 | -<p align="center">Promise based HTTP client for the browser and node.js</p> | ||
8 | - | ||
9 | -<p align="center"> | ||
10 | - <a href="https://axios-http.com/"><b>Website</b></a> • | ||
11 | - <a href="https://axios-http.com/docs/intro"><b>Documentation</b></a> | ||
12 | -</p> | ||
13 | - | ||
14 | -<div align="center"> | ||
15 | - | ||
16 | -[![npm version](https://img.shields.io/npm/v/axios.svg?style=flat-square)](https://www.npmjs.org/package/axios) | ||
17 | -[![CDNJS](https://img.shields.io/cdnjs/v/axios.svg?style=flat-square)](https://cdnjs.com/libraries/axios) | ||
18 | -[![Build status](https://img.shields.io/github/actions/workflow/status/axios/axios/ci.yml?branch=v1.x&label=CI&logo=github&style=flat-square)](https://github.com/axios/axios/actions/workflows/ci.yml) | ||
19 | -[![Gitpod Ready-to-Code](https://img.shields.io/badge/Gitpod-Ready--to--Code-blue?logo=gitpod&style=flat-square)](https://gitpod.io/#https://github.com/axios/axios) | ||
20 | -[![code coverage](https://img.shields.io/coveralls/mzabriskie/axios.svg?style=flat-square)](https://coveralls.io/r/mzabriskie/axios) | ||
21 | -[![install size](https://img.shields.io/badge/dynamic/json?url=https://packagephobia.com/v2/api.json?p=axios&query=$.install.pretty&label=install%20size&style=flat-square)](https://packagephobia.now.sh/result?p=axios) | ||
22 | -[![npm bundle size](https://img.shields.io/bundlephobia/minzip/axios?style=flat-square)](https://bundlephobia.com/package/axios@latest) | ||
23 | -[![npm downloads](https://img.shields.io/npm/dm/axios.svg?style=flat-square)](https://npm-stat.com/charts.html?package=axios) | ||
24 | -[![gitter chat](https://img.shields.io/gitter/room/mzabriskie/axios.svg?style=flat-square)](https://gitter.im/mzabriskie/axios) | ||
25 | -[![code helpers](https://www.codetriage.com/axios/axios/badges/users.svg)](https://www.codetriage.com/axios/axios) | ||
26 | -[![Known Vulnerabilities](https://snyk.io/test/npm/axios/badge.svg)](https://snyk.io/test/npm/axios) | ||
27 | - | ||
28 | - | ||
29 | - | ||
30 | - | ||
31 | -</div> | ||
32 | - | ||
33 | -## Table of Contents | ||
34 | - | ||
35 | - - [Features](#features) | ||
36 | - - [Browser Support](#browser-support) | ||
37 | - - [Installing](#installing) | ||
38 | - - [Package manager](#package-manager) | ||
39 | - - [CDN](#cdn) | ||
40 | - - [Example](#example) | ||
41 | - - [Axios API](#axios-api) | ||
42 | - - [Request method aliases](#request-method-aliases) | ||
43 | - - [Concurrency 👎](#concurrency-deprecated) | ||
44 | - - [Creating an instance](#creating-an-instance) | ||
45 | - - [Instance methods](#instance-methods) | ||
46 | - - [Request Config](#request-config) | ||
47 | - - [Response Schema](#response-schema) | ||
48 | - - [Config Defaults](#config-defaults) | ||
49 | - - [Global axios defaults](#global-axios-defaults) | ||
50 | - - [Custom instance defaults](#custom-instance-defaults) | ||
51 | - - [Config order of precedence](#config-order-of-precedence) | ||
52 | - - [Interceptors](#interceptors) | ||
53 | - - [Multiple Interceptors](#multiple-interceptors) | ||
54 | - - [Handling Errors](#handling-errors) | ||
55 | - - [Cancellation](#cancellation) | ||
56 | - - [AbortController](#abortcontroller) | ||
57 | - - [CancelToken 👎](#canceltoken-deprecated) | ||
58 | - - [Using application/x-www-form-urlencoded format](#using-applicationx-www-form-urlencoded-format) | ||
59 | - - [URLSearchParams](#urlsearchparams) | ||
60 | - - [Query string](#query-string-older-browsers) | ||
61 | - - [🆕 Automatic serialization](#-automatic-serialization-to-urlsearchparams) | ||
62 | - - [Using multipart/form-data format](#using-multipartform-data-format) | ||
63 | - - [FormData](#formdata) | ||
64 | - - [🆕 Automatic serialization](#-automatic-serialization-to-formdata) | ||
65 | - - [Files Posting](#files-posting) | ||
66 | - - [HTML Form Posting](#-html-form-posting-browser) | ||
67 | - - [🆕 Progress capturing](#-progress-capturing) | ||
68 | - - [🆕 Rate limiting](#-progress-capturing) | ||
69 | - - [🆕 AxiosHeaders](#-axiosheaders) | ||
70 | - - [Semver](#semver) | ||
71 | - - [Promises](#promises) | ||
72 | - - [TypeScript](#typescript) | ||
73 | - - [Resources](#resources) | ||
74 | - - [Credits](#credits) | ||
75 | - - [License](#license) | ||
76 | - | ||
77 | -## Features | ||
78 | - | ||
79 | -- Make [XMLHttpRequests](https://developer.mozilla.org/en-US/docs/Web/API/XMLHttpRequest) from the browser | ||
80 | -- Make [http](https://nodejs.org/api/http.html) requests from node.js | ||
81 | -- Supports the [Promise](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise) API | ||
82 | -- Intercept request and response | ||
83 | -- Transform request and response data | ||
84 | -- Cancel requests | ||
85 | -- Automatic transforms for [JSON](https://www.json.org/json-en.html) data | ||
86 | -- 🆕 Automatic data object serialization to `multipart/form-data` and `x-www-form-urlencoded` body encodings | ||
87 | -- Client side support for protecting against [XSRF](https://en.wikipedia.org/wiki/Cross-site_request_forgery) | ||
88 | - | ||
89 | -## Browser Support | ||
90 | - | ||
91 | -![Chrome](https://raw.githubusercontent.com/alrra/browser-logos/main/src/chrome/chrome_48x48.png) | ![Firefox](https://raw.githubusercontent.com/alrra/browser-logos/main/src/firefox/firefox_48x48.png) | ![Safari](https://raw.githubusercontent.com/alrra/browser-logos/main/src/safari/safari_48x48.png) | ![Opera](https://raw.githubusercontent.com/alrra/browser-logos/main/src/opera/opera_48x48.png) | ![Edge](https://raw.githubusercontent.com/alrra/browser-logos/main/src/edge/edge_48x48.png) | ![IE](https://raw.githubusercontent.com/alrra/browser-logos/master/src/archive/internet-explorer_9-11/internet-explorer_9-11_48x48.png) | | ||
92 | ---- | --- | --- | --- | --- | --- | | ||
93 | -Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | Latest ✔ | 11 ✔ | | ||
94 | - | ||
95 | -[![Browser Matrix](https://saucelabs.com/open_sauce/build_matrix/axios.svg)](https://saucelabs.com/u/axios) | ||
96 | - | ||
97 | -## Installing | ||
98 | - | ||
99 | -### Package manager | ||
100 | - | ||
101 | -Using npm: | ||
102 | - | ||
103 | -```bash | ||
104 | -$ npm install axios | ||
105 | -``` | ||
106 | - | ||
107 | -Using bower: | ||
108 | - | ||
109 | -```bash | ||
110 | -$ bower install axios | ||
111 | -``` | ||
112 | - | ||
113 | -Using yarn: | ||
114 | - | ||
115 | -```bash | ||
116 | -$ yarn add axios | ||
117 | -``` | ||
118 | - | ||
119 | -Using pnpm: | ||
120 | - | ||
121 | -```bash | ||
122 | -$ pnpm add axios | ||
123 | -``` | ||
124 | - | ||
125 | -Once the package is installed, you can import the library using `import` or `require` approach: | ||
126 | - | ||
127 | -```js | ||
128 | -import axios, {isCancel, AxiosError} from 'axios'; | ||
129 | -``` | ||
130 | - | ||
131 | -You can also use the default export, since the named export is just a re-export from the Axios factory: | ||
132 | - | ||
133 | -```js | ||
134 | -import axios from 'axios'; | ||
135 | - | ||
136 | -console.log(axios.isCancel('something')); | ||
137 | -```` | ||
138 | - | ||
139 | -If you use `require` for importing, **only default export is available**: | ||
140 | - | ||
141 | -```js | ||
142 | -const axios = require('axios'); | ||
143 | - | ||
144 | -console.log(axios.isCancel('something')); | ||
145 | -``` | ||
146 | - | ||
147 | -For cases where something went wrong when trying to import a module into a custom or legacy environment, | ||
148 | -you can try importing the module package directly: | ||
149 | - | ||
150 | -```js | ||
151 | -const axios = require('axios/dist/browser/axios.cjs'); // browser commonJS bundle (ES2017) | ||
152 | -// const axios = require('axios/dist/node/axios.cjs'); // node commonJS bundle (ES2017) | ||
153 | -``` | ||
154 | - | ||
155 | -### CDN | ||
156 | - | ||
157 | -Using jsDelivr CDN (ES5 UMD browser module): | ||
158 | - | ||
159 | -```html | ||
160 | -<script src="https://cdn.jsdelivr.net/npm/axios@1.1.2/dist/axios.min.js"></script> | ||
161 | -``` | ||
162 | - | ||
163 | -Using unpkg CDN: | ||
164 | - | ||
165 | -```html | ||
166 | -<script src="https://unpkg.com/axios@1.1.2/dist/axios.min.js"></script> | ||
167 | -``` | ||
168 | - | ||
169 | -## Example | ||
170 | - | ||
171 | -> **Note**: CommonJS usage | ||
172 | -> In order to gain the TypeScript typings (for intellisense / autocomplete) while using CommonJS imports with `require()`, use the following approach: | ||
173 | - | ||
174 | -```js | ||
175 | -import axios from 'axios'; | ||
176 | -//const axios = require('axios'); // legacy way | ||
177 | - | ||
178 | -// Make a request for a user with a given ID | ||
179 | -axios.get('/user?ID=12345') | ||
180 | - .then(function (response) { | ||
181 | - // handle success | ||
182 | - console.log(response); | ||
183 | - }) | ||
184 | - .catch(function (error) { | ||
185 | - // handle error | ||
186 | - console.log(error); | ||
187 | - }) | ||
188 | - .finally(function () { | ||
189 | - // always executed | ||
190 | - }); | ||
191 | - | ||
192 | -// Optionally the request above could also be done as | ||
193 | -axios.get('/user', { | ||
194 | - params: { | ||
195 | - ID: 12345 | ||
196 | - } | ||
197 | - }) | ||
198 | - .then(function (response) { | ||
199 | - console.log(response); | ||
200 | - }) | ||
201 | - .catch(function (error) { | ||
202 | - console.log(error); | ||
203 | - }) | ||
204 | - .finally(function () { | ||
205 | - // always executed | ||
206 | - }); | ||
207 | - | ||
208 | -// Want to use async/await? Add the `async` keyword to your outer function/method. | ||
209 | -async function getUser() { | ||
210 | - try { | ||
211 | - const response = await axios.get('/user?ID=12345'); | ||
212 | - console.log(response); | ||
213 | - } catch (error) { | ||
214 | - console.error(error); | ||
215 | - } | ||
216 | -} | ||
217 | -``` | ||
218 | - | ||
219 | -> **Note**: `async/await` is part of ECMAScript 2017 and is not supported in Internet | ||
220 | -> Explorer and older browsers, so use with caution. | ||
221 | - | ||
222 | -Performing a `POST` request | ||
223 | - | ||
224 | -```js | ||
225 | -axios.post('/user', { | ||
226 | - firstName: 'Fred', | ||
227 | - lastName: 'Flintstone' | ||
228 | - }) | ||
229 | - .then(function (response) { | ||
230 | - console.log(response); | ||
231 | - }) | ||
232 | - .catch(function (error) { | ||
233 | - console.log(error); | ||
234 | - }); | ||
235 | -``` | ||
236 | - | ||
237 | -Performing multiple concurrent requests | ||
238 | - | ||
239 | -```js | ||
240 | -function getUserAccount() { | ||
241 | - return axios.get('/user/12345'); | ||
242 | -} | ||
243 | - | ||
244 | -function getUserPermissions() { | ||
245 | - return axios.get('/user/12345/permissions'); | ||
246 | -} | ||
247 | - | ||
248 | -Promise.all([getUserAccount(), getUserPermissions()]) | ||
249 | - .then(function (results) { | ||
250 | - const acct = results[0]; | ||
251 | - const perm = results[1]; | ||
252 | - }); | ||
253 | -``` | ||
254 | - | ||
255 | -## axios API | ||
256 | - | ||
257 | -Requests can be made by passing the relevant config to `axios`. | ||
258 | - | ||
259 | -##### axios(config) | ||
260 | - | ||
261 | -```js | ||
262 | -// Send a POST request | ||
263 | -axios({ | ||
264 | - method: 'post', | ||
265 | - url: '/user/12345', | ||
266 | - data: { | ||
267 | - firstName: 'Fred', | ||
268 | - lastName: 'Flintstone' | ||
269 | - } | ||
270 | -}); | ||
271 | -``` | ||
272 | - | ||
273 | -```js | ||
274 | -// GET request for remote image in node.js | ||
275 | -axios({ | ||
276 | - method: 'get', | ||
277 | - url: 'https://bit.ly/2mTM3nY', | ||
278 | - responseType: 'stream' | ||
279 | -}) | ||
280 | - .then(function (response) { | ||
281 | - response.data.pipe(fs.createWriteStream('ada_lovelace.jpg')) | ||
282 | - }); | ||
283 | -``` | ||
284 | - | ||
285 | -##### axios(url[, config]) | ||
286 | - | ||
287 | -```js | ||
288 | -// Send a GET request (default method) | ||
289 | -axios('/user/12345'); | ||
290 | -``` | ||
291 | - | ||
292 | -### Request method aliases | ||
293 | - | ||
294 | -For convenience, aliases have been provided for all common request methods. | ||
295 | - | ||
296 | -##### axios.request(config) | ||
297 | -##### axios.get(url[, config]) | ||
298 | -##### axios.delete(url[, config]) | ||
299 | -##### axios.head(url[, config]) | ||
300 | -##### axios.options(url[, config]) | ||
301 | -##### axios.post(url[, data[, config]]) | ||
302 | -##### axios.put(url[, data[, config]]) | ||
303 | -##### axios.patch(url[, data[, config]]) | ||
304 | - | ||
305 | -###### NOTE | ||
306 | -When using the alias methods `url`, `method`, and `data` properties don't need to be specified in config. | ||
307 | - | ||
308 | -### Concurrency (Deprecated) | ||
309 | -Please use `Promise.all` to replace the below functions. | ||
310 | - | ||
311 | -Helper functions for dealing with concurrent requests. | ||
312 | - | ||
313 | -axios.all(iterable) | ||
314 | -axios.spread(callback) | ||
315 | - | ||
316 | -### Creating an instance | ||
317 | - | ||
318 | -You can create a new instance of axios with a custom config. | ||
319 | - | ||
320 | -##### axios.create([config]) | ||
321 | - | ||
322 | -```js | ||
323 | -const instance = axios.create({ | ||
324 | - baseURL: 'https://some-domain.com/api/', | ||
325 | - timeout: 1000, | ||
326 | - headers: {'X-Custom-Header': 'foobar'} | ||
327 | -}); | ||
328 | -``` | ||
329 | - | ||
330 | -### Instance methods | ||
331 | - | ||
332 | -The available instance methods are listed below. The specified config will be merged with the instance config. | ||
333 | - | ||
334 | -##### axios#request(config) | ||
335 | -##### axios#get(url[, config]) | ||
336 | -##### axios#delete(url[, config]) | ||
337 | -##### axios#head(url[, config]) | ||
338 | -##### axios#options(url[, config]) | ||
339 | -##### axios#post(url[, data[, config]]) | ||
340 | -##### axios#put(url[, data[, config]]) | ||
341 | -##### axios#patch(url[, data[, config]]) | ||
342 | -##### axios#getUri([config]) | ||
343 | - | ||
344 | -## Request Config | ||
345 | - | ||
346 | -These are the available config options for making requests. Only the `url` is required. Requests will default to `GET` if `method` is not specified. | ||
347 | - | ||
348 | -```js | ||
349 | -{ | ||
350 | - // `url` is the server URL that will be used for the request | ||
351 | - url: '/user', | ||
352 | - | ||
353 | - // `method` is the request method to be used when making the request | ||
354 | - method: 'get', // default | ||
355 | - | ||
356 | - // `baseURL` will be prepended to `url` unless `url` is absolute. | ||
357 | - // It can be convenient to set `baseURL` for an instance of axios to pass relative URLs | ||
358 | - // to methods of that instance. | ||
359 | - baseURL: 'https://some-domain.com/api/', | ||
360 | - | ||
361 | - // `transformRequest` allows changes to the request data before it is sent to the server | ||
362 | - // This is only applicable for request methods 'PUT', 'POST', 'PATCH' and 'DELETE' | ||
363 | - // The last function in the array must return a string or an instance of Buffer, ArrayBuffer, | ||
364 | - // FormData or Stream | ||
365 | - // You may modify the headers object. | ||
366 | - transformRequest: [function (data, headers) { | ||
367 | - // Do whatever you want to transform the data | ||
368 | - | ||
369 | - return data; | ||
370 | - }], | ||
371 | - | ||
372 | - // `transformResponse` allows changes to the response data to be made before | ||
373 | - // it is passed to then/catch | ||
374 | - transformResponse: [function (data) { | ||
375 | - // Do whatever you want to transform the data | ||
376 | - | ||
377 | - return data; | ||
378 | - }], | ||
379 | - | ||
380 | - // `headers` are custom headers to be sent | ||
381 | - headers: {'X-Requested-With': 'XMLHttpRequest'}, | ||
382 | - | ||
383 | - // `params` are the URL parameters to be sent with the request | ||
384 | - // Must be a plain object or a URLSearchParams object | ||
385 | - params: { | ||
386 | - ID: 12345 | ||
387 | - }, | ||
388 | - | ||
389 | - // `paramsSerializer` is an optional config that allows you to customize serializing `params`. | ||
390 | - paramsSerializer: { | ||
391 | - | ||
392 | - //Custom encoder function which sends key/value pairs in an iterative fashion. | ||
393 | - encode?: (param: string): string => { /* Do custom operations here and return transformed string */ }, | ||
394 | - | ||
395 | - // Custom serializer function for the entire parameter. Allows user to mimic pre 1.x behaviour. | ||
396 | - serialize?: (params: Record<string, any>, options?: ParamsSerializerOptions ), | ||
397 | - | ||
398 | - //Configuration for formatting array indexes in the params. | ||
399 | - indexes: false // Three available options: (1) indexes: null (leads to no brackets), (2) (default) indexes: false (leads to empty brackets), (3) indexes: true (leads to brackets with indexes). | ||
400 | - }, | ||
401 | - | ||
402 | - // `data` is the data to be sent as the request body | ||
403 | - // Only applicable for request methods 'PUT', 'POST', 'DELETE , and 'PATCH' | ||
404 | - // When no `transformRequest` is set, must be of one of the following types: | ||
405 | - // - string, plain object, ArrayBuffer, ArrayBufferView, URLSearchParams | ||
406 | - // - Browser only: FormData, File, Blob | ||
407 | - // - Node only: Stream, Buffer, FormData (form-data package) | ||
408 | - data: { | ||
409 | - firstName: 'Fred' | ||
410 | - }, | ||
411 | - | ||
412 | - // syntax alternative to send data into the body | ||
413 | - // method post | ||
414 | - // only the value is sent, not the key | ||
415 | - data: 'Country=Brasil&City=Belo Horizonte', | ||
416 | - | ||
417 | - // `timeout` specifies the number of milliseconds before the request times out. | ||
418 | - // If the request takes longer than `timeout`, the request will be aborted. | ||
419 | - timeout: 1000, // default is `0` (no timeout) | ||
420 | - | ||
421 | - // `withCredentials` indicates whether or not cross-site Access-Control requests | ||
422 | - // should be made using credentials | ||
423 | - withCredentials: false, // default | ||
424 | - | ||
425 | - // `adapter` allows custom handling of requests which makes testing easier. | ||
426 | - // Return a promise and supply a valid response (see lib/adapters/README.md). | ||
427 | - adapter: function (config) { | ||
428 | - /* ... */ | ||
429 | - }, | ||
430 | - | ||
431 | - // `auth` indicates that HTTP Basic auth should be used, and supplies credentials. | ||
432 | - // This will set an `Authorization` header, overwriting any existing | ||
433 | - // `Authorization` custom headers you have set using `headers`. | ||
434 | - // Please note that only HTTP Basic auth is configurable through this parameter. | ||
435 | - // For Bearer tokens and such, use `Authorization` custom headers instead. | ||
436 | - auth: { | ||
437 | - username: 'janedoe', | ||
438 | - password: 's00pers3cret' | ||
439 | - }, | ||
440 | - | ||
441 | - // `responseType` indicates the type of data that the server will respond with | ||
442 | - // options are: 'arraybuffer', 'document', 'json', 'text', 'stream' | ||
443 | - // browser only: 'blob' | ||
444 | - responseType: 'json', // default | ||
445 | - | ||
446 | - // `responseEncoding` indicates encoding to use for decoding responses (Node.js only) | ||
447 | - // Note: Ignored for `responseType` of 'stream' or client-side requests | ||
448 | - responseEncoding: 'utf8', // default | ||
449 | - | ||
450 | - // `xsrfCookieName` is the name of the cookie to use as a value for xsrf token | ||
451 | - xsrfCookieName: 'XSRF-TOKEN', // default | ||
452 | - | ||
453 | - // `xsrfHeaderName` is the name of the http header that carries the xsrf token value | ||
454 | - xsrfHeaderName: 'X-XSRF-TOKEN', // default | ||
455 | - | ||
456 | - // `undefined` (default) - set XSRF header only for the same origin requests | ||
457 | - withXSRFToken: boolean | undefined | ((config: InternalAxiosRequestConfig) => boolean | undefined), | ||
458 | - | ||
459 | - // `onUploadProgress` allows handling of progress events for uploads | ||
460 | - // browser & node.js | ||
461 | - onUploadProgress: function ({loaded, total, progress, bytes, estimated, rate, upload = true}) { | ||
462 | - // Do whatever you want with the Axios progress event | ||
463 | - }, | ||
464 | - | ||
465 | - // `onDownloadProgress` allows handling of progress events for downloads | ||
466 | - // browser & node.js | ||
467 | - onDownloadProgress: function ({loaded, total, progress, bytes, estimated, rate, download = true}) { | ||
468 | - // Do whatever you want with the Axios progress event | ||
469 | - }, | ||
470 | - | ||
471 | - // `maxContentLength` defines the max size of the http response content in bytes allowed in node.js | ||
472 | - maxContentLength: 2000, | ||
473 | - | ||
474 | - // `maxBodyLength` (Node only option) defines the max size of the http request content in bytes allowed | ||
475 | - maxBodyLength: 2000, | ||
476 | - | ||
477 | - // `validateStatus` defines whether to resolve or reject the promise for a given | ||
478 | - // HTTP response status code. If `validateStatus` returns `true` (or is set to `null` | ||
479 | - // or `undefined`), the promise will be resolved; otherwise, the promise will be | ||
480 | - // rejected. | ||
481 | - validateStatus: function (status) { | ||
482 | - return status >= 200 && status < 300; // default | ||
483 | - }, | ||
484 | - | ||
485 | - // `maxRedirects` defines the maximum number of redirects to follow in node.js. | ||
486 | - // If set to 0, no redirects will be followed. | ||
487 | - maxRedirects: 21, // default | ||
488 | - | ||
489 | - // `beforeRedirect` defines a function that will be called before redirect. | ||
490 | - // Use this to adjust the request options upon redirecting, | ||
491 | - // to inspect the latest response headers, | ||
492 | - // or to cancel the request by throwing an error | ||
493 | - // If maxRedirects is set to 0, `beforeRedirect` is not used. | ||
494 | - beforeRedirect: (options, { headers }) => { | ||
495 | - if (options.hostname === "example.com") { | ||
496 | - options.auth = "user:password"; | ||
497 | - } | ||
498 | - }, | ||
499 | - | ||
500 | - // `socketPath` defines a UNIX Socket to be used in node.js. | ||
501 | - // e.g. '/var/run/docker.sock' to send requests to the docker daemon. | ||
502 | - // Only either `socketPath` or `proxy` can be specified. | ||
503 | - // If both are specified, `socketPath` is used. | ||
504 | - socketPath: null, // default | ||
505 | - | ||
506 | - // `transport` determines the transport method that will be used to make the request. If defined, it will be used. Otherwise, if `maxRedirects` is 0, the default `http` or `https` library will be used, depending on the protocol specified in `protocol`. Otherwise, the `httpFollow` or `httpsFollow` library will be used, again depending on the protocol, which can handle redirects. | ||
507 | - transport: undefined, // default | ||
508 | - | ||
509 | - // `httpAgent` and `httpsAgent` define a custom agent to be used when performing http | ||
510 | - // and https requests, respectively, in node.js. This allows options to be added like | ||
511 | - // `keepAlive` that are not enabled by default. | ||
512 | - httpAgent: new http.Agent({ keepAlive: true }), | ||
513 | - httpsAgent: new https.Agent({ keepAlive: true }), | ||
514 | - | ||
515 | - // `proxy` defines the hostname, port, and protocol of the proxy server. | ||
516 | - // You can also define your proxy using the conventional `http_proxy` and | ||
517 | - // `https_proxy` environment variables. If you are using environment variables | ||
518 | - // for your proxy configuration, you can also define a `no_proxy` environment | ||
519 | - // variable as a comma-separated list of domains that should not be proxied. | ||
520 | - // Use `false` to disable proxies, ignoring environment variables. | ||
521 | - // `auth` indicates that HTTP Basic auth should be used to connect to the proxy, and | ||
522 | - // supplies credentials. | ||
523 | - // This will set an `Proxy-Authorization` header, overwriting any existing | ||
524 | - // `Proxy-Authorization` custom headers you have set using `headers`. | ||
525 | - // If the proxy server uses HTTPS, then you must set the protocol to `https`. | ||
526 | - proxy: { | ||
527 | - protocol: 'https', | ||
528 | - host: '127.0.0.1', | ||
529 | - // hostname: '127.0.0.1' // Takes precedence over 'host' if both are defined | ||
530 | - port: 9000, | ||
531 | - auth: { | ||
532 | - username: 'mikeymike', | ||
533 | - password: 'rapunz3l' | ||
534 | - } | ||
535 | - }, | ||
536 | - | ||
537 | - // `cancelToken` specifies a cancel token that can be used to cancel the request | ||
538 | - // (see Cancellation section below for details) | ||
539 | - cancelToken: new CancelToken(function (cancel) { | ||
540 | - }), | ||
541 | - | ||
542 | - // an alternative way to cancel Axios requests using AbortController | ||
543 | - signal: new AbortController().signal, | ||
544 | - | ||
545 | - // `decompress` indicates whether or not the response body should be decompressed | ||
546 | - // automatically. If set to `true` will also remove the 'content-encoding' header | ||
547 | - // from the responses objects of all decompressed responses | ||
548 | - // - Node only (XHR cannot turn off decompression) | ||
549 | - decompress: true, // default | ||
550 | - | ||
551 | - // `insecureHTTPParser` boolean. | ||
552 | - // Indicates where to use an insecure HTTP parser that accepts invalid HTTP headers. | ||
553 | - // This may allow interoperability with non-conformant HTTP implementations. | ||
554 | - // Using the insecure parser should be avoided. | ||
555 | - // see options https://nodejs.org/dist/latest-v12.x/docs/api/http.html#http_http_request_url_options_callback | ||
556 | - // see also https://nodejs.org/en/blog/vulnerability/february-2020-security-releases/#strict-http-header-parsing-none | ||
557 | - insecureHTTPParser: undefined, // default | ||
558 | - | ||
559 | - // transitional options for backward compatibility that may be removed in the newer versions | ||
560 | - transitional: { | ||
561 | - // silent JSON parsing mode | ||
562 | - // `true` - ignore JSON parsing errors and set response.data to null if parsing failed (old behaviour) | ||
563 | - // `false` - throw SyntaxError if JSON parsing failed (Note: responseType must be set to 'json') | ||
564 | - silentJSONParsing: true, // default value for the current Axios version | ||
565 | - | ||
566 | - // try to parse the response string as JSON even if `responseType` is not 'json' | ||
567 | - forcedJSONParsing: true, | ||
568 | - | ||
569 | - // throw ETIMEDOUT error instead of generic ECONNABORTED on request timeouts | ||
570 | - clarifyTimeoutError: false, | ||
571 | - }, | ||
572 | - | ||
573 | - env: { | ||
574 | - // The FormData class to be used to automatically serialize the payload into a FormData object | ||
575 | - FormData: window?.FormData || global?.FormData | ||
576 | - }, | ||
577 | - | ||
578 | - formSerializer: { | ||
579 | - visitor: (value, key, path, helpers) => {}; // custom visitor function to serialize form values | ||
580 | - dots: boolean; // use dots instead of brackets format | ||
581 | - metaTokens: boolean; // keep special endings like {} in parameter key | ||
582 | - indexes: boolean; // array indexes format null - no brackets, false - empty brackets, true - brackets with indexes | ||
583 | - }, | ||
584 | - | ||
585 | - // http adapter only (node.js) | ||
586 | - maxRate: [ | ||
587 | - 100 * 1024, // 100KB/s upload limit, | ||
588 | - 100 * 1024 // 100KB/s download limit | ||
589 | - ] | ||
590 | -} | ||
591 | -``` | ||
592 | - | ||
593 | -## Response Schema | ||
594 | - | ||
595 | -The response for a request contains the following information. | ||
596 | - | ||
597 | -```js | ||
598 | -{ | ||
599 | - // `data` is the response that was provided by the server | ||
600 | - data: {}, | ||
601 | - | ||
602 | - // `status` is the HTTP status code from the server response | ||
603 | - status: 200, | ||
604 | - | ||
605 | - // `statusText` is the HTTP status message from the server response | ||
606 | - statusText: 'OK', | ||
607 | - | ||
608 | - // `headers` the HTTP headers that the server responded with | ||
609 | - // All header names are lowercase and can be accessed using the bracket notation. | ||
610 | - // Example: `response.headers['content-type']` | ||
611 | - headers: {}, | ||
612 | - | ||
613 | - // `config` is the config that was provided to `axios` for the request | ||
614 | - config: {}, | ||
615 | - | ||
616 | - // `request` is the request that generated this response | ||
617 | - // It is the last ClientRequest instance in node.js (in redirects) | ||
618 | - // and an XMLHttpRequest instance in the browser | ||
619 | - request: {} | ||
620 | -} | ||
621 | -``` | ||
622 | - | ||
623 | -When using `then`, you will receive the response as follows: | ||
624 | - | ||
625 | -```js | ||
626 | -axios.get('/user/12345') | ||
627 | - .then(function (response) { | ||
628 | - console.log(response.data); | ||
629 | - console.log(response.status); | ||
630 | - console.log(response.statusText); | ||
631 | - console.log(response.headers); | ||
632 | - console.log(response.config); | ||
633 | - }); | ||
634 | -``` | ||
635 | - | ||
636 | -When using `catch`, or passing a [rejection callback](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/then) as second parameter of `then`, the response will be available through the `error` object as explained in the [Handling Errors](#handling-errors) section. | ||
637 | - | ||
638 | -## Config Defaults | ||
639 | - | ||
640 | -You can specify config defaults that will be applied to every request. | ||
641 | - | ||
642 | -### Global axios defaults | ||
643 | - | ||
644 | -```js | ||
645 | -axios.defaults.baseURL = 'https://api.example.com'; | ||
646 | - | ||
647 | -// Important: If axios is used with multiple domains, the AUTH_TOKEN will be sent to all of them. | ||
648 | -// See below for an example using Custom instance defaults instead. | ||
649 | -axios.defaults.headers.common['Authorization'] = AUTH_TOKEN; | ||
650 | - | ||
651 | -axios.defaults.headers.post['Content-Type'] = 'application/x-www-form-urlencoded'; | ||
652 | -``` | ||
653 | - | ||
654 | -### Custom instance defaults | ||
655 | - | ||
656 | -```js | ||
657 | -// Set config defaults when creating the instance | ||
658 | -const instance = axios.create({ | ||
659 | - baseURL: 'https://api.example.com' | ||
660 | -}); | ||
661 | - | ||
662 | -// Alter defaults after instance has been created | ||
663 | -instance.defaults.headers.common['Authorization'] = AUTH_TOKEN; | ||
664 | -``` | ||
665 | - | ||
666 | -### Config order of precedence | ||
667 | - | ||
668 | -Config will be merged with an order of precedence. The order is library defaults found in [lib/defaults.js](https://github.com/axios/axios/blob/master/lib/defaults/index.js#L28), then `defaults` property of the instance, and finally `config` argument for the request. The latter will take precedence over the former. Here's an example. | ||
669 | - | ||
670 | -```js | ||
671 | -// Create an instance using the config defaults provided by the library | ||
672 | -// At this point the timeout config value is `0` as is the default for the library | ||
673 | -const instance = axios.create(); | ||
674 | - | ||
675 | -// Override timeout default for the library | ||
676 | -// Now all requests using this instance will wait 2.5 seconds before timing out | ||
677 | -instance.defaults.timeout = 2500; | ||
678 | - | ||
679 | -// Override timeout for this request as it's known to take a long time | ||
680 | -instance.get('/longRequest', { | ||
681 | - timeout: 5000 | ||
682 | -}); | ||
683 | -``` | ||
684 | - | ||
685 | -## Interceptors | ||
686 | - | ||
687 | -You can intercept requests or responses before they are handled by `then` or `catch`. | ||
688 | - | ||
689 | -```js | ||
690 | -// Add a request interceptor | ||
691 | -axios.interceptors.request.use(function (config) { | ||
692 | - // Do something before request is sent | ||
693 | - return config; | ||
694 | - }, function (error) { | ||
695 | - // Do something with request error | ||
696 | - return Promise.reject(error); | ||
697 | - }); | ||
698 | - | ||
699 | -// Add a response interceptor | ||
700 | -axios.interceptors.response.use(function (response) { | ||
701 | - // Any status code that lie within the range of 2xx cause this function to trigger | ||
702 | - // Do something with response data | ||
703 | - return response; | ||
704 | - }, function (error) { | ||
705 | - // Any status codes that falls outside the range of 2xx cause this function to trigger | ||
706 | - // Do something with response error | ||
707 | - return Promise.reject(error); | ||
708 | - }); | ||
709 | -``` | ||
710 | - | ||
711 | -If you need to remove an interceptor later you can. | ||
712 | - | ||
713 | -```js | ||
714 | -const myInterceptor = axios.interceptors.request.use(function () {/*...*/}); | ||
715 | -axios.interceptors.request.eject(myInterceptor); | ||
716 | -``` | ||
717 | - | ||
718 | -You can also clear all interceptors for requests or responses. | ||
719 | -```js | ||
720 | -const instance = axios.create(); | ||
721 | -instance.interceptors.request.use(function () {/*...*/}); | ||
722 | -instance.interceptors.request.clear(); // Removes interceptors from requests | ||
723 | -instance.interceptors.response.use(function () {/*...*/}); | ||
724 | -instance.interceptors.response.clear(); // Removes interceptors from responses | ||
725 | -``` | ||
726 | - | ||
727 | -You can add interceptors to a custom instance of axios. | ||
728 | - | ||
729 | -```js | ||
730 | -const instance = axios.create(); | ||
731 | -instance.interceptors.request.use(function () {/*...*/}); | ||
732 | -``` | ||
733 | - | ||
734 | -When you add request interceptors, they are presumed to be asynchronous by default. This can cause a delay | ||
735 | -in the execution of your axios request when the main thread is blocked (a promise is created under the hood for | ||
736 | -the interceptor and your request gets put on the bottom of the call stack). If your request interceptors are synchronous you can add a flag | ||
737 | -to the options object that will tell axios to run the code synchronously and avoid any delays in request execution. | ||
738 | - | ||
739 | -```js | ||
740 | -axios.interceptors.request.use(function (config) { | ||
741 | - config.headers.test = 'I am only a header!'; | ||
742 | - return config; | ||
743 | -}, null, { synchronous: true }); | ||
744 | -``` | ||
745 | - | ||
746 | -If you want to execute a particular interceptor based on a runtime check, | ||
747 | -you can add a `runWhen` function to the options object. The interceptor will not be executed **if and only if** the return | ||
748 | -of `runWhen` is `false`. The function will be called with the config | ||
749 | -object (don't forget that you can bind your own arguments to it as well.) This can be handy when you have an | ||
750 | -asynchronous request interceptor that only needs to run at certain times. | ||
751 | - | ||
752 | -```js | ||
753 | -function onGetCall(config) { | ||
754 | - return config.method === 'get'; | ||
755 | -} | ||
756 | -axios.interceptors.request.use(function (config) { | ||
757 | - config.headers.test = 'special get headers'; | ||
758 | - return config; | ||
759 | -}, null, { runWhen: onGetCall }); | ||
760 | -``` | ||
761 | - | ||
762 | -### Multiple Interceptors | ||
763 | - | ||
764 | -Given you add multiple response interceptors | ||
765 | -and when the response was fulfilled | ||
766 | -- then each interceptor is executed | ||
767 | -- then they are executed in the order they were added | ||
768 | -- then only the last interceptor's result is returned | ||
769 | -- then every interceptor receives the result of its predecessor | ||
770 | -- and when the fulfillment-interceptor throws | ||
771 | - - then the following fulfillment-interceptor is not called | ||
772 | - - then the following rejection-interceptor is called | ||
773 | - - once caught, another following fulfill-interceptor is called again (just like in a promise chain). | ||
774 | - | ||
775 | -Read [the interceptor tests](./test/specs/interceptors.spec.js) for seeing all this in code. | ||
776 | - | ||
777 | -## Error Types | ||
778 | - | ||
779 | -There are many different axios error messages that can appear that can provide basic information about the specifics of the error and where opportunities may lie in debugging. | ||
780 | - | ||
781 | -The general structure of axios errors is as follows: | ||
782 | -| Property | Definition | | ||
783 | -| -------- | ---------- | | ||
784 | -| message | A quick summary of the error message and the status it failed with. | | ||
785 | -| name | This defines where the error originated from. For axios, it will always be an 'AxiosError'. | | ||
786 | -| stack | Provides the stack trace of the error. | | ||
787 | -| config | An axios config object with specific instance configurations defined by the user from when the request was made | | ||
788 | -| code | Represents an axios identified error. The table below lists out specific definitions for internal axios error. | | ||
789 | -| status | HTTP response status code. See [here](https://en.wikipedia.org/wiki/List_of_HTTP_status_codes) for common HTTP response status code meanings. | ||
790 | - | ||
791 | -Below is a list of potential axios identified error | ||
792 | -| Code | Definition | | ||
793 | -| -------- | ---------- | | ||
794 | -| ERR_BAD_OPTION_VALUE | Invalid or unsupported value provided in axios configuration. | | ||
795 | -| ERR_BAD_OPTION | Invalid option provided in axios configuration. | | ||
796 | -| ECONNABORTED | Request timed out due to exceeding timeout specified in axios configuration. | | ||
797 | -| ETIMEDOUT | Request timed out due to exceeding default axios timelimit. | | ||
798 | -| ERR_NETWORK | Network-related issue. | ||
799 | -| ERR_FR_TOO_MANY_REDIRECTS | Request is redirected too many times; exceeds max redirects specified in axios configuration. | ||
800 | -| ERR_DEPRECATED | Deprecated feature or method used in axios. | ||
801 | -| ERR_BAD_RESPONSE | Response cannot be parsed properly or is in an unexpected format. | ||
802 | -| ERR_BAD_REQUEST | Requested has unexpected format or missing required parameters. | | ||
803 | -| ERR_CANCELED | Feature or method is canceled explicitly by the user. | ||
804 | -| ERR_NOT_SUPPORT | Feature or method not supported in the current axios environment. | ||
805 | -| ERR_INVALID_URL | Invalid URL provided for axios request. | ||
806 | - | ||
807 | -## Handling Errors | ||
808 | - | ||
809 | -the default behavior is to reject every response that returns with a status code that falls out of the range of 2xx and treat it as an error. | ||
810 | - | ||
811 | -```js | ||
812 | -axios.get('/user/12345') | ||
813 | - .catch(function (error) { | ||
814 | - if (error.response) { | ||
815 | - // The request was made and the server responded with a status code | ||
816 | - // that falls out of the range of 2xx | ||
817 | - console.log(error.response.data); | ||
818 | - console.log(error.response.status); | ||
819 | - console.log(error.response.headers); | ||
820 | - } else if (error.request) { | ||
821 | - // The request was made but no response was received | ||
822 | - // `error.request` is an instance of XMLHttpRequest in the browser and an instance of | ||
823 | - // http.ClientRequest in node.js | ||
824 | - console.log(error.request); | ||
825 | - } else { | ||
826 | - // Something happened in setting up the request that triggered an Error | ||
827 | - console.log('Error', error.message); | ||
828 | - } | ||
829 | - console.log(error.config); | ||
830 | - }); | ||
831 | -``` | ||
832 | - | ||
833 | -Using the `validateStatus` config option, you can override the default condition (status >= 200 && status < 300) and define HTTP code(s) that should throw an error. | ||
834 | - | ||
835 | -```js | ||
836 | -axios.get('/user/12345', { | ||
837 | - validateStatus: function (status) { | ||
838 | - return status < 500; // Resolve only if the status code is less than 500 | ||
839 | - } | ||
840 | -}) | ||
841 | -``` | ||
842 | - | ||
843 | -Using `toJSON` you get an object with more information about the HTTP error. | ||
844 | - | ||
845 | -```js | ||
846 | -axios.get('/user/12345') | ||
847 | - .catch(function (error) { | ||
848 | - console.log(error.toJSON()); | ||
849 | - }); | ||
850 | -``` | ||
851 | - | ||
852 | -## Cancellation | ||
853 | - | ||
854 | -### AbortController | ||
855 | - | ||
856 | -Starting from `v0.22.0` Axios supports AbortController to cancel requests in fetch API way: | ||
857 | - | ||
858 | -```js | ||
859 | -const controller = new AbortController(); | ||
860 | - | ||
861 | -axios.get('/foo/bar', { | ||
862 | - signal: controller.signal | ||
863 | -}).then(function(response) { | ||
864 | - //... | ||
865 | -}); | ||
866 | -// cancel the request | ||
867 | -controller.abort() | ||
868 | -``` | ||
869 | - | ||
870 | -### CancelToken `👎deprecated` | ||
871 | - | ||
872 | -You can also cancel a request using a *CancelToken*. | ||
873 | - | ||
874 | -> The axios cancel token API is based on the withdrawn [cancellable promises proposal](https://github.com/tc39/proposal-cancelable-promises). | ||
875 | - | ||
876 | -> This API is deprecated since v0.22.0 and shouldn't be used in new projects | ||
877 | - | ||
878 | -You can create a cancel token using the `CancelToken.source` factory as shown below: | ||
879 | - | ||
880 | -```js | ||
881 | -const CancelToken = axios.CancelToken; | ||
882 | -const source = CancelToken.source(); | ||
883 | - | ||
884 | -axios.get('/user/12345', { | ||
885 | - cancelToken: source.token | ||
886 | -}).catch(function (thrown) { | ||
887 | - if (axios.isCancel(thrown)) { | ||
888 | - console.log('Request canceled', thrown.message); | ||
889 | - } else { | ||
890 | - // handle error | ||
891 | - } | ||
892 | -}); | ||
893 | - | ||
894 | -axios.post('/user/12345', { | ||
895 | - name: 'new name' | ||
896 | -}, { | ||
897 | - cancelToken: source.token | ||
898 | -}) | ||
899 | - | ||
900 | -// cancel the request (the message parameter is optional) | ||
901 | -source.cancel('Operation canceled by the user.'); | ||
902 | -``` | ||
903 | - | ||
904 | -You can also create a cancel token by passing an executor function to the `CancelToken` constructor: | ||
905 | - | ||
906 | -```js | ||
907 | -const CancelToken = axios.CancelToken; | ||
908 | -let cancel; | ||
909 | - | ||
910 | -axios.get('/user/12345', { | ||
911 | - cancelToken: new CancelToken(function executor(c) { | ||
912 | - // An executor function receives a cancel function as a parameter | ||
913 | - cancel = c; | ||
914 | - }) | ||
915 | -}); | ||
916 | - | ||
917 | -// cancel the request | ||
918 | -cancel(); | ||
919 | -``` | ||
920 | - | ||
921 | -> **Note:** you can cancel several requests with the same cancel token/abort controller. | ||
922 | -> If a cancellation token is already cancelled at the moment of starting an Axios request, then the request is cancelled immediately, without any attempts to make a real request. | ||
923 | - | ||
924 | -> During the transition period, you can use both cancellation APIs, even for the same request: | ||
925 | - | ||
926 | -## Using `application/x-www-form-urlencoded` format | ||
927 | - | ||
928 | -### URLSearchParams | ||
929 | - | ||
930 | -By default, axios serializes JavaScript objects to `JSON`. To send data in the [`application/x-www-form-urlencoded` format](https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods/POST) instead, you can use the [`URLSearchParams`](https://developer.mozilla.org/en-US/docs/Web/API/URLSearchParams) API, which is [supported](http://www.caniuse.com/#feat=urlsearchparams) in the vast majority of browsers,and [ Node](https://nodejs.org/api/url.html#url_class_urlsearchparams) starting with v10 (released in 2018). | ||
931 | - | ||
932 | -```js | ||
933 | -const params = new URLSearchParams({ foo: 'bar' }); | ||
934 | -params.append('extraparam', 'value'); | ||
935 | -axios.post('/foo', params); | ||
936 | -``` | ||
937 | - | ||
938 | -### Query string (Older browsers) | ||
939 | - | ||
940 | -For compatibility with very old browsers, there is a [polyfill](https://github.com/WebReflection/url-search-params) available (make sure to polyfill the global environment). | ||
941 | - | ||
942 | -Alternatively, you can encode data using the [`qs`](https://github.com/ljharb/qs) library: | ||
943 | - | ||
944 | -```js | ||
945 | -const qs = require('qs'); | ||
946 | -axios.post('/foo', qs.stringify({ 'bar': 123 })); | ||
947 | -``` | ||
948 | - | ||
949 | -Or in another way (ES6), | ||
950 | - | ||
951 | -```js | ||
952 | -import qs from 'qs'; | ||
953 | -const data = { 'bar': 123 }; | ||
954 | -const options = { | ||
955 | - method: 'POST', | ||
956 | - headers: { 'content-type': 'application/x-www-form-urlencoded' }, | ||
957 | - data: qs.stringify(data), | ||
958 | - url, | ||
959 | -}; | ||
960 | -axios(options); | ||
961 | -``` | ||
962 | - | ||
963 | -### Older Node.js versions | ||
964 | - | ||
965 | -For older Node.js engines, you can use the [`querystring`](https://nodejs.org/api/querystring.html) module as follows: | ||
966 | - | ||
967 | -```js | ||
968 | -const querystring = require('querystring'); | ||
969 | -axios.post('https://something.com/', querystring.stringify({ foo: 'bar' })); | ||
970 | -``` | ||
971 | - | ||
972 | -You can also use the [`qs`](https://github.com/ljharb/qs) library. | ||
973 | - | ||
974 | -> **Note**: The `qs` library is preferable if you need to stringify nested objects, as the `querystring` method has [known issues](https://github.com/nodejs/node-v0.x-archive/issues/1665) with that use case. | ||
975 | - | ||
976 | -### 🆕 Automatic serialization to URLSearchParams | ||
977 | - | ||
978 | -Axios will automatically serialize the data object to urlencoded format if the content-type header is set to "application/x-www-form-urlencoded". | ||
979 | - | ||
980 | -```js | ||
981 | -const data = { | ||
982 | - x: 1, | ||
983 | - arr: [1, 2, 3], | ||
984 | - arr2: [1, [2], 3], | ||
985 | - users: [{name: 'Peter', surname: 'Griffin'}, {name: 'Thomas', surname: 'Anderson'}], | ||
986 | -}; | ||
987 | - | ||
988 | -await axios.postForm('https://postman-echo.com/post', data, | ||
989 | - {headers: {'content-type': 'application/x-www-form-urlencoded'}} | ||
990 | -); | ||
991 | -``` | ||
992 | - | ||
993 | -The server will handle it as: | ||
994 | - | ||
995 | -```js | ||
996 | - { | ||
997 | - x: '1', | ||
998 | - 'arr[]': [ '1', '2', '3' ], | ||
999 | - 'arr2[0]': '1', | ||
1000 | - 'arr2[1][0]': '2', | ||
1001 | - 'arr2[2]': '3', | ||
1002 | - 'arr3[]': [ '1', '2', '3' ], | ||
1003 | - 'users[0][name]': 'Peter', | ||
1004 | - 'users[0][surname]': 'griffin', | ||
1005 | - 'users[1][name]': 'Thomas', | ||
1006 | - 'users[1][surname]': 'Anderson' | ||
1007 | - } | ||
1008 | -```` | ||
1009 | - | ||
1010 | -If your backend body-parser (like `body-parser` of `express.js`) supports nested objects decoding, you will get the same object on the server-side automatically | ||
1011 | - | ||
1012 | -```js | ||
1013 | - var app = express(); | ||
1014 | - | ||
1015 | - app.use(bodyParser.urlencoded({ extended: true })); // support encoded bodies | ||
1016 | - | ||
1017 | - app.post('/', function (req, res, next) { | ||
1018 | - // echo body as JSON | ||
1019 | - res.send(JSON.stringify(req.body)); | ||
1020 | - }); | ||
1021 | - | ||
1022 | - server = app.listen(3000); | ||
1023 | -``` | ||
1024 | - | ||
1025 | -## Using `multipart/form-data` format | ||
1026 | - | ||
1027 | -### FormData | ||
1028 | - | ||
1029 | -To send the data as a `multipart/formdata` you need to pass a formData instance as a payload. | ||
1030 | -Setting the `Content-Type` header is not required as Axios guesses it based on the payload type. | ||
1031 | - | ||
1032 | -```js | ||
1033 | -const formData = new FormData(); | ||
1034 | -formData.append('foo', 'bar'); | ||
1035 | - | ||
1036 | -axios.post('https://httpbin.org/post', formData); | ||
1037 | -``` | ||
1038 | - | ||
1039 | -In node.js, you can use the [`form-data`](https://github.com/form-data/form-data) library as follows: | ||
1040 | - | ||
1041 | -```js | ||
1042 | -const FormData = require('form-data'); | ||
1043 | - | ||
1044 | -const form = new FormData(); | ||
1045 | -form.append('my_field', 'my value'); | ||
1046 | -form.append('my_buffer', new Buffer(10)); | ||
1047 | -form.append('my_file', fs.createReadStream('/foo/bar.jpg')); | ||
1048 | - | ||
1049 | -axios.post('https://example.com', form) | ||
1050 | -``` | ||
1051 | - | ||
1052 | -### 🆕 Automatic serialization to FormData | ||
1053 | - | ||
1054 | -Starting from `v0.27.0`, Axios supports automatic object serialization to a FormData object if the request `Content-Type` | ||
1055 | -header is set to `multipart/form-data`. | ||
1056 | - | ||
1057 | -The following request will submit the data in a FormData format (Browser & Node.js): | ||
1058 | - | ||
1059 | -```js | ||
1060 | -import axios from 'axios'; | ||
1061 | - | ||
1062 | -axios.post('https://httpbin.org/post', {x: 1}, { | ||
1063 | - headers: { | ||
1064 | - 'Content-Type': 'multipart/form-data' | ||
1065 | - } | ||
1066 | -}).then(({data}) => console.log(data)); | ||
1067 | -``` | ||
1068 | - | ||
1069 | -In the `node.js` build, the ([`form-data`](https://github.com/form-data/form-data)) polyfill is used by default. | ||
1070 | - | ||
1071 | -You can overload the FormData class by setting the `env.FormData` config variable, | ||
1072 | -but you probably won't need it in most cases: | ||
1073 | - | ||
1074 | -```js | ||
1075 | -const axios = require('axios'); | ||
1076 | -var FormData = require('form-data'); | ||
1077 | - | ||
1078 | -axios.post('https://httpbin.org/post', {x: 1, buf: new Buffer(10)}, { | ||
1079 | - headers: { | ||
1080 | - 'Content-Type': 'multipart/form-data' | ||
1081 | - } | ||
1082 | -}).then(({data}) => console.log(data)); | ||
1083 | -``` | ||
1084 | - | ||
1085 | -Axios FormData serializer supports some special endings to perform the following operations: | ||
1086 | - | ||
1087 | -- `{}` - serialize the value with JSON.stringify | ||
1088 | -- `[]` - unwrap the array-like object as separate fields with the same key | ||
1089 | - | ||
1090 | -> **Note**: unwrap/expand operation will be used by default on arrays and FileList objects | ||
1091 | - | ||
1092 | -FormData serializer supports additional options via `config.formSerializer: object` property to handle rare cases: | ||
1093 | - | ||
1094 | -- `visitor: Function` - user-defined visitor function that will be called recursively to serialize the data object | ||
1095 | -to a `FormData` object by following custom rules. | ||
1096 | - | ||
1097 | -- `dots: boolean = false` - use dot notation instead of brackets to serialize arrays and objects; | ||
1098 | - | ||
1099 | -- `metaTokens: boolean = true` - add the special ending (e.g `user{}: '{"name": "John"}'`) in the FormData key. | ||
1100 | -The back-end body-parser could potentially use this meta-information to automatically parse the value as JSON. | ||
1101 | - | ||
1102 | -- `indexes: null|false|true = false` - controls how indexes will be added to unwrapped keys of `flat` array-like objects | ||
1103 | - | ||
1104 | - - `null` - don't add brackets (`arr: 1`, `arr: 2`, `arr: 3`) | ||
1105 | - - `false`(default) - add empty brackets (`arr[]: 1`, `arr[]: 2`, `arr[]: 3`) | ||
1106 | - - `true` - add brackets with indexes (`arr[0]: 1`, `arr[1]: 2`, `arr[2]: 3`) | ||
1107 | - | ||
1108 | -Let's say we have an object like this one: | ||
1109 | - | ||
1110 | -```js | ||
1111 | -const obj = { | ||
1112 | - x: 1, | ||
1113 | - arr: [1, 2, 3], | ||
1114 | - arr2: [1, [2], 3], | ||
1115 | - users: [{name: 'Peter', surname: 'Griffin'}, {name: 'Thomas', surname: 'Anderson'}], | ||
1116 | - 'obj2{}': [{x:1}] | ||
1117 | -}; | ||
1118 | -``` | ||
1119 | - | ||
1120 | -The following steps will be executed by the Axios serializer internally: | ||
1121 | - | ||
1122 | -```js | ||
1123 | -const formData = new FormData(); | ||
1124 | -formData.append('x', '1'); | ||
1125 | -formData.append('arr[]', '1'); | ||
1126 | -formData.append('arr[]', '2'); | ||
1127 | -formData.append('arr[]', '3'); | ||
1128 | -formData.append('arr2[0]', '1'); | ||
1129 | -formData.append('arr2[1][0]', '2'); | ||
1130 | -formData.append('arr2[2]', '3'); | ||
1131 | -formData.append('users[0][name]', 'Peter'); | ||
1132 | -formData.append('users[0][surname]', 'Griffin'); | ||
1133 | -formData.append('users[1][name]', 'Thomas'); | ||
1134 | -formData.append('users[1][surname]', 'Anderson'); | ||
1135 | -formData.append('obj2{}', '[{"x":1}]'); | ||
1136 | -``` | ||
1137 | - | ||
1138 | -Axios supports the following shortcut methods: `postForm`, `putForm`, `patchForm` | ||
1139 | -which are just the corresponding http methods with the `Content-Type` header preset to `multipart/form-data`. | ||
1140 | - | ||
1141 | -## Files Posting | ||
1142 | - | ||
1143 | -You can easily submit a single file: | ||
1144 | - | ||
1145 | -```js | ||
1146 | -await axios.postForm('https://httpbin.org/post', { | ||
1147 | - 'myVar' : 'foo', | ||
1148 | - 'file': document.querySelector('#fileInput').files[0] | ||
1149 | -}); | ||
1150 | -``` | ||
1151 | - | ||
1152 | -or multiple files as `multipart/form-data`: | ||
1153 | - | ||
1154 | -```js | ||
1155 | -await axios.postForm('https://httpbin.org/post', { | ||
1156 | - 'files[]': document.querySelector('#fileInput').files | ||
1157 | -}); | ||
1158 | -``` | ||
1159 | - | ||
1160 | -`FileList` object can be passed directly: | ||
1161 | - | ||
1162 | -```js | ||
1163 | -await axios.postForm('https://httpbin.org/post', document.querySelector('#fileInput').files) | ||
1164 | -``` | ||
1165 | - | ||
1166 | -All files will be sent with the same field names: `files[]`. | ||
1167 | - | ||
1168 | -## 🆕 HTML Form Posting (browser) | ||
1169 | - | ||
1170 | -Pass HTML Form element as a payload to submit it as `multipart/form-data` content. | ||
1171 | - | ||
1172 | -```js | ||
1173 | -await axios.postForm('https://httpbin.org/post', document.querySelector('#htmlForm')); | ||
1174 | -``` | ||
1175 | - | ||
1176 | -`FormData` and `HTMLForm` objects can also be posted as `JSON` by explicitly setting the `Content-Type` header to `application/json`: | ||
1177 | - | ||
1178 | -```js | ||
1179 | -await axios.post('https://httpbin.org/post', document.querySelector('#htmlForm'), { | ||
1180 | - headers: { | ||
1181 | - 'Content-Type': 'application/json' | ||
1182 | - } | ||
1183 | -}) | ||
1184 | -``` | ||
1185 | - | ||
1186 | -For example, the Form | ||
1187 | - | ||
1188 | -```html | ||
1189 | -<form id="form"> | ||
1190 | - <input type="text" name="foo" value="1"> | ||
1191 | - <input type="text" name="deep.prop" value="2"> | ||
1192 | - <input type="text" name="deep prop spaced" value="3"> | ||
1193 | - <input type="text" name="baz" value="4"> | ||
1194 | - <input type="text" name="baz" value="5"> | ||
1195 | - | ||
1196 | - <select name="user.age"> | ||
1197 | - <option value="value1">Value 1</option> | ||
1198 | - <option value="value2" selected>Value 2</option> | ||
1199 | - <option value="value3">Value 3</option> | ||
1200 | - </select> | ||
1201 | - | ||
1202 | - <input type="submit" value="Save"> | ||
1203 | -</form> | ||
1204 | -``` | ||
1205 | - | ||
1206 | -will be submitted as the following JSON object: | ||
1207 | - | ||
1208 | -```js | ||
1209 | -{ | ||
1210 | - "foo": "1", | ||
1211 | - "deep": { | ||
1212 | - "prop": { | ||
1213 | - "spaced": "3" | ||
1214 | - } | ||
1215 | - }, | ||
1216 | - "baz": [ | ||
1217 | - "4", | ||
1218 | - "5" | ||
1219 | - ], | ||
1220 | - "user": { | ||
1221 | - "age": "value2" | ||
1222 | - } | ||
1223 | -} | ||
1224 | -```` | ||
1225 | - | ||
1226 | -Sending `Blobs`/`Files` as JSON (`base64`) is not currently supported. | ||
1227 | - | ||
1228 | -## 🆕 Progress capturing | ||
1229 | - | ||
1230 | -Axios supports both browser and node environments to capture request upload/download progress. | ||
1231 | - | ||
1232 | -```js | ||
1233 | -await axios.post(url, data, { | ||
1234 | - onUploadProgress: function (axiosProgressEvent) { | ||
1235 | - /*{ | ||
1236 | - loaded: number; | ||
1237 | - total?: number; | ||
1238 | - progress?: number; // in range [0..1] | ||
1239 | - bytes: number; // how many bytes have been transferred since the last trigger (delta) | ||
1240 | - estimated?: number; // estimated time in seconds | ||
1241 | - rate?: number; // upload speed in bytes | ||
1242 | - upload: true; // upload sign | ||
1243 | - }*/ | ||
1244 | - }, | ||
1245 | - | ||
1246 | - onDownloadProgress: function (axiosProgressEvent) { | ||
1247 | - /*{ | ||
1248 | - loaded: number; | ||
1249 | - total?: number; | ||
1250 | - progress?: number; | ||
1251 | - bytes: number; | ||
1252 | - estimated?: number; | ||
1253 | - rate?: number; // download speed in bytes | ||
1254 | - download: true; // download sign | ||
1255 | - }*/ | ||
1256 | - } | ||
1257 | -}); | ||
1258 | -``` | ||
1259 | - | ||
1260 | -You can also track stream upload/download progress in node.js: | ||
1261 | - | ||
1262 | -```js | ||
1263 | -const {data} = await axios.post(SERVER_URL, readableStream, { | ||
1264 | - onUploadProgress: ({progress}) => { | ||
1265 | - console.log((progress * 100).toFixed(2)); | ||
1266 | - }, | ||
1267 | - | ||
1268 | - headers: { | ||
1269 | - 'Content-Length': contentLength | ||
1270 | - }, | ||
1271 | - | ||
1272 | - maxRedirects: 0 // avoid buffering the entire stream | ||
1273 | -}); | ||
1274 | -```` | ||
1275 | - | ||
1276 | -> **Note:** | ||
1277 | -> Capturing FormData upload progress is not currently supported in node.js environments. | ||
1278 | - | ||
1279 | -> **⚠️ Warning** | ||
1280 | -> It is recommended to disable redirects by setting maxRedirects: 0 to upload the stream in the **node.js** environment, | ||
1281 | -> as follow-redirects package will buffer the entire stream in RAM without following the "backpressure" algorithm. | ||
1282 | - | ||
1283 | - | ||
1284 | -## 🆕 Rate limiting | ||
1285 | - | ||
1286 | -Download and upload rate limits can only be set for the http adapter (node.js): | ||
1287 | - | ||
1288 | -```js | ||
1289 | -const {data} = await axios.post(LOCAL_SERVER_URL, myBuffer, { | ||
1290 | - onUploadProgress: ({progress, rate}) => { | ||
1291 | - console.log(`Upload [${(progress*100).toFixed(2)}%]: ${(rate / 1024).toFixed(2)}KB/s`) | ||
1292 | - }, | ||
1293 | - | ||
1294 | - maxRate: [100 * 1024], // 100KB/s limit | ||
1295 | -}); | ||
1296 | -``` | ||
1297 | - | ||
1298 | -## 🆕 AxiosHeaders | ||
1299 | - | ||
1300 | -Axios has its own `AxiosHeaders` class to manipulate headers using a Map-like API that guarantees caseless work. | ||
1301 | -Although HTTP is case-insensitive in headers, Axios will retain the case of the original header for stylistic reasons | ||
1302 | -and for a workaround when servers mistakenly consider the header's case. | ||
1303 | -The old approach of directly manipulating headers object is still available, but deprecated and not recommended for future usage. | ||
1304 | - | ||
1305 | -### Working with headers | ||
1306 | - | ||
1307 | -An AxiosHeaders object instance can contain different types of internal values. that control setting and merging logic. | ||
1308 | -The final headers object with string values is obtained by Axios by calling the `toJSON` method. | ||
1309 | - | ||
1310 | -> Note: By JSON here we mean an object consisting only of string values intended to be sent over the network. | ||
1311 | - | ||
1312 | -The header value can be one of the following types: | ||
1313 | -- `string` - normal string value that will be sent to the server | ||
1314 | -- `null` - skip header when rendering to JSON | ||
1315 | -- `false` - skip header when rendering to JSON, additionally indicates that `set` method must be called with `rewrite` option set to `true` | ||
1316 | - to overwrite this value (Axios uses this internally to allow users to opt out of installing certain headers like `User-Agent` or `Content-Type`) | ||
1317 | -- `undefined` - value is not set | ||
1318 | - | ||
1319 | -> Note: The header value is considered set if it is not equal to undefined. | ||
1320 | - | ||
1321 | -The headers object is always initialized inside interceptors and transformers: | ||
1322 | - | ||
1323 | -```ts | ||
1324 | - axios.interceptors.request.use((request: InternalAxiosRequestConfig) => { | ||
1325 | - request.headers.set('My-header', 'value'); | ||
1326 | - | ||
1327 | - request.headers.set({ | ||
1328 | - "My-set-header1": "my-set-value1", | ||
1329 | - "My-set-header2": "my-set-value2" | ||
1330 | - }); | ||
1331 | - | ||
1332 | - request.headers.set('User-Agent', false); // disable subsequent setting the header by Axios | ||
1333 | - | ||
1334 | - request.headers.setContentType('text/plain'); | ||
1335 | - | ||
1336 | - request.headers['My-set-header2'] = 'newValue' // direct access is deprecated | ||
1337 | - | ||
1338 | - return request; | ||
1339 | - } | ||
1340 | - ); | ||
1341 | -```` | ||
1342 | - | ||
1343 | -You can iterate over an `AxiosHeaders` instance using a `for...of` statement: | ||
1344 | - | ||
1345 | -````js | ||
1346 | -const headers = new AxiosHeaders({ | ||
1347 | - foo: '1', | ||
1348 | - bar: '2', | ||
1349 | - baz: '3' | ||
1350 | -}); | ||
1351 | - | ||
1352 | -for(const [header, value] of headers) { | ||
1353 | - console.log(header, value); | ||
1354 | -} | ||
1355 | - | ||
1356 | -// foo 1 | ||
1357 | -// bar 2 | ||
1358 | -// baz 3 | ||
1359 | -```` | ||
1360 | - | ||
1361 | -### new AxiosHeaders(headers?) | ||
1362 | - | ||
1363 | -Constructs a new `AxiosHeaders` instance. | ||
1364 | - | ||
1365 | -``` | ||
1366 | -constructor(headers?: RawAxiosHeaders | AxiosHeaders | string); | ||
1367 | -``` | ||
1368 | - | ||
1369 | -If the headers object is a string, it will be parsed as RAW HTTP headers. | ||
1370 | - | ||
1371 | -````js | ||
1372 | -const headers = new AxiosHeaders(` | ||
1373 | -Host: www.bing.com | ||
1374 | -User-Agent: curl/7.54.0 | ||
1375 | -Accept: */*`); | ||
1376 | - | ||
1377 | -console.log(headers); | ||
1378 | - | ||
1379 | -// Object [AxiosHeaders] { | ||
1380 | -// host: 'www.bing.com', | ||
1381 | -// 'user-agent': 'curl/7.54.0', | ||
1382 | -// accept: '*/*' | ||
1383 | -// } | ||
1384 | -```` | ||
1385 | - | ||
1386 | -### AxiosHeaders#set | ||
1387 | - | ||
1388 | -```ts | ||
1389 | -set(headerName, value: Axios, rewrite?: boolean); | ||
1390 | -set(headerName, value, rewrite?: (this: AxiosHeaders, value: string, name: string, headers: RawAxiosHeaders) => boolean); | ||
1391 | -set(headers?: RawAxiosHeaders | AxiosHeaders | string, rewrite?: boolean); | ||
1392 | -``` | ||
1393 | - | ||
1394 | -The `rewrite` argument controls the overwriting behavior: | ||
1395 | -- `false` - do not overwrite if header's value is set (is not `undefined`) | ||
1396 | -- `undefined` (default) - overwrite the header unless its value is set to `false` | ||
1397 | -- `true` - rewrite anyway | ||
1398 | - | ||
1399 | -The option can also accept a user-defined function that determines whether the value should be overwritten or not. | ||
1400 | - | ||
1401 | -Returns `this`. | ||
1402 | - | ||
1403 | -### AxiosHeaders#get(header) | ||
1404 | - | ||
1405 | -``` | ||
1406 | - get(headerName: string, matcher?: true | AxiosHeaderMatcher): AxiosHeaderValue; | ||
1407 | - get(headerName: string, parser: RegExp): RegExpExecArray | null; | ||
1408 | -```` | ||
1409 | - | ||
1410 | -Returns the internal value of the header. It can take an extra argument to parse the header's value with `RegExp.exec`, | ||
1411 | -matcher function or internal key-value parser. | ||
1412 | - | ||
1413 | -```ts | ||
1414 | -const headers = new AxiosHeaders({ | ||
1415 | - 'Content-Type': 'multipart/form-data; boundary=Asrf456BGe4h' | ||
1416 | -}); | ||
1417 | - | ||
1418 | -console.log(headers.get('Content-Type')); | ||
1419 | -// multipart/form-data; boundary=Asrf456BGe4h | ||
1420 | - | ||
1421 | -console.log(headers.get('Content-Type', true)); // parse key-value pairs from a string separated with \s,;= delimiters: | ||
1422 | -// [Object: null prototype] { | ||
1423 | -// 'multipart/form-data': undefined, | ||
1424 | -// boundary: 'Asrf456BGe4h' | ||
1425 | -// } | ||
1426 | - | ||
1427 | - | ||
1428 | -console.log(headers.get('Content-Type', (value, name, headers) => { | ||
1429 | - return String(value).replace(/a/g, 'ZZZ'); | ||
1430 | -})); | ||
1431 | -// multipZZZrt/form-dZZZtZZZ; boundZZZry=Asrf456BGe4h | ||
1432 | - | ||
1433 | -console.log(headers.get('Content-Type', /boundary=(\w+)/)?.[0]); | ||
1434 | -// boundary=Asrf456BGe4h | ||
1435 | - | ||
1436 | -``` | ||
1437 | - | ||
1438 | -Returns the value of the header. | ||
1439 | - | ||
1440 | -### AxiosHeaders#has(header, matcher?) | ||
1441 | - | ||
1442 | -``` | ||
1443 | -has(header: string, matcher?: AxiosHeaderMatcher): boolean; | ||
1444 | -``` | ||
1445 | - | ||
1446 | -Returns `true` if the header is set (has no `undefined` value). | ||
1447 | - | ||
1448 | -### AxiosHeaders#delete(header, matcher?) | ||
1449 | - | ||
1450 | -``` | ||
1451 | -delete(header: string | string[], matcher?: AxiosHeaderMatcher): boolean; | ||
1452 | -``` | ||
1453 | - | ||
1454 | -Returns `true` if at least one header has been removed. | ||
1455 | - | ||
1456 | -### AxiosHeaders#clear(matcher?) | ||
1457 | - | ||
1458 | -``` | ||
1459 | -clear(matcher?: AxiosHeaderMatcher): boolean; | ||
1460 | -``` | ||
1461 | - | ||
1462 | -Removes all headers. | ||
1463 | -Unlike the `delete` method matcher, this optional matcher will be used to match against the header name rather than the value. | ||
1464 | - | ||
1465 | -```ts | ||
1466 | -const headers = new AxiosHeaders({ | ||
1467 | - 'foo': '1', | ||
1468 | - 'x-foo': '2', | ||
1469 | - 'x-bar': '3', | ||
1470 | -}); | ||
1471 | - | ||
1472 | -console.log(headers.clear(/^x-/)); // true | ||
1473 | - | ||
1474 | -console.log(headers.toJSON()); // [Object: null prototype] { foo: '1' } | ||
1475 | -``` | ||
1476 | - | ||
1477 | -Returns `true` if at least one header has been cleared. | ||
1478 | - | ||
1479 | -### AxiosHeaders#normalize(format); | ||
1480 | - | ||
1481 | -If the headers object was changed directly, it can have duplicates with the same name but in different cases. | ||
1482 | -This method normalizes the headers object by combining duplicate keys into one. | ||
1483 | -Axios uses this method internally after calling each interceptor. | ||
1484 | -Set `format` to true for converting headers name to lowercase and capitalize the initial letters (`cOntEnt-type` => `Content-Type`) | ||
1485 | - | ||
1486 | -```js | ||
1487 | -const headers = new AxiosHeaders({ | ||
1488 | - 'foo': '1', | ||
1489 | -}); | ||
1490 | - | ||
1491 | -headers.Foo = '2'; | ||
1492 | -headers.FOO = '3'; | ||
1493 | - | ||
1494 | -console.log(headers.toJSON()); // [Object: null prototype] { foo: '1', Foo: '2', FOO: '3' } | ||
1495 | -console.log(headers.normalize().toJSON()); // [Object: null prototype] { foo: '3' } | ||
1496 | -console.log(headers.normalize(true).toJSON()); // [Object: null prototype] { Foo: '3' } | ||
1497 | -``` | ||
1498 | - | ||
1499 | -Returns `this`. | ||
1500 | - | ||
1501 | -### AxiosHeaders#concat(...targets) | ||
1502 | - | ||
1503 | -``` | ||
1504 | -concat(...targets: Array<AxiosHeaders | RawAxiosHeaders | string | undefined | null>): AxiosHeaders; | ||
1505 | -``` | ||
1506 | - | ||
1507 | -Merges the instance with targets into a new `AxiosHeaders` instance. If the target is a string, it will be parsed as RAW HTTP headers. | ||
1508 | - | ||
1509 | -Returns a new `AxiosHeaders` instance. | ||
1510 | - | ||
1511 | -### AxiosHeaders#toJSON(asStrings?) | ||
1512 | - | ||
1513 | -```` | ||
1514 | -toJSON(asStrings?: boolean): RawAxiosHeaders; | ||
1515 | -```` | ||
1516 | - | ||
1517 | -Resolve all internal headers values into a new null prototype object. | ||
1518 | -Set `asStrings` to true to resolve arrays as a string containing all elements, separated by commas. | ||
1519 | - | ||
1520 | -### AxiosHeaders.from(thing?) | ||
1521 | - | ||
1522 | -```` | ||
1523 | -from(thing?: AxiosHeaders | RawAxiosHeaders | string): AxiosHeaders; | ||
1524 | -```` | ||
1525 | - | ||
1526 | -Returns a new `AxiosHeaders` instance created from the raw headers passed in, | ||
1527 | -or simply returns the given headers object if it's an `AxiosHeaders` instance. | ||
1528 | - | ||
1529 | -### AxiosHeaders.concat(...targets) | ||
1530 | - | ||
1531 | -```` | ||
1532 | -concat(...targets: Array<AxiosHeaders | RawAxiosHeaders | string | undefined | null>): AxiosHeaders; | ||
1533 | -```` | ||
1534 | - | ||
1535 | -Returns a new `AxiosHeaders` instance created by merging the target objects. | ||
1536 | - | ||
1537 | -### Shortcuts | ||
1538 | - | ||
1539 | -The following shortcuts are available: | ||
1540 | - | ||
1541 | -- `setContentType`, `getContentType`, `hasContentType` | ||
1542 | - | ||
1543 | -- `setContentLength`, `getContentLength`, `hasContentLength` | ||
1544 | - | ||
1545 | -- `setAccept`, `getAccept`, `hasAccept` | ||
1546 | - | ||
1547 | -- `setUserAgent`, `getUserAgent`, `hasUserAgent` | ||
1548 | - | ||
1549 | -- `setContentEncoding`, `getContentEncoding`, `hasContentEncoding` | ||
1550 | - | ||
1551 | - | ||
1552 | -## Semver | ||
1553 | - | ||
1554 | -Until axios reaches a `1.0` release, breaking changes will be released with a new minor version. For example `0.5.1`, and `0.5.4` will have the same API, but `0.6.0` will have breaking changes. | ||
1555 | - | ||
1556 | -## Promises | ||
1557 | - | ||
1558 | -axios depends on a native ES6 Promise implementation to be [supported](https://caniuse.com/promises). | ||
1559 | -If your environment doesn't support ES6 Promises, you can [polyfill](https://github.com/jakearchibald/es6-promise). | ||
1560 | - | ||
1561 | -## TypeScript | ||
1562 | - | ||
1563 | -axios includes [TypeScript](https://typescriptlang.org) definitions and a type guard for axios errors. | ||
1564 | - | ||
1565 | -```typescript | ||
1566 | -let user: User = null; | ||
1567 | -try { | ||
1568 | - const { data } = await axios.get('/user?ID=12345'); | ||
1569 | - user = data.userDetails; | ||
1570 | -} catch (error) { | ||
1571 | - if (axios.isAxiosError(error)) { | ||
1572 | - handleAxiosError(error); | ||
1573 | - } else { | ||
1574 | - handleUnexpectedError(error); | ||
1575 | - } | ||
1576 | -} | ||
1577 | -``` | ||
1578 | - | ||
1579 | -Because axios dual publishes with an ESM default export and a CJS `module.exports`, there are some caveats. | ||
1580 | -The recommended setting is to use `"moduleResolution": "node16"` (this is implied by `"module": "node16"`). Note that this requires TypeScript 4.7 or greater. | ||
1581 | -If use ESM, your settings should be fine. | ||
1582 | -If you compile TypeScript to CJS and you can’t use `"moduleResolution": "node 16"`, you have to enable `esModuleInterop`. | ||
1583 | -If you use TypeScript to type check CJS JavaScript code, your only option is to use `"moduleResolution": "node16"`. | ||
1584 | - | ||
1585 | -## Online one-click setup | ||
1586 | - | ||
1587 | -You can use Gitpod, an online IDE(which is free for Open Source) for contributing or running the examples online. | ||
1588 | - | ||
1589 | -[![Open in Gitpod](https://gitpod.io/button/open-in-gitpod.svg)](https://gitpod.io/#https://github.com/axios/axios/blob/main/examples/server.js) | ||
1590 | - | ||
1591 | - | ||
1592 | -## Resources | ||
1593 | - | ||
1594 | -* [Changelog](https://github.com/axios/axios/blob/v1.x/CHANGELOG.md) | ||
1595 | -* [Ecosystem](https://github.com/axios/axios/blob/v1.x/ECOSYSTEM.md) | ||
1596 | -* [Contributing Guide](https://github.com/axios/axios/blob/v1.x/CONTRIBUTING.md) | ||
1597 | -* [Code of Conduct](https://github.com/axios/axios/blob/v1.x/CODE_OF_CONDUCT.md) | ||
1598 | - | ||
1599 | -## Credits | ||
1600 | - | ||
1601 | -axios is heavily inspired by the [$http service](https://docs.angularjs.org/api/ng/service/$http) provided in [AngularJS](https://angularjs.org/). Ultimately axios is an effort to provide a standalone `$http`-like service for use outside of AngularJS. | ||
1602 | - | ||
1603 | -## License | ||
1604 | - | ||
1605 | -[MIT](LICENSE) |
node_modules/axios/SECURITY.md
已删除
100644 → 0
1 | -# Reporting a Vulnerability | ||
2 | - | ||
3 | -If you discover a security vulnerability in axios please disclose it via [our huntr page](https://huntr.dev/repos/axios/axios/). Bounty eligibility, CVE assignment, response times and past reports are all there. | ||
4 | - | ||
5 | - | ||
6 | -Thank you for improving the security of axios. |
node_modules/axios/dist/axios.js
已删除
100644 → 0
此 diff 太大无法显示。
node_modules/axios/dist/axios.js.map
已删除
100644 → 0
此 diff 太大无法显示。
node_modules/axios/dist/axios.min.js
已删除
100644 → 0
1 | -!function(e,t){"object"==typeof exports&&"undefined"!=typeof module?module.exports=t():"function"==typeof define&&define.amd?define(t):(e="undefined"!=typeof globalThis?globalThis:e||self).axios=t()}(this,(function(){"use strict";function e(e,t){var n=Object.keys(e);if(Object.getOwnPropertySymbols){var r=Object.getOwnPropertySymbols(e);t&&(r=r.filter((function(t){return Object.getOwnPropertyDescriptor(e,t).enumerable}))),n.push.apply(n,r)}return n}function t(t){for(var n=1;n<arguments.length;n++){var r=null!=arguments[n]?arguments[n]:{};n%2?e(Object(r),!0).forEach((function(e){a(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):e(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}function n(e){return n="function"==typeof Symbol&&"symbol"==typeof Symbol.iterator?function(e){return typeof e}:function(e){return e&&"function"==typeof Symbol&&e.constructor===Symbol&&e!==Symbol.prototype?"symbol":typeof e},n(e)}function r(e,t){if(!(e instanceof t))throw new TypeError("Cannot call a class as a function")}function o(e,t){for(var n=0;n<t.length;n++){var r=t[n];r.enumerable=r.enumerable||!1,r.configurable=!0,"value"in r&&(r.writable=!0),Object.defineProperty(e,r.key,r)}}function i(e,t,n){return t&&o(e.prototype,t),n&&o(e,n),Object.defineProperty(e,"prototype",{writable:!1}),e}function a(e,t,n){return t in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function s(e,t){return c(e)||function(e,t){var n=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null==n)return;var r,o,i=[],a=!0,s=!1;try{for(n=n.call(e);!(a=(r=n.next()).done)&&(i.push(r.value),!t||i.length!==t);a=!0);}catch(e){s=!0,o=e}finally{try{a||null==n.return||n.return()}finally{if(s)throw o}}return i}(e,t)||l(e,t)||p()}function u(e){return function(e){if(Array.isArray(e))return d(e)}(e)||f(e)||l(e)||function(){throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function c(e){if(Array.isArray(e))return e}function f(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}function l(e,t){if(e){if("string"==typeof e)return d(e,t);var n=Object.prototype.toString.call(e).slice(8,-1);return"Object"===n&&e.constructor&&(n=e.constructor.name),"Map"===n||"Set"===n?Array.from(e):"Arguments"===n||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)?d(e,t):void 0}}function d(e,t){(null==t||t>e.length)&&(t=e.length);for(var n=0,r=new Array(t);n<t;n++)r[n]=e[n];return r}function p(){throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}function h(e,t){return function(){return e.apply(t,arguments)}}var m,y=Object.prototype.toString,v=Object.getPrototypeOf,b=(m=Object.create(null),function(e){var t=y.call(e);return m[t]||(m[t]=t.slice(8,-1).toLowerCase())}),g=function(e){return e=e.toLowerCase(),function(t){return b(t)===e}},w=function(e){return function(t){return n(t)===e}},O=Array.isArray,E=w("undefined");var S=g("ArrayBuffer");var R=w("string"),A=w("function"),j=w("number"),T=function(e){return null!==e&&"object"===n(e)},P=function(e){if("object"!==b(e))return!1;var t=v(e);return!(null!==t&&t!==Object.prototype&&null!==Object.getPrototypeOf(t)||Symbol.toStringTag in e||Symbol.iterator in e)},N=g("Date"),x=g("File"),C=g("Blob"),k=g("FileList"),_=g("URLSearchParams");function F(e,t){var r,o,i=arguments.length>2&&void 0!==arguments[2]?arguments[2]:{},a=i.allOwnKeys,s=void 0!==a&&a;if(null!=e)if("object"!==n(e)&&(e=[e]),O(e))for(r=0,o=e.length;r<o;r++)t.call(null,e[r],r,e);else{var u,c=s?Object.getOwnPropertyNames(e):Object.keys(e),f=c.length;for(r=0;r<f;r++)u=c[r],t.call(null,e[u],u,e)}}function U(e,t){t=t.toLowerCase();for(var n,r=Object.keys(e),o=r.length;o-- >0;)if(t===(n=r[o]).toLowerCase())return n;return null}var D="undefined"!=typeof globalThis?globalThis:"undefined"!=typeof self?self:"undefined"!=typeof window?window:global,B=function(e){return!E(e)&&e!==D};var L,I=(L="undefined"!=typeof Uint8Array&&v(Uint8Array),function(e){return L&&e instanceof L}),q=g("HTMLFormElement"),z=function(e){var t=Object.prototype.hasOwnProperty;return function(e,n){return t.call(e,n)}}(),M=g("RegExp"),H=function(e,t){var n=Object.getOwnPropertyDescriptors(e),r={};F(n,(function(n,o){var i;!1!==(i=t(n,o,e))&&(r[o]=i||n)})),Object.defineProperties(e,r)},J="abcdefghijklmnopqrstuvwxyz",W="0123456789",K={DIGIT:W,ALPHA:J,ALPHA_DIGIT:J+J.toUpperCase()+W};var V=g("AsyncFunction"),G={isArray:O,isArrayBuffer:S,isBuffer:function(e){return null!==e&&!E(e)&&null!==e.constructor&&!E(e.constructor)&&A(e.constructor.isBuffer)&&e.constructor.isBuffer(e)},isFormData:function(e){var t;return e&&("function"==typeof FormData&&e instanceof FormData||A(e.append)&&("formdata"===(t=b(e))||"object"===t&&A(e.toString)&&"[object FormData]"===e.toString()))},isArrayBufferView:function(e){return"undefined"!=typeof ArrayBuffer&&ArrayBuffer.isView?ArrayBuffer.isView(e):e&&e.buffer&&S(e.buffer)},isString:R,isNumber:j,isBoolean:function(e){return!0===e||!1===e},isObject:T,isPlainObject:P,isUndefined:E,isDate:N,isFile:x,isBlob:C,isRegExp:M,isFunction:A,isStream:function(e){return T(e)&&A(e.pipe)},isURLSearchParams:_,isTypedArray:I,isFileList:k,forEach:F,merge:function e(){for(var t=B(this)&&this||{},n=t.caseless,r={},o=function(t,o){var i=n&&U(r,o)||o;P(r[i])&&P(t)?r[i]=e(r[i],t):P(t)?r[i]=e({},t):O(t)?r[i]=t.slice():r[i]=t},i=0,a=arguments.length;i<a;i++)arguments[i]&&F(arguments[i],o);return r},extend:function(e,t,n){var r=arguments.length>3&&void 0!==arguments[3]?arguments[3]:{},o=r.allOwnKeys;return F(t,(function(t,r){n&&A(t)?e[r]=h(t,n):e[r]=t}),{allOwnKeys:o}),e},trim:function(e){return e.trim?e.trim():e.replace(/^[\s\uFEFF\xA0]+|[\s\uFEFF\xA0]+$/g,"")},stripBOM:function(e){return 65279===e.charCodeAt(0)&&(e=e.slice(1)),e},inherits:function(e,t,n,r){e.prototype=Object.create(t.prototype,r),e.prototype.constructor=e,Object.defineProperty(e,"super",{value:t.prototype}),n&&Object.assign(e.prototype,n)},toFlatObject:function(e,t,n,r){var o,i,a,s={};if(t=t||{},null==e)return t;do{for(i=(o=Object.getOwnPropertyNames(e)).length;i-- >0;)a=o[i],r&&!r(a,e,t)||s[a]||(t[a]=e[a],s[a]=!0);e=!1!==n&&v(e)}while(e&&(!n||n(e,t))&&e!==Object.prototype);return t},kindOf:b,kindOfTest:g,endsWith:function(e,t,n){e=String(e),(void 0===n||n>e.length)&&(n=e.length),n-=t.length;var r=e.indexOf(t,n);return-1!==r&&r===n},toArray:function(e){if(!e)return null;if(O(e))return e;var t=e.length;if(!j(t))return null;for(var n=new Array(t);t-- >0;)n[t]=e[t];return n},forEachEntry:function(e,t){for(var n,r=(e&&e[Symbol.iterator]).call(e);(n=r.next())&&!n.done;){var o=n.value;t.call(e,o[0],o[1])}},matchAll:function(e,t){for(var n,r=[];null!==(n=e.exec(t));)r.push(n);return r},isHTMLForm:q,hasOwnProperty:z,hasOwnProp:z,reduceDescriptors:H,freezeMethods:function(e){H(e,(function(t,n){if(A(e)&&-1!==["arguments","caller","callee"].indexOf(n))return!1;var r=e[n];A(r)&&(t.enumerable=!1,"writable"in t?t.writable=!1:t.set||(t.set=function(){throw Error("Can not rewrite read-only method '"+n+"'")}))}))},toObjectSet:function(e,t){var n={},r=function(e){e.forEach((function(e){n[e]=!0}))};return O(e)?r(e):r(String(e).split(t)),n},toCamelCase:function(e){return e.toLowerCase().replace(/[-_\s]([a-z\d])(\w*)/g,(function(e,t,n){return t.toUpperCase()+n}))},noop:function(){},toFiniteNumber:function(e,t){return e=+e,Number.isFinite(e)?e:t},findKey:U,global:D,isContextDefined:B,ALPHABET:K,generateString:function(){for(var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:16,t=arguments.length>1&&void 0!==arguments[1]?arguments[1]:K.ALPHA_DIGIT,n="",r=t.length;e--;)n+=t[Math.random()*r|0];return n},isSpecCompliantForm:function(e){return!!(e&&A(e.append)&&"FormData"===e[Symbol.toStringTag]&&e[Symbol.iterator])},toJSONObject:function(e){var t=new Array(10);return function e(n,r){if(T(n)){if(t.indexOf(n)>=0)return;if(!("toJSON"in n)){t[r]=n;var o=O(n)?[]:{};return F(n,(function(t,n){var i=e(t,r+1);!E(i)&&(o[n]=i)})),t[r]=void 0,o}}return n}(e,0)},isAsyncFn:V,isThenable:function(e){return e&&(T(e)||A(e))&&A(e.then)&&A(e.catch)}};function X(e,t,n,r,o){Error.call(this),Error.captureStackTrace?Error.captureStackTrace(this,this.constructor):this.stack=(new Error).stack,this.message=e,this.name="AxiosError",t&&(this.code=t),n&&(this.config=n),r&&(this.request=r),o&&(this.response=o)}G.inherits(X,Error,{toJSON:function(){return{message:this.message,name:this.name,description:this.description,number:this.number,fileName:this.fileName,lineNumber:this.lineNumber,columnNumber:this.columnNumber,stack:this.stack,config:G.toJSONObject(this.config),code:this.code,status:this.response&&this.response.status?this.response.status:null}}});var $=X.prototype,Q={};["ERR_BAD_OPTION_VALUE","ERR_BAD_OPTION","ECONNABORTED","ETIMEDOUT","ERR_NETWORK","ERR_FR_TOO_MANY_REDIRECTS","ERR_DEPRECATED","ERR_BAD_RESPONSE","ERR_BAD_REQUEST","ERR_CANCELED","ERR_NOT_SUPPORT","ERR_INVALID_URL"].forEach((function(e){Q[e]={value:e}})),Object.defineProperties(X,Q),Object.defineProperty($,"isAxiosError",{value:!0}),X.from=function(e,t,n,r,o,i){var a=Object.create($);return G.toFlatObject(e,a,(function(e){return e!==Error.prototype}),(function(e){return"isAxiosError"!==e})),X.call(a,e.message,t,n,r,o),a.cause=e,a.name=e.name,i&&Object.assign(a,i),a};function Z(e){return G.isPlainObject(e)||G.isArray(e)}function Y(e){return G.endsWith(e,"[]")?e.slice(0,-2):e}function ee(e,t,n){return e?e.concat(t).map((function(e,t){return e=Y(e),!n&&t?"["+e+"]":e})).join(n?".":""):t}var te=G.toFlatObject(G,{},null,(function(e){return/^is[A-Z]/.test(e)}));function ne(e,t,r){if(!G.isObject(e))throw new TypeError("target must be an object");t=t||new FormData;var o=(r=G.toFlatObject(r,{metaTokens:!0,dots:!1,indexes:!1},!1,(function(e,t){return!G.isUndefined(t[e])}))).metaTokens,i=r.visitor||f,a=r.dots,s=r.indexes,u=(r.Blob||"undefined"!=typeof Blob&&Blob)&&G.isSpecCompliantForm(t);if(!G.isFunction(i))throw new TypeError("visitor must be a function");function c(e){if(null===e)return"";if(G.isDate(e))return e.toISOString();if(!u&&G.isBlob(e))throw new X("Blob is not supported. Use a Buffer instead.");return G.isArrayBuffer(e)||G.isTypedArray(e)?u&&"function"==typeof Blob?new Blob([e]):Buffer.from(e):e}function f(e,r,i){var u=e;if(e&&!i&&"object"===n(e))if(G.endsWith(r,"{}"))r=o?r:r.slice(0,-2),e=JSON.stringify(e);else if(G.isArray(e)&&function(e){return G.isArray(e)&&!e.some(Z)}(e)||(G.isFileList(e)||G.endsWith(r,"[]"))&&(u=G.toArray(e)))return r=Y(r),u.forEach((function(e,n){!G.isUndefined(e)&&null!==e&&t.append(!0===s?ee([r],n,a):null===s?r:r+"[]",c(e))})),!1;return!!Z(e)||(t.append(ee(i,r,a),c(e)),!1)}var l=[],d=Object.assign(te,{defaultVisitor:f,convertValue:c,isVisitable:Z});if(!G.isObject(e))throw new TypeError("data must be an object");return function e(n,r){if(!G.isUndefined(n)){if(-1!==l.indexOf(n))throw Error("Circular reference detected in "+r.join("."));l.push(n),G.forEach(n,(function(n,o){!0===(!(G.isUndefined(n)||null===n)&&i.call(t,n,G.isString(o)?o.trim():o,r,d))&&e(n,r?r.concat(o):[o])})),l.pop()}}(e),t}function re(e){var t={"!":"%21","'":"%27","(":"%28",")":"%29","~":"%7E","%20":"+","%00":"\0"};return encodeURIComponent(e).replace(/[!'()~]|%20|%00/g,(function(e){return t[e]}))}function oe(e,t){this._pairs=[],e&&ne(e,this,t)}var ie=oe.prototype;function ae(e){return encodeURIComponent(e).replace(/%3A/gi,":").replace(/%24/g,"$").replace(/%2C/gi,",").replace(/%20/g,"+").replace(/%5B/gi,"[").replace(/%5D/gi,"]")}function se(e,t,n){if(!t)return e;var r,o=n&&n.encode||ae,i=n&&n.serialize;if(r=i?i(t,n):G.isURLSearchParams(t)?t.toString():new oe(t,n).toString(o)){var a=e.indexOf("#");-1!==a&&(e=e.slice(0,a)),e+=(-1===e.indexOf("?")?"?":"&")+r}return e}ie.append=function(e,t){this._pairs.push([e,t])},ie.toString=function(e){var t=e?function(t){return e.call(this,t,re)}:re;return this._pairs.map((function(e){return t(e[0])+"="+t(e[1])}),"").join("&")};var ue,ce=function(){function e(){r(this,e),this.handlers=[]}return i(e,[{key:"use",value:function(e,t,n){return this.handlers.push({fulfilled:e,rejected:t,synchronous:!!n&&n.synchronous,runWhen:n?n.runWhen:null}),this.handlers.length-1}},{key:"eject",value:function(e){this.handlers[e]&&(this.handlers[e]=null)}},{key:"clear",value:function(){this.handlers&&(this.handlers=[])}},{key:"forEach",value:function(e){G.forEach(this.handlers,(function(t){null!==t&&e(t)}))}}]),e}(),fe={silentJSONParsing:!0,forcedJSONParsing:!0,clarifyTimeoutError:!1},le={isBrowser:!0,classes:{URLSearchParams:"undefined"!=typeof URLSearchParams?URLSearchParams:oe,FormData:"undefined"!=typeof FormData?FormData:null,Blob:"undefined"!=typeof Blob?Blob:null},protocols:["http","https","file","blob","url","data"]},de="undefined"!=typeof window&&"undefined"!=typeof document,pe=(ue="undefined"!=typeof navigator&&navigator.product,de&&["ReactNative","NativeScript","NS"].indexOf(ue)<0),he="undefined"!=typeof WorkerGlobalScope&&self instanceof WorkerGlobalScope&&"function"==typeof self.importScripts,me=t(t({},Object.freeze({__proto__:null,hasBrowserEnv:de,hasStandardBrowserWebWorkerEnv:he,hasStandardBrowserEnv:pe})),le);function ye(e){function t(e,n,r,o){var i=e[o++],a=Number.isFinite(+i),s=o>=e.length;return i=!i&&G.isArray(r)?r.length:i,s?(G.hasOwnProp(r,i)?r[i]=[r[i],n]:r[i]=n,!a):(r[i]&&G.isObject(r[i])||(r[i]=[]),t(e,n,r[i],o)&&G.isArray(r[i])&&(r[i]=function(e){var t,n,r={},o=Object.keys(e),i=o.length;for(t=0;t<i;t++)r[n=o[t]]=e[n];return r}(r[i])),!a)}if(G.isFormData(e)&&G.isFunction(e.entries)){var n={};return G.forEachEntry(e,(function(e,r){t(function(e){return G.matchAll(/\w+|\[(\w*)]/g,e).map((function(e){return"[]"===e[0]?"":e[1]||e[0]}))}(e),r,n,0)})),n}return null}var ve={transitional:fe,adapter:["xhr","http"],transformRequest:[function(e,t){var n,r=t.getContentType()||"",o=r.indexOf("application/json")>-1,i=G.isObject(e);if(i&&G.isHTMLForm(e)&&(e=new FormData(e)),G.isFormData(e))return o&&o?JSON.stringify(ye(e)):e;if(G.isArrayBuffer(e)||G.isBuffer(e)||G.isStream(e)||G.isFile(e)||G.isBlob(e))return e;if(G.isArrayBufferView(e))return e.buffer;if(G.isURLSearchParams(e))return t.setContentType("application/x-www-form-urlencoded;charset=utf-8",!1),e.toString();if(i){if(r.indexOf("application/x-www-form-urlencoded")>-1)return function(e,t){return ne(e,new me.classes.URLSearchParams,Object.assign({visitor:function(e,t,n,r){return me.isNode&&G.isBuffer(e)?(this.append(t,e.toString("base64")),!1):r.defaultVisitor.apply(this,arguments)}},t))}(e,this.formSerializer).toString();if((n=G.isFileList(e))||r.indexOf("multipart/form-data")>-1){var a=this.env&&this.env.FormData;return ne(n?{"files[]":e}:e,a&&new a,this.formSerializer)}}return i||o?(t.setContentType("application/json",!1),function(e,t,n){if(G.isString(e))try{return(t||JSON.parse)(e),G.trim(e)}catch(e){if("SyntaxError"!==e.name)throw e}return(n||JSON.stringify)(e)}(e)):e}],transformResponse:[function(e){var t=this.transitional||ve.transitional,n=t&&t.forcedJSONParsing,r="json"===this.responseType;if(e&&G.isString(e)&&(n&&!this.responseType||r)){var o=!(t&&t.silentJSONParsing)&&r;try{return JSON.parse(e)}catch(e){if(o){if("SyntaxError"===e.name)throw X.from(e,X.ERR_BAD_RESPONSE,this,null,this.response);throw e}}}return e}],timeout:0,xsrfCookieName:"XSRF-TOKEN",xsrfHeaderName:"X-XSRF-TOKEN",maxContentLength:-1,maxBodyLength:-1,env:{FormData:me.classes.FormData,Blob:me.classes.Blob},validateStatus:function(e){return e>=200&&e<300},headers:{common:{Accept:"application/json, text/plain, */*","Content-Type":void 0}}};G.forEach(["delete","get","head","post","put","patch"],(function(e){ve.headers[e]={}}));var be=ve,ge=G.toObjectSet(["age","authorization","content-length","content-type","etag","expires","from","host","if-modified-since","if-unmodified-since","last-modified","location","max-forwards","proxy-authorization","referer","retry-after","user-agent"]),we=Symbol("internals");function Oe(e){return e&&String(e).trim().toLowerCase()}function Ee(e){return!1===e||null==e?e:G.isArray(e)?e.map(Ee):String(e)}function Se(e,t,n,r,o){return G.isFunction(r)?r.call(this,t,n):(o&&(t=n),G.isString(t)?G.isString(r)?-1!==t.indexOf(r):G.isRegExp(r)?r.test(t):void 0:void 0)}var Re=function(e,t){function n(e){r(this,n),e&&this.set(e)}return i(n,[{key:"set",value:function(e,t,n){var r=this;function o(e,t,n){var o=Oe(t);if(!o)throw new Error("header name must be a non-empty string");var i=G.findKey(r,o);(!i||void 0===r[i]||!0===n||void 0===n&&!1!==r[i])&&(r[i||t]=Ee(e))}var i,a,s,u,c,f=function(e,t){return G.forEach(e,(function(e,n){return o(e,n,t)}))};return G.isPlainObject(e)||e instanceof this.constructor?f(e,t):G.isString(e)&&(e=e.trim())&&!/^[-_a-zA-Z0-9^`|~,!#$%&'*+.]+$/.test(e.trim())?f((c={},(i=e)&&i.split("\n").forEach((function(e){u=e.indexOf(":"),a=e.substring(0,u).trim().toLowerCase(),s=e.substring(u+1).trim(),!a||c[a]&&ge[a]||("set-cookie"===a?c[a]?c[a].push(s):c[a]=[s]:c[a]=c[a]?c[a]+", "+s:s)})),c),t):null!=e&&o(t,e,n),this}},{key:"get",value:function(e,t){if(e=Oe(e)){var n=G.findKey(this,e);if(n){var r=this[n];if(!t)return r;if(!0===t)return function(e){for(var t,n=Object.create(null),r=/([^\s,;=]+)\s*(?:=\s*([^,;]+))?/g;t=r.exec(e);)n[t[1]]=t[2];return n}(r);if(G.isFunction(t))return t.call(this,r,n);if(G.isRegExp(t))return t.exec(r);throw new TypeError("parser must be boolean|regexp|function")}}}},{key:"has",value:function(e,t){if(e=Oe(e)){var n=G.findKey(this,e);return!(!n||void 0===this[n]||t&&!Se(0,this[n],n,t))}return!1}},{key:"delete",value:function(e,t){var n=this,r=!1;function o(e){if(e=Oe(e)){var o=G.findKey(n,e);!o||t&&!Se(0,n[o],o,t)||(delete n[o],r=!0)}}return G.isArray(e)?e.forEach(o):o(e),r}},{key:"clear",value:function(e){for(var t=Object.keys(this),n=t.length,r=!1;n--;){var o=t[n];e&&!Se(0,this[o],o,e,!0)||(delete this[o],r=!0)}return r}},{key:"normalize",value:function(e){var t=this,n={};return G.forEach(this,(function(r,o){var i=G.findKey(n,o);if(i)return t[i]=Ee(r),void delete t[o];var a=e?function(e){return e.trim().toLowerCase().replace(/([a-z\d])(\w*)/g,(function(e,t,n){return t.toUpperCase()+n}))}(o):String(o).trim();a!==o&&delete t[o],t[a]=Ee(r),n[a]=!0})),this}},{key:"concat",value:function(){for(var e,t=arguments.length,n=new Array(t),r=0;r<t;r++)n[r]=arguments[r];return(e=this.constructor).concat.apply(e,[this].concat(n))}},{key:"toJSON",value:function(e){var t=Object.create(null);return G.forEach(this,(function(n,r){null!=n&&!1!==n&&(t[r]=e&&G.isArray(n)?n.join(", "):n)})),t}},{key:Symbol.iterator,value:function(){return Object.entries(this.toJSON())[Symbol.iterator]()}},{key:"toString",value:function(){return Object.entries(this.toJSON()).map((function(e){var t=s(e,2);return t[0]+": "+t[1]})).join("\n")}},{key:Symbol.toStringTag,get:function(){return"AxiosHeaders"}}],[{key:"from",value:function(e){return e instanceof this?e:new this(e)}},{key:"concat",value:function(e){for(var t=new this(e),n=arguments.length,r=new Array(n>1?n-1:0),o=1;o<n;o++)r[o-1]=arguments[o];return r.forEach((function(e){return t.set(e)})),t}},{key:"accessor",value:function(e){var t=(this[we]=this[we]={accessors:{}}).accessors,n=this.prototype;function r(e){var r=Oe(e);t[r]||(!function(e,t){var n=G.toCamelCase(" "+t);["get","set","has"].forEach((function(r){Object.defineProperty(e,r+n,{value:function(e,n,o){return this[r].call(this,t,e,n,o)},configurable:!0})}))}(n,e),t[r]=!0)}return G.isArray(e)?e.forEach(r):r(e),this}}]),n}();Re.accessor(["Content-Type","Content-Length","Accept","Accept-Encoding","User-Agent","Authorization"]),G.reduceDescriptors(Re.prototype,(function(e,t){var n=e.value,r=t[0].toUpperCase()+t.slice(1);return{get:function(){return n},set:function(e){this[r]=e}}})),G.freezeMethods(Re);var Ae=Re;function je(e,t){var n=this||be,r=t||n,o=Ae.from(r.headers),i=r.data;return G.forEach(e,(function(e){i=e.call(n,i,o.normalize(),t?t.status:void 0)})),o.normalize(),i}function Te(e){return!(!e||!e.__CANCEL__)}function Pe(e,t,n){X.call(this,null==e?"canceled":e,X.ERR_CANCELED,t,n),this.name="CanceledError"}G.inherits(Pe,X,{__CANCEL__:!0});var Ne=me.hasStandardBrowserEnv?{write:function(e,t,n,r,o,i){var a=[e+"="+encodeURIComponent(t)];G.isNumber(n)&&a.push("expires="+new Date(n).toGMTString()),G.isString(r)&&a.push("path="+r),G.isString(o)&&a.push("domain="+o),!0===i&&a.push("secure"),document.cookie=a.join("; ")},read:function(e){var t=document.cookie.match(new RegExp("(^|;\\s*)("+e+")=([^;]*)"));return t?decodeURIComponent(t[3]):null},remove:function(e){this.write(e,"",Date.now()-864e5)}}:{write:function(){},read:function(){return null},remove:function(){}};function xe(e,t){return e&&!/^([a-z][a-z\d+\-.]*:)?\/\//i.test(t)?function(e,t){return t?e.replace(/\/+$/,"")+"/"+t.replace(/^\/+/,""):e}(e,t):t}var Ce=me.hasStandardBrowserEnv?function(){var e,t=/(msie|trident)/i.test(navigator.userAgent),n=document.createElement("a");function r(e){var r=e;return t&&(n.setAttribute("href",r),r=n.href),n.setAttribute("href",r),{href:n.href,protocol:n.protocol?n.protocol.replace(/:$/,""):"",host:n.host,search:n.search?n.search.replace(/^\?/,""):"",hash:n.hash?n.hash.replace(/^#/,""):"",hostname:n.hostname,port:n.port,pathname:"/"===n.pathname.charAt(0)?n.pathname:"/"+n.pathname}}return e=r(window.location.href),function(t){var n=G.isString(t)?r(t):t;return n.protocol===e.protocol&&n.host===e.host}}():function(){return!0};function ke(e,t){var n=0,r=function(e,t){e=e||10;var n,r=new Array(e),o=new Array(e),i=0,a=0;return t=void 0!==t?t:1e3,function(s){var u=Date.now(),c=o[a];n||(n=u),r[i]=s,o[i]=u;for(var f=a,l=0;f!==i;)l+=r[f++],f%=e;if((i=(i+1)%e)===a&&(a=(a+1)%e),!(u-n<t)){var d=c&&u-c;return d?Math.round(1e3*l/d):void 0}}}(50,250);return function(o){var i=o.loaded,a=o.lengthComputable?o.total:void 0,s=i-n,u=r(s);n=i;var c={loaded:i,total:a,progress:a?i/a:void 0,bytes:s,rate:u||void 0,estimated:u&&a&&i<=a?(a-i)/u:void 0,event:o};c[t?"download":"upload"]=!0,e(c)}}var _e={http:null,xhr:"undefined"!=typeof XMLHttpRequest&&function(e){return new Promise((function(t,n){var r,o,i,a=e.data,s=Ae.from(e.headers).normalize(),d=e.responseType,h=e.withXSRFToken;function m(){e.cancelToken&&e.cancelToken.unsubscribe(r),e.signal&&e.signal.removeEventListener("abort",r)}if(G.isFormData(a))if(me.hasStandardBrowserEnv||me.hasStandardBrowserWebWorkerEnv)s.setContentType(!1);else if(!1!==(o=s.getContentType())){var y=o?o.split(";").map((function(e){return e.trim()})).filter(Boolean):[],v=c(i=y)||f(i)||l(i)||p(),b=v[0],g=v.slice(1);s.setContentType([b||"multipart/form-data"].concat(u(g)).join("; "))}var w=new XMLHttpRequest;if(e.auth){var O=e.auth.username||"",E=e.auth.password?unescape(encodeURIComponent(e.auth.password)):"";s.set("Authorization","Basic "+btoa(O+":"+E))}var S=xe(e.baseURL,e.url);function R(){if(w){var r=Ae.from("getAllResponseHeaders"in w&&w.getAllResponseHeaders());!function(e,t,n){var r=n.config.validateStatus;n.status&&r&&!r(n.status)?t(new X("Request failed with status code "+n.status,[X.ERR_BAD_REQUEST,X.ERR_BAD_RESPONSE][Math.floor(n.status/100)-4],n.config,n.request,n)):e(n)}((function(e){t(e),m()}),(function(e){n(e),m()}),{data:d&&"text"!==d&&"json"!==d?w.response:w.responseText,status:w.status,statusText:w.statusText,headers:r,config:e,request:w}),w=null}}if(w.open(e.method.toUpperCase(),se(S,e.params,e.paramsSerializer),!0),w.timeout=e.timeout,"onloadend"in w?w.onloadend=R:w.onreadystatechange=function(){w&&4===w.readyState&&(0!==w.status||w.responseURL&&0===w.responseURL.indexOf("file:"))&&setTimeout(R)},w.onabort=function(){w&&(n(new X("Request aborted",X.ECONNABORTED,e,w)),w=null)},w.onerror=function(){n(new X("Network Error",X.ERR_NETWORK,e,w)),w=null},w.ontimeout=function(){var t=e.timeout?"timeout of "+e.timeout+"ms exceeded":"timeout exceeded",r=e.transitional||fe;e.timeoutErrorMessage&&(t=e.timeoutErrorMessage),n(new X(t,r.clarifyTimeoutError?X.ETIMEDOUT:X.ECONNABORTED,e,w)),w=null},me.hasStandardBrowserEnv&&(h&&G.isFunction(h)&&(h=h(e)),h||!1!==h&&Ce(S))){var A=e.xsrfHeaderName&&e.xsrfCookieName&&Ne.read(e.xsrfCookieName);A&&s.set(e.xsrfHeaderName,A)}void 0===a&&s.setContentType(null),"setRequestHeader"in w&&G.forEach(s.toJSON(),(function(e,t){w.setRequestHeader(t,e)})),G.isUndefined(e.withCredentials)||(w.withCredentials=!!e.withCredentials),d&&"json"!==d&&(w.responseType=e.responseType),"function"==typeof e.onDownloadProgress&&w.addEventListener("progress",ke(e.onDownloadProgress,!0)),"function"==typeof e.onUploadProgress&&w.upload&&w.upload.addEventListener("progress",ke(e.onUploadProgress)),(e.cancelToken||e.signal)&&(r=function(t){w&&(n(!t||t.type?new Pe(null,e,w):t),w.abort(),w=null)},e.cancelToken&&e.cancelToken.subscribe(r),e.signal&&(e.signal.aborted?r():e.signal.addEventListener("abort",r)));var j,T=(j=/^([-+\w]{1,25})(:?\/\/|:)/.exec(S))&&j[1]||"";T&&-1===me.protocols.indexOf(T)?n(new X("Unsupported protocol "+T+":",X.ERR_BAD_REQUEST,e)):w.send(a||null)}))}};G.forEach(_e,(function(e,t){if(e){try{Object.defineProperty(e,"name",{value:t})}catch(e){}Object.defineProperty(e,"adapterName",{value:t})}}));var Fe=function(e){return"- ".concat(e)},Ue=function(e){return G.isFunction(e)||null===e||!1===e},De=function(e){for(var t,n,r=(e=G.isArray(e)?e:[e]).length,o={},i=0;i<r;i++){var a=void 0;if(n=t=e[i],!Ue(t)&&void 0===(n=_e[(a=String(t)).toLowerCase()]))throw new X("Unknown adapter '".concat(a,"'"));if(n)break;o[a||"#"+i]=n}if(!n){var u=Object.entries(o).map((function(e){var t=s(e,2),n=t[0],r=t[1];return"adapter ".concat(n," ")+(!1===r?"is not supported by the environment":"is not available in the build")}));throw new X("There is no suitable adapter to dispatch the request "+(r?u.length>1?"since :\n"+u.map(Fe).join("\n"):" "+Fe(u[0]):"as no adapter specified"),"ERR_NOT_SUPPORT")}return n};function Be(e){if(e.cancelToken&&e.cancelToken.throwIfRequested(),e.signal&&e.signal.aborted)throw new Pe(null,e)}function Le(e){return Be(e),e.headers=Ae.from(e.headers),e.data=je.call(e,e.transformRequest),-1!==["post","put","patch"].indexOf(e.method)&&e.headers.setContentType("application/x-www-form-urlencoded",!1),De(e.adapter||be.adapter)(e).then((function(t){return Be(e),t.data=je.call(e,e.transformResponse,t),t.headers=Ae.from(t.headers),t}),(function(t){return Te(t)||(Be(e),t&&t.response&&(t.response.data=je.call(e,e.transformResponse,t.response),t.response.headers=Ae.from(t.response.headers))),Promise.reject(t)}))}var Ie=function(e){return e instanceof Ae?e.toJSON():e};function qe(e,t){t=t||{};var n={};function r(e,t,n){return G.isPlainObject(e)&&G.isPlainObject(t)?G.merge.call({caseless:n},e,t):G.isPlainObject(t)?G.merge({},t):G.isArray(t)?t.slice():t}function o(e,t,n){return G.isUndefined(t)?G.isUndefined(e)?void 0:r(void 0,e,n):r(e,t,n)}function i(e,t){if(!G.isUndefined(t))return r(void 0,t)}function a(e,t){return G.isUndefined(t)?G.isUndefined(e)?void 0:r(void 0,e):r(void 0,t)}function s(n,o,i){return i in t?r(n,o):i in e?r(void 0,n):void 0}var u={url:i,method:i,data:i,baseURL:a,transformRequest:a,transformResponse:a,paramsSerializer:a,timeout:a,timeoutMessage:a,withCredentials:a,withXSRFToken:a,adapter:a,responseType:a,xsrfCookieName:a,xsrfHeaderName:a,onUploadProgress:a,onDownloadProgress:a,decompress:a,maxContentLength:a,maxBodyLength:a,beforeRedirect:a,transport:a,httpAgent:a,httpsAgent:a,cancelToken:a,socketPath:a,responseEncoding:a,validateStatus:s,headers:function(e,t){return o(Ie(e),Ie(t),!0)}};return G.forEach(Object.keys(Object.assign({},e,t)),(function(r){var i=u[r]||o,a=i(e[r],t[r],r);G.isUndefined(a)&&i!==s||(n[r]=a)})),n}var ze="1.6.2",Me={};["object","boolean","number","function","string","symbol"].forEach((function(e,t){Me[e]=function(r){return n(r)===e||"a"+(t<1?"n ":" ")+e}}));var He={};Me.transitional=function(e,t,n){function r(e,t){return"[Axios v1.6.2] Transitional option '"+e+"'"+t+(n?". "+n:"")}return function(n,o,i){if(!1===e)throw new X(r(o," has been removed"+(t?" in "+t:"")),X.ERR_DEPRECATED);return t&&!He[o]&&(He[o]=!0,console.warn(r(o," has been deprecated since v"+t+" and will be removed in the near future"))),!e||e(n,o,i)}};var Je={assertOptions:function(e,t,r){if("object"!==n(e))throw new X("options must be an object",X.ERR_BAD_OPTION_VALUE);for(var o=Object.keys(e),i=o.length;i-- >0;){var a=o[i],s=t[a];if(s){var u=e[a],c=void 0===u||s(u,a,e);if(!0!==c)throw new X("option "+a+" must be "+c,X.ERR_BAD_OPTION_VALUE)}else if(!0!==r)throw new X("Unknown option "+a,X.ERR_BAD_OPTION)}},validators:Me},We=Je.validators,Ke=function(){function e(t){r(this,e),this.defaults=t,this.interceptors={request:new ce,response:new ce}}return i(e,[{key:"request",value:function(e,t){"string"==typeof e?(t=t||{}).url=e:t=e||{};var n=t=qe(this.defaults,t),r=n.transitional,o=n.paramsSerializer,i=n.headers;void 0!==r&&Je.assertOptions(r,{silentJSONParsing:We.transitional(We.boolean),forcedJSONParsing:We.transitional(We.boolean),clarifyTimeoutError:We.transitional(We.boolean)},!1),null!=o&&(G.isFunction(o)?t.paramsSerializer={serialize:o}:Je.assertOptions(o,{encode:We.function,serialize:We.function},!0)),t.method=(t.method||this.defaults.method||"get").toLowerCase();var a=i&&G.merge(i.common,i[t.method]);i&&G.forEach(["delete","get","head","post","put","patch","common"],(function(e){delete i[e]})),t.headers=Ae.concat(a,i);var s=[],u=!0;this.interceptors.request.forEach((function(e){"function"==typeof e.runWhen&&!1===e.runWhen(t)||(u=u&&e.synchronous,s.unshift(e.fulfilled,e.rejected))}));var c,f=[];this.interceptors.response.forEach((function(e){f.push(e.fulfilled,e.rejected)}));var l,d=0;if(!u){var p=[Le.bind(this),void 0];for(p.unshift.apply(p,s),p.push.apply(p,f),l=p.length,c=Promise.resolve(t);d<l;)c=c.then(p[d++],p[d++]);return c}l=s.length;var h=t;for(d=0;d<l;){var m=s[d++],y=s[d++];try{h=m(h)}catch(e){y.call(this,e);break}}try{c=Le.call(this,h)}catch(e){return Promise.reject(e)}for(d=0,l=f.length;d<l;)c=c.then(f[d++],f[d++]);return c}},{key:"getUri",value:function(e){return se(xe((e=qe(this.defaults,e)).baseURL,e.url),e.params,e.paramsSerializer)}}]),e}();G.forEach(["delete","get","head","options"],(function(e){Ke.prototype[e]=function(t,n){return this.request(qe(n||{},{method:e,url:t,data:(n||{}).data}))}})),G.forEach(["post","put","patch"],(function(e){function t(t){return function(n,r,o){return this.request(qe(o||{},{method:e,headers:t?{"Content-Type":"multipart/form-data"}:{},url:n,data:r}))}}Ke.prototype[e]=t(),Ke.prototype[e+"Form"]=t(!0)}));var Ve=Ke,Ge=function(){function e(t){if(r(this,e),"function"!=typeof t)throw new TypeError("executor must be a function.");var n;this.promise=new Promise((function(e){n=e}));var o=this;this.promise.then((function(e){if(o._listeners){for(var t=o._listeners.length;t-- >0;)o._listeners[t](e);o._listeners=null}})),this.promise.then=function(e){var t,n=new Promise((function(e){o.subscribe(e),t=e})).then(e);return n.cancel=function(){o.unsubscribe(t)},n},t((function(e,t,r){o.reason||(o.reason=new Pe(e,t,r),n(o.reason))}))}return i(e,[{key:"throwIfRequested",value:function(){if(this.reason)throw this.reason}},{key:"subscribe",value:function(e){this.reason?e(this.reason):this._listeners?this._listeners.push(e):this._listeners=[e]}},{key:"unsubscribe",value:function(e){if(this._listeners){var t=this._listeners.indexOf(e);-1!==t&&this._listeners.splice(t,1)}}}],[{key:"source",value:function(){var t;return{token:new e((function(e){t=e})),cancel:t}}}]),e}();var Xe={Continue:100,SwitchingProtocols:101,Processing:102,EarlyHints:103,Ok:200,Created:201,Accepted:202,NonAuthoritativeInformation:203,NoContent:204,ResetContent:205,PartialContent:206,MultiStatus:207,AlreadyReported:208,ImUsed:226,MultipleChoices:300,MovedPermanently:301,Found:302,SeeOther:303,NotModified:304,UseProxy:305,Unused:306,TemporaryRedirect:307,PermanentRedirect:308,BadRequest:400,Unauthorized:401,PaymentRequired:402,Forbidden:403,NotFound:404,MethodNotAllowed:405,NotAcceptable:406,ProxyAuthenticationRequired:407,RequestTimeout:408,Conflict:409,Gone:410,LengthRequired:411,PreconditionFailed:412,PayloadTooLarge:413,UriTooLong:414,UnsupportedMediaType:415,RangeNotSatisfiable:416,ExpectationFailed:417,ImATeapot:418,MisdirectedRequest:421,UnprocessableEntity:422,Locked:423,FailedDependency:424,TooEarly:425,UpgradeRequired:426,PreconditionRequired:428,TooManyRequests:429,RequestHeaderFieldsTooLarge:431,UnavailableForLegalReasons:451,InternalServerError:500,NotImplemented:501,BadGateway:502,ServiceUnavailable:503,GatewayTimeout:504,HttpVersionNotSupported:505,VariantAlsoNegotiates:506,InsufficientStorage:507,LoopDetected:508,NotExtended:510,NetworkAuthenticationRequired:511};Object.entries(Xe).forEach((function(e){var t=s(e,2),n=t[0],r=t[1];Xe[r]=n}));var $e=Xe;var Qe=function e(t){var n=new Ve(t),r=h(Ve.prototype.request,n);return G.extend(r,Ve.prototype,n,{allOwnKeys:!0}),G.extend(r,n,null,{allOwnKeys:!0}),r.create=function(n){return e(qe(t,n))},r}(be);return Qe.Axios=Ve,Qe.CanceledError=Pe,Qe.CancelToken=Ge,Qe.isCancel=Te,Qe.VERSION=ze,Qe.toFormData=ne,Qe.AxiosError=X,Qe.Cancel=Qe.CanceledError,Qe.all=function(e){return Promise.all(e)},Qe.spread=function(e){return function(t){return e.apply(null,t)}},Qe.isAxiosError=function(e){return G.isObject(e)&&!0===e.isAxiosError},Qe.mergeConfig=qe,Qe.AxiosHeaders=Ae,Qe.formToJSON=function(e){return ye(G.isHTMLForm(e)?new FormData(e):e)},Qe.getAdapter=De,Qe.HttpStatusCode=$e,Qe.default=Qe,Qe})); | ||
2 | -//# sourceMappingURL=axios.min.js.map |
node_modules/axios/dist/axios.min.js.map
已删除
100644 → 0
此 diff 太大无法显示。
请
注册
或
登录
后发表评论