-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathis-device-root.mts
More file actions
34 lines (31 loc) · 726 Bytes
/
is-device-root.mts
File metadata and controls
34 lines (31 loc) · 726 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
/**
* @file isDeviceRoot
* @module pathe/lib/isDeviceRoot
*/
import { DRIVE_PATH_REGEX } from '#internal/constants'
import isSep from '#lib/is-sep'
import type { DeviceRoot } from '@flex-development/pathe'
/**
* Check if `value` is a device root.
*
* @see {@linkcode DeviceRoot}
*
* @category
* utils
*
* @this {void}
*
* @param {unknown} value
* The value to check
* @return {value is DeviceRoot}
* `true` if `value` is device root, `false` otherwise
*/
function isDeviceRoot(this: void, value: unknown): value is DeviceRoot {
return (
typeof value === 'string' &&
value.length === 3 &&
DRIVE_PATH_REGEX.test(value) &&
isSep(value[value.length - 1])
)
}
export default isDeviceRoot