Skip to content

Commit

Permalink
console: lazy load cli
Browse files Browse the repository at this point in the history
PR-URL: #20567
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Matteo Collina <matteo.collina@gmail.com>
Reviewed-By: James M Snell <jasnell@gmail.com>
Reviewed-By: Jeremiah Senkpiel <fishrock123@rocketmail.com>
  • Loading branch information
BridgeAR authored and MylesBorins committed May 22, 2018
1 parent 94d217f commit bc6dbc3
Showing 1 changed file with 4 additions and 1 deletion.
5 changes: 4 additions & 1 deletion lib/console.js
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ const {
} = require('internal/errors');
const { previewMapIterator, previewSetIterator } = require('internal/v8');
const { Buffer: { isBuffer } } = require('buffer');
const cliTable = require('internal/cli_table');
const util = require('util');
const {
isTypedArray, isSet, isMap, isSetIterator, isMapIterator,
Expand All @@ -49,6 +48,9 @@ const {
from: ArrayFrom,
} = Array;

// Lazy loaded for startup performance.
let cliTable;

// Track amount of indentation required via `console.group()`.
const kGroupIndent = Symbol('kGroupIndent');

Expand Down Expand Up @@ -325,6 +327,7 @@ Console.prototype.table = function(tabularData, properties) {
(typeof tabularData !== 'object' && typeof tabularData !== 'function'))
return this.log(tabularData);

if (cliTable === undefined) cliTable = require('internal/cli_table');
const final = (k, v) => this.log(cliTable(k, v));

const inspect = (v) => {
Expand Down

0 comments on commit bc6dbc3

Please sign in to comment.