一个 110KB 大小的 JS 解释器/运行器
A 110KB size JS parser and runner.
import * as esParser from "es-parser";
const esParser = require("es-parser");
- run:
run(codeString: string, globalMap: GlobalMap)
interface GlobalMap{
[prop: globalIdentifier]: value
}
esParser.run("console.log('hello world')");
esParser.run(
`
const progress = wx.downloadFile({
url: 'https://www.baidu.com/img/bd_logo1.png',
success: res => {
wx.hideLoading();
if (res.statusCode === 200) console.log(success, res.tempFilePath);
else wx.showToast({ title: '下载失败' });
});
},
fail: failMsg => {
wx.hideLoading();
wx.showToast({ title: '下载失败' });
}
});
progress.onProgressUpdate(res => {
wx.showLoading({ title: \`下载中\${Math.round(res.progress)}%\` });
});
`,
{ wx }
);
// this will pass the global variable `wx` to the parser
None, but package is still in test.
- You should always access
isFinite
,isNaN
throughNumber
.
- add Stack Track