repl: remove usage of require('util') in repl.js · nodejs/node@415a825 (original) (raw)

`@@ -51,8 +51,12 @@ const {

`

51

51

` isIdentifierStart,

`

52

52

` isIdentifierChar

`

53

53

`} = require('internal/deps/acorn/acorn/dist/acorn');

`

54

``

`-

const internalUtil = require('internal/util');

`

55

``

`-

const util = require('util');

`

``

54

`+

const {

`

``

55

`+

decorateErrorStack,

`

``

56

`+

isError,

`

``

57

`+

deprecate

`

``

58

`+

} = require('internal/util');

`

``

59

`+

const { inspect } = require('internal/util/inspect');

`

56

60

`const Stream = require('stream');

`

57

61

`const vm = require('vm');

`

58

62

`const path = require('path');

`

`@@ -61,7 +65,7 @@ const { Interface } = require('readline');

`

61

65

`const { Console } = require('console');

`

62

66

`const CJSModule = require('internal/modules/cjs/loader');

`

63

67

`const domain = require('domain');

`

64

``

`-

const debug = util.debuglog('repl');

`

``

68

`+

const debug = require('internal/util/debuglog').debuglog('repl');

`

65

69

`const {

`

66

70

`ERR_CANNOT_WATCH_SIGINT,

`

67

71

`ERR_INVALID_ARG_TYPE,

`

`@@ -120,8 +124,8 @@ function hasOwnProperty(obj, prop) {

`

120

124

`// This is the default "writer" value, if none is passed in the REPL options,

`

121

125

`` // and it can be overridden by custom print functions, such as probe or

``

122

126

`` // eyes.js.

``

123

``

`-

const writer = exports.writer = (obj) => util.inspect(obj, writer.options);

`

124

``

`-

writer.options = { ...util.inspect.defaultOptions, showProxy: true };

`

``

127

`+

const writer = exports.writer = (obj) => inspect(obj, writer.options);

`

``

128

`+

writer.options = { ...inspect.defaultOptions, showProxy: true };

`

125

129

``

126

130

`exports._builtinLibs = builtinLibs;

`

127

131

``

`@@ -204,10 +208,10 @@ function REPLServer(prompt,

`

204

208

``

205

209

`let rli = this;

`

206

210

`Object.defineProperty(this, 'rli', {

`

207

``

`-

get: util.deprecate(() => rli,

`

208

``

`-

'REPLServer.rli is deprecated', 'DEP0124'),

`

209

``

`-

set: util.deprecate((val) => rli = val,

`

210

``

`-

'REPLServer.rli is deprecated', 'DEP0124'),

`

``

211

`+

get: deprecate(() => rli,

`

``

212

`+

'REPLServer.rli is deprecated', 'DEP0124'),

`

``

213

`+

set: deprecate((val) => rli = val,

`

``

214

`+

'REPLServer.rli is deprecated', 'DEP0124'),

`

211

215

`enumerable: true,

`

212

216

`configurable: true

`

213

217

`});

`

`@@ -430,15 +434,15 @@ function REPLServer(prompt,

`

430

434

`if (typeof e === 'object' && e !== null) {

`

431

435

`const pstrace = Error.prepareStackTrace;

`

432

436

`Error.prepareStackTrace = prepareStackTrace(pstrace);

`

433

``

`-

internalUtil.decorateErrorStack(e);

`

``

437

`+

decorateErrorStack(e);

`

434

438

`Error.prepareStackTrace = pstrace;

`

435

439

``

436

440

`if (e.domainThrown) {

`

437

441

`delete e.domain;

`

438

442

`delete e.domainThrown;

`

439

443

`}

`

440

444

``

441

``

`-

if (internalUtil.isError(e)) {

`

``

445

`+

if (isError(e)) {

`

442

446

`if (e.stack) {

`

443

447

`if (e.name === 'SyntaxError') {

`

444

448

`// Remove stack trace.

`

`@@ -482,10 +486,12 @@ function REPLServer(prompt,

`

482

486

``

483

487

`self.clearBufferedCommand();

`

484

488

`Object.defineProperty(this, 'bufferedCommand', {

`

485

``

`-

get: util.deprecate(() => self[kBufferedCommandSymbol],

`

486

``

`-

'REPLServer.bufferedCommand is deprecated', 'DEP0074'),

`

487

``

`-

set: util.deprecate((val) => self[kBufferedCommandSymbol] = val,

`

488

``

`-

'REPLServer.bufferedCommand is deprecated', 'DEP0074'),

`

``

489

`+

get: deprecate(() => self[kBufferedCommandSymbol],

`

``

490

`+

'REPLServer.bufferedCommand is deprecated',

`

``

491

`+

'DEP0074'),

`

``

492

`+

set: deprecate((val) => self[kBufferedCommandSymbol] = val,

`

``

493

`+

'REPLServer.bufferedCommand is deprecated',

`

``

494

`+

'DEP0074'),

`

489

495

`enumerable: true

`

490

496

`});

`

491

497

``

`@@ -518,7 +524,7 @@ function REPLServer(prompt,

`

518

524

`writer.options.colors = self.useColors;

`

519

525

``

520

526

`if (options[kStandaloneREPL]) {

`

521

``

`-

Object.defineProperty(util.inspect, 'replDefaults', {

`

``

527

`+

Object.defineProperty(inspect, 'replDefaults', {

`

522

528

`get() {

`

523

529

`return writer.options;

`

524

530

`},

`

`@@ -567,7 +573,7 @@ function REPLServer(prompt,

`

567

573

`return false;

`

568

574

`}

`

569

575

``

570

``

`-

self.parseREPLKeyword = util.deprecate(

`

``

576

`+

self.parseREPLKeyword = deprecate(

`

571

577

`_parseREPLKeyword,

`

572

578

`'REPLServer.parseREPLKeyword() is deprecated',

`

573

579

`'DEP0075');

`

`@@ -924,7 +930,7 @@ REPLServer.prototype.setPrompt = function setPrompt(prompt) {

`

924

930

`Interface.prototype.setPrompt.call(this, prompt);

`

925

931

`};

`

926

932

``

927

``

`-

REPLServer.prototype.turnOffEditorMode = util.deprecate(

`

``

933

`+

REPLServer.prototype.turnOffEditorMode = deprecate(

`

928

934

`function() { _turnOffEditorMode(this); },

`

929

935

`'REPLServer.turnOffEditorMode() is deprecated',

`

930

936

`'DEP0078');

`

`@@ -1315,7 +1321,7 @@ REPLServer.prototype.defineCommand = function(keyword, cmd) {

`

1315

1321

`this.commands[keyword] = cmd;

`

1316

1322

`};

`

1317

1323

``

1318

``

`-

REPLServer.prototype.memory = util.deprecate(

`

``

1324

`+

REPLServer.prototype.memory = deprecate(

`

1319

1325

`_memory,

`

1320

1326

`'REPLServer.memory() is deprecated',

`

1321

1327

`'DEP0082');

`