cprintf

1.0.60 • Public • Published

cprintf

cprintf supported this env

  • nodejs
  • broswer
  • webchat app

install via npm

npm install cprintf --save

this lib include two functions

string sprintf(strFormat , ...);
void printf(strFormat , ...);

usage

// import function
const sprintf = require('cprintf').sprintf;
const printf = require('cprintf').printf;
 
// c-like printf
printf('hellp prinf %d\n' , 1 );
 
// c-like sprintf
var strText = sprintf('hellp prinf %d\n' , 1 );
printf( strText );
console.log( strText );
 
// direct printf a JSON object
var xxObj = {: 1 , b : 2};
printf( "%s" , xxObj);

support formats just like c printf and sprintf

  • %c -- ascii value
  • %d -- signed number
  • %s -- string
  • %x -- number in hex
  • %i -- signed number
  • %f -- float
  • %o -- octal number
  • %u -- unsigned number

Readme

Keywords

Package Sidebar

Install

npm i cprintf

Weekly Downloads

3

Version

1.0.60

License

MIT

Last publish

Collaborators

  • tinysec