Created
March 19, 2013 10:38
-
-
Save adrianheine/5195136 to your computer and use it in GitHub Desktop.
A test case for https://github.com/wdavidw/node-csv-parser/pull/86
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
var csv = require('./lib/csv'); | |
var util = require('util'); | |
var Stream = require('stream').Stream; | |
function ChunksStream(chunks) { | |
var self = this; | |
var i = 0; | |
var tick = function () { | |
if (i < chunks.length) { | |
self.emit('data', chunks[i++]); | |
process.nextTick(tick); | |
} else { | |
self.emit('end'); | |
} | |
}; | |
process.nextTick(tick); | |
} | |
util.inherits(ChunksStream, Stream); | |
ChunksStream.prototype.destroy = function () {}; | |
var data = ['"field with \\', '" inside"']; | |
console.log(data, data.join('')); | |
csv() | |
.fromStream(new ChunksStream(data), { | |
escape: '\\' | |
}).on('error', function (err) { | |
console.log(err); | |
}).on('end', function (c) { | |
console.log(c); | |
}); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment