Browse Source

changed 'strict' to 'greedy'

pull/544/head
jaymeans 7 years ago
parent
commit
585b427bba
  1. 2
      docs/docs.html
  2. 2
      papaparse.js
  3. 8
      tests/test-cases.js

2
docs/docs.html

@ -505,7 +505,7 @@ var csv = Papa.unparse({ @@ -505,7 +505,7 @@ var csv = Papa.unparse({
<code>skipEmptyLines</code>
</td>
<td>
If true, lines that are completely empty (those which evaluate to an empty string) will be skipped. If set to <code>'strict'</code>, lines that don't have any content (those which have only delimiters, quotes, and whitespace) will also be skipped.
If true, lines that are completely empty (those which evaluate to an empty string) will be skipped. If set to <code>'greedy'</code>, lines that don't have any content (those which have only delimiters, quotes, and whitespace) will also be skipped.
</td>
</tr>
<tr>

2
papaparse.js

@ -1077,7 +1077,7 @@ @@ -1077,7 +1077,7 @@
function testEmptyLine(s, d) {
var q = _config.quoteChar || '"';
var r = _config.skipEmptyLines === 'strict' ? new RegExp('^[' + escapeRegExp(d) + escapeRegExp(q) + '\\s]*$') : new RegExp('^$');
var r = _config.skipEmptyLines === 'greedy' ? new RegExp('^[' + escapeRegExp(d) + escapeRegExp(q) + '\\s]*$') : new RegExp('^$');
for (var i = 0; i < s.length; i++)
if (r.test(s[i]))
return true;

8
tests/test-cases.js

@ -1340,10 +1340,10 @@ var PARSE_TESTS = [ @@ -1340,10 +1340,10 @@ var PARSE_TESTS = [
}
},
{
description: "Parsing with skipEmptyLines set to 'strict'",
description: "Parsing with skipEmptyLines set to 'greedy'",
notes: "Must parse correctly without lines with no content",
input: 'a,b\n\n,\nc,d\n , \n""," "\n " " , " "\n,,,,\n",,,",","\n',
config: { skipEmptyLines: 'strict' },
config: { skipEmptyLines: 'greedy' },
expected: {
data: [['a', 'b'], ['c', 'd']],
errors: []
@ -1353,7 +1353,7 @@ var PARSE_TESTS = [ @@ -1353,7 +1353,7 @@ var PARSE_TESTS = [
description: "Parsing with skipNoContentLines and regex special char as quoteChar",
notes: "Must skip lines correctly with reserved regex char as quoteChar",
input: 'a,b\n\n,\nc,d\n , \n]],] ]\n ] ] , ] ]\n,,,,\n],,,],],]\n',
config: { skipEmptyLines: 'strict', quoteChar: ']' },
config: { skipEmptyLines: 'greedy', quoteChar: ']' },
expected: {
data: [['a', 'b'], ['c', 'd']],
errors: []
@ -1363,7 +1363,7 @@ var PARSE_TESTS = [ @@ -1363,7 +1363,7 @@ var PARSE_TESTS = [
description: "Parsing with skipNoContentLines and regex special char as delimiter",
notes: "Must skip lines correctly with reserved regex char as delimiter",
input: 'a]b\n\n]\nc]d\n ] \n""]" "\n " " ] " "\n]]]]\n"]]]"]"]"\n',
config: { skipEmptyLines: 'strict', delimiter: ']' },
config: { skipEmptyLines: 'greedy', delimiter: ']' },
expected: {
data: [['a', 'b'], ['c', 'd']],
errors: []

Loading…
Cancel
Save