dustjs-helpers
Advanced tools
Comparing version 1.7.0 to 1.7.1
{ | ||
"name": "dustjs-helpers", | ||
"version": "1.7.0", | ||
"version": "1.7.1", | ||
"homepage": "https://github.com/linkedin/dustjs-helpers", | ||
@@ -5,0 +5,0 @@ "authors": [ |
## Change Log | ||
### v1.7.0 (2015/04/18 00:24 +00:00) | ||
### v1.7.1 (2015/04/29 02:39 +00:00) | ||
- [#136](https://github.com/linkedin/dustjs-helpers/pull/136) Sync linkedin/dustjs#650 (@sethkinast) | ||
- [#135](https://github.com/linkedin/dustjs-helpers/pull/135) Evaluate truth test bodies inside a @select before resolving the select. (@sethkinast) | ||
### v1.7.0 (2015/04/18 00:26 +00:00) | ||
- [#133](https://github.com/linkedin/dustjs-helpers/pull/133) Don't require a key for `{@select}` (@sethkinast) | ||
@@ -5,0 +9,0 @@ - [#129](https://github.com/linkedin/dustjs-helpers/pull/129) Refactor for 1.7 (@sethkinast) |
@@ -1,2 +0,2 @@ | ||
/*! dustjs-helpers - v1.7.0 | ||
/*! dustjs-helpers - v1.7.1 | ||
* http://dustjs.com/ | ||
@@ -54,2 +54,3 @@ * Copyright (c) 2015 Aleksander Williams; Released under the MIT License */ | ||
var state = { | ||
isPending: false, | ||
isResolved: false, | ||
@@ -112,3 +113,3 @@ isDeferredComplete: false, | ||
selectState = getSelectState(context) || {}, | ||
key, value, type; | ||
willResolve, key, value, type; | ||
@@ -136,10 +137,16 @@ // Once one truth test in a select passes, short-circuit the rest of the tests | ||
if (test(key, value)) { | ||
if (selectState) { | ||
// Once a truth test passes, put the select into "pending" state. Now we can render the body of | ||
// the truth test (which may contain truth tests) without altering the state of the select. | ||
if (!selectState.isPending) { | ||
willResolve = true; | ||
selectState.isPending = true; | ||
} | ||
if (body) { | ||
chunk = chunk.render(body, context); | ||
} | ||
if (willResolve) { | ||
selectState.isResolved = true; | ||
} | ||
if(body) { | ||
return chunk.render(body, context); | ||
} | ||
} else if (skip) { | ||
return chunk.render(skip, context); | ||
chunk = chunk.render(skip, context); | ||
} | ||
@@ -146,0 +153,0 @@ return chunk; |
@@ -1,4 +0,4 @@ | ||
/*! dustjs-helpers - v1.7.0 | ||
/*! dustjs-helpers - v1.7.1 | ||
* http://dustjs.com/ | ||
* Copyright (c) 2015 Aleksander Williams; Released under the MIT License */ | ||
!function(a,b){"function"==typeof define&&define.amd&&define.amd.dust===!0?define(["dust.core"],b):"object"==typeof exports?module.exports=b(require("dustjs-linkedin")):b(a.dust)}(this,function(dust){function a(a,b,c){c=c||"INFO",a=a?"{@"+a+"}: ":"",dust.log(a+b,c)}function b(b){k[b]||(a(b,"Deprecation warning: "+b+" is deprecated and will be removed in a future version of dustjs-helpers","WARN"),a(null,"For help and a deprecation timeline, see https://github.com/linkedin/dustjs-helpers/wiki/Deprecated-Features#"+b.replace(/\W+/g,""),"WARN"),k[b]=!0)}function c(a){return a.stack.tail&&a.stack.tail.head&&"undefined"!=typeof a.stack.tail.head.__select__}function d(a){return c(a)&&a.get("__select__")}function e(a,b){var c,d=a.stack.head,e=a.rebase();a.stack&&a.stack.tail&&(e.stack=a.stack.tail);var f={isResolved:!1,isDeferredComplete:!1,deferreds:[]};for(c in b)f[c]=b[c];return e.push({__select__:f}).push(d,a.stack.index,a.stack.of)}function f(a){var b,c;if(a.deferreds.length)for(a.isDeferredComplete=!0,b=0,c=a.deferreds.length;c>b;b++)a.deferreds[b]()}function g(a,b){return"function"==typeof b?b.toString().replace(/(^\s+|\s+$)/gm,"").replace(/\n/gm,"").replace(/,\s*/gm,", ").replace(/\)\{/gm,") {"):b}function h(a,b){return function(c,d,e,f){return i(c,d,e,f,a,b)}}function i(b,c,e,f,g,h){var i,k,l,m=e.block,n=e["else"],o=d(c)||{};if(o.isResolved)return b;if(f.hasOwnProperty("key"))i=f.key;else{if(!o.hasOwnProperty("key"))return a(g,"No key specified","WARN"),b;i=o.key}if(l=f.type||o.type,i=j(c.resolve(i),l),k=j(c.resolve(f.value),l),h(i,k)){if(o&&(o.isResolved=!0),m)return b.render(m,c)}else if(n)return b.render(n,c);return b}function j(a,b){switch(b&&(b=b.toLowerCase()),b){case"number":return+a;case"string":return String(a);case"boolean":return a="false"===a?!1:a,Boolean(a);case"date":return new Date(a)}return a}var k={},l={tap:function(a,c,d){return b("tap"),d.resolve(a)},sep:function(a,b,c){var d=c.block;return b.stack.index===b.stack.of-1?a:d?d(a,b):a},first:function(a,b,c){return 0===b.stack.index?c.block(a,b):a},last:function(a,b,c){return b.stack.index===b.stack.of-1?c.block(a,b):a},contextDump:function(b,c,d,e){var f,h,i=c.resolve(e.to),j=c.resolve(e.key);switch(j){case"full":f=c.stack;break;default:f=c.stack.head}switch(h=JSON.stringify(f,g,2),i){case"console":a("contextDump",h);break;default:h=h.replace(/</g,"\\u003c"),b=b.write(h)}return b},math:function(b,c,g,h){var i,j=h.key,k=h.method,l=h.operand,m=h.round;if(!h.hasOwnProperty("key")||!h.method)return a("math","`key` or `method` was not provided","ERROR"),b;switch(j=parseFloat(c.resolve(j)),l=parseFloat(c.resolve(l)),k){case"mod":0===l&&a("math","Division by 0","ERROR"),i=j%l;break;case"add":i=j+l;break;case"subtract":i=j-l;break;case"multiply":i=j*l;break;case"divide":0===l&&a("math","Division by 0","ERROR"),i=j/l;break;case"ceil":case"floor":case"round":case"abs":i=Math[k](j);break;case"toint":i=parseInt(j,10);break;default:a("math","Method `"+k+"` is not supported","ERROR")}return"undefined"!=typeof i&&(m&&(i=Math.round(i)),g&&g.block?(c=e(c,{key:i}),b=b.render(g.block,c),f(d(c))):b=b.write(i)),b},select:function(b,c,g,h){var i=g.block,j={};return h.hasOwnProperty("key")&&(j.key=c.resolve(h.key)),h.hasOwnProperty("type")&&(j.type=h.type),i?(c=e(c,j),b=b.render(i,c),f(d(c))):a("select","Missing body block","WARN"),b},eq:h("eq",function(a,b){return a===b}),ne:h("ne",function(a,b){return a!==b}),lt:h("lt",function(a,b){return b>a}),lte:h("lte",function(a,b){return b>=a}),gt:h("gt",function(a,b){return a>b}),gte:h("gte",function(a,b){return a>=b}),any:function(b,c,e,f){var g=d(c);return g?g.isDeferredComplete?a("any","Must not be nested inside {@any} or {@none} block","ERROR"):b=b.map(function(a){g.deferreds.push(function(){g.isResolved&&(a=a.render(e.block,c)),a.end()})}):a("any","Must be used inside a {@select} block","ERROR"),b},none:function(b,c,e,f){var g=d(c);return g?g.isDeferredComplete?a("none","Must not be nested inside {@any} or {@none} block","ERROR"):b=b.map(function(a){g.deferreds.push(function(){g.isResolved||(a=a.render(e.block,c)),a.end()})}):a("none","Must be used inside a {@select} block","ERROR"),b},size:function(a,b,c,d){var e,f,g=d.key;if(g=b.resolve(d.key),g&&g!==!0)if(dust.isArray(g))e=g.length;else if(!isNaN(parseFloat(g))&&isFinite(g))e=g;else if("object"==typeof g){e=0;for(f in g)g.hasOwnProperty(f)&&e++}else e=(g+"").length;else e=0;return a.write(e)}};for(var m in l)dust.helpers[m]=l[m];return dust}); | ||
!function(a,b){"function"==typeof define&&define.amd&&define.amd.dust===!0?define(["dust.core"],b):"object"==typeof exports?module.exports=b(require("dustjs-linkedin")):b(a.dust)}(this,function(dust){function a(a,b,c){c=c||"INFO",a=a?"{@"+a+"}: ":"",dust.log(a+b,c)}function b(b){k[b]||(a(b,"Deprecation warning: "+b+" is deprecated and will be removed in a future version of dustjs-helpers","WARN"),a(null,"For help and a deprecation timeline, see https://github.com/linkedin/dustjs-helpers/wiki/Deprecated-Features#"+b.replace(/\W+/g,""),"WARN"),k[b]=!0)}function c(a){return a.stack.tail&&a.stack.tail.head&&"undefined"!=typeof a.stack.tail.head.__select__}function d(a){return c(a)&&a.get("__select__")}function e(a,b){var c,d=a.stack.head,e=a.rebase();a.stack&&a.stack.tail&&(e.stack=a.stack.tail);var f={isPending:!1,isResolved:!1,isDeferredComplete:!1,deferreds:[]};for(c in b)f[c]=b[c];return e.push({__select__:f}).push(d,a.stack.index,a.stack.of)}function f(a){var b,c;if(a.deferreds.length)for(a.isDeferredComplete=!0,b=0,c=a.deferreds.length;c>b;b++)a.deferreds[b]()}function g(a,b){return"function"==typeof b?b.toString().replace(/(^\s+|\s+$)/gm,"").replace(/\n/gm,"").replace(/,\s*/gm,", ").replace(/\)\{/gm,") {"):b}function h(a,b){return function(c,d,e,f){return i(c,d,e,f,a,b)}}function i(b,c,e,f,g,h){var i,k,l,m,n=e.block,o=e["else"],p=d(c)||{};if(p.isResolved)return b;if(f.hasOwnProperty("key"))k=f.key;else{if(!p.hasOwnProperty("key"))return a(g,"No key specified","WARN"),b;k=p.key}return m=f.type||p.type,k=j(c.resolve(k),m),l=j(c.resolve(f.value),m),h(k,l)?(p.isPending||(i=!0,p.isPending=!0),n&&(b=b.render(n,c)),i&&(p.isResolved=!0)):o&&(b=b.render(o,c)),b}function j(a,b){switch(b&&(b=b.toLowerCase()),b){case"number":return+a;case"string":return String(a);case"boolean":return a="false"===a?!1:a,Boolean(a);case"date":return new Date(a)}return a}var k={},l={tap:function(a,c,d){return b("tap"),d.resolve(a)},sep:function(a,b,c){var d=c.block;return b.stack.index===b.stack.of-1?a:d?d(a,b):a},first:function(a,b,c){return 0===b.stack.index?c.block(a,b):a},last:function(a,b,c){return b.stack.index===b.stack.of-1?c.block(a,b):a},contextDump:function(b,c,d,e){var f,h,i=c.resolve(e.to),j=c.resolve(e.key);switch(j){case"full":f=c.stack;break;default:f=c.stack.head}switch(h=JSON.stringify(f,g,2),i){case"console":a("contextDump",h);break;default:h=h.replace(/</g,"\\u003c"),b=b.write(h)}return b},math:function(b,c,g,h){var i,j=h.key,k=h.method,l=h.operand,m=h.round;if(!h.hasOwnProperty("key")||!h.method)return a("math","`key` or `method` was not provided","ERROR"),b;switch(j=parseFloat(c.resolve(j)),l=parseFloat(c.resolve(l)),k){case"mod":0===l&&a("math","Division by 0","ERROR"),i=j%l;break;case"add":i=j+l;break;case"subtract":i=j-l;break;case"multiply":i=j*l;break;case"divide":0===l&&a("math","Division by 0","ERROR"),i=j/l;break;case"ceil":case"floor":case"round":case"abs":i=Math[k](j);break;case"toint":i=parseInt(j,10);break;default:a("math","Method `"+k+"` is not supported","ERROR")}return"undefined"!=typeof i&&(m&&(i=Math.round(i)),g&&g.block?(c=e(c,{key:i}),b=b.render(g.block,c),f(d(c))):b=b.write(i)),b},select:function(b,c,g,h){var i=g.block,j={};return h.hasOwnProperty("key")&&(j.key=c.resolve(h.key)),h.hasOwnProperty("type")&&(j.type=h.type),i?(c=e(c,j),b=b.render(i,c),f(d(c))):a("select","Missing body block","WARN"),b},eq:h("eq",function(a,b){return a===b}),ne:h("ne",function(a,b){return a!==b}),lt:h("lt",function(a,b){return b>a}),lte:h("lte",function(a,b){return b>=a}),gt:h("gt",function(a,b){return a>b}),gte:h("gte",function(a,b){return a>=b}),any:function(b,c,e,f){var g=d(c);return g?g.isDeferredComplete?a("any","Must not be nested inside {@any} or {@none} block","ERROR"):b=b.map(function(a){g.deferreds.push(function(){g.isResolved&&(a=a.render(e.block,c)),a.end()})}):a("any","Must be used inside a {@select} block","ERROR"),b},none:function(b,c,e,f){var g=d(c);return g?g.isDeferredComplete?a("none","Must not be nested inside {@any} or {@none} block","ERROR"):b=b.map(function(a){g.deferreds.push(function(){g.isResolved||(a=a.render(e.block,c)),a.end()})}):a("none","Must be used inside a {@select} block","ERROR"),b},size:function(a,b,c,d){var e,f,g=d.key;if(g=b.resolve(d.key),g&&g!==!0)if(dust.isArray(g))e=g.length;else if(!isNaN(parseFloat(g))&&isFinite(g))e=g;else if("object"==typeof g){e=0;for(f in g)g.hasOwnProperty(f)&&e++}else e=(g+"").length;else e=0;return a.write(e)}};for(var m in l)dust.helpers[m]=l[m];return dust}); |
@@ -51,2 +51,3 @@ (function(root, factory) { | ||
var state = { | ||
isPending: false, | ||
isResolved: false, | ||
@@ -109,3 +110,3 @@ isDeferredComplete: false, | ||
selectState = getSelectState(context) || {}, | ||
key, value, type; | ||
willResolve, key, value, type; | ||
@@ -133,10 +134,16 @@ // Once one truth test in a select passes, short-circuit the rest of the tests | ||
if (test(key, value)) { | ||
if (selectState) { | ||
// Once a truth test passes, put the select into "pending" state. Now we can render the body of | ||
// the truth test (which may contain truth tests) without altering the state of the select. | ||
if (!selectState.isPending) { | ||
willResolve = true; | ||
selectState.isPending = true; | ||
} | ||
if (body) { | ||
chunk = chunk.render(body, context); | ||
} | ||
if (willResolve) { | ||
selectState.isResolved = true; | ||
} | ||
if(body) { | ||
return chunk.render(body, context); | ||
} | ||
} else if (skip) { | ||
return chunk.render(skip, context); | ||
chunk = chunk.render(skip, context); | ||
} | ||
@@ -143,0 +150,0 @@ return chunk; |
{ | ||
"name": "dustjs-helpers", | ||
"version": "1.7.0", | ||
"version": "1.7.1", | ||
"author": { | ||
@@ -25,3 +25,3 @@ "name": "Aleksander Williams", | ||
"scripts": { | ||
"test": "grunt test" | ||
"test": "grunt travis" | ||
}, | ||
@@ -48,2 +48,3 @@ "main": "./lib/dust-helpers", | ||
"grunt": "~0.4.2", | ||
"grunt-cli": "~0.1.13", | ||
"grunt-contrib-jshint": "~0.11.1", | ||
@@ -50,0 +51,0 @@ "grunt-contrib-jasmine": "~0.8.2", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Environment variable access
Supply chain riskPackage accesses environment variables, which may be a sign of credential stuffing or data theft.
Found 1 instance in 1 package
Filesystem access
Supply chain riskAccesses the file system, and could potentially read sensitive data.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
50414
9
1123
0
14
2