Research
Security News
Quasar RAT Disguised as an npm Package for Detecting Vulnerabilities in Ethereum Smart Contracts
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Increase localStorage size 10 times or more! This tiny script uses bare minimum of IndexedDB to give you a simple key - value local storage system. It's asnychchronous so it's performance is also faster than native localStorage(in theory and this must be
Increase localStorage size 10 times or more! This tiny script uses bare minimum of IndexedDB to give you a simple key - value local storage system. It's asnychchronous so it's performance is also faster than native localStorage(in theory and this must be confirmed by testing)
You can either use the snippet at the bottom or install the module
npm i localdata
import ldb from 'localdata'
// Setting values
ldb.set('nameGoesHere', 'value goes here');
// or
ldb.set('nameGoesHere', 'value goes here', function(){
console.log("Data is successfully written to the disk.")
});
// Getting values - callback is required because the data is being retrieved asynchronously:
ldb.get('nameGoesHere', function (value) {
console.log('And the value is', value);
});
This version makes setting values even easier and it looks more like original localStorage. To use this mode uncomment marked section in localdata.js
Now you can set values like this:
ldb.nameGoesHere = 'value goes here';
Getting will stay the same, because callback is still needed for asynchronous retrieval
Instead of including a file you can copy and paste this piece of code to your JS file
Minified by
uglifyjs -c -m -- localdata.js > localdata.min.js
!function(){var r,i,e="undefined"!=typeof window?window:{},t=e.indexedDB||e.mozIndexedDB||e.webkitIndexedDB||e.msIndexedDB;"undefined"==typeof window||t?((t=t.open("ldb",1)).onsuccess=function(e){r=this.result},t.onerror=function(e){console.error("indexedDB request error"),console.log(e)},t.onupgradeneeded=function(e){r=null,e.target.result.createObjectStore("s",{keyPath:"k"}).transaction.oncomplete=function(e){r=e.target.db}},e.ldb=i={get:function(e,t){r?r.transaction("s").objectStore("s").get(e).onsuccess=function(e){e=e.target.result&&e.target.result.v||null;t(e)}:setTimeout(function(){i.get(e,t)},50)},set:function(t,n,o){if(r){let e=r.transaction("s","readwrite");e.oncomplete=function(e){"Function"==={}.toString.call(o).slice(8,-1)&&o()},e.objectStore("s").put({k:t,v:n}),e.commit()}else setTimeout(function(){i.set(t,n,o)},50)}},"undefined"!=typeof module&&(module.exports=i)):console.error("indexDB not supported")}();
FAQs
Increase localStorage size 10 times or more! This tiny script uses bare minimum of IndexedDB to give you a simple key - value local storage system. It's asnychchronous so it's performance is also faster than native localStorage(in theory and this must be
The npm package localdata receives a total of 591 weekly downloads. As such, localdata popularity was classified as not popular.
We found that localdata 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.
Research
Security News
Socket researchers uncover a malicious npm package posing as a tool for detecting vulnerabilities in Etherium smart contracts.
Security News
Research
A supply chain attack on Rspack's npm packages injected cryptomining malware, potentially impacting thousands of developers.
Research
Security News
Socket researchers discovered a malware campaign on npm delivering the Skuld infostealer via typosquatted packages, exposing sensitive data.