Skip to content

Commit 6f4cc3e

Browse files
committed
Update documentation
1 parent d3ec617 commit 6f4cc3e

File tree

2 files changed

+9
-11
lines changed

2 files changed

+9
-11
lines changed

README.md

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,10 +37,8 @@ Creates a new instance of the WebStorage with the specified options. The followi
3737

3838
| Option | Type | Default | Description |
3939
| ------ | ---- | ------- | ----------- |
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. |
4442

4543
**Example**
4644

@@ -68,7 +66,7 @@ const myStore = WebStorage.createInstance({
6866

6967
### WebStorage.isAvailable(storageType)
7068

71-
Check if `storageType` is supported and is available.
69+
Checks if `storageType` is supported and is available.
7270
Storage might be unavailable due to no browser support or due to being full or due to browser privacy settings.
7371

7472
**Returns**: `boolean` - Returns `true` if Storage available; otherwise `false`.
@@ -94,7 +92,7 @@ Gets the saved item for the specified key from the storage for a specific datast
9492

9593
| Param | Type | Default | Description |
9694
| ----- | ---- | ------- | ----------- |
97-
| key | `string` | - |The property name of the saved item |
95+
| key | `string` | - | The key of the item to retrieve. |
9896

9997
**Usage**
10098

@@ -116,7 +114,7 @@ Saves an item to storage with the specified key. You can store items of any of t
116114

117115
| Param | Type | Default | Description |
118116
| ----- | ---- | ------- | ----------- |
119-
| key | `string` | - | The property name of the item to save |
117+
| key | `string` | - | The key under which to store the item. |
120118
| value | `any` | - | The item to save to the selected storage. |
121119

122120
**Usage**
@@ -134,7 +132,7 @@ Removes the saved item for the specified key from storage.
134132

135133
| Param | Type | Default | Description |
136134
| ----- | ---- | ------- | ----------- |
137-
| key | `string` | | The property name of the item to remove |
135+
| key | `string` | - | The key of the item to remove. |
138136

139137
**Usage**
140138

src/web-storage.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ class WebStorage {
100100
/**
101101
* Gets the saved item for the specified key from the storage for a specific datastore.
102102
*
103-
* @param {string} key - The property name of the saved item.
103+
* @param {string} key - The key of the item to retrieve.
104104
* @throws {TypeError} - Throws if `key` is not a string.
105105
* @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.
106106
*/
@@ -120,7 +120,7 @@ class WebStorage {
120120
/**
121121
* Saves an item to storage with the specified key.
122122
*
123-
* @param {string} key - The property name of the item to save.
123+
* @param {string} key - The key under which to store the item.
124124
* @param {any} value - The item to save to the selected storage.
125125
* @throws {TypeError} - Throws if `key` is not a string.
126126
* @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 {
143143
/**
144144
* Removes the saved item for the specified key from storage.
145145
*
146-
* @param {string} key - The property name of the item to remove.
146+
* @param {string} key - The key of the item to remove.
147147
* @throws {TypeError} - Throws if `key` is not a string.
148148
* @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.
149149
*/

0 commit comments

Comments
 (0)