温馨提示:本站仅提供公开网络链接索引服务,不存储、不篡改任何第三方内容,所有内容版权归原作者所有
AI智能索引来源:http://www.bun.com/reference/bun/%24/ShellPromise/catch
点击访问原文链接

ShellPromise.catch method | Bun module | Bun

ShellPromise.catch method | Bun module | BunBuildDocsReferenceGuidesBlogDiscord/Bun/$/ShellPromise/catchMcatch

Search the reference...

/

BuildDocsReferenceGuidesBlogDiscord/Bun/$/ShellPromise/catchMcatch

method

$.ShellPromise.catchcatchTResult = never>(onrejected?: null | (reason: any) => TResult | PromiseLikeTResult>): PromiseShellOutput | TResult>;

Attaches a callback for only the rejection of the Promise.

@param onrejected

The callback to execute when the Promise is rejected.

@returns

A Promise for the completion of the callback.

Referenced typesinterface ShellOutputreadonly exitCode: numberreadonly stderr: Bufferreadonly stdout: BufferarrayBuffer(): ArrayBuffer;

Read from stdout as an ArrayBuffer

@returns

Stdout as an ArrayBuffer

const output = await $`echo hello`;
console.log(output.arrayBuffer()); // ArrayBuffer { byteLength: 6 }
blob(): Blob;

Read from stdout as a Blob

@returns

Stdout as a blob

const output = await $`echo hello`;
console.log(output.blob()); // Blob { size: 6, type: "" }
bytes(): Uint8ArrayArrayBuffer>;

Read from stdout as an Uint8Array

@returns

Stdout as an Uint8Array

const output = await $`echo hello`;
console.log(output.bytes()); // Uint8Array { byteLength: 6 }
json(): any;

Read from stdout as a JSON object

@returns

Stdout as a JSON object

const output = await $`echo '{"hello": 123}'`;
console.log(output.json()); // { hello: 123 }
text(encoding?: BufferEncoding): string;

Read from stdout as a string

@param encoding

The encoding to use when decoding the output

@returns

Stdout as a string with the given encoding

Read as UTF-8 string

const output = await $`echo hello`;
console.log(output.text()); // "hello\n"

Read as base64 string

const output = await $`echo ${atob("hello")}`;
console.log(output.text("base64")); // "hello\n"

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 →

ShellPromise.catch method | Bun module | Bun,AI智能索引,全网链接索引,智能导航,网页索引

    API documentation for method bun.$.ShellPromise.catch | Bun