import { iso } from "https://deno.land/x/fun@v2.0.0/newtype.ts";
If the Newtype and its underlying value are referentially transparent (meaning they can always be swapped) then you can create an instance of Iso for the Newtype for mapping back and forth.
Examples
Example 1
Example 1
import * as N from "./newtype.ts";
type Real = N.Newtype<"Real", number>;
const isoReal = N.iso<Real>();
const result1: Real = isoReal.view(1); // Turn number into Real
const result2: number = isoReal.review(result1); // Turn Real into number
Type Parameters
T extends AnyNewtype