mirror of
https://github.com/nasa/openmct.git
synced 2025-06-18 07:08:12 +00:00
[Code Style] Use prototypes in forms bundle
WTD-1482.
This commit is contained in:
@ -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;
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user