Arrays.isNotEmpty()
Syntax
function isNotEmpty(iterable: Iterable<unknown> | HasLength | HasSize): boolean
Checks whether an iterable is not empty.
Parameters | |
iterable
|
An iterable with any number of elements. |
Example
import { Arrays } from 'potence';
Arrays.isEmpty([]); // -> false
Arrays.isEmpty([1, 2, 3]); // -> true
Arrays.isEmpty(new Set()); // -> false
Remarks
If the iterable has a length
or size
property, this function simply checks
whether its value is not 0
. If the iterable has neither, this function checks
whether its iterator returns any elements. This means that the time complexity
of this function is O(1) for both array-likes and other iterables.
Compare
Arrays.isEmpty()
.