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({
<code>skipEmptyLines</code> <code>skipEmptyLines</code>
</td> </td>
<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> </td>
</tr> </tr>
<tr> <tr>

2
papaparse.js

@ -1077,7 +1077,7 @@
function testEmptyLine(s, d) { function testEmptyLine(s, d) {
var q = _config.quoteChar || '"'; 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++) for (var i = 0; i < s.length; i++)
if (r.test(s[i])) if (r.test(s[i]))
return true; return true;

8
tests/test-cases.js

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

Loading…
Cancel
Save