Permalink
Browse files

use merge, minor optimizations

  • Loading branch information...
1 parent 8fcdfe3 commit adc061d140177d38dcbdb28a9aaa2d7defced951 @jonschlinkert jonschlinkert committed Jan 8, 2017
Showing with 12 additions and 18 deletions.
  1. +9 −15 lib/comparison.js
  2. +3 −3 lib/utils/index.js
View
@@ -442,30 +442,24 @@ helpers.neither = function(a, b, options) {
* ```
*
* @name .or
- * @param {...any} `arguments`,
- * @param `options` Handlebars options object
+ * @param {...any} `arguments` Variable number of arguments
+ * @param {Object} `options` Handlebars options object
* @return {String} Block, or inverse block if specified and falsey.
* @block
* @api public
*/
helpers.or = function(/* any, any, ..., options */) {
- var argLength = arguments.length - 1;
- var options = arguments[argLength];
- var success = false;
- var i = 0;
- while (i < argLength) {
+ var len = arguments.length - 1;
+ var options = arguments[len];
+
+ for (var i = 0; i < len; i++) {
if (arguments[i]) {
- success = true;
- break;
+ return options.fn(this);
}
- i++;
- }
- if (success) {
- return options.fn(this);
- } else {
- return options.inverse(this);
}
+
+ return options.inverse(this);
};
/**
View
@@ -173,7 +173,7 @@ utils.isOptions = function(val) {
*/
utils.getArgs = function(app, args) {
- var opts = Object.assign({}, app && app.options);
+ var opts = utils.merge({}, app && app.options);
if (!Array.isArray(args)) {
args = [].slice.call(args);
}
@@ -184,12 +184,12 @@ utils.getArgs = function(app, args) {
if (utils.isOptions(last)) {
var hbsOptions = args.pop();
opts = utils.get(opts, hbsOptions.name) || opts;
- opts = Object.assign({}, opts, hbsOptions.hash);
+ opts = utils.merge({}, opts, hbsOptions.hash);
// if the last arg is an object, merge it
// into the options
} else if (utils.isObject(last)) {
- opts = Object.assign({}, opts, args.pop());
+ opts = utils.merge({}, opts, args.pop());
}
args.push(opts);

0 comments on commit adc061d

Please sign in to comment.