New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

esprintf

Package Overview
Dependencies
Maintainers
1
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

esprintf

Enhanced sprintf implementation with lots of extras

  • 1.3.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
1
decreased by-93.75%
Maintainers
1
Weekly downloads
 
Created
Source

esprintf

NPM

Build Status Dependencies Coverage Status npm version

Requirements & Installation

Just run npm install esprintf

Usage

The following formatters are supported:

  • b Binary
  • d & i Decimial
  • u Unsigned int
  • o Octal
  • x Lowercase hexadecimal
  • X Uppercase hexadecimal
  • f Floating point number using locale
  • F Floating point number
  • e Expontential representation using locale
  • E Expontential representation
  • g Shortest of both f and e
  • G Shortest of both F and E
  • a Lowercase hexadecimal floating point
  • A Uppercase hexadecimal floating point
  • c Character
  • s String
  • j JSON

All regular sprintf operations are supported:

  • Padding/Truncation length and content specification
  • Dynamic length and precision
  • Forced prefix/sign
  • Left justification

Furthermore this function supports index based and associative replacement:

Please see the tests for more info.

Please note that mixing regular and index based replacement is possible but NOT recommended as it's messy, mixing regular or index based with associate replacement is NOT possible.

JSON formatting special:

I added JSON formatting for convenience reasons(because I could), in order to use prettyfied json you need to pass the padding specifier eg.

console.log(esprintf('%\'\tj', {
	hello: 'world'
}));

Will result in:

{
	"hello":	"world"
}

It also supports template strings:

esprintf`%.2${42.4242}f`;

Will result in:

42.42

Keywords

FAQs

Package last updated on 06 Mar 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc