summaryrefslogtreecommitdiff
path: root/lib/crypto.js
diff options
context:
space:
mode:
authorBrendan Ashworth <brendan.ashworth@me.com>2015-08-26 14:41:28 -0700
committerBrendan Ashworth <brendan.ashworth@me.com>2015-09-14 19:58:04 -0700
commitc70c7781e3c231e18a9c9eafdddfff0c7471820a (patch)
tree8542b7ad5e56f862397d5dead08627c5b4e0f4e2 /lib/crypto.js
parent7ec0491fd04767a8e6ab6277c7b58dc19f93cbf8 (diff)
downloadandroid-node-v8-c70c7781e3c231e18a9c9eafdddfff0c7471820a.tar.gz
android-node-v8-c70c7781e3c231e18a9c9eafdddfff0c7471820a.tar.bz2
android-node-v8-c70c7781e3c231e18a9c9eafdddfff0c7471820a.zip
streams: refactor LazyTransform to internal/
This commit refactors LazyTransform from the crypto implementation (lib/crypto.js) into an internal module (not publicy accessible) in internal/streams/lazy_transform.js. This promotes a more modular core design and removes code bloat in crypto, as LazyTransform didn't specifically have anything to do with cryptography, but rather a fast way to support two APIs on a stream. PR-URL: https://github.com/nodejs/node/pull/2566 Reviewed-By: Fedor Indutny <fedor.indutny@gmail.com>
Diffstat (limited to 'lib/crypto.js')
-rw-r--r--lib/crypto.js32
1 files changed, 1 insertions, 31 deletions
diff --git a/lib/crypto.js b/lib/crypto.js
index bfe7837cb4..b32d9aff90 100644
--- a/lib/crypto.js
+++ b/lib/crypto.js
@@ -20,6 +20,7 @@ const constants = require('constants');
const stream = require('stream');
const util = require('util');
const internalUtil = require('internal/util');
+const LazyTransform = require('internal/streams/lazy_transform');
const DH_GENERATOR = 2;
@@ -42,37 +43,6 @@ const assert = require('assert');
const StringDecoder = require('string_decoder').StringDecoder;
-function LazyTransform(options) {
- this._options = 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;
- this._writableState.defaultEncoding = 'binary';
- return this[prop];
- },
- set: function(val) {
- Object.defineProperty(this, prop, {
- value: val,
- enumerable: true,
- configurable: true,
- writable: true
- });
- },
- configurable: true,
- enumerable: true
- });
-});
-
-
exports.createHash = exports.Hash = Hash;
function Hash(algorithm, options) {
if (!(this instanceof Hash))