Browse Source

don't shadow global window.length value

master
Feross Aboukhadijeh 9 years ago
parent
commit
a8064c78c3
  1. 8
      lib/b64.js

8
lib/b64.js

@ -81,18 +81,16 @@ function encodeChunk (uint8, start, end) {
} }
function fromByteArray (uint8) { function fromByteArray (uint8) {
var i var i, temp, len2
var len = uint8.length var len = uint8.length
var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes var extraBytes = len % 3 // if we have 1 byte left, pad 2 bytes
var output = '' var output = ''
var parts = [] var parts = []
var temp, length
var maxChunkLength = 16383 // must be multiple of 3 var maxChunkLength = 16383 // must be multiple of 3
// go through the array every three bytes, we'll deal with trailing stuff later // go through the array every three bytes, we'll deal with trailing stuff later
for (i = 0, len2 = len - extraBytes; i < len2; i += maxChunkLength) {
for (i = 0, length = len - extraBytes; i < length; i += maxChunkLength) { parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > len2 ? len2 : (i + maxChunkLength)))
parts.push(encodeChunk(uint8, i, (i + maxChunkLength) > length ? length : (i + maxChunkLength)))
} }
// pad the end with zeros, but make sure to not forget the extra bytes // pad the end with zeros, but make sure to not forget the extra bytes

Loading…
Cancel
Save