import type { Spectrum } from '@zakodium/nmrium-core'; export function getSpectraObjectPaths( spectra: Spectrum[], keys: Array = ['display', 'meta', 'info', 'customInfo'], ) { const paths: Record = {}; for (const spectrum of spectra) { for (const key of keys) { lookForObjectsPaths(spectrum[key], [key], paths); } } return { datalist: Object.keys(paths), paths }; } function lookForObjectsPaths( obj: any, path: string[], output: Record, ) { if (['string', 'number', 'boolean'].includes(typeof obj)) { const key = path.join('.'); output[key] = path; path = []; } else { for (const key in obj) { lookForObjectsPaths(obj[key], [...path.slice(), key], output); } } }