MCPcopy Create free account
hub / github.com/DTStack/Taier / getPlus

Function getPlus

taier-ui/src/utils/index.ts:627–641  ·  view source on GitHub ↗
(obj: Record<string, any>, rawPath: string, value?: any)

Source from the content-addressed store, hash-verified

625 * ```
626 */
627export function getPlus(obj: Record<string, any>, rawPath: string, value?: any) {
628 const path = regex.test(rawPath) ? rawPath.substring(2, rawPath.length - 2) : rawPath;
629 const namePath = path.split('.');
630 if (namePath.some((p) => p.includes('#'))) {
631 const idx = namePath.findIndex((p) => p.includes('#'));
632 const firstPath = namePath.slice(0, idx);
633 const [idxPath, idxHandler] = namePath[idx].split('#');
634 const restPath = namePath.slice(idx + 1);
635 const rest = get(obj, firstPath);
636 const target = rest[idxPath][idxHandler]((item: any) => item.value === value);
637 return get(target, restPath);
638 }
639
640 return get(obj, path);
641}
642
643/**
644 * Convert nested object to form's name path

Callers 2

handlerFunction · 0.90
index.test.tsxFile · 0.85

Calls 2

getFunction · 0.85
splitMethod · 0.80

Tested by

no test coverage detected