@naturalcycles/nodejs-lib 12.80.0 → 12.80.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/fs/del.d.ts CHANGED
@@ -12,7 +12,7 @@ export interface DelOptions {
12
12
  debug?: boolean;
13
13
  dry?: boolean;
14
14
  }
15
- export declare type DelSingleOption = string;
15
+ export type DelSingleOption = string;
16
16
  /**
17
17
  * Delete files that match input patterns.
18
18
  *
@@ -78,7 +78,7 @@ export interface SlackMessageAttachment {
78
78
  /**
79
79
  * Return `null` to skip (filter out) the message completely.
80
80
  */
81
- export declare type SlackMessagePrefixHook<CTX = any> = (msg: SlackMessage<CTX>) => string[] | null | Promise<string[] | null>;
81
+ export type SlackMessagePrefixHook<CTX = any> = (msg: SlackMessage<CTX>) => string[] | null | Promise<string[] | null>;
82
82
  export interface SlackServiceCfg<CTX = any> {
83
83
  /**
84
84
  * Undefined means slack is disabled.
@@ -2,7 +2,7 @@
2
2
  /// <reference types="node" />
3
3
  import { Readable, Transform } from 'node:stream';
4
4
  import { DeferredPromise } from '@naturalcycles/js-lib';
5
- declare type AnyStream = NodeJS.ReadableStream | NodeJS.WritableStream | NodeJS.ReadWriteStream;
5
+ type AnyStream = NodeJS.ReadableStream | NodeJS.WritableStream | NodeJS.ReadWriteStream;
6
6
  export interface PipelineOptions {
7
7
  /**
8
8
  * Set to true to allow ERR_STREAM_PREMATURE_CLOSE.
@@ -5,8 +5,9 @@ const node_stream_1 = require("node:stream");
5
5
  const js_lib_1 = require("@naturalcycles/js-lib");
6
6
  function readableMap(readable, mapper) {
7
7
  let i = -1;
8
- // todo: check if we need to handle errors somehow specifically
9
- return readable.pipe(new node_stream_1.Transform({
8
+ const stream = readable
9
+ .on('error', err => stream.emit('error', err))
10
+ .pipe(new node_stream_1.Transform({
10
11
  objectMode: true,
11
12
  async transform(chunk, _enc, cb) {
12
13
  try {
@@ -25,5 +26,6 @@ function readableMap(readable, mapper) {
25
26
  }
26
27
  },
27
28
  }));
29
+ return stream;
28
30
  }
29
31
  exports.readableMap = readableMap;
@@ -1,6 +1,6 @@
1
1
  import { MemoCache } from '@naturalcycles/js-lib';
2
2
  import * as LRUCache from 'lru-cache';
3
- export declare type LRUMemoCacheOptions<KEY, VALUE> = Partial<LRUCache.Options<KEY, VALUE>>;
3
+ export type LRUMemoCacheOptions<KEY, VALUE> = Partial<LRUCache.Options<KEY, VALUE>>;
4
4
  /**
5
5
  * @example
6
6
  * Use it like this:
@@ -1,6 +1,6 @@
1
1
  /// <reference types="node" />
2
2
  import { AlternativesSchema, AnySchema, ArraySchema, BinarySchema, BooleanSchema, DateSchema, FunctionSchema, NumberSchema, ObjectSchema, StringSchema } from 'joi';
3
- export declare type SchemaTyped<IN, OUT = IN> = AnySchemaTyped<IN, OUT> | ArraySchemaTyped<IN> | AlternativesSchemaTyped<IN> | BinarySchemaTyped | BooleanSchemaTyped | DateSchemaTyped<IN> | FunctionSchemaTyped<IN> | NumberSchemaTyped | ObjectSchemaTyped<IN, OUT> | StringSchemaTyped;
3
+ export type SchemaTyped<IN, OUT = IN> = AnySchemaTyped<IN, OUT> | ArraySchemaTyped<IN> | AlternativesSchemaTyped<IN> | BinarySchemaTyped | BooleanSchemaTyped | DateSchemaTyped<IN> | FunctionSchemaTyped<IN> | NumberSchemaTyped | ObjectSchemaTyped<IN, OUT> | StringSchemaTyped;
4
4
  /**
5
5
  * IN - value before validation/conversion
6
6
  * OUT - value after validation/conversion (can be different due to conversion, stripping, etc)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@naturalcycles/nodejs-lib",
3
- "version": "12.80.0",
3
+ "version": "12.80.1",
4
4
  "scripts": {
5
5
  "prepare": "husky install",
6
6
  "docs-serve": "vuepress dev docs",
@@ -8,24 +8,27 @@ export function readableMap<IN, OUT>(
8
8
  ): ReadableTyped<OUT> {
9
9
  let i = -1
10
10
 
11
- // todo: check if we need to handle errors somehow specifically
12
- return readable.pipe(
13
- new Transform({
14
- objectMode: true,
15
- async transform(chunk, _enc, cb) {
16
- try {
17
- const r = await mapper(chunk, ++i)
18
- if (r === SKIP) {
19
- cb()
20
- } else {
21
- // _assert(r !== END, `readableMap END not supported`)
22
- cb(null, r)
11
+ const stream: ReadableTyped<OUT> = readable
12
+ .on('error', err => stream.emit('error', err))
13
+ .pipe(
14
+ new Transform({
15
+ objectMode: true,
16
+ async transform(chunk, _enc, cb) {
17
+ try {
18
+ const r = await mapper(chunk, ++i)
19
+ if (r === SKIP) {
20
+ cb()
21
+ } else {
22
+ // _assert(r !== END, `readableMap END not supported`)
23
+ cb(null, r)
24
+ }
25
+ } catch (err) {
26
+ console.error(err)
27
+ cb(err as Error)
23
28
  }
24
- } catch (err) {
25
- console.error(err)
26
- cb(err as Error)
27
- }
28
- },
29
- }),
30
- )
29
+ },
30
+ }),
31
+ )
32
+
33
+ return stream
31
34
  }