forked from sheepzh/time-tracker-4-browser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmemory-detector.ts
More file actions
37 lines (33 loc) · 720 Bytes
/
memory-detector.ts
File metadata and controls
37 lines (33 loc) · 720 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
/**
* Copyright (c) 2021 Hengyang Zhang
*
* This software is released under the MIT License.
* https://opensource.org/licenses/MIT
*/
import StoragePromise from "./common/storage-promise"
/**
* User memory of this extension
*/
export declare type MemoryInfo = {
/**
* Used bytes
*/
used: number
/**
* Total bytes
*/
total: number
}
/**
* 'QUOTA_BYTES' Not supported in Firefox
*/
const total: number = chrome.storage.local.QUOTA_BYTES || 0
/**
* Get the used memory by bytes
*
* @since 0.0.9
*/
export async function getUsedStorage(): Promise<MemoryInfo> {
const used = await new StoragePromise(chrome.storage.local).getUsedMemory()
return { used, total }
}