Skip to content

Commit

Permalink
[added] type guard for PointerEvent
Browse files Browse the repository at this point in the history
Reviewers: O2 Material Motion, O3 Material JavaScript platform reviewers, #material_motion, featherless

Reviewed By: O2 Material Motion, #material_motion, featherless

Tags: #material_motion

Differential Revision: http://codereview.cc/D3082
  • Loading branch information
appsforartists committed Apr 21, 2017
1 parent 1fbd220 commit 0d87dd1
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions packages/core/src/typeGuards.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,11 @@ import {
export function isPoint2D(value: any): value is Point2D {
return typeof value.x === 'number' && typeof value.y === 'number';
}

/**
* Checks if a value is a `PointerEvent` by checking if `type` starts with
* `pointer`.
*/
export function isPointerEvent(value: any): value is PointerEvent {
return value.type.startsWith('pointer');
}

0 comments on commit 0d87dd1

Please sign in to comment.