From 1d7fb0c8bfc96dcdd1763673db3dcb6d1298f0b2 Mon Sep 17 00:00:00 2001 From: 30secondsofcode <30secondsofcode@gmail.com> Date: Tue, 9 Oct 2018 08:16:49 +0000 Subject: [PATCH] Travis build: 620 --- README.md | 2 +- docs/index.html | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index 448fc2eaf..c0e4315bb 100644 --- a/README.md +++ b/README.md @@ -1767,7 +1767,7 @@ join(['pen', 'pineapple', 'apple', 'pen']); // "pen,pineapple,apple,pen" Converts an array of objects to a comma-separated values (CSV) string that contains only the `columns` specified. -Use `Array.prototype.join(demiliter)` to combine all the names in `columns` to create the first row. +Use `Array.prototype.join(delimiter)` to combine all the names in `columns` to create the first row. Use `Array.prototype.map()` and `Array.prototype.reduce()` to create a row for each object, substituting non-existent values with empty strings and only mapping values in `columns`. Use `Array.prototype.join('\n')` to combine all rows into a string. Omit the third argument, `delimiter`, to use a default delimiter of `,`. diff --git a/docs/index.html b/docs/index.html index 62c1782c8..661a471df 100644 --- a/docs/index.html +++ b/docs/index.html @@ -266,7 +266,7 @@
join(['pen', 'pineapple', 'apple', 'pen'], ',', '&'); // "pen,pineapple,apple&pen" join(['pen', 'pineapple', 'apple', 'pen'], ','); // "pen,pineapple,apple,pen" join(['pen', 'pineapple', 'apple', 'pen']); // "pen,pineapple,apple,pen" -
Converts an array of objects to a comma-separated values (CSV) string that contains only the columns specified.
Use Array.prototype.join(demiliter) to combine all the names in columns to create the first row. Use Array.prototype.map() and Array.prototype.reduce() to create a row for each object, substituting non-existent values with empty strings and only mapping values in columns. Use Array.prototype.join('\n') to combine all rows into a string. Omit the third argument, delimiter, to use a default delimiter of ,.
const JSONtoCSV = (arr, columns, delimiter = ',') => +
Converts an array of objects to a comma-separated values (CSV) string that contains only the columns specified.
Use Array.prototype.join(delimiter) to combine all the names in columns to create the first row. Use Array.prototype.map() and Array.prototype.reduce() to create a row for each object, substituting non-existent values with empty strings and only mapping values in columns. Use Array.prototype.join('\n') to combine all rows into a string. Omit the third argument, delimiter, to use a default delimiter of ,.
const JSONtoCSV = (arr, columns, delimiter = ',') => [ columns.join(delimiter), ...arr.map(obj =>