MCPcopy
hub / github.com/lingodotdev/lingo.dev / setCommentAtPath

Function setCommentAtPath

packages/cli/src/cli/loaders/jsonc.ts:290–316  ·  view source on GitHub ↗
(
  comments: Record<string, any>,
  path: string[],
  key: string,
  hint: string,
)

Source from the content-addressed store, hash-verified

288}
289
290function setCommentAtPath(
291 comments: Record<string, any>,
292 path: string[],
293 key: string,
294 hint: string,
295): void {
296 let current = comments;
297
298 // Navigate to the correct nested location
299 for (const pathKey of path) {
300 if (!current[pathKey]) {
301 current[pathKey] = {};
302 }
303 current = current[pathKey];
304 }
305
306 // Set the hint for the key
307 if (!current[key]) {
308 current[key] = {};
309 }
310
311 if (typeof current[key] === "object" && current[key] !== null) {
312 current[key].hint = hint;
313 } else {
314 current[key] = { hint };
315 }
316}
317
318export default function createJsoncLoader(): ILoader<
319 string,

Callers 1

extractCommentsFromJsoncFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected