reslib 1.0.0
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/README.md +298 -0
- package/build/auth/index.d.ts +2034 -0
- package/build/auth/index.js +5 -0
- package/build/auth/types.d.ts +465 -0
- package/build/auth/types.js +1 -0
- package/build/countries/countries.d.ts +1454 -0
- package/build/countries/countries.js +1 -0
- package/build/countries/index.d.ts +159 -0
- package/build/countries/index.js +5 -0
- package/build/countries/types.d.ts +65 -0
- package/build/countries/types.js +1 -0
- package/build/currency/currencies.d.ts +8 -0
- package/build/currency/currencies.js +1 -0
- package/build/currency/index.d.ts +51 -0
- package/build/currency/index.js +5 -0
- package/build/currency/session.d.ts +23 -0
- package/build/currency/session.js +5 -0
- package/build/currency/types.d.ts +1039 -0
- package/build/currency/types.js +1 -0
- package/build/currency/utils.d.ts +25 -0
- package/build/currency/utils.js +1 -0
- package/build/i18n/index.d.ts +640 -0
- package/build/i18n/index.js +5 -0
- package/build/inputFormatter/index.d.ts +396 -0
- package/build/inputFormatter/index.js +5 -0
- package/build/inputFormatter/types.d.ts +544 -0
- package/build/inputFormatter/types.js +1 -0
- package/build/logger/index.d.ts +235 -0
- package/build/logger/index.js +5 -0
- package/build/observable/index.d.ts +329 -0
- package/build/observable/index.js +1 -0
- package/build/platform/index.d.ts +32 -0
- package/build/platform/index.js +1 -0
- package/build/resources/ResourcePaginationHelper.d.ts +537 -0
- package/build/resources/ResourcePaginationHelper.js +2 -0
- package/build/resources/decorators/create.decorator.d.ts +20 -0
- package/build/resources/decorators/create.decorator.js +1 -0
- package/build/resources/decorators/index.d.ts +41 -0
- package/build/resources/decorators/index.js +1 -0
- package/build/resources/fields/index.d.ts +33 -0
- package/build/resources/fields/index.js +1 -0
- package/build/resources/filters.d.ts +62 -0
- package/build/resources/filters.js +1 -0
- package/build/resources/index.d.ts +854 -0
- package/build/resources/index.js +6 -0
- package/build/resources/types/filters.d.ts +508 -0
- package/build/resources/types/filters.js +1 -0
- package/build/resources/types/index.d.ts +4138 -0
- package/build/resources/types/index.js +1 -0
- package/build/session/index.d.ts +1474 -0
- package/build/session/index.js +1 -0
- package/build/translations/auth.en.d.ts +3 -0
- package/build/translations/auth.en.js +1 -0
- package/build/translations/countries.en.d.ts +6 -0
- package/build/translations/countries.en.js +1 -0
- package/build/translations/currencies.en.d.ts +5 -0
- package/build/translations/currencies.en.js +1 -0
- package/build/translations/date.en.d.ts +19 -0
- package/build/translations/date.en.js +1 -0
- package/build/translations/index.d.ts +1583 -0
- package/build/translations/index.js +5 -0
- package/build/translations/resources.en.d.ts +6 -0
- package/build/translations/resources.en.js +1 -0
- package/build/translations/validator.en.d.ts +104 -0
- package/build/translations/validator.en.js +5 -0
- package/build/types/date.d.ts +44 -0
- package/build/types/date.js +1 -0
- package/build/types/dictionary.d.ts +29 -0
- package/build/types/dictionary.js +1 -0
- package/build/types/i18n.d.ts +121 -0
- package/build/types/i18n.js +1 -0
- package/build/types/index.d.ts +145 -0
- package/build/types/index.js +1 -0
- package/build/utils/areEquals.d.ts +19 -0
- package/build/utils/areEquals.js +1 -0
- package/build/utils/date/dateHelper.d.ts +371 -0
- package/build/utils/date/dateHelper.js +5 -0
- package/build/utils/date/index.d.ts +212 -0
- package/build/utils/date/index.js +5 -0
- package/build/utils/date/isDateObj.d.ts +14 -0
- package/build/utils/date/isDateObj.js +1 -0
- package/build/utils/debounce.d.ts +52 -0
- package/build/utils/debounce.js +1 -0
- package/build/utils/defaultArray.d.ts +18 -0
- package/build/utils/defaultArray.js +1 -0
- package/build/utils/defaultBool.d.ts +14 -0
- package/build/utils/defaultBool.js +1 -0
- package/build/utils/defaultStr.d.ts +17 -0
- package/build/utils/defaultStr.js +1 -0
- package/build/utils/defaultVal.d.ts +18 -0
- package/build/utils/defaultVal.js +1 -0
- package/build/utils/dom/index.d.ts +65 -0
- package/build/utils/dom/index.js +1 -0
- package/build/utils/dom/isDOMElement.d.ts +11 -0
- package/build/utils/dom/isDOMElement.js +1 -0
- package/build/utils/file/index.d.ts +26 -0
- package/build/utils/file/index.js +1 -0
- package/build/utils/global.d.ts +53 -0
- package/build/utils/global.js +1 -0
- package/build/utils/image.d.ts +56 -0
- package/build/utils/image.js +1 -0
- package/build/utils/index.d.ts +39 -0
- package/build/utils/index.js +6 -0
- package/build/utils/interpolate.d.ts +105 -0
- package/build/utils/interpolate.js +1 -0
- package/build/utils/isEmail.d.ts +57 -0
- package/build/utils/isEmail.js +1 -0
- package/build/utils/isEmpty.d.ts +18 -0
- package/build/utils/isEmpty.js +1 -0
- package/build/utils/isNonNullString.d.ts +17 -0
- package/build/utils/isNonNullString.js +1 -0
- package/build/utils/isNullable.d.ts +7 -0
- package/build/utils/isNullable.js +1 -0
- package/build/utils/isNumber.d.ts +36 -0
- package/build/utils/isNumber.js +1 -0
- package/build/utils/isPrimitive.d.ts +16 -0
- package/build/utils/isPrimitive.js +1 -0
- package/build/utils/isPromise.d.ts +14 -0
- package/build/utils/isPromise.js +1 -0
- package/build/utils/isRegex.d.ts +15 -0
- package/build/utils/isRegex.js +1 -0
- package/build/utils/isTime.d.ts +18 -0
- package/build/utils/isTime.js +1 -0
- package/build/utils/json.d.ts +224 -0
- package/build/utils/json.js +1 -0
- package/build/utils/numbers.d.ts +148 -0
- package/build/utils/numbers.js +5 -0
- package/build/utils/object.d.ts +567 -0
- package/build/utils/object.js +1 -0
- package/build/utils/sort.d.ts +67 -0
- package/build/utils/sort.js +1 -0
- package/build/utils/string.d.ts +165 -0
- package/build/utils/string.js +1 -0
- package/build/utils/stringify.d.ts +23 -0
- package/build/utils/stringify.js +1 -0
- package/build/utils/uniqid.d.ts +18 -0
- package/build/utils/uniqid.js +1 -0
- package/build/utils/uri/index.d.ts +333 -0
- package/build/utils/uri/index.js +2 -0
- package/build/validator/index.d.ts +4 -0
- package/build/validator/index.js +6 -0
- package/build/validator/rules/array.d.ts +848 -0
- package/build/validator/rules/array.js +5 -0
- package/build/validator/rules/boolean.d.ts +87 -0
- package/build/validator/rules/boolean.js +5 -0
- package/build/validator/rules/date.d.ts +551 -0
- package/build/validator/rules/date.js +5 -0
- package/build/validator/rules/default.d.ts +367 -0
- package/build/validator/rules/default.js +5 -0
- package/build/validator/rules/enum.d.ts +155 -0
- package/build/validator/rules/enum.js +5 -0
- package/build/validator/rules/file.d.ts +356 -0
- package/build/validator/rules/file.js +5 -0
- package/build/validator/rules/format.d.ts +2825 -0
- package/build/validator/rules/format.js +6 -0
- package/build/validator/rules/index.d.ts +16 -0
- package/build/validator/rules/index.js +6 -0
- package/build/validator/rules/multiRules.d.ts +475 -0
- package/build/validator/rules/multiRules.js +5 -0
- package/build/validator/rules/numeric.d.ts +1135 -0
- package/build/validator/rules/numeric.js +5 -0
- package/build/validator/rules/string.d.ts +504 -0
- package/build/validator/rules/string.js +5 -0
- package/build/validator/rules/target.d.ts +137 -0
- package/build/validator/rules/target.js +5 -0
- package/build/validator/rules/utils.d.ts +1 -0
- package/build/validator/rules/utils.js +1 -0
- package/build/validator/rulesMarkers.d.ts +11 -0
- package/build/validator/rulesMarkers.js +1 -0
- package/build/validator/types.d.ts +2906 -0
- package/build/validator/types.js +1 -0
- package/build/validator/validator.d.ts +3692 -0
- package/build/validator/validator.js +5 -0
- package/lib/cjs/auth.js +1 -0
- package/lib/cjs/countries.js +1 -0
- package/lib/cjs/currency.js +1 -0
- package/lib/cjs/i18n.js +1 -0
- package/lib/cjs/inputFormatter.js +1 -0
- package/lib/cjs/logger.js +1 -0
- package/lib/cjs/observable.js +1 -0
- package/lib/cjs/platform.js +1 -0
- package/lib/cjs/resources.js +1 -0
- package/lib/cjs/session.js +1 -0
- package/lib/cjs/types.js +1 -0
- package/lib/cjs/utils.js +1 -0
- package/lib/cjs/validator.js +1 -0
- package/lib/esm/auth.mjs +1 -0
- package/lib/esm/countries.mjs +1 -0
- package/lib/esm/currency.mjs +1 -0
- package/lib/esm/i18n.mjs +1 -0
- package/lib/esm/inputFormatter.mjs +1 -0
- package/lib/esm/logger.mjs +1 -0
- package/lib/esm/observable.mjs +1 -0
- package/lib/esm/platform.mjs +1 -0
- package/lib/esm/resources.mjs +1 -0
- package/lib/esm/session.mjs +1 -0
- package/lib/esm/types.mjs +1 -0
- package/lib/esm/utils.mjs +1 -0
- package/lib/esm/validator.mjs +1 -0
- package/package.json +244 -0
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Removes all occurrences of the specified string from the left side of the current string.
|
|
3
|
+
*
|
|
4
|
+
* This function takes two parameters: the current string and the string to remove.
|
|
5
|
+
* If the string to remove is not provided, it defaults to an empty string and the function simply trims the current string.
|
|
6
|
+
*
|
|
7
|
+
* @param {string} current The string to modify.
|
|
8
|
+
* @param {string} [str=""] The string to remove from the left side of the current string.
|
|
9
|
+
* @returns {string} The modified string with all occurrences of the specified string removed from the left side.
|
|
10
|
+
* @example
|
|
11
|
+
* ```typescript
|
|
12
|
+
* console.log(ltrim(" hello world", " ")); // Output: "hello world"
|
|
13
|
+
* console.log(ltrim("hello world", " ")); // Output: "hello world"
|
|
14
|
+
* console.log(ltrim(" hello world")); // Output: "hello world"
|
|
15
|
+
* ```
|
|
16
|
+
*/
|
|
17
|
+
export declare const ltrim: (current: string, str?: string) => string;
|
|
18
|
+
/**
|
|
19
|
+
* Removes all occurrences of the specified string from the right side of the current string.
|
|
20
|
+
*
|
|
21
|
+
* This function takes two parameters: the current string and the string to remove.
|
|
22
|
+
* If the string to remove is not provided, it defaults to an empty string and the function simply trims the current string.
|
|
23
|
+
*
|
|
24
|
+
* @param {string} current The string to modify.
|
|
25
|
+
* @param {string} [str=""] The string to remove from the right side of the current string.
|
|
26
|
+
* @returns {string} The modified string with all occurrences of the specified string removed from the right side.
|
|
27
|
+
* @example
|
|
28
|
+
* ```typescript
|
|
29
|
+
* console.log(rtrim("test heee", "e")); // Output: "test h"
|
|
30
|
+
* console.log(rtrim("hello world", " ")); // Output: "hello world"
|
|
31
|
+
* console.log(rtrim(" hello world")); // Output: " hello world"
|
|
32
|
+
* ```
|
|
33
|
+
*/
|
|
34
|
+
export declare const rtrim: (current: string, str?: string) => string;
|
|
35
|
+
/**
|
|
36
|
+
* Checks if the provided string consists only of numbers.
|
|
37
|
+
*
|
|
38
|
+
* This function takes two parameters: the string to check and an optional flag to indicate whether to consider decimal points.
|
|
39
|
+
*
|
|
40
|
+
* @param {string} str The string to check.
|
|
41
|
+
* @param {boolean} [withDecimal=true] Whether to consider decimal points in the check.
|
|
42
|
+
* @returns {boolean} True if the string consists only of numbers, false otherwise.
|
|
43
|
+
* @example
|
|
44
|
+
* ```typescript
|
|
45
|
+
* console.log(isStringNumber("123")); // Output: true
|
|
46
|
+
* console.log(isStringNumber("123.45")); // Output: true
|
|
47
|
+
* console.log(isStringNumber("123.45", false)); // Output: false
|
|
48
|
+
* console.log(isStringNumber("abc")); // Output: false
|
|
49
|
+
* ```
|
|
50
|
+
*/
|
|
51
|
+
export declare const isStringNumber: (str: string, withDecimal?: boolean) => boolean;
|
|
52
|
+
/**
|
|
53
|
+
* Extends the String interface with additional methods for string manipulation.
|
|
54
|
+
*/
|
|
55
|
+
declare global {
|
|
56
|
+
interface String {
|
|
57
|
+
/**
|
|
58
|
+
* Removes all occurrences of the specified string from the left side of the string.
|
|
59
|
+
* @param {string} [str=""] The string to remove from the left side.
|
|
60
|
+
* @returns {string} The modified string with all occurrences of the specified string removed from the left side.
|
|
61
|
+
*/
|
|
62
|
+
ltrim(str?: string): string;
|
|
63
|
+
/**
|
|
64
|
+
* Removes all occurrences of the specified string from the right side of the string.
|
|
65
|
+
* @param {string} [str=""] The string to remove from the right side.
|
|
66
|
+
* @returns {string} The modified string with all occurrences of the specified string removed from the right side.
|
|
67
|
+
*/
|
|
68
|
+
rtrim(str?: string): string;
|
|
69
|
+
/**
|
|
70
|
+
* Checks if the string consists only of numbers.
|
|
71
|
+
* @param {boolean} [withDecimal=true] Whether to consider decimal points in the check.
|
|
72
|
+
* @returns {boolean} True if the string consists only of numbers, false otherwise.
|
|
73
|
+
*/
|
|
74
|
+
isNumber(withDecimal?: boolean): boolean;
|
|
75
|
+
/**
|
|
76
|
+
* Converts the string to snake case (e.g. "hello world" becomes "hello_world").
|
|
77
|
+
* @returns {string} The string in snake case.
|
|
78
|
+
*/
|
|
79
|
+
toSnakeCase(): string;
|
|
80
|
+
/**
|
|
81
|
+
* Converts the string to camel case (e.g. "hello world" becomes "helloWorld").
|
|
82
|
+
* @returns {string} The string in camel case.
|
|
83
|
+
*/
|
|
84
|
+
toCamelCase(): string;
|
|
85
|
+
/**
|
|
86
|
+
* Converts the first character of the string to uppercase.
|
|
87
|
+
* @returns {string} The string with the first character in uppercase.
|
|
88
|
+
*/
|
|
89
|
+
upperFirst(): string;
|
|
90
|
+
/**
|
|
91
|
+
* Converts the first character of the string to lowercase.
|
|
92
|
+
* @returns {string} The string with the first character in lowercase.
|
|
93
|
+
*/
|
|
94
|
+
lowerFirst(): string;
|
|
95
|
+
/**
|
|
96
|
+
* Replaces all occurrences of the specified string with another string.
|
|
97
|
+
* @param {string} find The string to replace.
|
|
98
|
+
* @param {string} replace The string to replace with.
|
|
99
|
+
* @returns {string} The string with all occurrences replaced.
|
|
100
|
+
*/
|
|
101
|
+
replaceAll(find: string, replace: string): string;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Converts a string from camel case to snake case (e.g. "addElementComponent" becomes "ADD_ELEMENT_COMPONENT").
|
|
106
|
+
*
|
|
107
|
+
* This function takes a string as input, trims it, and then replaces all occurrences of camel case with underscores.
|
|
108
|
+
* The resulting string is then converted to uppercase.
|
|
109
|
+
*
|
|
110
|
+
* @param {string} text The string to convert.
|
|
111
|
+
* @returns {string} The string in snake case.
|
|
112
|
+
* @example
|
|
113
|
+
* ```typescript
|
|
114
|
+
* console.log(toSnakeCase("thisISDifficult")); // Output: "THIS_IS_DIFFICULT"
|
|
115
|
+
* console.log(toSnakeCase("thisISNT")); // Output: "THIS_ISNT"
|
|
116
|
+
* console.log(toSnakeCase("addElementComponent")); // Output: "ADD_ELEMENT_COMPONENT"
|
|
117
|
+
* ```
|
|
118
|
+
*/
|
|
119
|
+
export declare const toSnakeCase: (text: string) => string;
|
|
120
|
+
/**
|
|
121
|
+
* Converts a string from snake case to camel case (e.g. "ADD_ELEMENT_COMPONENT" becomes "addElementComponent").
|
|
122
|
+
*
|
|
123
|
+
* This function takes a string as input, trims it, and then replaces all occurrences of underscores with uppercase letters.
|
|
124
|
+
* The resulting string is then converted to camel case by making the first character lowercase.
|
|
125
|
+
*
|
|
126
|
+
* @param {string} text The string to convert.
|
|
127
|
+
* @returns {string} The string in camel case.
|
|
128
|
+
* @example
|
|
129
|
+
* ```typescript
|
|
130
|
+
* console.log(toCamelCase("THIS_IS_DIFFICULT")); // Output: "thisISDifficult"
|
|
131
|
+
* console.log(toCamelCase("THIS_ISNT")); // Output: "thisISNT"
|
|
132
|
+
* console.log(toCamelCase("ADD_ELEMENT_COMPONENT")); // Output: "addElementComponent"
|
|
133
|
+
* ```
|
|
134
|
+
*/
|
|
135
|
+
export declare const toCamelCase: (text: string) => string;
|
|
136
|
+
/**
|
|
137
|
+
* Converts the first character of a string to uppercase.
|
|
138
|
+
*
|
|
139
|
+
* This function takes a string as input, trims it, and then converts the first character to uppercase.
|
|
140
|
+
*
|
|
141
|
+
* @param {string} str The string to modify.
|
|
142
|
+
* @returns {string} The modified string with the first character in uppercase.
|
|
143
|
+
* @example
|
|
144
|
+
* ```typescript
|
|
145
|
+
* console.log(upperFirst("hello world")); // Output: "Hello world"
|
|
146
|
+
* console.log(upperFirst("HELLO WORLD")); // Output: "HELLO WORLD"
|
|
147
|
+
* console.log(upperFirst("")); // Output: ""
|
|
148
|
+
* ```
|
|
149
|
+
*/
|
|
150
|
+
export declare const upperFirst: (str: string) => string;
|
|
151
|
+
/**
|
|
152
|
+
* Converts the first character of a string to lowercase.
|
|
153
|
+
*
|
|
154
|
+
* This function takes a string as input, trims it, and then converts the first character to lowercase.
|
|
155
|
+
*
|
|
156
|
+
* @param {string} str The string to modify.
|
|
157
|
+
* @returns {string} The modified string with the first character in lowercase.
|
|
158
|
+
* @example
|
|
159
|
+
* ```typescript
|
|
160
|
+
* console.log(lowerFirst("Hello World")); // Output: "hello World"
|
|
161
|
+
* console.log(lowerFirst("HELLO WORLD")); // Output: "hello WORLD"
|
|
162
|
+
* console.log(lowerFirst("")); // Output: ""
|
|
163
|
+
* ```
|
|
164
|
+
*/
|
|
165
|
+
export declare const lowerFirst: (str: string) => string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';function n(t){return !!(t&&typeof t=="string")}var e=function(t,r=""){if(!t||typeof t!="string")return "";if(!r||typeof r!="string")return t.trim();let i=t.length;for(;t.startsWith(r)&&i>=0;)t=t.slice(r.length),--i;return t.toString()},o=function(t,r=""){if(!t||typeof t!="string")return "";if(!r||typeof r!="string")return t.trim();let i=t.length;for(;t.endsWith(r)&&i>=0;)t=t.slice(0,-r.length),--i;return t.toString()},s=(t,r=true)=>typeof t!="string"?false:r!==false?/^\d*\.?\d+$/.test(t):/^\d+$/.test(t);String.prototype.ltrim=function(t){return e(this.toString(),t)};String.prototype.rtrim=function(t){return o(this.toString(),t)};String.prototype.isNumber=function(t=true){return s(this.toString(),t)};String.prototype.replaceAll=function(t,r){return !n(t)||!n(r)?this.toString():this.toString().split(t).join(r)};var g=t=>n(t)?(t=t.trim(),t.replace(/(.)([A-Z][a-z]+)/,"$1_$2").replace(/([a-z0-9])([A-Z])/,"$1_$2").toUpperCase()):"";String.prototype.toSnakeCase=function(){return g(this.toString())};var p=t=>n(t)?(t=t.trim(),t.charAt(0)+t.replace(/(_\w)/g,r=>r[1].toUpperCase()).substring(1)):"";String.prototype.toCamelCase=function(){return p(this.toString())};var l=function(t){return !t||typeof t!="string"?"":(t=t.trim(),t.charAt(0).toUpperCase()+t.slice(1))};String.prototype.upperFirst=function(){return l(this.toString())};var a=function(t){return !t||typeof t!="string"?"":(t=t.trim(),t.charAt(0).toLowerCase()+t.slice(1))};String.prototype.lowerFirst=function(){return a(this.toString())};exports.isStringNumber=s;exports.lowerFirst=a;exports.ltrim=e;exports.rtrim=o;exports.toCamelCase=p;exports.toSnakeCase=g;exports.upperFirst=l;
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Converts a variable to a string representation.
|
|
3
|
+
*
|
|
4
|
+
* This function takes a variable as input and returns a string representation of it.
|
|
5
|
+
* It works similarly to the JSON.stringify function, but with additional options.
|
|
6
|
+
*
|
|
7
|
+
* @param {any} obj The variable to convert to a string.
|
|
8
|
+
* @param {{parenthesis: boolean}} [options] Additional options.
|
|
9
|
+
* @param {boolean} [options.parenthesis=false] Whether to wrap the result in parentheses.
|
|
10
|
+
* @param {boolean} [options.escapeString=true] Whether to escape quotes and other special characters in the string representation.
|
|
11
|
+
* @returns {string} The string representation of the variable.
|
|
12
|
+
* @example
|
|
13
|
+
* ```typescript
|
|
14
|
+
* console.log(stringify({ a: 1, b: 2 })); // Output: "{a:1,b:2}"
|
|
15
|
+
* console.log(stringify({ a: 1, b: 2 }, { parenthesis: true })); // Output: "({a:1,b:2})"
|
|
16
|
+
* console.log(stringify(null)); // Output: "null"
|
|
17
|
+
* console.log(stringify(undefined)); // Output: "undefined"
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare function stringify(obj: any, options?: {
|
|
21
|
+
parenthesis?: boolean;
|
|
22
|
+
escapeString?: boolean;
|
|
23
|
+
}): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';function f(r){return !!(r&&typeof r=="string")}function u(...r){for(var e in r){let t=r[e];if(f(t))return t}return ""}function g(r){return typeof r=="number"&&!isNaN(r)&&isFinite(r)}function p(r){return u(r).replace(/\\/g,"\\\\").replace(/'/g,"\\'").replace(/\n/g,"\\n").replace(/\r/g,"\\r").replace(/\t/g,"\\t").replace(/\v/g,"\\v").replace(/[\b]/g,"\\b").replace(/\f/g,"\\f")}function i(r,e){var t=Object.prototype.toString.call(r);return t==="[object "+e+"]"}function a(r,e){if(["boolean","undefined"].includes(typeof r)||r===null)return String(r);if(g(r))return r.formatNumber();if(r instanceof Date)return r.toFormat();if(r instanceof Error)return r==null?void 0:r.toString();e=Object.assign({},e);let{parenthesis:t}=e,c=t?"(":"",s=t?")":"";return typeof r=="string"?(e==null?void 0:e.escapeString)!==false?"'"+p(r)+"'":r:i(r,"RegExp")||i(r,"Number")||i(r,"Boolean")?r.toString():i(r,"Date")?"new Date("+r.getTime()+")":Array.isArray(r)?"["+r.map(n=>a(n,e)).join(",")+"]":typeof r=="object"?c+"{"+Object.keys(r).map(n=>{var l=r[n];return a(n,e)+":"+a(l,e)}).join(",")+"}"+s:r&&typeof(r==null?void 0:r.toString)=="function"?r==null?void 0:r.toString():String(r)}exports.stringify=a;
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates a unique identifier.
|
|
3
|
+
*
|
|
4
|
+
* This function takes three parameters: a prefix, a maximum length, and a separator.
|
|
5
|
+
* It generates a unique identifier with the specified prefix, length, and separator.
|
|
6
|
+
*
|
|
7
|
+
* @param {string} [prefix=""] The prefix to use for the identifier.
|
|
8
|
+
* @param {number} [idStrLen=16] The maximum length of the identifier.
|
|
9
|
+
* @param {string} [separator=""] The separator to use in the identifier.
|
|
10
|
+
* @returns {string} The generated unique identifier.
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* console.log(uniqid()); // Output: a random unique identifier
|
|
14
|
+
* console.log(uniqid("prefix", 16)); // Output: a unique identifier with prefix and length 16
|
|
15
|
+
* console.log(uniqid("prefix", 16, "-")); // Output: a unique identifier with prefix, length 16, and separator "-"
|
|
16
|
+
* ```
|
|
17
|
+
*/
|
|
18
|
+
export declare function uniqid(prefix: string, idStrLen?: number, separator?: string): string;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
'use strict';function h(g,t=16,n=""){n=n||"",g=g||"",t<=0&&(t=16),t=Math.floor(t);var o=g+(Math.floor(Math.random()*25)+10).toString(36)+n;o+=new Date().getTime().toString(36)+n;do o+=Math.floor(Math.random()*35).toString(36);while(o.length<t);return o}exports.uniqid=h;
|
|
@@ -0,0 +1,333 @@
|
|
|
1
|
+
import { IParseBaseOptions, IStringifyBaseOptions } from 'qs';
|
|
2
|
+
import { Dictionary } from '../../types';
|
|
3
|
+
/**
|
|
4
|
+
* Returns the query string from a given URL.
|
|
5
|
+
*
|
|
6
|
+
* This function takes a URL and an optional flag as input.
|
|
7
|
+
* It parses the URL to extract the query string, which is the part of the URL after the `?` character.
|
|
8
|
+
* If the `addQuestionSeparator` flag is true, the query string is returned with a leading `?` character.
|
|
9
|
+
*
|
|
10
|
+
* @param uri The URL to extract the query string from.
|
|
11
|
+
* @param addQuestionSeparator Whether to include the `?` character in the returned query string (default: true).
|
|
12
|
+
* @returns The query string associated with the given URL.
|
|
13
|
+
* @example
|
|
14
|
+
* ```typescript
|
|
15
|
+
* const url = 'https://example.com/path?a=1&b=2';
|
|
16
|
+
* console.log(extractQueryString(url)); // Output: "?a=1&b=2"
|
|
17
|
+
* console.log(extractQueryString(url, false)); // Output: "a=1&b=2"
|
|
18
|
+
* ```
|
|
19
|
+
*/
|
|
20
|
+
export declare const extractQueryString: (uri?: string, addQuestionSeparator?: boolean) => string;
|
|
21
|
+
/**
|
|
22
|
+
* Returns the query parameters from a given URL as an object.
|
|
23
|
+
*
|
|
24
|
+
* This function takes a URL and an optional options object as input.
|
|
25
|
+
* It extracts the query string from the URL using the `extractQueryString` function and then parses it into an object using the `queryString.parse` method.
|
|
26
|
+
* The `queryString.parse` method is configured to allow sparse arrays and to merge the provided options with the default options.
|
|
27
|
+
*
|
|
28
|
+
* @param uri The URL to extract the query parameters from.
|
|
29
|
+
* @param queryStringOpts Options for the `queryString.parse` method (default: {}).
|
|
30
|
+
* @returns An object containing the query parameters.
|
|
31
|
+
* @example
|
|
32
|
+
* ```typescript
|
|
33
|
+
* const url = 'https://example.com/path?a=1&b=2&c[]=3&c[]=4';
|
|
34
|
+
* console.log(getQueryParams(url)); // Output: { a: '1', b: '2', c: [ '3', '4' ] }
|
|
35
|
+
* ```
|
|
36
|
+
*/
|
|
37
|
+
export declare const getQueryParams: (uri: string | null | undefined, queryStringOpts?: IParseBaseOptions) => Dictionary;
|
|
38
|
+
/**
|
|
39
|
+
* Removes the query string from a given URL and returns the resulting URL.
|
|
40
|
+
*
|
|
41
|
+
* This function takes a URL and an optional flag as input.
|
|
42
|
+
* It removes the query string and any fragment identifier from the URL using regular expressions.
|
|
43
|
+
* If the `_decodeURIComponent` flag is true, the resulting URL is decoded using the `decodeURIComponent` function.
|
|
44
|
+
*
|
|
45
|
+
* @param uri The URL to remove the query string from.
|
|
46
|
+
* @param _decodeURIComponent Whether to decode the resulting URL using `decodeURIComponent` (default: false).
|
|
47
|
+
* @returns The URL with the query string removed.
|
|
48
|
+
* @example
|
|
49
|
+
* ```typescript
|
|
50
|
+
* const url = 'https://example.com/path?a=1&b=2#fragment';
|
|
51
|
+
* console.log(removeQueryString(url)); // Output: "https://example.com/path"
|
|
52
|
+
* console.log(removeQueryString(url, true)); // Output: "https://example.com/path" (decoded)
|
|
53
|
+
* ```
|
|
54
|
+
*/
|
|
55
|
+
export declare const removeQueryString: (uri: string | undefined | null, _decodeURIComponent?: boolean) => string;
|
|
56
|
+
/**
|
|
57
|
+
* Adds query parameters to a given URL.
|
|
58
|
+
*
|
|
59
|
+
* This function takes a URL, a key-value pair or an object of key-value pairs, and optional options as input.
|
|
60
|
+
* It removes any existing query string from the URL, merges the new query parameters with the existing ones, and then appends the resulting query string to the URL.
|
|
61
|
+
*
|
|
62
|
+
* @param url The URL to add query parameters to.
|
|
63
|
+
* @param key A string key or an object of key-value pairs to add to the query string.
|
|
64
|
+
* @param value The value associated with the key, only applicable when key is a string.
|
|
65
|
+
* @param options Options for the `queryString.stringify` method (default: {}).
|
|
66
|
+
* @returns The URL with the query parameters added.
|
|
67
|
+
* @example
|
|
68
|
+
* ```typescript
|
|
69
|
+
* const url = 'https://example.com/path';
|
|
70
|
+
* console.log(setQueryParams(url, 'a', 1)); // Output: "https://example.com/path?a=1"
|
|
71
|
+
* console.log(setQueryParams(url, { a: 1, b: 2 })); // Output: "https://example.com/path?a=1&b=2"
|
|
72
|
+
* ```
|
|
73
|
+
*/
|
|
74
|
+
export declare function setQueryParams(url: string | undefined | null, key: any, value?: any, options?: IStringifyBaseOptions): string;
|
|
75
|
+
/**
|
|
76
|
+
* Converts an object to a query string.
|
|
77
|
+
*
|
|
78
|
+
* This function takes an object and an optional flag as input.
|
|
79
|
+
* It recursively iterates through the object's properties and converts them to a query string format.
|
|
80
|
+
* If the `encodeURI` flag is true, the values are encoded using the `encodeURIComponent` function.
|
|
81
|
+
*
|
|
82
|
+
* @param o The object to convert to a query string.
|
|
83
|
+
* @param encodeURI Whether to encode the values using `encodeURIComponent` (default: false).
|
|
84
|
+
* @returns The object converted to a query string.
|
|
85
|
+
* @example
|
|
86
|
+
* ```typescript
|
|
87
|
+
* const obj = { a: 1, b: 2, c: { d: 3, e: 4 } };
|
|
88
|
+
* console.log(objectToQueryString(obj)); // Output: "a=1&b=2&c[d]=3&c[e]=4"
|
|
89
|
+
* console.log(objectToQueryString(obj, true)); // Output: "a=1&b=2&c%5Bd%5D=3&c%5Be%5D=4"
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
92
|
+
export declare function objectToQueryString(o: any, encodeURI?: boolean): string;
|
|
93
|
+
/**
|
|
94
|
+
* Parses a URI and returns the parsed object.
|
|
95
|
+
*
|
|
96
|
+
* This function takes a URI as input and returns an object containing the parsed components of the URI.
|
|
97
|
+
* The object includes properties for the hash, host, hostname, href, origin, pathname, port, protocol, search, username, and password.
|
|
98
|
+
*
|
|
99
|
+
* @param uri The URI to parse.
|
|
100
|
+
* @returns The parsed URI object.
|
|
101
|
+
* @example
|
|
102
|
+
* ```typescript
|
|
103
|
+
* const uri = 'http://username:password@localhost:257/deploy/?asd=asd#asd';
|
|
104
|
+
* console.log(parseURI(uri));
|
|
105
|
+
* // Output:
|
|
106
|
+
* // {
|
|
107
|
+
* // hash: "#asd",
|
|
108
|
+
* // host: "localhost:257",
|
|
109
|
+
* // hostname: "localhost",
|
|
110
|
+
* // href: "http://username:password@localhost:257/deploy/?asd=asd#asd",
|
|
111
|
+
* // origin: "http://username:password@localhost:257",
|
|
112
|
+
* // pathname: "/deploy/",
|
|
113
|
+
* // port: "257",
|
|
114
|
+
* // protocol: "http:",
|
|
115
|
+
* // search: "?asd=asd",
|
|
116
|
+
* // username: "username",
|
|
117
|
+
* // password: "password"
|
|
118
|
+
* // }
|
|
119
|
+
* ```
|
|
120
|
+
*/
|
|
121
|
+
export declare const parseURI: (uri: string | null | undefined) => {
|
|
122
|
+
hash?: string;
|
|
123
|
+
host?: string;
|
|
124
|
+
hostname?: string;
|
|
125
|
+
href?: string;
|
|
126
|
+
origin?: string;
|
|
127
|
+
pathname?: string;
|
|
128
|
+
port?: string;
|
|
129
|
+
protocol?: string;
|
|
130
|
+
search?: string;
|
|
131
|
+
username?: string;
|
|
132
|
+
password?: string;
|
|
133
|
+
};
|
|
134
|
+
/**
|
|
135
|
+
* Options for configuring URL validation behavior.
|
|
136
|
+
*
|
|
137
|
+
* @public
|
|
138
|
+
*/
|
|
139
|
+
export interface IsUrlOptions {
|
|
140
|
+
/**
|
|
141
|
+
* If true, only allows protocols that require a hostname (http, https, ftp, etc.).
|
|
142
|
+
* If false, allows all valid protocols including mailto, tel, data, etc.
|
|
143
|
+
*
|
|
144
|
+
* @defaultValue true
|
|
145
|
+
*/
|
|
146
|
+
requireHost?: boolean;
|
|
147
|
+
/**
|
|
148
|
+
* List of allowed protocols. If provided, only URLs with these protocols are considered valid.
|
|
149
|
+
* Protocols should be specified without the trailing colon (e.g., 'http', not 'http:').
|
|
150
|
+
*
|
|
151
|
+
* @defaultValue undefined (all protocols allowed based on requireHost setting)
|
|
152
|
+
*
|
|
153
|
+
* @example
|
|
154
|
+
* ```typescript
|
|
155
|
+
* // Only allow HTTPS URLs
|
|
156
|
+
* isUrl('https://example.com', { allowedProtocols: ['https'] }); // true
|
|
157
|
+
* isUrl('http://example.com', { allowedProtocols: ['https'] }); // false
|
|
158
|
+
* ```
|
|
159
|
+
*/
|
|
160
|
+
allowedProtocols?: string[];
|
|
161
|
+
}
|
|
162
|
+
/**
|
|
163
|
+
* Validates whether a given string is a valid, full URL.
|
|
164
|
+
*
|
|
165
|
+
* @remarks
|
|
166
|
+
* This function uses a dual-approach validation strategy:
|
|
167
|
+
* 1. First attempts to use the native URL constructor if available (modern environments)
|
|
168
|
+
* 2. Falls back to a comprehensive regex pattern for environments without URL support
|
|
169
|
+
*
|
|
170
|
+
* By default, a valid full URL must include:
|
|
171
|
+
* - A protocol (http, https, ftp, etc.)
|
|
172
|
+
* - A domain/host (for protocols that require one)
|
|
173
|
+
* - Optional path, query parameters, and hash fragments
|
|
174
|
+
*
|
|
175
|
+
* The function can be configured to:
|
|
176
|
+
* - Accept only host-requiring protocols (default)
|
|
177
|
+
* - Accept any valid URI including mailto:, tel:, data:, etc.
|
|
178
|
+
* - Restrict to specific protocols only
|
|
179
|
+
*
|
|
180
|
+
* @param value - The string to test for URL validity
|
|
181
|
+
* @param options - Optional configuration for validation behavior
|
|
182
|
+
*
|
|
183
|
+
* @returns `true` if the string is a valid full URL, `false` otherwise
|
|
184
|
+
*
|
|
185
|
+
* @example
|
|
186
|
+
* Basic usage:
|
|
187
|
+
* ```typescript
|
|
188
|
+
* isUrl('https://example.com'); // true
|
|
189
|
+
* isUrl('example.com'); // false (missing protocol)
|
|
190
|
+
* isUrl('mailto:user@example.com'); // false (default requires host)
|
|
191
|
+
* ```
|
|
192
|
+
*
|
|
193
|
+
* @example
|
|
194
|
+
* Allow all valid URIs:
|
|
195
|
+
* ```typescript
|
|
196
|
+
* isUrl('mailto:user@example.com', { requireHost: false }); // true
|
|
197
|
+
* isUrl('tel:+1234567890', { requireHost: false }); // true
|
|
198
|
+
* isUrl('data:text/plain,hello', { requireHost: false }); // true
|
|
199
|
+
* ```
|
|
200
|
+
*
|
|
201
|
+
* @example
|
|
202
|
+
* Restrict to specific protocols:
|
|
203
|
+
* ```typescript
|
|
204
|
+
* isUrl('https://example.com', { allowedProtocols: ['https'] }); // true
|
|
205
|
+
* isUrl('http://example.com', { allowedProtocols: ['https'] }); // false
|
|
206
|
+
* ```
|
|
207
|
+
*
|
|
208
|
+
* @public
|
|
209
|
+
*/
|
|
210
|
+
export declare function isUrl(value: string, options?: IsUrlOptions): boolean;
|
|
211
|
+
/**
|
|
212
|
+
* Detects if a URL string has been encoded using encodeURIComponent.
|
|
213
|
+
*
|
|
214
|
+
* This function uses multiple heuristics to determine if a string has been
|
|
215
|
+
* encoded with encodeURIComponent. It checks for:
|
|
216
|
+
* 1. Presence of valid encoded character sequences (%XX where XX are hex digits)
|
|
217
|
+
* 2. Whether decoding changes the string (indicating encoded content)
|
|
218
|
+
* 3. Handles mixed encoded/unencoded content properly
|
|
219
|
+
*
|
|
220
|
+
* @param {any} str - The string to check for encoding
|
|
221
|
+
* @returns {boolean} - Returns true if the string appears to be encoded, false otherwise
|
|
222
|
+
*
|
|
223
|
+
* @example
|
|
224
|
+
* console.log(isUriEncoded('hello%20world')); // true
|
|
225
|
+
* console.log(isUriEncoded('hello world')); // false
|
|
226
|
+
* console.log(isUriEncoded('hello%2Bworld')); // true
|
|
227
|
+
* console.log(isUriEncoded('hello+world')); // false
|
|
228
|
+
* console.log(isUriEncoded('https%3A%2F%2Fexample.com')); // true
|
|
229
|
+
* console.log(isUriEncoded('https://example.com')); // false
|
|
230
|
+
* console.log(isUriEncoded('hello%20world%21normal')); // true (mixed)
|
|
231
|
+
*/
|
|
232
|
+
export declare const isUriEncoded: (str: string) => boolean;
|
|
233
|
+
/**
|
|
234
|
+
* Options for configuring Data URL validation behavior.
|
|
235
|
+
*
|
|
236
|
+
* @public
|
|
237
|
+
*/
|
|
238
|
+
export interface IsDataUrlOptions {
|
|
239
|
+
/**
|
|
240
|
+
* List of allowed MIME types. If provided, only Data URLs with these MIME types are considered valid.
|
|
241
|
+
* MIME types should be specified in lowercase (e.g., 'image/png', 'text/plain').
|
|
242
|
+
*
|
|
243
|
+
* @defaultValue undefined (all MIME types allowed)
|
|
244
|
+
*
|
|
245
|
+
* @example
|
|
246
|
+
* ```typescript
|
|
247
|
+
* // Only allow image Data URLs
|
|
248
|
+
* isDataUrl('data:image/png;base64,ABC', { allowedMimeTypes: ['image/png', 'image/jpeg'] }); // true
|
|
249
|
+
* isDataUrl('data:text/plain;base64,ABC', { allowedMimeTypes: ['image/png'] }); // false
|
|
250
|
+
* ```
|
|
251
|
+
*/
|
|
252
|
+
allowedMimeTypes?: string[];
|
|
253
|
+
/**
|
|
254
|
+
* If true, requires the Data URL to use base64 encoding.
|
|
255
|
+
* If false, allows both base64 and URL-encoded data.
|
|
256
|
+
*
|
|
257
|
+
* @defaultValue false
|
|
258
|
+
*
|
|
259
|
+
* @example
|
|
260
|
+
* ```typescript
|
|
261
|
+
* isDataUrl('data:text/plain;base64,SGVsbG8=', { requireBase64: true }); // true
|
|
262
|
+
* isDataUrl('data:text/plain,Hello', { requireBase64: true }); // false
|
|
263
|
+
* ```
|
|
264
|
+
*/
|
|
265
|
+
requireBase64?: boolean;
|
|
266
|
+
/**
|
|
267
|
+
* If true, validates that base64-encoded data appears to be valid base64.
|
|
268
|
+
* Performs basic validation of base64 character set and padding.
|
|
269
|
+
*
|
|
270
|
+
* @defaultValue false
|
|
271
|
+
*
|
|
272
|
+
* @example
|
|
273
|
+
* ```typescript
|
|
274
|
+
* isDataUrl('data:text/plain;base64,SGVsbG8=', { validateBase64: true }); // true
|
|
275
|
+
* isDataUrl('data:text/plain;base64,!!!invalid', { validateBase64: true }); // false
|
|
276
|
+
* ```
|
|
277
|
+
*/
|
|
278
|
+
validateBase64?: boolean;
|
|
279
|
+
}
|
|
280
|
+
/**
|
|
281
|
+
* Validates whether a given string is a valid Data URL (RFC 2897).
|
|
282
|
+
*
|
|
283
|
+
* @remarks
|
|
284
|
+
* Data URLs allow embedding small files inline in documents using the format:
|
|
285
|
+
* `data:[<mediatype>][;base64],<data>`
|
|
286
|
+
*
|
|
287
|
+
* This function validates:
|
|
288
|
+
* - Proper data: protocol prefix
|
|
289
|
+
* - Valid MIME type format (if present)
|
|
290
|
+
* - Proper encoding declaration (base64 or URL-encoded)
|
|
291
|
+
* - Data payload presence
|
|
292
|
+
*
|
|
293
|
+
* Components of a Data URL:
|
|
294
|
+
* - Protocol: Always "data:"
|
|
295
|
+
* - Media type (optional): MIME type like "text/plain" or "image/png" (defaults to "text/plain;charset=US-ASCII")
|
|
296
|
+
* - Encoding (optional): ";base64" for base64 encoding (defaults to URL encoding)
|
|
297
|
+
* - Data: The actual content after the comma
|
|
298
|
+
*
|
|
299
|
+
* The function uses a dual-approach validation strategy:
|
|
300
|
+
* 1. First attempts to use the native URL constructor if available (modern environments)
|
|
301
|
+
* 2. Falls back to a comprehensive regex pattern for environments without URL support
|
|
302
|
+
*
|
|
303
|
+
* @param value - The string to test for Data URL validity
|
|
304
|
+
* @param options - Optional configuration for validation behavior
|
|
305
|
+
*
|
|
306
|
+
* @returns `true` if the string is a valid Data URL, `false` otherwise
|
|
307
|
+
*
|
|
308
|
+
* @example
|
|
309
|
+
* Basic usage:
|
|
310
|
+
* ```typescript
|
|
311
|
+
* isDataUrl('data:text/plain,Hello%20World'); // true
|
|
312
|
+
* isDataUrl('data:text/plain;base64,SGVsbG8gV29ybGQ='); // true
|
|
313
|
+
* isDataUrl('data:image/png;base64,iVBORw0KG...'); // true
|
|
314
|
+
* isDataUrl('not a data url'); // false
|
|
315
|
+
* ```
|
|
316
|
+
*
|
|
317
|
+
* @example
|
|
318
|
+
* With MIME type filtering:
|
|
319
|
+
* ```typescript
|
|
320
|
+
* isDataUrl('data:image/png;base64,ABC', { allowedMimeTypes: ['image/png'] }); // true
|
|
321
|
+
* isDataUrl('data:text/plain,Hello', { allowedMimeTypes: ['image/png'] }); // false
|
|
322
|
+
* ```
|
|
323
|
+
*
|
|
324
|
+
* @example
|
|
325
|
+
* Require base64 encoding:
|
|
326
|
+
* ```typescript
|
|
327
|
+
* isDataUrl('data:text/plain;base64,SGVsbG8=', { requireBase64: true }); // true
|
|
328
|
+
* isDataUrl('data:text/plain,Hello', { requireBase64: true }); // false
|
|
329
|
+
* ```
|
|
330
|
+
*
|
|
331
|
+
* @public
|
|
332
|
+
*/
|
|
333
|
+
export declare function isDataUrl(value: string, options?: IsDataUrlOptions): boolean;
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
'use strict';var R=require('qs');function _interopDefault(e){return e&&e.__esModule?e:{default:e}}var R__default=/*#__PURE__*/_interopDefault(R);var L=Object.defineProperty;var P=Object.getOwnPropertySymbols;var T=Object.prototype.hasOwnProperty,B=Object.prototype.propertyIsEnumerable;var A=(t,e,r)=>e in t?L(t,e,{enumerable:true,configurable:true,writable:true,value:r}):t[e]=r,w=(t,e)=>{for(var r in e||(e={}))T.call(e,r)&&A(t,r,e[r]);if(P)for(var r of P(e))B.call(e,r)&&A(t,r,e[r]);return t};function g(t){return !!(t&&typeof t=="string")}var U=function(t,e=""){if(!t||typeof t!="string")return "";if(!e||typeof e!="string")return t.trim();let r=t.length;for(;t.startsWith(e)&&r>=0;)t=t.slice(e.length),--r;return t.toString()},C=function(t,e=""){if(!t||typeof t!="string")return "";if(!e||typeof e!="string")return t.trim();let r=t.length;for(;t.endsWith(e)&&r>=0;)t=t.slice(0,-e.length),--r;return t.toString()},N=(t,e=true)=>typeof t!="string"?false:e!==false?/^\d*\.?\d+$/.test(t):/^\d+$/.test(t);String.prototype.ltrim=function(t){return U(this.toString(),t)};String.prototype.rtrim=function(t){return C(this.toString(),t)};String.prototype.isNumber=function(t=true){return N(this.toString(),t)};String.prototype.replaceAll=function(t,e){return !g(t)||!g(e)?this.toString():this.toString().split(t).join(e)};var q=t=>g(t)?(t=t.trim(),t.replace(/(.)([A-Z][a-z]+)/,"$1_$2").replace(/([a-z0-9])([A-Z])/,"$1_$2").toUpperCase()):"";String.prototype.toSnakeCase=function(){return q(this.toString())};var D=t=>g(t)?(t=t.trim(),t.charAt(0)+t.replace(/(_\w)/g,e=>e[1].toUpperCase()).substring(1)):"";String.prototype.toCamelCase=function(){return D(this.toString())};var F=function(t){return !t||typeof t!="string"?"":(t=t.trim(),t.charAt(0).toUpperCase()+t.slice(1))};String.prototype.upperFirst=function(){return F(this.toString())};var M=function(t){return !t||typeof t!="string"?"":(t=t.trim(),t.charAt(0).toLowerCase()+t.slice(1))};String.prototype.lowerFirst=function(){return M(this.toString())};var W=(t,e=true)=>{if(typeof t!="string")return "";let r=V(t);return t=typeof r.search=="string"?r.search:"",e&&t?"?"+U(t,"?"):(t=C(U(t.trim(),"?"),"?"),t)},Z=function(t,e={}){return typeof t!="string"?{}:R__default.default.parse(W(t,false),w({allowSparse:true,decoder:r=>decodeURIComponent(r.replace(/\+/g," "))},Object.assign({},e)))},E=function(t,e=false){return typeof t!="string"?"":(t=t.replace(/#.*$/,"").replace(/\?.*$/,""),e===true?decodeURIComponent(t):t)},Q={indices:true,encodeValuesOnly:false,skipNulls:false,arrayFormat:"indices",encoder:t=>encodeURIComponent(t).replace(/%5B/g,"[").replace(/%5D/g,"]")};function rt(t,e,r,s={}){if(typeof t!="string")return "";t||(t="");let i=Z(t),n=t.split("#"),a=n[0],d=n[1]?"#"+n[1]:"";t=E(a),typeof e=="object"?(e||(e={}),s=typeof s=="object"&&s?s:typeof r=="object"&&r?r:{}):typeof e=="string"&&(e={[e]:r}),typeof e=="object"&&e&&!Array.isArray(e)&&Object.assign(i,e);let u=R__default.default.stringify(i,w(w({},Q),Object.assign({},s)));return t+(u?"?"+u:"")+d}function nt(t,e=false){if(t==null||typeof t!="object")return "";function r(i,n){if(Array.isArray(i)){i.forEach(function(a){r(a,n+"[]");});return}if(i!==null&&typeof i=="object"){Object.keys(i).forEach(function(a){r(i[a],n+"["+a+"]");});return}s.push((e?encodeURIComponent(n):n)+"="+(e?encodeURIComponent(i):i));}let s=[];return Object.keys(t).forEach(function(i){r(t[i],i);}),s.join("&")}var V=t=>{if(typeof t!="string")return {};if(typeof URL!="undefined"&&URL&&H(t))try{return new URL(t)}catch(s){}t=_(t)?decodeURIComponent(t):t;var e=t.match(/^(([^:\\/?#]+:)?(?:\/\/((?:([^\\/?#:]*):([^\\/?#:]*)@)?([^\\/?#:]*)(?::([^\\/?#:]*))?)))?([^?#]*)(\?[^#]*)?(#.*)?$/);let r=e?{hash:e[10]||"",host:e[3]||"",hostname:e[6]||"",href:e[0]||"",origin:e[1]||"",pathname:e[8]||(e[1]?"/":""),port:e[7]||"",protocol:e[2]||"",search:e[9]||"",username:e[4]||"",password:e[5]||""}:{};return r.protocol&&r.protocol.length==2&&(r.protocol="file:///"+r.protocol.toUpperCase(),r.origin=r.protocol+"//"+r.host),r.protocol&&(r.href=r.origin+r.pathname+r.search+r.hash),r};function H(t,e={}){let{requireHost:r=true,allowedProtocols:s}=Object.assign({},e);if(!g(t)||!g(t.trim()))return false;let i=t;if(typeof URL!="undefined"&&URL)try{let n=new URL(i);if(!n.protocol||n.protocol===":")return !1;let a=n.protocol.slice(0,-1);if(s&&s.length>0&&!s.includes(a))return !1;if(r)if(["http","https","ftp","ftps","ws","wss"].includes(a)){if(!g(n.hostname)||!n.hostname.trim()||!g(n.host)||!n.host.trim())return !1;let u=`${a}://`;if(!i.startsWith(u)||i.slice(u.length).startsWith("/"))return !1;let p=/^(\d{1,3})\.(\d{1,3})\.(\d{1,3})\.(\d{1,3})$/,h=n.hostname.match(p);if(h&&!h.slice(1,5).map(Number).every(o=>o>=0&&o<=255))return !1}else return !1;return !0}catch(n){return false}if(r){let n=i.indexOf("://");if(n===-1)return false;let a=i.slice(0,n);if(!a||s&&s.length>0&&!s.includes(a))return false;let d=i.slice(n+3);if(d==="")return false;let u=d.indexOf("@"),c=u>=0?d.slice(u+1):d;if(c===""||c.startsWith("/"))return false;let p=c.indexOf("/"),h=c.indexOf("?"),x=c.indexOf("#"),b=Math.min(p>=0?p:c.length,h>=0?h:c.length,x>=0?x:c.length),o=c.slice(0,b);if(!o)return false;let l=o;if(o.startsWith("[")){let f=o.indexOf("]");if(f===-1)return false;l=o.slice(0,f+1);let m=o.slice(f+1);if(m&&!m.startsWith(":"))return false}else {let f=o.indexOf(":");f>=0&&(l=o.slice(0,f));}if(!l)return false;if(l==="localhost")return true;if(/^\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}$/.test(l))return !l.split(".").map(Number).some(m=>m>255||m<0);if(/^\[.*\]$/.test(l)){let f=l.slice(1,-1);return !(!f||f.includes(":::"))}return !!(/^[a-zA-Z\d-]*(\.[a-zA-Z\d-]+)*$/.test(l)&&l!=="")}else {let n="[a-zA-Z][a-zA-Z\\d+\\-.]*";return s&&s.length>0&&(n=`(?:${s.join("|")})`),new RegExp(`^(${n}):.+$`).test(i)}}var _=t=>{if(!g(t)||!t.includes("%"))return false;let e=/%[0-9A-Fa-f]{2}/g;if(!t.match(e))return false;try{let s=decodeURIComponent(t);if(s!==t)return !0;try{if(decodeURIComponent(s)!==s)return !0}catch(i){return !0}}catch(s){return false}return false};function st(t,e={}){let{allowedMimeTypes:r,requireBase64:s=false,validateBase64:i=false}=Object.assign({},e);if(typeof t!="string"||t.trim()==="")return false;let n=t.trim();if(!n.toLowerCase().startsWith("data:"))return false;if(typeof URL!="undefined")try{if(new URL(n).protocol!=="data:")return !1;let o=/^data:([^,;]*)(;[^,]*)?,(.*)$/i,l=n.match(o);if(!l)return !1;let[,f,m,y]=l;if(y===void 0||y.length===0)return !1;let I=(f||"text/plain").trim().toLowerCase();if(f&&f.trim()!==""&&!/^[a-z]+\/[a-z0-9][a-z0-9\-+.]*$/i.test(I)||r&&r.length>0&&!r.some(S=>S.toLowerCase()===I))return !1;let O=(m==null?void 0:m.toLowerCase().includes("base64"))||!1;if(s&&!O)return !1;if(i&&O){if(!/^[A-Za-z0-9+/]*={0,2}$/.test(y)||y.length%4!==0)return !1;let S=y.match(/=+$/);if(S&&S[0].length>2)return !1;if(y.includes("=")){let j=y.indexOf("="),z=y.slice(j);if(!/^=+$/.test(z))return !1}}return !0}catch(b){return false}let a=/^data:([^,;]*)(;[^,]*)?,(.+)$/i,d=n.match(a);if(!d)return false;let[,u,c,p]=d,h=(u||"text/plain").trim().toLowerCase();if(u&&u.trim()!==""&&!/^[a-z]+\/[a-z0-9][a-z0-9\-+.]*$/i.test(h)||r&&r.length>0&&!r.some(o=>o.toLowerCase()===h))return false;let x=(c==null?void 0:c.toLowerCase().includes("base64"))||false;if(s&&!x)return false;if(i&&x){if(!/^[A-Za-z0-9+/]*={0,2}$/.test(p)||p.length%4!==0)return false;let o=p.match(/=+$/);if(o&&o[0].length>2)return false;if(p.includes("=")){let l=p.indexOf("="),f=p.slice(l);if(!/^=+$/.test(f))return false}}return true}
|
|
2
|
+
exports.extractQueryString=W;exports.getQueryParams=Z;exports.isDataUrl=st;exports.isUriEncoded=_;exports.isUrl=H;exports.objectToQueryString=nt;exports.parseURI=V;exports.removeQueryString=E;exports.setQueryParams=rt;
|