Converts a nullable value to a Result. null and undefined map to
Errors, any other value maps to Oks.
Converts a nullable value to a Result. null and undefined map to
Errors, any other value maps to Oks.
A nullable is a value that may be any type, or null/undefined.
const nullableToResult = require('folktale/conversions/nullable-to-result');
const { Error, Ok } = require('folktale/result');
nullableToResult(undefined); // ==> Error(undefined)
nullableToResult(null); // ==> Error(null)
nullableToResult(1); // ==> Ok(1)
(a) =>
a != null ? Ok(a)
:/*else*/ Error(a)