Skip to content

Making util.TextDecoder and util.TextEncoder available on the global object #20365

Closed

Description

@MarkTiedemann
  • Version: v10.0.0
  • Platform: Microsoft Windows [Version 10.0.16299.371]
  • Subsystem: util

Just wondering since the WHATWG URL API was made available on the global object in Node v10.0.0: Should the WHATWG TextEncoder and TextDecoder APIs (that are currectly available via require('util')) be made available on the global object, too, or are there any reasons for not doing so?

PS: If this should be done, I'd love to start working on a PR for it.

Activity

  1. added
    utilIssues and PRs related to the built-in util module.
    feature requestIssues requesting new Node.js features.
    on Apr 27, 2018
  2. addaleax commented on Apr 27, 2018

    @addaleax
    Member

    @nodejs/tsc

  3. added
    encodingIssues and PRs related to the TextEncoder and TextDecoder APIs.
    on Apr 27, 2018
  4. mcollina commented on Apr 27, 2018

    @mcollina
    SponsorMember

    +1 as semver-major.

  5. jasnell commented on Apr 27, 2018

    @jasnell
    Member

    +1 as a major

  6. BridgeAR commented on May 10, 2018

    @BridgeAR
    Member

    Just as a note: the more we add as globals, the harder it gets to lazy load parts of core to improve startup time and to minimize memory overhead.

  7. MarkTiedemann commented on May 10, 2018

    @MarkTiedemann
    ContributorAuthor

    @BridgeAR I agree with you in general. I do think, however, in this particular case const { deprecate } = NativeModule.require('internal/util'); is called before const { TextEncoder, TextDecoder } = NativeModule.require('internal/util');. Not sure how NativeModule.require works internally, but I would expect the second call not to add large overhead. Is that correct?

    EDIT: Correction: deprecate is required after TextEncoder and TextDecoder.

  8. BridgeAR commented on May 10, 2018

    @BridgeAR
    Member

    See #20567. It is the combination of all those files at startup time. It is not about this specifically (it would be fine as it is right now) but I just want to point out in general that every added global is making it more difficult to load less things on startup. Using getters for the globals would help but at least for console it should not be a getter due to the spec. I do not know if that is also here the case but I guess it is.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    encodingIssues and PRs related to the TextEncoder and TextDecoder APIs.feature requestIssues requesting new Node.js features.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