UNPKG

option-t

Version:

A toolkit of Nullable/Option/Result type implementation in ECMAScript. Their APIs are inspired by Rust's `Option<T>` and `Result<T, E>`.

16 lines (15 loc) 561 B
import { isNotNull } from '../core/nullable.js'; /** * * Return _input_ directly. * * This value is passed as the input. But it maybe mutated by calling _effector_. * * Call _effector_ with _input_ if _input_ is not `null`. * * * This was added to sort with others or future enhancement to accept chaining functions. * We recommend to use simple `if` statement or similar way and they would be more efficient. */ export function inspectNullable(input, effector) { if (isNotNull(input)) { effector(input); } return input; }