add formatter

This commit is contained in:
Hare Sudhan 2024-02-24 22:59:51 -05:00
parent c4e7c41a6e
commit ce30989adc
693 changed files with 51226 additions and 26671 deletions

View file

@ -5,21 +5,20 @@
*/
import Utils from "./Utils.mjs";
import {fromHex} from "./lib/Hex.mjs";
import { fromHex } from "./lib/Hex.mjs";
/**
* The arguments to operations.
*/
class Ingredient {
/**
* Ingredient constructor
*
* @param {Object} ingredientConfig
*/
constructor(ingredientConfig) {
this.name = "";
this.type = "";
this.name = "";
this.type = "";
this._value = null;
this.disabled = false;
this.hint = "";
@ -37,7 +36,6 @@ class Ingredient {
}
}
/**
* Reads and parses the given config.
*
@ -52,15 +50,20 @@ class Ingredient {
this.hint = ingredientConfig.hint || false;
this.rows = ingredientConfig.rows || false;
this.toggleValues = ingredientConfig.toggleValues;
this.target = typeof ingredientConfig.target !== "undefined" ? ingredientConfig.target : null;
this.defaultIndex = typeof ingredientConfig.defaultIndex !== "undefined" ? ingredientConfig.defaultIndex : 0;
this.target =
typeof ingredientConfig.target !== "undefined"
? ingredientConfig.target
: null;
this.defaultIndex =
typeof ingredientConfig.defaultIndex !== "undefined"
? ingredientConfig.defaultIndex
: 0;
this.maxLength = ingredientConfig.maxLength || null;
this.min = ingredientConfig.min;
this.max = ingredientConfig.max;
this.step = ingredientConfig.step;
}
/**
* Returns the value of the Ingredient as it should be displayed in a recipe config.
*
@ -70,7 +73,6 @@ class Ingredient {
return this._value;
}
/**
* Sets the value of the Ingredient.
*
@ -80,7 +82,6 @@ class Ingredient {
this._value = Ingredient.prepare(value, this.type);
}
/**
* Gets the value of the Ingredient.
*
@ -90,14 +91,13 @@ class Ingredient {
return this._value;
}
/**
* Most values will be strings when they are entered. This function converts them to the correct
* type.
*
* @param {*} data
* @param {string} type - The name of the data type.
*/
*/
static prepare(data, type) {
let number;
@ -126,7 +126,6 @@ class Ingredient {
return data;
}
}
}
export default Ingredient;