This repository was archived by the owner on Dec 9, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathStringUtil.d.ts
205 lines (205 loc) · 6.01 KB
/
StringUtil.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
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
/**
* The StringUtil...
*
* @class StringUtil
* @module StructureJS
* @submodule util
* @author Robert S. (www.codeBelt.com)
* @static
*/
declare class StringUtil {
constructor();
/**
* Gets the extension name off the string being passed in.
*
* @method getExtension
* @param filename {string}
* @param withDot {boolean} If you want the period to be included in the extension name.
* @returns {string}
* @public
* @static
* @example
* StringUtil.getExtension('file.exe');
* // 'exe'
*
* StringUtil.getExtension('file.exe', true);
* // '.exe'
*/
static getExtension(filename: string, withDot?: boolean): string;
/**
* Converts a string to a sentence case string.
*
* @method toSentence
* @param str {string}
* @param [separator] {string} Can be any string you want to use as a separator.
* @returns {string}
* @public
* @static
* @example
* StringUtil.toSentence("liveDown_by-the.River");
* // 'live down by the river'
*
* StringUtil.toSentence("liveDown_by-the.River", '-');
* // 'live-down-by-the-river'
*
* StringUtil.toSentence("liveDown_by-the.River", '_');
* // 'live_down_by_the_river'
*
* StringUtil.toSentence("liveDown_by-the.River", '/');
* // 'live/down/by/the/river'
*/
static toSentence(str: string, separator?: string): string;
/**
* Converts a string to a camel case string.
*
* @method toCamelCase
* @param str {string}
* @returns {string}
* @public
* @static
* @example
* StringUtil.toCamelCase("liveDown_by-the.River");
* // 'liveDownByTheRiver'
*/
static toCamelCase(str: string): string;
/**
* Converts a hyphen string to a pascal case string.
*
* @method toPascalCase
* @param str {string}
* @returns {string}
* @public
* @static
* @example
* StringUtil.toPascalCase("liveDown_by-the.River");
* // 'LiveDownByTheRiver'
*/
static toPascalCase(str: string): string;
/**
* Converts a string to a constant case string.
*
* @method toConstantCase
* @param str {string}
* @returns {string}
* @public
* @static
* @example
* StringUtil.toConstantCase("liveDown_by-the.River");
* // 'LIVE_DOWN_BY_THE_RIVER'
*/
static toConstantCase(str: string): string;
/**
* Creates a universally unique identifier.
*
* @method createUUID
* @returns {string}
* @public
* @static
* @example
* StringUtil.createUUID();
* // 'a95d7134-3342-4001-bcea-cc0371b70dec'
*/
static createUUID(): string;
/**
* Converts a query string to an object.
*
* @method queryStringToObject
* @param queryString {string}
* @param [useParseFloat=false] {boolean} If true converts strings to numbers.
* @returns {Object|Null}
* @public
* @static
* @example
* StringUtil.queryStringToObject('?name=Robert&age=23&gender=male');
* // {name: 'Robert', age: '23', gender: 'male'}
*
* StringUtil.queryStringToObject('?name=Robert&age=23&gender=male', true);
* // {name: 'Robert', age: 23, gender: 'male'}
*/
static queryStringToObject(queryString: string, useParseFloat?: boolean): any;
/**
* Converts a query string to an object.
*
* @method toQueryString
* @param obj {Object}
* @public
* @static
* @example
* StringUtil.toQueryString({name: 'Robert', age: '23', gender: 'male'});
* // name=Robert&age=23&gender=male'
*/
static toQueryString(obj: any): string;
/**
* Remove all whitespace from the string passed in.
*
* @method removeAllWhitespace
* @param str {string}
* @returns {string}
* @public
* @static
* @example
* let str = ' a b c d e f g ';
* StringUtil.removeAllWhitespace(str);
* // 'abcdefg'
*/
static removeAllWhitespace(str: string): string;
/**
* Remove leading and trailing whitespace.
*
* @method removeLeadingTrailingWhitespace
* @param str {string}
* @returns {string}
* @public
* @static
* @example
* let str = ' a b c d e f g ';
* StringUtil.removeLeadingTrailingWhitespace(str);
* // 'a b c d e f g'
*/
static removeLeadingTrailingWhitespace(str: string): string;
/**
*
* @method truncate
* @param text {string}
* @param length {int}
* @param indicator {string}
* @returns {string}
* @public
* @static
* @example
* StringUtil.truncate('Robert is cool and he likes bruschetta.', 14));
* // 'Robert is cool...'
*
* StringUtil.truncate('Robert is cool and he likes bruschetta.', 14, '!!!'));
* // 'Robert is cool!!!'
*/
static truncate(text: string, length: number, indicator?: string): string;
/**
* Replaces each format item in a specified string with the text equivalent of a corresponding object's value.
*
* @method format
* @returns {string}
* @param str {string}
* @param ...rest {Array.<any>}
* @public
* @static
* @example
* StringUtil.format('Robert is {0}. Very {0} and {1}!', 'cool', 'smart');
* // 'Robert is cool. Very cool and smart!'
*/
static format(str: string, ...rest: Array<any>): string;
/**
* Updates a value in the query string by its key name.
*
* @method paramReplace
* @param queryString
* @param name
* @param value
* @returns {string|void}
* @example
* StringUtil.paramReplace('?name=Robert&age=23&gender=male', 'gender', 'female');
* // '?name=Robert&age=23&gender=female'
*/
static paramReplace(queryString: any, name: any, value: any): any;
}
export default StringUtil;