* fix(route/yystv): fix cache collisions induced by these two implementations * chore(route/yystv): prefer existing types over new types * fix(route/yystv): prefer caching processed items over raw web pages * docs: fix maintainer github id ---------
11 lines
377 B
TypeScript
11 lines
377 B
TypeScript
import { DataItem } from '@/types';
|
|
import cache from '@/utils/cache';
|
|
import ofetch from '@/utils/ofetch';
|
|
|
|
export function fetchDataItemCached(link: string, processor: (articleContent: string) => DataItem): Promise<DataItem> {
|
|
return cache.tryGet(link, async () => {
|
|
const page = await ofetch(link);
|
|
return processor(page);
|
|
}) as Promise<DataItem>;
|
|
}
|