import isString from '@tinkoff/utils/is/string' ; import identity from '@tinkoff/utils/function/identity' ; import type { AnyEventCreator , AnyPayloadTransformer , EmptyEventCreator , EventCreator0 , EventCreator1 , EventCreator2 , EventCreator3 , EventCreatorN , PayloadTransformer0 , PayloadTransformer1 , PayloadTransformer2 , PayloadTransformer3 , PayloadTransformerN , } from './createEvent.h' ; export function createEvent ( description ) ; export function createEvent < A1 > ( description ) ; typeparam param description param payloadCreator export function createEvent < Payload > ( description , payloadCreator ) ; export function createEvent ( description , payloadCreator ) ; typeparam typeparam param description param payloadCreator export function createEvent < A1 , Payload > ( description , payloadCreator ) ; typeparam typeparam typeparam param description param payloadCreator export function createEvent < A1 , A2 , Payload > ( description , payloadCreator ) ; typeparam typeparam typeparam typeparam param description param payloadCreator export function createEvent < A1 , A2 , A3 , Payload > ( description , payloadCreator ) ; export function createEvent < Payload > ( description , payloadCreator ) ; export function createEvent ( eventName , payloadCreator = identity ) { if ( process . env . NODE_ENV !== 'production' ) { if ( ! isString ( eventName ) || ! eventName . length ) { throw new Error ( `eventName should be not empty string, got '${ eventName }'` ) ; } } const type = eventName ; const eventCreator = ( ... args ) => { return { type , payload : ( payloadCreator as any ) ( ... args ) , } ; } ; eventCreator . getType = ( ) => type ; eventCreator . toString = ( ) => type ; return eventCreator ; }