| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 54d8068 commit bc0ae3e
5 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -56,14 +56,20 @@ const byteSizeFunction = ObjectDefineProperty( | |||
| 56 | 56 | ); | |
| 57 | 57 | const countSizeFunction = ObjectDefineProperty(() => 1, 'name', nameDescriptor); | |
| 58 | 58 | ||
| 59 | + const getNonWritablePropertyDescriptor = (value) => { | ||
| 60 | + return { | ||
| 61 | + __proto__: null, | ||
| 62 | + configurable: true, | ||
| 63 | + value, | ||
| 64 | + }; | ||
| 65 | + }; | ||
| 66 | + | ||
| 59 | 67 | /** | |
| 60 | 68 | * @type {QueuingStrategy} | |
| 61 | 69 | */ | |
| 62 | 70 | class ByteLengthQueuingStrategy { | |
| 63 | 71 | [kType] = 'ByteLengthQueuingStrategy'; | |
| 64 | 72 | ||
| 65 | - get [SymbolToStringTag]() { return this[kType]; } | ||
| 66 | - | ||
| 67 | 73 | /** | |
| 68 | 74 | * @param {{ | |
| 69 | 75 | * highWaterMark : number | |
@@ -110,6 +116,7 @@ class ByteLengthQueuingStrategy { | |||
| 110 | 116 | ObjectDefineProperties(ByteLengthQueuingStrategy.prototype, { | |
| 111 | 117 | highWaterMark: kEnumerableProperty, | |
| 112 | 118 | size: kEnumerableProperty, | |
| 119 | + [SymbolToStringTag]: getNonWritablePropertyDescriptor(ByteLengthQueuingStrategy.name), | ||
| 113 | 120 | }); | |
| 114 | 121 | ||
| 115 | 122 | /** | |
@@ -118,8 +125,6 @@ ObjectDefineProperties(ByteLengthQueuingStrategy.prototype, { | |||
| 118 | 125 | class CountQueuingStrategy { | |
| 119 | 126 | [kType] = 'CountQueuingStrategy'; | |
| 120 | 127 | ||
| 121 | - get [SymbolToStringTag]() { return this[kType]; } | ||
| 122 | - | ||
| 123 | 128 | /** | |
| 124 | 129 | * @param {{ | |
| 125 | 130 | * highWaterMark : number | |
@@ -166,6 +171,7 @@ class CountQueuingStrategy { | |||
| 166 | 171 | ObjectDefineProperties(CountQueuingStrategy.prototype, { | |
| 167 | 172 | highWaterMark: kEnumerableProperty, | |
| 168 | 173 | size: kEnumerableProperty, | |
| 174 | + [SymbolToStringTag]: getNonWritablePropertyDescriptor(CountQueuingStrategy.name), | ||
| 169 | 175 | }); | |
| 170 | 176 | ||
| 171 | 177 | module.exports = { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -141,6 +141,14 @@ const kError = Symbol('kError'); | |||
| 141 | 141 | const kPull = Symbol('kPull'); | |
| 142 | 142 | const kRelease = Symbol('kRelease'); | |
| 143 | 143 | ||
| 144 | + const getNonWritablePropertyDescriptor = (value) => { | ||
| 145 | + return { | ||
| 146 | + __proto__: null, | ||
| 147 | + configurable: true, | ||
| 148 | + value, | ||
| 149 | + }; | ||
| 150 | + }; | ||
| 151 | + | ||
| 144 | 152 | /** | |
| 145 | 153 | * @typedef {import('../abort_controller').AbortSignal} AbortSignal | |
| 146 | 154 | * @typedef {import('./queuingstrategies').QueuingStrategy} QueuingStrategy | |
@@ -206,8 +214,6 @@ const kRelease = Symbol('kRelease'); | |||
| 206 | 214 | class ReadableStream { | |
| 207 | 215 | [kType] = 'ReadableStream'; | |
| 208 | 216 | ||
| 209 | - get [SymbolToStringTag]() { return this[kType]; } | ||
| 210 | - | ||
| 211 | 217 | /** | |
| 212 | 218 | * @param {UnderlyingSource} [source] | |
| 213 | 219 | * @param {QueuingStrategy} [strategy] | |
@@ -604,6 +610,7 @@ ObjectDefineProperties(ReadableStream.prototype, { | |||
| 604 | 610 | pipeThrough: kEnumerableProperty, | |
| 605 | 611 | pipeTo: kEnumerableProperty, | |
| 606 | 612 | tee: kEnumerableProperty, | |
| 613 | + [SymbolToStringTag]: getNonWritablePropertyDescriptor(ReadableStream.name), | ||
| 607 | 614 | }); | |
| 608 | 615 | ||
| 609 | 616 | function TransferredReadableStream() { | |
@@ -629,8 +636,6 @@ TransferredReadableStream.prototype[kDeserialize] = () => {}; | |||
| 629 | 636 | class ReadableStreamBYOBRequest { | |
| 630 | 637 | [kType] = 'ReadableStreamBYOBRequest'; | |
| 631 | 638 | ||
| 632 | - get [SymbolToStringTag]() { return this[kType]; } | ||
| 633 | - | ||
| 634 | 639 | constructor() { | |
| 635 | 640 | throw new ERR_ILLEGAL_CONSTRUCTOR(); | |
| 636 | 641 | } | |
@@ -710,6 +715,7 @@ ObjectDefineProperties(ReadableStreamBYOBRequest.prototype, { | |||
| 710 | 715 | view: kEnumerableProperty, | |
| 711 | 716 | respond: kEnumerableProperty, | |
| 712 | 717 | respondWithNewView: kEnumerableProperty, | |
| 718 | + [SymbolToStringTag]: getNonWritablePropertyDescriptor(ReadableStreamBYOBRequest.name), | ||
| 713 | 719 | }); | |
| 714 | 720 | ||
| 715 | 721 | function createReadableStreamBYOBRequest(controller, view) { | |
@@ -769,8 +775,6 @@ class ReadIntoRequest { | |||
| 769 | 775 | class ReadableStreamDefaultReader { | |
| 770 | 776 | [kType] = 'ReadableStreamDefaultReader'; | |
| 771 | 777 | ||
| 772 | - get [SymbolToStringTag]() { return this[kType]; } | ||
| 773 | - | ||
| 774 | 778 | /** | |
| 775 | 779 | * @param {ReadableStream} stream | |
| 776 | 780 | */ | |
@@ -854,13 +858,12 @@ ObjectDefineProperties(ReadableStreamDefaultReader.prototype, { | |||
| 854 | 858 | read: kEnumerableProperty, | |
| 855 | 859 | releaseLock: kEnumerableProperty, | |
| 856 | 860 | cancel: kEnumerableProperty, | |
| 861 | + [SymbolToStringTag]: getNonWritablePropertyDescriptor(ReadableStreamDefaultReader.name), | ||
| 857 | 862 | }); | |
| 858 | 863 | ||
| 859 | 864 | class ReadableStreamBYOBReader { | |
| 860 | 865 | [kType] = 'ReadableStreamBYOBReader'; | |
| 861 | 866 | ||
| 862 | - get [SymbolToStringTag]() { return this[kType]; } | ||
| 863 | - | ||
| 864 | 867 | /** | |
| 865 | 868 | * @param {ReadableStream} stream | |
| 866 | 869 | */ | |
@@ -971,13 +974,12 @@ ObjectDefineProperties(ReadableStreamBYOBReader.prototype, { | |||
| 971 | 974 | read: kEnumerableProperty, | |
| 972 | 975 | releaseLock: kEnumerableProperty, | |
| 973 | 976 | cancel: kEnumerableProperty, | |
| 977 | + [SymbolToStringTag]: getNonWritablePropertyDescriptor(ReadableStreamBYOBReader.name), | ||
| 974 | 978 | }); | |
| 975 | 979 | ||
| 976 | 980 | class ReadableStreamDefaultController { | |
| 977 | 981 | [kType] = 'ReadableStreamDefaultController'; | |
| 978 | 982 | ||
| 979 | - get [SymbolToStringTag]() { return this[kType]; } | ||
| 980 | - | ||
| 981 | 983 | constructor() { | |
| 982 | 984 | throw new ERR_ILLEGAL_CONSTRUCTOR(); | |
| 983 | 985 | } | |
@@ -1032,6 +1034,7 @@ ObjectDefineProperties(ReadableStreamDefaultController.prototype, { | |||
| 1032 | 1034 | close: kEnumerableProperty, | |
| 1033 | 1035 | enqueue: kEnumerableProperty, | |
| 1034 | 1036 | error: kEnumerableProperty, | |
| 1037 | + [SymbolToStringTag]: getNonWritablePropertyDescriptor(ReadableStreamDefaultController.name), | ||
| 1035 | 1038 | }); | |
| 1036 | 1039 | ||
| 1037 | 1040 | function createReadableStreamDefaultController() { | |
@@ -1048,8 +1051,6 @@ function createReadableStreamDefaultController() { | |||
| 1048 | 1051 | class ReadableByteStreamController { | |
| 1049 | 1052 | [kType] = 'ReadableByteStreamController'; | |
| 1050 | 1053 | ||
| 1051 | - get [SymbolToStringTag]() { return this[kType]; } | ||
| 1052 | - | ||
| 1053 | 1054 | constructor() { | |
| 1054 | 1055 | throw new ERR_ILLEGAL_CONSTRUCTOR(); | |
| 1055 | 1056 | } | |
@@ -1168,6 +1169,7 @@ ObjectDefineProperties(ReadableByteStreamController.prototype, { | |||
| 1168 | 1169 | close: kEnumerableProperty, | |
| 1169 | 1170 | enqueue: kEnumerableProperty, | |
| 1170 | 1171 | error: kEnumerableProperty, | |
| 1172 | + [SymbolToStringTag]: getNonWritablePropertyDescriptor(ReadableByteStreamController.name), | ||
| 1171 | 1173 | }); | |
| 1172 | 1174 | ||
| 1173 | 1175 | function createReadableByteStreamController() { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -64,6 +64,14 @@ const { | |||
| 64 | 64 | ||
| 65 | 65 | const assert = require('internal/assert'); | |
| 66 | 66 | ||
| 67 | + const getNonWritablePropertyDescriptor = (value) => { | ||
| 68 | + return { | ||
| 69 | + __proto__: null, | ||
| 70 | + configurable: true, | ||
| 71 | + value, | ||
| 72 | + }; | ||
| 73 | + }; | ||
| 74 | + | ||
| 67 | 75 | /** | |
| 68 | 76 | * @typedef {import('./queuingstrategies').QueuingStrategy | |
| 69 | 77 | * } QueuingStrategy | |
@@ -102,8 +110,6 @@ const assert = require('internal/assert'); | |||
| 102 | 110 | class TransformStream { | |
| 103 | 111 | [kType] = 'TransformStream'; | |
| 104 | 112 | ||
| 105 | - get [SymbolToStringTag]() { return this[kType]; } | ||
| 106 | - | ||
| 107 | 113 | /** | |
| 108 | 114 | * @param {Transformer} [transformer] | |
| 109 | 115 | * @param {QueuingStrategy} [writableStrategy] | |
@@ -236,6 +242,7 @@ class TransformStream { | |||
| 236 | 242 | ObjectDefineProperties(TransformStream.prototype, { | |
| 237 | 243 | readable: kEnumerableProperty, | |
| 238 | 244 | writable: kEnumerableProperty, | |
| 245 | + [SymbolToStringTag]: getNonWritablePropertyDescriptor(TransformStream.name), | ||
| 239 | 246 | }); | |
| 240 | 247 | ||
| 241 | 248 | function TransferredTransformStream() { | |
@@ -261,8 +268,6 @@ TransferredTransformStream.prototype[kDeserialize] = () => {}; | |||
| 261 | 268 | class TransformStreamDefaultController { | |
| 262 | 269 | [kType] = 'TransformStreamDefaultController'; | |
| 263 | 270 | ||
| 264 | - get [SymbolToStringTag]() { return this[kType]; } | ||
| 265 | - | ||
| 266 | 271 | constructor() { | |
| 267 | 272 | throw new ERR_ILLEGAL_CONSTRUCTOR(); | |
| 268 | 273 | } | |
@@ -322,6 +327,7 @@ ObjectDefineProperties(TransformStreamDefaultController.prototype, { | |||
| 322 | 327 | enqueue: kEnumerableProperty, | |
| 323 | 328 | error: kEnumerableProperty, | |
| 324 | 329 | terminate: kEnumerableProperty, | |
| 330 | + [SymbolToStringTag]: getNonWritablePropertyDescriptor(TransformStreamDefaultController.name), | ||
| 325 | 331 | }); | |
| 326 | 332 | ||
| 327 | 333 | function createTransformStreamDefaultController() { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -77,6 +77,14 @@ const kAbort = Symbol('kAbort'); | |||
| 77 | 77 | const kCloseSentinel = Symbol('kCloseSentinel'); | |
| 78 | 78 | const kError = Symbol('kError'); | |
| 79 | 79 | ||
| 80 | + const getNonWritablePropertyDescriptor = (value) => { | ||
| 81 | + return { | ||
| 82 | + __proto__: null, | ||
| 83 | + configurable: true, | ||
| 84 | + value, | ||
| 85 | + }; | ||
| 86 | + }; | ||
| 87 | + | ||
| 80 | 88 | /** | |
| 81 | 89 | * @typedef {import('../abort_controller').AbortSignal} AbortSignal | |
| 82 | 90 | * @typedef {import('./queuingstrategies').QueuingStrategy | |
@@ -121,8 +129,6 @@ const kError = Symbol('kError'); | |||
| 121 | 129 | class WritableStream { | |
| 122 | 130 | [kType] = 'WritableStream'; | |
| 123 | 131 | ||
| 124 | - get [SymbolToStringTag]() { return this[kType]; } | ||
| 125 | - | ||
| 126 | 132 | /** | |
| 127 | 133 | * @param {UnderlyingSink} [sink] | |
| 128 | 134 | * @param {QueuingStrategy} [strategy] | |
@@ -295,6 +301,7 @@ ObjectDefineProperties(WritableStream.prototype, { | |||
| 295 | 301 | abort: kEnumerableProperty, | |
| 296 | 302 | close: kEnumerableProperty, | |
| 297 | 303 | getWriter: kEnumerableProperty, | |
| 304 | + [SymbolToStringTag]: getNonWritablePropertyDescriptor(WritableStream.name), | ||
| 298 | 305 | }); | |
| 299 | 306 | ||
| 300 | 307 | function TransferredWritableStream() { | |
@@ -348,8 +355,6 @@ TransferredWritableStream.prototype[kDeserialize] = () => {}; | |||
| 348 | 355 | class WritableStreamDefaultWriter { | |
| 349 | 356 | [kType] = 'WritableStreamDefaultWriter'; | |
| 350 | 357 | ||
| 351 | - get [SymbolToStringTag]() { return this[kType]; } | ||
| 352 | - | ||
| 353 | 358 | /** | |
| 354 | 359 | * @param {WritableStream} stream | |
| 355 | 360 | */ | |
@@ -487,13 +492,12 @@ ObjectDefineProperties(WritableStreamDefaultWriter.prototype, { | |||
| 487 | 492 | close: kEnumerableProperty, | |
| 488 | 493 | releaseLock: kEnumerableProperty, | |
| 489 | 494 | write: kEnumerableProperty, | |
| 495 | + [SymbolToStringTag]: getNonWritablePropertyDescriptor(WritableStreamDefaultWriter.name), | ||
| 490 | 496 | }); | |
| 491 | 497 | ||
| 492 | 498 | class WritableStreamDefaultController { | |
| 493 | 499 | [kType] = 'WritableStreamDefaultController'; | |
| 494 | 500 | ||
| 495 | - get [SymbolToStringTag]() { return this[kType]; } | ||
| 496 | - | ||
| 497 | 501 | constructor() { | |
| 498 | 502 | throw new ERR_ILLEGAL_CONSTRUCTOR(); | |
| 499 | 503 | } | |
@@ -538,6 +542,7 @@ class WritableStreamDefaultController { | |||
| 538 | 542 | ObjectDefineProperties(WritableStreamDefaultController.prototype, { | |
| 539 | 543 | signal: kEnumerableProperty, | |
| 540 | 544 | error: kEnumerableProperty, | |
| 545 | + [SymbolToStringTag]: getNonWritablePropertyDescriptor(WritableStreamDefaultController.name), | ||
| 541 | 546 | }); | |
| 542 | 547 | ||
| 543 | 548 | function createWritableStreamDefaultController() { | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -0,0 +1,18 @@ | |||
| 1 | + 'use strict'; | ||
| 2 | + | ||
| 3 | + require('../common'); | ||
| 4 | + | ||
| 5 | + const assert = require('assert'); | ||
| 6 | + | ||
| 7 | + const classesToBeTested = [ WritableStream, WritableStreamDefaultWriter, WritableStreamDefaultController, | ||
| 8 | + ReadableStream, ReadableStreamBYOBRequest, ReadableStreamDefaultReader, | ||
| 9 | + ReadableStreamBYOBReader, ReadableStreamDefaultController, ReadableByteStreamController, | ||
| 10 | + ByteLengthQueuingStrategy, CountQueuingStrategy, TransformStream, | ||
| 11 | + TransformStreamDefaultController]; | ||
| 12 | + | ||
| 13 | + | ||
| 14 | + classesToBeTested.forEach((cls) => { | ||
| 15 | + assert.strictEqual(cls.prototype[Symbol.toStringTag], cls.name); | ||
| 16 | + assert.deepStrictEqual(Object.getOwnPropertyDescriptor(cls.prototype, Symbol.toStringTag), | ||
| 17 | + { configurable: true, enumerable: false, value: cls.name, writable: false }); | ||
| 18 | + }); | ||
| Back | FazBrowse Home | New Git URL |
0 commit comments