[Pkg-javascript-commits] [node-hash-base] 01/02: Remove extra check

Bastien Roucariès rouca at moszumanska.debian.org
Thu May 4 10:21:29 UTC 2017


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to annotated tag v3.0.2
in repository node-hash-base.

commit bd13db2156ce1fa56ddfc7931ef034aebf693903
Author: Kirill Fomichev <fanatid at ya.ru>
Date:   Thu Aug 25 15:37:37 2016 +0300

    Remove extra check
---
 index.js      | 3 +--
 test/index.js | 9 ++++++---
 2 files changed, 7 insertions(+), 5 deletions(-)

diff --git a/index.js b/index.js
index c917cdf..01371cd 100644
--- a/index.js
+++ b/index.js
@@ -18,8 +18,7 @@ inherits(HashBase, Transform)
 HashBase.prototype._transform = function (chunk, encoding, callback) {
   var error = null
   try {
-    if (encoding !== 'buffer') chunk = new Buffer(chunk, encoding)
-    this.update(chunk)
+    this.update(chunk, encoding)
   } catch (err) {
     error = err
   }
diff --git a/test/index.js b/test/index.js
index 3b5ddba..0b260f1 100644
--- a/test/index.js
+++ b/test/index.js
@@ -26,9 +26,12 @@ test('_transform', function (t) {
     t.end()
   })
 
-  t.test('should decode string with custom encoding', function (t) {
-    t.plan(2)
-    t.base.update = function (data) { t.same(data, new Buffer('УТФ-8 text', 'utf8')) }
+  t.test('should pass encoding to update', function (t) {
+    t.plan(3)
+    t.base.update = function (data, encoding) {
+      t.same(data, 'УТФ-8 text')
+      t.same(encoding, 'utf8')
+    }
     t.base._transform('УТФ-8 text', 'utf8', function (err) {
       t.same(err, null)
     })

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-hash-base.git



More information about the Pkg-javascript-commits mailing list