New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ariestp

Package Overview
Dependencies
Maintainers
1
Versions
32
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ariestp - npm Package Compare versions

Comparing version 0.1.4 to 0.1.5

benchmark/benchmark.js

1

lib/aries.js

@@ -13,2 +13,3 @@ var fs = require('fs');

aries.set = function(opt){

@@ -15,0 +16,0 @@ if(hasSet) return te;

62

lib/ariestp.js

@@ -9,2 +9,10 @@ var path = require('path'),

var _escape_table = { '&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'":'&apos;' }
var _escape_reg = new RegExp(/[&<>"']/g);
var _escape_func = function(m) { return _escape_table[m]; }
var _escape = function(s) {
return typeof(s) != 'string' ? s : s.replace(_escape_reg, _escape_func);
}
function Promise() {

@@ -129,2 +137,3 @@ this.cbs = [];

atry(function() {
ctx._escape = _escape; //传入escape函数
fnList[res.exePos](ctx, res);

@@ -331,2 +340,3 @@ }).catch(function(err) {

var dynPart = [];
// TODO tweak the second replace so that the first can go away (and the later which reverse it)

@@ -337,3 +347,4 @@ var staticParts = str.replace(/[\n\r]/g, "<;;;;>").replace(/<%(.*?)%>/g, function (part, code) {

}).replace(/<;;;;>/g, "\n").replace(/'/g, "\\'").replace(/[\n\r]/g, "\\n\\\n").split(/<%%>/);
var staticPartsList = [];

@@ -352,3 +363,3 @@ var dynPartList = [];

if(code != null) {
if(code.charAt(0) === "=") {
if(code.charAt(0) === "-" || code.charAt(0) === "=") {
staticPartsList[i].push(part)

@@ -385,6 +396,11 @@ dynPartList[i].push(code)

if(code != null) {
if(code.charAt(0) === "=") {
if(code.charAt(0) === "-") {
code = code.substr(1);
src = src + "res.p.push("+code+");";
}
else if(code.charAt(0) === "="){
code = code.substr(1);
src = src + "res.p.push(ctx._escape("+code+"));";
}
else if(code.charAt(0) === "?") {

@@ -408,22 +424,22 @@ code = code.substr(1);

function parseJohnResig(str) {
// Stolen from underscore.js http://documentcloud.github.com/underscore/underscore.js
// JavaScript templating a-la ERB, pilfered from John Resig's
// "Secrets of the JavaScript Ninja", page 83.
var src =
'function __template__ (ctx, res) {' +
'res.p.push(\'' +
str
.replace(/[\t]/g, " ")
.replace(/[\n\r]/g, "<%\n%>\\n")
.split("<%").join("\t")
.replace(/((^|%>)[^\t]*)'/g, "$1\n")
.replace(/\t=(.*?)%>/g, "',$1,'")
.replace(/\t\?(.*?)%>/g, "',res._schedule(function (res) {$1}),'")
.split("\t").join("');")
.split("%>").join("res.p.push('")
.split("\r").join("\\'")
+ "');return res}__template__;";
// function parseJohnResig(str) {
// // Stolen from underscore.js http://documentcloud.github.com/underscore/underscore.js
// // JavaScript templating a-la ERB, pilfered from John Resig's
// // "Secrets of the JavaScript Ninja", page 83.
// var src =
// 'function __template__ (ctx, res) {' +
// 'res.p.push(\'' +
// str
// .replace(/[\t]/g, " ")
// .replace(/[\n\r]/g, "<%\n%>\\n")
// .split("<%").join("\t")
// .replace(/((^|%>)[^\t]*)'/g, "$1\n")
// .replace(/\t\-(.*?)%>/g, "',$1,'")
// .replace(/\t\?(.*?)%>/g, "',res._schedule(function (res) {$1}),'")
// .split("\t").join("');")
// .split("%>").join("res.p.push('")
// .split("\r").join("\\'")
// + "');return res}__template__;";
return src;
}
// return src;
// }
{
"name": "ariestp",
"description": "A Async Template for Node.js",
"version": "0.1.4",
"version": "0.1.5",
"license": "MIT",

@@ -27,2 +27,5 @@ "author": {

},
"devDependencies": {
"ejs": "2.4.1"
},
"dependencies": {

@@ -29,0 +32,0 @@ "async":"1.5.2",

@@ -41,6 +41,33 @@ "use strict";

// //测试转移字符串
taskList.push(function(callback){
let syncStr = "<%= ctx.data %>";
aries.compile(syncStr, {data:"<p>\"\'</p>"}, (err, renderStr, isUseCache) => {
if(err){
console.log(err.stack)
}
console.log(renderStr)
assert(!err);
assert(!isUseCache);
assert(renderStr === "&lt;p&gt;&quot;&apos;&lt;/p&gt;");
aries.compile(syncStr, {data:"<p>\"\'</p>"}, (err, renderStr, isUseCache) => {
assert(!err);
assert(isUseCache);
assert(renderStr === "&lt;p&gt;&quot;&apos;&lt;/p&gt;");
console.log("sync str test ok");
callback();
})
})
});
// //测试渲染字符串
taskList.push(function(callback){
let syncStr = "<%= ctx.data %>";
let syncStr = "<%- ctx.data %>";
aries.compile(syncStr, {data:"123"}, (err, renderStr, isUseCache) => {
if(err){
console.log(err.stack)
}
assert(!err);

@@ -63,3 +90,3 @@ assert(!isUseCache);

taskList.push(function(callback){
let syncStr = "<%? setTimeout(function(){ctx.data='123';res.finish();},ctx.timeout) %><%= ctx.data %>";
let syncStr = "<%? setTimeout(function(){ctx.data='123';res.finish();},ctx.timeout) %><%- ctx.data %>";
aries.compile(syncStr, {timeout:1000}, function(err, renderStr, isUseCache){

@@ -145,3 +172,3 @@ assert(!err);

taskList.push(function(callback){
let syncStr = "<% if(false){ %><%= ctx.data %><%} else {%><%= ctx.data %><%}%>";
let syncStr = "<% if(false){ %><%- ctx.data %><%} else {%><%- ctx.data %><%}%>";
aries.compile(syncStr, {data:"123"}, (err, renderStr, isUseCache) => {

@@ -164,3 +191,3 @@ assert(!err);

taskList.push(function(callback){
let syncStr = "<% for(var i=1;i<ctx.data;i++){%><%= i %><%}%>";
let syncStr = "<% for(var i=1;i<ctx.data;i++){%><%- i %><%}%>";
aries.compile(syncStr, {data:10}, (err, renderStr, isUseCache) => {

@@ -167,0 +194,0 @@ assert(!err);

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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