@creopse/utils 0.0.1
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 +1 -0
- package/dist/enums/account-status.d.ts +4 -0
- package/dist/enums/account-status.js +5 -0
- package/dist/enums/ad-content-type.d.ts +4 -0
- package/dist/enums/ad-content-type.js +5 -0
- package/dist/enums/auth-type.d.ts +8 -0
- package/dist/enums/auth-type.js +9 -0
- package/dist/enums/bool.d.ts +4 -0
- package/dist/enums/bool.js +5 -0
- package/dist/enums/content-type.d.ts +6 -0
- package/dist/enums/content-type.js +7 -0
- package/dist/enums/index.d.ts +16 -0
- package/dist/enums/index.js +16 -0
- package/dist/enums/media-file-type.d.ts +7 -0
- package/dist/enums/media-file-type.js +8 -0
- package/dist/enums/menu-item-target-type.d.ts +5 -0
- package/dist/enums/menu-item-target-type.js +6 -0
- package/dist/enums/news-article-status.d.ts +6 -0
- package/dist/enums/news-article-status.js +7 -0
- package/dist/enums/notification-source.d.ts +4 -0
- package/dist/enums/notification-source.js +5 -0
- package/dist/enums/notification-type.d.ts +3 -0
- package/dist/enums/notification-type.js +4 -0
- package/dist/enums/permalink-content-type.d.ts +6 -0
- package/dist/enums/permalink-content-type.js +7 -0
- package/dist/enums/profile-type.d.ts +3 -0
- package/dist/enums/profile-type.js +4 -0
- package/dist/enums/response-error-code.d.ts +18 -0
- package/dist/enums/response-error-code.js +20 -0
- package/dist/enums/user-role.d.ts +5 -0
- package/dist/enums/user-role.js +6 -0
- package/dist/enums/video-display-type.d.ts +4 -0
- package/dist/enums/video-display-type.js +5 -0
- package/dist/enums/video-item-source.d.ts +4 -0
- package/dist/enums/video-item-source.js +5 -0
- package/dist/index.d.ts +4 -0
- package/dist/index.js +4 -0
- package/dist/models/ad-identifier.d.ts +14 -0
- package/dist/models/ad-identifier.js +11 -0
- package/dist/models/ad.d.ts +21 -0
- package/dist/models/ad.js +16 -0
- package/dist/models/admin-profile.d.ts +7 -0
- package/dist/models/admin-profile.js +8 -0
- package/dist/models/app-information.d.ts +8 -0
- package/dist/models/app-information.js +9 -0
- package/dist/models/app-setting.d.ts +8 -0
- package/dist/models/app-setting.js +9 -0
- package/dist/models/content-model-item.d.ts +17 -0
- package/dist/models/content-model-item.js +12 -0
- package/dist/models/content-model.d.ts +18 -0
- package/dist/models/content-model.js +16 -0
- package/dist/models/index.d.ts +30 -0
- package/dist/models/index.js +30 -0
- package/dist/models/media-file.d.ts +23 -0
- package/dist/models/media-file.js +22 -0
- package/dist/models/menu-item-group.d.ts +8 -0
- package/dist/models/menu-item-group.js +9 -0
- package/dist/models/menu-item.d.ts +39 -0
- package/dist/models/menu-item.js +25 -0
- package/dist/models/menu-location.d.ts +8 -0
- package/dist/models/menu-location.js +9 -0
- package/dist/models/menu.d.ts +15 -0
- package/dist/models/menu.js +11 -0
- package/dist/models/news-article.d.ts +35 -0
- package/dist/models/news-article.js +23 -0
- package/dist/models/news-category.d.ts +20 -0
- package/dist/models/news-category.js +17 -0
- package/dist/models/news-comment.d.ts +18 -0
- package/dist/models/news-comment.js +15 -0
- package/dist/models/news-tag.d.ts +15 -0
- package/dist/models/news-tag.js +13 -0
- package/dist/models/newsletter-campaign.d.ts +17 -0
- package/dist/models/newsletter-campaign.js +13 -0
- package/dist/models/newsletter-email.d.ts +7 -0
- package/dist/models/newsletter-email.js +8 -0
- package/dist/models/newsletter-phone.d.ts +7 -0
- package/dist/models/newsletter-phone.js +8 -0
- package/dist/models/notification.d.ts +22 -0
- package/dist/models/notification.js +12 -0
- package/dist/models/page.d.ts +15 -0
- package/dist/models/page.js +15 -0
- package/dist/models/permalink.d.ts +14 -0
- package/dist/models/permalink.js +12 -0
- package/dist/models/permission.d.ts +9 -0
- package/dist/models/permission.js +10 -0
- package/dist/models/role.d.ts +11 -0
- package/dist/models/role.js +11 -0
- package/dist/models/section.d.ts +17 -0
- package/dist/models/section.js +12 -0
- package/dist/models/subscriber-profile.d.ts +7 -0
- package/dist/models/subscriber-profile.js +8 -0
- package/dist/models/user-session.d.ts +27 -0
- package/dist/models/user-session.js +12 -0
- package/dist/models/user.d.ts +36 -0
- package/dist/models/user.js +27 -0
- package/dist/models/video-item.d.ts +23 -0
- package/dist/models/video-item.js +22 -0
- package/dist/models/video-setting.d.ts +8 -0
- package/dist/models/video-setting.js +9 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/dist/types/app-information.d.ts +41 -0
- package/dist/types/app-information.js +1 -0
- package/dist/types/common.d.ts +11 -0
- package/dist/types/common.js +1 -0
- package/dist/types/index.d.ts +4 -0
- package/dist/types/index.js +4 -0
- package/dist/types/pagination.d.ts +26 -0
- package/dist/types/pagination.js +1 -0
- package/dist/types/props.d.ts +42 -0
- package/dist/types/props.js +1 -0
- package/dist/utils/chronos.d.ts +97 -0
- package/dist/utils/chronos.js +97 -0
- package/dist/utils/functions.d.ts +312 -0
- package/dist/utils/functions.js +574 -0
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.js +2 -0
- package/package.json +48 -0
|
@@ -0,0 +1,312 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Generates the initials of a given name.
|
|
3
|
+
*
|
|
4
|
+
* @param {string} name - The name to generate the initials from.
|
|
5
|
+
* @return {string} The initials of the given name.
|
|
6
|
+
*/
|
|
7
|
+
export declare function getNameInitials(name: string): string;
|
|
8
|
+
/**
|
|
9
|
+
* Generates a random integer between the provided minimum and maximum values (inclusive).
|
|
10
|
+
*
|
|
11
|
+
* @param {number} min - The minimum value for the random integer.
|
|
12
|
+
* @param {number} max - The maximum value for the random integer.
|
|
13
|
+
* @return {number} The randomly generated integer.
|
|
14
|
+
*/
|
|
15
|
+
export declare function getRandomInteger(min: number, max: number): number;
|
|
16
|
+
/**
|
|
17
|
+
* Removes the trailing slash from a given path.
|
|
18
|
+
*
|
|
19
|
+
* @param {string} path - The path to remove the trailing slash from.
|
|
20
|
+
* @return {string} The path without the trailing slash.
|
|
21
|
+
*/
|
|
22
|
+
export declare function removeTrailingSlash(path: string): string;
|
|
23
|
+
/**
|
|
24
|
+
* Removes the leading slash from a path if it starts with a slash.
|
|
25
|
+
*
|
|
26
|
+
* @param {string} path - The path from which to remove the leading slash.
|
|
27
|
+
* @return {string} The path without the leading slash.
|
|
28
|
+
*/
|
|
29
|
+
export declare function removeLeadingSlash(path: string): string;
|
|
30
|
+
/**
|
|
31
|
+
* Calculates the distance between two points on the Earth's surface using the Haversine formula.
|
|
32
|
+
*
|
|
33
|
+
* @param {number} lat1 - The latitude of the first point.
|
|
34
|
+
* @param {number} lon1 - The longitude of the first point.
|
|
35
|
+
* @param {number} lat2 - The latitude of the second point.
|
|
36
|
+
* @param {number} lon2 - The longitude of the second point.
|
|
37
|
+
* @return {number} The distance between the two points in kilometers.
|
|
38
|
+
*/
|
|
39
|
+
export declare function getDistanceFromLatLonInKm(lat1: number, lon1: number, lat2: number, lon2: number): number;
|
|
40
|
+
/**
|
|
41
|
+
* Converts degrees to radians.
|
|
42
|
+
*
|
|
43
|
+
* @param {number} deg - The angle in degrees.
|
|
44
|
+
* @returns {number} The angle in radians.
|
|
45
|
+
*/
|
|
46
|
+
export declare function deg2rad(deg: number): number;
|
|
47
|
+
/**
|
|
48
|
+
* Checks if the given path is an external URL, email address, or phone number.
|
|
49
|
+
*
|
|
50
|
+
* @param {string} path - The path to check.
|
|
51
|
+
* @return {boolean} Returns true if the path is external, false otherwise.
|
|
52
|
+
*/
|
|
53
|
+
export declare function isExternal(path: string): boolean;
|
|
54
|
+
/**
|
|
55
|
+
* Formats the given duration in seconds into a string representation of time.
|
|
56
|
+
*
|
|
57
|
+
* @param {number} duration - The duration in seconds to be formatted.
|
|
58
|
+
* @param {Object} options - Optional parameters for formatting.
|
|
59
|
+
* @param {string} options.separator - The separator used between hours, minutes, and seconds. Defaults to ':'.
|
|
60
|
+
* @return {string} - The formatted time string.
|
|
61
|
+
*/
|
|
62
|
+
export declare function formatTimeFromSeconds(duration: number, { separator }?: {
|
|
63
|
+
separator?: string | undefined;
|
|
64
|
+
}): string;
|
|
65
|
+
/**
|
|
66
|
+
* Pads the left side of a string with a specified character until it reaches a specified length.
|
|
67
|
+
*
|
|
68
|
+
* @param {string} string - The string to be padded.
|
|
69
|
+
* @param {string} pad - The character used for padding.
|
|
70
|
+
* @param {number} length - The desired length of the resulting string.
|
|
71
|
+
* @return {string} The padded string.
|
|
72
|
+
*/
|
|
73
|
+
export declare function strPadLeft(string: string, pad: string, length: number): string;
|
|
74
|
+
/**
|
|
75
|
+
* Capitalizes the first letter of a given string.
|
|
76
|
+
*
|
|
77
|
+
* @param {string} string - The string to capitalize.
|
|
78
|
+
* @return {string} The modified string with the first letter capitalized.
|
|
79
|
+
*/
|
|
80
|
+
export declare function capitalizeFirstLetter(string: string): string;
|
|
81
|
+
/**
|
|
82
|
+
* Generates a password with the specified length and character options.
|
|
83
|
+
*
|
|
84
|
+
* @param {number} length - The length of the password to be generated. Default is 10.
|
|
85
|
+
* @param {object} options - The character options for the password. Default is { letters: true, numbers: true, symbols: false }.
|
|
86
|
+
* @param {boolean} options.letters - Specifies whether to include letters in the password. Default is true.
|
|
87
|
+
* @param {boolean} options.numbers - Specifies whether to include numbers in the password. Default is true.
|
|
88
|
+
* @param {boolean} options.symbols - Specifies whether to include symbols in the password. Default is false.
|
|
89
|
+
* @return {string} The generated password.
|
|
90
|
+
*/
|
|
91
|
+
export declare function genPassword(length?: number, { letters, numbers, symbols }?: {
|
|
92
|
+
letters?: boolean | undefined;
|
|
93
|
+
numbers?: boolean | undefined;
|
|
94
|
+
symbols?: boolean | undefined;
|
|
95
|
+
}): string;
|
|
96
|
+
/**
|
|
97
|
+
* Extracts uppercase words from the given input string.
|
|
98
|
+
*
|
|
99
|
+
* @param {string} input - The input string to extract uppercase words from.
|
|
100
|
+
* @return {Array<string>} An array of uppercase words found in the input string.
|
|
101
|
+
*/
|
|
102
|
+
export declare function extractUppercaseWords(input: string): RegExpMatchArray | null;
|
|
103
|
+
/**
|
|
104
|
+
* Extracts lowercase words from the input string.
|
|
105
|
+
*
|
|
106
|
+
* @param {string} input - The string to extract lowercase words from.
|
|
107
|
+
* @return {string[]} An array of lowercase words extracted from the input string.
|
|
108
|
+
*/
|
|
109
|
+
export declare function extractLowercaseWords(input: string): RegExpMatchArray | null;
|
|
110
|
+
/**
|
|
111
|
+
* Generates a random color code in hexadecimal format.
|
|
112
|
+
*
|
|
113
|
+
* @return {string} The randomly generated color code.
|
|
114
|
+
*/
|
|
115
|
+
export declare function genRandomColor(): string;
|
|
116
|
+
/**
|
|
117
|
+
* Converts a data URL to a Blob object.
|
|
118
|
+
*
|
|
119
|
+
* @param {string} dataUrl - The data URL to be converted.
|
|
120
|
+
* @return {Blob} The resulting Blob object.
|
|
121
|
+
*/
|
|
122
|
+
export declare function dataUrlToBlob(dataUrl: string): Blob;
|
|
123
|
+
/**
|
|
124
|
+
* Converts a data URL to a File object.
|
|
125
|
+
*
|
|
126
|
+
* @param {string} dataUrl - The data URL to convert.
|
|
127
|
+
* @param {Object} options - Optional parameters.
|
|
128
|
+
* @param {string} options.fileName - The name of the file. Default is 'file.png'.
|
|
129
|
+
* @param {string} options.type - The MIME type of the file. Default is 'image/png'.
|
|
130
|
+
* @returns {File} The converted File object.
|
|
131
|
+
*/
|
|
132
|
+
export declare function dataUrlToFile(dataUrl: string, { fileName, type, }?: {
|
|
133
|
+
fileName?: string;
|
|
134
|
+
type?: string;
|
|
135
|
+
}): File;
|
|
136
|
+
/**
|
|
137
|
+
* Creates a new array of pure JavaScript objects by making a shallow copy of each object in the input array.
|
|
138
|
+
*
|
|
139
|
+
* @param {Array<object>} array - The input array containing objects to be copied.
|
|
140
|
+
* @return {Array<object>} A new array containing the copied objects.
|
|
141
|
+
*/
|
|
142
|
+
export declare function toArrayOfPureJsObjects(array: Array<object>): object[];
|
|
143
|
+
/**
|
|
144
|
+
* Converts a number of bytes to a human-readable file size.
|
|
145
|
+
*
|
|
146
|
+
* @param {number} bytes - The number of bytes to convert.
|
|
147
|
+
* @param {boolean} si - Whether to use the SI units (1000) or binary units (1024).
|
|
148
|
+
* @param {number} dp - The number of decimal places to round the result to.
|
|
149
|
+
* @return {string} The human-readable file size.
|
|
150
|
+
*/
|
|
151
|
+
export declare function humanFileSize(bytes: number, si?: boolean, dp?: number): string;
|
|
152
|
+
/**
|
|
153
|
+
* Returns the filename from a given URL.
|
|
154
|
+
*
|
|
155
|
+
* @param {string} url - The URL from which to extract the filename.
|
|
156
|
+
* @return {string} The filename extracted from the URL.
|
|
157
|
+
*/
|
|
158
|
+
export declare function filenameFromUrl(url: string): string;
|
|
159
|
+
/**
|
|
160
|
+
* Downloads a file by URL.
|
|
161
|
+
*
|
|
162
|
+
* @param {string} url - The URL of the file to be downloaded.
|
|
163
|
+
*/
|
|
164
|
+
export declare function downloadByUrl(url: string): void;
|
|
165
|
+
/**
|
|
166
|
+
* Downloads the given object as a JSON file with the specified name.
|
|
167
|
+
*
|
|
168
|
+
* @param {object} exportObj - The object to be exported as JSON.
|
|
169
|
+
* @param {string} exportName - The name of the exported file.
|
|
170
|
+
* @return {void} This function does not return a value.
|
|
171
|
+
*/
|
|
172
|
+
export declare function downloadObjectAsJson(exportObj: object, exportName: string): void;
|
|
173
|
+
/**
|
|
174
|
+
* Parses an INI string and returns an object containing the key-value pairs.
|
|
175
|
+
*
|
|
176
|
+
* @param {string} iniString - The INI string to parse.
|
|
177
|
+
* @return {{ [key: string]: string }} - An object containing the key-value pairs parsed from the INI string.
|
|
178
|
+
*/
|
|
179
|
+
export declare function parseINIString(iniString: string): {
|
|
180
|
+
[key: string]: string;
|
|
181
|
+
};
|
|
182
|
+
/**
|
|
183
|
+
* Compresses an image file.
|
|
184
|
+
*
|
|
185
|
+
* @param {File} file - The image file to compress.
|
|
186
|
+
* @param {Object} options - Optional parameters for compression.
|
|
187
|
+
* @param {number} options.maxSizeMB - The maximum size of the compressed image file in megabytes (default is 1MB).
|
|
188
|
+
* @param {number} options.maxWidthOrHeight - The maximum width or height of the compressed image file in pixels (default is 1920).
|
|
189
|
+
* @return {Promise<File>} The compressed image file.
|
|
190
|
+
*/
|
|
191
|
+
export declare function compressImage(file: File, { maxSizeMB, maxWidthOrHeight }?: {
|
|
192
|
+
maxSizeMB?: number | undefined;
|
|
193
|
+
maxWidthOrHeight?: number | undefined;
|
|
194
|
+
}): Promise<File>;
|
|
195
|
+
/**
|
|
196
|
+
* Returns the base URL of the current window location.
|
|
197
|
+
*
|
|
198
|
+
* @return {string} The base URL of the current window location.
|
|
199
|
+
*/
|
|
200
|
+
export declare function getBaseUrl(): string;
|
|
201
|
+
/**
|
|
202
|
+
* Returns the URL of the current page by appending the base URL with the pathname.
|
|
203
|
+
*
|
|
204
|
+
* @return {string} The URL of the current page.
|
|
205
|
+
*/
|
|
206
|
+
export declare function getPageUrl(): string;
|
|
207
|
+
/**
|
|
208
|
+
* Generates a function comment for the given function body in a markdown code block with the correct language syntax.
|
|
209
|
+
*
|
|
210
|
+
* @param {string} url - the URL to open in the new window
|
|
211
|
+
* @param {Array<string>} data - an array of strings containing the data to be sent to the server
|
|
212
|
+
* @param {Object} options - an optional object containing target and method properties
|
|
213
|
+
* @param {string} options.target - the target attribute for the form submission (default: '_self')
|
|
214
|
+
* @param {string} options.method - the method attribute for the form submission (default: 'POST')
|
|
215
|
+
* @return {void} This function does not return anything
|
|
216
|
+
*/
|
|
217
|
+
export declare function openWindowWithJS(url: string, data: {
|
|
218
|
+
[key: string]: string;
|
|
219
|
+
}, { target, method }?: {
|
|
220
|
+
target?: string | undefined;
|
|
221
|
+
method?: string | undefined;
|
|
222
|
+
}): void;
|
|
223
|
+
/**
|
|
224
|
+
* Loads the metadata of an image from the specified URL.
|
|
225
|
+
*
|
|
226
|
+
* @param {string} url - The URL of the image.
|
|
227
|
+
* @return {Promise<Image>} A promise that resolves with the loaded image.
|
|
228
|
+
*/
|
|
229
|
+
export declare function loadImageMeta(url: string): Promise<unknown>;
|
|
230
|
+
/**
|
|
231
|
+
* Abbreviates a number by adding a suffix representing the magnitude.
|
|
232
|
+
*
|
|
233
|
+
* @param {number} number - The number to be abbreviated.
|
|
234
|
+
* @return {string} The abbreviated number with the magnitude suffix.
|
|
235
|
+
*/
|
|
236
|
+
export declare function abbreviateNumber(number: number): string | number;
|
|
237
|
+
/**
|
|
238
|
+
* Extracts numbers from a given string.
|
|
239
|
+
*
|
|
240
|
+
* @param {string} string - The string from which to extract numbers.
|
|
241
|
+
* @param {object} options - Optional parameters for customization.
|
|
242
|
+
* @param {boolean} options.array - Whether to return an array of numbers. Defaults to false.
|
|
243
|
+
* @param {boolean} options.float - Whether to include floating-point numbers. Defaults to true.
|
|
244
|
+
* @return {number|array} - The extracted number(s) from the string. If options.array is true, an array will be returned. Otherwise, a single number will be returned.
|
|
245
|
+
*/
|
|
246
|
+
export declare function extractNumber(string: string, { array, float }?: {
|
|
247
|
+
array?: boolean | undefined;
|
|
248
|
+
float?: boolean | undefined;
|
|
249
|
+
}): number | number[];
|
|
250
|
+
/**
|
|
251
|
+
* Extracts all alphabetic characters from a given string.
|
|
252
|
+
*
|
|
253
|
+
* @param {string} string - The input string.
|
|
254
|
+
* @param {Object} options - Optional parameters.
|
|
255
|
+
* @param {boolean} options.array - Whether to return the result as an array. Default is false.
|
|
256
|
+
* @return {string | string[]} - The extracted alphabetic characters, either as a string or an array.
|
|
257
|
+
*/
|
|
258
|
+
export declare function extractAlphabet(string: string, { array }?: {
|
|
259
|
+
array?: boolean | undefined;
|
|
260
|
+
}): string | string[];
|
|
261
|
+
/**
|
|
262
|
+
* Removes the specified searchString from the given str.
|
|
263
|
+
*
|
|
264
|
+
* @param {string} str - The original string.
|
|
265
|
+
* @param {string} searchString - The string to be removed from str.
|
|
266
|
+
* @return {string} The modified string with the searchString removed.
|
|
267
|
+
*/
|
|
268
|
+
export declare function removeFromString(str: string, searchString: string): string;
|
|
269
|
+
/**
|
|
270
|
+
* Replaces multiple parts of a string based on a given set of replacements.
|
|
271
|
+
*
|
|
272
|
+
* @param {string} inputString - The original string to be modified.
|
|
273
|
+
* @param {Record<string, string>} replacements - An object containing key-value pairs where the key is the part to be replaced and the value is the replacement string.
|
|
274
|
+
* @return {string} - The modified string with all occurrences of the specified parts replaced.
|
|
275
|
+
*/
|
|
276
|
+
export declare function replaceStringParts(inputString: string, replacements: Record<string, string>): string;
|
|
277
|
+
/**
|
|
278
|
+
* Generates a custom ID of the specified length.
|
|
279
|
+
*
|
|
280
|
+
* @param {number} length - The length of the ID to be generated.
|
|
281
|
+
* @return {string} The custom ID.
|
|
282
|
+
*/
|
|
283
|
+
export declare function generateCustomId(length: number): string;
|
|
284
|
+
/**
|
|
285
|
+
* Removes duplicate elements from an array based on a specified property.
|
|
286
|
+
*
|
|
287
|
+
* @param {T[]} arr - The array from which duplicate elements will be removed.
|
|
288
|
+
* @param {keyof T} property - The property used to determine duplicates.
|
|
289
|
+
* @returns {T[]} The array with duplicate elements removed.
|
|
290
|
+
*/
|
|
291
|
+
export declare function removeDuplicates<T>(arr: T[], property: keyof T): T[];
|
|
292
|
+
/**
|
|
293
|
+
* Converts a hexadecimal color code to an RGBA color with the specified alpha value.
|
|
294
|
+
*
|
|
295
|
+
* @param {string} hex - the hexadecimal color code
|
|
296
|
+
* @param {number} alpha - the alpha value for the RGBA color
|
|
297
|
+
* @return {string} the RGBA color code
|
|
298
|
+
*/
|
|
299
|
+
export declare function hexToRgba(hex: string, alpha: number): string;
|
|
300
|
+
/**
|
|
301
|
+
* Shuffles the elements in an array in place using the Fisher-Yates algorithm.
|
|
302
|
+
*
|
|
303
|
+
* @param {T[]} array - The array to be shuffled.
|
|
304
|
+
* @return {T[]} The shuffled array.
|
|
305
|
+
*/
|
|
306
|
+
export declare function shuffleArray<T>(array: T[]): T[];
|
|
307
|
+
/**
|
|
308
|
+
* Scrolls to the element with the specified ID, with a smooth animation.
|
|
309
|
+
*
|
|
310
|
+
* @param {string} id - The ID of the element to scroll to.
|
|
311
|
+
*/
|
|
312
|
+
export declare function slideToId(id: string): void;
|