Skip to content

Commit

Permalink
minor fixes, code comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jonschlinkert committed Dec 30, 2015
1 parent 3a75203 commit b07854d
Show file tree
Hide file tree
Showing 5 changed files with 50 additions and 53 deletions.
24 changes: 12 additions & 12 deletions lib/array.js
Original file line number Diff line number Diff line change
Expand Up @@ -87,9 +87,9 @@ helpers.eachIndex = function(array, options) {

/**
* @name .filter
* @param {type} `array`
* @param {type} `value`
* @param {type} `options`
* @param {Array} `array`
* @param {any} `value`
* @param {Object} `options`
* @return {String}
* @block
* @api public
Expand Down Expand Up @@ -215,9 +215,9 @@ helpers.forEach = function(array, options) {
* ```
*
* @name .inArray
* @param {type} `array`
* @param {type} `value`
* @param {type} `options`
* @param {Array} `array`
* @param {any} `value`
* @param {Object} `options`
* @return {String}
* @block
* @api public
Expand Down Expand Up @@ -301,9 +301,9 @@ helpers.last = function(array, n) {
* otherwise an inverse block may optionally be returned.
*
* @name .lengthEqual
* @param {type} `array`
* @param {type} `length`
* @param {type} `options`
* @param {Array} `array`
* @param {Number} `length`
* @param {Object} `options`
* @return {String}
* @block
* @api public
Expand Down Expand Up @@ -566,9 +566,9 @@ helpers.withLast = function(array, idx, options) {
* collection as context inside the block.
*
* @name .withSort
* @param {type} `array`
* @param {type} `prop`
* @param {type} `options` Specify `reverse="true"` to reverse the array.
* @param {Array} `array`
* @param {String} `prop`
* @param {Object} `options` Specify `reverse="true"` to reverse the array.
* @return {String}
* @block
* @api public
Expand Down
4 changes: 2 additions & 2 deletions lib/collection.js
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@ var helpers = module.exports;
* (if supplied).
*
* @name .isEmpty
* @param {type} `collection`
* @param {type} `options`
* @param {Object} `collection`
* @param {Object} `options`
* @return {String}
* @block
* @api public
Expand Down
24 changes: 10 additions & 14 deletions lib/inflection.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,26 +10,21 @@ var helpers = module.exports;

/**
* @name .inflect
* @param {type} `count`
* @param {type} `singular`
* @param {type} `plural`
* @param {type} `include`
* @param {Number} `count`
* @param {String} `singular` The singular form
* @param {String} `plural` The plural form
* @param {String} `include`
* @return {String}
* @api public
*/

helpers.inflect = function(count, singular, plural, include) {
var word = count > 1 || count === 0
? plural
: singular;
var word = (count > 1 || count === 0) ? plural : singular;

if (utils.isUndefined(include) || include === false) {
return word;
} else {
return ''
+ count
+ ' '
+ word;
return String(count) + ' ' + word;
}
};

Expand All @@ -54,9 +49,9 @@ helpers.inflect = function(count, singular, plural, include) {

helpers.ordinalize = function(val) {
var num = Math.abs(Math.round(val));
var res;
var res = num % 100;

if (res = num % 100, utils.indexOf([11, 12, 13], res) >= 0) {
if (utils.indexOf([11, 12, 13], res) >= 0) {
return '' + val + 'th';
}

Expand All @@ -67,7 +62,8 @@ helpers.ordinalize = function(val) {
return '' + val + 'nd';
case 3:
return '' + val + 'rd';
default:
default: {
return '' + val + 'th';
}
}
};
18 changes: 7 additions & 11 deletions lib/misc.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,10 @@ var helpers = module.exports;
* Returns the first value if defined, otherwise the second ("default")
* value is returned.
*
* @name .default
* @alias .or
* @param {type} `value`
* @param {type} `defaultValue`
* @param {any} `value`
* @param {any} `defaultValue`
* @return {String}
* @alias .or
* @api public
*/

Expand All @@ -30,11 +29,10 @@ helpers.default = function(value, defaultValue) {
* Returns the first value if defined, otherwise the
* second value is returned.
*
* @name .or
* @alias .default
* @param {type} `value`
* @param {type} `defaultValue`
* @param {any} `value`
* @param {any} `defaultValue`
* @return {String}
* @alias .default
* @api public
*/

Expand All @@ -52,8 +50,7 @@ helpers.or = function(value, defaultValue) {
* ```
* Returns `ddd`
*
* @name .option
* @param {type} `prop`
* @param {String} `prop`
* @return {any}
* @api public
*/
Expand All @@ -66,7 +63,6 @@ helpers.option = function(prop) {
/**
* Block helper that renders the block without taking any arguments.
*
* @name .noop
* @param {type} `options`
* @return {String}
* @block
Expand Down
33 changes: 19 additions & 14 deletions lib/number.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,33 +83,38 @@ helpers.toAbbr = function(number, precision) {
};

/**
* @name .toExponential
* @param {type} `number`
* @param {type} `fractions`
* Returns a string representing the given number in exponential notation.
*
* ```js
* {{toExponential number digits}};
* ```
* @param {Number} `number`
* @param {Number} `fractionDigits` Optional. An integer specifying the number of digits to use after the decimal point. Defaults to as many digits as necessary to specify the number.
* @return {Number}
* @api public
*/

helpers.toExponential = function(number, fractions) {
if (utils.isUndefined(fractions)) {
fractions = 0;
helpers.toExponential = function(number, digits) {
if (utils.isUndefined(digits)) {
digits = 0;
}
return number.toExponential(fractions);
return number.toExponential(digits);
};

/**
* @name .toFixed
* @param {type} `number`
* @param {type} `precision`
* Formats the given number using fixed-point notation.
*
* @param {Number} `number`
* @param {Number} `digits` Optional. The number of digits to use after the decimal point; this may be a value between 0 and 20, inclusive, and implementations may optionally support a larger range of values. If this argument is omitted, it is treated as 0.
* @return {Number}
* @api public
*/

helpers.toFixed = function(number, precision) {
if (utils.isUndefined(precision)) {
precision = 0;
helpers.toFixed = function(number, digits) {
if (utils.isUndefined(digits)) {
digits = 0;
}
return number.toFixed(precision);
return number.toFixed(digits);
};

/**
Expand Down

0 comments on commit b07854d

Please sign in to comment.