@kingstinct/react-native-healthkit
Version:
React Native bindings for HealthKit
20 lines (15 loc) • 490 B
text/typescript
import queryCategorySamples from './queryCategorySamples'
import type { HKCategoryTypeIdentifier } from '../native-types'
import type { HKCategorySample } from '../types'
async function getMostRecentCategorySample<
T extends HKCategoryTypeIdentifier
>(
identifier: T,
): Promise<HKCategorySample<T> | null> {
const samples = await queryCategorySamples(identifier, {
limit: 1,
ascending: false,
})
return samples[0] ?? null
}
export default getMostRecentCategorySample