FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

docs: correct %d and document %f in the formatters table by FirmaSpring · Pull Request #1053 · debug-js/debug · GitHub

/ debug Public

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

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>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
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


Back | FazBrowse Home | New Git URL