-
Notifications
You must be signed in to change notification settings - Fork 0
/
types.d.ts
54 lines (50 loc) · 1.74 KB
/
types.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
47
48
49
50
51
52
53
54
declare module 'unitedstatesofamerica' {
type JSTypes = 'string' | 'number' | 'boolean' | 'object' | 'function' | 'symbol' | 'undefined';
type ArrayUSATypes = JSTypes & ('null' | 'array' | 'objectOnly');
type CallbackFn<ReturnType> = (value: any, index: number, array: ArrayUSA<any>) => ReturnType;
type GenericObject = { [key: string]: any };
type ToObjectShape = { key: string; value: any };
interface ArrayUSA<ArrayItemsType> extends Array<ArrayItemsType> {
ascending(): void;
assert(comparedValue: any): boolean;
batch(size: number): ArrayUSA<any[]>;
copy(): ArrayUSA<any>;
countIf(condition: CallbackFn<boolean>): number;
countOf(value: any): number;
deepCopy(): ArrayUSA<any>;
descending(): void;
difference(): number;
duplicates(): ArrayUSA<any>;
evenIndexes(): ArrayUSA<any>;
filterType(type: ArrayUSATypes): ArrayUSA<any>;
isEmpty(): boolean;
last(): any;
mean(): number;
median(): number;
mode(): number;
oddIndexes(): ArrayUSA<any>;
partialMatch(matchObj: GenericObject): any;
partialMatchIndex(matchObj: GenericObject): number;
product(): number;
quotient(): number;
random(): any;
randomIndex(): number;
replace(oldVal: any, newVal: any): ArrayUSA<any>;
shuffle(): ArrayUSA<any>;
sum(): number;
toArray(): any[];
toNum(): number;
toObject(callback: CallbackFn<ToObjectShape>): GenericObject;
toStr(): ArrayUSA<string>;
types(): JSTypes;
withoutDuplicates(): ArrayUSA<any>;
withoutFalseyValues(): ArrayUSA<any>;
withoutNullishValues(): ArrayUSA<any>;
}
const arrayUSA: {
(arr: any[]): ArrayUSA<any>;
exposeProtos(): void;
withLength: (length: number) => ArrayUSA<any>;
};
export = arrayUSA;
}