You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+6-8Lines changed: 6 additions & 8 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -37,10 +37,8 @@ Creates a new instance of the WebStorage with the specified options. The followi
37
37
38
38
| Option | Type | Default | Description |
39
39
| ------ | ---- | ------- | ----------- |
40
-
|**driver**|`String`| "localStorage" | The preferred driver to use. Use one between "localStorage" or "sessionStorage". |
41
-
|**keyPrefix<sup>1</sup>**|`String`| "web-storage/" | The prefix for all keys stored in the offline storage. The value provided is trimmed (both left and right) internally to avoid potential user mistakes. |
42
-
43
-
**<sup>1</sup>***`keyPrefix` needs to be declared only when creating an instance of `WebStorage`. Afterwards, when using any of the API methods that accept `key` as argument, we just use the key to refer to the item we want to manipulate.*
40
+
|**driver**|`String`| "localStorage" | Specifies the storage driver to use. Accepts either "localStorage" or "sessionStorage". This determines where data will be persisted. |
41
+
|**keyPrefix**|`String`| "web-storage/" | A prefix applied to all keys stored in offline storage. It is automatically trimmed on both sides to prevent user errors. You only need to set `keyPrefix` when creating a `WebStorage` instance. After that, API methods should be used with plain keys—`keyPrefix` is applied internally. |
Copy file name to clipboardExpand all lines: src/web-storage.js
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -100,7 +100,7 @@ class WebStorage {
100
100
/**
101
101
* Gets the saved item for the specified key from the storage for a specific datastore.
102
102
*
103
-
* @param {string} key - The property name of the saved item.
103
+
* @param {string} key - The key of the item to retrieve.
104
104
* @throws {TypeError} - Throws if `key` is not a string.
105
105
* @returns {Result<unknown>} - Returns an array with two elements: the first is the value of the saved item, and the second is `null` if no error occurred, or an `Error` object if an error occurred.
106
106
*/
@@ -120,7 +120,7 @@ class WebStorage {
120
120
/**
121
121
* Saves an item to storage with the specified key.
122
122
*
123
-
* @param {string} key - The property name of the item to save.
123
+
* @param {string} key - The key under which to store the item.
124
124
* @param {any} value - The item to save to the selected storage.
125
125
* @throws {TypeError} - Throws if `key` is not a string.
126
126
* @returns {Result<boolean>} - Returns an array with two elements: the first is `true` if the item was saved successfully, or `false` if it was not, and the second is `null` if no error occurred, or an `Error` object if an error occurred.
@@ -143,7 +143,7 @@ class WebStorage {
143
143
/**
144
144
* Removes the saved item for the specified key from storage.
145
145
*
146
-
* @param {string} key - The property name of the item to remove.
146
+
* @param {string} key - The key of the item to remove.
147
147
* @throws {TypeError} - Throws if `key` is not a string.
148
148
* @returns {Result<boolean>} - Returns an array with two elements: the first is `true` if the item was removed successfully, or `false` if it was not, and the second is `null` if no error occurred, or an `Error` object if an error occurred.
0 commit comments