atcheck/lsscanner/new_ubuntu/node_modules/pvutils/build/utils.js.map

1 line
38 KiB
Plaintext

{"version":3,"sources":["../src/utils.js"],"names":["getUTCDate","getParametersValue","bufferToHexCodes","checkBufferParams","utilFromBase","utilToBase","utilConcatBuf","utilConcatView","utilDecodeTC","utilEncodeTC","isEqualBuffer","padNumber","toBase64","fromBase64","arrayBufferToString","stringToArrayBuffer","nearestPowerOf2","clearProps","date","Date","getTime","getTimezoneOffset","parameters","name","defaultValue","Object","inputBuffer","inputOffset","inputLength","byteLength","insertSpace","result","Uint8Array","item","str","toString","toUpperCase","length","trim","baseBlock","ArrayBuffer","error","inputBase","i","Math","pow","value","base","reserved","internalReserved","internalValue","biggest","retBuf","retView","j","basis","floor","buffers","outputLength","prevLength","buffer","set","views","view","buf","valueHex","condition1","condition2","warnings","push","bigIntBuffer","bigIntView","bigInt","smallIntBuffer","smallIntView","smallInt","modValue","tempBuf","slice","tempView","k","inputBuffer1","inputBuffer2","view1","view2","inputNumber","fullLength","dif","padding","Array","paddingString","join","concat","base64Template","base64UrlTemplate","input","useUrlTemplate","skipPadding","skipLeadingZeros","flag1","flag2","output","template","nonZeroPosition","charCodeAt","chr1","chr2","chr3","enc1","enc2","enc3","enc4","charAt","cutTailZeros","indexof","toSearch","test","incoming","String","fromCharCode","nonZeroStart","resultString","element","stringLength","resultBuffer","resultView","log2","log","round","object","propsArray","prop"],"mappings":";;;;;QAMgBA,U,GAAAA,U;QAaAC,kB,GAAAA,kB;QAqBAC,gB,GAAAA,gB;QAgCAC,iB,GAAAA,iB;QAoDAC,Y,GAAAA,Y;QAuBAC,U,GAAAA,U;QAyDAC,a,GAAAA,a;QAgCAC,c,GAAAA,c;QA+BAC,Y,GAAAA,Y;QAoDAC,Y,GAAAA,Y;QA+DAC,a,GAAAA,a;QA4BAC,S,GAAAA,S;QAgCAC,Q,GAAAA,Q;QAuGAC,U,GAAAA,U;QAyFAC,mB,GAAAA,mB;QAYAC,mB,GAAAA,mB;QAsBAC,e,G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,OAAQH,KAAKmF,GAAL,CAAS1F,MAAT,IAAmByF,IAAjC;;AAEA,OAAMtE,QAAQZ,KAAKY,KAAL,CAAWT,IAAX,CAAd;AACA,OAAMiF,QAAQpF,KAAKoF,KAAL,CAAWjF,IAAX,CAAd;;AAEA;AACA,QAASS,UAAUwE,KAAX,GAAoBxE,KAApB,GAA4BwE,KAApC;AACA;AACD;AACA;;;;;AAKO,SAAS/G,UAAT,CAAoBgH,MAApB,EAA4BC,UAA5B,EACP;AAAA;AAAA;AAAA;;AAAA;AACC,wBAAkBA,UAAlB;AAAA,SAAUC,IAAV;;AACC,UAAOF,OAAOE,IAAP,CAAP;AADD;AADD;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAGC;AACD","file":"utils.js","sourcesContent":["//**************************************************************************************\r\n/**\r\n * Making UTC date from local date\r\n * @param {Date} date Date to convert from\r\n * @returns {Date}\r\n */\r\nexport function getUTCDate(date)\r\n{\r\n\t// noinspection NestedFunctionCallJS, MagicNumberJS\r\n\treturn new Date(date.getTime() + (date.getTimezoneOffset() * 60000));\r\n}\r\n//**************************************************************************************\r\n// noinspection FunctionWithMultipleReturnPointsJS\r\n/**\r\n * Get value for input parameters, or set a default value\r\n * @param {Object} parameters\r\n * @param {string} name\r\n * @param defaultValue\r\n */\r\nexport function getParametersValue(parameters, name, defaultValue)\r\n{\r\n\t// noinspection ConstantOnRightSideOfComparisonJS, NonBlockStatementBodyJS\r\n\tif((parameters instanceof Object) === false)\r\n\t\treturn defaultValue;\r\n\t\r\n\t// noinspection NonBlockStatementBodyJS\r\n\tif(name in parameters)\r\n\t\treturn parameters[name];\r\n\t\r\n\treturn defaultValue;\r\n}\r\n//**************************************************************************************\r\n/**\r\n * Converts \"ArrayBuffer\" into a hexdecimal string\r\n * @param {ArrayBuffer} inputBuffer\r\n * @param {number} [inputOffset=0]\r\n * @param {number} [inputLength=inputBuffer.byteLength]\r\n * @param {boolean} [insertSpace=false]\r\n * @returns {string}\r\n */\r\nexport function bufferToHexCodes(inputBuffer, inputOffset = 0, inputLength = (inputBuffer.byteLength - inputOffset), insertSpace = false)\r\n{\r\n\tlet result = \"\";\r\n\t\r\n\tfor(const item of (new Uint8Array(inputBuffer, inputOffset, inputLength)))\r\n\t{\r\n\t\t// noinspection ChainedFunctionCallJS\r\n\t\tconst str = item.toString(16).toUpperCase();\r\n\t\t\r\n\t\t// noinspection ConstantOnRightSideOfComparisonJS, NonBlockStatementBodyJS\r\n\t\tif(str.length === 1)\r\n\t\t\tresult += \"0\";\r\n\t\t\r\n\t\tresult += str;\r\n\t\t\r\n\t\t// noinspection NonBlockStatementBodyJS\r\n\t\tif(insertSpace)\r\n\t\t\tresult += \" \";\r\n\t}\r\n\t\r\n\treturn result.trim();\r\n}\r\n//**************************************************************************************\r\n// noinspection JSValidateJSDoc, FunctionWithMultipleReturnPointsJS\r\n/**\r\n * Check input \"ArrayBuffer\" for common functions\r\n * @param {LocalBaseBlock} baseBlock\r\n * @param {ArrayBuffer} inputBuffer\r\n * @param {number} inputOffset\r\n * @param {number} inputLength\r\n * @returns {boolean}\r\n */\r\nexport function checkBufferParams(baseBlock, inputBuffer, inputOffset, inputLength)\r\n{\r\n\t// noinspection ConstantOnRightSideOfComparisonJS\r\n\tif((inputBuffer instanceof ArrayBuffer) === false)\r\n\t{\r\n\t\t// noinspection JSUndefinedPropertyAssignment\r\n\t\tbaseBlock.error = \"Wrong parameter: inputBuffer must be \\\"ArrayBuffer\\\"\";\r\n\t\treturn false;\r\n\t}\r\n\t\r\n\t// noinspection ConstantOnRightSideOfComparisonJS\r\n\tif(inputBuffer.byteLength === 0)\r\n\t{\r\n\t\t// noinspection JSUndefinedPropertyAssignment\r\n\t\tbaseBlock.error = \"Wrong parameter: inputBuffer has zero length\";\r\n\t\treturn false;\r\n\t}\r\n\t\r\n\t// noinspection ConstantOnRightSideOfComparisonJS\r\n\tif(inputOffset < 0)\r\n\t{\r\n\t\t// noinspection JSUndefinedPropertyAssignment\r\n\t\tbaseBlock.error = \"Wrong parameter: inputOffset less than zero\";\r\n\t\treturn false;\r\n\t}\r\n\t\r\n\t// noinspection ConstantOnRightSideOfComparisonJS\r\n\tif(inputLength < 0)\r\n\t{\r\n\t\t// noinspection JSUndefinedPropertyAssignment\r\n\t\tbaseBlock.error = \"Wrong parameter: inputLength less than zero\";\r\n\t\treturn false;\r\n\t}\r\n\t\r\n\t// noinspection ConstantOnRightSideOfComparisonJS\r\n\tif((inputBuffer.byteLength - inputOffset - inputLength) < 0)\r\n\t{\r\n\t\t// noinspection JSUndefinedPropertyAssignment\r\n\t\tbaseBlock.error = \"End of input reached before message was fully decoded (inconsistent offset and length values)\";\r\n\t\treturn false;\r\n\t}\r\n\t\r\n\treturn true;\r\n}\r\n//**************************************************************************************\r\n// noinspection FunctionWithMultipleReturnPointsJS\r\n/**\r\n * Convert number from 2^base to 2^10\r\n * @param {Uint8Array} inputBuffer\r\n * @param {number} inputBase\r\n * @returns {number}\r\n */\r\nexport function utilFromBase(inputBuffer, inputBase)\r\n{\r\n\tlet result = 0;\r\n\t\r\n\t// noinspection ConstantOnRightSideOfComparisonJS, NonBlockStatementBodyJS\r\n\tif(inputBuffer.length === 1)\r\n\t\treturn inputBuffer[0];\r\n\t\r\n\t// noinspection ConstantOnRightSideOfComparisonJS, NonBlockStatementBodyJS\r\n\tfor(let i = (inputBuffer.length - 1); i >= 0; i--)\r\n\t\tresult += inputBuffer[(inputBuffer.length - 1) - i] * Math.pow(2, inputBase * i);\r\n\t\r\n\treturn result;\r\n}\r\n//**************************************************************************************\r\n// noinspection FunctionWithMultipleLoopsJS, FunctionWithMultipleReturnPointsJS\r\n/**\r\n * Convert number from 2^10 to 2^base\r\n * @param {!number} value The number to convert\r\n * @param {!number} base The base for 2^base\r\n * @param {number} [reserved=0] Pre-defined number of bytes in output array (-1 = limited by function itself)\r\n * @returns {ArrayBuffer}\r\n */\r\nexport function utilToBase(value, base, reserved = (-1))\r\n{\r\n\tconst internalReserved = reserved;\r\n\tlet internalValue = value;\r\n\t\r\n\tlet result = 0;\r\n\tlet biggest = Math.pow(2, base);\r\n\t\r\n\t// noinspection ConstantOnRightSideOfComparisonJS\r\n\tfor(let i = 1; i < 8; i++)\r\n\t{\r\n\t\tif(value < biggest)\r\n\t\t{\r\n\t\t\tlet retBuf;\r\n\t\t\t\r\n\t\t\t// noinspection ConstantOnRightSideOfComparisonJS\r\n\t\t\tif(internalReserved < 0)\r\n\t\t\t{\r\n\t\t\t\tretBuf = new ArrayBuffer(i);\r\n\t\t\t\tresult = i;\r\n\t\t\t}\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\t// noinspection NonBlockStatementBodyJS\r\n\t\t\t\tif(internalReserved < i)\r\n\t\t\t\t\treturn (new ArrayBuffer(0));\r\n\t\t\t\t\r\n\t\t\t\tretBuf = new ArrayBuffer(internalReserved);\r\n\t\t\t\t\r\n\t\t\t\tresult = internalReserved;\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tconst retView = new Uint8Array(retBuf);\r\n\t\t\t\r\n\t\t\t// noinspection ConstantOnRightSideOfComparisonJS\r\n\t\t\tfor(let j = (i - 1); j >= 0; j--)\r\n\t\t\t{\r\n\t\t\t\tconst basis = Math.pow(2, j * base);\r\n\t\t\t\t\r\n\t\t\t\tretView[result - j - 1] = Math.floor(internalValue / basis);\r\n\t\t\t\tinternalValue -= (retView[result - j - 1]) * basis;\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\treturn retBuf;\r\n\t\t}\r\n\t\t\r\n\t\tbiggest *= Math.pow(2, base);\r\n\t}\r\n\t\r\n\treturn new ArrayBuffer(0);\r\n}\r\n//**************************************************************************************\r\n// noinspection FunctionWithMultipleLoopsJS\r\n/**\r\n * Concatenate two ArrayBuffers\r\n * @param {...ArrayBuffer} buffers Set of ArrayBuffer\r\n */\r\nexport function utilConcatBuf(...buffers)\r\n{\r\n\t//region Initial variables\r\n\tlet outputLength = 0;\r\n\tlet prevLength = 0;\r\n\t//endregion\r\n\t\r\n\t//region Calculate output length\r\n\t\r\n\t// noinspection NonBlockStatementBodyJS\r\n\tfor(const buffer of buffers)\r\n\t\toutputLength += buffer.byteLength;\r\n\t//endregion\r\n\t\r\n\tconst retBuf = new ArrayBuffer(outputLength);\r\n\tconst retView = new Uint8Array(retBuf);\r\n\t\r\n\tfor(const buffer of buffers)\r\n\t{\r\n\t\t// noinspection NestedFunctionCallJS\r\n\t\tretView.set(new Uint8Array(buffer), prevLength);\r\n\t\tprevLength += buffer.byteLength;\r\n\t}\r\n\t\r\n\treturn retBuf;\r\n}\r\n//**************************************************************************************\r\n// noinspection FunctionWithMultipleLoopsJS\r\n/**\r\n * Concatenate two Uint8Array\r\n * @param {...Uint8Array} views Set of Uint8Array\r\n */\r\nexport function utilConcatView(...views)\r\n{\r\n\t//region Initial variables\r\n\tlet outputLength = 0;\r\n\tlet prevLength = 0;\r\n\t//endregion\r\n\t\r\n\t//region Calculate output length\r\n\t// noinspection NonBlockStatementBodyJS\r\n\tfor(const view of views)\r\n\t\toutputLength += view.length;\r\n\t//endregion\r\n\t\r\n\tconst retBuf = new ArrayBuffer(outputLength);\r\n\tconst retView = new Uint8Array(retBuf);\r\n\t\r\n\tfor(const view of views)\r\n\t{\r\n\t\tretView.set(view, prevLength);\r\n\t\tprevLength += view.length;\r\n\t}\r\n\t\r\n\treturn retView;\r\n}\r\n//**************************************************************************************\r\n// noinspection FunctionWithMultipleLoopsJS\r\n/**\r\n * Decoding of \"two complement\" values\r\n * The function must be called in scope of instance of \"hexBlock\" class (\"valueHex\" and \"warnings\" properties must be present)\r\n * @returns {number}\r\n */\r\nexport function utilDecodeTC()\r\n{\r\n\tconst buf = new Uint8Array(this.valueHex);\r\n\t\r\n\t// noinspection ConstantOnRightSideOfComparisonJS\r\n\tif(this.valueHex.byteLength >= 2)\r\n\t{\r\n\t\t//noinspection JSBitwiseOperatorUsage, ConstantOnRightSideOfComparisonJS, LocalVariableNamingConventionJS, MagicNumberJS, NonShortCircuitBooleanExpressionJS\r\n\t\tconst condition1 = (buf[0] === 0xFF) && (buf[1] & 0x80);\r\n\t\t// noinspection ConstantOnRightSideOfComparisonJS, LocalVariableNamingConventionJS, MagicNumberJS, NonShortCircuitBooleanExpressionJS\r\n\t\tconst condition2 = (buf[0] === 0x00) && ((buf[1] & 0x80) === 0x00);\r\n\t\t\r\n\t\t// noinspection NonBlockStatementBodyJS\r\n\t\tif(condition1 || condition2)\r\n\t\t\tthis.warnings.push(\"Needlessly long format\");\r\n\t}\r\n\t\r\n\t//region Create big part of the integer\r\n\tconst bigIntBuffer = new ArrayBuffer(this.valueHex.byteLength);\r\n\tconst bigIntView = new Uint8Array(bigIntBuffer);\r\n\t// noinspection NonBlockStatementBodyJS\r\n\tfor(let i = 0; i < this.valueHex.byteLength; i++)\r\n\t\tbigIntView[i] = 0;\r\n\t\r\n\t// noinspection MagicNumberJS, NonShortCircuitBooleanExpressionJS\r\n\tbigIntView[0] = (buf[0] & 0x80); // mask only the biggest bit\r\n\t\r\n\tconst bigInt = utilFromBase(bigIntView, 8);\r\n\t//endregion\r\n\t\r\n\t//region Create small part of the integer\r\n\tconst smallIntBuffer = new ArrayBuffer(this.valueHex.byteLength);\r\n\tconst smallIntView = new Uint8Array(smallIntBuffer);\r\n\t// noinspection NonBlockStatementBodyJS\r\n\tfor(let j = 0; j < this.valueHex.byteLength; j++)\r\n\t\tsmallIntView[j] = buf[j];\r\n\t\r\n\t// noinspection MagicNumberJS\r\n\tsmallIntView[0] &= 0x7F; // mask biggest bit\r\n\t\r\n\tconst smallInt = utilFromBase(smallIntView, 8);\r\n\t//endregion\r\n\t\r\n\treturn (smallInt - bigInt);\r\n}\r\n//**************************************************************************************\r\n// noinspection FunctionWithMultipleLoopsJS, FunctionWithMultipleReturnPointsJS\r\n/**\r\n * Encode integer value to \"two complement\" format\r\n * @param {number} value Value to encode\r\n * @returns {ArrayBuffer}\r\n */\r\nexport function utilEncodeTC(value)\r\n{\r\n\t// noinspection ConstantOnRightSideOfComparisonJS, ConditionalExpressionJS\r\n\tconst modValue = (value < 0) ? (value * (-1)) : value;\r\n\tlet bigInt = 128;\r\n\t\r\n\t// noinspection ConstantOnRightSideOfComparisonJS\r\n\tfor(let i = 1; i < 8; i++)\r\n\t{\r\n\t\tif(modValue <= bigInt)\r\n\t\t{\r\n\t\t\t// noinspection ConstantOnRightSideOfComparisonJS\r\n\t\t\tif(value < 0)\r\n\t\t\t{\r\n\t\t\t\tconst smallInt = bigInt - modValue;\r\n\t\t\t\t\r\n\t\t\t\tconst retBuf = utilToBase(smallInt, 8, i);\r\n\t\t\t\tconst retView = new Uint8Array(retBuf);\r\n\t\t\t\t\r\n\t\t\t\t// noinspection MagicNumberJS\r\n\t\t\t\tretView[0] |= 0x80;\r\n\t\t\t\t\r\n\t\t\t\treturn retBuf;\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\tlet retBuf = utilToBase(modValue, 8, i);\r\n\t\t\tlet retView = new Uint8Array(retBuf);\r\n\t\t\t\r\n\t\t\t//noinspection JSBitwiseOperatorUsage, MagicNumberJS, NonShortCircuitBooleanExpressionJS\r\n\t\t\tif(retView[0] & 0x80)\r\n\t\t\t{\r\n\t\t\t\t//noinspection JSCheckFunctionSignatures\r\n\t\t\t\tconst tempBuf = retBuf.slice(0);\r\n\t\t\t\tconst tempView = new Uint8Array(tempBuf);\r\n\t\t\t\t\r\n\t\t\t\tretBuf = new ArrayBuffer(retBuf.byteLength + 1);\r\n\t\t\t\t// noinspection ReuseOfLocalVariableJS\r\n\t\t\t\tretView = new Uint8Array(retBuf);\r\n\t\t\t\t\r\n\t\t\t\t// noinspection NonBlockStatementBodyJS\r\n\t\t\t\tfor(let k = 0; k < tempBuf.byteLength; k++)\r\n\t\t\t\t\tretView[k + 1] = tempView[k];\r\n\t\t\t\t\r\n\t\t\t\t// noinspection MagicNumberJS\r\n\t\t\t\tretView[0] = 0x00;\r\n\t\t\t}\r\n\t\t\t\r\n\t\t\treturn retBuf;\r\n\t\t}\r\n\t\t\r\n\t\tbigInt *= Math.pow(2, 8);\r\n\t}\r\n\t\r\n\treturn (new ArrayBuffer(0));\r\n}\r\n//**************************************************************************************\r\n// noinspection FunctionWithMultipleReturnPointsJS, ParameterNamingConventionJS\r\n/**\r\n * Compare two array buffers\r\n * @param {!ArrayBuffer} inputBuffer1\r\n * @param {!ArrayBuffer} inputBuffer2\r\n * @returns {boolean}\r\n */\r\nexport function isEqualBuffer(inputBuffer1, inputBuffer2)\r\n{\r\n\t// noinspection NonBlockStatementBodyJS\r\n\tif(inputBuffer1.byteLength !== inputBuffer2.byteLength)\r\n\t\treturn false;\r\n\t\r\n\t// noinspection LocalVariableNamingConventionJS\r\n\tconst view1 = new Uint8Array(inputBuffer1);\r\n\t// noinspection LocalVariableNamingConventionJS\r\n\tconst view2 = new Uint8Array(inputBuffer2);\r\n\t\r\n\tfor(let i = 0; i < view1.length; i++)\r\n\t{\r\n\t\t// noinspection NonBlockStatementBodyJS\r\n\t\tif(view1[i] !== view2[i])\r\n\t\t\treturn false;\r\n\t}\r\n\t\r\n\treturn true;\r\n}\r\n//**************************************************************************************\r\n// noinspection FunctionWithMultipleReturnPointsJS\r\n/**\r\n * Pad input number with leade \"0\" if needed\r\n * @returns {string}\r\n * @param {number} inputNumber\r\n * @param {number} fullLength\r\n */\r\nexport function padNumber(inputNumber, fullLength)\r\n{\r\n\tconst str = inputNumber.toString(10);\r\n\t\r\n\t// noinspection NonBlockStatementBodyJS\r\n\tif(fullLength < str.length)\r\n\t\treturn \"\";\r\n\t\r\n\tconst dif = fullLength - str.length;\r\n\t\r\n\tconst padding = new Array(dif);\r\n\t// noinspection NonBlockStatementBodyJS\r\n\tfor(let i = 0; i < dif; i++)\r\n\t\tpadding[i] = \"0\";\r\n\t\r\n\tconst paddingString = padding.join(\"\");\r\n\t\r\n\treturn paddingString.concat(str);\r\n}\r\n//**************************************************************************************\r\nconst base64Template = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=\";\r\nconst base64UrlTemplate = \"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789-_=\";\r\n//**************************************************************************************\r\n// noinspection FunctionWithMultipleLoopsJS, OverlyComplexFunctionJS, FunctionTooLongJS, FunctionNamingConventionJS\r\n/**\r\n * Encode string into BASE64 (or \"base64url\")\r\n * @param {string} input\r\n * @param {boolean} useUrlTemplate If \"true\" then output would be encoded using \"base64url\"\r\n * @param {boolean} skipPadding Skip BASE-64 padding or not\r\n * @param {boolean} skipLeadingZeros Skip leading zeros in input data or not\r\n * @returns {string}\r\n */\r\nexport function toBase64(input, useUrlTemplate = false, skipPadding = false, skipLeadingZeros = false)\r\n{\r\n\tlet i = 0;\r\n\t\r\n\t// noinspection LocalVariableNamingConventionJS\r\n\tlet flag1 = 0;\r\n\t// noinspection LocalVariableNamingConventionJS\r\n\tlet flag2 = 0;\r\n\t\r\n\tlet output = \"\";\r\n\t\r\n\t// noinspection ConditionalExpressionJS\r\n\tconst template = (useUrlTemplate) ? base64UrlTemplate : base64Template;\r\n\t\r\n\tif(skipLeadingZeros)\r\n\t{\r\n\t\tlet nonZeroPosition = 0;\r\n\t\t\r\n\t\tfor(let i = 0; i < input.length; i++)\r\n\t\t{\r\n\t\t\t// noinspection ConstantOnRightSideOfComparisonJS\r\n\t\t\tif(input.charCodeAt(i) !== 0)\r\n\t\t\t{\r\n\t\t\t\tnonZeroPosition = i;\r\n\t\t\t\t// noinspection BreakStatementJS\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n\t\t// noinspection AssignmentToFunctionParameterJS\r\n\t\tinput = input.slice(nonZeroPosition);\r\n\t}\r\n\t\r\n\twhile(i < input.length)\r\n\t{\r\n\t\t// noinspection LocalVariableNamingConventionJS, IncrementDecrementResultUsedJS\r\n\t\tconst chr1 = input.charCodeAt(i++);\r\n\t\t// noinspection NonBlockStatementBodyJS\r\n\t\tif(i >= input.length)\r\n\t\t\tflag1 = 1;\r\n\t\t// noinspection LocalVariableNamingConventionJS, IncrementDecrementResultUsedJS\r\n\t\tconst chr2 = input.charCodeAt(i++);\r\n\t\t// noinspection NonBlockStatementBodyJS\r\n\t\tif(i >= input.length)\r\n\t\t\tflag2 = 1;\r\n\t\t// noinspection LocalVariableNamingConventionJS, IncrementDecrementResultUsedJS\r\n\t\tconst chr3 = input.charCodeAt(i++);\r\n\t\t\r\n\t\t// noinspection LocalVariableNamingConventionJS\r\n\t\tconst enc1 = chr1 >> 2;\r\n\t\t// noinspection LocalVariableNamingConventionJS, MagicNumberJS, NonShortCircuitBooleanExpressionJS\r\n\t\tconst enc2 = ((chr1 & 0x03) << 4) | (chr2 >> 4);\r\n\t\t// noinspection LocalVariableNamingConventionJS, MagicNumberJS, NonShortCircuitBooleanExpressionJS\r\n\t\tlet enc3 = ((chr2 & 0x0F) << 2) | (chr3 >> 6);\r\n\t\t// noinspection LocalVariableNamingConventionJS, MagicNumberJS, NonShortCircuitBooleanExpressionJS\r\n\t\tlet enc4 = chr3 & 0x3F;\r\n\t\t\r\n\t\t// noinspection ConstantOnRightSideOfComparisonJS\r\n\t\tif(flag1 === 1)\r\n\t\t{\r\n\t\t\t// noinspection NestedAssignmentJS, AssignmentResultUsedJS, MagicNumberJS\r\n\t\t\tenc3 = enc4 = 64;\r\n\t\t}\r\n\t\telse\r\n\t\t{\r\n\t\t\t// noinspection ConstantOnRightSideOfComparisonJS\r\n\t\t\tif(flag2 === 1)\r\n\t\t\t{\r\n\t\t\t\t// noinspection MagicNumberJS\r\n\t\t\t\tenc4 = 64;\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n\t\t// noinspection NonBlockStatementBodyJS\r\n\t\tif(skipPadding)\r\n\t\t{\r\n\t\t\t// noinspection ConstantOnRightSideOfComparisonJS, NonBlockStatementBodyJS, MagicNumberJS\r\n\t\t\tif(enc3 === 64)\r\n\t\t\t\toutput += `${template.charAt(enc1)}${template.charAt(enc2)}`;\r\n\t\t\telse\r\n\t\t\t{\r\n\t\t\t\t// noinspection ConstantOnRightSideOfComparisonJS, NonBlockStatementBodyJS, MagicNumberJS\r\n\t\t\t\tif(enc4 === 64)\r\n\t\t\t\t\toutput += `${template.charAt(enc1)}${template.charAt(enc2)}${template.charAt(enc3)}`;\r\n\t\t\t\telse\r\n\t\t\t\t\toutput += `${template.charAt(enc1)}${template.charAt(enc2)}${template.charAt(enc3)}${template.charAt(enc4)}`;\r\n\t\t\t}\r\n\t\t}\r\n\t\telse\r\n\t\t\toutput += `${template.charAt(enc1)}${template.charAt(enc2)}${template.charAt(enc3)}${template.charAt(enc4)}`;\r\n\t}\r\n\t\r\n\treturn output;\r\n}\r\n//**************************************************************************************\r\n// noinspection FunctionWithMoreThanThreeNegationsJS, FunctionWithMultipleLoopsJS, OverlyComplexFunctionJS, FunctionNamingConventionJS\r\n/**\r\n * Decode string from BASE64 (or \"base64url\")\r\n * @param {string} input\r\n * @param {boolean} [useUrlTemplate=false] If \"true\" then output would be encoded using \"base64url\"\r\n * @param {boolean} [cutTailZeros=false] If \"true\" then cut tailing zeroz from function result\r\n * @returns {string}\r\n */\r\nexport function fromBase64(input, useUrlTemplate = false, cutTailZeros = false)\r\n{\r\n\t// noinspection ConditionalExpressionJS\r\n\tconst template = (useUrlTemplate) ? base64UrlTemplate : base64Template;\r\n\t\r\n\t//region Aux functions\r\n\t// noinspection FunctionWithMultipleReturnPointsJS, NestedFunctionJS\r\n\tfunction indexof(toSearch)\r\n\t{\r\n\t\t// noinspection ConstantOnRightSideOfComparisonJS, MagicNumberJS\r\n\t\tfor(let i = 0; i < 64; i++)\r\n\t\t{\r\n\t\t\t// noinspection NonBlockStatementBodyJS\r\n\t\t\tif(template.charAt(i) === toSearch)\r\n\t\t\t\treturn i;\r\n\t\t}\r\n\t\t\r\n\t\t// noinspection MagicNumberJS\r\n\t\treturn 64;\r\n\t}\r\n\t\r\n\t// noinspection NestedFunctionJS\r\n\tfunction test(incoming)\r\n\t{\r\n\t\t// noinspection ConstantOnRightSideOfComparisonJS, ConditionalExpressionJS, MagicNumberJS\r\n\t\treturn ((incoming === 64) ? 0x00 : incoming);\r\n\t}\r\n\t//endregion\r\n\t\r\n\tlet i = 0;\r\n\t\r\n\tlet output = \"\";\r\n\t\r\n\twhile(i < input.length)\r\n\t{\r\n\t\t// noinspection NestedFunctionCallJS, LocalVariableNamingConventionJS, IncrementDecrementResultUsedJS\r\n\t\tconst enc1 = indexof(input.charAt(i++));\r\n\t\t// noinspection NestedFunctionCallJS, LocalVariableNamingConventionJS, ConditionalExpressionJS, MagicNumberJS, IncrementDecrementResultUsedJS\r\n\t\tconst enc2 = (i >= input.length) ? 0x00 : indexof(input.charAt(i++));\r\n\t\t// noinspection NestedFunctionCallJS, LocalVariableNamingConventionJS, ConditionalExpressionJS, MagicNumberJS, IncrementDecrementResultUsedJS\r\n\t\tconst enc3 = (i >= input.length) ? 0x00 : indexof(input.charAt(i++));\r\n\t\t// noinspection NestedFunctionCallJS, LocalVariableNamingConventionJS, ConditionalExpressionJS, MagicNumberJS, IncrementDecrementResultUsedJS\r\n\t\tconst enc4 = (i >= input.length) ? 0x00 : indexof(input.charAt(i++));\r\n\t\t\r\n\t\t// noinspection LocalVariableNamingConventionJS, NonShortCircuitBooleanExpressionJS\r\n\t\tconst chr1 = (test(enc1) << 2) | (test(enc2) >> 4);\r\n\t\t// noinspection LocalVariableNamingConventionJS, MagicNumberJS, NonShortCircuitBooleanExpressionJS\r\n\t\tconst chr2 = ((test(enc2) & 0x0F) << 4) | (test(enc3) >> 2);\r\n\t\t// noinspection LocalVariableNamingConventionJS, MagicNumberJS, NonShortCircuitBooleanExpressionJS\r\n\t\tconst chr3 = ((test(enc3) & 0x03) << 6) | test(enc4);\r\n\t\t\r\n\t\toutput += String.fromCharCode(chr1);\r\n\t\t\r\n\t\t// noinspection ConstantOnRightSideOfComparisonJS, NonBlockStatementBodyJS, MagicNumberJS\r\n\t\tif(enc3 !== 64)\r\n\t\t\toutput += String.fromCharCode(chr2);\r\n\t\t\r\n\t\t// noinspection ConstantOnRightSideOfComparisonJS, NonBlockStatementBodyJS, MagicNumberJS\r\n\t\tif(enc4 !== 64)\r\n\t\t\toutput += String.fromCharCode(chr3);\r\n\t}\r\n\t\r\n\tif(cutTailZeros)\r\n\t{\r\n\t\tconst outputLength = output.length;\r\n\t\tlet nonZeroStart = (-1);\r\n\t\t\r\n\t\t// noinspection ConstantOnRightSideOfComparisonJS\r\n\t\tfor(let i = (outputLength - 1); i >= 0; i--)\r\n\t\t{\r\n\t\t\t// noinspection ConstantOnRightSideOfComparisonJS\r\n\t\t\tif(output.charCodeAt(i) !== 0)\r\n\t\t\t{\r\n\t\t\t\tnonZeroStart = i;\r\n\t\t\t\t// noinspection BreakStatementJS\r\n\t\t\t\tbreak;\r\n\t\t\t}\r\n\t\t}\r\n\t\t\r\n\t\t// noinspection NonBlockStatementBodyJS, NegatedIfStatementJS\r\n\t\tif(nonZeroStart !== (-1))\r\n\t\t\toutput = output.slice(0, nonZeroStart + 1);\r\n\t\telse\r\n\t\t\toutput = \"\";\r\n\t}\r\n\t\r\n\treturn output;\r\n}\r\n//**************************************************************************************\r\nexport function arrayBufferToString(buffer)\r\n{\r\n\tlet resultString = \"\";\r\n\tconst view = new Uint8Array(buffer);\r\n\t\r\n\t// noinspection NonBlockStatementBodyJS\r\n\tfor(const element of view)\r\n\t\tresultString += String.fromCharCode(element);\r\n\t\r\n\treturn resultString;\r\n}\r\n//**************************************************************************************\r\nexport function stringToArrayBuffer(str)\r\n{\r\n\tconst stringLength = str.length;\r\n\t\r\n\tconst resultBuffer = new ArrayBuffer(stringLength);\r\n\tconst resultView = new Uint8Array(resultBuffer);\r\n\t\r\n\t// noinspection NonBlockStatementBodyJS\r\n\tfor(let i = 0; i < stringLength; i++)\r\n\t\tresultView[i] = str.charCodeAt(i);\r\n\t\r\n\treturn resultBuffer;\r\n}\r\n//**************************************************************************************\r\nconst log2 = Math.log(2);\r\n//**************************************************************************************\r\n// noinspection FunctionNamingConventionJS\r\n/**\r\n * Get nearest to input length power of 2\r\n * @param {number} length Current length of existing array\r\n * @returns {number}\r\n */\r\nexport function nearestPowerOf2(length)\r\n{\r\n\tconst base = (Math.log(length) / log2);\r\n\t\r\n\tconst floor = Math.floor(base);\r\n\tconst round = Math.round(base);\r\n\t\r\n\t// noinspection ConditionalExpressionJS\r\n\treturn ((floor === round) ? floor : round);\r\n}\r\n//**************************************************************************************\r\n/**\r\n * Delete properties by name from specified object\r\n * @param {Object} object Object to delete properties from\r\n * @param {Array.<string>} propsArray Array of properties names\r\n */\r\nexport function clearProps(object, propsArray)\r\n{\r\n\tfor(const prop of propsArray)\r\n\t\tdelete object[prop];\r\n}\r\n//**************************************************************************************\r\n"]}