Update ToPythonString.mjs
Update after check in pull request failed
This commit is contained in:
parent
3b8997003c
commit
364427c3e5
@ -5,7 +5,6 @@
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
import Operation from "../Operation.mjs";
|
import Operation from "../Operation.mjs";
|
||||||
import OperationError from "../errors/OperationError.mjs";
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* toPythonString operation
|
* toPythonString operation
|
||||||
@ -32,12 +31,12 @@ class ToPythonString extends Operation {
|
|||||||
* @param {int} value
|
* @param {int} value
|
||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
toPyChar(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
|
// 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)
|
if (32 <= value && value <= 126)
|
||||||
return String.fromCharCode(value)
|
return String.fromCharCode(value);
|
||||||
else
|
else
|
||||||
return "\\x" + value.toString(16).padStart(2, "0")
|
return "\\x" + value.toString(16).padStart(2, "0");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -46,7 +45,7 @@ class ToPythonString extends Operation {
|
|||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
run(input, args) {
|
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("") + '"';
|
return 'b"' + input.map(this.toPyChar).join("") + '"';
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user