Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

wash

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

wash - npm Package Compare versions

Comparing version 1.1.0 to 1.2.0

test/customBuiltins.test.js

11

lib/precompiled.js

@@ -5,5 +5,6 @@ 'use strict';

Builtins = require('./builtins'),
defaultOptions = require('./defaultOptions.json');
defaultOptions = require('./defaultOptions.json'),
_ = require('lodash');
function Precompiled(code, options) {
function Precompiled(code, options, customBuiltins) {
var self = this;

@@ -16,2 +17,4 @@

self.customBuiltins = customBuiltins;
self.fn = null;

@@ -41,2 +44,6 @@ try {

var builtins = new Builtins(context, locals);
// add/update custom builtins
_.each(self.customBuiltins, function(builtin, name) {
builtins[name] = builtin;
});

@@ -43,0 +50,0 @@ try {

@@ -79,2 +79,3 @@ 'use strict';

function _renderPlainText(t) {

@@ -84,6 +85,7 @@ return '__out+="' + utils.escapeStr(t) + '";\n';

function Wash(source, options) {
function Wash(source, options, customBuiltins) {
var self = this;
self.source = source;
console.assert(_.isString(self.source));

@@ -96,2 +98,6 @@ self.options = options || {};

if(customBuiltins) {
self.customBuiltins = customBuiltins;
}
self._code = '';

@@ -102,2 +108,11 @@ self._forLoopVars = [];

Wash.prototype._isBuiltin = function(token) {
var self = this;
if(Builtins.isBuiltin(token)) { return true; }
if(self.customBuiltins) {
return !!utils.getValueByPath(self.customBuiltins, '.' + token);
}
};
Wash.prototype._evalTokens = function(tokens) {

@@ -122,3 +137,3 @@ var self = this;

}
} else if(Builtins.isBuiltin(token)) {
} else if(self._isBuiltin(token)) {
outs += '__builtins.' + token;

@@ -292,3 +307,3 @@ } else {

return new Precompiled(self._code, self.options);
return new Precompiled(self._code, self.options, self.customBuiltins);
};

@@ -295,0 +310,0 @@

2

package.json
{
"name": "wash",
"description": "a safe template rendering engine",
"version": "1.1.0",
"version": "1.2.0",
"main": "index",

@@ -6,0 +6,0 @@ "author": {

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc