itee-validators 5.3.5 → 5.3.7
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 +1 -1
- package/CHANGELOG.md +34 -0
- package/builds/itee-validators.cjs.js +87 -48
- package/builds/itee-validators.cjs.js.map +1 -1
- package/builds/itee-validators.cjs.min.js +64 -64
- package/builds/itee-validators.esm.js +11 -11
- package/builds/itee-validators.esm.js.map +1 -1
- package/builds/itee-validators.esm.min.js +4 -4
- package/builds/itee-validators.iife.js +11 -11
- package/builds/itee-validators.iife.js.map +1 -1
- package/builds/itee-validators.iife.min.js +4 -4
- package/package.json +26 -23
- package/sources/cores/_cores.js +1 -1
- package/sources/cores/numbers/_numbers.js +2 -0
- package/sources/cores/tests/isTestUnitGenerator.js +118 -0
- package/sources/dom/isEventTarget.js +10 -0
- package/sources/file-system/block-devices/isBlockDevicePath.js +9 -2
- package/sources/file-system/character-devices/isCharacterDevicePath.js +8 -1
- package/sources/file-system/directories/isDirectoryPath.js +8 -1
- package/sources/file-system/directories/isEmptyDirectory.js +2 -1
- package/sources/file-system/fifo-pipes/isFIFOPath.js +8 -1
- package/sources/file-system/files/isEmptyFile.js +9 -3
- package/sources/file-system/files/isFilePath.js +8 -1
- package/sources/file-system/sockets/isSocketPath.js +8 -1
- package/sources/file-system/symbolic-links/isSymbolicLinkPath.js +8 -1
- package/sources/physics/temperatures/isCelsius.js +3 -3
- package/sources/physics/temperatures/isFahrenheit.js +3 -3
- package/sources/physics/temperatures/isKelvin.js +3 -3
- package/sources/physics/temperatures/isTemperature.js +1 -1
|
@@ -704,7 +704,7 @@ const Z=4.5e-10,x=-273.14999999955,G=-459.67;
|
|
|
704
704
|
* @author [Tristan Valcke]{@link https://github.com/Itee}
|
|
705
705
|
* @license [BSD-3-Clause]{@link https://opensource.org/licenses/BSD-3-Clause}
|
|
706
706
|
*
|
|
707
|
-
* @module sources/physics/
|
|
707
|
+
* @module sources/physics/temperatures
|
|
708
708
|
* @desc Export function to validate if a value is a Celsius temperature
|
|
709
709
|
* @example
|
|
710
710
|
*
|
|
@@ -722,7 +722,7 @@ function Y(r){return A(r)&&r>=x}function K(r){return!Y(r)}
|
|
|
722
722
|
* @author [Tristan Valcke]{@link https://github.com/Itee}
|
|
723
723
|
* @license [BSD-3-Clause]{@link https://opensource.org/licenses/BSD-3-Clause}
|
|
724
724
|
*
|
|
725
|
-
* @module sources/physics/
|
|
725
|
+
* @module sources/physics/temperatures
|
|
726
726
|
* @desc Export function to validate if a value is a Fahrenheit temperature
|
|
727
727
|
* @example
|
|
728
728
|
*
|
|
@@ -739,7 +739,7 @@ function Y(r){return A(r)&&r>=x}function K(r){return!Y(r)}
|
|
|
739
739
|
* @author [Tristan Valcke]{@link https://github.com/Itee}
|
|
740
740
|
* @license [BSD-3-Clause]{@link https://opensource.org/licenses/BSD-3-Clause}
|
|
741
741
|
*
|
|
742
|
-
* @module sources/physics/
|
|
742
|
+
* @module sources/physics/temperatures
|
|
743
743
|
* @desc Export function to validate if a value is a kelvin temperature
|
|
744
744
|
* @example
|
|
745
745
|
*
|
|
@@ -756,7 +756,7 @@ function Y(r){return A(r)&&r>=x}function K(r){return!Y(r)}
|
|
|
756
756
|
* @author [Tristan Valcke]{@link https://github.com/Itee}
|
|
757
757
|
* @license [BSD-3-Clause]{@link https://opensource.org/licenses/BSD-3-Clause}
|
|
758
758
|
*
|
|
759
|
-
* @module sources/physics/
|
|
759
|
+
* @module sources/physics/temperatures
|
|
760
760
|
* @desc Export function to validate if a value is a temperature
|
|
761
761
|
* @example
|
|
762
762
|
*
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "itee-validators",
|
|
3
|
-
"version": "5.3.
|
|
3
|
+
"version": "5.3.7",
|
|
4
4
|
"description": "A library of validation functions use in various Itee projects",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"itee",
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"url": "https://github.com/Itee/itee-validators/issues"
|
|
29
29
|
},
|
|
30
30
|
"engines": {
|
|
31
|
-
"node": ">=
|
|
31
|
+
"node": ">=18"
|
|
32
32
|
},
|
|
33
33
|
"os": [
|
|
34
34
|
"win32",
|
|
@@ -45,56 +45,59 @@
|
|
|
45
45
|
"clean": "gulp clean",
|
|
46
46
|
"lint": "gulp lint",
|
|
47
47
|
"doc": "gulp doc",
|
|
48
|
-
"build-test": "gulp build-
|
|
49
|
-
"bench": "gulp
|
|
50
|
-
"unit": "gulp unit",
|
|
48
|
+
"build-test": "gulp build-tests",
|
|
49
|
+
"bench": "gulp run-benchmarks",
|
|
50
|
+
"unit": "gulp run-unit-tests",
|
|
51
51
|
"test": "gulp test",
|
|
52
52
|
"build": "gulp build",
|
|
53
53
|
"release": "gulp release",
|
|
54
54
|
"semantic-release": "semantic-release --dry-run --no-ci",
|
|
55
55
|
"postversion": "gulp build"
|
|
56
56
|
},
|
|
57
|
-
"dependencies": {},
|
|
58
57
|
"devDependencies": {
|
|
59
|
-
"@rollup/plugin-commonjs": "^
|
|
60
|
-
"@rollup/plugin-node-resolve": "^
|
|
61
|
-
"@semantic-release/changelog": "^6.0.
|
|
58
|
+
"@rollup/plugin-commonjs": "^23.0.4",
|
|
59
|
+
"@rollup/plugin-node-resolve": "^15.0.1",
|
|
60
|
+
"@semantic-release/changelog": "^6.0.2",
|
|
62
61
|
"@semantic-release/commit-analyzer": "^9.0.2",
|
|
63
62
|
"@semantic-release/git": "^10.0.1",
|
|
64
|
-
"@semantic-release/github": "^8.0.
|
|
65
|
-
"@semantic-release/npm": "^9.0.
|
|
63
|
+
"@semantic-release/github": "^8.0.7",
|
|
64
|
+
"@semantic-release/npm": "^9.0.1",
|
|
66
65
|
"@semantic-release/release-notes-generator": "^10.0.3",
|
|
67
|
-
"ansi-colors": "^4.1.
|
|
66
|
+
"ansi-colors": "^4.1.3",
|
|
68
67
|
"benchmark": "^2.1.4",
|
|
69
|
-
"chai": "^4.3.
|
|
68
|
+
"chai": "^4.3.7",
|
|
70
69
|
"cz-conventional-changelog": "^3.3.0",
|
|
71
|
-
"del": "^
|
|
72
|
-
"eslint-plugin-mocha": "^10.0
|
|
70
|
+
"del": "^7.0.0",
|
|
71
|
+
"eslint-plugin-mocha": "^10.1.0",
|
|
73
72
|
"fancy-log": "^2.0.0",
|
|
73
|
+
"glob": "^8.0.3",
|
|
74
74
|
"gulp": "^4.0.2",
|
|
75
75
|
"gulp-eslint": "^6.0.0",
|
|
76
76
|
"gulp-jsdoc3": "^3.0.0",
|
|
77
77
|
"gulp-replace": "^1.1.3",
|
|
78
|
-
"
|
|
78
|
+
"itee-utils": "^5.4.2",
|
|
79
|
+
"karma": "^4.4.1",
|
|
79
80
|
"karma-benchmark": "^1.0.4",
|
|
80
81
|
"karma-benchmarkjs-reporter": "^1.0.0",
|
|
81
82
|
"karma-chai": "^0.1.0",
|
|
82
|
-
"karma-chrome-launcher": "^3.1.
|
|
83
|
+
"karma-chrome-launcher": "^3.1.1",
|
|
83
84
|
"karma-edge-launcher": "^0.4.2",
|
|
84
85
|
"karma-firefox-launcher": "^2.1.2",
|
|
85
86
|
"karma-htmlfile-reporter": "^0.3.8",
|
|
86
87
|
"karma-mocha": "^2.0.1",
|
|
87
88
|
"karma-mocha-reporter": "^2.2.5",
|
|
88
|
-
"leveldown": "^6.1.
|
|
89
|
-
"minimist": "^1.2.
|
|
90
|
-
"mocha": "^
|
|
91
|
-
"mochawesome": "^7.
|
|
89
|
+
"leveldown": "^6.1.1",
|
|
90
|
+
"minimist": "^1.2.7",
|
|
91
|
+
"mocha": "^10.1.0",
|
|
92
|
+
"mochawesome": "^7.1.3",
|
|
93
|
+
"prettier": "^2.8.1",
|
|
92
94
|
"rollup": "^2.67.2",
|
|
95
|
+
"rollup-plugin-cleanup": "^3.2.1",
|
|
96
|
+
"rollup-plugin-prettier": "^3.0.0",
|
|
93
97
|
"rollup-plugin-re": "^1.0.7",
|
|
94
98
|
"rollup-plugin-terser": "^7.0.2",
|
|
95
|
-
"semantic-release": "^19.0.
|
|
99
|
+
"semantic-release": "^19.0.5"
|
|
96
100
|
},
|
|
97
|
-
"optionalDependencies": {},
|
|
98
101
|
"config": {
|
|
99
102
|
"commitizen": {
|
|
100
103
|
"path": "./node_modules/cz-conventional-changelog"
|
package/sources/cores/_cores.js
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
*
|
|
5
5
|
* @module sources/cores
|
|
6
6
|
* @description This is the cores main export entry point.
|
|
7
|
-
* It
|
|
7
|
+
* It exposes all exports of the voids, booleans, numbers, symbols, strings, arrays, typed arrays, objects and functions validators.
|
|
8
8
|
*
|
|
9
9
|
*/
|
|
10
10
|
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @author [Tristan Valcke]{@link https://github.com/Itee}
|
|
3
|
+
* @license [BSD-3-Clause]{@link https://opensource.org/licenses/BSD-3-Clause}
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* This is noParamNoReturn
|
|
8
|
+
*/
|
|
9
|
+
function noParamNoReturn () {
|
|
10
|
+
// eslint-disable-next-line no-console
|
|
11
|
+
console.log( 'Hello' )
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
/**
|
|
15
|
+
*
|
|
16
|
+
* @returns {number} The response to life
|
|
17
|
+
*/
|
|
18
|
+
function noParamOneReturn () {
|
|
19
|
+
return 42
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
*
|
|
24
|
+
* @returns {string|number}
|
|
25
|
+
*/
|
|
26
|
+
function noParamTwoReturn () {
|
|
27
|
+
return ( Math.random() >= 0.5 ) ? 'The response to life is' : 42
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/**
|
|
31
|
+
*
|
|
32
|
+
* @param {string} paramA
|
|
33
|
+
*/
|
|
34
|
+
function oneParamNoReturn ( paramA = '' ) {
|
|
35
|
+
// eslint-disable-next-line no-console
|
|
36
|
+
console.log( paramA )
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
*
|
|
41
|
+
* @param {number} theParam What add to the response of life
|
|
42
|
+
* @returns {boolean} Your response to life is correct
|
|
43
|
+
*/
|
|
44
|
+
function oneParamOneReturn ( theParam = 0 ) {
|
|
45
|
+
return ( 42 === theParam )
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/**
|
|
49
|
+
*
|
|
50
|
+
* @param {number} paramA
|
|
51
|
+
* @returns {null|number}
|
|
52
|
+
*/
|
|
53
|
+
function oneParamTwoReturn ( paramA = 0 ) {
|
|
54
|
+
if ( paramA === 0 ) {
|
|
55
|
+
return null
|
|
56
|
+
} else {
|
|
57
|
+
return ( 42 + paramA )
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
/**
|
|
62
|
+
*
|
|
63
|
+
* @param {string} paramA
|
|
64
|
+
* @param {number} paramB
|
|
65
|
+
*/
|
|
66
|
+
function twoParamNoReturn ( paramA = '', paramB = 123 ) {
|
|
67
|
+
// eslint-disable-next-line no-console
|
|
68
|
+
console.log( `${ paramA }:${ paramB }` )
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
*
|
|
73
|
+
* @param {string} paramA
|
|
74
|
+
* @param {number} paramB
|
|
75
|
+
* @returns {string}
|
|
76
|
+
*/
|
|
77
|
+
function twoParamOneReturn ( paramA = '', paramB = 123 ) {
|
|
78
|
+
return `${ paramA }:${ paramB }`
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
/**
|
|
82
|
+
*
|
|
83
|
+
* @param {number} paramA
|
|
84
|
+
* @param {string} paramB
|
|
85
|
+
* @returns {string|number}
|
|
86
|
+
*/
|
|
87
|
+
function twoParamTwoReturn ( paramA = 0, paramB = '' ) {
|
|
88
|
+
if ( paramA === 0 ) {
|
|
89
|
+
return paramB
|
|
90
|
+
} else {
|
|
91
|
+
return ( 42 + paramA )
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
*
|
|
97
|
+
* @param {*} any
|
|
98
|
+
* @returns {boolean}
|
|
99
|
+
*/
|
|
100
|
+
function anyParamOneReturn ( any ) {
|
|
101
|
+
return any != null
|
|
102
|
+
}
|
|
103
|
+
|
|
104
|
+
export {
|
|
105
|
+
noParamNoReturn,
|
|
106
|
+
noParamOneReturn,
|
|
107
|
+
noParamTwoReturn,
|
|
108
|
+
|
|
109
|
+
oneParamNoReturn,
|
|
110
|
+
oneParamOneReturn,
|
|
111
|
+
oneParamTwoReturn,
|
|
112
|
+
|
|
113
|
+
twoParamNoReturn,
|
|
114
|
+
twoParamOneReturn,
|
|
115
|
+
twoParamTwoReturn,
|
|
116
|
+
|
|
117
|
+
anyParamOneReturn
|
|
118
|
+
}
|
|
@@ -4,10 +4,20 @@
|
|
|
4
4
|
*
|
|
5
5
|
*/
|
|
6
6
|
|
|
7
|
+
/**
|
|
8
|
+
*
|
|
9
|
+
* @param data {*}
|
|
10
|
+
* @returns {boolean}
|
|
11
|
+
*/
|
|
7
12
|
export function isEventTarget ( data ) {
|
|
8
13
|
return ( data instanceof EventTarget )
|
|
9
14
|
}
|
|
10
15
|
|
|
16
|
+
/**
|
|
17
|
+
*
|
|
18
|
+
* @param data {*}
|
|
19
|
+
* @returns {boolean}
|
|
20
|
+
*/
|
|
11
21
|
export function isNotEventTarget ( data ) {
|
|
12
22
|
return !isEventTarget( data )
|
|
13
23
|
}
|
|
@@ -19,7 +19,9 @@
|
|
|
19
19
|
*
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
|
-
import fs
|
|
22
|
+
import fs from 'fs'
|
|
23
|
+
import { isDefined } from '../../cores/voids/isDefined'
|
|
24
|
+
import {isNotString} from '../../cores/strings/isString';
|
|
23
25
|
|
|
24
26
|
/**
|
|
25
27
|
* Check if given path is a block device path
|
|
@@ -28,7 +30,12 @@ import fs from 'fs'
|
|
|
28
30
|
* @returns {boolean} true if path is a block device path, false otherwise
|
|
29
31
|
*/
|
|
30
32
|
export function isBlockDevicePath ( path ) {
|
|
31
|
-
|
|
33
|
+
if( isNotString(path) && !(path instanceof Buffer) && !(path instanceof URL) ) {
|
|
34
|
+
throw new TypeError('Invalid path type! Expect string, buffer or url.')
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const stat = fs.statSync( path, { throwIfNoEntry: false } )
|
|
38
|
+
return isDefined(stat) && stat.isBlockDevice()
|
|
32
39
|
}
|
|
33
40
|
|
|
34
41
|
/**
|
|
@@ -20,6 +20,8 @@
|
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
22
|
import fs from 'fs'
|
|
23
|
+
import { isDefined } from '../../cores/voids/isDefined'
|
|
24
|
+
import {isNotString} from '../../cores/strings/isString';
|
|
23
25
|
|
|
24
26
|
/**
|
|
25
27
|
* Check if given path is a character device path
|
|
@@ -28,7 +30,12 @@ import fs from 'fs'
|
|
|
28
30
|
* @returns {boolean} true if path is a character device path, false otherwise
|
|
29
31
|
*/
|
|
30
32
|
export function isCharacterDevicePath ( path ) {
|
|
31
|
-
|
|
33
|
+
if( isNotString(path) && !(path instanceof Buffer) && !(path instanceof URL) ) {
|
|
34
|
+
throw new TypeError('Invalid path type! Expect string, buffer or url.')
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const stat = fs.statSync( path, { throwIfNoEntry: false } )
|
|
38
|
+
return isDefined(stat) && stat.isCharacterDevice()
|
|
32
39
|
}
|
|
33
40
|
|
|
34
41
|
/**
|
|
@@ -20,6 +20,8 @@
|
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
22
|
import fs from 'fs'
|
|
23
|
+
import { isDefined } from '../../cores/voids/isDefined'
|
|
24
|
+
import {isNotString} from '../../cores/strings/isString';
|
|
23
25
|
|
|
24
26
|
/**
|
|
25
27
|
* Check if given path is a directory path
|
|
@@ -28,7 +30,12 @@ import fs from 'fs'
|
|
|
28
30
|
* @returns {boolean} true if path is a directory path, false otherwise
|
|
29
31
|
*/
|
|
30
32
|
export function isDirectoryPath ( path ) {
|
|
31
|
-
|
|
33
|
+
if( isNotString(path) && !(path instanceof Buffer) && !(path instanceof URL) ) {
|
|
34
|
+
throw new TypeError('Invalid path type! Expect string, buffer or url.')
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const stat = fs.statSync( path, { throwIfNoEntry: false } )
|
|
38
|
+
return isDefined(stat) && stat.isDirectory()
|
|
32
39
|
}
|
|
33
40
|
|
|
34
41
|
/**
|
|
@@ -20,6 +20,7 @@
|
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
22
|
import fs from 'fs'
|
|
23
|
+
import { isDirectoryPath } from './isDirectoryPath'
|
|
23
24
|
|
|
24
25
|
/**
|
|
25
26
|
* Check if given directory path is an empty directory
|
|
@@ -28,7 +29,7 @@ import fs from 'fs'
|
|
|
28
29
|
* @returns {boolean} true if directory is empty, false otherwise
|
|
29
30
|
*/
|
|
30
31
|
export function isEmptyDirectory ( directoryPath ) {
|
|
31
|
-
return ( fs.readdirSync( directoryPath ).length === 0 )
|
|
32
|
+
return isDirectoryPath(directoryPath) && ( fs.readdirSync( directoryPath ).length === 0 )
|
|
32
33
|
}
|
|
33
34
|
|
|
34
35
|
/**
|
|
@@ -20,6 +20,8 @@
|
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
22
|
import fs from 'fs'
|
|
23
|
+
import { isDefined } from '../../cores/voids/isDefined'
|
|
24
|
+
import {isNotString} from '../../cores/strings/isString';
|
|
23
25
|
|
|
24
26
|
/**
|
|
25
27
|
* Check if given path is a fifo path
|
|
@@ -28,7 +30,12 @@ import fs from 'fs'
|
|
|
28
30
|
* @returns {boolean} true if path is a fifo path, false otherwise
|
|
29
31
|
*/
|
|
30
32
|
export function isFIFOPath ( path ) {
|
|
31
|
-
|
|
33
|
+
if( isNotString(path) && !(path instanceof Buffer) && !(path instanceof URL) ) {
|
|
34
|
+
throw new TypeError('Invalid path type! Expect string, buffer or url.')
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const stat = fs.statSync( path, { throwIfNoEntry: false } )
|
|
38
|
+
return isDefined(stat) && stat.isFIFO()
|
|
32
39
|
}
|
|
33
40
|
|
|
34
41
|
/**
|
|
@@ -19,7 +19,9 @@
|
|
|
19
19
|
*
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
|
-
import fs
|
|
22
|
+
import fs from 'fs'
|
|
23
|
+
import { isFilePath } from './isFilePath'
|
|
24
|
+
import {isNotString} from '../../cores/strings/isString';
|
|
23
25
|
|
|
24
26
|
/**
|
|
25
27
|
* Check if given file path is an empty file more or less a threshold in bytes.
|
|
@@ -29,7 +31,11 @@ import fs from 'fs'
|
|
|
29
31
|
* @returns {boolean} true if file is empty, false otherwise
|
|
30
32
|
*/
|
|
31
33
|
export function isEmptyFile ( filePath, threshold = 0 ) {
|
|
32
|
-
|
|
34
|
+
if( isNotString(filePath) && !(filePath instanceof Buffer) && !(filePath instanceof URL) ) {
|
|
35
|
+
throw new TypeError('Invalid path type! Expect string, buffer or url.')
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
return isFilePath(filePath) && ( fs.statSync( filePath ).size <= threshold )
|
|
33
39
|
}
|
|
34
40
|
|
|
35
41
|
/**
|
|
@@ -40,5 +46,5 @@ export function isEmptyFile ( filePath, threshold = 0 ) {
|
|
|
40
46
|
* @returns {boolean} true if file is not empty, false otherwise
|
|
41
47
|
*/
|
|
42
48
|
export function isNotEmptyFile ( filePath, threshold = 0 ) {
|
|
43
|
-
return (
|
|
49
|
+
return !isEmptyFile(filePath, threshold)
|
|
44
50
|
}
|
|
@@ -20,6 +20,8 @@
|
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
22
|
import fs from 'fs'
|
|
23
|
+
import { isDefined } from '../../cores/voids/isDefined'
|
|
24
|
+
import {isNotString} from '../../cores/strings/isString';
|
|
23
25
|
|
|
24
26
|
/**
|
|
25
27
|
* Check if given path is a file path
|
|
@@ -28,7 +30,12 @@ import fs from 'fs'
|
|
|
28
30
|
* @returns {boolean} true if path is a file path, false otherwise
|
|
29
31
|
*/
|
|
30
32
|
export function isFilePath ( path ) {
|
|
31
|
-
|
|
33
|
+
if( isNotString(path) && !(path instanceof Buffer) && !(path instanceof URL) ) {
|
|
34
|
+
throw new TypeError('Invalid path type! Expect string, buffer or url.')
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const stat = fs.statSync( path, { throwIfNoEntry: false } )
|
|
38
|
+
return isDefined(stat) && stat.isFile()
|
|
32
39
|
}
|
|
33
40
|
|
|
34
41
|
/**
|
|
@@ -20,6 +20,8 @@
|
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
22
|
import fs from 'fs'
|
|
23
|
+
import { isDefined } from '../../cores/voids/isDefined'
|
|
24
|
+
import {isNotString} from '../../cores/strings/isString';
|
|
23
25
|
|
|
24
26
|
/**
|
|
25
27
|
* Check if given path is a socket path
|
|
@@ -28,7 +30,12 @@ import fs from 'fs'
|
|
|
28
30
|
* @returns {boolean} true if path is a socket path, false otherwise
|
|
29
31
|
*/
|
|
30
32
|
export function isSocketPath ( path ) {
|
|
31
|
-
|
|
33
|
+
if( isNotString(path) && !(path instanceof Buffer) && !(path instanceof URL) ) {
|
|
34
|
+
throw new TypeError('Invalid path type! Expect string, buffer or url.')
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const stat = fs.statSync( path, { throwIfNoEntry: false } )
|
|
38
|
+
return isDefined(stat) && stat.isSocket()
|
|
32
39
|
}
|
|
33
40
|
|
|
34
41
|
/**
|
|
@@ -20,6 +20,8 @@
|
|
|
20
20
|
*/
|
|
21
21
|
|
|
22
22
|
import fs from 'fs'
|
|
23
|
+
import { isDefined } from '../../cores/voids/isDefined'
|
|
24
|
+
import {isNotString} from '../../cores/strings/isString';
|
|
23
25
|
|
|
24
26
|
/**
|
|
25
27
|
* Check if given path is a symbolic link path
|
|
@@ -28,7 +30,12 @@ import fs from 'fs'
|
|
|
28
30
|
* @returns {boolean} true if path is a symbolic link path, false otherwise
|
|
29
31
|
*/
|
|
30
32
|
export function isSymbolicLinkPath ( path ) {
|
|
31
|
-
|
|
33
|
+
if( isNotString(path) && !(path instanceof Buffer) && !(path instanceof URL) ) {
|
|
34
|
+
throw new TypeError('Invalid path type! Expect string, buffer or url.')
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
const stat = fs.statSync( path, { throwIfNoEntry: false } )
|
|
38
|
+
return isDefined(stat) && stat.isSymbolicLink()
|
|
32
39
|
}
|
|
33
40
|
|
|
34
41
|
/**
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @author [Tristan Valcke]{@link https://github.com/Itee}
|
|
3
3
|
* @license [BSD-3-Clause]{@link https://opensource.org/licenses/BSD-3-Clause}
|
|
4
4
|
*
|
|
5
|
-
* @module sources/physics/
|
|
5
|
+
* @module sources/physics/temperatures
|
|
6
6
|
* @desc Export function to validate if a value is a Celsius temperature
|
|
7
7
|
* @example
|
|
8
8
|
*
|
|
@@ -21,7 +21,7 @@ import { ABSOLUTE_ZERO_CELSIUS } from './constants'
|
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
*
|
|
24
|
-
* @param data
|
|
24
|
+
* @param data {*}
|
|
25
25
|
* @return {boolean}
|
|
26
26
|
*/
|
|
27
27
|
export function isCelsius ( data ) {
|
|
@@ -30,7 +30,7 @@ export function isCelsius ( data ) {
|
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
32
|
*
|
|
33
|
-
* @param data
|
|
33
|
+
* @param data {*}
|
|
34
34
|
* @return {boolean}
|
|
35
35
|
*/
|
|
36
36
|
export function isNotCelsius ( data ) {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @author [Tristan Valcke]{@link https://github.com/Itee}
|
|
3
3
|
* @license [BSD-3-Clause]{@link https://opensource.org/licenses/BSD-3-Clause}
|
|
4
4
|
*
|
|
5
|
-
* @module sources/physics/
|
|
5
|
+
* @module sources/physics/temperatures
|
|
6
6
|
* @desc Export function to validate if a value is a Fahrenheit temperature
|
|
7
7
|
* @example
|
|
8
8
|
*
|
|
@@ -21,7 +21,7 @@ import { ABSOLUTE_ZERO_FAHRENHEIT } from './constants'
|
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
*
|
|
24
|
-
* @param data
|
|
24
|
+
* @param data {*}
|
|
25
25
|
* @return {boolean}
|
|
26
26
|
*/
|
|
27
27
|
export function isFahrenheit ( data ) {
|
|
@@ -30,7 +30,7 @@ export function isFahrenheit ( data ) {
|
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
32
|
*
|
|
33
|
-
* @param data
|
|
33
|
+
* @param data {*}
|
|
34
34
|
* @return {boolean}
|
|
35
35
|
*/
|
|
36
36
|
export function isNotFahrenheit ( data ) {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @author [Tristan Valcke]{@link https://github.com/Itee}
|
|
3
3
|
* @license [BSD-3-Clause]{@link https://opensource.org/licenses/BSD-3-Clause}
|
|
4
4
|
*
|
|
5
|
-
* @module sources/physics/
|
|
5
|
+
* @module sources/physics/temperatures
|
|
6
6
|
* @desc Export function to validate if a value is a kelvin temperature
|
|
7
7
|
* @example
|
|
8
8
|
*
|
|
@@ -21,7 +21,7 @@ import { ABSOLUTE_ZERO_KELVIN } from './constants'
|
|
|
21
21
|
|
|
22
22
|
/**
|
|
23
23
|
*
|
|
24
|
-
* @param data
|
|
24
|
+
* @param data {*}
|
|
25
25
|
* @return {boolean}
|
|
26
26
|
*/
|
|
27
27
|
export function isKelvin ( data ) {
|
|
@@ -30,7 +30,7 @@ export function isKelvin ( data ) {
|
|
|
30
30
|
|
|
31
31
|
/**
|
|
32
32
|
*
|
|
33
|
-
* @param data
|
|
33
|
+
* @param data {*}
|
|
34
34
|
* @return {boolean}
|
|
35
35
|
*/
|
|
36
36
|
export function isNotKelvin ( data ) {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
* @author [Tristan Valcke]{@link https://github.com/Itee}
|
|
3
3
|
* @license [BSD-3-Clause]{@link https://opensource.org/licenses/BSD-3-Clause}
|
|
4
4
|
*
|
|
5
|
-
* @module sources/physics/
|
|
5
|
+
* @module sources/physics/temperatures
|
|
6
6
|
* @desc Export function to validate if a value is a temperature
|
|
7
7
|
* @example
|
|
8
8
|
*
|