From 078bc8858abe885cb16fa4227c433e978d3b0706 Mon Sep 17 00:00:00 2001 From: Billiam Date: Wed, 30 Oct 2013 13:20:41 -0500 Subject: [PATCH] Fixes parsing error when delimiter is not provided. --- jquery.parse.js | 4 ++-- jquery.parse.min.js | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/jquery.parse.js b/jquery.parse.js index 9e7b6e5..372d942 100644 --- a/jquery.parse.js +++ b/jquery.parse.js @@ -26,7 +26,7 @@ function verifyOptions(opt) { - opt.delimeter = opt.delimiter || defaults.delimiter; + opt.delimiter = opt.delimiter || defaults.delimiter; opt.header = typeof opt.header === 'undefined' ? defaults.header : opt.header; @@ -332,4 +332,4 @@ } -})(jQuery); \ No newline at end of file +})(jQuery); diff --git a/jquery.parse.min.js b/jquery.parse.min.js index 795a21a..2540191 100644 --- a/jquery.parse.min.js +++ b/jquery.parse.min.js @@ -3,4 +3,4 @@ v0.5.5 https://github.com/mholt/jquery.parse */ -;(function(e){"use strict";function n(e){e.delimeter=e.delimiter||t.delimiter;e.header=typeof e.header==="undefined"?t.header:e.header;e.dynamicTyping=typeof e.dynamicTyping==="undefined"?t.dynamicTyping:e.dynamicTyping;if(e.delimiter=='"'||e.delimiter=="\n")e.delimiter=t.delimiter;if(e.delimiter.length>1)e.delimiter=e.delimiter[0];return e}function r(e,t){function u(e){return e?{fields:[],rows:[]}:[[]]}function a(){return{i:0,line:1,field:0,fieldVal:"",ch:"",inQuotes:false,parsed:u(t.header)}}function f(){var e=o.i>0&&p(r[o.i-1])||o.i==0;var t=o.i0)o.parsed.rows.push({})}else o.parsed.push([]);o.line++;o.field=0}function m(e){var t=/^-?\d+(\.\d+)?$/.test(e);return t?parseFloat(e):e}function g(){if(i.header){if(o.line==1){if(o.parsed.fields.length==1&&o.parsed.fields[0].length==0){o.parsed.fields=[];o.line--}}else{var e=o.parsed.rows[o.parsed.rows.length-1];if(!e[o.parsed.fields[0]])o.parsed.rows.splice(o.parsed.rows.length-1,1)}}else{var e=o.parsed[o.parsed.length-1];if(e.length==0||e[0].length==0)o.parsed.splice(o.parsed.length-1,1)}}function y(){if(!i.header)return true;if(o.parsed.rows.length==0)return true;var e=o.parsed.fields.length;var t=0;var n=o.parsed.rows[o.parsed.rows.length-1];for(var r in n)if(n.hasOwnProperty(r))t++;if(e!=t)return b("Too few fields; expected "+e+" fields, parsed "+t);return true}function b(e){s.push({message:e,line:o.line,row:i.header?o.parsed.rows.length-1:o.parsed.length-1,index:o.i});return false}var n=this;var r=e;var i=t;var s=[];var o=a();this.parse=function(e){if(typeof e==="object")n.setConfig(e);else if(typeof e==="string")n.setInput(e);s=[];o=a();for(o.i=0;o.i1)e.delimiter=e.delimiter[0];return e}function r(e,t){function u(e){return e?{fields:[],rows:[]}:[[]]}function a(){return{i:0,line:1,field:0,fieldVal:"",ch:"",inQuotes:false,parsed:u(t.header)}}function f(){var e=o.i>0&&p(r[o.i-1])||o.i==0;var t=o.i0)o.parsed.rows.push({})}else o.parsed.push([]);o.line++;o.field=0}function m(e){var t=/^-?\d+(\.\d+)?$/.test(e);return t?parseFloat(e):e}function g(){if(i.header){if(o.line==1){if(o.parsed.fields.length==1&&o.parsed.fields[0].length==0){o.parsed.fields=[];o.line--}}else{var e=o.parsed.rows[o.parsed.rows.length-1];if(!e[o.parsed.fields[0]])o.parsed.rows.splice(o.parsed.rows.length-1,1)}}else{var e=o.parsed[o.parsed.length-1];if(e.length==0||e[0].length==0)o.parsed.splice(o.parsed.length-1,1)}}function y(){if(!i.header)return true;if(o.parsed.rows.length==0)return true;var e=o.parsed.fields.length;var t=0;var n=o.parsed.rows[o.parsed.rows.length-1];for(var r in n)if(n.hasOwnProperty(r))t++;if(e!=t)return b("Too few fields; expected "+e+" fields, parsed "+t);return true}function b(e){s.push({message:e,line:o.line,row:i.header?o.parsed.rows.length-1:o.parsed.length-1,index:o.i});return false}var n=this;var r=e;var i=t;var s=[];var o=a();this.parse=function(e){if(typeof e==="object")n.setConfig(e);else if(typeof e==="string")n.setInput(e);s=[];o=a();for(o.i=0;o.i