Skip to content

Commit

Permalink
ref #11 Use Array.from to convert an iterable object into an array
Browse files Browse the repository at this point in the history
  • Loading branch information
ryu1kn committed Aug 22, 2018
1 parent 7c96d01 commit 47a925e
Showing 1 changed file with 2 additions and 7 deletions.
9 changes: 2 additions & 7 deletions lib/csv-stringifiers/abstract.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

'use strict';

const RECORD_DELIMITER = '\n';
Expand All @@ -16,12 +15,8 @@ class AbstractCsvStringifier {
}

stringifyRecords(records) {
const array = [];
for (let record of records) {
array.push(this._getCsvLine(this._getRecordAsArray(record)));
}
array.push('');
return array.join(RECORD_DELIMITER);
const csvLines = Array.from(records, record => this._getCsvLine(this._getRecordAsArray(record)));
return csvLines.join(RECORD_DELIMITER) + RECORD_DELIMITER;
}

/* istanbul ignore next */_getRecordAsArray(_record) {
Expand Down

0 comments on commit 47a925e

Please sign in to comment.