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
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 b...
/** * ToCamelCase constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2/app/[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/app/[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.or...
/** * ToCharcode constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2/app/[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); ...
/** * @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/app/[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"; ...
/** * ToDecimal constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2/app/[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/app/[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_...
/** * ToHTMLEntity constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2/app/[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 += "&#" ...
/** * @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/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", ...
/** * ToHex constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2/app/[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/app/[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) ...
/** * 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/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 countL...
/** * 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/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", ...
/** * ToHexdump constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2/app/[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 =...
/** * @param {ArrayBuffer} input * @param {Object[]} args * @returns {string} */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2/app/[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); o...
/** * 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/app/[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...
/** * 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/app/[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 m...
/** * ToKebabCase constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2/app/[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/app/[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/app/[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/app/[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/app/[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/app/[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 array...
/** * ToMessagePack constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2/app/[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 (e...
/** * @param {JSON} input * @param {Object[]} args * @returns {ArrayBuffer} */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2/app/[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 = "ht...
/** * ToMorseCode constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2/app/[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...
/** * @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/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 31...
/** * ToOctal constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2/app/[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/app/[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' w...
/** * ToSnakeCase constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2/app/[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/app/[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 = "stri...
/** * ToUpperCase constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2/app/[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,...
/** * @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/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/app/[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/app/[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/app/[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"; th...
/** * URLDecode constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2/app/[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/app/[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>", "...
// impl getOptDetail
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2/app/[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-...
/** * URLEncode constructor */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2/app/[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/app/[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"...
/** * Encode characters in URL outside of encodeURI() function spec * * @param {string} str * @returns {string} */
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2/app/[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/app/[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/app/[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/app/[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/app/[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/app/[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/app/[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/app/[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/app/[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) { ...
// xml
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2/app/[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; ...
// _.defaultsDeep(newState, state);
https://github.com/work7z/LafTools/blob/ec1910c3ddf2827b529e4e1f0bed06d762f33b4a/modules/web2/app/[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/app/__CORE__/components/LightDarkButton/theme.tsx#L33-L37
ec1910c3ddf2827b529e4e1f0bed06d762f33b4a
Food-Delivery-WebApp
github_2023
shahriarsajeeb
typescript
RestaurantService.registerRestaurant
async registerRestaurant(registerDto: RegisterDto, response: Response) { const { name, country, city, address, email, phone_number, password } = registerDto as Restaurant; const isEmailExist = await this.prisma.restaurant.findUnique({ where: { email, }, }); if (isEmailExist) {...
// register restaurant service
https://github.com/shahriarsajeeb/Food-Delivery-WebApp/blob/c26ac7f3873ee965a367d1836386686f5336bacf/apps/api-restuarants/src/restaurant.service.ts#L31-L88
c26ac7f3873ee965a367d1836386686f5336bacf
Food-Delivery-WebApp
github_2023
shahriarsajeeb
typescript
RestaurantService.createActivationToken
async createActivationToken(restaurant: Restaurant) { const activationToken = this.jwtService.sign( { restaurant, }, { secret: this.configService.get<string>("JWT_SECRET_KEY"), expiresIn: "5m", } ); return activationToken; }
// create activation token
https://github.com/shahriarsajeeb/Food-Delivery-WebApp/blob/c26ac7f3873ee965a367d1836386686f5336bacf/apps/api-restuarants/src/restaurant.service.ts#L91-L102
c26ac7f3873ee965a367d1836386686f5336bacf
Food-Delivery-WebApp
github_2023
shahriarsajeeb
typescript
RestaurantService.activateRestaurant
async activateRestaurant(activationDto: ActivationDto, response: Response) { const { activationToken } = activationDto; const newRestaurant: { exp: number; restaurant: Restaurant; activationToken: string; } = this.jwtService.verify(activationToken, { secret: this.configService.get<s...
// activation restaurant
https://github.com/shahriarsajeeb/Food-Delivery-WebApp/blob/c26ac7f3873ee965a367d1836386686f5336bacf/apps/api-restuarants/src/restaurant.service.ts#L105-L148
c26ac7f3873ee965a367d1836386686f5336bacf
Food-Delivery-WebApp
github_2023
shahriarsajeeb
typescript
RestaurantService.LoginRestuarant
async LoginRestuarant(loginDto: LoginDto) { const { email, password } = loginDto; const restaurant = await this.prisma.restaurant.findUnique({ where: { email, }, }); if ( restaurant && (await this.comparePassword(password, restaurant.password)) ) { const token...
// Login restaurant
https://github.com/shahriarsajeeb/Food-Delivery-WebApp/blob/c26ac7f3873ee965a367d1836386686f5336bacf/apps/api-restuarants/src/restaurant.service.ts#L151-L176
c26ac7f3873ee965a367d1836386686f5336bacf
Food-Delivery-WebApp
github_2023
shahriarsajeeb
typescript
RestaurantService.comparePassword
async comparePassword( password: string, hashedPassword: string ): Promise<boolean> { return await bcrypt.compare(password, hashedPassword); }
// compare with hashed password
https://github.com/shahriarsajeeb/Food-Delivery-WebApp/blob/c26ac7f3873ee965a367d1836386686f5336bacf/apps/api-restuarants/src/restaurant.service.ts#L179-L184
c26ac7f3873ee965a367d1836386686f5336bacf
Food-Delivery-WebApp
github_2023
shahriarsajeeb
typescript
RestaurantService.getLoggedInRestaurant
async getLoggedInRestaurant(req: any) { const restaurant = req.restaurant; const refreshToken = req.refreshtoken; const accessToken = req.accesstoken; return { restaurant, accessToken, refreshToken }; }
// get logged in restaurant
https://github.com/shahriarsajeeb/Food-Delivery-WebApp/blob/c26ac7f3873ee965a367d1836386686f5336bacf/apps/api-restuarants/src/restaurant.service.ts#L187-L192
c26ac7f3873ee965a367d1836386686f5336bacf
Food-Delivery-WebApp
github_2023
shahriarsajeeb
typescript
RestaurantService.Logout
async Logout(req: any) { req.restaurant = null; req.refreshtoken = null; req.accesstoken = null; return { message: "Logged out successfully!" }; }
// log out restaurant
https://github.com/shahriarsajeeb/Food-Delivery-WebApp/blob/c26ac7f3873ee965a367d1836386686f5336bacf/apps/api-restuarants/src/restaurant.service.ts#L195-L200
c26ac7f3873ee965a367d1836386686f5336bacf
Food-Delivery-WebApp
github_2023
shahriarsajeeb
typescript
FoodsService.createFood
async createFood(createFoodDto: CreateFoodDto, req: any, response: Response) { try { const { name, description, price, estimatedPrice, category, images } = createFoodDto as Food; const restaurantId = req.restaurant?.id; let foodImages: Images | any = []; for (const image of images)...
// create food
https://github.com/shahriarsajeeb/Food-Delivery-WebApp/blob/c26ac7f3873ee965a367d1836386686f5336bacf/apps/api-restuarants/src/foods/foods.service.ts#L32-L75
c26ac7f3873ee965a367d1836386686f5336bacf
Food-Delivery-WebApp
github_2023
shahriarsajeeb
typescript
FoodsService.getLoggedInRestuarantFood
async getLoggedInRestuarantFood(req: any, res: Response) { const restaurantId = req.restaurant?.id; const foods = await this.prisma.foods.findMany({ where: { restaurantId, }, include: { images: true, restaurant: true, }, orderBy: { createdAt: "desc"...
// get all restaurant foods
https://github.com/shahriarsajeeb/Food-Delivery-WebApp/blob/c26ac7f3873ee965a367d1836386686f5336bacf/apps/api-restuarants/src/foods/foods.service.ts#L78-L94
c26ac7f3873ee965a367d1836386686f5336bacf
Food-Delivery-WebApp
github_2023
shahriarsajeeb
typescript
FoodsService.deleteFood
async deleteFood(deleteFoodDto: DeleteFoodDto, req: any) { const restaurantId = req.restaurant?.id; const food = await this.prisma.foods.findUnique({ where: { id: deleteFoodDto.id, }, include: { restaurant: true, images: true, }, }); if (food.restaurant....
// delete foods of a restaurant
https://github.com/shahriarsajeeb/Food-Delivery-WebApp/blob/c26ac7f3873ee965a367d1836386686f5336bacf/apps/api-restuarants/src/foods/foods.service.ts#L97-L128
c26ac7f3873ee965a367d1836386686f5336bacf
Food-Delivery-WebApp
github_2023
shahriarsajeeb
typescript
UsersService.register
async register(registerDto: RegisterDto, response: Response) { const { name, email, password, phone_number } = registerDto; const isEmailExist = await this.prisma.user.findUnique({ where: { email, }, }); if (isEmailExist) { throw new BadRequestException('User already exist wit...
// register user service
https://github.com/shahriarsajeeb/Food-Delivery-WebApp/blob/c26ac7f3873ee965a367d1836386686f5336bacf/apps/api-users/src/user.service.ts#L34-L87
c26ac7f3873ee965a367d1836386686f5336bacf
Food-Delivery-WebApp
github_2023
shahriarsajeeb
typescript
UsersService.createActivationToken
async createActivationToken(user: UserData) { const activationCode = Math.floor(1000 + Math.random() * 9000).toString(); const token = this.jwtService.sign( { user, activationCode, }, { secret: this.configService.get<string>('ACTIVATION_SECRET'), expiresIn: '5m...
// create activation token
https://github.com/shahriarsajeeb/Food-Delivery-WebApp/blob/c26ac7f3873ee965a367d1836386686f5336bacf/apps/api-users/src/user.service.ts#L90-L104
c26ac7f3873ee965a367d1836386686f5336bacf
Food-Delivery-WebApp
github_2023
shahriarsajeeb
typescript
UsersService.activateUser
async activateUser(activationDto: ActivationDto, response: Response) { const { activationToken, activationCode } = activationDto; const newUser: { user: UserData; activationCode: string } = this.jwtService.verify(activationToken, { secret: this.configService.get<string>('ACTIVATION_SECRET'), ...
// activation user
https://github.com/shahriarsajeeb/Food-Delivery-WebApp/blob/c26ac7f3873ee965a367d1836386686f5336bacf/apps/api-users/src/user.service.ts#L107-L141
c26ac7f3873ee965a367d1836386686f5336bacf
Food-Delivery-WebApp
github_2023
shahriarsajeeb
typescript
UsersService.Login
async Login(loginDto: LoginDto) { const { email, password } = loginDto; const user = await this.prisma.user.findUnique({ where: { email, }, }); if (user && (await this.comparePassword(password, user.password))) { const tokenSender = new TokenSender(this.configService, this.jwt...
// Login service
https://github.com/shahriarsajeeb/Food-Delivery-WebApp/blob/c26ac7f3873ee965a367d1836386686f5336bacf/apps/api-users/src/user.service.ts#L144-L165
c26ac7f3873ee965a367d1836386686f5336bacf
Food-Delivery-WebApp
github_2023
shahriarsajeeb
typescript
UsersService.comparePassword
async comparePassword( password: string, hashedPassword: string, ): Promise<boolean> { return await bcrypt.compare(password, hashedPassword); }
// compare with hashed password
https://github.com/shahriarsajeeb/Food-Delivery-WebApp/blob/c26ac7f3873ee965a367d1836386686f5336bacf/apps/api-users/src/user.service.ts#L168-L173
c26ac7f3873ee965a367d1836386686f5336bacf
Food-Delivery-WebApp
github_2023
shahriarsajeeb
typescript
UsersService.generateForgotPasswordLink
async generateForgotPasswordLink(user: User) { const forgotPasswordToken = this.jwtService.sign( { user, }, { secret: this.configService.get<string>('FORGOT_PASSWORD_SECRET'), expiresIn: '5m', }, ); return forgotPasswordToken; }
// generate forgot password link
https://github.com/shahriarsajeeb/Food-Delivery-WebApp/blob/c26ac7f3873ee965a367d1836386686f5336bacf/apps/api-users/src/user.service.ts#L176-L187
c26ac7f3873ee965a367d1836386686f5336bacf
Food-Delivery-WebApp
github_2023
shahriarsajeeb
typescript
UsersService.forgotPassword
async forgotPassword(forgotPasswordDto: ForgotPasswordDto) { const { email } = forgotPasswordDto; const user = await this.prisma.user.findUnique({ where: { email, }, }); if (!user) { throw new BadRequestException('User not found with this email!'); } const forgotPasswo...
// forgot password
https://github.com/shahriarsajeeb/Food-Delivery-WebApp/blob/c26ac7f3873ee965a367d1836386686f5336bacf/apps/api-users/src/user.service.ts#L190-L216
c26ac7f3873ee965a367d1836386686f5336bacf
Food-Delivery-WebApp
github_2023
shahriarsajeeb
typescript
UsersService.resetPassword
async resetPassword(resetPasswordDto: ResetPasswordDto) { const { password, activationToken } = resetPasswordDto; const decoded = await this.jwtService.decode(activationToken); if (!decoded || decoded?.exp * 1000 < Date.now()) { throw new BadRequestException('Invalid token!'); } const hashe...
// reset password
https://github.com/shahriarsajeeb/Food-Delivery-WebApp/blob/c26ac7f3873ee965a367d1836386686f5336bacf/apps/api-users/src/user.service.ts#L219-L240
c26ac7f3873ee965a367d1836386686f5336bacf
Food-Delivery-WebApp
github_2023
shahriarsajeeb
typescript
UsersService.getLoggedInUser
async getLoggedInUser(req: any) { const user = req.user; const refreshToken = req.refreshtoken; const accessToken = req.accesstoken; return { user, refreshToken, accessToken }; }
// eslint-disable-next-line @typescript-eslint/no-explicit-any
https://github.com/shahriarsajeeb/Food-Delivery-WebApp/blob/c26ac7f3873ee965a367d1836386686f5336bacf/apps/api-users/src/user.service.ts#L244-L249
c26ac7f3873ee965a367d1836386686f5336bacf
Food-Delivery-WebApp
github_2023
shahriarsajeeb
typescript
UsersService.Logout
async Logout(req: any) { req.user = null; req.refreshtoken = null; req.accesstoken = null; return { message: 'Logged out successfully!' }; }
// eslint-disable-next-line @typescript-eslint/no-explicit-any
https://github.com/shahriarsajeeb/Food-Delivery-WebApp/blob/c26ac7f3873ee965a367d1836386686f5336bacf/apps/api-users/src/user.service.ts#L253-L258
c26ac7f3873ee965a367d1836386686f5336bacf
Food-Delivery-WebApp
github_2023
shahriarsajeeb
typescript
UsersService.getUsers
async getUsers() { return this.prisma.user.findMany({}); }
// get all users service
https://github.com/shahriarsajeeb/Food-Delivery-WebApp/blob/c26ac7f3873ee965a367d1836386686f5336bacf/apps/api-users/src/user.service.ts#L261-L263
c26ac7f3873ee965a367d1836386686f5336bacf
Food-Delivery-WebApp
github_2023
shahriarsajeeb
typescript
AuthGuard.updateAccessToken
private async updateAccessToken(req: any): Promise<void> { try { const refreshTokenData = req.headers.refreshtoken as string; const decoded = this.jwtService.decode(refreshTokenData); const expirationTime = decoded.exp * 1000; if (expirationTime < Date.now()) { t...
// eslint-disable-next-line @typescript-eslint/no-explicit-any
https://github.com/shahriarsajeeb/Food-Delivery-WebApp/blob/c26ac7f3873ee965a367d1836386686f5336bacf/apps/api-users/src/guards/auth.guard.ts#L45-L87
c26ac7f3873ee965a367d1836386686f5336bacf
OpenAssistantGPT
github_2023
OpenAssistantGPT
typescript
concatChunks
function concatChunks(chunks: Uint8Array[], totalLength: number) { const concatenatedChunks = new Uint8Array(totalLength); let offset = 0; for (const chunk of chunks) { concatenatedChunks.set(chunk, offset); offset += chunk.length; } chunks.length = 0; return concatenatedChunks; }
// concatenates all the chunks into a single Uint8Array
https://github.com/OpenAssistantGPT/OpenAssistantGPT/blob/644f2a5f68125d8bdbd72b6d20b0f19ced1bb2bc/lib/read-data-stream.ts#L6-L17
644f2a5f68125d8bdbd72b6d20b0f19ced1bb2bc
hsr-optimizer
github_2023
fribbels
typescript
readBuffer
async function readBuffer(offset: number, gpuReadBuffer: GPUBuffer, gpuContext: GpuExecutionContext, elementOffset: number = 0) { await gpuReadBuffer.mapAsync(GPUMapMode.READ, elementOffset) const arrayBuffer = gpuReadBuffer.getMappedRange(elementOffset * 4) const array = new Float32Array(arrayBuffer) const r...
// eslint-disable-next-line
https://github.com/fribbels/hsr-optimizer/blob/dcd874755b98536e01ee8cc1c099aa8f55dd2d5e/src/lib/gpu/webgpuOptimizer.ts#L110-L164
dcd874755b98536e01ee8cc1c099aa8f55dd2d5e
hsr-optimizer
github_2023
fribbels
typescript
getHash
function getHash(key: string) { let hash1 = 5381 let hash2 = 5381 for (let i = 0; i < key.length; i += 2) { hash1 = Math.imul((hash1 << 5) + hash1, 1) ^ key.charCodeAt(i) if (i === key.length - 1) break hash2 = Math.imul((hash2 << 5) + hash2, 1) ^ key.charCodeAt(i + 1) } return Math.imul(has...
// from the readme on Dim's old github repo
https://github.com/fribbels/hsr-optimizer/blob/dcd874755b98536e01ee8cc1c099aa8f55dd2d5e/src/lib/i18n/generateTranslations.ts#L302-L312
dcd874755b98536e01ee8cc1c099aa8f55dd2d5e
hsr-optimizer
github_2023
fribbels
typescript
readCharacterV3
function readCharacterV3(character: V4ParserCharacter & { key: string }, lightCones: (V4ParserLightCone & { key: string })[], trailblazer, path) { let lightCone: (V4ParserLightCone & { key: string }) | undefined if (lightCones) { if (character.key.startsWith('Trailblazer')) { lightCone = lightCo...
// ================================================== V3 ==================================================
https://github.com/fribbels/hsr-optimizer/blob/dcd874755b98536e01ee8cc1c099aa8f55dd2d5e/src/lib/importer/kelzFormatParser.tsx#L179-L219
dcd874755b98536e01ee8cc1c099aa8f55dd2d5e
hsr-optimizer
github_2023
fribbels
typescript
readCharacterV4
function readCharacterV4(character: V4ParserCharacter, lightCones: V4ParserLightCone[]) { let lightCone: V4ParserLightCone | undefined if (lightCones) { // TODO: don't search on an array lightCone = lightCones.find((x) => x.location === character.id) } const characterId = character.id const lightCon...
// ================================================== V4 ==================================================
https://github.com/fribbels/hsr-optimizer/blob/dcd874755b98536e01ee8cc1c099aa8f55dd2d5e/src/lib/importer/kelzFormatParser.tsx#L257-L278
dcd874755b98536e01ee8cc1c099aa8f55dd2d5e
hsr-optimizer
github_2023
fribbels
typescript
FixedSizePriorityQueue.fixedSizePushOvercapped
fixedSizePushOvercapped(item: T): T { this.push(item) return this.pop()! }
// If we already know the queue is full, skip the checks
https://github.com/fribbels/hsr-optimizer/blob/dcd874755b98536e01ee8cc1c099aa8f55dd2d5e/src/lib/optimization/fixedSizePriorityQueue.ts#L29-L32
dcd874755b98536e01ee8cc1c099aa8f55dd2d5e
hsr-optimizer
github_2023
fribbels
typescript
relicSetAllowListToIndices
function relicSetAllowListToIndices(arr: number[]) { const out: number[] = [] for (let i = 0; i < arr.length; i++) { while (arr[i]) { arr[i]-- out.push(i) } } return out }
// [0, 0, 0, 2, 0, 2] => [3, 3, 5, 5]
https://github.com/fribbels/hsr-optimizer/blob/dcd874755b98536e01ee8cc1c099aa8f55dd2d5e/src/lib/optimization/relicSetSolver.ts#L79-L89
dcd874755b98536e01ee8cc1c099aa8f55dd2d5e
hsr-optimizer
github_2023
fribbels
typescript
fillRelicSetArrPossibilities
function fillRelicSetArrPossibilities(arr: number[], len: number) { const out: number[][] = [] for (let i = 0; i < len; i++) { for (let j = 0; j < len; j++) { const newArr: number[] = Utils.arrayOfZeroes(4) newArr[0] = arr[0] newArr[1] = arr[1] newArr[2] = i newArr[3] = j ou...
// [5, 5] => [[5,5,0,0], [5,5,0,1], [5,5,1,1], [5,5,1,2], ...]
https://github.com/fribbels/hsr-optimizer/blob/dcd874755b98536e01ee8cc1c099aa8f55dd2d5e/src/lib/optimization/relicSetSolver.ts#L92-L107
dcd874755b98536e01ee8cc1c099aa8f55dd2d5e
hsr-optimizer
github_2023
fribbels
typescript
convertRelicSetIndicesTo1D
function convertRelicSetIndicesTo1D(setIndices: number[][]) { const len = Constants.SetsRelicsNames.length if (setIndices.length == 0) { return Utils.arrayOfValue(Math.pow(len, 4), 1) } const arr = Utils.arrayOfZeroes(Math.pow(len, 4)) for (let i = 0; i < setIndices.length; i++) { const y = setIndic...
// [[5,5,0,0], [5,5,0,1], [5,5,1,1], [5,5,1,2], ...] => [0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0..]
https://github.com/fribbels/hsr-optimizer/blob/dcd874755b98536e01ee8cc1c099aa8f55dd2d5e/src/lib/optimization/relicSetSolver.ts#L110-L128
dcd874755b98536e01ee8cc1c099aa8f55dd2d5e
hsr-optimizer
github_2023
fribbels
typescript
sortSubstats
function sortSubstats(relic: Relic) { relic.substats = relic.substats.sort((a, b) => substatToOrder[a.stat] - substatToOrder[b.stat]) }
// Relic substats are always sorted in the predefined order above when the user logs out.
https://github.com/fribbels/hsr-optimizer/blob/dcd874755b98536e01ee8cc1c099aa8f55dd2d5e/src/lib/relics/relicAugmenter.ts#L71-L73
dcd874755b98536e01ee8cc1c099aa8f55dd2d5e
hsr-optimizer
github_2023
fribbels
typescript
fixAugmentedStats
function fixAugmentedStats(relics: Relic[]) { return relics.map((relic) => { for (const stat of Object.values(Constants.Stats)) { if (!relic.augmentedStats) continue relic.augmentedStats[stat] = relic.augmentedStats[stat] || 0 if (!Utils.isFlat(stat)) { if (relic.augmentedStats.mainStat...
// Changes the augmented stats percents to decimals
https://github.com/fribbels/hsr-optimizer/blob/dcd874755b98536e01ee8cc1c099aa8f55dd2d5e/src/lib/relics/relicAugmenter.ts#L76-L91
dcd874755b98536e01ee8cc1c099aa8f55dd2d5e
hsr-optimizer
github_2023
fribbels
typescript
search
function search(sum: number, counts: StatRolls, index: number): void { if (index === Object.keys(incrementOptions).length) { if (Math.abs(sum - currentStat) < Math.abs(closestSum - currentStat)) { closestSum = sum closestCounts = { ...counts } } return } co...
// TODO: There is a bug in this where it potentially overcounts the number of rolls when ambiguous.
https://github.com/fribbels/hsr-optimizer/blob/dcd874755b98536e01ee8cc1c099aa8f55dd2d5e/src/lib/relics/relicRollGrader.ts#L23-L37
dcd874755b98536e01ee8cc1c099aa8f55dd2d5e
hsr-optimizer
github_2023
fribbels
typescript
RelicScorer.scoreFutureRelic
static scoreFutureRelic(relic: Relic, characterId: CharacterId, withMeta: boolean = false) { return new RelicScorer().getFutureRelicScore(relic, characterId, withMeta) }
/** * returns the current score of the relic, as well as the best, worst, and average scores when at max enhance\ * meta field includes the ideal added and/or upgraded substats for the relic */
https://github.com/fribbels/hsr-optimizer/blob/dcd874755b98536e01ee8cc1c099aa8f55dd2d5e/src/lib/relics/relicScorerPotential.ts#L138-L140
dcd874755b98536e01ee8cc1c099aa8f55dd2d5e
hsr-optimizer
github_2023
fribbels
typescript
RelicScorer.scoreCurrentRelic
static scoreCurrentRelic(relic: Relic, id: CharacterId): RelicScoringResult { return new RelicScorer().getCurrentRelicScore(relic, id) }
/** * returns the current score, mainstat score, and rating for the relic\ * additionally returns the part, and scoring metadata */
https://github.com/fribbels/hsr-optimizer/blob/dcd874755b98536e01ee8cc1c099aa8f55dd2d5e/src/lib/relics/relicScorerPotential.ts#L146-L148
dcd874755b98536e01ee8cc1c099aa8f55dd2d5e
hsr-optimizer
github_2023
fribbels
typescript
RelicScorer.scoreCharacterWithRelics
static scoreCharacterWithRelics(character: Character, relics: Relic[]) { return new RelicScorer().scoreCharacterWithRelics(character, relics) }
/** * returns a score (number) and rating (string) for the character, and the scored relics * @param character character object to score * @param relics relics to score against the character */
https://github.com/fribbels/hsr-optimizer/blob/dcd874755b98536e01ee8cc1c099aa8f55dd2d5e/src/lib/relics/relicScorerPotential.ts#L155-L157
dcd874755b98536e01ee8cc1c099aa8f55dd2d5e
hsr-optimizer
github_2023
fribbels
typescript
RelicScorer.scoreCharacter
static scoreCharacter(character: Character) { return new RelicScorer().scoreCharacter(character) }
/** * returns a score (number) and rating (string) for the character, and the scored equipped relics * @param character character object to score */
https://github.com/fribbels/hsr-optimizer/blob/dcd874755b98536e01ee8cc1c099aa8f55dd2d5e/src/lib/relics/relicScorerPotential.ts#L163-L165
dcd874755b98536e01ee8cc1c099aa8f55dd2d5e
hsr-optimizer
github_2023
fribbels
typescript
RelicScorer.scoreRelicPotential
static scoreRelicPotential(relic: Relic, characterId: CharacterId, withMeta: boolean = false) { return new RelicScorer().scoreRelicPotential(relic, characterId, withMeta) }
/** * evaluates the max, min, and avg potential optimalities of a relic * @param relic relic to evaluate * @param characterId id of character to evaluate against * @param withMeta whether or not to include the character scoringMetadata in the return */
https://github.com/fribbels/hsr-optimizer/blob/dcd874755b98536e01ee8cc1c099aa8f55dd2d5e/src/lib/relics/relicScorerPotential.ts#L173-L175
dcd874755b98536e01ee8cc1c099aa8f55dd2d5e
hsr-optimizer
github_2023
fribbels
typescript
RelicScorer.getRelicScoreMeta
getRelicScoreMeta(id: CharacterId): ScoringMetadata { let scoringMetadata = this.characterRelicScoreMetas.get(id) if (scoringMetadata) return scoringMetadata scoringMetadata = Utils.clone(DB.getScoringMetadata(id)) as ScoringMetadata const defaultScoringMetadata = DB.getMetadata().characters[id].scori...
/** * returns the scoring metadata for the given character * @param id id of the character who's scoring data is wanted */
https://github.com/fribbels/hsr-optimizer/blob/dcd874755b98536e01ee8cc1c099aa8f55dd2d5e/src/lib/relics/relicScorerPotential.ts#L181-L242
dcd874755b98536e01ee8cc1c099aa8f55dd2d5e
hsr-optimizer
github_2023
fribbels
typescript
RelicScorer.substatScore
substatScore(relic: Relic, id: CharacterId) { const scoringMetadata = this.getRelicScoreMeta(id) if (!scoringMetadata || !id || !relic) { console.warn('substatScore() called but missing 1 or more arguments. relic:', relic, 'meta:', scoringMetadata, 'id:', id) return { score: 0, mainS...
/** * returns the substat score of the given relic, does not include mainstat bonus */
https://github.com/fribbels/hsr-optimizer/blob/dcd874755b98536e01ee8cc1c099aa8f55dd2d5e/src/lib/relics/relicScorerPotential.ts#L296-L336
dcd874755b98536e01ee8cc1c099aa8f55dd2d5e
hsr-optimizer
github_2023
fribbels
typescript
RelicScorer.scoreOptimalRelic
scoreOptimalRelic(part: Parts, mainstat: MainStats, id: CharacterId) { let maxScore: number = 0 let fake: Relic const meta = this.getRelicScoreMeta(id) const handlingCase = getHandlingCase(meta) switch (handlingCase) { case relicPotentialCases.NONE: maxScore = Infinity// force relic po...
/** * returns the substat score for the ideal relic\ * handles special cases scoring for when only 1 stat has been weighted by the user */
https://github.com/fribbels/hsr-optimizer/blob/dcd874755b98536e01ee8cc1c099aa8f55dd2d5e/src/lib/relics/relicScorerPotential.ts#L342-L444
dcd874755b98536e01ee8cc1c099aa8f55dd2d5e
hsr-optimizer
github_2023
fribbels
typescript
RelicScorer.scoreFutureRelic
scoreFutureRelic(relic: Relic, id: CharacterId, withMeta: boolean = false) { if (!id || !relic) { console.warn('scoreFutureRelic() called but lacking arguments') return { current: 0, best: 0, average: 0, worst: 0, rerollAvg: 0, idealScore: 1, meta:...
/** * returns the current score of the relic, as well as the best, worst, and average scores when at max enhance\ * meta field includes the ideal added and/or upgraded substats for the relic */
https://github.com/fribbels/hsr-optimizer/blob/dcd874755b98536e01ee8cc1c099aa8f55dd2d5e/src/lib/relics/relicScorerPotential.ts#L450-L667
dcd874755b98536e01ee8cc1c099aa8f55dd2d5e
hsr-optimizer
github_2023
fribbels
typescript
RelicScorer.scoreCurrentRelic
scoreCurrentRelic(relic: Relic, id: CharacterId): RelicScoringResult { if (!relic) { // console.warn('scoreCurrentRelic called but no relic given for character', id ?? '????') return { score: '', rating: '', mainStatScore: 0, } } if (!id) { console.warn('score...
/** * returns the current score, mainstat score, and rating for the relic\ * additionally returns the part, and scoring metadata */
https://github.com/fribbels/hsr-optimizer/blob/dcd874755b98536e01ee8cc1c099aa8f55dd2d5e/src/lib/relics/relicScorerPotential.ts#L673-L705
dcd874755b98536e01ee8cc1c099aa8f55dd2d5e
hsr-optimizer
github_2023
fribbels
typescript
RelicScorer.scoreCharacterWithRelics
scoreCharacterWithRelics(character: Character, relics: Relic[]): { relics: object[] totalScore: number totalRating: string } { if (!character?.id) { console.warn('scoreCharacterWithRelics called but no character given') return { relics: [], totalScore: 0, totalRatin...
/** * returns a score (number) and rating (string) for the character, and the scored relics * @param character character object to score * @param relics relics to score against the character */
https://github.com/fribbels/hsr-optimizer/blob/dcd874755b98536e01ee8cc1c099aa8f55dd2d5e/src/lib/relics/relicScorerPotential.ts#L712-L739
dcd874755b98536e01ee8cc1c099aa8f55dd2d5e
hsr-optimizer
github_2023
fribbels
typescript
RelicScorer.scoreCharacter
scoreCharacter(character: Character) { if (!character) return {} const relicsById = window.store.getState().relicsById const relics: Relic[] = Object.values(character.equipped).map((x) => relicsById[x ?? '']) return this.scoreCharacterWithRelics(character, relics) }
/** * returns a score (number) and rating (string) for the character, and the scored equipped relics * @param character character object to score */
https://github.com/fribbels/hsr-optimizer/blob/dcd874755b98536e01ee8cc1c099aa8f55dd2d5e/src/lib/relics/relicScorerPotential.ts#L745-L750
dcd874755b98536e01ee8cc1c099aa8f55dd2d5e
hsr-optimizer
github_2023
fribbels
typescript
RelicScorer.scoreRelicPotential
scoreRelicPotential(relic: Relic, id: CharacterId, withMeta: boolean = false) { const meta = this.getRelicScoreMeta(id) const mainstatBonus = mainStatBonus(relic.part, relic.main.stat, meta) const futureScore = this.getFutureRelicScore(relic, id, withMeta) return { bestPct: Math.max(0, futureScor...
// linear relation between score and potential makes this very easy now
https://github.com/fribbels/hsr-optimizer/blob/dcd874755b98536e01ee8cc1c099aa8f55dd2d5e/src/lib/relics/relicScorerPotential.ts#L759-L771
dcd874755b98536e01ee8cc1c099aa8f55dd2d5e
hsr-optimizer
github_2023
fribbels
typescript
fakeRelic
function fakeRelic(grade: RelicGrade, enhance: RelicEnhance, part: string, mainstat: string, substats: subStat[]): Relic { return { enhance: enhance, grade: grade, part: part, main: { stat: mainstat, value: MainStatsValues[mainstat][grade].base + MainStatsValues[mainstat][grade].increment ...
/** * creates a fake relic that can be submitted for scoring * @param grade relic rarity * @param enhance relic level * @param part relic slot * @param mainstat relic primary stat * @param substats array of substats, recommended to obtain via generateSubStats() */
https://github.com/fribbels/hsr-optimizer/blob/dcd874755b98536e01ee8cc1c099aa8f55dd2d5e/src/lib/relics/relicScorerPotential.ts#L810-L821
dcd874755b98536e01ee8cc1c099aa8f55dd2d5e