Skip to content

docs: correct %d and document %f in the formatters table - #1053

Open
FirmaSpring wants to merge 1 commit into
debug-js:masterfrom
FirmaSpring:docs/formatters-table
Open

docs: correct %d and document %f in the formatters table#1053
FirmaSpring wants to merge 1 commit into
debug-js:masterfrom
FirmaSpring:docs/formatters-table

Conversation

@FirmaSpring

Copy link
Copy Markdown

Problem

The formatters table documents %d as "Number (both integer and float)". That is inaccurate and matches issue #913, where a float passed to %d is truncated: in Node.js the log call goes through util.formatWithOptions (see src/node.js log()), whose %d is printf-style integer formatting. The table also omits %f, which util.format supports for floats.

Solution

  • Describe %d as integer formatting (floats truncated toward zero).
  • Add a %f row for floating-point numbers.

Node example confirming current behavior:

const createDebug = require('./src/node')('t');
createDebug.log = (...a) => console.log(require('util').formatWithOptions({}, ...a));
createDebug('int %d float %f', 3.7, 3.7); // int 3 float 3.7

Verification

  • %d / %f behavior verified against util.format() on current Node.js.
  • No code change; documentation only.

Co-authored-by: FirmamentalSpring <287222957+FirmaSpring@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Development

Successfully merging this pull request may close these issues.

1 participant