//\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\\
// TypeScript helpers (universal micro-lib.) | Author: Sergei Y.Kitaev
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// Primitive operations (static class):
class HOps
{
   static Nop(): void {}

   static ObjectTypeName(obj): string {
      return obj.constructor.name
   }

   static NullSubst<T>(value: T, subst: T): T {
      return value ? value : subst
   }
   static NullAsUndefined<T>(value: T|null|undefined): T|null|undefined {
      return value===null ? undefined : value
   }
   static UndefinedAsNull<T>(value: T|null|undefined): T|null|undefined {
      return value===undefined ? null : value
   }

   static Bool(value): boolean {
      return value ? true : false
   }
   static BoolDefaultFalse(value): boolean {
      return value===true ? true : false
   }
   static BoolDefaultTrue(value): boolean {
      return value===true || value==null ? true : false
   }

   static InvokeIfNotNull(action: any): boolean {
      if (action!=null) {
         action()
         return true
      }
      return false
   }
} // HOps
