示例工程 23-esm-live-bindings

23-esm-live-bindings/01-live-bindings/src/main.ts

typescript · 0.3 KB

运行:23 · live-bindings

点击「运行示例」后,左侧显示源码、右侧显示运行结果;console 输出会实时回传。

import { count, increment } from './counter.js';
 
export function run(log: (msg: string) => void = console.log): string[] {
  const before = count;
  increment();
  const after = count;
  const lines = [`before:${before}`, `after:${after}`];
  for (const line of lines) {
    log(line);
  }
  return lines;
}