mirror of
https://github.com/emn178/js-md2.git
synced 2026-08-12 20:27:33 +08:00
Support AMD.
This commit is contained in:
+12
-5
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* js-md5 v0.2.0
|
||||
* js-md5 v0.2.1
|
||||
* https://github.com/emn178/js-md2
|
||||
*
|
||||
* Copyright 2014-2015, emn178@gmail.com
|
||||
@@ -10,10 +10,12 @@
|
||||
;(function(root, undefined) {
|
||||
'use strict';
|
||||
|
||||
var NODE_JS = typeof(module) != 'undefined';
|
||||
var NODE_JS = typeof process == 'object' && process.versions && process.versions.node;
|
||||
if(NODE_JS) {
|
||||
root = global;
|
||||
}
|
||||
var COMMON_JS = !root.JS_MD2_TEST && typeof module == 'object' && module.exports;
|
||||
var AMD = typeof define == 'function' && define.amd;
|
||||
var HEX_CHARS = '0123456789abcdef'.split('');
|
||||
|
||||
var S = [ 0x29, 0x2E, 0x43, 0xC9, 0xA2, 0xD8, 0x7C, 0x01, 0x3D, 0x36, 0x54, 0xA1, 0xEC, 0xF0, 0x06, 0x13,
|
||||
@@ -35,7 +37,7 @@
|
||||
|
||||
var M = [], X = [], C = [];
|
||||
|
||||
var md2 = function(message, asciiOnly) {
|
||||
var md2 = function(message) {
|
||||
var code, i, j, k, t, L = 0, loop = 1, B,
|
||||
index = 0, start = 0, bytes = 0, length = message.length;
|
||||
|
||||
@@ -140,9 +142,14 @@
|
||||
return hex;
|
||||
};
|
||||
|
||||
if(!root.JS_MD2_TEST && NODE_JS) {
|
||||
if(COMMON_JS) {
|
||||
module.exports = md2;
|
||||
} else if(root) {
|
||||
} else {
|
||||
if(AMD) {
|
||||
define(function() {
|
||||
return md2;
|
||||
});
|
||||
}
|
||||
root.md2 = md2;
|
||||
}
|
||||
}(this));
|
||||
|
||||
Reference in New Issue
Block a user