/
githubmirror
/
gutenberg
Обзор
Документация
Войти
/
githubmirror
/
gutenberg
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
trunk
packages/data/src/plugins/persistence/storage/object.ts
25 строк
551 B
Manzoor Wani
Convert data package fully to TS (#76149)
07 мар 2026, 20:22
Не верифицирован
07 мар 2026, 20:22
31ee8cb
Код
Авторство
О чём код?
import type { StorageInterface } from '../../../types'; let objectStorage: Record< string, string > | undefined; const storage: StorageInterface & { clear: VoidFunction } = { getItem( key: string ): string | null { if ( ! objectStorage || ! objectStorage[ key ] ) { return null; } return objectStorage[ key ]; }, setItem( key: string, value: string ) { if ( ! objectStorage ) { storage.clear(); } objectStorage![ key ] = String( value ); }, clear() { objectStorage = Object.create( null ); }, }; export default storage;