UNPKG

motion

Version:

motion - moving development forward

64 lines (58 loc) 3.96 kB
[ "/*\n * https://github.com/davidchambers/Base64.js\n */","\n", ";","(","function"," ","(",")"," ","{","\n\n ", "var"," ","object"," ","="," ","typeof"," ","exports"," ","!="," ","'undefined'"," ","?"," ","exports"," ",":"," ","this",";"," ","// #8: web workers","\n ", "var"," ","chars"," ","="," ","'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/='",";","\n\n ", "function"," ","InvalidCharacterError","(","message",")"," ","{","\n ", "this",".","message"," ","="," ","message",";","\n ", "}","\n ", "InvalidCharacterError",".","prototype"," ","="," ","new"," ","Error",";","\n ", "InvalidCharacterError",".","prototype",".","name"," ","="," ","'InvalidCharacterError'",";","\n\n ", "// encoder","\n ", "// [https://gist.github.com/999166] by [https://github.com/nignag]","\n ", "object",".","btoa"," ","||"," ","(","\n ", "object",".","btoa"," ","="," ","function"," ","(","input",")"," ","{","\n ", "for"," ","(","\n ", "// initialize result and counter","\n ", "var"," ","block",","," ","charCode",","," ","idx"," ","="," ","0",","," ","map"," ","="," ","chars",","," ","output"," ","="," ","''",";","\n ", "// if the next input index does not exist:","\n ", "// change the mapping table to \"=\"","\n ", "// check if d has no fractional digits","\n ", "input",".","charAt","(","idx"," ","|"," ","0",")"," ","||"," ","(","map"," ","="," ","'='",","," ","idx"," ","%"," ","1",")",";","\n ", "// \"8 - idx % 1 * 8\" generates the sequence 2, 4, 6, 8","\n ", "output"," ","+="," ","map",".","charAt","(","63"," ","&"," ","block"," ",">>"," ","8"," ","-"," ","idx"," ","%"," ","1"," ","*"," ","8",")","\n ", ")"," ","{","\n ", "charCode"," ","="," ","input",".","charCodeAt","(","idx"," ","+="," ","3","/","4",")",";","\n ", "if"," ","(","charCode"," ",">"," ","0xFF",")"," ","{","\n ", "throw"," ","new"," ","InvalidCharacterError","(","\"'btoa' failed: The string to be encoded contains characters outside of the Latin1 range.\"",")",";","\n ", "}","\n ", "block"," ","="," ","block"," ","<<"," ","8"," ","|"," ","charCode",";","\n ", "}","\n ", "return"," ","output",";","\n ", "}",")",";","\n\n ", "// decoder","\n ", "// [https://gist.github.com/1020396] by [https://github.com/atk]","\n ", "object",".","atob"," ","||"," ","(","\n ", "object",".","atob"," ","="," ","function"," ","(","input",")"," ","{","\n ", "input"," ","="," ","input",".","replace","(","/=+$/",","," ","''",")","\n ", "if"," ","(","input",".","length"," ","%"," ","4"," ","=="," ","1",")"," ","{","\n ", "throw"," ","new"," ","InvalidCharacterError","(","\"'atob' failed: The string to be decoded is not correctly encoded.\"",")",";","\n ", "}","\n ", "for"," ","(","\n ", "// initialize result and counters","\n ", "var"," ","bc"," ","="," ","0",","," ","bs",","," ","buffer",","," ","idx"," ","="," ","0",","," ","output"," ","="," ","''",";","\n ", "// get next character","\n ", "buffer"," ","="," ","input",".","charAt","(","idx","++",")",";","\n ", "// character found in table? initialize bit storage and add its ascii value;","\n ", "~","buffer"," ","&&"," ","(","bs"," ","="," ","bc"," ","%"," ","4"," ","?"," ","bs"," ","*"," ","64"," ","+"," ","buffer"," ",":"," ","buffer",",","\n ", "// and if not first of each 4 characters,","\n ", "// convert the first 8 bits to one ascii character","\n ", "bc","++"," ","%"," ","4",")"," ","?"," ","output"," ","+="," ","String",".","fromCharCode","(","255"," ","&"," ","bs"," ",">>"," ","(","-","2"," ","*"," ","bc"," ","&"," ","6",")",")"," ",":"," ","0","\n ", ")"," ","{","\n ", "// try to find character in table (0-63, not found => -1)","\n ", "buffer"," ","="," ","chars",".","indexOf","(","buffer",")",";","\n ", "}","\n ", "return"," ","output",";","\n ", "}",")",";","\n\n", "}","(",")",")",";","\n" ]