csv-streamify
Advanced tools
Comparing version 0.6.0 to 0.7.0
@@ -0,1 +1,11 @@ | ||
0.7.0 / 2013-11-14 | ||
================== | ||
* change: use iconv-lite for encoding conversion (please test und submit issues) | ||
0.6.1 / 2013-11-13 | ||
================== | ||
* fix: properly handle CRLF in quoted sequences | ||
0.6.0 / 2013-11-12 | ||
@@ -2,0 +12,0 @@ ================== |
@@ -13,3 +13,3 @@ var Transform = require('stream').Transform, | ||
try { Iconv = require('iconv').Iconv } catch (err) {} | ||
try { iconv = require('iconv-lite') } catch (err) {} | ||
@@ -29,4 +29,6 @@ module.exports = function (opts, cb) { | ||
if (opts.inputEncoding) { | ||
if (!Iconv) throw new Error('Please "npm install iconv"') | ||
this.iconv = new Iconv(opts.inputEncoding, 'UTF-8') | ||
if (!iconv) throw new Error('Please "npm install iconv-lite"') | ||
if (!iconv.encodingExists(opts.inputEncoding)) | ||
throw new Error('unkown input encoding') | ||
this.inputEncoding = opts.inputEncoding | ||
} | ||
@@ -60,3 +62,5 @@ | ||
CSVStream.prototype._transform = function (chunk, encoding, done) { | ||
if (this.iconv) chunk = this.iconv.convert(chunk) | ||
if (this.inputEncoding) | ||
chunk = iconv.fromEncoding(chunk, this.inputEncoding) | ||
chunk = chunk.toString() | ||
@@ -98,4 +102,7 @@ | ||
if (this.isQuoted && c === this.newline) { | ||
c = c.replace(this.newline, '\\n') | ||
// escape special chars in quotes | ||
if (this.isQuoted) { | ||
c = c.replace(/\r/, '\\r') | ||
.replace(/\n/, '\\n') | ||
.replace(/"/, '\"') | ||
} | ||
@@ -102,0 +109,0 @@ |
{ | ||
"name": "csv-streamify", | ||
"version": "0.6.0", | ||
"version": "0.7.0", | ||
"description": "Streaming CSV Parser. Made entirely out of streams.", | ||
@@ -24,4 +24,4 @@ "author": "Clemens Stolle", | ||
"devDependencies": { | ||
"mocha": "1.12.x", | ||
"iconv": "2.0.x" | ||
"mocha": "1.14.x", | ||
"iconv-lite": "~0.2.11" | ||
}, | ||
@@ -28,0 +28,0 @@ "engines": { |
@@ -66,4 +66,5 @@ csv-streamify [![Build Status](https://travis-ci.org/klaemo/csv-stream.png)](https://travis-ci.org/klaemo/csv-stream) | ||
In order for the encoding option to take effect you need to install the excellent [node-iconv](https://github.com/bnoordhuis/node-iconv) by node core contributor @bnoordhuis | ||
Also, take a look at the node-iconv documentation for supported encodings. | ||
In order for the inputEncoding option to take effect you need to install [iconv-lite](https://github.com/ashtuchkin/iconv-lite). | ||
Also, take a look at the iconv-lite documentation for supported encodings. | ||
(iconv-lite provides pure javascript character encoding conversion -> no native code compilation) | ||
@@ -70,0 +71,0 @@ |
Sorry, the diff of this file is not supported yet
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
73
1
8841
6
139