module.evaluate([options])
评估模块。
必须在模块链接后调用,否则会拒绝。
当模块已经被评估时,它也可以被调用,在这种情况下,如果初始评估成功结束(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, anError
will be thrown. This value must be a strictly positive integer.breakOnSigint
<boolean> Iftrue
, receivingSIGINT
(Ctrl+C) will terminate execution and throw anError
. Existing handlers for the event that have been attached viaprocess.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.