|
|
@ -14,31 +14,47 @@ function LazyTransform(options) { |
|
|
|
} |
|
|
|
util.inherits(LazyTransform, stream.Transform); |
|
|
|
|
|
|
|
[ |
|
|
|
'_readableState', |
|
|
|
'_writableState', |
|
|
|
'_transformState' |
|
|
|
].forEach(function(prop, i, props) { |
|
|
|
Object.defineProperty(LazyTransform.prototype, prop, { |
|
|
|
get: function() { |
|
|
|
stream.Transform.call(this, this._options); |
|
|
|
this._writableState.decodeStrings = false; |
|
|
|
|
|
|
|
if (!this._options || !this._options.defaultEncoding) { |
|
|
|
this._writableState.defaultEncoding = crypto.DEFAULT_ENCODING; |
|
|
|
} |
|
|
|
|
|
|
|
return this[prop]; |
|
|
|
}, |
|
|
|
set: function(val) { |
|
|
|
Object.defineProperty(this, prop, { |
|
|
|
value: val, |
|
|
|
enumerable: true, |
|
|
|
configurable: true, |
|
|
|
writable: true |
|
|
|
}); |
|
|
|
}, |
|
|
|
function makeGetter(name) { |
|
|
|
return function() { |
|
|
|
stream.Transform.call(this, this._options); |
|
|
|
this._writableState.decodeStrings = false; |
|
|
|
|
|
|
|
if (!this._options || !this._options.defaultEncoding) { |
|
|
|
this._writableState.defaultEncoding = crypto.DEFAULT_ENCODING; |
|
|
|
} |
|
|
|
|
|
|
|
return this[name]; |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
function makeSetter(name) { |
|
|
|
return function(val) { |
|
|
|
Object.defineProperty(this, name, { |
|
|
|
value: val, |
|
|
|
enumerable: true, |
|
|
|
configurable: true, |
|
|
|
writable: true |
|
|
|
}); |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
Object.defineProperties(LazyTransform.prototype, { |
|
|
|
_readableState: { |
|
|
|
get: makeGetter('_readableState'), |
|
|
|
set: makeSetter('_readableState'), |
|
|
|
configurable: true, |
|
|
|
enumerable: true |
|
|
|
}, |
|
|
|
_writableState: { |
|
|
|
get: makeGetter('_writableState'), |
|
|
|
set: makeSetter('_writableState'), |
|
|
|
configurable: true, |
|
|
|
enumerable: true |
|
|
|
}, |
|
|
|
_transformState: { |
|
|
|
get: makeGetter('_transformState'), |
|
|
|
set: makeSetter('_transformState'), |
|
|
|
configurable: true, |
|
|
|
enumerable: true |
|
|
|
}); |
|
|
|
} |
|
|
|
}); |
|
|
|