source: imaps-frontend/node_modules/@webassemblyjs/utf8/lib/encoder.js

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

F4 Finalna Verzija

  • Property mode set to 100644
File size: 2.5 KB
Line 
1"use strict";
2
3Object.defineProperty(exports, "__esModule", {
4 value: true
5});
6exports.encode = encode;
7
8function _toConsumableArray(arr) { return _arrayWithoutHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableSpread(); }
9
10function _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."); }
11
12function _arrayWithoutHoles(arr) { if (Array.isArray(arr)) return _arrayLikeToArray(arr); }
13
14function _toArray(arr) { return _arrayWithHoles(arr) || _iterableToArray(arr) || _unsupportedIterableToArray(arr) || _nonIterableRest(); }
15
16function _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."); }
17
18function _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); }
19
20function _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; }
21
22function _iterableToArray(iter) { if (typeof Symbol !== "undefined" && iter[Symbol.iterator] != null || iter["@@iterator"] != null) return Array.from(iter); }
23
24function _arrayWithHoles(arr) { if (Array.isArray(arr)) return arr; }
25
26function con(n) {
27 return 0x80 | n & 0x3f;
28}
29
30function encode(str) {
31 var arr = str.split("").map(function (x) {
32 return x.charCodeAt(0);
33 });
34 return _encode(arr);
35}
36
37function _encode(arr) {
38 if (arr.length === 0) {
39 return [];
40 }
41
42 var _arr = _toArray(arr),
43 n = _arr[0],
44 ns = _arr.slice(1);
45
46 if (n < 0) {
47 throw new Error("utf8");
48 }
49
50 if (n < 0x80) {
51 return [n].concat(_toConsumableArray(_encode(ns)));
52 }
53
54 if (n < 0x800) {
55 return [0xc0 | n >>> 6, con(n)].concat(_toConsumableArray(_encode(ns)));
56 }
57
58 if (n < 0x10000) {
59 return [0xe0 | n >>> 12, con(n >>> 6), con(n)].concat(_toConsumableArray(_encode(ns)));
60 }
61
62 if (n < 0x110000) {
63 return [0xf0 | n >>> 18, con(n >>> 12), con(n >>> 6), con(n)].concat(_toConsumableArray(_encode(ns)));
64 }
65
66 throw new Error("utf8");
67}
Note: See TracBrowser for help on using the repository browser.