extsprintf
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|
"extsprintf" is a JavaScript package available on npm that presents a stripped-down version of s[n]printf(3c), adopting an extended POSIX-style sprintf function. In order to prevent the breakdown of existing programs, it provides a best-effort throw of an exception when confronted with an unrecognized format string, as opposed to simple ignorance. Its current feature set includes field alignment, zero padding, the forced display of numeric signs, field width, conversions for strings, decimal integers, and floats. The package also accepts but ignores argument size specifiers, given JavaScript's lack of acknowledgement for the physical size of an argument. Moreover, "extsprintf" supports the pretty-printing of JSON objects with %j
and Error Objects with %r
.
To use "extsprintf", you first need to install it through npm with npm install extsprintf
. After installation, a typical usage of the package is as follows:
var mod_extsprintf = require('extsprintf');
console.log(mod_extsprintf.sprintf('hello %25s', 'world'));
In the code snippet above, the sprintf
function is used to format a string, inserting the string 'world' into the format placeholder %25s. The output will be 'hello' followed by a number of spaces and then 'world'.
Additionally, "extsprintf" supports printf
and fprintf
, with the former taking the same arguments as sprintf
and printing the result to stdout, while the latter requires a Node stream as the first argument followed by the arguments of sprintf
, printing the results to the provided stream.
For detailed instructions, usage examples, and further information about the extsprintf package, you can visit the GitHub page at https://github.com/davepacheco/node-extsprintf. The repository's README file provides a meaningful overview for users and developers alike. As of now, there doesn't appear to be any standalone documentation aside from the README included on the GitHub project page.