我想这就是你想要的:
const readline = require('readline');const rl = readline.createInterface({ input: process.stdin , output: process.stdout });const getLine = (function () { const getLineGen = (async function* () { for await (const line of rl) { yield line; } })(); return async () => ((await getLineGen.next()).value);})();const main = async () => { let a = Number(await getLine()); let b = Number(await getLine()); console.log(a+b); process.exit(0);};main();
注意:此答案使用实验性功能,并且需要Node v11.7
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)