qsu 1.1.1 → 1.1.3

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