feat(reactflowUtils.ts): add checkEdgesHandles function to validate if any of the handles in an array of edges are not a JSON string
The checkEdgesHandles function is added to the reactflowUtils.ts file. This function takes an array of edges as input and returns true if any of the handles in the edges are not a JSON string. It checks each edge in the array and verifies if the sourceHandle and targetHandle properties exist and contain a JSON string. If any of the handles are not a JSON string, the function returns true. This function is useful for validating the integrity of the handles in the edges before further processing.
This commit is contained in:
parent
d7516e17e4
commit
d6168cabde
1 changed files with 11 additions and 0 deletions
|
|
@ -295,3 +295,14 @@ export function scapedJSONStringfy(json: object): string {
|
|||
export function scapeJSONParse(json: string): any {
|
||||
return JSON.parse(json.replace(/\\"/g, '"'));
|
||||
}
|
||||
|
||||
// this function receives an array of edges and return true if any of the handles are not a json string
|
||||
export function checkEdgesHandles(edges: Edge[]): boolean {
|
||||
return edges.some(
|
||||
(edge) =>
|
||||
!edge.sourceHandle ||
|
||||
!edge.targetHandle ||
|
||||
!edge.sourceHandle.includes("{") ||
|
||||
!edge.targetHandle.includes("{")
|
||||
);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue