You're Invited:Meet the Socket Team at RSAC and BSidesSF 2026, March 23–26.RSVP
Socket
Book a DemoSign in
Socket

dphelper

Package Overview
Dependencies
Maintainers
1
Versions
407
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dphelper - npm Package Compare versions

Comparing version
3.3.5
to
3.3.6
+1
-1
package.json
{
"name": "dphelper",
"code": "dphelper",
"version": "3.3.5",
"version": "3.3.6",
"description": "dphelper devtools for developers",

@@ -6,0 +6,0 @@ "main": "./index.cjs",

+150
-13

@@ -34,3 +34,3 @@ # [dphelper](https://npmjs.com/package/dphelper)

**dphelper** is a powerful, zero-dependency utility library that brings together 45+ production-ready tools for web developers, AI engineers, and DevTools creators.
**dphelper** is a powerful, zero-dependency utility library that brings together **53 production-ready tools** for web developers, AI engineers, and DevTools creators.

@@ -45,3 +45,3 @@ Think of it as your **universal toolbox** - from DOM manipulation to cryptographic operations, from real-time WebSocket handling to AI-powered token optimization. No more juggling multiple packages. One import, infinite possibilities.

- **🔒 Type-Safe** - Full TypeScript definitions auto-generated for every tool.
- **📦 Tiny Bundle** - Only ~136KB minified, tree-shakeable.
- **📦 Tiny Bundle** - Only ~171KB minified, tree-shakeable.

@@ -62,20 +62,157 @@ > *"dphelper is what you'd build if you combined lodash, socket.io, and an AI SDK - but lighter."*

## 🚀 Version 3.0: The AI Leap
## 🚀 Version 3.3: New Powerful Modules
`dphelper` has evolved into a powerhouse for AI-driven applications. We've removed legacy dependencies (bye-bye jQuery!) and shifted focus to **performance**, **modularity**, and **LLM optimization**.
`dphelper` has expanded with powerful new modules for modern web development:
### ✨ Highlights
- **🤖 Advanced AI Module**: Built-in support for RAG, token counting, and prompt engineering.
- **🚀 AI Black Box (Snapshot)**: The first "Flight Recorder" for apps, capturing the internal state in TOON for instant AI debugging.
- **🎒 TOON Integration**: Native support for **Token-Oriented Object Notation** (3.0), reducing LLM context usage by up to 50%.
- **🛠️ Zero Dependencies**: Pure vanilla JavaScript/TypeScript architecture.
- **🌐 Fetch & SSE Pro**: High-level networking with automatic retries and custom headers.
- **⚡ Bulletproof Dispatcher**: Integrated listener management with automatic cleanup.
- **🔄 UI Mirror & Pulse**: Cross-tab synchronization and automatic UI state recovery (Zero-Code Persistence).
- **🌊 SSE Pro**: Server-Sent Events with POST & Custom Header support (modern AI streaming ready).
- **🧬 Modular Types**: Auto-generated Type definitions for all 200+ tools.
- **💾 IndexedDB Module**: Full-featured wrapper for IndexedDB with query builder, transactions, and bulk operations.
- **⚙️ Web Worker Module**: Create and manage workers, worker pools for parallel processing, and SharedWorkers for cross-tab communication.
- **🌍 i18n Module**: Complete internationalization with translations, pluralization, date/number formatting, and relative time.
- **🖼️ Image Module**: Image processing including resize, crop, filters, rotation, flip, and compositing.
- **🗜️ Compression Module**: Gzip, deflate, LZW compression, plus base64, URL, and HTML encoding/decoding.
- **🔐 Biometric Module**: WebAuthn support for fingerprint, face recognition, and secure credential management.
---
## 💾 IndexedDB Module
```javascript
// Open/create database
const db = await dphelper.idb.open('mydb', 1, { users: 'id++,name,email' });
// Add record
await dphelper.idb.put('mydb', 'users', { name: 'John', email: 'john@example.com' });
// Query records
const users = await dphelper.idb.getAll('mydb', 'users');
// Query by index
const johns = await dphelper.idb.query('mydb', 'users', 'name', 'John');
// Bulk operations
await dphelper.idb.bulkPut('mydb', 'users', [{name: 'A'}, {name: 'B'}]);
```
---
## ⚙️ Web Worker Module
```javascript
// Create worker from file
const worker = dphelper.worker.create('worker.js', {
onmessage: (e) => console.log(e.data)
});
// Create inline worker
const inlineWorker = dphelper.worker.createInline(`
self.onmessage = e => postMessage(e.data * 2);
`);
// Worker pool for parallel processing
const pool = dphelper.worker.pool('worker.js', 4);
const results = await dphelper.worker.poolExec(pool, [1, 2, 3, 4]);
// SharedWorker for cross-tab communication
const shared = dphelper.worker.shared('worker.js', { name: 'my-shared' });
```
---
## 🌍 i18n Module
```javascript
// Set locale
dphelper.i18n.setLocale('it');
// Add translations
dphelper.i18n.addTranslations('it', {
hello: 'Ciao {name}!',
items: '{count, plural, one{# item} other{# items}}'
});
// Translate with interpolation
dphelper.i18n.t('hello', { name: 'World' }); // "Ciao World!"
// Pluralize
dphelper.i18n.pluralize(5, { one: 'item', other: 'items' }); // "items"
// Format number/currency
dphelper.i18n.number(1234.56, 'de-DE', { style: 'currency', currency: 'EUR' });
// Relative time
dphelper.i18n.relativeTime(Date.now() - 3600000); // "1 hour ago"
```
---
## 🖼️ Image Module
```javascript
// Load image
const img = await dphelper.image.load('photo.jpg');
// Resize
const resized = dphelper.image.resize(img, 100, 100);
// Crop
const cropped = dphelper.image.crop(img, { x: 0, y: 0, width: 50, height: 50 });
// Apply filters
const filtered = dphelper.image.filter(img, { brightness: 1.2, sepia: 0.5 });
// Rotate/Flip
const rotated = dphelper.image.rotate(img, 90);
const flipped = dphelper.image.flip(img, 'horizontal');
// Grayscale/Blur
const gray = dphelper.image.grayscale(img);
const blurred = dphelper.image.blur(img, 5);
```
---
## 🗜️ Compression Module
```javascript
// Gzip compression
const compressed = await dphelper.compress.gzip('Hello World');
const decompressed = await dphelper.compress.gunzip(compressed);
// Base64 encoding
const encoded = dphelper.compress.base64Encode('Hello');
const decoded = dphelper.compress.base64Decode(encoded);
// URL encoding
const urlEncoded = dphelper.compress.urlEncode('Hello World!');
const urlDecoded = dphelper.compress.urlDecode(urlEncoded);
// HTML encoding
const htmlEncoded = dphelper.compress.htmlEncode('<script>');
const htmlDecoded = dphelper.compress.htmlDecode('&lt;script&gt;');
```
---
## 🔐 Biometric Module (WebAuthn)
```javascript
// Check availability
const available = dphelper.biometric.isAvailable();
// Get support details
const support = dphelper.biometric.getWebAuthnSupport();
// Register credential
const { success, credentialId } = await dphelper.biometric.register('user123');
// Authenticate
const { success } = await dphelper.biometric.authenticate('user123');
// Check specific sensor
const hasFingerprint = await dphelper.biometric.isSensorAvailable('fingerprint');
```
---
## Table of Contents

@@ -82,0 +219,0 @@

@@ -67,2 +67,19 @@ // --- AUTO-GENERATED TOOL TYPES START ---

// --- biometric ---
interface BiometricTool {
isAvailable: () => boolean
getWebAuthnSupport: () => {
supported: boolean
platformAuthenticator: boolean
hybridTransport: boolean
uvToken: boolean
}
isSensorAvailable: (type: "fingerprint" | "face" | "iris") => Promise<boolean>
register: (userId: string, rpId?: string, rpName?: string, userName?: string) => Promise<{ success: boolean; credentialId?: string; error?: string }>
authenticate: (userId: string, rpId?: string, credentialId?: string) => Promise<{ success: boolean; error?: string }>
getCredential: (credentialId: string) => PublicKeyCredentialDescriptor | undefined
deleteCredential: (credentialId: string) => boolean
listCredentials: () => string[]
}
// --- browser ---

@@ -97,2 +114,18 @@ interface BrowserTool {

// --- compress ---
interface CompressTool {
gzip: (data: string | Uint8Array) => Promise<Blob>
gunzip: (blob: Blob) => Promise<string>
deflate: (data: string | Uint8Array) => Promise<Blob>
inflate: (blob: Blob) => Promise<string>
compress: (data: string) => string
decompress: (data: string) => string
base64Encode: (data: string) => string
base64Decode: (data: string) => string
urlEncode: (data: string) => string
urlDecode: (data: string) => string
htmlEncode: (data: string) => string
htmlDecode: (data: string) => string
}
// --- cookie ---

@@ -239,2 +272,46 @@ interface CookieTool {

// --- i18n ---
interface I18nTool {
setLocale: (locale: string) => void
getLocale: () => string
addTranslations: (locale: string, strings: Record<string, string>) => void
t: (key: string, vars?: Record<string, any>) => string
pluralize: (count: number, options: { zero?: string; one?: string; two?: string; few?: string; many?: string; other?: string }, locale?: string) => string
number: (value: number, locale?: string, options?: Intl.NumberFormatOptions) => string
date: (value: Date | number, locale?: string, options?: Intl.DateTimeFormatOptions) => string
relativeTime: (timestamp: number | Date, locale?: string) => string
list: (items: string[], locale?: string, options?: Intl.ListFormatOptions) => string
getSupportedLocales: () => string[]
}
// --- idb ---
interface IDBTool {
open: (dbName: string, version?: number, stores?: Record<string, string>) => Promise<IDBDatabase>
put: (dbName: string, storeName: string, data: any) => Promise<IDBValidKey>
get: (dbName: string, storeName: string, key: IDBValidKey) => Promise<any>
getAll: (dbName: string, storeName: string) => Promise<any[]>
delete: (dbName: string, storeName: string, key: IDBValidKey) => Promise<void>
clear: (dbName: string, storeName: string) => Promise<void>
count: (dbName: string, storeName: string) => Promise<number>
query: (dbName: string, storeName: string, indexName: string, value: IDBValidKey, options?: { range?: IDBKeyRange, direction?: IDBCursorDirection, limit?: number }) => Promise<any[]>
bulkPut: (dbName: string, storeName: string, items: any[]) => Promise<IDBValidKey[]>
close: (dbName: string) => void
}
// --- image ---
interface ImageTool {
resize: (img: HTMLImageElement, width: number, height: number, quality?: "pixelated" | "auto") => string
crop: (img: HTMLImageElement, region: { x: number; y: number; width: number; height: number }) => string
toDataURL: (img: HTMLImageElement | HTMLCanvasElement, format?: string, quality?: number) => string
fromDataURL: (dataURL: string) => Promise<HTMLImageElement>
filter: (img: HTMLImageElement, options: { brightness?: number; contrast?: number; saturate?: number; hueRotate?: number; invert?: number; sepia?: number; blur?: number; grayscale?: number }) => string
rotate: (img: HTMLImageElement, degrees: number) => string
flip: (img: HTMLImageElement, direction: "horizontal" | "vertical") => string
grayscale: (img: HTMLImageElement) => string
blur: (img: HTMLImageElement, radius: number) => string
getDimensions: (img: HTMLImageElement | HTMLCanvasElement) => { width: number; height: number }
load: (src: string) => Promise<HTMLImageElement>
composite: (img1: HTMLImageElement, img2: HTMLImageElement, mode?: "source-over" | "multiply" | "screen" | "overlay" | "darken" | "lighten", x?: number, y?: number) => string
}
// --- json ---

@@ -567,2 +644,21 @@ interface JsonTool {

}
// --- worker ---
interface WorkerPool {
workers: Worker[]
busy: Set<Worker>
queue: Array<{ task: any, resolve: Function, reject: Function }>
size: number
}
interface WorkerTool {
create: (src: string, options?: { onmessage?: (e: MessageEvent) => void; onerror?: (e: ErrorEvent) => void }) => Worker
createInline: (code: string, options?: { onmessage?: (e: MessageEvent) => void; onerror?: (e: ErrorEvent) => void }) => Worker
post: (worker: Worker, message: any, transferables?: Transferable[]) => void
terminate: (worker: Worker) => void
pool: (src: string, size?: number) => WorkerPool
poolExec: (pool: WorkerPool, tasks: any[]) => Promise<any[]>
importScripts: (worker: Worker, scripts: string[]) => void
shared: (src: string, options?: { name?: string; onconnect?: (e: MessageEvent) => void; onmessage?: (e: MessageEvent) => void }) => SharedWorker
}
// --- AUTO-GENERATED TOOL TYPES END ---

@@ -599,5 +695,7 @@

readonly avoid: AvoidTool
readonly biometric: BiometricTool
readonly browser: BrowserTool
readonly check: CheckTool
readonly color: ColorTool
readonly compress: CompressTool
readonly cookie: CookieTool

@@ -614,2 +712,5 @@ readonly coords: CoordsTool

readonly format: FormatTool
readonly i18n: I18nTool
readonly idb: IdbTool
readonly image: ImageTool
readonly json: JsonTool

@@ -643,2 +744,3 @@ readonly load: LoadTool

readonly window: WindowTool
readonly worker: WorkerTool
// --- AUTO-GENERATED TOOL MEMBERS END ---

@@ -645,0 +747,0 @@

Sorry, the diff of this file is too big to display

Sorry, the diff of this file is too big to display