MCPcopy Create free account
hub / github.com/heygen-com/hyperframes / writeVariableDefault

Function writeVariableDefault

packages/sdk/src/engine/variableModel.ts:53–61  ·  view source on GitHub ↗
(document: Document, id: string, newDefault: unknown)

Source from the content-addressed store, hash-verified

51 * the attribute was updated.
52 */
53export function writeVariableDefault(document: Document, id: string, newDefault: unknown): boolean {
54 const decls = readDecls(document);
55 if (!decls) return false;
56 const idx = indexOfId(decls.arr, id);
57 if (idx < 0) return false; // variable not declared — don't auto-add
58 decls.arr[idx] = { ...decls.arr[idx]!, default: newDefault };
59 decls.htmlEl.setAttribute("data-composition-variables", JSON.stringify(decls.arr));
60 return true;
61}
62
63/**
64 * Remove the `default` key from a variable declaration, restoring its

Callers 2

applyVariableDefaultFunction · 0.85
handleSetVariableValueFunction · 0.85

Calls 3

readDeclsFunction · 0.85
indexOfIdFunction · 0.85
setAttributeMethod · 0.65

Tested by

no test coverage detected