import type { IDeref } from "@thi.ng/api" ; export class Reduced < T > implements IDeref < T > { protected value : T ; constructor ( val ) { this . value = val ; } deref ( ) { return this . value ; } } export const reduced = ( x ) : any => new Reduced ( x ) ; export const isReduced = < T > ( x ) : x is Reduced < T > => x instanceof Reduced ; export const ensureReduced = ( x ) => x instanceof Reduced ? x : new Reduced ( x ) ; export const unreduced = ( x ) => ( x instanceof Reduced ? x . deref ( ) : x ) ;