streams: refactor LazyTransform to internal/ · nodejs/node@eaa8e60

Original file line numberDiff line numberDiff line change

@@ -20,6 +20,7 @@ const constants = require('constants');

2020

const stream = require('stream');

2121

const util = require('util');

2222

const internalUtil = require('internal/util');

23+

const LazyTransform = require('internal/streams/lazy_transform');

2324
2425

const DH_GENERATOR = 2;

2526

@@ -42,37 +43,6 @@ const assert = require('assert');

4243

const StringDecoder = require('string_decoder').StringDecoder;

4344
4445
45-

function LazyTransform(options) {

46-

this._options = options;

47-

}

48-

util.inherits(LazyTransform, stream.Transform);

49-
50-

[

51-

'_readableState',

52-

'_writableState',

53-

'_transformState'

54-

].forEach(function(prop, i, props) {

55-

Object.defineProperty(LazyTransform.prototype, prop, {

56-

get: function() {

57-

stream.Transform.call(this, this._options);

58-

this._writableState.decodeStrings = false;

59-

this._writableState.defaultEncoding = 'binary';

60-

return this[prop];

61-

},

62-

set: function(val) {

63-

Object.defineProperty(this, prop, {

64-

value: val,

65-

enumerable: true,

66-

configurable: true,

67-

writable: true

68-

});

69-

},

70-

configurable: true,

71-

enumerable: true

72-

});

73-

});

74-
75-
7646

exports.createHash = exports.Hash = Hash;

7747

function Hash(algorithm, options) {

7848

if (!(this instanceof Hash))