
Security News
CVE Volume Surges Past 48,000 in 2025 as WordPress Plugin Ecosystem Drives Growth
CVE disclosures hit a record 48,185 in 2025, driven largely by vulnerabilities in third-party WordPress plugins.
Rewrites a JavaScript function or module, such that any global property access is transformed to call a member of a new dsl argument. Use dslify to interpret domain-specific languages without messing around in global scope.
npm install dslify
var dslify = require('dslify');
var fn = function() { return shout(word); };
var shouter = dslify.transform(fn);
var dsl = {
shout: function(something) {
return something + "!!";
},
word: "unicorns"
};
shouter(dsl); // unicorns!!
Sometimes you might want to operate with strings instead of JavaScript functions. For example if you are generating templates or want to send JavaScript to the client.
var dslify = require('dslify');
var input = "function(input) { return shout(input, globalValue); };";
var output = dslify.transform(input, {asString: true});
output // function(input) { return shout(input, _dsl.globalValue); };
By rewriting an entire module in terms of another 'dsl' interpreter module, you can make slightly larger DSLs:
// abstract.js
module.exports = {
log: function(message) {
print(message);
}
};
// printer.js
module.exports = {
print: function(message) {
console.log(message + '!')
}
};
// compile.js
var dslify = require('dslify');
var abstract = require('fs').readFileSync('./abstract.js', 'utf-8');
var concrete = dslify.transformModule(abstract, './printer');
fs.writeFileSync('./concrete.js', concrete);
// then...
var concrete = require('./concrete.js');
concrete.log('jibber jabber'); // -> jibber jabber!
dslify parses JavaScript using esprima, rewriting it as new JavaScript using escodegen.
Yes. But 'with' is leaky and dangerous, wheras dslify is like a sandbox because it rewrites access to global scope, e.g:
var dslify = require('dslify');
var dsl = {};
var withWith = function(dsl) {
with (dsl) {
y = 'leaks into global!';
}
};
var withDslify = dslify.transform(function() {
z = 'global is safe!';
});
withWith(dsl);
withDslify(dsl);
console.log(global.y); // leaks into global!
console.log(global.z); // undefined
console.log(dsl.z); // global is safe!
Yes. And dynamically generating functions is relatively slow, compared to calling functions. Therefore consider transforming functions at build time instead of run time.
BSD
FAQs
Rewrites functions or modules in terms of a DSL
We found that dslify 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
CVE disclosures hit a record 48,185 in 2025, driven largely by vulnerabilities in third-party WordPress plugins.

Security News
Socket CEO Feross Aboukhadijeh joins Insecure Agents to discuss CVE remediation and why supply chain attacks require a different security approach.

Security News
Tailwind Labs laid off 75% of its engineering team after revenue dropped 80%, as LLMs redirect traffic away from documentation where developers discover paid products.