MCPcopy Create free account
hub / github.com/chhoumann/quickadd / insertUnderParent

Function insertUnderParent

src/services/packageImportService.ts:988–1006  ·  view source on GitHub ↗
(
	choices: IChoice[],
	parentId: string,
	child: IChoice,
)

Source from the content-addressed store, hash-verified

986}
987
988function insertUnderParent(
989 choices: IChoice[],
990 parentId: string,
991 child: IChoice,
992): boolean {
993 for (const choice of choices) {
994 if (choice.id === parentId && choice.type === "Multi") {
995 insertIntoMulti(choice as IMultiChoice, child);
996 return true;
997 }
998 if (choice.type === "Multi") {
999 const multi = choice as IMultiChoice;
1000 if (multi.choices && insertUnderParent(multi.choices, parentId, child)) {
1001 return true;
1002 }
1003 }
1004 }
1005 return false;
1006}
1007
1008function insertIntoMulti(parent: IMultiChoice, child: IChoice): void {
1009 if (!Array.isArray(parent.choices)) {

Callers 1

applyPackageImportFunction · 0.85

Calls 1

insertIntoMultiFunction · 0.70

Tested by

no test coverage detected