[Pkg-javascript-commits] [node-hash.js] 07/29: lib: remove require('util')

Bastien Roucariès rouca at moszumanska.debian.org
Thu Apr 20 19:30:37 UTC 2017


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

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

commit 7686e1eb27270cdcd1f957fd7d5adfcd774ca87c
Author: Fedor Indutny <fedor at indutny.com>
Date:   Tue May 6 13:39:07 2014 +0400

    lib: remove require('util')
---
 lib/hash/ripemd.js |  3 +--
 lib/hash/sha.js    |  5 ++---
 lib/hash/utils.js  | 25 +++++++++++++++++++++++++
 3 files changed, 28 insertions(+), 5 deletions(-)

diff --git a/lib/hash/ripemd.js b/lib/hash/ripemd.js
index cce8baf..7f569ed 100644
--- a/lib/hash/ripemd.js
+++ b/lib/hash/ripemd.js
@@ -1,4 +1,3 @@
-var util = require('util');
 var hash = require('../hash');
 var utils = hash.utils;
 
@@ -17,7 +16,7 @@ function RIPEMD160() {
   this.h = [ 0x67452301, 0xefcdab89, 0x98badcfe, 0x10325476, 0xc3d2e1f0 ];
   this.endian = 'little';
 }
-util.inherits(RIPEMD160, BlockHash);
+utils.inherits(RIPEMD160, BlockHash);
 exports.ripemd160 = RIPEMD160;
 
 RIPEMD160.blockSize = 512;
diff --git a/lib/hash/sha.js b/lib/hash/sha.js
index c22d78f..7b9b673 100644
--- a/lib/hash/sha.js
+++ b/lib/hash/sha.js
@@ -1,4 +1,3 @@
-var util = require('util');
 var hash = require('../hash');
 var utils = hash.utils;
 var assert = utils.assert;
@@ -38,7 +37,7 @@ function SHA256() {
              0x510e527f, 0x9b05688c, 0x1f83d9ab, 0x5be0cd19 ];
   this.k = sha256_K;
 }
-util.inherits(SHA256, BlockHash);
+utils.inherits(SHA256, BlockHash);
 exports.sha256 = SHA256;
 
 SHA256.blockSize = 512;
@@ -100,7 +99,7 @@ function SHA224() {
   this.h = [ 0xc1059ed8, 0x367cd507, 0x3070dd17, 0xf70e5939,
              0xffc00b31, 0x68581511, 0x64f98fa7, 0xbefa4fa4 ];
 }
-util.inherits(SHA224, SHA256);
+utils.inherits(SHA224, SHA256);
 exports.sha224 = SHA224;
 
 SHA224.blockSize = 512;
diff --git a/lib/hash/utils.js b/lib/hash/utils.js
index 2dc7fdc..55e14f0 100644
--- a/lib/hash/utils.js
+++ b/lib/hash/utils.js
@@ -170,3 +170,28 @@ function assert(cond, msg) {
     throw new Error(msg || 'Assertion failed');
 }
 utils.assert = assert;
+
+// Shamelessly copied from browserify
+if (typeof Object.create === 'function') {
+  // implementation from standard node.js 'util' module
+  utils.inherits = function inherits(ctor, superCtor) {
+    ctor.super_ = superCtor
+    ctor.prototype = Object.create(superCtor.prototype, {
+      constructor: {
+        value: ctor,
+        enumerable: false,
+        writable: true,
+        configurable: true
+      }
+    });
+  };
+} else {
+  // old school shim for old browsers
+  utils.inherits = function inherits(ctor, superCtor) {
+    ctor.super_ = superCtor
+    var TempCtor = function () {}
+    TempCtor.prototype = superCtor.prototype
+    ctor.prototype = new TempCtor()
+    ctor.prototype.constructor = ctor
+  }
+}

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



More information about the Pkg-javascript-commits mailing list