mirror of
https://github.com/emn178/js-md2.git
synced 2026-08-13 04:31:34 +08:00
Fixed root is undefined in some special environment.
This commit is contained in:
+1
-1
@@ -1,2 +1,2 @@
|
|||||||
|
/node_modules/
|
||||||
/tests/
|
/tests/
|
||||||
node_modules/
|
|
||||||
|
|||||||
+2
-2
@@ -1,2 +1,2 @@
|
|||||||
node_modules
|
/node_modules/
|
||||||
my_test
|
/covreporter/
|
||||||
|
|||||||
@@ -1,4 +0,0 @@
|
|||||||
my_test
|
|
||||||
covreporter
|
|
||||||
build
|
|
||||||
tests
|
|
||||||
+5
-6
@@ -1,12 +1,11 @@
|
|||||||
language: node_js
|
language: node_js
|
||||||
node_js:
|
node_js:
|
||||||
- "0.11"
|
- "0.12.15"
|
||||||
- "0.10"
|
- "4.5"
|
||||||
- "0.8"
|
- "6.5.0"
|
||||||
before_install:
|
before_install:
|
||||||
- npm install mocha -g
|
- npm install coveralls
|
||||||
- npm install coveralls -g
|
- npm install mocha-lcov-reporter
|
||||||
- npm install mocha-lcov-reporter -g
|
|
||||||
script: npm run-script coveralls
|
script: npm run-script coveralls
|
||||||
branches:
|
branches:
|
||||||
only:
|
only:
|
||||||
|
|||||||
+27
-15
@@ -1,24 +1,36 @@
|
|||||||
# v0.2.1 / 2015-04-03
|
# Change Log
|
||||||
|
|
||||||
* Support AMD.
|
## v0.2.2 / 2017-02-08
|
||||||
|
### Fixed
|
||||||
|
- `root` is undefined in some special environment.
|
||||||
|
|
||||||
# v0.2.0 / 2015-02-28
|
## v0.2.1 / 2015-04-03
|
||||||
|
### Added
|
||||||
|
- support AMD.
|
||||||
|
|
||||||
* Remove ascii parameter.
|
## v0.2.0 / 2015-02-28
|
||||||
* Improve performance.
|
### Added
|
||||||
* Add test case.
|
- test cases.
|
||||||
|
|
||||||
# v0.1.2 / 2015-01-07
|
### Removed
|
||||||
|
- ascii parameter.
|
||||||
|
|
||||||
* Add bower package.
|
### Improved
|
||||||
* Fixed JSHint warnings.
|
- performance.
|
||||||
* Add travis.
|
|
||||||
* Add coveralls.
|
|
||||||
|
|
||||||
# v0.1.1 / 2014-07-27
|
## v0.1.2 / 2015-01-07
|
||||||
|
### Added
|
||||||
|
- bower package.
|
||||||
|
- travis.
|
||||||
|
- coveralls.
|
||||||
|
|
||||||
Fixed accents bug
|
### Fixed
|
||||||
|
- JSHint warnings.
|
||||||
|
|
||||||
# v0.1.0 / 2014-01-05
|
## v0.1.1 / 2014-07-27
|
||||||
|
### Fixed
|
||||||
|
- accents bug
|
||||||
|
|
||||||
Initial release
|
## v0.1.0 / 2014-01-05
|
||||||
|
### Added
|
||||||
|
- initial release.
|
||||||
|
|||||||
+1
-1
@@ -1,4 +1,4 @@
|
|||||||
Copyright 2014-2015 emn178@gmail.com
|
Copyright 2014-2017 Chen, Yi-Cyuan
|
||||||
|
|
||||||
Permission is hereby granted, free of charge, to any person obtaining
|
Permission is hereby granted, free of charge, to any person obtaining
|
||||||
a copy of this software and associated documentation files (the
|
a copy of this software and associated documentation files (the
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ md2('Message to hash');
|
|||||||
```
|
```
|
||||||
If you use node.js, you should require the module first:
|
If you use node.js, you should require the module first:
|
||||||
```JavaScript
|
```JavaScript
|
||||||
md2 = require('js-md2');
|
var md2 = require('js-md2');
|
||||||
```
|
```
|
||||||
If you use require.js, you should require the module first:
|
If you use require.js, you should require the module first:
|
||||||
```JavaScript
|
```JavaScript
|
||||||
@@ -37,56 +37,18 @@ require(['md2.js'], function(md2) {
|
|||||||
```
|
```
|
||||||
|
|
||||||
## Example
|
## Example
|
||||||
Code
|
|
||||||
```JavaScript
|
```JavaScript
|
||||||
md2('');
|
md2(''); // 8350e5a3e24c153df2275c9f80692773
|
||||||
md2('The quick brown fox jumps over the lazy dog');
|
md2('The quick brown fox jumps over the lazy dog'); // 03d85a0d629d2c442e987525319fc471
|
||||||
md2('The quick brown fox jumps over the lazy dog.');
|
md2('The quick brown fox jumps over the lazy dog.'); // 71eaa7e440b611e41a6f0d97384b342a
|
||||||
|
|
||||||
|
// It also supports UTF-8 encoding
|
||||||
|
md2('中文'); // 7af93c270b0ec392ca2f0d90a927cf8a
|
||||||
```
|
```
|
||||||
Output
|
|
||||||
|
|
||||||
8350e5a3e24c153df2275c9f80692773
|
|
||||||
03d85a0d629d2c442e987525319fc471
|
|
||||||
71eaa7e440b611e41a6f0d97384b342a
|
|
||||||
|
|
||||||
It also supports UTF-8 encoding:
|
|
||||||
|
|
||||||
Code
|
|
||||||
```JavaScript
|
|
||||||
md2('中文');
|
|
||||||
```
|
|
||||||
Output
|
|
||||||
|
|
||||||
7af93c270b0ec392ca2f0d90a927cf8a
|
|
||||||
|
|
||||||
## Extensions
|
|
||||||
### jQuery
|
|
||||||
If you prefer jQuery style, you can add following code to add a jQuery extension.
|
|
||||||
|
|
||||||
Code
|
|
||||||
```JavaScript
|
|
||||||
jQuery.md2 = md2
|
|
||||||
```
|
|
||||||
And then you could use like this:
|
|
||||||
```JavaScript
|
|
||||||
$.md2('message');
|
|
||||||
```
|
|
||||||
### Prototype
|
|
||||||
If you prefer prototype style, you can add following code to add a prototype extension.
|
|
||||||
|
|
||||||
Code
|
|
||||||
```JavaScript
|
|
||||||
String.prototype.md2 = function() {
|
|
||||||
return md2(this);
|
|
||||||
};
|
|
||||||
```
|
|
||||||
And then you could use like this:
|
|
||||||
```JavaScript
|
|
||||||
'message'.md2();
|
|
||||||
```
|
|
||||||
## License
|
## License
|
||||||
The project is released under the [MIT license](http://www.opensource.org/licenses/MIT).
|
The project is released under the [MIT license](http://www.opensource.org/licenses/MIT).
|
||||||
|
|
||||||
## Contact
|
## Contact
|
||||||
The project's website is located at https://github.com/emn178/js-md2
|
The project's website is located at https://github.com/emn178/js-md2
|
||||||
Author: emn178@gmail.com
|
Author: Chen, Yi-Cyuan (emn178@gmail.com)
|
||||||
|
|||||||
+1
-1
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "js-md2",
|
"name": "js-md2",
|
||||||
"version": "0.2.1",
|
"version": "0.2.2",
|
||||||
"main": ["src/md2.js"],
|
"main": ["src/md2.js"],
|
||||||
"ignore": [
|
"ignore": [
|
||||||
"samples",
|
"samples",
|
||||||
|
|||||||
Vendored
+8
-12
@@ -1,14 +1,10 @@
|
|||||||
/*
|
/**
|
||||||
* js-md5 v0.2.1
|
* [js-md2]{@link https://github.com/emn178/js-md2}
|
||||||
* https://github.com/emn178/js-md2
|
|
||||||
*
|
*
|
||||||
* Copyright 2014-2015, emn178@gmail.com
|
* @namespace md2
|
||||||
*
|
* @version 0.2.2
|
||||||
* Licensed under the MIT license:
|
* @author Chen, Yi-Cyuan [emn178@gmail.com]
|
||||||
* http://www.opensource.org/licenses/MIT
|
* @copyright Chen, Yi-Cyuan 2014-2017
|
||||||
|
* @license MIT
|
||||||
*/
|
*/
|
||||||
(function(h,v){"object"==typeof process&&process.versions&&process.versions.node&&(h=global);var u="function"==typeof define&&define.amd,q="0123456789abcdef".split(""),r=[41,46,67,201,162,216,124,1,61,54,84,161,236,240,6,19,98,167,5,243,192,199,115,140,152,147,43,217,188,76,130,202,30,155,87,60,253,212,224,22,103,66,111,24,138,23,229,18,190,78,196,214,218,158,222,73,160,251,245,142,187,47,238,122,169,104,121,145,21,178,7,63,148,194,16,137,11,34,95,33,128,127,93,154,90,144,50,39,53,62,204,231,191,
|
!function(){"use strict";var o="object"==typeof window?window:{},e=!o.JS_MD2_NO_NODE_JS&&"object"==typeof process&&process.versions&&process.versions.node;e&&(o=global);var r=!o.JS_MD2_NO_COMMON_JS&&"object"==typeof module&&module.exports,f="function"==typeof define&&define.amd,t="0123456789abcdef".split(""),n=[41,46,67,201,162,216,124,1,61,54,84,161,236,240,6,19,98,167,5,243,192,199,115,140,152,147,43,217,188,76,130,202,30,155,87,60,253,212,224,22,103,66,111,24,138,23,229,18,190,78,196,214,218,158,222,73,160,251,245,142,187,47,238,122,169,104,121,145,21,178,7,63,148,194,16,137,11,34,95,33,128,127,93,154,90,144,50,39,53,62,204,231,191,247,151,3,255,25,48,179,72,165,181,209,215,94,146,42,172,86,170,198,79,184,56,210,150,164,125,182,118,252,107,226,156,116,4,241,69,157,112,89,100,113,135,32,134,91,207,101,230,45,168,2,27,96,37,173,174,176,185,246,28,70,97,105,52,64,126,15,85,71,163,35,221,81,175,58,195,92,249,206,186,197,234,38,44,83,13,110,133,40,132,9,211,223,205,244,65,129,77,82,106,220,55,200,108,193,171,250,36,225,123,8,12,189,177,74,120,136,149,139,227,99,232,109,233,203,213,254,59,0,29,57,242,239,183,14,102,88,208,228,166,119,114,248,235,117,75,10,49,68,80,180,143,237,31,26,219,153,141,51,159,17,131,20],d=[],i=[],s=[],c=function(o){var e,r,f,c,p,u,a=0,l=1,_=0,v=0,b=0,m=o.length;for(r=0;16>r;++r)i[r]=s[r]=0;d[16]=d[17]=d[18]=0;do{for(d[0]=d[16],d[1]=d[17],d[2]=d[18],d[16]=d[17]=d[18]=d[3]=d[4]=d[5]=d[6]=d[7]=d[8]=d[9]=d[10]=d[11]=d[12]=d[13]=d[14]=d[15]=0,r=v;m>_&&16>r;++_)e=o.charCodeAt(_),128>e?d[r++]=e:2048>e?(d[r++]=192|e>>6,d[r++]=128|63&e):55296>e||e>=57344?(d[r++]=224|e>>12,d[r++]=128|e>>6&63,d[r++]=128|63&e):(e=65536+((1023&e)<<10|1023&o.charCodeAt(++_)),d[r++]=240|e>>18,d[r++]=128|e>>12&63,d[r++]=128|e>>6&63,d[r++]=128|63&e);if(b+=r-v,v=r-16,_===m&&16>r)for(l=2,p=16-(15&b);16>r;++r)d[r]=p;for(r=0;16>r;++r)s[r]^=n[d[r]^a],a=s[r];for(r=0;l>r;++r)for(u=0===r?d:s,i[16]=u[0],i[32]=i[16]^i[0],i[17]=u[1],i[33]=i[17]^i[1],i[18]=u[2],i[34]=i[18]^i[2],i[19]=u[3],i[35]=i[19]^i[3],i[20]=u[4],i[36]=i[20]^i[4],i[21]=u[5],i[37]=i[21]^i[5],i[22]=u[6],i[38]=i[22]^i[6],i[23]=u[7],i[39]=i[23]^i[7],i[24]=u[8],i[40]=i[24]^i[8],i[25]=u[9],i[41]=i[25]^i[9],i[26]=u[10],i[42]=i[26]^i[10],i[27]=u[11],i[43]=i[27]^i[11],i[28]=u[12],i[44]=i[28]^i[12],i[29]=u[13],i[45]=i[29]^i[13],i[30]=u[14],i[46]=i[30]^i[14],i[31]=u[15],i[47]=i[31]^i[15],p=0,f=0;18>f;++f){for(c=0;48>c;++c)i[c]=p=i[c]^n[p];p=p+f&255}}while(1===l);var w="";for(r=0;16>r;++r)w+=t[i[r]>>4&15]+t[15&i[r]];return w};r?module.exports=c:(o.md2=c,f&&define(function(){return c}))}();
|
||||||
247,151,3,255,25,48,179,72,165,181,209,215,94,146,42,172,86,170,198,79,184,56,210,150,164,125,182,118,252,107,226,156,116,4,241,69,157,112,89,100,113,135,32,134,91,207,101,230,45,168,2,27,96,37,173,174,176,185,246,28,70,97,105,52,64,126,15,85,71,163,35,221,81,175,58,195,92,249,206,186,197,234,38,44,83,13,110,133,40,132,9,211,223,205,244,65,129,77,82,106,220,55,200,108,193,171,250,36,225,123,8,12,189,177,74,120,136,149,139,227,99,232,109,233,203,213,254,59,0,29,57,242,239,183,14,102,88,208,228,166,
|
|
||||||
119,114,248,235,117,75,10,49,68,80,180,143,237,31,26,219,153,141,51,159,17,131,20],c=[],a=[],k=[],g=function(e){var d,b,l,f,h=0,g=1,m=0,n=0,p=0,t=e.length;for(b=0;16>b;++b)a[b]=k[b]=0;c[16]=c[17]=c[18]=0;do{c[0]=c[16];c[1]=c[17];c[2]=c[18];c[16]=c[17]=c[18]=c[3]=c[4]=c[5]=c[6]=c[7]=c[8]=c[9]=c[10]=c[11]=c[12]=c[13]=c[14]=c[15]=0;for(b=n;m<t&&16>b;++m)d=e.charCodeAt(m),128>d?c[b++]=d:(2048>d?c[b++]=192|d>>6:(55296>d||57344<=d?c[b++]=224|d>>12:(d=65536+((d&1023)<<10|e.charCodeAt(++m)&1023),c[b++]=240|
|
|
||||||
d>>18,c[b++]=128|d>>12&63),c[b++]=128|d>>6&63),c[b++]=128|d&63);p+=b-n;n=b-16;if(m==t&&16>b)for(g=2,f=16-(p&15);16>b;++b)c[b]=f;for(b=0;16>b;++b)k[b]^=r[c[b]^h],h=k[b];for(b=0;b<g;++b)for(d=0===b?c:k,a[16]=d[0],a[32]=a[16]^a[0],a[17]=d[1],a[33]=a[17]^a[1],a[18]=d[2],a[34]=a[18]^a[2],a[19]=d[3],a[35]=a[19]^a[3],a[20]=d[4],a[36]=a[20]^a[4],a[21]=d[5],a[37]=a[21]^a[5],a[22]=d[6],a[38]=a[22]^a[6],a[23]=d[7],a[39]=a[23]^a[7],a[24]=d[8],a[40]=a[24]^a[8],a[25]=d[9],a[41]=a[25]^a[9],a[26]=d[10],a[42]=a[26]^
|
|
||||||
a[10],a[27]=d[11],a[43]=a[27]^a[11],a[28]=d[12],a[44]=a[28]^a[12],a[29]=d[13],a[45]=a[29]^a[13],a[30]=d[14],a[46]=a[30]^a[14],a[31]=d[15],a[47]=a[31]^a[15],d=f=0;18>d;++d){for(l=0;48>l;++l)a[l]=f=a[l]^r[f];f=f+d&255}}while(1==g);e="";for(b=0;16>b;++b)e+=q[a[b]>>4&15]+q[a[b]&15];return e};!h.JS_MD2_TEST&&"object"==typeof module&&module.exports?module.exports=g:(u&&define(function(){return g}),h.md2=g)})(this);
|
|
||||||
+8
-4
@@ -1,15 +1,19 @@
|
|||||||
{
|
{
|
||||||
"name": "js-md2",
|
"name": "js-md2",
|
||||||
"version": "0.2.1",
|
"version": "0.2.2",
|
||||||
"description": "A simple MD2 hash function for JavaScript supports UTF-8 encoding.",
|
"description": "A simple MD2 hash function for JavaScript supports UTF-8 encoding.",
|
||||||
"main": "src/md2.js",
|
"main": "src/md2.js",
|
||||||
"devDependencies": {
|
"devDependencies": {
|
||||||
"expect.js": "~0.3.1",
|
"expect.js": "~0.3.1",
|
||||||
"jscoverage": "~0.5.9"
|
"jscoverage": "~0.5.9",
|
||||||
|
"mocha": "~2.3.4",
|
||||||
|
"uglifyjs": "~2.4.10"
|
||||||
},
|
},
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"test": "mocha tests/node-test.js -r jscoverage",
|
"test": "mocha tests/node-test.js -r jscoverage",
|
||||||
"coveralls": "mocha tests/node-test.js -R mocha-lcov-reporter -r jscoverage | coveralls"
|
"report": "mocha tests/node-test.js -r jscoverage --covout=html",
|
||||||
|
"coveralls": "mocha tests/node-test.js -R mocha-lcov-reporter -r jscoverage | coveralls",
|
||||||
|
"build": "uglifyjs src/md2.js --compress --mangle --comments --output build/md2.min.js"
|
||||||
},
|
},
|
||||||
"repository": {
|
"repository": {
|
||||||
"type": "git",
|
"type": "git",
|
||||||
@@ -23,7 +27,7 @@
|
|||||||
"HMAC"
|
"HMAC"
|
||||||
],
|
],
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"author": "emn178 <emn178@gmail.com>",
|
"author": "Chen, Yi-Cyuan <emn178@gmail.com>",
|
||||||
"homepage": "https://github.com/emn178/js-md2",
|
"homepage": "https://github.com/emn178/js-md2",
|
||||||
"bugs": {
|
"bugs": {
|
||||||
"url": "https://github.com/emn178/js-md2/issues"
|
"url": "https://github.com/emn178/js-md2/issues"
|
||||||
|
|||||||
+21
-17
@@ -1,24 +1,27 @@
|
|||||||
/*
|
/**
|
||||||
* js-md5 v0.2.1
|
* [js-md2]{@link https://github.com/emn178/js-md2}
|
||||||
* https://github.com/emn178/js-md2
|
|
||||||
*
|
*
|
||||||
* Copyright 2014-2015, emn178@gmail.com
|
* @namespace md2
|
||||||
*
|
* @version 0.2.2
|
||||||
* Licensed under the MIT license:
|
* @author Chen, Yi-Cyuan [emn178@gmail.com]
|
||||||
* http://www.opensource.org/licenses/MIT
|
* @copyright Chen, Yi-Cyuan 2014-2017
|
||||||
|
* @license MIT
|
||||||
*/
|
*/
|
||||||
;(function(root, undefined) {
|
/*jslint bitwise: true */
|
||||||
|
(function () {
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var NODE_JS = typeof process == 'object' && process.versions && process.versions.node;
|
var root = typeof window === 'object' ? window : {};
|
||||||
|
var NODE_JS = !root.JS_MD2_NO_NODE_JS && typeof process === 'object' && process.versions && process.versions.node;
|
||||||
if (NODE_JS) {
|
if (NODE_JS) {
|
||||||
root = global;
|
root = global;
|
||||||
}
|
}
|
||||||
var COMMON_JS = !root.JS_MD2_TEST && typeof module == 'object' && module.exports;
|
var COMMON_JS = !root.JS_MD2_NO_COMMON_JS && typeof module === 'object' && module.exports;
|
||||||
var AMD = typeof define == 'function' && define.amd;
|
var AMD = typeof define === 'function' && define.amd;
|
||||||
var HEX_CHARS = '0123456789abcdef'.split('');
|
var HEX_CHARS = '0123456789abcdef'.split('');
|
||||||
|
|
||||||
var S = [ 0x29, 0x2E, 0x43, 0xC9, 0xA2, 0xD8, 0x7C, 0x01, 0x3D, 0x36, 0x54, 0xA1, 0xEC, 0xF0, 0x06, 0x13,
|
var S = [
|
||||||
|
0x29, 0x2E, 0x43, 0xC9, 0xA2, 0xD8, 0x7C, 0x01, 0x3D, 0x36, 0x54, 0xA1, 0xEC, 0xF0, 0x06, 0x13,
|
||||||
0x62, 0xA7, 0x05, 0xF3, 0xC0, 0xC7, 0x73, 0x8C, 0x98, 0x93, 0x2B, 0xD9, 0xBC, 0x4C, 0x82, 0xCA,
|
0x62, 0xA7, 0x05, 0xF3, 0xC0, 0xC7, 0x73, 0x8C, 0x98, 0x93, 0x2B, 0xD9, 0xBC, 0x4C, 0x82, 0xCA,
|
||||||
0x1E, 0x9B, 0x57, 0x3C, 0xFD, 0xD4, 0xE0, 0x16, 0x67, 0x42, 0x6F, 0x18, 0x8A, 0x17, 0xE5, 0x12,
|
0x1E, 0x9B, 0x57, 0x3C, 0xFD, 0xD4, 0xE0, 0x16, 0x67, 0x42, 0x6F, 0x18, 0x8A, 0x17, 0xE5, 0x12,
|
||||||
0xBE, 0x4E, 0xC4, 0xD6, 0xDA, 0x9E, 0xDE, 0x49, 0xA0, 0xFB, 0xF5, 0x8E, 0xBB, 0x2F, 0xEE, 0x7A,
|
0xBE, 0x4E, 0xC4, 0xD6, 0xDA, 0x9E, 0xDE, 0x49, 0xA0, 0xFB, 0xF5, 0x8E, 0xBB, 0x2F, 0xEE, 0x7A,
|
||||||
@@ -33,7 +36,8 @@
|
|||||||
0x6A, 0xDC, 0x37, 0xC8, 0x6C, 0xC1, 0xAB, 0xFA, 0x24, 0xE1, 0x7B, 0x08, 0x0C, 0xBD, 0xB1, 0x4A,
|
0x6A, 0xDC, 0x37, 0xC8, 0x6C, 0xC1, 0xAB, 0xFA, 0x24, 0xE1, 0x7B, 0x08, 0x0C, 0xBD, 0xB1, 0x4A,
|
||||||
0x78, 0x88, 0x95, 0x8B, 0xE3, 0x63, 0xE8, 0x6D, 0xE9, 0xCB, 0xD5, 0xFE, 0x3B, 0x00, 0x1D, 0x39,
|
0x78, 0x88, 0x95, 0x8B, 0xE3, 0x63, 0xE8, 0x6D, 0xE9, 0xCB, 0xD5, 0xFE, 0x3B, 0x00, 0x1D, 0x39,
|
||||||
0xF2, 0xEF, 0xB7, 0x0E, 0x66, 0x58, 0xD0, 0xE4, 0xA6, 0x77, 0x72, 0xF8, 0xEB, 0x75, 0x4B, 0x0A,
|
0xF2, 0xEF, 0xB7, 0x0E, 0x66, 0x58, 0xD0, 0xE4, 0xA6, 0x77, 0x72, 0xF8, 0xEB, 0x75, 0x4B, 0x0A,
|
||||||
0x31, 0x44, 0x50, 0xB4, 0x8F, 0xED, 0x1F, 0x1A, 0xDB, 0x99, 0x8D, 0x33, 0x9F, 0x11, 0x83, 0x14];
|
0x31, 0x44, 0x50, 0xB4, 0x8F, 0xED, 0x1F, 0x1A, 0xDB, 0x99, 0x8D, 0x33, 0x9F, 0x11, 0x83, 0x14
|
||||||
|
];
|
||||||
|
|
||||||
var M = [], X = [], C = [];
|
var M = [], X = [], C = [];
|
||||||
|
|
||||||
@@ -76,7 +80,7 @@
|
|||||||
bytes += i - start;
|
bytes += i - start;
|
||||||
start = i - 16;
|
start = i - 16;
|
||||||
|
|
||||||
if(index == length && i < 16) {
|
if (index === length && i < 16) {
|
||||||
loop = 2;
|
loop = 2;
|
||||||
t = 16 - (bytes & 15);
|
t = 16 - (bytes & 15);
|
||||||
for (; i < 16; ++i) {
|
for (; i < 16; ++i) {
|
||||||
@@ -133,7 +137,7 @@
|
|||||||
t = (t + j) & 0xFF;
|
t = (t + j) & 0xFF;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} while(loop == 1);
|
} while (loop === 1);
|
||||||
|
|
||||||
var hex = '';
|
var hex = '';
|
||||||
for (i = 0; i < 16; ++i) {
|
for (i = 0; i < 16; ++i) {
|
||||||
@@ -145,11 +149,11 @@
|
|||||||
if (COMMON_JS) {
|
if (COMMON_JS) {
|
||||||
module.exports = md2;
|
module.exports = md2;
|
||||||
} else {
|
} else {
|
||||||
|
root.md2 = md2;
|
||||||
if (AMD) {
|
if (AMD) {
|
||||||
define(function() {
|
define(function() {
|
||||||
return md2;
|
return md2;
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
root.md2 = md2;
|
|
||||||
}
|
}
|
||||||
}(this));
|
})();
|
||||||
|
|||||||
+33
-6
@@ -1,23 +1,50 @@
|
|||||||
md2 = require('../src/md2.js');
|
// Node.js env
|
||||||
expect = require('expect.js');
|
expect = require('expect.js');
|
||||||
|
md2 = require('../src/md2.js');
|
||||||
require('./test.js');
|
require('./test.js');
|
||||||
|
|
||||||
delete require.cache[require.resolve('../src/md2.js')]
|
delete require.cache[require.resolve('../src/md2.js')]
|
||||||
delete require.cache[require.resolve('./test.js')]
|
delete require.cache[require.resolve('./test.js')]
|
||||||
md2 = null
|
md2 = null
|
||||||
|
|
||||||
JS_MD2_TEST = true;
|
// Webpack browser env
|
||||||
|
JS_MD2_NO_NODE_JS = true;
|
||||||
|
window = global;
|
||||||
|
md2 = require('../src/md2.js');
|
||||||
|
require('./test.js');
|
||||||
|
|
||||||
|
delete require.cache[require.resolve('../src/md2.js')]
|
||||||
|
delete require.cache[require.resolve('./test.js')]
|
||||||
|
md2 = null
|
||||||
|
|
||||||
|
// browser env
|
||||||
|
JS_MD2_NO_NODE_JS = true;
|
||||||
|
JS_MD2_NO_COMMON_JS = true;
|
||||||
|
window = global;
|
||||||
require('../src/md2.js');
|
require('../src/md2.js');
|
||||||
require('./test.js');
|
require('./test.js');
|
||||||
|
|
||||||
delete require.cache[require.resolve('../src/md2.js')]
|
delete require.cache[require.resolve('../src/md2.js')];
|
||||||
delete require.cache[require.resolve('./test.js')]
|
delete require.cache[require.resolve('./test.js')];
|
||||||
md2 = null
|
md2 = null;
|
||||||
|
|
||||||
|
// browser AMD
|
||||||
|
JS_MD2_NO_NODE_JS = true;
|
||||||
|
JS_MD2_NO_COMMON_JS = true;
|
||||||
|
window = global;
|
||||||
define = function (func) {
|
define = function (func) {
|
||||||
md2 = func();
|
md2 = func();
|
||||||
|
require('./test.js');
|
||||||
};
|
};
|
||||||
define.amd = true;
|
define.amd = true;
|
||||||
|
|
||||||
require('../src/md2.js');
|
require('../src/md2.js');
|
||||||
require('./test.js');
|
|
||||||
|
|
||||||
|
// define = function(func) {
|
||||||
|
// md2 = func();
|
||||||
|
// };
|
||||||
|
// define.amd = true;
|
||||||
|
|
||||||
|
// require('../src/md2.js');
|
||||||
|
// require('./test.js');
|
||||||
|
|||||||
Reference in New Issue
Block a user