0.2.0-alpha • Published 5 years ago

@perfective/value v0.2.0-alpha

Weekly downloads
27
License
MIT
Repository
github
Last release
5 years ago

Value

The @perfective/value package provides functions to work with undefined and null values and utility types (similar to the TS NonNullable<T> to describe some of such values.

  • Utility types:
    • type Defined<T> = T extends undefined ? never : T
    • type NotNull<T> = T extends null ? never : T
    • type Present<T> = T extends null | undefined ? never : T
    • type Absent<T> = T extends null | undefined ? T : never
  • Type Guards:
    • isDefined<T>(value: T | undefined): value is T
    • isUndefined<T>(value: T | undefined): value is undefined
    • isNotNull<T>(value: T | null): value is T
    • isNull<T>(value: T | null): value is null
    • isPresent<T>(value: T | null | undefined): value is T
    • isAbsent<T>(value: T | null | undefined): value is null | undefined
  • Handling void:
    • voidable<T>(value: T | void): T | null | undefined

Full documentation is available in the repository.