source: imaps-frontend/node_modules/utrie/dist/lib/Util.js@ 79a0317

main
Last change on this file since 79a0317 was 79a0317, checked in by stefan toskovski <stefantoska84@…>, 3 days ago

F4 Finalna Verzija

  • Property mode set to 100644
File size: 2.1 KB
RevLine 
[79a0317]1"use strict";
2Object.defineProperty(exports, "__esModule", { value: true });
3exports.polyUint32Array = exports.polyUint16Array = exports.decode = void 0;
4var chars = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/';
5// Use a lookup table to find the index.
6var lookup = typeof Uint8Array === 'undefined' ? [] : new Uint8Array(256);
7for (var i = 0; i < chars.length; i++) {
8 lookup[chars.charCodeAt(i)] = i;
9}
10var decode = function (base64) {
11 var bufferLength = base64.length * 0.75, len = base64.length, i, p = 0, encoded1, encoded2, encoded3, encoded4;
12 if (base64[base64.length - 1] === '=') {
13 bufferLength--;
14 if (base64[base64.length - 2] === '=') {
15 bufferLength--;
16 }
17 }
18 var buffer = typeof ArrayBuffer !== 'undefined' &&
19 typeof Uint8Array !== 'undefined' &&
20 typeof Uint8Array.prototype.slice !== 'undefined'
21 ? new ArrayBuffer(bufferLength)
22 : new Array(bufferLength);
23 var bytes = Array.isArray(buffer) ? buffer : new Uint8Array(buffer);
24 for (i = 0; i < len; i += 4) {
25 encoded1 = lookup[base64.charCodeAt(i)];
26 encoded2 = lookup[base64.charCodeAt(i + 1)];
27 encoded3 = lookup[base64.charCodeAt(i + 2)];
28 encoded4 = lookup[base64.charCodeAt(i + 3)];
29 bytes[p++] = (encoded1 << 2) | (encoded2 >> 4);
30 bytes[p++] = ((encoded2 & 15) << 4) | (encoded3 >> 2);
31 bytes[p++] = ((encoded3 & 3) << 6) | (encoded4 & 63);
32 }
33 return buffer;
34};
35exports.decode = decode;
36var polyUint16Array = function (buffer) {
37 var length = buffer.length;
38 var bytes = [];
39 for (var i = 0; i < length; i += 2) {
40 bytes.push((buffer[i + 1] << 8) | buffer[i]);
41 }
42 return bytes;
43};
44exports.polyUint16Array = polyUint16Array;
45var polyUint32Array = function (buffer) {
46 var length = buffer.length;
47 var bytes = [];
48 for (var i = 0; i < length; i += 4) {
49 bytes.push((buffer[i + 3] << 24) | (buffer[i + 2] << 16) | (buffer[i + 1] << 8) | buffer[i]);
50 }
51 return bytes;
52};
53exports.polyUint32Array = polyUint32Array;
54//# sourceMappingURL=Util.js.map
Note: See TracBrowser for help on using the repository browser.