
Research
/Security News
Weaponizing Discord for Command and Control Across npm, PyPI, and RubyGems.org
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
nunjucks-setasync
Advanced tools
Like set, but for async functions.
You can use this extension in the following 4 easy steps:
let env = new nunjucks.Environment();
env.addExtension('SetAsyncExtension', new SetAsyncExtension())
{% setAsync 'variable', functionName, [functionArguments] %}
variable
is the name of the variable that will hold the results of functionName
with [functionArguments]
. If the function functionName
does not take any arguments, you need to still pass an empty array {% setAsync 'variable', functionName, [] %}
.{{ variable }}
to render the value of variable
anywhere after the setAsync
block.In this example we are simulating getting the number of astronauts currently in space with an asynchronous function:
let getNumberOfAstronauts = function(cb) {
setTimeout(function() {
cb(null, 12);
}, 10);
}
env.addGlobal('getNumberOfAstronauts', getNumberOfAstronauts);
env.addExtension('SetAsyncExtension', new SetAsyncExtension())
{% setAsync 'numberofAstronauts', getNumberOfAstronauts, [] %}
<p> There are {{numberofAstronauts}} in space right now! </p>
Or you can also use setAsync
with parens as follow:
{% setAsync('numberofAstronauts', getNumberOfAstronauts, []) %}
<p> There are {{numberofAstronauts}} in space right now! </p>
env.render('template.html', function(err, res) {
console.log(res);
});
FAQs
Set Async tag
The npm package nunjucks-setasync receives a total of 0 weekly downloads. As such, nunjucks-setasync popularity was classified as not popular.
We found that nunjucks-setasync demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 2 open source maintainers 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
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.
Security News
Socket now integrates with Bun 1.3’s Security Scanner API to block risky packages at install time and enforce your organization’s policies in local dev and CI.
Research
The Socket Threat Research Team is tracking weekly intrusions into the npm registry that follow a repeatable adversarial playbook used by North Korean state-sponsored actors.