mirror of
https://github.com/emn178/js-md5.git
synced 2026-08-12 20:31:43 +08:00
Support node.js
This commit is contained in:
+6
-29
@@ -1,35 +1,12 @@
|
||||
(function(window){
|
||||
//console.time implementation for IE
|
||||
if(window.console && typeof(window.console.time) == "undefined") {
|
||||
console.time = function(name, reset){
|
||||
if(!name) { return; }
|
||||
var time = new Date().getTime();
|
||||
if(!console.timeCounters) { console.timeCounters = {} };
|
||||
var key = "KEY" + name.toString();
|
||||
if(!reset && console.timeCounters[key]) { return; }
|
||||
console.timeCounters[key] = time;
|
||||
};
|
||||
|
||||
console.timeEnd = function(name){
|
||||
var time = new Date().getTime();
|
||||
if(!console.timeCounters) { return; }
|
||||
var key = "KEY" + name.toString();
|
||||
var timeCounter = console.timeCounters[key];
|
||||
if(timeCounter) {
|
||||
var diff = time - timeCounter;
|
||||
var label = name + ": " + diff + "ms";
|
||||
console.info(label);
|
||||
delete console.timeCounters[key];
|
||||
}
|
||||
return diff;
|
||||
};
|
||||
}
|
||||
|
||||
(function(root){
|
||||
var assert = function (title, expect, actual) {
|
||||
if(expect == actual)
|
||||
console.log(title + ': true');
|
||||
else
|
||||
console.log(title + ': false', 'Except:' + expect, 'Actual: ' + actual);
|
||||
};
|
||||
window.assert = assert;
|
||||
})(window);
|
||||
if(typeof(module) != 'undefined')
|
||||
global.assert = assert;
|
||||
else if(root)
|
||||
root.assert = assert;
|
||||
})(this);
|
||||
|
||||
+1
-2
@@ -1,4 +1,3 @@
|
||||
window = global;
|
||||
require('../src/md5.js');
|
||||
global.md5 = require('../src/md5.js');
|
||||
require('./debug.js');
|
||||
require('./test.js');
|
||||
|
||||
Reference in New Issue
Block a user