Skip to content

Commit 47a925e

Browse files
committed
ref #11 Use Array.from to convert an iterable object into an array
1 parent 7c96d01 commit 47a925e

File tree

1 file changed

+2
-7
lines changed

1 file changed

+2
-7
lines changed

lib/csv-stringifiers/abstract.js

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
'use strict';
32

43
const RECORD_DELIMITER = '\n';
@@ -16,12 +15,8 @@ class AbstractCsvStringifier {
1615
}
1716

1817
stringifyRecords(records) {
19-
const array = [];
20-
for (let record of records) {
21-
array.push(this._getCsvLine(this._getRecordAsArray(record)));
22-
}
23-
array.push('');
24-
return array.join(RECORD_DELIMITER);
18+
const csvLines = Array.from(records, record => this._getCsvLine(this._getRecordAsArray(record)));
19+
return csvLines.join(RECORD_DELIMITER) + RECORD_DELIMITER;
2520
}
2621

2722
/* istanbul ignore next */_getRecordAsArray(_record) {

0 commit comments

Comments
 (0)