{"size": 346, "ext": "js", "max_stars_repo_path": "src/javascript/flattenObject.js", "max_stars_repo_name": "qunzi0214/many-tricks", "max_stars_repo_stars_event_min_datetime": "2021-03-03T06:38:17.000Z", "max_stars_repo_stars_event_max_datetime": "2022-01-18T07:19:20.000Z", "max_issues_repo_path": "src/javascript/flattenObject.js", "max_issues_repo_name": "qunzi0214/many-tricks", "max_issues_repo_issues_event_min_datetime": null, "max_issues_repo_issues_event_max_datetime": null, "max_forks_repo_path": "src/javascript/flattenObject.js", "max_forks_repo_name": "qunzi0214/many-tricks", "max_forks_repo_forks_event_min_datetime": null, "max_forks_repo_forks_event_max_datetime": null}
{"max_stars_count": 4, "max_issues_count": null, "max_forks_count": null, "avg_line_length": 31.4545454545, "max_line_length": 86, "alphanum_fraction": 0.5173410405}

const flattenObject = (obj, prefix = '') =>
  Object.keys(obj).reduce((acc, k) => {
    const pre = prefix.length ? prefix + '.' : ''
    if (typeof obj[k] === 'object') Object.assign(acc, flattenObject(obj[k], pre + k))
    else acc[pre + k] = obj[k]
    return acc
  }, {})

flattenObject({ a: { b: { c: 1 } }, d: 1 }) // { 'a.b.c': 1, d: 1 }
