⚡ DeepBase is the fastest and simplest way to add persistence to your projects while allowing you to view information in a user-friendly format.
Installations
npm install deepbase
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
20.10.0
NPM Version
10.2.3
Score
71.4
Supply Chain
98.8
Quality
85.8
Maintenance
100
Vulnerability
99.6
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Love this project? Help keep it running — sponsor us today! 🚀
Developer
clasen
Download Statistics
Total Downloads
2,275
Last Day
2
Last Week
9
Last Month
135
Last Year
1,251
GitHub Statistics
MIT License
3 Stars
24 Commits
2 Watchers
1 Branches
1 Contributors
Updated on Jan 18, 2025
Bundle Size
14.61 kB
Minified
4.70 kB
Minified + Gzipped
Package Meta Information
Latest Version
1.2.8
Package Id
deepbase@1.2.8
Unpacked Size
21.02 kB
Size
6.12 kB
File Count
17
NPM Version
10.2.3
Node Version
20.10.0
Published on
Jan 18, 2025
Total Downloads
Cumulative downloads
Total Downloads
2,275
Last Day
0%
2
Compared to previous day
Last Week
-65.4%
9
Compared to previous week
Last Month
132.8%
135
Compared to previous month
Last Year
22.2%
1,251
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
🌳 DeepBase
DeepBase is the fastest and simplest way to add persistence to your projects while allowing you to view information in a user-friendly format.
A powerful JSON-based storage library that allows you to store, retrieve, and modify nested objects with ease.
📦 Installation
1npm install deepbase
🔧 Usage
1const DeepBase = require("deepbase"); 2const mem = new DeepBase({ name: "db" }); // db.json
✍️ Setting Values
1mem.set("config", "lang", "en"); 2 3const configLang = mem.get("config", "lang"); 4console.log(configLang); // "en"
✅ Adding Rows
1const path = mem.add("user", { name: "martin" }); 2 3// add() will create a secure key (ie. "iKidAOCKds") 4console.log(path) // [ 'user', 'iKidAOCKds' ] 5 6const userName = mem.get(...path, "name"); 7console.log(userName); // "martin"
🔢 Increment fields
1mem.inc(...path, "balance", 160); 2mem.inc(...path, "balance", 420); 3 4const userBalance = mem.get(...path, "balance"); 5console.log(userBalance); // 580
⚗️ Update
1mem.upd("config", "lang", v => v.toUpperCase()); 2const lang = mem.get("config", "lang"); // EN
🔥 Finally
1mem.add("user", { name: "anya" }); 2 3const userIds = mem.keys("user") 4console.log(userIds) // [ 'iKidAOCKds', 'FEwORvJjs' ] 5 6console.log(mem.get()) // db.json 7// { 8// config: { lang: 'EN' }, 9// user: { 10// iKidAOCKds: { name: 'martin', balance: 580 }, 11// FEwORvJjs: { name: 'anya' } 12// } 13// }
🧪 Custom JSON Serialization
DeepBase supports custom JSON serialization, allowing for circular references in complex data structures.
Example with CircularJSON
:
1const CircularJSON = require('circular-json'); 2const db = new DeepBase({ 3 stringify: (obj) => CircularJSON.stringify(obj, null, 4), 4 parse: CircularJSON.parse 5}); 6 7db.set("a", "b", { circular: {} }); 8db.set("a", "b", "circular", "self", customDB.get("a", "b"));
Example with flatted
:
1const { parse, stringify } = require('flatted'); 2const db = new DeepBase({ stringify, parse });
🔒 Secure Storage with Encryption
1const CryptoJS = require('crypto-js'); 2 3class DeepbaseSecure extends DeepBase { 4 constructor(opts) { 5 opts.stringify = (obj) => { 6 const iv = CryptoJS.lib.WordArray.random(128 / 8); 7 const encrypted = CryptoJS.AES.encrypt(JSON.stringify(obj), opts.encryptionKey, { iv }); 8 return iv.toString(CryptoJS.enc.Hex) + ':' + encrypted.toString(); 9 }; 10 11 opts.parse = (encryptedData) => { 12 const [ivHex, encrypted] = encryptedData.split(':'); 13 const iv = CryptoJS.enc.Hex.parse(ivHex); 14 const bytes = CryptoJS.AES.decrypt(encrypted, opts.encryptionKey, { iv }); 15 return JSON.parse(bytes.toString(CryptoJS.enc.Utf8)); 16 }; 17 18 super(opts); 19 } 20} 21 22// Create an encrypted database 23const secureDB = new DeepbaseSecure({ 24 name: "secure_db", 25 encryptionKey: 'your-secret-key' 26}); 27 28// Use it like a regular DeepBase instance 29secureDB.set("users", "admin", { password: "secret123" });
🤯 Features
- 🔍 Easily access and modify nested objects in JSON storage.
- 📁 Automatically save changes to a file.
- 🌱 Simple and intuitive API for managing complex JSON structures.
🤔 Why DeepBase
- ⚡ Fastest and simplest way to add persistence to your projects.
- 📖 View information in a user-friendly format.
- 🧠 Easy to use and understand.
🤝 Contributing
Contributions to DeepBase are welcome! If you have an idea or a bug to report, please open an issue. If you would like to contribute to the code, please open a pull request.
🎬 Conclusion
DeepBase is a powerful and flexible solution for managing complex JSON structures.
🚀 Try it out and simplify your code today!
📄 License
The MIT License (MIT)
Copyright (c) Martin Clasen
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.

No vulnerabilities found.

No security vulnerabilities found.