@vbarbarosh/node-helpers 3.47.2 → 3.48.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.47.2",
5
+ "version": "3.48.0",
6
6
  "description": "A set of helpers for JavaScript/Node.js",
7
7
  "files": [
8
8
  "src"
@@ -0,0 +1,6 @@
1
+ function format_date(d)
2
+ {
3
+ return d.getFullYear() + `/0${d.getMonth()+1}/0${d.getDate()} 0${d.getHours()}:0${d.getMinutes()}:0${d.getSeconds()}`.replace(/0(\d\d)/g, '$1');
4
+ }
5
+
6
+ module.exports = format_date;
@@ -0,0 +1,8 @@
1
+ const axios = require('axios');
2
+
3
+ function http_get_utf8(url, options)
4
+ {
5
+ return axios.get(url, {responseType: 'text', responseEncoding: 'utf8', ...options}).then(v => v.data);
6
+ }
7
+
8
+ module.exports = http_get_utf8;
@@ -6,10 +6,10 @@ const stream_map_parallel = require('./stream_map_parallel');
6
6
 
7
7
  describe('stream_map_parallel', function () {
8
8
  it('basic', async function () {
9
- const r = Array(100).fill().map((v,i) => i);
10
- const out = [];
9
+ const actual = [];
10
+ const expected = Array(100).fill().map((v,i) => i);
11
11
  await stream.promises.pipeline(
12
- stream.Readable.from(r),
12
+ stream.Readable.from(expected),
13
13
  stream_map_parallel({
14
14
  concurrency: 5,
15
15
  handler: async function (num) {
@@ -18,9 +18,9 @@ describe('stream_map_parallel', function () {
18
18
  },
19
19
  }),
20
20
  stream_each(function (item) {
21
- out.push(item);
21
+ actual.push(item);
22
22
  }),
23
23
  );
24
- assert.deepStrictEqual(out, r);
24
+ assert.deepStrictEqual(actual, expected);
25
25
  });
26
26
  });