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

i18n-patch

Package Overview
Dependencies
Maintainers
1
Versions
23
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

i18n-patch - npm Package Compare versions

Comparing version 0.0.16 to 0.0.17

55

lib/index.js

@@ -97,11 +97,17 @@ 'use strict';

}
async.waterfall(_this.config.translations.map(function (t) {
async.series(_this.createParallelGroups().map(function (parallelGroup) {
return function (cb) {
var startTime = process.hrtime();
_this.processTranslation(t).catch(function (err) {
return cb(err);
}).then(function () {
t.statistics.time = process.hrtime(startTime);
_this.showStatistics(t);
cb();
async.parallel(parallelGroup.map(function (t) {
return function (cb2) {
var startTime = process.hrtime();
_this.processTranslation(t).catch(function (err) {
return cb2(err);
}).then(function () {
t.statistics.time = process.hrtime(startTime);
_this.showStatistics(t);
cb2();
});
};
}), function (err) {
cb(err);
});

@@ -799,2 +805,35 @@ };

}, {
key: 'createParallelGroups',
value: function createParallelGroups() {
var parallelGroups = [];
var done = [];
for (var i = 0; i < this.config.translations.length; i++) {
done.push(false);
}
for (var _i = 0; _i < this.config.translations.length; _i++) {
if (done[_i]) {
continue;
}
if (this.config.translations[_i].hasOwnProperty('parallelGroup')) {
// Search the same translation in rest of the translations
var parallelGroupId = this.config.translations[_i].parallelGroup;
var group = [this.config.translations[_i]];
for (var j = _i + 1; j < this.config.translations.length; j++) {
if (this.config.translations[j].hasOwnProperty('parallelGroup')) {
var parallelGroupId2 = this.config.translations[j].parallelGroup;
if (parallelGroupId === parallelGroupId2) {
group.push(this.config.translations[j]);
done[j] = true;
}
}
}
parallelGroups.push(group);
} else {
parallelGroups.push([this.config.translations[_i]]);
}
done[_i] = true;
}
return parallelGroups;
}
}, {
key: 'showStatistics',

@@ -801,0 +840,0 @@ value: function showStatistics(t) {

2

package.json
{
"name": "i18n-patch",
"version": "0.0.16",
"version": "0.0.17",
"description": "Replacing codes for i18n with patterns.",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -139,2 +139,3 @@ # i18n-patch

* [Complete pattern](#complete-pattern)
* [Parallel groups](#parallel-groups)

@@ -853,4 +854,21 @@ ### Basic

### Parallel groups
When you want to process several `translation`s in parallel,
you can use `parallel-group` option.
```yaml
# i18n.yml
translations:
- name: 'foo'
parallel-group: 'group1'
- name: 'bar'
parallel-group: 'group1'
- name: 'baz'
```
With the above example, `foo` and `bar` will be processed in parallel because the same `parallel-group` value `group1` is given, and then `baz` will be processed.
## License
MIT

@@ -48,11 +48,17 @@ 'use strict';

}
async.waterfall(this.config.translations.map((t) => {
async.series(this.createParallelGroups().map((parallelGroup) => {
return (cb) => {
let startTime = process.hrtime();
this.processTranslation(t)
.catch((err) => cb(err))
.then(() => {
t.statistics.time = process.hrtime(startTime);
this.showStatistics(t);
cb();
async.parallel(parallelGroup.map((t) => {
return (cb2) => {
let startTime = process.hrtime();
this.processTranslation(t)
.catch((err) => cb2(err))
.then(() => {
t.statistics.time = process.hrtime(startTime);
this.showStatistics(t);
cb2();
});
};
}), (err) => {
cb(err);
});

@@ -427,2 +433,34 @@ };

createParallelGroups() {
let parallelGroups = [];
let done = [];
for (let i = 0; i < this.config.translations.length; i++) {
done.push(false);
}
for (let i = 0; i < this.config.translations.length; i++) {
if (done[i]) {
continue;
}
if (this.config.translations[i].hasOwnProperty('parallelGroup')) {
// Search the same translation in rest of the translations
let parallelGroupId = this.config.translations[i].parallelGroup;
let group = [this.config.translations[i]];
for (let j = i + 1; j < this.config.translations.length; j++) {
if (this.config.translations[j].hasOwnProperty('parallelGroup')) {
let parallelGroupId2 = this.config.translations[j].parallelGroup;
if (parallelGroupId === parallelGroupId2) {
group.push(this.config.translations[j]);
done[j] = true;
}
}
}
parallelGroups.push(group);
} else {
parallelGroups.push([this.config.translations[i]]);
}
done[i] = true;
}
return parallelGroups;
}
showStatistics(t) {

@@ -429,0 +467,0 @@ if (this.options.statistics) {

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