From eb1d7eab10ace307cdb8de8051e97358acf13c9c Mon Sep 17 00:00:00 2001 From: Matthew Holt Date: Sun, 13 Oct 2013 19:40:23 -0600 Subject: [PATCH] Clarified title; minor bug fix for negative numbers --- README.md | 6 +++--- jquery.parse.js | 6 +++--- jquery.parse.min.js | 6 +++--- parse.jquery.json | 10 +++++----- 4 files changed, 14 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index f358f5c..96d4aa8 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ -jquery.parse -============ +Parse jQuery Plugin (jquery.parse) +================================== -Robust, efficient CSV parsing (with nearly any delimiting character). Malformed CSV files are especially common, and this parser is an attempt to handle parsing errors more robustly and parse CSV text more efficiently. +Robust, efficient CSV parsing (supports custom delimiting characters). Malformed CSV files are especially common, and this parser is an attempt to handle parsing errors more robustly and parse CSV text more efficiently. **[jsFIDDLE DEMO](http://jsfiddle.net/mholt/nCaee/)** diff --git a/jquery.parse.js b/jquery.parse.js index a4c6ae6..ec74712 100644 --- a/jquery.parse.js +++ b/jquery.parse.js @@ -1,6 +1,6 @@ /* - jQuery Parse plugin - v0.5.2 + Parse jQuery Plugin + v0.5.3 https://github.com/mholt/jquery.parse */ @@ -263,7 +263,7 @@ function tryParseFloat(num) { - var isNumber = /^\d+(\.\d+)?$/.test(num); + var isNumber = /^-?\d+(\.\d+)?$/.test(num); return isNumber ? parseFloat(num) : num; } diff --git a/jquery.parse.min.js b/jquery.parse.min.js index 7aef6a1..9395a04 100644 --- a/jquery.parse.min.js +++ b/jquery.parse.min.js @@ -1,6 +1,6 @@ /* - jQuery Parse plugin - v0.5.2 + Parse jQuery Plugin + v0.5.3 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]);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=Object.keys(o.parsed.rows[o.parsed.rows.length-1]).length;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]);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=Object.keys(o.parsed.rows[o.parsed.rows.length-1]).length;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