UNPKG

@sapphire/utilities

Version:
25 lines (23 loc) 1.14 kB
/** * Flattens an object to a list of its keys, traversing deeply into nested objects and arrays of objects. * * @note By default Nested array values are flattened to `arrayKey.${index}.subKey`. * This can be changed to `arrayKey[${index}].subKey` by setting `options.arrayKeysIndexStyle` to `'braces-with-dot'`. * Or it can also be changed to `arrayKey[${index}]subKey` by setting `options.arrayKeysIndexStyle` to `'braces'`. * * @param obj The object of which to deeply retrieve its keys * @param options The options with which to customize the output of this function * @returns An array of strings holding the keys of the object */ declare function getDeepObjectKeys(obj: object, options?: GetDeepObjectKeysOptions): string[]; /** * The options for {@link getDeepObjectKeys} */ interface GetDeepObjectKeysOptions { /** * Whether to use `.${index}.` (`'dotted'`), `[${index}].`, (`'braces-with-dot'`) or `[${index}]` (`'braces'`) to separate array keys * @default 'dotted' */ arrayKeysIndexStyle?: 'dotted' | 'braces-with-dot' | 'braces'; } export { type GetDeepObjectKeysOptions, getDeepObjectKeys };