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

cjs-format

Package Overview
Dependencies
Maintainers
2
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

cjs-format

String substitution according to the given format.

  • 1.4.2
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
29
increased by81.25%
Maintainers
2
Weekly downloads
 
Created
Source

String substitution according to the given format

build status npm version dependencies status devDependencies status Gitter RunKit

Simplified speed-oriented JavaScript equivalent of the C/PHP sprintf function.

Installation

npm install cjs-format

Usage

Add to the scope:

var format = require('cjs-format');

Simple replacement:

// This is a cat
console.log(format('This is a {0}', 'cat'));

Multiple replacement:

// This is a cat and a dog
console.log(format('This is a {0} and a {1}', 'cat', 'dog'));

Replacement with changed order:

// This is a cat and a dog and another cat
console.log(format('This is a {0} and a {1} and another {0}', 'cat', 'dog'));

Development mode

There is a global var DEVELOP which activates additional consistency checks and protection logic not available in release mode.

Contribution

If you have any problems or suggestions please open an issue according to the contribution rules.

License

cjs-format is released under the MIT License.

Keywords

FAQs

Package last updated on 04 Aug 2018

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