refactoring
This commit is contained in:
15
docs/Dict2CsvConverter.js
Normal file
15
docs/Dict2CsvConverter.js
Normal file
@@ -0,0 +1,15 @@
|
||||
class Dict2CsvConverter {
|
||||
|
||||
static convertDict2CSV(dict) {
|
||||
const { 'keys': columns, 'values': firstRow } = Utils.getKeysAlignedWithValues(dict);
|
||||
return `${Dict2CsvConverter.#quoteValues(columns)}\n${firstRow}`;
|
||||
}
|
||||
|
||||
static #quoteValues(values) {
|
||||
return values.map(Dict2CsvConverter.#quoteValue);
|
||||
}
|
||||
|
||||
static #quoteValue(value) {
|
||||
return '"' + value + '"';
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user