@naturalcycles/nodejs-lib 15.106.3 → 15.107.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/fs/kpy.js CHANGED
@@ -12,7 +12,7 @@ export async function kpy(opt) {
12
12
  });
13
13
  kpyLogFilenames(opt, filenames);
14
14
  const overwrite = !opt.noOverwrite;
15
- await Promise.all(filenames.map(async filename => {
15
+ await Promise.all(filenames.map(async (filename) => {
16
16
  const basename = path.basename(filename);
17
17
  const srcFilename = path.resolve(opt.baseDir, filename);
18
18
  const destFilename = path.resolve(opt.outputDir, opt.flat ? basename : filename);
@@ -74,8 +74,8 @@ class ProcessUtil {
74
74
  getCPUInfo() {
75
75
  // oxlint-disable-next-line unicorn/no-array-reduce
76
76
  return os.cpus().reduce((r, cpu) => {
77
- r['idle'] += cpu.times.idle;
78
- Object.values(cpu.times).forEach(m => (r['total'] += m));
77
+ r.idle += cpu.times.idle;
78
+ Object.values(cpu.times).forEach(m => (r.total += m));
79
79
  return r;
80
80
  }, {
81
81
  idle: 0,
@@ -1,2 +1,2 @@
1
1
  export * from './slack.service.js';
2
- export * from './slack.service.model.js';
2
+ export type * from './slack.service.model.js';
@@ -1,2 +1 @@
1
1
  export * from './slack.service.js';
2
- export * from './slack.service.model.js';
@@ -8,7 +8,7 @@ export * from './progressLogger.js';
8
8
  export * from './readable/createReadable.js';
9
9
  export * from './readable/readableCombined.js';
10
10
  export * from './readable/readableFromArray.js';
11
- export * from './stream.model.js';
11
+ export type * from './stream.model.js';
12
12
  export * from './transform/transformChunk.js';
13
13
  export * from './transform/transformFilter.js';
14
14
  export * from './transform/transformFlatten.js';
@@ -27,7 +27,7 @@ export * from './transform/transformThrottleByRSS.js';
27
27
  export * from './transform/transformWarmup.js';
28
28
  export * from './transform/worker/baseWorkerClass.js';
29
29
  export * from './transform/worker/transformMultiThreaded.js';
30
- export * from './transform/worker/transformMultiThreaded.model.js';
30
+ export type * from './transform/worker/transformMultiThreaded.model.js';
31
31
  export * from './writable/writableChunk.js';
32
32
  export * from './writable/writablePushToArray.js';
33
33
  export * from './writable/writableVoid.js';
@@ -8,7 +8,6 @@ export * from './progressLogger.js';
8
8
  export * from './readable/createReadable.js';
9
9
  export * from './readable/readableCombined.js';
10
10
  export * from './readable/readableFromArray.js';
11
- export * from './stream.model.js';
12
11
  export * from './transform/transformChunk.js';
13
12
  export * from './transform/transformFilter.js';
14
13
  export * from './transform/transformFlatten.js';
@@ -27,7 +26,6 @@ export * from './transform/transformThrottleByRSS.js';
27
26
  export * from './transform/transformWarmup.js';
28
27
  export * from './transform/worker/baseWorkerClass.js';
29
28
  export * from './transform/worker/transformMultiThreaded.js';
30
- export * from './transform/worker/transformMultiThreaded.model.js';
31
29
  export * from './writable/writableChunk.js';
32
30
  export * from './writable/writablePushToArray.js';
33
31
  export * from './writable/writableVoid.js';
@@ -99,7 +99,8 @@ export declare class Pipeline<T = unknown> {
99
99
  parseJson<TO = unknown>(this: Pipeline<Buffer> | Pipeline<Uint8Array> | Pipeline<string>): Pipeline<TO>;
100
100
  gzip(this: Pipeline<Uint8Array>, opt?: ZlibOptions): Pipeline<Uint8Array>;
101
101
  gunzip(this: Pipeline<Uint8Array>, opt?: ZlibOptions): Pipeline<Uint8Array>;
102
- zstdCompress(this: Pipeline<Uint8Array>, level?: Integer, opt?: ZstdOptions): Pipeline<Uint8Array>;
102
+ zstdCompress(this: Pipeline<Uint8Array>, level?: Integer, // defaults to 3
103
+ opt?: ZstdOptions): Pipeline<Uint8Array>;
103
104
  zstdDecompress(this: Pipeline<Uint8Array>, opt?: ZstdOptions): Pipeline<Uint8Array>;
104
105
  toArray(opt?: TransformOptions): Promise<T[]>;
105
106
  toFile(outputFilePath: string): Promise<void>;
@@ -304,7 +304,9 @@ export class Pipeline {
304
304
  else if (outputFilePath.endsWith('.zst')) {
305
305
  this.transforms.push(createZstdCompress(zip2.zstdLevelToOptions(level)));
306
306
  }
307
- this.destination = fs2.createWriteStream(outputFilePath, {});
307
+ this.destination = fs2.createWriteStream(outputFilePath, {
308
+ // highWaterMark: 64 * 1024, // no observed speedup
309
+ });
308
310
  await this.run();
309
311
  }
310
312
  async to(destination) {
@@ -17,7 +17,7 @@ export declare const j: {
17
17
  dbEntity: typeof objectDbEntity;
18
18
  infer: typeof objectInfer;
19
19
  any(): JObject<AnyObject, false>;
20
- stringMap<S extends JSchema<any, any>>(schema: S): JObject<StringMap<SchemaOut<S>>, false>;
20
+ stringMap<S extends JSchema<any, any>>(schema: S): JObject<StringMap<SchemaOut<S>>>;
21
21
  /**
22
22
  * @experimental Look around, maybe you find a rule that is better for your use-case.
23
23
  *
@@ -64,9 +64,9 @@ export declare const j: {
64
64
  };
65
65
  array<OUT, Opt>(itemSchema: JSchema<OUT, Opt>): JArray<OUT, Opt>;
66
66
  tuple<const S extends JSchema<any, any>[]>(items: S): JTuple<S>;
67
- set<OUT, Opt>(itemSchema: JSchema<OUT, Opt>): JSet2Builder<OUT, Opt>;
68
- buffer(): JBuilder<Buffer<ArrayBufferLike>, false>;
69
- enum<const T extends any>(input: T, opt?: JsonBuilderRuleOpt | undefined): JEnum<T extends readonly (infer U)[] ? U : T extends StringEnum ? T[keyof T] : T extends NumberEnum ? T[keyof T] : never, false>;
67
+ set<OUT_1, Opt_1>(itemSchema: JSchema<OUT_1, Opt_1>): JSet2Builder<OUT_1, Opt_1>;
68
+ buffer(): JBuilder<Buffer, false>;
69
+ enum<const T extends readonly (string | number | boolean | null)[] | StringEnum | NumberEnum>(input: T, opt?: JsonBuilderRuleOpt): JEnum<T extends readonly (infer U)[] ? U : T extends StringEnum ? T[keyof T] : T extends NumberEnum ? T[keyof T] : never>;
70
70
  /**
71
71
  * Use only with primitive values, otherwise this function will throw to avoid bugs.
72
72
  * To validate objects, use `anyOfBy`.
@@ -90,7 +90,7 @@ export declare const j: {
90
90
  * Use `anyOf` when schemas may overlap (e.g., AccountId | PartnerId with same format).
91
91
  * Use `oneOf` when schemas are mutually exclusive.
92
92
  */
93
- anyOf<B extends readonly JSchema<any, boolean>[]>(items: [...B]): JBuilder<BuilderOutUnion<B>, false>;
93
+ anyOf<B_1 extends readonly JSchema<any, boolean>[]>(items: [...B_1]): JBuilder<BuilderOutUnion<B_1>, false>;
94
94
  /**
95
95
  * Pick validation schema for an object based on the value of a specific property.
96
96
  *
@@ -112,7 +112,7 @@ export declare const j: {
112
112
  * const schema = j.anyOfThese([successSchema, errorSchema])
113
113
  * ```
114
114
  */
115
- anyOfThese<B extends readonly JSchema<any, boolean>[]>(items: [...B]): JBuilder<BuilderOutUnion<B>, false>;
115
+ anyOfThese<B_2 extends readonly JSchema<any, boolean>[]>(items: [...B_2]): JBuilder<BuilderOutUnion<B_2>, false>;
116
116
  and(): {
117
117
  silentBob: () => never;
118
118
  };
@@ -123,10 +123,10 @@ export declare const j: {
123
123
  *
124
124
  * Optionally accepts a custom Ajv instance and/or inputName for error messages.
125
125
  */
126
- fromSchema<OUT>(schema: JsonSchema<OUT>, cfg?: {
127
- ajv?: Ajv | undefined;
128
- inputName?: string | undefined;
129
- } | undefined): JSchema<OUT, false>;
126
+ fromSchema<OUT_2>(schema: JsonSchema<OUT_2>, cfg?: {
127
+ ajv?: Ajv;
128
+ inputName?: string;
129
+ }): JSchema<OUT_2, false>;
130
130
  };
131
131
  export declare const HIDDEN_AJV_SCHEMA: unique symbol;
132
132
  export type WithCachedAjvSchema<Base, OUT> = Base & {
@@ -363,8 +363,8 @@ export declare class JObject<OUT extends AnyObject, Opt extends boolean = false>
363
363
  */
364
364
  dbEntity(): JObject<Expand<Override<OUT, {
365
365
  id: string;
366
- created: UnixTimestamp;
367
- updated: UnixTimestamp;
366
+ created: JNumber<UnixTimestamp, false>;
367
+ updated: JNumber<UnixTimestamp, false>;
368
368
  } & {}>>, false>;
369
369
  minProperties(minProperties: number): this;
370
370
  maxProperties(maxProperties: number): this;
@@ -37,11 +37,19 @@ declare class Zip2 {
37
37
  gunzipSync(buf: Buffer, options?: ZlibOptions): Buffer<ArrayBuffer>;
38
38
  gunzipToString(buf: Buffer, options?: ZlibOptions): Promise<string>;
39
39
  gunzipToStringSync(buf: Buffer, options?: ZlibOptions): string;
40
- zstdCompress(input: Buffer | string, level?: Integer, options?: ZstdOptions): Promise<Buffer<ArrayBuffer>>;
41
- zstdCompressSync(input: Buffer | string, level?: Integer, options?: ZstdOptions): Buffer<ArrayBuffer>;
40
+ zstdCompress(input: Buffer | string, level?: Integer, // defaults to 3
41
+ options?: ZstdOptions): Promise<Buffer<ArrayBuffer>>;
42
+ zstdCompressSync(input: Buffer | string, level?: Integer, // defaults to 3
43
+ options?: ZstdOptions): Buffer<ArrayBuffer>;
42
44
  zstdLevelToOptions(level: Integer | undefined, opt?: ZstdOptions): ZstdOptions;
43
45
  zstdDecompressToString(input: Buffer, options?: ZstdOptions): Promise<string>;
46
+ /**
47
+ * Warning! It leaks memory severely. Prefer sync.
48
+ */
44
49
  zstdDecompress(input: Buffer, options?: ZstdOptions): Promise<Buffer<ArrayBuffer>>;
50
+ /**
51
+ * Warning! It leaks memory severely. Prefer sync.
52
+ */
45
53
  zstdDecompressToStringSync(input: Buffer, options?: ZstdOptions): string;
46
54
  zstdDecompressSync(input: Buffer, options?: ZstdOptions): Buffer<ArrayBuffer>;
47
55
  isZstdBuffer(input: Buffer): boolean;
package/dist/zip/zip2.js CHANGED
@@ -103,9 +103,15 @@ class Zip2 {
103
103
  async zstdDecompressToString(input, options = {}) {
104
104
  return (await zstdDecompressAsync(input, options)).toString();
105
105
  }
106
+ /**
107
+ * Warning! It leaks memory severely. Prefer sync.
108
+ */
106
109
  async zstdDecompress(input, options = {}) {
107
110
  return await zstdDecompressAsync(input, options);
108
111
  }
112
+ /**
113
+ * Warning! It leaks memory severely. Prefer sync.
114
+ */
109
115
  zstdDecompressToStringSync(input, options = {}) {
110
116
  return zlib.zstdDecompressSync(input, options).toString();
111
117
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@naturalcycles/nodejs-lib",
3
3
  "type": "module",
4
- "version": "15.106.3",
4
+ "version": "15.107.0",
5
5
  "dependencies": {
6
6
  "@naturalcycles/js-lib": "^15",
7
7
  "@standard-schema/spec": "^1",
@@ -17,8 +17,8 @@
17
17
  "yargs": "^18"
18
18
  },
19
19
  "devDependencies": {
20
- "@typescript/native-preview": "7.0.0-dev.20260301.1",
21
- "@naturalcycles/dev-lib": "18.4.2"
20
+ "@typescript/native-preview": "7.0.0-dev.20260401.1",
21
+ "@naturalcycles/dev-lib": "20.42.0"
22
22
  },
23
23
  "exports": {
24
24
  ".": "./dist/index.js",
@@ -104,8 +104,8 @@ class ProcessUtil {
104
104
  // oxlint-disable-next-line unicorn/no-array-reduce
105
105
  return os.cpus().reduce(
106
106
  (r, cpu) => {
107
- r['idle'] += cpu.times.idle
108
- Object.values(cpu.times).forEach(m => (r['total'] += m))
107
+ r.idle += cpu.times.idle
108
+ Object.values(cpu.times).forEach(m => (r.total += m))
109
109
  return r
110
110
  },
111
111
  {
@@ -1,2 +1,2 @@
1
1
  export * from './slack.service.js'
2
- export * from './slack.service.model.js'
2
+ export type * from './slack.service.model.js'
@@ -8,7 +8,7 @@ export * from './progressLogger.js'
8
8
  export * from './readable/createReadable.js'
9
9
  export * from './readable/readableCombined.js'
10
10
  export * from './readable/readableFromArray.js'
11
- export * from './stream.model.js'
11
+ export type * from './stream.model.js'
12
12
  export * from './transform/transformChunk.js'
13
13
  export * from './transform/transformFilter.js'
14
14
  export * from './transform/transformFlatten.js'
@@ -27,7 +27,7 @@ export * from './transform/transformThrottleByRSS.js'
27
27
  export * from './transform/transformWarmup.js'
28
28
  export * from './transform/worker/baseWorkerClass.js'
29
29
  export * from './transform/worker/transformMultiThreaded.js'
30
- export * from './transform/worker/transformMultiThreaded.model.js'
30
+ export type * from './transform/worker/transformMultiThreaded.model.js'
31
31
  export * from './writable/writableChunk.js'
32
32
  export * from './writable/writablePushToArray.js'
33
33
  export * from './writable/writableVoid.js'
package/src/zip/zip2.ts CHANGED
@@ -133,10 +133,16 @@ class Zip2 {
133
133
  return (await zstdDecompressAsync(input, options)).toString()
134
134
  }
135
135
 
136
+ /**
137
+ * Warning! It leaks memory severely. Prefer sync.
138
+ */
136
139
  async zstdDecompress(input: Buffer, options: ZstdOptions = {}): Promise<Buffer<ArrayBuffer>> {
137
140
  return await zstdDecompressAsync(input, options)
138
141
  }
139
142
 
143
+ /**
144
+ * Warning! It leaks memory severely. Prefer sync.
145
+ */
140
146
  zstdDecompressToStringSync(input: Buffer, options: ZstdOptions = {}): string {
141
147
  return zlib.zstdDecompressSync(input, options).toString()
142
148
  }