| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
1 parent 2c568c8 commit db2d1ca
2 files changed
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -2695,6 +2695,18 @@ The `repl` module exports a `_builtinLibs` property that contains an array with | |||
| 2695 | 2695 | native modules. It was incomplete so far and instead it's better to rely upon | |
| 2696 | 2696 | `require('module').builtinModules`. | |
| 2697 | 2697 | ||
| 2698 | + <a id="DEP0143"></a> | ||
| 2699 | + ### DEP0143: `Transform._transformState` | ||
| 2700 | + <!-- YAML | ||
| 2701 | + changes: | ||
| 2702 | + - version: REPLACEME | ||
| 2703 | + pr-url: https://github.com/nodejs/node/pull/33126 | ||
| 2704 | + description: Runtime deprecation. | ||
| 2705 | + --> | ||
| 2706 | + Type: Runtime | ||
| 2707 | + `Transform._transformState` will be removed in future versions where it is | ||
| 2708 | + no longer required due to simplification of the implementation. | ||
| 2709 | + | ||
| 2698 | 2710 | [`--pending-deprecation`]: cli.html#cli_pending_deprecation | |
| 2699 | 2711 | [`--throw-deprecation`]: cli.html#cli_throw_deprecation | |
| 2700 | 2712 | [`Buffer.allocUnsafeSlow(size)`]: buffer.html#buffer_class_method_buffer_allocunsafeslow_size | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -64,7 +64,9 @@ | |||
| 64 | 64 | 'use strict'; | |
| 65 | 65 | ||
| 66 | 66 | const { | |
| 67 | + ObjectDefineProperty, | ||
| 67 | 68 | ObjectSetPrototypeOf, | |
| 69 | + Symbol | ||
| 68 | 70 | } = primordials; | |
| 69 | 71 | ||
| 70 | 72 | module.exports = Transform; | |
@@ -75,12 +77,15 @@ const { | |||
| 75 | 77 | ERR_TRANSFORM_WITH_LENGTH_0 | |
| 76 | 78 | } = require('internal/errors').codes; | |
| 77 | 79 | const Duplex = require('_stream_duplex'); | |
| 80 | + const internalUtil = require('internal/util'); | ||
| 81 | + | ||
| 78 | 82 | ObjectSetPrototypeOf(Transform.prototype, Duplex.prototype); | |
| 79 | 83 | ObjectSetPrototypeOf(Transform, Duplex); | |
| 80 | 84 | ||
| 85 | + const kTransformState = Symbol('kTransformState'); | ||
| 81 | 86 | ||
| 82 | 87 | function afterTransform(er, data) { | |
| 83 | - const ts = this._transformState; | ||
| 88 | + const ts = this[kTransformState]; | ||
| 84 | 89 | ts.transforming = false; | |
| 85 | 90 | ||
| 86 | 91 | const cb = ts.writecb; | |
@@ -111,7 +116,7 @@ function Transform(options) { | |||
| 111 | 116 | ||
| 112 | 117 | Duplex.call(this, options); | |
| 113 | 118 | ||
| 114 | - this._transformState = { | ||
| 119 | + this[kTransformState] = { | ||
| 115 | 120 | afterTransform: afterTransform.bind(this), | |
| 116 | 121 | needTransform: false, | |
| 117 | 122 | transforming: false, | |
@@ -147,8 +152,17 @@ function prefinish() { | |||
| 147 | 152 | } | |
| 148 | 153 | } | |
| 149 | 154 | ||
| 155 | + ObjectDefineProperty(Transform.prototype, '_transformState', { | ||
| 156 | + get: internalUtil.deprecate(function() { | ||
| 157 | + return this[kTransformState]; | ||
| 158 | + }, 'Transform.prototype._transformState is deprecated', 'DEP0143'), | ||
| 159 | + set: internalUtil.deprecate(function(val) { | ||
| 160 | + this[kTransformState] = val; | ||
| 161 | + }, 'Transform.prototype._transformState is deprecated', 'DEP0143') | ||
| 162 | + }); | ||
| 163 | + | ||
| 150 | 164 | Transform.prototype.push = function(chunk, encoding) { | |
| 151 | - this._transformState.needTransform = false; | ||
| 165 | + this[kTransformState].needTransform = false; | ||
| 152 | 166 | return Duplex.prototype.push.call(this, chunk, encoding); | |
| 153 | 167 | }; | |
| 154 | 168 | ||
@@ -167,7 +181,7 @@ Transform.prototype._transform = function(chunk, encoding, cb) { | |||
| 167 | 181 | }; | |
| 168 | 182 | ||
| 169 | 183 | Transform.prototype._write = function(chunk, encoding, cb) { | |
| 170 | - const ts = this._transformState; | ||
| 184 | + const ts = this[kTransformState]; | ||
| 171 | 185 | ts.writecb = cb; | |
| 172 | 186 | ts.writechunk = chunk; | |
| 173 | 187 | ts.writeencoding = encoding; | |
@@ -184,7 +198,7 @@ Transform.prototype._write = function(chunk, encoding, cb) { | |||
| 184 | 198 | // _transform does all the work. | |
| 185 | 199 | // That we got here means that the readable side wants more data. | |
| 186 | 200 | Transform.prototype._read = function(n) { | |
| 187 | - const ts = this._transformState; | ||
| 201 | + const ts = this[kTransformState]; | ||
| 188 | 202 | ||
| 189 | 203 | if (ts.writechunk !== null && !ts.transforming) { | |
| 190 | 204 | ts.transforming = true; | |
@@ -215,7 +229,7 @@ function done(stream, er, data) { | |||
| 215 | 229 | if (stream._writableState.length) | |
| 216 | 230 | throw new ERR_TRANSFORM_WITH_LENGTH_0(); | |
| 217 | 231 | ||
| 218 | - if (stream._transformState.transforming) | ||
| 232 | + if (stream[kTransformState].transforming) | ||
| 219 | 233 | throw new ERR_TRANSFORM_ALREADY_TRANSFORMING(); | |
| 220 | 234 | return stream.push(null); | |
| 221 | 235 | } | |
| Back | FazBrowse Home | New Git URL |
0 commit comments