[Pkg-javascript-commits] [node-sha.js] 105/237: remove encoding utils

Bastien Roucariès rouca at moszumanska.debian.org
Fri May 5 09:03:44 UTC 2017


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

rouca pushed a commit to branch master
in repository node-sha.js.

commit b0a9d4bc153bd8ffd23d85e5c6a51ac8d7f81d51
Author: Dominic Tarr <dominic.tarr at gmail.com>
Date:   Wed Jan 15 16:20:27 2014 +0700

    remove encoding utils
---
 util.js | 34 ----------------------------------
 1 file changed, 34 deletions(-)

diff --git a/util.js b/util.js
index bd46ec8..9944196 100644
--- a/util.js
+++ b/util.js
@@ -1,9 +1,7 @@
 exports.write = write
-exports.toHex = toHex
 exports.zeroFill = zeroFill
 
 exports.toString = toString
-var bopsToString = require('bops/typedarray/to')
 
 function write (buffer, string, enc, start, from, to, LE) {
   var l = (to - from)
@@ -30,41 +28,9 @@ function write (buffer, string, enc, start, from, to, LE) {
     throw new Error(enc +' encoding not yet supported')
 }
 
-function toHex (buf) {
-  buf = buf.buffer || buf
-  var l = 'string' === typeof buf ? buf.length : buf.byteLength
-  var s = ''
-  for(var i = 0; i < l; i++) {
-    var char = buf.charCodeAt ? buf.charCodeAt(i) : buf[i]
-    s += ((char>>4).toString(16)) + ((char&0xf).toString(16))
-  }
-  return s
-}
-
-function toBinary (buf) {
-  var s = ''
-  var l = 'string' === typeof buf ? buf.length : buf.byteLength
-  var s = ''
-  for(var i = 0; i < l; i++) {
-    var char = buf.charCodeAt ? buf.charCodeAt(i) :  buf[i]
-    s += String.fromCharCode(char)
-  }
-  return s
-}
-
 //always fill to the end!
 function zeroFill(buf, from) {
   for(var i = from; i < buf.length; i++)
     buf[i] = 0
 }
 
-function toString(buf, enc) {
-  if(Buffer.isBuffer(buf))
-    return buf.toString(enc)
-  if(null == enc) return buf
-  if('hex' == enc)
-    return toHex(buf)
-  if('binary' == enc)
-    return toBinary(buf)
-  return bopsToString(buf, enc)
-}

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



More information about the Pkg-javascript-commits mailing list