Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

fast-csv

Package Overview
Dependencies
Maintainers
1
Versions
74
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

fast-csv - npm Package Compare versions

Comparing version 0.4.1 to 0.4.2

6

lib/formatter.js

@@ -55,2 +55,3 @@ var fs = require("fs"),

hasHeaders = extended.has(options, "headers") ? options.headers : true,
rowDelimiter = options.rowDelimiter || LINE_BREAK,
headersLength = 0,

@@ -91,3 +92,3 @@ i = -1,

}
writer.push(ret.join(LINE_BREAK));
writer.push(ret.join(rowDelimiter));
}

@@ -102,2 +103,3 @@ }

this.formatter = createFormatter(options);
this.rowDelimiter = options.rowDelimiter || "\n";
var hasHeaders = this.hasHeaders = extended.has(options, "headers") ? options.headers : true;

@@ -140,3 +142,3 @@ this.parsedHeaders = hasHeaders ? false : true;

if (this.totalCount++) {
buffer.push("\n");
buffer.push(this.rowDelimiter);
}

@@ -143,0 +145,0 @@ if (isHash) {

@@ -54,2 +54,3 @@ var extended = require("./extended"),

this._ignoreEmpty = options.ignoreEmpty;
this._discardUnmappedColumns = options.discardUnmappedColumns;
this.__objectMode = options.objectMode;

@@ -115,2 +116,3 @@ this.__buffered = [];

var headers = this._headers;
var discardUnmappedColumns = this._discardUnmappedColumns;
if (extended.isBoolean(headers) && headers) {

@@ -125,3 +127,7 @@ headers = this.__handleLine(rows.shift(), 0, true);

if (data.length > headersLength) {
self.emit("error", new Error("Unexpected Error: column header mismatch expected: " + headersLength + " columns got: " + data.length));
if (discardUnmappedColumns) {
data.splice(headersLength);
} else {
self.emit("error", new Error("Unexpected Error: column header mismatch expected: " + headersLength + " columns got: " + data.length));
}
}

@@ -274,2 +280,2 @@ while (++i < headersLength) {

module.exports = ParserStream;
module.exports = ParserStream;
{
"name": "fast-csv",
"version": "0.4.1",
"version": "0.4.2",
"description": "CSV parser and writer",

@@ -5,0 +5,0 @@ "main": "index.js",

@@ -21,2 +21,3 @@ [![build status](https://secure.travis-ci.org/C2FO/fast-csv.png)](http://travis-ci.org/C2FO/fast-csv)

* `ignoreEmpty=false`: If you wish to ignore empty rows.
* `discardUnmappedColumns=false`: If you want to discard columns that do not map to a header.
* `delimiter=','`: If your data uses an alternate delimiter such as `;` or `\t`.

@@ -48,3 +49,3 @@ * **NOTE** When specifying an alternate `delimiter` you may only pass in a single character delimiter

.on("record", function(data){
console.log(data):
console.log(data);
})

@@ -68,3 +69,3 @@ .on("end", function(){

.on("record", function(data){
console.log(data):
console.log(data);
})

@@ -88,5 +89,5 @@ .on("end", function(){

csv
.fromPath(CSV_STRING, {headers: true})
.fromString(CSV_STRING, {headers: true})
.on("record", function(data){
console.log(data):
console.log(data);
})

@@ -108,3 +109,3 @@ .on("end", function(){

.on("record", function(data){
console.log(data):
console.log(data);
})

@@ -125,3 +126,3 @@ .on("end", function(){

.on("record", function(data){
console.log(data):
console.log(data);
})

@@ -143,3 +144,3 @@ .on("end", function(){

.on("record", function(data){
console.log(data):
console.log(data);
})

@@ -163,3 +164,3 @@ .on("end", function(){

.on("record", function(data){
console.log(data):
console.log(data);
})

@@ -189,3 +190,3 @@ .on("end", function(){

.on("record", function(data){
console.log(data):
console.log(data);
})

@@ -212,3 +213,3 @@ .on("end", function(){

.on("record", function(data){
console.log(data):
console.log(data);
})

@@ -228,2 +229,3 @@ .on("end", function(){

* `transform(row)`: A function that accepts a row and returns a transformed one to be written.
* `rowDelimiter='\n'`: Specify an alternate row delimiter (i.e `\r\n`)

@@ -487,3 +489,3 @@ **`createWriteStream(options)`**

};
});
});
csv

@@ -490,0 +492,0 @@ .fromPath("in.csv", {headers: true})

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc