UNPKG

@gameroom/cli

Version:

A command line tool for Gameroom

9 lines (8 loc) 310 B
module.exports = (array) => { const replacer = (key, value) => value === null ? '' : value const header = Object.keys(array[0]) let csv = array.map(row => header.map(fieldName => JSON.stringify(row[fieldName], replacer)).join(',')) csv.unshift(header.join(',')) csv = csv.join('\r\n') return csv }