Browse Source

Allow multi-characters delimtier at serialization.

pull/519/head
Adi Roiban 7 years ago
parent
commit
59e475ee6e
  1. 5
      papaparse.js
  2. 6
      tests/test-cases.js

5
papaparse.js

@ -326,9 +326,10 @@ @@ -326,9 +326,10 @@
return;
if (typeof _config.delimiter === 'string'
&& _config.delimiter.length === 1
&& Papa.BAD_DELIMITERS.indexOf(_config.delimiter) === -1)
&& !Papa.BAD_DELIMITERS.filter(function(value) { return _config.delimiter.includes(value); }).length)
{
// We have a string as config and it does not contains any
// of the invalid delimiters.
_delimiter = _config.delimiter;
}

6
tests/test-cases.js

@ -1396,6 +1396,12 @@ var UNPARSE_TESTS = [ @@ -1396,6 +1396,12 @@ var UNPARSE_TESTS = [
config: { delimiter: RECORD_SEP },
expected: 'a' + RECORD_SEP + 'b' + RECORD_SEP + 'c\r\nd' + RECORD_SEP + 'e' + RECORD_SEP + 'f'
},
{
description: "Custom delimiter (Multi-character)",
input: [['A', 'b', 'c'], ['d', 'e', 'f']],
config: { delimiter: ', ' },
expected: 'A, b, c\r\nd, e, f'
},
{
description: "Bad delimiter (\\n)",
notes: "Should default to comma",

Loading…
Cancel
Save