A tiny module for manipulating local storage.
You can install local-call via npm or yarn:
npm install local-callor
yarn add local-callimport * as localStorageModule from "local-call";
setItem(key: string, value: any): boolean
Sets an item in local storage with the specified key and value.
key: The key of the item.value: The value to be stored. It can be of any data type. Returnstrueif the item was successfully set,falseotherwise.
getItem(key: string): any
Gets an item from local storage with the specified key.
key: The key of the item. Returns thevalueof the item if found,nullotherwise.
removeItem(key: string): boolean
Removes an item from local storage with the specified key.
key: The key of the item to be removed. Returnstrueif the item was successfully removed,falseotherwise.
clearStorage(): boolean
Clears all items from local storage.
Returns true if the storage was successfully cleared, false otherwise.
keyExists(key: string): boolean
Checks if an item with the specified key exists in local storage.
key: The key to check. Returnstrueif the item exists,falseotherwise.
storageLength(): number
Gets the number of items in local storage.
Returns the number of items in local storage, or -1 if an error occurs.
This project is licensed under the MIT License - see the LICENSE file for details.