Created
November 8, 2022 17:29
-
-
Save ValentaTomas/a5621836636c96b20a16d237670413d4 to your computer and use it in GitHub Desktop.
Wrap the argument in an array if it is not already an array
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
export function asArray<T>(item: T | T[]) { | |
return Array.isArray(item) ? item : [item] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment