qsu 1.1.0 → 1.1.2

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 CHANGED
@@ -1,591 +1,650 @@
1
- <div align="center">
2
-
3
- ![logo](logo.webp)
4
-
5
- ### Node.js Quick & Simple Utility for JavaScript
6
-
7
- <table>
8
- <tr>
9
- <td>📑</td>
10
- <td>
11
-
12
- [![license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/jooy2/qsu/blob/master/LICENSE)
13
- ![Programming Language Usage](https://img.shields.io/github/languages/top/jooy2/qsu)
14
- ![Commit Count](https://img.shields.io/github/commit-activity/y/jooy2/qsu)
15
- ![Line Count](https://img.shields.io/tokei/lines/github/jooy2/qsu)
16
-
17
- </td>
18
- </tr>
19
- <tr>
20
- <td>📊</td>
21
- <td>
22
-
23
- [![npm downloads](https://img.shields.io/npm/dm/qsu.svg)](https://www.npmjs.com/package/qsu)
24
- [![npm latest package](https://img.shields.io/npm/v/qsu/latest.svg)](https://www.npmjs.com/package/qsu)
25
- ![npm maintenance](https://img.shields.io/npms-io/maintenance-score/qsu)
26
- ![npm quality](https://img.shields.io/npms-io/quality-score/qsu)
27
- ![minified size](https://img.shields.io/bundlephobia/min/qsu)
28
- ![github repo size](https://img.shields.io/github/repo-size/jooy2/qsu)
29
-
30
- </td>
31
- </tr>
32
- <tr>
33
- <td>💕</td>
34
- <td>
35
-
36
- [![Followers](https://img.shields.io/github/followers/jooy2?style=social)](https://github.com/jooy2)
37
- ![Stars](https://img.shields.io/github/stars/jooy2/qsu?style=social)
38
-
39
- </td>
40
- </tr>
41
- </table>
42
-
43
- </div>
44
-
45
- A collection of complex or useful features that are often used in **JavaScript**. It is implemented to be used in both a client or server environment.
46
-
47
- **qsu** is optimized for modern development environments, so older browsers such as Internet Explorer 11 and Legacy Edge (Not Chromium) may not support it unless you use a transcompiler. Some functions use ES6 or higher JS standard syntax.
48
-
49
- Some solutions partially referenced external documentation (e.g. [Stack Overflow](https://stackoverflow.com)).
50
-
51
- # Installation
52
- Qsu requires **Node.js 14.x** or higher, and the repository is serviced through **[NPM](https://npmjs.com)**.
53
- After configuring the node environment, you can simply run the following command.
54
- ```bash
55
- $ npm i qsu
56
- ```
57
-
58
- # Usage
59
- ```javascript
60
- import _ from 'qsu';
61
-
62
- function main () {
63
- console.log(_.today()); // '20xx-xx-xx'
64
- }
65
- ```
66
-
67
- # Methods
68
-
69
- ### `_.sleep (Promise:boolean)`
70
-
71
- Sleep function using Promise.
72
- - `milliseconds::number`
73
-
74
- ```javascript
75
- await _.sleep(1000); // 1s
76
- _.sleep(5000).then(() => {
77
- // continue
78
- });
79
- ```
80
-
81
- ### `_.numRandom (number)`
82
-
83
- Returns a random number (Between min and max).
84
- - `min::number`
85
- - `max::number`
86
-
87
- ```javascript
88
- _.rand(1, 5); // Returns 1~5
89
- _.rand(10, 20); // Returns 10~20
90
- ```
91
-
92
- ### `_.sum (number)`
93
-
94
- Returns after adding up all the n arguments of numbers or the values of a single array of numbers.
95
- - `numbers::...number[]`
96
-
97
- ```javascript
98
- _.sum(1, 2, 3); // Returns 6
99
- _.sum([1, 2, 3, 4]); // Returns 10
100
- ```
101
-
102
- ### `_.mul (number)`
103
-
104
- Returns after multiplying all n arguments of numbers or the values of a single array of numbers.
105
- - `numbers::...number[]`
106
-
107
- ```javascript
108
- _.mul(1, 2, 3); // Returns 6
109
- _.mul([1, 2, 3, 4]); // Returns 24
110
- ```
111
-
112
- ### `_.dayDiff (number)`
113
-
114
- Calculates the difference between two given dates and returns the number of days.
115
- - `date1::Date`
116
- - `date2::Date?`
117
-
118
- ```javascript
119
- _.daydiff(new Date('2021-01-01'), new Date('2021-01-03')); // Returns 2
120
- ```
121
-
122
- ### `_.today (string)`
123
-
124
- Returns today's date.
125
- - `separator::string = '-'`
126
- - `yearFirst::boolean = false`
127
-
128
- ```javascript
129
- _.today(); // Returns YYYY-MM-DD
130
- _.today('/'); // Returns YYYY/MM/DD
131
- _.today('/', false); // Returns DD/MM/YYYY
132
- ```
133
-
134
- ### `_.isRealDate (boolean)`
135
-
136
- Checks if a given date actually exists. Check only in YYYY-MM-DD format.
137
- - `date::string|Date`
138
-
139
- ```javascript
140
- _.isRealDate('2021-01-01'); // Returns true
141
- _.isRealDate('2021-02-30'); // Returns false
142
- ```
143
-
144
- ### `_.arrShuffle (any[])`
145
-
146
- Shuffle the order of the given array and return.
147
- - `array::any[]`
148
-
149
- ```javascript
150
- _.arrShuffle([1, 2, 3, 4]); // Returns [4, 2, 3, 1]
151
- ```
152
-
153
- ### `_.arrWithDefault (any[])`
154
-
155
- Initialize an array with a default value of a specific length.
156
- - `defaultValue::any`
157
- - `length::number || 0`
158
-
159
- ```javascript
160
- _.arrWithDefault('abc', 4); // Returns ['abc', 'abc', 'abc', 'abc']
161
- _.arrWithDefault(null, 3); // Returns [null, null, null]
162
- ```
163
-
164
- ### `_.arrWithNumber (number[])`
165
-
166
- Creates and returns an Array in the order of start...end values.
167
- - `start::number`
168
- - `end::number`
169
-
170
- ```javascript
171
- _.arrWithNumber(1, 3); // Returns [1, 2, 3]
172
- _.arrWithNumber(0, 3); // Returns [0, 1, 2, 3]
173
- ```
174
-
175
- ### `_.arrUnique (any[])`
176
-
177
- Remove duplicate values from array and two-dimensional array data. In the case of 2d arrays, json type data duplication is not removed.
178
- - `array::any[]`
179
-
180
- ```javascript
181
- _.arrUnique([1, 2, 2, 3]); // Returns [1, 2, 3]
182
- _.arrUnique([[1], [1], [2]]); // Returns [[1], [2]]
183
- ```
184
-
185
- ### `_.average (number)`
186
-
187
- Returns the average of all numeric values in an array.
188
- - `array::number[]`
189
-
190
- ```javascript
191
- _.average([1, 5, 15, 50]); // Returns 17.75
192
- ```
193
-
194
- ### `_.arrMove (any[])`
195
-
196
- Moves the position of a specific element in an array to the specified position. (Position starts from 0.)
197
- - `array::any[]`
198
- - `from::number`
199
- - `to::number`
200
-
201
- ```javascript
202
- _.arrMove([1, 2, 3, 4], 1, 0); // Returns [2, 1, 3, 4]
203
- ```
204
-
205
- ### `_.removeSpecialChar (string)`
206
-
207
- Returns after removing all special characters, including spaces.
208
- - `str::string`
209
- - `withoutSpace::boolean`
210
-
211
- ```javascript
212
- _.removeSpecialChar('Hello, World!'); // Returns 'HelloWorld'
213
- ```
214
-
215
- ### `_.removeNewLine (string)`
216
-
217
- Removes `\n`, `\r` characters or replaces them with specified characters.
218
- - `str::string`
219
- - `replaceTo::string || ''`
220
-
221
- ```javascript
222
- _.removeNewLine('ab\ncd'); // Returns 'abcd'
223
- _.removeNewLine('ab\r\ncd', '-'); // Returns 'ab-cd'
224
- ```
225
-
226
- ### `_.capitalizeFirst (string)`
227
-
228
- Converts the first letter of the entire string to uppercase and returns.
229
- - `str::string`
230
-
231
- ```javascript
232
- _.capitalizeFirst('abcd'); // Returns 'Abcd'
233
- ```
234
-
235
- ### `_.capitalizeEachWords (string)`
236
-
237
- Converts every word with spaces to uppercase. If the naturally argument is true, only some special cases (such as prepositions) are kept lowercase.
238
- - `str::string`
239
- - `natural::boolean || false`
240
-
241
- ```javascript
242
- _.capitalizeEachWords('abcd'); // Returns 'Abcd'
243
- ```
244
-
245
- ### `_.strNumberOf (number)`
246
-
247
- Returns the number of times the second String character is contained in the first String argument.
248
- - `str::string`
249
- - `search::string`
250
-
251
- ```javascript
252
- _.count('abcabc', 'a'); // Returns 2
253
- ```
254
-
255
- ### `_.strShuffle (string)`
256
-
257
- Randomly shuffles the received string and returns it.
258
- - `str::string`
259
-
260
- ```javascript
261
- _.shuffle('abcdefg'); // Returns 'bgafced'
262
- ```
263
-
264
- ### `_.strRandom (string)`
265
-
266
- Returns a random String containing numbers or uppercase and lowercase letters of the given length. The default return length is 12.
267
- - `length::number`
268
- - `additionalCharacters::string?`
269
-
270
- ```javascript
271
- _.strRandom(5); // Returns 'CHy2M'
272
- ```
273
-
274
- ### `_.strBlindRandom (string)`
275
-
276
- Replaces strings at random locations with a specified number of characters (default 1) with characters (default *).
277
- - `str::string`
278
- - `blindLength::number`
279
- - `blindStr::string || '*'`
280
-
281
- ```javascript
282
- _.hideRandom('hello', 2, '#'); // Returns '#el#o'
283
- ```
284
-
285
- ### `_.truncate (string)`
286
-
287
- Truncates a long string to a specified length, optionally appending an ellipsis after the string.
288
- - `str::string`
289
- - `length::number`
290
- - `ellipsis::string || ''`
291
-
292
- ```javascript
293
- _.truncate('hello', 3); // Returns 'hel'
294
- _.truncate('hello', 2, '...'); // Returns 'he...'
295
- ```
296
-
297
- ### `_.split (string[])`
298
-
299
- Splits a string based on the specified character and returns it as an Array. Unlike the existing split, it splits the values provided as multiple parameters (array or multiple arguments) at once.
300
- - `str::string`
301
- - `splitter::string||string[]||...string`
302
-
303
- ```javascript
304
- _.split('hello% js world', '% '); // Returns ['hello', 'js world']
305
- _.split('hello,js,world', ','); // Returns ['hello', 'js', 'world']
306
- _.split('hello%js,world', ',', '%'); // Returns ['hello', 'js', 'world']
307
- _.split('hello%js,world', [',', '%']); // Returns ['hello', 'js', 'world']
308
- ```
309
-
310
- ### `_.encrypt (string)`
311
-
312
- Encrypt with the algorithm of your choice (algorithm default: `aes-256-cbc`, ivSize default: `16`) using a string and a secret (secret).
313
- - `str::string`
314
- - `secret::string`
315
- - `algorithm::string || 'aes-256-cbc'`
316
- - `ivSize::number || 16`
317
-
318
- ```javascript
319
- _.encrypt('test', 'secret-key');
320
- ```
321
-
322
- ### `_.decrypt (string)`
323
-
324
- Decrypt with the specified algorithm (default: `aes-256-cbc`) using a string and a secret (secret).
325
- - `str::string`
326
- - `secret::string`
327
- - `algorithm::string || 'aes-256-cbc'`
328
-
329
- ```javascript
330
- _.decrypt('61ba43b65fc...', 'secret-key');
331
- ```
332
-
333
- ### `_.md5 (string)`
334
-
335
- Converts String data to md5 hash value and returns it.
336
- - `str::string`
337
-
338
- ```javascript
339
- _.md5('test'); // Returns '098f6bcd4621d373cade4e832627b4f6'
340
- ```
341
-
342
- ### `_.sha1 (string)`
343
-
344
- Converts String data to sha1 hash value and returns it.
345
- - `str::string`
346
-
347
- ```javascript
348
- _.sha1('test'); // Returns 'a94a8fe5ccb19ba61c4c0873d391e987982fbbd3'
349
- ```
350
-
351
- ### `_.sha256 (string)`
352
-
353
- Converts String data to sha256 hash value and returns it.
354
- - `str::string`
355
-
356
- ```javascript
357
- _.sha256('test'); // Returns '9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08'
358
- ```
359
-
360
- ### `_.encodeBase64 (string)`
361
-
362
- Base64-encode the given string.
363
- - `str::string`
364
-
365
- ```javascript
366
- _.encodeBase64('this is test'); // Returns 'dGhpcyBpcyB0ZXN0'
367
- ```
368
-
369
- ### `_.decodeBase64 (string)`
370
-
371
- Decodes an encoded base64 string to a plain string.
372
- - `encodedStr::string`
373
-
374
- ```javascript
375
- _.decodeBase64('dGhpcyBpcyB0ZXN0'); // Returns 'this is test'
376
- ```
377
-
378
- ### `_.strUnique (string)`
379
-
380
- Remove duplicate characters from a given string and output only one.
381
- - `str::string`
382
-
383
- ```javascript
384
- _.strUnique('aaabbbcc'); // Returns 'abc'
385
- ```
386
-
387
- ### `_.isEqual (boolean)`
388
-
389
- It compares the first argument value as the left operand and the argument values given thereafter as the right operand, and returns `true` if the values are all the same.
390
-
391
- `isEqual` returns `true` even if the data types do not match, but `isEqualStrict` returns `true` only when the data types of all argument values match.
392
- - `leftOperand::any`
393
- - `rightOperand::any||any[]||...any`
394
-
395
- ```javascript
396
- const val1 = 'Left';
397
- const val2 = 1;
398
-
399
- _.isEqual('Left', 'Left', val1); // Returns true
400
- _.isEqual(1, [1, '1', 1, val2]); // Returns true
401
- _.isEqual(val1, ['Right', 'Left', 1]); // Returns false
402
- _.isEqual(1, 1, 1, 1); // Returns true
403
- ```
404
-
405
- ### `_.isEqualStrict (boolean)`
406
-
407
- It compares the first argument value as the left operand and the argument values given thereafter as the right operand, and returns `true` if the values are all the same.
408
-
409
- `isEqual` returns `true` even if the data types do not match, but `isEqualStrict` returns `true` only when the data types of all argument values match.
410
- - `leftOperand::any`
411
- - `rightOperand::any||any[]||...any`
412
-
413
- ```javascript
414
- const val1 = 'Left';
415
- const val2 = 1;
416
-
417
- _.isEqualStrict('Left', 'Left', val1); // Returns true
418
- _.isEqualStrict(1, [1, '1', 1, val2]); // Returns false
419
- _.isEqualStrict(1, 1, '1', 1); // Returns false
420
- ```
421
-
422
- ### `_.isEmpty (boolean)`
423
-
424
- Returns true if the passed data is empty or has a length of 0.
425
- - `data::any?`
426
-
427
- ```javascript
428
- _.isEmpty([]); // Returns true
429
- _.isEmpty(''); // Returns true
430
- _.isEmpty('abc'); // Returns false
431
- ```
432
-
433
- ### `_.isUrl (boolean)`
434
-
435
- Returns `true` if the given data is in the correct URL format. If withProtocol is `true`, it is automatically appended to the URL when the protocol does not exist. If strict is `true`, URLs without commas (`.`) return `false`.
436
- - `url::string`
437
- - `withProtocol::boolean || false`
438
- - `strict::boolean || false`
439
-
440
- ```javascript
441
- _.isUrl('google.com'); // Returns false
442
- _.isUrl('google.com', true); // Returns true
443
- _.isUrl('https://google.com'); // Returns true
444
- ```
445
-
446
- ### `_.contains (boolean)`
447
-
448
- Returns `true` if the first string argument contains the second argument "string" or "one or more of the strings listed in the array". If the exact value is `true`, it returns true only for an exact match.
449
- - `str::any[]|string`
450
- - `search::any[]|string`
451
- - `exact::boolean || false`
452
-
453
- ```javascript
454
- _.contains('abc', 'a'); // Returns true
455
- _.contains('abc', 'd'); // Returns false
456
- _.contains('abc', ['a', 'd']); // Returns true
457
- ```
458
-
459
- ### `_.is2dArray (boolean)`
460
-
461
- Returns `true` if the given array is a two-dimensional array.
462
- - `array::any[]`
463
-
464
- ```javascript
465
- _.is2dArray([1]); // Returns false
466
- _.is2dArray([[1], [2]]); // Returns true
467
- ```
468
-
469
- ### `_.between (boolean)`
470
-
471
- Returns `true` if the first argument is in the range of the second argument (`[min, max]`). To allow the minimum and maximum values to be in the range, pass `true` for the third argument.
472
- - `range::[number, number]`
473
- - `number::number`
474
- - `inclusive::boolean || false`
475
-
476
- ```javascript
477
- _.between([10, 20], 10); // Returns false
478
- _.between([10, 20], 10, true); // Returns true
479
- ```
480
-
481
- ### `_.len (number)`
482
-
483
- Returns the length of any type of data. If the argument value is `null` or `undefined`, `0` is returned.
484
- - `data::any`
485
-
486
- ```javascript
487
- _.len('12345'); // Returns 5
488
- _.len([1, 2, 3]); // Returns 3
489
- ```
490
-
491
- ### `_.isBotAgent (boolean)`
492
-
493
- Analyze the user agent value to determine if it's a bot for a search engine. Returns `true` if it's a bot.
494
- - `userAgent::string`
495
-
496
- ```javascript
497
- _.isBotAgent('Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)'); // Returns true
498
- ```
499
-
500
- ### `_.numberFormat (string)`
501
-
502
- Return number format including comma symbol.
503
- - `number::number`
504
-
505
- ```javascript
506
- _.number(1234567); // Returns 1,234,567
507
- ```
508
-
509
- ### `_.fileName (string)`
510
-
511
- Extract the file name from the path. Include the extension if withExtension is `true`.
512
- - `filePath::string`
513
- - `withExtension::boolean || false`
514
-
515
- ```javascript
516
- _.fileName('C:\Temp\hello.txt'); // Returns 'hello.txt'
517
- _.fileName('C:\Temp\file.mp3', true); // Returns 'file.mp3'
518
- ```
519
-
520
- ### `_.fileSize (string)`
521
-
522
- Converts the file size in bytes to human-readable and returns it. The return value is a String and includes the file units (Bytes, MB, GB...). If the second optional argument value is included, you can display as many decimal places as you like.
523
- - `bytes::number`
524
- - `decimals::number || 2`
525
-
526
- ```javascript
527
- _.fileSize(2000, 3); // Returns '1.953 KB'
528
- _.fileSize(250000000); // Returns '238.42 MB'
529
- ```
530
-
531
- ### `_.fileExt (string)`
532
-
533
- Returns only the extensions in the file path. If unknown, returns 'Unknown'.
534
- - `filePath::string`
535
-
536
- ```javascript
537
- _.fileExt('C:\Temp\hello.txt'); // Returns 'txt'
538
- _.fileExt('this-is-file.mp3'); // Returns 'mp3'
539
- ```
540
-
541
- ### `_.msToTime (string)`
542
-
543
- Converts milliseconds to hours, minutes, seconds, and milliseconds and returns. If the second argument is true, milliseconds are also printed. You can put any separator (String) between hours, minutes, and seconds in the third argument.
544
- - `milliseconds::number`
545
- - `withMilliseconds::boolean || false`
546
- - `separator::string || ':'`
547
-
548
- ```javascript
549
- _.msToTime(100000); // 'Returns '00:01:40'
550
- _.msToTime(100000, true, '-'); // Returns '00-01-40.0'
551
- ```
552
-
553
- ### `_.secToTime (string)`
554
-
555
- Converts seconds to hours, minutes, seconds and returns. You can put any separator (String) between hours, minutes, and seconds in the third argument.
556
- - `seconds::number`
557
- - `onlyHour::boolean || false`
558
- - `separator::string || ':'`
559
-
560
- ```javascript
561
- _.secToTime(3800); // Returns '01:03:20'
562
- _.secToTime(60, '-'); // Returns '00-01-00'
563
- ```
564
-
565
- ### `_.license (string)`
566
-
567
- Returns text in a specific license format based on the author information of the given argument. The argument uses the Object type.
568
- - `options::LicenseOption{
569
- author: string,
570
- email: string?,
571
- yearStart: string|number,
572
- yearEnd: string?,
573
- htmlBr: boolean?,
574
- type: 'mit' | 'apache20'
575
- }`
576
-
577
- ```javascript
578
- _.license({
579
- holder: 'example',
580
- email: 'example@example.com',
581
- yearStart: 2020,
582
- yearEnd: 2021,
583
- htmlBr: true
584
- });
585
- ```
586
-
587
- # Contribute
588
- You can report issues on [GitHub Issue Tracker](https://github.com/jooy2/qsu/issues). You can also request a pull to fix bugs and add frequently used features.
589
-
590
- # License
591
- Copyright © 2021-2022 Jooy2 Released under the MIT license.
1
+ <div align="center">
2
+
3
+ ![logo](logo.webp)
4
+
5
+ ### Node.js Quick & Simple Utility for JavaScript
6
+
7
+ <table>
8
+ <tr>
9
+ <td>📑</td>
10
+ <td>
11
+
12
+ [![license](https://img.shields.io/badge/license-MIT-blue.svg)](https://github.com/jooy2/qsu/blob/master/LICENSE)
13
+ ![Programming Language Usage](https://img.shields.io/github/languages/top/jooy2/qsu)
14
+ ![Commit Count](https://img.shields.io/github/commit-activity/y/jooy2/qsu)
15
+ ![Line Count](https://img.shields.io/tokei/lines/github/jooy2/qsu)
16
+
17
+ </td>
18
+ </tr>
19
+ <tr>
20
+ <td>📊</td>
21
+ <td>
22
+
23
+ [![npm downloads](https://img.shields.io/npm/dm/qsu.svg)](https://www.npmjs.com/package/qsu)
24
+ [![npm latest package](https://img.shields.io/npm/v/qsu/latest.svg)](https://www.npmjs.com/package/qsu)
25
+ ![npm maintenance](https://img.shields.io/npms-io/maintenance-score/qsu)
26
+ ![npm quality](https://img.shields.io/npms-io/quality-score/qsu)
27
+ ![minified size](https://img.shields.io/bundlephobia/min/qsu)
28
+ ![github repo size](https://img.shields.io/github/repo-size/jooy2/qsu)
29
+
30
+ </td>
31
+ </tr>
32
+ <tr>
33
+ <td>💕</td>
34
+ <td>
35
+
36
+ [![Followers](https://img.shields.io/github/followers/jooy2?style=social)](https://github.com/jooy2)
37
+ ![Stars](https://img.shields.io/github/stars/jooy2/qsu?style=social)
38
+
39
+ </td>
40
+ </tr>
41
+ </table>
42
+
43
+ </div>
44
+
45
+ A collection of complex or useful features that are often used in **JavaScript**. It is implemented to be used in both a client or server environment.
46
+
47
+ **qsu** is optimized for modern development environments, so older browsers such as Internet Explorer 11 and Legacy Edge (Not Chromium) may not support it unless you use a transcompiler. Some functions use ES6 or higher JS standard syntax.
48
+
49
+ Some solutions partially referenced external documentation (e.g. [Stack Overflow](https://stackoverflow.com)).
50
+
51
+ # Installation
52
+
53
+ Qsu requires **Node.js 12.x** or higher, and the repository is serviced through **[NPM](https://npmjs.com)**.
54
+
55
+ After configuring the node environment, you can simply run the following command.
56
+
57
+ ```bash
58
+ $ npm install qsu
59
+ ```
60
+
61
+ # Usage
62
+
63
+ ```javascript
64
+ import _ from 'qsu';
65
+
66
+ function main() {
67
+ console.log(_.today()); // '20xx-xx-xx'
68
+ }
69
+ ```
70
+
71
+ # Methods
72
+
73
+ ### `_.sleep (Promise:boolean)`
74
+
75
+ Sleep function using Promise.
76
+
77
+ - `milliseconds::number`
78
+
79
+ ```javascript
80
+ await _.sleep(1000); // 1s
81
+
82
+ _.sleep(5000).then(() => {
83
+ // continue
84
+ });
85
+ ```
86
+
87
+ ### `_.numRandom (number)`
88
+
89
+ Returns a random number (Between min and max).
90
+
91
+ - `min::number`
92
+ - `max::number`
93
+
94
+ ```javascript
95
+ _.numRandom(1, 5); // Returns 1~5
96
+ _.numRandom(10, 20); // Returns 10~20
97
+ ```
98
+
99
+ ### `_.sum (number)`
100
+
101
+ Returns after adding up all the n arguments of numbers or the values of a single array of numbers.
102
+
103
+ - `numbers::...number[]`
104
+
105
+ ```javascript
106
+ _.sum(1, 2, 3); // Returns 6
107
+ _.sum([1, 2, 3, 4]); // Returns 10
108
+ ```
109
+
110
+ ### `_.mul (number)`
111
+
112
+ Returns after multiplying all n arguments of numbers or the values of a single array of numbers.
113
+
114
+ - `numbers::...number[]`
115
+
116
+ ```javascript
117
+ _.mul(1, 2, 3); // Returns 6
118
+ _.mul([1, 2, 3, 4]); // Returns 24
119
+ ```
120
+
121
+ ### `_.dayDiff (number)`
122
+
123
+ Calculates the difference between two given dates and returns the number of days.
124
+
125
+ - `date1::Date`
126
+ - `date2::Date?`
127
+
128
+ ```javascript
129
+ _.daydiff(new Date('2021-01-01'), new Date('2021-01-03')); // Returns 2
130
+ ```
131
+
132
+ ### `_.today (string)`
133
+
134
+ Returns today's date.
135
+
136
+ - `separator::string = '-'`
137
+ - `yearFirst::boolean = false`
138
+
139
+ ```javascript
140
+ _.today(); // Returns YYYY-MM-DD
141
+ _.today('/'); // Returns YYYY/MM/DD
142
+ _.today('/', false); // Returns DD/MM/YYYY
143
+ ```
144
+
145
+ ### `_.isRealDate (boolean)`
146
+
147
+ Checks if a given date actually exists. Check only in YYYY-MM-DD format.
148
+
149
+ - `date::string|Date`
150
+
151
+ ```javascript
152
+ _.isRealDate('2021-01-01'); // Returns true
153
+ _.isRealDate('2021-02-30'); // Returns false
154
+ ```
155
+
156
+ ### `_.arrShuffle (any[])`
157
+
158
+ Shuffle the order of the given array and return.
159
+
160
+ - `array::any[]`
161
+
162
+ ```javascript
163
+ _.arrShuffle([1, 2, 3, 4]); // Returns [4, 2, 3, 1]
164
+ ```
165
+
166
+ ### `_.arrWithDefault (any[])`
167
+
168
+ Initialize an array with a default value of a specific length.
169
+
170
+ - `defaultValue::any`
171
+ - `length::number || 0`
172
+
173
+ ```javascript
174
+ _.arrWithDefault('abc', 4); // Returns ['abc', 'abc', 'abc', 'abc']
175
+ _.arrWithDefault(null, 3); // Returns [null, null, null]
176
+ ```
177
+
178
+ ### `_.arrWithNumber (number[])`
179
+
180
+ Creates and returns an Array in the order of start...end values.
181
+
182
+ - `start::number`
183
+ - `end::number`
184
+
185
+ ```javascript
186
+ _.arrWithNumber(1, 3); // Returns [1, 2, 3]
187
+ _.arrWithNumber(0, 3); // Returns [0, 1, 2, 3]
188
+ ```
189
+
190
+ ### `_.arrUnique (any[])`
191
+
192
+ Remove duplicate values from array and two-dimensional array data. In the case of 2d arrays, json type data duplication is not removed.
193
+
194
+ - `array::any[]`
195
+
196
+ ```javascript
197
+ _.arrUnique([1, 2, 2, 3]); // Returns [1, 2, 3]
198
+ _.arrUnique([[1], [1], [2]]); // Returns [[1], [2]]
199
+ ```
200
+
201
+ ### `_.average (number)`
202
+
203
+ Returns the average of all numeric values in an array.
204
+
205
+ - `array::number[]`
206
+
207
+ ```javascript
208
+ _.average([1, 5, 15, 50]); // Returns 17.75
209
+ ```
210
+
211
+ ### `_.arrMove (any[])`
212
+
213
+ Moves the position of a specific element in an array to the specified position. (Position starts from 0.)
214
+
215
+ - `array::any[]`
216
+ - `from::number`
217
+ - `to::number`
218
+
219
+ ```javascript
220
+ _.arrMove([1, 2, 3, 4], 1, 0); // Returns [2, 1, 3, 4]
221
+ ```
222
+
223
+ ### `_.trim (string)`
224
+
225
+ Removes leading and trailing spaces, and returns a value converted from two or more spaces between strings to one space. If the removeAllSpace value is true, all spaces including one space are removed.
226
+
227
+ - `str::string`
228
+ - `removeAllSpace::boolean`
229
+
230
+ ```javascript
231
+ _.trim(' Hello Wor ld '); // Returns 'Hello World'
232
+ _.trim('H e l l o World', true); // Returns 'HelloWorld'
233
+ ```
234
+
235
+ ### `_.removeSpecialChar (string)`
236
+
237
+ Returns after removing all special characters, including spaces.
238
+
239
+ - `str::string`
240
+ - `withoutSpace::boolean`
241
+
242
+ ```javascript
243
+ _.removeSpecialChar('Hello, World!'); // Returns 'HelloWorld'
244
+ ```
245
+
246
+ ### `_.removeNewLine (string)`
247
+
248
+ Removes `\n`, `\r` characters or replaces them with specified characters.
249
+
250
+ - `str::string`
251
+ - `replaceTo::string || ''`
252
+
253
+ ```javascript
254
+ _.removeNewLine('ab\ncd'); // Returns 'abcd'
255
+ _.removeNewLine('ab\r\ncd', '-'); // Returns 'ab-cd'
256
+ ```
257
+
258
+ ### `_.capitalizeFirst (string)`
259
+
260
+ Converts the first letter of the entire string to uppercase and returns.
261
+
262
+ - `str::string`
263
+
264
+ ```javascript
265
+ _.capitalizeFirst('abcd'); // Returns 'Abcd'
266
+ ```
267
+
268
+ ### `_.capitalizeEachWords (string)`
269
+
270
+ Converts every word with spaces to uppercase. If the naturally argument is true, only some special cases (such as prepositions) are kept lowercase.
271
+
272
+ - `str::string`
273
+ - `natural::boolean || false`
274
+
275
+ ```javascript
276
+ _.capitalizeEachWords('abcd'); // Returns 'Abcd'
277
+ ```
278
+
279
+ ### `_.strCount (number)`
280
+
281
+ Returns the number of times the second String argument is contained in the first String argument.
282
+
283
+ - `str::string`
284
+ - `search::string`
285
+
286
+ ```javascript
287
+ _.strCount('abcabc', 'a'); // Returns 2
288
+ ```
289
+
290
+ ### `_.strShuffle (string)`
291
+
292
+ Randomly shuffles the received string and returns it.
293
+
294
+ - `str::string`
295
+
296
+ ```javascript
297
+ _.strShuffle('abcdefg'); // Returns 'bgafced'
298
+ ```
299
+
300
+ ### `_.strRandom (string)`
301
+
302
+ Returns a random String containing numbers or uppercase and lowercase letters of the given length. The default return length is 12.
303
+
304
+ - `length::number`
305
+ - `additionalCharacters::string?`
306
+
307
+ ```javascript
308
+ _.strRandom(5); // Returns 'CHy2M'
309
+ ```
310
+
311
+ ### `_.strBlindRandom (string)`
312
+
313
+ Replace strings at random locations with a specified number of characters (default 1) with characters (default \*).
314
+
315
+ - `str::string`
316
+ - `blindLength::number`
317
+ - `blindStr::string || '*'`
318
+
319
+ ```javascript
320
+ _.strBlindRandom('hello', 2, '#'); // Returns '#el#o'
321
+ ```
322
+
323
+ ### `_.truncate (string)`
324
+
325
+ Truncates a long string to a specified length, optionally appending an ellipsis after the string.
326
+
327
+ - `str::string`
328
+ - `length::number`
329
+ - `ellipsis::string || ''`
330
+
331
+ ```javascript
332
+ _.truncate('hello', 3); // Returns 'hel'
333
+ _.truncate('hello', 2, '...'); // Returns 'he...'
334
+ ```
335
+
336
+ ### `_.split (string[])`
337
+
338
+ Splits a string based on the specified character and returns it as an Array. Unlike the existing split, it splits the values provided as multiple parameters (array or multiple arguments) at once.
339
+
340
+ - `str::string`
341
+ - `splitter::string||string[]||...string`
342
+
343
+ ```javascript
344
+ _.split('hello% js world', '% '); // Returns ['hello', 'js world']
345
+ _.split('hello,js,world', ','); // Returns ['hello', 'js', 'world']
346
+ _.split('hello%js,world', ',', '%'); // Returns ['hello', 'js', 'world']
347
+ _.split('hello%js,world', [',', '%']); // Returns ['hello', 'js', 'world']
348
+ ```
349
+
350
+ ### `_.encrypt (string)`
351
+
352
+ Encrypt with the algorithm of your choice (algorithm default: `aes-256-cbc`, ivSize default: `16`) using a string and a secret (secret).
353
+
354
+ - `str::string`
355
+ - `secret::string`
356
+ - `algorithm::string || 'aes-256-cbc'`
357
+ - `ivSize::number || 16`
358
+
359
+ ```javascript
360
+ _.encrypt('test', 'secret-key');
361
+ ```
362
+
363
+ ### `_.decrypt (string)`
364
+
365
+ Decrypt with the specified algorithm (default: `aes-256-cbc`) using a string and a secret (secret).
366
+
367
+ - `str::string`
368
+ - `secret::string`
369
+ - `algorithm::string || 'aes-256-cbc'`
370
+
371
+ ```javascript
372
+ _.decrypt('61ba43b65fc...', 'secret-key');
373
+ ```
374
+
375
+ ### `_.md5 (string)`
376
+
377
+ Converts String data to md5 hash value and returns it.
378
+
379
+ - `str::string`
380
+
381
+ ```javascript
382
+ _.md5('test'); // Returns '098f6bcd4621d373cade4e832627b4f6'
383
+ ```
384
+
385
+ ### `_.sha1 (string)`
386
+
387
+ Converts String data to sha1 hash value and returns it.
388
+
389
+ - `str::string`
390
+
391
+ ```javascript
392
+ _.sha1('test'); // Returns 'a94a8fe5ccb19ba61c4c0873d391e987982fbbd3'
393
+ ```
394
+
395
+ ### `_.sha256 (string)`
396
+
397
+ Converts String data to sha256 hash value and returns it.
398
+
399
+ - `str::string`
400
+
401
+ ```javascript
402
+ _.sha256('test'); // Returns '9f86d081884c7d659a2feaa0c55ad015a3bf4f1b2b0b822cd15d6c15b0f00a08'
403
+ ```
404
+
405
+ ### `_.encodeBase64 (string)`
406
+
407
+ Base64-encode the given string.
408
+
409
+ - `str::string`
410
+
411
+ ```javascript
412
+ _.encodeBase64('this is test'); // Returns 'dGhpcyBpcyB0ZXN0'
413
+ ```
414
+
415
+ ### `_.decodeBase64 (string)`
416
+
417
+ Decodes an encoded base64 string to a plain string.
418
+
419
+ - `encodedStr::string`
420
+
421
+ ```javascript
422
+ _.decodeBase64('dGhpcyBpcyB0ZXN0'); // Returns 'this is test'
423
+ ```
424
+
425
+ ### `_.strUnique (string)`
426
+
427
+ Remove duplicate characters from a given string and output only one.
428
+
429
+ - `str::string`
430
+
431
+ ```javascript
432
+ _.strUnique('aaabbbcc'); // Returns 'abc'
433
+ ```
434
+
435
+ ### `_.isEqual (boolean)`
436
+
437
+ It compares the first argument value as the left operand and the argument values given thereafter as the right operand, and returns `true` if the values are all the same.
438
+
439
+ `isEqual` returns `true` even if the data types do not match, but `isEqualStrict` returns `true` only when the data types of all argument values match.
440
+
441
+ - `leftOperand::any`
442
+ - `rightOperand::any||any[]||...any`
443
+
444
+ ```javascript
445
+ const val1 = 'Left';
446
+ const val2 = 1;
447
+
448
+ _.isEqual('Left', 'Left', val1); // Returns true
449
+ _.isEqual(1, [1, '1', 1, val2]); // Returns true
450
+ _.isEqual(val1, ['Right', 'Left', 1]); // Returns false
451
+ _.isEqual(1, 1, 1, 1); // Returns true
452
+ ```
453
+
454
+ ### `_.isEqualStrict (boolean)`
455
+
456
+ It compares the first argument value as the left operand and the argument values given thereafter as the right operand, and returns `true` if the values are all the same.
457
+
458
+ `isEqual` returns `true` even if the data types do not match, but `isEqualStrict` returns `true` only when the data types of all argument values match.
459
+
460
+ - `leftOperand::any`
461
+ - `rightOperand::any||any[]||...any`
462
+
463
+ ```javascript
464
+ const val1 = 'Left';
465
+ const val2 = 1;
466
+
467
+ _.isEqualStrict('Left', 'Left', val1); // Returns true
468
+ _.isEqualStrict(1, [1, '1', 1, val2]); // Returns false
469
+ _.isEqualStrict(1, 1, '1', 1); // Returns false
470
+ ```
471
+
472
+ ### `_.isEmpty (boolean)`
473
+
474
+ Returns true if the passed data is empty or has a length of 0.
475
+
476
+ - `data::any?`
477
+
478
+ ```javascript
479
+ _.isEmpty([]); // Returns true
480
+ _.isEmpty(''); // Returns true
481
+ _.isEmpty('abc'); // Returns false
482
+ ```
483
+
484
+ ### `_.isUrl (boolean)`
485
+
486
+ Returns `true` if the given data is in the correct URL format. If withProtocol is `true`, it is automatically appended to the URL when the protocol does not exist. If strict is `true`, URLs without commas (`.`) return `false`.
487
+
488
+ - `url::string`
489
+ - `withProtocol::boolean || false`
490
+ - `strict::boolean || false`
491
+
492
+ ```javascript
493
+ _.isUrl('google.com'); // Returns false
494
+ _.isUrl('google.com', true); // Returns true
495
+ _.isUrl('https://google.com'); // Returns true
496
+ ```
497
+
498
+ ### `_.contains (boolean)`
499
+
500
+ Returns `true` if the first string argument contains the second argument "string" or "one or more of the strings listed in the array". If the exact value is `true`, it returns true only for an exact match.
501
+
502
+ - `str::any[]|string`
503
+ - `search::any[]|string`
504
+ - `exact::boolean || false`
505
+
506
+ ```javascript
507
+ _.contains('abc', 'a'); // Returns true
508
+ _.contains('abc', 'd'); // Returns false
509
+ _.contains('abc', ['a', 'd']); // Returns true
510
+ ```
511
+
512
+ ### `_.is2dArray (boolean)`
513
+
514
+ Returns `true` if the given array is a two-dimensional array.
515
+
516
+ - `array::any[]`
517
+
518
+ ```javascript
519
+ _.is2dArray([1]); // Returns false
520
+ _.is2dArray([[1], [2]]); // Returns true
521
+ ```
522
+
523
+ ### `_.between (boolean)`
524
+
525
+ Returns `true` if the first argument is in the range of the second argument (`[min, max]`). To allow the minimum and maximum values to be in the range, pass `true` for the third argument.
526
+
527
+ - `range::[number, number]`
528
+ - `number::number`
529
+ - `inclusive::boolean || false`
530
+
531
+ ```javascript
532
+ _.between([10, 20], 10); // Returns false
533
+ _.between([10, 20], 10, true); // Returns true
534
+ ```
535
+
536
+ ### `_.len (number)`
537
+
538
+ Returns the length of any type of data. If the argument value is `null` or `undefined`, `0` is returned.
539
+
540
+ - `data::any`
541
+
542
+ ```javascript
543
+ _.len('12345'); // Returns 5
544
+ _.len([1, 2, 3]); // Returns 3
545
+ ```
546
+
547
+ ### `_.isBotAgent (boolean)`
548
+
549
+ Analyze the user agent value to determine if it's a bot for a search engine. Returns `true` if it's a bot.
550
+
551
+ - `userAgent::string`
552
+
553
+ ```javascript
554
+ _.isBotAgent('Mozilla/5.0 (compatible; Googlebot/2.1; +http://www.google.com/bot.html)'); // Returns true
555
+ ```
556
+
557
+ ### `_.numberFormat (string)`
558
+
559
+ Return number format including comma symbol.
560
+
561
+ - `number::number`
562
+
563
+ ```javascript
564
+ _.numberFormat(1234567); // Returns 1,234,567
565
+ ```
566
+
567
+ ### `_.fileName (string)`
568
+
569
+ Extract the file name from the path. Include the extension if withExtension is `true`.
570
+
571
+ - `filePath::string`
572
+ - `withExtension::boolean || false`
573
+
574
+ ```javascript
575
+ _.fileName('C:Temphello.txt'); // Returns 'hello.txt'
576
+ _.fileName('C:Temp\file.mp3', true); // Returns 'file.mp3'
577
+ ```
578
+
579
+ ### `_.fileSize (string)`
580
+
581
+ Converts the file size in bytes to human-readable and returns it. The return value is a String and includes the file units (Bytes, MB, GB...). If the second optional argument value is included, you can display as many decimal places as you like.
582
+
583
+ - `bytes::number`
584
+ - `decimals::number || 2`
585
+
586
+ ```javascript
587
+ _.fileSize(2000, 3); // Returns '1.953 KB'
588
+ _.fileSize(250000000); // Returns '238.42 MB'
589
+ ```
590
+
591
+ ### `_.fileExt (string)`
592
+
593
+ Returns only the extensions in the file path. If unknown, returns 'Unknown'.
594
+
595
+ - `filePath::string`
596
+
597
+ ```javascript
598
+ _.fileExt('C:Temphello.txt'); // Returns 'txt'
599
+ _.fileExt('this-is-file.mp3'); // Returns 'mp3'
600
+ ```
601
+
602
+ ### `_.msToTime (string)`
603
+
604
+ Converts milliseconds to hours, minutes, seconds, and milliseconds and returns. If the second argument is true, milliseconds are also printed. You can put any separator (String) between hours, minutes, and seconds in the third argument.
605
+
606
+ - `milliseconds::number`
607
+ - `withMilliseconds::boolean || false`
608
+ - `separator::string || ':'`
609
+
610
+ ```javascript
611
+ _.msToTime(100000); // 'Returns '00:01:40'
612
+ _.msToTime(100000, true, '-'); // Returns '00-01-40.0'
613
+ ```
614
+
615
+ ### `_.secToTime (string)`
616
+
617
+ Converts seconds to hours, minutes, seconds and returns. You can put any separator (String) between hours, minutes, and seconds in the third argument.
618
+
619
+ - `seconds::number`
620
+ - `onlyHour::boolean || false`
621
+ - `separator::string || ':'`
622
+
623
+ ```javascript
624
+ _.secToTime(3800); // Returns '01:03:20'
625
+ _.secToTime(60, '-'); // Returns '00-01-00'
626
+ ```
627
+
628
+ ### `_.license (string)`
629
+
630
+ Returns text in a specific license format based on the author information of the given argument. The argument uses the Object type.
631
+
632
+ - `options::LicenseOption{ author: string, email: string?, yearStart: string|number, yearEnd: string?, htmlBr: boolean?, type: 'mit' | 'apache20' }`
633
+
634
+ ```javascript
635
+ _.license({
636
+ holder: 'example',
637
+ email: 'example@example.com',
638
+ yearStart: 2020,
639
+ yearEnd: 2021,
640
+ htmlBr: true
641
+ });
642
+ ```
643
+
644
+ # Contribute
645
+
646
+ You can report issues on [GitHub Issue Tracker](https://github.com/jooy2/qsu/issues). You can also request a pull to fix bugs and add frequently used features.
647
+
648
+ # License
649
+
650
+ Copyright © 2021-2022 Jooy2 Released under the MIT license.