1 | import React from 'react';
|
2 | import JSONNestedNode from './JSONNestedNode.js';
|
3 |
|
4 |
|
5 | function createItemString(data, limit) {
|
6 | let count = 0;
|
7 | let hasMore = false;
|
8 | if (Number.isSafeInteger(data.size)) {
|
9 | count = data.size;
|
10 | }
|
11 | else {
|
12 |
|
13 | for (const entry of data) {
|
14 | if (limit && count + 1 > limit) {
|
15 | hasMore = true;
|
16 | break;
|
17 | }
|
18 | count += 1;
|
19 | }
|
20 | }
|
21 | return `${hasMore ? '>' : ''}${count} ${count !== 1 ? 'entries' : 'entry'}`;
|
22 | }
|
23 |
|
24 | export default function JSONIterableNode(props) {
|
25 | return (React.createElement(JSONNestedNode, { ...props, nodeType: "Iterable", nodeTypeIndicator: "()", createItemString: createItemString, expandable: true }));
|
26 | }
|