itee-validators 5.5.1 → 6.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.github/workflows/node.js.yml +2 -2
- package/.releaserc.mjs +94 -0
- package/.tasks/.builds/build-benchmarks.task.mjs +16 -0
- package/.tasks/.builds/build-tests.task.mjs +18 -0
- package/.tasks/.builds/build-unit-tests.task.mjs +16 -0
- package/.tasks/.builds/build.task.mjs +46 -0
- package/.tasks/.cleans/clean.task.mjs +23 -0
- package/.tasks/.docs/doc.task.mjs +35 -0
- package/.tasks/.helps/help.task.mjs +151 -0
- package/.tasks/.lints/lint.task.mjs +37 -0
- package/.tasks/.patches/patch.task.mjs +13 -0
- package/.tasks/.releases/release.task.mjs +26 -0
- package/.tasks/.tests/benchmarks/build-benchmarks-backend.task.mjs +42 -0
- package/.tasks/.tests/benchmarks/compute-benchmarks.task.mjs +210 -0
- package/.tasks/.tests/benchmarks/run-benchmarks-for-backend.task.mjs +39 -0
- package/.tasks/.tests/benchmarks/run-benchmarks-for-frontend.task.mjs +41 -0
- package/.tasks/.tests/benchmarks/run-benchmarks.task.mjs +18 -0
- package/.tasks/.tests/bundling/check-bundling-from-esm-build-import.task.mjs +123 -0
- package/.tasks/.tests/bundling/check-bundling-from-esm-files-direct.task.mjs +77 -0
- package/.tasks/.tests/bundling/check-bundling-from-esm-files-import.task.mjs +95 -0
- package/.tasks/.tests/bundling/check-bundling.task.mjs +20 -0
- package/.tasks/.tests/run-tests.task.mjs +18 -0
- package/.tasks/.tests/unit-tests/build-unit-tests-backend.task.mjs +42 -0
- package/.tasks/.tests/unit-tests/compute-unit-tests.task.mjs +537 -0
- package/.tasks/.tests/unit-tests/run-unit-tests-for-backend.task.mjs +44 -0
- package/.tasks/.tests/unit-tests/run-unit-tests-for-frontend.task.mjs +41 -0
- package/.tasks/.tests/unit-tests/run-unit-tests.task.mjs +18 -0
- package/.tasks/_refresh-gulpfile.task.mjs +65 -0
- package/.tasks/_utils.mjs +192 -0
- package/.tasks/configs/benchmarks.conf.mjs +57 -0
- package/.tasks/configs/build-benchmarks-backend.conf.mjs +51 -0
- package/.tasks/configs/build-unit-tests-backend.conf.mjs +46 -0
- package/.tasks/configs/build.conf.mjs +354 -0
- package/.tasks/configs/check-bundling.conf.mjs +26 -0
- package/.tasks/configs/clean.conf.mjs +9 -0
- package/.tasks/configs/compute-benchmarks.conf.mjs +28 -0
- package/.tasks/configs/compute-unit-tests.conf.mjs +27 -0
- package/.tasks/configs/doc.conf.json +50 -0
- package/.tasks/configs/eslint.conf.mjs +121 -0
- package/.tasks/configs/units.conf.mjs +27 -0
- package/.tasks/itee-benchmarks-framework.js +186 -0
- package/.tasks/itee-reporter.mjs +217 -0
- package/CHANGELOG.md +20 -0
- package/builds/itee-validators.cjs.js +71 -25
- package/builds/itee-validators.cjs.js.map +1 -1
- package/builds/itee-validators.cjs.min.js +70 -69
- package/builds/itee-validators.esm.js +27 -4
- package/builds/itee-validators.esm.js.map +1 -1
- package/builds/itee-validators.esm.min.js +3 -3
- package/builds/itee-validators.iife.js +27 -6
- package/builds/itee-validators.iife.js.map +1 -1
- package/builds/itee-validators.iife.min.js +10 -10
- package/package.json +49 -41
- package/sources/cores/_cores.js +10 -10
- package/sources/cores/arrays/_arrays.js +12 -12
- package/sources/cores/arrays/isArrayOfArray.js +2 -2
- package/sources/cores/arrays/isArrayOfBoolean.js +3 -3
- package/sources/cores/arrays/isArrayOfFunction.js +3 -3
- package/sources/cores/arrays/isArrayOfMultiElement.js +1 -1
- package/sources/cores/arrays/isArrayOfNull.js +3 -3
- package/sources/cores/arrays/isArrayOfNumber.js +3 -3
- package/sources/cores/arrays/isArrayOfObject.js +3 -3
- package/sources/cores/arrays/isArrayOfSingleElement.js +1 -1
- package/sources/cores/arrays/isArrayOfString.js +3 -3
- package/sources/cores/arrays/isArrayOfUndefined.js +3 -3
- package/sources/cores/arrays/isEmptyArray.js +1 -1
- package/sources/cores/booleans/_booleans.js +2 -2
- package/sources/cores/booleans/isTrue.js +1 -1
- package/sources/cores/cores.js +8 -8
- package/sources/cores/functions/_functions.js +1 -1
- package/sources/cores/numbers/_numbers.js +6 -6
- package/sources/cores/numbers/isNumber.js +3 -3
- package/sources/cores/objects/_objects.js +2 -2
- package/sources/cores/objects/isEmptyObject.js +1 -1
- package/sources/cores/objects/isObject.js +1 -1
- package/sources/cores/strings/_strings.js +3 -3
- package/sources/cores/strings/isBlankString.js +2 -2
- package/sources/cores/strings/isEmptyString.js +1 -1
- package/sources/cores/symbols/_symbols.js +1 -1
- package/sources/cores/tests/isTestUnitGenerator.js +5 -6
- package/sources/cores/typed-arrays/_typedArrays.js +12 -12
- package/sources/cores/voids/_voids.js +4 -4
- package/sources/cores/voids/isEmpty.js +4 -4
- package/sources/file-system/_file-system.js +9 -9
- package/sources/file-system/block-devices/_blockDevices.js +3 -3
- package/sources/file-system/block-devices/isBlockDevicePath.js +5 -4
- package/sources/file-system/block-devices/isValidBlockDevicePath.js +2 -2
- package/sources/file-system/character-devices/_characterDevices.js +3 -3
- package/sources/file-system/character-devices/isCharacterDevicePath.js +5 -4
- package/sources/file-system/character-devices/isValidCharacterDevicePath.js +2 -2
- package/sources/file-system/directories/_directories.js +4 -4
- package/sources/file-system/directories/isDirectoryPath.js +5 -4
- package/sources/file-system/directories/isEmptyDirectory.js +2 -2
- package/sources/file-system/directories/isValidDirectoryPath.js +2 -2
- package/sources/file-system/fifo-pipes/_fifoPipes.js +3 -3
- package/sources/file-system/fifo-pipes/isFIFOPath.js +5 -4
- package/sources/file-system/fifo-pipes/isValidFIFOPath.js +2 -2
- package/sources/file-system/files/_files.js +4 -4
- package/sources/file-system/files/isEmptyFile.js +5 -4
- package/sources/file-system/files/isFilePath.js +5 -4
- package/sources/file-system/files/isValidFilePath.js +2 -2
- package/sources/file-system/paths/_paths.js +2 -2
- package/sources/file-system/paths/isValidPath.js +1 -1
- package/sources/file-system/sockets/_sockets.js +3 -3
- package/sources/file-system/sockets/isSocketPath.js +5 -4
- package/sources/file-system/sockets/isValidSocketPath.js +2 -2
- package/sources/file-system/symbolic-links/_symbolicLinks.js +3 -3
- package/sources/file-system/symbolic-links/isSymbolicLinkPath.js +5 -4
- package/sources/file-system/symbolic-links/isValidSymbolicLinkPath.js +2 -2
- package/sources/itee-validators.js +4 -4
- package/sources/maths/_maths.js +1 -1
- package/sources/physics/_physics.js +2 -2
- package/sources/physics/temperatures/_temperatures.js +5 -5
- package/sources/physics/temperatures/isCelsius.js +2 -2
- package/sources/physics/temperatures/isFahrenheit.js +2 -2
- package/sources/physics/temperatures/isKelvin.js +2 -2
- package/sources/physics/temperatures/isTemperature.js +3 -3
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* ┳ ┓┏ ┓• ┓
|
|
3
|
-
* ┃╋┏┓┏┓ ┃┃┏┓┃┓┏┫┏┓╋┏┓┏┓┏
|
|
4
|
-
* ┻┗┗ ┗ •┗┛┗┻┗┗┗┻┗┻┗┗┛┛ ┛
|
|
5
|
-
*
|
|
2
|
+
* ┳ ┓┏ ┓• ┓ ┏┓ ┏┓ ┏┓ ┏┓ ┏┳
|
|
3
|
+
* ┃╋┏┓┏┓ ┃┃┏┓┃┓┏┫┏┓╋┏┓┏┓┏ ┓┏┣┓ ┃┫ ┃┫ ━━ ┃ ┏┓┏┳┓┏┳┓┏┓┏┓ ┃┏
|
|
4
|
+
* ┻┗┗ ┗ •┗┛┗┻┗┗┗┻┗┻┗┗┛┛ ┛ ┗┛┗┛•┗┛•┗┛ ┗┛┗┛┛┗┗┛┗┗┗┛┛┗┗┛┛
|
|
5
|
+
*
|
|
6
6
|
* @desc A library of validation functions use in various Itee projects
|
|
7
7
|
* @author [Tristan Valcke]{@link https://github.com/Itee}
|
|
8
8
|
* @license [BSD-3-Clause]{@link https://opensource.org/licenses/BSD-3-Clause}
|
|
@@ -10,9 +10,7 @@
|
|
|
10
10
|
*/
|
|
11
11
|
'use strict';
|
|
12
12
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
var fs = require('fs');
|
|
13
|
+
var node_fs = require('node:fs');
|
|
16
14
|
|
|
17
15
|
/**
|
|
18
16
|
* @author [Tristan Valcke]{@link https://github.com/Itee}
|
|
@@ -70,6 +68,7 @@ function isNotArray( data ) {
|
|
|
70
68
|
*
|
|
71
69
|
*/
|
|
72
70
|
|
|
71
|
+
|
|
73
72
|
/**
|
|
74
73
|
* Check if given data is an empty array
|
|
75
74
|
*
|
|
@@ -116,6 +115,7 @@ function isNotEmptyArray( data ) {
|
|
|
116
115
|
*
|
|
117
116
|
*/
|
|
118
117
|
|
|
118
|
+
|
|
119
119
|
/**
|
|
120
120
|
* Check if given data is an array of array
|
|
121
121
|
*
|
|
@@ -214,6 +214,7 @@ function isNotBoolean( data ) {
|
|
|
214
214
|
*
|
|
215
215
|
*/
|
|
216
216
|
|
|
217
|
+
|
|
217
218
|
/**
|
|
218
219
|
* Check if given data is not an empty array where all values are boolean
|
|
219
220
|
*
|
|
@@ -312,6 +313,7 @@ function isNotFunction( data ) {
|
|
|
312
313
|
*
|
|
313
314
|
*/
|
|
314
315
|
|
|
316
|
+
|
|
315
317
|
/**
|
|
316
318
|
* Check if given data is not an empty array where all values are functions
|
|
317
319
|
*
|
|
@@ -372,6 +374,7 @@ function isNotArrayOfFunction( data ) {
|
|
|
372
374
|
*
|
|
373
375
|
*/
|
|
374
376
|
|
|
377
|
+
|
|
375
378
|
/**
|
|
376
379
|
* Check if given data is an array with multiples values
|
|
377
380
|
*
|
|
@@ -443,6 +446,7 @@ function isNotNull( data ) {
|
|
|
443
446
|
* } *
|
|
444
447
|
*/
|
|
445
448
|
|
|
449
|
+
|
|
446
450
|
/**
|
|
447
451
|
* Check if given data is not an empty array where all values are null
|
|
448
452
|
*
|
|
@@ -651,6 +655,7 @@ function isZeroNegative( data ) {
|
|
|
651
655
|
*
|
|
652
656
|
*/
|
|
653
657
|
|
|
658
|
+
|
|
654
659
|
/**
|
|
655
660
|
* Check if given data is a number
|
|
656
661
|
*
|
|
@@ -754,6 +759,7 @@ function isNaN( data ) {
|
|
|
754
759
|
*
|
|
755
760
|
*/
|
|
756
761
|
|
|
762
|
+
|
|
757
763
|
/**
|
|
758
764
|
* Check if given data is not an empty array where all values are numbers
|
|
759
765
|
*
|
|
@@ -814,6 +820,7 @@ function isNotArrayOfNumber( data ) {
|
|
|
814
820
|
*
|
|
815
821
|
*/
|
|
816
822
|
|
|
823
|
+
|
|
817
824
|
/**
|
|
818
825
|
* Check if given data is an object
|
|
819
826
|
*
|
|
@@ -855,6 +862,7 @@ function isNotObject( data ) {
|
|
|
855
862
|
*
|
|
856
863
|
*/
|
|
857
864
|
|
|
865
|
+
|
|
858
866
|
/**
|
|
859
867
|
* Check if given data is an array where all values are of object type
|
|
860
868
|
*
|
|
@@ -915,6 +923,7 @@ function isNotArrayOfObject( data ) {
|
|
|
915
923
|
*
|
|
916
924
|
*/
|
|
917
925
|
|
|
926
|
+
|
|
918
927
|
/**
|
|
919
928
|
* Check if given data is an array with a single value
|
|
920
929
|
*
|
|
@@ -989,6 +998,7 @@ function isNotString( data ) {
|
|
|
989
998
|
*
|
|
990
999
|
*/
|
|
991
1000
|
|
|
1001
|
+
|
|
992
1002
|
/**
|
|
993
1003
|
* Check if given data is not an empty array where all values are string
|
|
994
1004
|
*
|
|
@@ -1087,6 +1097,7 @@ function isNotUndefined( data ) {
|
|
|
1087
1097
|
*
|
|
1088
1098
|
*/
|
|
1089
1099
|
|
|
1100
|
+
|
|
1090
1101
|
/**
|
|
1091
1102
|
* Check if given data is not an empty array where all values are undefined
|
|
1092
1103
|
*
|
|
@@ -1147,6 +1158,7 @@ function isNotArrayOfUndefined( data ) {
|
|
|
1147
1158
|
*
|
|
1148
1159
|
*/
|
|
1149
1160
|
|
|
1161
|
+
|
|
1150
1162
|
/**
|
|
1151
1163
|
* Check if given data is a boolean with value to true
|
|
1152
1164
|
*
|
|
@@ -1303,6 +1315,7 @@ function isMinSafeInteger( data ) {
|
|
|
1303
1315
|
*
|
|
1304
1316
|
*/
|
|
1305
1317
|
|
|
1318
|
+
|
|
1306
1319
|
/**
|
|
1307
1320
|
* Check if given data is an empty object
|
|
1308
1321
|
*
|
|
@@ -1356,6 +1369,7 @@ function isNotEmptyObject( data ) {
|
|
|
1356
1369
|
*
|
|
1357
1370
|
*/
|
|
1358
1371
|
|
|
1372
|
+
|
|
1359
1373
|
/**
|
|
1360
1374
|
* Check if given data is an empty string
|
|
1361
1375
|
*
|
|
@@ -1402,6 +1416,7 @@ function isNotEmptyString( data ) {
|
|
|
1402
1416
|
*
|
|
1403
1417
|
*/
|
|
1404
1418
|
|
|
1419
|
+
|
|
1405
1420
|
/**
|
|
1406
1421
|
* Check if the given data is a blank string
|
|
1407
1422
|
*
|
|
@@ -1484,6 +1499,7 @@ function isNotSymbol( data ) {
|
|
|
1484
1499
|
*
|
|
1485
1500
|
*/
|
|
1486
1501
|
|
|
1502
|
+
|
|
1487
1503
|
/**
|
|
1488
1504
|
* Check emptiness of given data
|
|
1489
1505
|
*
|
|
@@ -1639,6 +1655,7 @@ function isNotEmpty( data ) {
|
|
|
1639
1655
|
*
|
|
1640
1656
|
*/
|
|
1641
1657
|
|
|
1658
|
+
|
|
1642
1659
|
class Validator {
|
|
1643
1660
|
|
|
1644
1661
|
constructor() {
|
|
@@ -2310,6 +2327,7 @@ const ABSOLUTE_ZERO_FAHRENHEIT = -459.67;
|
|
|
2310
2327
|
*
|
|
2311
2328
|
*/
|
|
2312
2329
|
|
|
2330
|
+
|
|
2313
2331
|
/**
|
|
2314
2332
|
*
|
|
2315
2333
|
* @param data {*}
|
|
@@ -2346,6 +2364,7 @@ function isNotCelsius( data ) {
|
|
|
2346
2364
|
*
|
|
2347
2365
|
*/
|
|
2348
2366
|
|
|
2367
|
+
|
|
2349
2368
|
/**
|
|
2350
2369
|
*
|
|
2351
2370
|
* @param data {*}
|
|
@@ -2382,6 +2401,7 @@ function isNotFahrenheit( data ) {
|
|
|
2382
2401
|
*
|
|
2383
2402
|
*/
|
|
2384
2403
|
|
|
2404
|
+
|
|
2385
2405
|
/**
|
|
2386
2406
|
*
|
|
2387
2407
|
* @param data {*}
|
|
@@ -2418,6 +2438,7 @@ function isNotKelvin( data ) {
|
|
|
2418
2438
|
*
|
|
2419
2439
|
*/
|
|
2420
2440
|
|
|
2441
|
+
|
|
2421
2442
|
/**
|
|
2422
2443
|
*
|
|
2423
2444
|
* @param data {*}
|
|
@@ -2457,6 +2478,7 @@ function isNotTemperature( data ) {
|
|
|
2457
2478
|
*
|
|
2458
2479
|
*/
|
|
2459
2480
|
|
|
2481
|
+
|
|
2460
2482
|
/**
|
|
2461
2483
|
* Check if given path is a block device path
|
|
2462
2484
|
*
|
|
@@ -2465,10 +2487,11 @@ function isNotTemperature( data ) {
|
|
|
2465
2487
|
*/
|
|
2466
2488
|
function isBlockDevicePath( path ) {
|
|
2467
2489
|
if ( isNotString( path ) && !( path instanceof Buffer ) && !( path instanceof URL ) ) {
|
|
2468
|
-
|
|
2490
|
+
return false
|
|
2491
|
+
// throw new TypeError( 'Invalid path type! Expect string, buffer or url.' )
|
|
2469
2492
|
}
|
|
2470
2493
|
|
|
2471
|
-
const stat =
|
|
2494
|
+
const stat = node_fs.statSync( path, { throwIfNoEntry: false } );
|
|
2472
2495
|
return isDefined( stat ) && stat.isBlockDevice()
|
|
2473
2496
|
}
|
|
2474
2497
|
|
|
@@ -2503,6 +2526,7 @@ function isNotBlockDevicePath( path ) {
|
|
|
2503
2526
|
*
|
|
2504
2527
|
*/
|
|
2505
2528
|
|
|
2529
|
+
|
|
2506
2530
|
/**
|
|
2507
2531
|
* Check if given data is a valid file path
|
|
2508
2532
|
*
|
|
@@ -2510,7 +2534,7 @@ function isNotBlockDevicePath( path ) {
|
|
|
2510
2534
|
* @returns {boolean} true if data is a valid path, false otherwise
|
|
2511
2535
|
*/
|
|
2512
2536
|
function isValidPath( data ) {
|
|
2513
|
-
return
|
|
2537
|
+
return node_fs.existsSync( data )
|
|
2514
2538
|
}
|
|
2515
2539
|
|
|
2516
2540
|
/**
|
|
@@ -2541,6 +2565,7 @@ function isInvalidPath( data ) {
|
|
|
2541
2565
|
*
|
|
2542
2566
|
*/
|
|
2543
2567
|
|
|
2568
|
+
|
|
2544
2569
|
/**
|
|
2545
2570
|
* Check if given data is a valid block device path
|
|
2546
2571
|
*
|
|
@@ -2582,6 +2607,7 @@ function isInvalidBlockDevicePath( data ) {
|
|
|
2582
2607
|
*
|
|
2583
2608
|
*/
|
|
2584
2609
|
|
|
2610
|
+
|
|
2585
2611
|
/**
|
|
2586
2612
|
* Check if given path is a character device path
|
|
2587
2613
|
*
|
|
@@ -2590,10 +2616,11 @@ function isInvalidBlockDevicePath( data ) {
|
|
|
2590
2616
|
*/
|
|
2591
2617
|
function isCharacterDevicePath( path ) {
|
|
2592
2618
|
if ( isNotString( path ) && !( path instanceof Buffer ) && !( path instanceof URL ) ) {
|
|
2593
|
-
|
|
2619
|
+
return false
|
|
2620
|
+
// throw new TypeError( 'Invalid path type! Expect string, buffer or url.' )
|
|
2594
2621
|
}
|
|
2595
2622
|
|
|
2596
|
-
const stat =
|
|
2623
|
+
const stat = node_fs.statSync( path, { throwIfNoEntry: false } );
|
|
2597
2624
|
return isDefined( stat ) && stat.isCharacterDevice()
|
|
2598
2625
|
}
|
|
2599
2626
|
|
|
@@ -2625,6 +2652,7 @@ function isNotCharacterDevicePath( path ) {
|
|
|
2625
2652
|
*
|
|
2626
2653
|
*/
|
|
2627
2654
|
|
|
2655
|
+
|
|
2628
2656
|
/**
|
|
2629
2657
|
* Check if given data is a valid character device path
|
|
2630
2658
|
*
|
|
@@ -2666,6 +2694,7 @@ function isInvalidCharacterDevicePath( data ) {
|
|
|
2666
2694
|
*
|
|
2667
2695
|
*/
|
|
2668
2696
|
|
|
2697
|
+
|
|
2669
2698
|
/**
|
|
2670
2699
|
* Check if given path is a directory path
|
|
2671
2700
|
*
|
|
@@ -2674,10 +2703,11 @@ function isInvalidCharacterDevicePath( data ) {
|
|
|
2674
2703
|
*/
|
|
2675
2704
|
function isDirectoryPath( path ) {
|
|
2676
2705
|
if ( isNotString( path ) && !( path instanceof Buffer ) && !( path instanceof URL ) ) {
|
|
2677
|
-
|
|
2706
|
+
return false
|
|
2707
|
+
// throw new TypeError( 'Invalid path type! Expect string, buffer or url.' )
|
|
2678
2708
|
}
|
|
2679
2709
|
|
|
2680
|
-
const stat =
|
|
2710
|
+
const stat = node_fs.statSync( path, { throwIfNoEntry: false } );
|
|
2681
2711
|
return isDefined( stat ) && stat.isDirectory()
|
|
2682
2712
|
}
|
|
2683
2713
|
|
|
@@ -2712,6 +2742,7 @@ function isNotDirectoryPath( path ) {
|
|
|
2712
2742
|
*
|
|
2713
2743
|
*/
|
|
2714
2744
|
|
|
2745
|
+
|
|
2715
2746
|
/**
|
|
2716
2747
|
* Check if given directory path is an empty directory
|
|
2717
2748
|
*
|
|
@@ -2719,7 +2750,7 @@ function isNotDirectoryPath( path ) {
|
|
|
2719
2750
|
* @returns {boolean} true if directory is empty, false otherwise
|
|
2720
2751
|
*/
|
|
2721
2752
|
function isEmptyDirectory( directoryPath ) {
|
|
2722
|
-
return isDirectoryPath( directoryPath ) && (
|
|
2753
|
+
return isDirectoryPath( directoryPath ) && ( node_fs.readdirSync( directoryPath ).length === 0 )
|
|
2723
2754
|
}
|
|
2724
2755
|
|
|
2725
2756
|
/**
|
|
@@ -2750,6 +2781,7 @@ function isNotEmptyDirectory( directoryPath ) {
|
|
|
2750
2781
|
*
|
|
2751
2782
|
*/
|
|
2752
2783
|
|
|
2784
|
+
|
|
2753
2785
|
/**
|
|
2754
2786
|
* Check if given data is a valid directory path
|
|
2755
2787
|
*
|
|
@@ -2791,6 +2823,7 @@ function isInvalidDirectoryPath( data ) {
|
|
|
2791
2823
|
*
|
|
2792
2824
|
*/
|
|
2793
2825
|
|
|
2826
|
+
|
|
2794
2827
|
/**
|
|
2795
2828
|
* Check if given path is a fifo path
|
|
2796
2829
|
*
|
|
@@ -2799,10 +2832,11 @@ function isInvalidDirectoryPath( data ) {
|
|
|
2799
2832
|
*/
|
|
2800
2833
|
function isFIFOPath( path ) {
|
|
2801
2834
|
if ( isNotString( path ) && !( path instanceof Buffer ) && !( path instanceof URL ) ) {
|
|
2802
|
-
|
|
2835
|
+
return false
|
|
2836
|
+
// throw new TypeError( 'Invalid path type! Expect string, buffer or url.' )
|
|
2803
2837
|
}
|
|
2804
2838
|
|
|
2805
|
-
const stat =
|
|
2839
|
+
const stat = node_fs.statSync( path, { throwIfNoEntry: false } );
|
|
2806
2840
|
return isDefined( stat ) && stat.isFIFO()
|
|
2807
2841
|
}
|
|
2808
2842
|
|
|
@@ -2837,6 +2871,7 @@ function isNotFIFOPath( path ) {
|
|
|
2837
2871
|
*
|
|
2838
2872
|
*/
|
|
2839
2873
|
|
|
2874
|
+
|
|
2840
2875
|
/**
|
|
2841
2876
|
* Check if given data is a valid fifo path
|
|
2842
2877
|
*
|
|
@@ -2878,6 +2913,7 @@ function isInvalidFIFOPath( data ) {
|
|
|
2878
2913
|
*
|
|
2879
2914
|
*/
|
|
2880
2915
|
|
|
2916
|
+
|
|
2881
2917
|
/**
|
|
2882
2918
|
* Check if given path is a file path
|
|
2883
2919
|
*
|
|
@@ -2886,10 +2922,11 @@ function isInvalidFIFOPath( data ) {
|
|
|
2886
2922
|
*/
|
|
2887
2923
|
function isFilePath( path ) {
|
|
2888
2924
|
if ( isNotString( path ) && !( path instanceof Buffer ) && !( path instanceof URL ) ) {
|
|
2889
|
-
|
|
2925
|
+
return false
|
|
2926
|
+
// throw new TypeError( 'Invalid path type! Expect string, buffer or url.' )
|
|
2890
2927
|
}
|
|
2891
2928
|
|
|
2892
|
-
const stat =
|
|
2929
|
+
const stat = node_fs.statSync( path, { throwIfNoEntry: false } );
|
|
2893
2930
|
return isDefined( stat ) && stat.isFile()
|
|
2894
2931
|
}
|
|
2895
2932
|
|
|
@@ -2924,6 +2961,7 @@ function isNotFilePath( path ) {
|
|
|
2924
2961
|
*
|
|
2925
2962
|
*/
|
|
2926
2963
|
|
|
2964
|
+
|
|
2927
2965
|
/**
|
|
2928
2966
|
* Check if given file path is an empty file more or less a threshold in bytes.
|
|
2929
2967
|
*
|
|
@@ -2933,10 +2971,11 @@ function isNotFilePath( path ) {
|
|
|
2933
2971
|
*/
|
|
2934
2972
|
function isEmptyFile( filePath, threshold = 0 ) {
|
|
2935
2973
|
if ( isNotString( filePath ) && !( filePath instanceof Buffer ) && !( filePath instanceof URL ) ) {
|
|
2936
|
-
|
|
2974
|
+
return false
|
|
2975
|
+
// throw new TypeError( 'Invalid path type! Expect string, buffer or url.' )
|
|
2937
2976
|
}
|
|
2938
2977
|
|
|
2939
|
-
return isFilePath( filePath ) && (
|
|
2978
|
+
return isFilePath( filePath ) && ( node_fs.statSync( filePath ).size <= threshold )
|
|
2940
2979
|
}
|
|
2941
2980
|
|
|
2942
2981
|
/**
|
|
@@ -2968,6 +3007,7 @@ function isNotEmptyFile( filePath, threshold = 0 ) {
|
|
|
2968
3007
|
*
|
|
2969
3008
|
*/
|
|
2970
3009
|
|
|
3010
|
+
|
|
2971
3011
|
/**
|
|
2972
3012
|
* Check if given data is a valid file path
|
|
2973
3013
|
*
|
|
@@ -3009,6 +3049,7 @@ function isInvalidFilePath( data ) {
|
|
|
3009
3049
|
*
|
|
3010
3050
|
*/
|
|
3011
3051
|
|
|
3052
|
+
|
|
3012
3053
|
/**
|
|
3013
3054
|
* Check if given path is a socket path
|
|
3014
3055
|
*
|
|
@@ -3017,10 +3058,11 @@ function isInvalidFilePath( data ) {
|
|
|
3017
3058
|
*/
|
|
3018
3059
|
function isSocketPath( path ) {
|
|
3019
3060
|
if ( isNotString( path ) && !( path instanceof Buffer ) && !( path instanceof URL ) ) {
|
|
3020
|
-
|
|
3061
|
+
return false
|
|
3062
|
+
// throw new TypeError( 'Invalid path type! Expect string, buffer or url.' )
|
|
3021
3063
|
}
|
|
3022
3064
|
|
|
3023
|
-
const stat =
|
|
3065
|
+
const stat = node_fs.statSync( path, { throwIfNoEntry: false } );
|
|
3024
3066
|
return isDefined( stat ) && stat.isSocket()
|
|
3025
3067
|
}
|
|
3026
3068
|
|
|
@@ -3052,6 +3094,7 @@ function isNotSocketPath( path ) {
|
|
|
3052
3094
|
*
|
|
3053
3095
|
*/
|
|
3054
3096
|
|
|
3097
|
+
|
|
3055
3098
|
/**
|
|
3056
3099
|
* Check if given data is a valid socket path
|
|
3057
3100
|
*
|
|
@@ -3093,6 +3136,7 @@ function isInvalidSocketPath( data ) {
|
|
|
3093
3136
|
*
|
|
3094
3137
|
*/
|
|
3095
3138
|
|
|
3139
|
+
|
|
3096
3140
|
/**
|
|
3097
3141
|
* Check if given path is a symbolic link path
|
|
3098
3142
|
*
|
|
@@ -3101,10 +3145,11 @@ function isInvalidSocketPath( data ) {
|
|
|
3101
3145
|
*/
|
|
3102
3146
|
function isSymbolicLinkPath( path ) {
|
|
3103
3147
|
if ( isNotString( path ) && !( path instanceof Buffer ) && !( path instanceof URL ) ) {
|
|
3104
|
-
|
|
3148
|
+
return false
|
|
3149
|
+
// throw new TypeError( 'Invalid path type! Expect string, buffer or url.' )
|
|
3105
3150
|
}
|
|
3106
3151
|
|
|
3107
|
-
const stat =
|
|
3152
|
+
const stat = node_fs.statSync( path, { throwIfNoEntry: false } );
|
|
3108
3153
|
return isDefined( stat ) && stat.isSymbolicLink()
|
|
3109
3154
|
}
|
|
3110
3155
|
|
|
@@ -3136,6 +3181,7 @@ function isNotSymbolicLinkPath( path ) {
|
|
|
3136
3181
|
*
|
|
3137
3182
|
*/
|
|
3138
3183
|
|
|
3184
|
+
|
|
3139
3185
|
/**
|
|
3140
3186
|
* Check if given data is a valid symbolic link path
|
|
3141
3187
|
*
|