[Pkg-javascript-commits] [node-hash.js] 06/29: lib: remove require('assert')
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 ef8f6b80bf9166381523530d688322c536b638e9
Author: Fedor Indutny <fedor at indutny.com>
Date: Tue May 6 13:34:17 2014 +0400
lib: remove require('assert')
---
lib/hash/common.js | 2 +-
lib/hash/hmac.js | 2 +-
lib/hash/ripemd.js | 1 -
lib/hash/sha.js | 4 ++--
lib/hash/utils.js | 10 +++++++---
5 files changed, 11 insertions(+), 8 deletions(-)
diff --git a/lib/hash/common.js b/lib/hash/common.js
index a186377..1e0506a 100644
--- a/lib/hash/common.js
+++ b/lib/hash/common.js
@@ -1,6 +1,6 @@
-var assert = require('assert');
var hash = require('../hash');
var utils = hash.utils;
+var assert = utils.assert;
function BlockHash() {
this.pending = null;
diff --git a/lib/hash/hmac.js b/lib/hash/hmac.js
index ebffd3f..d48f3eb 100644
--- a/lib/hash/hmac.js
+++ b/lib/hash/hmac.js
@@ -1,8 +1,8 @@
var hmac = exports;
-var assert = require('assert');
var hash = require('../hash');
var utils = hash.utils;
+var assert = utils.assert;
function Hmac(hash, key, enc) {
if (!(this instanceof Hmac))
diff --git a/lib/hash/ripemd.js b/lib/hash/ripemd.js
index 9f37f5b..cce8baf 100644
--- a/lib/hash/ripemd.js
+++ b/lib/hash/ripemd.js
@@ -1,4 +1,3 @@
-var assert = require('assert');
var util = require('util');
var hash = require('../hash');
var utils = hash.utils;
diff --git a/lib/hash/sha.js b/lib/hash/sha.js
index 80fe84e..c22d78f 100644
--- a/lib/hash/sha.js
+++ b/lib/hash/sha.js
@@ -1,7 +1,7 @@
-var assert = require('assert');
var util = require('util');
var hash = require('../hash');
var utils = hash.utils;
+var assert = utils.assert;
var rotr32 = utils.rotr32;
var rotl32 = utils.rotl32;
@@ -61,7 +61,7 @@ SHA256.prototype._update = function _update(msg) {
var g = this.h[6];
var h = this.h[7];
- assert.equal(this.k.length, W.length);
+ assert(this.k.length === W.length);
for (var i = 0; i < W.length; i++) {
var T1 = sum32_5(h, s1_256(e), ch32(e, f, g), this.k[i], W[i]);
var T2 = sum32(s0_256(a), maj32(a, b, c));
diff --git a/lib/hash/utils.js b/lib/hash/utils.js
index b2797c8..2dc7fdc 100644
--- a/lib/hash/utils.js
+++ b/lib/hash/utils.js
@@ -1,5 +1,3 @@
-var assert = require('assert');
-
var utils = exports;
function toArray(msg, enc) {
@@ -89,7 +87,7 @@ function zero8(word) {
utils.zero8 = zero8;
function join32(msg, endian) {
- assert.equal(msg.length % 4, 0);
+ assert(msg.length % 4 === 0);
var res = new Array(msg.length / 4);
for (var i = 0, k = 0; i < res.length; i++, k += 4) {
var w;
@@ -166,3 +164,9 @@ function sum32_5(a, b, c, d, e) {
return r;
}
utils.sum32_5 = sum32_5;
+
+function assert(cond, msg) {
+ if (!cond)
+ throw new Error(msg || 'Assertion failed');
+}
+utils.assert = assert;
--
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