包详细信息

cli-sprintf-format

medikoo3.6mISC1.1.1

sprintf formatting targetted for CLI

printf, sprintf, log, format

自述文件

Build status Tests coverage npm version

cli-sprintf-format

CLI dedicated sprintf formatter

An improved version of util.formatWithOptions

  • Provides more reliable type resolution and error handling
  • Detects color support (via supports-color)
  • Ensures colored (if supported) output not only for the inspected objects but also for primitive vaulues
  • Colored JSON (%j) formatting
  • Object inspection depth defaults to 4, but can be overriden via FORMAT_INSPECT_DEPTH environment variable
  • For %s strings are passed through inspect formatter therefore appear colored (if supported) and eventual multiline content appears inline. To escape that behavior %#s should be used instead

Installation

npm install cli-sprintf-format

Usage

const cliFormat = require("cli-sprintf-format");

console.log(cliFormat("Some %s with %d count", "foo", 12)); // Some foo with 12 count

Tests

npm test

更新日志

Changelog

All notable changes to this project will be documented in this file. See standard-version for commit guidelines.

1.1.1 (2021-12-21)

Bug Fixes

  • Ensure same literals output in Node.js v12+ versions (835ff8f)

Maintenance Improvements

  • Upgrade cli-color to v2 (94a420f)
  • Upgrade supports-color to v6 (0d68980)

1.1.0 (2018-10-02)

Features

  • support pass through of raw string not modified (5988a40)

1.0.0 (2018-09-28)