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

interface Console | globals module | Bun

interface Console | globals module | BunBuildDocsReferenceGuidesBlogDiscord/Globals/ConsoleM[Symbol.asyncIterator]MassertMclearPConsoleMcountMcountResetMdebugMdirMdirxmlMerrorMgroupMgroupCollapsedMgroupEndMinfoMlogMprofileMprofileEndMtableMtimeMtimeEndMtimeLogMtimeStampMtraceMwarnMwrite

Search the reference...

/

BuildDocsReferenceGuidesBlogDiscord/Globals/ConsoleM[Symbol.asyncIterator]MassertMclearPConsoleMcountMcountResetMdebugMdirMdirxmlMerrorMgroupMgroupCollapsedMgroupEndMinfoMlogMprofileMprofileEndMtableMtimeMtimeEndMtimeLogMtimeStampMtraceMwarnMwrite

interface

Consoleinterface Consolereadonly Console: {new (stdout: WritableStream, stderr?: WritableStream, ignoreErrors?: boolean) => Console; new (options: ConsoleOptions) => Console}[Symbol.asyncIterator](): AsyncIterableIteratorstring>;

Asynchronously read lines from standard input (fd 0)

for await (const line of console) {
console.log(line);
}
assert(condition?: boolean,...data: any[]): void;clear(): void;

Clear the console

count(label?: string): void;@param label

label counter

countReset(label?: string): void;debug(...data: any[]): void;dir(item?: any,options?: any): void;dirxml(...data: any[]): void;error(...data: any[]): void;

Log to stderr in your terminal

Appears in red

@param data

something to display

group(...data: any[]): void;

Does nothing currently

groupCollapsed(...data: any[]): void;

Does nothing currently

groupEnd(): void;

Does nothing currently

info(...data: any[]): void;log(...data: any[]): void;profile(label?: string): void;

This method does not display anything unless used in the inspector. The console.profile() method starts a JavaScript CPU profile with an optional label until profileEnd is called. The profile is then added to the Profile panel of the inspector.

console.profile('MyLabel');
// Some code
console.profileEnd('MyLabel');
// Adds the profile 'MyLabel' to the Profiles panel of the inspector.
profileEnd(label?: string): void;

This method does not display anything unless used in the inspector. Stops the current JavaScript CPU profiling session if one has been started and prints the report to the Profiles panel of the inspector. See profile for an example.

If this method is called without a label, the most recently started profile is stopped.

table(tabularData?: any,properties?: string[]): void;

Try to construct a table with the columns of the properties of tabularData (or use properties) and rows of tabularData and log it. Falls back to just logging the argument if it can't be parsed as tabular.

// These can't be parsed as tabular data
console.table(Symbol());
// Symbol()

console.table(undefined);
// undefined

console.table([{ a: 1, b: 'Y' }, { a: 'Z', b: 2 }]);
// ┌────┬─────┬─────┐
// │ │ a │ b │
// ├────┼─────┼─────┤
// │ 0 │ 1 │ 'Y' │
// │ 1 │ 'Z' │ 2 │
// └────┴─────┴─────┘

console.table([{ a: 1, b: 'Y' }, { a: 'Z', b: 2 }], ['a']);
// ┌────┬─────┐
// │ │ a │
// ├────┼─────┤
// │ 0 │ 1 │
// │ 1 │ 'Z' │
// └────┴─────┘
@param properties

Alternate properties for constructing the table.

time(label?: string): void;

Begin a timer to log with console.timeEnd

@param label

The label to use for the timer

 console.time("how long????");
for (let i = 0; i 999999; i++) {
// do stuff
let x = i * i;
}
console.timeEnd("how long????");
timeEnd(label?: string): void;

End a timer to log with console.time

@param label

The label to use for the timer

 console.time("how long????");
for (let i = 0; i 999999; i++) {
// do stuff
let x = i * i;
}
console.timeEnd("how long????");
timeLog(label?: string,...data: any[]): void;timeStamp(label?: string): void;trace(...data: any[]): void;warn(...data: any[]): void;write(...data: string | ArrayBuffer | ArrayBufferViewArrayBufferLike>[]): number;

Write text or bytes to stdout

Unlike console.log, this does no formatting and doesn't add a newline or spaces between arguments. You can pass it strings or bytes or any combination of the two.

console.write("hello world!", "\n"); // "hello world\n"
@param data

The data to write

@returns

The number of bytes written

This function is not available in the browser.

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 →

interface Console | globals module | Bun,AI智能索引,全网链接索引,智能导航,网页索引

    [MDN Reference](https://developer.mozilla.org/docs/Web/API/console)