Warning: SimpleXMLElement::asXML(E:\phpstudy_pro\zhutiblog\sitemaps\sitemap_107.xml.tmp): failed to open stream: Permission denied in E:\phpstudy_pro\zhutiblog\dd.php on line 1322
PromiseConstructor.try method | globals module | Bun - AI智能索引
温馨提示:本站仅提供公开网络链接索引服务,不存储、不篡改任何第三方内容,所有内容版权归原作者所有
AI智能索引来源:http://www.bun.com/reference/globals/PromiseConstructor/try
点击访问原文链接

PromiseConstructor.try method | globals module | Bun

PromiseConstructor.try method | globals module | BunBuildDocsReferenceGuidesBlogDiscord/Globals/PromiseConstructor/tryMtry

Search the reference...

/

BuildDocsReferenceGuidesBlogDiscord/Globals/PromiseConstructor/tryMtry

method

PromiseConstructor.trytryT, U extends unknown[]>(callbackFn: (...args: U) => T | PromiseLikeT>,...args: U): PromiseAwaitedT>>;

Takes a callback of any kind (returns or throws, synchronously or asynchronously) and wraps its result in a Promise.

@param callbackFn

A function that is called synchronously. It can do anything: either return a value, throw an error, or return a promise.

@param args

Additional arguments, that will be passed to the callback.

@returns

A Promise that is:

Already fulfilled, if the callback synchronously returns a value.Already rejected, if the callback synchronously throws an error.Asynchronously fulfilled or rejected, if the callback returns a promise.
tryT, A extends any[] = []>(fn: (...args: A) => T | PromiseLikeT>,...args: A): PromiseT>;

Try to run a function and return the result. If the function throws, return the result of the catch function.

@param fn

The function to run

@param args

The arguments to pass to the function. This is similar to setTimeout and avoids the extra closure.

@returns

The result of the function or the result of the catch function

Resources

ReferenceDocsGuidesDiscordMerch StoreGitHubBlog 

Toolkit

RuntimePackage managerTest runnerBundlerPackage runner

Project

Bun 1.0Bun 1.1Bun 1.2Bun 1.3RoadmapContributingLicense

Baked with ❤️ in San Francisco

We're hiring →

PromiseConstructor.try method | globals module | Bun,AI智能索引,全网链接索引,智能导航,网页索引

    API documentation for method globals.PromiseConstructor.try | Bun