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.3 to 1.0.4

2

bower.json
{
"name": "csv-utility",
"main": "./dist/csv-utility.min.js",
"version": "1.0.2",
"version": "1.0.4",
"homepage": "https://github.com/eterna2/csv-utility",

@@ -6,0 +6,0 @@ "authors": [

@@ -47,3 +47,3 @@ (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){

return sumerror;
return 0.01+Math.sqrt(sumerror)/sum;
}

@@ -50,0 +50,0 @@ }

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

!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]);
(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){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}}function guessSeparator(line,linebreak,opts){line=line.slice(0,102400);linebreak=linebreak||"\n";var choices=union([","," ","|",";"],opts);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.01+Math.sqrt(sumerror)/sum}}function guessLinebreak(line,opts){line=line.slice(0,102400);var choices=union(["\r\n","\r","\n"],opts);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]);

@@ -46,3 +46,3 @@ module.exports = {

return sumerror;
return 0.01+Math.sqrt(sumerror)/sum;
}

@@ -49,0 +49,0 @@ }

@@ -0,0 +0,0 @@ var csvUtility = require('./index.js');

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

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

@@ -62,1 +62,2 @@ # csv-utility

1.0.3 BUGFIX: Fixed bug at parsing non-array inputs.
1.0.4 UPDATE: Modified the error weights for the separator detection, to reduce noise from low frequency separator characters.

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