@naturalcycles/nodejs-lib 13.31.1 → 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.
@@ -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 32.
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 32.
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 32.
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 = 32, predicate, // we now default to "no predicate" (meaning pass-everything)
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, { Extension, NumberSchema as JoiNumberSchema } from '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, { Extension, StringSchema as JoiStringSchema } from '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,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturalcycles/nodejs-lib",
3
- "version": "13.31.1",
3
+ "version": "13.32.0",
4
4
  "scripts": {
5
5
  "prepare": "husky",
6
6
  "build": "dev-lib build",
@@ -41,7 +41,7 @@
41
41
  "devDependencies": {
42
42
  "@naturalcycles/bench-lib": "^3.0.0",
43
43
  "@naturalcycles/dev-lib": "^15.0.3",
44
- "@types/node": "^20.1.0",
44
+ "@types/node": "^22.1.0",
45
45
  "@types/yargs": "^16.0.0",
46
46
  "jest": "^29.0.0"
47
47
  },
@@ -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 32.
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 32.
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 = 32,
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, { Extension, NumberSchema as JoiNumberSchema } from '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, { Extension, StringSchema as JoiStringSchema } from '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