mirror of
https://github.com/gchq/CyberChef.git
synced 2025-04-21 07:16:17 -04:00
eslint autofix
This commit is contained in:
parent
0d42541860
commit
ad730d806b
60 changed files with 13067 additions and 13014 deletions
|
@ -8,14 +8,14 @@
|
|||
* @class
|
||||
* @param {Object} ingredient_config
|
||||
*/
|
||||
var Ingredient = function(ingredient_config) {
|
||||
this.name = "";
|
||||
this.type = "";
|
||||
this.value = null;
|
||||
|
||||
if (ingredient_config) {
|
||||
this._parse_config(ingredient_config);
|
||||
}
|
||||
const Ingredient = function (ingredient_config) {
|
||||
this.name = '';
|
||||
this.type = '';
|
||||
this.value = null;
|
||||
|
||||
if (ingredient_config) {
|
||||
this._parse_config(ingredient_config);
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
@ -25,9 +25,9 @@ var Ingredient = function(ingredient_config) {
|
|||
* @private
|
||||
* @param {Object} ingredient_config
|
||||
*/
|
||||
Ingredient.prototype._parse_config = function(ingredient_config) {
|
||||
this.name = ingredient_config.name;
|
||||
this.type = ingredient_config.type;
|
||||
Ingredient.prototype._parse_config = function (ingredient_config) {
|
||||
this.name = ingredient_config.name;
|
||||
this.type = ingredient_config.type;
|
||||
};
|
||||
|
||||
|
||||
|
@ -36,8 +36,8 @@ Ingredient.prototype._parse_config = function(ingredient_config) {
|
|||
*
|
||||
* @returns {*}
|
||||
*/
|
||||
Ingredient.prototype.get_config = function() {
|
||||
return this.value;
|
||||
Ingredient.prototype.get_config = function () {
|
||||
return this.value;
|
||||
};
|
||||
|
||||
|
||||
|
@ -46,8 +46,8 @@ Ingredient.prototype.get_config = function() {
|
|||
*
|
||||
* @param {*} value
|
||||
*/
|
||||
Ingredient.prototype.set_value = function(value) {
|
||||
this.value = Ingredient.prepare(value, this.type);
|
||||
Ingredient.prototype.set_value = function (value) {
|
||||
this.value = Ingredient.prepare(value, this.type);
|
||||
};
|
||||
|
||||
|
||||
|
@ -59,28 +59,28 @@ Ingredient.prototype.set_value = function(value) {
|
|||
* @param {*} data
|
||||
* @param {string} type - The name of the data type.
|
||||
*/
|
||||
Ingredient.prepare = function(data, type) {
|
||||
switch (type) {
|
||||
case "binary_string":
|
||||
case "binary_short_string":
|
||||
case "editable_option":
|
||||
return Utils.parse_escaped_chars(data);
|
||||
case "byte_array":
|
||||
if (typeof data == "string") {
|
||||
data = data.replace(/\s+/g, '');
|
||||
return Utils.hex_to_byte_array(data);
|
||||
} else {
|
||||
return data;
|
||||
}
|
||||
break;
|
||||
case "number":
|
||||
var number = parseFloat(data);
|
||||
if (isNaN(number)) {
|
||||
var sample = Utils.truncate(data.toString(), 10);
|
||||
throw "Invalid ingredient value. Not a number: " + sample;
|
||||
}
|
||||
return number;
|
||||
default:
|
||||
return data;
|
||||
}
|
||||
Ingredient.prepare = function (data, type) {
|
||||
switch (type) {
|
||||
case 'binary_string':
|
||||
case 'binary_short_string':
|
||||
case 'editable_option':
|
||||
return Utils.parse_escaped_chars(data);
|
||||
case 'byte_array':
|
||||
if (typeof data === 'string') {
|
||||
data = data.replace(/\s+/g, '');
|
||||
return Utils.hex_to_byte_array(data);
|
||||
} else {
|
||||
return data;
|
||||
}
|
||||
break;
|
||||
case 'number':
|
||||
var number = parseFloat(data);
|
||||
if (isNaN(number)) {
|
||||
const sample = Utils.truncate(data.toString(), 10);
|
||||
throw `Invalid ingredient value. Not a number: ${sample}`;
|
||||
}
|
||||
return number;
|
||||
default:
|
||||
return data;
|
||||
}
|
||||
};
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue