Repository: mholt/PapaParse (JavaScript)

Issue:
Both config skipEmptyLines: 'greedy' and step throw error
``` javascript
Papa.parse(event.target.files[0], {
    header: true,
    transformHeader: (val) => FIELDS_MAP[val],
    skipEmptyLines: 'greedy',  // Both config skipEmptyLines: 'greedy' and step throw error
    step: (results, parser) => {
      console.log('Row data:', results.data);
      console.log('Row errors:', results.errors);
      parser.resume();
    },
    complete: (results, file) => {
      console.log('Parsing complete:', results, file);
    }
});
```
`Uncaught TypeError: e.join is not a function`

``` javascript
return"greedy"===_.skipEmptyLines?""===e.join("") 
```
in this line



Discussion:
Can confirm this issue is still present with v5.0.0.
I have the problem that I cannot parse any file that has "newline at end of file" added e.g. when saving a CSV file under Linux using LibreOffice. I was hoping `skipEmptyLines: 'greedy'` solves this issue, but all attempts to parse a file now throw `e.join is not a function`

just in case somebody has the same issue with new lines and passes a File object to PapaParse.. a workaround by now can be something like:
```javascript
const reader = new FileReader()
reader.onload = (event) => {
  let csvString = event.target.result
  while (csvString.endsWith('\r') || csvString.endsWith('\n')) {
    csvString = csvString.slice(0, csvString.length - 1)
  }
  Papa.parse(csvString, {...})
}
reader.readAsText(this.file)
```
To add onto this, it appears setting `skipEmptyLines` to `true` does nothing when a step function is declared.

A simple test you can add to the `CUSTOM_TESTS` in `test-cases.js` to show this: 

```javascript
{
	description: "Data is correctly parsed with steps when skipping empty lines",
	expected: [['A', 'b', 'c'], ['d', 'E', 'f']],
	run: function(callback) {
		var data = [];
		Papa.parse('A,b,c\n\nd,E,f\n', {
			skipEmptyLines: true,
			step: function(results) {
				data.push(results.data);
			},
			complete: function() {
				callback(data);
			}
		});
	}
}
```
The problem is still there in 5.1.0:

skipEmptyLines set to greedy and step function triggers this error:

```node_modules/papaparse/papaparse.js:1126 return _config.skipEmptyLines === 'greedy' ? s.join('').trim() === '' : s.length === 1 && s[0].length === 0; TypeError: s.join is not a function```



Patch:
diff --git a/papaparse.js b/papaparse.js
index b624e503..f1674f52 100755
--- a/papaparse.js
+++ b/papaparse.js
@@ -1036,8 +1036,10 @@ License: MIT
 					_stepCounter += results.data.length;
 					if (_config.preview && _stepCounter > _config.preview)
 						_parser.abort();
-					else
+					else {
+						_results.data = _results.data[0];
 						userStep(_results, self);
+					}
 				}
 			};
 		}
@@ -1706,11 +1708,10 @@ License: MIT
 			}
 
 			/** Returns an object with the results, errors, and meta. */
-			function returnable(stopped, step)
+			function returnable(stopped)
 			{
-				var isStep = step || false;
 				return {
-					data: isStep ? data[0]  : data,
+					data: data,
 					errors: errors,
 					meta: {
 						delimiter: delim,
@@ -1725,7 +1726,7 @@ License: MIT
 			/** Executes the user's step function and resets data & errors. */
 			function doStep()
 			{
-				step(returnable(undefined, true));
+				step(returnable());
 				data = [];
 				errors = [];
 			}


Test patch:
diff --git a/tests/test-cases.js b/tests/test-cases.js
index 0c4ab048..58a85f08 100644
--- a/tests/test-cases.js
+++ b/tests/test-cases.js
@@ -1973,6 +1973,22 @@ var CUSTOM_TESTS = [
 			});
 		}
 	},
+	{
+		description: "Data is correctly parsed with steps when skipping empty lines",
+		expected: [['A', 'b', 'c'], ['d', 'E', 'f']],
+		run: function(callback) {
+			var data = [];
+			Papa.parse('A,b,c\n\nd,E,f', {
+				skipEmptyLines: true,
+				step: function(results) {
+					data.push(results.data);
+				},
+				complete: function() {
+					callback(data);
+				}
+			});
+		}
+	},
 	{
 		description: "Step is called with the contents of the row",
 		expected: ['A', 'b', 'c'],