@naturalcycles/nodejs-lib 13.45.3 → 13.45.4
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/dist/csv/csvWriter.js +1 -0
- package/dist/fs/fs2.js +18 -20
- package/dist/infra/process.util.js +1 -0
- package/dist/jwt/jwt.service.js +1 -0
- package/dist/slack/slack.service.js +2 -0
- package/dist/stream/ndjson/ndjson.model.js +3 -5
- package/dist/stream/pipeline/pipeline.js +2 -0
- package/dist/stream/progressLogger.js +10 -0
- package/dist/stream/sizeStack.js +2 -1
- package/dist/stream/transform/worker/baseWorkerClass.js +1 -0
- package/dist/util/lruMemoCache.js +1 -0
- package/dist/validation/ajv/ajvSchema.js +3 -0
- package/package.json +1 -1
package/dist/csv/csvWriter.js
CHANGED
package/dist/fs/fs2.js
CHANGED
|
@@ -35,26 +35,9 @@ const env_util_1 = require("../util/env.util");
|
|
|
35
35
|
* 3. fs-extra
|
|
36
36
|
*/
|
|
37
37
|
class FS2 {
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
// - sync function has postfix in the name, e.g readText
|
|
42
|
-
// Re-export the whole fs/fsp, for the edge cases where they are needed
|
|
43
|
-
this.fs = node_fs_1.default;
|
|
44
|
-
this.fsp = promises_1.default;
|
|
45
|
-
// Re-export existing fs/fsp functions
|
|
46
|
-
// rm/rmAsync are replaced with removePath/removePathAsync
|
|
47
|
-
this.lstat = node_fs_1.default.lstatSync;
|
|
48
|
-
this.lstatAsync = promises_1.default.lstat;
|
|
49
|
-
this.stat = node_fs_1.default.statSync;
|
|
50
|
-
this.statAsync = promises_1.default.stat;
|
|
51
|
-
this.mkdir = node_fs_1.default.mkdirSync;
|
|
52
|
-
this.mkdirAsync = promises_1.default.mkdir;
|
|
53
|
-
this.readdir = node_fs_1.default.readdirSync;
|
|
54
|
-
this.readdirAsync = promises_1.default.readdir;
|
|
55
|
-
this.createWriteStream = node_fs_1.default.createWriteStream;
|
|
56
|
-
this.createReadStream = node_fs_1.default.createReadStream;
|
|
57
|
-
}
|
|
38
|
+
// Naming convention is:
|
|
39
|
+
// - async function has Async in the name, e.g readTextAsync
|
|
40
|
+
// - sync function has postfix in the name, e.g readText
|
|
58
41
|
/**
|
|
59
42
|
* Convenience wrapper that defaults to utf-8 string output.
|
|
60
43
|
*/
|
|
@@ -291,6 +274,21 @@ class FS2 {
|
|
|
291
274
|
})
|
|
292
275
|
?.isDirectory() || false);
|
|
293
276
|
}
|
|
277
|
+
// Re-export the whole fs/fsp, for the edge cases where they are needed
|
|
278
|
+
fs = node_fs_1.default;
|
|
279
|
+
fsp = promises_1.default;
|
|
280
|
+
// Re-export existing fs/fsp functions
|
|
281
|
+
// rm/rmAsync are replaced with removePath/removePathAsync
|
|
282
|
+
lstat = node_fs_1.default.lstatSync;
|
|
283
|
+
lstatAsync = promises_1.default.lstat;
|
|
284
|
+
stat = node_fs_1.default.statSync;
|
|
285
|
+
statAsync = promises_1.default.stat;
|
|
286
|
+
mkdir = node_fs_1.default.mkdirSync;
|
|
287
|
+
mkdirAsync = promises_1.default.mkdir;
|
|
288
|
+
readdir = node_fs_1.default.readdirSync;
|
|
289
|
+
readdirAsync = promises_1.default.readdir;
|
|
290
|
+
createWriteStream = node_fs_1.default.createWriteStream;
|
|
291
|
+
createReadStream = node_fs_1.default.createReadStream;
|
|
294
292
|
/*
|
|
295
293
|
Returns a Readable of [already parsed] NDJSON objects.
|
|
296
294
|
|
package/dist/jwt/jwt.service.js
CHANGED
|
@@ -4,11 +4,6 @@ exports.NDJsonStats = void 0;
|
|
|
4
4
|
const js_lib_1 = require("@naturalcycles/js-lib");
|
|
5
5
|
const colors_1 = require("../../colors/colors");
|
|
6
6
|
class NDJsonStats {
|
|
7
|
-
constructor() {
|
|
8
|
-
this.tookMillis = 0;
|
|
9
|
-
this.rows = 0;
|
|
10
|
-
this.sizeBytes = 0;
|
|
11
|
-
}
|
|
12
7
|
static create(o = {}) {
|
|
13
8
|
return Object.assign(new NDJsonStats(), o);
|
|
14
9
|
}
|
|
@@ -19,6 +14,9 @@ class NDJsonStats {
|
|
|
19
14
|
// eslint-disable-next-line unicorn/no-array-reduce
|
|
20
15
|
return stats.reduce((statsTotal, stats) => statsTotal.add(stats), new NDJsonStats());
|
|
21
16
|
}
|
|
17
|
+
tookMillis = 0;
|
|
18
|
+
rows = 0;
|
|
19
|
+
sizeBytes = 0;
|
|
22
20
|
get rpsTotal() {
|
|
23
21
|
return Math.round(this.rows / ((this.tookMillis || 1) / 1000));
|
|
24
22
|
}
|
|
@@ -29,6 +29,16 @@ class ProgressLogger {
|
|
|
29
29
|
this.start();
|
|
30
30
|
this.logStats(); // initial
|
|
31
31
|
}
|
|
32
|
+
cfg;
|
|
33
|
+
started;
|
|
34
|
+
lastSecondStarted;
|
|
35
|
+
sma;
|
|
36
|
+
logEvery10;
|
|
37
|
+
processedLastSecond;
|
|
38
|
+
progress;
|
|
39
|
+
peakRSS;
|
|
40
|
+
sizes;
|
|
41
|
+
sizesZipped;
|
|
32
42
|
start() {
|
|
33
43
|
this.started = Date.now();
|
|
34
44
|
this.lastSecondStarted = Date.now();
|
package/dist/stream/sizeStack.js
CHANGED
|
@@ -5,11 +5,12 @@ const js_lib_1 = require("@naturalcycles/js-lib");
|
|
|
5
5
|
const colors_1 = require("../colors/colors");
|
|
6
6
|
const zip_util_1 = require("../util/zip.util");
|
|
7
7
|
class SizeStack extends js_lib_1.NumberStack {
|
|
8
|
+
name;
|
|
8
9
|
constructor(name, size) {
|
|
9
10
|
super(size);
|
|
10
11
|
this.name = name;
|
|
11
|
-
this.total = 0;
|
|
12
12
|
}
|
|
13
|
+
total = 0;
|
|
13
14
|
push(item) {
|
|
14
15
|
this.total += item;
|
|
15
16
|
return super.push(item);
|
|
@@ -12,6 +12,7 @@ const getAjv_1 = require("./getAjv");
|
|
|
12
12
|
* @experimental
|
|
13
13
|
*/
|
|
14
14
|
class AjvSchema {
|
|
15
|
+
schema;
|
|
15
16
|
constructor(schema, cfg = {}) {
|
|
16
17
|
this.schema = schema;
|
|
17
18
|
this.cfg = {
|
|
@@ -62,6 +63,8 @@ class AjvSchema {
|
|
|
62
63
|
const schema = index_1.fs2.readJson(filePath);
|
|
63
64
|
return new AjvSchema(schema, cfg);
|
|
64
65
|
}
|
|
66
|
+
cfg;
|
|
67
|
+
validateFunction;
|
|
65
68
|
/**
|
|
66
69
|
* It returns the original object just for convenience.
|
|
67
70
|
* Reminder: Ajv will MUTATE your object under 2 circumstances:
|