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

csv-utility

Package Overview
Dependencies
Maintainers
1
Versions
5
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

csv-utility - npm Package Compare versions

Comparing version 1.0.2 to 1.0.3

16

dist/csv-utility.js

@@ -1,2 +0,2 @@

(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.tmp = f()}})(function(){var define,module,exports;return (function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
(function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s})({1:[function(require,module,exports){
module.exports = {

@@ -9,4 +9,5 @@ guessSeparator: guessSeparator,

function guessCSV(line,opts){
var linebreak = guessLinebreak(line,opts);
var sep = guessSeparator(line,linebreak,opts);
opts = opts || {};
var linebreak = (Array.isArray(opts.linebreak))?guessLinebreak(line,opts.linebreak):guessLinebreak(line,[opts.linebreak]);
var sep = (Array.isArray(opts.sep))?guessSeparator(line,linebreak,opts.sep):guessSeparator(line,linebreak,[opts.sep]);
return {sep:sep, linebreak:linebreak};

@@ -18,4 +19,3 @@ }

linebreak = linebreak || '\n';
opts = opts || {};
var choices = union([",", "\t", "|", ";"],opts.sep);
var choices = union([",", "\t", "|", ";"],opts);

@@ -55,4 +55,3 @@ var res = choices[0], error = Number.MAX_VALUE;

line = line.slice(0,102400);
opts = opts || {};
var choices = union(["\r\n", "\r", "\n"],opts.linebreak);
var choices = union(["\r\n", "\r", "\n"],opts);
var res = choices[0], score = 0;

@@ -87,3 +86,2 @@

}).call(this,typeof global !== "undefined" ? global : typeof self !== "undefined" ? self : typeof window !== "undefined" ? window : {})
},{"./index.js":1}]},{},[2])(2)
});
},{"./index.js":1}]},{},[2]);

@@ -1,1 +0,1 @@

(function(f){if(typeof exports==="object"&&typeof module!=="undefined"){module.exports=f()}else if(typeof define==="function"&&define.amd){define([],f)}else{var g;if(typeof window!=="undefined"){g=window}else if(typeof global!=="undefined"){g=global}else if(typeof self!=="undefined"){g=self}else{g=this}g.tmp=f()}})(function(){var define,module,exports;return function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a=typeof require=="function"&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}var i=typeof require=="function"&&require;for(var o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){module.exports={guessSeparator:guessSeparator,guessLinebreak:guessLinebreak,guessCSV:guessCSV};function guessCSV(line,opts){var linebreak=guessLinebreak(line,opts);var sep=guessSeparator(line,linebreak,opts);return{sep:sep,linebreak:linebreak}}function guessSeparator(line,linebreak,opts){line=line.slice(0,102400);linebreak=linebreak||"\n";opts=opts||{};var choices=union([","," ","|",";"],opts.sep);var res=choices[0],error=Number.MAX_VALUE;var lines=line.split(linebreak);choices.forEach(function(sep){var _error=examineLine(sep);if(_error<error){error=_error;res=sep}});return res;function examineLine(sep){var sum=0;var res=lines.map(function(d){var len=d.split(sep).length;sum+=len;return len});if(sum===res.length)return Number.MAX_VALUE;var mean=sum/res.length;var sumerror=res.map(function(d){return(d-mean)*(d-mean)}).reduce(function(a,b){return a+b});return sumerror}}function guessLinebreak(line,opts){line=line.slice(0,102400);opts=opts||{};var choices=union(["\r\n","\r","\n"],opts.linebreak);var res=choices[0],score=0;choices.forEach(function(sep,i){var len=line.split(sep).length;if(score<len){score=len;res=sep}});return res}function union(array1,array2){if(!array2)return array1;var map={};array1.forEach(function(d){map[d]=true});array2.forEach(function(d){map[d]=true});return Object.keys(map)}},{}],2:[function(require,module,exports){(function(global){var csvUtility=require("./index.js");if(typeof global.window.define=="function"&&global.window.define.amd){global.window.define("csvUtility",function(){return csvUtility})}else{global.window.csvUtility=csvUtility}}).call(this,typeof global!=="undefined"?global:typeof self!=="undefined"?self:typeof window!=="undefined"?window:{})},{"./index.js":1}]},{},[2])(2)});
!function e(t,n,r){function s(o,u){if(!n[o]){if(!t[o]){var a="function"==typeof require&&require;if(!u&&a)return a(o,!0);if(i)return i(o,!0);var f=new Error("Cannot find module '"+o+"'");throw f.code="MODULE_NOT_FOUND",f}var l=n[o]={exports:{}};t[o][0].call(l.exports,function(e){var n=t[o][1][e];return s(n?n:e)},l,l.exports,e,t,n,r)}return n[o].exports}for(var i="function"==typeof require&&require,o=0;o<r.length;o++)s(r[o]);return s}({1:[function(require,module,exports){function guessCSV(line,opts){opts=opts||{};var linebreak=Array.isArray(opts.linebreak)?guessLinebreak(line,opts.linebreak):guessLinebreak(line,[opts.linebreak]),sep=Array.isArray(opts.sep)?guessSeparator(line,linebreak,opts.sep):guessSeparator(line,linebreak,[opts.sep]);return{sep:sep,linebreak:linebreak}}function guessSeparator(line,linebreak,opts){function examineLine(sep){var sum=0,res=lines.map(function(d){var len=d.split(sep).length;return sum+=len,len});if(sum===res.length)return Number.MAX_VALUE;var mean=sum/res.length,sumerror=res.map(function(d){return(d-mean)*(d-mean)}).reduce(function(a,b){return a+b});return sumerror}line=line.slice(0,102400),linebreak=linebreak||"\n";var choices=union([","," ","|",";"],opts),res=choices[0],error=Number.MAX_VALUE,lines=line.split(linebreak);return choices.forEach(function(sep){var _error=examineLine(sep);error>_error&&(error=_error,res=sep)}),res}function guessLinebreak(line,opts){line=line.slice(0,102400);var choices=union(["\r\n","\r","\n"],opts),res=choices[0],score=0;return choices.forEach(function(sep,i){var len=line.split(sep).length;len>score&&(score=len,res=sep)}),res}function union(array1,array2){if(!array2)return array1;var map={};return array1.forEach(function(d){map[d]=!0}),array2.forEach(function(d){map[d]=!0}),Object.keys(map)}module.exports={guessSeparator:guessSeparator,guessLinebreak:guessLinebreak,guessCSV:guessCSV}},{}],2:[function(require,module,exports){(function(global){var csvUtility=require("./index.js");"function"==typeof global.window.define&&global.window.define.amd?global.window.define("csvUtility",function(){return csvUtility}):global.window.csvUtility=csvUtility}).call(this,"undefined"!=typeof global?global:"undefined"!=typeof self?self:"undefined"!=typeof window?window:{})},{"./index.js":1}]},{},[2]);

@@ -9,4 +9,4 @@ module.exports = {

opts = opts || {};
var linebreak = (Array.isArray(opts.linebreak))?guessLinebreak(line,opts.linebreak):opts.linebreak;
var sep = (Array.isArray(opts.sep))?guessSeparator(line,linebreak,opts.sep):opts.sep;
var linebreak = (Array.isArray(opts.linebreak))?guessLinebreak(line,opts.linebreak):guessLinebreak(line,[opts.linebreak]);
var sep = (Array.isArray(opts.sep))?guessSeparator(line,linebreak,opts.sep):guessSeparator(line,linebreak,[opts.sep]);
return {sep:sep, linebreak:linebreak};

@@ -13,0 +13,0 @@ }

{
"name": "csv-utility",
"version": "1.0.2",
"version": "1.0.3",
"description": "A simple package to guess the separator and linebreak characters for a csv file.",

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

@@ -60,2 +60,3 @@ # csv-utility

1.0.1 BUGFIX: Corrected the documentation for csvUtility.guessSeparator.
1.0.2 BUGFIX: Forgot to push the changes for the codes.
1.0.2 BUGFIX: Forgot to push the changes for the codes.
1.0.3 BUGFIX: Fixed bug at parsing non-array inputs.
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