run method

Future<Object?> run(
  1. String code, {
  2. Duration? timeout,
  3. String name = '<run>',
  4. Map<String, Object?> tempGlobals = const {},
})

求值 code、等待其 Promise 结果并转换为 Dart 值。

Implementation

Future<Object?> run(
  String code, {

  /// 从任务入队开始计算的总时限,包含排队、执行和等待 Promise 的时间。
  Duration? timeout,

  /// 本次执行的源码名称,用于错误堆栈、诊断信息和 source map 匹配。
  String name = '<run>',
  Map<String, Object?> tempGlobals = const {},
}) {
  _ensureOpen();
  return _engine.run(
    code,
    timeout: timeout,
    name: name,
    tempGlobals: tempGlobals,
  );
}