7 lines
252 B
TypeScript
Raw Normal View History

2024-08-22 17:41:44 +02:00
type Attributes = Record<string, string | boolean>;
export const attributes = (attributes: Attributes) =>
Object.keys(attributes)
.filter((key) => attributes[key] !== false)
.reduce((prev, key) => ({ ...prev, [key]: attributes[key] }), {});