4.0.8 • Published 4 years ago

super-simple v4.0.8

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

Super Simple & Safe(r) types for TypeScript

Using TypeScript's strict mode, null and undefined can no longer be used in an "unsafe" way.
Moreover, JavaScript now offers built-in operators, such as:

x ?? defaultValue
x?.propertyName

and

a?.[index]

analogous to <|> and >>= from Haskell.

Therefore, a Maybe implementation is no longer necessary.


As for arrays, unfortunately TypeScript allows unsafe indexing:

a[-1]

is allowed and if a is T[], the result is inferred to be of type T, which is not always true...

So a safer List<T> = readonly Maybe<T>[] type is provided, where Maybe<T> = T | undefined.

Usage

Install via your package manager:

npm install super-simple

and use like so:

import { List } from "super-simple";
const a = List([1, 2, 3]);
4.0.8

4 years ago

4.0.6

4 years ago

4.0.5

4 years ago

4.0.4

4 years ago