-
Notifications
You must be signed in to change notification settings - Fork 29.6k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
util: expose the WHATWG Encoding API globally #20662
Changes from 5 commits
ffd137a
651ad34
7020995
5820e16
98b1684
a6637f0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -771,9 +771,13 @@ added: v8.0.0 | |
* {symbol} that can be used to declare custom promisified variants of functions, | ||
see [Custom promisified functions][]. | ||
|
||
## Class: util.TextDecoder | ||
## Class: TextDecoder | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this is confusing if There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mscdex I did this for consistency since, in the But I agree with you that this is confusing. In the case of So I'm gonna change this here, and also follow your suggestion of moving the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mscdex Actually, I'm not quite sure about this. All the globals in In fact, I think there are 3 possibilities here: [1.] Keep the encoding documentation in
[2.] Move the encoding documentation to
[3.] Move the encoding documentation to a new documentation section, e.g.
In any case, I'm not sure what's a good way to proceed with this. So I'd greatly appreciate more feedback regarding this issue. PS: When I go to https://nodejs.org/dist/latest-v10.x/docs/api/, I sorely miss a tiny search-box in the top-right corner - I think that would help a lot. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. For overall doc search, you can use "View on single page" variant, there is a link at the top of each doc. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @vsemozhetbyt True, but I don't think that's a friendly UX/DX. (Especially on mobile, loading the whole documentation on a single page might not be the best option. But then again, I think this is off-topic here.) |
||
<!-- YAML | ||
added: v8.3.0 | ||
changes: | ||
- version: REPLACEME | ||
pr-url: https://github.com/nodejs/node/pull/20662 | ||
description: The class is now available on the global object. | ||
--> | ||
|
||
An implementation of the [WHATWG Encoding Standard][] `TextDecoder` API. | ||
|
@@ -908,9 +912,13 @@ thrown. | |
The value will be `true` if the decoding result will include the byte order | ||
mark. | ||
|
||
## Class: util.TextEncoder | ||
## Class: TextEncoder | ||
<!-- YAML | ||
added: v8.3.0 | ||
changes: | ||
- version: REPLACEME | ||
pr-url: https://github.com/nodejs/node/pull/20662 | ||
description: The class is now available on the global object. | ||
--> | ||
|
||
An implementation of the [WHATWG Encoding Standard][] `TextEncoder` API. All | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -316,7 +316,9 @@ let knownGlobals = [ | |
process, | ||
setImmediate, | ||
setInterval, | ||
setTimeout | ||
setTimeout, | ||
TextDecoder, | ||
TextEncoder | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I made a mistake in my review earlier. By adding these non-enumerable values we actually do exactly the opposite of what is required in this test. Please remove them and just keep the common files as they were therefore. See #20717 for further details. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @BridgeAR Thanks, will do! |
||
]; | ||
|
||
if (global.gc) { | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
'use strict'; | ||
|
||
require('../common'); | ||
const assert = require('assert'); | ||
const { TextEncoder, TextDecoder } = require('util'); | ||
|
||
assert.deepStrictEqual( | ||
Object.getOwnPropertyDescriptor(global, 'TextEncoder'), | ||
{ | ||
value: TextEncoder, | ||
writable: true, | ||
configurable: true, | ||
enumerable: false | ||
} | ||
); | ||
|
||
assert.deepStrictEqual( | ||
Object.getOwnPropertyDescriptor(global, 'TextDecoder'), | ||
{ | ||
value: TextDecoder, | ||
writable: true, | ||
configurable: true, | ||
enumerable: false | ||
} | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If what we're doing is migrating from
util
to a global, I think it'd be better to have the reverse: document here and haveutil.TextEncoder
link to the definition here.