1 | # path-is-absolute [![Build Status](https://travis-ci.org/sindresorhus/path-is-absolute.svg?branch=master)](https://travis-ci.org/sindresorhus/path-is-absolute)
|
2 |
|
3 | > Node.js 0.12 [`path.isAbsolute()`](http://nodejs.org/api/path.html#path_path_isabsolute_path) [ponyfill](https://ponyfill.com)
|
4 |
|
5 |
|
6 | ## Install
|
7 |
|
8 | ```
|
9 | $ npm install --save path-is-absolute
|
10 | ```
|
11 |
|
12 |
|
13 | ## Usage
|
14 |
|
15 | ```js
|
16 | const pathIsAbsolute = require('path-is-absolute');
|
17 |
|
18 | // Running on Linux
|
19 | pathIsAbsolute('/home/foo');
|
20 | //=> true
|
21 | pathIsAbsolute('C:/Users/foo');
|
22 | //=> false
|
23 |
|
24 | // Running on Windows
|
25 | pathIsAbsolute('C:/Users/foo');
|
26 | //=> true
|
27 | pathIsAbsolute('/home/foo');
|
28 | //=> false
|
29 |
|
30 | // Running on any OS
|
31 | pathIsAbsolute.posix('/home/foo');
|
32 | //=> true
|
33 | pathIsAbsolute.posix('C:/Users/foo');
|
34 | //=> false
|
35 | pathIsAbsolute.win32('C:/Users/foo');
|
36 | //=> true
|
37 | pathIsAbsolute.win32('/home/foo');
|
38 | //=> false
|
39 | ```
|
40 |
|
41 |
|
42 | ## API
|
43 |
|
44 | See the [`path.isAbsolute()` docs](http://nodejs.org/api/path.html#path_path_isabsolute_path).
|
45 |
|
46 | ### pathIsAbsolute(path)
|
47 |
|
48 | ### pathIsAbsolute.posix(path)
|
49 |
|
50 | POSIX specific version.
|
51 |
|
52 | ### pathIsAbsolute.win32(path)
|
53 |
|
54 | Windows specific version.
|
55 |
|
56 |
|
57 | ## License
|
58 |
|
59 | MIT © [Sindre Sorhus](https://sindresorhus.com)
|