0.0.3 • Published 4 years ago

typescript-essentials v0.0.3

Weekly downloads
1
License
MIT
Repository
-
Last release
4 years ago

Typescript Essentials

Must-have utility types and functions for TypeScript

NPM version NPM downloads Build status All Contributors

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 and TypeGuard interfaces
  • not() function to negate predicates
  • isNull() type guard
  • isUndefined() type guard
  • isNullOrUndefined() type guard
  • isNotNull() type guard
  • isNotUndefined() type guard
  • isNotNullOrUndefined() type guard
  • matchesDiscriminator() function that returns a type guard

Ordered

  • Ordered<T> interface
  • compareByOrder() comparator function

Generics

  • DiscriminatedUnion to narrow a union type using a discriminator field
  • WithPartial to make certain properties optional
  • Narrowable 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 and createTrackByFn functions

Contributors ✨

Thanks goes to these wonderful people (emoji key):

This project follows the all-contributors specification. Contributions of any kind welcome!

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago