puppeteer/assets/js/d89c87ad.6471d113.js
release-please[bot] d3364cba40 deploy: af6eba4bea
2023-12-15 12:13:30 +00:00

2 lines
5.2 KiB
JavaScript

/*! For license information please see d89c87ad.6471d113.js.LICENSE.txt */
"use strict";(self.webpackChunkwebsite=self.webpackChunkwebsite||[]).push([[99327],{60673:(e,r,t)=>{t.r(r),t.d(r,{assets:()=>l,contentTitle:()=>s,default:()=>u,frontMatter:()=>o,metadata:()=>i,toc:()=>d});var n=t(85893),a=t(11151);const o={sidebar_label:"WebWorker.evaluate"},s="WebWorker.evaluate() method",i={id:"api/puppeteer.webworker.evaluate",title:"WebWorker.evaluate() method",description:"If the function passed to the worker.evaluate returns a Promise, then worker.evaluate would wait for the promise to resolve and return its value. If the function passed to the worker.evaluate returns a non-serializable value, then worker.evaluate resolves to undefined. DevTools Protocol also supports transferring some additional values that are not serializable by JSON: -0, NaN, Infinity, -Infinity, and bigint literals. Shortcut for await worker.executionContext()).evaluate(pageFunction, ...args).",source:"@site/versioned_docs/version-21.6.1/api/puppeteer.webworker.evaluate.md",sourceDirName:"api",slug:"/api/puppeteer.webworker.evaluate",permalink:"/api/puppeteer.webworker.evaluate",draft:!1,unlisted:!1,tags:[],version:"21.6.1",frontMatter:{sidebar_label:"WebWorker.evaluate"},sidebar:"api",previous:{title:"WebWorker",permalink:"/api/puppeteer.webworker"},next:{title:"WebWorker.evaluateHandle",permalink:"/api/puppeteer.webworker.evaluatehandle"}},l={},d=[{value:"Signature:",id:"signature",level:4},{value:"Parameters",id:"parameters",level:2}];function c(e){const r={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:"webworkerevaluate-method",children:"WebWorker.evaluate() method"}),"\n",(0,n.jsxs)(r.p,{children:["If the function passed to the ",(0,n.jsx)(r.code,{children:"worker.evaluate"})," returns a Promise, then ",(0,n.jsx)(r.code,{children:"worker.evaluate"})," would wait for the promise to resolve and return its value. If the function passed to the ",(0,n.jsx)(r.code,{children:"worker.evaluate"})," returns a non-serializable value, then ",(0,n.jsx)(r.code,{children:"worker.evaluate"})," resolves to ",(0,n.jsx)(r.code,{children:"undefined"}),". DevTools Protocol also supports transferring some additional values that are not serializable by ",(0,n.jsx)(r.code,{children:"JSON"}),": ",(0,n.jsx)(r.code,{children:"-0"}),", ",(0,n.jsx)(r.code,{children:"NaN"}),", ",(0,n.jsx)(r.code,{children:"Infinity"}),", ",(0,n.jsx)(r.code,{children:"-Infinity"}),", and bigint literals. Shortcut for ",(0,n.jsx)(r.code,{children:"await worker.executionContext()).evaluate(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 evaluate<\n Params extends unknown[],\n Func extends EvaluateFunc<Params> = EvaluateFunc<Params>,\n >(\n pageFunction: Func | string,\n ...args: Params\n ): Promise<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 worker 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.jsx)(r.p,{children:"Promise<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,i=n.__SECRET_INTERNALS_DO_NOT_USE_OR_YOU_WILL_BE_FIRED.ReactCurrentOwner,l={key:!0,ref:!0,__self:!0,__source:!0};function d(e,r,t){var n,o={},d=null,c=null;for(n in void 0!==t&&(d=""+t),void 0!==r.key&&(d=""+r.key),void 0!==r.ref&&(c=r.ref),r)s.call(r,n)&&!l.hasOwnProperty(n)&&(o[n]=r[n]);if(e&&e.defaultProps)for(n in r=e.defaultProps)void 0===o[n]&&(o[n]=r[n]);return{$$typeof:a,type:e,key:d,ref:c,props:o,_owner:i.current}}r.Fragment=o,r.jsx=d,r.jsxs=d},85893:(e,r,t)=>{e.exports=t(75251)},11151:(e,r,t)=>{t.d(r,{Z:()=>i,a:()=>s});var n=t(67294);const a={},o=n.createContext(a);function s(e){const r=n.useContext(o);return n.useMemo((function(){return"function"==typeof e?e(r):{...r,...e}}),[r,e])}function i(e){let r;return r=e.disableParentContext?"function"==typeof e.components?e.components(a):e.components||a:s(e.components),n.createElement(o.Provider,{value:r},e.children)}}}]);