UNPKG

fus-ext

Version:
43 lines (41 loc) 1.79 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.fromHex = exports.fromString = exports.fromBase64 = undefined; var _main = require("./main"); var mod_573300145710716007 = function (a, b) { return (a % b + b) % b; };var dotDotCalc_573300145710716007 = function (dotDot, a, b, c) { return dotDot(a)[b](a, ...c); };var $base64, fromBase64, fromString, fromHex;$base64 = require("./base64");exports.fromBase64 = fromBase64 = function (ns, s) { return (() => { return $base64.toByteArray(s); })(); };exports.fromString = fromString = function (ns, s) { return (() => { var bytes, pos;s = encodeURIComponent(s);bytes = [];pos = 0;(0, _main.loop)(function () { return (() => { return pos < s.length ? (() => { return s[pos] === "%" ? (() => { bytes.push(parseInt(s.substr(pos + 1, 2), 16));pos = pos + 3; })() : (() => { bytes.push(s.charCodeAt(pos));pos = pos + 1; })(); })() : (() => { return _main.break; })(); })(); });bytes = new Uint8Array(bytes);return bytes; })(); };exports.fromHex = fromHex = function (ns, s) { return (() => { (0, _main.assert)(mod_573300145710716007(s.length, 2) === 0);return new Uint8Array((0, _main.repeat)({ [""]: 0, to: dotDotCalc_573300145710716007(_main.dotDot_573300145710716007, s, "bound", []), by: 2, for: function (i) { return (() => { return parseInt(s.substr(i, 2), 16); })(); } })); })(); };exports.fromBase64 = fromBase64; exports.fromString = fromString; exports.fromHex = fromHex;