permanent-local-storage v1.0.5
Permanent Local Storage
Permanent Local Storage is an tiny npm package designed to emulate the localStorage API by leveraging the window.name
attribute. This approach ensures data persistence even when users clear their browser cache. Ideal for applications requiring permanent data storage solutions, this package offers compatibility with both CommonJS (CJS) and ECMAScript Modules (ESM).
Permanent Local Storage has full Typescript support and does not rely on any other packages.
💻 Installation
npm install permanent-local-storage
Or, if you're using Yarn
yarn add permanent-local-storage
🚢 Usage
Permanent Local Storage is designed to be a drop-in replacement for the standard localStorage API, making integration into your existing projects seamless and straightforward.
Importing
import permanentLocalStorage from 'permanent-local-storage';
🦾 Basic operations
Setting an item
permanentLocalStorage.setItem('key', 'value');
Getting an item
let value = permanentLocalStorage.getItem('key');
Removing an item
permanentLocalStorage.removeItem('key');
Clearing all data
permanentLocalStorage.clear();
Getting a specific key
let value = permanentLocalStorage.key(3);
Getting number of key value pairs in permanentLocalStorage
permanentLocalStorage.length;
🚀 Use Cases
Limiting Free Trial Abuse Prevent repeat free trial access by tracking devices with Permanent Local Storage, thus stopping users from creating new accounts or sessions to exploit trial offers.
Restricting Content Access Use Permanent Local Storage to monitor user access to content over time, preventing them from bypassing limits through cache clearing or new sessions.
Preventing Voting Manipulation Ensure each user only votes once in online polls by recording their activity with Permanent Local Storage, maintaining the integrity of the voting process.
E-commerce and Advertising Keep e-commerce offers and ad targeting consistent across sessions using Permanent Local Storage, even when users reset their session data.
Use Permanent Local Storage responsibly. It's a powerful tool, intended for enhancing user experience. Let's keep things fair and respect privacy