UNPKG

467 BTypeScriptView Raw
1/**
2 * Parse object key from dot notation
3 * @example
4 * parseKey('person.name', 'John Doe');
5 * // outputs { person: { name: 'John Doe' } }
6 * parseKey('person.alias[]', 'John Doe');
7 * // outputs { person: { alias: ['John Doe] } }
8 * @param {string} path - Dot notation object path
9 * @param {any} value - Dot notation path value
10 * @returns {object}
11 */
12declare const parseKey: <T>(path: string, value: unknown) => T extends [] ? T[] : T;
13export default parseKey;