示例工程 21-commonjs-snapshot
21-commonjs-snapshot/04-snapshot-vs-live/src/main.ts
点击「运行示例」后,左侧显示源码、右侧显示运行结果;console 输出会实时回传。
import { count, increment } from './counter.js';
export function run(log: (msg: string) => void = console.log): string[] {
const before = count;
increment();
const lines = [`before:${before}`, `after:${count}`];
for (const line of lines) {
log(line);
}
return lines;
}