@json-eval-rs/webcore 0.0.54 → 0.0.55
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/dist/index.d.ts +10 -0
- package/dist/index.js +22 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -372,6 +372,16 @@ export declare class JSONEvalCore {
|
|
|
372
372
|
* @returns New instance
|
|
373
373
|
*/
|
|
374
374
|
static fromCache(wasmModule: any, cacheKey: string, context?: any, data?: any): JSONEvalCore;
|
|
375
|
+
/**
|
|
376
|
+
* Evaluate logic expression without creating an instance
|
|
377
|
+
*
|
|
378
|
+
* @param wasmModule - WASM module
|
|
379
|
+
* @param logicStr - JSON Logic expression (string or object)
|
|
380
|
+
* @param data - Optional data (string or object)
|
|
381
|
+
* @param context - Optional context (string or object)
|
|
382
|
+
* @returns Evaluation result
|
|
383
|
+
*/
|
|
384
|
+
static evaluateLogic(wasmModule: any, logicStr: string | object, data?: any, context?: any): any;
|
|
375
385
|
/**
|
|
376
386
|
* Validate data against schema (returns parsed JavaScript object)
|
|
377
387
|
* Uses validateJS for Worker-safe serialization
|
package/dist/index.js
CHANGED
|
@@ -119,6 +119,28 @@ export class JSONEvalCore {
|
|
|
119
119
|
fromCache: true
|
|
120
120
|
});
|
|
121
121
|
}
|
|
122
|
+
/**
|
|
123
|
+
* Evaluate logic expression without creating an instance
|
|
124
|
+
*
|
|
125
|
+
* @param wasmModule - WASM module
|
|
126
|
+
* @param logicStr - JSON Logic expression (string or object)
|
|
127
|
+
* @param data - Optional data (string or object)
|
|
128
|
+
* @param context - Optional context (string or object)
|
|
129
|
+
* @returns Evaluation result
|
|
130
|
+
*/
|
|
131
|
+
static evaluateLogic(wasmModule, logicStr, data, context) {
|
|
132
|
+
if (!wasmModule) {
|
|
133
|
+
throw new Error('No WASM module provided.');
|
|
134
|
+
}
|
|
135
|
+
const { JSONEvalWasm } = wasmModule;
|
|
136
|
+
if (!JSONEvalWasm || typeof JSONEvalWasm.evaluateLogic !== 'function') {
|
|
137
|
+
throw new Error('WASM module does not support evaluateLogic.');
|
|
138
|
+
}
|
|
139
|
+
const logic = typeof logicStr === 'string' ? logicStr : JSON.stringify(logicStr);
|
|
140
|
+
const dataStr = data ? (typeof data === 'string' ? data : JSON.stringify(data)) : null;
|
|
141
|
+
const contextStr = context ? (typeof context === 'string' ? context : JSON.stringify(context)) : null;
|
|
142
|
+
return JSONEvalWasm.evaluateLogic(logic, dataStr, contextStr);
|
|
143
|
+
}
|
|
122
144
|
/**
|
|
123
145
|
* Validate data against schema (returns parsed JavaScript object)
|
|
124
146
|
* Uses validateJS for Worker-safe serialization
|