UNPKG

@stryke/helpers

Version:

A package containing miscellaneous helper functions that are used across many different Storm Software projects.

21 lines (20 loc) 789 B
/** * Converts a deep key string into an array of path segments. * * @remarks * This function takes a string representing a deep key (e.g., 'a.b.c' or 'a[b][c]') and breaks it down into an array of strings, each representing a segment of the path. * * @example * ```ts * toPath('a.b.c') // Returns ['a', 'b', 'c'] * toPath('a[b][c]') // Returns ['a', 'b', 'c'] * toPath('.a.b.c') // Returns ['', 'a', 'b', 'c'] * toPath('a["b.c"].d') // Returns ['a', 'b.c', 'd'] * toPath('') // Returns [] * toPath('.a[b].c.d[e]["f.g"].h') // Returns ['', 'a', 'b', 'c', 'd', 'e', 'f.g', 'h'] * ``` * * @param deepKey - The deep key string to convert. * @returns An array of strings, each representing a segment of the path. */ export declare function toPath(deepKey: string): string[];