🚀 Big News:Socket Has Acquired Secure Annex.Learn More
Socket
Book a DemoSign in
Socket

dustjs-helpers

Package Overview
Dependencies
Maintainers
4
Versions
17
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

dustjs-helpers - npm Package Compare versions

Comparing version
1.7.0
to
1.7.1
+260
Gruntfile.js
module.exports = function (grunt) {
//--------------------------------------------------
//------------Project config------------------------
//--------------------------------------------------
grunt.initConfig({
pkg: grunt.file.readJSON('package.json'),
banner: '/*! <%= pkg.title || pkg.name %> - v<%= pkg.version %>\n' +
'<%= pkg.homepage ? "* " + pkg.homepage + "\\n" : "" %>' +
'* Copyright (c) <%= grunt.template.today("yyyy") %> <%= pkg.author.name %>;' +
' Released under the <%= pkg.license %> License */\n',
distName: '<%=pkg.name%>-<%=pkg.version%>',
paths: {
project: __dirname,
lib: '<%=paths.project%>/lib',
build: '<%=paths.project%>/tmp',
helpers: '<%=paths.build%>/dust-helpers.js',
helpersMin: '<%=paths.build%>/dust-helpers.min.js',
test: '<%=paths.project%>/test',
testSpecs: '<%=paths.test%>/jasmine-test/spec',
dust: '<%=paths.project%>/node_modules/dustjs-linkedin/dist/dust-full.js',
dustMin: '<%=paths.project%>/node_modules/dustjs-linkedin/dist/dust-full.min.js',
dist: '<%=paths.project%>/dist',
archive: '<%=paths.project%>/archive'
},
jshint : {
options: {
jshintrc: true
},
gruntfile: {
src: 'gruntfile.js'
},
libs: {
src: ['<%=paths.lib%>/**/*.js']
},
testSpecs: {
src: ['<%=paths.testSpecs%>/**/*.js']
}
},
clean : {
build: ['<%=paths.build%>']
},
copy : {
build : {
src: '<%=paths.lib%>/dust-helpers.js',
dest: '<%=paths.helpers%>',
options: {
process: function (content, srcpath) {
return grunt.template.process('<%= banner %>') + content;
}
}
},
release : {
files : [
{
src : '<%=paths.helpers%>',
dest : '<%=paths.dist%>/dust-helpers.js'
},
{
src : '<%=paths.helpersMin%>',
dest : '<%=paths.dist%>/dust-helpers.min.js'
},
{
src : 'LICENSE',
dest : '<%=paths.dist%>/LICENSE'
}
]
}
},
uglify: {
options: {
banner: '<%= banner %>',
mangle: {
except: ['require', 'define', 'module', 'dust']
}
},
build: {
files : {
'<%=paths.helpersMin%>' : ['<%=paths.helpers%>']
}
}
},
jasmine : {
/*tests production (minified) code*/
testProd : {
src : '<%=paths.helpersMin%>',
options: {
keepRunner: false,
display: 'short',
helpers: ['<%=paths.testSpecs%>/helpersTests.js'],
specs: ['<%=paths.test%>/testUtils.js', '<%=paths.testSpecs%>/renderTestSpec.js'],
vendor: ['<%=paths.dustMin%>']
}
},
/*tests unminified code, mostly used for debugging by `grunt dev` task*/
testDev : {
src: '<%=paths.helpers%>',
options : {
keepRunner: false,
specs : '<%=jasmine.testProd.options.specs%>',
helpers : '<%=jasmine.testProd.options.helpers%>',
vendor : ['<%=paths.dust%>']
}
},
/* Used for coverage report only based on unminified code.
Not suited for debugging because istanbul decorates and jumbles code*/
coverage : {
src: '<%=paths.helpers%>',
options : {
keepRunner: false,
display: 'none',
specs : '<%=jasmine.testProd.options.specs%>',
helpers : '<%=jasmine.testProd.options.helpers%>',
vendor : '<%=jasmine.testProd.options.vendor%>',
template: require('grunt-template-jasmine-istanbul'),
templateOptions: {
coverage: '<%=paths.build%>/coverage/coverage.json',
report: '<%=paths.build%>/coverage',
thresholds: {
lines: 90,
statements: 90,
branches: 80,
functions: 80
}
}
}
}
},
connect: {
testServer: {
options: {
port: 3000,
keepalive: false
}
}
},
shell : {
testNode: {
command: 'node test/server.js',
options: {
stdout: true,
failOnError: true
}
},
testRhino : {
command : function() {
var commandList = [],
fs = require('fs'),
rhinoFolder = 'test/rhino-test/';
fs.readdirSync(__dirname + '/' + rhinoFolder + 'lib').forEach( function(rhinoJar) {
if(rhinoJar.indexOf('.jar') >= 0) {
commandList.push('java -jar ' + rhinoFolder + 'lib/' + rhinoJar + ' -f ' + rhinoFolder + 'rhinoTest.js');
}
});
return commandList.join(' && ');
},
options : {
stdout: true,
failOnError: true
}
},
},
bump: {
options: {
files: ['package.json', 'bower.json'],
updateConfigs: ['pkg'],
push: false,
commit: true,
commitFiles: ['-a'],
createTag: true
}
},
log : {
testClient: {
message: 'Navigate to http://localhost:<%= connect.testServer.options.port %>/_SpecRunner.html\nCtrl-C to kill the server.'
},
coverage: {
message: 'Open <%=jasmine.coverage.options.templateOptions.report%>/index.html in the browser to view the coverage.'
}
},
watch: {
lib: {
files: ['<%=paths.lib%>/**/*.js'],
tasks: ['clean:build', 'buildLib']
},
gruntfile: {
files: '<%= jshint.gruntfile.src %>',
tasks: ['jshint:gruntfile']
},
lib_test: {
files: ['<%=paths.lib%>/**/*.js', '<%=paths.testSpecs%>/**/*.js'],
tasks: ['testPhantom']
}
},
githubChanges: {
dist: {
options: {
owner: "linkedin",
repository: "dustjs-helpers",
tagName: "v<%= pkg.version %>",
onlyPulls: true,
useCommitBody: true,
auth: true
}
}
}
});
//--------------------------------------------------
//------------Custom tasks -------------------------
//--------------------------------------------------
grunt.registerMultiTask('log', 'Print messages defined via config', function() {
grunt.log.ok(this.data.message);
});
//--------------------------------------------------
//------------External tasks -----------------------
//--------------------------------------------------
grunt.loadNpmTasks('grunt-contrib-jshint');
grunt.loadNpmTasks('grunt-contrib-clean');
grunt.loadNpmTasks('grunt-contrib-copy');
grunt.loadNpmTasks('grunt-contrib-uglify');
grunt.loadNpmTasks('grunt-contrib-jasmine');
grunt.loadNpmTasks('grunt-contrib-connect');
grunt.loadNpmTasks('grunt-contrib-watch');
grunt.loadNpmTasks('grunt-bump');
grunt.loadNpmTasks('grunt-shell');
grunt.loadNpmTasks('grunt-github-changes');
//--------------------------------------------------
//------------Grunt task aliases -------------------
//--------------------------------------------------
grunt.registerTask('buildLib', ['jshint:libs', 'copy:build']);
grunt.registerTask('build', ['clean:build', 'jshint:testSpecs', 'buildLib', 'uglify:build']);
//test tasks
grunt.registerTask('testNode', ['shell:testNode']);
grunt.registerTask('testRhino', ['build', 'shell:testRhino']);
grunt.registerTask('testPhantom', ['build', 'jasmine:testProd']);
grunt.registerTask('test', ['build', 'jasmine:testProd', 'testNode', 'shell:testRhino', 'jasmine:coverage']);
//decide whether to run all tests or just the Node tests for Travis CI
grunt.registerTask('travis', (process.env.TEST === 'all') ? ['test'] : ['testNode']);
//task for debugging in browser
grunt.registerTask('dev', ['build', 'jasmine:testDev:build', 'connect:testServer','log:testClient', 'watch:lib']);
//task to run unit tests on client against prod version of code
grunt.registerTask('testClient', ['build', 'jasmine:testProd:build', 'connect:testServer', 'log:testClient', 'watch:lib_test']);
//coverage report
grunt.registerTask('coverage', ['jasmine:coverage', 'log:coverage']);
//release tasks
grunt.registerTask('buildRelease', ['test', 'githubChanges', 'copy:release']);
grunt.registerTask('releasePatch', ['bump-only:patch', 'buildRelease', 'bump-commit']);
grunt.registerTask('releaseMinor', ['bump-only:minor', 'buildRelease', 'bump-commit']);
//default task - full test
grunt.registerTask('default', ['test']);
};
+1
-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",