From 23785b82caf419908cca737cda4cda48100aef6c Mon Sep 17 00:00:00 2001 From: jbruggem Date: Fri, 21 Mar 2014 17:18:29 +0100 Subject: [PATCH 1/2] Set default codec if header does not provide any. Otherwise, upon decoding some objects, I encountered "TypeError: Cannot call method 'toString' of undefined" on datafile.js:333 --- lib/datafile.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/datafile.js b/lib/datafile.js index 10ffd29..1b87cc9 100644 --- a/lib/datafile.js +++ b/lib/datafile.js @@ -327,7 +327,7 @@ _.extend(Reader.prototype, { if (block.sync && block.sync.toString() !== this.header.sync.toString()) self._fileBlock.skip(-SYNC_SIZE); - var codec = this.header.meta['avro.codec'].toString(); + var codec = this.header.meta['avro.codec'] ? this.header.meta['avro.codec'].toString() : "null"; this.decompressData(block.objects, codec, function(err, data) { if (err) self.emit('error', err); From 6d05ded25018639e75bb0c61e6fe0ebb7bb929f8 Mon Sep 17 00:00:00 2001 From: jbruggem Date: Fri, 21 Mar 2014 17:19:42 +0100 Subject: [PATCH 2/2] Update README - missing argument in avro.open --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index d08498a..e541082 100644 --- a/README.md +++ b/README.md @@ -40,7 +40,7 @@ var DataFile = require("node-avro-io").DataFile; var avro = DataFile.AvroFile(); -var reader = avro.open('test.avro', { flags: 'r' }); +var reader = avro.open('test.avro', 'string', { flags: 'r' }); reader.on('data', function(data) { console.log(data); });