MCPcopy
hub / github.com/graphql/graphql-js / formatArray

Function formatArray

src/jsutils/inspect.ts:82–109  ·  view source on GitHub ↗
(
  array: ReadonlyArray<unknown>,
  seenValues: ReadonlyArray<unknown>,
)

Source from the content-addressed store, hash-verified

80}
81
82function formatArray(
83 array: ReadonlyArray<unknown>,
84 seenValues: ReadonlyArray<unknown>,
85): string {
86 if (array.length === 0) {
87 return '[]';
88 }
89
90 if (seenValues.length > MAX_RECURSIVE_DEPTH) {
91 return '[Array]';
92 }
93
94 const len = Math.min(MAX_ARRAY_LENGTH, array.length);
95 const remaining = array.length - len;
96 const items = [];
97
98 for (let i = 0; i < len; ++i) {
99 items.push(formatValue(array[i], seenValues));
100 }
101
102 if (remaining === 1) {
103 items.push('... 1 more item');
104 } else if (remaining > 1) {
105 items.push(`... ${remaining} more items`);
106 }
107
108 return '[' + items.join(', ') + ']';
109}
110
111function getObjectTag(object: object): string {
112 const tag = Object.prototype.toString

Callers 1

formatObjectValueFunction · 0.85

Calls 1

formatValueFunction · 0.85

Tested by

no test coverage detected