# HsunaJS **Repository Path**: hsuna/HsunaJS ## Basic Information - **Project Name**: HsunaJS - **Description**: JS写JS的解释器 - **Primary Language**: Unknown - **License**: Not specified - **Default Branch**: master - **Homepage**: None - **GVP Project**: No ## Statistics - **Stars**: 0 - **Forks**: 0 - **Created**: 2021-01-27 - **Last Updated**: 2024-11-30 ## Categories & Tags **Categories**: Uncategorized **Tags**: None ## README # HsunaJS HsunaJS is a javascript interpreter, which can run JS code in JS. ## Install ``` git clone https://github.com/hsuna/HsunaJS.git ``` ## Usage ```javascript const acorn = require("acorn") const HsunaJS = require("../lib/HsunaJS.common") let code = ` (function (global, factory) { typeof exports === 'object' && typeof module !== 'undefined' ? module.exports = factory() : typeof define === 'function' && define.amd ? define(factory) : (global = global || self, global.SDK = factory()); }(this, (function () { 'use strict'; return function(a, b, c) { return a + b + c; } }))); ` let ast = acorn.parse(code) console.log(ast) HsunaJS.parse(ast, { this: global, define: { amd: undefined }, self: undefined }) const SDK = global.SDK console.log(SDK(1, 2, 3)) ``` ## License MIT