Skip to content

Commit

Permalink
crypto: naming anonymous functions
Browse files Browse the repository at this point in the history
Ref: #8913
PR-URL: #8993
Reviewed-By: James M Snell <[email protected]>
Reviewed-By: Michaël Zasso <[email protected]>
Reviewed-By: Sakthipriyan Vairamani <[email protected]>
Reviewed-By: Luigi Pinca <[email protected]>
Reviewed-By: Anna Henningsen <[email protected]>
  • Loading branch information
solebox authored and jasnell committed Oct 17, 2016
1 parent ea011eb commit 72f1c41
Showing 1 changed file with 26 additions and 24 deletions.
50 changes: 26 additions & 24 deletions lib/crypto.js
Original file line number Diff line number Diff line change
Expand Up @@ -59,24 +59,24 @@ function Hash(algorithm, options) {

util.inherits(Hash, LazyTransform);

Hash.prototype._transform = function(chunk, encoding, callback) {
Hash.prototype._transform = function _transform(chunk, encoding, callback) {
this._handle.update(chunk, encoding);
callback();
};

Hash.prototype._flush = function(callback) {
Hash.prototype._flush = function _flush(callback) {
this.push(this._handle.digest());
callback();
};

Hash.prototype.update = function(data, encoding) {
Hash.prototype.update = function update(data, encoding) {
encoding = encoding || exports.DEFAULT_ENCODING;
this._handle.update(data, encoding);
return this;
};


Hash.prototype.digest = function(outputEncoding) {
Hash.prototype.digest = function digest(outputEncoding) {
outputEncoding = outputEncoding || exports.DEFAULT_ENCODING;
return this._handle.digest(outputEncoding);
};
Expand Down Expand Up @@ -122,12 +122,12 @@ function Cipher(cipher, password, options) {

util.inherits(Cipher, LazyTransform);

Cipher.prototype._transform = function(chunk, encoding, callback) {
Cipher.prototype._transform = function _transform(chunk, encoding, callback) {
this.push(this._handle.update(chunk, encoding));
callback();
};

Cipher.prototype._flush = function(callback) {
Cipher.prototype._flush = function _flush(callback) {
try {
this.push(this._handle.final());
} catch (e) {
Expand All @@ -137,7 +137,7 @@ Cipher.prototype._flush = function(callback) {
callback();
};

Cipher.prototype.update = function(data, inputEncoding, outputEncoding) {
Cipher.prototype.update = function update(data, inputEncoding, outputEncoding) {
inputEncoding = inputEncoding || exports.DEFAULT_ENCODING;
outputEncoding = outputEncoding || exports.DEFAULT_ENCODING;

Expand All @@ -152,7 +152,7 @@ Cipher.prototype.update = function(data, inputEncoding, outputEncoding) {
};


Cipher.prototype.final = function(outputEncoding) {
Cipher.prototype.final = function final(outputEncoding) {
outputEncoding = outputEncoding || exports.DEFAULT_ENCODING;
var ret = this._handle.final();

Expand All @@ -165,21 +165,21 @@ Cipher.prototype.final = function(outputEncoding) {
};


Cipher.prototype.setAutoPadding = function(ap) {
Cipher.prototype.setAutoPadding = function setAutoPadding(ap) {
this._handle.setAutoPadding(ap);
return this;
};

Cipher.prototype.getAuthTag = function() {
Cipher.prototype.getAuthTag = function getAuthTag() {
return this._handle.getAuthTag();
};


Cipher.prototype.setAuthTag = function(tagbuf) {
Cipher.prototype.setAuthTag = function setAuthTag(tagbuf) {
this._handle.setAuthTag(tagbuf);
};

Cipher.prototype.setAAD = function(aadbuf) {
Cipher.prototype.setAAD = function setAAD(aadbuf) {
this._handle.setAAD(aadbuf);
};

Expand Down Expand Up @@ -267,14 +267,14 @@ function Sign(algorithm, options) {

util.inherits(Sign, stream.Writable);

Sign.prototype._write = function(chunk, encoding, callback) {
Sign.prototype._write = function _write(chunk, encoding, callback) {
this._handle.update(chunk, encoding);
callback();
};

Sign.prototype.update = Hash.prototype.update;

Sign.prototype.sign = function(options, encoding) {
Sign.prototype.sign = function sign(options, encoding) {
if (!options)
throw new Error('No key provided to sign');

Expand Down Expand Up @@ -306,7 +306,7 @@ util.inherits(Verify, stream.Writable);
Verify.prototype._write = Sign.prototype._write;
Verify.prototype.update = Sign.prototype.update;

Verify.prototype.verify = function(object, signature, sigEncoding) {
Verify.prototype.verify = function verify(object, signature, sigEncoding) {
sigEncoding = sigEncoding || exports.DEFAULT_ENCODING;
return this._handle.verify(toBuf(object), toBuf(signature, sigEncoding));
};
Expand Down Expand Up @@ -474,14 +474,14 @@ function dhGetPrivateKey(encoding) {
}


DiffieHellman.prototype.setPublicKey = function(key, encoding) {
DiffieHellman.prototype.setPublicKey = function setPublicKey(key, encoding) {
encoding = encoding || exports.DEFAULT_ENCODING;
this._handle.setPublicKey(toBuf(key, encoding));
return this;
};


DiffieHellman.prototype.setPrivateKey = function(key, encoding) {
DiffieHellman.prototype.setPrivateKey = function setPrivateKey(key, encoding) {
encoding = encoding || exports.DEFAULT_ENCODING;
this._handle.setPrivateKey(toBuf(key, encoding));
return this;
Expand Down Expand Up @@ -599,19 +599,21 @@ function Certificate() {
}


Certificate.prototype.verifySpkac = function(object) {
Certificate.prototype.verifySpkac = function verifySpkac(object) {
return binding.certVerifySpkac(object);
};


Certificate.prototype.exportPublicKey = function(object, encoding) {
return binding.certExportPublicKey(toBuf(object, encoding));
};
Certificate.prototype.exportPublicKey =
function exportPublicKey(object, encoding) {
return binding.certExportPublicKey(toBuf(object, encoding));
};


Certificate.prototype.exportChallenge = function(object, encoding) {
return binding.certExportChallenge(toBuf(object, encoding));
};
Certificate.prototype.exportChallenge =
function exportChallenge(object, encoding) {
return binding.certExportChallenge(toBuf(object, encoding));
};


exports.setEngine = function setEngine(id, flags) {
Expand Down

0 comments on commit 72f1c41

Please sign in to comment.