Socket
Socket
Sign inDemoInstall

csv-parse

Package Overview
Dependencies
Maintainers
1
Versions
141
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

csv-parse - npm Package Compare versions

Comparing version 0.1.0 to 0.1.1

37

lib/index.js
// Generated by CoffeeScript 1.9.1
var Parser, stream, util;
var Parser, StringDecoder, stream, util;

@@ -8,2 +8,4 @@ stream = require('stream');

StringDecoder = require('string_decoder').StringDecoder;
module.exports = function() {

@@ -72,3 +74,3 @@ var callback, called, chunks, data, options, parser;

Parser = function(options) {
var base, base1, base10, base11, base2, base3, base4, base5, base6, base7, base8, base9;
var base, base1, base10, base11, base2, base3, base4, base5, base6, base7, base8, base9, k, v;
if (options == null) {

@@ -78,4 +80,8 @@ options = {};

options.objectMode = true;
stream.Transform.call(this, options);
this.options = options;
this.options = {};
for (k in options) {
v = options[k];
this.options[k] = v;
}
stream.Transform.call(this, this.options);
if ((base = this.options).rowDelimiter == null) {

@@ -118,2 +124,6 @@ base.rowDelimiter = null;

this.lines = 0;
this.count = 0;
this.regexp_int = /^(\-|\+)?([1-9]+[0-9]*)$/;
this.regexp_float = /^(\-|\+)?([0-9]+(\.[0-9]+)?([eE][0-9]+)?|Infinity)$/;
this.decoder = new StringDecoder();
this.buf = '';

@@ -127,4 +137,2 @@ this.quoting = false;

this.chunks = [];
this.intRegexp = /^(\-|\+)?([1-9]+[0-9]*)$/;
this.floatRegexp = /^(\-|\+)?([0-9]+(\.[0-9]+)?([eE][0-9]+)?|Infinity)$/;
return this;

@@ -140,3 +148,3 @@ };

if (chunk instanceof Buffer) {
chunk = chunk.toString();
chunk = this.decoder.write(chunk);
}

@@ -155,3 +163,3 @@ try {

try {
this.__write('', true);
this.__write(this.decoder.end(), true);
if (this.quoting) {

@@ -180,2 +188,3 @@ this.emit('error', new Error("Quoted field not terminated at line " + (this.lines + 1)));

}
this.count++;
if (this.options.columns != null) {

@@ -198,3 +207,3 @@ lineAsColumns = {};

Parser.prototype.__write = function(chars, end, callback) {
var acceptedLength, areNextCharsRowDelimiters, char, escapeIsQuote, i, isDelimiter, isEscape, isNextCharAComment, isNextCharADelimiter, isQuote, isRowDelimiter, l, ltrim, nextCharPos, results, rowDelimiter, rowDelimiterLength, rtrim, wasCommenting;
var acceptedLength, areNextCharsRowDelimiters, char, escapeIsQuote, i, isDelimiter, isEscape, isNextCharAComment, isNextCharADelimiter, isQuote, isRowDelimiter, l, ltrim, nextCharPos, ref, results, rowDelimiter, rowDelimiterLength, rtrim, wasCommenting;
ltrim = this.options.trim || this.options.ltrim;

@@ -278,2 +287,5 @@ rtrim = this.options.trim || this.options.rtrim;

isRowDelimiter = this.options.rowDelimiter && chars.substr(i, this.options.rowDelimiter.length) === this.options.rowDelimiter;
if (isRowDelimiter) {
this.lines++;
}
wasCommenting = false;

@@ -300,5 +312,5 @@ if (!this.commenting && !this.quoting && this.options.comment && chars.substr(i, this.options.comment.length) === this.options.comment) {

}
if (this.options.auto_parse && this.intRegexp.test(this.field)) {
if (this.options.auto_parse && this.regexp_int.test(this.field)) {
this.line.push(parseInt(this.field));
} else if (this.options.auto_parse && this.floatRegexp.test(this.field)) {
} else if (this.options.auto_parse && this.regexp_float.test(this.field)) {
this.line.push(parseFloat(this.field));

@@ -320,5 +332,4 @@ } else {

this.__push(this.line);
this.lines++;
this.line = [];
i += this.options.rowDelimiter.length;
i += (ref = this.options.rowDelimiter) != null ? ref.length : void 0;
this.nextChar = chars.charAt(i);

@@ -325,0 +336,0 @@ continue;

{
"version": "0.1.0",
"version": "0.1.1",
"name": "csv-parse",

@@ -4,0 +4,0 @@ "description": "CSV parsing implementing the Node.js `stream.Transform` API",

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