Rebasely Beta: data may be purged

justintypescript-ultra-strict Public

JavaScript · 22 lines · 569 B · at 9ba9e6b

// The interop boundary: converts the outside world's nulls, undefineds, and// throws into Option and Result at the edge of tsus code.import { Some, None, Ok, Err } from "./index.js";export const fromNullable = (value) =>  value === null || value === undefined ? None : Some(value);export const wrapSync = (fn) => (...args) => {  try {    return Ok(fn(...args));  } catch (error) {    return Err(error);  }};export const wrapAsync = (fn) => async (...args) => {  try {    return Ok(await fn(...args));  } catch (error) {    return Err(error);  }};