Back to Puppeteer

WebWorker.evaluateHandle() method

docs/api/puppeteer.webworker.evaluatehandle.md

19.2.21.2 KB
Original Source

WebWorker.evaluateHandle() method

Evaluates a given function in the worker.

Signature

typescript
class WebWorker {
  evaluateHandle<
    Params extends unknown[],
    Func extends EvaluateFunc<Params> = EvaluateFunc<Params>,
  >(
    func: Func | string,
    ...args: Params
  ): Promise<HandleFor<Awaited<ReturnType<Func>>>>;
}

Parameters

<table><thead><tr><th>

Parameter

</th><th>

Type

</th><th>

Description

</th></tr></thead> <tbody><tr><td>

func

</td><td>

Func | string

</td><td>

Function to be evaluated.

</td></tr> <tr><td>

args

</td><td>

Params

</td><td>

Arguments to pass into func.

</td></tr> </tbody></table>

Returns:

Promise<HandleFor<Awaited<ReturnType<Func>>>>

A handle to the return value of func.

Remarks

If the given function returns a promise, evaluate will wait for the promise to resolve.

In general, you should use evaluateHandle if evaluate cannot serialize the return value properly or you need a mutable handle to the return object.