local-storage-plus-plus
v1.1.4
Published
This is the documentation of how to use the `local-storage-plus-plus` package.
Downloads
28
Readme
local-storage-plus-plus package
This is the documentation of how to use the local-storage-plus-plus
package.
please follow all of the instructions bellow if you havent already done them.
Installing Node.js
First you will have to install node.js at https://nodejs.org/en/
and click and select one of
the two options. I would recommend installing the recommended for most users
option but its really
up to you.
NOTE: Any package version bellow 1.1.0 will not work properly!
Setting up the project
First, you have to go into your project folder and run npm init --y
which will create the
package.json
file and after that you have to run npm i local-storage-plus-plus
which will install the
local-storage-plus-plus package.
NOTE: If you want to use the package with vanilla javascript/html, then you have to use a bundler such as webpack, babel, or you can use vite.
- Webpack- https://webpack.js.org/
- Babel- https://babeljs.io/
- Vite- https://vitejs.dev/
Getting started
First you need the import the package such as shown in the example
import {StoragePlusPlus} from 'local-storage-plus-plus'
For you to be able to use the package, you will need to make a instance of the StoragePlusPlus class as shown in the example
const storage = new StoragePlusPlus();
Methods
This is the list of methods that are currently available
add(key, value)- adds data to local storage
remove(key)- removes a item from local storage
clear()- deletes all of the items from local storage
getAllKeys()- returns a list of all of the items keys
getAllValues()- returns a list of all of the items values
getKey(value)- returns the key of the item which value is specified in the parameter
getValue(key)- returns the value of the item which key is specified in the parameter
parse(value)- parses the given value from type string
stringify(value)- stringifies the given value
Examples
note: all of the returned values from all of the methods, except stringify
are automaticly parsed
this is the instance of the StoragePlusPlus class
const storage = new StoragePlusPlus();
add()
storage.add("key1", "this is the value")
remove()
storage.remove("key1")
clear()
storage.clear()
getAllKeys()
storage.getAllKeys()
//outupt: ['key1', 'key2', 'key3']
getAllValues()
storage.getAllValues()
//output: ['value1', 'value2', 'value3']
getKey()
storage.getKey('value1')
//output: 'key1'
getValue()
storage.getValue("key1")
//output: 'value1'
parse()
storage.parse("1")
//output: 1
stringify()
storage.stringify(1)
//output: "1"