source: imaps-frontend/node_modules/@webassemblyjs/utf8/esm/encoder.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.4 KB
Line 
1function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
2
3function _nonIterableSpread() { throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
4
5function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
6
7function _toArray(arr) { return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableRest(); }
8
9function _nonIterableRest() { throw new TypeError("Invalid attempt to destructure non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method."); }
10
11function _unsupportedIterableToArray(o, minLen) { if (!o) return; if (typeof o === "string") return _arrayLikeToArray(o, minLen); var n = Object.prototype.toString.call(o).slice(8, -1); if (n === "Object" && o.constructor) n = o.constructor.name; if (n === "Map" || n === "Set") return Array.from(o); if (n === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n)) return _arrayLikeToArray(o, minLen); }
12
13function _arrayLikeToArray(arr, len) { if (len == null || len > arr.length) len = arr.length; for (var i = 0, arr2 = new Array(len); i < len; i++) { arr2[i] = arr[i]; } return arr2; }
14
15function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
16
17function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
18
19function con(n) {
20 return 0x80 | n & 0x3f;
21}
22
23export function encode(str) {
24 var arr = str.split("").map(function (x) {
25 return x.charCodeAt(0);
26 });
27 return _encode(arr);
28}
29
30function _encode(arr) {
31 if (arr.length === 0) {
32 return [];
33 }
34
35 var _arr = _toArray(arr),
36 n = _arr[0],
37 ns = _arr.slice(1);
38
39 if (n < 0) {
40 throw new Error("utf8");
41 }
42
43 if (n < 0x80) {
44 return [n].concat(_toConsumableArray(_encode(ns)));
45 }
46
47 if (n < 0x800) {
48 return [0xc0 | n >>> 6, con(n)].concat(_toConsumableArray(_encode(ns)));
49 }
50
51 if (n < 0x10000) {
52 return [0xe0 | n >>> 12, con(n >>> 6), con(n)].concat(_toConsumableArray(_encode(ns)));
53 }
54
55 if (n < 0x110000) {
56 return [0xf0 | n >>> 18, con(n >>> 12), con(n >>> 6), con(n)].concat(_toConsumableArray(_encode(ns)));
57 }
58
59 throw new Error("utf8");
60}
Note: See TracBrowser for help on using the repository browser.