init
This commit is contained in:
@@ -0,0 +1,19 @@
|
||||
import { Transform } from 'stream';
|
||||
|
||||
export class BufferTransform extends Transform {
|
||||
constructor(transform) {
|
||||
super({
|
||||
objectMode: true,
|
||||
transform(file, enc, callback) {
|
||||
if (file.isBuffer()) {
|
||||
file.contents = Buffer.from(transform(new String(file.contents)));
|
||||
}
|
||||
if (file.isStream()) {
|
||||
console.log('stream file', file.path);
|
||||
}
|
||||
return callback(null, file);
|
||||
},
|
||||
});
|
||||
return this;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user