Surprise! We've been running on hardware provided by BuyVM for a few months and wanted to show them a little appreciation.
Running a paste site comes with unique challenges, ones that aren't always obvious and hard to control. As such, BuyVM offered us a home where we could worry less about the hosting side of things and focus on maintaining a clean and useful service! Go check them out and show them some love!
Description: getDeepKeys - SO
Submitted on July 8, 2022 at 05:54 PM

getDeepKeys.ts (TypeScript)

type NonNullObject = {} & object;

function getDeepKeys(obj: NonNullObject) {
  let keys: string[] = [];

  for (const key in obj) {
    if (typeof obj[key] === 'object') {
      const subKeys = getDeepKeys(obj[key]);
      keys = keys.concat(subKeys.map((subKey) => `${key}.${subKey}`));
    } else {
      keys.push(key);
    }
  }

  return keys;
}