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

csv-parser

Package Overview
Dependencies
Maintainers
2
Versions
44
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

csv-parser - npm Package Compare versions

Comparing version 1.4.6 to 1.5.0

test/data/custom-newlines.csv

13

index.js

@@ -8,3 +8,2 @@ var stream = require('stream')

var comma = new Buffer(',')[0]
var lf = new Buffer('\n')[0]
var cr = new Buffer('\r')[0]

@@ -19,2 +18,10 @@

this.separator = opts.separator ? new Buffer(opts.separator)[0] : comma
if(opts.newline) {
this.newline = new Buffer(opts.newline)[0]
this.customNewline = true
} else {
this.newline = new Buffer('\n')[0]
this.customNewline = false
}
this.headers = opts.headers || null

@@ -53,3 +60,3 @@

if (!this._quoting && buf[i] === lf) {
if (!this._quoting && buf[i] === this.newline) {
this._online(buf, this._prevEnd, i+1)

@@ -83,3 +90,3 @@ this._prevEnd = i+1

end -- // trim newline
if (buf.length && buf[end-1] === cr) end--
if (!this.customNewline && buf.length && buf[end-1] === cr) end--

@@ -86,0 +93,0 @@ var comma = this.separator

{
"name": "csv-parser",
"version": "1.4.6",
"version": "1.5.0",
"description": "Streaming csv parser inspired by binary-csv that aims to be faster than everyone else",

@@ -5,0 +5,0 @@ "repository": "mafintosh/csv-parser",

@@ -37,3 +37,4 @@ # csv-parser

raw: false, // do not decode to utf-8 strings
separator: ',' // specify optional cell separator
separator: ',', // specify optional cell separator
newline: '\n' // specify a newline character
})

@@ -40,0 +41,0 @@ ```

@@ -220,2 +220,14 @@ var test = require('tape')

test('custom newline', function(t) {
collect('custom-newlines.csv', {newline: 'X'},verify)
function verify(err, lines) {
t.false(err, 'no err')
t.same(lines[0], {a:'1', b:'2', c:'3'}, 'first row')
t.same(lines[1], {a:'X-Men', b:'5', c:'6'}, 'second row')
t.same(lines[2], {a:'7', b:'8', c:'9'}, 'third row')
t.equal(lines.length, 3, '3 rows')
t.end()
}
})
// helpers

@@ -222,0 +234,0 @@

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