Typescript adapted Java Optional class.
The library barebone is generated with typescript-library-starter.
npm i @itfobos/ts-optional
Documentation is available here.
Optional.ofNullable(someValue)
Optional.of(nonNullableValue)
Optional.empty()
const entityUuid = Optional.of(response)
.filter(resp => resp.isPresent)
.map(responseToEntity)
.map(entity => entity.uuid)
.filter(isNotNullOrEmpty)
.orElseGet(() => route.snapshot.queryParamMap.get('uuid') as string);
Automatically tested with Node versions:
- 8
- 10
- 11
- 12
To integrate with the CI:
- github personal access tokens should be generated.
- Generated value should be defined in Travis as GH_TOKEN environment variable for master branch.
- npm account email should be defined as NPM_EMAIL environment variable for all branches.
- npm access tokens should be defined as NPM_TOKEN environment variable for all branches.