@naturalcycles/nodejs-lib 15.131.0 → 15.132.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/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
- export * from './buffer/buffer.util.js';
2
1
  export * from './diff/tableDiff.js';
3
2
  export * from './infra/process.util.js';
4
3
  export * from './log/log.util.js';
package/dist/index.js CHANGED
@@ -1,4 +1,3 @@
1
- export * from './buffer/buffer.util.js';
2
1
  export * from './diff/tableDiff.js';
3
2
  export * from './infra/process.util.js';
4
3
  export * from './log/log.util.js';
@@ -1,7 +1,7 @@
1
1
  import type { Transform } from 'node:stream';
2
2
  import type { ReadableStream as WebReadableStream } from 'node:stream/web';
3
3
  import type { ZlibOptions, ZstdOptions } from 'node:zlib';
4
- import type { AbortableAsyncMapper, AbortableMapper, AsyncIndexedMapper, AsyncPredicate, END, IndexedMapper, Integer, NonNegativeInteger, PositiveInteger, Predicate, SKIP } from '@naturalcycles/js-lib/types';
4
+ import type { AbortableAsyncMapper, AbortableMapper, AsyncIndexedMapper, AsyncPredicate, END, IndexedMapper, Integer, NonEmptyArray, NonNegativeInteger, PositiveInteger, Predicate, SKIP } from '@naturalcycles/js-lib/types';
5
5
  import type { ReadableTyped, TransformOptions, TransformTyped, WritableTyped } from './stream.model.js';
6
6
  import type { TransformLogProgressOptions } from './transform/transformLogProgress.js';
7
7
  import type { TransformMapOptions } from './transform/transformMap.js';
@@ -57,7 +57,7 @@ export declare class Pipeline<T = unknown> {
57
57
  * less clean than `.take()` on the source.
58
58
  */
59
59
  limit(limit: NonNegativeInteger | undefined): this;
60
- chunk(chunkSize: PositiveInteger, opt?: TransformOptions): Pipeline<T[]>;
60
+ chunk(chunkSize: PositiveInteger, opt?: TransformOptions): Pipeline<NonEmptyArray<T>>;
61
61
  flatten<TO>(this: Pipeline<readonly TO[]>): Pipeline<TO>;
62
62
  flattenIfNeeded(): Pipeline<T extends readonly (infer TO)[] ? TO : T>;
63
63
  logProgress(opt?: TransformLogProgressOptions): this;
@@ -1,4 +1,4 @@
1
- import type { PositiveInteger } from '@naturalcycles/js-lib/types';
1
+ import type { NonEmptyArray, PositiveInteger } from '@naturalcycles/js-lib/types';
2
2
  import type { TransformOptions, TransformTyped } from '../stream.model.js';
3
3
  /**
4
4
  * Similar to RxJS bufferCount(),
@@ -8,4 +8,4 @@ import type { TransformOptions, TransformTyped } from '../stream.model.js';
8
8
  * `chunkSize` indicates how many items to include in each chunk.
9
9
  * Last chunk will contain the remaining items, possibly less than chunkSize.
10
10
  */
11
- export declare function transformChunk<IN = any>(chunkSize: PositiveInteger, opt?: TransformOptions): TransformTyped<IN, IN[]>;
11
+ export declare function transformChunk<IN = any>(chunkSize: PositiveInteger, opt?: TransformOptions): TransformTyped<IN, NonEmptyArray<IN>>;
@@ -8,6 +8,7 @@ import { Transform } from 'node:stream';
8
8
  * Last chunk will contain the remaining items, possibly less than chunkSize.
9
9
  */
10
10
  export function transformChunk(chunkSize, opt) {
11
+ // Only non-empty buffers are emitted
11
12
  let buf = [];
12
13
  return new Transform({
13
14
  objectMode: true,
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@naturalcycles/nodejs-lib",
3
3
  "type": "module",
4
- "version": "15.131.0",
4
+ "version": "15.132.0",
5
5
  "dependencies": {
6
6
  "@naturalcycles/js-lib": "^15",
7
7
  "@standard-schema/spec": "^1",
@@ -14,7 +14,7 @@
14
14
  "yaml": "^2"
15
15
  },
16
16
  "devDependencies": {
17
- "@naturalcycles/dev-lib": "20.66.0",
17
+ "@naturalcycles/dev-lib": "0.0.0",
18
18
  "typescript": "^7"
19
19
  },
20
20
  "exports": {
package/src/index.ts CHANGED
@@ -1,4 +1,3 @@
1
- export * from './buffer/buffer.util.js'
2
1
  export * from './diff/tableDiff.js'
3
2
  export * from './infra/process.util.js'
4
3
  export * from './log/log.util.js'
@@ -14,6 +14,7 @@ import type {
14
14
  END,
15
15
  IndexedMapper,
16
16
  Integer,
17
+ NonEmptyArray,
17
18
  NonNegativeInteger,
18
19
  PositiveInteger,
19
20
  Predicate,
@@ -162,7 +163,7 @@ export class Pipeline<T = unknown> {
162
163
  return this
163
164
  }
164
165
 
165
- chunk(chunkSize: PositiveInteger, opt?: TransformOptions): Pipeline<T[]> {
166
+ chunk(chunkSize: PositiveInteger, opt?: TransformOptions): Pipeline<NonEmptyArray<T>> {
166
167
  this.transforms.push(transformChunk(chunkSize, opt))
167
168
  return this as any
168
169
  }
@@ -1,5 +1,5 @@
1
1
  import { Transform } from 'node:stream'
2
- import type { PositiveInteger } from '@naturalcycles/js-lib/types'
2
+ import type { NonEmptyArray, PositiveInteger } from '@naturalcycles/js-lib/types'
3
3
  import type { TransformOptions, TransformTyped } from '../stream.model.js'
4
4
 
5
5
  /**
@@ -13,7 +13,8 @@ import type { TransformOptions, TransformTyped } from '../stream.model.js'
13
13
  export function transformChunk<IN = any>(
14
14
  chunkSize: PositiveInteger,
15
15
  opt?: TransformOptions,
16
- ): TransformTyped<IN, IN[]> {
16
+ ): TransformTyped<IN, NonEmptyArray<IN>> {
17
+ // Only non-empty buffers are emitted
17
18
  let buf: IN[] = []
18
19
 
19
20
  return new Transform({
@@ -1,4 +0,0 @@
1
- /**
2
- * Same as _chunk, but for Buffer.
3
- */
4
- export declare function _chunkBuffer(buf: Buffer, size: number): Buffer[];
@@ -1,10 +0,0 @@
1
- /**
2
- * Same as _chunk, but for Buffer.
3
- */
4
- export function _chunkBuffer(buf, size) {
5
- const out = [];
6
- for (let i = 0; i < buf.length; i += size) {
7
- out.push(buf.subarray(i, i + size));
8
- }
9
- return out;
10
- }
@@ -1,12 +0,0 @@
1
- /**
2
- * Same as _chunk, but for Buffer.
3
- */
4
- export function _chunkBuffer(buf: Buffer, size: number): Buffer[] {
5
- const out: Buffer[] = []
6
-
7
- for (let i = 0; i < buf.length; i += size) {
8
- out.push(buf.subarray(i, i + size))
9
- }
10
-
11
- return out
12
- }