0console

中文文档
0.0.1发布于 2022/03/06MITCommonJS

Patched console functions with improved output.

原始使用文档

✒️ 0console

NPM version

Simple patched console functions with improved output.

Screenshot

📥 Install

npm i 0console

🏁 Use

With patched console object:

require("0console").patch();

console.log("Hello World!");
console.log("Highlighted", "Hello World!");

Without patching the console object:

const $console = require("0console");

$console.log("Hello World!");
$console.log("Highlighted", "Hello World!");

⚙️ Functions

  • console.log(...args) : Writes a normal message.
  • console.info(...args) : Writes an information message.
  • console.warn(...args) : Writes a warning message.
  • console.error(...args) : Writes an error message.
  • console.clear(...args) : Clears the output (Unlike the original).
  • 🆕 console.success(...args) : Writes a success message.
  • 🆕 console.line(char?, color?, count?) : Writes an horizontal line.
    • char : text to repeat (one character).
    • color : text color in the console (Using Chalk).
    • count : times to repeat char (Length of the line).

💡 If a logging function (log, info, warn, error, success) has more than one argument, the text of the first argument will be highlighted in the console.

⚙️ Craft Function

You can craft your own custom function:

const $console = require("0console");

const newConsoleInfo = $console.craft(console.info, {
  prefix: { text: "?", color: "cyanBright", bgColor: "bgBlueBright" },
  highlight: { color: "blueBright" },
  normal: { color: "blueBright" },
});
  • console.craft(fn, options?) : Crafts a patched version of the given console function.
    • fn : Console function to craft from.
    • options : Options object.
      • prefix : Object describing the prefix text.
        • text: Text of the prefix.
        • color: Color of the prefix.
        • bgColor: Background color of the prefix.
      • highlight : Object describing the highlighted text of the first argument.
        • color: Color of the highlighted text.
      • normal : Object describing the normal text.
        • color: Color of the normal text.

📃 License

MIT © Ambratolm

版本与发布记录

0console 共发布 1 个版本,首次发布于 2022/03/06;过去 12 个月发布了 0 个版本。

版本发布日期距今
0.0.1latest2022/03/064 年前

关于 0console 的常见问题

0console 是什么?

修复控制台功能,改善输出。

如何安装 0console?

在项目目录运行 npm install 0console,或使用 pnpm add / yarn add / bun add。

0console 支持 TypeScript 吗?

该包的 package.json 没有声明类型入口。需要类型提示时,可以在 npm 上查找社区维护的 @types/0console 是否存在。

0console 支持 ESM 还是 CommonJS?

以 CommonJS 形式发布,可以直接 require();在 ES Module 项目中也可以用 import 引入(Node.js 会把 module.exports 作为默认导出)。

0console 可以商用吗?

0console 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

0console 还在维护吗?

最新版本 0.0.1 发布于 2022/03/06(4 年前);至今共发布 1 个版本,其中过去 12 个月发布了 0 个;首次发布于 2022/03/06。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。