Comparing version 2.0.1 to 2.0.2
55
index.js
@@ -18,3 +18,27 @@ 'use strict' | ||
HashBase.prototype._transform = function (chunk, encoding, callback) { | ||
var error = null | ||
try { | ||
if (encoding !== 'buffer') chunk = new Buffer(chunk, encoding) | ||
this.update(chunk) | ||
} catch (err) { | ||
error = err | ||
} | ||
callback(error) | ||
} | ||
HashBase.prototype._flush = function (callback) { | ||
var error = null | ||
try { | ||
this.push(this._digest()) | ||
} catch (err) { | ||
error = err | ||
} | ||
callback(error) | ||
} | ||
HashBase.prototype.update = function (data, encoding) { | ||
if (!Buffer.isBuffer(data) && typeof data !== 'string') throw new TypeError('Data must be a string or a buffer') | ||
if (this._finalized) throw new Error('Digest already called') | ||
@@ -43,2 +67,6 @@ if (!Buffer.isBuffer(data)) data = new Buffer(data, encoding || 'binary') | ||
HashBase.prototype._update = function (data) { | ||
throw new Error('_update is not implemented') | ||
} | ||
HashBase.prototype.digest = function (encoding) { | ||
@@ -53,6 +81,2 @@ if (this._finalized) throw new Error('Digest already called') | ||
HashBase.prototype._update = function (data) { | ||
throw new Error('_update is not implemented') | ||
} | ||
HashBase.prototype._digest = function () { | ||
@@ -62,25 +86,2 @@ throw new Error('_digest is not implemented') | ||
HashBase.prototype._transform = function (chunk, encoding, callback) { | ||
var error = null | ||
try { | ||
if (encoding !== 'buffer') chunk = new Buffer(chunk, encoding) | ||
this.update(chunk) | ||
} catch (err) { | ||
error = err | ||
} | ||
callback(error) | ||
} | ||
HashBase.prototype._flush = function (callback) { | ||
var error = null | ||
try { | ||
this.push(this._digest()) | ||
} catch (err) { | ||
error = err | ||
} | ||
callback(error) | ||
} | ||
module.exports = HashBase |
{ | ||
"name": "hash-base", | ||
"version": "2.0.1", | ||
"version": "2.0.2", | ||
"description": "abstract base class for hash-streams", | ||
@@ -5,0 +5,0 @@ "keywords": [ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
4406
66