Research
Security News
Malicious npm Package Targets Solana Developers and Hijacks Funds
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Minimalist mustache template replacement. Works extremely fast on one-off replacements and doesn't escape any values.
$ npm install maxstache
const maxstache = require('maxstache')
const str = 'My name is {{name}}'
const ctx = { name: 'jjjohnny' }
maxstache(str, ctx)
// => 'My name is jjjohnny'
Replace {{<var>}}
style variables in a string with values from a context.
Variable replacement doesn't escape values.
minstache
was built as a minimalist replacement for mustache
, but is
unfortunately no longer maintained. This package is built as a smaller, faster
alternative to minstache
that makes no assumptions about the file types (e.g.
no HTML-style escaping by default).
Template string escaping is useful for more than HTML. When building templates for a variety of languages, escaping assumptions merely get in the way. If you want to escape values, it's easy to pass the string result through an escape function or escape the variable values before passing them into this function. Hurray for composition!
Sure thing:
module.exports = function maxstache (str, ctx) {
return str.split(/\{\{|\}\}/).map((t, i) => !(i % 2) ? t : ctx[t]).join('')
}
:rotating_light: CODE GOLF :rotating_light: Shout out to @divinegod and @someoneweird for thinking of ways to do this in less lines (hint: I don't think it can).
FAQs
Minimalist mustache template replacement
The npm package maxstache receives a total of 141,600 weekly downloads. As such, maxstache popularity was classified as popular.
We found that maxstache 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.
Research
Security News
A malicious npm package targets Solana developers, rerouting funds in 2% of transactions to a hardcoded address.
Security News
Research
Socket researchers have discovered malicious npm packages targeting crypto developers, stealing credentials and wallet data using spyware delivered through typosquats of popular cryptographic libraries.
Security News
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.