remeda
Version:
A utility library for JavaScript and Typescript.
29 lines (27 loc) • 801 B
text/typescript
/**
* Gets the value of the given property.
*
* @param data - The object to extract the prop from.
* @param key - The key of the property to extract.
* @signature
* R.prop(data, key);
* @example
* R.prop({ foo: 'bar' }, 'foo'); // => 'bar'
* @dataFirst
* @category Object
*/
declare function prop<T, K extends keyof T>(data: T, key: K): T[K];
/**
* Gets the value of the given property.
*
* @param key - The key of the property to extract.
* @signature
* R.prop(key)(data);
* @example
* R.pipe({foo: 'bar'}, R.prop('foo')) // => 'bar'
* @dataLast
* @category Object
*/
declare function prop<T, K extends keyof T>(key: K): (data: T) => T[K];
declare function prop<K extends PropertyKey>(key: K): <T extends Partial<Record<K, unknown>>>(data: T) => T[K];
export { prop };