ops, object, maxLengthMap.get(mode)); brackets = needSpace(!!items.length); } return span( { className: "objectBox objectBox-array", title: shouldRenderTooltip ? "Array" : null, }, lengthBubble({ object, mode, maxLengthMap, getLength: () => object.length, }), span( { className: "arrayLeftBracket", }, brackets.left ), ...items, span( { className: "arrayRightBracket", }, brackets.right ) ); } function arrayIterator(props, array, max) { const items = []; for (let i = 0; i < array.length && i < max; i++) { const config = { mode: MODE.TINY, delim: i == array.length - 1 ? "" : ", ", }; let item; try { item = ItemRep({ ...props, ...config, object: array[i], }); } catch (exc) { item = ItemRep({ ...props, ...config, object: exc, }); } items.push(item); } if (array.length > max) { items.push( span( { className: "more-ellipsis", }, "…" ) ); } return items; } /** * Renders array item. Individual values are separated by a comma. */ ItemRep.propTypes = { object: PropTypes.any.isRequired, delim: PropTypes.string.isRequired, mode: ModePropType, }; function ItemRep(props) { const { object, delim, mode } = props; return span( {}, props.Rep({ ...props, object, mode, }), delim ); } function getLength(object) { return object.length; } function supportsObject(object, noGrip = false) { return ( noGrip && (Array.isArray(object) || Object.prototype.toString.call(object) === "[object Arguments]") ); } const maxLengthMap = new Map(); maxLengthMap.set(MODE.SHORT, 3); maxLengthMap.set(MODE.LONG, 10); const rep = wrapRender(ArrayRep); // Exports from this module export { rep, supportsObject, maxLengthMap, getLength, ModePropType }; PK