Security News
The Unpaid Backbone of Open Source: Solo Maintainers Face Increasing Security Demands
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
fast-format
Advanced tools
This is a string formatter like util.format()
method in Node.js, supports just only %s
placeholder but accordingly faster than that. It will be one of the best solution if need a speed rather than complex formatting.
Same as util.format()
method.
format(formatString[, ...])
If use one formatting repeatedly, recommended to compile the formatString
in advance.
format.compile(formatString)
let s = format('%s, %s!', 'Hello', 'world');
console.log(s); // => 'Hello, world!'
let f = format.compile('%s, %s!');
let s1 = f('Hello', 'world');
console.log(s1); // => 'Hello, world!'
let s2 = f('Howdy', 'World');
console.log(s2); // => 'Howdy, World!'
// Bench 1
let s = Date.now();
for (let i = 0, len = 100000000; i < len; i++) {
format('i = %s, len = %s', i, len);
}
console.log(Date.now() - s);
// Bench 2
let s = Date.now();
let f = format.compile('i = %s, len = %s');
for (let i = 0, len = 100000000; i < len; i++) {
f(i, len);
}
console.log(Date.now() - s);
environment1: Core i7 2.2GHz + Node.js v6.9.5
module | time | bench |
---|---|---|
fast-format | 12,388 msec | 2 |
fast-format | 22,039 msec | 1 |
util.format | 28,659 msec | 1 |
environment2: Core i7 2.2GHz + Google Chrome 56.0.2924.87
module | time | bench |
---|---|---|
fast-format | 12,898 msec | 2 |
fast-format | 22,705 msec | 1 |
util.format | 99,103 msec | 1 |
The util.format()
method was converted with Browserify
to run on the browser.
npm install fast-format --save
bower install fast-format
<script src="/path/to/fast-format.min.js"></script>
Google Chrome, Firefox, Safari, Opera, Microsoft Edge and IE 6+
MIT
FAQs
A fast, simple string formatter like util.format() method in Node.js
The npm package fast-format receives a total of 23 weekly downloads. As such, fast-format popularity was classified as not popular.
We found that fast-format demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
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.
Security News
Solo open source maintainers face burnout and security challenges, with 60% unpaid and 60% considering quitting.
Security News
License exceptions modify the terms of open source licenses, impacting how software can be used, modified, and distributed. Developers should be aware of the legal implications of these exceptions.
Security News
A developer is accusing Tencent of violating the GPL by modifying a Python utility and changing its license to BSD, highlighting the importance of copyleft compliance.