import { DEFAULT_START_CODEPOINT } from '../constants' ; import { AssetsMap } from './assets' ; export type CodepointsMap = { [ key ] : number ; } ; export const getCodepoints = ( assets , predefined = { } , start = DEFAULT_START_CODEPOINT ) : CodepointsMap => { const out = { } ; const used = Object . values ( predefined ) ; let current = start ; const getNextCodepoint = ( ) => { while ( used . includes ( current ) ) { current ++ ; } const res = current ; current ++ ; return res ; } ; for ( const id of Object . keys ( assets ) ) { if ( ! predefined [ id ] ) { out [ id ] = getNextCodepoint ( ) ; } } return { ... predefined , ... out } ; } ; export const getHexCodepoint = ( decimalCodepoint ) : string => decimalCodepoint . toString ( 16 ) ;