import { BindingRegistry } from "./binding-registry" ; import { Callsite } from "./our-callsite" ; import { StepBinding , StepBindingFlags } from "./step-binding" ; param stepPattern param tag param timeout export function given ( stepPattern , tag ? , timeout ? ) { const callsite = Callsite . capture ( ) ; return < T > ( target , propertyKey , descriptor ) => { const stepBinding = { stepPattern : stepPattern , bindingType : StepBindingFlags . given , targetPrototype : target , targetPropertyKey : propertyKey , argsLength : target [ propertyKey ] . length , callsite : callsite } ; if ( tag ) { stepBinding . tag = tag [ 0 ] === "@" ? tag : `@${ tag }` ; } if ( timeout ) { stepBinding . timeout = timeout ; } BindingRegistry . instance . registerStepBinding ( stepBinding ) ; return descriptor ; } ; } param stepPattern param tag param timeout export function when ( stepPattern , tag ? , timeout ? ) { const callsite = Callsite . capture ( ) ; return < T > ( target , propertyKey , descriptor ) => { const stepBinding = { stepPattern : stepPattern , bindingType : StepBindingFlags . when , targetPrototype : target , targetPropertyKey : propertyKey , argsLength : target [ propertyKey ] . length , callsite : callsite } ; if ( tag ) { stepBinding . tag = tag [ 0 ] === "@" ? tag : `@${ tag }` ; } if ( timeout ) { stepBinding . timeout = timeout ; } BindingRegistry . instance . registerStepBinding ( stepBinding ) ; return descriptor ; } ; } param stepPattern param tag param timeout export function then ( stepPattern , tag ? , timeout ? ) { const callsite = Callsite . capture ( ) ; return < T > ( target , propertyKey , descriptor ) => { const stepBinding = { stepPattern : stepPattern , bindingType : StepBindingFlags . then , targetPrototype : target , targetPropertyKey : propertyKey , argsLength : target [ propertyKey ] . length , callsite : callsite } ; if ( tag ) { stepBinding . tag = tag [ 0 ] === "@" ? tag : `@${ tag }` ; } if ( timeout ) { stepBinding . timeout = timeout ; } BindingRegistry . instance . registerStepBinding ( stepBinding ) ; return descriptor ; } ; }