MCPcopy
hub / github.com/gchq/CyberChef / set

Method set

src/core/Dish.mjs:169–182  ·  view source on GitHub ↗

* Sets the data value and type and then validates them. * * @param {*} value * - The value of the input data. * @param {number} type * - The data type of value, see Dish enums.

(value, type)

Source from the content-addressed store, hash-verified

167 * - The data type of value, see Dish enums.
168 */
169 set(value, type) {
170 if (typeof type === "string") {
171 type = Dish.typeEnum(type);
172 }
173
174 log.debug("Dish type: " + Dish.enumLookup(type));
175 this.value = value;
176 this.type = type;
177
178 if (!this.valid()) {
179 const sample = Utils.truncate(JSON.stringify(this.value), 25);
180 throw new DishError(`Data is not a valid ${Dish.enumLookup(type)}: ${sample}`);
181 }
182 }
183
184 /**
185 * Returns the Dish as the given type, without mutating the original dish.

Callers 15

constructorMethod · 0.95
cloneMethod · 0.95
_runRecipeMethod · 0.95
runMethod · 0.95
runMethod · 0.95
Gruntfile.jsFile · 0.45
executeMethod · 0.45
presentMethod · 0.45
bakeMethod · 0.45
readFileMethod · 0.45

Calls 4

validMethod · 0.95
typeEnumMethod · 0.80
enumLookupMethod · 0.80
truncateMethod · 0.80

Tested by

no test coverage detected