php sprint 补0,sprint-JavaScript中文网-JavaScript教程资源分享门户

Complex sprintf() implementation

52e41f175983192e3c9d557e0d7ab53c.png

sprint is implementation of sprintf function from C++. If it is ran in

Node.js envirnoment then it's used as module, otherwise module inserts

sprint() function into global object (usually window).

Usage:

// Node.js

var sprint = require('sprint');

// Will return "b a"

console.log(sprint('%2$s %1$s', 'a', 'b'));

All standard format placeholders are supported with the exception of %p

(lack of pointers in JavaScript) and %n (lack of references in JavaScript).

In addition, following non-standard features are supported:

n$ - number of the parameter allowing the parameters to be used multiple

times or displayed in different order. It's not in C99, but it's POSIX

entension, so support for it is already common.

%b and %B - a binary number

%D, %U, %O - practially their lowercase variants. Inserted in this

list just because of their usage in Perl's printf() implementation.

%v - vectors (from Perl implementation of sprintf())

For more information, read documentation of sprintf() in other programming

languages.

If certain feature doesn't exist and you think it should exist, feel free to

make issue about it. Unless it's

impossible to implement it, you can expect it in next major release.

And last thing before I will end this README file, have fun!

HomePage

Repository

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值