typescript-essentials
v0.0.3
Published
Must-have utility types and functions for TypeScript
Downloads
9
Readme
Typescript Essentials
Must-have utility types and functions for TypeScript
Overview
This is a small util library which contains several types and functions that may be useful in your TypeScript project.
Getting started 🌩
npm
npm install typescript-essentials
yarn
yarn add typescript-essentials
Contents
Predicates & type guards
Useful to compose simple predicates, or to narrow types in arrays or other data structures.
Predicate
andTypeGuard
interfacesnot()
function to negate predicatesisNull()
type guardisUndefined()
type guardisNullOrUndefined()
type guardisNotNull()
type guardisNotUndefined()
type guardisNotNullOrUndefined()
type guardmatchesDiscriminator()
function that returns a type guard
Ordered
Ordered<T>
interfacecompareByOrder()
comparator function
Generics
DiscriminatedUnion
to narrow a union type using a discriminator fieldWithPartial
to make certain properties optionalNarrowable
to identify a type that can be narrowed
Array utils
uniqueValues()
exclude()
partition()
Object utils
omit
function (to omit specific properties from objects)
Angular utils
trackByIndex
,trackById
andcreateTrackByFn
functions
Contributors ✨
Thanks goes to these wonderful people (emoji key):
This project follows the all-contributors specification. Contributions of any kind welcome!