nullable2
A nullable(Null safety) implementation. Inspired by Kotlin.
Install
yarn add nullable2
Usage
Basic
Before
const item = items.findOrNull(id);
const child = item && item.getChildOrNull();
const value = child && child.values && child.values.getValue(param)
After
const nullable = require('nullable2')
const value = nullable(items, v => v
.findOrNull(id)
.getChildOrNull()
.values
.getValue(param))
Currying
const items$$ = nullable(items)
const child = items$$(v => v
.findOrNull(id)
.getChildOrNull())
const otherTitle = items$$(v => v
.findOrNull(otherId)
.title)
Related
License
MIT