import { Collection } from './types' ; param hexWithCase { string } returns export function parseHex2Int ( hexWithCase ) { const hex = hexWithCase . toUpperCase ( ) ; if ( [ '0' , '1' , '2' , '3' , '4' , '5' , '6' , '7' , '8' , '9' ] . includes ( hex ) ) { return < u32 > parseInt ( hex , 10 ) ; } else if ( hex == 'A' ) { return 10 ; } else if ( hex == 'B' ) { return 11 ; } else if ( hex == 'C' ) { return 12 ; } else if ( hex == 'D' ) { return 13 ; } else if ( hex == 'E' ) { return 14 ; } else if ( hex == 'F' ) { return 15 ; } throw new Error ( '[cryptofish] invilid hex string' ) ; } param collection returns { string } export const stringifyCollection = ( collection ) : string => { const index = collection . get ( 'index' ) ; if ( ! index ) { return '' ; } const creator = collection . get ( 'creator' ) ; const attribute = collection . get ( 'attribute' ) ; const score = collection . get ( 'score' ) ; const favorCount = collection . get ( 'favorCount' ) ; return `{"index":${ index },"creator":"${ creator }","attribute":"${ attribute }","score":${ score },"favorCount":${ favorCount }}` ; } ; param collections returns { string } export const stringifyCollections = ( collections ) : string => { let result = '[' ; for ( let index = 0 ; index < collections . length ; index += 1 ) { const collection = collections [ index ] ; const str = stringifyCollection ( collection ) ; if ( str . length > 0 ) { result = `${ result }${ index === 0 ? '' : ',' }${ str }` ; } } return `${ result }]` ; } ;