mirror of
https://github.com/oven-sh/bun
synced 2026-02-12 03:48:56 +00:00
* feat(console-log): fix className not printed for objects that are instances of classes Uses getClassName native method instead of getName * test(console-log): objects with class names are printed correctly * test(esbuild): add class name to log message
109 lines
2.4 KiB
JavaScript
109 lines
2.4 KiB
JavaScript
console.log("Hello World!");
|
|
console.log(0);
|
|
console.log(-0);
|
|
console.log(123);
|
|
console.log(-123);
|
|
console.log(123.567);
|
|
console.log(-123.567);
|
|
console.log(true);
|
|
console.log(false);
|
|
console.log(null);
|
|
console.log(undefined);
|
|
console.log(Infinity);
|
|
console.log(-Infinity);
|
|
console.log(Symbol("Symbol Description"));
|
|
console.log(new Date(Math.pow(2, 34) * 56));
|
|
console.log([123, 456, 789]);
|
|
console.log({ name: "foo" });
|
|
console.log({ a: 123, b: 456, c: 789 });
|
|
console.log({
|
|
a: {
|
|
b: {
|
|
c: 123,
|
|
},
|
|
bacon: true,
|
|
},
|
|
name: "bar",
|
|
});
|
|
|
|
console.log(new Promise(() => {}));
|
|
|
|
class Foo {}
|
|
class FooWithProp {
|
|
a = 1;
|
|
}
|
|
|
|
console.log({});
|
|
console.log(() => {});
|
|
console.log(function () {});
|
|
console.log(Foo);
|
|
console.log(class {});
|
|
console.log(new Foo());
|
|
console.log(new FooWithProp());
|
|
console.log(function foooo() {});
|
|
|
|
console.log(/FooRegex/);
|
|
|
|
console.error("uh oh");
|
|
console.time("Check");
|
|
|
|
console.log("Is it a bug or a feature that formatting numbers like %d is colored", 123);
|
|
//console.log(globalThis);
|
|
|
|
console.log("String %s should be 2nd word, 456 == %s and percent s %s == %s", "123", "456", "%s", "What", "okay");
|
|
|
|
const infinteLoop = {
|
|
foo: {
|
|
name: "baz",
|
|
},
|
|
bar: {},
|
|
};
|
|
|
|
infinteLoop.bar = infinteLoop;
|
|
console.log(infinteLoop, "am");
|
|
|
|
console.log(new Array(4).fill({}));
|
|
const nestedObject = {
|
|
level1: {
|
|
level2: {
|
|
level3: {
|
|
level4: {
|
|
level5: {
|
|
name: "Deeply nested object",
|
|
},
|
|
},
|
|
},
|
|
},
|
|
},
|
|
};
|
|
console.log(nestedObject);
|
|
console.dir({ 1: { 2: { 3: 3 } } }, { depth: 0, colors: false }, "Some ignored arg");
|
|
console.dir({ 1: { 2: { 3: 3 } } }, { depth: -1, colors: false }, "Some ignored arg");
|
|
console.dir({ 1: { 2: { 3: 3 } } }, { depth: 1.2, colors: false }, "Some ignored arg");
|
|
console.dir({ 1: { 2: { 3: 3 } } }, { depth: Infinity, colors: false }, "Some ignored arg");
|
|
const set = new Set([1, "123", { a: [], str: "123123132", nr: 3453 }]);
|
|
console.log(set.keys());
|
|
console.log(set.values());
|
|
console.log(new Set().keys(), new Set().values());
|
|
const m = new Map([
|
|
["key", { a: [], str: "123123132", nr: 3453 }],
|
|
["key_2", { b: "test" }],
|
|
]);
|
|
console.log(m.keys());
|
|
console.log(m.values());
|
|
console.log(new Map().keys(), new Map().values());
|
|
class NestedClass {
|
|
a = 1;
|
|
b = 2;
|
|
foo = new FooWithProp();
|
|
test() {
|
|
return 3;
|
|
}
|
|
}
|
|
console.log(new NestedClass());
|
|
|
|
const objectWithStringTag = {
|
|
[Symbol.toStringTag]: "myCustomName",
|
|
};
|
|
console.log(objectWithStringTag);
|