Skip to content

Instantly share code, notes, and snippets.

@demipixel
Created July 1, 2022 23:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save demipixel/6d92789db75b40eff9bbc514d12fa6b4 to your computer and use it in GitHub Desktop.
Save demipixel/6d92789db75b40eff9bbc514d12fa6b4 to your computer and use it in GitHub Desktop.
export type RelationDepth = {
[key: string]: RelationDepth;
};
export function getRelations(depth: RelationDepth = {}) {
const relations: string[] = [];
const recurse = (obj: RelationDepth, path = '') => {
Object.keys(obj).forEach((key) => {
relations.push(path + key);
recurse(obj[key], path + key + '.');
});
};
recurse(depth);
return relations;
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment