mirror of
https://github.com/LuanRT/YouTube.js.git
synced 2026-07-02 04:58:42 +00:00
refactor(general): Clean up and add a logger (#587)
* feat(utils): Add logger * chore: Clean up some classes and add more logging * chore: Fix conflicts
This commit is contained in:
@@ -1,10 +1,21 @@
|
||||
import { Jinter } from 'jintr';
|
||||
import type { VMPrimative } from '../../types/PlatformShim.js';
|
||||
import { Log } from '../lib.js';
|
||||
|
||||
const TAG = 'JsRuntime';
|
||||
|
||||
export default function evaluate(code: string, env: Record<string, VMPrimative>) {
|
||||
Log.info(TAG, 'Evaluating JavaScript.\n', code);
|
||||
|
||||
const runtime = new Jinter(code);
|
||||
|
||||
for (const [ key, value ] of Object.entries(env)) {
|
||||
runtime.scope.set(key, value);
|
||||
}
|
||||
return runtime.interpret();
|
||||
|
||||
const result = runtime.interpret();
|
||||
|
||||
Log.info(TAG, 'Done. Result:', result);
|
||||
|
||||
return result;
|
||||
}
|
||||
Reference in New Issue
Block a user