@giancosta86/swan-lake
v3.1.0
Published
Elegant TypeScript extensions
Downloads
14
Maintainers
Readme
swan-lake
Elegant TypeScript extensions
swan-lake is a library providing useful and minimalist extensions for the TypeScript language.
Installation
The package on NPM is:
@giancosta86/swan-lake
The public API entirely resides in the root package index, so one shouldn't reference specific modules.
Usage
ImmediateOrPromise<T>
- can be assigned aT
or aPromise<T>
AnyClass
is an alias forFunction
- to express a class, even ones having aprivate
constructorHasEquals
is an interface having anequals(other): boolean
method, whereother
belongs to the same type or a structurally compatible oneNone
is declared asundefined | null
Optional
is a namespace including:map
- returnsundefined
if the input value isnull
orundefined
, but applies the given mapper otherwiseequals
- this function returnstrue
if:both
left
andright
are eitherundefined
ornull
left
andright
are both defined andleft.equals(right)
returnstrue
Please, note: this function does not check whether the two operands belong to the same type - according to TypeScript's structural equality; should you have such specific requirement, you'll need to perform a dedicated check.
ExpressiveUrl::create
- creates a URL from a string - throwing a descriptive error on failure