import * as assert from "assert" ; export function isDefined < X > ( value ) { if ( value ) { return { and : function ( cb ) { cb ( value ) ; } , } ; } else { assert ( value !== undefined , `expected to be defined` ) ; throw new Error ( "this is unreachable" ) ; } } export function isNotNull < X > ( value ) { if ( value ) { return { and : function ( cb ) { cb ( value ) ; } , } ; } else { assert ( value !== null , `expected to not be null` ) ; throw new Error ( "this is unreachable" ) ; } } export function isExisting < X > ( value ) { if ( value ) { return { and : function ( cb ) { cb ( value ) ; } , } ; } else { assert ( value , `expected to exist` ) ; throw new Error ( "this is unreachable" ) ; } } export function isType < ArgumentType , AssertedType extends ArgumentType > ( typeGuard , x ) { if ( typeGuard ( x ) ) { return { and : function ( cb ) { cb ( x ) ; } , } ; } else { assert . fail ( `is not the expected type` ) ; throw new Error ( "this is unreachable" ) ; } }