repo_name
string
dataset
string
owner
string
lang
string
func_name
string
code
string
docstring
string
url
string
sha
string
LafTools
github_2023
work7z
typescript
FromHexdump.constructor
constructor() { super(); this.name = "From Hexdump"; this.module = "Default"; this.inputType = "string"; this.outputType = "byteArray"; this.args = []; this.checks = [ { pattern: "^(?:(?:[\\dA-F]{4,16}h?:?)?[ \\t]*((?:[\\dA-F]{2} ){1,8}(?:[ \\t]|[\\dA-F]{2}-)(?:[\\dA-F]{2} ){1,8}|(?:[\\dA-F]{4} )*[\\dA-F]{4}|(?:[\\dA-F]{2} )*[\\dA-F]{2})[^\\n]*\\n?){2,}$", flags: "i", args: [], }, ]; }
/** * FromHexdump constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/FromHexdump.tsx#L58-L74
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
FromHexdump.run
run(input, args) { const output: any = [], regex = /^\s*(?:[\dA-F]{4,16}h?:?)?[ \t]+((?:[\dA-F]{2} ){1,8}(?:[ \t]|[\dA-F]{2}-)(?:[\dA-F]{2} ){1,8}|(?:[\dA-F]{4} )*[\dA-F]{4}|(?:[\dA-F]{2} )*[\dA-F]{2})/gim; let block: any, line: any; while ((block = regex.exec(input))) { line = fromHex(block[1].replace(/-/g, " ")); for (let i = 0; i < line.length; i++) { output.push(line[i]); } } // Is this a CyberChef hexdump or is it from a different tool? const width = input.indexOf("\n"); const w = (width - 13) / 4; // w should be the specified width of the hexdump and therefore a round number if ( Math.floor(w) !== w || input.indexOf("\r") !== -1 || output.indexOf(13) !== -1 ) { // TODO: attemptHighlight in FromHexdump // if (isWorkerEnvironment()) self.setOption("attemptHighlight", false); } return output; }
/** * @param {string} input * @param {Object[]} args * @returns {byteArray} */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/FromHexdump.tsx#L81-L106
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
FromHexdump.highlight
highlight(pos, args) { const w = args[0] || 16; const width = 14 + w * 4; let line = Math.floor(pos[0].start / width); let offset = pos[0].start % width; if (offset < 10) { // In line number section pos[0].start = line * w; } else if (offset > 10 + w * 3) { // In ASCII section pos[0].start = (line + 1) * w; } else { // In byte section pos[0].start = line * w + Math.floor((offset - 10) / 3); } line = Math.floor(pos[0].end / width); offset = pos[0].end % width; if (offset < 10) { // In line number section pos[0].end = line * w; } else if (offset > 10 + w * 3) { // In ASCII section pos[0].end = (line + 1) * w; } else { // In byte section pos[0].end = line * w + Math.ceil((offset - 10) / 3); } return pos; }
/** * Highlight From Hexdump * * @param {Object[]} pos * @param {number} pos[].start * @param {number} pos[].end * @param {Object[]} args * @returns {Object[]} pos */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/FromHexdump.tsx#L117-L150
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
FromHexdump.highlightReverse
highlightReverse(pos, args) { // Calculate overall selection const w = args[0] || 16, width = 14 + w * 4; let line = Math.floor(pos[0].start / w), offset = pos[0].start % w, start = 0, end = 0; pos[0].start = line * width + 10 + offset * 3; line = Math.floor(pos[0].end / w); offset = pos[0].end % w; if (offset === 0) { line--; offset = w; } pos[0].end = line * width + 10 + offset * 3 - 1; // Set up multiple selections for bytes let startLineNum = Math.floor(pos[0].start / width); const endLineNum = Math.floor(pos[0].end / width); if (startLineNum === endLineNum) { pos.push(pos[0]); } else { start = pos[0].start; end = (startLineNum + 1) * width - w - 5; pos.push({ start: start, end: end }); while (end < pos[0].end) { startLineNum++; start = startLineNum * width + 10; end = (startLineNum + 1) * width - w - 5; if (end > pos[0].end) end = pos[0].end; pos.push({ start: start, end: end }); } } // Set up multiple selections for ASCII const len = pos.length; let lineNum = 0; start = 0; end = 0; for (let i = 1; i < len; i++) { lineNum = Math.floor(pos[i].start / width); start = (pos[i].start - lineNum * width - 10) / 3 + (width - w - 2) + lineNum * width; end = (pos[i].end + 1 - lineNum * width - 10) / 3 + (width - w - 2) + lineNum * width; pos.push({ start: start, end: end }); } return pos; }
/** * Highlight From Hexdump in reverse * * @param {Object[]} pos * @param {number} pos[].start * @param {number} pos[].end * @param {Object[]} args * @returns {Object[]} pos */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/FromHexdump.tsx#L161-L217
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
FromMessagePack.constructor
constructor() { super(); this.name = "From MessagePack"; this.module = "Code"; // this.description = // "Converts MessagePack encoded data to JSON. MessagePack is a computer data interchange format. It is a binary form for representing simple data structures like arrays and associative arrays."; // this.infoURL = "https://wikipedia.org/wiki/MessagePack"; this.inputType = "ArrayBuffer"; this.outputType = "JSON"; this.args = []; }
/** * FromMessagePack constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/FromMessagePack.tsx#L46-L57
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
FromMessagePack.run
run(input, args) { try { const buf = Buffer.from(new Uint8Array(input)); return notepack.decode(buf); } catch (err) { throw new OperationError(`Could not decode MessagePack to JSON: ${err}`); } }
/** * @param {ArrayBuffer} input * @param {Object[]} args * @returns {JSON} */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/FromMessagePack.tsx#L64-L71
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
FromMorseCode.constructor
constructor() { super(); this.name = "From Morse Code"; this.module = "Default"; // this.description = // "Translates Morse Code into (upper case) alphanumeric characters."; // this.infoURL = "https://wikipedia.org/wiki/Morse_code"; this.inputType = "string"; this.outputType = "string"; this.args = [ { name: "Letter delimiter", type: "option", value: LETTER_DELIM_OPTIONS, }, { name: "Word delimiter", type: "option", value: WORD_DELIM_OPTIONS, }, ]; this.checks = [ { pattern: "(?:^[-. \\n]{5,}$|^[_. \\n]{5,}$|^(?:dash|dot| |\\n){5,}$)", flags: "i", args: ["Space", "Line feed"], }, ]; }
/** * FromMorseCode constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/FromMorseCode.tsx#L48-L77
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
FromMorseCode.run
run(input, args) { if (!this.reversedTable) { this.reverseTable(); } if (!this.reversedTable) { return "Error: reversedTable is not defined" } const letterDelim = Utils.charRep(args[0]); const wordDelim = Utils.charRep(args[1]); input = input.replace(/-|‐|−|_|–|—|dash/gi, "<dash>"); // hyphen-minus|hyphen|minus-sign|undersore|en-dash|em-dash input = input.replace(/\.|·|dot/gi, "<dot>"); let words = input.split(wordDelim); const self = this; words = Array.prototype.map.call(words, function (word) { const signals = word.split(letterDelim); const letters = signals.map(function (signal) { return self.reversedTable && self.reversedTable[signal]; }); return letters.join(""); }); words = words.join(" "); return words; }
/** * @param {string} input * @param {Object[]} args * @returns {string} */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/FromMorseCode.tsx#L84-L112
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
FromMorseCode.reverseTable
reverseTable() { this.reversedTable = {}; for (const letter in MORSE_TABLE) { const signal = MORSE_TABLE[letter]; this.reversedTable[signal] = letter; } }
/** * Reverses the Morse Code lookup table */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/FromMorseCode.tsx#L117-L124
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
FromOctal.constructor
constructor() { super(); this.name = "From Octal"; this.module = "Default"; // this.description = // "Converts an octal byte string back into its raw value.<br><br>e.g. <code>316 223 316 265 316 271 316 254 40 317 203 316 277 317 205</code> becomes the UTF-8 encoded string <code>Γειά σου</code>"; // this.infoURL = "https://wikipedia.org/wiki/Octal"; this.inputType = "string"; this.outputType = "byteArray"; this.args = [ { name: "Delimiter", type: "option", value: DELIM_OPTIONS, }, ]; this.checks = [ { pattern: "^(?:[0-7]{1,2}|[123][0-7]{2})(?: (?:[0-7]{1,2}|[123][0-7]{2}))*$", flags: "", args: ["Space"], }, { pattern: "^(?:[0-7]{1,2}|[123][0-7]{2})(?:,(?:[0-7]{1,2}|[123][0-7]{2}))*$", flags: "", args: ["Comma"], }, { pattern: "^(?:[0-7]{1,2}|[123][0-7]{2})(?:;(?:[0-7]{1,2}|[123][0-7]{2}))*$", flags: "", args: ["Semi-colon"], }, { pattern: "^(?:[0-7]{1,2}|[123][0-7]{2})(?::(?:[0-7]{1,2}|[123][0-7]{2}))*$", flags: "", args: ["Colon"], }, { pattern: "^(?:[0-7]{1,2}|[123][0-7]{2})(?:\\n(?:[0-7]{1,2}|[123][0-7]{2}))*$", flags: "", args: ["Line feed"], }, { pattern: "^(?:[0-7]{1,2}|[123][0-7]{2})(?:\\r\\n(?:[0-7]{1,2}|[123][0-7]{2}))*$", flags: "", args: ["CRLF"], }, ]; }
/** * FromOctal constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/FromOctal.tsx#L53-L108
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
FromOctal.run
run(input, args) { const delim = Utils.charRep(args[0] || "Space"); if (input.length === 0) return []; return input.split(delim).map((val) => parseInt(val, 8)); }
/** * @param {string} input * @param {Object[]} args * @returns {byteArray} */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/FromOctal.tsx#L115-L119
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
GenericCodeBeautify.constructor
constructor() { super(); // this.name = "Generic Code Beautify"; this.module = "Code"; // this.description = ; this.inputType = "string"; this.outputType = "string"; this.args = []; }
/** * GenericCodeBeautify constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/GenericCodeBeautify.tsx#L66-L78
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
GenericCodeBeautify.run
run(input, args) { const preservedTokens: any[] = []; let code = input, t = 0, m; // Remove strings const sstrings = /'([^'\\]|\\.)*'/g; while ((m = sstrings.exec(code))) { code = preserveToken(code, m, t++); sstrings.lastIndex = m.index; } const dstrings = /"([^"\\]|\\.)*"/g; while ((m = dstrings.exec(code))) { code = preserveToken(code, m, t++); dstrings.lastIndex = m.index; } // Remove comments const scomments = /\/\/[^\n\r]*/g; while ((m = scomments.exec(code))) { code = preserveToken(code, m, t++); scomments.lastIndex = m.index; } const mcomments = /\/\*[\s\S]*?\*\//gm; while ((m = mcomments.exec(code))) { code = preserveToken(code, m, t++); mcomments.lastIndex = m.index; } const hcomments = /(^|\n)#[^\n\r#]+/g; while ((m = hcomments.exec(code))) { code = preserveToken(code, m, t++); hcomments.lastIndex = m.index; } // Remove regexes const regexes = /\/.*?[^\\]\/[gim]{0,3}/gi; while ((m = regexes.exec(code))) { code = preserveToken(code, m, t++); regexes.lastIndex = m.index; } code = code // Create newlines after ; .replace(/;/g, ";\n") // Create newlines after { and around } .replace(/{/g, "{\n") .replace(/}/g, "\n}\n") // Remove carriage returns .replace(/\r/g, "") // Remove all indentation .replace(/^\s+/g, "") .replace(/\n\s+/g, "\n") // Remove trailing spaces .replace(/\s*$/g, "") .replace(/\n{/g, "{"); // Indent let i = 0, level = 0, indent; while (i < code.length) { switch (code[i]) { case "{": level++; break; case "\n": if (i + 1 >= code.length) break; if (code[i + 1] === "}") level--; indent = (level >= 0) ? Array(level * 4 + 1).join(" ") : ""; code = code.substring(0, i + 1) + indent + code.substring(i + 1); if (level > 0) i += level * 4; break; } i++; } code = code // Add strategic spaces .replace(/\s*([!<>=+-/*]?)=\s*/g, " $1= ") .replace(/\s*<([=]?)\s*/g, " <$1 ") .replace(/\s*>([=]?)\s*/g, " >$1 ") .replace(/([^+])\+([^+=])/g, "$1 + $2") .replace(/([^-])-([^-=])/g, "$1 - $2") .replace(/([^*])\*([^*=])/g, "$1 * $2") .replace(/([^/])\/([^/=])/g, "$1 / $2") .replace(/\s*,\s*/g, ", ") .replace(/\s*{/g, " {") .replace(/}\n/g, "}\n\n") // Hacky horribleness .replace(/(if|for|while|with|elif|elseif)\s*\(([^\n]*)\)\s*\n([^{])/gim, "$1 ($2)\n $3") .replace(/(if|for|while|with|elif|elseif)\s*\(([^\n]*)\)([^{])/gim, "$1 ($2) $3") .replace(/else\s*\n([^{])/gim, "else\n $1") .replace(/else\s+([^{])/gim, "else $1") // Remove strategic spaces .replace(/\s+;/g, ";") .replace(/\{\s+\}/g, "{}") .replace(/\[\s+\]/g, "[]") .replace(/}\s*(else|catch|except|finally|elif|elseif|else if)/gi, "} $1"); // Replace preserved tokens const ptokens = /###preservedToken(\d+)###/g; while ((m = ptokens.exec(code))) { const ti = parseInt(m[1], 10); code = code.substring(0, m.index) + preservedTokens[ti] + code.substring(m.index + m[0].length); ptokens.lastIndex = m.index; } return code; /** * Replaces a matched token with a placeholder value. */ function preserveToken(str, match, t) { preservedTokens[t] = match[0]; return str.substring(0, match.index) + "###preservedToken" + t + "###" + str.substring(match.index + match[0].length); } }
/** * @param {string} input * @param {Object[]} args * @returns {string} */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/GenericCodeBeautify.tsx#L85-L209
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
preserveToken
function preserveToken(str, match, t) { preservedTokens[t] = match[0]; return str.substring(0, match.index) + "###preservedToken" + t + "###" + str.substring(match.index + match[0].length); }
/** * Replaces a matched token with a placeholder value. */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/GenericCodeBeautify.tsx#L203-L208
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
GraphQLBeautify.constructor
constructor() { super(); this.module = "Code"; this.inputType = "string"; this.outputType = "string"; this.args = [ ]; }
/** * MarkdownBeautify constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/GraphQLBeautify.tsx#L48-L56
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
XMLBeautify.constructor
constructor() { super(); this.module = "Code"; this.inputType = "string"; this.outputType = "string"; this.args = [ { "name": Dot("isti", "Indent string"), "type": "binaryShortString", "value": "\\t" } ]; }
/** * XMLBeautify constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/HTMLBeautify.tsx#L60-L74
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
XMLBeautify.run
run(input, args) { const indentStr = args[0]; return vkbeautify.xml(input, indentStr); }
/** * @param {string} input * @param {Object[]} args * @returns {string} */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/HTMLBeautify.tsx#L81-L85
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
XMLMinify.constructor
constructor() { super(); this.module = "Code"; this.inputType = "string"; this.outputType = "string"; this.args = [ { name: "Preserve comments", type: "boolean", value: false, }, ]; }
/** * XMLMinify constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/HTMLMinify.tsx#L67-L81
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
XMLMinify.run
run(input, args) { const preserveComments = args[0]; return vkbeautify.xmlmin(input, preserveComments); }
/** * @param {string} input * @param {Object[]} args * @returns {string} */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/HTMLMinify.tsx#L88-L91
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
JSONBeautify.constructor
constructor() { super(); this.module = "Code"; this.inputType = "string"; this.outputType = "string"; this.presentType = "html"; this.args = [ { name: Dot("isti", "Indent string"), type: "binaryShortString", value: " " }, { name: Dot("NLXUGv5gF", "Sort Object Keys"), type: "boolean", value: false }, { name: Dot("7n9nxrgrr", "Formatted"), type: "boolean", value: true } ]; }
/** * JSONBeautify constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/JSONBeautify.tsx#L74-L98
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
JSONBeautify.run
run(input, args) { if (!input) return ""; const [indentStr, sortBool] = args; let json = null; try { json = JSON5.parse(input); } catch (err) { throw new OperationError("Unable to parse input as JSON.\n" + err); } if (sortBool) json = sortKeys(json); return JSON.stringify(json, null, indentStr); }
/** * @param {string} input * @param {Object[]} args * @returns {string} */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/JSONBeautify.tsx#L113-L128
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
JSONBeautify.present
present(data, args) { const formatted = args[2]; if (!formatted) return Utils.escapeHtml(data); const json = JSON5.parse(data); const options = { withLinks: true, bigNumbers: true }; let html = '<div class="json-document">'; if (isCollapsable(json)) { const isArr = json instanceof Array; html += '<details open class="json-details">' + `<summary class="json-summary ${isArr ? "json-arr" : "json-obj"}"></summary>` + json2html(json, options) + "</details>"; } else { html += json2html(json, options); } html += "</div>"; return html; }
/** * Adds various dynamic features to the JSON blob * * @param {string} data * @param {Object[]} args * @returns {html} */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/JSONBeautify.tsx#L137-L160
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
sortKeys
function sortKeys(o) { if (Array.isArray(o)) { return o.map(sortKeys); } else if ("[object Object]" === Object.prototype.toString.call(o)) { return Object.keys(o).sort().reduce(function (a, k) { a[k] = sortKeys(o[k]); return a; }, {}); } return o; }
/** * Sort keys in a JSON object * * @author Phillip Nordwall [phillip.nordwall@gmail.com] * @param {object} o * @returns {object} */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/JSONBeautify.tsx#L170-L180
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
isCollapsable
function isCollapsable(arg) { return arg instanceof Object && Object.keys(arg).length > 0; }
/** * Check if arg is either an array with at least 1 element, or a dict with at least 1 key * @returns {boolean} */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/JSONBeautify.tsx#L187-L189
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
isUrl
function isUrl(string) { const protocols = ["http", "https", "ftp", "ftps"]; for (let i = 0; i < protocols.length; i++) { if (string.startsWith(protocols[i] + "://")) { return true; } } return false; }
/** * Check if a string looks like a URL, based on protocol * @returns {boolean} */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/JSONBeautify.tsx#L195-L203
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
json2html
function json2html(json, options) { let html = ""; if (typeof json === "string") { // Escape tags and quotes json = Utils.escapeHtml(json); if (options.withLinks && isUrl(json)) { html += `<a href="${json}" class="json-string" target="_blank">${json}</a>`; } else { // Escape double quotes in the rendered non-URL string. json = json.replace(/&quot;/g, "\\&quot;"); html += `<span class="json-string">"${json}"</span>`; } } else if (typeof json === "number" || typeof json === "bigint") { html += `<span class="json-literal">${json}</span>`; } else if (typeof json === "boolean") { html += `<span class="json-literal">${json}</span>`; } else if (json === null) { html += '<span class="json-literal">null</span>'; } else if (json instanceof Array) { if (json.length > 0) { html += '<span class="json-bracket">[</span><ol class="json-array">'; for (let i = 0; i < json.length; i++) { html += "<li>"; // Add toggle button if item is collapsable if (isCollapsable(json[i])) { const isArr = json[i] instanceof Array; html += '<details open class="json-details">' + `<summary class="json-summary ${isArr ? "json-arr" : "json-obj"}"></summary>` + json2html(json[i], options) + "</details>"; } else { html += json2html(json[i], options); } // Add comma if item is not last if (i < json.length - 1) { html += '<span class="json-comma">,</span>'; } html += "</li>"; } html += '</ol><span class="json-bracket">]</span>'; } else { html += '<span class="json-bracket">[]</span>'; } } else if (typeof json === "object") { // Optional support different libraries for big numbers // json.isLosslessNumber: package lossless-json // json.toExponential(): packages bignumber.js, big.js, decimal.js, decimal.js-light, others? if (options.bigNumbers && (typeof json.toExponential === "function" || json.isLosslessNumber)) { html += `<span class="json-literal">${json.toString()}</span>`; } else { let keyCount = Object.keys(json).length; if (keyCount > 0) { html += '<span class="json-brace">{</span><ul class="json-dict">'; for (const key in json) { if (Object.prototype.hasOwnProperty.call(json, key)) { const safeKey = Utils.escapeHtml(key); html += "<li>"; // Add toggle button if item is collapsable if (isCollapsable(json[key])) { const isArr = json[key] instanceof Array; html += '<details open class="json-details">' + `<summary class="json-summary ${isArr ? "json-arr" : "json-obj"}">${safeKey}<span class="json-colon">:</span> </summary>` + json2html(json[key], options) + "</details>"; } else { html += safeKey + '<span class="json-colon">:</span> ' + json2html(json[key], options); } // Add comma if item is not last if (--keyCount > 0) { html += '<span class="json-comma">,</span>'; } html += "</li>"; } } html += '</ul><span class="json-brace">}</span>'; } else { html += '<span class="json-brace">{}</span>'; } } } return html; }
/** * Transform a json object into html representation * * Adapted for CyberChef by @n1474335 from jQuery json-viewer * @author Alexandre Bodelot <alexandre.bodelot@gmail.com> * @link https://github.com/abodelot/jquery.json-viewer * @license MIT * * @returns {string} */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/JSONBeautify.tsx#L215-L301
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
JSONEscape.constructor
constructor() { super(); this.name = Dot("N_9_M4KgI", "JSON Escape"); this.module = "Code"; this.inputType = "string"; this.outputType = "string"; this.args = []; }
/** * JSONMinify constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/JSONEscape.tsx#L51-L60
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
JSONEscape.run
run(input, args) { if (!input) return ""; return input.replace(/[\\"']/g, '\\$&').replace(/\u0000/g, '\\0'); }
/** * @param {string} input * @param {Object[]} args * @returns {string} */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/JSONEscape.tsx#L67-L70
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
JSONMinify.constructor
constructor() { super(); this.name = "JSON Minify"; this.module = "Code"; this.inputType = "string"; this.outputType = "string"; this.args = []; }
/** * JSONMinify constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/JSONMinify.tsx#L54-L63
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
JSONMinify.run
run(input, args) { if (!input) return ""; return vkbeautify.jsonmin(input); }
/** * @param {string} input * @param {Object[]} args * @returns {string} */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/JSONMinify.tsx#L70-L73
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
JSONToCSV.constructor
constructor() { super(); this.name = "JSON to CSV"; this.module = "Default"; this.inputType = "JSON"; this.outputType = "string"; this.args = [ { name: "Cell delimiter", type: "binaryShortString", value: ",", }, { name: "Row delimiter", type: "binaryShortString", value: "\\r\\n", }, ]; }
/** * JSONToCSV constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/JSONToCSV.tsx#L58-L77
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
JSONToCSV.toCSV
toCSV(force = false) { const self = this; // If the JSON is an array of arrays, this is easy if (this.flattened[0] instanceof Array) { return ( this.flattened .map((row) => row .map((d) => self.escapeCellContents(d, force)) .join(this.cellDelim), ) .join(this.rowDelim) + this.rowDelim ); } // If it's an array of dictionaries... const header = Object.keys(this.flattened[0]); return ( header .map((d) => self.escapeCellContents(d, force)) .join(this.cellDelim) + this.rowDelim + this.flattened .map((row) => header .map((h) => row[h]) .map((d) => self.escapeCellContents(d, force)) .join(this.cellDelim), ) .join(this.rowDelim) + this.rowDelim ); }
/** * Converts JSON to a CSV equivalent. * * @param {boolean} force - Whether to force conversion of data to fit in a cell * @returns {string} */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/JSONToCSV.tsx#L88-L120
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
JSONToCSV.run
run(input, args) { const [cellDelim, rowDelim] = args; // Record values so they don't have to be passed to other functions explicitly this.cellDelim = cellDelim; this.rowDelim = rowDelim; this.flattened = input; if (!(this.flattened instanceof Array)) { this.flattened = [input]; } try { return this.toCSV(); } catch (err) { try { this.flattened = flatten(input); if (!(this.flattened instanceof Array)) { this.flattened = [this.flattened]; } return this.toCSV(true); } catch (err: any) { throw new OperationError( "Unable to parse JSON to CSV: " + err.toString(), ); } } }
/** * @param {JSON} input * @param {Object[]} args * @returns {string} */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/JSONToCSV.tsx#L127-L153
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
JSONToCSV.escapeCellContents
escapeCellContents(data, force = false) { if (data !== "string") { const isPrimitive = data == null || typeof data !== "object"; if (isPrimitive) data = `${data}`; else if (force) data = JSON.stringify(data); } // Double quotes should be doubled up data = data.replace(/"/g, '""'); // If the cell contains a cell or row delimiter or a double quote, it must be enclosed in double quotes if ( data.indexOf(this.cellDelim) >= 0 || data.indexOf(this.rowDelim) >= 0 || data.indexOf("\n") >= 0 || data.indexOf("\r") >= 0 || data.indexOf('"') >= 0 ) { data = `"${data}"`; } return data; }
/** * Correctly escapes a cell's contents based on the cell and row delimiters. * * @param {string} data * @param {boolean} force - Whether to force conversion of data to fit in a cell * @returns {string} */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/JSONToCSV.tsx#L162-L184
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
JSONToXML.constructor
constructor() { super(); this.name = "JSON to XML"; this.module = "Default"; this.inputType = "JSON"; this.outputType = "string"; this.args = [ ]; }
/** * JSONToXML constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/JSONToXML.tsx#L46-L56
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
JSONToXML.run
run(input, args) { let val = xmlutils.json2xml.getStructXmlFromRawJson(input) return val }
/** * @param {JSON} input * @param {Object[]} args * @returns {string} */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/JSONToXML.tsx#L67-L70
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
JSONUnescape.constructor
constructor() { super(); this.name = Dot("N_9_dM4KgI", "JSON Escape"); this.module = "Code"; this.inputType = "string"; this.outputType = "string"; this.args = []; }
/** * JSONMinify constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/JSONUnescape.tsx#L46-L55
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
JSONUnescape.run
run(input, args) { if (!input) return ""; // write a function to unescape JSON str return input.replace(/\\./g, function (m) { switch (m[1]) { case '"': case "'": case "\\": return m[1]; case "b": return "\b"; case "f": return "\f"; case "n": return "\n"; case "r": return "\r"; case "t": return "\t"; case "u": return String.fromCharCode(parseInt(m.substr(2, 4), 16)); default: return m; } }); }
/** * @param {string} input * @param {Object[]} args * @returns {string} */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/JSONUnescape.tsx#L62-L87
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
JavaScriptBeautify.constructor
constructor() { super(); this.name = "JavaScript Beautify"; this.module = "Code"; this.inputType = "string"; this.outputType = "string"; this.args = [ { "name": Dot("isti", "Indent string"), "type": "binaryShortString", "value": "\\t" }, { "name": "Quotes", "type": "option", "value": ["Auto", "Single", "Double"] }, { "name": "Semicolons before closing braces", "type": "boolean", "value": true }, { "name": "Include comments", "type": "boolean", "value": true } ]; }
/** * JavaScriptBeautify constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/JavaScriptBeautify.tsx#L81-L112
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
JavaScriptBeautify.run
run(input, args) { console.log('args', args) const beautifyIndent = args[0] || "\\t", quotes = args[1].toLowerCase(), [, , beautifySemicolons, beautifyComment] = args; let result = "", AST; try { AST = esprima.parseScript(input, { range: true, tokens: true, comment: true }); const options = { format: { indent: { style: beautifyIndent }, quotes: quotes, semicolons: beautifySemicolons, }, comment: beautifyComment }; if (options.comment) AST = escodegen.attachComments(AST, AST.comments, AST.tokens); result = escodegen.generate(AST, options); } catch (e: any) { // Leave original error so the user can see the detail throw new OperationError("Unable to parse JavaScript.<br>" + e.message); } return result; }
/** * @param {string} input * @param {Object[]} args * @returns {string} */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/JavaScriptBeautify.tsx#L119-L154
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
JavaScriptMinify.constructor
constructor() { super(); this.name = "JavaScript Minify"; this.module = "Code"; this.inputType = "string"; this.outputType = "string"; this.args = []; }
/** * JavaScriptMinify constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/JavaScriptMinify.tsx#L54-L64
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
JavaScriptMinify.run
async run(input, args) { const result = await terser.minify(input); if (result["error"]) { throw new OperationError(`Error minifying JavaScript. (${result["error"]})`); } return result.code; }
/** * @param {string} input * @param {Object[]} args * @returns {string} */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/JavaScriptMinify.tsx#L71-L77
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
LessBeautify.constructor
constructor() { super(); this.module = "Code"; this.inputType = "string"; this.outputType = "string"; this.args = [ ]; }
/** * MarkdownBeautify constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/LessBeautify.tsx#L48-L56
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
MD2.constructor
constructor() { super(); this.name = "MD2"; this.module = "Crypto"; this.inputType = "ArrayBuffer"; this.outputType = "string"; this.args = [ { name: "Rounds", type: "number", value: 18, min: 0, }, ]; }
/** * MD2 constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/MD2.tsx#L59-L76
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
MD2.run
run(input, args) { return runHash("md2", input, { rounds: args[0] }); }
/** * @param {ArrayBuffer} input * @param {Object[]} args * @returns {string} */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/MD2.tsx#L83-L85
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
MD4.constructor
constructor() { super(); this.name = "MD4"; this.module = "Crypto"; this.inputType = "ArrayBuffer"; this.outputType = "string"; this.args = []; }
/** * MD4 constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/MD4.tsx#L51-L60
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
MD4.run
run(input, args) { return runHash("md4", input); }
/** * @param {ArrayBuffer} input * @param {Object[]} args * @returns {string} */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/MD4.tsx#L67-L69
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
MD5.constructor
constructor() { super(); this.name = "MD5"; this.module = "Crypto"; // this.infoURL = ""; this.inputType = "ArrayBuffer"; this.outputType = "string"; this.args = []; }
/** * MD5 constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/MD5.tsx#L51-L61
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
MD5.run
run(input, args) { return runHash("md5", input); }
/** * @param {ArrayBuffer} input * @param {Object[]} args * @returns {string} */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/MD5.tsx#L68-L70
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
MD6.constructor
constructor() { super(); this.name = "MD6"; this.module = "Crypto"; this.inputType = "string"; this.outputType = "string"; this.args = [ { name: "Size", type: "number", value: 256, }, { name: "Levels", type: "number", value: 64, }, { name: "Key", type: "string", value: "", }, ]; }
/** * MD6 constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/MD6.tsx#L68-L92
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
MD6.run
run(input, args) { const [size, levels, key] = args; if (size < 0 || size > 512) throw new OperationError(Dot("CFg8B", "Size must be between 0 and 512")); if (levels < 0) throw new OperationError(Dot("DqFI5", "Levels must be greater than 0")); return NodeMD6.getHashOfText(input, size, key, levels); }
/** * @param {string} input * @param {Object[]} args * @returns {string} */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/MD6.tsx#L99-L108
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
MarkdownBeautify.constructor
constructor() { super(); this.module = "Code"; this.inputType = "string"; this.outputType = "string"; this.args = [ // { // "name": Dot("isti", "Indent string"), // "type": "binaryShortString", // "value": "\\t" // } ]; }
/** * MarkdownBeautify constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/MarkdownBeautify.tsx#L54-L67
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
RemoveLineNumbers.constructor
constructor() { super(); this.module = "Default"; this.inputType = "string"; this.outputType = "string"; this.args = []; }
/** * RemoveLineNumbers constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/RemoveLineNumbers.tsx#L45-L52
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
RemoveLineNumbers.run
run(input, args) { return input.replace(/^[ \t]{0,5}\d+[\s:|\-,.)\]]/gm, ""); }
/** * @param {string} input * @param {Object[]} args * @returns {string} */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/RemoveLineNumbers.tsx#L59-L61
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
RemoveWhitespace.constructor
constructor() { super(); this.module = "Default"; this.inputType = "string"; this.outputType = "string"; this.args = [ { name: "Spaces", type: "boolean", value: true, }, { name: "Carriage returns (\\r)", type: "boolean", value: true, }, { name: "Line feeds (\\n)", type: "boolean", value: true, }, { name: "Tabs", type: "boolean", value: true, }, { name: "Form feeds (\\f)", type: "boolean", value: true, }, { name: "Full stops", type: "boolean", value: false, }, ]; }
/** * RemoveWhitespace constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/RemoveWhitespace.tsx#L76-L114
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
RemoveWhitespace.run
run(input, args) { const [ removeSpaces, removeCarriageReturns, removeLineFeeds, removeTabs, removeFormFeeds, removeFullStops, ] = args; let data = input; if (removeSpaces) data = data.replace(/ /g, ""); if (removeCarriageReturns) data = data.replace(/\r/g, ""); if (removeLineFeeds) data = data.replace(/\n/g, ""); if (removeTabs) data = data.replace(/\t/g, ""); if (removeFormFeeds) data = data.replace(/\f/g, ""); if (removeFullStops) data = data.replace(/\./g, ""); return data; }
/** * @param {string} input * @param {Object[]} args * @returns {string} */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/RemoveWhitespace.tsx#L121-L139
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
Reverse.constructor
constructor() { super(); this.module = "Default"; this.inputType = "byteArray"; this.outputType = "byteArray"; this.args = [ { name: "By", type: "option", value: ["Byte", "Character", "Line"], defaultIndex: 1, }, ]; }
/** * Reverse constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/Reverse.tsx#L58-L72
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
Reverse.run
run(input, args) { let i; if (args[0] === "Line") { const lines: any = []; let line: any = [], result: any = []; for (i = 0; i < input.length; i++) { if (input[i] === 0x0a) { lines.push(line); line = []; } else { line.push(input[i]); } } lines.push(line); lines.reverse(); for (i = 0; i < lines.length; i++) { result = result.concat(lines[i]); result.push(0x0a); } return result.slice(0, input.length); } else if (args[0] === "Character") { const inputString = Utils.byteArrayToUtf8(input); let result = ""; for (let i = inputString.length - 1; i >= 0; i--) { const c = inputString.charCodeAt(i); if (i > 0 && 0xdc00 <= c && c <= 0xdfff) { const c2 = inputString.charCodeAt(i - 1); if (0xd800 <= c2 && c2 <= 0xdbff) { // surrogates result += inputString.charAt(i - 1); result += inputString.charAt(i); i--; continue; } } result += inputString.charAt(i); } return Utils.strToUtf8ByteArray(result); } else { return input.reverse(); } }
/** * @param {byteArray} input * @param {Object[]} args * @returns {byteArray} */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/Reverse.tsx#L79-L121
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
SCSSBeautify.constructor
constructor() { super(); this.module = "Code"; this.inputType = "string"; this.outputType = "string"; this.args = [ ]; }
/** * MarkdownBeautify constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/SCSSBeautify.tsx#L48-L56
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
SHA0.constructor
constructor() { super(); this.module = "Crypto"; this.inputType = "ArrayBuffer"; this.outputType = "string"; this.args = [ { name: "Rounds", type: "number", value: 80, min: 16, }, ]; }
/** * SHA0 constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/SHA0.tsx#L54-L68
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
SHA0.run
run(input, args) { return runHash("sha0", input, { rounds: args[0] }); }
/** * @param {ArrayBuffer} input * @param {Object[]} args * @returns {string} */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/SHA0.tsx#L75-L77
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
SHA1.constructor
constructor() { super(); this.module = "Crypto"; this.inputType = "ArrayBuffer"; this.outputType = "string"; this.args = [ { name: "Rounds", type: "number", value: 80, min: 16, }, ]; }
/** * SHA1 constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/SHA1.tsx#L55-L69
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
SHA1.run
run(input, args) { return runHash("sha1", input, { rounds: args[0] }); }
/** * @param {ArrayBuffer} input * @param {Object[]} args * @returns {string} */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/SHA1.tsx#L76-L78
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
SHA2.constructor
constructor() { super(); this.module = "Crypto"; this.inputType = "ArrayBuffer"; this.outputType = "string"; this.args = [ { name: "Size", type: "argSelector", value: [ { name: "512", on: [2], off: [1], }, { name: "384", on: [2], off: [1], }, { name: "256", on: [1], off: [2], }, { name: "224", on: [1], off: [2], }, { name: "512/256", on: [2], off: [1], }, { name: "512/224", on: [2], off: [1], }, ], }, { name: "Rounds", // For SHA256 variants type: "number", value: 64, min: 16, }, { name: "Rounds", // For SHA512 variants type: "number", value: 160, min: 32, }, ]; }
/** * SHA2 constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/SHA2.tsx#L122-L178
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
SHA2.run
run(input, args) { const size = args[0]; const rounds = size === "256" || size === "224" ? args[1] : args[2]; return runHash("sha" + size, input, { rounds: rounds }); }
/** * @param {ArrayBuffer} input * @param {Object[]} args * @returns {string} */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/SHA2.tsx#L185-L189
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
SHA3.constructor
constructor() { super(); this.name = "SHA384"; this.module = "Crypto"; this.inputType = "ArrayBuffer"; this.outputType = "string"; this.args = [ { name: "Size", type: "option", value: ["256"], }, ]; }
/** * SHA3 constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/SHA224.tsx#L58-L72
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
SHA3.run
run(input, args) { const size = parseInt(args[0], 10); let algo; switch (size) { case 224: algo = JSSHA3.sha3_224; break; case 384: algo = JSSHA3.sha3_384; break; case 256: algo = JSSHA3.sha3_256; break; case 512: algo = JSSHA3.sha3_512; break; default: throw new OperationError("Invalid size"); } return algo(input); }
/** * @param {ArrayBuffer} input * @param {Object[]} args * @returns {string} */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/SHA224.tsx#L79-L101
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
SHA3.constructor
constructor() { super(); this.name = "SHA384"; this.module = "Crypto"; this.inputType = "ArrayBuffer"; this.outputType = "string"; this.args = [ { name: "Size", type: "option", value: ["256"], }, ]; }
/** * SHA3 constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/SHA256.tsx#L58-L72
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
SHA3.run
run(input, args) { const size = parseInt(args[0], 10); let algo; switch (size) { case 224: algo = JSSHA3.sha3_224; break; case 384: algo = JSSHA3.sha3_384; break; case 256: algo = JSSHA3.sha3_256; break; case 512: algo = JSSHA3.sha3_512; break; default: throw new OperationError("Invalid size"); } return algo(input); }
/** * @param {ArrayBuffer} input * @param {Object[]} args * @returns {string} */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/SHA256.tsx#L79-L101
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
SHA3.constructor
constructor() { super(); this.name = "SHA3"; this.module = "Crypto"; this.inputType = "ArrayBuffer"; this.outputType = "string"; this.args = [ { name: "Size", type: "option", value: ["512", "384", "256", "224"], }, ]; }
/** * SHA3 constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/SHA3.tsx#L60-L74
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
SHA3.run
run(input, args) { const size = parseInt(args[0], 10); let algo; switch (size) { case 224: algo = JSSHA3.sha3_224; break; case 384: algo = JSSHA3.sha3_384; break; case 256: algo = JSSHA3.sha3_256; break; case 512: algo = JSSHA3.sha3_512; break; default: throw new OperationError("Invalid size"); } return algo(input); }
/** * @param {ArrayBuffer} input * @param {Object[]} args * @returns {string} */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/SHA3.tsx#L81-L103
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
SHA3.constructor
constructor() { super(); this.name = "SHA384"; this.module = "Crypto"; this.inputType = "ArrayBuffer"; this.outputType = "string"; this.args = [ { name: "Size", type: "option", value: ["384"], }, ]; }
/** * SHA3 constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/SHA384.tsx#L58-L72
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
SHA3.run
run(input, args) { const size = parseInt(args[0], 10); let algo; switch (size) { case 224: algo = JSSHA3.sha3_224; break; case 384: algo = JSSHA3.sha3_384; break; case 256: algo = JSSHA3.sha3_256; break; case 512: algo = JSSHA3.sha3_512; break; default: throw new OperationError("Invalid size"); } return algo(input); }
/** * @param {ArrayBuffer} input * @param {Object[]} args * @returns {string} */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/SHA384.tsx#L79-L101
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
SHA3.constructor
constructor() { super(); this.name = "SHA512"; this.module = "Crypto"; this.inputType = "ArrayBuffer"; this.outputType = "string"; this.args = [ { name: "Size", type: "option", value: ["512"], }, ]; }
/** * SHA3 constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/SHA512.tsx#L58-L72
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
SHA3.run
run(input, args) { const size = parseInt(args[0], 10); let algo; switch (size) { case 224: algo = JSSHA3.sha3_224; break; case 384: algo = JSSHA3.sha3_384; break; case 256: algo = JSSHA3.sha3_256; break; case 512: algo = JSSHA3.sha3_512; break; default: throw new OperationError("Invalid size"); } return algo(input); }
/** * @param {ArrayBuffer} input * @param {Object[]} args * @returns {string} */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/SHA512.tsx#L79-L101
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
SQLBeautify.constructor
constructor() { super(); this.module = "Code"; // this.description =; this.inputType = "string"; this.outputType = "string"; this.args = [ { "name": Dot("isti", "Indent string"), "type": "binaryShortString", "value": "\\t" } ]; }
/** * SQLBeautify constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/SQLBeautify.tsx#L62-L77
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
SQLBeautify.run
run(input, args) { const indentStr = args[0]; return vkbeautify.sql(input, indentStr); }
/** * @param {string} input * @param {Object[]} args * @returns {string} */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/SQLBeautify.tsx#L84-L87
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
SQLMinify.constructor
constructor() { super(); this.name = "SQL Minify"; this.module = "Code"; this.inputType = "string"; this.outputType = "string"; this.args = []; }
/** * SQLMinify constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/SQLMinify.tsx#L53-L63
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
SQLMinify.run
run(input, args) { return vkbeautify.sqlmin(input); }
/** * @param {string} input * @param {Object[]} args * @returns {string} */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/SQLMinify.tsx#L70-L72
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
Tail.constructor
constructor() { super(); this.name = "Tail"; this.module = "Default"; this.inputType = "string"; this.outputType = "string"; this.args = [ { name: "Delimiter", type: "option", value: INPUT_DELIM_OPTIONS, }, { name: "Number", type: "number", value: 10, }, ]; }
/** * Tail constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/Tail.tsx#L66-L85
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
Tail.run
run(input, args) { let delimiter = args[0]; const number = args[1]; delimiter = Utils.charRep(delimiter); const splitInput = input.split(delimiter); return splitInput .filter((line, lineIndex) => { lineIndex += 1; if (number < 0) { return lineIndex > -number; } else { return lineIndex > splitInput.length - number; } }) .join(delimiter); }
/** * @param {string} input * @param {Object[]} args * @returns {string} */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/Tail.tsx#L92-L110
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
ToBCD.constructor
constructor() { super(); this.module = "Default"; this.inputType = "BigNumber"; this.outputType = "string"; this.args = [ { name: "Scheme", type: "option", value: ENCODING_SCHEME, }, { name: "Packed", type: "boolean", value: true, }, { name: "Signed", type: "boolean", value: false, }, { name: "Output format", type: "option", value: FORMAT, }, ]; }
/** * ToBCD constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/ToBCD.tsx#L86-L116
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
ToBCD.run
run(input, args) { if (input.isNaN()) throw new OperationError("Invalid input"); if (!input.integerValue(BigNumber.ROUND_DOWN).isEqualTo(input)) throw new OperationError("Fractional values are not supported by BCD"); const encoding: any = ENCODING_LOOKUP[args[0]], packed = args[1], signed = args[2], outputFormat = args[3]; // Split input number up into separate digits const digits = input.toFixed().split(""); if (digits[0] === "-" || digits[0] === "+") { digits.shift(); } let nibbles: any = []; digits.forEach((d) => { const n = parseInt(d, 10); nibbles.push(encoding[n]); }); if (signed) { if (packed && digits.length % 2 === 0) { // If there are an even number of digits, we add a leading 0 so // that the sign nibble doesn't sit in its own byte, leading to // ambiguity around whether the number ends with a 0 or not. nibbles.unshift(encoding[0]); } nibbles.push(input > 0 ? 12 : 13); // 12 ("C") for + (credit) // 13 ("D") for - (debit) } let bytes: any = []; if (packed) { let encoded = 0, little = false; nibbles.forEach((n) => { encoded ^= little ? n : n << 4; if (little) { bytes.push(encoded); encoded = 0; } little = !little; }); if (little) bytes.push(encoded); } else { bytes = nibbles; // Add null high nibbles nibbles = nibbles .map((n) => { return [0, n]; }) .reduce((a, b) => { return a.concat(b); }); } // Output switch (outputFormat) { case "Nibbles": return nibbles .map((n) => { return n.toString(2).padStart(4, "0"); }) .join(" "); case "Bytes": return bytes .map((b) => { return b.toString(2).padStart(8, "0"); }) .join(" "); case "Raw": default: return Utils.byteArrayToChars(bytes); } }
/** * @param {BigNumber} input * @param {Object[]} args * @returns {string} */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/ToBCD.tsx#L123-L207
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
ToBase32.constructor
constructor() { super(); this.module = "Default"; this.inputType = "ArrayBuffer"; this.outputType = "string"; this.args = [ { name: Dot("skq3i12", "Alphabet"), type: "binaryString", value: "A-Z2-7=" } ]; }
/** * ToBase32 constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/ToBase32.tsx#L60-L73
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
ToBase32.run
run(input, args) { if (!input) return ""; input = new Uint8Array(input); const alphabet = args[0] ? Utils.expandAlphRange(args[0]).join("") : "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567="; let output = "", chr1, chr2, chr3, chr4, chr5, enc1, enc2, enc3, enc4, enc5, enc6, enc7, enc8, i = 0; while (i < input.length) { chr1 = input[i++]; chr2 = input[i++]; chr3 = input[i++]; chr4 = input[i++]; chr5 = input[i++]; enc1 = chr1 >> 3; enc2 = ((chr1 & 7) << 2) | (chr2 >> 6); enc3 = (chr2 >> 1) & 31; enc4 = ((chr2 & 1) << 4) | (chr3 >> 4); enc5 = ((chr3 & 15) << 1) | (chr4 >> 7); enc6 = (chr4 >> 2) & 31; enc7 = ((chr4 & 3) << 3) | (chr5 >> 5); enc8 = chr5 & 31; if (isNaN(chr2)) { enc3 = enc4 = enc5 = enc6 = enc7 = enc8 = 32; } else if (isNaN(chr3)) { enc5 = enc6 = enc7 = enc8 = 32; } else if (isNaN(chr4)) { enc6 = enc7 = enc8 = 32; } else if (isNaN(chr5)) { enc8 = 32; } output += alphabet.charAt(enc1) + alphabet.charAt(enc2) + alphabet.charAt(enc3) + alphabet.charAt(enc4) + alphabet.charAt(enc5) + alphabet.charAt(enc6) + alphabet.charAt(enc7) + alphabet.charAt(enc8); } return output; }
/** * @param {ArrayBuffer} input * @param {Object[]} args * @returns {string} */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/ToBase32.tsx#L80-L122
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
ToBase45.constructor
constructor() { super(); this.module = "Default"; this.inputType = "ArrayBuffer"; this.outputType = "string"; this.args = [ { name: Dot("skq3i12", "Alphabet"), type: "string", value: ALPHABET } ]; this.highlight = highlightToBase45; this.highlightReverse = highlightFromBase45; }
/** * ToBase45 constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/ToBase45.tsx#L61-L77
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
ToBase45.run
run(input, args) { if (!input) return ""; input = new Uint8Array(input); const alphabet: any[] = Utils.expandAlphRange(args[0]); const res: any[] = []; for (const pair of Utils.chunked(input, 2)) { let b = 0; for (const e of pair) { b *= 256; b += e; } let chars = 0; do { res.push(alphabet[b % 45]); chars++; b = Math.floor(b / 45); } while (b > 0); if (chars < 2) { res.push("0"); chars++; } if (pair.length > 1 && chars < 3) { res.push("0"); } } return res.join(""); }
/** * @param {ArrayBuffer} input * @param {Object[]} args * @returns {string} */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/ToBase45.tsx#L84-L117
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
ToBase58.constructor
constructor() { super(); this.module = "Default"; this.inputType = "ArrayBuffer"; this.outputType = "string"; this.args = [ { "name": Dot("anosdk", "Alphabet"), "type": "editableOption", "value": ALPHABET_OPTIONS } ]; }
/** * ToBase58 constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/ToBase58.tsx#L70-L85
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
ToBase58.run
run(input, args) { input = new Uint8Array(input); let alphabet = args[0] || ALPHABET_OPTIONS[0].value, result: any = [0]; alphabet = Utils.expandAlphRange(alphabet).join(""); if (alphabet.length !== 58 || ([] as any).unique.call(alphabet).length !== 58) { throw new OperationError("Error: alphabet must be of length 58"); } if (input.length === 0) return ""; let zeroPrefix = 0; for (let i = 0; i < input.length && input[i] === 0; i++) { zeroPrefix++; } input.forEach(function (b) { let carry = (result[0] << 8) + b; result[0] = carry % 58; carry = (carry / 58) | 0; for (let i = 1; i < result.length; i++) { carry += result[i] << 8; result[i] = carry % 58; carry = (carry / 58) | 0; } while (carry > 0) { result.push(carry % 58); carry = (carry / 58) | 0; } }); result = result.map(function (b) { return alphabet[b]; }).reverse().join(""); while (zeroPrefix--) { result = alphabet[0] + result; } return result; }
/** * @param {ArrayBuffer} input * @param {Object[]} args * @returns {string} */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/ToBase58.tsx#L92-L137
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
ToBase62.constructor
constructor() { super(); this.module = "Default"; this.inputType = "ArrayBuffer"; this.outputType = "string"; this.args = [ { name: Dot("skq3i12", "Alphabet"), type: "string", value: "0-9A-Za-z" } ]; }
/** * ToBase62 constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/ToBase62.tsx#L62-L79
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
ToBase62.run
run(input, args) { input = new Uint8Array(input); if (input.length < 1) return ""; const alphabet = Utils.expandAlphRange(args[0]).join(""); const BN62 = BigNumber.clone({ ALPHABET: alphabet }); input = toHexFast(input).toUpperCase(); // Read number in as hex using normal alphabet const normalized = new BigNumber(input, 16); // Copy to BigNumber clone that uses the specified Base62 alphabet const number = new BN62(normalized); return number.toString(62); }
/** * @param {ArrayBuffer} input * @param {Object[]} args * @returns {string} */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/ToBase62.tsx#L86-L101
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
ToBase64.constructor
constructor() { super(); this.module = "Default"; this.inputType = "ArrayBuffer"; this.outputType = "string"; this.args = [ { name: Dot("skq3i12", "Alphabet"), type: "editableOption", value: ALPHABET_OPTIONS, }, ]; }
/** * ToBase64 constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/ToBase64.tsx#L126-L139
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
ToBase64.run
run(input, args) { const alphabet = args[0]; return toBase64(input, alphabet); }
/** * @param {ArrayBuffer} input * @param {Object[]} args * @returns {string} */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/ToBase64.tsx#L146-L149
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
ToBase64.highlight
highlight(pos, args) { pos[0].start = Math.floor((pos[0].start / 3) * 4); pos[0].end = Math.ceil((pos[0].end / 3) * 4); return pos; }
/** * Highlight to Base64 * * @param {Object[]} pos * @param {number} pos[].start * @param {number} pos[].end * @param {Object[]} args * @returns {Object[]} pos */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/ToBase64.tsx#L160-L164
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
ToBase64.highlightReverse
highlightReverse(pos, args) { pos[0].start = Math.ceil((pos[0].start / 4) * 3); pos[0].end = Math.floor((pos[0].end / 4) * 3); return pos; }
/** * Highlight from Base64 * * @param {Object[]} pos * @param {number} pos[].start * @param {number} pos[].end * @param {Object[]} args * @returns {Object[]} pos */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/ToBase64.tsx#L175-L179
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
ToBase85.constructor
constructor() { super(); this.module = "Default"; this.inputType = "ArrayBuffer"; this.outputType = "string"; this.args = [ { name: Dot("skq3i12", "Alphabet"), type: "editableOption", value: ALPHABET_OPTIONS }, { name: "Include delimeter", type: "boolean", value: false } ]; }
/** * To Base85 constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/ToBase85.tsx#L79-L99
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
ToBase85.run
run(input, args) { input = new Uint8Array(input); const alphabet = Utils.expandAlphRange(args[0]).join(""), encoding = alphabetName(alphabet), includeDelim = args[1]; let result = ""; if (alphabet.length !== 85 || ([] as any).unique.call(alphabet).length !== 85) { throw new OperationError("Error: Alphabet must be of length 85"); } if (input.length === 0) return ""; let block: number; for (let i = 0; i < input.length; i += 4) { block = ( ((input[i]) << 24) + ((input[i + 1] || 0) << 16) + ((input[i + 2] || 0) << 8) + ((input[i + 3] || 0)) ) >>> 0; if (encoding !== "Standard" || block > 0) { let digits: any = []; for (let j = 0; j < 5; j++) { digits.push((block as any) % 85); block = Math.floor(block / 85); } digits = digits.reverse(); if (input.length < i + 4) { digits.splice(input.length - (i + 4), 4); } result += digits.map(digit => alphabet[digit]).join(""); } else { result += (encoding === "Standard") ? "z" : null; } } return includeDelim ? `<~${result}~>` : result; }
/** * @param {ArrayBuffer} input * @param {Object[]} args * @returns {string} */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/ToBase85.tsx#L106-L149
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
ToBinary.constructor
constructor() { super(); this.name = "To Binary"; this.module = "Default"; // this.description = // "Displays the input data as a binary string.<br><br>e.g. <code>Hi</code> becomes <code>01001000 01101001</code>"; // this.infoURL = "https://wikipedia.org/wiki/Binary_code"; this.inputType = "ArrayBuffer"; this.outputType = "string"; this.args = [ { name: "Delimiter", type: "option", value: BIN_DELIM_OPTIONS, }, { name: "Byte Length", type: "number", value: 8, }, ]; }
/** * ToBinary constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/ToBinary.tsx#L59-L81
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
ToBinary.run
run(input, args) { input = new Uint8Array(input); const padding = args[1] ? args[1] : 8; return toBinary(input, args[0], padding); }
/** * @param {ArrayBuffer} input * @param {Object[]} args * @returns {string} */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/ToBinary.tsx#L88-L92
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
ToBinary.highlight
highlight(pos, args) { const delim = Utils.charRep(args[0] || "Space"); pos[0].start = pos[0].start * (8 + delim.length); pos[0].end = pos[0].end * (8 + delim.length) - delim.length; return pos; }
/** * Highlight To Binary * * @param {Object[]} pos * @param {number} pos[].start * @param {number} pos[].end * @param {Object[]} args * @returns {Object[]} pos */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/ToBinary.tsx#L103-L108
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a