logoalt Hacker News

slopinthebag • yesterday at 10:20 PM • 2 replies • view on HN

did you read the docs? it says

"Use when you need to guarantee a non-empty result after adding a required trailing value."

...whatever that means lol


Replies

itishappy • today at 1:30 AM

NonEmpty is a type that allows you to distinguish between:

    a = [undefined];
    res = a.pop() // undefined

    a = [];
    res = a.pop() // undefined
➕ show 1 reply
spaethnl • today at 12:14 AM

The types allow you to very narrowly define functions so that you can, for example, require that a NonEmptyArray be passed. This helps to fulfill that requirement without casts.