import { Optional } from "https://deno.land/x/mandarinets@v2.3.2/plugins/optional.ts";
The optional class is used to avoid repetitive validation with If's. If an object is present, you can verify this with Optional.isPresent() If An object is not present but you would like to get a default value, you can do this with Optional.orElseGet(defaultValue); This classs allows you to avoid null exceptions.
Properties
"Optionable" object.
Methods
Gets the value of the Optional only if it is present. If value is not present, an exception will be thrown.
Returns a boolean value of whether the optional value is present.
Returns the value present in the Optional instance. if @param value is an Optional, it will invoke "get", otherwise it will return the whole value. If not value is present, it will return undefined.
Tries to get the value in Optional. If value is not present, it will throw an exception.
Static Properties
Default empty optional
Static Methods
Creates a new optional from a value which will be the optional's object.
Creates a Optional instance. if @param value is provided but it is either null or undefined, then it creates an empty instance of Optional.