* Fixed ArrayBuffer.isView issue in IE10.

* Improved performance of input check.
This commit is contained in:
Yi-Cyuan Chen
2017-10-07 10:12:06 +08:00
parent e7f1ca7da8
commit a54f102b8a
13 changed files with 619 additions and 108 deletions
+10 -10
View File
@@ -93,7 +93,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line172">line 172</a>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line178">line 178</a>
</li></ul></dd>
@@ -206,7 +206,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line566">line 566</a>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line574">line 574</a>
</li></ul></dd>
@@ -326,7 +326,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line578">line 578</a>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line586">line 586</a>
</li></ul></dd>
@@ -446,7 +446,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line613">line 613</a>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line621">line 621</a>
</li></ul></dd>
@@ -568,7 +568,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line600">line 600</a>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line608">line 608</a>
</li></ul></dd>
@@ -688,7 +688,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line544">line 544</a>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line552">line 552</a>
</li></ul></dd>
@@ -808,7 +808,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line499">line 499</a>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line507">line 507</a>
</li></ul></dd>
@@ -928,7 +928,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line532">line 532</a>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line540">line 540</a>
</li></ul></dd>
@@ -1106,7 +1106,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line200">line 200</a>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line206">line 206</a>
</li></ul></dd>
@@ -1185,7 +1185,7 @@
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.3</a> on Fri Jul 28 2017 14:11:21 GMT+0800 (CST)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Sat Oct 07 2017 09:51:51 GMT+0800 (CST)
</footer>
<script> prettyPrint(); </script>
+2 -2
View File
@@ -214,7 +214,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line646">line 646</a>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line654">line 654</a>
</li></ul></dd>
@@ -300,7 +300,7 @@ md5(new Uint8Array([])); // d41d8cd98f00b204e9800998ecf8427e</code></pre>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.3</a> on Fri Jul 28 2017 14:11:21 GMT+0800 (CST)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Sat Oct 07 2017 09:51:51 GMT+0800 (CST)
</footer>
<script> prettyPrint(); </script>
+1 -1
View File
@@ -96,7 +96,7 @@ md5.base64(''); // 1B2M2Y8AsgTpgAmY7PhCfg==</code></pre><h2>License</h2><p>The p
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.3</a> on Fri Jul 28 2017 14:11:21 GMT+0800 (CST)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Sat Oct 07 2017 09:51:51 GMT+0800 (CST)
</footer>
<script> prettyPrint(); </script>
+10 -10
View File
@@ -47,7 +47,7 @@
<dt class="tag-version">Version:</dt>
<dd class="tag-version"><ul class="dummy"><li>0.6.0</li></ul></dd>
<dd class="tag-version"><ul class="dummy"><li>0.6.1</li></ul></dd>
@@ -237,7 +237,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line68">line 68</a>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line74">line 74</a>
</li></ul></dd>
@@ -408,7 +408,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line77">line 77</a>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line83">line 83</a>
</li></ul></dd>
@@ -579,7 +579,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line96">line 96</a>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line102">line 102</a>
</li></ul></dd>
@@ -752,7 +752,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line86">line 86</a>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line92">line 92</a>
</li></ul></dd>
@@ -865,7 +865,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line111">line 111</a>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line117">line 117</a>
</li></ul></dd>
@@ -1036,7 +1036,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line59">line 59</a>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line65">line 65</a>
</li></ul></dd>
@@ -1207,7 +1207,7 @@
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line48">line 48</a>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line54">line 54</a>
</li></ul></dd>
@@ -1380,7 +1380,7 @@ md5('The quick brown fox jumps over the lazy dog');</code></pre>
<dt class="tag-source">Source:</dt>
<dd class="tag-source"><ul class="dummy"><li>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line119">line 119</a>
<a href="md5.js.html">md5.js</a>, <a href="md5.js.html#line125">line 125</a>
</li></ul></dd>
@@ -1460,7 +1460,7 @@ hash.update('The quick brown fox jumps over the lazy dog');</code></pre>
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.3</a> on Fri Jul 28 2017 14:11:21 GMT+0800 (CST)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Sat Oct 07 2017 09:51:51 GMT+0800 (CST)
</footer>
<script> prettyPrint(); </script>
+24 -16
View File
@@ -30,7 +30,7 @@
* [js-md5]{@link https://github.com/emn178/js-md5}
*
* @namespace md5
* @version 0.6.0
* @version 0.6.1
* @author Chen, Yi-Cyuan [emn178@gmail.com]
* @copyright Chen, Yi-Cyuan 2014-2017
* @license MIT
@@ -73,6 +73,12 @@
};
}
if (ARRAY_BUFFER &amp;&amp; (root.JS_MD5_NO_ARRAY_BUFFER_IS_VIEW || !ArrayBuffer.isView)) {
ArrayBuffer.isView = function (obj) {
return typeof obj === 'object' &amp;&amp; obj.buffer &amp;&amp; obj.buffer.constructor === ArrayBuffer;
};
}
/**
* @method hex
* @memberof md5
@@ -238,23 +244,25 @@
if (this.finalized) {
return;
}
var notString = typeof(message) != 'string';
if (notString) {
if (message === null || message === undefined) {
throw ERROR;
} else if (message.constructor === root.ArrayBuffer) {
message = new Uint8Array(message);
}
}
var length = message.length;
if (notString) {
if (typeof length !== 'number' ||
!Array.isArray(message) &amp;&amp;
!(ARRAY_BUFFER &amp;&amp; ArrayBuffer.isView(message))) {
var notString, type = typeof message;
if (type !== 'string') {
if (type === 'object') {
if (message === null) {
throw ERROR;
} else if (ARRAY_BUFFER &amp;&amp; message.constructor === ArrayBuffer) {
message = new Uint8Array(message);
} else if (!Array.isArray(message)) {
if (!ARRAY_BUFFER || !ArrayBuffer.isView(message)) {
throw ERROR;
}
}
} else {
throw ERROR;
}
notString = true;
}
var code, index = 0, i, blocks = this.blocks;
var code, index = 0, i, length = message.length, blocks = this.blocks;
var buffer8 = this.buffer8;
while (index &lt; length) {
@@ -712,7 +720,7 @@
<br class="clear">
<footer>
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.3</a> on Fri Jul 28 2017 14:11:21 GMT+0800 (CST)
Documentation generated by <a href="https://github.com/jsdoc3/jsdoc">JSDoc 3.5.5</a> on Sat Oct 07 2017 09:51:51 GMT+0800 (CST)
</footer>
<script> prettyPrint(); </script>