@push.rocks/smartstream 2.0.4 → 2.0.7
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_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/index.d.ts +1 -0
- package/dist_ts/index.js +2 -1
- package/dist_ts/smartstream.classes.smartstream.d.ts +12 -0
- package/dist_ts/smartstream.classes.smartstream.js +48 -0
- package/package.json +9 -9
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/index.ts +1 -0
- package/ts/smartstream.classes.smartstream.ts +55 -0
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export const commitinfo = {
|
|
5
5
|
name: '@push.rocks/smartstream',
|
|
6
|
-
version: '2.0.
|
|
6
|
+
version: '2.0.6',
|
|
7
7
|
description: 'simplifies access to node streams'
|
|
8
8
|
};
|
|
9
9
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMDBfY29tbWl0aW5mb19kYXRhLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvMDBfY29tbWl0aW5mb19kYXRhLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOztHQUVHO0FBQ0gsTUFBTSxDQUFDLE1BQU0sVUFBVSxHQUFHO0lBQ3hCLElBQUksRUFBRSx5QkFBeUI7SUFDL0IsT0FBTyxFQUFFLE9BQU87SUFDaEIsV0FBVyxFQUFFLG1DQUFtQztDQUNqRCxDQUFBIn0=
|
package/dist_ts/index.d.ts
CHANGED
package/dist_ts/index.js
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
+
export * from './smartstream.classes.smartstream.js';
|
|
1
2
|
export * from './smartstream.classes.streamwrapper.js';
|
|
2
3
|
export * from './smartstream.classes.streamintake.js';
|
|
3
4
|
export * from './smartstream.duplex.js';
|
|
4
|
-
//# sourceMappingURL=data:application/json;base64,
|
|
5
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxjQUFjLHNDQUFzQyxDQUFDO0FBQ3JELGNBQWMsd0NBQXdDLENBQUM7QUFDdkQsY0FBYyx1Q0FBdUMsQ0FBQztBQUN0RCxjQUFjLHlCQUF5QixDQUFDIn0=
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
2
|
+
/// <reference types="node" resolution-mode="require"/>
|
|
3
|
+
import * as plugins from './smartstream.plugins.js';
|
|
4
|
+
import { Duplex, type DuplexOptions } from 'stream';
|
|
5
|
+
export declare class SmartStream extends Duplex {
|
|
6
|
+
private observableSubscription?;
|
|
7
|
+
constructor(options?: DuplexOptions);
|
|
8
|
+
_read(size: number): void;
|
|
9
|
+
_write(chunk: any, encoding: string, callback: (error?: Error | null) => void): void;
|
|
10
|
+
static fromBuffer(buffer: Buffer, options?: DuplexOptions): SmartStream;
|
|
11
|
+
static fromObservable(observable: plugins.smartrx.rxjs.Observable<any>, options?: DuplexOptions): SmartStream;
|
|
12
|
+
}
|
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
import * as plugins from './smartstream.plugins.js';
|
|
2
|
+
import { Duplex } from 'stream';
|
|
3
|
+
export class SmartStream extends Duplex {
|
|
4
|
+
constructor(options) {
|
|
5
|
+
super(options);
|
|
6
|
+
}
|
|
7
|
+
_read(size) {
|
|
8
|
+
// Implement if you need custom behavior, otherwise leave it empty
|
|
9
|
+
}
|
|
10
|
+
_write(chunk, encoding, callback) {
|
|
11
|
+
// Implement if you need custom behavior
|
|
12
|
+
callback();
|
|
13
|
+
}
|
|
14
|
+
static fromBuffer(buffer, options) {
|
|
15
|
+
const smartStream = new SmartStream(options);
|
|
16
|
+
process.nextTick(() => {
|
|
17
|
+
smartStream.push(buffer);
|
|
18
|
+
smartStream.push(null); // Signal the end of the data
|
|
19
|
+
});
|
|
20
|
+
return smartStream;
|
|
21
|
+
}
|
|
22
|
+
static fromObservable(observable, options) {
|
|
23
|
+
const smartStream = new SmartStream(options);
|
|
24
|
+
smartStream.observableSubscription = observable.subscribe({
|
|
25
|
+
next: (data) => {
|
|
26
|
+
if (!smartStream.push(data)) {
|
|
27
|
+
// Pause the observable if the stream buffer is full
|
|
28
|
+
smartStream.observableSubscription?.unsubscribe();
|
|
29
|
+
smartStream.once('drain', () => {
|
|
30
|
+
// Resume the observable when the stream buffer is drained
|
|
31
|
+
smartStream.observableSubscription?.unsubscribe();
|
|
32
|
+
smartStream.observableSubscription = observable.subscribe(data => {
|
|
33
|
+
smartStream.push(data);
|
|
34
|
+
});
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
},
|
|
38
|
+
error: (err) => {
|
|
39
|
+
smartStream.emit('error', err);
|
|
40
|
+
},
|
|
41
|
+
complete: () => {
|
|
42
|
+
smartStream.push(null); // Signal the end of the data
|
|
43
|
+
}
|
|
44
|
+
});
|
|
45
|
+
return smartStream;
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzdHJlYW0uY2xhc3Nlcy5zbWFydHN0cmVhbS5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0c3RyZWFtLmNsYXNzZXMuc21hcnRzdHJlYW0udHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLE9BQU8sTUFBTSwwQkFBMEIsQ0FBQztBQUNwRCxPQUFPLEVBQUUsTUFBTSxFQUFzQixNQUFNLFFBQVEsQ0FBQztBQUVwRCxNQUFNLE9BQU8sV0FBWSxTQUFRLE1BQU07SUFHckMsWUFBWSxPQUF1QjtRQUNqQyxLQUFL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7d0JBQzFELFdBQVcsQ0FBQyxzQkFBc0IsRUFBRSxXQUFXLEVBQUUsQ0FBQzt3QkFDbEQsV0FBVyxDQUFDLHNCQUFzQixHQUFHLFVBQVUsQ0FBQyxTQUFTLENBQUMsSUFBSSxDQUFDLEVBQUU7NEJBQy9ELFdBQVcsQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLENBQUM7d0JBQ3pCLENBQUMsQ0FBQyxDQUFDO29CQUNMLENBQUMsQ0FBQyxDQUFDO2lCQUNKO1lBQ0gsQ0FBQztZQUNELEtBQUssRUFBRSxDQUFDLEdBQUcsRUFBRSxFQUFFO2dCQUNiLFdBQVcsQ0FBQyxJQUFJLENBQUMsT0FBTyxFQUFFLEdBQUcsQ0FBQyxDQUFDO1lBQ2pDLENBQUM7WUFDRCxRQUFRLEVBQUUsR0FBRyxFQUFFO2dCQUNiLFdBQVcsQ0FBQyxJQUFJLENBQUMsSUFBSSxDQUFDLENBQUMsQ0FBQyw2QkFBNkI7WUFDdkQsQ0FBQztTQUNGLENBQUMsQ0FBQztRQUVILE9BQU8sV0FBVyxDQUFDO0lBQ3JCLENBQUM7Q0FDRiJ9
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@push.rocks/smartstream",
|
|
3
|
-
"version": "2.0.
|
|
3
|
+
"version": "2.0.7",
|
|
4
4
|
"private": false,
|
|
5
5
|
"description": "simplifies access to node streams",
|
|
6
6
|
"main": "dist_ts/index.js",
|
|
@@ -21,17 +21,17 @@
|
|
|
21
21
|
},
|
|
22
22
|
"homepage": "https://gitlab.com/pushrocks/smartstream#README",
|
|
23
23
|
"devDependencies": {
|
|
24
|
-
"@
|
|
25
|
-
"@
|
|
26
|
-
"@
|
|
27
|
-
"@push.rocks/smartfile": "^10.0.
|
|
28
|
-
"@push.rocks/tapbundle": "^5.0.
|
|
24
|
+
"@git.zone/tsbuild": "^2.1.66",
|
|
25
|
+
"@git.zone/tsrun": "^1.2.44",
|
|
26
|
+
"@git.zone/tstest": "^1.0.77",
|
|
27
|
+
"@push.rocks/smartfile": "^10.0.33",
|
|
28
|
+
"@push.rocks/tapbundle": "^5.0.15"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
31
|
"@push.rocks/smartpromise": "^4.0.3",
|
|
32
|
-
"@push.rocks/smartrx": "^3.0.
|
|
33
|
-
"@types/from2": "^2.3.
|
|
34
|
-
"@types/through2": "^2.0.
|
|
32
|
+
"@push.rocks/smartrx": "^3.0.7",
|
|
33
|
+
"@types/from2": "^2.3.4",
|
|
34
|
+
"@types/through2": "^2.0.40",
|
|
35
35
|
"from2": "^2.3.0",
|
|
36
36
|
"through2": "^4.0.2"
|
|
37
37
|
},
|
package/ts/00_commitinfo_data.ts
CHANGED
package/ts/index.ts
CHANGED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
import * as plugins from './smartstream.plugins.js';
|
|
2
|
+
import { Duplex, type DuplexOptions } from 'stream';
|
|
3
|
+
|
|
4
|
+
export class SmartStream extends Duplex {
|
|
5
|
+
private observableSubscription?: plugins.smartrx.rxjs.Subscription;
|
|
6
|
+
|
|
7
|
+
constructor(options?: DuplexOptions) {
|
|
8
|
+
super(options);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
_read(size: number) {
|
|
12
|
+
// Implement if you need custom behavior, otherwise leave it empty
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
_write(chunk: any, encoding: string, callback: (error?: Error | null) => void) {
|
|
16
|
+
// Implement if you need custom behavior
|
|
17
|
+
callback();
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
static fromBuffer(buffer: Buffer, options?: DuplexOptions): SmartStream {
|
|
21
|
+
const smartStream = new SmartStream(options);
|
|
22
|
+
process.nextTick(() => {
|
|
23
|
+
smartStream.push(buffer);
|
|
24
|
+
smartStream.push(null); // Signal the end of the data
|
|
25
|
+
});
|
|
26
|
+
return smartStream;
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
static fromObservable(observable: plugins.smartrx.rxjs.Observable<any>, options?: DuplexOptions): SmartStream {
|
|
30
|
+
const smartStream = new SmartStream(options);
|
|
31
|
+
smartStream.observableSubscription = observable.subscribe({
|
|
32
|
+
next: (data) => {
|
|
33
|
+
if (!smartStream.push(data)) {
|
|
34
|
+
// Pause the observable if the stream buffer is full
|
|
35
|
+
smartStream.observableSubscription?.unsubscribe();
|
|
36
|
+
smartStream.once('drain', () => {
|
|
37
|
+
// Resume the observable when the stream buffer is drained
|
|
38
|
+
smartStream.observableSubscription?.unsubscribe();
|
|
39
|
+
smartStream.observableSubscription = observable.subscribe(data => {
|
|
40
|
+
smartStream.push(data);
|
|
41
|
+
});
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
error: (err) => {
|
|
46
|
+
smartStream.emit('error', err);
|
|
47
|
+
},
|
|
48
|
+
complete: () => {
|
|
49
|
+
smartStream.push(null); // Signal the end of the data
|
|
50
|
+
}
|
|
51
|
+
});
|
|
52
|
+
|
|
53
|
+
return smartStream;
|
|
54
|
+
}
|
|
55
|
+
}
|