Skip to content

Instantly share code, notes, and snippets.

@apaleslimghost
Created October 9, 2017 11:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save apaleslimghost/bff72a47d493c0bc6b1cd3a196110a80 to your computer and use it in GitHub Desktop.
Save apaleslimghost/bff72a47d493c0bc6b1cd3a196110a80 to your computer and use it in GitHub Desktop.
const kinesis = require('kinesis');
const {Transform} = require('stream');
class KinesisDecode extends Transform {
constructor(options) {
super(Object.assign({objectMode: true}, options));
}
_transform(record, encoding, cb) {
try {
cb(null, JSON.parse(record.Data.toString('utf8')));
} catch(err) {
cb(err);
}
}
}
module.exports = options => kinesis.stream(options).pipe(new KinesisDecode());
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment