import { InvalidFormatError } from './common' ; export enum StackItemType { Any = 0x00 , Pointer = 0x10 , Boolean = 0x20 , Integer = 0x21 , ByteString = 0x28 , Buffer = 0x30 , Array = 0x40 , Struct = 0x41 , Map = 0x48 , InteropInterface = 0x60 } export const isStackItemType = ( value ) : value is StackItemType => StackItemType [ value ] !== undefined ; export const assertStackItemType = ( value ) : StackItemType => { if ( isStackItemType ( value ) ) { return value ; } throw new InvalidFormatError ( `Expected StackItemType, found: ${ value }` ) ; } ; export type StackItemTypeJSON = keyof typeof StackItemType ; export const isStackItemTypeJSON = ( type ) : type is StackItemTypeJSON => StackItemType [ type as any ] !== undefined ; export const assertStackItemTypeJSON = ( type ) : StackItemTypeJSON => { if ( isStackItemTypeJSON ( type ) ) { return type ; } throw new InvalidFormatError ( ) ; } ; export const toStackItemTypeJSON = ( type ) => assertStackItemTypeJSON ( StackItemType [ type ] ) ;