-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.d.ts
46 lines (38 loc) · 1.37 KB
/
index.d.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
export type Joinable<T> = Array<T> | ArrayLike<T> | Iterable<T>;
export type Mapper<T> = (value: T, index: number) => any;
export type Wrappable<T> = (value: T, ...rest: any[]) => any;
export type BaseOptions = {
last?: string;
pair?: string;
serial?: string | boolean;
with?: string;
};
export type OptionsWithDollarMap<T> = BaseOptions & { $map: Wrappable<T> };
export type OptionsWithMap<T> = BaseOptions & { map: Mapper<T> };
export type Options<T> = OptionsWithDollarMap<T> | OptionsWithMap<T> | BaseOptions;
export interface BaseConjoin<T> {
(values: Joinable<T>, options: BaseOptions): string;
(values: Joinable<T>): string;
}
// disallow +map+ when +$map+ is defined
export interface ConjoinWithDollarMap<T> extends BaseConjoin<T> {
<U>(values: Joinable<U>, options: OptionsWithDollarMap<U>): string;
}
export interface Conjoin<T = any> extends BaseConjoin<T> {
<U>(values: Joinable<U>, options: OptionsWithDollarMap<U>): string;
<U>(values: Joinable<U>, options: OptionsWithMap<U>): string;
}
export interface Conjoiner {
<T>(options: OptionsWithDollarMap<T>): ConjoinWithDollarMap<T>;
<T>(options: OptionsWithMap<T>): Conjoin<T>;
(options: BaseOptions): Conjoin;
(): Conjoin;
}
declare const conjoin: Conjoin;
declare const conjoiner: Conjoiner;
export {
conjoin,
conjoin as join,
conjoiner,
conjoiner as joiner,
};