import React from 'react' ; import JSONNestedNode from './JSONNestedNode' ; import { CircularPropsPassedThroughJSONNode } from './types' ; function createItemString ( data , limit ) { let count = 0 ; let hasMore = false ; if ( Number . isSafeInteger ( data . size ) ) { count = data . size ; } else { for ( const entry of data ) { if ( limit && count + 1 > limit ) { hasMore = true ; break ; } count += 1 ; } } return `${ hasMore ? '>' : '' }${ count } ${ count !== 1 ? 'entries' : 'entry' }` ; } interface Props extends CircularPropsPassedThroughJSONNode { data : any ; nodeType : string ; } const JSONIterableNode = ( { ... props } ) => { return ( < JSONNestedNode { ... props } nodeType = "Iterable" nodeTypeIndicator = "()" createItemString = { createItemString } / > ) ; } ; export default JSONIterableNode ;