import { createErrorReporter } from "./error-reporter" ; import { createVal } from "./val" ; import { createWildcard } from "./wildcard" ; param { ... function | * } tests return { function } export const createArrArgMatch = ctx => function arrArgMatch ( ... tests ) { return function matchFn ( arr , msg ? ) { return createErrorReporter ( "arrArgMatch" , ctx , msg , [ arr ] ) ( ( ) => { const hasWildcard = tests . slice ( - 1 ) [ 0 ] === "..." ; let matches = hasWildcard || arr . length === tests . length ; for ( let i = 0 ; i < tests . length ; i ++ ) { const testVal = tests [ i ] ; const predicate = testVal === "..." ? createWildcard ( ) : createVal ( ctx ) ( testVal ) ; const pass = predicate ( arr [ i ] ) ; matches = matches && pass ; } return matches ; } ) ; } ; } ;