Skip to content

Commit

Permalink
feat: is point like & is point data
Browse files Browse the repository at this point in the history
  • Loading branch information
bubkoo committed Mar 18, 2020
1 parent b3e1b1a commit 1d1e2f7
Showing 1 changed file with 19 additions and 0 deletions.
19 changes: 19 additions & 0 deletions packages/x6/src/geometry/point.ts
Expand Up @@ -324,6 +324,25 @@ export namespace Point {
}

export type PointData = [number, number]

export function isPointLike(o: any): o is PointLike {
return (
o != null &&
typeof o === 'object' &&
typeof o.x === 'number' &&
typeof o.y === 'number'
)
}

export function isPointData(o: any): o is PointData {
return (
o != null &&
Array.isArray(o) &&
o.length === 2 &&
typeof o[0] === 'number' &&
typeof o[1] === 'number'
)
}
}

export namespace Point {
Expand Down

0 comments on commit 1d1e2f7

Please sign in to comment.