1
0
Fork 0
js-utils/docs/api/js-utils.hasitems.md

27 lines
870 B
Markdown

<!-- Do not edit this file. It is automatically generated by API Documenter. -->
[Home](./index.md) &gt; [@apextoaster/js-utils](./js-utils.md) &gt; [hasItems](./js-utils.hasitems.md)
## hasItems() function
Test if a value is an array with some items (length &gt; 0).
This is not a general replacement for `.length > 0`<!-- -->, since it is also a typeguard: `if (hasItems(val)) else { val }` will complain that `val` is `never` in the `else` branch, since it was proven not to be an array by this function, even if `val` is simply empty.
<b>Signature:</b>
```typescript
export declare function hasItems<T>(val: Maybe<Array<T>>): val is Array<T>;
```
## Parameters
| Parameter | Type | Description |
| --- | --- | --- |
| val | [Maybe](./js-utils.maybe.md)<!-- -->&lt;Array&lt;T&gt;&gt; | |
<b>Returns:</b>
val is Array&lt;T&gt;