import { GanttItemInternal } from '../class/item' ; export interface Dictionary < T = unknown > { [ key ] : T ; } export function isNumber ( value ) { return typeof value === 'number' ; } export function isString ( value ) { return typeof value === 'string' ; } export function isUndefined ( value ) { return value === undefined ; } export function hexToRgb ( color , opacity = 1 ) { if ( /^#/g . test ( color ) ) { return `rgba(${ parseInt ( color . slice ( 1 , 3 ) , 16 ) },${ parseInt ( color . slice ( 3 , 5 ) , 16 ) },${ parseInt ( color . slice ( 5 , 7 ) , 16 ) },${ opacity })` ; } else { return color ; } } export function uniqBy < T = unknown > ( array , key ) { const valuesMap = { } ; const result = [ ] ; ( array || [ ] ) . forEach ( ( value ) => { const _key = value [ key as string ] ; if ( ! valuesMap [ _key ] ) { valuesMap [ _key ] = value ; result . push ( value ) ; } } ) ; return result ; } export function flatten < T = unknown > ( array ) { return array . reduce ( ( pre , cur ) => { return pre . concat ( Array . isArray ( cur ) ? flatten ( cur ) : cur ) ; } , [ ] ) ; } export function recursiveItems ( items ) { const result = [ ] ; ( items || [ ] ) . forEach ( ( item ) => { result . push ( item ) ; if ( item . expanded && item . children ) { result . push ( ... recursiveItems ( item . children ) ) ; } } ) ; return result ; }