Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

quick-format

Package Overview
Dependencies
Maintainers
1
Versions
10
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

quick-format

Solves a problem with util.format in <= Node 5.9

  • 1.0.1
  • Source
  • npm
  • Socket score

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

quick format

Solves a problem with util.format in <= Node 5.9

usage

var format = require('quick-format')
format(['hello %s %j %d', 'world', {obj: true}, 4, {another: 'obj'}])

util.format

In util.format for Node 5.9, performance is significantly affected when we pass in more arguments than interpolation characters, e.g

util.format('hello %s %j %d', 'world', {obj: true}, 4, {another: 'obj'})

This is mostly due to the use of util.inspect. Use JSON.stringify (safely) instead which is significantly faster.

It also takes an array instead of arguments, which helps us avoid the use of apply in some cases.

Also - for speed purposes, we ignore symbol.

Benchmarks

Benchmarks are very marginally slower than 5.9 util.format when there is no "tail" arguments,

util*50000: 112.749ms
quick*50000: 118.393ms
utilWithTailObj*50000: 517.232ms
quickWithTailObj*50000: 141.821ms
util*50000: 111.217ms
quick*50000: 117.432ms
utilWithTailObj*50000: 504.271ms
quickWithTailObj*50000: 142.759ms

Acknowledgements

Sponsored by nearForm

FAQs

Package last updated on 19 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