import * as React from 'react' ; import compareArray from './compareArray' ; function childrenToMap ( children ? ) { const childMap = new Map ( ) ; if ( ! children ) { return childMap ; } React . Children . map ( children , child => child ) . forEach ( child => { if ( React . isValidElement ( child ) ) { childMap . set ( child . key as string , child ) ; } } ) ; return childMap ; } function compareChildren ( children1 , children2 ) { if ( children1 . size === 0 || children2 . size === 0 ) { return false ; } const keys1 = Array . from ( children1 . keys ( ) ) ; const keys2 = Array . from ( children2 . keys ( ) ) ; return compareArray ( keys1 , keys2 ) ; } export { childrenToMap , compareChildren } ;