* Creates a new instance of the object array to csv converter. * @param {object[]} objectArray
(objectArray)
| 13 | * @param {object[]} objectArray |
| 14 | */ |
| 15 | constructor(objectArray) { |
| 16 | if (!Array.isArray(objectArray)) { |
| 17 | throw new Error('The input to objects-to-csv must be an array of objects.'); |
| 18 | } |
| 19 | |
| 20 | if (objectArray.length > 0) { |
| 21 | if (objectArray.some(row => typeof row !== 'object')) { |
| 22 | throw new Error('The array must contain objects, not other data types.'); |
| 23 | } |
| 24 | } |
| 25 | |
| 26 | this.data = objectArray; |
| 27 | } |
| 28 | |
| 29 | /** |
| 30 | * Saves the CSV file to the specified file. |
no outgoing calls
no test coverage detected