@naturalcycles/nodejs-lib 15.122.4 → 15.123.1
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/infra/process.util.d.ts +2 -1
- package/dist/infra/process.util.js +4 -3
- package/dist/script/runScript.js +1 -1
- package/dist/validation/ajv/jSchema.d.ts +4 -2
- package/package.json +1 -1
- package/src/infra/process.util.ts +6 -4
- package/src/script/runScript.ts +1 -1
- package/src/validation/ajv/jSchema.ts +9 -12
|
@@ -3,15 +3,16 @@ export declare function memoryUsage(): {
|
|
|
3
3
|
heapTotal: number;
|
|
4
4
|
heapUsed: number;
|
|
5
5
|
external: number;
|
|
6
|
+
arrayBuffers: number;
|
|
6
7
|
};
|
|
7
8
|
export declare function memoryUsageFull(): {
|
|
8
9
|
rss: number;
|
|
9
10
|
heapTotal: number;
|
|
10
11
|
heapUsed: number;
|
|
11
12
|
external: number;
|
|
13
|
+
arrayBuffers: number;
|
|
12
14
|
totalMem: number;
|
|
13
15
|
freeMem: number;
|
|
14
|
-
usedMem: number;
|
|
15
16
|
};
|
|
16
17
|
declare class ProcessUtil {
|
|
17
18
|
private timer;
|
|
@@ -1,16 +1,17 @@
|
|
|
1
1
|
import os from 'node:os';
|
|
2
2
|
import { _mb } from '@naturalcycles/js-lib';
|
|
3
3
|
export function memoryUsage() {
|
|
4
|
-
const { rss, external, heapUsed, heapTotal } = process.memoryUsage();
|
|
4
|
+
const { rss, external, arrayBuffers, heapUsed, heapTotal } = process.memoryUsage();
|
|
5
5
|
return {
|
|
6
6
|
rss: _mb(rss),
|
|
7
7
|
heapTotal: _mb(heapTotal),
|
|
8
8
|
heapUsed: _mb(heapUsed),
|
|
9
9
|
external: _mb(external),
|
|
10
|
+
arrayBuffers: _mb(arrayBuffers),
|
|
10
11
|
};
|
|
11
12
|
}
|
|
12
13
|
export function memoryUsageFull() {
|
|
13
|
-
const { rss, external, heapUsed, heapTotal } = process.memoryUsage();
|
|
14
|
+
const { rss, external, arrayBuffers, heapUsed, heapTotal } = process.memoryUsage();
|
|
14
15
|
const totalMem = os.totalmem();
|
|
15
16
|
const freeMem = os.freemem();
|
|
16
17
|
return {
|
|
@@ -18,9 +19,9 @@ export function memoryUsageFull() {
|
|
|
18
19
|
heapTotal: _mb(heapTotal),
|
|
19
20
|
heapUsed: _mb(heapUsed),
|
|
20
21
|
external: _mb(external),
|
|
22
|
+
arrayBuffers: _mb(arrayBuffers),
|
|
21
23
|
totalMem: _mb(totalMem),
|
|
22
24
|
freeMem: _mb(freeMem),
|
|
23
|
-
usedMem: _mb(totalMem - freeMem),
|
|
24
25
|
};
|
|
25
26
|
}
|
|
26
27
|
class ProcessUtil {
|
package/dist/script/runScript.js
CHANGED
|
@@ -68,7 +68,7 @@ export function runScript(fn, opt = {}) {
|
|
|
68
68
|
function checkAndlogEnvironment() {
|
|
69
69
|
const { platform, arch, versions: { node }, env: { CPU_LIMIT, NODE_OPTIONS, TZ }, } = process;
|
|
70
70
|
const cpuLimit = Number(CPU_LIMIT) || undefined;
|
|
71
|
-
const availableParallelism = os.availableParallelism
|
|
71
|
+
const availableParallelism = os.availableParallelism();
|
|
72
72
|
const cpus = os.cpus().length;
|
|
73
73
|
console.log(dimGrey(formatObject({
|
|
74
74
|
node: `${node} ${platform} ${arch}`,
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { ValidationFunction, ValidationFunctionResult } from '@naturalcycles/js-lib';
|
|
2
2
|
import type { Set2 } from '@naturalcycles/js-lib/object';
|
|
3
|
-
import type { AnyObject, BaseDBEntity, IANATimezone, Inclusiveness, IsoDate, IsoDateTime, IsoMonth, NumberEnum, StringEnum, StringMap, UnixTimestamp, UnixTimestampMillis } from '@naturalcycles/js-lib/types';
|
|
3
|
+
import type { AnyObject, BaseDBEntity, IANATimezone, Inclusiveness, IsoDate, IsoDateTime, IsoMonth, Enum, NumberEnum, StringEnum, StringMap, UnixTimestamp, UnixTimestampMillis } from '@naturalcycles/js-lib/types';
|
|
4
4
|
import type { StandardJSONSchemaV1, StandardSchemaV1 } from '@standard-schema/spec';
|
|
5
5
|
import type { Ajv, ValidateFunction } from 'ajv';
|
|
6
6
|
import { AjvValidationError } from './ajvValidationError.js';
|
|
@@ -66,7 +66,9 @@ export declare const j: {
|
|
|
66
66
|
tuple<const S extends JSchema<any, any>[]>(items: S): JTuple<S>;
|
|
67
67
|
set<OUT, Opt>(itemSchema: JSchema<OUT, Opt>): JSet2Builder<OUT, Opt>;
|
|
68
68
|
buffer(): JBuilder<Buffer, false>;
|
|
69
|
-
enum<const T extends readonly (string | number | boolean | null)[] | StringEnum | NumberEnum
|
|
69
|
+
enum<const T extends readonly (string | number | boolean | null)[] | StringEnum | NumberEnum | {
|
|
70
|
+
readonly values: readonly (string | number | boolean | null)[];
|
|
71
|
+
}>(input: T, opt?: JsonBuilderRuleOpt): JEnum<T extends readonly (infer U)[] ? U : Enum<T>>;
|
|
70
72
|
/**
|
|
71
73
|
* Use only with primitive values, otherwise this function will throw to avoid bugs.
|
|
72
74
|
* To validate objects, use `anyOfBy`.
|
package/package.json
CHANGED
|
@@ -6,13 +6,15 @@ export function memoryUsage(): {
|
|
|
6
6
|
heapTotal: number
|
|
7
7
|
heapUsed: number
|
|
8
8
|
external: number
|
|
9
|
+
arrayBuffers: number
|
|
9
10
|
} {
|
|
10
|
-
const { rss, external, heapUsed, heapTotal } = process.memoryUsage()
|
|
11
|
+
const { rss, external, arrayBuffers, heapUsed, heapTotal } = process.memoryUsage()
|
|
11
12
|
return {
|
|
12
13
|
rss: _mb(rss),
|
|
13
14
|
heapTotal: _mb(heapTotal),
|
|
14
15
|
heapUsed: _mb(heapUsed),
|
|
15
16
|
external: _mb(external),
|
|
17
|
+
arrayBuffers: _mb(arrayBuffers),
|
|
16
18
|
}
|
|
17
19
|
}
|
|
18
20
|
|
|
@@ -21,11 +23,11 @@ export function memoryUsageFull(): {
|
|
|
21
23
|
heapTotal: number
|
|
22
24
|
heapUsed: number
|
|
23
25
|
external: number
|
|
26
|
+
arrayBuffers: number
|
|
24
27
|
totalMem: number
|
|
25
28
|
freeMem: number
|
|
26
|
-
usedMem: number
|
|
27
29
|
} {
|
|
28
|
-
const { rss, external, heapUsed, heapTotal } = process.memoryUsage()
|
|
30
|
+
const { rss, external, arrayBuffers, heapUsed, heapTotal } = process.memoryUsage()
|
|
29
31
|
const totalMem = os.totalmem()
|
|
30
32
|
const freeMem = os.freemem()
|
|
31
33
|
return {
|
|
@@ -33,9 +35,9 @@ export function memoryUsageFull(): {
|
|
|
33
35
|
heapTotal: _mb(heapTotal),
|
|
34
36
|
heapUsed: _mb(heapUsed),
|
|
35
37
|
external: _mb(external),
|
|
38
|
+
arrayBuffers: _mb(arrayBuffers),
|
|
36
39
|
totalMem: _mb(totalMem),
|
|
37
40
|
freeMem: _mb(freeMem),
|
|
38
|
-
usedMem: _mb(totalMem - freeMem),
|
|
39
41
|
}
|
|
40
42
|
}
|
|
41
43
|
|
package/src/script/runScript.ts
CHANGED
|
@@ -105,7 +105,7 @@ function checkAndlogEnvironment(): void {
|
|
|
105
105
|
} = process
|
|
106
106
|
|
|
107
107
|
const cpuLimit = Number(CPU_LIMIT) || undefined
|
|
108
|
-
const availableParallelism = os.availableParallelism
|
|
108
|
+
const availableParallelism = os.availableParallelism()
|
|
109
109
|
const cpus = os.cpus().length
|
|
110
110
|
console.log(
|
|
111
111
|
dimGrey(
|
|
@@ -19,6 +19,7 @@ import type {
|
|
|
19
19
|
IsoDate,
|
|
20
20
|
IsoDateTime,
|
|
21
21
|
IsoMonth,
|
|
22
|
+
Enum,
|
|
22
23
|
NumberEnum,
|
|
23
24
|
StringEnum,
|
|
24
25
|
StringMap,
|
|
@@ -172,18 +173,14 @@ export const j = {
|
|
|
172
173
|
})
|
|
173
174
|
},
|
|
174
175
|
|
|
175
|
-
enum<
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
:
|
|
182
|
-
|
|
183
|
-
: T extends NumberEnum
|
|
184
|
-
? T[keyof T]
|
|
185
|
-
: never
|
|
186
|
-
> {
|
|
176
|
+
enum<
|
|
177
|
+
const T extends
|
|
178
|
+
| readonly (string | number | boolean | null)[]
|
|
179
|
+
| StringEnum
|
|
180
|
+
| NumberEnum
|
|
181
|
+
// an `_enum()` object, which carries helpers and so satisfies neither of the two above
|
|
182
|
+
| { readonly values: readonly (string | number | boolean | null)[] },
|
|
183
|
+
>(input: T, opt?: JsonBuilderRuleOpt): JEnum<T extends readonly (infer U)[] ? U : Enum<T>> {
|
|
187
184
|
let enumValues: readonly (string | number | boolean | null)[] | undefined
|
|
188
185
|
let baseType: EnumBaseType = 'other'
|
|
189
186
|
|