
Security News
The Hidden Blast Radius of the Axios Compromise
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.
console.dir
Advanced tools
An enhanced console.dir method for beautiful object printing in browsers and Node.js with perfect support for Chinese characters.
console.dir methodnpm install console.dir
// Enhance console.dir automatically
require('console.dir');
const data = {
name: 'Zhang San',
age: 25,
city: 'Beijing',
skills: ['JavaScript', 'TypeScript'],
address: {
street: '123 Main St',
country: 'China'
}
};
console.dir(data);
import 'console.dir'; // Automatically enhances console object
interface User {
name: string;
age: number;
city: string;
skills: string[];
address: {
street: string;
country: string;
}
}
const data: User = {
name: 'Zhang San',
age: 25,
city: 'Beijing',
skills: ['JavaScript', 'TypeScript'],
address: {
street: '123 Main St',
country: 'China'
}
};
console.dir(data);
<!-- Include UMD version -->
<script src="node_modules/console.dir/dist/index.js"></script>
<script>
const data = {
name: 'John',
age: 30,
city: 'New York',
hobbies: ['Reading', 'Swimming'],
contact: {
email: 'john@example.com',
phone: '123-456-7890'
}
};
console.dir(data);
</script>
import 'console.dir';
const data = {
name: 'John',
age: 30,
city: 'New York',
hobbies: ['Reading', 'Swimming'],
contact: {
email: 'john@example.com',
phone: '123-456-7890'
}
};
console.dir(data);
The enhanced console.dir method provides beautifully formatted output for objects and arrays with proper indentation:
{
name: "Zhang San"
age: 25
city: "Beijing"
skills: Array(2) [
0: "JavaScript"
1: "TypeScript"
]
address: {
street: "123 Main St"
country: "China"
}
}
Gracefully handles circular references without causing infinite loops:
const obj = { name: 'Test' };
obj.self = obj;
console.dir(obj);
// Output:
// {
// name: "Test"
// self: [Circular Reference]
// }
Properly formats special JavaScript values:
null and undefined[Function]This package enhances the native console.dir method to provide better visualization of JavaScript objects. For simple values (strings, numbers, etc.), it falls back to the native implementation. For objects and arrays, it provides a beautifully formatted output with proper indentation.
The enhanced method:
console.dir functionalityEnhanced version of the native console.dir method.
data - The data to displayoptions - Options for display (reserved for future use)For non-object data types (strings, numbers, booleans, etc.), the native implementation is used. For objects and arrays, the enhanced formatting is applied.
const user = {
name: 'Alice',
age: 30,
active: true
};
console.dir(user);
// Output:
// {
// name: "Alice"
// age: 30
// active: true
// }
const company = {
name: 'Tech Corp',
founded: 2010,
employees: [
{ name: '张三', position: 'Developer' },
{ name: '李四', position: 'Designer' }
],
address: {
city: '北京',
country: 'China'
}
};
console.dir(company);
// Output:
// {
// name: "Tech Corp"
// founded: 2010
// employees: Array(2) [
// 0: {
// name: "张三"
// position: "Developer"
// }
// 1: {
// name: "李四"
// position: "Designer"
// }
// ]
// address: {
// city: "北京"
// country: "China"
// }
// }
const products = [
{ name: 'Laptop', price: 1200 },
{ name: 'Mouse', price: 25 }
];
console.dir(products);
// Output:
// Array(2) [
// 0: {
// name: "Laptop"
// price: 1200
// }
// 1: {
// name: "Mouse"
// price: 25
// }
// ]
The package works in all modern browsers that support:
console.logThe package works in Node.js versions that support:
console.logFull TypeScript support is provided with type definitions included. No additional typings need to be installed.
git checkout -b my-new-featuregit commit -am 'Add some feature'git push origin my-new-featureFAQs
Enhanced console.dir for beautiful object printing in browsers and Node.js
We found that console.dir demonstrated a healthy version release cadence and project activity because the last version was released less than a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Security News
The Axios compromise shows how time-dependent dependency resolution makes exposure harder to detect and contain.

Research
A supply chain attack on Axios introduced a malicious dependency, plain-crypto-js@4.2.1, published minutes earlier and absent from the project’s GitHub releases.

Research
Malicious versions of the Telnyx Python SDK on PyPI delivered credential-stealing malware via a multi-stage supply chain attack.