system change

This commit is contained in:
2018-03-03 13:57:55 +01:00
parent 48a9affa47
commit 96a5142409
4 changed files with 44 additions and 46 deletions
+9 -9
View File
@@ -1,12 +1,12 @@
// this file contains the code to generate and handle the stream
import * as plugins from './smartgulp.plugins'
import { Smartfile } from 'smartfile'
import * as plugins from './smartgulp.plugins';
import { Smartfile } from 'smartfile';
import { Transform } from 'stream'
import { Transform } from 'stream';
export class GulpStream {
stream = new Transform({ objectMode: true })
stream = new Transform({ objectMode: true });
/**
* allows you to pipe a SmartfileArray into the stream
@@ -14,17 +14,17 @@ export class GulpStream {
async pipeSmartfileArray(smartfileArray: Smartfile[]) {
// ensure what we get is an array
if (!Array.isArray(smartfileArray)) {
throw new Error('fileArg has unknown format')
throw new Error('fileArg has unknown format');
}
for (let smartfile of smartfileArray) {
let hasWritten = this.stream.push(smartfile)
let hasWritten = this.stream.push(smartfile);
if (!hasWritten) {
await plugins.smartevent.once(this.stream, 'drain')
await plugins.smartevent.once(this.stream, 'drain');
} else {
// iterate
}
};
}
// signal end of stream;
this.stream.push(null)
this.stream.push(null);
}
}