Advertisement
nubooya

AppendInitVect

Feb 23rd, 2022
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.40 KB | None | 0 0
  1. const { Transform } = require('stream');
  2.  
  3. class AppendInitVect extends Transform {
  4. constructor(initVect, opts) {
  5. super(opts);
  6. this.initVect = initVect;
  7. this.appended = false;
  8. }
  9.  
  10. _transform(chunk, encoding, cb) {
  11. if (!this.appended) {
  12. this.push(this.initVect);
  13. this.appended = true;
  14. }
  15. this.push(chunk);
  16. cb();
  17. }
  18. }
  19.  
  20. module.exports = AppendInitVect;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement