@vbarbarosh/node-helpers 3.31.0 → 3.32.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "author": "Vladimir Barbarosh <vladimir.barbarosh@gmail.com>",
3
3
  "license": "MIT",
4
4
  "name": "@vbarbarosh/node-helpers",
5
- "version": "3.31.0",
5
+ "version": "3.32.0",
6
6
  "description": "A set of helpers for JavaScript/Node.js",
7
7
  "files": [
8
8
  "src"
package/src/plural.js ADDED
@@ -0,0 +1,6 @@
1
+ function plural(n, apple, apples)
2
+ {
3
+ return (n % 10 === 1 && n % 100 !== 11) ? apple.split('#').join(n) : apples.split('#').join(n);
4
+ }
5
+
6
+ module.exports = plural;
@@ -0,0 +1,18 @@
1
+ const assert = require('assert');
2
+ const plural = require('./plural');
3
+
4
+ const items = [
5
+ ['1 apple', 1, '# apple', '# apples', ],
6
+ ['2 apples', 2, '# apple', '# apples'],
7
+ ['10 apples', 10, '# apple', '# apples'],
8
+ ['21 apple', 21, '# apple', '# apples'],
9
+ ];
10
+
11
+ describe('plural', function () {
12
+ items.forEach(function ([expected, ...args],) {
13
+ it(expected, function () {
14
+ const actual = plural(...args);
15
+ assert.deepStrictEqual(actual, expected);
16
+ });
17
+ });
18
+ });
package/src/shell.js CHANGED
@@ -8,7 +8,7 @@ function shell(args, options)
8
8
  reject(error);
9
9
  }
10
10
  else if (stderr) {
11
- reject(new Error(`Process terminated with the following stderr:\n\n${stderr}`));
11
+ reject(new Error(`Process terminated with the following STDERR:\n\n${stderr}`));
12
12
  }
13
13
  else {
14
14
  resolve(stdout);
package/src/shell_json.js CHANGED
@@ -8,7 +8,7 @@ function shell_json(args, options)
8
8
  reject(error);
9
9
  }
10
10
  else if (stderr) {
11
- reject(new Error(`Process terminated with the following stderr:\n\n${stderr}`));
11
+ reject(new Error(`Process terminated with the following STDERR:\n\n${stderr}`));
12
12
  }
13
13
  else {
14
14
  try {