Added signed feature to 'To Decimal'
This commit is contained in:
parent
ca47ba3c7c
commit
91fc2c28dc
@ -31,7 +31,7 @@ class FromDecimal extends Operation {
|
|||||||
"value": DELIM_OPTIONS
|
"value": DELIM_OPTIONS
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
"name": "Convert negatives",
|
"name": "Support signed values",
|
||||||
"type": "boolean",
|
"type": "boolean",
|
||||||
"value": false
|
"value": false
|
||||||
}
|
}
|
||||||
@ -40,32 +40,32 @@ class FromDecimal extends Operation {
|
|||||||
{
|
{
|
||||||
match: "^(?:\\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]))*$",
|
match: "^(?:\\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: "",
|
flags: "",
|
||||||
args: ["Space"]
|
args: ["Space", false]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
match: "^(?:\\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]))*$",
|
match: "^(?:\\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: "",
|
flags: "",
|
||||||
args: ["Comma"]
|
args: ["Comma", false]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
match: "^(?:\\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]))*$",
|
match: "^(?:\\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: "",
|
flags: "",
|
||||||
args: ["Semi-colon"]
|
args: ["Semi-colon", false]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
match: "^(?:\\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]))*$",
|
match: "^(?:\\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: "",
|
flags: "",
|
||||||
args: ["Colon"]
|
args: ["Colon", false]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
match: "^(?:\\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]))*$",
|
match: "^(?:\\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: "",
|
flags: "",
|
||||||
args: ["Line feed"]
|
args: ["Line feed", false]
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
match: "^(?:\\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]))*$",
|
match: "^(?:\\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: "",
|
flags: "",
|
||||||
args: ["CRLF"]
|
args: ["CRLF", false]
|
||||||
},
|
},
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
|
@ -30,6 +30,11 @@ class ToDecimal extends Operation {
|
|||||||
"name": "Delimiter",
|
"name": "Delimiter",
|
||||||
"type": "option",
|
"type": "option",
|
||||||
"value": DELIM_OPTIONS
|
"value": DELIM_OPTIONS
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"name": "Support signed values",
|
||||||
|
"type": "boolean",
|
||||||
|
"value": false
|
||||||
}
|
}
|
||||||
];
|
];
|
||||||
}
|
}
|
||||||
@ -40,7 +45,11 @@ class ToDecimal extends Operation {
|
|||||||
* @returns {string}
|
* @returns {string}
|
||||||
*/
|
*/
|
||||||
run(input, args) {
|
run(input, args) {
|
||||||
const delim = Utils.charRep(args[0]);
|
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);
|
return input.join(delim);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -8,26 +8,26 @@
|
|||||||
import TestRegister from "../../TestRegister";
|
import TestRegister from "../../TestRegister";
|
||||||
|
|
||||||
TestRegister.addTests([
|
TestRegister.addTests([
|
||||||
{
|
{
|
||||||
name: "From Decimal",
|
name: "From Decimal",
|
||||||
input: "83 97 109 112 108 101 32 84 101 120 116",
|
input: "83 97 109 112 108 101 32 84 101 120 116",
|
||||||
expectedOutput: "Sample Text",
|
expectedOutput: "Sample Text",
|
||||||
recipeConfig: [
|
recipeConfig: [
|
||||||
{
|
{
|
||||||
op: "From Decimal",
|
op: "From Decimal",
|
||||||
args: ["Space", false]
|
args: ["Space", false]
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
name: "From Decimal with negatives",
|
name: "From Decimal with negatives",
|
||||||
input: "-130,-140,-152,-151,115,33,0,-1",
|
input: "-130,-140,-152,-151,115,33,0,-1",
|
||||||
expectedOutput: "~this!\u0000\u00ff",
|
expectedOutput: "~this!\u0000\u00ff",
|
||||||
recipeConfig: [
|
recipeConfig: [
|
||||||
{
|
{
|
||||||
op: "From Decimal",
|
op: "From Decimal",
|
||||||
args: ["Comma", true]
|
args: ["Comma", true]
|
||||||
},
|
},
|
||||||
],
|
],
|
||||||
},
|
},
|
||||||
]);
|
]);
|
||||||
|
Loading…
Reference in New Issue
Block a user