MCPcopy Create free account
hub / github.com/violentmonkey/violentmonkey / getSizes

Function getSizes

src/background/utils/db.js:512–526  ·  view source on GitHub ↗
(ids)

Source from the content-addressed store, hash-verified

510 * @return {number[][]}
511 */
512export function getSizes(ids) {
513 const scripts = getScriptsByIdsOrAll(ids);
514 return scripts.map(({
515 meta,
516 custom: { pathMap = {} },
517 props: { id },
518 }, i) => [
519 // Same order as SIZE_TITLES and sizesPrefixRe
520 scriptSizes[S_CODE_PRE + id] || 0,
521 deepSize(scripts[i]),
522 scriptSizes[S_VALUE_PRE + id] || 0,
523 meta.require.reduce(getSizeForRequires, { len: 0, pathMap }).len,
524 Object.values(meta.resources).reduce(getSizeForResources, { len: 0, pathMap }).len,
525 ]);
526}
527
528function getSizeForRequires(accum, url) {
529 accum.len += (scriptSizes[S_REQUIRE_PRE + (accum.pathMap[url] || url)] || 0) + url.length;

Callers 1

getDataFunction · 0.85

Calls 3

deepSizeFunction · 0.90
getScriptsByIdsOrAllFunction · 0.85
mapMethod · 0.80

Tested by

no test coverage detected