From 364427c3e521a6ece1feac48ff38f447d0e58477 Mon Sep 17 00:00:00 2001 From: Samuele Facenda Date: Sun, 2 Oct 2022 10:35:52 +0200 Subject: [PATCH] Update ToPythonString.mjs Update after check in pull request failed --- src/core/operations/ToPythonString.mjs | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/src/core/operations/ToPythonString.mjs b/src/core/operations/ToPythonString.mjs index 6e5758b2..c6bc3f61 100644 --- a/src/core/operations/ToPythonString.mjs +++ b/src/core/operations/ToPythonString.mjs @@ -5,7 +5,6 @@ */ import Operation from "../Operation.mjs"; -import OperationError from "../errors/OperationError.mjs"; /** * toPythonString operation @@ -32,21 +31,21 @@ class ToPythonString extends Operation { * @param {int} value * @returns {string} */ - toPyChar(value){ - //check if it's a standard ascii value and return the corresponding char or format it as a hex value with the \x prefix - if(32 <= value && value <= 126) - return String.fromCharCode(value) + toPyChar(value) { + // check if it's a standard ascii value and return the corresponding char or format it as a hex value with the \x prefix + if (32 <= value && value <= 126) + return String.fromCharCode(value); else - return "\\x" + value.toString(16).padStart(2, "0") + return "\\x" + value.toString(16).padStart(2, "0"); } - + /** * @param {byteArray} input * @param {Object[]} args * @returns {string} */ run(input, args) { - //format the converted string as a python byte string + // format the converted string as a python byte string return 'b"' + input.map(this.toPyChar).join("") + '"'; }