Skip to content

lib: reduce internal usage of public require('util') #26546

Description

@joyeecheung

A few patterns (modulo destructuring):

  1. Replace require('util').inherits() usages under lib: Remove util.inherits usage internally? #24395
// Change thisutil.inherits(A,B);// To thisObject.setPrototypeOf(A.prototype,B.prototype);Object.setPrototypeOf(A,B);
  1. Replace require('util').inspect with require('internal/util/inspect').inspect
  2. Replace require('util').format with require('internal/util/inspect').format
  3. Replace require('util').debuglog with require('internal/util/debuglog').debuglog
  4. Replace require('util').types with require('internal/util/types')
  5. Replace require('util').deprecate with require('internal/util').deprecate
  6. Replace require('util').promisify with require('internal/util').promisify

List of JS files that can be refactored:

RefactoredSubsystemFilesPR
assertlib/assert.js#L32, lib/internal/assert/assertion_error.js#L3#26762, #26750
bootstraplib/internal/bootstrap/node.js#L192#26547
child_processlib/child_process.js#L24, lib/internal/child_process.js#L21#26769, #26773
consolelib/internal/console/constructor.js#L18#26777
dgramlib/dgram.js#L48#26770
domainlib/domain.js#L29
encodinglib/internal/encoding.js#L330#26779
errorslib/internal/error-serdes.js#L83, lib/internal/errors.js#L210#26782, #26781
fslib/internal/fs/utils.js#L15#26783
httplib/_http_agent.js#L25, lib/_http_common.js#L39, lib/_http_outgoing.js#L26, lib/_http_server.js#L24#26548
http2lib/internal/http2/core.js#L21#26789
httpslib/https.js#L28#26772
inspectorlib/inspector.js#L19
liblib/internal/policy/manifest.js#L7#26833
modulelib/internal/modules/cjs/loader.js#L26, lib/internal/modules/esm/create_dynamic_module.js#L4, lib/internal/modules/esm/loader.js#L21, lib/internal/modules/esm/module_map.js#L7, lib/internal/modules/esm/translators.js#L22#26802, #26803, #26804, #26805, #26806
netlib/net.js#L26#26807
processlib/internal/process/per_thread.js#L18#26817
readlinelib/readline.js#L35#26818
repllib/internal/repl/history.js#L7, lib/repl.js#L55#26819#26820
streamlib/internal/js_stream_socket.js#L4, lib/internal/streams/buffer_list.js#L4, lib/internal/streams/lazy_transform.js#L7, lib/stream.js#L46#26698
timerslib/internal/timers.js#L19, lib/timers.js#L43
tlslib/_tls_wrap.js#L30#26747
trace_eventslib/trace_events.js#L22#26822
ttylib/tty.js#L24#26797
urllib/internal/url.js#L3#26808
vmlib/internal/vm/source_text_module.js#L3, lib/vm.js#L35#26716
workerlib/internal/main/worker_thread.js#L46, lib/internal/worker/io.js#L17#26814, #26810
zliblib/zlib.js#L38#26716

Metadata

Metadata

Assignees

No one assigned

    Labels

    good first issueIssues that are suitable for first-time contributors.help wantedIssues that need assistance from volunteers or PRs that need help to proceed.utilIssues and PRs related to the built-in util module.

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions