diff --git a/test/test.streamfunction.ts b/test/test.streamfunction.ts index 1d99c45..b1ae09f 100644 --- a/test/test.streamfunction.ts +++ b/test/test.streamfunction.ts @@ -10,7 +10,7 @@ tap.test('should handle a read stream', async (tools) => { const streamWrapper = new smartstream.StreamWrapper([ smartfile.fsStream.createReadStream('./test/assets/readabletext.txt'), new smartstream.SmartDuplex({ - writeAndTransformFunction: async (chunkStringArg: Buffer, streamTools) => { + writeFunction: async (chunkStringArg: Buffer, streamTools) => { // do something with the stream here const result = chunkStringArg.toString().substr(0, 100); streamTools.push('wow =========== \n'); @@ -21,7 +21,7 @@ tap.test('should handle a read stream', async (tools) => { }, }), new smartstream.SmartDuplex({ - writeAndTransformFunction: async (chunkStringArg) => { + writeFunction: async (chunkStringArg) => { console.log(chunkStringArg.toString()); }, finalFunction: async (tools) => { @@ -37,7 +37,7 @@ tap.test('should create a valid Intake', async (tools) => { testIntake.pipe( new smartstream.SmartDuplex({ objectMode: true, - writeAndTransformFunction: async (chunkStringArg: string, streamTools) => { + writeFunction: async (chunkStringArg: string, streamTools) => { await tools.delayFor(100); console.log(chunkStringArg); return chunkStringArg; diff --git a/ts/00_commitinfo_data.ts b/ts/00_commitinfo_data.ts index b3b9d29..52f9e77 100644 --- a/ts/00_commitinfo_data.ts +++ b/ts/00_commitinfo_data.ts @@ -3,6 +3,6 @@ */ export const commitinfo = { name: '@push.rocks/smartstream', - version: '3.0.11', + version: '3.0.12', description: 'simplifies access to node streams' } diff --git a/ts/smartstream.classes.smartduplex.ts b/ts/smartstream.classes.smartduplex.ts index 3073c01..7cf99a0 100644 --- a/ts/smartstream.classes.smartduplex.ts +++ b/ts/smartstream.classes.smartduplex.ts @@ -6,18 +6,18 @@ export interface IStreamTools { push: (pipeObject: any) => void; } -export interface IWriteAndTransformFunction { +export interface IStreamWriteFunction { (chunkArg: T, toolsArg: IStreamTools): Promise; } -export interface IStreamEndFunction { +export interface IStreamFinalFunction { (toolsArg: IStreamTools): Promise; } export interface SmartStreamOptions extends DuplexOptions { readFunction?: () => Promise; - writeAndTransformFunction?: IWriteAndTransformFunction; - finalFunction?: IStreamEndFunction; + writeFunction?: IStreamWriteFunction; + finalFunction?: IStreamFinalFunction; // Add other custom options if necessary } @@ -109,14 +109,14 @@ export class SmartDuplex extends Duplex { // INSTANCE private readFunction?: () => Promise; - private writeFunction?: IWriteAndTransformFunction; - private finalFunction?: IStreamEndFunction; + private writeFunction?: IStreamWriteFunction; + private finalFunction?: IStreamFinalFunction; private observableSubscription?: plugins.smartrx.rxjs.Subscription; constructor(optionsArg?: SmartStreamOptions) { super(optionsArg); this.readFunction = optionsArg?.readFunction; - this.writeFunction = optionsArg?.writeAndTransformFunction; + this.writeFunction = optionsArg?.writeFunction; this.finalFunction = optionsArg?.finalFunction; }