apache / cordova-js
Showing 1 of 2 files from the diff.
Other files ignored by Codecov

@@ -23,7 +23,7 @@
Loading
23 23
24 24
base64.fromArrayBuffer = function (arrayBuffer) {
25 25
    var array = new Uint8Array(arrayBuffer);
26 -
    return uint8ToBase64(array);
26 +
    return btoa(bytesToBinaryString(array));
27 27
};
28 28
29 29
base64.toArrayBuffer = function (str) {
@@ -36,46 +36,12 @@
Loading
36 36
    return arrayBuffer;
37 37
};
38 38
39 -
// ------------------------------------------------------------------------------
40 -
41 -
/* This code is based on the performance tests at http://jsperf.com/b64tests
42 -
 * This 12-bit-at-a-time algorithm was the best performing version on all
43 -
 * platforms tested.
44 -
 */
45 -
46 -
var b64_6bit = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
47 -
var b64_12bit;
48 -
49 -
var b64_12bitTable = function () {
50 -
    b64_12bit = [];
51 -
    for (var i = 0; i < 64; i++) {
52 -
        for (var j = 0; j < 64; j++) {
53 -
            b64_12bit[i * 64 + j] = b64_6bit[i] + b64_6bit[j];
54 -
        }
55 -
    }
56 -
    b64_12bitTable = function () { return b64_12bit; };
57 -
    return b64_12bit;
58 -
};
59 -
60 -
function uint8ToBase64 (rawData) {
61 -
    var numBytes = rawData.byteLength;
62 -
    var output = '';
63 -
    var segment;
64 -
    var table = b64_12bitTable();
65 -
    for (var i = 0; i < numBytes - 2; i += 3) {
66 -
        segment = (rawData[i] << 16) + (rawData[i + 1] << 8) + rawData[i + 2];
67 -
        output += table[segment >> 12];
68 -
        output += table[segment & 0xfff];
69 -
    }
70 -
    if (numBytes - i === 2) {
71 -
        segment = (rawData[i] << 16) + (rawData[i + 1] << 8);
72 -
        output += table[segment >> 12];
73 -
        output += b64_6bit[(segment & 0xfff) >> 6];
74 -
        output += '=';
75 -
    } else if (numBytes - i === 1) {
76 -
        segment = (rawData[i] << 16);
77 -
        output += table[segment >> 12];
78 -
        output += '==';
39 +
function bytesToBinaryString (bytes) {
40 +
    var CHUNK_SIZE = 1 << 15;
41 +
    var string = '';
42 +
    for (var i = 0; i < bytes.length; i += CHUNK_SIZE) {
43 +
        var chunk = bytes.subarray(i, i + CHUNK_SIZE);
44 +
        string += String.fromCharCode.apply(null, chunk);
79 45
    }
80 -
    return output;
46 +
    return string;
81 47
}
Files Coverage
src 83.59%
test/test-platform-modules 100.00%
Project Totals (14 files) 83.65%
Sunburst
The inner-most circle is the entire project, moving away from the center are folders then, finally, a single file. The size and color of each slice is representing the number of statements and the coverage, respectively.
Icicle
The top section represents the entire project. Proceeding with folders and finally individual files. The size and color of each slice is representing the number of statements and the coverage, respectively.
Grid
Each block represents a single file in the project. The size and color of each block is represented by the number of statements and the coverage, respectively.
Loading