@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 +0 -1
- package/dist/index.js +0 -1
- package/dist/stream/pipeline.d.ts +2 -2
- package/dist/stream/transform/transformChunk.d.ts +2 -2
- package/dist/stream/transform/transformChunk.js +1 -0
- package/package.json +2 -2
- package/src/index.ts +0 -1
- package/src/stream/pipeline.ts +2 -1
- package/src/stream/transform/transformChunk.ts +3 -2
- package/dist/buffer/buffer.util.d.ts +0 -4
- package/dist/buffer/buffer.util.js +0 -10
- package/src/buffer/buffer.util.ts +0 -12
package/dist/index.d.ts
CHANGED
package/dist/index.js
CHANGED
|
@@ -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.
|
|
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": "
|
|
17
|
+
"@naturalcycles/dev-lib": "0.0.0",
|
|
18
18
|
"typescript": "^7"
|
|
19
19
|
},
|
|
20
20
|
"exports": {
|
package/src/index.ts
CHANGED
package/src/stream/pipeline.ts
CHANGED
|
@@ -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({
|