MCPcopy
hub / github.com/AndrewWalsh/openapi-devtools / remove

Function remove

src/lib/store-helpers/remove.ts:5–34  ·  view source on GitHub ↗
(ctx: RadixRouterContext, path: string)

Source from the content-addressed store, hash-verified

3
4// This can be removed when https://github.com/unjs/radix3/pull/73 is fixed
5function remove(ctx: RadixRouterContext, path: string) {
6 let success = false;
7 const sections = path.split("/");
8 let node = ctx.rootNode;
9
10 for (const section of sections) {
11 // @ts-expect-error tempfile
12 node = node.children.get(section);
13 if (!node) {
14 return success;
15 }
16 }
17
18 if (node.data) {
19 const lastSection = sections[-1];
20 node.data = null;
21 if (node.children.size === 0) {
22 const parentNode = node.parent;
23 // @ts-expect-error tempfile
24 parentNode.children.delete(lastSection);
25 // @ts-expect-error tempfile
26 parentNode.wildcardChildNode = null;
27 // @ts-expect-error tempfile
28 parentNode.placeholderChildNode = null;
29 }
30 success = true;
31 }
32
33 return success;
34}
35
36export default remove;

Callers 1

parameteriseFunction · 0.85

Calls 1

getMethod · 0.80

Tested by

no test coverage detected