@naturalcycles/nodejs-lib 13.31.0 → 13.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/dist/stream/ndjson/ndjson.model.js +3 -3
- package/dist/stream/transform/transformMap.d.ts +4 -2
- package/dist/stream/transform/transformMap.js +2 -2
- package/dist/validation/joi/number.extensions.d.ts +2 -1
- package/dist/validation/joi/string.extensions.d.ts +2 -1
- package/package.json +8 -3
- package/src/stream/ndjson/ndjson.model.ts +3 -3
- package/src/stream/transform/transformMap.ts +5 -3
- package/src/validation/joi/number.extensions.ts +2 -1
- package/src/validation/joi/string.extensions.ts +2 -1
|
@@ -41,9 +41,9 @@ class NDJsonStats {
|
|
|
41
41
|
toPretty(name) {
|
|
42
42
|
return [
|
|
43
43
|
`Processed ${name ? (0, colors_1.boldWhite)(name) + ': ' : ''}${(0, colors_1.dimWhite)(this.rows)} rows, ${(0, colors_1.dimWhite)((0, js_lib_1._hb)(this.sizeBytes))} in ${(0, colors_1.dimWhite)((0, js_lib_1._ms)(this.tookMillis))}`,
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
44
|
+
(0, colors_1.dimWhite)(this.rpsTotal + ' rows/sec'),
|
|
45
|
+
(0, colors_1.dimWhite)((0, js_lib_1._hb)(this.avgBytesPerRow) + '/row'),
|
|
46
|
+
(0, colors_1.dimWhite)((0, js_lib_1._hb)(this.bpsTotal) + '/sec'),
|
|
47
47
|
].join(', ');
|
|
48
48
|
}
|
|
49
49
|
}
|
|
@@ -18,10 +18,12 @@ export interface TransformMapOptions<IN = any, OUT = IN> {
|
|
|
18
18
|
/**
|
|
19
19
|
* Number of concurrently pending promises returned by `mapper`.
|
|
20
20
|
*
|
|
21
|
-
* Default is
|
|
21
|
+
* Default is 16.
|
|
22
22
|
* It was recently changed up from 16, after some testing that shown that
|
|
23
23
|
* for simple low-cpu mapper functions 32 produces almost 2x throughput.
|
|
24
24
|
* For example, in scenarios like streaming a query from Datastore.
|
|
25
|
+
* UPD: changed back from 32 to 16, "to be on a safe side", as 32 sometimes
|
|
26
|
+
* causes "Datastore timeout errors".
|
|
25
27
|
*/
|
|
26
28
|
concurrency?: number;
|
|
27
29
|
/**
|
|
@@ -86,7 +88,7 @@ export interface TransformMapStatsSummary extends TransformMapStats {
|
|
|
86
88
|
*
|
|
87
89
|
* Only works in objectMode (due to through2Concurrent).
|
|
88
90
|
*
|
|
89
|
-
* Concurrency defaults to
|
|
91
|
+
* Concurrency defaults to 16.
|
|
90
92
|
*
|
|
91
93
|
* If an Array is returned by `mapper` - it will be flattened and multiple results will be emitted from it. Tested by Array.isArray().
|
|
92
94
|
*/
|
|
@@ -16,12 +16,12 @@ const stream_util_1 = require("../stream.util");
|
|
|
16
16
|
*
|
|
17
17
|
* Only works in objectMode (due to through2Concurrent).
|
|
18
18
|
*
|
|
19
|
-
* Concurrency defaults to
|
|
19
|
+
* Concurrency defaults to 16.
|
|
20
20
|
*
|
|
21
21
|
* If an Array is returned by `mapper` - it will be flattened and multiple results will be emitted from it. Tested by Array.isArray().
|
|
22
22
|
*/
|
|
23
23
|
function transformMap(mapper, opt = {}) {
|
|
24
|
-
const { concurrency =
|
|
24
|
+
const { concurrency = 16, predicate, // we now default to "no predicate" (meaning pass-everything)
|
|
25
25
|
errorMode = js_lib_1.ErrorMode.THROW_IMMEDIATELY, flattenArrayOutput, onError, onDone, metric = 'stream', logger = console, } = opt;
|
|
26
26
|
const started = Date.now();
|
|
27
27
|
let index = -1;
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import Joi
|
|
1
|
+
import type Joi from 'joi';
|
|
2
|
+
import { Extension, NumberSchema as JoiNumberSchema } from 'joi';
|
|
2
3
|
export interface NumberSchema<TSchema = number> extends JoiNumberSchema<TSchema> {
|
|
3
4
|
dividable: (q: number) => this;
|
|
4
5
|
}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import Joi
|
|
1
|
+
import type Joi from 'joi';
|
|
2
|
+
import { Extension, StringSchema as JoiStringSchema } from 'joi';
|
|
2
3
|
export interface StringSchema<TSchema = string> extends JoiStringSchema<TSchema> {
|
|
3
4
|
dateString: (min?: string, max?: string) => this;
|
|
4
5
|
}
|
package/package.json
CHANGED
|
@@ -1,8 +1,13 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@naturalcycles/nodejs-lib",
|
|
3
|
-
"version": "13.
|
|
3
|
+
"version": "13.32.0",
|
|
4
4
|
"scripts": {
|
|
5
5
|
"prepare": "husky",
|
|
6
|
+
"build": "dev-lib build",
|
|
7
|
+
"test": "dev-lib test",
|
|
8
|
+
"lint": "dev-lib lint",
|
|
9
|
+
"bt": "dev-lib bt",
|
|
10
|
+
"lbt": "dev-lib lbt",
|
|
6
11
|
"docs-serve": "vuepress dev docs",
|
|
7
12
|
"docs-build": "vuepress build docs",
|
|
8
13
|
"slack-this-debug": "tsn ./src/bin/slack-this.ts --channel test --msg 'Hello slack!'",
|
|
@@ -35,8 +40,8 @@
|
|
|
35
40
|
},
|
|
36
41
|
"devDependencies": {
|
|
37
42
|
"@naturalcycles/bench-lib": "^3.0.0",
|
|
38
|
-
"@naturalcycles/dev-lib": "^
|
|
39
|
-
"@types/node": "^
|
|
43
|
+
"@naturalcycles/dev-lib": "^15.0.3",
|
|
44
|
+
"@types/node": "^22.1.0",
|
|
40
45
|
"@types/yargs": "^16.0.0",
|
|
41
46
|
"jest": "^29.0.0"
|
|
42
47
|
},
|
|
@@ -46,9 +46,9 @@ export class NDJsonStats {
|
|
|
46
46
|
`Processed ${name ? boldWhite(name) + ': ' : ''}${dimWhite(this.rows)} rows, ${dimWhite(
|
|
47
47
|
_hb(this.sizeBytes),
|
|
48
48
|
)} in ${dimWhite(_ms(this.tookMillis))}`,
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
49
|
+
dimWhite(this.rpsTotal + ' rows/sec'),
|
|
50
|
+
dimWhite(_hb(this.avgBytesPerRow) + '/row'),
|
|
51
|
+
dimWhite(_hb(this.bpsTotal) + '/sec'),
|
|
52
52
|
].join(', ')
|
|
53
53
|
}
|
|
54
54
|
}
|
|
@@ -40,10 +40,12 @@ export interface TransformMapOptions<IN = any, OUT = IN> {
|
|
|
40
40
|
/**
|
|
41
41
|
* Number of concurrently pending promises returned by `mapper`.
|
|
42
42
|
*
|
|
43
|
-
* Default is
|
|
43
|
+
* Default is 16.
|
|
44
44
|
* It was recently changed up from 16, after some testing that shown that
|
|
45
45
|
* for simple low-cpu mapper functions 32 produces almost 2x throughput.
|
|
46
46
|
* For example, in scenarios like streaming a query from Datastore.
|
|
47
|
+
* UPD: changed back from 32 to 16, "to be on a safe side", as 32 sometimes
|
|
48
|
+
* causes "Datastore timeout errors".
|
|
47
49
|
*/
|
|
48
50
|
concurrency?: number
|
|
49
51
|
|
|
@@ -120,7 +122,7 @@ export interface TransformMapStatsSummary extends TransformMapStats {
|
|
|
120
122
|
*
|
|
121
123
|
* Only works in objectMode (due to through2Concurrent).
|
|
122
124
|
*
|
|
123
|
-
* Concurrency defaults to
|
|
125
|
+
* Concurrency defaults to 16.
|
|
124
126
|
*
|
|
125
127
|
* If an Array is returned by `mapper` - it will be flattened and multiple results will be emitted from it. Tested by Array.isArray().
|
|
126
128
|
*/
|
|
@@ -129,7 +131,7 @@ export function transformMap<IN = any, OUT = IN>(
|
|
|
129
131
|
opt: TransformMapOptions<IN, OUT> = {},
|
|
130
132
|
): TransformTyped<IN, OUT> {
|
|
131
133
|
const {
|
|
132
|
-
concurrency =
|
|
134
|
+
concurrency = 16,
|
|
133
135
|
predicate, // we now default to "no predicate" (meaning pass-everything)
|
|
134
136
|
errorMode = ErrorMode.THROW_IMMEDIATELY,
|
|
135
137
|
flattenArrayOutput,
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import Joi
|
|
1
|
+
import type Joi from 'joi'
|
|
2
|
+
import { Extension, NumberSchema as JoiNumberSchema } from 'joi'
|
|
2
3
|
|
|
3
4
|
export interface NumberSchema<TSchema = number> extends JoiNumberSchema<TSchema> {
|
|
4
5
|
dividable: (q: number) => this
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { localTime } from '@naturalcycles/js-lib'
|
|
2
|
-
import Joi
|
|
2
|
+
import type Joi from 'joi'
|
|
3
|
+
import { Extension, StringSchema as JoiStringSchema } from 'joi'
|
|
3
4
|
|
|
4
5
|
export interface StringSchema<TSchema = string> extends JoiStringSchema<TSchema> {
|
|
5
6
|
dateString: (min?: string, max?: string) => this
|