base64-arraybuffer
Advanced tools
Comparing version 0.1.4 to 0.1.5
@@ -8,5 +8,13 @@ /* | ||
*/ | ||
(function(chars){ | ||
(function(){ | ||
"use strict"; | ||
var chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"; | ||
// Use a lookup table to find the index. | ||
var lookup = new Uint8Array(256); | ||
for (var i = 0; i < chars.length; i++) { | ||
lookup[chars.charCodeAt(i)] = i; | ||
} | ||
exports.encode = function(arraybuffer) { | ||
@@ -48,6 +56,6 @@ var bytes = new Uint8Array(arraybuffer), | ||
for (i = 0; i < len; i+=4) { | ||
encoded1 = chars.indexOf(base64[i]); | ||
encoded2 = chars.indexOf(base64[i+1]); | ||
encoded3 = chars.indexOf(base64[i+2]); | ||
encoded4 = chars.indexOf(base64[i+3]); | ||
encoded1 = lookup[base64.charCodeAt(i)]; | ||
encoded2 = lookup[base64.charCodeAt(i+1)]; | ||
encoded3 = lookup[base64.charCodeAt(i+2)]; | ||
encoded4 = lookup[base64.charCodeAt(i+3)]; | ||
@@ -61,2 +69,2 @@ bytes[p++] = (encoded1 << 2) | (encoded2 >> 4); | ||
}; | ||
})("ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/"); | ||
})(); |
{ | ||
"name": "base64-arraybuffer", | ||
"description": "Encode/decode base64 data into ArrayBuffers", | ||
"version": "0.1.4", | ||
"version": "0.1.5", | ||
"homepage": "https://github.com/niklasvh/base64-arraybuffer", | ||
@@ -6,0 +6,0 @@ "author": { |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5228
55