1.0.2 • Published 4 years ago

babel-plugin-variable-token v1.0.2

Weekly downloads
3
License
MIT
Repository
github
Last release
4 years ago

babel-plugin-variable-token

support different token,support different languages javascript

fork from @babel/parser

install

npm install babel-plugin-variable-token

example

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);
 *  }
 */