Created
October 9, 2017 11:38
-
-
Save apaleslimghost/bff72a47d493c0bc6b1cd3a196110a80 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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