StorageArea.getBytesInUse()
Gets the amount of storage space, in bytes, used by one or more items stored in the storage area.
Note: In Firefox, this method is supported in:
storage.sync.storage.sessionfrom Firefox 131.storage.localandstorage.managedfrom Firefox 144.
Note:
storage.managed.getBytesInUse() always returns 0, at least in Chrome and Firefox.
Syntax
let gettingSpace = browser.storage.<storageType>.getBytesInUse(
keys // null, string, or array of strings
)
Where <storageType> is one of the storage types — sync, local, session, or managed.
Parameters
keys-
A key (string) or keys (an array of strings) to identify the items whose storage space you want to retrieve. If an empty array is passed in, 0 is returned. If you pass
nullorundefined, the function returns the space used by the entire storage area.
Return value
A Promise that is fulfilled with an integer, bytesUsed, representing the storage space used by the objects specified in keys. If the operation fails, the promise is rejected with an error message.
Browser compatibility
Loading…
Note:
This API is based on Chromium's chrome.storage API. This documentation is derived from storage.json in the Chromium code.