mirror of https://github.com/emn178/js-md5.git
Support node.js
parent
e7294029a3
commit
38c2c6f816
@ -0,0 +1,23 @@
|
||||
{
|
||||
"name": "js-md5",
|
||||
"version": "0.1.0",
|
||||
"description": "A simple MD5 hash function for JavaScript supports UTF-8 encoding.",
|
||||
"main": "src/md5.js",
|
||||
"scripts": {
|
||||
"test": "node tests/node-test.js"
|
||||
},
|
||||
"repository": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/emn178/js-md5.git"
|
||||
},
|
||||
"keywords": [
|
||||
"md5",
|
||||
"hash",
|
||||
"encryption"
|
||||
],
|
||||
"author": "emn178 <emn178@gmail.com>",
|
||||
"homepage": "https://github.com/emn178/js-md5",
|
||||
"bugs": {
|
||||
"url": "https://github.com/emn178/js-md5/issues"
|
||||
}
|
||||
}
|
@ -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,4 +1,3 @@
|
||||
window = global;
|
||||
require('../src/md5.js');
|
||||
global.md5 = require('../src/md5.js');
|
||||
require('./debug.js');
|
||||
require('./test.js');
|
||||
|
Loading…
Reference in New Issue