
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
storage-wrapper
Advanced tools
A small utility for working with localStorage and sessionStorage in the browser
A small utility for working with localStorage and sessionStorage in the browser, with support for type safety, expiration, and namespacing.
npm install storage-wrapper
import { StorageWrapper } from 'storage-wrapper';
const localStorageWrapper = new StorageWrapper('local', 'myApp');
const sessionStorageWrapper = new StorageWrapper('session', 'myApp');
// Setting items
localStorageWrapper.set('user', { name: 'John Doe' }, 30); // Expires in 30 minutes
sessionStorageWrapper.set('sessionID', 'abc123');
// Getting items
console.log(localStorageWrapper.get('user')); // { name: 'John Doe' }
console.log(sessionStorageWrapper.get('sessionID')); // 'abc123'
// Removing items
localStorageWrapper.remove('user');
sessionStorageWrapper.remove('sessionID');
// Clearing all items in the namespace
localStorageWrapper.clear();
sessionStorageWrapper.clear();
const storageWithEvents = new StorageWrapper('local', 'myApp');
// Adding event listeners
storageWithEvents.on('set', 'print', (key, value) => {
console.log(`Item set: ${key} = ${value}`);
});
storageWithEvents.on('remove', 'print', (key) => {
console.log(`Item removed: ${key}`);
});
storageWithEvents.on('clear', 'print', () => {
console.log('Storage cleared');
});
// Setting an item
storageWithEvents.set('key', 'value'); // Console: Item set: key = value
// Removing an item
storageWithEvents.remove('key'); // Console: Item removed: key
// Clearing storage
storageWithEvents.clear(); // Console: Storage cleared
StorageWrapperconstructor(storageType: 'local' | 'session', namespace?: string)storageType: Determines whether to use localStorage or sessionStorage.namespace: Optional namespace to avoid key collisions.set(key: string, value: any, expirationInMinutes?: number): voidkey: The key under which the value is stored.value: The value to store.expirationInMinutes: Optional expiration time in minutes.get<T>(key: string): T | nullkey: The key of the value to retrieve.null if the key doesn't exist or has expired.remove(key: string): voidkey: The key of the value to remove.clear(): voidon(event: 'set' | 'remove' | 'clear' | 'expired', event_name: string, callback: (key?: string, value?: any) => void): voidCheck out the demo.
This project is open to contributions. Feel free to open an issue or submit a pull request.
MIT
FAQs
A small utility for working with localStorage and sessionStorage in the browser
We found that storage-wrapper 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.