
Security News
New CVE Forecasting Tool Predicts 47,000 Disclosures in 2025
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.
A simple, lightweight JavaScript API for handling browser localStorage, it is easy to pick up and use, has a reasonable footprint 2.08kb(gzipped: 0.97kb), and has no dependencies. It should not interfere with any JavaScript libraries or frameworks.
Old v1 version document preview.
Features:
š Has no dependencies
š± Works in all browsers
š„ Heavily tested
š¦ Supports AMD/CommonJS
š„ store.min.js 2.08kb(gzipped: 0.97kb)
Installed via npm. You will need Node.js
installed on your system.
$ npm install storejs --save
import store from 'storejs';
store('test', 'tank', 1)
Or manually download and link storejs
in your HTML, It can also be downloaded via UNPKG or jsDelivr CDN:
CDN: UNPKG | jsDelivr | Githack | Statically | bundle.run
<script src="https://unpkg.com/storejs/dist/store.js"></script>
<script type="text/javascript">
store('test', 'tank');
</script>
store(key, data); // Single storage string data
store({key: data, key2: data2}); // Bulk storage of multiple string data
store(key); // Get `key` string data
store('?key'); // Determine if the `key` exists
store(); // Get all key/data
//store(false);š« // (Deprecated) because it is easy to empty the storage because of a null value or an error
//store(key, false); š« // (Deprecated)
store.set(key, data[, overwrite]); // === store(key, data);
store.set({key: data, key2: data2}) // === store({key: data, key2: data});
store.get(key[, alt]); // === store(key);
store.get('?key'); // Determine if the `key` exists
store.get('key1', 'key2', 'key3'); // Get `key1`,`key2`,`key3` data
store.remove(key); // ===store(key,false)
store.clear(); // Clean all key/data
store.keys(); // Returns an array of all the keys
store.forEach(callback); // Loop traversal, return false to end traversal
store.search(string); // Search method
store.len(); // Returns store length
store.has(key); //ā Determine if there is a return true/false
//ā Provide callback method to process data
store('test', (key,val) => {
console.log(val) // Processing the data obtained through the test here
return [3,4,5] // Return data and set store
})
store(['key', 'key2'], (key) => {
// Get data processing of multiple keys, return and save;
console.log('key:', key)
return 'éäøŖę“ę¹ę°ę®'
})
Store or delete string data individually store.set(key, data[, overwrite]);
. Same effect store(key, data);
.
store.set('wcj', '1') //ā 1
store.set('wcj') //ā Delete `wcj` and string data
Get the string data of the key
store.get(key[, alt])
. Same effect store(key)
.
store.get('wcj1') // Get the string data of `wcj1`
store('wcj1') // Same function as above
Bulk storage of multiple string data store.setAll(data[, overwrite])
. Same effect store({key: data, key2: data});
.
store.setAll({
"wcj1": 123,
"wcj2": 345
}) // Store two string data
store.setAll(["w1", "w2", "w3"])
// Store three strings of data
// 0ā "w1"
// 1ā "w2"
// 2ā "w3"
Get all key/data . Same effect store.getAll()
store()
.
store.getAll() // ā JSON
store() // Same function as above
Clear all key/data. store.clear()
ā ļø Deprecate because it is easy to empty the library because of passing in a null value or reporting an errorstore(false)
store.clear()
Return an array of all keys
. store.keys()
.
store.keys() //ā ["w1", "w2", "w3"]
Judge whether it exists, return true/false store.has(key)
.
store.has('w1'); //ā true
Delete key string data including key store.remove(key)
store.remove('w1'); // Delete w1 and return the value of w1
store('w1', false) // So also delete w1
Returns the length of the store store.len()
store.len(); //ā 10
Loop traversal, return false
to end the traversal
store.forEach((k, d) => {
console.log(k, d);
if (k== 3) return false
});
Responding to storage changes with the StorageEvent
if (window.addEventListener) {
window.addEventListener('storage', handleStorage,false);
} else if (window.attachEvent){
window.attachEvent('onstorage', handleStorage);
}
function handleStorage(e) {
if(!e) { e=window.event; }
//showStorage();
}
Property | Type | Description |
---|---|---|
key | String | The named key that was added, removed, or moddified |
oldValue | Any | The previous value(now overwritten), or null if a new item was added |
newValue | Any | The new value, or null if an item was added |
url/uri | String | The page that called the method that triggered this change |
store.set('ad', 234).get('ad')
store.get([key,key2])
Get method, return jsonstore([key,key2])
Get method, return jsononStorage
Method test cases, and implementationAs always, thanks to our amazing contributors!
Made with action-contributors.
Licensed under the MIT License.
FAQs
Local storage localstorage package provides a simple API
The npm package storejs receives a total of 2,110 weekly downloads. As such, storejs popularity was classified as popular.
We found that storejs demonstrated a not healthy version release cadence and project activity because the last version was released a year ago.Ā It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
CVEForecast.org uses machine learning to project a record-breaking surge in vulnerability disclosures in 2025.
Security News
Browserslist-rs now uses static data to reduce binary size by over 1MB, improving memory use and performance for Rust-based frontend tools.
Research
Security News
Eight new malicious Firefox extensions impersonate games, steal OAuth tokens, hijack sessions, and exploit browser permissions to spy on users.