objectValues
Object.values()
와 동일하게 동작하는 함수입니다.
Code
Interface
typescript
type ObjectKeys<T extends Record<PropertyKey, T[keyof T]>> = Exclude<
keyof T,
symbol
>;
const objectValues: <T extends Record<PropertyKey, T[keyof T]>>(
obj: T
) => T[ObjectKeys<T>][];
Usage
typescript
import { objectValues } from '@modern-kit/utils';
const symbol = Symbol('d');
const obj = {
a: 1,
b: 2,
c: 3,
[symbol]: 4,
} as const;
/**
* type: (1 | 2 | 3)[]
* value: [1, 2, 3]
*/
const values = objectValues(obj);