Skip Navigation

InitialsDiceBearhttps://github.com/dicebear/dicebearhttps://creativecommons.org/publicdomain/zero/1.0/„Initials” (https://github.com/dicebear/dicebear) by „DiceBear”, licensed under „CC0 1.0” (https://creativecommons.org/publicdomain/zero/1.0/)SW
Posts
15
Comments
274
Joined
1 yr. ago

  •  
        
    type NonEmptyArray<T> = [T, ...T[]];
    
    function isNonEmptyArray<T>(arr: T[]): arr is NonEmptyArray<T> {
        return arr.length > 0;
    }
    
    function neverEmpty<T>(array: T[]): NonEmptyArray<T> | null {  
        if (!isNonEmptyArray(array)) return null
    
        return array
    }