-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathns8-utils.d.ts
136 lines (103 loc) · 5.29 KB
/
ns8-utils.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
declare module 'ns8-utils' {
export function JSONEscape(str: string): string;
export function JSONSafeParse(str: string): any;
export function superRandom(bytes?: number): string;
export function isArray(obj: any): boolean;
export function prefixAttributes(obj: Object, prefix: string): Object;
export function isNumeric(n: any): boolean;
export function currencyToNumber(n: any): number;
export function toBytes(num: number): Uint8Array;
export function uuid(len?: number, radix?: number): string;
export function base62encode(i: any): string;
export function isUTF8(charset: any): boolean;
export function padLeft(value: any, padChar: string, padCount: number): string;
export function urlDecode(str: any, charset: any): any;
export function clone(o: Object): Object;
export function extend(o1: Object, o2: Object): Object;
export function copyProperty(property: string, o1: Object, o2: Object, allowNull?: boolean, allowEmpty?: boolean): boolean;
export function isFunction(functionToCheck: any): boolean;
export function replaceAll(original: string, search: string, replacement: string): string;
export function htmlify(obj: any): string;
export function empty(obj: Object): boolean;
export function trimStart(value: string, start: string): string;
export function parseCookieValueFromString(headerVal: string, key: string): any;
export function trimEnd(val: string, end: string): string;
export function repeat(val: string, n: number): string;
export function spaces(n: number): string;
export function merge(o1: any, o2: any, overwrite: boolean): Object;
export function validEmail(email: string): boolean;
export function missingParams(req: any, requiredParams: string[]): string[];
export function guid(): string;
export function hash(input: string): number;
export function noCache(res: any): void;
export function stripProtocol(url: string): string;
export function parseBoolean(value, nullOnFailure?: boolean);
export function renameAttribute(obj: Object, name: string, replacement: string): Object;
export function getUrlText(url, callback);
export function appendQueryString(url: string, name: string, value: string): string;
export module config {
export function env(): string;
export function dev(): boolean;
export function settings(envir?: string): any;
}
export module ip {
export function localHost(req: any): boolean;
export function isIPV6(address: string): boolean;
export function remoteAddress(req: any): string;
export function isLoopback(addr: any): boolean;
export function hashIPV6(ip: string): number;
export function hash(address: string): number;
export function toNumber(address: string, reverse?: boolean): number;
export function compress(address: string): any;
export function decompress(address: string): any;
export function toNumber32(address: string): number;
export function fromNumber(ipNumber: number): string;
export function toNumberIPV6(address: string): number;
export function isPrivate(address): boolean;
}
export module epoch {
export interface Timezone {
code: string,
name: string,
momentName: string
}
export let timezones: { [id: number]: Timezone };
export enum DateIntervals {
second = 0,
minute = 1,
hour = 2,
day = 3,
week = 4,
month = 5,
quarter = 6,
year = 7,
}
export function getTimezoneId(timezone: any): number;
export function getTimezone(timezone: any);
export function utcOffset(timezoneId: number): number;
export function currentDatetime(utcOffset?: number): Date;
export function toUTC(strDate: string, utcOffset?: number): Date;
export function currentDate(utcOffset?: number): Date;
export function dateToString(date: Date, includeTime?: boolean): string;
export function startOfDate(date?: Date): Date;
export function addMonths(months: number, date?: Date): Date;
export function addWeeks(weeks: number, date?: Date): Date;
export function addYears(years: number, date?: Date): Date;
export function addDays(days: number, date?: Date): Date;
export function addHours(hours: number, date?: Date): Date;
export function addMinutes(minutes: number, date?: Date): Date;
export function addSeconds(seconds: number, date?: Date): Date;
export function diff(interval: DateIntervals, date1: Date, date2?: Date): number;
export function start(): Date;
export function millisecond(date?: Date): number;
export function second(date?: Date): number;
export function minute(date?: Date): number;
export function hour(date?: Date): number;
export function day(date?: Date): number;
export function week(date?: Date): number;
export function month(date?: Date): number;
export function quarter(date?: Date): number;
export function currentMonth(utcOffset?: number): Date;
export function monthCode(date?: Date, utcOffset?: number): string;
}
}