mirror of
https://github.com/zoriya/v10.git
synced 2026-08-16 02:45:09 +00:00
19 lines
495 B
TypeScript
19 lines
495 B
TypeScript
import { isNumber, isObject, isString } from '../predicate';
|
|
|
|
export interface EventLike {
|
|
type: string;
|
|
timeStamp: number;
|
|
isTrusted?: boolean;
|
|
}
|
|
|
|
/**
|
|
* Check if a value looks like an Event (has type and timeStamp).
|
|
*
|
|
* Works with DOM Events, React SyntheticEvents, and RN events.
|
|
*/
|
|
export function isEventLike(value: unknown): value is EventLike {
|
|
return (
|
|
isObject(value) && 'type' in value && isString(value.type) && 'timeStamp' in value && isNumber(value.timeStamp)
|
|
);
|
|
}
|