{"size": 1128, "ext": "js", "max_stars_repo_path": "src/utils/convert.js", "max_stars_repo_name": "mahongquan/electron-sqlite3", "max_stars_repo_stars_event_min_datetime": "2018-07-08T14:01:04.000Z", "max_stars_repo_stars_event_max_datetime": "2021-09-28T04:02:27.000Z", "max_issues_repo_path": "src/renderer/utils/convert.js", "max_issues_repo_name": "manuelh2410/sqlectron-gui", "max_issues_repo_issues_event_min_datetime": "2021-01-28T20:48:47.000Z", "max_issues_repo_issues_event_max_datetime": "2022-03-25T19:03:15.000Z", "max_forks_repo_path": "src/renderer/utils/convert.js", "max_forks_repo_name": "manuelh2410/sqlectron-gui", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 18, "max_issues_count": 2, "max_forks_count": null, "avg_line_length": 18.1935483871, "max_line_length": 88, "alphanum_fraction": 0.6471631206}
export function rowsValuesToString(rows) {
  return rows.map(rowValuesToString);
}


export function rowValuesToString(row) {
  if (Array.isArray(row)) {
    return rowsValuesToString(row);
  }

  const parsedRow = {};

  Object.keys(row).forEach((col) => {
    parsedRow[col] = valueToString(row[col]);
  });

  return parsedRow;
}


export function valueToString(value) {
  if (value === null) {
    return 'NULL';
  }

  if (typeof value === 'boolean') {
    return value.toString();
  }

  if (!value) {
    return String(value);
  }

  if (value.toISOString) {
    return value.toISOString();
  }

  if (typeof value === 'object') {
    if (isArrayBuffer(value)) {
      return arrayBufferToString(value);
    }

    return JSON.stringify(value);
  }

  return String(value);
}

function arrayBufferToString(buf) {
  if (buf.length === 1) {
    // Probably is a bit column
    return String(buf[0]);
  }
  return buf.toString('utf-8');
}

// reference:
// http://stackoverflow.com/a/21799845/1050818
function isArrayBuffer(value) {
  return value && value.buffer instanceof ArrayBuffer && value.byteLength !== undefined;
}
