Nickelback Plays Music

    is-non-nullable
    TypeScript icon, indicating that this package has built-in type declarations

    1.0.2 • Public • Published

    is-non-nullable

    npm version test

    Just function to predicate non nullable with type guard.

    Install

    $ npm install is-non-nullable
    

    Usage

    import isNonNullable from 'is-non-nullable'
    
    isNonNullable('foo')
    //=> true
    
    isNonNullable('')
    //=> true
    
    isNonNullable(0)
    //=> true
    
    isNonNullable(false)
    //=> true
    
    isNonNullable(null)
    //=> false
    
    isNonNullable(undefined)
    //=> false
    

    Type narrowing with Array.filter

    const items: (number | null | undefined)[] = [0, 1, null, undefined, 2]
    
    const filtered = items.filter(isNonNullable)
    //=> number[]
    

    Install

    npm i is-non-nullable

    DownloadsWeekly Downloads

    198

    Version

    1.0.2

    License

    MIT

    Unpacked Size

    6.95 kB

    Total Files

    9

    Last publish

    Collaborators

    • pnly