Skip to content

Commit 6652ed0

Browse files
committed
chore: rename for clarify
1 parent 1752ed7 commit 6652ed0

File tree

3 files changed

+5
-5
lines changed

3 files changed

+5
-5
lines changed

src/cache.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export function memoryStorage() {
2222

2323
const ONE_WEEK = 1000 * 60 * 60 * 24 * 7
2424

25-
export function createAsyncStorage(storage: Storage) {
25+
export function createCachedAsyncStorage(storage: Storage) {
2626
return {
2727
async getItem<T = unknown>(key: string, init?: () => T | Promise<T>) {
2828
const now = Date.now()

src/index.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import type { Storage } from './cache'
22
import type { InitializedProvider, Provider, ResolveFontOptions, ResolveFontResult } from './types'
3-
import { createAsyncStorage, memoryStorage } from './cache'
3+
import { createCachedAsyncStorage, memoryStorage } from './cache'
44

55
export * as providers from './providers'
66
export type { FontFaceData, FontFaceMeta, FontStyles, LocalFontSource, Provider, ProviderContext, ProviderDefinition, ProviderFactory, RemoteFontSource, ResolveFontOptions } from './types'
@@ -35,7 +35,7 @@ export const defaultResolveOptions: ResolveFontOptions = {
3535
export async function createUnifont<T extends Provider[]>(providers: T, unifontOptions?: UnifontOptions): Promise<Unifont<T[number]['_name']>> {
3636
const stack: Record<string, InitializedProvider> = {}
3737
const unifontContext = {
38-
storage: createAsyncStorage(unifontOptions?.storage ?? memoryStorage()),
38+
storage: createCachedAsyncStorage(unifontOptions?.storage ?? memoryStorage()),
3939
}
4040

4141
// preserve provider order

test/cache.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import { createStorage } from 'unstorage'
22
import { describe, expect, it, vi } from 'vitest'
33

4-
import { createAsyncStorage, memoryStorage } from '../src/cache'
4+
import { createCachedAsyncStorage, memoryStorage } from '../src/cache'
55
import { createUnifont, defineFontProvider } from '../src/index'
66

77
describe('cache storage', () => {
@@ -15,7 +15,7 @@ describe('cache storage', () => {
1515
const storageTypes = { unstorage: createStorage(), memoryStorage: memoryStorage() }
1616

1717
it.each(Object.entries(storageTypes))('createAsyncStorage works with %s', async (name, storage) => {
18-
const asyncStorage = createAsyncStorage(storage)
18+
const asyncStorage = createCachedAsyncStorage(storage)
1919

2020
await asyncStorage.setItem('key', 'value')
2121
expect(await asyncStorage.getItem('key')).toBe('value')

0 commit comments

Comments
 (0)