( key: Key, value: Storage[Key] )
| 83 | } |
| 84 | |
| 85 | export function setStorageItem<Key extends keyof Storage>( |
| 86 | key: Key, |
| 87 | value: Storage[Key] |
| 88 | ): Promise<void> { |
| 89 | return new Promise((resolve, reject) => { |
| 90 | chrome.storage.sync.set({ [key]: value }, () => { |
| 91 | if (chrome.runtime.lastError) { |
| 92 | return reject(chrome.runtime.lastError); |
| 93 | } |
| 94 | |
| 95 | return resolve(); |
| 96 | }); |
| 97 | }); |
| 98 | } |
| 99 | |
| 100 | export async function initializeStorageWithDefaults(defaults: Storage) { |
| 101 | const currentStorageData = await getStorageData(); |
no outgoing calls
no test coverage detected