Made requested changes.

This commit is contained in:
Matt C 2017-03-27 20:30:32 +00:00
parent 497824ff21
commit 96e40a6479
3 changed files with 7 additions and 42 deletions

View file

@ -432,7 +432,7 @@ var OperationConfig = {
{
name: "Delimiter",
type: "option",
value: ByteRepr.OCT_DELIM_OPTIONS
value: ByteRepr.DELIM_OPTIONS
}
]
},
@ -447,7 +447,7 @@ var OperationConfig = {
{
name: "Delimiter",
type: "option",
value: ByteRepr.OCT_DELIM_OPTIONS
value: ByteRepr.DELIM_OPTIONS
}
]
},

View file

@ -828,38 +828,6 @@ var Utils = {
},
/**
* Convert an byte array into a octal string
*
* @author Matt C [matt@artemisbot.pw]
* @param {byteArray} data
* @param {string} [delim]
* @returns {string}
*
*/
toOct: function(data, delim) {
var output = "";
delim = delim || "Space";
data.map(val => output += (parseInt(Utils.bin(val), 2).toString(8) + delim));
return output.slice(0, -delim.length);
},
/**
* Convert an Octal string into a byte array.
*
* @author Matt C [matt@artemisbot.pw]
* @param {string} data
* @param {string} [delim]
* @returns {byteArray}
*
*/
fromOct: function(data, delim) {
delim = delim || "Space";
return data.split(delim).map(val => parseInt(val, 8));
},
/**
* Parses CSV data and returns it as a two dimensional array or strings.
*

View file

@ -21,11 +21,6 @@ var ByteRepr = {
* @default
*/
HEX_DELIM_OPTIONS: ["Space", "Comma", "Semi-colon", "Colon", "Line feed", "CRLF", "0x", "\\x", "None"],
/**
* @constant
* @default
*/
OCT_DELIM_OPTIONS: ["Space", "Comma", "Semi-colon", "Colon", "Line feed", "CRLF"],
/**
* @constant
* @default
@ -67,8 +62,10 @@ var ByteRepr = {
* @returns {string}
*/
runToOct: function(input, args) {
var delim = Utils.charRep[args[0] || "Space"];
return Utils.toOct(input, delim, 2);
var delim = Utils.charRep[args[0] || "Space"],
output = "";
input.map(val => output += (parseInt(Utils.bin(val), 2).toString(8) + delim));
return output.slice(0, -delim.length);
},
/**
@ -81,7 +78,7 @@ var ByteRepr = {
*/
runFromOct: function(input, args) {
var delim = Utils.charRep[args[0] || "Space"];
return Utils.fromOct(input, delim);
return input.split(delim).map(val => parseInt(val, 8));
},
/**