Browse Source

Do not pass an array of array when using step and worker

Closes #613
pull/622/head
Sergi Almacellas Abellana 6 years ago
parent
commit
dc16b88e5e
  1. 2
      papaparse.js
  2. 31
      tests/test-cases.js

2
papaparse.js

@ -1707,7 +1707,7 @@ License: MIT
for (var i = 0; i < msg.results.data.length; i++) for (var i = 0; i < msg.results.data.length; i++)
{ {
worker.userStep({ worker.userStep({
data: [msg.results.data[i]], data: msg.results.data[i],
errors: msg.results.errors, errors: msg.results.errors,
meta: msg.results.meta meta: msg.results.meta
}, handle); }, handle);

31
tests/test-cases.js

@ -1789,6 +1789,37 @@ var CUSTOM_TESTS = [
}); });
} }
}, },
{
description: "Data is correctly parsed with steps",
expected: [['A', 'b', 'c'], ['d', 'E', 'f']],
run: function(callback) {
var data = [];
Papa.parse('A,b,c\nd,E,f', {
step: function(results) {
data.push(results.data);
},
complete: function() {
callback(data);
}
});
}
},
{
description: "Data is correctly parsed with steps and worker",
expected: [['A', 'b', 'c'], ['d', 'E', 'f']],
run: function(callback) {
var data = [];
Papa.parse('A,b,c\nd,E,f', {
worker: true,
step: function(results) {
data.push(results.data);
},
complete: function() {
callback(data);
}
});
}
},
{ {
description: "Step is called with the contents of the row", description: "Step is called with the contents of the row",
expected: ['A', 'b', 'c'], expected: ['A', 'b', 'c'],

Loading…
Cancel
Save