Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/mister-hope/es-parser
A 100kb size es6 parser
https://github.com/mister-hope/es-parser
js mr-hope parser
Last synced: 3 months ago
JSON representation
A 100kb size es6 parser
- Host: GitHub
- URL: https://github.com/mister-hope/es-parser
- Owner: Mister-Hope
- License: mit
- Created: 2020-03-13T09:55:33.000Z (almost 5 years ago)
- Default Branch: main
- Last Pushed: 2023-12-14T22:05:22.000Z (about 1 year ago)
- Last Synced: 2024-10-04T18:53:23.136Z (4 months ago)
- Topics: js, mr-hope, parser
- Language: TypeScript
- Homepage:
- Size: 1.89 MB
- Stars: 7
- Watchers: 1
- Forks: 1
- Open Issues: 27
-
Metadata Files:
- Readme: readme.md
- License: LICENSE
Awesome Lists containing this project
README
# es-parser
[![Author: Mr.Hope](https://img.shields.io/badge/作者-Mr.Hope-blue.svg?style=for-the-badge)](https://mrhope.site)
一个 110KB 大小的 JS 解释器/运行器
A 110KB size JS parser and runner.
## Import
### TypeScript
```ts
import * as esParser from "es-parser";
```### JavaScript
```js
const esParser = require("es-parser");
```## API
- run:
```ts
run(codeString: string, globalMap: GlobalMap)interface GlobalMap{
[prop: globalIdentifier]: value
}
```## Demo
```js
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
```## Known Bugs
None, but package is still in test.
## Notes
- You should always access `isFinite`, `isNaN` through `Number`.
## TODO
- add Stack Track