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
Advanced tools
Solves a problem with util.format
var format = require('quick-format')
var options = {lowres: false} // <--default
format(['hello %s %j %d', 'world', {obj: true}, 4, {another: 'obj'}], options)
Passing an options object with lowres: true
will cause quick-format any object with a circular as a string with the value '"[Circular]"'. The default behaviour is to label
circular references in an object, instead of abandoning the entire object. Naturally,
lowres
is a faster mode, and assumes you have made the decision to ensure the objects
you're passing have no circular references.
We use JSON.stringify
instead of util.inspect
, this means object
methods (functions) will not be serialized.
In util.format
for Node 5.9, performance is significantly affected
when we pass in more arguments than interpolation characters, e.g
util.format('hello %s %j %d', 'world', {obj: true}, 4, {another: 'obj'})
This is mostly due to the use of util.inspect
. Use JSON.stringify
(safely) instead which is significantly faster.
It also takes an array instead of arguments, which helps us
avoid the use of apply
in some cases.
Also - for speed purposes, we ignore symbol.
Whilst exact matching of objects to interpolation characters is slower,
the case of additional objects is 3x faster. Further, using lowres
mode
brings us closer to util.inspect
speeds.
util*100000: 205.978ms
quickLowres*100000: 236.337ms
quick*100000: 292.018ms
utilWithTailObj*100000: 1054.592ms
quickWithTailObjLowres*100000: 267.992ms
quickWithTailObj*100000: 343.048ms
util*100000: 212.011ms
quickLowres*100000: 226.441ms
quick*100000: 296.600ms
utilWithTailObj*100000: 1020.195ms
quickWithTailObjLowres*100000: 267.331ms
quickWithTailObj*100000: 343.867ms
Sponsored by nearForm
FAQs
Solves a problem with util.format
The npm package quick-format receives a total of 28 weekly downloads. As such, quick-format popularity was classified as not popular.
We found that quick-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
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.