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>`.

23 lines (22 loc) 858 B
// This is introduced to avoid to evaluate the guard if statement twice // for implementing a operator. export function unsafeUnwrapValueInOkWithoutAnyCheck(input) { const val = input.val; return val; } // This is introduced to avoid to evaluate the guard if statement twice // for implementing a operator. export function unsafeUnwrapValueInErrWithoutAnyCheck(input) { const err = input.err; return err; } export function setUndefinedToValFieldOnOkDirectly(input) { // This fill field by `undefined` to allow to release the previous value. // eslint-disable-next-line no-param-reassign input.val = undefined; } export function setUndefinedToErrFieldOnErrDirectly(input) { // This fill field by `undefined` to allow to release the previous value. // eslint-disable-next-line no-param-reassign input.err = undefined; }