chore(core): cleanup

This commit is contained in:
braks
2023-05-25 20:48:26 +02:00
committed by Braks
parent 4ad10c5030
commit b2cdb6a143
2 changed files with 4 additions and 4 deletions
+2 -2
View File
@@ -69,7 +69,7 @@ export function getHostForElement(element: HTMLElement): Document {
// todo: refactor generic to use MaybeElement
export function isEdge<Data = ElementData>(element: MaybeElement): element is Edge<Data> {
return typeof element === 'object' && 'id' in element && 'source' in element && 'target' in element
return element && typeof element === 'object' && 'id' in element && 'source' in element && 'target' in element
}
// todo: refactor generic to use MaybeElement
@@ -79,7 +79,7 @@ export function isGraphEdge<Data = ElementData>(element: MaybeElement): element
// todo: refactor generic to use MaybeElement
export function isNode<Data = ElementData>(element: MaybeElement): element is Node<Data> {
return typeof element === 'object' && 'id' in element && !isEdge(element)
return element && typeof element === 'object' && 'id' in element && 'position' in element && !isEdge(element)
}
// todo: refactor generic to use MaybeElement
+2 -2
View File
@@ -1,11 +1,11 @@
import { toValue } from '@vueuse/core'
import { unref } from 'vue'
import { ErrorCode, VueFlowError, connectionExists, getEdgeId, isEdge, isNode, parseEdge, parseNode } from '.'
import type { Actions, Connection, Edge, GraphEdge, GraphNode, Node, State } from '~/types'
type NonUndefined<T> = T extends undefined ? never : T
export function isDef<T>(val: T): val is NonUndefined<T> {
const unrefVal = toValue(val)
const unrefVal = unref(val)
return typeof unrefVal !== 'undefined'
}