Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

axios-extra

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

axios-extra - npm Package Compare versions

Comparing version 0.0.1 to 0.0.2

43

create.js

@@ -1,2 +0,2 @@

const Queue = require('promise-queue-plus');
const Queue = require('promise-queue-plus/create')(Promise);
const apis = new Set(['request', 'get', 'delete', 'head', 'options', 'post', 'put', 'patch']);

@@ -9,4 +9,3 @@ const DEF_MAX_CONCURRENT = 10;

let axiosConfig = args[args.length - 1];
let queueOptions =
typeof axiosConfig == 'object' ? axiosConfig.queueOptions : undefined;
let queueOptions = typeof axiosConfig == 'object' ? axiosConfig.queueOptions : undefined;
debug && console.log('workQueueOptions:', queueOptions);

@@ -33,2 +32,38 @@ if (debug) {

// 为 axios.defaults 添加 maxConcurrent 与 queueOptions 支持
axios.defaults.queueOptions = queue._options;
Object.defineProperties(axios.defaults, {
maxConcurrent: {
get() {
return queue.getMax();
},
set(v) {
queue.setMax(v);
}
},
queueOptions: {
get() {
return queue._options;
},
set(v) {
[
'queueStart',
'queueEnd',
'workAdd',
'workResolve',
'workReject',
'workFinally',
'retry',
'retryIsJump',
'timeout',
'autoRun'
].map(k => {
if (k in v) {
queue._options[k] = k.v;
}
});
}
}
});
return new Proxy(axios, {

@@ -57,5 +92,5 @@ apply: function(target, thisArg, argumentsList) {

function create(axios, maxConcurrent = DEF_MAX_CONCURRENT, queueOptions = {}) {
return proxyAxios(new Queue(maxConcurrent, queueOptions), axios);
return proxyAxios(Queue(maxConcurrent, queueOptions), axios);
}
module.exports = create;

4

package.json
{
"name": "axios-extra",
"version": "0.0.1",
"version": "0.0.2",
"description": "Extend \"Axios\"; add concurrency limits, retry, etc.",

@@ -27,4 +27,4 @@ "main": "index.js",

"axios": "^0.18.0",
"promise-queue-plus": "^1.1.0"
"promise-queue-plus": "^1.2.1"
}
}

@@ -50,5 +50,1 @@ # axios-extra

```
## 己知问题
- 不能通过 `axios.defaults` 更改并发及重试次数.

@@ -5,2 +5,4 @@ const axios = require('../').create({ maxConcurrent: 1 });

// axios.defaults.maxConcurrent = 3;
for (var i = 0; i < max; i++) {

@@ -7,0 +9,0 @@ +(function(k) {

@@ -5,2 +5,4 @@ const axios = require('../').create({ maxConcurrent: 1, queueOptions: { retry: 3, retryIsJump: true } });

axios.defaults.queueOptions.retry = 0;
let x = 0;

@@ -7,0 +9,0 @@ //添加一个拦截器,模拟失败

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc