Methods
(static) clear() → {void}
Delete all data saved in the local storage
Returns:
- Type:
- void
Example
Local.clear();(static) getAll(jsonopt) → {any}
Get all data saved in the local storage
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
json | boolean | <optional> | false | if true, return the data in json format |
Returns:
the data saved in the local storage
- Type:
- any
Example
Local.getAll();(static) getData(key) → {any}
Get a specific data saved in the local storage
Parameters:
| Name | Type | Description |
|---|---|---|
key | string | key of the data to get |
Returns:
the data saved in the local storage
- Type:
- any
Example
Local.getData("myKey");(static) has(key) → {boolean}
Check if the given key is stored
Parameters:
| Name | Type | Description |
|---|---|---|
key | string | key to check |
Returns:
true if the key is stored
- Type:
- boolean
Example
Local.has("myKey");(static) isEmpty() → {boolean}
Check if the local storage is empty
Returns:
- true if the local storage is empty
- Type:
- boolean
Example
Local.isEmpty();(static) keys() → {Array.<string>}
Get keys of the stored items
Returns:
return all keys
- Type:
- Array.<string>
Example
Local.keys();(static) removeData(key) → {void}
Delete a specific data by name
Parameters:
| Name | Type | Description |
|---|---|---|
key | sting | the name of the data to delete |
Returns:
- Type:
- void
Example
Local.removeData("myKey");(static) setData(key, value) → {void}
Save/change a specific data by key
Parameters:
| Name | Type | Description |
|---|---|---|
key | string | name of the key |
value | any | value of the item |
Returns:
- Type:
- void
Examples
Local.setData("myKeyString", "myString");Local.setData("myKeyBool", true);Local.setData("myKeyNumber", 1234567890);Local.setData("myKeyObject", {name: "Dog", age: 3,});Local.setData("myKeyArr", [1, 2, 3, 4, 5]);(static) setName(name) → {void}
Change the name of data saved in the local storage
Parameters:
| Name | Type | Description |
|---|---|---|
name | string | the name to save the data in the local storage |
Returns:
- Type:
- void
Example
Local.setName("myLocalStorage");(static) size() → {number}
Get number of stored items
Returns:
number of stored items
- Type:
- number
Example
Local.size();(static) updateAll(data) → {void}
Save/change all data
Parameters:
| Name | Type | Description |
|---|---|---|
data | any | data to save |
Returns:
- Type:
- void
Example
Local.updateAll({ otherNewData: "Hello World" });