GeezerVison is showing github.com — streams: refactor LazyTransform to internal/ · nodejs/node@ed08783
File treeExpand file treeCollapse file tree Open diff view settings Expand file treeCollapse file tree Open diff view settings Collapse file Copy file name to clipboardExpand all lines: lib/crypto.js +1-31Lines changed: 1 addition & 31 deletions | Original file line number | Diff line number | Diff line change |
|---|
@@ -20,6 +20,7 @@ const constants = require('constants'); | 20 | 20 | const stream = require('stream'); | 21 | 21 | const util = require('util'); | 22 | 22 | const internalUtil = require('internal/util'); | | 23 | +const LazyTransform = require('internal/streams/lazy_transform'); | 23 | 24 |
| 24 | 25 | const DH_GENERATOR = 2; | 25 | 26 |
| @@ -42,37 +43,6 @@ const assert = require('assert'); | 42 | 43 | const StringDecoder = require('string_decoder').StringDecoder; | 43 | 44 |
| 44 | 45 |
| 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 | | - | 76 | 46 | exports.createHash = exports.Hash = Hash; | 77 | 47 | function Hash(algorithm, options) { | 78 | 48 | if (!(this instanceof Hash)) | |
Collapse file Copy file name to clipboard +39Lines changed: 39 additions & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| | 1 | +// LazyTransform is a special type of Transform stream that is lazily loaded. | | 2 | +// This is used for performance with bi-API-ship: when two APIs are available | | 3 | +// for the stream, one conventional and one non-conventional. | | 4 | +'use strict'; | | 5 | + | | 6 | +const stream = require('stream'); | | 7 | +const util = require('util'); | | 8 | + | | 9 | +module.exports = LazyTransform; | | 10 | + | | 11 | +function LazyTransform(options) { | | 12 | + this._options = options; | | 13 | +} | | 14 | +util.inherits(LazyTransform, stream.Transform); | | 15 | + | | 16 | +[ | | 17 | + '_readableState', | | 18 | + '_writableState', | | 19 | + '_transformState' | | 20 | +].forEach(function(prop, i, props) { | | 21 | + Object.defineProperty(LazyTransform.prototype, prop, { | | 22 | + get: function() { | | 23 | + stream.Transform.call(this, this._options); | | 24 | + this._writableState.decodeStrings = false; | | 25 | + this._writableState.defaultEncoding = 'binary'; | | 26 | + return this[prop]; | | 27 | + }, | | 28 | + set: function(val) { | | 29 | + Object.defineProperty(this, prop, { | | 30 | + value: val, | | 31 | + enumerable: true, | | 32 | + configurable: true, | | 33 | + writable: true | | 34 | + }); | | 35 | + }, | | 36 | + configurable: true, | | 37 | + enumerable: true | | 38 | + }); | | 39 | +}); |
Collapse file Copy file name to clipboardExpand all lines: node.gyp +1Lines changed: 1 addition & 0 deletions | Original file line number | Diff line number | Diff line change |
|---|
| 73 | 73 | 'lib/internal/socket_list.js', | 74 | 74 | 'lib/internal/repl.js', | 75 | 75 | 'lib/internal/util.js', | | 76 | + 'lib/internal/streams/lazy_transform.js', | 76 | 77 | ], | 77 | 78 | }, | 78 | 79 |
| |
|