puppeteer/assets/js/013051ac.a9f24789.js

2 lines
4.9 KiB
JavaScript
Raw Normal View History

/*! For license information please see 013051ac.a9f24789.js.LICENSE.txt */
"use strict";(self.webpackChunkwebsite=self.webpackChunkwebsite||[]).push([[26787],{35876:(e,r,t)=>{t.r(r),t.d(r,{assets:()=>d,contentTitle:()=>s,default:()=>u,frontMatter:()=>o,metadata:()=>l,toc:()=>i});var n=t(85893),a=t(11151);const o={sidebar_label:"WebWorker.evaluateHandle"},s="WebWorker.evaluateHandle() method",l={id:"api/puppeteer.webworker.evaluatehandle",title:"WebWorker.evaluateHandle() method",description:"The only difference between worker.evaluate and worker.evaluateHandle is that worker.evaluateHandle returns in-page object (JSHandle). If the function passed to the worker.evaluateHandle returns a Promise, then worker.evaluateHandle would wait for the promise to resolve and return its value. Shortcut for await worker.executionContext()).evaluateHandle(pageFunction, ...args)",source:"@site/../docs/api/puppeteer.webworker.evaluatehandle.md",sourceDirName:"api",slug:"/api/puppeteer.webworker.evaluatehandle",permalink:"/next/api/puppeteer.webworker.evaluatehandle",draft:!1,unlisted:!1,tags:[],version:"current",frontMatter:{sidebar_label:"WebWorker.evaluateHandle"},sidebar:"api",previous:{title:"WebWorker.evaluate",permalink:"/next/api/puppeteer.webworker.evaluate"},next:{title:"WebWorker.url",permalink:"/next/api/puppeteer.webworker.url"}},d={},i=[{value:"Signature:",id:"signature",level:4},{value:"Parameters",id:"parameters",level:2}];function c(e){const r={a:"a",code:"code",h1:"h1",h2:"h2",h4:"h4",p:"p",pre:"pre",strong:"strong",table:"table",tbody:"tbody",td:"td",th:"th",thead:"thead",tr:"tr",...(0,a.a)(),...e.components};return(0,n.jsxs)(n.Fragment,{children:[(0,n.jsx)(r.h1,{id:"webworkerevaluatehandle-method",children:"WebWorker.evaluateHandle() method"}),"\n",(0,n.jsxs)(r.p,{children:["The only difference between ",(0,n.jsx)(r.code,{children:"worker.evaluate"})," and ",(0,n.jsx)(r.code,{children:"worker.evaluateHandle"})," is that ",(0,n.jsx)(r.code,{children:"worker.evaluateHandle"})," returns in-page object (JSHandle). If the function passed to the ",(0,n.jsx)(r.code,{children:"worker.evaluateHandle"})," returns a ",(0,n.jsx)(r.code,{children:"Promise"}),", then ",(0,n.jsx)(r.code,{children:"worker.evaluateHandle"})," would wait for the promise to resolve and return its value. Shortcut for ",(0,n.jsx)(r.code,{children:"await worker.executionContext()).evaluateHandle(pageFunction, ...args)"})]}),"\n",(0,n.jsx)(r.h4,{id:"signature",children:"Signature:"}),"\n",(0,n.jsx)(r.pre,{children:(0,n.jsx)(r.code,{className:"language-typescript",children:"class WebWorker {\n evaluateHandle<\n Params extends unknown[],\n Func extends EvaluateFunc<Params> = EvaluateFunc<Params>,\n >(\n pageFunction: Func | string,\n ...args: Params\n ): Promise<HandleFor<Awaited<ReturnType<Func>>>>;\n}\n"})}),"\n",(0,n.jsx)(r.h2,{id:"parameters",children:"Parameters"}),"\n",(0,n.jsxs)(r.table,{children:[(0,n.jsx)(r.thead,{children:(0,n.jsxs)(r.tr,{children:[(0,n.jsx)(r.th,{children:"Parameter"}),(0,n.jsx)(r.th,{children:"Type"}),(0,n.jsx)(r.th,{children:"Description"})]})}),(0,n.jsxs)(r.tbody,{children:[(0,n.jsxs)(r.tr,{children:[(0,n.jsx)(r.td,{children:"pageFunction"}),(0,n.jsx)(r.td,{children:"Func | string"}),(0,n.jsx)(r.td,{children:"Function to be evaluated in the page context."})]}),(0,n.jsxs)(r.tr,{children:[(0,n.jsx)(r.td,{children:"args"}),(0,n.jsx)(r.td,{children:"Params"}),(0,n.jsxs)(r.td,{children:["Arguments to pass to ",(0,n.jsx)("code",{children:"pageFunction"}),"."]})]})]})]}),"\n",(0,n.jsx)(r.p,{children:(0,n.jsx)(r.strong,{children:"Returns:"})}),"\n",(0,n.jsxs)(r.p,{children:["Promise<",(0,n.jsx)(r.a,{href:"/next/api/puppeteer.handlefor",children:"HandleFor"}),"<Awaited<ReturnType<Func>>>>"]}),"\n",(0,n.jsxs)(r.p,{children:["Promise which resolves to the return value of ",(0,n.jsx)(r.code,{children:"pageFunction"}),"."]})]})}function u(e={}){const{wrapper:r}={...(0,a.a)(),...e.components};return r?(0,n.jsx)(r,{...e,children:(0,n.jsx)(c,{...e})}):c(e)}},75251:(e,r,t)=>{var n=t(67294),a=Symbol.for("react.element"),o=Symbol.for("react.fragment"),s=Object.prototype.hasOwnProperty,l=n.__SECRET_INTERNALS_