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
ToBinary.highlightReverse
highlightReverse(pos, args) { const delim = Utils.charRep(args[0] || "Space"); pos[0].start = pos[0].start === 0 ? 0 : Math.floor(pos[0].start / (8 + delim.length)); pos[0].end = pos[0].end === 0 ? 0 : Math.ceil(pos[0].end / (8 + delim.length)); return pos; }
/** * Highlight To Binary 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/ToBinary.tsx#L119-L126
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
ToCamelCase.constructor
constructor() { super(); this.name = "To Camel case"; this.module = "Code"; // this.description = // "Converts the input string to camel case.\n<br><br>\nCamel case is all lower case except letters after word boundaries which are uppercase.\n<br><br>\ne.g. thisIsCamelCase\n<br><br>\n'Attempt to be context aware' will make the operation attempt to nicely transform variable and function names."; // this.infoURL = "https://wikipedia.org/wiki/Camel_case"; this.inputType = "string"; this.outputType = "string"; this.args = [ { name: "Attempt to be context aware", type: "boolean", value: false, }, ]; }
/** * ToCamelCase constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/ToCamelCase.tsx#L52-L69
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
ToCamelCase.run
run(input, args) { const smart = args[0]; if (smart) { return replaceVariableNames(input, camelCase); } else { return camelCase(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/ToCamelCase.tsx#L76-L84
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
ToCharcode.constructor
constructor() { super(); this.name = "To Charcode"; this.module = "Default"; // this.description = // "Converts text to its unicode character code equivalent.<br><br>e.g. <code>Γειά σου</code> becomes <code>0393 03b5 03b9 03ac 20 03c3 03bf 03c5</code>"; // this.infoURL = "https://wikipedia.org/wiki/Plane_(Unicode)"; this.inputType = "string"; this.outputType = "string"; this.args = [ { name: "Delimiter", type: "option", value: DELIM_OPTIONS, }, { name: "Base", type: "number", value: 16, }, ]; }
/** * ToCharcode constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/ToCharcode.tsx#L64-L86
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
ToCharcode.run
run(input, args) { const delim = Utils.charRep(args[0] || "Space"), base = args[1]; let output = "", padding, ordinal; if (base < 2 || base > 36) { throw new OperationError("Error: Base argument must be between 2 and 36"); } const charcode = Utils.strToCharcode(input); for (let i = 0; i < charcode.length; i++) { ordinal = charcode[i]; if (base === 16) { if (ordinal < 256) padding = 2; else if (ordinal < 65536) padding = 4; else if (ordinal < 16777216) padding = 6; else if (ordinal < 4294967296) padding = 8; else padding = 2; // TODO: Fix this // if (padding > 2 && isWorkerEnvironment()) // self.setOption("attemptHighlight", false); output += Utils.hex(ordinal, padding) + delim; } else { // if (isWorkerEnvironment()) self.setOption("attemptHighlight", false); output += ordinal.toString(base) + delim; } } return output.slice(0, -delim.length); }
/** * @param {string} input * @param {Object[]} args * @returns {string} * * @throws {OperationError} if base argument out of range */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/ToCharcode.tsx#L95-L129
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
ToDecimal.constructor
constructor() { super(); this.name = "To Decimal"; this.module = "Default"; // this.description = // "Converts the input data to an ordinal integer array.<br><br>e.g. <code>Hello</code> becomes <code>72 101 108 108 111</code>"; this.inputType = "ArrayBuffer"; this.outputType = "string"; this.args = [ { name: "Delimiter", type: "option", value: DELIM_OPTIONS, }, { name: "Support signed values", type: "boolean", value: false, }, ]; }
/** * ToDecimal constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/ToDecimal.tsx#L56-L77
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
ToDecimal.run
run(input, args) { input = new Uint8Array(input); const delim = Utils.charRep(args[0]), signed = args[1]; if (signed) { input = input.map((v) => (v > 0x7f ? v - 0xff - 1 : v)); } return input.join(delim); }
/** * @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/ToDecimal.tsx#L84-L92
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
ToHTMLEntity.constructor
constructor() { super(); this.name = "To HTML Entity"; this.module = "Encodings"; // this.description = // "Converts characters to HTML entities<br><br>e.g. <code>&amp;</code> becomes <code>&amp;<span>amp;</span></code>"; // this.infoURL = // "https://wikipedia.org/wiki/List_of_XML_and_HTML_character_entity_references"; this.inputType = "string"; this.outputType = "string"; this.args = [ { name: Dot("tpjs2gJDt", "Convert all characters"), type: "boolean", value: false, }, { name: Dot("Kd4QkQG2F", "Convert to"), type: "option", value: ["Named entities", "Numeric entities", "Hex entities"], }, ]; }
/** * ToHTMLEntity constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/ToHTMLEntity.tsx#L60-L83
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
ToHTMLEntity.run
run(input, args) { const convertAll = args[0], numeric = args[1] === "Numeric entities", hexa = args[1] === "Hex entities"; const charcodes = Utils.strToCharcode(input); let output = ""; for (let i = 0; i < charcodes.length; i++) { if (convertAll && numeric) { output += "&#" + charcodes[i] + ";"; } else if (convertAll && hexa) { output += "&#x" + Utils.hex(charcodes[i]) + ";"; } else if (convertAll) { output += byteToEntity[charcodes[i]] || "&#" + charcodes[i] + ";"; } else if (numeric) { if (charcodes[i] > 255 || charcodes[i] in byteToEntity) { output += "&#" + charcodes[i] + ";"; } else { output += Utils.chr(charcodes[i]); } } else if (hexa) { if (charcodes[i] > 255 || charcodes[i] in byteToEntity) { output += "&#x" + Utils.hex(charcodes[i]) + ";"; } else { output += Utils.chr(charcodes[i]); } } else { output += byteToEntity[charcodes[i]] || (charcodes[i] > 255 ? "&#" + charcodes[i] + ";" : Utils.chr(charcodes[i])); } } return output; }
/** * @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/ToHTMLEntity.tsx#L90-L126
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
ToHex.constructor
constructor() { super(); this.module = "Default"; this.inputType = "ArrayBuffer"; this.outputType = "string"; this.args = [ { name: "Delimiter", type: "option", value: TO_HEX_DELIM_OPTIONS, }, { name: "Bytes per line", type: "number", value: 0, }, ]; }
/** * ToHex constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/ToHex.tsx#L75-L93
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
ToHex.run
run(input, args) { let delim, comma; if (args[0] === "0x with comma") { delim = "0x"; comma = ","; } else { delim = Utils.charRep(args[0] || "Space"); } const lineSize = args[1]; return toHex(new Uint8Array(input), delim, 2, comma, lineSize); }
/** * @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/ToHex.tsx#L100-L111
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
ToHex.highlight
highlight(pos, args) { let delim, commaLen = 0; if (args[0] === "0x with comma") { delim = "0x"; commaLen = 1; } else { delim = Utils.charRep(args[0] || "Space"); } const lineSize: any = args[1], len = delim.length + commaLen; const countLF = function (p: number) { // Count the number of LFs from 0 upto p return ((p / lineSize) | 0) - (p as any >= lineSize as any && p % lineSize === 0); }; pos[0].start = pos[0].start * (2 + len) + countLF(pos[0].start); pos[0].end = pos[0].end * (2 + len) + countLF(pos[0].end); // if the delimiters are not prepended, trim the trailing delimiter if (!(delim === "0x" || delim === "\\x")) { pos[0].end -= delim.length; } // if there is comma, trim the trailing comma pos[0].end -= commaLen; return pos; }
/** * Highlight to Hex * * @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/ToHex.tsx#L122-L150
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
ToHex.highlightReverse
highlightReverse(pos, args) { let delim, commaLen = 0; if (args[0] === "0x with comma") { delim = "0x"; commaLen = 1; } else { delim = Utils.charRep(args[0] || "Space"); } const lineSize = args[1], len = delim.length + commaLen, width = len + 2; const countLF = function (p) { // Count the number of LFs from 0 up to p const lineLength = width * lineSize; return ((p / lineLength) | 0) - (p >= lineLength as any && p % lineLength === 0); }; pos[0].start = pos[0].start === 0 ? 0 : Math.round((pos[0].start - countLF(pos[0].start)) / width); pos[0].end = pos[0].end === 0 ? 0 : Math.ceil((pos[0].end - countLF(pos[0].end)) / width); return pos; }
/** * Highlight from Hex * * @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/ToHex.tsx#L161-L190
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
ToHexdump.constructor
constructor() { super(); this.name = "To Hexdump"; this.module = "Default"; this.inputType = "ArrayBuffer"; this.outputType = "string"; this.args = [ { name: "Width", type: "number", value: 16, min: 1, }, { name: "Upper case hex", type: "boolean", value: false, }, { name: "Include final length", type: "boolean", value: false, }, { name: "UNIX format", type: "boolean", value: false, }, ]; }
/** * ToHexdump constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/ToHexdump.tsx#L70-L100
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
ToHexdump.run
run(input, args) { const data = new Uint8Array(input); const [length, upperCase, includeFinalLength, unixFormat] = args; const padding = 2; if (length < 1 || Math.round(length) !== length) throw new OperationError("Width must be a positive integer"); const lines: any[] = []; for (let i = 0; i < data.length; i += length) { let lineNo = Utils.hex(i, 8); const buff = data.slice(i, i + length); const hex: any[] = []; buff.forEach((b) => hex.push(Utils.hex(b, padding))); let hexStr = hex.join(" ").padEnd(length * (padding + 1), " "); const ascii = Utils.printable( Utils.byteArrayToChars(buff), false, unixFormat, ); const asciiStr = ascii.padEnd(buff.length, " "); if (upperCase) { hexStr = hexStr.toUpperCase(); lineNo = lineNo.toUpperCase(); } lines.push(`${lineNo} ${hexStr} |${asciiStr}|`); if (includeFinalLength && i + buff.length === data.length) { lines.push(Utils.hex(i + buff.length, 8)); } } return lines.join("\n"); }
/** * @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/ToHexdump.tsx#L107-L144
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
ToHexdump.highlight
highlight(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 To 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/ToHexdump.tsx#L155-L211
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
ToHexdump.highlightReverse
highlightReverse(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 To 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/ToHexdump.tsx#L222-L255
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
ToKebabCase.constructor
constructor() { super(); this.name = "To Kebab case"; this.module = "Code"; // this.description = // "Converts the input string to kebab case.\n<br><br>\nKebab case is all lower case with dashes as word boundaries.\n<br><br>\ne.g. this-is-kebab-case\n<br><br>\n'Attempt to be context aware' will make the operation attempt to nicely transform variable and function names."; // this.infoURL = "https://wikipedia.org/wiki/Kebab_case"; this.inputType = "string"; this.outputType = "string"; this.args = [ { name: Dot("GSgmYW7Qv", "Attempt to be context aware"), type: "boolean", value: false, }, ]; }
/** * ToKebabCase constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/ToKebabCase.tsx#L52-L69
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
ToKebabCase.run
run(input, args) { const smart = args[0]; if (smart) { return replaceVariableNames(input, kebabCase); } else { return kebabCase(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/ToKebabCase.tsx#L76-L84
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
ToLowerCase.constructor
constructor() { super(); this.name = "To Lower case"; this.module = "Default"; // this.description = "Converts every character in the input to lower case."; this.inputType = "string"; this.outputType = "string"; this.args = []; }
/** * ToLowerCase constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/ToLowerCase.tsx#L45-L54
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
ToLowerCase.run
run(input, args) { return input.toLowerCase(); }
/** * @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/ToLowerCase.tsx#L61-L63
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
ToLowerCase.highlight
highlight(pos, args) { return pos; }
/** * Highlight To Lower case * * @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/ToLowerCase.tsx#L74-L76
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
ToLowerCase.highlightReverse
highlightReverse(pos, args) { return pos; }
/** * Highlight To Lower case 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/ToLowerCase.tsx#L87-L89
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
ToMessagePack.constructor
constructor() { super(); this.name = "To MessagePack"; this.module = "Code"; // this.description = // "Converts JSON to MessagePack encoded byte buffer. 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 = "JSON"; this.outputType = "ArrayBuffer"; this.args = []; }
/** * ToMessagePack constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/ToMessagePack.tsx#L47-L58
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
ToMessagePack.run
run(input, args) { try { if (isWorkerEnvironment()) { return notepack.encode(input); } else { const res = notepack.encode(input); // Safely convert from Node Buffer to ArrayBuffer using the correct view of the data return new Uint8Array(res).buffer; } } catch (err) { throw new OperationError(`Could not encode JSON to MessagePack: ${err}`); } }
/** * @param {JSON} input * @param {Object[]} args * @returns {ArrayBuffer} */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/ToMessagePack.tsx#L65-L77
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
ToMorseCode.constructor
constructor() { super(); this.name = "To Morse Code"; this.module = "Default"; // this.description = // "Translates alphanumeric characters into International Morse Code.<br><br>Ignores non-Morse characters.<br><br>e.g. <code>SOS</code> becomes <code>... --- ...</code>"; // this.infoURL = "https://wikipedia.org/wiki/Morse_code"; this.inputType = "string"; this.outputType = "string"; this.args = [ { name: "Format options", type: "option", value: ["-/.", "_/.", "Dash/Dot", "DASH/DOT", "dash/dot"], }, { name: "Letter delimiter", type: "option", value: LETTER_DELIM_OPTIONS, }, { name: "Word delimiter", type: "option", value: WORD_DELIM_OPTIONS, }, ]; }
/** * ToMorseCode constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/ToMorseCode.tsx#L65-L92
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
ToMorseCode.run
run(input, args) { const format = args[0].split("/"); const dash = format[0]; const dot = format[1]; const letterDelim = Utils.charRep(args[1]); const wordDelim = Utils.charRep(args[2]); input = input.split(/\r?\n/); input = Array.prototype.map.call(input, function (line) { let words = line.split(/ +/); words = Array.prototype.map.call(words, function (word) { const letters = Array.prototype.map.call(word, function (character) { const letter = character.toUpperCase(); if (typeof MORSE_TABLE[letter] == "undefined") { return ""; } return MORSE_TABLE[letter]; }); return letters.join("<ld>"); }); line = words.join("<wd>"); return line; }); input = input.join("\n"); input = input.replace(/<dash>|<dot>|<ld>|<wd>/g, function (match) { switch (match) { case "<dash>": return dash; case "<dot>": return dot; case "<ld>": return letterDelim; case "<wd>": return wordDelim; } }); return 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/ToMorseCode.tsx#L99-L141
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
ToOctal.constructor
constructor() { super(); this.name = "To Octal"; this.module = "Default"; // this.description = // "Converts the input string to octal bytes separated by the specified delimiter.<br><br>e.g. The UTF-8 encoded string <code>Γειά σου</code> becomes <code>316 223 316 265 316 271 316 254 40 317 203 316 277 317 205</code>"; // this.infoURL = "https://wikipedia.org/wiki/Octal"; this.inputType = "byteArray"; this.outputType = "string"; this.args = [ { name: "Delimiter", type: "option", value: DELIM_OPTIONS, }, ]; }
/** * ToOctal constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/ToOctal.tsx#L52-L69
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
ToOctal.run
run(input, args) { const delim = Utils.charRep(args[0] || "Space"); return input.map((val) => val.toString(8)).join(delim); }
/** * @param {byteArray} input * @param {Object[]} args * @returns {string} */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/ToOctal.tsx#L76-L79
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
ToSnakeCase.constructor
constructor() { super(); this.name = "To Snake case"; this.module = "Code"; // this.description = // "Converts the input string to snake case.\n<br><br>\nSnake case is all lower case with underscores as word boundaries.\n<br><br>\ne.g. this_is_snake_case\n<br><br>\n'Attempt to be context aware' will make the operation attempt to nicely transform variable and function names."; // this.infoURL = "https://wikipedia.org/wiki/Snake_case"; this.inputType = "string"; this.outputType = "string"; this.args = [ { name: "Attempt to be context aware", type: "boolean", value: false, }, ]; }
/** * ToSnakeCase constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/ToSnakeCase.tsx#L52-L69
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
ToSnakeCase.run
run(input, args) { const smart = args[0]; if (smart) { return replaceVariableNames(input, snakeCase); } else { return snakeCase(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/ToSnakeCase.tsx#L76-L84
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
ToUpperCase.constructor
constructor() { super(); this.name = "To Upper case"; this.module = "Default"; // this.description = // "Converts the input string to upper case, optionally limiting scope to only the first character in each word, sentence or paragraph."; this.inputType = "string"; this.outputType = "string"; this.args = [ { name: "Scope", type: "option", value: ["All", "Word", "Sentence", "Paragraph"], }, ]; }
/** * ToUpperCase constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/ToUpperCase.tsx#L53-L69
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
ToUpperCase.run
run(input, args) { if (!args || args.length === 0) { throw new OperationError("No capitalization scope was provided."); } const scope = args[0]; if (scope === "All") { return input.toUpperCase(); } const scopeRegex = { Word: /(\b\w)/gi, Sentence: /(?:\.|^)\s*(\b\w)/gi, Paragraph: /(?:\n|^)\s*(\b\w)/gi, }[scope]; if (scopeRegex === undefined) { throw new OperationError("Unrecognized capitalization scope"); } // Use the regex to capitalize the input return input.replace(scopeRegex, function (m) { return m.toUpperCase(); }); }
/** * @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/ToUpperCase.tsx#L76-L101
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
ToUpperCase.highlight
highlight(pos, args) { return pos; }
/** * Highlight To Upper case * * @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/ToUpperCase.tsx#L112-L114
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
ToUpperCase.highlightReverse
highlightReverse(pos, args) { return pos; }
/** * Highlight To Upper case 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/ToUpperCase.tsx#L125-L127
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
TypeScriptBeautify.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/TypeScriptBeautify.tsx#L53-L61
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
URLDecode.constructor
constructor() { super(); this.name = "URL Decode"; this.module = "URL"; // this.description = // "Converts URI/URL percent-encoded characters back to their raw values.<br><br>e.g. <code>%3d</code> becomes <code>=</code>"; // this.infoURL = "https://wikipedia.org/wiki/Percent-encoding"; this.inputType = "string"; this.outputType = "string"; this.args = []; this.checks = [ { pattern: ".*(?:%[\\da-f]{2}.*){4}", flags: "i", args: [], }, ]; }
/** * URLDecode constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/URLDecode.tsx#L46-L64
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
URLDecode.run
run(input, args) { const data = input.replace(/\+/g, "%20"); try { return decodeURIComponent(data); } catch (err) { return unescape(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/URLDecode.tsx#L71-L78
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
URLEncode.getOptDetail
public getOptDetail(): OptDetail { return { // provide information relatedID: 'url', config: { "module": "Default", "description": "Encodes problematic characters into percent-encoding, a format supported by URIs/URLs.<br><br>e.g. <code>=</code> becomes <code>%3d</code>", "infoURL": "https://wikipedia.org/wiki/Percent-encoding", "inputType": "string", "outputType": "string", "flowControl": false, "manualBake": false, "args": [ { "name": Dot("e7Afj0xo2", "Encode all special chars"), "type": "boolean", "value": false, }, ] }, optName: Dot("btUdVQx8duc", "{0} Encode", 'URL'), optDescription: Dot("btUVqx8uc", "Encodes problematic characters into percent-encoding, a format supported by URIs/URLs."), exampleInput: "test 12345", exampleOutput: "test%2012345", infoURL: "https://wikipedia.org/wiki/Percent-encoding", nousenouseID: "urlencode", } }
// impl getOptDetail
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/URLEncode.tsx#L23-L50
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
URLEncode.constructor
constructor() { super(); this.name = "URL Encode"; this.module = "URL"; // this.description = // "Encodes problematic characters into percent-encoding, a format supported by URIs/URLs.<br><br>e.g. <code>=</code> becomes <code>%3d</code>"; // this.infoURL = "https://wikipedia.org/wiki/Percent-encoding"; this.inputType = "string"; this.outputType = "string"; this.args = [ { name: Dot("0NSerY3oe", "Encode all special chars"), type: "boolean", value: false, }, ]; }
/** * URLEncode constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/URLEncode.tsx#L55-L72
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
URLEncode.run
run(input, args) { const encodeAll = args[0]; return encodeAll ? this.encodeAllChars(input) : encodeURI(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/URLEncode.tsx#L79-L82
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
URLEncode.encodeAllChars
encodeAllChars(str) { // TODO Do this programmatically return encodeURIComponent(str) .replace(/!/g, "%21") .replace(/#/g, "%23") .replace(/'/g, "%27") .replace(/\(/g, "%28") .replace(/\)/g, "%29") .replace(/\*/g, "%2A") .replace(/-/g, "%2D") .replace(/\./g, "%2E") .replace(/_/g, "%5F") .replace(/~/g, "%7E"); }
/** * Encode characters in URL outside of encodeURI() function spec * * @param {string} str * @returns {string} */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/URLEncode.tsx#L90-L103
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/XMLBeautify.tsx#L68-L82
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/XMLBeautify.tsx#L89-L93
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/XMLMinify.tsx#L65-L79
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/XMLMinify.tsx#L86-L89
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
XMLToJSON.constructor
constructor() { super(); this.name = "XML to JSON"; this.module = "Default"; this.inputType = "JSON"; this.outputType = "string"; this.args = [ ]; }
/** * XMLToJSON constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/XMLToJSON.tsx#L46-L56
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
XMLToJSON.run
run(input, args) { let val = xmlutils.json2xml.getRawJsonFromStructXml(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/XMLToJSON.tsx#L67-L70
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
YamlBeautify.constructor
constructor() { super(); this.module = "Code"; this.inputType = "string"; this.outputType = "string"; this.args = [ // { // "name": Dot("isti", "Indent string"), // "type": "binaryShortString", // "value": " " // } ]; }
/** * YamlBeautify constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/impl/conversion/YAMLBeautify.tsx#L69-L83
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
YamlBeautify.run
run(input, args) { const indentStr = args[0]; let exts = { parser: "yaml", plugins: [parserYaml], } let results = prettier.format(input, exts); return results; }
/** * @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/YAMLBeautify.tsx#L90-L99
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
getXmlFactory
function getXmlFactory() { function _getAllAttr(node) { var attributes = node.attributes; if (node.hasAttributes() === false) { return {}; } var result = {}; for (let attr of attributes) { result[attr.name] = attr.value; } return result; } function _getContent(node) { let html = node.innerHTML; if (_.isNil(html)) { return ""; } return html; } function _getTagName(node) { return node.tagName; } function _getChildren(parent) { var childNodes = parent.childNodes; var children: any = []; for (let child of childNodes) { if (child.nodeType !== 1) { continue; } else { children.push(child); } } return children; } function _getEachNodeInfo(child) { var eachChildInfo: any = { tagName: _getTagName(child), attr: _getAllAttr(child), }; var subChildren = _getChildren(child); if (subChildren.length !== 0) { eachChildInfo.children = _getChildrenList(subChildren); } if (_.isNil(eachChildInfo.children)) { eachChildInfo.content = _getContent(child); } return eachChildInfo; } function _getChildrenList(children) { var resultArr: any[] = []; for (var child of children) { let eachChildInfo: any = _getEachNodeInfo(child); resultArr.push(eachChildInfo); } return resultArr; } function _renderXMLTree(parent) { var parentEle = document.createElement(parent.tagName); //append attributes if (parent.attr) { var attributes = parent.attr; for (var attrName in attributes) { var attrVal = attributes[attrName]; parentEle.setAttribute(attrName, attrVal); } } if (!_.isNil(parent.children)) { var children = parent.children; for (var child of children) { parentEle.appendChild(_renderXMLTree(child)); } } else { if (!_.isNil(parent.content)) { parentEle.appendChild(document.createTextNode(parent.content)); } } return parentEle; } function getXmlObject(xmlString) { // return $(xmlString)[0]; var parser = new DOMParser(); var xmlDoc = parser.parseFromString(xmlString, "text/xml"); return xmlDoc; } let crtref = { xml2json: { getStructJsonFromRawXml(xmlString) { var doc = getXmlObject(xmlString); if (_.isNil(doc)) { return {}; } return _getEachNodeInfo(doc.childNodes[0]); }, getRawXmlFromStructJson(json) { return _renderXMLTree(json); }, }, json2xml: { getStructXmlFromRawJson(rawJson) { let crtRootName = "root"; let crtLayer = utils.createJsonMetaLayerData({ rawdata: rawJson }); let xmlStyleFormatLayer = crtref.reFormatXmlStyleFromRawLayer( crtLayer.value, ); xmlStyleFormatLayer = { tagName: crtRootName, children: xmlStyleFormatLayer, }; let rawXml = crtref.xml2json.getRawXmlFromStructJson(xmlStyleFormatLayer); // let finxmlstr = new XML(rawXml).toXMLString(); // let finxmlstr = `<?xml version="1.0" encoding="utf-8" ?>\n${rawXml.outerHTML}`; // finxmlstr = utils.formatxml(finxmlstr); return finxmlstr; }, getRawJsonFromStructXml(structXml) { let crtStructJson = crtref.xml2json.getStructJsonFromRawXml(structXml); let crtFinalJson = crtref.flatternStructJsonToKV(crtStructJson); return crtFinalJson; }, }, flatternStructJsonToKV(crtJson, obj = {}) { let { tagName, children, attr, content } = crtJson; if (notempty(children)) { let subObj = {}; obj[tagName] = subObj; for (let idx in children) { let item = children[idx]; crtref.flatternStructJsonToKV(item, subObj); } if (notempty(content)) { obj[tagName + "_text"] = content; } } else { obj[tagName] = content; } if (notempty(attr)) { obj[tagName + "_attr"] = attr; } return obj; }, reFormatXmlStyleFromRawLayer(layerArr) { let finReturnArr: any = []; if (_.isNil(layerArr) || !utils.isArray(layerArr)) { return layerArr; } for (let i = 0; i < layerArr.length; i++) { let crtLayerObject = layerArr[i]; let { type, key, value, leaf } = crtLayerObject; let crtXmlReturnObj: any = { tagName: key, attr: {}, }; let shouldSkipFinAdd = false; if (leaf) { crtXmlReturnObj.content = value; } else { let finChildrenForTmp = crtref.reFormatXmlStyleFromRawLayer(value); if (type == "Array") { shouldSkipFinAdd = true; console.log("finChildrenForTmp", finChildrenForTmp); for (let eachChild of finChildrenForTmp) { finReturnArr.push( _.merge({}, crtXmlReturnObj, { children: eachChild.children, }), ); } } else { crtXmlReturnObj.children = finChildrenForTmp; } } finReturnArr.push(crtXmlReturnObj); } return finReturnArr; }, }; return crtref; }
// xml
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/impl/tools/other/xmlutils.ts#L118-L304
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
checkDefaultsDeep
function checkDefaultsDeep( value: any, srcValue: any, key: string, object: any, source: any ) { if (_.isNil(value)) { return srcValue; } if (_.isArray(value) || _.isArray(srcValue)) { return value; } return value; }
// _.defaultsDeep(newState, state);
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/[lang]/client/src/utils/SyncStateUtils.tsx#L59-L73
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
setTheme
let setTheme = (theme: ThemeType) => { localStorage.setItem(key, theme) handleTheme(theme) _setTheme(theme) }
// let [theme, _setTheme] = useState<ThemeType>(
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/__CORE__/components/LightDarkButton/theme.tsx#L33-L37
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
getPathnameInRSC
let getPathnameInRSC = () => { // const headersList = headers(); // const header_url = headersList.get('x-url') || ""; // return header_url return location.pathname }
// import { SystemInfoBody, fn_add_user_into_active, fn_get_system_info_from_redis } from "@/[lang]/register/user-types";
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2-spa/src/__CORE__/containers/GrailLayoutWithUser/actions/handleAuthInfo.tsx#L12-L17
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
getLocale
function getLocale(request: NextRequest) { let acceptLanguage = _.toLower(request.headers.get("accept-language") + ""); let val = defaultLocale.langInHttp; let ack = false; rever_locales_http.every((locale) => { _.every(locale, (x) => { if (acceptLanguage?.includes(x)) { val = _.first(locale) || defaultLocale.langInHttp; ack = true; } return !ack; }); return !ack; }); return val; }
// Get the preferred locale, similar to the above or using a library
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2/middleware.ts#L70-L85
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
toRgba
const toRgba = (hexCode, opacity = 50) => { let hex = hexCode.replace("#", ""); if (hex.length === 3) { hex = `${hex[0]}${hex[0]}${hex[1]}${hex[1]}${hex[2]}${hex[2]}`; } const r = parseInt(hex.substring(0, 2), 16); const g = parseInt(hex.substring(2, 4), 16); const b = parseInt(hex.substring(4, 6), 16); return `rgba(${r},${g},${b},${opacity / 100})`; };
/** @type {import('tailwindcss').Config} */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2/tailwind.config.ts#L8-L20
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
fn
let fn = (obj: Partial<Metadata>) => { return _.merge({ icons: [ '/icon.png' ], title: Dot("title-laftools", "LafTools - The Leading All-In-One ToolBox for Programmers"), description: Dot("iZXig7E2JF", "LafTools offers a comprehensive suite of development utilities including codecs, formatters, image processing tools, and computer resource management solutions. Designed to streamline and enhance your development workflow, LafTools is your go-to resource for efficient, high-quality software development."), keywords: getAppKeywords(), } satisfies Metadata, obj) };
// fn
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2/app/[lang]/page.tsx#L92-L101
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
formatEachNodeItem
let formatEachNodeItem = (nodeList: TreeNodeInfo[]): TreeNodeInfo[] => { return _.map(nodeList, (x) => { let rootLevel = (x.id + "").indexOf(TREE_ROOT_ID_PREFIX) == 0; let hasCaret = !_.isNil(x.hasCaret) ? x.hasCaret : !_.isEmpty(x.childNodes); let isExpanded = hasSearchText ? true : _.includes(props.expanded, x.id.toString()); let i = { icon: "application", ...x, label: props.needShowCountChildren && hasCaret && !rootLevel ? x.label + `(${_.size(x.childNodes)})` : x.label, isExpanded: isExpanded, isSelected: _.includes(props.selected, x.id.toString()), childNodes: !isExpanded ? [] : rootLevel ? x.childNodes : formatEachNodeItem(x.childNodes || []), // secondaryLabel: <Button minimal={true} icon="star-empty" />, hasCaret, } as TreeNodeInfo; if (props.formatEachNode) { i = props.formatEachNode(i); } return i; }); };
// recursively format tmp_nodes to nodes, so that we can use it in Tree, note that isExpanded is true when it's in props.expanded and isSeleced is true when it's in props.selected
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2/app/[lang]/client/src/components/SystemNavTree/index.tsx#L113-L144
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
AND.constructor
constructor() { super(); this.name = Dot("and.name", "AND"); this.module = "Default"; this.description = Dot("and.desc", "AND the input with the given key. e.g. fe023da5"); this.infoURL = "https://wikipedia.org/wiki/Bitwise_operation#AND"; this.inputType = "byteArray"; this.outputType = "byteArray"; this.args = [ { name: Dot("and.arg.key", "Key"), type: "toggleString", value: "", toggleValues: BITWISE_OP_DELIMS, }, ]; }
/** * AND constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2/app/[lang]/client/src/impl/tools/impl/conversion/AND.tsx#L19-L36
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
AND.getOptDetail
public getOptDetail(): OptDetail { return { relatedID: 'nothing', config: { "module": "Default", "description": this.description, "infoURL": this.infoURL, "inputType": this.inputType, "outputType": this.outputType, "flowControl": false, "manualBake": false, "args": this.args, }, infoURL: this.infoURL, nousenouseID: 'and', optName: Dot("and.textiDjMIo", "Generate {0} Hash", "AND"), optDescription: Dot( "and.desc.rxsHq", "This operation performs a bitwise {0} on data.", "AND" ), // exampleInput and exampleOutput are placeholders, actual values should be provided exampleInput: "", exampleOutput: "" }; }
/** * Get operation details */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2/app/[lang]/client/src/impl/tools/impl/conversion/AND.tsx#L41-L66
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
AND.run
run(input: Uint8Array, args: any[]): Uint8Array { const key = Utils.convertToByteArray(args[0].string || "", args[0].option); return bitOp(input, key, and); }
/** * @param {Uint8Array} input * @param {Object[]} args * @returns {Uint8Array} */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2/app/[lang]/client/src/impl/tools/impl/conversion/AND.tsx#L73-L77
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
AND.highlight
highlight(pos: { start: number; end: number }[], args: any[]): { start: number; end: number }[] { return pos; }
/** * Highlight AND * * @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/app/[lang]/client/src/impl/tools/impl/conversion/AND.tsx#L88-L90
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
AND.highlightReverse
highlightReverse(pos: { start: number; end: number }[], args: any[]): { start: number; end: number }[] { return pos; }
/** * Highlight AND 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/app/[lang]/client/src/impl/tools/impl/conversion/AND.tsx#L101-L103
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
CSSBeautify.constructor
constructor() { super(); this.module = "Code"; this.inputType = "string"; this.outputType = "string"; this.args = [ { "name": Dot("isti", "Indent string"), "type": "binaryShortString", "value": "\\t" } ]; }
/** * CSSBeautify constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2/app/[lang]/client/src/impl/tools/impl/conversion/CSSBeautify.tsx#L61-L75
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
CSSBeautify.run
run(input, args) { let indentStr = gutils.convertASCIICodeInStr(args[0]); return vkbeautify.css(input, indentStr); }
/** * @param {string} input * @param {Object[]} args * @returns {string} */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2/app/[lang]/client/src/impl/tools/impl/conversion/CSSBeautify.tsx#L82-L85
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
CSSMinify.constructor
constructor() { super(); this.module = "Code"; this.inputType = "string"; this.outputType = "string"; this.args = [ { name: "Preserve comments", type: "boolean", value: false, }, ]; }
/** * CSSMinify constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2/app/[lang]/client/src/impl/tools/impl/conversion/CSSMinify.tsx#L59-L74
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
CSSMinify.run
run(input, args) { const preserveComments = args[0]; return vkbeautify.cssmin(input, preserveComments); }
/** * @param {string} input * @param {Object[]} args * @returns {string} */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2/app/[lang]/client/src/impl/tools/impl/conversion/CSSMinify.tsx#L81-L84
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
CSVToJSON.constructor
constructor() { super(); this.outputType = "JSON"; this.inputType = "string"; this.args = [ { name: "Cell delimiters", type: "binaryShortString", value: ",", }, { name: "Row delimiters", type: "binaryShortString", value: "\\r\\n", }, { name: "Format", type: "option", value: ["Array of dictionaries", "Array of arrays"], }, ]; }
/** * CSVToJSON constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2/app/[lang]/client/src/impl/tools/impl/conversion/CSVToJSON.tsx#L74-L96
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
CSVToJSON.run
run(input, args) { const [cellDelims, rowDelims, format] = args; let json, header; try { json = Utils.parseCSV(input, cellDelims.split(""), rowDelims.split("")); } catch (err) { throw new OperationError("Unable to parse CSV: " + err); } switch (format) { case "Array of dictionaries": header = json[0]; return json.slice(1).map((row) => { const obj = {}; header.forEach((h, i) => { obj[h] = row[i]; }); return obj; }); case "Array of arrays": default: return json; } }
/** * @param {string} input * @param {Object[]} args * @returns {JSON} */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2/app/[lang]/client/src/impl/tools/impl/conversion/CSVToJSON.tsx#L103-L127
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
FromBCD.constructor
constructor() { super(); this.module = "Default" this.inputType = "string"; this.outputType = "BigNumber"; this.args = [ { name: "Scheme", type: "option", value: ENCODING_SCHEME, }, { name: "Packed", type: "boolean", value: true, }, { name: "Signed", type: "boolean", value: false, }, { name: "Input format", type: "option", value: FORMAT, }, ]; this.checks = [ { pattern: "^(?:\\d{4} ){3,}\\d{4}$", flags: "", args: ["8 4 2 1", true, false, "Nibbles"], }, ]; }
/** * FromBCD constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2/app/[lang]/client/src/impl/tools/impl/conversion/FromBCD.tsx#L98-L132
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
FromBCD.run
run(input, args) { const encoding = ENCODING_LOOKUP[args[0]], packed = args[1], signed = args[2], inputFormat = args[3], nibbles: any = []; let output = "", byteArray; // Normalise the input switch (inputFormat) { case "Nibbles": case "Bytes": input = input.replace(/\s/g, ""); for (let i = 0; i < input.length; i += 4) { nibbles.push(parseInt(input.substr(i, 4), 2)); } break; case "Raw": default: byteArray = new Uint8Array(Utils.strToArrayBuffer(input)); byteArray.forEach((b) => { nibbles.push(b >>> 4); nibbles.push(b & 15); }); break; } if (!packed) { // Discard each high nibble for (let i = 0; i < nibbles.length; i++) { nibbles.splice(i, 1); // lgtm [js/loop-iteration-skipped-due-to-shifting] } } if (signed) { const sign = nibbles.pop(); if (sign === 13 || sign === 11) { // Negative output += "-"; } } nibbles.forEach((n) => { if (isNaN(n)) throw new OperationError("Invalid input"); const val = encoding.indexOf(n); if (val < 0) throw new OperationError( `Value ${Utils.bin(n, 4)} is not in the encoding scheme`, ); output += val.toString(); }); return new BigNumber(output); }
/** * @param {string} input * @param {Object[]} args * @returns {BigNumber} */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2/app/[lang]/client/src/impl/tools/impl/conversion/FromBCD.tsx#L139-L194
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
FromBase32.constructor
constructor() { super(); this.name = "From Base32"; this.module = "Default"; this.inputType = "string"; this.outputType = "byteArray"; this.args = [ { name: Dot("skq3i12", "Alphabet"), type: "binaryString", value: "A-Z2-7=" }, { name: Dot("nskqw", "Remove non-alphabet chars"), type: "boolean", value: true } ]; this.checks = [ { pattern: "^(?:[A-Z2-7]{8})+(?:[A-Z2-7]{2}={6}|[A-Z2-7]{4}={4}|[A-Z2-7]{5}={3}|[A-Z2-7]{7}={1})?$", flags: "", args: ["A-Z2-7=", false] } ]; }
/** * FromBase32 constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2/app/[lang]/client/src/impl/tools/impl/conversion/FromBase32.tsx#L78-L106
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
FromBase32.run
run(input, args) { if (!input) return []; const alphabet = args[0] ? Utils.expandAlphRange(args[0]).join("") : "ABCDEFGHIJKLMNOPQRSTUVWXYZ234567=", removeNonAlphChars = args[1], output: any[] = []; let chr1, chr2, chr3, chr4, chr5, enc1, enc2, enc3, enc4, enc5, enc6, enc7, enc8, i = 0; if (removeNonAlphChars) { const re = new RegExp("[^" + alphabet.replace(/[\]\\\-^]/g, "\\$&") + "]", "g"); input = input.replace(re, ""); } while (i < input.length) { enc1 = alphabet.indexOf(input.charAt(i++)); enc2 = alphabet.indexOf(input.charAt(i++) || "="); enc3 = alphabet.indexOf(input.charAt(i++) || "="); enc4 = alphabet.indexOf(input.charAt(i++) || "="); enc5 = alphabet.indexOf(input.charAt(i++) || "="); enc6 = alphabet.indexOf(input.charAt(i++) || "="); enc7 = alphabet.indexOf(input.charAt(i++) || "="); enc8 = alphabet.indexOf(input.charAt(i++) || "="); chr1 = (enc1 << 3) | (enc2 >> 2); chr2 = ((enc2 & 3) << 6) | (enc3 << 1) | (enc4 >> 4); chr3 = ((enc4 & 15) << 4) | (enc5 >> 1); chr4 = ((enc5 & 1) << 7) | (enc6 << 2) | (enc7 >> 3); chr5 = ((enc7 & 7) << 5) | enc8; output.push(chr1); if ((enc2 & 3) !== 0 || enc3 !== 32) output.push(chr2); if ((enc4 & 15) !== 0 || enc5 !== 32) output.push(chr3); if ((enc5 & 1) !== 0 || enc6 !== 32) output.push(chr4); if ((enc7 & 7) !== 0 || enc8 !== 32) output.push(chr5); } return output; }
/** * @param {string} input * @param {Object[]} args * @returns {byteArray} */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2/app/[lang]/client/src/impl/tools/impl/conversion/FromBase32.tsx#L113-L154
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
FromBase45.constructor
constructor() { super(); this.name = "From Base45"; this.module = "Default"; this.inputType = "string"; this.outputType = "byteArray"; this.args = [ { name: Dot("skq3i12", "Alphabet"), type: "string", value: ALPHABET }, { name: Dot("nskqw", "Remove non-alphabet chars"), type: "boolean", value: true }, ]; this.highlight = highlightFromBase45; this.highlightReverse = highlightToBase45; }
/** * FromBase45 constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2/app/[lang]/client/src/impl/tools/impl/conversion/FromBase45.tsx#L71-L97
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
FromBase45.run
run(input, args) { if (!input) return []; const alphabet = Utils.expandAlphRange(args[0]).join(""); const removeNonAlphChars = args[1]; const res: any = []; // Remove non-alphabet characters if (removeNonAlphChars) { const re = new RegExp("[^" + alphabet.replace(/[[\]\\\-^$]/g, "\\$&") + "]", "g"); input = input.replace(re, ""); } for (const triple of Utils.chunked(input, 3)) { triple.reverse(); let b = 0; for (const c of triple) { const idx = alphabet.indexOf(c); if (idx === -1) { throw new OperationError(`Character not in alphabet: '${c}'`); } b *= 45; b += idx; } if (b > 65535) { throw new OperationError(`Triplet too large: '${triple.join("")}'`); } if (triple.length > 2) { /** * The last triple may only have 2 bytes so we push the MSB when we got 3 bytes * Pushing MSB */ res.push(b >> 8); } /** * Pushing LSB */ res.push(b & 0xff); } return res; }
/** * @param {string} input * @param {Object[]} args * @returns {byteArray} */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2/app/[lang]/client/src/impl/tools/impl/conversion/FromBase45.tsx#L104-L149
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
FromBase58.constructor
constructor() { super(); this.module = "Default"; // this.description = ; // this.infoURL = ""; this.inputType = "string"; this.outputType = "byteArray"; this.args = [ { "name": Dot("anosdk", "Alphabet"), "type": "editableOption", "value": ALPHABET_OPTIONS }, { "name": Dot("nskqw", "Remove non-alphabet chars"), "type": "boolean", "value": true } ]; this.checks = [ { pattern: "^[1-9A-HJ-NP-Za-km-z]{20,}$", flags: "", args: ["123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz", false] }, { pattern: "^[1-9A-HJ-NP-Za-km-z]{20,}$", flags: "", args: ["rpshnaf39wBUDNEGHJKLM4PQRST7VWXYZ2bcdeCg65jkm8oFqi1tuvAxyz", false] }, ]; }
/** * FromBase58 constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2/app/[lang]/client/src/impl/tools/impl/conversion/FromBase58.tsx#L96-L133
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
FromBase58.run
run(input, args) { let alphabet = args[0] || ALPHABET_OPTIONS[0].value; const removeNonAlphaChars = args[1] === undefined ? true : args[1], result = [0]; alphabet = Utils.expandAlphRange(alphabet).join(""); if (alphabet.length !== 58 || ([] as any).unique.call(alphabet).length !== 58) { throw new OperationError("Alphabet must be of length 58"); } if (input.length === 0) return []; let zeroPrefix = 0; for (let i = 0; i < input.length && input[i] === alphabet[0]; i++) { zeroPrefix++; } [].forEach.call(input, function (c, charIndex) { const index = alphabet.indexOf(c); if (index === -1) { if (removeNonAlphaChars) { return; } else { throw new OperationError(`Char '${c}' at position ${charIndex} not in alphabet`); } } let carry = result[0] * 58 + index; result[0] = carry & 0xFF; carry = carry >> 8; for (let i = 1; i < result.length; i++) { carry += result[i] * 58; result[i] = carry & 0xFF; carry = carry >> 8; } while (carry > 0) { result.push(carry & 0xFF); carry = carry >> 8; } }); while (zeroPrefix--) { result.push(0); } return result.reverse(); }
/** * @param {string} input * @param {Object[]} args * @returns {byteArray} */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2/app/[lang]/client/src/impl/tools/impl/conversion/FromBase58.tsx#L140-L191
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
FromBase62.constructor
constructor() { super(); this.name = "From Base62"; this.module = "Default"; // this.description = ""; // this.infoURL = "https://wikipedia.org/wiki/List_of_numeral_systems"; this.inputType = "string"; this.outputType = "byteArray"; this.args = [ { name: Dot("skq3i12", "Alphabet"), type: "string", value: "0-9A-Za-z" } ]; }
/** * FromBase62 constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2/app/[lang]/client/src/impl/tools/impl/conversion/FromBase62.tsx#L68-L88
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
FromBase62.run
run(input, args) { if (input.length < 1) return []; const alphabet = Utils.expandAlphRange(args[0]).join(""); const BN62 = BigNumber.clone({ ALPHABET: alphabet }); const re = new RegExp("[^" + alphabet.replace(/[[\]\\\-^$]/g, "\\$&") + "]", "g"); input = input.replace(re, ""); // Read number in using Base62 alphabet const number = new BN62(input, 62); // Copy to new BigNumber object that uses the default alphabet const normalized = new BigNumber(number); // Convert to hex and add leading 0 if required let hex = normalized.toString(16); if (hex.length % 2 !== 0) hex = "0" + hex; return Utils.convertToByteArray(hex, "Hex"); }
/** * @param {string} input * @param {Object[]} args * @returns {byteArray} */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2/app/[lang]/client/src/impl/tools/impl/conversion/FromBase62.tsx#L95-L113
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
FromBase64.constructor
constructor() { super(); this.module = "Default"; this.inputType = "string"; this.outputType = "byteArray"; this.args = [ { name: Dot("skq3i12", "Alphabet"), type: "editableOption", value: ALPHABET_OPTIONS, }, { name: Dot("nskqw", "Remove non-alphabet chars"), type: "boolean", value: true, }, { name: "Strict mode", type: "boolean", value: false, }, ]; this.checks = [ { pattern: "^\\s*(?:[A-Z\\d+/]{4})+(?:[A-Z\\d+/]{2}==|[A-Z\\d+/]{3}=)?\\s*$", flags: "i", args: ["A-Za-z0-9+/=", true, false], }, { pattern: "^\\s*[A-Z\\d\\-_]{20,}\\s*$", flags: "i", args: ["A-Za-z0-9-_", true, false], }, { pattern: "^\\s*(?:[A-Z\\d+\\-]{4}){5,}(?:[A-Z\\d+\\-]{2}==|[A-Z\\d+\\-]{3}=)?\\s*$", flags: "i", args: ["A-Za-z0-9+\\-=", true, false], }, { pattern: "^\\s*(?:[A-Z\\d./]{4}){5,}(?:[A-Z\\d./]{2}==|[A-Z\\d./]{3}=)?\\s*$", flags: "i", args: ["./0-9A-Za-z=", true, false], }, { pattern: "^\\s*[A-Z\\d_.]{20,}\\s*$", flags: "i", args: ["A-Za-z0-9_.", true, false], }, { pattern: "^\\s*(?:[A-Z\\d._]{4}){5,}(?:[A-Z\\d._]{2}--|[A-Z\\d._]{3}-)?\\s*$", flags: "i", args: ["A-Za-z0-9._-", true, false], }, { pattern: "^\\s*(?:[A-Z\\d+/]{4}){5,}(?:[A-Z\\d+/]{2}==|[A-Z\\d+/]{3}=)?\\s*$", flags: "i", args: ["0-9a-zA-Z+/=", true, false], }, { pattern: "^\\s*(?:[A-Z\\d+/]{4}){5,}(?:[A-Z\\d+/]{2}==|[A-Z\\d+/]{3}=)?\\s*$", flags: "i", args: ["0-9A-Za-z+/=", true, false], }, { pattern: "^[ !\"#$%&'()*+,\\-./\\d:;<=>?@A-Z[\\\\\\]^_]{20,}$", flags: "", args: [" -_", false, false], }, { pattern: "^\\s*[A-Z\\d+\\-]{20,}\\s*$", flags: "i", args: ["+\\-0-9A-Za-z", true, false], }, { pattern: "^\\s*[!\"#$%&'()*+,\\-0-689@A-NP-VX-Z[`a-fh-mp-r]{20,}\\s*$", flags: "", args: ["!-,-0-689@A-NP-VX-Z[`a-fh-mp-r", true, false], }, { pattern: "^\\s*(?:[N-ZA-M\\d+/]{4}){5,}(?:[N-ZA-M\\d+/]{2}==|[N-ZA-M\\d+/]{3}=)?\\s*$", flags: "i", args: ["N-ZA-Mn-za-m0-9+/=", true, false], }, { pattern: "^\\s*[A-Z\\d./]{20,}\\s*$", flags: "i", args: ["./0-9A-Za-z", true, false], }, { pattern: "^\\s*(?:[A-Z=\\d\\+/]{4}){5,}(?:[A-Z=\\d\\+/]{2}CC|[A-Z=\\d\\+/]{3}C)?\\s*$", flags: "i", args: [ "/128GhIoPQROSTeUbADfgHijKLM+n0pFWXY456xyzB7=39VaqrstJklmNuZvwcdEC", true, false, ], }, { pattern: "^\\s*(?:[A-Z=\\d\\+/]{4}){5,}(?:[A-Z=\\d\\+/]{2}55|[A-Z=\\d\\+/]{3}5)?\\s*$", flags: "i", args: [ "3GHIJKLMNOPQRSTUb=cdefghijklmnopWXYZ/12+406789VaqrstuvwxyzABCDEF5", true, false, ], }, { pattern: "^\\s*(?:[A-Z=\\d\\+/]{4}){5,}(?:[A-Z=\\d\\+/]{2}22|[A-Z=\\d\\+/]{3}2)?\\s*$", flags: "i", args: [ "ZKj9n+yf0wDVX1s/5YbdxSo=ILaUpPBCHg8uvNO4klm6iJGhQ7eFrWczAMEq3RTt2", true, false, ], }, { pattern: "^\\s*(?:[A-Z=\\d\\+/]{4}){5,}(?:[A-Z=\\d\\+/]{2}55|[A-Z=\\d\\+/]{3}5)?\\s*$", flags: "i", args: [ "HNO4klm6ij9n+J2hyf0gzA8uvwDEq3X1Q7ZKeFrWcVTts/MRGYbdxSo=ILaUpPBC5", true, false, ], }, ]; }
/** * FromBase64 constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2/app/[lang]/client/src/impl/tools/impl/conversion/FromBase64.tsx#L291-L431
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
FromBase64.run
run(input, args) { const [alphabet, removeNonAlphChars, strictMode] = args; return fromBase64( input, alphabet, "byteArray", removeNonAlphChars, strictMode, ); }
/** * @param {string} input * @param {Object[]} args * @returns {byteArray} */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2/app/[lang]/client/src/impl/tools/impl/conversion/FromBase64.tsx#L438-L448
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
FromBase64.highlight
highlight(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 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/app/[lang]/client/src/impl/tools/impl/conversion/FromBase64.tsx#L459-L463
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
FromBase64.highlightReverse
highlightReverse(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 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/app/[lang]/client/src/impl/tools/impl/conversion/FromBase64.tsx#L474-L478
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
FromBase85.constructor
constructor() { super(); this.name = "From Base85"; this.module = "Default"; // this.description = ; // this.infoURL = ""; this.inputType = "string"; this.outputType = "byteArray"; this.args = [ { name: Dot("skq3i12", "Alphabet"), type: "editableOption", value: ALPHABET_OPTIONS }, { name: Dot("nskqw", "Remove non-alphabet chars"), type: "boolean", value: true }, { name: "All-zero group char", type: "binaryShortString", value: "z", maxLength: 1 } ]; this.checks = [ { pattern: "^\\s*(?:<~)?" + // Optional whitespace and starting marker "[\\s!-uz]*" + // Any amount of base85 characters and whitespace "[!-uz]{15}" + // At least 15 continoues base85 characters without whitespace "[\\s!-uz]*" + // Any amount of base85 characters and whitespace "(?:~>)?\\s*$", // Optional ending marker and whitespace args: ["!-u"], }, { pattern: "^" + "[\\s0-9a-zA-Z.\\-:+=^!/*?&<>()[\\]{}@%$#]*" + "[0-9a-zA-Z.\\-:+=^!/*?&<>()[\\]{}@%$#]{15}" + // At least 15 continoues base85 characters without whitespace "[\\s0-9a-zA-Z.\\-:+=^!/*?&<>()[\\]{}@%$#]*" + "$", args: ["0-9a-zA-Z.\\-:+=^!/*?&<>()[]{}@%$#"], }, { pattern: "^" + "[\\s0-9A-Za-z!#$%&()*+\\-;<=>?@^_`{|}~]*" + "[0-9A-Za-z!#$%&()*+\\-;<=>?@^_`{|}~]{15}" + // At least 15 continoues base85 characters without whitespace "[\\s0-9A-Za-z!#$%&()*+\\-;<=>?@^_`{|}~]*" + "$", args: ["0-9A-Za-z!#$%&()*+\\-;<=>?@^_`{|}~"], }, ]; }
/** * From Base85 constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2/app/[lang]/client/src/impl/tools/impl/conversion/FromBase85.tsx#L112-L173
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
FromBase85.run
run(input, args) { const alphabet = Utils.expandAlphRange(args[0]).join(""), removeNonAlphChars = args[1], allZeroGroupChar = typeof args[2] === "string" ? args[2].slice(0, 1) : "", result: any = []; if (alphabet.length !== 85 || ([] as any).unique.call(alphabet).length !== 85) { throw new OperationError("Alphabet must be of length 85"); } if (allZeroGroupChar && alphabet.includes(allZeroGroupChar)) { throw new OperationError("The all-zero group char cannot appear in the alphabet"); } // Remove delimiters if present const matches = input.match(/^<~(.+?)~>$/); if (matches !== null) input = matches[1]; // Remove non-alphabet characters if (removeNonAlphChars) { const re = new RegExp("[^~" + allZeroGroupChar + alphabet.replace(/[[\]\\\-^$]/g, "\\$&") + "]", "g"); input = input.replace(re, ""); // Remove delimiters again if present (incase of non-alphabet characters in front/behind delimiters) const matches = input.match(/^<~(.+?)~>$/); if (matches !== null) input = matches[1]; } if (input.length === 0) return []; let i = 0; let block, blockBytes; while (i < input.length) { if (input[i] === allZeroGroupChar) { result.push(0, 0, 0, 0); i++; } else { let digits = []; digits = input .substr(i, 5) .split("") .map((chr, idx) => { const digit = alphabet.indexOf(chr); if ((digit < 0 || digit > 84) && chr !== allZeroGroupChar) { throw `Invalid character '${chr}' at index ${i + idx}`; } return digit; }); block = digits[0] * 52200625 + digits[1] * 614125 + (i + 2 < input.length ? digits[2] : 84) * 7225 + (i + 3 < input.length ? digits[3] : 84) * 85 + (i + 4 < input.length ? digits[4] : 84); blockBytes = [ (block >> 24) & 0xff, (block >> 16) & 0xff, (block >> 8) & 0xff, block & 0xff ]; if (input.length < i + 5) { blockBytes.splice(input.length - (i + 5), 5); } result.push.apply(result, blockBytes); i += 5; } } return result; }
/** * @param {string} input * @param {Object[]} args * @returns {byteArray} */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2/app/[lang]/client/src/impl/tools/impl/conversion/FromBase85.tsx#L180-L253
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
FromBinary.constructor
constructor() { super(); this.name = "From Binary"; this.module = "Default"; this.inputType = "string"; this.outputType = "byteArray"; this.args = [ { name: "Delimiter", type: "option", value: BIN_DELIM_OPTIONS, }, { name: "Byte Length", type: "number", value: 8, min: 1, }, ]; this.checks = [ { pattern: "^(?:[01]{8})+$", flags: "", args: ["None"], }, { pattern: "^(?:[01]{8})(?: [01]{8})*$", flags: "", args: ["Space"], }, { pattern: "^(?:[01]{8})(?:,[01]{8})*$", flags: "", args: ["Comma"], }, { pattern: "^(?:[01]{8})(?:;[01]{8})*$", flags: "", args: ["Semi-colon"], }, { pattern: "^(?:[01]{8})(?::[01]{8})*$", flags: "", args: ["Colon"], }, { pattern: "^(?:[01]{8})(?:\\n[01]{8})*$", flags: "", args: ["Line feed"], }, { pattern: "^(?:[01]{8})(?:\\r\\n[01]{8})*$", flags: "", args: ["CRLF"], }, ]; }
/** * FromBinary constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2/app/[lang]/client/src/impl/tools/impl/conversion/FromBinary.tsx#L76-L133
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
FromBinary.run
run(input, args) { const byteLen = args[1] ? args[1] : 8; return fromBinary(input, args[0], byteLen); }
/** * @param {string} input * @param {Object[]} args * @returns {byteArray} */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2/app/[lang]/client/src/impl/tools/impl/conversion/FromBinary.tsx#L140-L143
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
FromBinary.highlight
highlight(pos, args) { const delim = Utils.charRep(args[0] || "Space"); pos[0].start = pos[0].start === 0 ? 0 : Math.floor(pos[0].start / (8 + delim.length)); pos[0].end = pos[0].end === 0 ? 0 : Math.ceil(pos[0].end / (8 + delim.length)); return pos; }
/** * Highlight From 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/app/[lang]/client/src/impl/tools/impl/conversion/FromBinary.tsx#L154-L161
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
FromBinary.highlightReverse
highlightReverse(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 From Binary 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/app/[lang]/client/src/impl/tools/impl/conversion/FromBinary.tsx#L172-L177
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
FromCharcode.constructor
constructor() { super(); this.name = "From Charcode"; this.module = "Default"; this.inputType = "string"; this.outputType = "ArrayBuffer"; this.args = [ { name: "Delimiter", type: "option", value: DELIM_OPTIONS, }, { name: "Base", type: "number", value: 16, }, ]; }
/** * FromCharcode constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2/app/[lang]/client/src/impl/tools/impl/conversion/FromCharcode.tsx#L64-L83
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
FromCharcode.run
run(input, args) { const delim = Utils.charRep(args[0] || "Space"), base = args[1]; let bites = input.split(delim), i = 0; if (base < 2 || base > 36) { throw new OperationError("Error: Base argument must be between 2 and 36"); } if (input.length === 0) { return new ArrayBuffer(0); } // if (base !== 16 && isWorkerEnvironment()) // self.setOption("attemptHighlight", false); // Split into groups of 2 if the whole string is concatenated and // too long to be a single character if (bites.length === 1 && input.length > 17) { bites = []; for (i = 0; i < input.length; i += 2) { bites.push(input.slice(i, i + 2)); } } let latin1 = ""; for (i = 0; i < bites.length; i++) { latin1 += Utils.chr(parseInt(bites[i], base)); } return Utils.strToArrayBuffer(latin1); }
/** * @param {string} input * @param {Object[]} args * @returns {ArrayBuffer} * * @throws {OperationError} if base out of range */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2/app/[lang]/client/src/impl/tools/impl/conversion/FromCharcode.tsx#L92-L123
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
FromDecimal.constructor
constructor() { super(); this.name = "From Decimal"; this.module = "Default"; // this.description = // "Converts the data from an ordinal integer array back into its raw form.<br><br>e.g. <code>72 101 108 108 111</code> becomes <code>Hello</code>"; this.inputType = "string"; this.outputType = "byteArray"; this.args = [ { name: "Delimiter", type: "option", value: DELIM_OPTIONS, }, { name: "Support signed values", type: "boolean", value: false, }, ]; this.checks = [ { pattern: "^(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5])(?: (?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5]))*$", flags: "", args: ["Space", false], }, { pattern: "^(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5])(?:,(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5]))*$", flags: "", args: ["Comma", false], }, { pattern: "^(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5])(?:;(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5]))*$", flags: "", args: ["Semi-colon", false], }, { pattern: "^(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5])(?::(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5]))*$", flags: "", args: ["Colon", false], }, { pattern: "^(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5])(?:\\n(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5]))*$", flags: "", args: ["Line feed", false], }, { pattern: "^(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5])(?:\\r\\n(?:\\d{1,2}|1\\d{2}|2[0-4]\\d|25[0-5]))*$", flags: "", args: ["CRLF", false], }, ]; }
/** * FromDecimal constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2/app/[lang]/client/src/impl/tools/impl/conversion/FromDecimal.tsx#L95-L154
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
FromDecimal.run
run(input, args) { let data = fromDecimal(input, args[0]); if (args[1]) { // Convert negatives data = data.map((v) => (v < 0 ? 0xff + v + 1 : v)); } return data; }
/** * @param {string} input * @param {Object[]} args * @returns {byteArray} */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2/app/[lang]/client/src/impl/tools/impl/conversion/FromDecimal.tsx#L161-L168
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
FromHTMLEntity.constructor
constructor() { super(); this.name = "From HTML Entity"; this.module = "Encodings"; this.inputType = "string"; this.outputType = "string"; this.args = []; this.checks = [ { pattern: "&(?:#\\d{2,3}|#x[\\da-f]{2}|[a-z]{2,6});", flags: "i", args: [], }, ]; }
/** * FromHTMLEntity constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2/app/[lang]/client/src/impl/tools/impl/conversion/FromHTMLEntity.tsx#L46-L61
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
FromHTMLEntity.run
run(input, args) { const regex = /&(#?x?[a-zA-Z0-9]{1,20});/g; let output = "", m, i = 0; while ((m = regex.exec(input))) { // Add up to match for (; i < m.index;) output += input[i++]; // Add match const bite = entityToByte[m[1]]; if (bite) { output += Utils.chr(bite); } else if ( !bite && m[1][0] === "#" && m[1].length > 1 && /^#\d{1,6}$/.test(m[1]) ) { // Numeric entity (e.g. &#10;) const num = m[1].slice(1, m[1].length); output += Utils.chr(parseInt(num, 10)); } else if ( !bite && m[1][0] === "#" && m[1].length > 3 && /^#x[\dA-F]{2,8}$/i.test(m[1]) ) { // Hex entity (e.g. &#x3A;) const hex = m[1].slice(2, m[1].length); output += Utils.chr(parseInt(hex, 16)); } else { // Not a valid entity, print as normal for (; i < regex.lastIndex;) output += input[i++]; } i = regex.lastIndex; } // Add all after final match for (; i < input.length;) output += input[i++]; return output; }
/** * @param {string} input * @param {Object[]} args * @returns {string} */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2/app/[lang]/client/src/impl/tools/impl/conversion/FromHTMLEntity.tsx#L68-L111
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
FromHex.constructor
constructor() { super(); this.module = "Default"; this.inputType = "string" this.outputType = "byteArray" this.args = [ { name: "Delimiter", type: "option", value: FROM_HEX_DELIM_OPTIONS, }, ]; this.checks = [ { pattern: "^(?:[\\dA-F]{2})+$", flags: "i", args: ["None"], }, { pattern: "^[\\dA-F]{2}(?: [\\dA-F]{2})*$", flags: "i", args: ["Space"], }, { pattern: "^[\\dA-F]{2}(?:,[\\dA-F]{2})*$", flags: "i", args: ["Comma"], }, { pattern: "^[\\dA-F]{2}(?:;[\\dA-F]{2})*$", flags: "i", args: ["Semi-colon"], }, { pattern: "^[\\dA-F]{2}(?::[\\dA-F]{2})*$", flags: "i", args: ["Colon"], }, { pattern: "^[\\dA-F]{2}(?:\\n[\\dA-F]{2})*$", flags: "i", args: ["Line feed"], }, { pattern: "^[\\dA-F]{2}(?:\\r\\n[\\dA-F]{2})*$", flags: "i", args: ["CRLF"], }, { pattern: "^(?:0x[\\dA-F]{2})+$", flags: "i", args: ["0x"], }, { pattern: "^0x[\\dA-F]{2}(?:,0x[\\dA-F]{2})*$", flags: "i", args: ["0x with comma"], }, { pattern: "^(?:\\\\x[\\dA-F]{2})+$", flags: "i", args: ["\\x"], }, ]; }
/** * FromHex constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2/app/[lang]/client/src/impl/tools/impl/conversion/FromHex.tsx#L142-L209
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
FromHex.run
run(input, args) { const delim = args[0] || "Auto"; return fromHex(input, delim, 2); }
/** * @param {string} input * @param {Object[]} args * @returns {byteArray} */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2/app/[lang]/client/src/impl/tools/impl/conversion/FromHex.tsx#L216-L219
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
FromHex.highlight
highlight(pos, args) { if (args[0] === "Auto") return false; const delim = Utils.charRep(args[0] || "Space"), len = delim === "\r\n" ? 1 : delim.length, width = len + 2; // 0x and \x are added to the beginning if they are selected, so increment the positions accordingly if (delim === "0x" || delim === "\\x") { if (pos[0].start > 1) pos[0].start -= 2; else pos[0].start = 0; if (pos[0].end > 1) pos[0].end -= 2; else pos[0].end = 0; } pos[0].start = pos[0].start === 0 ? 0 : Math.round(pos[0].start / width); pos[0].end = pos[0].end === 0 ? 0 : Math.ceil(pos[0].end / width); return pos; }
/** * Highlight to Hex * * @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/app/[lang]/client/src/impl/tools/impl/conversion/FromHex.tsx#L230-L247
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
LafTools
github_2023
work7z
typescript
FromHex.highlightReverse
highlightReverse(pos, args) { const delim = Utils.charRep(args[0] || "Space"), len = delim === "\r\n" ? 1 : delim.length; pos[0].start = pos[0].start * (2 + len); pos[0].end = pos[0].end * (2 + len) - len; // 0x and \x are added to the beginning if they are selected, so increment the positions accordingly if (delim === "0x" || delim === "\\x") { pos[0].start += 2; pos[0].end += 2; } return pos; }
/** * Highlight from Hex * * @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/app/[lang]/client/src/impl/tools/impl/conversion/FromHex.tsx#L258-L271
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
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/app/[lang]/client/src/impl/tools/impl/conversion/FromHexdump.tsx#L58-L74
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a