Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/zy445566/babel-plugin-variable-token
support different token,support different languages javascript
https://github.com/zy445566/babel-plugin-variable-token
babel
Last synced: about 11 hours ago
JSON representation
support different token,support different languages javascript
- Host: GitHub
- URL: https://github.com/zy445566/babel-plugin-variable-token
- Owner: zy445566
- License: mit
- Created: 2019-12-26T01:45:46.000Z (almost 5 years ago)
- Default Branch: master
- Last Pushed: 2023-01-05T03:40:40.000Z (almost 2 years ago)
- Last Synced: 2024-11-02T16:23:07.691Z (6 days ago)
- Topics: babel
- Language: JavaScript
- Size: 103 KB
- Stars: 1
- Watchers: 2
- Forks: 0
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# babel-plugin-variable-token
support different token,support different languages javascript`fork from @babel/parser`
# install
```sh
npm install babel-plugin-variable-token
```
# example
```js
const babelCore = require('@babel/core')
const babelPluginVariableToken = require('babel-plugin-variable-token')
babelPluginVariableToken.customTokenTypes._function.keyword = '函数'
babelPluginVariableToken.customTokenTypes._if.keyword = '如果'
babelPluginVariableToken.customTokenTypes._return.keyword = '返回'
const result = babelCore.transformSync(`
函数 斐波那契(所求数) {
如果(所求数<=2){返回 1};
返回 斐波那契(所求数-2)+斐波那契(所求数-1);
}
`, { plugins: [babelPluginVariableToken.plugin] });
/**
* result.code:
* function 斐波那契(所求数) {
* if (所求数 <= 2) {
* return 1;
* };
* return 斐波那契(所求数 - 2) + 斐波那契(所求数 - 1);
* }
*/
```