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

Method size

src/core/Dish.mjs:324–344  ·  view source on GitHub ↗

* Determines how much space the Dish takes up. * Numbers in JavaScript are 64-bit floating point, however for the purposes of the Dish, * we measure how many bytes are taken up when the number is written as a string. * * @returns {number}

()

Source from the content-addressed store, hash-verified

322 * @returns {number}
323 */
324 get size() {
325 switch (this.type) {
326 case Dish.BYTE_ARRAY:
327 case Dish.STRING:
328 case Dish.HTML:
329 return this.value.length;
330 case Dish.NUMBER:
331 case Dish.BIG_NUMBER:
332 return this.value.toString().length;
333 case Dish.ARRAY_BUFFER:
334 return this.value.byteLength;
335 case Dish.JSON:
336 return JSON.stringify(this.value).length;
337 case Dish.FILE:
338 return this.value.size;
339 case Dish.LIST_FILE:
340 return this.value.reduce((acc, curr) => acc + curr.size, 0);
341 default:
342 return -1;
343 }
344 }
345
346
347 /**

Callers 1

runMethod · 0.45

Calls 1

toStringMethod · 0.45

Tested by

no test coverage detected