Skip to content

Commit

Permalink
extract concurrency param to config
Browse files Browse the repository at this point in the history
  • Loading branch information
konstantin committed Oct 7, 2015
1 parent 3200068 commit b959fe4
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,11 @@ var host = 'https://transifex.com';
var Promise = require("bluebird");
/**
*
* @param {{login:String, password:String, projectSlug: String, resourceSlug: String, skipTags: Array[String]}} config
* @param {{login:String, password:String, projectSlug: String, resourceSlug: String, skipTags: Array[String], requestConcurrency: Number}} config
* @return {{getTranslatedResources: Function, updateResourceFile: Function}}
*/
var transifex = function (config) {
var concurrency = config.requestConcurrency || 5;
var makeRequest = function (url, method, data) {
method = method || 'GET';
// console.log(method + ' ', apiUrl + url);
Expand Down Expand Up @@ -77,14 +78,14 @@ var transifex = function (config) {
console.log(token, 'token not found by string hash');
return;
})
}, {concurrency: 10});
}, {concurrency: concurrency});
};

var putResourceStrings = function (strings) {
return Promise.map(strings, function (value) {
var url = `project/${resourceFile}source/${generateHash(value.token)}`;
return makeRequest(url, 'PUT', _.omit(value, 'token'))
}, {concurrency: 10});
}, {concurrency: concurrency});
};

var updateResourceFile = function (dictionaries) {
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tau-transifex",
"version": "0.6.0",
"version": "0.6.1",
"description": "Simple API for request to transifex REST API",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit b959fe4

Please sign in to comment.