js/toyplus_wrap.js
/**
     * Encodes a uint8 array into a base64 string if possible 
     * @param blob uint8 array to encode
     * @return A base64 string representation of the uint8 array
     * @throws An exception if the argument is not a uint8 array 
     */
Encodes a uint8 array into a base64 string if possible
@param blob uint8 array to encode
@return A base64 string representation of the uint8 array
@throws An exception if the argument is not a uint8 array
Encodes a uint8 array into a base64 string if possible @param blob uint8 array to encode @return A base64 string representation of the uint8 array @throws An exception if the argument is not a uint8 array
encode(blob){
        Base64.init()
        if( blob.byteLength === undefined ) throw '·Not a byte array·'
        var str=''
        var m = (blob.length%3)
        if(m>0) m++        
        var n = 4*Math.floor(blob.length/3) + m
        var k=0
        var c=0
        for(var i=0; i<n; i++){
            c=i&3
            switch(c){
                case 0: str += Base64.i2a[blob[k]>>2]; break;
                case 1: str += Base64.i2a[((blob[k]&3)<<4) | (blob[k+1]>>4)]; break;
                case 2: str += Base64.i2a[((blob[k]&15)<<2) | (blob[k+1]>>6)]; break;
                case 3: str += Base64.i2a[blob[k]&63]; break;
            }
            if(c!=0) k++        
        }
        while(m<4){
            str+='='
            m++
        }     
        return str
    }
encode ( blob ) { Base64 . init ( ) if ( blob . byteLength === undefined ) throw '·Not a byte array·' var str = '' var m = ( blob . length % 3 ) if ( m > 0 ) m ++ var n = 4 * Math . floor ( blob . length / 3 ) + m var k = 0 var c = 0 for ( var i = 0 ; i < n ; i ++ ) { c = i & 3 switch ( c ) { case 0 : str += Base64 . i2a [ blob [ k ] >> 2 ] ; break ; case 1 : str += Base64 . i2a [ ( ( blob [ k ] & 3 ) << 4 ) | ( blob [ k + 1 ] >> 4 ) ] ; break ; case 2 : str += Base64 . i2a [ ( ( blob [ k ] & 15 ) << 2 ) | ( blob [ k + 1 ] >> 6 ) ] ; break ; case 3 : str += Base64 . i2a [ blob [ k ] & 63 ] ; break ; } if ( c != 0 ) k ++ } while ( m < 4 ) { str += '=' m ++ } return str }
Encodes a uint8 array into a base64 string if possible
 @param blob uint8 array to encode
 @return A base64 string representation of the uint8 array
 @throws An exception if the argument is not a uint8 array
Encodes a uint8 array into a base64 string if possible @param blob uint8 array to encode @return A base64 string representation of the uint8 array @throws An exception if the argument is not a uint8 array