@pushrocks/smartstream
Advanced tools
Comparing version 2.0.1 to 2.0.2
@@ -1,37 +0,3 @@ | ||
import * as plugins from './smartstream.plugins.js'; | ||
export interface IErrorFunction { | ||
(err: Error): any; | ||
} | ||
export interface ICustomEventFunction { | ||
(): any; | ||
} | ||
export interface ICustomEventObject { | ||
eventName: string; | ||
eventFunction: ICustomEventFunction; | ||
} | ||
/** | ||
* class Smartstream handles | ||
*/ | ||
export declare class Smartstream { | ||
private streamArray; | ||
private customEventObjectArray; | ||
private streamStartedDeferred; | ||
/** | ||
* constructor | ||
*/ | ||
constructor(streamArrayArg: any[]); | ||
/** | ||
* make something with the stream itself | ||
*/ | ||
streamStarted(): Promise<any>; | ||
/** | ||
* attach listener to custom event | ||
*/ | ||
onCustomEvent(eventNameArg: string, eventFunctionArg: ICustomEventFunction): void; | ||
/** | ||
* run the stream | ||
* @returns Promise | ||
*/ | ||
run(): Promise<void>; | ||
} | ||
export declare let cleanPipe: () => plugins.stream.Transform; | ||
export * from './smartstream.classes.streamwrapper.js'; | ||
export * from './smartstream.classes.streamintake.js'; | ||
export * from './smartstream.duplex.js'; |
@@ -1,81 +0,4 @@ | ||
import * as plugins from './smartstream.plugins.js'; | ||
// interfaces | ||
import 'stream'; | ||
/** | ||
* class Smartstream handles | ||
*/ | ||
export class Smartstream { | ||
/** | ||
* constructor | ||
*/ | ||
constructor(streamArrayArg) { | ||
this.streamArray = []; | ||
this.customEventObjectArray = []; | ||
this.streamStartedDeferred = plugins.smartpromise.defer(); | ||
this.streamArray = streamArrayArg; | ||
} | ||
/** | ||
* make something with the stream itself | ||
*/ | ||
streamStarted() { | ||
return this.streamStartedDeferred.promise; | ||
} | ||
/** | ||
* attach listener to custom event | ||
*/ | ||
onCustomEvent(eventNameArg, eventFunctionArg) { | ||
this.customEventObjectArray.push({ | ||
eventName: eventNameArg, | ||
eventFunction: eventFunctionArg, | ||
}); | ||
} | ||
/** | ||
* run the stream | ||
* @returns Promise | ||
*/ | ||
run() { | ||
const done = plugins.smartpromise.defer(); | ||
// clone Array | ||
const streamExecutionArray = []; | ||
for (const streamItem of this.streamArray) { | ||
streamExecutionArray.push(streamItem); | ||
} | ||
// combine the stream | ||
let finalStream = null; | ||
let firstIteration = true; | ||
for (const stream of streamExecutionArray) { | ||
if (firstIteration === true) { | ||
finalStream = stream; | ||
} | ||
stream.on('error', (err) => { | ||
done.reject(err); | ||
}); | ||
for (const customEventObject of this.customEventObjectArray) { | ||
stream.on(customEventObject.eventName, customEventObject.eventFunction); | ||
} | ||
if (!firstIteration) { | ||
finalStream = finalStream.pipe(stream); | ||
} | ||
firstIteration = false; | ||
} | ||
this.streamStartedDeferred.resolve(); | ||
finalStream.on('end', () => { | ||
done.resolve(); | ||
}); | ||
finalStream.on('close', () => { | ||
done.resolve(); | ||
}); | ||
finalStream.on('finish', () => { | ||
done.resolve(); | ||
}); | ||
return done.promise; | ||
} | ||
} | ||
export let cleanPipe = () => { | ||
return plugins.through2.obj((file, enc, cb) => { | ||
cb(); | ||
}, (cb) => { | ||
cb(); | ||
}); | ||
}; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssT0FBTyxNQUFNLDBCQUEwQixDQUFDO0FBRXBELGFBQWE7QUFDYixPQUEwQixRQUFRLENBQUM7QUFlbkM7O0dBRUc7QUFDSCxNQUFNLE9BQU8sV0FBVztJQUt0Qjs7T0FFRztJQUNILFlBQVksY0FBcUI7UUFQekIsZ0JBQVcsR0FBaUMsRUFBRSxDQUFDO1FBQy9DLDJCQUFzQixHQUF5QixFQUFFLENBQUM7UUFDbEQsMEJBQXFCLEdBQUcsT0FBTyxDQUFDLFlBQVksQ0FBQyxLQUFLLEVBQUUsQ0FBQztRQU0zRCxJQUFJLENBQUMsV0FBVyxH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O1FBQ0wsRUFBRSxFQUFFLENBQUM7SUFDUCxDQUFDLENBQ0YsQ0FBQztBQUNKLENBQUMsQ0FBQyJ9 | ||
export * from './smartstream.classes.streamwrapper.js'; | ||
export * from './smartstream.classes.streamintake.js'; | ||
export * from './smartstream.duplex.js'; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9pbmRleC50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxjQUFjLHdDQUF3QyxDQUFDO0FBQ3ZELGNBQWMsdUNBQXVDLENBQUM7QUFDdEQsY0FBYyx5QkFBeUIsQ0FBQyJ9 |
import * as stream from 'stream'; | ||
export { stream }; | ||
import * as smartpromise from '@pushrocks/smartpromise'; | ||
export { smartpromise }; | ||
import * as through2 from 'through2'; | ||
export { through2 }; | ||
import * as smartrx from '@pushrocks/smartrx'; | ||
export { smartpromise, smartrx }; | ||
import from2 from 'from2'; | ||
import through2 from 'through2'; | ||
export { from2, through2 }; |
@@ -0,1 +1,2 @@ | ||
// node native | ||
import * as stream from 'stream'; | ||
@@ -5,6 +6,8 @@ export { stream }; | ||
import * as smartpromise from '@pushrocks/smartpromise'; | ||
export { smartpromise }; | ||
import * as smartrx from '@pushrocks/smartrx'; | ||
export { smartpromise, smartrx }; | ||
// thirdparty | ||
import * as through2 from 'through2'; | ||
export { through2 }; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzdHJlYW0ucGx1Z2lucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0c3RyZWFtLnBsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsT0FBTyxLQUFLLE1BQU0sTUFBTSxRQUFRLENBQUM7QUFFakMsT0FBTyxFQUFFLE1BQU0sRUFBRSxDQUFDO0FBRWxCLGtCQUFrQjtBQUNsQixPQUFPLEtBQUssWUFBWSxNQUFNLHlCQUF5QixDQUFDO0FBQ3hELE9BQU8sRUFBRSxZQUFZLEVBQUUsQ0FBQztBQUV4QixhQUFhO0FBQ2IsT0FBTyxLQUFLLFFBQVEsTUFBTSxVQUFVLENBQUM7QUFFckMsT0FBTyxFQUFFLFFBQVEsRUFBRSxDQUFDIn0= | ||
import from2 from 'from2'; | ||
import through2 from 'through2'; | ||
export { from2, through2 }; | ||
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoic21hcnRzdHJlYW0ucGx1Z2lucy5qcyIsInNvdXJjZVJvb3QiOiIiLCJzb3VyY2VzIjpbIi4uL3RzL3NtYXJ0c3RyZWFtLnBsdWdpbnMudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsY0FBYztBQUNkLE9BQU8sS0FBSyxNQUFNLE1BQU0sUUFBUSxDQUFDO0FBRWpDLE9BQU8sRUFBRSxNQUFNLEVBQUUsQ0FBQztBQUVsQixrQkFBa0I7QUFDbEIsT0FBTyxLQUFLLFlBQVksTUFBTSx5QkFBeUIsQ0FBQztBQUN4RCxPQUFPLEtBQUssT0FBTyxNQUFNLG9CQUFvQixDQUFDO0FBRTlDLE9BQU8sRUFBRSxZQUFZLEVBQUUsT0FBTyxFQUFFLENBQUM7QUFFakMsYUFBYTtBQUNiLE9BQU8sS0FBSyxNQUFNLE9BQU8sQ0FBQztBQUMxQixPQUFPLFFBQVEsTUFBTSxVQUFVLENBQUM7QUFFaEMsT0FBTyxFQUFFLEtBQUssRUFBRSxRQUFRLEVBQUUsQ0FBQyJ9 |
{ | ||
"name": "@pushrocks/smartstream", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"private": false, | ||
@@ -24,4 +24,5 @@ "description": "simplifies access to node streams", | ||
"devDependencies": { | ||
"@gitzone/tsbuild": "^2.1.61", | ||
"@gitzone/tstest": "^1.0.70", | ||
"@gitzone/tsbuild": "^2.1.63", | ||
"@gitzone/tstest": "^1.0.71", | ||
"@pushrocks/smartfile": "^10.0.0", | ||
"@pushrocks/tapbundle": "^5.0.3", | ||
@@ -33,3 +34,6 @@ "tslint": "^6.1.3", | ||
"@pushrocks/smartpromise": "^3.1.7", | ||
"@pushrocks/smartrx": "^2.0.25", | ||
"@types/from2": "^2.3.1", | ||
"@types/through2": "^2.0.36", | ||
"from2": "^2.3.0", | ||
"through2": "^4.0.2" | ||
@@ -36,0 +40,0 @@ }, |
110
ts/index.ts
@@ -1,107 +0,3 @@ | ||
import * as plugins from './smartstream.plugins.js'; | ||
// interfaces | ||
import { Transform } from 'stream'; | ||
export interface IErrorFunction { | ||
(err: Error): any; | ||
} | ||
export interface ICustomEventFunction { | ||
(): any; | ||
} | ||
export interface ICustomEventObject { | ||
eventName: string; | ||
eventFunction: ICustomEventFunction; | ||
} | ||
/** | ||
* class Smartstream handles | ||
*/ | ||
export class Smartstream { | ||
private streamArray: Array<plugins.stream.Duplex> = []; | ||
private customEventObjectArray: ICustomEventObject[] = []; | ||
private streamStartedDeferred = plugins.smartpromise.defer(); | ||
/** | ||
* constructor | ||
*/ | ||
constructor(streamArrayArg: any[]) { | ||
this.streamArray = streamArrayArg; | ||
} | ||
/** | ||
* make something with the stream itself | ||
*/ | ||
streamStarted(): Promise<any> { | ||
return this.streamStartedDeferred.promise; | ||
} | ||
/** | ||
* attach listener to custom event | ||
*/ | ||
onCustomEvent(eventNameArg: string, eventFunctionArg: ICustomEventFunction) { | ||
this.customEventObjectArray.push({ | ||
eventName: eventNameArg, | ||
eventFunction: eventFunctionArg, | ||
}); | ||
} | ||
/** | ||
* run the stream | ||
* @returns Promise | ||
*/ | ||
run(): Promise<void> { | ||
const done = plugins.smartpromise.defer<void>(); | ||
// clone Array | ||
const streamExecutionArray: Array<plugins.stream.Duplex> = []; | ||
for (const streamItem of this.streamArray) { | ||
streamExecutionArray.push(streamItem); | ||
} | ||
// combine the stream | ||
let finalStream = null; | ||
let firstIteration: boolean = true; | ||
for (const stream of streamExecutionArray) { | ||
if (firstIteration === true) { | ||
finalStream = stream; | ||
} | ||
stream.on('error', (err) => { | ||
done.reject(err); | ||
}); | ||
for (const customEventObject of this.customEventObjectArray) { | ||
stream.on(customEventObject.eventName, customEventObject.eventFunction); | ||
} | ||
if (!firstIteration) { | ||
finalStream = finalStream.pipe(stream); | ||
} | ||
firstIteration = false; | ||
} | ||
this.streamStartedDeferred.resolve(); | ||
finalStream.on('end', () => { | ||
done.resolve(); | ||
}); | ||
finalStream.on('close', () => { | ||
done.resolve(); | ||
}); | ||
finalStream.on('finish', () => { | ||
done.resolve(); | ||
}); | ||
return done.promise; | ||
} | ||
} | ||
export let cleanPipe = () => { | ||
return plugins.through2.obj( | ||
(file, enc, cb) => { | ||
cb(); | ||
}, | ||
(cb) => { | ||
cb(); | ||
} | ||
); | ||
}; | ||
export * from './smartstream.classes.streamwrapper.js'; | ||
export * from './smartstream.classes.streamintake.js'; | ||
export * from './smartstream.duplex.js'; |
@@ -0,1 +1,2 @@ | ||
// node native | ||
import * as stream from 'stream'; | ||
@@ -7,7 +8,10 @@ | ||
import * as smartpromise from '@pushrocks/smartpromise'; | ||
export { smartpromise }; | ||
import * as smartrx from '@pushrocks/smartrx'; | ||
export { smartpromise, smartrx }; | ||
// thirdparty | ||
import * as through2 from 'through2'; | ||
import from2 from 'from2'; | ||
import through2 from 'through2'; | ||
export { through2 }; | ||
export { from2, through2 }; |
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
29014
21
565
6
6
+ Added@pushrocks/smartrx@^2.0.25
+ Added@types/from2@^2.3.1
+ Addedfrom2@^2.3.0
+ Added@pushrocks/smartrx@2.0.27(transitive)
+ Added@types/from2@2.3.5(transitive)
+ Addedcore-util-is@1.0.3(transitive)
+ Addedfrom2@2.3.0(transitive)
+ Addedisarray@1.0.0(transitive)
+ Addedprocess-nextick-args@2.0.1(transitive)
+ Addedreadable-stream@2.3.8(transitive)
+ Addedrxjs@7.8.1(transitive)
+ Addedsafe-buffer@5.1.2(transitive)
+ Addedstring_decoder@1.1.1(transitive)
+ Addedtslib@2.6.3(transitive)
- Removedsafe-buffer@5.2.1(transitive)
- Removedstring_decoder@1.3.0(transitive)