You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Opening as an Issue because I am not sure where to land the code.
/** * Convert a flat object to an array of values suitable for use with [table]{@link https://npmjs.com/package/table}. * * @param {Object} obj source of plain values * @param {Object} [options] * @param {string[]} [options.columns] the key names to use. Order is respected. Default is the result of `Object.keys(obj)` * @param {Object} [options.custom=null] additional values to use. Keys must not overlap with source obj. * @param {*} [options.default=''] value to use if a column name is not found in either the source obj or additional custom values. * @returns {Array} values in the same order as the specified columns */functionrowify(obj,options){constcolumns=options&&options.columns||Object.keys(obj);constcustom=options&&options.custom;constmissingValue=options&&options['default']||'';constrow=[];// add keys if no columns were specifiedif(custom&&!options.columns){columns.push(...Object.keys(custom));}for(constcolumnofcolumns){if(obj.hasOwnProperty(column)){row.push(obj[column]);}elseif(custom&&custom.hasOwnProperty(column)){row.push(custom[column]);}else{row.push(missingValue);}}returnrow;}
Opening as an Issue because I am not sure where to land the code.
Simple Usage
Advanced Usage
Let me know if you think others will find this useful :)
The text was updated successfully, but these errors were encountered: