[Pkg-javascript-commits] [node-hash-base] 01/05: utf8 as default encoding
Bastien Roucariès
rouca at moszumanska.debian.org
Thu May 4 10:21:26 UTC 2017
This is an automated email from the git hooks/post-receive script.
rouca pushed a commit to annotated tag v3.0.0
in repository node-hash-base.
commit 5d95d75d68483c99909b53007110ef6f8509c830
Author: Kirill Fomichev <fanatid at ya.ru>
Date: Fri Apr 29 12:17:15 2016 +0300
utf8 as default encoding
details: https://github.com/nodejs/node/pull/5522
---
.travis.yml | 1 +
index.js | 2 +-
test/index.js | 8 +++++---
3 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index d4dedd6..296bd19 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -6,6 +6,7 @@ node_js:
- "0.12"
- "4"
- "5"
+ - "6"
env:
matrix:
- TEST_SUITE=unit
diff --git a/index.js b/index.js
index 9cd6a70..914af68 100644
--- a/index.js
+++ b/index.js
@@ -41,7 +41,7 @@ HashBase.prototype._flush = function (callback) {
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')
- if (!Buffer.isBuffer(data)) data = new Buffer(data, encoding || 'binary')
+ if (!Buffer.isBuffer(data)) data = new Buffer(data, encoding)
// consume data
var block = this._block
diff --git a/test/index.js b/test/index.js
index 5cd9c93..18798d1 100644
--- a/test/index.js
+++ b/test/index.js
@@ -1,5 +1,5 @@
'use strict'
-var test = require('tape').test
+var test = require('tape')
var HashBase = require('../')
function beforeEach (t) {
@@ -87,11 +87,13 @@ test('update', function (t) {
t.end()
})
- t.test('decode string with binary by default', function (t) {
+ t.test('decode string with utf8 by default', function (t) {
t.plan(1)
var buffer = new Buffer(64)
+ buffer.fill(0)
+ new Buffer('УТФ-8', 'utf8').copy(buffer)
t.base._update = function () { t.same(this._block, buffer) }
- t.base.update(buffer.toString('binary'))
+ t.base.update(buffer.toString('utf8'))
t.end()
})
--
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