MCPcopy Create free account
hub / github.com/pacexy/flow / removeUndefinedProperty

Function removeUndefinedProperty

apps/reader/src/hooks/useTypography.ts:7–17  ·  view source on GitHub ↗
(obj: T)

Source from the content-addressed store, hash-verified

5import { useSettings } from '../state'
6
7function removeUndefinedProperty<T extends Record<string, any>>(obj: T) {
8 const newObj: Partial<T> = {}
9
10 Object.entries(obj).forEach(([k, v]) => {
11 if (v !== undefined) {
12 newObj[k as keyof T] = v
13 }
14 })
15
16 return newObj
17}
18
19export function useTypography(tab: BookTab) {
20 const { book } = useSnapshot(tab)

Callers 1

useTypographyFunction · 0.85

Calls 1

forEachMethod · 0.45

Tested by

no test coverage detected