• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

nightlycommit / twing / 307

02 Jun 2025 09:53AM UTC coverage: 100.0%. Remained the same
307

push

gitlab-ci

Eric MORAND
Replace useless https protocol with http.

2541 of 2541 branches covered (100.0%)

Branch coverage included in aggregate %.

5851 of 5851 relevant lines covered (100.0%)

2499.09 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

100.0
/src/main/lib/callable-wrapper.ts
1
import {TwingExecutionContext, TwingSynchronousExecutionContext} from "./execution-context";
2

3
export type TwingCallable<A extends Array<any> = any, R = any> = (executionContext: TwingExecutionContext, ...args: A) => Promise<R>;
4
export type TwingSynchronousCallable<A extends Array<any> = any, R = any> = (executionContext: TwingSynchronousExecutionContext, ...args: A) => R;
5

6
export type TwingCallableArgument = {
7
    name: string;
8
    defaultValue?: any;
9
};
10

11
export type TwingCallableWrapperOptions = {
12
    is_variadic?: boolean;
13
    deprecated?: boolean | string;
14
    alternative?: string;
15
}
16

17
export interface TwingCallableWrapper {
18
    readonly acceptedArguments: Array<TwingCallableArgument>;
19
    readonly alternative: string | undefined;
20
    readonly callable: TwingCallable;
21
    readonly deprecatedVersion: string | boolean | undefined;
22
    readonly isDeprecated: boolean;
23
    readonly isVariadic: boolean;
24
    readonly name: string;
25
    /**
26
     * native arguments are the arguments implicitly passed to the call, deduced from the operator name
27
     * typically, a Callable Wrapper registered under the name "foo-*-*"
28
     * would generate native arguments ["bar","oof"] when the operator name is "foo-bar-oof"
29
     */
30
    nativeArguments: Array<string>;
31
}
32

33
export interface TwingSynchronousCallableWrapper extends Omit<TwingCallableWrapper, "callable"> {
34
    readonly callable: TwingSynchronousCallable;
35
}
36

37
export const createCallableWrapper = (
1✔
38
    name: string,
39
    callable: TwingCallable,
40
    acceptedArguments: Array<TwingCallableArgument>,
41
    options: TwingCallableWrapperOptions
42
): TwingCallableWrapper => {
43
    let nativeArguments: Array<string> = [];
122,528✔
44

45
    const callableWrapper = {
122,528✔
46
        get callable() {
47
            return callable;
74,676✔
48
        },
49
        get name() {
50
            return name;
169,672✔
51
        },
52
        get acceptedArguments() {
53
            return acceptedArguments;
74,682✔
54
        },
55
        get alternative() {
56
            return options.alternative;
74,176✔
57
        },
58
        get deprecatedVersion() {
59
            return options.deprecated;
74,174✔
60
        },
61
        get isDeprecated() {
62
            return options.deprecated ? true : false;
74,542✔
63
        },
64
        get isVariadic() {
65
            return options.is_variadic || false;
74,682✔
66
        },
67
        get nativeArguments() {
68
            return nativeArguments;
74,681✔
69
        },
70
        set nativeArguments(values) {
71
            nativeArguments = values;
12✔
72
        }
73
    };
74

75
    return callableWrapper;
122,528✔
76
};
77

78
export const createSynchronousCallableWrapper = (
1✔
79
    name: string,
80
    callable: TwingSynchronousCallable,
81
    acceptedArguments: Array<TwingCallableArgument>,
82
    options: TwingCallableWrapperOptions
83
): TwingSynchronousCallableWrapper => {
84
    let nativeArguments: Array<string> = [];
122,121✔
85

86
    const callableWrapper = {
122,121✔
87
        get callable() {
88
            return callable;
74,414✔
89
        },
90
        get name() {
91
            return name;
170,279✔
92
        },
93
        get acceptedArguments() {
94
            return acceptedArguments;
74,420✔
95
        },
96
        get alternative() {
97
            return options.alternative;
73,916✔
98
        },
99
        get deprecatedVersion() {
100
            return options.deprecated;
73,914✔
101
        },
102
        get isDeprecated() {
103
            return options.deprecated ? true : false;
74,280✔
104
        },
105
        get isVariadic() {
106
            return options.is_variadic || false;
74,420✔
107
        },
108
        get nativeArguments() {
109
            return nativeArguments;
74,419✔
110
        },
111
        set nativeArguments(values) {
112
            nativeArguments = values;
12✔
113
        }
114
    };
115

116
    return callableWrapper;
122,121✔
117
};
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc