[Code Style] Use prototypes in forms bundle

WTD-1482.
This commit is contained in:
Victor Woeltjen
2015-08-14 13:40:33 -07:00
parent 1c187c3914
commit 7fe866060b
4 changed files with 42 additions and 45 deletions

View File

@ -39,32 +39,25 @@ define(
* @constructor
*/
function CompositeController() {
// Check if an element is defined; the map step of isNonEmpty
function isDefined(element) {
return typeof element !== 'undefined';
}
// Boolean or; the reduce step of isNonEmpty
function or(a, b) {
return a || b;
}
return {
/**
* Check if an array contains anything other than
* undefined elements.
* @param {Array} value the array to check
* @returns {boolean} true if any non-undefined
* element is in the array
* @memberof platform/forms.CompositeController#
*/
isNonEmpty: function (value) {
return Array.isArray(value) &&
value.map(isDefined).reduce(or, false);
}
};
}
// Check if an element is defined; the map step of isNonEmpty
function isDefined(element) {
return typeof element !== 'undefined';
}
/**
* Check if an array contains anything other than
* undefined elements.
* @param {Array} value the array to check
* @returns {boolean} true if any non-undefined
* element is in the array
* @memberof platform/forms.CompositeController#
*/
CompositeController.prototype.isNonEmpty = function (value) {
return Array.isArray(value) && value.some(isDefined);
};
return CompositeController;
}