MCPcopy Index your code
hub / github.com/nodejs/node / table

Function table

lib/internal/console/constructor.js:554–665  ·  view source on GitHub ↗
(tabularData, properties)

Source from the content-addressed store, hash-verified

552
553 // https://console.spec.whatwg.org/#table
554 table(tabularData, properties) {
555 if (properties !== undefined)
556 validateArray(properties, 'properties');
557
558 if (tabularData === null || typeof tabularData !== 'object')
559 return this.log(tabularData);
560
561 cliTable ??= require('internal/cli_table');
562 const final = (k, v) => this.log(cliTable(k, v));
563
564 const _inspect = (v) => {
565 const depth = v !== null &&
566 typeof v === 'object' &&
567 !isArray(v) &&
568 ObjectKeys(v).length > 2 ? -1 : 0;
569 const opt = {
570 depth,
571 maxArrayLength: 3,
572 breakLength: Infinity,
573 ...this[kGetInspectOptions](this._stdout),
574 };
575 return inspect(v, opt);
576 };
577 const getIndexArray = (length) => ArrayFrom(
578 { length }, (_, i) => _inspect(i));
579
580 const mapIter = isMapIterator(tabularData);
581 let isKeyValue = false;
582 let i = 0;
583 if (mapIter) {
584 const res = previewEntries(tabularData, true);
585 tabularData = res[0];
586 isKeyValue = res[1];
587 }
588
589 if (isKeyValue || isMap(tabularData)) {
590 const keys = [];
591 const values = [];
592 let length = 0;
593 if (mapIter) {
594 for (; i < tabularData.length / 2; ++i) {
595 ArrayPrototypePush(keys, _inspect(tabularData[i * 2]));
596 ArrayPrototypePush(values, _inspect(tabularData[i * 2 + 1]));
597 length++;
598 }
599 } else {
600 for (const { 0: k, 1: v } of tabularData) {
601 ArrayPrototypePush(keys, _inspect(k));
602 ArrayPrototypePush(values, _inspect(v));
603 length++;
604 }
605 }
606 return final([
607 iterKey, keyKey, valuesKey,
608 ], [
609 getIndexArray(length),
610 keys,
611 values,

Callers

nothing calls this directly

Calls 6

_inspectFunction · 0.85
getIndexArrayFunction · 0.85
isSetFunction · 0.85
finalFunction · 0.70
requireFunction · 0.50
logMethod · 0.45

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…