11import { Object } from "ts-toolbelt" ;
2- declare type Pattern < TValue > = RegExp | ( ( value : TValue ) => boolean ) | ( ( value : TValue ) => any ) | any ;
3- declare type Result < TValue , TOutput > = TOutput | ( ( param : TValue ) => TOutput ) ;
4- declare type CaseElement < TValue , TOutput > = [
2+ export declare type Pattern < TValue > = RegExp | ( ( value : TValue ) => boolean ) | ( ( value : TValue ) => any ) | any ;
3+ export declare type Result < TValue , TOutput > = TOutput | ( ( param : TValue ) => TOutput ) ;
4+ export declare type CaseElement < TValue , TOutput > = [
55 Pattern < TValue > ,
66 Result < TValue , TOutput > ,
77 true ?
88] ;
9- declare type DefaultCaseElement < TValue , TOutput > = [ Result < TValue , TOutput > ] ;
10- declare type CaseElements < TValue , TOutput > = ( CaseElement < TValue , TOutput > | DefaultCaseElement < TValue , TOutput > ) [ ] ;
11- declare type Matcher < TValue , TOutput > = ( config : Object . Omit < Config < TValue , TOutput > , "matcher" | "resultGetter" > ) => ( valueToMatch : TValue , pattern : Pattern < TValue > ) => boolean ;
12- declare type ResultGetter < TValue , TOutput > = ( config : Object . Omit < Config < TValue , TOutput > , "matcher" | "resultGetter" > ) => ( valueToMatch : TValue , pattern : Pattern < TValue > , result : any ) => TOutput ;
13- declare type Config < TValue , TOutput > = {
9+ export declare type DefaultCaseElement < TValue , TOutput > = [ Result < TValue , TOutput > ] ;
10+ export declare type CaseElements < TValue , TOutput > = ( CaseElement < TValue , TOutput > | DefaultCaseElement < TValue , TOutput > ) [ ] ;
11+ export declare type Matcher < TValue , TOutput > = ( config : Object . Omit < Config < TValue , TOutput > , "matcher" | "resultGetter" > ) => ( valueToMatch : TValue , pattern : Pattern < TValue > ) => boolean ;
12+ export declare type ResultGetter < TValue , TOutput > = ( config : Object . Omit < Config < TValue , TOutput > , "matcher" | "resultGetter" > ) => ( valueToMatch : TValue , pattern : Pattern < TValue > , result : any ) => TOutput ;
13+ export declare type Config < TValue , TOutput > = {
1414 returnMany : boolean ;
1515 strict : boolean ;
1616 acceptTruthyFunctionReturn : boolean ;
@@ -21,43 +21,27 @@ declare type Config<TValue, TOutput> = {
2121 matcher : Matcher < TValue , TOutput > ;
2222 resultGetter : ResultGetter < TValue , TOutput > ;
2323} ;
24- declare type BasicConfig < TValue , TOutput > = Object . Omit < Config < TValue , TOutput > , "matcher" | "resultGetter" > ;
24+ export declare type BasicConfig < TValue , TOutput > = Object . Omit < Config < TValue , TOutput > , "matcher" | "resultGetter" > ;
2525export declare const defaultMatcher : < TValue , TOutput > ( config : import ( "ts-toolbelt/out/Object/Omit" ) . _Omit < Config < TValue , TOutput > , "matcher" | "resultGetter" > ) => ( valueToMatch : TValue , pattern : any ) => boolean;
26- export declare const defaultResultGetter : < TValue , TOutput > ( config : import ( "ts-toolbelt/out/Object/Omit" ) . _Omit < Config < TValue , TOutput > , "matcher" | "resultGetter" > ) = > ( valueToMatch : TValue , pattern : any , result : any ) => TOutput ;
27- export declare const createSwich : < TValue , TOutput > ( { returnMany : defaultReturnMany , strict : defaultStrict , acceptTruthyFunctionReturn : defaultAcceptTruthyFunctionReturn , catchFunctionErrors : defaultCatchFunctionErrors , performReplaceOnRegex : defaultPerformReplaceOnRegex , runResultFunction : defaultRunResultFunction , stopFallThrough : defaultStopFallThrough , matcher : defaultMatcherValue , resultGetter : defaultResultGetterValue , } ?: {
28- returnMany ?: boolean;
29- strict ?: boolean;
30- acceptTruthyFunctionReturn ?: boolean;
31- catchFunctionErrors ?: boolean;
32- performReplaceOnRegex ?: boolean;
33- runResultFunction ?: boolean;
34- stopFallThrough ?: boolean;
35- matcher ?: Matcher < TValue , TOutput > ;
36- resultGetter ?: ResultGetter < TValue , TOutput > ;
37- } ) = > ( patterns : CaseElements < TValue , TOutput > , { returnMany, strict, acceptTruthyFunctionReturn, catchFunctionErrors, performReplaceOnRegex, runResultFunction, stopFallThrough, matcher, resultGetter, } ?: {
38- returnMany ?: boolean ;
39- strict ?: boolean ;
40- acceptTruthyFunctionReturn ?: boolean ;
41- catchFunctionErrors ?: boolean ;
42- performReplaceOnRegex ?: boolean ;
43- runResultFunction ?: boolean ;
44- stopFallThrough ?: boolean ;
45- matcher ?: Matcher < TValue , TOutput > ;
46- resultGetter ?: ResultGetter < TValue , TOutput > ;
47- } ) => ( valueToMatch ?: boolean | TValue ) => TOutput [ ] ;
26+ export declare const defaultResultGetter : < TValue , TOutput > ( config : import ( "ts-toolbelt/out/Object/Omit" ) . _Omit < Config < TValue , TOutput > , "matcher" | "resultGetter" > ) = > ( valueToMatch : TValue , pattern : any , result : TOutput ) => TOutput ;
27+ declare type SwichReturnMany < TValue , TOutput > = ( valueToMatch ?: TValue | true ) => TOutput [ ] ;
28+ declare type SwichReturnOne < TValue , TOutput > = ( valueToMatch ?: TValue | true ) => TOutput ;
29+ declare function swich < TValue , TOutput > ( patterns : CaseElements < TValue , TOutput > , config : Object . Optional < Config < TValue , TOutput > > & {
30+ returnMany : true ;
31+ } ) : SwichReturnMany < TValue , TOutput > ;
32+ declare function swich < TValue , TOutput > ( patterns : CaseElements < TValue , TOutput > , config ?: Object . Optional < Config < TValue , TOutput > > & {
33+ returnMany ?: false ;
34+ } ) : SwichReturnOne < TValue , TOutput > ;
4835export declare const gt : ( compareValue : number ) => ( value : number ) => boolean ;
4936export declare const gte : ( compareValue : number ) => ( value : number ) => boolean ;
5037export declare const lt : ( compareValue : number ) => ( value : number ) => boolean ;
5138export declare const lte : ( compareValue : number ) => ( value : number ) => boolean ;
52- declare const defaultSwich : < TValue , TOutput > ( patterns : CaseElements < TValue , TOutput > , config ?: {
53- returnMany ?: boolean ;
54- strict ?: boolean ;
55- acceptTruthyFunctionReturn ?: boolean ;
56- catchFunctionErrors ?: boolean ;
57- performReplaceOnRegex ?: boolean ;
58- runResultFunction ?: boolean ;
59- stopFallThrough ?: boolean ;
60- matcher ?: Matcher < TValue , TOutput > ;
61- resultGetter ?: ResultGetter < TValue , TOutput > ;
62- } ) => ( valueToMatch ?: boolean | TValue ) => TOutput [ ] ;
63- export default defaultSwich ;
39+ declare type CreateSwichReturnMany < TValue , TOutput > = < TValue , TOutput > ( patterns : CaseElements < TValue , TOutput > , config ?: Object . Optional < Config < TValue , TOutput > > ) => SwichReturnMany < TValue , TOutput > ;
40+ declare type CreateSwichReturnOne < TValue , TOutput > = < TValue , TOutput > ( patterns : CaseElements < TValue , TOutput > , config ?: Object . Optional < Config < TValue , TOutput > > ) => SwichReturnOne < TValue , TOutput > ;
41+ export declare function createSwich < TValue , TOutput > ( defaultConfig : Object . Optional < Config < TValue , TOutput > > & {
42+ returnMany : true ;
43+ } ) : CreateSwichReturnMany < TValue , TOutput > ;
44+ export declare function createSwich < TValue , TOutput > ( defaultConfig : Object . Optional < Config < TValue , TOutput > > & {
45+ returnMany ?: false ;
46+ } ) : CreateSwichReturnOne < TValue , TOutput > ;
47+ export default swich ;
0 commit comments