/**
* @author [Tristan Valcke]{@link https://github.com/Itee}
* @license [BSD-3-Clause]{@link https://opensource.org/licenses/BSD-3-Clause}
*
* @module sources/cores/arrays/isArrayOfUndefined
* @desc Export function to validate if a value is an array of undefined values or not
* @example
*
* import { isArrayOfUndefined } from 'itee-validators'
*
* if( isArrayOfUndefined( value ) ) {
* //...
* } else {
* //...
* }
*
*/
import { isNotUndefined } from '../voids/isUndefined.js'
import { isNotArray } from './isArray.js'
import { isEmptyArray } from './isEmptyArray.js'
/**
* Check if given data is not an empty array where all values are undefined
*
* @param data {*} The data to check against the array of undefined
* @returns {boolean} true if data is not an empty array where all values are undefined, false otherwise
*/
export function isArrayOfUndefined( data ) {
if ( isNotArray( data ) ) { return false }
if ( isEmptyArray( data ) ) { return false }
for ( let index = 0, dataLength = data.length ; index < dataLength ; index++ ) {
if ( isNotUndefined( data[ index ] ) ) {
return false
}
}
return true
}
/**
* Check if given data is not an empty array where all values are defined
*
* @param data {*} The data to check against the array of undefined
* @returns {boolean} true if data is not an empty array where all values are defined, false otherwise
*/
export function isNotArrayOfUndefined( data ) {
if ( isNotArray( data ) ) { return true }
if ( isEmptyArray( data ) ) { return true }
for ( let index = 0, dataLength = data.length ; index < dataLength ; index++ ) {
if ( isNotUndefined( data[ index ] ) ) {
return true
}
}
return false
}