-
-
Notifications
You must be signed in to change notification settings - Fork 813
/
Copy pathindex.js
44 lines (35 loc) · 1006 Bytes
/
index.js
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
35
36
37
38
39
40
41
42
43
44
'use strict';
/**
* Test if a value is an absolute path.
*
* @module @stdlib/utils/is-absolute-path
*
* @example
* var isWindows = require( '@stdlib/utils/is-windows' );
* var isAbsolutePath = require( '@stdlib/utils/is-absolute-path' );
*
* var bool;
* if ( isWindows ) {
* bool = isAbsolutePath( 'C:\\foo\\bar\\baz' );
* // returns true
* } else {
* bool = isAbsolutePath( '/foo/bar/baz' );
* // returns true
* }
*/
// MODULES //
var setReadOnly = require( '@stdlib/utils/define-read-only-property' );
var isWindows = require( '@stdlib/utils/is-windows' );
var isAbsolutePathPosix = require( './posix.js' );
var isAbsolutePathWin32 = require( './win32.js' );
// IS ABSOLUTE PATH //
var isAbsolutePath;
if ( isWindows ) {
isAbsolutePath = isAbsolutePathWin32;
} else {
isAbsolutePath = isAbsolutePathPosix;
}
setReadOnly( isAbsolutePath, 'posix', isAbsolutePathPosix );
setReadOnly( isAbsolutePath, 'win32', isAbsolutePathWin32 );
// EXPORTS //
module.exports = isAbsolutePath;