expensify-common 2.0.8 → 2.0.10
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/ExpensiMark.js +3 -4
- package/dist/components/form/element/dropdownItem.d.ts +1 -1
- package/dist/jquery.expensifyIframify.d.ts +1 -1
- package/dist/str.d.ts +74 -134
- package/dist/str.js +196 -295
- package/package.json +4 -2
package/dist/ExpensiMark.js
CHANGED
|
@@ -75,9 +75,8 @@ class ExpensiMark {
|
|
|
75
75
|
return `<pre>${group}</pre>`;
|
|
76
76
|
},
|
|
77
77
|
rawInputReplacement: (match, __, textWithinFences) => {
|
|
78
|
-
const
|
|
79
|
-
|
|
80
|
-
return `<pre data-code-raw="${withinFences}">${group}</pre>`;
|
|
78
|
+
const group = textWithinFences.replace(/(?:(?![\n\r])\s)/g, ' ').replace(/<emoji>|<\/emoji>/g, '');
|
|
79
|
+
return `<pre>${group}</pre>`;
|
|
81
80
|
},
|
|
82
81
|
},
|
|
83
82
|
/**
|
|
@@ -188,7 +187,7 @@ class ExpensiMark {
|
|
|
188
187
|
*/
|
|
189
188
|
{
|
|
190
189
|
name: 'reportMentions',
|
|
191
|
-
regex: /(?<![^ \n*~_])(#[\p{Ll}0-9-]{1,80})/gimu,
|
|
190
|
+
regex: /(?<![^ \n*~_])(#[\p{Ll}0-9-]{1,80})(?![^<]*(?:<\/pre>|<\/code>))/gimu,
|
|
192
191
|
replacement: '<mention-report>$1</mention-report>',
|
|
193
192
|
},
|
|
194
193
|
/**
|
|
@@ -12,7 +12,7 @@ declare class DropDownItem extends React.Component<any, any, any> {
|
|
|
12
12
|
*/
|
|
13
13
|
destroyTooltip(): void;
|
|
14
14
|
render(): React.JSX.Element;
|
|
15
|
-
tooltipContainer:
|
|
15
|
+
tooltipContainer: JQueryStatic | undefined;
|
|
16
16
|
}
|
|
17
17
|
declare namespace DropDownItem {
|
|
18
18
|
export { propTypes };
|
package/dist/str.d.ts
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Checks if parameter is a string or function
|
|
3
|
+
* if it is a function then we will call it with
|
|
4
|
+
* any additional arguments.
|
|
5
|
+
*/
|
|
6
|
+
declare function resultFn(parameter: string): string;
|
|
7
|
+
declare function resultFn<R, A extends unknown[]>(parameter: (...args: A) => R, ...args: A): R;
|
|
1
8
|
declare const Str: {
|
|
2
9
|
/**
|
|
3
10
|
* Return true if the string is ending with the provided suffix
|
|
@@ -9,7 +16,7 @@ declare const Str: {
|
|
|
9
16
|
/**
|
|
10
17
|
* Converts a USD string into th number of cents it represents.
|
|
11
18
|
*
|
|
12
|
-
* @param
|
|
19
|
+
* @param amountStr A string representing a USD value.
|
|
13
20
|
* @param allowFraction Flag indicating if fractions of cents should be
|
|
14
21
|
* allowed in the output.
|
|
15
22
|
*
|
|
@@ -18,15 +25,10 @@ declare const Str: {
|
|
|
18
25
|
fromUSDToNumber(amountStr: string, allowFraction: boolean): number;
|
|
19
26
|
/**
|
|
20
27
|
* Truncates the middle section of a string based on the max allowed length
|
|
21
|
-
*
|
|
22
|
-
* @param fullStr
|
|
23
|
-
* @param maxLength
|
|
24
28
|
*/
|
|
25
29
|
truncateInMiddle(fullStr: string, maxLength: number): string;
|
|
26
30
|
/**
|
|
27
31
|
* Convert new line to <br />
|
|
28
|
-
*
|
|
29
|
-
* @param str
|
|
30
32
|
*/
|
|
31
33
|
nl2br(str: string): string;
|
|
32
34
|
/**
|
|
@@ -40,14 +42,14 @@ declare const Str: {
|
|
|
40
42
|
* HTML encodes the given string.
|
|
41
43
|
*
|
|
42
44
|
* @param s The string to encode.
|
|
43
|
-
* @
|
|
45
|
+
* @return string @p s HTML encoded.
|
|
44
46
|
*/
|
|
45
47
|
htmlEncode(s: string): string;
|
|
46
48
|
/**
|
|
47
49
|
* Escape text while preventing any sort of double escape, so 'X & Y' -> 'X & Y' and 'X & Y' -> 'X & Y'
|
|
48
50
|
*
|
|
49
|
-
* @param s
|
|
50
|
-
* @returns
|
|
51
|
+
* @param s The string to escape
|
|
52
|
+
* @returns The escaped string
|
|
51
53
|
*/
|
|
52
54
|
safeEscape(s: string): string;
|
|
53
55
|
/**
|
|
@@ -55,7 +57,7 @@ declare const Str: {
|
|
|
55
57
|
*
|
|
56
58
|
* @param first string to compare
|
|
57
59
|
* @param second string to compare
|
|
58
|
-
* @returns
|
|
60
|
+
* @returns True when first === second, ignoring HTML encoding
|
|
59
61
|
*/
|
|
60
62
|
htmlEncodingInsensitiveEquals(first: string, second: string): boolean;
|
|
61
63
|
/**
|
|
@@ -81,19 +83,14 @@ declare const Str: {
|
|
|
81
83
|
recapitalize(val: string): string;
|
|
82
84
|
/**
|
|
83
85
|
* Replace all the non alphanumerical character by _
|
|
84
|
-
*
|
|
85
|
-
* @param input
|
|
86
86
|
*/
|
|
87
87
|
sanitizeToAlphaNumeric(input: string): string;
|
|
88
88
|
/**
|
|
89
89
|
* Strip out all the non numerical characters
|
|
90
|
-
*
|
|
91
|
-
* @param input
|
|
92
90
|
*/
|
|
93
91
|
stripNonNumeric(input: string): string;
|
|
94
92
|
/**
|
|
95
93
|
* Strips all non ascii characters from a string
|
|
96
|
-
* @param input
|
|
97
94
|
* @returns The ascii version of the string.
|
|
98
95
|
*/
|
|
99
96
|
stripNonASCIICharacters(input: string): string;
|
|
@@ -103,7 +100,7 @@ declare const Str: {
|
|
|
103
100
|
* The ellipses will only be appended if @p text is longer than the @p length
|
|
104
101
|
* given.
|
|
105
102
|
*
|
|
106
|
-
* @param val
|
|
103
|
+
* @param val The string to reduce in size.
|
|
107
104
|
* @param length The maximal length desired.
|
|
108
105
|
* @returns The shortened @p text.
|
|
109
106
|
*/
|
|
@@ -117,13 +114,11 @@ declare const Str: {
|
|
|
117
114
|
getRawByteSize(inputChar: string): number;
|
|
118
115
|
/**
|
|
119
116
|
* Gets the length of a string in bytes, including non-ASCII characters
|
|
120
|
-
* @param input
|
|
121
117
|
* @returns The number of bytes used by string
|
|
122
118
|
*/
|
|
123
119
|
getByteLength(input: string): number;
|
|
124
120
|
/**
|
|
125
121
|
* Shortens the input by max byte size instead of by character length
|
|
126
|
-
* @param input
|
|
127
122
|
* @param maxSize The max size in bytes, e.g. 256
|
|
128
123
|
* @returns Returns a shorted input if the input size exceeds the max
|
|
129
124
|
*/
|
|
@@ -131,9 +126,9 @@ declare const Str: {
|
|
|
131
126
|
/**
|
|
132
127
|
* Returns true if the haystack begins with the needle
|
|
133
128
|
*
|
|
134
|
-
* @param haystack
|
|
135
|
-
* @param needle
|
|
136
|
-
* @returns
|
|
129
|
+
* @param haystack The full string to be searched
|
|
130
|
+
* @param needle The case-sensitive string to search for
|
|
131
|
+
* @returns True if the haystack starts with the needle.
|
|
137
132
|
*/
|
|
138
133
|
startsWith(haystack: string, needle: string): boolean;
|
|
139
134
|
/**
|
|
@@ -173,44 +168,42 @@ declare const Str: {
|
|
|
173
168
|
/**
|
|
174
169
|
* Checks that the string is a domain name (e.g. example.com)
|
|
175
170
|
*
|
|
176
|
-
* @param
|
|
171
|
+
* @param str The string to check for domainnameness.
|
|
177
172
|
*
|
|
178
|
-
* @returns True
|
|
173
|
+
* @returns True if the string is a domain name
|
|
179
174
|
*/
|
|
180
|
-
isValidDomainName(
|
|
175
|
+
isValidDomainName(str: string): boolean;
|
|
181
176
|
/**
|
|
182
177
|
* Checks that the string is a valid url
|
|
183
178
|
*
|
|
184
|
-
* @param string
|
|
185
|
-
*
|
|
186
179
|
* @returns True if the string is a valid hyperlink
|
|
187
180
|
*/
|
|
188
|
-
isValidURL(
|
|
181
|
+
isValidURL(str: string): boolean;
|
|
189
182
|
/**
|
|
190
183
|
* Checks that the string is an email address.
|
|
191
184
|
* NOTE: TLDs are not just 2-4 characters. Keep this in sync with _inputrules.php
|
|
192
185
|
*
|
|
193
|
-
* @param
|
|
186
|
+
* @param str The string to check for email validity.
|
|
194
187
|
*
|
|
195
|
-
* @returns True
|
|
188
|
+
* @returns True if the string is an email
|
|
196
189
|
*/
|
|
197
|
-
isValidEmail(
|
|
190
|
+
isValidEmail(str: string): boolean;
|
|
198
191
|
/**
|
|
199
192
|
* Checks if the string is an valid email address formed during comment markdown formation.
|
|
200
193
|
*
|
|
201
|
-
* @param
|
|
194
|
+
* @param str The string to check for email validity.
|
|
202
195
|
*
|
|
203
196
|
* @returns True if the string is an valid email created by comment markdown.
|
|
204
197
|
*/
|
|
205
|
-
isValidEmailMarkdown(
|
|
198
|
+
isValidEmailMarkdown(str: string): boolean;
|
|
206
199
|
/**
|
|
207
200
|
* Remove trailing comma from a string.
|
|
208
201
|
*
|
|
209
|
-
* @param
|
|
202
|
+
* @param str The string with any trailing comma to be removed.
|
|
210
203
|
*
|
|
211
204
|
* @returns string with the trailing comma removed
|
|
212
205
|
*/
|
|
213
|
-
removeTrailingComma(
|
|
206
|
+
removeTrailingComma(str: string): string;
|
|
214
207
|
/**
|
|
215
208
|
* Checks that the string is a list of coma separated email addresss.
|
|
216
209
|
*
|
|
@@ -221,10 +214,8 @@ declare const Str: {
|
|
|
221
214
|
areValidEmails(str: string): boolean;
|
|
222
215
|
/**
|
|
223
216
|
* Extract the email addresses from a string
|
|
224
|
-
*
|
|
225
|
-
* @param string
|
|
226
217
|
*/
|
|
227
|
-
extractEmail(
|
|
218
|
+
extractEmail(str: string): RegExpMatchArray | null;
|
|
228
219
|
/**
|
|
229
220
|
* Extracts the domain name from the given email address
|
|
230
221
|
* (e.g. "domain.com" for "joe@domain.com").
|
|
@@ -254,57 +245,46 @@ declare const Str: {
|
|
|
254
245
|
extractEmailLocalPart(email: string): string;
|
|
255
246
|
/**
|
|
256
247
|
* Sanitize phone number to return only numbers. Return null if non valid phone number.
|
|
257
|
-
*
|
|
258
|
-
* @param str
|
|
259
248
|
*/
|
|
260
249
|
sanitizePhoneNumber(str: string): string | null;
|
|
261
250
|
/**
|
|
262
251
|
* Sanitize email. Return null if non valid email.
|
|
263
|
-
*
|
|
264
|
-
* @param str
|
|
265
252
|
*/
|
|
266
253
|
sanitizeEmail(str: string): string | null;
|
|
267
254
|
/**
|
|
268
255
|
* Escapes all special RegExp characters from a string
|
|
269
256
|
*
|
|
270
|
-
* @param
|
|
257
|
+
* @param str The subject
|
|
271
258
|
*
|
|
272
259
|
* @returns The escaped string
|
|
273
260
|
*/
|
|
274
|
-
escapeForRegExp(
|
|
261
|
+
escapeForRegExp(str: string): string;
|
|
275
262
|
/**
|
|
276
263
|
* Escapes all special RegExp characters from a string except for the period
|
|
277
264
|
*
|
|
278
|
-
* @param
|
|
265
|
+
* @param str The subject
|
|
279
266
|
* @returns The escaped string
|
|
280
267
|
*/
|
|
281
|
-
escapeForExpenseRule(
|
|
268
|
+
escapeForExpenseRule(str: string): string;
|
|
282
269
|
/**
|
|
283
270
|
* Adds a backslash in front of each of colon
|
|
284
271
|
* if they don't already have a backslash in front of them
|
|
285
272
|
*
|
|
286
|
-
* @param
|
|
273
|
+
* @param str The subject
|
|
287
274
|
* @returns The escaped string
|
|
288
275
|
*/
|
|
289
|
-
addBackslashBeforeColonsForTagNamesComingFromQBD(
|
|
276
|
+
addBackslashBeforeColonsForTagNamesComingFromQBD(str: string): string;
|
|
290
277
|
/**
|
|
291
278
|
* Removes backslashes from string
|
|
292
279
|
* eg: myString\[\]\* -> myString[]*
|
|
293
|
-
*
|
|
294
|
-
* @param string
|
|
295
|
-
*
|
|
296
280
|
*/
|
|
297
|
-
stripBackslashes(
|
|
281
|
+
stripBackslashes(str: string): string;
|
|
298
282
|
/**
|
|
299
283
|
* Checks if a string's length is in the specified range
|
|
300
284
|
*
|
|
301
|
-
* @param string The subject
|
|
302
|
-
* @param minimumLength
|
|
303
|
-
* @param [maximumLength]
|
|
304
|
-
*
|
|
305
285
|
* @returns true if the length is in the range, false otherwise
|
|
306
286
|
*/
|
|
307
|
-
isOfLength(
|
|
287
|
+
isOfLength(str: string, minimumLength: number, maximumLength: number): boolean;
|
|
308
288
|
/**
|
|
309
289
|
* Count the number of occurences of needle in haystack.
|
|
310
290
|
* This is faster than counting the results of haystack.match( /needle/g )
|
|
@@ -321,8 +301,8 @@ declare const Str: {
|
|
|
321
301
|
* Uppercases the first letter of each word
|
|
322
302
|
* via https://github.com/kvz/phpjs/blob/master/functions/strings/ucwords.js
|
|
323
303
|
*
|
|
324
|
-
* @param
|
|
325
|
-
* @returns
|
|
304
|
+
* @param str to uppercase words
|
|
305
|
+
* @returns Uppercase worded string
|
|
326
306
|
*/
|
|
327
307
|
ucwords(str: string): string;
|
|
328
308
|
/**
|
|
@@ -346,83 +326,75 @@ declare const Str: {
|
|
|
346
326
|
/**
|
|
347
327
|
* Case insensitive compare function
|
|
348
328
|
*
|
|
349
|
-
* @param
|
|
350
|
-
* @param
|
|
329
|
+
* @param strA string to compare
|
|
330
|
+
* @param strB string to compare
|
|
351
331
|
*
|
|
352
332
|
* @returns -1 if first string < second string
|
|
353
333
|
* 1 if first string > second string
|
|
354
334
|
* 0 if first string = second string
|
|
355
335
|
*/
|
|
356
|
-
caseInsensitiveCompare(
|
|
336
|
+
caseInsensitiveCompare(strA: string, strB: string): 1 | 0 | -1;
|
|
357
337
|
/**
|
|
358
338
|
* Case insensitive equals
|
|
359
339
|
*
|
|
360
|
-
* @param
|
|
361
|
-
* @param
|
|
340
|
+
* @param strA string to compare
|
|
341
|
+
* @param strB string to compare
|
|
362
342
|
* @returns true when first == second except for case
|
|
363
343
|
*/
|
|
364
|
-
caseInsensitiveEquals(
|
|
344
|
+
caseInsensitiveEquals(strA: string, strB: string): boolean;
|
|
365
345
|
/**
|
|
366
346
|
* Compare function
|
|
367
347
|
*
|
|
368
|
-
* @param
|
|
369
|
-
* @param
|
|
348
|
+
* @param strA string to compare
|
|
349
|
+
* @param strB string to compare
|
|
370
350
|
*
|
|
371
351
|
* @returns -1 if first string < second string
|
|
372
352
|
* 1 if first string > second string
|
|
373
353
|
* 0 if first string = second string
|
|
374
354
|
*/
|
|
375
|
-
compare(
|
|
355
|
+
compare(strA: string, strB: string): 1 | 0 | -1;
|
|
376
356
|
/**
|
|
377
357
|
* Check if a file extension is supported by SmartReports
|
|
378
|
-
* @param filename
|
|
379
358
|
*/
|
|
380
359
|
isFileExtensionSmartReportsValid(filename: string): boolean;
|
|
381
360
|
/**
|
|
382
361
|
* Mask Permanent Account Number (PAN) the same way Auth does
|
|
383
|
-
* @param
|
|
362
|
+
* @param num account number
|
|
384
363
|
* @returns masked account number
|
|
385
364
|
*/
|
|
386
|
-
maskPAN(
|
|
365
|
+
maskPAN(num: number | string): string;
|
|
387
366
|
/**
|
|
388
367
|
* Checks if something is a string
|
|
389
368
|
* Stolen from underscore
|
|
390
|
-
* @param obj
|
|
391
369
|
*/
|
|
392
|
-
isString(obj: unknown):
|
|
370
|
+
isString(obj: unknown): obj is string;
|
|
393
371
|
/**
|
|
394
372
|
* Checks if something is a number
|
|
395
373
|
* Stolen from underscore
|
|
396
374
|
* @param obj
|
|
397
375
|
*/
|
|
398
|
-
isNumber(obj: unknown):
|
|
376
|
+
isNumber(obj: unknown): obj is number;
|
|
399
377
|
/**
|
|
400
378
|
* Checks if something is a certain type
|
|
401
379
|
* Stolen from underscore
|
|
402
|
-
* @param obj
|
|
403
|
-
* @param type one of ['Arguments', 'Function', 'String', 'Number', 'Date',
|
|
404
|
-
* 'RegExp', 'Error', 'Symbol', 'Map', 'WeakMap', 'Set', 'WeakSet']
|
|
405
380
|
*/
|
|
406
381
|
isTypeOf(obj: unknown, type: 'Arguments' | 'Function' | 'String' | 'Number' | 'Date' | 'RegExp' | 'Error' | 'Symbol' | 'Map' | 'WeakMap' | 'Set' | 'WeakSet'): boolean;
|
|
407
382
|
/**
|
|
408
383
|
* Checks to see if something is undefined
|
|
409
384
|
* Stolen from underscore
|
|
410
|
-
* @param obj
|
|
411
385
|
*/
|
|
412
386
|
isUndefined(obj: unknown): boolean;
|
|
413
387
|
/**
|
|
414
388
|
* Replace first N characters of the string with maskChar
|
|
415
389
|
* eg: maskFirstNCharacters( '1234567890', 6, 'X' ) yields XXXXXX7890
|
|
416
|
-
* @param str
|
|
417
|
-
* @param
|
|
418
|
-
* @param mask
|
|
419
|
-
* @returns
|
|
390
|
+
* @param str String to mask
|
|
391
|
+
* @param num Number of characters we want to mask from the string
|
|
392
|
+
* @param mask String we want replace the first N chars with
|
|
393
|
+
* @returns Masked string
|
|
420
394
|
*/
|
|
421
|
-
maskFirstNCharacters(str: string,
|
|
395
|
+
maskFirstNCharacters(str: string, num: number, mask: string): string;
|
|
422
396
|
/**
|
|
423
397
|
* Trim a string
|
|
424
|
-
*
|
|
425
|
-
* @param str
|
|
426
398
|
*/
|
|
427
399
|
trim(str: string): string;
|
|
428
400
|
/**
|
|
@@ -431,64 +403,56 @@ declare const Str: {
|
|
|
431
403
|
*/
|
|
432
404
|
percentageStringToNumber(percentageString: string): number;
|
|
433
405
|
/**
|
|
434
|
-
*
|
|
435
|
-
* @param input
|
|
436
|
-
*
|
|
406
|
+
* Remove all the spaces from a string
|
|
437
407
|
*/
|
|
438
408
|
removeSpaces(input: string): string;
|
|
439
409
|
/**
|
|
440
410
|
* Returns the proper phrase depending on the count that is passed.
|
|
441
411
|
* Example:
|
|
442
|
-
* console.log(Str.pluralize('puppy', 'puppies', 1))
|
|
443
|
-
* console.log(Str.pluralize('puppy', 'puppies', 3))
|
|
412
|
+
* console.log(Str.pluralize('puppy', 'puppies', 1)) { // puppy
|
|
413
|
+
* console.log(Str.pluralize('puppy', 'puppies', 3)) { // puppies
|
|
444
414
|
*
|
|
445
415
|
* @param singular form of the phrase
|
|
446
416
|
* @param plural form of the phrase
|
|
447
|
-
* @param
|
|
417
|
+
* @param num the count which determines the plurality
|
|
448
418
|
*/
|
|
449
|
-
pluralize(singular: string, plural: string,
|
|
419
|
+
pluralize(singular: string, plural: string, num: number): string;
|
|
450
420
|
/**
|
|
451
421
|
* Returns whether or not a string is an encrypted number or not.
|
|
452
422
|
*
|
|
453
|
-
* @param
|
|
423
|
+
* @param num that we want to see if its encrypted or not
|
|
454
424
|
*
|
|
455
425
|
* @returns Whether or not this string is an encrpypted number
|
|
456
426
|
*/
|
|
457
|
-
isEncryptedCardNumber(
|
|
427
|
+
isEncryptedCardNumber(num: string): boolean;
|
|
458
428
|
/**
|
|
459
429
|
* Converts a value to boolean, case-insensitive.
|
|
460
|
-
* @param value
|
|
461
430
|
*/
|
|
462
431
|
toBool(value: unknown): boolean;
|
|
463
432
|
/**
|
|
464
433
|
* Checks if a string could be the masked version of another one.
|
|
465
434
|
*
|
|
466
|
-
* @param
|
|
467
|
-
* @param
|
|
468
|
-
* @param [mask]
|
|
469
|
-
* @returns
|
|
435
|
+
* @param strA String to compare
|
|
436
|
+
* @param strB String to compare
|
|
437
|
+
* @param [mask] Defaults to X
|
|
438
|
+
* @returns True when first could be the masked version of second
|
|
470
439
|
*/
|
|
471
|
-
maskedEquals(
|
|
440
|
+
maskedEquals(strA: string, strB: string, mask: string): boolean;
|
|
472
441
|
/**
|
|
473
442
|
* Bold any word matching the regexp in the text.
|
|
474
|
-
* @param text, htmlEncoded
|
|
475
|
-
* @param regexp
|
|
476
443
|
*/
|
|
477
444
|
boldify(text: string, regexp: RegExp): string;
|
|
478
445
|
/**
|
|
479
446
|
* Check for whether a phone number is valid.
|
|
480
|
-
* @
|
|
481
|
-
* @deprecated use isValidE164Phone to validate E.164 phone numbers, isValidPhoneFormat to validate phone number format, or isValidPhoneNumber to validate phone numbers in general
|
|
447
|
+
* @deprecated use isValidE164Phone to validate E.164 phone numbers or isValidPhoneFormat to validate phone numbers in general
|
|
482
448
|
*/
|
|
483
449
|
isValidPhone(phone: string): boolean;
|
|
484
450
|
/**
|
|
485
451
|
* Check for whether a phone number is valid.
|
|
486
|
-
* @param phone
|
|
487
452
|
*/
|
|
488
453
|
isValidPhoneNumber(phone: string): boolean;
|
|
489
454
|
/**
|
|
490
455
|
* Check for whether a phone number is valid according to E.164 standard.
|
|
491
|
-
* @param phone
|
|
492
456
|
*/
|
|
493
457
|
isValidE164Phone(phone: string): boolean;
|
|
494
458
|
/**
|
|
@@ -498,25 +462,18 @@ declare const Str: {
|
|
|
498
462
|
* e164: +14404589784
|
|
499
463
|
* national: (440) 458-9784
|
|
500
464
|
* 123.456.7890
|
|
501
|
-
* @param phone
|
|
502
465
|
*/
|
|
503
466
|
isValidPhoneFormat(phone: string): boolean;
|
|
504
467
|
/**
|
|
505
468
|
* We validate mentions by checking if it's first character is an allowed character.
|
|
506
|
-
*
|
|
507
|
-
* @param mention
|
|
508
469
|
*/
|
|
509
470
|
isValidMention(mention: string): boolean;
|
|
510
471
|
/**
|
|
511
472
|
* Returns text without our SMS domain
|
|
512
|
-
*
|
|
513
|
-
* @param text
|
|
514
473
|
*/
|
|
515
474
|
removeSMSDomain(text: string): string;
|
|
516
475
|
/**
|
|
517
476
|
* Returns true if the text is a valid E.164 phone number with our SMS domain removed
|
|
518
|
-
*
|
|
519
|
-
* @param text
|
|
520
477
|
*/
|
|
521
478
|
isSMSLogin(text: string): boolean;
|
|
522
479
|
/**
|
|
@@ -524,16 +481,15 @@ declare const Str: {
|
|
|
524
481
|
* JS yet, so this is a good way of doing it according to
|
|
525
482
|
* https://github.com/airbnb/javascript/issues/1439#issuecomment-306297399 and doesn't get us in trouble with
|
|
526
483
|
* linting rules.
|
|
527
|
-
*
|
|
528
|
-
* @param str
|
|
529
|
-
* @param regex
|
|
530
484
|
*/
|
|
531
|
-
matchAll(str: string, regex: RegExp): Array<RegExpMatchArray & {
|
|
485
|
+
matchAll(str: string, regex: RegExp): Array<RegExpMatchArray & {
|
|
486
|
+
input: string;
|
|
487
|
+
index: number;
|
|
488
|
+
}>;
|
|
532
489
|
/**
|
|
533
490
|
* A simple GUID generator taken from https://stackoverflow.com/a/32760401/9114791
|
|
534
491
|
*
|
|
535
492
|
* @param [prefix] an optional prefix to put in front of the guid
|
|
536
|
-
*
|
|
537
493
|
*/
|
|
538
494
|
guid(prefix?: string): string;
|
|
539
495
|
/**
|
|
@@ -554,18 +510,11 @@ declare const Str: {
|
|
|
554
510
|
* Checks if parameter is a string or function
|
|
555
511
|
* if it is a function then we will call it with
|
|
556
512
|
* any additional arguments.
|
|
557
|
-
*
|
|
558
|
-
* @param parameter
|
|
559
513
|
*/
|
|
560
|
-
result:
|
|
561
|
-
<R, A extends unknown[]>(parameter: string): string;
|
|
562
|
-
<R, A extends unknown[]>(parameter: (...args: A) => R, ...args: A): R;
|
|
563
|
-
};
|
|
514
|
+
result: typeof resultFn;
|
|
564
515
|
/**
|
|
565
516
|
* Get file extension for a given url with or
|
|
566
517
|
* without query parameters
|
|
567
|
-
*
|
|
568
|
-
* @param url
|
|
569
518
|
*/
|
|
570
519
|
getExtension(url: string): string | undefined;
|
|
571
520
|
/**
|
|
@@ -582,8 +531,6 @@ declare const Str: {
|
|
|
582
531
|
* supported by all platforms.
|
|
583
532
|
*
|
|
584
533
|
* https://reactnative.dev/docs/image#source
|
|
585
|
-
*
|
|
586
|
-
* @param url
|
|
587
534
|
*/
|
|
588
535
|
isImage(url: string): boolean;
|
|
589
536
|
/**
|
|
@@ -594,24 +541,17 @@ declare const Str: {
|
|
|
594
541
|
* https://developer.android.com/media/platform/supported-formats#video-formats
|
|
595
542
|
* https://developer.apple.com/documentation/coremedia/1564239-video_codec_constants
|
|
596
543
|
* https://developer.mozilla.org/en-US/docs/Web/Media/Formats/Video_codecs
|
|
597
|
-
*
|
|
598
|
-
* @param url
|
|
599
544
|
*/
|
|
600
545
|
isVideo(url: string): boolean;
|
|
601
546
|
/**
|
|
602
547
|
* Checks whether the given string is a +@ domain email account, such as
|
|
603
548
|
* +@domain.com
|
|
604
549
|
*
|
|
605
|
-
* @param email
|
|
606
550
|
* @returns True if is a domain account email, otherwise false.
|
|
607
551
|
*/
|
|
608
552
|
isDomainEmail(email: string): boolean;
|
|
609
553
|
/**
|
|
610
554
|
* Polyfill for String.prototype.replaceAll
|
|
611
|
-
*
|
|
612
|
-
* @param text
|
|
613
|
-
* @param searchValue
|
|
614
|
-
* @param replaceValue
|
|
615
555
|
*/
|
|
616
556
|
replaceAll(text: string, searchValue: string | RegExp, replaceValue: string | ((...args: unknown[]) => string)): string;
|
|
617
557
|
};
|