var getText = require("./utils/getText"); var setText = require("./utils/setText"); const SugarMap={ async init(val){ console.log(val) return val } } async function init() { let text=await getText('./test/test1.js'); async function Sugar(text) { //匹配語法糖 if(/Sugar\.(\w+)\(([^()]*)\)/.test(text)){ const match=RegExp.lastMatch; const key=RegExp.$1; const val=RegExp.$2; const str=await SugarMap[key](val) text=text.replace(match,str); await Sugar(text) } return text; } text=await Sugar(text) console.log(text) } init()