Skip to content

Commit

Permalink
chore: rebuild & format
Browse files Browse the repository at this point in the history
  • Loading branch information
nebrelbug committed May 13, 2023
1 parent af6018f commit e1a554b
Show file tree
Hide file tree
Showing 3 changed files with 9,629 additions and 9,761 deletions.
68 changes: 34 additions & 34 deletions browser-tests/benchmark.js
Original file line number Diff line number Diff line change
Expand Up @@ -133,10 +133,10 @@ templateList['swig-raw'] = `
var config = {
length: 20,
calls: 6000,
escape: true,
escape: true
}

function getParameterByName(name) {
function getParameterByName (name) {
var url = window.location.href
var regex = new RegExp('[?&]' + name + '(=([^&#]*)|&|#|$)')
var results = regex.exec(url)
Expand All @@ -159,7 +159,7 @@ if (window.location.search) {

// 制造测试数据
var data = {
list: [],
list: []
}

for (var i = 0; i < config.length; i++) {
Expand All @@ -168,7 +168,7 @@ for (var i = 0; i < config.length; i++) {
user: '<strong style="color:red">糖饼</strong>',
site: 'https://github.com/aui',
weibo: 'http://weibo.com/planeart',
QQweibo: 'http://t.qq.com/tangbin',
QQweibo: 'http://t.qq.com/tangbin'
})
}

Expand All @@ -187,7 +187,7 @@ var testList = [
html = fn(data)
}
return html
},
}
},

{
Expand All @@ -202,7 +202,7 @@ var testList = [
html = fn(data)
}
return html
},
}
},

{
Expand All @@ -217,7 +217,7 @@ var testList = [
html = fn(data)
}
return html
},
}
},

{
Expand All @@ -232,7 +232,7 @@ var testList = [
html = fn(data)
}
return html
},
}
},
{
name: 'Squirrelly',
Expand All @@ -248,7 +248,7 @@ var testList = [
html = Sqrl.render(source, data)
}
return html
},
}
},
{
name: 'Squirrelly - Fast',
Expand All @@ -264,7 +264,7 @@ var testList = [
html = Sqrl.render(source, data)
}
return html
},
}
},
{
name: 'Jade / pug',
Expand All @@ -279,7 +279,7 @@ var testList = [
html = fn(data)
}
return html
},
}
},
{
name: 'Handlebars',
Expand All @@ -293,7 +293,7 @@ var testList = [
html = fn(data)
}
return html
},
}
},
{
name: 'Mustache',
Expand All @@ -307,7 +307,7 @@ var testList = [
html = Mustache.render(source, data)
}
return html
},
}
},

{
Expand All @@ -322,8 +322,8 @@ var testList = [
html = fn(data)
}
return html
},
},
}
}
]

Highcharts.setOptions({
Expand All @@ -336,8 +336,8 @@ Highcharts.setOptions({
'#CB93E0',
'#A2A2A4',
'#E1AC65',
'#6AF9C4',
],
'#6AF9C4'
]
})

var runTest = function (callback) {
Expand All @@ -363,11 +363,11 @@ var runTest = function (callback) {
var chart = new Highcharts.Chart({
chart: {
animation: {
duration: 150,
duration: 150
},
renderTo: 'test-container',
height: categories.length * 32,
type: 'bar',
type: 'bar'
},

title: false,
Expand All @@ -378,47 +378,47 @@ var runTest = function (callback) {

xAxis: {
categories: categories,
labels: {},
labels: {}
},

yAxis: {
min: 0,
title: {
text: 'Time',
},
text: 'Time'
}
},

legend: {
enabled: false,
enabled: false
},

tooltip: {
formatter: function () {
return '<b>' + this.x + '</b><br/>' + this.y + ' ops/sec'
},
}
},

credits: {
enabled: false,
enabled: false
},
plotOptions: {
bar: {
dataLabels: {
enabled: true,
formatter: function () {
return this.y + ' ops/sec'
},
},
},
}
}
}
},
series: [
{
data: [],
},
],
data: []
}
]
})

function tester(target) {
function tester (target) {
var time = new Timer()
var html = target.tester()
var endTime = time.stop()
Expand All @@ -429,7 +429,7 @@ var runTest = function (callback) {

chart.series[0].addPoint({
color: colors.shift(),
y: opsPerSec,
y: opsPerSec
})

if (!list.length) {
Expand All @@ -452,7 +452,7 @@ window['restart'] = function (key, value) {
config[key] = value
}

function getLink() {
function getLink () {
window.location.search =
'length=' + config.length + '&calls=' + config.calls + '&escape=' + config.escape
}
Expand Down
18 changes: 9 additions & 9 deletions browser-tests/demo.html
Original file line number Diff line number Diff line change
Expand Up @@ -209,22 +209,22 @@ <h4>Result</h4>
</div>
<script>
/* global Sqrl */
window.onload = function() {
Sqrl.filters.define('reverse', function(str) {
window.onload = function () {
Sqrl.filters.define('reverse', function (str) {
var out = ''
for (var i = str.length - 1; i >= 0; i--) {
out += String(str).charAt(i)
}
return out || str
})

Sqrl.filters.define('capitalize', function(str) {
Sqrl.filters.define('capitalize', function (str) {
return str.toUpperCase()
})

Sqrl.templates.define('mypartial', Sqrl.compile('This is a partial'))

Sqrl.helpers.define('customhelper', function(content, blocks, options) {
Sqrl.helpers.define('customhelper', function (content, blocks, options) {
var returnStr = 'Custom Helper speaking! \n'
for (var i = 0; i < blocks.length; i++) {
var currentBlock = blocks[i]
Expand All @@ -234,12 +234,12 @@ <h4>Result</h4>
return returnStr
})

Sqrl.helpers.define('log', function(args) {
Sqrl.helpers.define('log', function (args) {
console.log(args[0])
return ''
})

function escape(str) {
function escape (str) {
// To handle escaping for the function result
var escMap = {
'&': '&amp;',
Expand All @@ -250,7 +250,7 @@ <h4>Result</h4>
'/': '&#x2F;'
}

function replaceChar(s) {
function replaceChar (s) {
return escMap[s]
}
var newStr = String(str)
Expand All @@ -261,7 +261,7 @@ <h4>Result</h4>
}
}

function render() {
function render () {
console.clear()
var options = JSON.parse('{' + document.getElementById('data').value + '}')
console.log(JSON.stringify(options))
Expand All @@ -272,7 +272,7 @@ <h4>Result</h4>
if (!Sqrl.defaultConfig.async) {
document.getElementById('result').innerHTML = Sqrl.render(template, options)
} else {
Sqrl.render(template, options).then(function(res) {
Sqrl.render(template, options).then(function (res) {
document.getElementById('result').innerHTML = res
})
}
Expand Down
Loading

0 comments on commit e1a554b

Please sign in to comment.