forked from DefinitelyTyped/DefinitelyTyped
-
Notifications
You must be signed in to change notification settings - Fork 0
/
jsuri.d.ts
143 lines (122 loc) · 3.99 KB
/
jsuri.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
137
138
139
140
141
142
143
// Type definitions for jsUri 1.3+
// Project: https://github.com/derek-watson/jsUri
// Definitions by: Chris Charabaruk <http://github.com/coldacid>, Florian Wagner <http://github.com/flqw>
// Definitions: https://github.com/DefinitelyTyped/DefinitelyTyped
declare namespace jsuri {
type Primitive = string | number | boolean;
export class Uri {
/**
* Creates a new Uri object
* @constructor
* @param {string} str
*/
constructor(str?: string);
/**
* Define getter/setter methods
*/
protocol(val?: string): string;
userInfo(val?: string): string;
host(val?: string): string;
port(val?: number): number;
path(val?: string): string;
anchor(val?: string): string;
/**
* if there is no protocol, the leading // can be enabled or disabled
* @param {Boolean} val
* @return {Boolean}
*/
hasAuthorityPrefix(val?: boolean): boolean;
isColonUri(val?: boolean): boolean;
/**
* Serializes the internal state of the query pairs
* @param {string} [val] set a new query string
* @return {string} query string
*/
query(val?: string): string;
/**
* returns the first query param value found for the key
* @param {string} key query key
* @return {string} first value found for key
*/
getQueryParamValue(key: string): string;
/**
* returns an array of query param values for the key
* @param {string} key query key
* @return {array} array of values
*/
getQueryParamValues(key: string): string[];
/**
* removes query parameters
* @param {string} key remove values for key
* @param {val} [val] remove a specific value, otherwise removes all
* @return {Uri} returns self for fluent chaining
*/
deleteQueryParam(key: string, val?: string): Uri;
/**
* adds a query parameter
* @param {string} key add values for key
* @param {string} val value to add
* @param {integer} [index] specific index to add the value at
* @return {Uri} returns self for fluent chaining
*/
addQueryParam(key: string, val: Primitive, index?: number): Uri;
/**
* test for the existence of a query parameter
* @param {string} key check values for key
* @return {Boolean} true if key exists, otherwise false
*/
hasQueryParam(key: string): boolean;
/**
* replaces query param values
* @param {string} key key to replace value for
* @param {string} newVal new value
* @param {string} [oldVal] replace only one specific value (otherwise replaces all)
* @return {Uri} returns self for fluent chaining
*/
replaceQueryParam(key: string, newVal: Primitive, oldVal?: Primitive): Uri;
/**
* Define fluent setter methods (setProtocol, setHasAuthorityPrefix, etc)
*/
setProtocol(val: string): Uri;
setHasAuthorityPrefix(val: boolean): Uri;
setIsColonUri(val: boolean): Uri;
setUserInfo(val: string): Uri;
setHost(val: string): Uri;
setPort(val: number): Uri;
setPath(val: string): Uri;
setQuery(val: string): Uri;
setAnchor(val: string): Uri;
/**
* Scheme name, colon and doubleslash, as required
* @return {string} http:// or possibly just //
*/
scheme(): string;
/**
* Same as Mozilla nsIURI.prePath
* @return {string} scheme://user:password@host:port
* @see https://developer.mozilla.org/en/nsIURI
*/
origin(): string;
/**
* Adds a trailing slash to the path
*/
addTrailingSlash(): Uri;
/**
* Serializes the internal state of the Uri object
* @return {string}
*/
toString(): string;
/**
* Clone a Uri object
* @return {Uri} duplicate copy of the Uri
*/
clone(): Uri;
}
}
declare type Uri = jsuri.Uri;
declare module 'jsuri' {
export = jsuri.Uri;
}
declare module 'jsUri' {
export = jsuri.Uri;
}