From 72be5edf03ccea2673150ba06b255ee1eabebb2f Mon Sep 17 00:00:00 2001 From: solebox Date: Sun, 9 Oct 2016 20:00:13 +0300 Subject: [PATCH] crypto: naming anonymous functions. Ref: https://github.com/nodejs/node/issues/8913 PR-URL: https://github.com/nodejs/node/pull/8993 --- lib/crypto.js | 50 ++++++++++++++++++++++++++------------------------ 1 file changed, 26 insertions(+), 24 deletions(-) diff --git a/lib/crypto.js b/lib/crypto.js index aa5a7d0cc97579..33de8a0baef66d 100644 --- a/lib/crypto.js +++ b/lib/crypto.js @@ -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); }; @@ -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) { @@ -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; @@ -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(); @@ -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); }; @@ -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'); @@ -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)); }; @@ -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; @@ -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) {