Skip to content

Instantly share code, notes, and snippets.

@bbstilson
Last active November 5, 2020 02:52
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save bbstilson/e2617cf1375481a34c0b6d9ecf0879bf to your computer and use it in GitHub Desktop.
Save bbstilson/e2617cf1375481a34c0b6d9ecf0879bf to your computer and use it in GitHub Desktop.
const { Transform } = require('stream');
class AppendInitVect extends Transform {
constructor(initVect, opts) {
super(opts);
this.initVect = initVect;
this.appended = false;
}
_transform(chunk, encoding, cb) {
if (!this.appended) {
this.push(this.initVect);
this.appended = true;
}
this.push(chunk);
cb();
}
}
module.exports = AppendInitVect;
@jmshal
Copy link

jmshal commented Apr 9, 2020

Surely this prepends the IV. Regardless, thanks.

@bbstilson
Copy link
Author

Yeah, the language is weird depending on how you think about it. If you think of it like an array that already exists that want to push something onto it, you would append. For example, (in python):

xs = []
xs.append(0)

Even though 0 is the first thing, we're appending.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment