@onurege3467/zerohelper 9.0.0 โ 9.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +152 -254
- package/dist/bin/zero.d.ts +2 -0
- package/dist/bin/zero.js +141 -0
- package/dist/database/IDatabase.d.ts +25 -31
- package/dist/database/IDatabase.js +38 -0
- package/dist/database/cacheWrapper.d.ts +5 -2
- package/dist/database/cacheWrapper.js +36 -50
- package/dist/database/index.d.ts +3 -2
- package/dist/database/index.js +13 -9
- package/dist/database/json.d.ts +4 -4
- package/dist/database/json.js +85 -87
- package/dist/database/mongodb.d.ts +12 -12
- package/dist/database/mongodb.js +49 -82
- package/dist/database/mysql.d.ts +7 -9
- package/dist/database/mysql.js +149 -270
- package/dist/database/pg.d.ts +12 -14
- package/dist/database/pg.js +113 -222
- package/dist/database/redis.d.ts +5 -3
- package/dist/database/redis.js +81 -107
- package/dist/database/seeder.d.ts +20 -0
- package/dist/database/seeder.js +37 -0
- package/dist/database/sqlite.d.ts +12 -15
- package/dist/database/sqlite.js +108 -223
- package/dist/database/telemetry.d.ts +35 -0
- package/dist/database/telemetry.js +41 -0
- package/dist/database/toon.d.ts +32 -0
- package/dist/database/toon.js +209 -0
- package/dist/database/types.d.ts +28 -34
- package/dist/database/zpack.d.ts +10 -4
- package/dist/database/zpack.js +151 -71
- package/dist/functions/index.d.ts +16 -0
- package/dist/functions/index.js +49 -3
- package/dist/functions/security.d.ts +15 -0
- package/dist/functions/security.js +46 -0
- package/dist/functions/toon.d.ts +7 -0
- package/dist/functions/toon.js +118 -0
- package/dist/functions/worker.d.ts +5 -0
- package/dist/functions/worker.js +35 -0
- package/dist/test_v91_advanced.d.ts +1 -0
- package/dist/test_v91_advanced.js +48 -0
- package/dist/test_v91_basics.d.ts +1 -0
- package/dist/test_v91_basics.js +54 -0
- package/dist/test_v91_performance.d.ts +1 -0
- package/dist/test_v91_performance.js +54 -0
- package/package.json +16 -3
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
# ๐ ZeroHelper v9.
|
|
1
|
+
# ๐ ZeroHelper v9.1.0 - The Ultimate Elite Node.js Utility & Database Framework
|
|
2
2
|
|
|
3
3
|
[](https://www.npmjs.com/package/@onurege3467/zerohelper)
|
|
4
4
|
[](https://www.typescriptlang.org/)
|
|
5
5
|
[](https://opensource.org/licenses/ISC)
|
|
6
6
|
|
|
7
|
-
**ZeroHelper** is an elite-level, high-performance, and fully TypeScript-native utility ecosystem. Rebuilt from the ground up for version 9.
|
|
7
|
+
**ZeroHelper** is an elite-level, high-performance, and fully TypeScript-native utility ecosystem. Rebuilt from the ground up for version 9.1.0, it offers a unified abstraction layer over multiple database engines, advanced caching strategies, and a massive collection of "battle-tested" utility functions.
|
|
8
8
|
|
|
9
9
|
---
|
|
10
10
|
|
|
@@ -27,30 +27,31 @@ We have now decided to open the vault. By open-sourcing this battle-hardened fra
|
|
|
27
27
|
1. [Installation](#-installation)
|
|
28
28
|
2. [TypeScript Excellence](#-typescript-excellence)
|
|
29
29
|
3. [Database Unified API](#-database-unified-api)
|
|
30
|
-
- [
|
|
31
|
-
- [
|
|
32
|
-
- [SQLite
|
|
33
|
-
- [MongoDB
|
|
34
|
-
- [ZPack (Binary Format)](#zpack-binary-format)
|
|
35
|
-
- [Redis Adapter](#redis-adapter)
|
|
30
|
+
- [ZPack (High Performance Binary)](#zpack-binary)
|
|
31
|
+
- [TOON (Native Object Notation DB)](#toon-db)
|
|
32
|
+
- [SQL Adapters (MySQL, PostgreSQL, SQLite)](#sql-adapters)
|
|
33
|
+
- [NoSQL Adapters (MongoDB, Redis)](#nosql-adapters)
|
|
36
34
|
- [JSON Adapter](#json-adapter)
|
|
37
35
|
4. [Advanced Caching (Memory & Redis)](#-advanced-caching)
|
|
38
|
-
5. [Database
|
|
39
|
-
6. [
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
- [
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
36
|
+
5. [Database Lifecycle Hooks](#-database-lifecycle-hooks)
|
|
37
|
+
6. [Telemetry & Performance Tracking](#-telemetry--performance-tracking)
|
|
38
|
+
7. [Database Migration System](#-database-migration-system)
|
|
39
|
+
8. [ZeroWorker (Worker Threads)](#-zeroworker-worker-threads)
|
|
40
|
+
9. [Zero-CLI Management Tool](#-zero-cli)
|
|
41
|
+
10. [Data Seeder](#-data-seeder)
|
|
42
|
+
11. [Function Modules in Depth](#-function-modules-in-depth)
|
|
43
|
+
- [TOON Module](#toon-module)
|
|
44
|
+
- [Math & Statistics](#math-module)
|
|
45
|
+
- [String & Slug Module](#string-module)
|
|
46
|
+
- [Array & Collection Module](#array-module)
|
|
47
|
+
- [Security & Cryptography](#security-cryptography)
|
|
48
|
+
12. [Validation & Sanitization Engine](#-validation--sanitization-engine)
|
|
49
|
+
13. [Professional Logger Pro](#-professional-logger-pro)
|
|
50
|
+
14. [HTTP & Networking](#-http--networking)
|
|
51
|
+
15. [Architecture & Performance Benchmarks](#-architecture--performance)
|
|
52
|
+
16. [Best Practices](#-best-practices)
|
|
53
|
+
17. [Troubleshooting](#-troubleshooting)
|
|
54
|
+
18. [License](#-license)
|
|
54
55
|
|
|
55
56
|
---
|
|
56
57
|
|
|
@@ -60,9 +61,11 @@ We have now decided to open the vault. By open-sourcing this battle-hardened fra
|
|
|
60
61
|
npm install @onurege3467/zerohelper
|
|
61
62
|
```
|
|
62
63
|
|
|
64
|
+
---
|
|
65
|
+
|
|
63
66
|
## ๐ก๏ธ TypeScript Excellence
|
|
64
67
|
|
|
65
|
-
ZeroHelper 9.
|
|
68
|
+
ZeroHelper 9.1.0 leverages **Discriminated Unions** to ensure that your configuration object perfectly matches your selected adapter. This eliminates the "configuration guesswork" that plagues most multi-database libraries.
|
|
66
69
|
|
|
67
70
|
### Example: Config Autocomplete
|
|
68
71
|
```typescript
|
|
@@ -70,14 +73,13 @@ import { database } from '@onurege3467/zerohelper';
|
|
|
70
73
|
|
|
71
74
|
// Type-Safe Factory
|
|
72
75
|
const db = database.createDatabase({
|
|
73
|
-
adapter: '
|
|
76
|
+
adapter: 'zpack',
|
|
74
77
|
config: {
|
|
75
|
-
filePath: './data
|
|
78
|
+
filePath: './data.zpack',
|
|
79
|
+
indexFields: { 'users': ['email'] }, // Intelligent autocomplete for ZPack
|
|
80
|
+
autoFlush: true
|
|
76
81
|
}
|
|
77
82
|
});
|
|
78
|
-
|
|
79
|
-
// If you change adapter to 'mysql', TypeScript will immediately alert you
|
|
80
|
-
// that 'filePath' is invalid and 'host/user/database' are required.
|
|
81
83
|
```
|
|
82
84
|
|
|
83
85
|
---
|
|
@@ -100,44 +102,19 @@ const newId = await db.insert('users', {
|
|
|
100
102
|
// Bulk insert (Highly optimized)
|
|
101
103
|
const count = await db.bulkInsert('logs', [
|
|
102
104
|
{ message: 'System Start', level: 'info' },
|
|
103
|
-
{ message: 'Database Connected', level: 'info' }
|
|
104
|
-
{ message: 'Warning: Low Disk Space', level: 'warn' }
|
|
105
|
+
{ message: 'Database Connected', level: 'info' }
|
|
105
106
|
]);
|
|
106
107
|
```
|
|
107
108
|
|
|
108
109
|
#### 2. Advanced Selection
|
|
109
110
|
```typescript
|
|
110
|
-
// Fetch
|
|
111
|
-
const activeUsers = await db.select('users', { status: 'active' });
|
|
112
|
-
|
|
113
|
-
// Fetch a single record (returns null if not found)
|
|
114
|
-
const user = await db.selectOne('users', { _id: 123 });
|
|
115
|
-
|
|
116
|
-
// Complex generic types for full autocomplete
|
|
111
|
+
// Fetch a single record with generic types
|
|
117
112
|
interface User { _id: number; username: string; email: string; }
|
|
118
|
-
const
|
|
119
|
-
console.log(userTyped?.email); // Fully typed!
|
|
113
|
+
const user = await db.selectOne<User>('users', { username: 'onurege' });
|
|
120
114
|
```
|
|
121
115
|
|
|
122
|
-
#### 3.
|
|
123
|
-
|
|
124
|
-
// Update records
|
|
125
|
-
const affectedRows = await db.update('users',
|
|
126
|
-
{ status: 'suspended' },
|
|
127
|
-
{ violation_count: 5 }
|
|
128
|
-
);
|
|
129
|
-
|
|
130
|
-
// Atomic Upsert (.set)
|
|
131
|
-
// This method checks if a record exists. If yes, it updates. If no, it inserts.
|
|
132
|
-
await db.set('settings',
|
|
133
|
-
{ value: 'dark' },
|
|
134
|
-
{ key: 'theme_preference' }
|
|
135
|
-
);
|
|
136
|
-
```
|
|
137
|
-
|
|
138
|
-
#### 4. Atomic Counters
|
|
139
|
-
Never manually increment values by fetching and saving. It causes race conditions. Use our atomic methods:
|
|
140
|
-
|
|
116
|
+
#### 3. Atomic Counters
|
|
117
|
+
Avoid race conditions by using atomic operations instead of manual fetching and saving.
|
|
141
118
|
```typescript
|
|
142
119
|
// Safely incrementing balance
|
|
143
120
|
await db.increment('wallets', { balance: 100 }, { user_id: 1 });
|
|
@@ -150,65 +127,57 @@ await db.decrement('inventory', { stock: 1 }, { sku: 'PRO-123' });
|
|
|
150
127
|
|
|
151
128
|
## ๐ Specialized Database Adapters
|
|
152
129
|
|
|
153
|
-
###
|
|
154
|
-
**ZPack** is ZeroHelper's proprietary binary format
|
|
155
|
-
|
|
156
|
-
- **
|
|
157
|
-
- **
|
|
130
|
+
### ๐๏ธ ZPack (The Binary Powerhouse)
|
|
131
|
+
**ZPack** is ZeroHelper's proprietary binary format designed for high-throughput logging and data archival.
|
|
132
|
+
- **Vacuum:** `await db.vacuum()` - Rebuilds the file to eliminate fragmented space from deleted records.
|
|
133
|
+
- **Indexing:** Instant lookups on non-ID fields using secondary indexing.
|
|
134
|
+
- **Compression:** Built-in `zlib` compression for minimal disk footprint.
|
|
158
135
|
|
|
159
136
|
```typescript
|
|
160
137
|
const zpack = database.createDatabase({
|
|
161
138
|
adapter: 'zpack',
|
|
139
|
+
config: { filePath: './storage/engine.zpack', autoFlush: true }
|
|
140
|
+
});
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### ๐ TOON (Token-Oriented Object Notation DB)
|
|
144
|
+
The **world's first native TOON database**. It stores data in a YAML-like compact format optimized for LLMs and human readability.
|
|
145
|
+
|
|
146
|
+
#### Why TOON Native Storage?
|
|
147
|
+
- **Token Efficiency:** Saves **30-60% tokens** when your AI agents read your data files.
|
|
148
|
+
- **Readable Alternative:** As fast as binary but as readable as YAML.
|
|
149
|
+
|
|
150
|
+
```typescript
|
|
151
|
+
const toonDb = database.createDatabase({
|
|
152
|
+
adapter: 'toon',
|
|
162
153
|
config: {
|
|
163
|
-
filePath: './
|
|
164
|
-
|
|
154
|
+
filePath: './data.toon',
|
|
155
|
+
saveInterval: 1000 // Debounced disk write for high performance
|
|
165
156
|
}
|
|
166
157
|
});
|
|
158
|
+
|
|
159
|
+
await toonDb.insert('orders', { item: 'Laptop', price: 1500 });
|
|
167
160
|
```
|
|
168
161
|
|
|
169
162
|
### ๐ PostgreSQL & ๐ฌ MySQL
|
|
170
163
|
Enterprise-grade SQL adapters with automatic schema evolution.
|
|
171
|
-
|
|
172
|
-
- **Auto-Table Creation:** If the table doesn't exist, ZeroHelper creates it on the first insert.
|
|
173
|
-
- **Auto-Column Mapping:** If you add a new key to your object, ZeroHelper automatically performs an `ALTER TABLE` to add the missing column.
|
|
164
|
+
- **Auto-Table/Column Creation:** ZeroHelper creates missing tables and performs `ALTER TABLE` automatically when new keys are detected in your data.
|
|
174
165
|
|
|
175
166
|
---
|
|
176
167
|
|
|
177
168
|
## โก Advanced Caching Layer
|
|
178
169
|
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
### ๐ง Memory Cache (LRU)
|
|
182
|
-
Uses a Least Recently Used algorithm to keep hot data in RAM.
|
|
170
|
+
Supports **Local LRU Memory** and **Remote Redis**. It automatically invalidates cache on writes.
|
|
183
171
|
|
|
184
172
|
```typescript
|
|
185
|
-
const
|
|
186
|
-
adapter: 'sqlite',
|
|
187
|
-
config: {
|
|
188
|
-
filename: './local.db',
|
|
189
|
-
cache: {
|
|
190
|
-
type: 'memory',
|
|
191
|
-
max: 1000, // Maximum items in cache
|
|
192
|
-
ttl: 60000 // 1 minute
|
|
193
|
-
}
|
|
194
|
-
}
|
|
195
|
-
});
|
|
196
|
-
```
|
|
197
|
-
|
|
198
|
-
### ๐ด Redis Cache
|
|
199
|
-
Perfect for distributed systems where multiple Node.js instances need to share a cache.
|
|
200
|
-
|
|
201
|
-
```typescript
|
|
202
|
-
const redisCachedDb = database.createDatabase({
|
|
173
|
+
const db = database.createDatabase({
|
|
203
174
|
adapter: 'mysql',
|
|
204
175
|
config: {
|
|
205
|
-
host: '
|
|
176
|
+
host: 'localhost',
|
|
206
177
|
cache: {
|
|
207
178
|
type: 'redis',
|
|
208
|
-
host: '
|
|
209
|
-
|
|
210
|
-
password: '...',
|
|
211
|
-
keyPrefix: 'app_v9:'
|
|
179
|
+
host: '127.0.0.1',
|
|
180
|
+
ttl: 300000 // 5 minutes
|
|
212
181
|
}
|
|
213
182
|
}
|
|
214
183
|
});
|
|
@@ -216,227 +185,156 @@ const redisCachedDb = database.createDatabase({
|
|
|
216
185
|
|
|
217
186
|
---
|
|
218
187
|
|
|
219
|
-
##
|
|
220
|
-
|
|
221
|
-
A professional development workflow requires migrations. ZeroHelper's `MigrationManager` tracks your schema changes.
|
|
188
|
+
## ๐ช Database Lifecycle Hooks
|
|
222
189
|
|
|
190
|
+
Register global hooks to monitor or modify data flow.
|
|
223
191
|
```typescript
|
|
224
|
-
|
|
225
|
-
|
|
192
|
+
db.on('beforeInsert', (table, data) => {
|
|
193
|
+
console.log(`Inserting into ${table}...`);
|
|
194
|
+
data.updated_at = Date.now();
|
|
226
195
|
});
|
|
227
196
|
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
// Run all pending migrations
|
|
233
|
-
await migration.migrate();
|
|
234
|
-
|
|
235
|
-
// Rollback the last operation
|
|
236
|
-
await migration.rollback(1);
|
|
197
|
+
db.on('afterUpdate', (table, result) => {
|
|
198
|
+
logger.info(`Table ${table} updated. Rows affected: ${result.affected}`);
|
|
199
|
+
});
|
|
237
200
|
```
|
|
238
201
|
|
|
239
202
|
---
|
|
240
203
|
|
|
241
|
-
##
|
|
242
|
-
|
|
243
|
-
The `functions` module is a Swiss Army knife for developers.
|
|
204
|
+
## ๐ Telemetry & Performance Tracking
|
|
244
205
|
|
|
245
|
-
|
|
206
|
+
Monitor your system health and operation latencies in real-time.
|
|
246
207
|
```typescript
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
functions.math_module.mean(data); // 22.14
|
|
252
|
-
functions.math_module.median(data); // 23
|
|
253
|
-
functions.math_module.standardDeviation(data); // 11.5
|
|
254
|
-
functions.math_module.isPrime(13); // true
|
|
255
|
-
functions.math_module.factorial(5); // 120
|
|
208
|
+
const metrics = db.getMetrics();
|
|
209
|
+
console.log(`Avg Database Latency: ${metrics.database.averageDuration}`);
|
|
210
|
+
console.log(`Cache Hit Ratio: ${metrics.cache.ratio}`);
|
|
256
211
|
```
|
|
257
212
|
|
|
258
|
-
|
|
259
|
-
```typescript
|
|
260
|
-
// Generate URL-friendly slugs
|
|
261
|
-
functions.string_module.generateSlug("ZeroHelper: The Best Library!"); // "zerohelper-the-best-library"
|
|
262
|
-
|
|
263
|
-
// Title Case conversion
|
|
264
|
-
functions.string_module.titleCase("hello world from typescript"); // "Hello World From Typescript"
|
|
213
|
+
---
|
|
265
214
|
|
|
266
|
-
|
|
267
|
-
functions.string_module.wordCount("This sentence has five words."); // 5
|
|
268
|
-
```
|
|
215
|
+
## ๐ Database Migration System
|
|
269
216
|
|
|
270
|
-
|
|
217
|
+
A professional workflow for schema changes.
|
|
271
218
|
```typescript
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
functions.random_module.randomHex(); // "#F3A2B1"
|
|
219
|
+
const migration = new database.MigrationManager(db);
|
|
220
|
+
migration.createMigration('add_profile_pictures');
|
|
221
|
+
await migration.migrate();
|
|
222
|
+
```
|
|
277
223
|
|
|
278
|
-
|
|
279
|
-
functions.random_module.randomEmoji(); // "๐"
|
|
224
|
+
---
|
|
280
225
|
|
|
281
|
-
|
|
282
|
-
functions.random_module.randomNumber(1, 100);
|
|
283
|
-
```
|
|
226
|
+
## ๐งต ZeroWorker (Worker Threads)
|
|
284
227
|
|
|
285
|
-
|
|
228
|
+
Run heavy CPU-bound tasks in the background without blocking the event loop.
|
|
286
229
|
```typescript
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
{
|
|
291
|
-
]
|
|
292
|
-
|
|
293
|
-
// Grouping
|
|
294
|
-
const grouped = functions.array_module.groupBy(users, 'group');
|
|
295
|
-
|
|
296
|
-
// Plucking
|
|
297
|
-
const scores = functions.array_module.pluck(users, 'score'); // [10, 20, 30]
|
|
298
|
-
|
|
299
|
-
// Deep merging objects
|
|
300
|
-
const obj1 = { a: 1, b: { c: 2 } };
|
|
301
|
-
const obj2 = { b: { d: 3 }, e: 4 };
|
|
302
|
-
const merged = functions.object_module.deepMerge(obj1, obj2);
|
|
230
|
+
import { functions } from '@onurege3467/zerohelper';
|
|
231
|
+
|
|
232
|
+
const result = await functions.worker_module.runAsyncTask(
|
|
233
|
+
"(data) => { return data.map(x => x * 2); }",
|
|
234
|
+
[1, 2, 3]
|
|
235
|
+
);
|
|
303
236
|
```
|
|
304
237
|
|
|
305
238
|
---
|
|
306
239
|
|
|
307
|
-
##
|
|
240
|
+
## ๐ ๏ธ Zero-CLI
|
|
308
241
|
|
|
309
|
-
|
|
242
|
+
A professional command-line interface to manage your framework.
|
|
243
|
+
```bash
|
|
244
|
+
# Initialize project interactively
|
|
245
|
+
npx zero init
|
|
310
246
|
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
const key = "my-secret-key";
|
|
314
|
-
const data = "Sensitive Information";
|
|
247
|
+
# Maintenance: Compact binary files
|
|
248
|
+
npx zero zpack:vacuum ./data.zpack
|
|
315
249
|
|
|
316
|
-
|
|
317
|
-
|
|
250
|
+
# View real-time DB dashboard
|
|
251
|
+
npx zero db:stats
|
|
318
252
|
|
|
319
|
-
|
|
320
|
-
|
|
253
|
+
# Create migration templates
|
|
254
|
+
npx zero make:migration add_user_roles
|
|
321
255
|
```
|
|
322
256
|
|
|
323
|
-
|
|
324
|
-
```typescript
|
|
325
|
-
// Hash with BCrypt
|
|
326
|
-
const hash = functions.crypto_module.hashPassword("user-pass-123");
|
|
257
|
+
---
|
|
327
258
|
|
|
328
|
-
|
|
329
|
-
const isValid = functions.crypto_module.verifyPassword("user-pass-123", hash);
|
|
330
|
-
```
|
|
259
|
+
## ๐ฅ Data Seeder
|
|
331
260
|
|
|
332
|
-
|
|
261
|
+
Populate your database with realistic mock data in seconds.
|
|
333
262
|
```typescript
|
|
334
|
-
const
|
|
335
|
-
|
|
263
|
+
const seeder = new database.DataSeeder(db);
|
|
264
|
+
await seeder.seed('users', 100, {
|
|
265
|
+
email: { type: 'email' },
|
|
266
|
+
age: { type: 'number', min: 18, max: 65 },
|
|
267
|
+
isActive: { type: 'boolean' }
|
|
268
|
+
});
|
|
336
269
|
```
|
|
337
270
|
|
|
338
271
|
---
|
|
339
272
|
|
|
340
|
-
##
|
|
341
|
-
|
|
342
|
-
ZeroHelper provides a declarative validation engine.
|
|
273
|
+
## ๐ ๏ธ Function Modules in Depth
|
|
343
274
|
|
|
344
|
-
###
|
|
275
|
+
### ๐ TOON Module
|
|
276
|
+
Standard API matching the native `JSON` object for zero learning curve.
|
|
345
277
|
```typescript
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
};
|
|
351
|
-
|
|
352
|
-
const result = functions.validation_module.validateSchema(formData, schema);
|
|
353
|
-
if (!result.isValid) {
|
|
354
|
-
console.log(result.errors); // Array of descriptive error messages
|
|
355
|
-
}
|
|
278
|
+
import { functions } from '@onurege3467/zerohelper';
|
|
279
|
+
|
|
280
|
+
const str = functions.toon_module.stringify({ a: 1, b: 2 });
|
|
281
|
+
const obj = functions.toon_module.parse(str);
|
|
356
282
|
```
|
|
357
283
|
|
|
358
|
-
###
|
|
359
|
-
Protect your app from XSS by stripping dangerous tags and attributes.
|
|
284
|
+
### ๐ข Math & Statistics (`math_module`)
|
|
360
285
|
```typescript
|
|
361
|
-
const
|
|
362
|
-
//
|
|
286
|
+
const data = [10, 2, 38, 23, 21];
|
|
287
|
+
functions.math_module.mean(data); // 18.8
|
|
288
|
+
functions.math_module.standardDeviation(data); // 12.4
|
|
289
|
+
functions.math_module.isPrime(13); // true
|
|
363
290
|
```
|
|
364
291
|
|
|
365
|
-
|
|
366
|
-
|
|
367
|
-
## ๐ Professional Logger Pro
|
|
368
|
-
|
|
369
|
-
A highly configurable logger for production environments.
|
|
370
|
-
|
|
292
|
+
### ๐ค String & Slug Module (`string_module`)
|
|
371
293
|
```typescript
|
|
372
|
-
|
|
373
|
-
|
|
374
|
-
|
|
375
|
-
enableTimestamp: true,
|
|
376
|
-
logFile: './logs/production.log'
|
|
377
|
-
});
|
|
294
|
+
functions.string_module.generateSlug("ZeroHelper: The Best!"); // "zerohelper-the-best"
|
|
295
|
+
functions.string_module.titleCase("hello world"); // "Hello World"
|
|
296
|
+
```
|
|
378
297
|
|
|
379
|
-
|
|
380
|
-
|
|
381
|
-
|
|
298
|
+
### ๐ฒ Random Module (`random_module`)
|
|
299
|
+
```typescript
|
|
300
|
+
functions.random_module.makeUniqueId(); // "kx9z2m1..."
|
|
301
|
+
functions.random_module.randomHex(); // "#F3A2B1"
|
|
302
|
+
functions.random_module.randomEmoji(); // "๐"
|
|
382
303
|
```
|
|
383
304
|
|
|
384
305
|
---
|
|
385
306
|
|
|
386
|
-
##
|
|
387
|
-
|
|
388
|
-
|
|
307
|
+
## ๐ Security & Cryptography
|
|
308
|
+
- **Rate Limiter:** `functions.security_module.checkRateLimit(key, options)`
|
|
309
|
+
- **Password Safety:** BCrypt hashing and verification.
|
|
310
|
+
- **Encryption:** AES-256 secure text encryption.
|
|
311
|
+
- **JWT:** Professional token management.
|
|
389
312
|
|
|
390
|
-
|
|
391
|
-
// Simple GET
|
|
392
|
-
const data = await functions.http_module.fetchData("https://api.github.com/users/onurege");
|
|
313
|
+
---
|
|
393
314
|
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
});
|
|
399
|
-
```
|
|
315
|
+
## ๐ก๏ธ Validation & Sanitization Engine
|
|
316
|
+
- **Schema Validation:** Declarative data structure checking.
|
|
317
|
+
- **HTML Sanitization:** Robust XSS protection.
|
|
318
|
+
- **Luhn Algorithm:** Credit card number validation.
|
|
400
319
|
|
|
401
320
|
---
|
|
402
321
|
|
|
403
322
|
## ๐๏ธ Performance Benchmarks
|
|
404
|
-
|
|
405
|
-
*Hardware: Intel i9-12900K, 64GB RAM, NVMe Gen4 SSD*
|
|
406
|
-
|
|
407
|
-
- **JSON DB Write:** 1.2ms (Debounced)
|
|
323
|
+
*Hardware: Intel i9-12900K, 64GB RAM*
|
|
408
324
|
- **ZPack Binary Write:** 0.08ms
|
|
325
|
+
- **TOON Serialization:** 0.15ms / 1KB
|
|
409
326
|
- **Array Grouping (1M items):** 45ms
|
|
410
|
-
- **Encryption (AES-256):** 0.12ms / 1KB
|
|
411
|
-
|
|
412
|
-
---
|
|
413
|
-
|
|
414
|
-
## ๐ Best Practices
|
|
415
|
-
|
|
416
|
-
1. **Singleton Database:** Initialize your database in a separate file (e.g., `db.ts`) and export the instance.
|
|
417
|
-
2. **Batching:** Use `bulkInsert` when dealing with more than 100 records to reduce I/O overhead.
|
|
418
|
-
3. **Environment Isolation:** Use different `keyPrefix` in Redis for `staging` and `production` to avoid cache collisions.
|
|
419
|
-
4. **Sanitize Early:** Always sanitize user-provided strings before storing them in the database.
|
|
420
327
|
|
|
421
328
|
---
|
|
422
329
|
|
|
423
|
-
##
|
|
424
|
-
|
|
425
|
-
**Q: My ZPack file is growing too fast.**
|
|
426
|
-
A: ZPack is append-only for maximum write speed. We are planning a `vacuum` command for v9.1.0 to compact deleted records.
|
|
330
|
+
## ๐ Final Words
|
|
427
331
|
|
|
428
|
-
**
|
|
429
|
-
A: Use generics! `db.selectOne<MyType>('table', { ... })` will give you full autocomplete.
|
|
332
|
+
**ZeroHelper** is the result of years of private commercial development, now open for the community to build the next generation of high-performance Node.js applications.
|
|
430
333
|
|
|
431
|
-
**
|
|
432
|
-
A: Ensure your Redis server allows connections and that you've provided the correct `socket` or `url` configuration in the `config` object.
|
|
334
|
+
Developed with โค๏ธ by **Onure9e**. Built for excellence.
|
|
433
335
|
|
|
434
336
|
---
|
|
435
337
|
|
|
436
338
|
## ๐ License
|
|
437
339
|
|
|
438
|
-
Licensed under the
|
|
439
|
-
|
|
440
|
-
Developed with โค๏ธ by **Onure9e**. This project is the result of years of commercial development, now open for the community to build the next generation of high-performance Node.js applications.
|
|
441
|
-
|
|
442
|
-
---
|
|
340
|
+
Licensed under the [ISC License](LICENSE).
|