|
|
@ -1,10 +1,30 @@ |
|
|
|
(function (exports) { |
|
|
|
'use strict'; |
|
|
|
|
|
|
|
var lookup = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/'; |
|
|
|
|
|
|
|
function decode (c) { |
|
|
|
return indexOf(lookup, c) |
|
|
|
|
|
|
|
;(function (exports) { |
|
|
|
'use strict'; |
|
|
|
|
|
|
|
var ZERO = '0'.charCodeAt(0) |
|
|
|
var PLUS = '+'.charCodeAt(0) |
|
|
|
var SLASH = '/'.charCodeAt(0) |
|
|
|
var NUMBER = '0'.charCodeAt(0) |
|
|
|
var LOWER = 'a'.charCodeAt(0) |
|
|
|
var UPPER = 'A'.charCodeAt(0) |
|
|
|
|
|
|
|
function decode (elt) { |
|
|
|
var code = elt.charCodeAt(0) |
|
|
|
if(code === PLUS) |
|
|
|
return 62 // '+'
|
|
|
|
if(code === SLASH) |
|
|
|
return 63 // '/'
|
|
|
|
if(code < NUMBER) |
|
|
|
return -1 //no match
|
|
|
|
if(code < NUMBER + 10) |
|
|
|
return code - NUMBER + 26 + 26 |
|
|
|
if(code < UPPER + 26) |
|
|
|
return code - UPPER |
|
|
|
if(code < LOWER + 26) |
|
|
|
return code - LOWER + 26 |
|
|
|
} |
|
|
|
|
|
|
|
function b64ToByteArray(b64) { |
|
|
@ -91,9 +111,14 @@ |
|
|
|
|
|
|
|
module.exports.toByteArray = b64ToByteArray; |
|
|
|
module.exports.fromByteArray = uint8ToBase64; |
|
|
|
module.exports.indexOf = indexOf |
|
|
|
module.exports.lookup = lookup |
|
|
|
}()); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
function indexOf (arr, elt /*, from*/) { |
|
|
|
|
|
|
|
var len = arr.length; |
|
|
|
|
|
|
|
var from = Number(arguments[1]) || 0; |
|
|
@ -111,3 +136,4 @@ function indexOf (arr, elt /*, from*/) { |
|
|
|
} |
|
|
|
return -1; |
|
|
|
} |
|
|
|
|
|
|
|