Security News
RubyGems.org Adds New Maintainer Role
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
quick-format-unescaped
Advanced tools
The quick-format-unescaped npm package is a fast and efficient string formatting library. It is designed to handle unescaped string formatting, making it suitable for performance-critical applications where escaping is not required.
Basic String Formatting
This feature allows you to format strings by replacing placeholders with provided values. The `%s` placeholder is replaced with the string 'world'.
const format = require('quick-format-unescaped');
const result = format('Hello, %s!', 'world');
console.log(result); // Output: Hello, world!
Multiple Placeholders
This feature supports multiple placeholders in a single string. The `%s` and `%d` placeholders are replaced with 'Alice' and 30, respectively.
const format = require('quick-format-unescaped');
const result = format('%s is %d years old.', 'Alice', 30);
console.log(result); // Output: Alice is 30 years old.
Object Formatting
This feature allows you to format objects using the `%j` placeholder, which converts the object to a JSON string.
const format = require('quick-format-unescaped');
const user = { name: 'Bob', age: 25 };
const result = format('User: %j', user);
console.log(result); // Output: User: {"name":"Bob","age":25}
The 'util' package is a core Node.js module that provides various utility functions, including string formatting with `util.format()`. It is more versatile but may not be as fast as quick-format-unescaped for unescaped formatting.
The 'sprintf-js' package is a comprehensive string formatting library that supports a wide range of formatting options. It is more feature-rich but may be slower compared to quick-format-unescaped.
The 'fast-format' package is another high-performance string formatting library. It is similar in speed to quick-format-unescaped but may offer different API features and options.
Sometimes you want to embed the results of quick-format into another string, and then escape the whole string.
var format = require('quick-format-unescaped')
format('hello %s %j %d', ['world', [{obj: true}, 4, {another: 'obj'}]])
A printf
-like format string. Example: 'hello %s %j %d'
Array of values to be inserted into the format
string. Example: ['world', {obj:true}]
Passing an options object as the third parameter with a stringify
will mean
any objects will be passed to the supplied function instead of an the
internal tryStringify
function. This can be useful when using augmented
capability serializers such as fast-safe-stringify
or fast-redact
.
By default quick-format-unescaped
uses JSON.stringify
instead of util.inspect
, this means functions will not be serialized.
util*100000: 350.325ms
quick*100000: 268.141ms
utilWithTailObj*100000: 586.387ms
quickWithTailObj*100000: 280.200ms
util*100000: 325.735ms
quick*100000: 270.251ms
utilWithTailObj*100000: 492.270ms
quickWithTailObj*100000: 261.797ms
util*100000: 301.035ms
quick*100000: 217.005ms
utilWithTailObj*100000: 404.778ms
quickWithTailObj*100000: 236.176ms
util*100000: 286.349ms
quick*100000: 214.646ms
utilWithTailObj*100000: 388.574ms
quickWithTailObj*100000: 226.036ms
Sponsored by nearForm
FAQs
Solves a problem with util.format
The npm package quick-format-unescaped receives a total of 1,241,020 weekly downloads. As such, quick-format-unescaped popularity was classified as popular.
We found that quick-format-unescaped 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
RubyGems.org has added a new "maintainer" role that allows for publishing new versions of gems. This new permission type is aimed at improving security for gem owners and the service overall.
Security News
Node.js will be enforcing stricter semver-major PR policies a month before major releases to enhance stability and ensure reliable release candidates.
Security News
Research
Socket's threat research team has detected five malicious npm packages targeting Roblox developers, deploying malware to steal credentials and personal data.