MCPcopy Index your code
hub / github.com/pythongosssss/ComfyUI-Custom-Scripts / applyDefaults

Function applyDefaults

web/js/widgetDefaults.js:40–63  ·  view source on GitHub ↗
(defaults)

Source from the content-addressed store, hash-verified

38 };
39
40 const applyDefaults = (defaults) => {
41 for (const node of Object.values(LiteGraph.registered_node_types)) {
42 const nodeData = node[nodeDataKey];
43 if (!nodeData) continue;
44 const nodeDefaults = getNodeDefaults(node, defaults);
45 if (!nodeDefaults) continue;
46 const inputs = { ...(nodeData.input?.required || {}), ...(nodeData.input?.optional || {}) };
47
48 for (const w in nodeDefaults) {
49 const widgetDef = inputs[w];
50 if (widgetDef) {
51 let v = nodeDefaults[w];
52 if (widgetDef[0] === "INT" || widgetDef[0] === "FLOAT") {
53 v = +v;
54 }
55 if (widgetDef[1]) {
56 widgetDef[1].default = v;
57 } else {
58 widgetDef[1] = { default: v };
59 }
60 }
61 }
62 }
63 };
64
65 const getDefaults = () => {
66 let items;

Callers 1

getDefaultsFunction · 0.85

Calls 1

getNodeDefaultsFunction · 0.85

Tested by

no test coverage detected