Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(list): add utils from salty-dog
- Loading branch information
Showing
7 changed files
with
151 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [@apextoaster/js-utils](./js-utils.md) > [ensureArray](./js-utils.ensurearray.md) | ||
|
||
## ensureArray() function | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
export declare function ensureArray<T>(val: Optional<Array<T>>): Array<T>; | ||
``` | ||
|
||
## Parameters | ||
|
||
| Parameter | Type | Description | | ||
| --- | --- | --- | | ||
| val | <code>Optional<Array<T>></code> | | | ||
|
||
<b>Returns:</b> | ||
|
||
`Array<T>` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [@apextoaster/js-utils](./js-utils.md) > [hasItems](./js-utils.hasitems.md) | ||
|
||
## hasItems() function | ||
|
||
Test if a value is an array with some items (length > 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: Optional<Array<T>>): val is Array<T>; | ||
``` | ||
|
||
## Parameters | ||
|
||
| Parameter | Type | Description | | ||
| --- | --- | --- | | ||
| val | <code>Optional<Array<T>></code> | | | ||
|
||
<b>Returns:</b> | ||
|
||
`val is Array<T>` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
<!-- Do not edit this file. It is automatically generated by API Documenter. --> | ||
|
||
[Home](./index.md) > [@apextoaster/js-utils](./js-utils.md) > [hasItems](./js-utils.hasitems_1.md) | ||
|
||
## hasItems() function | ||
|
||
<b>Signature:</b> | ||
|
||
```typescript | ||
export declare function hasItems<T>(val: Optional<ReadonlyArray<T>>): val is ReadonlyArray<T>; | ||
``` | ||
|
||
## Parameters | ||
|
||
| Parameter | Type | Description | | ||
| --- | --- | --- | | ||
| val | <code>Optional<ReadonlyArray<T>></code> | | | ||
|
||
<b>Returns:</b> | ||
|
||
`val is ReadonlyArray<T>` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters