token-dealer
Advanced tools
Comparing version 2.1.1 to 3.0.0
29
index.js
@@ -75,16 +75,15 @@ 'use strict'; | ||
return Promise.resolve() | ||
.then(() => { | ||
return fn(chosen.token, (reset, retry) => { | ||
chosen.usage.exhausted = true; | ||
chosen.usage.reset = reset; | ||
.then(() => fn(chosen.token, (reset, retry) => { | ||
chosen.usage.exhausted = true; | ||
chosen.usage.reset = reset; | ||
options.onExhausted && options.onExhausted(chosen.token, reset); | ||
options.onExhausted && options.onExhausted(chosen.token, reset); | ||
if (retry) { | ||
throw Object.assign(new Error('Token is exhausted, retrying..'), { code: 'ETOKENEXHAUSTED' }); | ||
} | ||
}); | ||
}) | ||
if (retry) { | ||
throw Object.assign(new Error('Token is exhausted, retrying..'), { code: 'ETOKENEXHAUSTED' }); | ||
} | ||
})) | ||
.then((val) => { | ||
chosen.usage.inflight -= 1; | ||
return val; | ||
@@ -109,3 +108,3 @@ }, (err) => { | ||
options = Object.assign({ | ||
options = { | ||
group: 'default', | ||
@@ -115,3 +114,4 @@ wait: false, | ||
onExhausted: null, | ||
}, options); | ||
...options, | ||
}; | ||
@@ -126,6 +126,7 @@ return dealToken(tokens, fn, options); | ||
options = Object.assign({ | ||
options = { | ||
group: 'default', | ||
lru: defaultLru, | ||
}, options); | ||
...options, | ||
}; | ||
@@ -132,0 +133,0 @@ const tokensUsage = {}; |
{ | ||
"name": "token-dealer", | ||
"version": "2.1.1", | ||
"description": "Circumvent API rate limits by having several API tokens and let the dealer manage and give them to you", | ||
"main": "index.js", | ||
"scripts": { | ||
"lint": "eslint '{*.js,test/**/*.js}' --ignore-pattern=test/coverage", | ||
"test": "mocha --bail -t 5000", | ||
"test-cov": "istanbul cover --dir test/coverage _mocha -- --bail -t 5000 && echo Coverage lies in test/coverage/lcov-report/index.html", | ||
"test-travis": "istanbul cover _mocha --report lcovonly -- --bail -t 5000 && cat ./coverage/lcov.info | ./node_modules/coveralls/bin/coveralls.js" | ||
}, | ||
"bugs": { | ||
"url": "https://github.com/IndigoUnited/node-token-dealer/issues/" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "git://github.com/IndigoUnited/node-token-dealer.git" | ||
}, | ||
"version": "3.0.0", | ||
"keywords": [ | ||
@@ -29,4 +15,37 @@ "token", | ||
], | ||
"author": "IndigoUnited <hello@indigounited.com> (http://indigounited.com)", | ||
"author": "André Cruz <andre@moxy.studio>", | ||
"homepage": "https://github.com/moxystudio/node-token-dealer", | ||
"repository": { | ||
"type": "git", | ||
"url": "git@github.com:moxystudio/node-token-dealer.git" | ||
}, | ||
"license": "MIT", | ||
"main": "index.js", | ||
"files": [ | ||
"index.js" | ||
], | ||
"scripts": { | ||
"lint": "eslint .", | ||
"test": "jest --env node --coverage", | ||
"prerelease": "npm t && npm run lint", | ||
"release": "standard-version", | ||
"precommit": "lint-staged", | ||
"commitmsg": "commitlint -e $GIT_PARAMS" | ||
}, | ||
"standard-version": { | ||
"scripts": { | ||
"posttag": "git push --follow-tags origin master && npm publish" | ||
} | ||
}, | ||
"lint-staged": { | ||
"*.js": [ | ||
"eslint --fix", | ||
"git add" | ||
] | ||
}, | ||
"commitlint": { | ||
"extends": [ | ||
"@commitlint/config-conventional" | ||
] | ||
}, | ||
"dependencies": { | ||
@@ -36,13 +55,12 @@ "lru-cache": "^4.0.0" | ||
"devDependencies": { | ||
"@satazor/eslint-config": "^3.0.0", | ||
"bluebird": "^3.3.1", | ||
"chai": "^3.4.1", | ||
"coveralls": "^2.11.6", | ||
"eslint": "^3.0.0", | ||
"istanbul": "^0.4.1", | ||
"mocha": "^3.0.1" | ||
}, | ||
"engines": { | ||
"node": ">=4.0.0" | ||
"@commitlint/cli": "^7.0.0", | ||
"@commitlint/config-conventional": "^7.0.1", | ||
"delay": "^3.0.0", | ||
"eslint": "^5.3.0", | ||
"eslint-config-moxy": "^6.0.1", | ||
"husky": "^0.14.3", | ||
"jest": "^23.4.2", | ||
"lint-staged": "^7.2.0", | ||
"standard-version": "^4.4.0" | ||
} | ||
} |
# token-dealer | ||
[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Coverage Status][coveralls-image]][coveralls-url] [![Dependency status][david-dm-image]][david-dm-url] [![Dev Dependency status][david-dm-dev-image]][david-dm-dev-url] | ||
[![NPM version][npm-image]][npm-url] [![Downloads][downloads-image]][npm-url] [![Build Status][travis-image]][travis-url] [![Coverage Status][codecov-image]][codecov-url] [![Dependency status][david-dm-image]][david-dm-url] [![Dev Dependency status][david-dm-dev-image]][david-dm-dev-url] [![Greenkeeper badge][greenkeeper-image]][greenkeeper-url] | ||
[npm-url]:https://npmjs.org/package/token-dealer | ||
[npm-image]:http://img.shields.io/npm/v/token-dealer.svg | ||
[downloads-image]:http://img.shields.io/npm/dm/token-dealer.svg | ||
[npm-image]:http://img.shields.io/npm/v/token-dealer.svg | ||
[travis-url]:https://travis-ci.org/IndigoUnited/node-token-dealer | ||
[travis-image]:http://img.shields.io/travis/IndigoUnited/node-token-dealer/master.svg | ||
[coveralls-url]:https://coveralls.io/r/IndigoUnited/node-token-dealer | ||
[coveralls-image]:https://img.shields.io/coveralls/IndigoUnited/node-token-dealer/master.svg | ||
[david-dm-url]:https://david-dm.org/IndigoUnited/node-token-dealer | ||
[david-dm-image]:https://img.shields.io/david/IndigoUnited/node-token-dealer.svg | ||
[david-dm-dev-url]:https://david-dm.org/IndigoUnited/node-token-dealer#info=devDependencies | ||
[david-dm-dev-image]:https://img.shields.io/david/dev/IndigoUnited/node-token-dealer.svg | ||
[travis-url]:https://travis-ci.org/moxystudio/node-token-dealer | ||
[travis-image]:http://img.shields.io/travis/moxystudio/node-token-dealer/master.svg | ||
[codecov-url]:https://codecov.io/gh/moxystudio/node-token-dealer | ||
[codecov-image]:https://img.shields.io/codecov/c/github/moxystudio/node-token-dealer/master.svg | ||
[david-dm-url]:https://david-dm.org/moxystudio/node-token-dealer | ||
[david-dm-image]:https://img.shields.io/david/moxystudio/node-token-dealer.svg | ||
[david-dm-dev-url]:https://david-dm.org/moxystudio/node-token-dealer?type=dev | ||
[david-dm-dev-image]:https://img.shields.io/david/dev/moxystudio/node-token-dealer.svg | ||
[greenkeeper-image]:https://badges.greenkeeper.io/moxystudio/node-token-dealer.svg | ||
[greenkeeper-url]:https://greenkeeper.io | ||
@@ -56,3 +58,3 @@ Circumvent API rate limits by having several API tokens and let the dealer manage and give them to you. | ||
return got('https://api.github.com/repos/IndigoUnited/node-cross-spawn', { | ||
return got('https://api.github.com/repos/moxystudio/node-cross-spawn', { | ||
json: true, | ||
@@ -118,3 +120,3 @@ headers: { Authorization: `token ${token}` }, | ||
`$ npm test` | ||
`$ npm test-cov` to get coverage report | ||
`$ npm test -- --watch` during development | ||
@@ -121,0 +123,0 @@ |
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
125
12538
9
5
106
1