storeage
v0.3.0
Published
High-performance Offline Storage with localStorage-like API and Enhanced Capabilities
Maintainers
Readme
Storeage 🚀
High-performance Offline Storage with localStorage-like API and Enhanced Capabilities
✨ Core Features
- Standardized API Design
📦 Familiar developer experience with localStorage-inspired API - Intelligent Storage Engine
⚡ Dual-driver fallback strategy (Priority: IndexedDB → LocalStorage) - Hybrid API Support
✅ Seamless Promise & Callback asynchronous patterns - Storage Isolation
✅ Multi-instance isolation vianame+storeNamecombination - Advanced Data Management
✅ TTL (Time-to-Live) expiration support 🔥
✅ Custom serialization (supportsBlob/BigInt/TypedArrayand complex types) - Developer Experience
✅ First-class TypeScript support
✅ Simplified configuration (removed redundantversionparameter)
🚀 Quick Start
Installation
npm install storeageBasic Usage
import storeage, { INTERNAL_DRIVERS } from 'storeage';
// Initialize storage
storeage.config({
name: 'databaseName',
storeName: 'storeName',
driver: [INTERNAL_DRIVERS.IDB, INTERNAL_DRIVERS.LOCALSTORAGE], // Driver priority
});
// Store complex data (expires after 2s)
await storage.setItem(
'userProfile',
{
id: BigInt(991234567890123456),
avatar: new Blob([
/* binary data */
]),
loginTime: new Date(),
},
2000
);
// Retrieve data (auto-deserialized)
const profile = await storage.getItem('userProfile');
console.log(profile);Advanced Configuration
// Create multi-instance storage
const cacheStorage = storage.createStorage({
name: 'myApp_cache',
storeName: 'imageCache',
});
await cacheStorage.setItem(
'bannerImage',
imageBlob,
1000 * 60 * 60 * 24 // Expires after 24 hours
);⚙️ Configuration Options
| Parameter | Type | Default | Description |
| ----------- | -------- | ------------------------- | ------------------- |
| name | string | 'storeage' | Database identifier |
| storeName | string | 'storeage' | Object store name |
| driver | string[] | ['idb', 'localstorage'] | Driver priority |
🤝 Contributing
We welcome contributions! Please feel free to:
- Submit Pull Requests
- Open Issues for bug reports or feature requests
📄 License
MIT © GameJoye
