benchpressjs
Advanced tools
Comparing version 2.4.3 to 2.5.0
(function (factory) { | ||
if (typeof define === 'function' && define.amd) { | ||
define('benchpress', factory); | ||
} | ||
})(function () { | ||
var runtime = function () { | ||
'use strict'; | ||
/** | ||
* Convert null and undefined values to empty strings | ||
* @param {any} value | ||
* @returns {string} | ||
*/ | ||
function guard(value) { | ||
return value == null || Array.isArray(value) && value.length === 0 ? '' : value; | ||
if (typeof define === 'function' && define.amd) { | ||
define('benchpress', factory); | ||
} | ||
/** | ||
* Iterate over an object or array | ||
* @param {string[]} obj - Iteratee object / array | ||
* @param {function} each - Callback to execute on each item | ||
* @return {string} | ||
*/ | ||
})(function () { | ||
const runtime = (function () { | ||
'use strict'; | ||
/** | ||
* Convert null and undefined values to empty strings | ||
* @param {any} value | ||
* @returns {string} | ||
*/ | ||
function guard(value) { | ||
return value == null || (Array.isArray(value) && value.length === 0) ? '' : value; | ||
} | ||
function iter(obj, each) { | ||
if (!obj || typeof obj !== 'object') { | ||
return ''; | ||
} | ||
/** | ||
* Iterate over an object or array | ||
* @param {string[]} obj - Iteratee object / array | ||
* @param {function} each - Callback to execute on each item | ||
* @return {string} | ||
*/ | ||
function iter(obj, each) { | ||
if (!obj || typeof obj !== 'object') { return ''; } | ||
var output = ''; | ||
var keys = Object.keys(obj); | ||
var length = keys.length; | ||
let output = ''; | ||
const keys = Object.keys(obj); | ||
const length = keys.length; | ||
for (var i = 0; i < length; i += 1) { | ||
var key = keys[i]; | ||
output += each(key, i, length, obj[key]); | ||
} | ||
for (let i = 0; i < length; i += 1) { | ||
const key = keys[i]; | ||
output += each(key, i, length, obj[key]); | ||
} | ||
return output; | ||
} | ||
/** | ||
* Execute a helper | ||
* @param {object} context - Base data object | ||
* @param {object} helpers - Map of helper functions | ||
* @param {string} helperName - Name of helper to execute | ||
* @param {any[]} args - Array of arguments | ||
* @returns {string} | ||
*/ | ||
return output; | ||
} | ||
/** | ||
* Execute a helper | ||
* @param {object} context - Base data object | ||
* @param {object} helpers - Map of helper functions | ||
* @param {string} helperName - Name of helper to execute | ||
* @param {any[]} args - Array of arguments | ||
* @returns {string} | ||
*/ | ||
function helper(context, helpers, helperName, args) { | ||
if (typeof helpers[helperName] !== 'function') { | ||
return ''; | ||
} | ||
try { | ||
const out = helpers[helperName].apply(context, args); | ||
return out || ''; | ||
} catch (e) { | ||
return ''; | ||
} | ||
} | ||
function helper(context, helpers, helperName, args) { | ||
if (typeof helpers[helperName] !== 'function') { | ||
return ''; | ||
} | ||
/** | ||
* Run a compiled template function | ||
* @param {object} helpers - Map of helper functions | ||
* @param {object} context - Base data object | ||
* @param {function} templateFunction - Compiled template function | ||
* @returns {string} | ||
*/ | ||
function runtime(helpers, context, templateFunction) { | ||
return guard(templateFunction(helpers, context, guard, iter, helper)).toString(); | ||
} | ||
try { | ||
var out = helpers[helperName].apply(context, args); | ||
return out || ''; | ||
} catch (e) { | ||
return ''; | ||
} | ||
} | ||
/** | ||
* Run a compiled template function | ||
* @param {object} helpers - Map of helper functions | ||
* @param {object} context - Base data object | ||
* @param {function} templateFunction - Compiled template function | ||
* @returns {string} | ||
*/ | ||
function runtime(helpers, context, templateFunction) { | ||
return guard(templateFunction(helpers, context, guard, iter, helper)).toString(); | ||
} // polyfill for Promise.try | ||
// polyfill for Promise.try | ||
if (typeof Promise.try !== 'function') { | ||
Promise.try = { | ||
try(fn) { | ||
return new Promise((resolve) => { resolve(fn()); }); | ||
}, | ||
}.try; | ||
} | ||
if (typeof Promise.try !== 'function') { | ||
Promise.try = { | ||
try: function _try(fn) { | ||
return new Promise(function (resolve) { | ||
return resolve(fn()); | ||
}); | ||
} | ||
}.try; | ||
} | ||
return runtime; | ||
})(); | ||
return runtime; | ||
}(); | ||
'use strict'; | ||
'use strict'; | ||
/** @exports Benchpress */ | ||
/** @exports Benchpress */ | ||
const Benchpress = (typeof module === 'object' && module.exports) ? module.exports : {}; | ||
var Benchpress = typeof module === 'object' && module.exports ? module.exports : {}; | ||
Benchpress.runtime = runtime; | ||
Benchpress.helpers = {}; | ||
/** | ||
* Register a helper function | ||
* @param {string} name - Helper name | ||
* @param {function} fn - Helper function | ||
*/ | ||
Benchpress.registerHelper = function registerHelper(name, fn) { | ||
Benchpress.helpers[name] = fn; | ||
}; // add default escape function for escaping HTML entities | ||
Benchpress.runtime = runtime; | ||
Benchpress.helpers = {}; | ||
var escapeCharMap = { | ||
'&': '&', | ||
'<': '<', | ||
'>': '>', | ||
'"': '"', | ||
"'": ''', | ||
'`': '`', | ||
'=': '=' | ||
}; | ||
/** | ||
* Register a helper function | ||
* @param {string} name - Helper name | ||
* @param {function} fn - Helper function | ||
*/ | ||
Benchpress.registerHelper = function registerHelper(name, fn) { | ||
Benchpress.helpers[name] = fn; | ||
}; | ||
var replaceChar = function replaceChar(c) { | ||
return escapeCharMap[c]; | ||
}; | ||
// add default escape function for escaping HTML entities | ||
const escapeCharMap = { | ||
'&': '&', | ||
'<': '<', | ||
'>': '>', | ||
'"': '"', | ||
"'": ''', | ||
'`': '`', | ||
'=': '=', | ||
}; | ||
const replaceChar = c => escapeCharMap[c]; | ||
const escapeChars = /[&<>"'`=]/g; | ||
var escapeChars = /[&<>"'`=]/g; | ||
Benchpress.registerHelper('__escape', function (str) { | ||
if (str == null) { | ||
return ''; | ||
} | ||
Benchpress.registerHelper('__escape', (str) => { | ||
if (str == null) { | ||
return ''; | ||
} | ||
if (!str) { | ||
return String(str); | ||
} | ||
if (!str) { | ||
return String(str); | ||
} | ||
return str.toString().replace(escapeChars, replaceChar); | ||
}); | ||
return str.toString().replace(escapeChars, replaceChar); | ||
}); | ||
Benchpress.cache = {}; | ||
Benchpress.globals = {}; | ||
/** | ||
* Set a global data value | ||
* @param {string} key - Property key | ||
* @param {Object} value - Property value | ||
*/ | ||
Benchpress.cache = {}; | ||
Benchpress.setGlobal = function setGlobal(key, value) { | ||
Benchpress.globals[key] = value; | ||
}; | ||
Benchpress.globals = {}; | ||
var assign = Object.assign || jQuery.extend; // eslint-disable-line | ||
/** | ||
* Set a global data value | ||
* @param {string} key - Property key | ||
* @param {Object} value - Property value | ||
*/ | ||
Benchpress.setGlobal = function setGlobal(key, value) { | ||
Benchpress.globals[key] = value; | ||
}; | ||
/** | ||
* @private | ||
*/ | ||
const assign = Object.assign || jQuery.extend; // eslint-disable-line | ||
Benchpress.addGlobals = function addGlobals(data) { | ||
return assign({}, Benchpress.globals, data); | ||
}; | ||
/** | ||
* Clear the template cache | ||
*/ | ||
/** | ||
* @private | ||
*/ | ||
Benchpress.addGlobals = function addGlobals(data) { | ||
return assign({}, Benchpress.globals, data); | ||
}; | ||
/** | ||
* Clear the template cache | ||
*/ | ||
Benchpress.flush = function flush() { | ||
Benchpress.cache = {}; | ||
}; | ||
Benchpress.flush = function flush() { | ||
Benchpress.cache = {}; | ||
}; // necessary to support both promises and callbacks | ||
// can remove when `parse` methods are removed | ||
// necessary to support both promises and callbacks | ||
// can remove when `parse` methods are removed | ||
function load(template) { | ||
return new Promise((resolve, reject) => { | ||
const promise = Benchpress.loader(template, (templateFunction) => { | ||
resolve(templateFunction); | ||
}); | ||
if (promise && promise.then) { | ||
promise.then(resolve, reject); | ||
} | ||
}); | ||
} | ||
function load(template) { | ||
return new Promise(function (resolve, reject) { | ||
var promise = Benchpress.loader(template, function (templateFunction) { | ||
resolve(templateFunction); | ||
}); | ||
/** | ||
* Fetch and run the given template | ||
* @param {string} template - Name of template to fetch | ||
* @param {Object} data - Data with which to run the template | ||
* @param {string} [block] - Parse only this block in the template | ||
* @returns {Promise<string>} - Rendered output | ||
*/ | ||
function render(template, data, block) { | ||
data = Benchpress.addGlobals(data || {}); | ||
if (promise && promise.then) { | ||
promise.then(resolve, reject); | ||
} | ||
}); | ||
} | ||
/** | ||
* Fetch and run the given template | ||
* @param {string} template - Name of template to fetch | ||
* @param {Object} data - Data with which to run the template | ||
* @param {string} [block] - Parse only this block in the template | ||
* @returns {Promise<string>} - Rendered output | ||
*/ | ||
return Promise.try(() => { | ||
Benchpress.cache[template] = Benchpress.cache[template] || load(template); | ||
return Benchpress.cache[template]; | ||
}).then((templateFunction) => { | ||
if (block) { | ||
templateFunction = templateFunction.blocks && templateFunction.blocks[block]; | ||
} | ||
if (!templateFunction) { | ||
return ''; | ||
} | ||
return runtime(Benchpress.helpers, data, templateFunction); | ||
}); | ||
} | ||
function render(template, data, block) { | ||
data = Benchpress.addGlobals(data || {}); | ||
return Promise.try(function () { | ||
Benchpress.cache[template] = Benchpress.cache[template] || load(template); | ||
return Benchpress.cache[template]; | ||
}).then(function (templateFunction) { | ||
if (block) { | ||
templateFunction = templateFunction.blocks && templateFunction.blocks[block]; | ||
} | ||
/** | ||
* Alias for {@link render}, but uses a callback | ||
* @param {string} template - Name of template to fetch | ||
* @param {string} [block] - Render only this block in the template | ||
* @param {Object} data - Data with which to run the template | ||
* @param {function} callback - callback(output) | ||
* | ||
* @deprecated - Use {@link render} instead | ||
*/ | ||
function parse(template, block, data, callback) { | ||
// eslint-disable-next-line no-console | ||
console.warn('Deprecated: Benchpress.parse is deprecated, to be removed in v3.0.0'); | ||
if (!templateFunction) { | ||
return ''; | ||
} | ||
return runtime(Benchpress.helpers, data, templateFunction); | ||
}); | ||
if (!callback && typeof block === 'object' && typeof data === 'function') { | ||
callback = data; | ||
data = block; | ||
block = null; | ||
} | ||
/** | ||
* Alias for {@link render}, but uses a callback | ||
* @param {string} template - Name of template to fetch | ||
* @param {string} [block] - Render only this block in the template | ||
* @param {Object} data - Data with which to run the template | ||
* @param {function} callback - callback(output) | ||
* | ||
* @deprecated - Use {@link render} instead | ||
*/ | ||
if (typeof callback !== 'function') { | ||
// Calling parse synchronously with no callback is discontinued | ||
throw TypeError('Invalid Arguments: callback must be a function'); | ||
} | ||
if (!template) { | ||
callback(''); | ||
return; | ||
} | ||
render(template, data, block).then( | ||
output => setTimeout(callback, 0, output), | ||
err => console.error(err), // eslint-disable-line no-console | ||
); | ||
} | ||
function parse(template, block, data, callback) { | ||
// eslint-disable-next-line no-console | ||
console.warn('Deprecated: Benchpress.parse is deprecated, to be removed in v3.0.0'); | ||
Benchpress.render = render; | ||
Benchpress.parse = parse; | ||
if (!callback && typeof block === 'object' && typeof data === 'function') { | ||
callback = data; | ||
data = block; | ||
block = null; | ||
} | ||
/** | ||
* Register a loader function to fetch templates | ||
* - `loader(name, callback) => callback(templateFunction)` | ||
* - `loader(name) => Promise<templateFunction>` | ||
* @param {function} loader | ||
*/ | ||
Benchpress.registerLoader = function registerLoader(loader) { | ||
Benchpress.loader = loader; | ||
}; | ||
if (typeof callback !== 'function') { | ||
// Calling parse synchronously with no callback is discontinued | ||
throw TypeError('Invalid Arguments: callback must be a function'); | ||
} | ||
if (!template) { | ||
callback(''); | ||
return; | ||
} | ||
render(template, data, block).then(function (output) { | ||
return setTimeout(callback, 0, output); | ||
}, function (err) { | ||
return console.error(err); | ||
} // eslint-disable-line no-console | ||
); | ||
} | ||
Benchpress.render = render; | ||
Benchpress.parse = parse; | ||
/** | ||
* Register a loader function to fetch templates | ||
* - `loader(name, callback) => callback(templateFunction)` | ||
* - `loader(name) => Promise<templateFunction>` | ||
* @param {function} loader | ||
*/ | ||
Benchpress.registerLoader = function registerLoader(loader) { | ||
Benchpress.loader = loader; | ||
}; | ||
return Benchpress; | ||
}); | ||
return Benchpress; | ||
}); |
@@ -1,3 +0,2 @@ | ||
/*! benchpressjs by psychobunny, built on 2021-03-26 */ | ||
"function"==typeof define&&define.amd&&define("benchpress",function(){var t=function(){"use strict";function t(e){return e==null||Array.isArray(e)&&e.length===0?"":e}function o(e,r){if(!e||typeof e!=="object")return"";var n="";var t=Object.keys(e);var o=t.length;for(var u=0;u<o;u+=1){var i=t[u];n+=r(i,u,o,e[i])}return n}function u(e,r,n,t){if(typeof r[n]!=="function")return"";try{var o=r[n].apply(e,t);return o||""}catch(e){return""}}function e(e,r,n){return t(n(e,r,t,o,u)).toString()}if(typeof Promise.try!=="function")Promise.try={try:function e(r){return new Promise(function(e){return e(r())})}}.try;return e}();"use strict";var o=typeof module==="object"&&module.exports?module.exports:{};o.runtime=t,o.helpers={},o.registerHelper=function e(r,n){o.helpers[r]=n};var n={"&":"&","<":"<",">":">",'"':""","'":"'","`":"`","=":"="},r=function e(r){return n[r]},u=/[&<>"'`=]/g;o.registerHelper("__escape",function(e){if(e==null)return"";if(!e)return String(e);return e.toString().replace(u,r)}),o.cache={},o.globals={},o.setGlobal=function e(r,n){o.globals[r]=n};var i=Object.assign||jQuery.extend;function c(t){return new Promise(function(r,e){var n=o.loader(t,function(e){r(e)});if(n&&n.then)n.then(r,e)})}function f(e,r,n){r=o.addGlobals(r||{});return Promise.try(function(){o.cache[e]=o.cache[e]||c(e);return o.cache[e]}).then(function(e){if(n)e=e.blocks&&e.blocks[n];if(!e)return"";return t(o.helpers,r,e)})}function e(e,r,n,t){console.warn("Deprecated: Benchpress.parse is deprecated, to be removed in v3.0.0");if(!t&&typeof r==="object"&&typeof n==="function"){t=n;n=r;r=null}if(typeof t!=="function")throw TypeError("Invalid Arguments: callback must be a function");if(!e){t("");return}f(e,n,r).then(function(e){return setTimeout(t,0,e)},function(e){return console.error(e)})}return o.addGlobals=function e(r){return i({},o.globals,r)},o.flush=function e(){o.cache={}},o.render=f,o.parse=e,o.registerLoader=function e(r){o.loader=r},o}); | ||
/*! benchpressjs by psychobunny, built on 2023-02-07 */ | ||
"function"==typeof define&&define.amd&&define("benchpress",function(){const n=function(){"use strict";function n(e){return e==null||Array.isArray(e)&&e.length===0?"":e}function o(t,r){if(!t||typeof t!=="object")return"";let n="";const o=Object.keys(t);const c=o.length;for(let e=0;e<c;e+=1){const u=o[e];n+=r(u,e,c,t[u])}return n}function c(e,t,r,n){if(typeof t[r]!=="function")return"";try{const o=t[r].apply(e,n);return o||""}catch(e){return""}}function e(e,t,r){return n(r(e,t,n,o,c)).toString()}if(typeof Promise.try!=="function")Promise.try={try(t){return new Promise(e=>{e(t())})}}.try;return e}(),o=("use strict",typeof module==="object"&&module.exports?module.exports:{}),t=(o.runtime=n,o.helpers={},o.registerHelper=function e(t,r){o.helpers[t]=r},{"&":"&","<":"<",">":">",'"':""","'":"'","`":"`","=":"="}),r=e=>t[e],c=/[&<>"'`=]/g,u=(o.registerHelper("__escape",e=>{if(e==null)return"";if(!e)return String(e);return e.toString().replace(c,r)}),o.cache={},o.globals={},o.setGlobal=function e(t,r){o.globals[t]=r},Object.assign||jQuery.extend);function i(n){return new Promise((t,e)=>{const r=o.loader(n,e=>{t(e)});if(r&&r.then)r.then(t,e)})}function s(e,t,r){t=o.addGlobals(t||{});return Promise.try(()=>{o.cache[e]=o.cache[e]||i(e);return o.cache[e]}).then(e=>{if(r)e=e.blocks&&e.blocks[r];if(!e)return"";return n(o.helpers,t,e)})}function e(e,t,r,n){console.warn("Deprecated: Benchpress.parse is deprecated, to be removed in v3.0.0");if(!n&&typeof t==="object"&&typeof r==="function"){n=r;r=t;t=null}if(typeof n!=="function")throw TypeError("Invalid Arguments: callback must be a function");if(!e){n("");return}s(e,r,t).then(e=>setTimeout(n,0,e),e=>console.error(e))}return o.addGlobals=function e(t){return u({},o.globals,t)},o.flush=function e(){o.cache={}},o.render=s,o.parse=e,o.registerLoader=function e(t){o.loader=t},o}); |
let imports = {}; | ||
imports['__wbindgen_placeholder__'] = module.exports; | ||
let wasm; | ||
const { TextDecoder, TextEncoder } = require(String.raw`util`); | ||
const { TextDecoder, TextEncoder } = require(`util`); | ||
@@ -10,8 +10,9 @@ let cachedTextDecoder = new TextDecoder('utf-8', { ignoreBOM: true, fatal: true }); | ||
let cachegetUint8Memory0 = null; | ||
let cachedUint8Memory0 = null; | ||
function getUint8Memory0() { | ||
if (cachegetUint8Memory0 === null || cachegetUint8Memory0.buffer !== wasm.memory.buffer) { | ||
cachegetUint8Memory0 = new Uint8Array(wasm.memory.buffer); | ||
if (cachedUint8Memory0 === null || cachedUint8Memory0.byteLength === 0) { | ||
cachedUint8Memory0 = new Uint8Array(wasm.memory.buffer); | ||
} | ||
return cachegetUint8Memory0; | ||
return cachedUint8Memory0; | ||
} | ||
@@ -23,3 +24,3 @@ | ||
const heap = new Array(32).fill(undefined); | ||
const heap = new Array(128).fill(undefined); | ||
@@ -42,3 +43,3 @@ heap.push(undefined, null, true, false); | ||
function dropObject(idx) { | ||
if (idx < 36) return; | ||
if (idx < 132) return; | ||
heap[idx] = heap_next; | ||
@@ -109,8 +110,9 @@ heap_next = idx; | ||
let cachegetInt32Memory0 = null; | ||
let cachedInt32Memory0 = null; | ||
function getInt32Memory0() { | ||
if (cachegetInt32Memory0 === null || cachegetInt32Memory0.buffer !== wasm.memory.buffer) { | ||
cachegetInt32Memory0 = new Int32Array(wasm.memory.buffer); | ||
if (cachedInt32Memory0 === null || cachedInt32Memory0.byteLength === 0) { | ||
cachedInt32Memory0 = new Int32Array(wasm.memory.buffer); | ||
} | ||
return cachegetInt32Memory0; | ||
return cachedInt32Memory0; | ||
} | ||
@@ -125,6 +127,6 @@ /** | ||
const retptr = wasm.__wbindgen_add_to_stack_pointer(-16); | ||
var ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
var ptr1 = passStringToWasm0(filename, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len1 = WASM_VECTOR_LEN; | ||
const ptr0 = passStringToWasm0(source, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
const len0 = WASM_VECTOR_LEN; | ||
const ptr1 = passStringToWasm0(filename, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
const len1 = WASM_VECTOR_LEN; | ||
wasm.compile(retptr, ptr0, len0, ptr1, len1); | ||
@@ -141,3 +143,3 @@ var r0 = getInt32Memory0()[retptr / 4 + 0]; | ||
module.exports.__wbindgen_string_new = function(arg0, arg1) { | ||
var ret = getStringFromWasm0(arg0, arg1); | ||
const ret = getStringFromWasm0(arg0, arg1); | ||
return addHeapObject(ret); | ||
@@ -150,11 +152,11 @@ }; | ||
module.exports.__wbg_new_59cb74e423758ede = function() { | ||
var ret = new Error(); | ||
module.exports.__wbg_new_abda76e883ba8a5f = function() { | ||
const ret = new Error(); | ||
return addHeapObject(ret); | ||
}; | ||
module.exports.__wbg_stack_558ba5917b466edd = function(arg0, arg1) { | ||
var ret = getObject(arg1).stack; | ||
var ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
var len0 = WASM_VECTOR_LEN; | ||
module.exports.__wbg_stack_658279fe44541cf6 = function(arg0, arg1) { | ||
const ret = getObject(arg1).stack; | ||
const ptr0 = passStringToWasm0(ret, wasm.__wbindgen_malloc, wasm.__wbindgen_realloc); | ||
const len0 = WASM_VECTOR_LEN; | ||
getInt32Memory0()[arg0 / 4 + 1] = len0; | ||
@@ -164,3 +166,3 @@ getInt32Memory0()[arg0 / 4 + 0] = ptr0; | ||
module.exports.__wbg_error_4bb6c2a97407129a = function(arg0, arg1) { | ||
module.exports.__wbg_error_f851667af71bcfc6 = function(arg0, arg1) { | ||
try { | ||
@@ -173,7 +175,7 @@ console.error(getStringFromWasm0(arg0, arg1)); | ||
module.exports.__wbg_error_e25c602bf2cc97d2 = function(arg0) { | ||
module.exports.__wbg_error_fe807da27c4a4ced = function(arg0) { | ||
console.error(getObject(arg0)); | ||
}; | ||
module.exports.__wbg_warn_703e3122e4d88974 = function(arg0) { | ||
module.exports.__wbg_warn_e57696dbb3977030 = function(arg0) { | ||
console.warn(getObject(arg0)); | ||
@@ -180,0 +182,0 @@ }; |
@@ -7,3 +7,2 @@ { | ||
"compiler.js", | ||
"compiler_bg.js", | ||
"compiler.d.ts" | ||
@@ -10,0 +9,0 @@ ], |
114
docs/api.md
@@ -5,22 +5,22 @@ <!-- Generated by documentation.js. Update this documentation by updating the source code. --> | ||
- [Benchpress][1] | ||
- [registerHelper][2] | ||
- [Parameters][3] | ||
- [setGlobal][4] | ||
- [Parameters][5] | ||
- [flush][6] | ||
- [registerLoader][7] | ||
- [Parameters][8] | ||
- [precompile][9] | ||
- [Parameters][10] | ||
- [compileRender][11] | ||
- [Parameters][12] | ||
- [\_\_express][13] | ||
- [Parameters][14] | ||
- [compileParse][15] | ||
- [Parameters][16] | ||
- [render][17] | ||
- [Parameters][18] | ||
- [parse][19] | ||
- [Parameters][20] | ||
* [Benchpress][1] | ||
* [registerHelper][2] | ||
* [Parameters][3] | ||
* [setGlobal][4] | ||
* [Parameters][5] | ||
* [flush][6] | ||
* [registerLoader][7] | ||
* [Parameters][8] | ||
* [precompile][9] | ||
* [Parameters][10] | ||
* [compileRender][11] | ||
* [Parameters][12] | ||
* [\__express][13] | ||
* [Parameters][14] | ||
* [compileParse][15] | ||
* [Parameters][16] | ||
* [render][17] | ||
* [Parameters][18] | ||
* [parse][19] | ||
* [Parameters][20] | ||
@@ -35,4 +35,4 @@ ## Benchpress | ||
- `name` **[string][21]** Helper name | ||
- `fn` **[function][22]** Helper function | ||
* `name` **[string][21]** Helper name | ||
* `fn` **[function][22]** Helper function | ||
@@ -45,4 +45,4 @@ ### setGlobal | ||
- `key` **[string][21]** Property key | ||
- `value` **[Object][23]** Property value | ||
* `key` **[string][21]** Property key | ||
* `value` **[Object][23]** Property value | ||
@@ -57,8 +57,8 @@ ### flush | ||
- `loader(name, callback) => callback(templateFunction)` | ||
- `loader(name) => Promise<templateFunction>` | ||
* `loader(name, callback) => callback(templateFunction)` | ||
* `loader(name) => Promise<templateFunction>` | ||
#### Parameters | ||
- `loader` **[function][22]** | ||
* `loader` **[function][22]** | ||
@@ -69,13 +69,13 @@ ## precompile | ||
- `precompiled(source): Promise<string>` | ||
- `precompile(source, {}, callback) => callback(err, output)` | ||
- `precompile({ source }, callback) => callback(err, output)` | ||
* `precompiled(source): Promise<string>` | ||
* `precompile(source, {}, callback) => callback(err, output)` | ||
* `precompile({ source }, callback) => callback(err, output)` | ||
### Parameters | ||
- `source` **[string][21]** Template source | ||
- `options` | ||
- `callback` **[function][22]?** (err, output) | ||
* `source` **[string][21]** Template source | ||
* `options` | ||
* `callback` **[function][22]?** (err, output) | ||
Returns **[Promise][24]<[string][21]>** output code | ||
Returns **[Promise][24]<[string][21]>** output code | ||
@@ -89,9 +89,9 @@ ## compileRender | ||
- `templateSource` **[string][21]** | ||
- `data` **any** | ||
- `block` **[string][21]?** | ||
* `templateSource` **[string][21]** | ||
* `data` **any** | ||
* `block` **[string][21]?** | ||
Returns **[Promise][24]<[string][21]>** rendered output | ||
Returns **[Promise][24]<[string][21]>** rendered output | ||
## \_\_express | ||
## \__express | ||
@@ -102,5 +102,5 @@ Provide functionality to act as an express engine | ||
- `filepath` **[string][21]** Compiled template file path | ||
- `data` **[Object][23]** Data with which to parse the template | ||
- `next` **[function][22]** (err, output) | ||
* `filepath` **[string][21]** Compiled template file path | ||
* `data` **[Object][23]** Data with which to parse the template | ||
* `next` **[function][22]** (err, output) | ||
@@ -113,12 +113,11 @@ ## compileParse | ||
- `templateSource` **[string][21]** | ||
- `block` **[string][21]?** | ||
- `data` **any** | ||
- `callback` **[function][22]** (err, output) | ||
* `templateSource` **[string][21]** | ||
* `block` **[string][21]?** | ||
* `data` **any** | ||
* `callback` **[function][22]** (err, output) | ||
**Meta** | ||
- **deprecated**: Use [compileRender][11] instead | ||
* **deprecated**: Use [compileRender][11] instead | ||
## render | ||
@@ -130,7 +129,7 @@ | ||
- `template` **[string][21]** Name of template to fetch | ||
- `data` **[Object][23]** Data with which to run the template | ||
- `block` **[string][21]?** Parse only this block in the template | ||
* `template` **[string][21]** Name of template to fetch | ||
* `data` **[Object][23]** Data with which to run the template | ||
* `block` **[string][21]?** Parse only this block in the template | ||
Returns **[Promise][24]<[string][21]>** Rendered output | ||
Returns **[Promise][24]<[string][21]>** Rendered output | ||
@@ -143,12 +142,11 @@ ## parse | ||
- `template` **[string][21]** Name of template to fetch | ||
- `block` **[string][21]?** Render only this block in the template | ||
- `data` **[Object][23]** Data with which to run the template | ||
- `callback` **[function][22]** callback(output) | ||
* `template` **[string][21]** Name of template to fetch | ||
* `block` **[string][21]?** Render only this block in the template | ||
* `data` **[Object][23]** Data with which to run the template | ||
* `callback` **[function][22]** callback(output) | ||
**Meta** | ||
- **deprecated**: Use [render][17] instead | ||
* **deprecated**: Use [render][17] instead | ||
[1]: #benchpress | ||
@@ -155,0 +153,0 @@ |
{ | ||
"name": "benchpressjs", | ||
"version": "2.4.3", | ||
"version": "2.5.0", | ||
"author": "psychobunny <psycho.bunny@hotmail.com>", | ||
@@ -24,32 +24,22 @@ "description": "An ultralight and super fast templating framework", | ||
"devDependencies": { | ||
"@babel/core": "^7.13.10", | ||
"@babel/plugin-proposal-class-properties": "^7.13.0", | ||
"@babel/plugin-transform-arrow-functions": "^7.13.0", | ||
"@babel/plugin-transform-block-scoped-functions": "^7.12.13", | ||
"@babel/plugin-transform-block-scoping": "^7.12.13", | ||
"@babel/plugin-transform-function-name": "^7.12.13", | ||
"@babel/plugin-transform-shorthand-properties": "^7.12.13", | ||
"async": "^3.2.0", | ||
"babel-eslint": "^10.1.0", | ||
"benchmark": "^2.1.4", | ||
"coveralls": "^3.1.0", | ||
"coveralls": "^3.1.1", | ||
"documentation": "^13.2.0", | ||
"eslint": "^7.22.0", | ||
"eslint-config-airbnb-base": "^14.2.1", | ||
"eslint-plugin-import": "^2.22.1", | ||
"express": "^4.17.1", | ||
"grunt": "^1.3.0", | ||
"grunt-babel": "^8.0.0", | ||
"grunt-contrib-uglify": "^5.0.0", | ||
"eslint": "^8.33.0", | ||
"eslint-config-airbnb-base": "^15.0.0", | ||
"eslint-plugin-import": "^2.27.5", | ||
"express": "^4.18.2", | ||
"grunt": "^1.6.1", | ||
"grunt-contrib-uglify": "^5.2.2", | ||
"grunt-contrib-watch": "^1.1.0", | ||
"grunt-mocha-test": "^0.13.3", | ||
"grunt-shell": "^3.0.1", | ||
"mkdirp": "^1.0.4", | ||
"mocha": "^8.3.2", | ||
"grunt-shell": "^4.0.0", | ||
"mkdirp": "^2.1.3", | ||
"mocha": "^10.2.0", | ||
"nyc": "^15.1.0", | ||
"uglify-js": "^3.13.2" | ||
"uglify-js": "^3.17.4" | ||
}, | ||
"license": "MIT", | ||
"engines": { | ||
"node": ">=10" | ||
"node": ">=14" | ||
}, | ||
@@ -56,0 +46,0 @@ "dependencies": { |
Sorry, the diff of this file is not supported yet
Deprecated
MaintenanceThe maintainer of the package marked it as deprecated. This could indicate that a single version should not be used, or that the package is no longer maintained and any new vulnerabilities will not be fixed.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
Dynamic require
Supply chain riskDynamic require can indicate the package is performing dangerous or unsafe dynamic code execution.
Found 1 instance in 1 package
16
337401
747
1