module.evaluate([options])


  • options <Object>
    • timeout <integer> 指定终止执行前要评估的毫秒数。 如果执行中断,则会抛出Error。 此值必须是严格的正整数。
    • breakOnSigint <boolean> 如果为 true,则接收 SIGINTCtrl+C)将终止执行并抛出 Error。 已通过 process.on('SIGINT') 附加的事件的现有句柄在脚本执行期间被禁用,但在此之后继续工作。 默认值: false
  • 返回: <Promise> 成功时将使用 undefined 履行。

评估模块。

必须在模块链接后调用,否则会拒绝。 当模块已经被评估时,它也可以被调用,在这种情况下,如果初始评估成功结束(module.status'evaluated'),则它将不做任何事情,或者它会重新抛出初始评估导致的异常(module.status'errored')。

在评估模块时无法调用此方法(module.status'evaluating')。

对应 ECMAScript 规范中循环模块记录Evaluate() 具体方法字段。

  • options <Object>
    • timeout <integer> Specifies the number of milliseconds to evaluate before terminating execution. If execution is interrupted, an Error will be thrown. This value must be a strictly positive integer.
    • breakOnSigint <boolean> If true, receiving SIGINT (Ctrl+C) will terminate execution and throw an Error. Existing handlers for the event that have been attached via process.on('SIGINT') are disabled during script execution, but continue to work after that. Default: false.
  • Returns: <Promise> Fulfills with undefined upon success.

Evaluate the module.

This must be called after the module has been linked; otherwise it will reject. It could be called also when the module has already been evaluated, in which case it will either do nothing if the initial evaluation ended in success (module.status is 'evaluated') or it will re-throw the exception that the initial evaluation resulted in (module.status is 'errored').

This method cannot be called while the module is being evaluated (module.status is 'evaluating').

Corresponds to the Evaluate() concrete method field of Cyclic Module Records in the ECMAScript specification.