Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

nullable2

skt-t1-byungi1MITdeprecated0.0.3-1

this version has been deprecated

A nullable(Null safety) implementation. Inspired by Kotlin.

nullable, optional, proxy, null, null safe, null safety

readme

nullable2

A nullable(Null safety) implementation. Inspired by Kotlin.

npm npm

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)

License

MIT